Fix custom radio button

This commit is contained in:
Dima-1 2020-08-06 15:40:19 +03:00
parent fff9a415d5
commit 04e7a8a0d7
7 changed files with 139 additions and 168 deletions

View file

@ -0,0 +1,70 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:osmand="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/custom_radio_buttons"
android:layout_width="match_parent"
android:layout_height="@dimen/dialog_button_height"
android:layout_marginStart="@dimen/content_padding"
android:layout_marginEnd="@dimen/content_padding"
android:background="?attr/btn_bg_border_inactive"
android:baselineAligned="false"
android:orientation="horizontal"
tools:showIn="@layout/fragment_route_between_points_bottom_sheet_dialog">
<FrameLayout
android:id="@+id/left_button_container"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/left_button"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/selectableItemBackground"
android:gravity="center"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_medium"
tools:text="@string/shared_string_left"/>
</FrameLayout>
<FrameLayout
android:id="@+id/center_button_container"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:visibility="gone">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/center_button"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/selectableItemBackground"
android:gravity="center"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_medium"
tools:text="@string/position_on_map_center"/>
</FrameLayout>
<FrameLayout
android:id="@+id/right_button_container"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/right_button"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/selectableItemBackground"
android:gravity="center"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_medium"
tools:text="@string/shared_string_right"/>
</FrameLayout>
</LinearLayout>

View file

@ -45,52 +45,7 @@
android:letterSpacing="@dimen/description_letter_spacing" android:letterSpacing="@dimen/description_letter_spacing"
android:textSize="@dimen/default_desc_text_size" /> android:textSize="@dimen/default_desc_text_size" />
<LinearLayout <include layout="@layout/custom_radio_buttons" />
android:layout_width="match_parent"
android:layout_height="@dimen/dialog_button_height"
android:layout_marginStart="@dimen/content_padding"
android:layout_marginEnd="@dimen/content_padding"
android:background="?attr/btn_bg_border_inactive"
android:baselineAligned="false"
android:orientation="horizontal">
<FrameLayout
android:id="@+id/next_segment_btn_container"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/next_segment_btn"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/selectableItemBackground"
android:gravity="center"
android:text="@string/next_segment"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_medium" />
</FrameLayout>
<FrameLayout
android:id="@+id/whole_track_btn_container"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/whole_track_btn"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/selectableItemBackground"
android:gravity="center"
android:text="@string/whole_track"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_medium" />
</FrameLayout>
</LinearLayout>
<net.osmand.plus.widgets.TextViewEx <net.osmand.plus.widgets.TextViewEx
android:id="@+id/button_description" android:id="@+id/button_description"

View file

@ -92,52 +92,7 @@
android:background="?attr/bg_color" android:background="?attr/bg_color"
android:orientation="vertical"> android:orientation="vertical">
<LinearLayout <include layout="@layout/custom_radio_buttons" />
android:layout_width="match_parent"
android:layout_height="@dimen/dialog_button_height"
android:layout_marginStart="@dimen/content_padding"
android:layout_marginEnd="@dimen/content_padding"
android:background="?attr/btn_bg_border_inactive"
android:baselineAligned="false"
android:orientation="horizontal">
<FrameLayout
android:id="@+id/hillshade_btn_container"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/hillshade_btn"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/selectableItemBackground"
android:gravity="center"
android:text="@string/shared_string_hillshade"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_medium" />
</FrameLayout>
<FrameLayout
android:id="@+id/slope_btn_container"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/slope_btn"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/selectableItemBackground"
android:gravity="center"
android:text="@string/shared_string_slope"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_medium" />
</FrameLayout>
</LinearLayout>
<net.osmand.plus.widgets.TextViewEx <net.osmand.plus.widgets.TextViewEx
android:id="@+id/description" android:id="@+id/description"

View file

