refactor / Hillshade action to Terrain
This commit is contained in:
parent
0ed85b1cb6
commit
7cfa03732b
11 changed files with 54 additions and 68 deletions
|
@ -210,7 +210,10 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:padding="@dimen/content_padding">
|
android:paddingTop="@dimen/content_padding"
|
||||||
|
android:paddingStart="@dimen/content_padding"
|
||||||
|
android:paddingEnd="@dimen/content_padding"
|
||||||
|
android:paddingBottom="@dimen/content_padding_half">
|
||||||
|
|
||||||
<net.osmand.plus.widgets.TextViewEx
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
|
|
|
@ -11,6 +11,10 @@
|
||||||
Thx - Hardy
|
Thx - Hardy
|
||||||
|
|
||||||
-->
|
-->
|
||||||
|
<string name="quick_action_terrain_descr">A button to show or hide terrain layer on the map.</string>
|
||||||
|
<string name="quick_action_terrain_show">Show terrain</string>
|
||||||
|
<string name="quick_action_terrain_hide">Hide terrain</string>
|
||||||
|
<string name="quick_action_show_hide_terrain">Show/hide terrain</string>
|
||||||
<string name="download_slope_maps">Slopes</string>
|
<string name="download_slope_maps">Slopes</string>
|
||||||
<string name="clear_recorded_data_warning">Are you sure you want to clear recorded data?</string>
|
<string name="clear_recorded_data_warning">Are you sure you want to clear recorded data?</string>
|
||||||
<string name="restore_all_profile_settings_descr">All profile settings will be restored to their original state after creating/importing this profile.</string>
|
<string name="restore_all_profile_settings_descr">All profile settings will be restored to their original state after creating/importing this profile.</string>
|
||||||
|
|
|
@ -2095,7 +2095,7 @@ public class OsmandSettings {
|
||||||
// this value string is synchronized with settings_pref.xml preference name
|
// this value string is synchronized with settings_pref.xml preference name
|
||||||
public final CommonPreference<Boolean> MAP_ONLINE_DATA = new BooleanPreference("map_online_data", false).makeProfile();
|
public final CommonPreference<Boolean> MAP_ONLINE_DATA = new BooleanPreference("map_online_data", false).makeProfile();
|
||||||
|
|
||||||
public final CommonPreference<Boolean> HILLSHADE = new BooleanPreference("hillshade_layer", true).makeProfile();
|
public final CommonPreference<TerrainMode> TERRAIN_MODE = new EnumIntPreference<>("terrain_mode", TerrainMode.HILLSHADE, TerrainMode.values()).makeProfile();
|
||||||
|
|
||||||
public final CommonPreference<Integer> HILLSHADE_MIN_ZOOM = new IntPreference("hillshade_min_zoom", 3).makeProfile();
|
public final CommonPreference<Integer> HILLSHADE_MIN_ZOOM = new IntPreference("hillshade_min_zoom", 3).makeProfile();
|
||||||
|
|
||||||
|
@ -2111,8 +2111,6 @@ public class OsmandSettings {
|
||||||
|
|
||||||
public final CommonPreference<Boolean> TERRAIN = new BooleanPreference("terrain_layer", true).makeProfile();
|
public final CommonPreference<Boolean> TERRAIN = new BooleanPreference("terrain_layer", true).makeProfile();
|
||||||
|
|
||||||
public final CommonPreference<TerrainMode> TERRAIN_MODE = new EnumIntPreference<>("terrain_mode", TerrainMode.HILLSHADE, TerrainMode.values()).makeProfile();
|
|
||||||
|
|
||||||
public final CommonPreference<String> CONTOUR_LINES_ZOOM = new StringPreference("contour_lines_zoom", null).makeProfile().cache();
|
public final CommonPreference<String> CONTOUR_LINES_ZOOM = new StringPreference("contour_lines_zoom", null).makeProfile().cache();
|
||||||
|
|
||||||
// this value string is synchronized with settings_pref.xml preference name
|
// this value string is synchronized with settings_pref.xml preference name
|
||||||
|
|
|
@ -173,7 +173,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, IRouteInfo
|
||||||
UNDERLAY_MAP,
|
UNDERLAY_MAP,
|
||||||
MAPILLARY,
|
MAPILLARY,
|
||||||
CONTOUR_LINES,
|
CONTOUR_LINES,
|
||||||
HILLSHADE,
|
|
||||||
OSM_NOTES,
|
OSM_NOTES,
|
||||||
TERRAIN,
|
TERRAIN,
|
||||||
SLOPE
|
SLOPE
|
||||||
|
@ -319,8 +318,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, IRouteInfo
|
||||||
tv.setText(R.string.mapillary);
|
tv.setText(R.string.mapillary);
|
||||||
} else if (visibleType == DashboardType.CONTOUR_LINES) {
|
} else if (visibleType == DashboardType.CONTOUR_LINES) {
|
||||||
tv.setText(R.string.srtm_plugin_name);
|
tv.setText(R.string.srtm_plugin_name);
|
||||||
} else if (visibleType == DashboardType.HILLSHADE) {
|
|
||||||
tv.setText(R.string.layer_hillshade);
|
|
||||||
} else if (visibleType == DashboardType.OSM_NOTES) {
|
} else if (visibleType == DashboardType.OSM_NOTES) {
|
||||||
tv.setText(R.string.osm_notes);
|
tv.setText(R.string.osm_notes);
|
||||||
} else if (visibleType == DashboardType.TERRAIN) {
|
} else if (visibleType == DashboardType.TERRAIN) {
|
||||||
|
@ -678,7 +675,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, IRouteInfo
|
||||||
if (visibleType != DashboardType.CONFIGURE_SCREEN
|
if (visibleType != DashboardType.CONFIGURE_SCREEN
|
||||||
&& visibleType != DashboardType.CONFIGURE_MAP
|
&& visibleType != DashboardType.CONFIGURE_MAP
|
||||||
&& visibleType != DashboardType.CONTOUR_LINES
|
&& visibleType != DashboardType.CONTOUR_LINES
|
||||||
&& visibleType != DashboardType.HILLSHADE
|
&& visibleType != DashboardType.TERRAIN
|
||||||
&& visibleType != DashboardType.OSM_NOTES) {
|
&& visibleType != DashboardType.OSM_NOTES) {
|
||||||
listView.setDivider(dividerDrawable);
|
listView.setDivider(dividerDrawable);
|
||||||
listView.setDividerHeight(AndroidUtils.dpToPx(mapActivity, 1f));
|
listView.setDividerHeight(AndroidUtils.dpToPx(mapActivity, 1f));
|
||||||
|
@ -733,14 +730,14 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, IRouteInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onNewDownloadIndexes() {
|
public void onNewDownloadIndexes() {
|
||||||
if (visibleType == DashboardType.CONTOUR_LINES || visibleType == DashboardType.HILLSHADE) {
|
if (visibleType == DashboardType.CONTOUR_LINES || visibleType == DashboardType.TERRAIN) {
|
||||||
refreshContent(true);
|
refreshContent(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void onDownloadInProgress() {
|
public void onDownloadInProgress() {
|
||||||
if (visibleType == DashboardType.CONTOUR_LINES || visibleType == DashboardType.HILLSHADE) {
|
if (visibleType == DashboardType.CONTOUR_LINES || visibleType == DashboardType.TERRAIN) {
|
||||||
DownloadIndexesThread downloadThread = getMyApplication().getDownloadThread();
|
DownloadIndexesThread downloadThread = getMyApplication().getDownloadThread();
|
||||||
IndexItem downloadIndexItem = downloadThread.getCurrentDownloadingItem();
|
IndexItem downloadIndexItem = downloadThread.getCurrentDownloadingItem();
|
||||||
if (downloadIndexItem != null) {
|
if (downloadIndexItem != null) {
|
||||||
|
@ -758,11 +755,11 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, IRouteInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onDownloadHasFinished() {
|
public void onDownloadHasFinished() {
|
||||||
if (visibleType == DashboardType.CONTOUR_LINES || visibleType == DashboardType.HILLSHADE) {
|
if (visibleType == DashboardType.CONTOUR_LINES || visibleType == DashboardType.TERRAIN) {
|
||||||
refreshContent(true);
|
refreshContent(true);
|
||||||
if (visibleType == DashboardType.HILLSHADE) {
|
if (visibleType == DashboardType.TERRAIN) {
|
||||||
SRTMPlugin plugin = OsmandPlugin.getEnabledPlugin(SRTMPlugin.class);
|
SRTMPlugin plugin = OsmandPlugin.getEnabledPlugin(SRTMPlugin.class);
|
||||||
if (plugin != null && plugin.isHillShadeLayerEnabled()) {
|
if (plugin != null && plugin.isTerrainLayerEnabled()) {
|
||||||
plugin.registerLayers(mapActivity);
|
plugin.registerLayers(mapActivity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ import net.osmand.plus.quickaction.actions.ContourLinesAction;
|
||||||
import net.osmand.plus.quickaction.actions.DayNightModeAction;
|
import net.osmand.plus.quickaction.actions.DayNightModeAction;
|
||||||
import net.osmand.plus.quickaction.actions.FavoriteAction;
|
import net.osmand.plus.quickaction.actions.FavoriteAction;
|
||||||
import net.osmand.plus.quickaction.actions.GPXAction;
|
import net.osmand.plus.quickaction.actions.GPXAction;
|
||||||
import net.osmand.plus.quickaction.actions.HillshadeAction;
|
import net.osmand.plus.quickaction.actions.TerrainAction;
|
||||||
import net.osmand.plus.quickaction.actions.MapOverlayAction;
|
import net.osmand.plus.quickaction.actions.MapOverlayAction;
|
||||||
import net.osmand.plus.quickaction.actions.MapSourceAction;
|
import net.osmand.plus.quickaction.actions.MapSourceAction;
|
||||||
import net.osmand.plus.quickaction.actions.MapStyleAction;
|
import net.osmand.plus.quickaction.actions.MapStyleAction;
|
||||||
|
@ -127,7 +127,7 @@ public class QuickActionFactory {
|
||||||
|
|
||||||
if (OsmandPlugin.getEnabledPlugin(SRTMPlugin.class) != null) {
|
if (OsmandPlugin.getEnabledPlugin(SRTMPlugin.class) != null) {
|
||||||
quickActions.add(new ContourLinesAction());
|
quickActions.add(new ContourLinesAction());
|
||||||
quickActions.add(new HillshadeAction());
|
quickActions.add(new TerrainAction());
|
||||||
}
|
}
|
||||||
|
|
||||||
quickActions.add(new DayNightModeAction());
|
quickActions.add(new DayNightModeAction());
|
||||||
|
@ -265,8 +265,8 @@ public class QuickActionFactory {
|
||||||
case ContourLinesAction.TYPE:
|
case ContourLinesAction.TYPE:
|
||||||
return new ContourLinesAction();
|
return new ContourLinesAction();
|
||||||
|
|
||||||
case HillshadeAction.TYPE:
|
case TerrainAction.TYPE:
|
||||||
return new HillshadeAction();
|
return new TerrainAction();
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return new QuickAction();
|
return new QuickAction();
|
||||||
|
@ -361,8 +361,8 @@ public class QuickActionFactory {
|
||||||
case ContourLinesAction.TYPE:
|
case ContourLinesAction.TYPE:
|
||||||
return new ContourLinesAction(quickAction);
|
return new ContourLinesAction(quickAction);
|
||||||
|
|
||||||
case HillshadeAction.TYPE:
|
case TerrainAction.TYPE:
|
||||||
return new HillshadeAction(quickAction);
|
return new TerrainAction(quickAction);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return quickAction;
|
return quickAction;
|
||||||
|
@ -457,7 +457,7 @@ public class QuickActionFactory {
|
||||||
case ContourLinesAction.TYPE:
|
case ContourLinesAction.TYPE:
|
||||||
return R.drawable.ic_plugin_srtm;
|
return R.drawable.ic_plugin_srtm;
|
||||||
|
|
||||||
case HillshadeAction.TYPE:
|
case TerrainAction.TYPE:
|
||||||
return R.drawable.ic_action_hillshade_dark;
|
return R.drawable.ic_action_hillshade_dark;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -553,8 +553,8 @@ public class QuickActionFactory {
|
||||||
case ContourLinesAction.TYPE:
|
case ContourLinesAction.TYPE:
|
||||||
return R.string.quick_action_show_hide_contour_lines;
|
return R.string.quick_action_show_hide_contour_lines;
|
||||||
|
|
||||||
case HillshadeAction.TYPE:
|
case TerrainAction.TYPE:
|
||||||
return R.string.quick_action_show_hide_hillshade;
|
return R.string.quick_action_show_hide_terrain;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return R.string.quick_action_new_action;
|
return R.string.quick_action_new_action;
|
||||||
|
@ -585,7 +585,7 @@ public class QuickActionFactory {
|
||||||
case DayNightModeAction.TYPE:
|
case DayNightModeAction.TYPE:
|
||||||
case ShowHideGpxTracksAction.TYPE:
|
case ShowHideGpxTracksAction.TYPE:
|
||||||
case ContourLinesAction.TYPE:
|
case ContourLinesAction.TYPE:
|
||||||
case HillshadeAction.TYPE:
|
case TerrainAction.TYPE:
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -18,7 +18,7 @@ import net.osmand.plus.parkingpoint.ParkingPositionPlugin;
|
||||||
import net.osmand.plus.quickaction.actions.AddOSMBugAction;
|
import net.osmand.plus.quickaction.actions.AddOSMBugAction;
|
||||||
import net.osmand.plus.quickaction.actions.AddPOIAction;
|
import net.osmand.plus.quickaction.actions.AddPOIAction;
|
||||||
import net.osmand.plus.quickaction.actions.ContourLinesAction;
|
import net.osmand.plus.quickaction.actions.ContourLinesAction;
|
||||||
import net.osmand.plus.quickaction.actions.HillshadeAction;
|
import net.osmand.plus.quickaction.actions.TerrainAction;
|
||||||
import net.osmand.plus.quickaction.actions.MapSourceAction;
|
import net.osmand.plus.quickaction.actions.MapSourceAction;
|
||||||
import net.osmand.plus.quickaction.actions.MapStyleAction;
|
import net.osmand.plus.quickaction.actions.MapStyleAction;
|
||||||
import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin;
|
import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin;
|
||||||
|
@ -118,7 +118,7 @@ public class QuickActionRegistry {
|
||||||
if (action.type == ContourLinesAction.TYPE) {
|
if (action.type == ContourLinesAction.TYPE) {
|
||||||
skip = true;
|
skip = true;
|
||||||
}
|
}
|
||||||
if (action.type == HillshadeAction.TYPE) {
|
if (action.type == TerrainAction.TYPE) {
|
||||||
skip = true;
|
skip = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,15 +13,15 @@ import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.quickaction.QuickAction;
|
import net.osmand.plus.quickaction.QuickAction;
|
||||||
import net.osmand.plus.srtmplugin.SRTMPlugin;
|
import net.osmand.plus.srtmplugin.SRTMPlugin;
|
||||||
|
|
||||||
public class HillshadeAction extends QuickAction {
|
public class TerrainAction extends QuickAction {
|
||||||
|
|
||||||
public static final int TYPE = 30;
|
public static final int TYPE = 30;
|
||||||
|
|
||||||
public HillshadeAction() {
|
public TerrainAction() {
|
||||||
super(TYPE);
|
super(TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public HillshadeAction(QuickAction quickAction) {
|
public TerrainAction(QuickAction quickAction) {
|
||||||
super(quickAction);
|
super(quickAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,10 +29,10 @@ public class HillshadeAction extends QuickAction {
|
||||||
public void execute(final MapActivity activity) {
|
public void execute(final MapActivity activity) {
|
||||||
final SRTMPlugin plugin = OsmandPlugin.getPlugin(SRTMPlugin.class);
|
final SRTMPlugin plugin = OsmandPlugin.getPlugin(SRTMPlugin.class);
|
||||||
if (plugin != null) {
|
if (plugin != null) {
|
||||||
plugin.toggleHillshade(activity, !plugin.isHillShadeLayerEnabled(), new Runnable() {
|
plugin.toggleTerrain(activity, !plugin.isTerrainLayerEnabled(), new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (plugin.isHillShadeLayerEnabled() && !plugin.isActive() && !plugin.needsInstallation()) {
|
if (plugin.isTerrainLayerEnabled() && !plugin.isActive() && !plugin.needsInstallation()) {
|
||||||
OsmandPlugin.enablePlugin(activity, activity.getMyApplication(), plugin, true);
|
OsmandPlugin.enablePlugin(activity, activity.getMyApplication(), plugin, true);
|
||||||
}
|
}
|
||||||
plugin.updateLayers(activity.getMapView(), activity);
|
plugin.updateLayers(activity.getMapView(), activity);
|
||||||
|
@ -47,7 +47,7 @@ public class HillshadeAction extends QuickAction {
|
||||||
View view = LayoutInflater.from(parent.getContext())
|
View view = LayoutInflater.from(parent.getContext())
|
||||||
.inflate(R.layout.quick_action_with_text, parent, false);
|
.inflate(R.layout.quick_action_with_text, parent, false);
|
||||||
((TextView) view.findViewById(R.id.text))
|
((TextView) view.findViewById(R.id.text))
|
||||||
.setText(R.string.quick_action_hillshade_descr);
|
.setText(R.string.quick_action_terrain_descr);
|
||||||
parent.addView(view);
|
parent.addView(view);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ public class HillshadeAction extends QuickAction {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getActionText(OsmandApplication application) {
|
public String getActionText(OsmandApplication application) {
|
||||||
return application.getSettings().HILLSHADE.get() ? application.getString(R.string.quick_action_hillshade_hide)
|
return application.getSettings().TERRAIN.get() ? application.getString(R.string.quick_action_terrain_hide)
|
||||||
: application.getString(R.string.quick_action_hillshade_show);
|
: application.getString(R.string.quick_action_terrain_show);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -51,7 +51,7 @@ public class HillshadeMenu {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final boolean selected = plugin.isHillShadeLayerEnabled();
|
final boolean selected = plugin.isTerrainLayerEnabled();
|
||||||
final int toggleActionStringId = selected ? R.string.shared_string_on : R.string.shared_string_off;
|
final int toggleActionStringId = selected ? R.string.shared_string_on : R.string.shared_string_off;
|
||||||
|
|
||||||
ContextMenuAdapter.OnRowItemClick l = new ContextMenuAdapter.OnRowItemClick() {
|
ContextMenuAdapter.OnRowItemClick l = new ContextMenuAdapter.OnRowItemClick() {
|
||||||
|
@ -68,7 +68,7 @@ public class HillshadeMenu {
|
||||||
app.runInUIThread(new Runnable() {
|
app.runInUIThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
plugin.toggleHillshade(mapActivity, isChecked, new Runnable() {
|
plugin.toggleTerrain(mapActivity, isChecked, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
mapActivity.getDashboard().refreshContent(true);
|
mapActivity.getDashboard().refreshContent(true);
|
||||||
|
|
|
@ -58,6 +58,9 @@ public class SRTMPlugin extends OsmandPlugin {
|
||||||
public static final String CONTOUR_WIDTH_ATTR = "contourWidth";
|
public static final String CONTOUR_WIDTH_ATTR = "contourWidth";
|
||||||
public static final String CONTOUR_DENSITY_ATTR = "contourDensity";
|
public static final String CONTOUR_DENSITY_ATTR = "contourDensity";
|
||||||
|
|
||||||
|
public static final int TERRAIN_MIN_ZOOM = 3;
|
||||||
|
public static final int TERRAIN_MAX_ZOOM = 19;
|
||||||
|
|
||||||
private OsmandApplication app;
|
private OsmandApplication app;
|
||||||
private OsmandSettings settings;
|
private OsmandSettings settings;
|
||||||
|
|
||||||
|
@ -155,10 +158,6 @@ public class SRTMPlugin extends OsmandPlugin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isHillShadeLayerEnabled() {
|
|
||||||
return settings.HILLSHADE.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isTerrainLayerEnabled() {
|
public boolean isTerrainLayerEnabled() {
|
||||||
return settings.TERRAIN.get();
|
return settings.TERRAIN.get();
|
||||||
}
|
}
|
||||||
|
@ -216,7 +215,7 @@ public class SRTMPlugin extends OsmandPlugin {
|
||||||
case SLOPE:
|
case SLOPE:
|
||||||
return settings.SLOPE_MIN_ZOOM.get();
|
return settings.SLOPE_MIN_ZOOM.get();
|
||||||
}
|
}
|
||||||
return 2;
|
return TERRAIN_MIN_ZOOM;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getTerrainMaxZoom() {
|
public int getTerrainMaxZoom() {
|
||||||
|
@ -226,7 +225,7 @@ public class SRTMPlugin extends OsmandPlugin {
|
||||||
case SLOPE:
|
case SLOPE:
|
||||||
return settings.SLOPE_MAX_ZOOM.get();
|
return settings.SLOPE_MAX_ZOOM.get();
|
||||||
}
|
}
|
||||||
return 19;
|
return TERRAIN_MAX_ZOOM;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isContourLinesLayerEnabled(OsmandApplication app) {
|
public static boolean isContourLinesLayerEnabled(OsmandApplication app) {
|
||||||
|
@ -422,15 +421,6 @@ public class SRTMPlugin extends OsmandPlugin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void toggleHillshade(final MapActivity activity,
|
|
||||||
final boolean isChecked,
|
|
||||||
final Runnable callback) {
|
|
||||||
settings.HILLSHADE.set(isChecked);
|
|
||||||
if (callback != null) {
|
|
||||||
callback.run();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void toggleTerrain(final MapActivity activity,
|
public void toggleTerrain(final MapActivity activity,
|
||||||
final boolean isChecked,
|
final boolean isChecked,
|
||||||
final Runnable callback) {
|
final Runnable callback) {
|
||||||
|
|
|
@ -53,6 +53,8 @@ import static net.osmand.plus.OsmandSettings.TerrainMode.HILLSHADE;
|
||||||
import static net.osmand.plus.OsmandSettings.TerrainMode.SLOPE;
|
import static net.osmand.plus.OsmandSettings.TerrainMode.SLOPE;
|
||||||
import static net.osmand.plus.download.DownloadActivityType.HILLSHADE_FILE;
|
import static net.osmand.plus.download.DownloadActivityType.HILLSHADE_FILE;
|
||||||
import static net.osmand.plus.download.DownloadActivityType.SLOPE_FILE;
|
import static net.osmand.plus.download.DownloadActivityType.SLOPE_FILE;
|
||||||
|
import static net.osmand.plus.srtmplugin.SRTMPlugin.TERRAIN_MAX_ZOOM;
|
||||||
|
import static net.osmand.plus.srtmplugin.SRTMPlugin.TERRAIN_MIN_ZOOM;
|
||||||
|
|
||||||
|
|
||||||
public class TerrainFragment extends BaseOsmAndFragment implements View.OnClickListener,
|
public class TerrainFragment extends BaseOsmAndFragment implements View.OnClickListener,
|
||||||
|
@ -62,9 +64,6 @@ public class TerrainFragment extends BaseOsmAndFragment implements View.OnClickL
|
||||||
private static final Log LOG = PlatformUtil.getLog(TerrainFragment.class.getSimpleName());
|
private static final Log LOG = PlatformUtil.getLog(TerrainFragment.class.getSimpleName());
|
||||||
private static final String SLOPES_WIKI_URL = "https://en.wikipedia.org/wiki/Grade_(slope)";
|
private static final String SLOPES_WIKI_URL = "https://en.wikipedia.org/wiki/Grade_(slope)";
|
||||||
private static final String PLUGIN_URL = "https://osmand.net/features/contour-lines-plugin";
|
private static final String PLUGIN_URL = "https://osmand.net/features/contour-lines-plugin";
|
||||||
private static final int SLIDER_MIN_ZOOM = 3;
|
|
||||||
private static final int SLIDER_MAX_ZOOM = 19;
|
|
||||||
private static final int SLIDER_MIN_TRANSPARENCY = 20;
|
|
||||||
|
|
||||||
private OsmandApplication app;
|
private OsmandApplication app;
|
||||||
private UiUtilities uiUtilities;
|
private UiUtilities uiUtilities;
|
||||||
|
@ -104,10 +103,6 @@ public class TerrainFragment extends BaseOsmAndFragment implements View.OnClickL
|
||||||
|
|
||||||
private ArrayAdapter<ContextMenuItem> listAdapter;
|
private ArrayAdapter<ContextMenuItem> listAdapter;
|
||||||
|
|
||||||
public TerrainFragment() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
app = requireMyApplication();
|
app = requireMyApplication();
|
||||||
|
@ -189,9 +184,9 @@ public class TerrainFragment extends BaseOsmAndFragment implements View.OnClickL
|
||||||
transparencySlider.addOnChangeListener(this);
|
transparencySlider.addOnChangeListener(this);
|
||||||
zoomSlider.addOnChangeListener(this);
|
zoomSlider.addOnChangeListener(this);
|
||||||
transparencySlider.setValueTo(100);
|
transparencySlider.setValueTo(100);
|
||||||
transparencySlider.setValueFrom(SLIDER_MIN_TRANSPARENCY);
|
transparencySlider.setValueFrom(0);
|
||||||
zoomSlider.setValueTo(SLIDER_MAX_ZOOM);
|
zoomSlider.setValueTo(TERRAIN_MAX_ZOOM);
|
||||||
zoomSlider.setValueFrom(SLIDER_MIN_ZOOM);
|
zoomSlider.setValueFrom(TERRAIN_MIN_ZOOM);
|
||||||
|
|
||||||
UiUtilities.setupCompoundButton(switchCompat, nightMode, UiUtilities.CompoundButtonType.PROFILE_DEPENDENT);
|
UiUtilities.setupCompoundButton(switchCompat, nightMode, UiUtilities.CompoundButtonType.PROFILE_DEPENDENT);
|
||||||
|
|
||||||
|
@ -259,10 +254,10 @@ public class TerrainFragment extends BaseOsmAndFragment implements View.OnClickL
|
||||||
private void updateUiMode() {
|
private void updateUiMode() {
|
||||||
TerrainMode mode = srtmPlugin.getTerrainMode();
|
TerrainMode mode = srtmPlugin.getTerrainMode();
|
||||||
if (terrainEnabled) {
|
if (terrainEnabled) {
|
||||||
int transparencyValue = Math.max(srtmPlugin.getTerrainTransparency(), SLIDER_MIN_TRANSPARENCY);
|
int transparencyValue = srtmPlugin.getTerrainTransparency();
|
||||||
String transparency = transparencyValue + "%";
|
String transparency = transparencyValue + "%";
|
||||||
int minZoom = Math.max(srtmPlugin.getTerrainMinZoom(), SLIDER_MIN_ZOOM);
|
int minZoom = Math.max(srtmPlugin.getTerrainMinZoom(), TERRAIN_MIN_ZOOM);
|
||||||
int maxZoom = Math.min(srtmPlugin.getTerrainMaxZoom(), SLIDER_MAX_ZOOM);
|
int maxZoom = Math.min(srtmPlugin.getTerrainMaxZoom(), TERRAIN_MAX_ZOOM);
|
||||||
iconIv.setImageDrawable(uiUtilities.getIcon(R.drawable.ic_action_hillshade_dark, colorProfile));
|
iconIv.setImageDrawable(uiUtilities.getIcon(R.drawable.ic_action_hillshade_dark, colorProfile));
|
||||||
stateTv.setText(R.string.shared_string_enabled);
|
stateTv.setText(R.string.shared_string_enabled);
|
||||||
transparencySlider.setValue(transparencyValue);
|
transparencySlider.setValue(transparencyValue);
|
||||||
|
|
|
@ -19,6 +19,7 @@ import net.osmand.plus.SQLiteTileSource;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.api.SQLiteAPI.SQLiteConnection;
|
import net.osmand.plus.api.SQLiteAPI.SQLiteConnection;
|
||||||
import net.osmand.plus.views.MapTileLayer;
|
import net.osmand.plus.views.MapTileLayer;
|
||||||
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
|
@ -39,9 +40,7 @@ public class TerrainLayer extends MapTileLayer {
|
||||||
private final static String HILLSHADE_CACHE = "hillshade.cache";
|
private final static String HILLSHADE_CACHE = "hillshade.cache";
|
||||||
private final static String SLOPE_CACHE = "slope.cache";
|
private final static String SLOPE_CACHE = "slope.cache";
|
||||||
private int ZOOM_BOUNDARY = 15;
|
private int ZOOM_BOUNDARY = 15;
|
||||||
private final static int MAX_TRANSPARENCY_ZOOM = 17;
|
|
||||||
private final static int DEFAULT_ALPHA = 100;
|
private final static int DEFAULT_ALPHA = 100;
|
||||||
private final static int MAX_TRANSPARENCY_ALPHA = 20;
|
|
||||||
private SRTMPlugin srtmPlugin;
|
private SRTMPlugin srtmPlugin;
|
||||||
private TerrainMode mode;
|
private TerrainMode mode;
|
||||||
|
|
||||||
|
@ -71,7 +70,7 @@ public class TerrainLayer extends MapTileLayer {
|
||||||
private void indexTerrainFiles(final OsmandApplication app) {
|
private void indexTerrainFiles(final OsmandApplication app) {
|
||||||
@SuppressLint("StaticFieldLeak") AsyncTask<Void, Void, Void> task = new AsyncTask<Void, Void, Void>() {
|
@SuppressLint("StaticFieldLeak") AsyncTask<Void, Void, Void> task = new AsyncTask<Void, Void, Void>() {
|
||||||
private SQLiteDatabase sqliteDb;
|
private SQLiteDatabase sqliteDb;
|
||||||
private String type = mode == HILLSHADE ? "hillshade" : "slope";
|
private String type = mode.name().toLowerCase();
|
||||||
@Override
|
@Override
|
||||||
protected Void doInBackground(Void... params) {
|
protected Void doInBackground(Void... params) {
|
||||||
|
|
||||||
|
@ -244,7 +243,7 @@ public class TerrainLayer extends MapTileLayer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return mode == HILLSHADE ? "Hillshade" : "Slope";
|
return Algorithms.capitalizeFirstLetter(mode.name().toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue