terrain ui, update material version, field box

This commit is contained in:
veliymolfar 2020-03-05 19:59:00 +02:00
parent 82264be1d7
commit 91f9268abf
15 changed files with 266 additions and 45 deletions

View file

@ -20,7 +20,7 @@
android:process="net.osmand"/>
<provider
android:name="android.support.v4.content.FileProvider"
android:name="androidx.core.content.FileProvider"
tools:replace="android:authorities"
android:authorities="net.osmand.fileprovider"/>
</application>

View file

@ -18,7 +18,7 @@
android:process="net.osmand.freecustom"
tools:replace="android:process"/>
<provider
android:name="android.support.v4.content.FileProvider"
android:name="androidx.core.content.FileProvider"
android:authorities="net.osmand.freecustom.fileprovider"
tools:replace="android:authorities"/>
</application>

View file

@ -17,7 +17,7 @@
android:process="net.osmand.dev"
tools:replace="android:process"/>
<provider
android:name="android.support.v4.content.FileProvider"
android:name="androidx.core.content.FileProvider"
android:authorities="net.osmand.dev.fileprovider"
tools:replace="android:authorities"/>
</application>

View file

@ -13,7 +13,7 @@
</activity>
<provider
android:name="android.support.v4.content.FileProvider"
android:name="androidx.core.content.FileProvider"
android:authorities="net.osmand.huawei.fileprovider"
tools:replace="android:authorities" />
<service

View file

@ -13,7 +13,7 @@
</activity>
<provider
android:name="android.support.v4.content.FileProvider"
android:name="androidx.core.content.FileProvider"
android:authorities="net.osmand.plus.huawei.fileprovider"
tools:replace="android:authorities" />
<service

View file