@ -3761,7 +3761,7 @@
<string name="terrain_slider_description">Поставите минимални и максимални ниво зума, при коме ће слој бити приказан.</string> <string name="terrain_slider_description">Поставите минимални и максимални ниво зума, при коме ће слој бити приказан.</string>
<string name="hillshade_download_description">Додатне мапе су потребне да бисте видели сенке брда на мапи.</string> <string name="hillshade_download_description">Додатне мапе су потребне да бисте видели сенке брда на мапи.</string>
<string name="slope_download_description">Додатне мапе су потребне да бисте видели нагибе на мапи.</string> <string name="slope_download_description">Додатне мапе су потребне да бисте видели нагибе на мапи.</string>
<string name="slope_read_more">Можете прочитати више о нагибима у %1$е.</string> <string name="slope_read_more">Можете прочитати више о нагибима у %1$s.</string>
<string name="terrain_empty_state_text">Омогућите да би видели сенке брда или мапе нагиба. Можете прочитати више о овим врстама карта на нашем сајту.</string> <string name="terrain_empty_state_text">Омогућите да би видели сенке брда или мапе нагиба. Можете прочитати више о овим врстама карта на нашем сајту.</string>
<string name="import_complete_description">Сви подаци %1$S су увезени, можете да употребите дугмад испод да би сте отворили неопходни део апликације ради управљања њима.</string> <string name="import_complete_description">Сви подаци %1$S су увезени, можете да употребите дугмад испод да би сте отворили неопходни део апликације ради управљања њима.</string>
<string name="checking_for_duplicate_description">Османд проверава %1$S постојање дупликата са постојећим елементима у апликацији. <string name="checking_for_duplicate_description">Османд проверава %1$S постојање дупликата са постојећим елементима у апликацији.

View file

