Custom plugins initial commit

This commit is contained in:
Vitaliy 2020-03-06 16:02:23 +02:00
parent 56c02046f3
commit 75b2cafbed
13 changed files with 94 additions and 42 deletions

View file

@ -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<Integer, Integer> soundIcons = new HashMap<Integer, Integer>();
public AccessibilityPlugin(OsmandApplication app) {
this.app = app;
super(app);
OsmandSettings settings = app.getSettings();
pluginPreferences.add(settings.ACCESSIBILITY_MODE);
pluginPreferences.add(settings.SPEECH_RATE);

View file

@ -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;
}
}

View file

@ -55,14 +55,21 @@ public abstract class OsmandPlugin {
public static final String PLUGIN_ID_KEY = "plugin_id";
private static List<OsmandPlugin> allPlugins = new ArrayList<OsmandPlugin>();
private static final Log LOG = PlatformUtil.getLog(OsmandPlugin.class);
private static List<OsmandPlugin> allPlugins = new ArrayList<OsmandPlugin>();
protected OsmandApplication app;
protected List<OsmandSettings.OsmandPreference> 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();

View file

@ -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<Boolean> 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);

View file

@ -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]);
}

View file

@ -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();
}

View file

@ -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<ApplicationMode> am = ApplicationMode.allPossibleValues();
ApplicationMode.regWidgetVisibility("monitoring", am.toArray(new ApplicationMode[am.size()]));

View file

@ -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

View file

@ -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();
}

View file

@ -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<Float> parkingLat;
private final CommonPreference<Float> parkingLon;
private CommonPreference<Boolean> parkingType;
private CommonPreference<Boolean> parkingEvent;
private CommonPreference<Long> parkingTime;
private CommonPreference<Long> parkingStartTime;
private final CommonPreference<Boolean> parkingType;
private final CommonPreference<Boolean> parkingEvent;
private final CommonPreference<Long> parkingTime;
private final CommonPreference<Long> 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();

View file

@ -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<Integer> overlayLayerListener;
public OsmandRasterMapsPlugin(OsmandApplication app) {
this.app = app;
super(app);
settings = app.getSettings();
}

View file

@ -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;

View file

@ -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();
}