@ -459,7 +459,7 @@ dependencies {
implementation 'androidx.gridlayout:gridlayout:1.0.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'com.google.android.material:material:1.2.0-alpha05'
implementation 'androidx.browser:browser:1.0.0'
implementation 'androidx.preference:preference:1.1.0'
implementation fileTree(include: ['gnu-trove-osmand.jar', 'icu4j-49_1_patched.jar'], dir: 'libs')
@ -495,7 +495,7 @@ dependencies {
exclude group: 'com.android.support'
}
implementation 'com.github.PhilJay:MPAndroidChart:v3.0.1'
implementation ("com.github.HITGIF:TextFieldBoxes:1.3.5"){
implementation ("com.github.HITGIF:TextFieldBoxes:1.4.5"){
exclude group: 'com.android.support'
}

View file

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="@color/terrain_active_button" />
<corners android:bottomLeftRadius="4dp" android:topLeftRadius="4dp" />
<stroke android:width="1dp" android:color="@color/terrain_active_button_stroke" />
</shape>
</item>
</selector>

View file

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="@android:color/transparent" />
<corners android:bottomLeftRadius="4dp" android:topLeftRadius="4dp" />
<stroke android:width="1dp" android:color="?attr/secondary_icon_color" />
</shape>
</item>
</selector>

View file

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="@color/terrain_active_button" />
<corners android:bottomRightRadius="4dp" android:topRightRadius="4dp" />
<stroke android:width="1dp" android:color="@color/terrain_active_button_stroke" />
</shape>
</item>
</selector>

View file

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="@android:color/transparent" />
<corners android:bottomRightRadius="4dp" android:topRightRadius="4dp" />
<stroke android:width="1dp" android:color="?attr/secondary_icon_color" />
</shape>
</item>
</selector>

View file

@ -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">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/activity_background_basic"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/content_padding_half"
android:paddingBottom="@dimen/content_padding_half"
android:background="?attr/bg_color"
android:gravity="center_vertical"
android:orientation="horizontal">
android:orientation="horizontal"
android:paddingTop="@dimen/content_padding_half"
android:paddingBottom="@dimen/content_padding_half">
<ImageView
android:id="@+id/icon_iv"
@ -54,7 +55,7 @@
</LinearLayout>
<android.support.v7.widget.SwitchCompat
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/switch_compat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@ -88,34 +89,40 @@
android:orientation="horizontal">
<FrameLayout
android:id="@+id/hillshade_btn_container"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="?attr/dlg_btn_primary">
tools:background="@drawable/btn_border_left_active">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/hillshade_tv"
android:id="@+id/hillshade_btn"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/selectableItemBackground"
android:gravity="center"
tools:text="Hillshade" />
android:text="@string/shared_string_hillshade"
android:textSize="@dimen/default_desc_text_size"
android:textStyle="bold" />
</FrameLayout>
<FrameLayout
android:id="@+id/slope_btn_container"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="?attr/dlg_btn_primary">
android:layout_weight="1">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/slope_tv"
android:id="@+id/slope_btn"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/selectableItemBackground"
android:gravity="center"
tools:text="Slope" />
android:text="@string/shared_string_slope"
android:textSize="@dimen/default_desc_text_size"
android:textStyle="bold"
tools:background="@drawable/btn_border_right_inactive" />
</FrameLayout>
@ -166,7 +173,7 @@
</LinearLayout>
<android.support.v7.widget.AppCompatSeekBar
<androidx.appcompat.widget.AppCompatSeekBar
android:id="@+id/transparency_slider"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -191,6 +198,67 @@
android:textColor="@color/preference_category_title"
android:textSize="@dimen/default_desc_text_size" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="@dimen/content_padding">
<net.osmand.plus.widgets.TextViewEx
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="start"
android:text="Min"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size" />
<net.osmand.plus.widgets.TextViewEx
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="end"
android:text="Max"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingStart="@dimen/content_padding"
android:paddingEnd="@dimen/content_padding">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/zoom_value_min"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="start"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_desc_text_size"
tools:text="3" />
<com.google.android.material.slider.Slider
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/content_padding"
android:layout_marginEnd="@dimen/content_padding"
android:layout_weight="1" />
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/zoom_value_max"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_desc_text_size"
tools:text="19" />
</LinearLayout>
<net.osmand.plus.widgets.TextViewEx
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -266,6 +334,12 @@
android:textSize="@dimen/default_desc_text_size"
tools:text="@string/hillshade_download_description" />
<LinearLayout
android:id="@+id/download_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" />
</LinearLayout>
<include layout="@layout/card_bottom_divider" />
@ -278,11 +352,11 @@
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:id="@+id/empty_state"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:visibility="gone">
android:layout_height="match_parent"
android:background="?attr/bg_color"
android:orientation="vertical">
<ImageView
android:id="@+id/empty_state_image"
@ -296,7 +370,7 @@
android:layout_margin="@dimen/content_padding"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_desc_text_size"
tools:text="Включите для просмотра слоя с затенениями рельефа или картой уклона склонов. О том зачем нужные такие карты и как они работают, вы можете узнать на нашем сайте: https://osmand.net/features/contour-lines-plugin *" />
tools:text="@string/terrain_empty_state_text" />
</LinearLayout>

View file

@ -458,4 +458,7 @@
<color name="profile_icon_color_inactive">#727272</color>
<color name="terrain_active_button">#1A237BFF</color>
<color name="terrain_active_button_stroke">#80237BFF</color>
</resources>

View file

@ -11,6 +11,8 @@
Thx - Hardy
-->
<string name="shared_string_hillshade">Hillshade</string>
<string name="terrain_empty_state_text">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</string>
<string name="shared_string_legend">Legend</string>
<string name="shared_string_zoom_levels">Zoom levels</string>
<string name="shared_string_transparency">Transparency</string>
@ -3238,7 +3240,7 @@
<string name="error_calculating_route">Could not calculate route.</string>
<string name="error_calculating_route_occured">Could not calculate route.</string>
<string name="empty_route_calculated">The calculated route is empty.</string>
<string name="new_route_calculated_dist_dbg">Route: distance %s, router time %s \nCalculation: %.1f sec, %d roads, %d tiles)</string>
<string name="new_route_calculated_dist_dbg" formatted="false">Route: distance %s, router time %s \nCalculation: %.1f sec, %d roads, %d tiles)</string>
<string name="arrived_at_destination">You have arrived.</string>
<string name="invalid_locations">Invalid coordinates</string>
<string name="go_back_to_osmand">Go back to map</string>

View file

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

View file

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