// Path: mapsforge-map-android/src/main/java/org/mapsforge/map/android/rendertheme/AssetsRenderTheme.java
// public class AssetsRenderTheme implements XmlRenderTheme {
// 
//     private final AssetManager assetManager;
//     private final String fileName;
//     private XmlRenderThemeMenuCallback menuCallback;
//     private final String relativePathPrefix;
//     private XmlThemeResourceProvider resourceProvider;
// 
//     /**
//      * @param assetManager       the Android asset manager.
//      * @param relativePathPrefix the prefix for all relative resource paths.
//      * @param fileName           the path to the XML render theme file.
//      */
//     public AssetsRenderTheme(AssetManager assetManager, String relativePathPrefix, String fileName) {
//         this(assetManager, relativePathPrefix, fileName, null);
//     }
// 
//     /**
//      * @param assetManager       the Android asset manager.
//      * @param relativePathPrefix the prefix for all relative resource paths.
//      * @param fileName           the path to the XML render theme file.
//      * @param menuCallback       the interface callback to create a settings menu on the fly.
//      */
//     public AssetsRenderTheme(AssetManager assetManager, String relativePathPrefix, String fileName, XmlRenderThemeMenuCallback menuCallback) {
//         this.assetManager = assetManager;
//         this.relativePathPrefix = relativePathPrefix;
//         this.fileName = fileName;
//         this.menuCallback = menuCallback;
//     }
// 
//     @Override
//     public boolean equals(Object obj) {
//         if (this == obj) {
//             return true;
//         } else if (!(obj instanceof AssetsRenderTheme)) {
//             return false;
//         }
//         AssetsRenderTheme other = (AssetsRenderTheme) obj;
//         try {
//             if (getRenderThemeAsStream() != other.getRenderThemeAsStream()) {
//                 return false;
//             }
//         } catch (IOException e) {
//             e.printStackTrace();
//             return false;
//         }
//         if (!Utils.equals(this.relativePathPrefix, other.relativePathPrefix)) {
//             return false;
//         }
//         return true;
//     }
// 
//     @Override
//     public XmlRenderThemeMenuCallback getMenuCallback() {
//         return this.menuCallback;
//     }
// 
//     @Override
//     public String getRelativePathPrefix() {
//         return this.relativePathPrefix;
//     }
// 
//     @Override
//     public InputStream getRenderThemeAsStream() throws IOException {
//         return this.assetManager.open((TextUtils.isEmpty(this.relativePathPrefix) ? "" : this.relativePathPrefix) + this.fileName);
//     }
// 
//     @Override
//     public XmlThemeResourceProvider getResourceProvider() {
//         return this.resourceProvider;
//     }
// 
//     @Override
//     public int hashCode() {
//         final int prime = 31;
//         int result = 1;
//         InputStream inputStream = null;
//         try {
//             inputStream = getRenderThemeAsStream();
//         } catch (IOException e) {
//             e.printStackTrace();
//         }
//         result = prime * result + ((inputStream == null) ? 0 : inputStream.hashCode());
//         result = prime * result + ((this.relativePathPrefix == null) ? 0 : this.relativePathPrefix.hashCode());
//         return result;
//     }
// 
//     @Override
//     public void setMenuCallback(XmlRenderThemeMenuCallback menuCallback) {
//         this.menuCallback = menuCallback;
//     }
// 
//     @Override
//     public void setResourceProvider(XmlThemeResourceProvider resourceProvider) {
//         this.resourceProvider = resourceProvider;
//     }
// }
// 
// Path: mapsforge-map/src/main/java/org/mapsforge/map/rendertheme/XmlRenderTheme.java
// public interface XmlRenderTheme {
//     /**
//      * @return the interface callback to create a settings menu on the fly.
//      */
//     XmlRenderThemeMenuCallback getMenuCallback();
// 
//     /**
//      * @return the prefix for all relative resource paths.
//      */
//     String getRelativePathPrefix();
// 
//     /**
//      * @return an InputStream to read the render theme data from.
//      * @throws IOException if the render theme file cannot be found.
//      */
//     InputStream getRenderThemeAsStream() throws IOException;
// 
//     /**
//      * @return a custom provider to retrieve resources internally referenced by "src" attribute (e.g. images, icons).
//      */
//     XmlThemeResourceProvider getResourceProvider();
// 
//     /**
//      * @param menuCallback the interface callback to create a settings menu on the fly.
//      */
//     void setMenuCallback(XmlRenderThemeMenuCallback menuCallback);
// 
//     /**
//      * @param resourceProvider a custom provider to retrieve resources internally referenced by "src" attribute (e.g. images, icons).
//      */
//     void setResourceProvider(XmlThemeResourceProvider resourceProvider);
// }