@ -6,6 +6,7 @@ import android.graphics.Color;
import android.graphics.Typeface; import android.graphics.Typeface;
import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.graphics.drawable.LayerDrawable; import android.graphics.drawable.LayerDrawable;
import android.graphics.drawable.RippleDrawable; import android.graphics.drawable.RippleDrawable;
import android.hardware.Sensor; import android.hardware.Sensor;
@ -89,6 +90,11 @@ public class UiUtilities {
TOOLBAR TOOLBAR
} }
public enum CustomRadioButtonType {
LEFT,
RIGHT,
}
public UiUtilities(OsmandApplication app) { public UiUtilities(OsmandApplication app) {
this.app = app; this.app = app;
} }
@ -437,11 +443,44 @@ public class UiUtilities {
image.setRotationY(rotation); image.setRotationY(rotation);
} }
public static void updateCustomRadioButtons(Context app, View buttonsView, boolean nightMode,
CustomRadioButtonType buttonType) {
int activeColor = ContextCompat.getColor(app, nightMode
? R.color.active_color_primary_dark
: R.color.active_color_primary_light);
int textColor = ContextCompat.getColor(app, nightMode
? R.color.text_color_primary_dark
: R.color.text_color_primary_light);
int radius = AndroidUtils.dpToPx(app, 4);
TextView leftButtonText = buttonsView.findViewById(R.id.left_button);
View leftButtonContainer = buttonsView.findViewById(R.id.left_button_container);
TextView rightButtonText = buttonsView.findViewById(R.id.right_button);
View rightButtonContainer = buttonsView.findViewById(R.id.right_button_container);
GradientDrawable background = new GradientDrawable();
background.setColor(UiUtilities.getColorWithAlpha(activeColor, 0.1f));
background.setStroke(AndroidUtils.dpToPx(app, 1), UiUtilities.getColorWithAlpha(activeColor, 0.5f));
if (buttonType == CustomRadioButtonType.LEFT) {
background.setCornerRadii(new float[]{radius, radius, 0, 0, 0, 0, radius, radius});
rightButtonContainer.setBackgroundColor(Color.TRANSPARENT);
rightButtonText.setTextColor(activeColor);
leftButtonContainer.setBackgroundDrawable(background);
leftButtonText.setTextColor(textColor);
} else {
background.setCornerRadii(new float[]{0, 0, radius, radius, radius, radius, 0, 0});
rightButtonContainer.setBackgroundDrawable(background);
rightButtonText.setTextColor(textColor);
leftButtonContainer.setBackgroundColor(Color.TRANSPARENT);
leftButtonText.setTextColor(activeColor);
}
}
public static void setupCompoundButtonDrawable(Context ctx, boolean nightMode, @ColorInt int activeColor, Drawable drawable) { public static void setupCompoundButtonDrawable(Context ctx, boolean nightMode, @ColorInt int activeColor, Drawable drawable) {
int inactiveColor = ContextCompat.getColor(ctx, nightMode ? R.color.icon_color_default_dark : R.color.icon_color_default_light); int inactiveColor = ContextCompat.getColor(ctx, nightMode ? R.color.icon_color_default_dark : R.color.icon_color_default_light);
int[][] states = new int[][] { int[][] states = new int[][]{
new int[] {-android.R.attr.state_checked}, new int[]{-android.R.attr.state_checked},
new int[] {android.R.attr.state_checked} new int[]{android.R.attr.state_checked}
}; };
ColorStateList csl = new ColorStateList(states, new int[]{inactiveColor, activeColor}); ColorStateList csl = new ColorStateList(states, new int[]{inactiveColor, activeColor});
DrawableCompat.setTintList(DrawableCompat.wrap(drawable), csl); DrawableCompat.setTintList(DrawableCompat.wrap(drawable), csl);

View file

@ -1,16 +1,13 @@
package net.osmand.plus.measurementtool; package net.osmand.plus.measurementtool;
import android.app.Dialog; import android.app.Dialog;
import android.graphics.Color;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.os.Bundle; import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.Window; import android.view.Window;
import android.view.WindowManager; import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.RadioButton; import android.widget.RadioButton;
@ -18,7 +15,6 @@ import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity; import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentManager;
@ -38,6 +34,7 @@ import org.apache.commons.logging.Log;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import static net.osmand.plus.UiUtilities.CustomRadioButtonType.*;
import static net.osmand.plus.measurementtool.MeasurementEditingContext.CalculationType.NEXT_SEGMENT; import static net.osmand.plus.measurementtool.MeasurementEditingContext.CalculationType.NEXT_SEGMENT;
import static net.osmand.plus.measurementtool.MeasurementEditingContext.CalculationType.WHOLE_TRACK; import static net.osmand.plus.measurementtool.MeasurementEditingContext.CalculationType.WHOLE_TRACK;
@ -52,14 +49,12 @@ public class RouteBetweenPointsBottomSheetDialogFragment extends BottomSheetDial
private boolean nightMode; private boolean nightMode;
private boolean portrait; private boolean portrait;
private boolean snapToRoadEnabled; private boolean snapToRoadEnabled;
private TextView segmentBtn;
private TextView wholeTrackBtn;
private TextView btnDescription; private TextView btnDescription;
private FrameLayout segmentBtnContainer;
private FrameLayout wholeTrackBtnContainer;
private CalculationType calculationType = WHOLE_TRACK; private CalculationType calculationType = WHOLE_TRACK;
private ApplicationMode snapToRoadAppMode; private ApplicationMode snapToRoadAppMode;
private LinearLayout customRadioButton;
@Nullable @Nullable
@Override @Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
@ -87,10 +82,12 @@ public class RouteBetweenPointsBottomSheetDialogFragment extends BottomSheetDial
dismiss(); dismiss();
} }
}); });
segmentBtnContainer = mainView.findViewById(R.id.next_segment_btn_container);
segmentBtn = mainView.findViewById(R.id.next_segment_btn); customRadioButton = mainView.findViewById(R.id.custom_radio_buttons);
wholeTrackBtnContainer = mainView.findViewById(R.id.whole_track_btn_container); TextView segmentBtn = mainView.findViewById(R.id.left_button);
wholeTrackBtn = mainView.findViewById(R.id.whole_track_btn); segmentBtn.setText(R.string.next_segment);
TextView wholeTrackBtn = mainView.findViewById(R.id.right_button);
wholeTrackBtn.setText(R.string.whole_track);
btnDescription = mainView.findViewById(R.id.button_description); btnDescription = mainView.findViewById(R.id.button_description);
LinearLayout navigationType = mainView.findViewById(R.id.navigation_types_container); LinearLayout navigationType = mainView.findViewById(R.id.navigation_types_container);
@ -144,39 +141,18 @@ public class RouteBetweenPointsBottomSheetDialogFragment extends BottomSheetDial
View row = UiUtilities.getInflater(getContext(), nightMode).inflate(R.layout.divider, container, false); View row = UiUtilities.getInflater(getContext(), nightMode).inflate(R.layout.divider, container, false);
View divider = row.findViewById(R.id.divider); View divider = row.findViewById(R.id.divider);
ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) divider.getLayoutParams(); ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) divider.getLayoutParams();
params.topMargin = container.getContext().getResources().getDimensionPixelSize(R.dimen.bottom_sheet_title_padding_bottom); params.topMargin = row.getResources().getDimensionPixelSize(R.dimen.bottom_sheet_title_padding_bottom);
params.bottomMargin = container.getContext().getResources().getDimensionPixelSize(R.dimen.bottom_sheet_title_padding_bottom); params.bottomMargin = row.getResources().getDimensionPixelSize(R.dimen.bottom_sheet_title_padding_bottom);
container.addView(row); container.addView(row);
} }
private void updateModeButtons(CalculationType calculationType) { private void updateModeButtons(CalculationType calculationType) {
OsmandApplication app = requiredMyApplication();
int activeColor = ContextCompat.getColor(app, nightMode
? R.color.active_color_primary_dark
: R.color.active_color_primary_light);
int textColor = ContextCompat.getColor(app, nightMode
? R.color.text_color_primary_dark
: R.color.text_color_primary_light);
int radius = AndroidUtils.dpToPx(app, 4);
GradientDrawable background = new GradientDrawable();
background.setColor(UiUtilities.getColorWithAlpha(activeColor, 0.1f));
background.setStroke(AndroidUtils.dpToPx(app, 1), UiUtilities.getColorWithAlpha(activeColor, 0.5f));
if (calculationType == NEXT_SEGMENT) { if (calculationType == NEXT_SEGMENT) {
background.setCornerRadii(new float[]{radius, radius, 0, 0, 0, 0, radius, radius}); UiUtilities.updateCustomRadioButtons(getMyApplication(), customRadioButton, nightMode, LEFT);
wholeTrackBtnContainer.setBackgroundColor(Color.TRANSPARENT);
wholeTrackBtn.setTextColor(activeColor);
segmentBtnContainer.setBackgroundDrawable(background);
segmentBtn.setTextColor(textColor);
btnDescription.setText(R.string.rourte_between_points_next_segment_button_desc); btnDescription.setText(R.string.rourte_between_points_next_segment_button_desc);
} else { } else {
background.setCornerRadii(new float[]{0, 0, radius, radius, radius, radius, 0, 0});
wholeTrackBtnContainer.setBackgroundDrawable(background);
wholeTrackBtn.setTextColor(textColor);
segmentBtnContainer.setBackgroundColor(Color.TRANSPARENT);
segmentBtn.setTextColor(activeColor);
btnDescription.setText(R.string.rourte_between_points_whole_track_button_desc); btnDescription.setText(R.string.rourte_between_points_whole_track_button_desc);
UiUtilities.updateCustomRadioButtons(getMyApplication(), customRadioButton, nightMode, RIGHT);
} }
setCalculationType(calculationType); setCalculationType(calculationType);
Fragment fragment = getTargetFragment(); Fragment fragment = getTargetFragment();

View file

@ -2,8 +2,6 @@ package net.osmand.plus.srtmplugin;
import android.app.Activity; import android.app.Activity;
import android.content.Intent; import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.GradientDrawable;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.text.SpannableString; import android.text.SpannableString;
@ -16,7 +14,6 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.FrameLayout;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
@ -55,6 +52,7 @@ import java.io.IOException;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import java.util.List; import java.util.List;
import static net.osmand.plus.UiUtilities.CustomRadioButtonType.*;
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.settings.backend.OsmandSettings.TerrainMode.HILLSHADE; import static net.osmand.plus.settings.backend.OsmandSettings.TerrainMode.HILLSHADE;
@ -84,13 +82,10 @@ public class TerrainFragment extends BaseOsmAndFragment implements View.OnClickL
private TextView downloadDescriptionTv; private TextView downloadDescriptionTv;
private TextView transparencyValueTv; private TextView transparencyValueTv;
private TextView descriptionTv; private TextView descriptionTv;
private TextView hillshadeBtn; private LinearLayout customRadioButton;
private TextView minZoomTv; private TextView minZoomTv;
private TextView maxZoomTv; private TextView maxZoomTv;
private TextView slopeBtn;
private TextView stateTv; private TextView stateTv;
private FrameLayout hillshadeBtnContainer;
private FrameLayout slopeBtnContainer;
private SwitchCompat switchCompat; private SwitchCompat switchCompat;
private ImageView iconIv; private ImageView iconIv;
private LinearLayout emptyState; private LinearLayout emptyState;
@ -176,14 +171,13 @@ public class TerrainFragment extends BaseOsmAndFragment implements View.OnClickL
emptyState = root.findViewById(R.id.empty_state); emptyState = root.findViewById(R.id.empty_state);
stateTv = root.findViewById(R.id.state_tv); stateTv = root.findViewById(R.id.state_tv);
iconIv = root.findViewById(R.id.icon_iv); iconIv = root.findViewById(R.id.icon_iv);
slopeBtn = root.findViewById(R.id.slope_btn);
zoomSlider = root.findViewById(R.id.zoom_slider); zoomSlider = root.findViewById(R.id.zoom_slider);
minZoomTv = root.findViewById(R.id.zoom_value_min); minZoomTv = root.findViewById(R.id.zoom_value_min);
maxZoomTv = root.findViewById(R.id.zoom_value_max); maxZoomTv = root.findViewById(R.id.zoom_value_max);
hillshadeBtn = root.findViewById(R.id.hillshade_btn); customRadioButton = root.findViewById(R.id.custom_radio_buttons);
slopeBtnContainer = root.findViewById(R.id.slope_btn_container); TextView hillshadeBtn = root.findViewById(R.id.left_button);
TextView slopeBtn = root.findViewById(R.id.right_button);
downloadContainer = root.findViewById(R.id.download_container); downloadContainer = root.findViewById(R.id.download_container);
hillshadeBtnContainer = root.findViewById(R.id.hillshade_btn_container);
downloadTopDivider = root.findViewById(R.id.download_container_top_divider); downloadTopDivider = root.findViewById(R.id.download_container_top_divider);
downloadBottomDivider = root.findViewById(R.id.download_container_bottom_divider); downloadBottomDivider = root.findViewById(R.id.download_container_bottom_divider);
observableListView = (ObservableListView) root.findViewById(R.id.list_view); observableListView = (ObservableListView) root.findViewById(R.id.list_view);
@ -205,8 +199,10 @@ public class TerrainFragment extends BaseOsmAndFragment implements View.OnClickL
switchCompat.setChecked(terrainEnabled); switchCompat.setChecked(terrainEnabled);
hillshadeBtn.setOnClickListener(this); hillshadeBtn.setOnClickListener(this);
hillshadeBtn.setText(R.string.shared_string_hillshade);
switchCompat.setOnClickListener(this); switchCompat.setOnClickListener(this);
slopeBtn.setOnClickListener(this); slopeBtn.setOnClickListener(this);
slopeBtn.setText(R.string.shared_string_slope);
UiUtilities.setupSlider(transparencySlider, nightMode, colorProfile); UiUtilities.setupSlider(transparencySlider, nightMode, colorProfile);
UiUtilities.setupSlider(zoomSlider, nightMode, colorProfile, true); UiUtilities.setupSlider(zoomSlider, nightMode, colorProfile, true);
@ -230,10 +226,10 @@ public class TerrainFragment extends BaseOsmAndFragment implements View.OnClickL
case R.id.switch_compat: case R.id.switch_compat:
onSwitchClick(); onSwitchClick();
break; break;
case R.id.hillshade_btn: case R.id.left_button:
setupTerrainMode(HILLSHADE); setupTerrainMode(HILLSHADE);
break; break;
case R.id.slope_btn: case R.id.right_button:
setupTerrainMode(SLOPE); setupTerrainMode(SLOPE);
break; break;
default: default:
@ -294,30 +290,10 @@ public class TerrainFragment extends BaseOsmAndFragment implements View.OnClickL
} }
private void adjustModeButtons(TerrainMode mode) { private void adjustModeButtons(TerrainMode mode) {
int activeColor = ContextCompat.getColor(app, nightMode
? R.color.active_color_primary_dark
: R.color.active_color_primary_light);
int textColor = ContextCompat.getColor(app, nightMode
? R.color.text_color_primary_dark
: R.color.text_color_primary_light);
int radius = AndroidUtils.dpToPx(app, 4);
GradientDrawable background = new GradientDrawable();
background.setColor(UiUtilities.getColorWithAlpha(activeColor, 0.1f));
background.setStroke(AndroidUtils.dpToPx(app, 1), UiUtilities.getColorWithAlpha(activeColor, 0.5f));
if (mode == SLOPE) { if (mode == SLOPE) {
background.setCornerRadii(new float[]{0, 0, radius, radius, radius, radius, 0, 0}); UiUtilities.updateCustomRadioButtons(app, customRadioButton, nightMode, RIGHT);
slopeBtnContainer.setBackgroundDrawable(background);
slopeBtn.setTextColor(textColor);
hillshadeBtnContainer.setBackgroundColor(Color.TRANSPARENT);
hillshadeBtn.setTextColor(activeColor);
} else { } else {
background.setCornerRadii(new float[]{radius, radius, 0, 0, 0, 0, radius, radius}); UiUtilities.updateCustomRadioButtons(app, customRadioButton, nightMode, LEFT);
slopeBtnContainer.setBackgroundColor(Color.TRANSPARENT);
slopeBtn.setTextColor(activeColor);
hillshadeBtnContainer.setBackgroundDrawable(background);
hillshadeBtn.setTextColor(textColor);
} }
} }