This commit is contained in:
androiddevkkotlin 2020-12-04 15:39:44 +02:00
parent 8b74ded620
commit d405a20c3e
4 changed files with 31 additions and 33 deletions

View file

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:osmand="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
@ -16,7 +15,7 @@
tools:background="?android:attr/selectableItemBackground">
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/icon_elevation"
android:id="@+id/icon"
android:layout_width="@dimen/standard_icon_size"
android:layout_height="@dimen/standard_icon_size"
android:layout_gravity="center_vertical"
@ -28,11 +27,6 @@
android:layout_marginBottom="@dimen/bottom_sheet_icon_margin"
osmand:srcCompat="@drawable/ic_action_altitude_average" />
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/icon"
android:layout_width="1dp"
android:layout_height="1dp" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
@ -41,7 +35,7 @@
android:orientation="vertical">
<net.osmand.plus.widgets.TextViewEx
android:id="@android:id/title"
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
@ -53,7 +47,7 @@
osmand:typeface="@string/font_roboto_regular" />
<net.osmand.plus.widgets.TextViewEx
android:id="@android:id/summary"
android:id="@+id/description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:letterSpacing="@dimen/description_letter_spacing"

View file

@ -50,7 +50,6 @@ import net.osmand.plus.settings.backend.CommonPreference;
import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.settings.bottomsheets.ElevationDateBottomSheet;
import net.osmand.plus.settings.fragments.BaseSettingsFragment;
import net.osmand.plus.widgets.TextViewEx;
import net.osmand.router.GeneralRouter;
import net.osmand.router.GeneralRouter.RoutingParameter;
import net.osmand.util.Algorithms;
@ -264,16 +263,9 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
final BottomSheetItemWithCompoundButton[] item = new BottomSheetItemWithCompoundButton[1];
final boolean active = !useHeightPref.getModeValue(applicationMode);
final View itemView = UiUtilities.getInflater(app, nightMode).inflate(
R.layout.elevation_preference, null, false);
final ImageView iconView = itemView.findViewById(R.id.icon_elevation);
R.layout.bottom_sheet_item_with_switch_and_dialog, null, false);
final SwitchCompat switchButton = itemView.findViewById(R.id.switchWidget);
int selectedModeColor = ContextCompat.getColor(app, selectedModeColorId);
iconView.setImageDrawable(getContentIcon(active ?
optionsItem.getActiveIconId() : optionsItem.getDisabledIconId()));
TextView title = itemView.findViewById(android.R.id.title);
title.setText(getString(R.string.routing_attr_height_obstacles_name));
final TextView description = itemView.findViewById(android.R.id.summary);
description.setText(getString(R.string.routing_attr_height_obstacles_name));
View itemsContainer = itemView.findViewById(R.id.selectable_list_item);
switchButton.setChecked(!active);
switchButton.setFocusable(false);
@ -297,6 +289,10 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
});
item[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder()
.setCompoundButtonColorId(selectedModeColorId)
.setDescription(getString(R.string.routing_attr_height_obstacles_name))
.setIcon(getContentIcon(active ? optionsItem.getActiveIconId() : optionsItem.getDisabledIconId()))
.setTitle(getString(R.string.routing_attr_height_obstacles_name))
.setCustomView(itemView)
.create();

View file

@ -74,7 +74,6 @@ public class ElevationDateBottomSheet extends MenuBottomSheetDialogFragment {
appMode = ApplicationMode.valueOfStringKey(savedInstanceState.getString(APP_MODE_KEY), null);
}
super.onCreate(savedInstanceState);
setDismissButtonTextId(R.string.shared_string_close);
Map<String, RoutingParameter> routingParameterMap = app.getRouter(appMode).getParameters();
RoutingParameter parameter = routingParameterMap.get(USE_HEIGHT_OBSTACLES);
@ -91,6 +90,11 @@ public class ElevationDateBottomSheet extends MenuBottomSheetDialogFragment {
}
}
@Override
protected int getDismissButtonTextId() {
return R.string.shared_string_close;
}
@Override
public void createMenuItems(Bundle savedInstanceState) {
Context themedCtx = UiUtilities.getThemedContext(requireContext(), nightMode);
@ -178,7 +182,7 @@ public class ElevationDateBottomSheet extends MenuBottomSheetDialogFragment {
((BaseSettingsFragment) target).updateSetting(useHeightPref.getId());
}
updateReliefButtons();
new Handler().postDelayed(new Runnable() {
app.runInUIThread(new Runnable() {
@Override
public void run() {
dismiss();

View file

@ -290,19 +290,7 @@ public class RouteParametersFragment extends BaseSettingsFragment implements OnP
switchPreferenceEx.setIcon(getRoutingPrefIcon(p.getId()));
screen.addPreference(switchPreferenceEx);
if (USE_HEIGHT_OBSTACLES.equals(p.getId()) && !Algorithms.isEmpty(reliefFactorParameters)) {
String summaryOn = getString(R.string.shared_string_enabled);
for (RoutingParameter parameter : reliefFactorParameters) {
if (isRoutingParameterSelected(settings, am, parameter)) {
summaryOn = getString(R.string.ltr_or_rtl_combine_via_comma, summaryOn, getRoutingParameterTitle(app, parameter));
}
}
switchPreferenceEx.setSummaryOn(summaryOn);
switchPreferenceEx.setSummaryOff(R.string.shared_string_disabled);
} else {
switchPreferenceEx.setSummaryOn(R.string.shared_string_on);
switchPreferenceEx.setSummaryOff(R.string.shared_string_off);
}
setupOtherBooleanParameterSummary(app, am, p, switchPreferenceEx);
} else {
Object[] vls = p.getPossibleValues();
String[] svlss = new String[vls.length];
@ -352,6 +340,22 @@ public class RouteParametersFragment extends BaseSettingsFragment implements OnP
setupFastRecalculationPref();
}
private void setupOtherBooleanParameterSummary(OsmandApplication app, ApplicationMode am, RoutingParameter p, SwitchPreferenceEx switchPreferenceEx) {
if (USE_HEIGHT_OBSTACLES.equals(p.getId()) && !Algorithms.isEmpty(reliefFactorParameters)) {
String summaryOn = getString(R.string.shared_string_enabled);
for (RoutingParameter parameter : reliefFactorParameters) {
if (isRoutingParameterSelected(settings, am, parameter)) {
summaryOn = getString(R.string.ltr_or_rtl_combine_via_comma, summaryOn, getRoutingParameterTitle(app, parameter));
}
}
switchPreferenceEx.setSummaryOn(summaryOn);
switchPreferenceEx.setSummaryOff(R.string.shared_string_disabled);
} else {
switchPreferenceEx.setSummaryOn(R.string.shared_string_on);
switchPreferenceEx.setSummaryOff(R.string.shared_string_off);
}
}
private void addDivider(PreferenceScreen screen) {
Preference divider = new Preference(requireContext());
divider.setLayoutResource(R.layout.simple_divider_item);