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"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:id="@+id/toolbar"
|
android:id="@+id/toolbar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="@dimen/dashboard_map_toolbar"
|
android:layout_height="@dimen/toolbar_height"
|
||||||
android:background="@color/app_bar_color_light"
|
android:background="@color/icon_color_osmand_light"
|
||||||
app:contentInsetLeft="4dp"
|
app:contentInsetLeft="0dp"
|
||||||
app:contentInsetStart="4dp">
|
app:contentInsetStart="0dp">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@+id/close_button"
|
android:id="@+id/close_button"
|
||||||
style="@style/Widget.AppCompat.Toolbar.Button.Navigation"
|
style="@style/Widget.AppCompat.Toolbar.Button.Navigation"
|
||||||
android:layout_width="56dp"
|
android:layout_width="@dimen/toolbar_height"
|
||||||
android:layout_height="56dp"
|
android:layout_height="@dimen/toolbar_height"
|
||||||
android:contentDescription="@string/access_shared_string_navigate_up"
|
android:contentDescription="@string/access_shared_string_navigate_up"
|
||||||
android:src="@drawable/ic_action_mode_back" />
|
android:src="@drawable/ic_action_mode_back" />
|
||||||
|
|
||||||
<TextView
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
android:id="@+id/toolbar_title"
|
android:id="@+id/toolbar_title"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent"
|
||||||
android:layout_gravity="left"
|
android:gravity="center_vertical"
|
||||||
android:scaleType="center"
|
android:paddingLeft="@dimen/content_padding"
|
||||||
android:textColor="@color/abc_primary_text_material_dark"
|
android:paddingRight="@dimen/content_padding"
|
||||||
android:textSize="@dimen/abc_text_size_large_material"
|
android:textColor="?attr/app_bar_primary_item_color"
|
||||||
tools:text="Toolbar"
|
android:textSize="@dimen/dialog_header_text_size"
|
||||||
tools:visibility="visible" />
|
app:typeface="@string/font_roboto_medium"
|
||||||
|
tools:text="@string/routing_settings_2" />
|
||||||
|
|
||||||
<ProgressBar
|
</LinearLayout>
|
||||||
android:id="@+id/ProgressBar"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="right"
|
|
||||||
android:visibility="gone" />
|
|
||||||
|
|
||||||
</android.support.v7.widget.Toolbar>
|
</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"
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools">
|
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
|
<Preference
|
||||||
android:key="route_parameters_info"
|
android:key="route_parameters_info"
|
||||||
android:layout="@layout/preference_info"
|
android:layout="@layout/preference_info"
|
||||||
|
|
|
@ -8,6 +8,12 @@
|
||||||
android:summaryOff="@string/shared_string_off"
|
android:summaryOff="@string/shared_string_off"
|
||||||
android:summaryOn="@string/shared_string_on" />
|
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
|
<Preference
|
||||||
android:key="show_routing_alarms_info"
|
android:key="show_routing_alarms_info"
|
||||||
android:layout="@layout/preference_info"
|
android:layout="@layout/preference_info"
|
||||||
|
|
|
@ -81,6 +81,8 @@ public class OsmandSettings {
|
||||||
void removeListener(StateChangedListener<T> listener);
|
void removeListener(StateChangedListener<T> listener);
|
||||||
|
|
||||||
boolean isSet();
|
boolean isSet();
|
||||||
|
|
||||||
|
boolean isSetForMode(ApplicationMode m);
|
||||||
}
|
}
|
||||||
|
|
||||||
private abstract class PreferenceWithListener<T> implements OsmandPreference<T> {
|
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
|
// this value string is synchronized with settings_pref.xml preference name
|
||||||
public final OsmandPreference<ApplicationMode> APPLICATION_MODE = new PreferenceWithListener<ApplicationMode>() {
|
public final OsmandPreference<ApplicationMode> APPLICATION_MODE = new PreferenceWithListener<ApplicationMode>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return "application_mode";
|
return "application_mode";
|
||||||
}
|
}
|
||||||
|
|
||||||
;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ApplicationMode get() {
|
public ApplicationMode get() {
|
||||||
return currentMode;
|
return currentMode;
|
||||||
|
@ -348,14 +349,15 @@ public class OsmandSettings {
|
||||||
set(ApplicationMode.DEFAULT);
|
set(ApplicationMode.DEFAULT);
|
||||||
}
|
}
|
||||||
|
|
||||||
;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isSet() {
|
public boolean isSet() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
;
|
@Override
|
||||||
|
public boolean isSetForMode(ApplicationMode m) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean set(ApplicationMode val) {
|
public boolean set(ApplicationMode val) {
|
||||||
|
@ -582,6 +584,9 @@ public class OsmandSettings {
|
||||||
return settingsAPI.contains(getPreferences(), getId());
|
return settingsAPI.contains(getPreferences(), getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isSetForMode(ApplicationMode mode) {
|
||||||
|
return settingsAPI.contains(getProfilePreferences(mode), getId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class BooleanPreference extends CommonPreference<Boolean> {
|
public class BooleanPreference extends CommonPreference<Boolean> {
|
||||||
|
|
|
@ -85,9 +85,14 @@ public class UiUtilities {
|
||||||
return getDrawable(id, colorId);
|
return getDrawable(id, colorId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Drawable getIcon(@DrawableRes int backgroundId, @DrawableRes int id, @ColorRes int colorId) {
|
public Drawable getLayeredIcon(@DrawableRes int bgIconId, @DrawableRes int foregroundIconId) {
|
||||||
Drawable b = getDrawable(backgroundId, 0);
|
return getLayeredIcon(bgIconId, foregroundIconId, 0, 0);
|
||||||
Drawable f = getDrawable(id, colorId);
|
}
|
||||||
|
|
||||||
|
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];
|
Drawable[] layers = new Drawable[2];
|
||||||
layers[0] = b;
|
layers[0] = b;
|
||||||
layers[1] = f;
|
layers[1] = f;
|
||||||
|
|
|
@ -164,26 +164,19 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisplayPreferenceDialog(Preference preference) {
|
public void onDisplayPreferenceDialog(Preference preference) {
|
||||||
|
FragmentManager fragmentManager = getFragmentManager();
|
||||||
|
if (fragmentManager == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (preference instanceof ListPreferenceEx) {
|
if (preference instanceof ListPreferenceEx) {
|
||||||
FragmentManager fragmentManager = getFragmentManager();
|
SingleSelectPreferenceBottomSheet.showInstance(fragmentManager, preference.getKey(), this, false);
|
||||||
if (fragmentManager != null) {
|
|
||||||
SingleSelectPreferenceBottomSheet.showInstance(fragmentManager, preference.getKey(), this);
|
|
||||||
}
|
|
||||||
} else if (preference instanceof SwitchPreferenceEx) {
|
} else if (preference instanceof SwitchPreferenceEx) {
|
||||||
FragmentManager fragmentManager = getFragmentManager();
|
BooleanPreferenceBottomSheet.showInstance(fragmentManager, preference.getKey(), this, false);
|
||||||
if (fragmentManager != null) {
|
|
||||||
BooleanPreferenceBottomSheet.showInstance(fragmentManager, preference.getKey(), this);
|
|
||||||
}
|
|
||||||
} else if (preference instanceof EditTextPreference) {
|
} else if (preference instanceof EditTextPreference) {
|
||||||
FragmentManager fragmentManager = getFragmentManager();
|
EditTextPreferenceBottomSheet.showInstance(fragmentManager, preference.getKey(), this, false);
|
||||||
if (fragmentManager != null) {
|
|
||||||
EditTextPreferenceBottomSheet.showInstance(fragmentManager, preference.getKey(), this);
|
|
||||||
}
|
|
||||||
} else if (preference instanceof MultiSelectBooleanPreference) {
|
} else if (preference instanceof MultiSelectBooleanPreference) {
|
||||||
FragmentManager fragmentManager = getFragmentManager();
|
MultiSelectPreferencesBottomSheet.showInstance(fragmentManager, preference.getKey(), this, false);
|
||||||
if (fragmentManager != null) {
|
|
||||||
MultiSelectPreferencesBottomSheet.showInstance(getFragmentManager(), preference.getKey(), this);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
super.onDisplayPreferenceDialog(preference);
|
super.onDisplayPreferenceDialog(preference);
|
||||||
}
|
}
|
||||||
|
|
|
@ -180,7 +180,7 @@ public class CoordinatesFormatFragment extends BaseSettingsFragment {
|
||||||
if (newFormat != -1) {
|
if (newFormat != -1) {
|
||||||
FragmentManager fragmentManager = getFragmentManager();
|
FragmentManager fragmentManager = getFragmentManager();
|
||||||
if (fragmentManager != null) {
|
if (fragmentManager != null) {
|
||||||
ChangeGeneralProfilesPrefBottomSheet.showInstance(fragmentManager, settings.COORDINATES_FORMAT.getId(), newFormat, this);
|
ChangeGeneralProfilesPrefBottomSheet.showInstance(fragmentManager, settings.COORDINATES_FORMAT.getId(), newFormat, this, false);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,8 +68,8 @@ public class GeneralProfileSettingsFragment extends BaseSettingsFragment {
|
||||||
|
|
||||||
private void setupAppThemePref() {
|
private void setupAppThemePref() {
|
||||||
final ListPreferenceEx appTheme = (ListPreferenceEx) findPreference(settings.OSMAND_THEME.getId());
|
final ListPreferenceEx appTheme = (ListPreferenceEx) findPreference(settings.OSMAND_THEME.getId());
|
||||||
appTheme.setEntries(new String[]{getString(R.string.dark_theme), getString(R.string.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.setEntryValues(new Integer[] {OsmandSettings.OSMAND_DARK_THEME, OsmandSettings.OSMAND_LIGHT_THEME});
|
||||||
appTheme.setIcon(getOsmandThemeIcon());
|
appTheme.setIcon(getOsmandThemeIcon());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,8 +79,8 @@ public class GeneralProfileSettingsFragment extends BaseSettingsFragment {
|
||||||
|
|
||||||
private void setupRotateMapPref() {
|
private void setupRotateMapPref() {
|
||||||
final ListPreferenceEx rotateMap = (ListPreferenceEx) findPreference(settings.ROTATE_MAP.getId());
|
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.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.setEntryValues(new Integer[] {OsmandSettings.ROTATE_MAP_NONE, OsmandSettings.ROTATE_MAP_BEARING, OsmandSettings.ROTATE_MAP_COMPASS});
|
||||||
rotateMap.setIcon(getRotateMapIcon());
|
rotateMap.setIcon(getRotateMapIcon());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,8 +97,8 @@ public class GeneralProfileSettingsFragment extends BaseSettingsFragment {
|
||||||
|
|
||||||
private void setupMapScreenOrientationPref() {
|
private void setupMapScreenOrientationPref() {
|
||||||
final ListPreferenceEx mapScreenOrientation = (ListPreferenceEx) findPreference(settings.MAP_SCREEN_ORIENTATION.getId());
|
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.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.setEntryValues(new Integer[] {ActivityInfo.SCREEN_ORIENTATION_PORTRAIT, ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE, ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED});
|
||||||
mapScreenOrientation.setIcon(getMapScreenOrientationIcon());
|
mapScreenOrientation.setIcon(getMapScreenOrientationIcon());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,14 +185,14 @@ public class GeneralProfileSettingsFragment extends BaseSettingsFragment {
|
||||||
|
|
||||||
private void setupExternalInputDevicePref() {
|
private void setupExternalInputDevicePref() {
|
||||||
ListPreferenceEx externalInputDevice = (ListPreferenceEx) findPreference(settings.EXTERNAL_INPUT_DEVICE.getId());
|
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_no_ext_input),
|
||||||
getString(R.string.sett_generic_ext_input),
|
getString(R.string.sett_generic_ext_input),
|
||||||
getString(R.string.sett_wunderlinq_ext_input),
|
getString(R.string.sett_wunderlinq_ext_input),
|
||||||
getString(R.string.sett_parrot_ext_input)
|
getString(R.string.sett_parrot_ext_input)
|
||||||
});
|
});
|
||||||
|
|
||||||
externalInputDevice.setEntryValues(new Integer[]{
|
externalInputDevice.setEntryValues(new Integer[] {
|
||||||
OsmandSettings.NO_EXTERNAL_DEVICE,
|
OsmandSettings.NO_EXTERNAL_DEVICE,
|
||||||
OsmandSettings.GENERIC_EXTERNAL_DEVICE,
|
OsmandSettings.GENERIC_EXTERNAL_DEVICE,
|
||||||
OsmandSettings.WUNDERLINQ_EXTERNAL_DEVICE,
|
OsmandSettings.WUNDERLINQ_EXTERNAL_DEVICE,
|
||||||
|
@ -279,10 +279,15 @@ public class GeneralProfileSettingsFragment extends BaseSettingsFragment {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
|
OsmandSettings.OsmandPreference pref = settings.getPreference(preference.getKey());
|
||||||
|
if (pref != null && !pref.isSetForMode(getSelectedAppMode())) {
|
||||||
FragmentManager fragmentManager = getFragmentManager();
|
FragmentManager fragmentManager = getFragmentManager();
|
||||||
if (fragmentManager != null) {
|
if (fragmentManager != null) {
|
||||||
ChangeGeneralProfilesPrefBottomSheet.showInstance(fragmentManager, preference.getKey(), newValue, this);
|
ChangeGeneralProfilesPrefBottomSheet.showInstance(fragmentManager, preference.getKey(), newValue, this, false);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,9 +1,13 @@
|
||||||
package net.osmand.plus.settings;
|
package net.osmand.plus.settings;
|
||||||
|
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.os.Build;
|
||||||
import android.support.v14.preference.SwitchPreference;
|
import android.support.v14.preference.SwitchPreference;
|
||||||
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.support.v7.preference.Preference;
|
import android.support.v7.preference.Preference;
|
||||||
import android.support.v7.preference.PreferenceScreen;
|
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.ApplicationMode;
|
||||||
import net.osmand.plus.OsmandApplication;
|
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 AVOID_ROUTING_PARAMETER_PREFIX = "avoid_";
|
||||||
private static final String PREFER_ROUTING_PARAMETER_PREFIX = "prefer_";
|
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 static final String RELIEF_SMOOTHNESS_FACTOR = "relief_smoothness_factor";
|
||||||
|
|
||||||
private List<GeneralRouter.RoutingParameter> avoidParameters = new ArrayList<GeneralRouter.RoutingParameter>();
|
private List<GeneralRouter.RoutingParameter> avoidParameters = new ArrayList<GeneralRouter.RoutingParameter>();
|
||||||
|
@ -58,7 +64,9 @@ public class RouteParametersFragment extends BaseSettingsFragment {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setupPreferences() {
|
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.setIcon(getContentIcon(R.drawable.ic_action_info_dark));
|
||||||
vehicleParametersInfo.setTitle(getString(R.string.route_parameters_info, getSelectedAppMode().toHumanString(getContext())));
|
vehicleParametersInfo.setTitle(getString(R.string.route_parameters_info, getSelectedAppMode().toHumanString(getContext())));
|
||||||
|
|
||||||
|
@ -66,6 +74,35 @@ public class RouteParametersFragment extends BaseSettingsFragment {
|
||||||
setupTimeConditionalRoutingPref();
|
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() {
|
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);
|
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()));
|
timeConditionalRouting.setIcon(getRoutingPrefIcon(settings.ENABLE_TIME_CONDITIONAL_ROUTING.getId()));
|
||||||
|
|
|
@ -1,18 +1,24 @@
|
||||||
package net.osmand.plus.settings;
|
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.v14.preference.SwitchPreference;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.support.v7.preference.Preference;
|
import android.support.v7.preference.Preference;
|
||||||
|
import android.support.v7.preference.PreferenceGroupAdapter;
|
||||||
import android.support.v7.preference.PreferenceViewHolder;
|
import android.support.v7.preference.PreferenceViewHolder;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
|
|
||||||
public class ScreenAlertsFragment extends BaseSettingsFragment {
|
public class ScreenAlertsFragment extends BaseSettingsFragment {
|
||||||
|
|
||||||
public static final String TAG = "ScreenAlertsFragment";
|
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
|
@Override
|
||||||
protected int getPreferencesResId() {
|
protected int getPreferencesResId() {
|
||||||
return R.xml.screen_alerts;
|
return R.xml.screen_alerts;
|
||||||
|
@ -30,7 +36,7 @@ public class ScreenAlertsFragment extends BaseSettingsFragment {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setupPreferences() {
|
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 showTrafficWarnings = (SwitchPreference) findPreference(settings.SHOW_TRAFFIC_WARNINGS.getId());
|
||||||
SwitchPreference showPedestrian = (SwitchPreference) findPreference(settings.SHOW_PEDESTRIAN.getId());
|
SwitchPreference showPedestrian = (SwitchPreference) findPreference(settings.SHOW_PEDESTRIAN.getId());
|
||||||
SwitchPreference showCameras = (SwitchPreference) findPreference(settings.SHOW_CAMERAS.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));
|
showPedestrian.setIcon(getIcon(R.drawable.list_warnings_pedestrian));
|
||||||
showCameras.setIcon(getIcon(R.drawable.list_warnings_speed_camera));
|
showCameras.setIcon(getIcon(R.drawable.list_warnings_speed_camera));
|
||||||
showTunnels.setIcon(getIcon(R.drawable.list_warnings_tunnel));
|
showTunnels.setIcon(getIcon(R.drawable.list_warnings_tunnel));
|
||||||
|
|
||||||
|
setupScreenAlertsImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onBindPreferenceViewHolder(Preference preference, PreferenceViewHolder holder) {
|
protected void onBindPreferenceViewHolder(Preference preference, PreferenceViewHolder holder) {
|
||||||
super.onBindPreferenceViewHolder(preference, 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();
|
boolean checked = ((SwitchPreference) preference).isChecked();
|
||||||
int color = checked ? getActiveProfileColor() : ContextCompat.getColor(app, R.color.preference_top_switch_off);
|
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;
|
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.os.Bundle;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v4.app.FragmentManager;
|
import android.support.v4.app.FragmentManager;
|
||||||
|
import android.view.ContextThemeWrapper;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
|
import net.osmand.AndroidUtils;
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandSettings;
|
import net.osmand.plus.OsmandSettings;
|
||||||
import net.osmand.plus.OsmandSettings.BooleanPreference;
|
import net.osmand.plus.OsmandSettings.BooleanPreference;
|
||||||
import net.osmand.plus.OsmandSettings.OsmandPreference;
|
import net.osmand.plus.OsmandSettings.OsmandPreference;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.UiUtilities;
|
||||||
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
|
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
|
||||||
import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithCompoundButton;
|
import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithCompoundButton;
|
||||||
import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription;
|
import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription;
|
||||||
|
@ -53,7 +59,7 @@ public class BooleanPreferenceBottomSheet extends BasePreferenceBottomSheet {
|
||||||
preferenceBtn[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder()
|
preferenceBtn[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder()
|
||||||
.setChecked(checked)
|
.setChecked(checked)
|
||||||
.setTitle(checked ? on : off)
|
.setTitle(checked ? on : off)
|
||||||
.setLayoutId(R.layout.bottom_sheet_item_with_switch)
|
.setCustomView(getCustomButtonView())
|
||||||
.setOnClickListener(new View.OnClickListener() {
|
.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
@ -72,7 +78,7 @@ public class BooleanPreferenceBottomSheet extends BasePreferenceBottomSheet {
|
||||||
if (description != null) {
|
if (description != null) {
|
||||||
BaseBottomSheetItem preferenceDescription = new BottomSheetItemWithDescription.Builder()
|
BaseBottomSheetItem preferenceDescription = new BottomSheetItemWithDescription.Builder()
|
||||||
.setDescription(description)
|
.setDescription(description)
|
||||||
.setLayoutId(R.layout.bottom_sheet_item_description_long)
|
.setLayoutId(R.layout.bottom_sheet_item_preference_descr)
|
||||||
.create();
|
.create();
|
||||||
items.add(preferenceDescription);
|
items.add(preferenceDescription);
|
||||||
}
|
}
|
||||||
|
@ -83,17 +89,46 @@ public class BooleanPreferenceBottomSheet extends BasePreferenceBottomSheet {
|
||||||
return R.string.shared_string_close;
|
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() {
|
private SwitchPreferenceEx getSwitchPreferenceEx() {
|
||||||
return (SwitchPreferenceEx) getPreference();
|
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 {
|
try {
|
||||||
if (fm.findFragmentByTag(BooleanPreferenceBottomSheet.TAG) == null) {
|
if (fm.findFragmentByTag(BooleanPreferenceBottomSheet.TAG) == null) {
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putString(PREFERENCE_ID, prefId);
|
args.putString(PREFERENCE_ID, prefId);
|
||||||
|
|
||||||
BooleanPreferenceBottomSheet fragment = new BooleanPreferenceBottomSheet();
|
BooleanPreferenceBottomSheet fragment = new BooleanPreferenceBottomSheet();
|
||||||
fragment.setArguments(args);
|
fragment.setArguments(args);
|
||||||
|
fragment.setUsedOnMap(usedOnMap);
|
||||||
fragment.setTargetFragment(target, 0);
|
fragment.setTargetFragment(target, 0);
|
||||||
fragment.show(fm, BooleanPreferenceBottomSheet.TAG);
|
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)) {
|
if (app == null || args == null || newValue == null || !args.containsKey(PREFERENCE_ID)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final String prefId = args.getString(PREFERENCE_ID);
|
final String prefId = args.getString(PREFERENCE_ID);
|
||||||
CommonPreference pref = getPreference(prefId);
|
CommonPreference pref = getPreference(prefId);
|
||||||
if (pref == null) {
|
OsmandPreference osmandPref = app.getSettings().getPreference(prefId);
|
||||||
|
if (pref == null || osmandPref == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,20 +53,16 @@ public class ChangeGeneralProfilesPrefBottomSheet extends BasePreferenceBottomSh
|
||||||
|
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
final List<ApplicationMode> values = ApplicationMode.values(app);
|
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++) {
|
for (int i = 0; i < values.size(); i++) {
|
||||||
ApplicationMode mode = values.get(i);
|
ApplicationMode mode = values.get(i);
|
||||||
Object modeValue = pref.getModeValue(mode);
|
if (!osmandPref.isSetForMode(mode)) {
|
||||||
if (modeValue instanceof Enum) {
|
appModesDefaultValue.add(mode);
|
||||||
modeValue = ((Enum) modeValue).ordinal();
|
|
||||||
}
|
|
||||||
if (modeValue.equals(newValue)) {
|
|
||||||
appModesSameValue.add(mode);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Iterator<ApplicationMode> iterator = appModesSameValue.iterator();
|
Iterator<ApplicationMode> iterator = appModesDefaultValue.iterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
builder.append(iterator.next().toHumanString(app));
|
builder.append(iterator.next().toHumanString(app));
|
||||||
builder.append(iterator.hasNext() ? ", " : '.');
|
builder.append(iterator.hasNext() ? ", " : '.');
|
||||||
|
@ -146,7 +144,7 @@ public class ChangeGeneralProfilesPrefBottomSheet extends BasePreferenceBottomSh
|
||||||
return null;
|
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 {
|
try {
|
||||||
if (fm.findFragmentByTag(ChangeGeneralProfilesPrefBottomSheet.TAG) == null) {
|
if (fm.findFragmentByTag(ChangeGeneralProfilesPrefBottomSheet.TAG) == null) {
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
|
@ -154,8 +152,9 @@ public class ChangeGeneralProfilesPrefBottomSheet extends BasePreferenceBottomSh
|
||||||
|
|
||||||
ChangeGeneralProfilesPrefBottomSheet fragment = new ChangeGeneralProfilesPrefBottomSheet();
|
ChangeGeneralProfilesPrefBottomSheet fragment = new ChangeGeneralProfilesPrefBottomSheet();
|
||||||
fragment.setArguments(args);
|
fragment.setArguments(args);
|
||||||
fragment.setTargetFragment(target, 0);
|
fragment.setUsedOnMap(usedOnMap);
|
||||||
fragment.newValue = newValue;
|
fragment.newValue = newValue;
|
||||||
|
fragment.setTargetFragment(target, 0);
|
||||||
fragment.show(fm, ChangeGeneralProfilesPrefBottomSheet.TAG);
|
fragment.show(fm, ChangeGeneralProfilesPrefBottomSheet.TAG);
|
||||||
}
|
}
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
|
|
|
@ -81,14 +81,15 @@ public class EditTextPreferenceBottomSheet extends BasePreferenceBottomSheet {
|
||||||
return (EditTextPreferenceEx) getPreference();
|
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 {
|
try {
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putString(PREFERENCE_ID, key);
|
args.putString(PREFERENCE_ID, key);
|
||||||
|
|
||||||
EditTextPreferenceBottomSheet fragment = new EditTextPreferenceBottomSheet();
|
EditTextPreferenceBottomSheet fragment = new EditTextPreferenceBottomSheet();
|
||||||
fragment.setTargetFragment(target, 0);
|
|
||||||
fragment.setArguments(args);
|
fragment.setArguments(args);
|
||||||
|
fragment.setUsedOnMap(usedOnMap);
|
||||||
|
fragment.setTargetFragment(target, 0);
|
||||||
fragment.show(fragmentManager, TAG);
|
fragment.show(fragmentManager, TAG);
|
||||||
return true;
|
return true;
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
|
|
|
@ -151,14 +151,15 @@ public class MultiSelectPreferencesBottomSheet extends BasePreferenceBottomSheet
|
||||||
return (MultiSelectBooleanPreference) getPreference();
|
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 {
|
try {
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putString(PREFERENCE_ID, prefId);
|
args.putString(PREFERENCE_ID, prefId);
|
||||||
|
|
||||||
MultiSelectPreferencesBottomSheet fragment = new MultiSelectPreferencesBottomSheet();
|
MultiSelectPreferencesBottomSheet fragment = new MultiSelectPreferencesBottomSheet();
|
||||||
fragment.setTargetFragment(target, 0);
|
|
||||||
fragment.setArguments(args);
|
fragment.setArguments(args);
|
||||||
|
fragment.setUsedOnMap(usedOnMap);
|
||||||
|
fragment.setTargetFragment(target, 0);
|
||||||
fragment.show(fragmentManager, TAG);
|
fragment.show(fragmentManager, TAG);
|
||||||
return true;
|
return true;
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
|
|
|
@ -127,14 +127,15 @@ public class SingleSelectPreferenceBottomSheet extends BasePreferenceBottomSheet
|
||||||
return (ListPreferenceEx) getPreference();
|
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 {
|
try {
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putString(PREFERENCE_ID, key);
|
args.putString(PREFERENCE_ID, key);
|
||||||
|
|
||||||
SingleSelectPreferenceBottomSheet fragment = new SingleSelectPreferenceBottomSheet();
|
SingleSelectPreferenceBottomSheet fragment = new SingleSelectPreferenceBottomSheet();
|
||||||
fragment.setTargetFragment(target, 0);
|
|
||||||
fragment.setArguments(args);
|
fragment.setArguments(args);
|
||||||
|
fragment.setUsedOnMap(usedOnMap);
|
||||||
|
fragment.setTargetFragment(target, 0);
|
||||||
fragment.show(fragmentManager, TAG);
|
fragment.show(fragmentManager, TAG);
|
||||||
return true;
|
return true;
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
|
|
|
@ -15,7 +15,6 @@ import net.osmand.plus.OsmAndFormatter;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||||
import net.osmand.plus.routepreparationmenu.MapRouteInfoMenu;
|
|
||||||
import net.osmand.plus.mapmarkers.MapMarkersDialogFragment;
|
import net.osmand.plus.mapmarkers.MapMarkersDialogFragment;
|
||||||
import net.osmand.plus.views.AnimateDraggingMapThread;
|
import net.osmand.plus.views.AnimateDraggingMapThread;
|
||||||
import net.osmand.plus.views.DirectionDrawable;
|
import net.osmand.plus.views.DirectionDrawable;
|
||||||
|
@ -354,8 +353,8 @@ public class MapMarkersWidgetsFactory {
|
||||||
if (marker.colorIndex != cachedMarkerColorIndex
|
if (marker.colorIndex != cachedMarkerColorIndex
|
||||||
|| cachedNightMode == null || cachedNightMode != isNight()) {
|
|| cachedNightMode == null || cachedNightMode != isNight()) {
|
||||||
setImageDrawable(map.getMyApplication().getUIUtilities()
|
setImageDrawable(map.getMyApplication().getUIUtilities()
|
||||||
.getIcon(isNight() ? R.drawable.widget_marker_night : R.drawable.widget_marker_day,
|
.getLayeredIcon(isNight() ? R.drawable.widget_marker_night : R.drawable.widget_marker_day,
|
||||||
R.drawable.widget_marker_triangle,
|
R.drawable.widget_marker_triangle, 0,
|
||||||
MapMarker.getColorId(marker.colorIndex)));
|
MapMarker.getColorId(marker.colorIndex)));
|
||||||
cachedMarkerColorIndex = marker.colorIndex;
|
cachedMarkerColorIndex = marker.colorIndex;
|
||||||
cachedNightMode = isNight();
|
cachedNightMode = isNight();
|
||||||
|
|
Loading…
Reference in a new issue