Merge pull request #7577 from osmandapp/ProfileSettingsImprovements
Profile settings UI improvements
This commit is contained in:
commit
b1edd88daa
21 changed files with 350 additions and 93 deletions
7
OsmAnd/res/drawable/rectangle_rounded_right.xml
Normal file
7
OsmAnd/res/drawable/rectangle_rounded_right.xml
Normal file
|
@ -0,0 +1,7 @@
|
|||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<corners
|
||||
android:bottomRightRadius="@dimen/list_item_button_padding"
|
||||
android:topRightRadius="@dimen/list_item_button_padding" />
|
||||
<solid android:color="@color/list_background_color_dark" />
|
||||
</shape>
|
11
OsmAnd/res/drawable/ripple_rectangle_rounded_right.xml
Normal file
11
OsmAnd/res/drawable/ripple_rectangle_rounded_right.xml
Normal file
|
@ -0,0 +1,11 @@
|
|||
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:color="@color/active_buttons_and_links_trans_light">
|
||||
<item android:id="@android:id/mask">
|
||||
<shape android:shape="rectangle">
|
||||
<corners
|
||||
android:bottomRightRadius="@dimen/list_item_button_padding"
|
||||
android:topRightRadius="@dimen/list_item_button_padding" />
|
||||
<solid android:color="@color/active_color_primary_light" />
|
||||
</shape>
|
||||
</item>
|
||||
</ripple>
|
16
OsmAnd/res/layout/bottom_sheet_item_preference_descr.xml
Normal file
16
OsmAnd/res/layout/bottom_sheet_item_preference_descr.xml
Normal file
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<net.osmand.plus.widgets.TextViewEx xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/description"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="@dimen/bottom_sheet_list_item_height"
|
||||
android:paddingLeft="@dimen/content_padding"
|
||||
android:paddingTop="@dimen/bottom_sheet_image_text_margin_start"
|
||||
android:paddingRight="@dimen/content_padding"
|
||||
android:paddingBottom="@dimen/gpx_small_text_margin"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textSize="@dimen/default_desc_text_size"
|
||||
app:typeface="@string/font_roboto_regular"
|
||||
tools:text="@string/auto_zoom_map_descr" />
|
45
OsmAnd/res/layout/bottom_sheet_item_preference_switch.xml
Normal file
45
OsmAnd/res/layout/bottom_sheet_item_preference_switch.xml
Normal file
|
@ -0,0 +1,45 @@
|
|||
<?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:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/button_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/content_padding"
|
||||
android:layout_marginRight="@dimen/content_padding"
|
||||
android:minHeight="@dimen/bottom_sheet_list_item_height"
|
||||
android:paddingLeft="@dimen/content_padding"
|
||||
android:paddingRight="@dimen/content_padding"
|
||||
tools:background="@drawable/rectangle_rounded_right">
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/title"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:textAppearance="@style/TextAppearance.ListItemTitle"
|
||||
android:textColor="?attr/active_color_basic"
|
||||
app:typeface="@string/font_roboto_medium"
|
||||
tools:text="Some Title" />
|
||||
|
||||
<android.support.v7.widget.SwitchCompat
|
||||
android:id="@+id/compound_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical|end"
|
||||
android:background="@null"
|
||||
android:clickable="false"
|
||||
android:focusable="false"
|
||||
android:focusableInTouchMode="false" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
|
@ -4,35 +4,35 @@
|
|||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/dashboard_map_toolbar"
|
||||
android:background="@color/app_bar_color_light"
|
||||
app:contentInsetLeft="4dp"
|
||||
app:contentInsetStart="4dp">
|
||||
android:layout_height="@dimen/toolbar_height"
|
||||
android:background="@color/icon_color_osmand_light"
|
||||
app:contentInsetLeft="0dp"
|
||||
app:contentInsetStart="0dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/close_button"
|
||||
style="@style/Widget.AppCompat.Toolbar.Button.Navigation"
|
||||
android:layout_width="56dp"
|
||||
android:layout_height="56dp"
|
||||
android:layout_width="@dimen/toolbar_height"
|
||||
android:layout_height="@dimen/toolbar_height"
|
||||
android:contentDescription="@string/access_shared_string_navigate_up"
|
||||
android:src="@drawable/ic_action_mode_back" />
|
||||
|
||||
<TextView
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/toolbar_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="left"
|
||||
android:scaleType="center"
|
||||
android:textColor="@color/abc_primary_text_material_dark"
|
||||
android:textSize="@dimen/abc_text_size_large_material"
|
||||
tools:text="Toolbar"
|
||||
tools:visibility="visible" />
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingLeft="@dimen/content_padding"
|
||||
android:paddingRight="@dimen/content_padding"
|
||||
android:textColor="?attr/app_bar_primary_item_color"
|
||||
android:textSize="@dimen/dialog_header_text_size"
|
||||
app:typeface="@string/font_roboto_medium"
|
||||
tools:text="@string/routing_settings_2" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/ProgressBar"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="right"
|
||||
android:visibility="gone" />
|
||||
</LinearLayout>
|
||||
|
||||
</android.support.v7.widget.Toolbar>
|
27
OsmAnd/res/layout/settings_device_image_screen.xml
Normal file
27
OsmAnd/res/layout/settings_device_image_screen.xml
Normal file
|
@ -0,0 +1,27 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/activity_background_color"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/device_image"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
tools:background="@drawable/img_settings_device_bottom_light"
|
||||
tools:src="@drawable/img_settings_sreen_route_parameters" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/warning_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="@dimen/local_size_height"
|
||||
android:layout_marginEnd="@dimen/fab_size_with_shadow"
|
||||
android:layout_marginRight="@dimen/fab_size_with_shadow"
|
||||
tools:src="@drawable/warnings_pedestrian" />
|
||||
|
||||
</FrameLayout>
|
|
@ -2,6 +2,12 @@
|
|||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<Preference
|
||||
android:key="route_parameters_image"
|
||||
android:layout="@layout/settings_device_image_screen"
|
||||
android:persistent="false"
|
||||
android:selectable="false" />
|
||||
|
||||
<Preference
|
||||
android:key="route_parameters_info"
|
||||
android:layout="@layout/preference_info"
|
||||
|
|
|
@ -8,6 +8,12 @@
|
|||
android:summaryOff="@string/shared_string_off"
|
||||
android:summaryOn="@string/shared_string_on" />
|
||||
|
||||
<Preference
|
||||
android:key="screen_alerts_image"
|
||||
android:layout="@layout/settings_device_image_screen"
|
||||
android:persistent="false"
|
||||
android:selectable="false" />
|
||||
|
||||
<Preference
|
||||
android:key="show_routing_alarms_info"
|
||||
android:layout="@layout/preference_info"
|
||||
|
|
|
@ -81,6 +81,8 @@ public class OsmandSettings {
|
|||
void removeListener(StateChangedListener<T> listener);
|
||||
|
||||
boolean isSet();
|
||||
|
||||
boolean isSetForMode(ApplicationMode m);
|
||||
}
|
||||
|
||||
private abstract class PreferenceWithListener<T> implements OsmandPreference<T> {
|
||||
|
@ -326,13 +328,12 @@ public class OsmandSettings {
|
|||
|
||||
// this value string is synchronized with settings_pref.xml preference name
|
||||
public final OsmandPreference<ApplicationMode> APPLICATION_MODE = new PreferenceWithListener<ApplicationMode>() {
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return "application_mode";
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
@Override
|
||||
public ApplicationMode get() {
|
||||
return currentMode;
|
||||
|
@ -348,14 +349,15 @@ public class OsmandSettings {
|
|||
set(ApplicationMode.DEFAULT);
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
@Override
|
||||
public boolean isSet() {
|
||||
return true;
|
||||
}
|
||||
|
||||
;
|
||||
@Override
|
||||
public boolean isSetForMode(ApplicationMode m) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean set(ApplicationMode val) {
|
||||
|
@ -582,6 +584,9 @@ public class OsmandSettings {
|
|||
return settingsAPI.contains(getPreferences(), getId());
|
||||
}
|
||||
|
||||
public boolean isSetForMode(ApplicationMode mode) {
|
||||
return settingsAPI.contains(getProfilePreferences(mode), getId());
|
||||
}
|
||||
}
|
||||
|
||||
public class BooleanPreference extends CommonPreference<Boolean> {
|
||||
|
|
|
@ -85,9 +85,14 @@ public class UiUtilities {
|
|||
return getDrawable(id, colorId);
|
||||
}
|
||||
|
||||
public Drawable getIcon(@DrawableRes int backgroundId, @DrawableRes int id, @ColorRes int colorId) {
|
||||
Drawable b = getDrawable(backgroundId, 0);
|
||||
Drawable f = getDrawable(id, colorId);
|
||||
public Drawable getLayeredIcon(@DrawableRes int bgIconId, @DrawableRes int foregroundIconId) {
|
||||
return getLayeredIcon(bgIconId, foregroundIconId, 0, 0);
|
||||
}
|
||||
|
||||
public Drawable getLayeredIcon(@DrawableRes int bgIconId, @DrawableRes int foregroundIconId,
|
||||
@ColorRes int bgColorId, @ColorRes int foregroundColorId) {
|
||||
Drawable b = getDrawable(bgIconId, bgColorId);
|
||||
Drawable f = getDrawable(foregroundIconId, foregroundColorId);
|
||||
Drawable[] layers = new Drawable[2];
|
||||
layers[0] = b;
|
||||
layers[1] = f;
|
||||
|
|
|
@ -164,26 +164,19 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
|
|||
|
||||
@Override
|
||||
public void onDisplayPreferenceDialog(Preference preference) {
|
||||
FragmentManager fragmentManager = getFragmentManager();
|
||||
if (fragmentManager == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (preference instanceof ListPreferenceEx) {
|
||||
FragmentManager fragmentManager = getFragmentManager();
|
||||
if (fragmentManager != null) {
|
||||
SingleSelectPreferenceBottomSheet.showInstance(fragmentManager, preference.getKey(), this);
|
||||
}
|
||||
SingleSelectPreferenceBottomSheet.showInstance(fragmentManager, preference.getKey(), this, false);
|
||||
} else if (preference instanceof SwitchPreferenceEx) {
|
||||
FragmentManager fragmentManager = getFragmentManager();
|
||||
if (fragmentManager != null) {
|
||||
BooleanPreferenceBottomSheet.showInstance(fragmentManager, preference.getKey(), this);
|
||||
}
|
||||
BooleanPreferenceBottomSheet.showInstance(fragmentManager, preference.getKey(), this, false);
|
||||
} else if (preference instanceof EditTextPreference) {
|
||||
FragmentManager fragmentManager = getFragmentManager();
|
||||
if (fragmentManager != null) {
|
||||
EditTextPreferenceBottomSheet.showInstance(fragmentManager, preference.getKey(), this);
|
||||
}
|
||||
EditTextPreferenceBottomSheet.showInstance(fragmentManager, preference.getKey(), this, false);
|
||||
} else if (preference instanceof MultiSelectBooleanPreference) {
|
||||
FragmentManager fragmentManager = getFragmentManager();
|
||||
if (fragmentManager != null) {
|
||||
MultiSelectPreferencesBottomSheet.showInstance(getFragmentManager(), preference.getKey(), this);
|
||||
}
|
||||
MultiSelectPreferencesBottomSheet.showInstance(fragmentManager, preference.getKey(), this, false);
|
||||
} else {
|
||||
super.onDisplayPreferenceDialog(preference);
|
||||
}
|
||||
|
|
|
@ -180,7 +180,7 @@ public class CoordinatesFormatFragment extends BaseSettingsFragment {
|
|||
if (newFormat != -1) {
|
||||
FragmentManager fragmentManager = getFragmentManager();
|
||||
if (fragmentManager != null) {
|
||||
ChangeGeneralProfilesPrefBottomSheet.showInstance(fragmentManager, settings.COORDINATES_FORMAT.getId(), newFormat, this);
|
||||
ChangeGeneralProfilesPrefBottomSheet.showInstance(fragmentManager, settings.COORDINATES_FORMAT.getId(), newFormat, this, false);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,8 +68,8 @@ public class GeneralProfileSettingsFragment extends BaseSettingsFragment {
|
|||
|
||||
private void setupAppThemePref() {
|
||||
final ListPreferenceEx appTheme = (ListPreferenceEx) findPreference(settings.OSMAND_THEME.getId());
|
||||
appTheme.setEntries(new String[]{getString(R.string.dark_theme), getString(R.string.light_theme)});
|
||||
appTheme.setEntryValues(new Integer[]{OsmandSettings.OSMAND_DARK_THEME, OsmandSettings.OSMAND_LIGHT_THEME});
|
||||
appTheme.setEntries(new String[] {getString(R.string.dark_theme), getString(R.string.light_theme)});
|
||||
appTheme.setEntryValues(new Integer[] {OsmandSettings.OSMAND_DARK_THEME, OsmandSettings.OSMAND_LIGHT_THEME});
|
||||
appTheme.setIcon(getOsmandThemeIcon());
|
||||
}
|
||||
|
||||
|
@ -79,8 +79,8 @@ public class GeneralProfileSettingsFragment extends BaseSettingsFragment {
|
|||
|
||||
private void setupRotateMapPref() {
|
||||
final ListPreferenceEx rotateMap = (ListPreferenceEx) findPreference(settings.ROTATE_MAP.getId());
|
||||
rotateMap.setEntries(new String[]{getString(R.string.rotate_map_none_opt), getString(R.string.rotate_map_bearing_opt), getString(R.string.rotate_map_compass_opt)});
|
||||
rotateMap.setEntryValues(new Integer[]{OsmandSettings.ROTATE_MAP_NONE, OsmandSettings.ROTATE_MAP_BEARING, OsmandSettings.ROTATE_MAP_COMPASS});
|
||||
rotateMap.setEntries(new String[] {getString(R.string.rotate_map_none_opt), getString(R.string.rotate_map_bearing_opt), getString(R.string.rotate_map_compass_opt)});
|
||||
rotateMap.setEntryValues(new Integer[] {OsmandSettings.ROTATE_MAP_NONE, OsmandSettings.ROTATE_MAP_BEARING, OsmandSettings.ROTATE_MAP_COMPASS});
|
||||
rotateMap.setIcon(getRotateMapIcon());
|
||||
}
|
||||
|
||||
|
@ -97,8 +97,8 @@ public class GeneralProfileSettingsFragment extends BaseSettingsFragment {
|
|||
|
||||
private void setupMapScreenOrientationPref() {
|
||||
final ListPreferenceEx mapScreenOrientation = (ListPreferenceEx) findPreference(settings.MAP_SCREEN_ORIENTATION.getId());
|
||||
mapScreenOrientation.setEntries(new String[]{getString(R.string.map_orientation_portrait), getString(R.string.map_orientation_landscape), getString(R.string.map_orientation_default)});
|
||||
mapScreenOrientation.setEntryValues(new Integer[]{ActivityInfo.SCREEN_ORIENTATION_PORTRAIT, ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE, ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED});
|
||||
mapScreenOrientation.setEntries(new String[] {getString(R.string.map_orientation_portrait), getString(R.string.map_orientation_landscape), getString(R.string.map_orientation_default)});
|
||||
mapScreenOrientation.setEntryValues(new Integer[] {ActivityInfo.SCREEN_ORIENTATION_PORTRAIT, ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE, ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED});
|
||||
mapScreenOrientation.setIcon(getMapScreenOrientationIcon());
|
||||
}
|
||||
|
||||
|
@ -185,14 +185,14 @@ public class GeneralProfileSettingsFragment extends BaseSettingsFragment {
|
|||
|
||||
private void setupExternalInputDevicePref() {
|
||||
ListPreferenceEx externalInputDevice = (ListPreferenceEx) findPreference(settings.EXTERNAL_INPUT_DEVICE.getId());
|
||||
externalInputDevice.setEntries(new String[]{
|
||||
externalInputDevice.setEntries(new String[] {
|
||||
getString(R.string.sett_no_ext_input),
|
||||
getString(R.string.sett_generic_ext_input),
|
||||
getString(R.string.sett_wunderlinq_ext_input),
|
||||
getString(R.string.sett_parrot_ext_input)
|
||||
});
|
||||
|
||||
externalInputDevice.setEntryValues(new Integer[]{
|
||||
externalInputDevice.setEntryValues(new Integer[] {
|
||||
OsmandSettings.NO_EXTERNAL_DEVICE,
|
||||
OsmandSettings.GENERIC_EXTERNAL_DEVICE,
|
||||
OsmandSettings.WUNDERLINQ_EXTERNAL_DEVICE,
|
||||
|
@ -279,10 +279,15 @@ public class GeneralProfileSettingsFragment extends BaseSettingsFragment {
|
|||
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
OsmandSettings.OsmandPreference pref = settings.getPreference(preference.getKey());
|
||||
if (pref != null && !pref.isSetForMode(getSelectedAppMode())) {
|
||||
FragmentManager fragmentManager = getFragmentManager();
|
||||
if (fragmentManager != null) {
|
||||
ChangeGeneralProfilesPrefBottomSheet.showInstance(fragmentManager, preference.getKey(), newValue, this);
|
||||
ChangeGeneralProfilesPrefBottomSheet.showInstance(fragmentManager, preference.getKey(), newValue, this, false);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,9 +1,13 @@
|
|||
package net.osmand.plus.settings;
|
||||
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.support.v14.preference.SwitchPreference;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.PreferenceScreen;
|
||||
import android.support.v7.preference.PreferenceViewHolder;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
|
@ -34,6 +38,8 @@ public class RouteParametersFragment extends BaseSettingsFragment {
|
|||
|
||||
private static final String AVOID_ROUTING_PARAMETER_PREFIX = "avoid_";
|
||||
private static final String PREFER_ROUTING_PARAMETER_PREFIX = "prefer_";
|
||||
private static final String ROUTE_PARAMETERS_INFO = "route_parameters_info";
|
||||
private static final String ROUTE_PARAMETERS_IMAGE = "route_parameters_image";
|
||||
private static final String RELIEF_SMOOTHNESS_FACTOR = "relief_smoothness_factor";
|
||||
|
||||
private List<GeneralRouter.RoutingParameter> avoidParameters = new ArrayList<GeneralRouter.RoutingParameter>();
|
||||
|
@ -58,7 +64,9 @@ public class RouteParametersFragment extends BaseSettingsFragment {
|
|||
|
||||
@Override
|
||||
protected void setupPreferences() {
|
||||
Preference vehicleParametersInfo = findPreference("route_parameters_info");
|
||||
setupRouteParametersImage();
|
||||
|
||||
Preference vehicleParametersInfo = findPreference(ROUTE_PARAMETERS_INFO);
|
||||
vehicleParametersInfo.setIcon(getContentIcon(R.drawable.ic_action_info_dark));
|
||||
vehicleParametersInfo.setTitle(getString(R.string.route_parameters_info, getSelectedAppMode().toHumanString(getContext())));
|
||||
|
||||
|
@ -66,6 +74,35 @@ public class RouteParametersFragment extends BaseSettingsFragment {
|
|||
setupTimeConditionalRoutingPref();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onBindPreferenceViewHolder(Preference preference, PreferenceViewHolder holder) {
|
||||
super.onBindPreferenceViewHolder(preference, holder);
|
||||
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) {
|
||||
return;
|
||||
}
|
||||
String key = preference.getKey();
|
||||
if (ROUTE_PARAMETERS_INFO.equals(key)) {
|
||||
int colorRes = isNightMode() ? R.color.activity_background_color_dark : R.color.activity_background_color_light;
|
||||
holder.itemView.setBackgroundColor(ContextCompat.getColor(app, colorRes));
|
||||
} else if (ROUTE_PARAMETERS_IMAGE.equals(key)) {
|
||||
ImageView imageView = (ImageView) holder.itemView.findViewById(R.id.device_image);
|
||||
if (imageView != null) {
|
||||
int bgResId = isNightMode() ? R.drawable.img_settings_device_bottom_dark : R.drawable.img_settings_device_bottom_light;
|
||||
Drawable layerDrawable = app.getUIUtilities().getLayeredIcon(bgResId, R.drawable.img_settings_sreen_route_parameters);
|
||||
|
||||
imageView.setImageDrawable(layerDrawable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setupRouteParametersImage() {
|
||||
Preference routeParametersImage = findPreference(ROUTE_PARAMETERS_IMAGE);
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) {
|
||||
routeParametersImage.setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
private void setupTimeConditionalRoutingPref() {
|
||||
SwitchPreference timeConditionalRouting = createSwitchPreferenceEx(settings.ENABLE_TIME_CONDITIONAL_ROUTING.getId(), R.string.temporary_conditional_routing, R.layout.preference_with_descr_dialog_and_switch);
|
||||
timeConditionalRouting.setIcon(getRoutingPrefIcon(settings.ENABLE_TIME_CONDITIONAL_ROUTING.getId()));
|
||||
|
|
|
@ -1,18 +1,24 @@
|
|||
package net.osmand.plus.settings;
|
||||
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.support.v14.preference.SwitchPreference;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.PreferenceGroupAdapter;
|
||||
import android.support.v7.preference.PreferenceViewHolder;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.plus.R;
|
||||
|
||||
public class ScreenAlertsFragment extends BaseSettingsFragment {
|
||||
|
||||
public static final String TAG = "ScreenAlertsFragment";
|
||||
|
||||
private static final String SHOW_ROUTING_ALARMS_INFO = "show_routing_alarms_info";
|
||||
private static final String SCREEN_ALERTS_IMAGE = "screen_alerts_image";
|
||||
|
||||
@Override
|
||||
protected int getPreferencesResId() {
|
||||
return R.xml.screen_alerts;
|
||||
|
@ -30,7 +36,7 @@ public class ScreenAlertsFragment extends BaseSettingsFragment {
|
|||
|
||||
@Override
|
||||
protected void setupPreferences() {
|
||||
Preference showRoutingAlarmsInfo = findPreference("show_routing_alarms_info");
|
||||
Preference showRoutingAlarmsInfo = findPreference(SHOW_ROUTING_ALARMS_INFO);
|
||||
SwitchPreference showTrafficWarnings = (SwitchPreference) findPreference(settings.SHOW_TRAFFIC_WARNINGS.getId());
|
||||
SwitchPreference showPedestrian = (SwitchPreference) findPreference(settings.SHOW_PEDESTRIAN.getId());
|
||||
SwitchPreference showCameras = (SwitchPreference) findPreference(settings.SHOW_CAMERAS.getId());
|
||||
|
@ -41,17 +47,69 @@ public class ScreenAlertsFragment extends BaseSettingsFragment {
|
|||
showPedestrian.setIcon(getIcon(R.drawable.list_warnings_pedestrian));
|
||||
showCameras.setIcon(getIcon(R.drawable.list_warnings_speed_camera));
|
||||
showTunnels.setIcon(getIcon(R.drawable.list_warnings_tunnel));
|
||||
|
||||
setupScreenAlertsImage();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onBindPreferenceViewHolder(Preference preference, PreferenceViewHolder holder) {
|
||||
super.onBindPreferenceViewHolder(preference, holder);
|
||||
|
||||
if (settings.SHOW_ROUTING_ALARMS.getId().equals(preference.getKey())) {
|
||||
String key = preference.getKey();
|
||||
if (settings.SHOW_ROUTING_ALARMS.getId().equals(key)) {
|
||||
boolean checked = ((SwitchPreference) preference).isChecked();
|
||||
int color = checked ? getActiveProfileColor() : ContextCompat.getColor(app, R.color.preference_top_switch_off);
|
||||
|
||||
AndroidUtils.setBackground(holder.itemView, new ColorDrawable(color));
|
||||
holder.itemView.setBackgroundColor(color);
|
||||
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
|
||||
if (SHOW_ROUTING_ALARMS_INFO.equals(key)) {
|
||||
int colorRes = isNightMode() ? R.color.activity_background_color_dark : R.color.activity_background_color_light;
|
||||
holder.itemView.setBackgroundColor(ContextCompat.getColor(app, colorRes));
|
||||
} else if (SCREEN_ALERTS_IMAGE.equals(key)) {
|
||||
ImageView deviceImage = (ImageView) holder.itemView.findViewById(R.id.device_image);
|
||||
ImageView warningIcon = (ImageView) holder.itemView.findViewById(R.id.warning_icon);
|
||||
|
||||
deviceImage.setImageDrawable(getDeviceImage());
|
||||
warningIcon.setImageDrawable(getWarningIcon());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("RestrictedApi")
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
|
||||
Preference routeParametersImage = findPreference(SCREEN_ALERTS_IMAGE);
|
||||
((PreferenceGroupAdapter) getListView().getAdapter()).onPreferenceChange(routeParametersImage);
|
||||
}
|
||||
|
||||
return super.onPreferenceClick(preference);
|
||||
}
|
||||
|
||||
private void setupScreenAlertsImage() {
|
||||
Preference routeParametersImage = findPreference(SCREEN_ALERTS_IMAGE);
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) {
|
||||
routeParametersImage.setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
private Drawable getDeviceImage() {
|
||||
int bgResId = isNightMode() ? R.drawable.img_settings_device_bottom_dark : R.drawable.img_settings_device_bottom_light;
|
||||
return app.getUIUtilities().getLayeredIcon(bgResId, R.drawable.img_settings_sreen_route_alerts);
|
||||
}
|
||||
|
||||
private Drawable getWarningIcon() {
|
||||
boolean americanSigns = settings.DRIVING_REGION.get().americanSigns;
|
||||
if (settings.SHOW_TRAFFIC_WARNINGS.get()) {
|
||||
return getIcon(americanSigns ? R.drawable.warnings_traffic_calming_us : R.drawable.warnings_traffic_calming);
|
||||
} else if (settings.SHOW_PEDESTRIAN.get()) {
|
||||
return getIcon(americanSigns ? R.drawable.warnings_pedestrian_us : R.drawable.warnings_pedestrian);
|
||||
} else if (settings.SHOW_CAMERAS.get()) {
|
||||
return getIcon(R.drawable.warnings_speed_camera);
|
||||
} else if (settings.SHOW_TUNNELS.get()) {
|
||||
return getIcon(americanSigns ? R.drawable.warnings_tunnel_us : R.drawable.warnings_tunnel);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,17 +1,23 @@
|
|||
package net.osmand.plus.settings.bottomsheets;
|
||||
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.LayerDrawable;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.view.ContextThemeWrapper;
|
||||
import android.view.View;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.OsmandSettings.BooleanPreference;
|
||||
import net.osmand.plus.OsmandSettings.OsmandPreference;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.UiUtilities;
|
||||
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
|
||||
import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithCompoundButton;
|
||||
import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription;
|
||||
|
@ -53,7 +59,7 @@ public class BooleanPreferenceBottomSheet extends BasePreferenceBottomSheet {
|
|||
preferenceBtn[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder()
|
||||
.setChecked(checked)
|
||||
.setTitle(checked ? on : off)
|
||||
.setLayoutId(R.layout.bottom_sheet_item_with_switch)
|
||||
.setCustomView(getCustomButtonView())
|
||||
.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
@ -72,7 +78,7 @@ public class BooleanPreferenceBottomSheet extends BasePreferenceBottomSheet {
|
|||
if (description != null) {
|
||||
BaseBottomSheetItem preferenceDescription = new BottomSheetItemWithDescription.Builder()
|
||||
.setDescription(description)
|
||||
.setLayoutId(R.layout.bottom_sheet_item_description_long)
|
||||
.setLayoutId(R.layout.bottom_sheet_item_preference_descr)
|
||||
.create();
|
||||
items.add(preferenceDescription);
|
||||
}
|
||||
|
@ -83,17 +89,46 @@ public class BooleanPreferenceBottomSheet extends BasePreferenceBottomSheet {
|
|||
return R.string.shared_string_close;
|
||||
}
|
||||
|
||||
private View getCustomButtonView() {
|
||||
OsmandApplication app = requiredMyApplication();
|
||||
View customView = View.inflate(new ContextThemeWrapper(app, themeRes), R.layout.bottom_sheet_item_preference_switch, null);
|
||||
View buttonView = customView.findViewById(R.id.button_container);
|
||||
|
||||
int colorRes = app.getSettings().APPLICATION_MODE.get().getIconColorInfo().getColor(nightMode);
|
||||
int color = getResolvedColor(colorRes);
|
||||
int bgColor = UiUtilities.getColorWithAlpha(color, 0.1f);
|
||||
int selectedColor = UiUtilities.getColorWithAlpha(color, 0.3f);
|
||||
|
||||
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
|
||||
int bgResId = R.drawable.rectangle_rounded_right;
|
||||
int selectableResId = R.drawable.ripple_rectangle_rounded_right;
|
||||
|
||||
Drawable bgDrawable = app.getUIUtilities().getPaintedIcon(bgResId, bgColor);
|
||||
Drawable selectable = app.getUIUtilities().getPaintedIcon(selectableResId, selectedColor);
|
||||
Drawable[] layers = {bgDrawable, selectable};
|
||||
AndroidUtils.setBackground(buttonView, new LayerDrawable(layers));
|
||||
} else {
|
||||
int bgResId = R.drawable.rectangle_rounded_right;
|
||||
Drawable bgDrawable = app.getUIUtilities().getPaintedIcon(bgResId, bgColor);
|
||||
AndroidUtils.setBackground(buttonView, bgDrawable);
|
||||
}
|
||||
|
||||
return customView;
|
||||
}
|
||||
|
||||
private SwitchPreferenceEx getSwitchPreferenceEx() {
|
||||
return (SwitchPreferenceEx) getPreference();
|
||||
}
|
||||
|
||||
public static void showInstance(@NonNull FragmentManager fm, String prefId, Fragment target) {
|
||||
public static void showInstance(@NonNull FragmentManager fm, String prefId, Fragment target, boolean usedOnMap) {
|
||||
try {
|
||||
if (fm.findFragmentByTag(BooleanPreferenceBottomSheet.TAG) == null) {
|
||||
Bundle args = new Bundle();
|
||||
args.putString(PREFERENCE_ID, prefId);
|
||||
|
||||
BooleanPreferenceBottomSheet fragment = new BooleanPreferenceBottomSheet();
|
||||
fragment.setArguments(args);
|
||||
fragment.setUsedOnMap(usedOnMap);
|
||||
fragment.setTargetFragment(target, 0);
|
||||
fragment.show(fm, BooleanPreferenceBottomSheet.TAG);
|
||||
}
|
||||
|
|
|
@ -41,9 +41,11 @@ public class ChangeGeneralProfilesPrefBottomSheet extends BasePreferenceBottomSh
|
|||
if (app == null || args == null || newValue == null || !args.containsKey(PREFERENCE_ID)) {
|
||||
return;
|
||||
}
|
||||
|
||||
final String prefId = args.getString(PREFERENCE_ID);
|
||||
CommonPreference pref = getPreference(prefId);
|
||||
if (pref == null) {
|
||||
OsmandPreference osmandPref = app.getSettings().getPreference(prefId);
|
||||
if (pref == null || osmandPref == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -51,20 +53,16 @@ public class ChangeGeneralProfilesPrefBottomSheet extends BasePreferenceBottomSh
|
|||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
final List<ApplicationMode> values = ApplicationMode.values(app);
|
||||
List<ApplicationMode> appModesSameValue = new ArrayList<>();
|
||||
List<ApplicationMode> appModesDefaultValue = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < values.size(); i++) {
|
||||
ApplicationMode mode = values.get(i);
|
||||
Object modeValue = pref.getModeValue(mode);
|
||||
if (modeValue instanceof Enum) {
|
||||
modeValue = ((Enum) modeValue).ordinal();
|
||||
}
|
||||
if (modeValue.equals(newValue)) {
|
||||
appModesSameValue.add(mode);
|
||||
if (!osmandPref.isSetForMode(mode)) {
|
||||
appModesDefaultValue.add(mode);
|
||||
}
|
||||
}
|
||||
|
||||
Iterator<ApplicationMode> iterator = appModesSameValue.iterator();
|
||||
Iterator<ApplicationMode> iterator = appModesDefaultValue.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
builder.append(iterator.next().toHumanString(app));
|
||||
builder.append(iterator.hasNext() ? ", " : '.');
|
||||
|
@ -146,7 +144,7 @@ public class ChangeGeneralProfilesPrefBottomSheet extends BasePreferenceBottomSh
|
|||
return null;
|
||||
}
|
||||
|
||||
public static void showInstance(@NonNull FragmentManager fm, String prefId, Object newValue, Fragment target) {
|
||||
public static void showInstance(@NonNull FragmentManager fm, String prefId, Object newValue, Fragment target, boolean usedOnMap) {
|
||||
try {
|
||||
if (fm.findFragmentByTag(ChangeGeneralProfilesPrefBottomSheet.TAG) == null) {
|
||||
Bundle args = new Bundle();
|
||||
|
@ -154,8 +152,9 @@ public class ChangeGeneralProfilesPrefBottomSheet extends BasePreferenceBottomSh
|
|||
|
||||
ChangeGeneralProfilesPrefBottomSheet fragment = new ChangeGeneralProfilesPrefBottomSheet();
|
||||
fragment.setArguments(args);
|
||||
fragment.setTargetFragment(target, 0);
|
||||
fragment.setUsedOnMap(usedOnMap);
|
||||
fragment.newValue = newValue;
|
||||
fragment.setTargetFragment(target, 0);
|
||||
fragment.show(fm, ChangeGeneralProfilesPrefBottomSheet.TAG);
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
|
|
|
@ -81,14 +81,15 @@ public class EditTextPreferenceBottomSheet extends BasePreferenceBottomSheet {
|
|||
return (EditTextPreferenceEx) getPreference();
|
||||
}
|
||||
|
||||
public static boolean showInstance(@NonNull FragmentManager fragmentManager, String key, Fragment target) {
|
||||
public static boolean showInstance(@NonNull FragmentManager fragmentManager, String key, Fragment target, boolean usedOnMap) {
|
||||
try {
|
||||
Bundle args = new Bundle();
|
||||
args.putString(PREFERENCE_ID, key);
|
||||
|
||||
EditTextPreferenceBottomSheet fragment = new EditTextPreferenceBottomSheet();
|
||||
fragment.setTargetFragment(target, 0);
|
||||
fragment.setArguments(args);
|
||||
fragment.setUsedOnMap(usedOnMap);
|
||||
fragment.setTargetFragment(target, 0);
|
||||
fragment.show(fragmentManager, TAG);
|
||||
return true;
|
||||
} catch (RuntimeException e) {
|
||||
|
|
|
@ -151,14 +151,15 @@ public class MultiSelectPreferencesBottomSheet extends BasePreferenceBottomSheet
|
|||
return (MultiSelectBooleanPreference) getPreference();
|
||||
}
|
||||
|
||||
public static boolean showInstance(@NonNull FragmentManager fragmentManager, String prefId, Fragment target) {
|
||||
public static boolean showInstance(@NonNull FragmentManager fragmentManager, String prefId, Fragment target, boolean usedOnMap) {
|
||||
try {
|
||||
Bundle args = new Bundle();
|
||||
args.putString(PREFERENCE_ID, prefId);
|
||||
|
||||
MultiSelectPreferencesBottomSheet fragment = new MultiSelectPreferencesBottomSheet();
|
||||
fragment.setTargetFragment(target, 0);
|
||||
fragment.setArguments(args);
|
||||
fragment.setUsedOnMap(usedOnMap);
|
||||
fragment.setTargetFragment(target, 0);
|
||||
fragment.show(fragmentManager, TAG);
|
||||
return true;
|
||||
} catch (RuntimeException e) {
|
||||
|
|
|
@ -127,14 +127,15 @@ public class SingleSelectPreferenceBottomSheet extends BasePreferenceBottomSheet
|
|||
return (ListPreferenceEx) getPreference();
|
||||
}
|
||||
|
||||
public static boolean showInstance(@NonNull FragmentManager fragmentManager, String key, Fragment target) {
|
||||
public static boolean showInstance(@NonNull FragmentManager fragmentManager, String key, Fragment target, boolean usedOnMap) {
|
||||
try {
|
||||
Bundle args = new Bundle();
|
||||
args.putString(PREFERENCE_ID, key);
|
||||
|
||||
SingleSelectPreferenceBottomSheet fragment = new SingleSelectPreferenceBottomSheet();
|
||||
fragment.setTargetFragment(target, 0);
|
||||
fragment.setArguments(args);
|
||||
fragment.setUsedOnMap(usedOnMap);
|
||||
fragment.setTargetFragment(target, 0);
|
||||
fragment.show(fragmentManager, TAG);
|
||||
return true;
|
||||
} catch (RuntimeException e) {
|
||||
|
|
|
@ -15,7 +15,6 @@ import net.osmand.plus.OsmAndFormatter;
|
|||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||
import net.osmand.plus.routepreparationmenu.MapRouteInfoMenu;
|
||||
import net.osmand.plus.mapmarkers.MapMarkersDialogFragment;
|
||||
import net.osmand.plus.views.AnimateDraggingMapThread;
|
||||
import net.osmand.plus.views.DirectionDrawable;
|
||||
|
@ -354,8 +353,8 @@ public class MapMarkersWidgetsFactory {
|
|||
if (marker.colorIndex != cachedMarkerColorIndex
|
||||
|| cachedNightMode == null || cachedNightMode != isNight()) {
|
||||
setImageDrawable(map.getMyApplication().getUIUtilities()
|
||||
.getIcon(isNight() ? R.drawable.widget_marker_night : R.drawable.widget_marker_day,
|
||||
R.drawable.widget_marker_triangle,
|
||||
.getLayeredIcon(isNight() ? R.drawable.widget_marker_night : R.drawable.widget_marker_day,
|
||||
R.drawable.widget_marker_triangle, 0,
|
||||
MapMarker.getColorId(marker.colorIndex)));
|
||||
cachedMarkerColorIndex = marker.colorIndex;
|
||||
cachedNightMode = isNight();
|
||||
|
|
Loading…
Reference in a new issue