Merge pull request #6253 from osmandapp/app_customizations

App customizations
This commit is contained in:
vshcherb 2018-11-03 16:05:20 +01:00 committed by GitHub
commit b5fe090a51
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 414 additions and 88 deletions

View file

@ -133,4 +133,11 @@ interface IOsmAndAidlInterface {
long registerForUpdates(in long updateTimeMS, IOsmAndAidlCallback callback);
boolean unregisterFromUpdates(in long callbackId);
boolean setNavDrawerLogo(in String imageUri);
boolean setEnabledIds(in List<String> ids);
boolean setDisabledIds(in List<String> ids);
boolean setEnabledPatterns(in List<String> patterns);
boolean setDisabledPatterns(in List<String> patterns);
}

View file

@ -82,6 +82,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashMap;
@ -1655,6 +1656,30 @@ public class OsmandAidlApi {
}
}
boolean setNavDrawerLogo(@Nullable String uri) {
return app.getAppCustomization().setNavDrawerLogo(uri);
}
boolean setEnabledIds(Collection<String> ids) {
app.getAppCustomization().setEnabledIds(ids);
return true;
}
boolean setDisabledIds(Collection<String> ids) {
app.getAppCustomization().setDisabledIds(ids);
return true;
}
boolean setEnabledPatterns(Collection<String> patterns) {
app.getAppCustomization().setEnabledPatterns(patterns);
return true;
}
boolean setDisabledPatterns(Collection<String> patterns) {
app.getAppCustomization().setDisabledPatterns(patterns);
return true;
}
public static class ConnectedApp implements Comparable<ConnectedApp> {
static final String PACK_KEY = "pack";

View file

@ -671,6 +671,36 @@ public class OsmandAidlService extends Service {
return true;
}
@Override
public boolean setNavDrawerLogo(String imageUri) throws RemoteException {
OsmandAidlApi api = getApi("setNavDrawerLogo");
return api != null && api.setNavDrawerLogo(imageUri);
}
@Override
public boolean setEnabledIds(List<String> ids) throws RemoteException {
OsmandAidlApi api = getApi("setEnabledIds");
return api != null && api.setEnabledIds(ids);
}
@Override
public boolean setDisabledIds(List<String> ids) throws RemoteException {
OsmandAidlApi api = getApi("setDisabledIds");
return api != null && api.setDisabledIds(ids);
}
@Override
public boolean setEnabledPatterns(List<String> patterns) throws RemoteException {
OsmandAidlApi api = getApi("setEnabledPatterns");
return api != null && api.setEnabledPatterns(patterns);
}
@Override
public boolean setDisabledPatterns(List<String> patterns) throws RemoteException {
OsmandAidlApi api = getApi("setDisabledPatterns");
return api != null && api.setDisabledPatterns(patterns);
}
void startRemoteUpdates(final long updateTimeMS, final long callbackId, final IOsmAndAidlCallback callback) {
mHandler.postDelayed(new Runnable() {
@Override

View file

@ -10,6 +10,7 @@ import android.support.annotation.IdRes;
import android.support.annotation.LayoutRes;
import android.support.v4.app.FragmentActivity;
import android.support.v7.widget.AppCompatImageView;
import android.text.TextUtils;
import android.view.ContextThemeWrapper;
import android.view.View;
import android.view.ViewGroup;
@ -32,6 +33,7 @@ import org.apache.commons.logging.Log;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
@ -100,6 +102,13 @@ public class ContextMenuAdapter {
public ArrayAdapter<ContextMenuItem> createListAdapter(final Activity activity, final boolean lightTheme) {
final int layoutId = DEFAULT_LAYOUT_ID;
final OsmandApplication app = ((OsmandApplication) activity.getApplication());
final OsmAndAppCustomization customization = app.getAppCustomization();
for (Iterator<ContextMenuItem> iterator = items.iterator(); iterator.hasNext(); ) {
String id = iterator.next().getId();
if (!TextUtils.isEmpty(id) && !customization.isFeatureEnabled(id)) {
iterator.remove();
}
}
return new ContextMenuArrayAdapter(activity, layoutId, R.id.title,
items.toArray(new ContextMenuItem[items.size()]), app, lightTheme, changeAppModeListener);
}

View file

@ -38,6 +38,7 @@ public class ContextMenuItem {
private final boolean hideDivider;
private final int minHeight;
private final int tag;
private final String id;
private ContextMenuItem(@StringRes int titleId,
String title,
@ -59,7 +60,8 @@ public class ContextMenuItem {
ContextMenuAdapter.ProgressListener progressListener,
boolean hideDivider,
int minHeight,
int tag) {
int tag,
String id) {
this.titleId = titleId;
this.title = title;
this.mIcon = icon;
@ -81,6 +83,7 @@ public class ContextMenuItem {
this.hideDivider = hideDivider;
this.minHeight = minHeight;
this.tag = tag;
this.id = id;
}
@StringRes
@ -218,6 +221,10 @@ public class ContextMenuItem {
return tag;
}
public String getId() {
return id;
}
public static ItemBuilder createBuilder(String title) {
return new ItemBuilder().setTitle(title);
}
@ -249,6 +256,7 @@ public class ContextMenuItem {
private boolean mHideDivider;
private int mMinHeight;
private int mTag;
private String mId;
public ItemBuilder setTitleId(@StringRes int titleId, @Nullable Context context) {
this.mTitleId = titleId;
@ -363,11 +371,16 @@ public class ContextMenuItem {
return this;
}
public ItemBuilder setId(String id) {
this.mId = id;
return this;
}
public ContextMenuItem createItem() {
return new ContextMenuItem(mTitleId, mTitle, mIcon, mColorRes, mSecondaryIcon,
mSelected, mProgress, mLayout, mLoading, mIsCategory, mIsClickable, mSkipPaintingWithoutColor,
mPosition, mOrder, mDescription, mItemClickListener, mIntegerListener, mProgressListener,
mHideDivider, mMinHeight, mTag);
mHideDivider, mMinHeight, mTag, mId);
}
}
}

View file

@ -1,6 +1,12 @@
package net.osmand.plus;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import net.osmand.IProgress;
import net.osmand.IndexConstants;
@ -9,136 +15,187 @@ import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.PluginsActivity;
import net.osmand.plus.activities.SettingsActivity;
import net.osmand.plus.activities.TrackActivity;
import net.osmand.plus.activities.search.SearchActivity;
import net.osmand.plus.download.DownloadActivity;
import net.osmand.plus.download.DownloadActivityType;
import net.osmand.plus.helpers.WaypointHelper;
import net.osmand.plus.myplaces.FavoritesActivity;
import net.osmand.plus.routing.RouteCalculationResult;
import net.osmand.plus.views.OsmandMapTileView;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
public class OsmAndAppCustomization {
protected OsmandApplication app;
protected OsmandSettings osmandSettings;
private Bitmap navDrawerLogo;
private Set<String> enabledIds = new HashSet<>();
private Set<String> disabledIds = new HashSet<>();
private Set<String> enabledPatterns = new HashSet<>();
private Set<String> disabledPatterns = new HashSet<>();
private boolean customizationEnabled;
public void setup(OsmandApplication app) {
this.app = app;
this.osmandSettings = new OsmandSettings(app, new net.osmand.plus.api.SettingsAPIImpl(app));
}
public OsmandSettings getOsmandSettings(){ return osmandSettings;}
// Main menu
public boolean checkExceptionsOnStart() {
return true;
public OsmandSettings getOsmandSettings() {
return osmandSettings;
}
public boolean showFirstTimeRunAndTips(boolean firstTime, boolean appVersionChanged) {
return true;
}
public boolean checkBasemapDownloadedOnStart() {
return true;
}
// Activities
public Class<? extends Activity> getSettingsActivity(){
public Class<? extends Activity> getSettingsActivity() {
return SettingsActivity.class;
}
public Class<MapActivity> getMapActivity(){
public Class<MapActivity> getMapActivity() {
return MapActivity.class;
}
public Class<TrackActivity> getTrackActivity(){
public Class<TrackActivity> getTrackActivity() {
return TrackActivity.class;
}
public Class<FavoritesActivity> getFavoritesActivity(){
public Class<FavoritesActivity> getFavoritesActivity() {
return FavoritesActivity.class;
}
public Class<? extends Activity> getDownloadIndexActivity() {
return DownloadActivity.class;
}
public Class<? extends Activity> getPluginsActivity() {
return PluginsActivity.class;
}
public Class<? extends Activity> getDownloadActivity() {
return DownloadActivity.class;
}
// Download screen
public void getDownloadTypes(List<DownloadActivityType> items) {
}
public List<String> onIndexingFiles(IProgress progress, Map<String, String> indexFileNames) {
return Collections.emptyList();
}
public void prepareLayerContextMenu(MapActivity activity, ContextMenuAdapter adapter) {
}
public void prepareOptionsMenu(MapActivity mapActivity, ContextMenuAdapter optionsMenuHelper) {
}
public String getIndexesUrl() {
return "http://"+IndexConstants.INDEX_DOWNLOAD_DOMAIN+"/get_indexes?gzip&" + Version.getVersionAsURLParam(app); //$NON-NLS-1$;
return "http://" + IndexConstants.INDEX_DOWNLOAD_DOMAIN + "/get_indexes?gzip&" + Version.getVersionAsURLParam(app);
}
public boolean showDownloadExtraActions() {
return true;
}
public File getTracksDir() {
return app.getAppPath(IndexConstants.GPX_RECORDED_INDEX_DIR);
}
public void createLayers(OsmandMapTileView mapView, MapActivity activity) {
}
public List<? extends LocationPoint> getWaypoints() {
return Collections.emptyList();
}
public boolean isWaypointGroupVisible(int waypointType, RouteCalculationResult route) {
if(waypointType == WaypointHelper.ALARMS) {
if (waypointType == WaypointHelper.ALARMS) {
return route != null && !route.getAlarmInfo().isEmpty();
} else if(waypointType == WaypointHelper.WAYPOINTS) {
} else if (waypointType == WaypointHelper.WAYPOINTS) {
return route != null && !route.getLocationPoints().isEmpty();
}
return true;
}
public void showLocationPoint(MapActivity ctx, LocationPoint locationPoint) {
}
public boolean onDestinationReached() {
return true;
}
@Nullable
public Bitmap getNavDrawerLogo() {
return navDrawerLogo;
}
public boolean onlyTourDownload() {
public boolean setNavDrawerLogo(@Nullable String uri) {
if (TextUtils.isEmpty(uri)) {
navDrawerLogo = null;
} else {
try {
InputStream is = app.getContentResolver().openInputStream(Uri.parse(uri));
if (is != null) {
navDrawerLogo = BitmapFactory.decodeStream(is);
is.close();
}
} catch (FileNotFoundException e) {
return false;
} catch (IOException e) {
// ignore
}
}
return true;
}
public void setEnabledIds(@NonNull Collection<String> ids) {
enabledIds.clear();
enabledIds.addAll(ids);
updateCustomizationEnabled();
}
public void setDisabledIds(@NonNull Collection<String> ids) {
disabledIds.clear();
disabledIds.addAll(ids);
updateCustomizationEnabled();
}
public void setEnabledPatterns(@NonNull Collection<String> patterns) {
enabledPatterns.clear();
enabledPatterns.addAll(patterns);
updateCustomizationEnabled();
}
public void setDisabledPatterns(@NonNull Collection<String> patterns) {
disabledPatterns.clear();
disabledPatterns.addAll(patterns);
updateCustomizationEnabled();
}
public boolean isFeatureEnabled(@NonNull String id) {
if (!customizationEnabled) {
return true;
}
if (enabledIds.contains(id)) {
return true;
}
if (disabledIds.contains(id)) {
return false;
}
if (isMatchesPattern(id, enabledPatterns)) {
return true;
}
return !isMatchesPattern(id, disabledPatterns);
}
private void updateCustomizationEnabled() {
customizationEnabled = !enabledIds.isEmpty() || !disabledIds.isEmpty()
|| !enabledPatterns.isEmpty() || !disabledPatterns.isEmpty();
}
private boolean isMatchesPattern(@NonNull String id, @NonNull Set<String> patterns) {
for (String pattern : patterns) {
if (id.startsWith(pattern)) {
return true;
}
}
return false;
}
public <T> void resumeActivity(Class<T> class1, T d) {
}
public <T> void pauseActivity(Class<T> class1) {
}
}

View file

@ -0,0 +1,73 @@
package net.osmand.plus;
public interface OsmAndCustomizationConstants {
// Navigation Drawer:
String DRAWER_ITEM_ID_SCHEME = "drawer.action.";
String DRAWER_DASHBOARD_ID = DRAWER_ITEM_ID_SCHEME + "dashboard";
String DRAWER_MAP_MARKERS_ID = DRAWER_ITEM_ID_SCHEME + "map_markers";
String DRAWER_MY_PLACES_ID = DRAWER_ITEM_ID_SCHEME + "my_places";
String DRAWER_SEARCH_ID = DRAWER_ITEM_ID_SCHEME + "search";
String DRAWER_DIRECTIONS_ID = DRAWER_ITEM_ID_SCHEME + "directions";
String DRAWER_CONFIGURE_MAP_ID = DRAWER_ITEM_ID_SCHEME + "configure_map";
String DRAWER_DOWNLOAD_MAPS_ID = DRAWER_ITEM_ID_SCHEME + "download_maps";
String DRAWER_OSMAND_LIVE_ID = DRAWER_ITEM_ID_SCHEME + "osmand_live";
String DRAWER_TRAVEL_GUIDES_ID = DRAWER_ITEM_ID_SCHEME + "travel_guides";
String DRAWER_MEASURE_DISTANCE_ID = DRAWER_ITEM_ID_SCHEME + "measure_distance";
String DRAWER_CONFIGURE_SCREEN_ID = DRAWER_ITEM_ID_SCHEME + "configure_screen";
String DRAWER_PLUGINS_ID = DRAWER_ITEM_ID_SCHEME + "plugins";
String DRAWER_SETTINGS_ID = DRAWER_ITEM_ID_SCHEME + "settings";
String DRAWER_HELP_ID = DRAWER_ITEM_ID_SCHEME + "help";
String DRAWER_BUILDS_ID = DRAWER_ITEM_ID_SCHEME + "builds";
String DRAWER_DIVIDER_ID = DRAWER_ITEM_ID_SCHEME + "divider";
// Configure Map:
String ITEM_ID_SCHEME = "map.configure.";
String SHOW_ITEMS_ID_SCHEME = ITEM_ID_SCHEME + "show.";
String RENDERING_ITEMS_ID_SCHEME = ITEM_ID_SCHEME + "rendering.";
String CUSTOM_RENDERING_ITEMS_ID_SCHEME = RENDERING_ITEMS_ID_SCHEME + "custom.";
String APP_PROFILES_ID = ITEM_ID_SCHEME + "app_profiles";
String SHOW_CATEGORY_ID = SHOW_ITEMS_ID_SCHEME + "category";
String FAVORITES_ID = SHOW_ITEMS_ID_SCHEME + "favorites";
String POI_OVERLAY_ID = SHOW_ITEMS_ID_SCHEME + "poi_overlay";
String POI_OVERLAY_LABELS_ID = SHOW_ITEMS_ID_SCHEME + "poi_overlay_labels";
String TRANSPORT_ID = SHOW_ITEMS_ID_SCHEME + "transport";
String GPX_FILES_ID = SHOW_ITEMS_ID_SCHEME + "gpx_files";
String MAP_MARKERS_ID = SHOW_ITEMS_ID_SCHEME + "map_markers";
String MAP_SOURCE_ID = SHOW_ITEMS_ID_SCHEME + "map_source";
String RECORDING_LAYER = SHOW_ITEMS_ID_SCHEME + "recording_layer";
String MAPILLARY = SHOW_ITEMS_ID_SCHEME + "mapillary";
String OSM_NOTES = SHOW_ITEMS_ID_SCHEME + "osm_notes";
String OVERLAY_MAP = SHOW_ITEMS_ID_SCHEME + "overlay_map";
String UNDERLAY_MAP = SHOW_ITEMS_ID_SCHEME + "underlay_map";
String CONTOUR_LINES = SHOW_ITEMS_ID_SCHEME + "contour_lines";
String HILLSHADE_LAYER = SHOW_ITEMS_ID_SCHEME + "hillshade_layer";
String MAP_RENDERING_CATEGORY_ID = RENDERING_ITEMS_ID_SCHEME + "category";
String MAP_STYLE_ID = RENDERING_ITEMS_ID_SCHEME + "map_style";
String MAP_MODE_ID = RENDERING_ITEMS_ID_SCHEME + "map_mode";
String MAP_MAGNIFIER_ID = RENDERING_ITEMS_ID_SCHEME + "map_marnifier";
String ROAD_STYLE_ID = RENDERING_ITEMS_ID_SCHEME + "road_style";
String TEXT_SIZE_ID = RENDERING_ITEMS_ID_SCHEME + "text_size";
String MAP_LANGUAGE_ID = RENDERING_ITEMS_ID_SCHEME + "map_language";
String TRANSPORT_RENDERING_ID = RENDERING_ITEMS_ID_SCHEME + "transport";
String DETAILS_ID = RENDERING_ITEMS_ID_SCHEME + "details";
String HIDE_ID = RENDERING_ITEMS_ID_SCHEME + "hide";
String ROUTES_ID = RENDERING_ITEMS_ID_SCHEME + "routes";
// Map Controls:
String HUD_BTN_ID_SCHEME = "map.view.";
String LAYERS_HUD_ID = HUD_BTN_ID_SCHEME + "layers";
String COMPASS_HUD_ID = HUD_BTN_ID_SCHEME + "compass";
String QUICK_SEARCH_HUD_ID = HUD_BTN_ID_SCHEME + "quick_search";
String BACK_TO_LOC_HUD_ID = HUD_BTN_ID_SCHEME + "back_to_loc";
String MENU_HUD_ID = HUD_BTN_ID_SCHEME + "menu";
String ROUTE_PLANNING_HUD_ID = HUD_BTN_ID_SCHEME + "route_planning";
String ZOOM_IN_HUD_ID = HUD_BTN_ID_SCHEME + "zoom_id";
String ZOOM_OUT_HUD_ID = HUD_BTN_ID_SCHEME + "zoom_out";
}

View file

@ -90,7 +90,6 @@ import net.osmand.plus.firstusage.FirstUsageWelcomeFragment;
import net.osmand.plus.firstusage.FirstUsageWizardFragment;
import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.helpers.DiscountHelper;
import net.osmand.plus.helpers.DiscountHelper.DiscountBarController;
import net.osmand.plus.helpers.ExternalApiHelper;
import net.osmand.plus.helpers.ImportHelper;
import net.osmand.plus.helpers.ImportHelper.ImportGpxBottomSheetDialogFragment;
@ -770,7 +769,6 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
}
}
getMyApplication().getAppCustomization().resumeActivity(MapActivity.class, this);
if (System.currentTimeMillis() - tm > 50) {
System.err.println("OnCreate for MapActivity took " + (System.currentTimeMillis() - tm) + " ms");
}
@ -1306,7 +1304,6 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
settings.setLastKnownMapZoom(mapView.getZoom());
settings.MAP_ACTIVITY_ENABLED.set(false);
getMyApplication().getAppCustomization().pauseActivity(MapActivity.class);
app.getResourceManager().interruptRendering();
OsmandPlugin.onMapActivityPause(this);
}

View file

@ -5,8 +5,10 @@ import android.app.Activity;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
@ -17,9 +19,11 @@ import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import net.osmand.AndroidUtils;
import net.osmand.IndexConstants;
import net.osmand.Location;
@ -47,7 +51,6 @@ import net.osmand.plus.R;
import net.osmand.plus.TargetPointsHelper;
import net.osmand.plus.Version;
import net.osmand.plus.activities.actions.OsmAndDialogs;
import net.osmand.plus.activities.search.SearchActivity;
import net.osmand.plus.dashboard.DashboardOnMap.DashboardType;
import net.osmand.plus.dialogs.FavoriteDialogs;
import net.osmand.plus.download.IndexItem;
@ -76,6 +79,21 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import static net.osmand.plus.OsmAndCustomizationConstants.DRAWER_CONFIGURE_MAP_ID;
import static net.osmand.plus.OsmAndCustomizationConstants.DRAWER_CONFIGURE_SCREEN_ID;
import static net.osmand.plus.OsmAndCustomizationConstants.DRAWER_DASHBOARD_ID;
import static net.osmand.plus.OsmAndCustomizationConstants.DRAWER_DIRECTIONS_ID;
import static net.osmand.plus.OsmAndCustomizationConstants.DRAWER_DIVIDER_ID;
import static net.osmand.plus.OsmAndCustomizationConstants.DRAWER_DOWNLOAD_MAPS_ID;
import static net.osmand.plus.OsmAndCustomizationConstants.DRAWER_HELP_ID;
import static net.osmand.plus.OsmAndCustomizationConstants.DRAWER_MAP_MARKERS_ID;
import static net.osmand.plus.OsmAndCustomizationConstants.DRAWER_MEASURE_DISTANCE_ID;
import static net.osmand.plus.OsmAndCustomizationConstants.DRAWER_MY_PLACES_ID;
import static net.osmand.plus.OsmAndCustomizationConstants.DRAWER_OSMAND_LIVE_ID;
import static net.osmand.plus.OsmAndCustomizationConstants.DRAWER_PLUGINS_ID;
import static net.osmand.plus.OsmAndCustomizationConstants.DRAWER_SEARCH_ID;
import static net.osmand.plus.OsmAndCustomizationConstants.DRAWER_SETTINGS_ID;
import static net.osmand.plus.OsmAndCustomizationConstants.DRAWER_TRAVEL_GUIDES_ID;
import static net.osmand.plus.helpers.ImportHelper.GPX_SUFFIX;
public class MapActivityActions implements DialogProvider {
@ -102,6 +120,7 @@ public class MapActivityActions implements DialogProvider {
private static final int DIALOG_RELOAD_TITLE = 103;
private static final int DIALOG_SAVE_DIRECTIONS = 106;
// make static
private static Bundle dialogBundle = new Bundle();
@ -109,10 +128,14 @@ public class MapActivityActions implements DialogProvider {
private OsmandSettings settings;
private RoutingHelper routingHelper;
@NonNull
private ImageView navDrawerLogoHeader;
public MapActivityActions(MapActivity mapActivity) {
this.mapActivity = mapActivity;
settings = mapActivity.getMyApplication().getSettings();
routingHelper = mapActivity.getMyApplication().getRoutingHelper();
navDrawerLogoHeader = new ImageView(mapActivity);
}
public void addAsTarget(double latitude, double longitude, PointDescription pd) {
@ -647,6 +670,7 @@ public class MapActivityActions implements DialogProvider {
ContextMenuAdapter optionsMenuHelper = new ContextMenuAdapter();
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.home, mapActivity)
.setId(DRAWER_DASHBOARD_ID)
.setIcon(R.drawable.map_dashboard)
.setListener(new ContextMenuAdapter.ItemClickListener() {
@Override
@ -660,6 +684,7 @@ public class MapActivityActions implements DialogProvider {
}).createItem());
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.map_markers, mapActivity)
.setId(DRAWER_MAP_MARKERS_ID)
.setIcon(R.drawable.ic_action_flag_dark)
.setListener(new ContextMenuAdapter.ItemClickListener() {
@Override
@ -672,6 +697,7 @@ public class MapActivityActions implements DialogProvider {
}).createItem());
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.shared_string_my_places, mapActivity)
.setId(DRAWER_MY_PLACES_ID)
.setIcon(R.drawable.ic_action_fav_dark)
.setListener(new ContextMenuAdapter.ItemClickListener() {
@Override
@ -686,6 +712,7 @@ public class MapActivityActions implements DialogProvider {
}).createItem());
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.search_button, mapActivity)
.setId(DRAWER_SEARCH_ID)
.setIcon(R.drawable.ic_action_search_dark)
.setListener(new ContextMenuAdapter.ItemClickListener() {
@Override
@ -698,6 +725,7 @@ public class MapActivityActions implements DialogProvider {
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.get_directions, mapActivity)
.setId(DRAWER_DIRECTIONS_ID)
.setIcon(R.drawable.ic_action_gdirections_dark)
.setListener(new ContextMenuAdapter.ItemClickListener() {
@Override
@ -725,6 +753,7 @@ public class MapActivityActions implements DialogProvider {
*/
optionsMenuHelper.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.configure_map, mapActivity)
.setId(DRAWER_CONFIGURE_MAP_ID)
.setIcon(R.drawable.ic_action_layers_dark)
.setListener(new ContextMenuAdapter.ItemClickListener() {
@Override
@ -744,6 +773,7 @@ public class MapActivityActions implements DialogProvider {
}
}
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.welmode_download_maps, null)
.setId(DRAWER_DOWNLOAD_MAPS_ID)
.setTitle(d).setIcon(R.drawable.ic_type_archive)
.setListener(new ContextMenuAdapter.ItemClickListener() {
@Override
@ -759,6 +789,7 @@ public class MapActivityActions implements DialogProvider {
if (Version.isGooglePlayEnabled(app) || Version.isDeveloperVersion(app)) {
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.osm_live, mapActivity)
.setId(DRAWER_OSMAND_LIVE_ID)
.setIcon(R.drawable.ic_action_osm_live)
.setListener(new ContextMenuAdapter.ItemClickListener() {
@Override
@ -773,6 +804,7 @@ public class MapActivityActions implements DialogProvider {
}
optionsMenuHelper.addItem(new ItemBuilder().setTitle(getString(R.string.shared_string_travel_guides) + " (Beta)")
.setId(DRAWER_TRAVEL_GUIDES_ID)
.setIcon(R.drawable.ic_action_travel)
.setListener(new ItemClickListener() {
@Override
@ -792,6 +824,7 @@ public class MapActivityActions implements DialogProvider {
}).createItem());
optionsMenuHelper.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.measurement_tool, mapActivity)
.setId(DRAWER_MEASURE_DISTANCE_ID)
.setIcon(R.drawable.ic_action_ruler)
.setListener(new ContextMenuAdapter.ItemClickListener() {
@Override
@ -804,6 +837,7 @@ public class MapActivityActions implements DialogProvider {
app.getAidlApi().registerNavDrawerItems(mapActivity, optionsMenuHelper);
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.layer_map_appearance, mapActivity)
.setId(DRAWER_CONFIGURE_SCREEN_ID)
.setIcon(R.drawable.ic_configure_screen_dark)
.setListener(new ContextMenuAdapter.ItemClickListener() {
@Override
@ -816,6 +850,7 @@ public class MapActivityActions implements DialogProvider {
}).createItem());
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.prefs_plugins, mapActivity)
.setId(DRAWER_PLUGINS_ID)
.setIcon(R.drawable.ic_extension_dark)
.setListener(new ItemClickListener() {
@Override
@ -830,6 +865,7 @@ public class MapActivityActions implements DialogProvider {
}).createItem());
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.shared_string_settings, mapActivity)
.setId(DRAWER_SETTINGS_ID)
.setIcon(R.drawable.ic_action_settings)
.setListener(new ContextMenuAdapter.ItemClickListener() {
@Override
@ -857,6 +893,7 @@ public class MapActivityActions implements DialogProvider {
*/
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.shared_string_help, mapActivity)
.setId(DRAWER_HELP_ID)
.setIcon(R.drawable.ic_action_help)
.setListener(new ContextMenuAdapter.ItemClickListener() {
@Override
@ -882,10 +919,10 @@ public class MapActivityActions implements DialogProvider {
}
ItemBuilder divider = new ItemBuilder().setLayout(R.layout.drawer_divider);
divider.setId(DRAWER_DIVIDER_ID);
divider.setPosition(dividerItemIndex >= 0 ? dividerItemIndex : 8);
optionsMenuHelper.addItem(divider.createItem());
getMyApplication().getAppCustomization().prepareOptionsMenu(mapActivity, optionsMenuHelper);
return optionsMenuHelper;
}
@ -958,6 +995,12 @@ public class MapActivityActions implements DialogProvider {
} else {
menuItemsListView.setBackgroundColor(ContextCompat.getColor(mapActivity, R.color.bg_color_light));
}
menuItemsListView.removeHeaderView(navDrawerLogoHeader);
Bitmap navDrawerLogo = getMyApplication().getAppCustomization().getNavDrawerLogo();
if (navDrawerLogo != null) {
navDrawerLogoHeader.setImageBitmap(navDrawerLogo);
menuItemsListView.addHeaderView(navDrawerLogoHeader);
}
menuItemsListView.setDivider(null);
final ContextMenuAdapter contextMenuAdapter = createMainOptionsMenu();
contextMenuAdapter.setDefaultLayoutId(R.layout.simple_list_menu_item);

View file

@ -91,6 +91,8 @@ import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;
import static net.osmand.plus.OsmAndCustomizationConstants.RECORDING_LAYER;
public class AudioVideoNotesPlugin extends OsmandPlugin {
@ -640,6 +642,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
}
};
adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.layer_recordings, app)
.setId(RECORDING_LAYER)
.setSelected(SHOW_RECORDINGS.get())
.setIcon(R.drawable.ic_action_micro_dark)
.setColor(SHOW_RECORDINGS.get() ? R.color.osmand_orange : ContextMenuItem.INVALID_ID)

View file

@ -18,6 +18,8 @@ import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.plus.views.mapwidgets.TextInfoWidget;
import static net.osmand.plus.OsmAndCustomizationConstants.DRAWER_BUILDS_ID;
public class OsmandDevelopmentPlugin extends OsmandPlugin {
private static final String ID = "osmand.development";
private OsmandApplication app;
@ -57,6 +59,7 @@ public class OsmandDevelopmentPlugin extends OsmandPlugin {
public void registerOptionsMenuItems(final MapActivity mapActivity, ContextMenuAdapter helper) {
if (Version.isDeveloperVersion(mapActivity.getMyApplication())) {
helper.addItem(new ContextMenuItem.ItemBuilder()
.setId(DRAWER_BUILDS_ID)
.setTitleId(R.string.version_settings, mapActivity)
.setIcon(R.drawable.ic_action_gabout_dark)
.setListener(new ContextMenuAdapter.ItemClickListener() {

View file

@ -68,6 +68,27 @@ import java.util.Map;
import gnu.trove.list.array.TIntArrayList;
import static net.osmand.plus.OsmAndCustomizationConstants.APP_PROFILES_ID;
import static net.osmand.plus.OsmAndCustomizationConstants.CUSTOM_RENDERING_ITEMS_ID_SCHEME;
import static net.osmand.plus.OsmAndCustomizationConstants.DETAILS_ID;
import static net.osmand.plus.OsmAndCustomizationConstants.FAVORITES_ID;
import static net.osmand.plus.OsmAndCustomizationConstants.GPX_FILES_ID;
import static net.osmand.plus.OsmAndCustomizationConstants.HIDE_ID;
import static net.osmand.plus.OsmAndCustomizationConstants.MAP_LANGUAGE_ID;
import static net.osmand.plus.OsmAndCustomizationConstants.MAP_MAGNIFIER_ID;
import static net.osmand.plus.OsmAndCustomizationConstants.MAP_MARKERS_ID;
import static net.osmand.plus.OsmAndCustomizationConstants.MAP_MODE_ID;
import static net.osmand.plus.OsmAndCustomizationConstants.MAP_RENDERING_CATEGORY_ID;
import static net.osmand.plus.OsmAndCustomizationConstants.MAP_SOURCE_ID;
import static net.osmand.plus.OsmAndCustomizationConstants.MAP_STYLE_ID;
import static net.osmand.plus.OsmAndCustomizationConstants.POI_OVERLAY_ID;
import static net.osmand.plus.OsmAndCustomizationConstants.POI_OVERLAY_LABELS_ID;
import static net.osmand.plus.OsmAndCustomizationConstants.ROAD_STYLE_ID;
import static net.osmand.plus.OsmAndCustomizationConstants.ROUTES_ID;
import static net.osmand.plus.OsmAndCustomizationConstants.SHOW_CATEGORY_ID;
import static net.osmand.plus.OsmAndCustomizationConstants.TEXT_SIZE_ID;
import static net.osmand.plus.OsmAndCustomizationConstants.TRANSPORT_ID;
import static net.osmand.plus.OsmAndCustomizationConstants.TRANSPORT_RENDERING_ID;
import static net.osmand.plus.srtmplugin.SRTMPlugin.CONTOUR_DENSITY_ATTR;
import static net.osmand.plus.srtmplugin.SRTMPlugin.CONTOUR_LINES_ATTR;
import static net.osmand.plus.srtmplugin.SRTMPlugin.CONTOUR_LINES_SCHEME_ATTR;
@ -80,6 +101,7 @@ public class ConfigureMapMenu {
public static final String CURRENT_TRACK_WIDTH_ATTR = "currentTrackWidth";
public static final String COLOR_ATTR = "color";
public static final String ROAD_STYLE_ATTR = "roadStyle";
private int hikingRouteOSMCValue;
private int selectedLanguageIndex;
private boolean transliterateNames;
@ -93,6 +115,7 @@ public class ConfigureMapMenu {
ContextMenuAdapter adapter = new ContextMenuAdapter();
adapter.setDefaultLayoutId(R.layout.list_item_icon_and_menu);
adapter.addItem(new ContextMenuItem.ItemBuilder()
.setId(APP_PROFILES_ID)
.setTitleId(R.string.app_modes_choose, ma)
.setLayout(R.layout.mode_toggles).createItem());
adapter.setChangeAppModeListener(new OnClickListener() {
@ -251,11 +274,13 @@ public class ConfigureMapMenu {
final OsmandSettings settings = app.getSettings();
LayerMenuListener l = new LayerMenuListener(activity, adapter);
adapter.addItem(new ContextMenuItem.ItemBuilder()
.setId(SHOW_CATEGORY_ID)
.setTitleId(R.string.shared_string_show, activity)
.setCategory(true).setLayout(R.layout.list_group_title_with_switch).createItem());
// String appMode = " [" + settings.getApplicationMode().toHumanString(view.getApplication()) +"] ";
boolean selected = settings.SHOW_FAVORITES.get();
adapter.addItem(new ContextMenuItem.ItemBuilder()
.setId(FAVORITES_ID)
.setTitleId(R.string.shared_string_favorites, activity)
.setSelected(settings.SHOW_FAVORITES.get())
.setColor(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID)
@ -263,6 +288,7 @@ public class ConfigureMapMenu {
.setListener(l).createItem());
selected = app.getPoiFilters().isShowingAnyPoi();
adapter.addItem(new ContextMenuItem.ItemBuilder()
.setId(POI_OVERLAY_ID)
.setTitleId(R.string.layer_poi, activity)
.setSelected(selected)
.setDescription(app.getPoiFilters().getSelectedPoiFiltersName())
@ -272,6 +298,7 @@ public class ConfigureMapMenu {
.setListener(l).createItem());
selected = settings.SHOW_POI_LABEL.get();
adapter.addItem(new ContextMenuItem.ItemBuilder()
.setId(POI_OVERLAY_LABELS_ID)
.setTitleId(R.string.layer_amenity_label, activity)
.setSelected(settings.SHOW_POI_LABEL.get())
.setColor(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID)
@ -308,6 +335,7 @@ public class ConfigureMapMenu {
}
final boolean transportSelected = selected;
adapter.addItem(new ContextMenuItem.ItemBuilder()
.setId(TRANSPORT_ID)
.setTitleId(R.string.rendering_category_transport, activity)
.setIcon(R.drawable.ic_action_bus_dark)
.setSecondaryIcon(R.drawable.ic_action_additional_option)
@ -459,6 +487,7 @@ public class ConfigureMapMenu {
}).createItem());
selected = app.getSelectedGpxHelper().isShowingAnyGpxFiles();
adapter.addItem(new ContextMenuItem.ItemBuilder()
.setId(GPX_FILES_ID)
.setTitleId(R.string.layer_gpx_layer, activity)
.setSelected(app.getSelectedGpxHelper().isShowingAnyGpxFiles())
.setDescription(app.getSelectedGpxHelper().getGpxDescription())
@ -469,6 +498,7 @@ public class ConfigureMapMenu {
selected = settings.SHOW_MAP_MARKERS.get();
adapter.addItem(new ContextMenuItem.ItemBuilder()
.setId(MAP_MARKERS_ID)
.setTitleId(R.string.map_markers, activity)
.setSelected(selected)
.setColor(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID)
@ -476,13 +506,13 @@ public class ConfigureMapMenu {
.setListener(l).createItem());
adapter.addItem(new ContextMenuItem.ItemBuilder()
.setId(MAP_SOURCE_ID)
.setTitleId(R.string.layer_map, activity)
.setIcon(R.drawable.ic_world_globe_dark)
.setDescription(settings.MAP_ONLINE_DATA.get() ? settings.MAP_TILE_SOURCES.get() : null)
.setListener(l).createItem());
OsmandPlugin.registerLayerContextMenu(activity.getMapView(), adapter, activity);
app.getAppCustomization().prepareLayerContextMenu(activity, adapter);
boolean srtmDisabled = OsmandPlugin.getEnabledPlugin(SRTMPlugin.class) == null
&& !InAppPurchaseHelper.isSubscribedToLiveUpdates(app);
if (srtmDisabled) {
@ -502,8 +532,10 @@ public class ConfigureMapMenu {
private void createRenderingAttributeItems(List<RenderingRuleProperty> customRules,
final ContextMenuAdapter adapter, final MapActivity activity) {
adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.map_widget_map_rendering, activity)
.setId(MAP_RENDERING_CATEGORY_ID)
.setCategory(true).setLayout(R.layout.list_group_title_with_switch).createItem());
adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.map_widget_renderer, activity)
.setId(MAP_STYLE_ID)
.setDescription(getRenderDescr(activity)).setLayout(R.layout.list_item_single_line_descrition_narrow)
.setIcon(R.drawable.ic_map).setListener(new ContextMenuAdapter.ItemClickListener() {
@Override
@ -516,6 +548,7 @@ public class ConfigureMapMenu {
}).createItem());
adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.map_mode, activity)
.setId(MAP_MODE_ID)
.setDescription(getDayNightDescr(activity)).setLayout(R.layout.list_item_single_line_descrition_narrow)
.setIcon(getDayNightIcon(activity)).setListener(new ItemClickListener() {
@Override
@ -548,6 +581,7 @@ public class ConfigureMapMenu {
}).createItem());
adapter.addItem(new ContextMenuItem.ItemBuilder()
.setId(MAP_MAGNIFIER_ID)
.setTitleId(R.string.map_magnifier, activity)
.setDescription(
String.format(Locale.UK, "%.0f",
@ -609,12 +643,13 @@ public class ConfigureMapMenu {
}).createItem());
ContextMenuItem props;
props = createRenderingProperty(customRules, adapter, activity, R.drawable.ic_action_intersection, ROAD_STYLE_ATTR);
props = createRenderingProperty(customRules, adapter, activity, R.drawable.ic_action_intersection, ROAD_STYLE_ATTR, ROAD_STYLE_ID);
if (props != null) {
adapter.addItem(props);
}
adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.text_size, activity)
.setId(TEXT_SIZE_ID)
.setDescription(getScale(activity)).setLayout(R.layout.list_item_single_line_descrition_narrow)
.setIcon(R.drawable.ic_action_map_text_size).setListener(new ContextMenuAdapter.ItemClickListener() {
@Override
@ -653,6 +688,7 @@ public class ConfigureMapMenu {
localeDescr = localeDescr == null || localeDescr.equals("") ? activity.getString(R.string.local_map_names)
: localeDescr;
adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.map_locale, activity)
.setId(MAP_LANGUAGE_ID)
.setDescription(localeDescr).setLayout(R.layout.list_item_single_line_descrition_narrow)
.setIcon(R.drawable.ic_action_map_language)
.setListener(new ContextMenuAdapter.ItemClickListener() {
@ -743,17 +779,17 @@ public class ConfigureMapMenu {
}).createItem());
props = createProperties(customRules, null, R.string.rendering_category_transport, R.drawable.ic_action_bus_dark,
"transport", null, adapter, activity, true);
"transport", null, adapter, activity, true, TRANSPORT_RENDERING_ID);
if (props != null) {
adapter.addItem(props);
}
props = createProperties(customRules, null, R.string.rendering_category_details, R.drawable.ic_action_layers_dark,
"details", null, adapter, activity, true);
"details", null, adapter, activity, true, DETAILS_ID);
if (props != null) {
adapter.addItem(props);
}
props = createProperties(customRules, null, R.string.rendering_category_hide, R.drawable.ic_action_hide,
"hide", null, adapter, activity, true);
"hide", null, adapter, activity, true, HIDE_ID);
if (props != null) {
adapter.addItem(props);
}
@ -765,7 +801,7 @@ public class ConfigureMapMenu {
}
}
props = createProperties(customRules, customRulesIncluded, R.string.rendering_category_routes, R.drawable.ic_action_map_routes,
"routes", null, adapter, activity, true);
"routes", null, adapter, activity, true, ROUTES_ID);
if (props != null) {
adapter.addItem(props);
}
@ -827,7 +863,8 @@ public class ConfigureMapMenu {
final ListStringPreference defaultSettings,
final ContextMenuAdapter adapter,
final MapActivity activity,
final boolean useDescription) {
final boolean useDescription,
final String id) {
final List<RenderingRuleProperty> ps = new ArrayList<>();
final List<OsmandSettings.CommonPreference<Boolean>> prefs = new ArrayList<>();
@ -883,6 +920,7 @@ public class ConfigureMapMenu {
};
ContextMenuItem.ItemBuilder builder = new ContextMenuItem.ItemBuilder().setTitleId(strId, activity)
.setId(id)
.setIcon(icon).setListener(clickListener);
boolean selected = false;
for (OsmandSettings.CommonPreference<Boolean> p : prefs) {
@ -1138,7 +1176,7 @@ public class ConfigureMapMenu {
List<RenderingRuleProperty> customRules) {
for (final RenderingRuleProperty p : customRules) {
if (isPropertyAccepted(p)) {
adapter.addItem(createRenderingProperty(adapter, activity, 0, p));
adapter.addItem(createRenderingProperty(adapter, activity, 0, p, CUSTOM_RENDERING_ITEMS_ID_SCHEME + p.getName()));
}
}
}
@ -1155,17 +1193,17 @@ public class ConfigureMapMenu {
private ContextMenuItem createRenderingProperty(final List<RenderingRuleProperty> customRules,
final ContextMenuAdapter adapter, final MapActivity activity,
@DrawableRes final int icon, final String attrName) {
@DrawableRes final int icon, final String attrName, String id) {
for (final RenderingRuleProperty p : customRules) {
if (p.getAttrName().equals(attrName)) {
return createRenderingProperty(adapter, activity, icon, p);
return createRenderingProperty(adapter, activity, icon, p, id);
}
}
return null;
}
private ContextMenuItem createRenderingProperty(final ContextMenuAdapter adapter, final MapActivity activity,
@DrawableRes final int icon, final RenderingRuleProperty p) {
@DrawableRes final int icon, final RenderingRuleProperty p, final String id) {
final OsmandMapTileView view = activity.getMapView();
String propertyName = SettingsActivity.getStringPropertyName(view.getContext(), p.getAttrName(),
p.getName());
@ -1176,6 +1214,7 @@ public class ConfigureMapMenu {
final OsmandSettings.CommonPreference<Boolean> pref = view.getApplication().getSettings()
.getCustomRenderBooleanProperty(p.getAttrName());
return ContextMenuItem.createBuilder(propertyName)
.setId(id)
.setListener(new ContextMenuAdapter.ItemClickListener() {
@Override
@ -1198,6 +1237,7 @@ public class ConfigureMapMenu {
p.getDefaultValueDescription());
}
ContextMenuItem.ItemBuilder builder = ContextMenuItem.createBuilder(propertyName)
.setId(id)
.setListener(new ContextMenuAdapter.ItemClickListener() {
@Override

View file

@ -254,7 +254,6 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo
protected void onResume() {
super.onResume();
initAppStatusVariables();
getMyApplication().getAppCustomization().resumeActivity(DownloadActivity.class, this);
downloadThread.setUiActivity(this);
downloadInProgress();
}
@ -283,7 +282,6 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo
@Override
public void onPause() {
super.onPause();
getMyApplication().getAppCustomization().pauseActivity(DownloadActivity.class);
downloadThread.resetUiActivity(this);
}

View file

@ -39,6 +39,7 @@ import java.text.MessageFormat;
import java.util.List;
import static android.content.Intent.ACTION_VIEW;
import static net.osmand.plus.OsmAndCustomizationConstants.MAPILLARY;
public class MapillaryPlugin extends OsmandPlugin {
public static final String ID = "osmand.mapillary";
@ -179,6 +180,7 @@ public class MapillaryPlugin extends OsmandPlugin {
settings.SHOW_MAPILLARY.set(false);
}
adapter.addItem(new ContextMenuItem.ItemBuilder()
.setId(MAPILLARY)
.setTitleId(R.string.mapillary, mapActivity)
.setSelected(settings.SHOW_MAPILLARY.get())
.setColor(settings.SHOW_MAPILLARY.get() ? R.color.osmand_orange : ContextMenuItem.INVALID_ID)

View file

@ -47,6 +47,8 @@ import org.apache.commons.logging.Log;
import java.util.List;
import static net.osmand.plus.OsmAndCustomizationConstants.OSM_NOTES;
public class OsmEditingPlugin extends OsmandPlugin {
private static final Log LOG = PlatformUtil.getLog(OsmEditingPlugin.class);
@ -292,6 +294,7 @@ public class OsmEditingPlugin extends OsmandPlugin {
@Override
public void registerLayerContextMenuActions(OsmandMapTileView mapView, ContextMenuAdapter adapter, final MapActivity mapActivity) {
adapter.addItem(new ContextMenuItem.ItemBuilder()
.setId(OSM_NOTES)
.setTitleId(R.string.layer_osm_bugs, mapActivity)
.setSelected(settings.SHOW_OSM_BUGS.get())
.setIcon(R.drawable.ic_action_bug_dark)

View file

@ -420,10 +420,6 @@ public class ParkingPositionPlugin extends OsmandPlugin {
}
clearParkingPosition();
}
@Override
public void registerOptionsMenuItems(final MapActivity mapActivity, ContextMenuAdapter helper) {
}
/**
* @return the control to be added on a MapInfoLayer

View file

@ -46,6 +46,9 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import static net.osmand.plus.OsmAndCustomizationConstants.OVERLAY_MAP;
import static net.osmand.plus.OsmAndCustomizationConstants.UNDERLAY_MAP;
public class OsmandRasterMapsPlugin extends OsmandPlugin {
public static final String ID = "osmand.rastermaps";
@ -323,6 +326,7 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
boolean hasOverlayDescription = overlayMapDescr != null;
overlayMapDescr = hasOverlayDescription ? overlayMapDescr : mapActivity.getString(R.string.shared_string_none);
adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.layer_overlay, mapActivity)
.setId(OVERLAY_MAP)
.setDescription(overlayMapDescr)
.setSelected(hasOverlayDescription)
.setColor(hasOverlayDescription ? R.color.osmand_orange : ContextMenuItem.INVALID_ID)
@ -335,6 +339,7 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
boolean hasUnderlayDescription = underlayMapDescr != null;
underlayMapDescr = hasUnderlayDescription ? underlayMapDescr : mapActivity.getString(R.string.shared_string_none);
adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.layer_underlay, mapActivity)
.setId(UNDERLAY_MAP)
.setDescription(underlayMapDescr)
.setSelected(hasUnderlayDescription)
.setColor(hasUnderlayDescription ? R.color.osmand_orange : ContextMenuItem.INVALID_ID)

View file

@ -29,6 +29,9 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import static net.osmand.plus.OsmAndCustomizationConstants.CONTOUR_LINES;
import static net.osmand.plus.OsmAndCustomizationConstants.HILLSHADE_LAYER;
public class SRTMPlugin extends OsmandPlugin {
public static final String ID = "osmand.srtm";
@ -217,6 +220,7 @@ public class SRTMPlugin extends OsmandPlugin {
}
String descr = getPrefDescription(app, contourLinesProp, pref);
adapter.addItem(new ContextMenuItem.ItemBuilder()
.setId(CONTOUR_LINES)
.setTitleId(R.string.srtm_plugin_name, mapActivity)
.setSelected(contourLinesSelected)
.setIcon(R.drawable.ic_plugin_srtm)
@ -227,6 +231,7 @@ public class SRTMPlugin extends OsmandPlugin {
.setListener(listener).createItem());
}
adapter.addItem(new ContextMenuItem.ItemBuilder()
.setId(HILLSHADE_LAYER)
.setTitleId(R.string.layer_hillshade, mapActivity)
.setSelected(HILLSHADE.get())
.setColor(HILLSHADE.get() ? R.color.osmand_orange : ContextMenuItem.INVALID_ID)

View file

@ -36,6 +36,7 @@ import net.osmand.core.android.MapRendererContext;
import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
import net.osmand.data.RotatedTileBox;
import net.osmand.plus.OsmAndAppCustomization;
import net.osmand.plus.OsmAndLocationProvider;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
@ -61,6 +62,15 @@ import java.util.List;
import gnu.trove.list.array.TIntArrayList;
import static net.osmand.plus.OsmAndCustomizationConstants.BACK_TO_LOC_HUD_ID;
import static net.osmand.plus.OsmAndCustomizationConstants.COMPASS_HUD_ID;
import static net.osmand.plus.OsmAndCustomizationConstants.LAYERS_HUD_ID;
import static net.osmand.plus.OsmAndCustomizationConstants.MENU_HUD_ID;
import static net.osmand.plus.OsmAndCustomizationConstants.QUICK_SEARCH_HUD_ID;
import static net.osmand.plus.OsmAndCustomizationConstants.ROUTE_PLANNING_HUD_ID;
import static net.osmand.plus.OsmAndCustomizationConstants.ZOOM_IN_HUD_ID;
import static net.osmand.plus.OsmAndCustomizationConstants.ZOOM_OUT_HUD_ID;
public class MapControlsLayer extends OsmandMapLayer {
private static final int TIMEOUT_TO_SHOW_BUTTONS = 7000;
@ -68,10 +78,11 @@ public class MapControlsLayer extends OsmandMapLayer {
private static final int REQUEST_LOCATION_FOR_NAVIGATION_FAB_PERMISSION = 201;
private static final int REQUEST_LOCATION_FOR_ADD_DESTINATION_PERMISSION = 202;
public MapHudButton createHudButton(View iv, int resId) {
public MapHudButton createHudButton(View iv, int resId, String id) {
MapHudButton mc = new MapHudButton();
mc.iv = iv;
mc.resId = resId;
mc.id = id;
return mc;
}
@ -97,6 +108,7 @@ public class MapControlsLayer extends OsmandMapLayer {
private TextView zoomText;
private OsmandMapTileView mapView;
private OsmandApplication app;
private OsmAndAppCustomization appCustomization;
private MapHudButton routePlanningBtn;
private long touchEvent;
private MapHudButton mapZoomOut;
@ -112,6 +124,7 @@ public class MapControlsLayer extends OsmandMapLayer {
public MapControlsLayer(MapActivity activity) {
this.mapActivity = activity;
app = activity.getMyApplication();
appCustomization = app.getAppCustomization();
settings = activity.getMyApplication().getSettings();
mapView = mapActivity.getMapView();
contextMenuLayer = mapActivity.getMapLayers().getContextMenuLayer();
@ -246,7 +259,7 @@ public class MapControlsLayer extends OsmandMapLayer {
private void initTopControls() {
View configureMap = mapActivity.findViewById(R.id.map_layers_button);
layersHud = createHudButton(configureMap, R.drawable.map_world_globe_dark)
layersHud = createHudButton(configureMap, R.drawable.map_world_globe_dark, LAYERS_HUD_ID)
.setIconColorId(R.color.on_map_icon_color, 0)
.setBg(R.drawable.btn_inset_circle_trans, R.drawable.btn_inset_circle_night);
controls.add(layersHud);
@ -259,7 +272,7 @@ public class MapControlsLayer extends OsmandMapLayer {
});
View compass = mapActivity.findViewById(R.id.map_compass_button);
compassHud = createHudButton(compass, R.drawable.map_compass).setIconColorId(0).
compassHud = createHudButton(compass, R.drawable.map_compass, COMPASS_HUD_ID).setIconColorId(0).
setBg(R.drawable.btn_inset_circle_trans, R.drawable.btn_inset_circle_night);
compassHud.compass = true;
controls.add(compassHud);
@ -271,7 +284,7 @@ public class MapControlsLayer extends OsmandMapLayer {
});
View search = mapActivity.findViewById(R.id.map_search_button);
quickSearchHud = createHudButton(search, R.drawable.map_search_dark)
quickSearchHud = createHudButton(search, R.drawable.map_search_dark, QUICK_SEARCH_HUD_ID)
.setIconsId(R.drawable.map_search_dark, R.drawable.map_search_night)
.setIconColorId(0)
.setBg(R.drawable.btn_inset_circle_trans, R.drawable.btn_inset_circle_night);
@ -389,7 +402,7 @@ public class MapControlsLayer extends OsmandMapLayer {
private void initControls() {
View backToLocation = mapActivity.findViewById(R.id.map_my_location_button);
backToLocationControl = createHudButton(backToLocation, R.drawable.map_my_location)
backToLocationControl = createHudButton(backToLocation, R.drawable.map_my_location, BACK_TO_LOC_HUD_ID)
.setBg(R.drawable.btn_circle_blue);
controls.add(backToLocationControl);
@ -409,7 +422,7 @@ public class MapControlsLayer extends OsmandMapLayer {
final boolean dash = settings.SHOW_DASHBOARD_ON_MAP_SCREEN.get();
menuControl = createHudButton(backToMenuButton,
!dash ? R.drawable.map_drawer : R.drawable.map_dashboard).setBg(
!dash ? R.drawable.map_drawer : R.drawable.map_dashboard, MENU_HUD_ID).setBg(
R.drawable.btn_round, R.drawable.btn_round_night);
controls.add(menuControl);
backToMenuButton.setOnClickListener(new View.OnClickListener() {
@ -426,7 +439,7 @@ public class MapControlsLayer extends OsmandMapLayer {
zoomText = (TextView) mapActivity.findViewById(R.id.map_app_mode_text);
View routePlanButton = mapActivity.findViewById(R.id.map_route_info_button);
routePlanningBtn = createHudButton(routePlanButton, R.drawable.map_directions).setBg(
routePlanningBtn = createHudButton(routePlanButton, R.drawable.map_directions, ROUTE_PLANNING_HUD_ID).setBg(
R.drawable.btn_round, R.drawable.btn_round_night);
controls.add(routePlanningBtn);
routePlanButton.setOnClickListener(new View.OnClickListener() {
@ -634,7 +647,7 @@ public class MapControlsLayer extends OsmandMapLayer {
private void initZooms() {
final OsmandMapTileView view = mapActivity.getMapView();
View zoomInButton = mapActivity.findViewById(R.id.map_zoom_in_button);
mapZoomIn = createHudButton(zoomInButton, R.drawable.map_zoom_in).
mapZoomIn = createHudButton(zoomInButton, R.drawable.map_zoom_in, ZOOM_IN_HUD_ID).
setIconsId(R.drawable.map_zoom_in, R.drawable.map_zoom_in_night).setRoundTransparent();
controls.add(mapZoomIn);
zoomInButton.setOnClickListener(new View.OnClickListener() {
@ -653,7 +666,7 @@ public class MapControlsLayer extends OsmandMapLayer {
final View.OnLongClickListener listener = MapControlsLayer.getOnClickMagnifierListener(view);
zoomInButton.setOnLongClickListener(listener);
View zoomOutButton = mapActivity.findViewById(R.id.map_zoom_out_button);
mapZoomOut = createHudButton(zoomOutButton, R.drawable.map_zoom_out).
mapZoomOut = createHudButton(zoomOutButton, R.drawable.map_zoom_out, ZOOM_OUT_HUD_ID).
setIconsId(R.drawable.map_zoom_out, R.drawable.map_zoom_out_night).setRoundTransparent();
controls.add(mapZoomOut);
zoomOutButton.setOnClickListener(new View.OnClickListener() {
@ -1035,6 +1048,7 @@ public class MapControlsLayer extends OsmandMapLayer {
int resDarkId;
int resClrLight = R.color.icon_color;
int resClrDark = 0;
String id;
boolean nightMode = false;
boolean f = true;
@ -1094,6 +1108,9 @@ public class MapControlsLayer extends OsmandMapLayer {
}
public boolean updateVisibility(boolean visible) {
if (visible) {
visible = appCustomization.isFeatureEnabled(id);
}
if (!compassOutside && visible != (iv.getVisibility() == View.VISIBLE)) {
if (visible) {
if (hideAnimator != null) {