diff --git a/OsmAnd/AndroidManifest-free.xml b/OsmAnd/AndroidManifest-free.xml
index 0cc15e429d..873848e1e9 100644
--- a/OsmAnd/AndroidManifest-free.xml
+++ b/OsmAnd/AndroidManifest-free.xml
@@ -20,7 +20,7 @@
android:process="net.osmand"/>
diff --git a/OsmAnd/AndroidManifest-freecustom.xml b/OsmAnd/AndroidManifest-freecustom.xml
index 3b9368a468..66ced1602a 100644
--- a/OsmAnd/AndroidManifest-freecustom.xml
+++ b/OsmAnd/AndroidManifest-freecustom.xml
@@ -18,7 +18,7 @@
android:process="net.osmand.freecustom"
tools:replace="android:process"/>
diff --git a/OsmAnd/AndroidManifest-freedev.xml b/OsmAnd/AndroidManifest-freedev.xml
index 0ef9c72e9c..09ecf8a880 100644
--- a/OsmAnd/AndroidManifest-freedev.xml
+++ b/OsmAnd/AndroidManifest-freedev.xml
@@ -17,7 +17,7 @@
android:process="net.osmand.dev"
tools:replace="android:process"/>
diff --git a/OsmAnd/AndroidManifest-freehuawei.xml b/OsmAnd/AndroidManifest-freehuawei.xml
index 9fe9a01ccf..e96bb7fe47 100644
--- a/OsmAnd/AndroidManifest-freehuawei.xml
+++ b/OsmAnd/AndroidManifest-freehuawei.xml
@@ -13,7 +13,7 @@
+
+ -
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/drawable/btn_border_left_inactive.xml b/OsmAnd/res/drawable/btn_border_left_inactive.xml
new file mode 100644
index 0000000000..a893ccb591
--- /dev/null
+++ b/OsmAnd/res/drawable/btn_border_left_inactive.xml
@@ -0,0 +1,10 @@
+
+
+ -
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/drawable/btn_border_right_active.xml b/OsmAnd/res/drawable/btn_border_right_active.xml
new file mode 100644
index 0000000000..e85a685d58
--- /dev/null
+++ b/OsmAnd/res/drawable/btn_border_right_active.xml
@@ -0,0 +1,10 @@
+
+
+ -
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/drawable/btn_border_right_inactive.xml b/OsmAnd/res/drawable/btn_border_right_inactive.xml
new file mode 100644
index 0000000000..80db8f1230
--- /dev/null
+++ b/OsmAnd/res/drawable/btn_border_right_inactive.xml
@@ -0,0 +1,10 @@
+
+
+ -
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/layout/fragment_terrain.xml b/OsmAnd/res/layout/fragment_terrain.xml
index 0a3e118d59..a42231bf4b 100644
--- a/OsmAnd/res/layout/fragment_terrain.xml
+++ b/OsmAnd/res/layout/fragment_terrain.xml
@@ -3,22 +3,23 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
+ android:animateLayoutChanges="true"
+ android:background="?attr/activity_background_basic"
android:orientation="vertical">
+ android:orientation="horizontal"
+ android:paddingTop="@dimen/content_padding_half"
+ android:paddingBottom="@dimen/content_padding_half">
-
+ tools:background="@drawable/btn_border_left_active">
+ android:text="@string/shared_string_hillshade"
+ android:textSize="@dimen/default_desc_text_size"
+ android:textStyle="bold" />
+ android:layout_weight="1">
+ android:text="@string/shared_string_slope"
+ android:textSize="@dimen/default_desc_text_size"
+ android:textStyle="bold"
+ tools:background="@drawable/btn_border_right_inactive" />
@@ -166,7 +173,7 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -278,11 +352,11 @@
+ android:layout_height="match_parent"
+ android:background="?attr/bg_color"
+ android:orientation="vertical">
+ tools:text="@string/terrain_empty_state_text" />
diff --git a/OsmAnd/res/values/colors.xml b/OsmAnd/res/values/colors.xml
index 093a1fcb38..c13c922373 100644
--- a/OsmAnd/res/values/colors.xml
+++ b/OsmAnd/res/values/colors.xml
@@ -458,4 +458,7 @@
#727272
+ #1A237BFF
+ #80237BFF
+
\ No newline at end of file
diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml
index 7259b518af..06b31fbec3 100644
--- a/OsmAnd/res/values/strings.xml
+++ b/OsmAnd/res/values/strings.xml
@@ -11,6 +11,8 @@
Thx - Hardy
-->
+ Hillshade
+ Turn on to view the layer with shading relief or a map of the slope of the slopes. \n\nYou can find out why such cards are needed and how they work on our website
Legend
Zoom levels
Transparency
@@ -3238,7 +3240,7 @@
Could not calculate route.
Could not calculate route.
The calculated route is empty.
- Route: distance %s, router time %s \nCalculation: %.1f sec, %d roads, %d tiles)
+ Route: distance %s, router time %s \nCalculation: %.1f sec, %d roads, %d tiles)
You have arrived.
Invalid coordinates
Go back to map
diff --git a/OsmAnd/src/net/osmand/plus/srtmplugin/SRTMPlugin.java b/OsmAnd/src/net/osmand/plus/srtmplugin/SRTMPlugin.java
index 04478d42d3..c7b395cc9a 100644
--- a/OsmAnd/src/net/osmand/plus/srtmplugin/SRTMPlugin.java
+++ b/OsmAnd/src/net/osmand/plus/srtmplugin/SRTMPlugin.java
@@ -162,10 +162,18 @@ public class SRTMPlugin extends OsmandPlugin {
return settings.TERRAIN.get();
}
+ public void setTerrainLayerEnabled(boolean enabled) {
+ settings.TERRAIN.set(enabled);
+ }
+
public TerrainMode getTerrainMode() {
return settings.TERRAIN_MODE.get();
}
+ public void setTerrainMode(TerrainMode mode) {
+ settings.TERRAIN_MODE.set(mode);
+ }
+
public static boolean isContourLinesLayerEnabled(OsmandApplication app) {
boolean contourLinesEnabled = false;
diff --git a/OsmAnd/src/net/osmand/plus/srtmplugin/TerrainFragment.java b/OsmAnd/src/net/osmand/plus/srtmplugin/TerrainFragment.java
index 5713129f75..795e9b786a 100644
--- a/OsmAnd/src/net/osmand/plus/srtmplugin/TerrainFragment.java
+++ b/OsmAnd/src/net/osmand/plus/srtmplugin/TerrainFragment.java
@@ -1,12 +1,10 @@
package net.osmand.plus.srtmplugin;
import android.content.Intent;
+import android.graphics.Color;
import android.net.Uri;
+import android.os.Build;
import android.os.Bundle;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-import android.support.v7.widget.AppCompatSeekBar;
-import android.support.v7.widget.SwitchCompat;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.method.LinkMovementMethod;
@@ -14,25 +12,47 @@ import android.text.style.ClickableSpan;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
+import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.appcompat.widget.AppCompatSeekBar;
+import androidx.appcompat.widget.SwitchCompat;
+
+import net.osmand.plus.ContextMenuAdapter;
+import net.osmand.plus.ContextMenuItem;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.OsmandSettings.TerrainMode;
import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
+import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.BaseOsmAndFragment;
+import net.osmand.plus.chooseplan.ChoosePlanDialogFragment;
+import net.osmand.plus.download.DownloadActivityType;
+import net.osmand.plus.download.DownloadIndexesThread;
+import net.osmand.plus.download.DownloadResources;
+import net.osmand.plus.download.DownloadValidationManager;
+import net.osmand.plus.download.IndexItem;
import net.osmand.plus.inapp.InAppPurchaseHelper;
-public class TerrainFragment extends BaseOsmAndFragment {
+import java.io.IOException;
+import java.util.List;
+
+import static net.osmand.plus.srtmplugin.ContourLinesMenu.closeDashboard;
+
+public class TerrainFragment extends BaseOsmAndFragment implements View.OnClickListener {
public static final String TAG = TerrainFragment.class.getSimpleName();
- private static final String SLOPES_WIKI_URL = "";
- private static final String PLUGIN_URL = "";
+ // TODO replace with correct string
+ private static final String SLOPES_WIKI_URL = "https://osmand.net/features/contour-lines-plugin";
+ private static final String PLUGIN_URL = "https://osmand.net/features/contour-lines-plugin";
private OsmandApplication app;
private UiUtilities uiUtilities;
@@ -51,11 +71,16 @@ public class TerrainFragment extends BaseOsmAndFragment {
private TextView descriptionTv;
private TextView titleTv;
private TextView stateTv;
+ private TextView slopeBtn;
+ private TextView hillshadeBtn;
+ private FrameLayout slopeBtnContainer;
+ private FrameLayout hillshadeBtnContainer;
private SwitchCompat switchCompat;
private ImageView iconIv;
private LinearLayout legendContainer;
private LinearLayout emptyState;
private LinearLayout contentContainer;
+ private LinearLayout downloadContainer;
private View legendTopDivider;
private View legendBottomDivider;
private View titleBottomDivider;
@@ -100,22 +125,56 @@ public class TerrainFragment extends BaseOsmAndFragment {
titleTv = root.findViewById(R.id.title_tv);
stateTv = root.findViewById(R.id.state_tv);
iconIv = root.findViewById(R.id.icon_iv);
+ slopeBtn = root.findViewById(R.id.slope_btn);
+ hillshadeBtn = root.findViewById(R.id.hillshade_btn);
+ slopeBtnContainer = root.findViewById(R.id.slope_btn_container);
+ hillshadeBtnContainer = root.findViewById(R.id.hillshade_btn_container);
+ downloadContainer = root.findViewById(R.id.download_container);
- setupClickableText(emptyStateDescriptionTv,
- String.format(getString(R.string.slope_read_more), PLUGIN_URL),
- PLUGIN_URL,
- PLUGIN_URL);
-
- adjustUiMode();
+ titleTv.setText(R.string.shared_string_terrain);
+ String emptyStateText = String.format(
+ getString(R.string.ltr_or_rtl_combine_via_colon),
+ getString(R.string.terrain_empty_state_text),
+ PLUGIN_URL
+ );
+ setupClickableText(emptyStateDescriptionTv, emptyStateText, PLUGIN_URL, PLUGIN_URL);
+ String wikiString = getString(R.string.shared_string_wikipedia);
+ String readMoreText = String.format(
+ getString(R.string.slope_read_more),
+ wikiString
+ );
+ setupClickableText(slopeReadMoreTv, readMoreText, wikiString, SLOPES_WIKI_URL);
+ switchCompat.setChecked(terrainEnabled);
+ switchCompat.setOnClickListener(this);
+ slopeBtn.setOnClickListener(this);
+ hillshadeBtn.setOnClickListener(this);
+ updateUiMode();
return root;
}
- private void adjustUiMode() {
+ @Override
+ public void onClick(View view) {
+ switch (view.getId()) {
+ case R.id.switch_compat:
+ onSwitchClick();
+ break;
+ case R.id.hillshade_btn:
+ setupTerrainMode(TerrainMode.HILLSHADE);
+ break;
+ case R.id.slope_btn:
+ setupTerrainMode(TerrainMode.SLOPE);
+ break;
+ default:
+ break;
+ }
+ }
+
+ private void updateUiMode() {
TerrainMode mode = srtmPlugin.getTerrainMode();
if (terrainEnabled) {
iconIv.setImageDrawable(uiUtilities.getIcon(R.drawable.ic_action_hillshade_dark, colorProfile));
- stateTv.setText(R.string.shared_string_enable);
+ stateTv.setText(R.string.shared_string_enabled);
switch (mode) {
case HILLSHADE:
descriptionTv.setText(R.string.hillshade_description);
@@ -124,11 +183,6 @@ public class TerrainFragment extends BaseOsmAndFragment {
case SLOPE:
descriptionTv.setText(R.string.slope_description);
downloadDescriptionTv.setText(R.string.slope_download_description);
- String wikiString = getString(R.string.shared_string_wikipedia);
- setupClickableText(slopeReadMoreTv,
- String.format(getString(R.string.slope_read_more), wikiString),
- wikiString,
- SLOPES_WIKI_URL);
break;
}
} else {
@@ -141,6 +195,7 @@ public class TerrainFragment extends BaseOsmAndFragment {
}
adjustGlobalVisibility();
adjustLegendVisibility(mode);
+ adjustModeButtons(mode);
}
private void adjustGlobalVisibility() {
@@ -156,6 +211,28 @@ public class TerrainFragment extends BaseOsmAndFragment {
legendTopDivider.setVisibility(visibility);
}
+ private void adjustModeButtons(TerrainMode mode) {
+ if (TerrainMode.SLOPE.equals(mode)) {
+ slopeBtnContainer.setBackgroundResource(R.drawable.btn_border_right_active);
+ slopeBtn.setTextColor(nightMode
+ ? getResources().getColor(R.color.text_color_primary_dark)
+ : getResources().getColor(R.color.text_color_primary_light));
+ hillshadeBtnContainer.setBackgroundResource(R.drawable.btn_border_left_inactive);
+ hillshadeBtn.setTextColor(nightMode
+ ? getResources().getColor(R.color.active_color_primary_dark)
+ : getResources().getColor(R.color.active_color_primary_light));
+ } else {
+ slopeBtnContainer.setBackgroundResource(R.drawable.btn_border_right_inactive);
+ slopeBtn.setTextColor(nightMode
+ ? getResources().getColor(R.color.active_color_primary_dark)
+ : getResources().getColor(R.color.active_color_primary_light));
+ hillshadeBtnContainer.setBackgroundResource(R.drawable.btn_border_left_active);
+ hillshadeBtn.setTextColor(nightMode
+ ? getResources().getColor(R.color.text_color_primary_dark)
+ : getResources().getColor(R.color.text_color_primary_light));
+ }
+ }
+
private void setupClickableText(TextView textView,
String text,
String clickableText,
@@ -181,4 +258,21 @@ public class TerrainFragment extends BaseOsmAndFragment {
// LOG.error("Error trying to find index of " + clickableText + " " + e);
}
}
+
+ private void onSwitchClick() {
+ terrainEnabled = !terrainEnabled;
+ switchCompat.setChecked(terrainEnabled);
+ srtmPlugin.setTerrainLayerEnabled(terrainEnabled);
+ updateUiMode();
+ }
+
+ private void setupTerrainMode(TerrainMode mode) {
+ TerrainMode currentMode = srtmPlugin.getTerrainMode();
+ if (!currentMode.equals(mode)) {
+ srtmPlugin.setTerrainMode(mode);
+ updateUiMode();
+ }
+ }
+
}
+