diff --git a/OsmAnd/src/net/osmand/access/AccessibilityPlugin.java b/OsmAnd/src/net/osmand/access/AccessibilityPlugin.java index 3336895bad..28fc35cb2f 100644 --- a/OsmAnd/src/net/osmand/access/AccessibilityPlugin.java +++ b/OsmAnd/src/net/osmand/access/AccessibilityPlugin.java @@ -23,12 +23,12 @@ public class AccessibilityPlugin extends OsmandPlugin { public static final int INCLINATION_RIGHT = 3; private static final String ID = "osmand.accessibility"; - private OsmandApplication app; + private SoundPool sounds; private Map soundIcons = new HashMap(); public AccessibilityPlugin(OsmandApplication app) { - this.app = app; + super(app); OsmandSettings settings = app.getSettings(); pluginPreferences.add(settings.ACCESSIBILITY_MODE); pluginPreferences.add(settings.SPEECH_RATE); diff --git a/OsmAnd/src/net/osmand/plus/CustomOsmandPlugin.java b/OsmAnd/src/net/osmand/plus/CustomOsmandPlugin.java new file mode 100644 index 0000000000..e94d6088ec --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/CustomOsmandPlugin.java @@ -0,0 +1,51 @@ +package net.osmand.plus; + +public class CustomOsmandPlugin extends OsmandPlugin { + + private String pluginId; + private String name; + private String description; + + public CustomOsmandPlugin(OsmandApplication app) { + super(app); + } + +// Prepare ".opr" desert-package manually + add all resources inside (extend json to describe package). +// +//Desert package +//1. Add to Plugins list +//1.1 Description / image / icon / name +//1.2 Enable description bottom sheet on Install +//2. Add custom rendering style to list Configure Map +//3. Include Special profile for navigation with selected style +//4. Add custom navigation icon (as example to use another car) +// +//P.S.: Functionality similar to Nautical / Ski Maps plugin, +// so we could remove all code for Nautical / Ski Maps from OsmAnd +// and put to separate "skimaps.opr", "nautical.opr" in future + + @Override + public String getId() { + return pluginId; + } + + @Override + public String getName() { + return name; + } + + @Override + public String getDescription() { + return description; + } + + @Override + public int getAssetResourceName() { + return 0; + } + + @Override + public int getLogoResourceId() { + return R.drawable.ic_action_skiing; + } +} \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/OsmandPlugin.java b/OsmAnd/src/net/osmand/plus/OsmandPlugin.java index f102c63a58..ba373f8303 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandPlugin.java +++ b/OsmAnd/src/net/osmand/plus/OsmandPlugin.java @@ -55,14 +55,21 @@ public abstract class OsmandPlugin { public static final String PLUGIN_ID_KEY = "plugin_id"; - private static List allPlugins = new ArrayList(); private static final Log LOG = PlatformUtil.getLog(OsmandPlugin.class); + private static List allPlugins = new ArrayList(); + + protected OsmandApplication app; + protected List pluginPreferences = new ArrayList<>(); private boolean active; private String installURL = null; + public OsmandPlugin(OsmandApplication app) { + this.app = app; + } + public abstract String getId(); public abstract String getName(); diff --git a/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java b/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java index 26fe6c967b..e0214f802e 100644 --- a/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java +++ b/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java @@ -104,11 +104,12 @@ public class AudioVideoNotesPlugin extends OsmandPlugin { public static final String THREEGP_EXTENSION = "3gp"; public static final String MPEG4_EXTENSION = "mp4"; public static final String IMG_EXTENSION = "jpg"; - private static final Log log = PlatformUtil.getLog(AudioVideoNotesPlugin.class); public static final int CAMERA_FOR_VIDEO_REQUEST_CODE = 101; public static final int CAMERA_FOR_PHOTO_REQUEST_CODE = 102; public static final int AUDIO_REQUEST_CODE = 103; + private static final Log log = PlatformUtil.getLog(AudioVideoNotesPlugin.class); + // Constants for determining the order of items in the additional actions context menu private static final int TAKE_AUDIO_NOTE_ITEM_ORDER = 4100; private static final int TAKE_VIDEO_NOTE_ITEM_ORDER = 4300; @@ -116,7 +117,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin { // private static Method mRegisterMediaButtonEventReceiver; // private static Method mUnregisterMediaButtonEventReceiver; - private OsmandApplication app; + private TextInfoWidget recordControl; public final CommonPreference AV_EXTERNAL_RECORDER; @@ -538,7 +539,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin { } public AudioVideoNotesPlugin(OsmandApplication app) { - this.app = app; + super(app); ApplicationMode.regWidgetVisibility("audionotes", (ApplicationMode[]) null); AV_EXTERNAL_RECORDER = registerBooleanPreference(app, "av_external_recorder", false); AV_EXTERNAL_PHOTO_CAM = registerBooleanPreference(app, "av_external_cam", true); diff --git a/OsmAnd/src/net/osmand/plus/development/OsmandDevelopmentPlugin.java b/OsmAnd/src/net/osmand/plus/development/OsmandDevelopmentPlugin.java index 976e09ecf1..9c8889f067 100644 --- a/OsmAnd/src/net/osmand/plus/development/OsmandDevelopmentPlugin.java +++ b/OsmAnd/src/net/osmand/plus/development/OsmandDevelopmentPlugin.java @@ -22,11 +22,11 @@ import net.osmand.plus.views.mapwidgets.TextInfoWidget; import static net.osmand.aidlapi.OsmAndCustomizationConstants.DRAWER_BUILDS_ID; public class OsmandDevelopmentPlugin extends OsmandPlugin { + private static final String ID = "osmand.development"; - private OsmandApplication app; public OsmandDevelopmentPlugin(OsmandApplication app) { - this.app = app; + super(app); //ApplicationMode.regWidgetVisibility("fps", new ApplicationMode[0]); } diff --git a/OsmAnd/src/net/osmand/plus/mapillary/MapillaryPlugin.java b/OsmAnd/src/net/osmand/plus/mapillary/MapillaryPlugin.java index fc8b7d8a55..22eef6281b 100644 --- a/OsmAnd/src/net/osmand/plus/mapillary/MapillaryPlugin.java +++ b/OsmAnd/src/net/osmand/plus/mapillary/MapillaryPlugin.java @@ -44,10 +44,11 @@ import static android.content.Intent.ACTION_VIEW; import static net.osmand.aidlapi.OsmAndCustomizationConstants.MAPILLARY; public class MapillaryPlugin extends OsmandPlugin { + public static final String ID = "osmand.mapillary"; private static final String MAPILLARY_PACKAGE_ID = "app.mapillary"; + private OsmandSettings settings; - private OsmandApplication app; private MapillaryRasterLayer rasterLayer; private MapillaryVectorLayer vectorLayer; @@ -55,7 +56,7 @@ public class MapillaryPlugin extends OsmandPlugin { private MapWidgetRegInfo mapillaryWidgetRegInfo; public MapillaryPlugin(OsmandApplication app) { - this.app = app; + super(app); settings = app.getSettings(); } diff --git a/OsmAnd/src/net/osmand/plus/monitoring/OsmandMonitoringPlugin.java b/OsmAnd/src/net/osmand/plus/monitoring/OsmandMonitoringPlugin.java index 42870b6896..ff42b4a653 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/OsmandMonitoringPlugin.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/OsmandMonitoringPlugin.java @@ -50,16 +50,17 @@ import gnu.trove.list.array.TIntArrayList; import static net.osmand.plus.UiUtilities.CompoundButtonType.PROFILE_DEPENDENT; public class OsmandMonitoringPlugin extends OsmandPlugin { + public static final String ID = "osmand.monitoring"; public final static String OSMAND_SAVE_SERVICE_ACTION = "OSMAND_SAVE_SERVICE_ACTION"; + private OsmandSettings settings; - private OsmandApplication app; private TextInfoWidget monitoringControl; private LiveMonitoringHelper liveMonitoringHelper; private boolean isSaving; public OsmandMonitoringPlugin(OsmandApplication app) { - this.app = app; + super(app); liveMonitoringHelper = new LiveMonitoringHelper(app); final List am = ApplicationMode.allPossibleValues(); ApplicationMode.regWidgetVisibility("monitoring", am.toArray(new ApplicationMode[am.size()])); diff --git a/OsmAnd/src/net/osmand/plus/openseamapsplugin/NauticalMapsPlugin.java b/OsmAnd/src/net/osmand/plus/openseamapsplugin/NauticalMapsPlugin.java index 5e9a72b9fd..86f425cccd 100644 --- a/OsmAnd/src/net/osmand/plus/openseamapsplugin/NauticalMapsPlugin.java +++ b/OsmAnd/src/net/osmand/plus/openseamapsplugin/NauticalMapsPlugin.java @@ -19,10 +19,8 @@ public class NauticalMapsPlugin extends OsmandPlugin { public static final String ID = "nauticalPlugin.plugin"; public static final String COMPONENT = "net.osmand.nauticalPlugin"; - private OsmandApplication app; - public NauticalMapsPlugin(OsmandApplication app) { - this.app = app; + super(app); } @Override diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java index 0624e088b6..8f99bf1dfd 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java @@ -71,7 +71,6 @@ public class OsmEditingPlugin extends OsmandPlugin { private static final int MODIFY_OSM_NOTE_ITEM_ORDER = 7600; private OsmandSettings settings; - private OsmandApplication app; private OpenstreetmapsDbHelper dbpoi; private OsmBugsDbHelper dbbug; private OpenstreetmapLocalUtil localUtil; @@ -80,7 +79,7 @@ public class OsmEditingPlugin extends OsmandPlugin { private OsmBugsLocalUtil localNotesUtil; public OsmEditingPlugin(OsmandApplication app) { - this.app = app; + super(app); settings = app.getSettings(); } diff --git a/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java b/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java index b13a2193a4..64061c3a7e 100644 --- a/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java +++ b/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java @@ -53,29 +53,28 @@ public class ParkingPositionPlugin extends OsmandPlugin { public static final String ID = "osmand.parking.position"; public static final String PARKING_PLUGIN_COMPONENT = "net.osmand.parkingPlugin"; //$NON-NLS-1$ - public final static String PARKING_POINT_LAT = "parking_point_lat"; //$NON-NLS-1$ - public final static String PARKING_POINT_LON = "parking_point_lon"; //$NON-NLS-1$ - public final static String PARKING_TYPE = "parking_type"; //$NON-NLS-1$ - public final static String PARKING_TIME = "parking_limit_time"; //$//$NON-NLS-1$ - public final static String PARKING_START_TIME = "parking_time"; //$//$NON-NLS-1$ - public final static String PARKING_EVENT_ADDED = "parking_event_added"; //$//$NON-NLS-1$ + public static final String PARKING_POINT_LAT = "parking_point_lat"; //$NON-NLS-1$ + public static final String PARKING_POINT_LON = "parking_point_lon"; //$NON-NLS-1$ + public static final String PARKING_TYPE = "parking_type"; //$NON-NLS-1$ + public static final String PARKING_TIME = "parking_limit_time"; //$//$NON-NLS-1$ + public static final String PARKING_START_TIME = "parking_time"; //$//$NON-NLS-1$ + public static final String PARKING_EVENT_ADDED = "parking_event_added"; //$//$NON-NLS-1$ // Constants for determining the order of items in the additional actions context menu private static final int MARK_AS_PARKING_POS_ITEM_ORDER = 10500; private LatLon parkingPosition; - private OsmandApplication app; - private TextInfoWidget parkingPlaceControl; + private final CommonPreference parkingLat; private final CommonPreference parkingLon; - private CommonPreference parkingType; - private CommonPreference parkingEvent; - private CommonPreference parkingTime; - private CommonPreference parkingStartTime; + private final CommonPreference parkingType; + private final CommonPreference parkingEvent; + private final CommonPreference parkingTime; + private final CommonPreference parkingStartTime; public ParkingPositionPlugin(OsmandApplication app) { - this.app = app; + super(app); OsmandSettings set = app.getSettings(); ApplicationMode.regWidgetVisibility("parking", (ApplicationMode[]) null); parkingLat = set.registerFloatPreference(PARKING_POINT_LAT, 0f).makeGlobal(); diff --git a/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java b/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java index 30253d5575..019a06dc08 100644 --- a/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java +++ b/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java @@ -61,20 +61,20 @@ import static net.osmand.aidlapi.OsmAndCustomizationConstants.UNDERLAY_MAP; import static net.osmand.plus.UiUtilities.CompoundButtonType.PROFILE_DEPENDENT; public class OsmandRasterMapsPlugin extends OsmandPlugin { + public static final String ID = "osmand.rastermaps"; // Constants for determining the order of items in the additional actions context menu private static final int UPDATE_MAP_ITEM_ORDER = 12300; private static final int DOWNLOAD_MAP_ITEM_ORDER = 12600; private OsmandSettings settings; - private OsmandApplication app; private MapTileLayer overlayLayer; private MapTileLayer underlayLayer; private StateChangedListener overlayLayerListener; public OsmandRasterMapsPlugin(OsmandApplication app) { - this.app = app; + super(app); settings = app.getSettings(); } diff --git a/OsmAnd/src/net/osmand/plus/skimapsplugin/SkiMapsPlugin.java b/OsmAnd/src/net/osmand/plus/skimapsplugin/SkiMapsPlugin.java index 8d49d2dc91..89e871ff6f 100644 --- a/OsmAnd/src/net/osmand/plus/skimapsplugin/SkiMapsPlugin.java +++ b/OsmAnd/src/net/osmand/plus/skimapsplugin/SkiMapsPlugin.java @@ -18,10 +18,8 @@ public class SkiMapsPlugin extends OsmandPlugin { public static final String ID = "skimaps.plugin"; public static final String COMPONENT = "net.osmand.skimapsPlugin"; - private OsmandApplication app; - public SkiMapsPlugin(OsmandApplication app) { - this.app = app; + super(app); } @Override @@ -33,12 +31,12 @@ public class SkiMapsPlugin extends OsmandPlugin { public String getName() { return app.getString(net.osmand.plus.R.string.plugin_ski_name); } - + @Override public int getLogoResourceId() { return R.drawable.ic_action_skiing; } - + @Override public int getAssetResourceName() { return R.drawable.ski_map; diff --git a/OsmAnd/src/net/osmand/plus/srtmplugin/SRTMPlugin.java b/OsmAnd/src/net/osmand/plus/srtmplugin/SRTMPlugin.java index f564fc05a4..2bf6e8ef37 100644 --- a/OsmAnd/src/net/osmand/plus/srtmplugin/SRTMPlugin.java +++ b/OsmAnd/src/net/osmand/plus/srtmplugin/SRTMPlugin.java @@ -57,19 +57,16 @@ public class SRTMPlugin extends OsmandPlugin { public static final String CONTOUR_WIDTH_ATTR = "contourWidth"; public static final String CONTOUR_DENSITY_ATTR = "contourDensity"; - private OsmandApplication app; private OsmandSettings settings; - - private boolean paid; private HillshadeLayer hillshadeLayer; @Override public String getId() { - return paid ? ID : FREE_ID; + return FREE_ID; } public SRTMPlugin(OsmandApplication app) { - this.app = app; + super(app); settings = app.getSettings(); }