import android.content.SharedPreferences;
import android.util.Log;
import org.mapsforge.map.android.rendertheme.AssetsRenderTheme;
import org.mapsforge.map.android.util.AndroidUtil;
import org.mapsforge.map.layer.cache.TileCache;
import org.mapsforge.map.rendertheme.XmlRenderTheme;
import org.mapsforge.map.rendertheme.XmlRenderThemeMenuCallback;
import org.mapsforge.map.rendertheme.XmlRenderThemeStyleLayer;
import org.mapsforge.map.rendertheme.XmlRenderThemeStyleMenu;
import java.util.Set;
/*
 * Copyright 2013-2014 Ludwig M Brinckmann
 * Copyright 2016-2020 devemux86
 *
 * This program is free software: you can redistribute it and/or modify it under the
 * terms of the GNU Lesser General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License along with
 * this program. If not, see <http://www.gnu.org/licenses/>.
 */
package org.mapsforge.samples.android;



/**
 * Load render theme from Android assets folder and show a configuration menu based on stylemenu.
 */
public class StyleMenuMapViewer extends SamplesBaseActivity implements XmlRenderThemeMenuCallback {

    @Override
// Path: mapsforge-map-android/src/main/java/org/mapsforge/map/android/rendertheme/AssetsRenderTheme.java
// public class AssetsRenderTheme implements XmlRenderTheme {
// 
//     private final AssetManager assetManager;
//     private final String fileName;
//     private XmlRenderThemeMenuCallback menuCallback;
//     private final String relativePathPrefix;
//     private XmlThemeResourceProvider resourceProvider;
// 
//     /**
//      * @param assetManager       the Android asset manager.
//      * @param relativePathPrefix the prefix for all relative resource paths.
//      * @param fileName           the path to the XML render theme file.
//      */
//     public AssetsRenderTheme(AssetManager assetManager, String relativePathPrefix, String fileName) {
//         this(assetManager, relativePathPrefix, fileName, null);
//     }
// 
//     /**
//      * @param assetManager       the Android asset manager.
//      * @param relativePathPrefix the prefix for all relative resource paths.
//      * @param fileName           the path to the XML render theme file.
//      * @param menuCallback       the interface callback to create a settings menu on the fly.
//      */
//     public AssetsRenderTheme(AssetManager assetManager, String relativePathPrefix, String fileName, XmlRenderThemeMenuCallback menuCallback) {
//         this.assetManager = assetManager;
//         this.relativePathPrefix = relativePathPrefix;
//         this.fileName = fileName;
//         this.menuCallback = menuCallback;
//     }
// 
//     @Override
//     public boolean equals(Object obj) {
//         if (this == obj) {
//             return true;
//         } else if (!(obj instanceof AssetsRenderTheme)) {
//             return false;
//         }
//         AssetsRenderTheme other = (AssetsRenderTheme) obj;
//         try {
//             if (getRenderThemeAsStream() != other.getRenderThemeAsStream()) {
//                 return false;
//             }
//         } catch (IOException e) {
//             e.printStackTrace();
//             return false;
//         }
//         if (!Utils.equals(this.relativePathPrefix, other.relativePathPrefix)) {
//             return false;
//         }
//         return true;
//     }
// 
//     @Override
//     public XmlRenderThemeMenuCallback getMenuCallback() {
//         return this.menuCallback;
//     }
// 
//     @Override
//     public String getRelativePathPrefix() {
//         return this.relativePathPrefix;
//     }
// 
//     @Override
//     public InputStream getRenderThemeAsStream() throws IOException {
//         return this.assetManager.open((TextUtils.isEmpty(this.relativePathPrefix) ? "" : this.relativePathPrefix) + this.fileName);
//     }
// 
//     @Override
//     public XmlThemeResourceProvider getResourceProvider() {
//         return this.resourceProvider;
//     }
// 
//     @Override
//     public int hashCode() {
//         final int prime = 31;
//         int result = 1;
//         InputStream inputStream = null;
//         try {
//             inputStream = getRenderThemeAsStream();
//         } catch (IOException e) {
//             e.printStackTrace();
//         }
//         result = prime * result + ((inputStream == null) ? 0 : inputStream.hashCode());
//         result = prime * result + ((this.relativePathPrefix == null) ? 0 : this.relativePathPrefix.hashCode());
//         return result;
//     }
// 
//     @Override
//     public void setMenuCallback(XmlRenderThemeMenuCallback menuCallback) {
//         this.menuCallback = menuCallback;
//     }
// 
//     @Override
//     public void setResourceProvider(XmlThemeResourceProvider resourceProvider) {
//         this.resourceProvider = resourceProvider;
//     }
// }
// 
// Path: mapsforge-map/src/main/java/org/mapsforge/map/rendertheme/XmlRenderTheme.java
// public interface XmlRenderTheme {
//     /**
//      * @return the interface callback to create a settings menu on the fly.
//      */
//     XmlRenderThemeMenuCallback getMenuCallback();
// 
//     /**
//      * @return the prefix for all relative resource paths.
//      */
//     String getRelativePathPrefix();
// 
//     /**
//      * @return an InputStream to read the render theme data from.
//      * @throws IOException if the render theme file cannot be found.
//      */
//     InputStream getRenderThemeAsStream() throws IOException;
// 
//     /**
//      * @return a custom provider to retrieve resources internally referenced by "src" attribute (e.g. images, icons).
//      */
//     XmlThemeResourceProvider getResourceProvider();
// 
//     /**
//      * @param menuCallback the interface callback to create a settings menu on the fly.
//      */
//     void setMenuCallback(XmlRenderThemeMenuCallback menuCallback);
// 
//     /**
//      * @param resourceProvider a custom provider to retrieve resources internally referenced by "src" attribute (e.g. images, icons).
//      */
//     void setResourceProvider(XmlThemeResourceProvider resourceProvider);
// }


// Path: mapsforge-samples-android/src/main/java/org/mapsforge/samples/android/StyleMenuMapViewer.java
import android.content.SharedPreferences;
import android.util.Log;
import org.mapsforge.map.android.rendertheme.AssetsRenderTheme;
import org.mapsforge.map.android.util.AndroidUtil;
import org.mapsforge.map.layer.cache.TileCache;
import org.mapsforge.map.rendertheme.XmlRenderTheme;
import org.mapsforge.map.rendertheme.XmlRenderThemeMenuCallback;
import org.mapsforge.map.rendertheme.XmlRenderThemeStyleLayer;
import org.mapsforge.map.rendertheme.XmlRenderThemeStyleMenu;
import java.util.Set;

/*
 * Copyright 2013-2014 Ludwig M Brinckmann
 * Copyright 2016-2020 devemux86
 *
 * This program is free software: you can redistribute it and/or modify it under the
 * terms of the GNU Lesser General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License along with
 * this program. If not, see <http://www.gnu.org/licenses/>.
 */
package org.mapsforge.samples.android;



/**
 * Load render theme from Android assets folder and show a configuration menu based on stylemenu.
 */
public class StyleMenuMapViewer extends SamplesBaseActivity implements XmlRenderThemeMenuCallback {

    @Override
    protected XmlRenderTheme getRenderTheme() {