Merge pull request #7568 from osmandapp/ProfileSettingsImprovements

Profile settings improvements
This commit is contained in:
max-klaus 2019-09-17 18:08:26 +03:00 committed by GitHub
commit dc7e027421
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
40 changed files with 662 additions and 464 deletions

View file

@ -0,0 +1,12 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:bottom="1dp"
android:left="1dp"
android:right="1dp"
android:top="1dp">
<shape android:shape="rectangle">
<corners android:radius="@dimen/context_menu_padding_margin_tiny" />
<solid android:color="@color/list_background_color_light" />
</shape>
</item>
</layer-list>

View file

@ -0,0 +1,13 @@
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/active_buttons_and_links_trans_dark">
<item
android:id="@android:id/mask"
android:bottom="1dp"
android:left="1dp"
android:right="1dp"
android:top="1dp">
<shape android:shape="oval">
<solid android:color="@color/active_color_primary_light" />
</shape>
</item>
</ripple>

View file

@ -0,0 +1,14 @@
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/active_buttons_and_links_trans_dark">
<item
android:id="@android:id/mask"
android:bottom="1dp"
android:left="1dp"
android:right="1dp"
android:top="1dp">
<shape android:shape="rectangle">
<corners android:radius="@dimen/context_menu_padding_margin_tiny" />
<solid android:color="@color/active_color_primary_light" />
</shape>
</item>
</ripple>

View file

@ -1,15 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:osmand="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/list_background_color"
android:gravity="center_vertical">
<LinearLayout
android:id="@+id/selectable_list_item"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground">
tools:background="?android:attr/selectableItemBackground">
<ImageView
android:id="@android:id/icon"
@ -26,9 +28,9 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="@dimen/content_padding"
android:layout_marginRight="@dimen/content_padding"
android:layout_weight="1"
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size"
osmand:typeface="@string/font_roboto_regular" />

View file

@ -22,10 +22,10 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="@dimen/content_padding"
android:layout_marginTop="@dimen/content_padding_small"
android:layout_marginRight="@dimen/content_padding"
android:layout_marginBottom="@dimen/list_header_settings_top_margin"
android:paddingLeft="@dimen/content_padding"
android:paddingTop="@dimen/content_padding_small"
android:paddingRight="@dimen/content_padding"
android:paddingBottom="@dimen/list_header_settings_top_margin"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_regular" />

View file

@ -1,24 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:osmand="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/list_background_color"
android:gravity="center_vertical">
android:gravity="center_vertical"
android:orientation="vertical">
<LinearLayout
android:id="@+id/selectable_list_item"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground"
android:minHeight="@dimen/bottom_sheet_list_item_height">
android:minHeight="@dimen/bottom_sheet_list_item_height"
tools:background="?android:attr/selectableItemBackground">
<RadioButton
android:id="@android:id/checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="@dimen/content_padding"
android:layout_marginRight="@dimen/content_padding"
android:layout_marginLeft="@dimen/content_padding_small"
android:layout_marginRight="@dimen/content_padding_small"
android:background="@null"
android:clickable="true"
android:focusable="true" />
@ -27,10 +30,11 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="@dimen/content_padding"
android:layout_marginRight="@dimen/content_padding"
android:layout_weight="1"
android:orientation="vertical">
android:orientation="vertical"
android:paddingLeft="@dimen/content_padding"
android:paddingTop="@dimen/gpx_small_text_margin"
android:paddingRight="@dimen/content_padding">
<net.osmand.plus.widgets.TextViewEx
android:id="@android:id/title"
@ -48,10 +52,18 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="4"
android:paddingBottom="@dimen/gpx_small_text_margin"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_list_text_size"
osmand:typeface="@string/font_roboto_regular" />
<View
android:id="@+id/divider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_gravity="bottom"
android:background="?attr/divider_color_basic" />
</LinearLayout>
</LinearLayout>

View file

@ -1,16 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:osmand="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/list_background_color"
android:gravity="center_vertical">
<LinearLayout
android:id="@+id/selectable_list_item"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground"
android:minHeight="@dimen/bottom_sheet_list_item_height">
android:minHeight="@dimen/bottom_sheet_list_item_height"
tools:background="?android:attr/selectableItemBackground">
<ImageView
android:id="@android:id/icon"
@ -24,10 +26,10 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="@dimen/content_padding"
android:layout_marginRight="@dimen/content_padding"
android:layout_weight="1"
android:orientation="vertical">
android:orientation="vertical"
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding">
<net.osmand.plus.widgets.TextViewEx
android:id="@android:id/title"

View file

@ -20,32 +20,25 @@
android:layout_marginLeft="@dimen/content_padding"
android:layout_marginRight="@dimen/content_padding" />
<LinearLayout
<net.osmand.plus.widgets.TextViewEx
android:id="@android:id/summary"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="@dimen/content_padding"
android:layout_marginRight="@dimen/content_padding"
android:layout_weight="1"
android:orientation="vertical">
<net.osmand.plus.widgets.TextViewEx
android:id="@android:id/summary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size"
osmand:typeface="@string/font_roboto_regular" />
</LinearLayout>
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"
android:textColor="?attr/text_color_tab_active"
android:textSize="@dimen/default_list_text_size"
osmand:typeface="@string/font_roboto_medium" />
<Switch
android:id="@android:id/switch_widget"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@null"
android:clickable="true"
android:focusable="true"
android:clickable="false"
android:focusable="false"
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding" />

View file

@ -1,16 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:osmand="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/list_background_color"
android:gravity="center_vertical">
<LinearLayout
android:id="@+id/selectable_list_item"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground"
android:minHeight="@dimen/bottom_sheet_list_item_height">
android:minHeight="@dimen/bottom_sheet_list_item_height"
tools:background="?android:attr/selectableItemBackground">
<ImageView
android:id="@android:id/icon"
@ -26,10 +28,10 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="@dimen/content_padding"
android:layout_marginRight="@dimen/content_padding"
android:layout_weight="1"
android:orientation="vertical">
android:orientation="vertical"
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding">
<net.osmand.plus.widgets.TextViewEx
android:id="@android:id/title"

View file

@ -1,15 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:osmand="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/list_background_color"
android:gravity="center_vertical">
<LinearLayout
android:id="@+id/selectable_list_item"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground">
tools:background="?android:attr/selectableItemBackground">
<ImageView
android:id="@android:id/icon"
@ -25,10 +27,10 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="@dimen/content_padding"
android:layout_marginRight="@dimen/content_padding"
android:layout_weight="1"
android:orientation="vertical">
android:orientation="vertical"
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding">
<net.osmand.plus.widgets.TextViewEx
android:id="@android:id/title"

View file

@ -4,8 +4,7 @@
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:minHeight="56dp"
android:minHeight="@dimen/dashboard_map_toolbar"
osmand:contentInsetLeft="0dp"
osmand:contentInsetStart="0dp"
osmand:theme="@style/ThemeOverlay.AppCompat.ActionBar">
@ -14,56 +13,49 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/card_and_list_background_basic"
android:orientation="vertical">
android:gravity="center_vertical"
android:orientation="horizontal">
<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="@dimen/toolbar_height"
android:layout_height="@dimen/toolbar_height"
android:contentDescription="@string/access_shared_string_navigate_up"
android:src="@drawable/ic_action_mode_back"
android:tint="?attr/default_icon_color" />
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/toolbar_title"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:minHeight="@dimen/dashboard_map_toolbar"
android:orientation="horizontal">
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/dialog_header_text_size"
osmand:typeface="@string/font_roboto_medium"
tools:text="@string/routing_settings_2" />
<ImageButton
android:id="@+id/close_button"
style="@style/Widget.AppCompat.Toolbar.Button.Navigation"
android:layout_width="56dp"
android:layout_height="56dp"
android:contentDescription="@string/access_shared_string_navigate_up"
android:src="@drawable/ic_action_mode_back"
android:tint="?attr/default_icon_color" />
<FrameLayout
android:id="@+id/switch_profile_button"
android:layout_width="@dimen/route_info_toolbar_button_size"
android:layout_height="@dimen/route_info_toolbar_button_size"
android:layout_marginLeft="@dimen/content_padding_half"
android:layout_marginRight="@dimen/content_padding_half"
tools:background="?attr/bg_circle"
tools:backgroundTint="@color/active_buttons_and_links_trans_light">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/toolbar_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/content_padding_half"
android:layout_marginRight="@dimen/content_padding_half"
android:layout_weight="1"
android:text="@string/routing_settings_2"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size_large"
android:textStyle="bold"
osmand:typeface="@string/font_roboto_regular" />
<ImageView
android:id="@+id/profile_icon"
android:layout_width="@dimen/standard_icon_size"
android:layout_height="@dimen/standard_icon_size"
android:layout_gravity="center"
tools:src="@drawable/ic_action_car_dark"
tools:tint="@color/active_color_primary_light" />
<FrameLayout
android:id="@+id/switch_profile_button"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginLeft="@dimen/content_padding_half"
android:layout_marginRight="@dimen/content_padding_half"
android:background="@drawable/bg_transparent_rounded_profile">
<ImageView
android:id="@+id/profile_icon"
android:layout_width="@dimen/standard_icon_size"
android:layout_height="@dimen/standard_icon_size"
android:layout_gravity="center"
android:src="@drawable/ic_action_car_dark"
tools:tint="@color/active_color_primary_light" />
</FrameLayout>
</LinearLayout>
</FrameLayout>
</LinearLayout>

View file

@ -4,8 +4,6 @@
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:minHeight="56dp"
osmand:contentInsetLeft="0dp"
osmand:contentInsetStart="0dp"
osmand:theme="@style/ThemeOverlay.AppCompat.ActionBar">
@ -20,14 +18,14 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:minHeight="@dimen/dashboard_map_toolbar"
android:minHeight="@dimen/toolbar_height"
android:orientation="horizontal">
<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"
android:tint="?attr/default_icon_color" />
@ -35,110 +33,93 @@
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/toolbar_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/content_padding_half"
android:layout_marginRight="@dimen/content_padding_half"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size_large"
android:textStyle="bold"
osmand:typeface="@string/font_roboto_regular"
android:textSize="@dimen/dialog_header_text_size"
osmand:typeface="@string/font_roboto_medium"
tools:text="@string/routing_settings_2" />
<ImageView
android:id="@+id/menu_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:padding="@dimen/content_padding"
android:src="@drawable/ic_overflow_menu_dark"
android:visibility="gone" />
</LinearLayout>
<LinearLayout
android:id="@+id/profile_button"
android:id="@+id/switch_profile_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
android:layout_marginLeft="@dimen/context_menu_padding_margin_tiny"
android:layout_marginRight="@dimen/context_menu_padding_margin_tiny"
android:layout_marginBottom="@dimen/context_menu_padding_margin_tiny"
android:clickable="true"
android:focusable="true"
android:minHeight="@dimen/bottom_sheet_list_item_height"
android:orientation="horizontal">
<ImageView
android:id="@+id/profile_icon"
android:layout_width="@dimen/standard_icon_size"
android:layout_height="@dimen/standard_icon_size"
android:layout_gravity="center_vertical"
android:layout_marginStart="@dimen/bottom_sheet_image_text_margin_start"
android:layout_marginLeft="@dimen/bottom_sheet_image_text_margin_start"
android:layout_marginEnd="@dimen/content_padding"
android:layout_marginRight="@dimen/content_padding"
tools:src="@drawable/ic_action_bus_dark"
tools:tint="?attr/default_icon_color" />
<LinearLayout
android:id="@+id/switch_profile_button"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginLeft="6dp"
android:layout_marginRight="6dp"
android:layout_marginBottom="6dp"
android:clickable="true"
android:focusable="true"
android:orientation="horizontal">
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:orientation="vertical"
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding">
<ImageView
android:id="@+id/profile_icon"
android:layout_width="wrap_content"
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/profile_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="@dimen/bottom_sheet_image_text_margin_start"
android:layout_marginLeft="@dimen/bottom_sheet_image_text_margin_start"
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
android:src="@drawable/ic_action_coordinates_latitude"
tools:tint="?attr/default_icon_color" />
android:ellipsize="end"
android:maxLines="1"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size"
osmand:typeface="@string/font_roboto_medium"
tools:text="@string/profile_type_base_string" />
<LinearLayout
android:layout_width="0dp"
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/profile_type"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginEnd="@dimen/content_padding"
android:layout_marginRight="@dimen/content_padding"
android:layout_weight="1"
android:gravity="center_vertical"
android:orientation="vertical">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/profile_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:text="@string/profile_type_base_string"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size"
osmand:typeface="@string/font_roboto_medium" />
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/profile_type"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_regular"
tools:text="Item additional description" />
</LinearLayout>
<ImageView
android:layout_width="@dimen/standard_icon_size"
android:layout_height="@dimen/standard_icon_size"
android:layout_gravity="center_vertical"
android:layout_marginLeft="@dimen/bottom_sheet_image_text_margin_start"
android:layout_marginRight="@dimen/bottom_sheet_image_text_margin_start"
android:src="@drawable/ic_action_arrow_drop_down"
android:tint="?attr/default_icon_color" />
android:ellipsize="end"
android:maxLines="1"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_regular"
tools:text="Item additional description" />
</LinearLayout>
<View
android:id="@+id/toolbar_divider"
android:layout_width="match_parent"
android:layout_height="2dp"
android:visibility="visible"
tools:background="?attr/active_color_basic" />
<ImageView
android:layout_width="@dimen/standard_icon_size"
android:layout_height="@dimen/standard_icon_size"
android:layout_gravity="center_vertical"
android:layout_marginLeft="@dimen/bottom_sheet_image_text_margin_start"
android:layout_marginRight="@dimen/bottom_sheet_image_text_margin_start"
android:src="@drawable/ic_action_arrow_drop_down"
android:tint="?attr/default_icon_color" />
</LinearLayout>
<View
android:id="@+id/toolbar_divider"
android:layout_width="match_parent"
android:layout_height="2dp"
android:visibility="visible"
tools:background="?attr/active_color_basic" />
</LinearLayout>
</android.support.v7.widget.Toolbar>

View file

@ -424,6 +424,7 @@
<color name="text_field_box_light">#eeeeee</color>
<color name="preference_category_title">#7E33FF</color>
<color name="preference_top_switch_off">#808080</color>
<!-- Basic colors -->
<color name="app_bar_main_dark">#101112</color>

View file

@ -11,7 +11,7 @@
Thx - Hardy
-->
<string name="plugins_settings">Plugin settings</string>
<string name="logcat_buffer">Logcat buffer</string>
<string name="application_profile_changed">Application profile changed to \"%s\"</string>
<string name="switch_profile">Switch profile</string>

View file

@ -44,6 +44,10 @@
android:key="plugin_settings"
android:layout="@layout/preference_category_with_descr"
android:summary="@string/list_of_installed_plugins"
android:title="@string/plugin_settings" />
android:title="@string/plugins_settings" />
<Preference
android:layout="@layout/card_bottom_divider"
android:selectable="false" />
</PreferenceScreen>

View file

@ -5,7 +5,6 @@
<Preference
android:key="coordinates_format_info"
android:layout="@layout/preference_info"
android:order="0"
android:persistent="false"
android:selectable="false"
android:title="@string/coordinates_format_info"
@ -14,35 +13,30 @@
<CheckBoxPreference
android:key="format_degrees"
android:layout="@layout/preference_radio_button"
android:order="1"
android:persistent="false"
android:title="@string/navigate_point_format_D" />
<CheckBoxPreference
android:key="format_minutes"
android:layout="@layout/preference_radio_button"
android:order="2"
android:persistent="false"
android:title="@string/navigate_point_format_DM" />
<CheckBoxPreference
android:key="format_seconds"
android:layout="@layout/preference_radio_button"
android:order="3"
android:persistent="false"
android:title="@string/navigate_point_format_DMS" />
<!-- This pref added in code -->
<!-- <CheckBoxPreference-->
<!-- android:key="utm_format"-->
<!-- android:layout="@layout/preference_radio_button"-->
<!-- android:persistent="false"-->
<!-- android:title="@string/navigate_point_format_utm" />-->
<CheckBoxPreference
android:key="utm_format"
android:layout="@layout/preference_radio_button"
android:persistent="false"
android:title="@string/navigate_point_format_utm" />
<CheckBoxPreference
android:key="olc_format"
android:layout="@layout/preference_radio_button"
android:order="5"
android:persistent="false"
android:title="@string/navigate_point_format_olc" />

View file

@ -13,7 +13,7 @@
<net.osmand.plus.settings.preferences.SwitchPreferenceEx
android:key="show_routing_alarms"
android:layout="@layout/preference_dialog_and_switch"
android:layout="@layout/preference_with_descr_dialog_and_switch"
android:summaryOff="@string/shared_string_off"
android:summaryOn="@string/shared_string_on"
android:title="@string/screen_alerts"
@ -22,7 +22,7 @@
<net.osmand.plus.settings.preferences.SwitchPreferenceEx
android:key="speak_routing_alarms"
android:layout="@layout/preference_dialog_and_switch"
android:layout="@layout/preference_with_descr_dialog_and_switch"
android:summary="@string/voice_announces_descr"
android:title="@string/voice_announces"
app:fragment="net.osmand.plus.settings.VoiceAnnouncesFragment"
@ -49,7 +49,7 @@
<net.osmand.plus.settings.preferences.SwitchPreferenceEx
android:key="turn_screen_on_enabled"
android:layout="@layout/preference_dialog_and_switch"
android:layout="@layout/preference_with_descr_dialog_and_switch"
android:summaryOff="@string/shared_string_off"
android:summaryOn="@string/shared_string_on"
android:title="@string/turn_screen_on"

View file

@ -17,12 +17,13 @@
<net.osmand.plus.settings.preferences.ListPreferenceEx
android:dependency="turn_screen_on_enabled"
android:key="turn_screen_on_time_int"
android:layout="@layout/preference_with_descr"
android:title="@string/wake_time" />
<net.osmand.plus.settings.preferences.SwitchPreferenceEx
android:dependency="turn_screen_on_enabled"
android:key="turn_screen_on_sensor"
android:layout="@layout/preference_dialog_and_switch"
android:layout="@layout/preference_with_descr_dialog_and_switch"
android:summaryOff="@string/shared_string_off"
android:summaryOn="@string/shared_string_on"
android:title="@string/turn_screen_on_sensor" />

View file

@ -318,14 +318,21 @@ public class AndroidUtils {
tv.setMaxLines(maxLines);
}
@SuppressLint("NewApi")
@SuppressWarnings("deprecation")
public static void setBackground(Context ctx, View view, boolean night, int lightResId, int darkResId) {
Drawable drawable;
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
view.setBackground(ctx.getResources().getDrawable(night ? darkResId : lightResId,
ctx.getTheme()));
drawable = ctx.getResources().getDrawable(night ? darkResId : lightResId, ctx.getTheme());
} else {
view.setBackgroundDrawable(ctx.getResources().getDrawable(night ? darkResId : lightResId));
drawable = ctx.getResources().getDrawable(night ? darkResId : lightResId);
}
setBackground(view, drawable);
}
public static void setBackground(View view, Drawable drawable) {
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
view.setBackground(drawable);
} else {
view.setBackgroundDrawable(drawable);
}
}

View file

@ -2,7 +2,9 @@ package net.osmand.plus;
import android.app.Activity;
import android.content.Intent;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
import android.net.Uri;
import android.support.annotation.ColorRes;
import android.support.annotation.DrawableRes;
@ -196,13 +198,16 @@ public class ContextMenuAdapter {
desc.setText(item.getDescription());
}
if (layoutId == R.layout.main_menu_drawer_btn_configure_profile) {
int colorAlpha50 = UiUtilities.getColorWithAlpha(colorNoAlpha, 0.5f);
View fatDivider = convertView.findViewById(R.id.fatDivider);
fatDivider.setBackgroundColor(colorAlpha50);
fatDivider.setBackgroundColor(colorNoAlpha);
}
int colorListBackground = ContextCompat.getColor(app, lightTheme ? R.color.list_background_color_light : R.color.list_background_color_dark);
convertView.setBackgroundDrawable(UiUtilities.getAlphaStateDrawable(colorListBackground, colorNoAlpha, true, true));
Drawable selectableBg = UiUtilities.getColoredSelectableDrawable(app, colorNoAlpha, 0.3f);
Drawable[] layers = {new ColorDrawable(UiUtilities.getColorWithAlpha(colorNoAlpha, 0.15f)), selectableBg};
LayerDrawable layerDrawable = new LayerDrawable(layers);
AndroidUtils.setBackground(convertView, layerDrawable);
return convertView;
}
if (layoutId == R.layout.help_to_improve_item) {

View file

@ -7,7 +7,6 @@ import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
import android.graphics.drawable.RippleDrawable;
import android.graphics.drawable.StateListDrawable;
import android.hardware.Sensor;
import android.hardware.SensorManager;
import android.os.Build;
@ -71,9 +70,7 @@ public class UiUtilities {
Drawable d = drawableCache.get(hash);
if (d == null) {
d = ContextCompat.getDrawable(app, resId);
d = DrawableCompat.wrap(d);
d.mutate();
DrawableCompat.setTint(d, color);
d = tintDrawable(d, color);
drawableCache.put(hash, d);
}
@ -109,6 +106,42 @@ public class UiUtilities {
return getDrawable(id, light ? R.color.icon_color_default_light : R.color.icon_color_default_dark);
}
public static Drawable getSelectableDrawable(Context ctx) {
int bgResId = AndroidUtils.resolveAttribute(ctx, R.attr.selectableItemBackground);
if (bgResId != 0) {
return ContextCompat.getDrawable(ctx, bgResId);
}
return null;
}
public static Drawable getColoredSelectableDrawable(Context ctx, int color, float alpha) {
Drawable drawable = null;
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
Drawable bg = getSelectableDrawable(ctx);
if (bg != null) {
drawable = tintDrawable(bg, getColorWithAlpha(color, alpha));
}
} else {
drawable = AndroidUtils.createPressedStateListDrawable(new ColorDrawable(Color.TRANSPARENT), new ColorDrawable(getColorWithAlpha(color, alpha)));
}
return drawable;
}
public static Drawable tintDrawable(Drawable drawable, int color) {
Drawable coloredDrawable = null;
if (drawable != null) {
coloredDrawable = DrawableCompat.wrap(drawable);
coloredDrawable.mutate();
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP && coloredDrawable instanceof RippleDrawable) {
((RippleDrawable) coloredDrawable).setColor(ColorStateList.valueOf(color));
} else {
DrawableCompat.setTint(coloredDrawable, color);
}
}
return coloredDrawable;
}
@ColorRes
public static int getDefaultColorRes(Context context) {
final OsmandApplication app = (OsmandApplication) context.getApplicationContext();
@ -156,35 +189,6 @@ public class UiUtilities {
return a << ALPHA_CHANNEL | r << RED_CHANNEL | g << GREEN_CHANNEL | b << BLUE_CHANNEL;
}
public static Drawable getAlphaStateDrawable(@ColorInt int colorNoAlpha) {
return getAlphaStateDrawable(colorNoAlpha, false, true);
}
public static Drawable getAlphaStateDrawable(@ColorInt int colorNoAlpha, boolean highlightOnNormal, boolean highlightOnPressed) {
int colorAlpha25 = getColorWithAlpha(colorNoAlpha, 0.25f);
int colorAlpha30 = getColorWithAlpha(colorNoAlpha, 0.3f);
return getAlphaStateDrawableImpl(colorAlpha25, colorAlpha30, highlightOnNormal, highlightOnPressed);
}
public static Drawable getAlphaStateDrawable(@ColorInt int colorBackground, @ColorInt int colorForeground, boolean highlightOnNormal, boolean highlightOnPressed) {
int colorAlpha25 = UiUtilities.mixTwoColors(colorForeground, colorBackground, 0.125f);
int colorAlpha30 = UiUtilities.mixTwoColors(colorForeground, colorBackground, 0.15f);
return getAlphaStateDrawableImpl(colorAlpha25, colorAlpha30, highlightOnNormal, highlightOnPressed);
}
private static Drawable getAlphaStateDrawableImpl(@ColorInt int colorMode1, @ColorInt int colorMode2, boolean highlightOnNormal, boolean highlightOnPressed) {
StateListDrawable sld = new StateListDrawable();
if (highlightOnNormal && highlightOnPressed) {
sld.addState(new int[]{android.R.attr.state_pressed}, new ColorDrawable(colorMode2));
sld.addState(new int[]{}, new ColorDrawable(colorMode1));
} else if (highlightOnPressed) {
sld.addState(new int[]{android.R.attr.state_pressed}, new ColorDrawable(colorMode1));
} else if (highlightOnNormal) {
sld.addState(new int[]{}, new ColorDrawable(colorMode1));
}
return sld;
}
public UpdateLocationViewCache getUpdateLocationViewCache(){
UpdateLocationViewCache uvc = new UpdateLocationViewCache();
uvc.screenOrientation = getScreenOrientation();

View file

@ -657,7 +657,7 @@ public class MapActivityActions implements DialogProvider {
final AppModesBottomSheetDialogFragment fragment = new SelectAppModesBottomSheetDialogFragment();
fragment.setUsedOnMap(true);
mapActivity.getSupportFragmentManager().beginTransaction()
.add(fragment, "app_profile_settings").commitAllowingStateLoss();
.add(fragment, SelectAppModesBottomSheetDialogFragment.TAG).commitAllowingStateLoss();
return true;
}
})

View file

@ -12,6 +12,8 @@ import java.util.Set;
public class ConfigureAppModesBottomSheetDialogFragment extends AppModesBottomSheetDialogFragment<ConfigureProfileMenuAdapter>
implements ConfigureProfileMenuAdapter.ProfileSelectedListener {
public static final String TAG = "ConfigureAppModesBottomSheetDialogFragment";
private List<ApplicationMode> allModes = new ArrayList<>();
private Set<ApplicationMode> selectedModes = new HashSet<>();

View file

@ -1,14 +1,24 @@
package net.osmand.plus.profiles;
import android.widget.Toast;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import net.osmand.PlatformUtil;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.R;
import org.apache.commons.logging.Log;
import java.util.ArrayList;
import java.util.List;
public class SelectAppModesBottomSheetDialogFragment extends AppModesBottomSheetDialogFragment<SelectProfileMenuAdapter> {
public static final String TAG = "SelectAppModesBottomSheetDialogFragment";
private static final Log LOG = PlatformUtil.getLog(SelectAppModesBottomSheetDialogFragment.class);
private List<ApplicationMode> activeModes = new ArrayList<>();
@Override
@ -38,8 +48,29 @@ public class SelectAppModesBottomSheetDialogFragment extends AppModesBottomSheet
public void onProfilePressed(ApplicationMode item) {
if (!(item == getMyApplication().getSettings().APPLICATION_MODE.get())) {
getMyApplication().getSettings().APPLICATION_MODE.set(item);
Toast.makeText(getMyApplication(), String.format(getString(R.string.application_profile_changed), item.toHumanString(getMyApplication())), Toast.LENGTH_SHORT).show();
Fragment targetFragment = getTargetFragment();
if (targetFragment instanceof AppModeChangedListener) {
AppModeChangedListener listener = (AppModeChangedListener) targetFragment;
listener.onAppModeChanged();
}
}
dismiss();
}
public static void showInstance(@NonNull FragmentManager fm, Fragment target) {
try {
if (fm.findFragmentByTag(SelectAppModesBottomSheetDialogFragment.TAG) == null) {
SelectAppModesBottomSheetDialogFragment fragment = new SelectAppModesBottomSheetDialogFragment();
fragment.setTargetFragment(target, 0);
fragment.show(fm, SelectAppModesBottomSheetDialogFragment.TAG);
}
} catch (RuntimeException e) {
LOG.error("showInstance", e);
}
}
public interface AppModeChangedListener {
void onAppModeChanged();
}
}

View file

@ -1,7 +1,8 @@
package net.osmand.plus.profiles;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.StateListDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
import android.support.annotation.ColorRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
@ -11,6 +12,7 @@ import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import net.osmand.AndroidUtils;
import net.osmand.PlatformUtil;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.OsmandApplication;
@ -106,8 +108,14 @@ public class SelectProfileMenuAdapter extends AbstractProfileMenuAdapter<SelectP
//set up cell color
int colorNoAlpha = ContextCompat.getColor(app, profileColorResId);
boolean selectedMode = app.getSettings().APPLICATION_MODE.get() == item;
holder.profileOptions.setBackgroundDrawable(UiUtilities.getAlphaStateDrawable(colorNoAlpha, selectedMode, true));
Drawable drawable = UiUtilities.getColoredSelectableDrawable(app, colorNoAlpha, 0.3f);
if (selectedMode) {
Drawable[] layers = {new ColorDrawable(UiUtilities.getColorWithAlpha(colorNoAlpha, 0.15f)), drawable};
drawable = new LayerDrawable(layers);
}
AndroidUtils.setBackground(holder.profileOptions, drawable);
updateViewHolder(holder, item);
} else {
final String title = (String) obj;
@ -119,15 +127,14 @@ public class SelectProfileMenuAdapter extends AbstractProfileMenuAdapter<SelectP
holder.descr.setVisibility(View.GONE);
holder.switcher.setVisibility(View.GONE);
holder.menuIcon.setVisibility(View.GONE);
int colorResId = nightMode
int color = ContextCompat.getColor(app, nightMode
? R.color.active_color_primary_dark
: R.color.active_color_primary_light;
holder.title.setTextColor(app.getResources().getColor(colorResId));
: R.color.active_color_primary_light);
holder.title.setTextColor(color);
holder.title.setText(bottomButtonText);
int colorAlpha25 = UiUtilities.getColorWithAlpha(ContextCompat.getColor(app, colorResId), 0.25f);
StateListDrawable sld = new StateListDrawable();
sld.addState(new int[]{android.R.attr.state_pressed}, new ColorDrawable(colorAlpha25));
holder.profileOptions.setBackgroundDrawable(sld);
Drawable drawable = UiUtilities.getColoredSelectableDrawable(app, color, 0.3f);
AndroidUtils.setBackground(holder.profileOptions, drawable);
}
}

View file

@ -787,7 +787,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
}
});
getMapActivity().getSupportFragmentManager().beginTransaction()
.add(fragment, "app_profile_settings").commitAllowingStateLoss();
.add(fragment, ConfigureAppModesBottomSheetDialogFragment.TAG).commitAllowingStateLoss();
}
private void updateApplicationMode(ApplicationMode mode, ApplicationMode next) {

View file

@ -1,28 +1,34 @@
package net.osmand.plus.settings;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.ColorInt;
import android.support.annotation.ColorRes;
import android.support.annotation.DrawableRes;
import android.support.annotation.LayoutRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.StringRes;
import android.support.annotation.XmlRes;
import android.support.design.widget.AppBarLayout;
import android.support.v14.preference.SwitchPreference;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AlertDialog;
import android.support.v7.preference.EditTextPreference;
import android.support.v7.preference.ListPreference;
import android.support.v7.preference.Preference;
import android.support.v7.preference.Preference.OnPreferenceChangeListener;
import android.support.v7.preference.Preference.OnPreferenceClickListener;
import android.support.v7.preference.PreferenceFragmentCompat;
import android.support.v7.preference.PreferenceGroupAdapter;
import android.support.v7.preference.PreferenceScreen;
import android.support.v7.preference.PreferenceViewHolder;
import android.support.v7.view.ContextThemeWrapper;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
@ -32,6 +38,7 @@ import android.widget.ImageView;
import android.widget.TextView;
import net.osmand.AndroidUtils;
import net.osmand.PlatformUtil;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
@ -40,8 +47,8 @@ import net.osmand.plus.UiUtilities;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.OsmandActionBarActivity;
import net.osmand.plus.activities.OsmandInAppPurchaseActivity;
import net.osmand.plus.profiles.AppProfileArrayAdapter;
import net.osmand.plus.profiles.ProfileDataObject;
import net.osmand.plus.profiles.SelectAppModesBottomSheetDialogFragment;
import net.osmand.plus.profiles.SelectAppModesBottomSheetDialogFragment.AppModeChangedListener;
import net.osmand.plus.settings.bottomsheets.BooleanPreferenceBottomSheet;
import net.osmand.plus.settings.bottomsheets.EditTextPreferenceBottomSheet;
import net.osmand.plus.settings.bottomsheets.MultiSelectPreferencesBottomSheet;
@ -50,15 +57,18 @@ import net.osmand.plus.settings.preferences.ListPreferenceEx;
import net.osmand.plus.settings.preferences.MultiSelectBooleanPreference;
import net.osmand.plus.settings.preferences.SwitchPreferenceEx;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.logging.Log;
public abstract class BaseSettingsFragment extends PreferenceFragmentCompat implements Preference.OnPreferenceChangeListener, Preference.OnPreferenceClickListener {
public abstract class BaseSettingsFragment extends PreferenceFragmentCompat implements OnPreferenceChangeListener,
OnPreferenceClickListener, AppModeChangedListener {
protected final Log log = PlatformUtil.getLog(this.getClass());
protected OsmandApplication app;
protected OsmandSettings settings;
protected UiUtilities iconsCache;
private int themeRes;
private boolean nightMode;
private boolean wasDrawerDisabled;
@ -77,6 +87,7 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
nightMode = !settings.isLightContent();
themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
View view = super.onCreateView(inflater, container, savedInstanceState);
if (view != null) {
@ -84,6 +95,7 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
createToolbar(inflater, view);
setDivider(null);
updateAllSettings();
view.setBackgroundColor(ContextCompat.getColor(app, getBackgroundColorRes()));
}
return view;
@ -91,12 +103,30 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
@Override
public RecyclerView onCreateRecyclerView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {
int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
Context themedContext = new ContextThemeWrapper(getActivity(), themeRes);
LayoutInflater themedInflater = inflater.cloneInContext(themedContext);
return super.onCreateRecyclerView(themedInflater, parent, savedInstanceState);
RecyclerView recyclerView = super.onCreateRecyclerView(themedInflater, parent, savedInstanceState);
recyclerView.setPadding(0, 0, 0, AndroidUtils.dpToPx(app, 80));
return recyclerView;
}
@SuppressLint("RestrictedApi")
@Override
protected RecyclerView.Adapter onCreateAdapter(PreferenceScreen preferenceScreen) {
return new PreferenceGroupAdapter(preferenceScreen) {
@Override
public void onBindViewHolder(PreferenceViewHolder holder, int position) {
super.onBindViewHolder(holder, position);
Preference preference = getItem(position);
if (preference != null) {
onBindPreferenceViewHolder(preference, holder);
}
}
};
}
@Override
@ -115,27 +145,76 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
@Override
public void onPause() {
super.onPause();
MapActivity mapActivity = getMapActivity();
if (!wasDrawerDisabled && mapActivity != null) {
mapActivity.enableDrawer();
}
}
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
return true;
}
@Override
public boolean onPreferenceClick(Preference preference) {
return false;
}
@Override
public void onDisplayPreferenceDialog(Preference preference) {
if (preference instanceof ListPreferenceEx) {
FragmentManager fragmentManager = getFragmentManager();
if (fragmentManager != null) {
SingleSelectPreferenceBottomSheet.showInstance(fragmentManager, preference.getKey(), this);
}
} else if (preference instanceof SwitchPreferenceEx) {
FragmentManager fragmentManager = getFragmentManager();
if (fragmentManager != null) {
BooleanPreferenceBottomSheet.showInstance(fragmentManager, preference.getKey(), this);
}
} else if (preference instanceof EditTextPreference) {
FragmentManager fragmentManager = getFragmentManager();
if (fragmentManager != null) {
EditTextPreferenceBottomSheet.showInstance(fragmentManager, preference.getKey(), this);
}
} else if (preference instanceof MultiSelectBooleanPreference) {
FragmentManager fragmentManager = getFragmentManager();
if (fragmentManager != null) {
MultiSelectPreferencesBottomSheet.showInstance(getFragmentManager(), preference.getKey(), this);
}
} else {
super.onDisplayPreferenceDialog(preference);
}
}
@Override
public void onAppModeChanged() {
updateAllSettings();
}
protected abstract void setupPreferences();
protected void onBindPreferenceViewHolder(Preference preference, PreferenceViewHolder holder) {
if (preference.isSelectable()) {
View selectableView = holder.itemView.findViewById(R.id.selectable_list_item);
if (selectableView != null) {
Drawable drawable = UiUtilities.getColoredSelectableDrawable(app, getActiveProfileColor(), 0.3f);
AndroidUtils.setBackground(selectableView, drawable);
}
}
}
private void createToolbar(LayoutInflater inflater, View view) {
AppBarLayout appBarLayout = (AppBarLayout) view.findViewById(R.id.appbar);
int toolbarRes = getToolbarResId();
if (toolbarRes != -1) {
Context activityContext = getActivity();
Context themedContext = new ContextThemeWrapper(getActivity(), themeRes);
View toolbarContainer = inflater.cloneInContext(themedContext).inflate(toolbarRes, appBarLayout);
final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
final Context themedContext = new ContextThemeWrapper(activityContext, themeRes);
LayoutInflater themedInflater = LayoutInflater.from(themedContext);
View toolbarContainer = themedInflater.inflate(toolbarRes, null);
appBarLayout.addView(toolbarContainer);
view.findViewById(R.id.close_button).setOnClickListener(new View.OnClickListener() {
toolbarContainer.findViewById(R.id.close_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
MapActivity mapActivity = getMapActivity();
@ -144,16 +223,19 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
}
}
});
View switchProfile = view.findViewById(R.id.switch_profile_button);
View switchProfile = toolbarContainer.findViewById(R.id.switch_profile_button);
if (switchProfile != null) {
switchProfile.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
selectAppModeDialog().show();
FragmentManager fragmentManager = getFragmentManager();
if (fragmentManager != null) {
SelectAppModesBottomSheetDialogFragment.showInstance(fragmentManager, BaseSettingsFragment.this);
}
}
});
}
updateToolbar(view);
updateToolbar(toolbarContainer);
}
}
@ -163,9 +245,7 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
}
ApplicationMode selectedAppMode = getSelectedAppMode();
int iconRes = selectedAppMode.getIconRes();
int iconColor = selectedAppMode.getIconColorInfo().getColor(nightMode);
String title = selectedAppMode.isCustomProfile() ? selectedAppMode.getCustomProfileName() : getResources().getString(selectedAppMode.getNameKeyResource());
int iconColor = getActiveProfileColor();
TextView toolbarTitle = (TextView) view.findViewById(R.id.toolbar_title);
if (toolbarTitle != null) {
@ -173,11 +253,13 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
}
ImageView profileIcon = (ImageView) view.findViewById(R.id.profile_icon);
if (profileIcon != null) {
profileIcon.setImageDrawable(getIcon(iconRes, iconColor));
int iconRes = selectedAppMode.getIconRes();
profileIcon.setImageDrawable(getPaintedIcon(iconRes, iconColor));
}
TextView profileTitle = (TextView) view.findViewById(R.id.profile_title);
if (profileTitle != null) {
profileTitle.setText(title);
String appName = selectedAppMode.toHumanString(app);
profileTitle.setText(appName);
}
TextView profileType = (TextView) view.findViewById(R.id.profile_type);
if (profileType != null) {
@ -185,12 +267,40 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
}
View toolbarDivider = view.findViewById(R.id.toolbar_divider);
if (toolbarDivider != null) {
toolbarDivider.setBackgroundColor(ContextCompat.getColor(app, iconColor));
toolbarDivider.setBackgroundColor(iconColor);
}
view.setBackgroundColor(ContextCompat.getColor(app, getBackgroundColor()));
}
View profileButton = view.findViewById(R.id.switch_profile_button);
if (profileButton != null) {
int toolbarRes = getToolbarResId();
int bgColor = UiUtilities.getColorWithAlpha(iconColor, 0.1f);
int selectedColor = UiUtilities.getColorWithAlpha(iconColor, 0.3f);
protected abstract void setupPreferences();
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
int bgResId = 0;
int selectableResId = 0;
if (toolbarRes == R.layout.profile_preference_toolbar) {
bgResId = R.drawable.circle_background_light;
selectableResId = R.drawable.ripple_circle;
} else if (toolbarRes == R.layout.profile_preference_toolbar_big) {
bgResId = R.drawable.rectangle_rounded;
selectableResId = R.drawable.ripple_rectangle_rounded;
}
Drawable bgDrawable = getPaintedIcon(bgResId, bgColor);
Drawable selectable = getPaintedIcon(selectableResId, selectedColor);
Drawable[] layers = {bgDrawable, selectable};
AndroidUtils.setBackground(profileButton, new LayerDrawable(layers));
} else {
int bgResId = 0;
if (toolbarRes == R.layout.profile_preference_toolbar) {
bgResId = R.drawable.circle_background_light;
} else if (toolbarRes == R.layout.profile_preference_toolbar_big) {
bgResId = R.drawable.rectangle_rounded;
}
Drawable bgDrawable = getPaintedIcon(bgResId, bgColor);
AndroidUtils.setBackground(profileButton, bgDrawable);
}
}
}
private void updatePreferencesScreen() {
if (getSelectedAppMode() != null) {
@ -213,64 +323,7 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
}
}
protected AlertDialog.Builder selectAppModeDialog() {
AlertDialog.Builder singleSelectDialogBuilder = new AlertDialog.Builder(getContext());
singleSelectDialogBuilder.setTitle(R.string.profile_settings);
final List<ProfileDataObject> activeModes = new ArrayList<>();
for (ApplicationMode am : ApplicationMode.values(getMyApplication())) {
boolean isSelected = false;
if (am == getSelectedAppMode()) {
isSelected = true;
}
activeModes.add(new ProfileDataObject(
am.toHumanString(getMyApplication()),
getAppModeDescription(am),
am.getStringKey(),
am.getIconRes(),
isSelected,
am.getIconColorInfo()
));
}
final AppProfileArrayAdapter modeNames = new AppProfileArrayAdapter(
getActivity(), R.layout.bottom_sheet_item_with_descr_and_radio_btn, activeModes, true);
singleSelectDialogBuilder.setNegativeButton(R.string.shared_string_cancel,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
singleSelectDialogBuilder.setAdapter(modeNames, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
ApplicationMode selectedAppMode = ApplicationMode.values(app).get(which);
requireSettings().APPLICATION_MODE.set(selectedAppMode);
updateAllSettings();
}
});
return singleSelectDialogBuilder;
}
private String getAppModeDescription(ApplicationMode mode) {
String descr;
if (!mode.isCustomProfile()) {
descr = getString(R.string.profile_type_base_string);
} else {
descr = String.format(getString(R.string.profile_type_descr_string),
mode.getParent().toHumanString(getMyApplication()));
if (mode.getRoutingProfile() != null && mode.getRoutingProfile().contains("/")) {
descr = descr.concat(", " + mode.getRoutingProfile()
.substring(0, mode.getRoutingProfile().indexOf("/")));
}
}
return descr;
}
public void updateAllSettings() {
getListView().getRecycledViewPool().clear();
PreferenceScreen screen = getPreferenceScreen();
if (screen != null) {
getPreferenceScreen().removeAll();
@ -289,8 +342,9 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
return -1;
}
protected String getToolbarTitle() {
return getString(R.string.shared_string_settings);
@StringRes
protected int getToolbarTitle() {
return R.string.shared_string_settings;
}
@ColorRes
@ -305,13 +359,18 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
return -1;
}
@ColorRes
@ColorInt
protected int getActiveProfileColor() {
return ContextCompat.getColor(app, getActiveProfileColorRes());
}
@ColorRes
protected int getActiveProfileColorRes() {
return getSelectedAppMode().getIconColorInfo().getColor(isNightMode());
}
@ColorRes
protected int getBackgroundColor() {
protected int getBackgroundColorRes() {
return isNightMode() ? R.color.list_background_color_dark : R.color.list_background_color_light;
}
@ -397,7 +456,7 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
protected Drawable getActiveIcon(@DrawableRes int id) {
UiUtilities cache = getIconsCache();
return cache != null ? cache.getIcon(id, getActiveProfileColor()) : null;
return cache != null ? cache.getIcon(id, getActiveProfileColorRes()) : null;
}
protected Drawable getIcon(@DrawableRes int id, @ColorRes int colorId) {
@ -410,6 +469,11 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
return cache != null ? cache.getThemedIcon(id) : null;
}
protected Drawable getPaintedIcon(@DrawableRes int id, @ColorInt int color) {
UiUtilities cache = getIconsCache();
return cache != null ? cache.getPaintedIcon(id, color) : null;
}
@Nullable
protected OsmandSettings getSettings() {
OsmandApplication app = getMyApplication();
@ -426,43 +490,6 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
return app.getSettings();
}
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
return true;
}
@Override
public void onDisplayPreferenceDialog(Preference preference) {
if (preference instanceof ListPreferenceEx) {
FragmentManager fragmentManager = getFragmentManager();
if (fragmentManager != null) {
SingleSelectPreferenceBottomSheet.showInstance(fragmentManager, preference.getKey(), this);
}
} else if (preference instanceof SwitchPreferenceEx) {
FragmentManager fragmentManager = getFragmentManager();
if (fragmentManager != null) {
BooleanPreferenceBottomSheet.showInstance(fragmentManager, preference.getKey(), this);
}
} else if (preference instanceof EditTextPreference) {
FragmentManager fragmentManager = getFragmentManager();
if (fragmentManager != null) {
EditTextPreferenceBottomSheet.showInstance(fragmentManager, preference.getKey(), this);
}
} else if (preference instanceof MultiSelectBooleanPreference) {
FragmentManager fragmentManager = getFragmentManager();
if (fragmentManager != null) {
MultiSelectPreferencesBottomSheet.showInstance(getFragmentManager(), preference.getKey(), this);
}
} else {
super.onDisplayPreferenceDialog(preference);
}
}
@Override
public boolean onPreferenceClick(Preference preference) {
return false;
}
public SwitchPreference createSwitchPreference(OsmandSettings.OsmandPreference<Boolean> b, int title, int summary, int layoutId) {
return createSwitchPreference(b, getString(title), getString(summary), layoutId);
}

View file

@ -3,12 +3,25 @@ package net.osmand.plus.settings;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.annotation.ColorRes;
import android.support.v14.preference.SwitchPreference;
import android.support.v4.app.FragmentManager;
import android.support.v4.content.ContextCompat;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceCategory;
import android.support.v7.preference.PreferenceGroup;
import android.support.v7.preference.PreferenceGroupAdapter;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import net.osmand.AndroidUtils;
import net.osmand.aidl.OsmandAidlApi;
import net.osmand.aidl.OsmandAidlApi.ConnectedApp;
import net.osmand.plus.ApplicationMode;
@ -40,27 +53,84 @@ public class ConfigureProfileFragment extends BaseSettingsFragment {
}
@Override
protected String getToolbarTitle() {
return getString(R.string.configure_profile);
protected int getToolbarTitle() {
return R.string.configure_profile;
}
@ColorRes
protected int getBackgroundColor() {
protected int getBackgroundColorRes() {
return isNightMode() ? R.color.activity_background_color_dark : R.color.activity_background_color_light;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = super.onCreateView(inflater, container, savedInstanceState);
getListView().addItemDecoration(createDividerItemDecoration());
return view;
}
private RecyclerView.ItemDecoration createDividerItemDecoration() {
final Drawable dividerLight = new ColorDrawable(ContextCompat.getColor(app, R.color.list_background_color_light));
final Drawable dividerDark = new ColorDrawable(ContextCompat.getColor(app, R.color.list_background_color_dark));
final int pluginDividerHeight = AndroidUtils.dpToPx(app, 3);
return new RecyclerView.ItemDecoration() {
@Override
public void onDraw(Canvas canvas, RecyclerView parent, RecyclerView.State state) {
int dividerLeft = parent.getPaddingLeft();
int dividerRight = parent.getWidth() - parent.getPaddingRight();
int childCount = parent.getChildCount();
for (int i = 0; i < childCount - 1; i++) {
View child = parent.getChildAt(i);
if (shouldDrawDivider(child)) {
RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
int dividerTop = child.getBottom() + params.bottomMargin;
int dividerBottom = dividerTop + pluginDividerHeight;
Drawable divider = isNightMode() ? dividerDark : dividerLight;
divider.setBounds(dividerLeft, dividerTop, dividerRight, dividerBottom);
divider.draw(canvas);
}
}
}
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
if (shouldDrawDivider(view)) {
outRect.set(0, 0, 0, pluginDividerHeight);
}
}
private boolean shouldDrawDivider(View view) {
int position = getListView().getChildAdapterPosition(view);
Preference pref = ((PreferenceGroupAdapter) getListView().getAdapter()).getItem(position);
if (pref != null && pref.getParent() != null) {
PreferenceGroup preferenceGroup = pref.getParent();
return preferenceGroup.hasKey() && preferenceGroup.getKey().equals("plugin_settings");
}
return false;
}
};
}
@Override
protected void setupPreferences() {
Preference generalSettings = findPreference("general_settings");
Preference pluginSettings = findPreference("plugin_settings");
pluginSettings.setIconSpaceReserved(false);
generalSettings.setIcon(getContentIcon(R.drawable.ic_action_settings));
setupNavigationSettingsPref();
setupConfigureMapPref();
setupConnectedAppsPref();
setupOsmandPluginsPref();
PreferenceCategory pluginSettings = (PreferenceCategory) findPreference("plugin_settings");
pluginSettings.setIconSpaceReserved(false);
setupConnectedAppsPref(pluginSettings);
setupOsmandPluginsPref(pluginSettings);
}
private void setupNavigationSettingsPref() {
@ -86,7 +156,7 @@ public class ConfigureProfileFragment extends BaseSettingsFragment {
configureMap.setVisible(false);
}
private void setupConnectedAppsPref() {
private void setupConnectedAppsPref(PreferenceCategory preferenceCategory) {
OsmandApplication app = getMyApplication();
if (app == null) {
return;
@ -101,11 +171,11 @@ public class ConfigureProfileFragment extends BaseSettingsFragment {
preference.setChecked(connectedApp.isEnabled());
preference.setLayoutResource(R.layout.preference_switch);
getPreferenceScreen().addPreference(preference);
preferenceCategory.addPreference(preference);
}
}
private void setupOsmandPluginsPref() {
private void setupOsmandPluginsPref(PreferenceCategory preferenceCategory) {
Context ctx = getContext();
if (ctx == null) {
return;
@ -121,7 +191,7 @@ public class ConfigureProfileFragment extends BaseSettingsFragment {
preference.setLayoutResource(R.layout.preference_dialog_and_switch);
preference.setIntent(getPluginIntent(plugin));
getPreferenceScreen().addPreference(preference);
preferenceCategory.addPreference(preference);
}
}

View file

@ -1,5 +1,7 @@
package net.osmand.plus.settings;
import android.content.Context;
import android.net.Uri;
import android.support.annotation.NonNull;
import android.support.v4.app.FragmentManager;
import android.support.v7.preference.CheckBoxPreference;
@ -17,19 +19,21 @@ import android.text.style.ClickableSpan;
import android.view.MotionEvent;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
import net.osmand.Location;
import net.osmand.data.PointDescription;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.R;
import net.osmand.plus.settings.bottomsheets.ChangeGeneralProfilesPrefBottomSheet;
import net.osmand.plus.wikipedia.WikipediaDialogFragment;
public class CoordinatesFormatFragment extends BaseSettingsFragment {
public static final String TAG = "CoordinatesFormatFragment";
private static final String UTM_FORMAT_WIKI_LINK = "https://en.wikipedia.org/wiki/Universal_Transverse_Mercator_coordinate_system";
private static final String FORMAT_DEGREES = "format_degrees";
private static final String FORMAT_MINUTES = "format_minutes";
private static final String FORMAT_SECONDS = "format_seconds";
@ -47,26 +51,21 @@ public class CoordinatesFormatFragment extends BaseSettingsFragment {
}
@Override
protected String getToolbarTitle() {
return getString(R.string.coordinates_format);
protected int getToolbarTitle() {
return R.string.coordinates_format;
}
@Override
protected void setupPreferences() {
PreferenceScreen screen = getPreferenceScreen();
screen.setOrderingAsAdded(false);
Preference generalSettings = findPreference("coordinates_format_info");
generalSettings.setIcon(getContentIcon(R.drawable.ic_action_info_dark));
CheckBoxPreference degreesPref = (CheckBoxPreference) findPreference(FORMAT_DEGREES);
CheckBoxPreference minutesPref = (CheckBoxPreference) findPreference(FORMAT_MINUTES);
CheckBoxPreference secondsPref = (CheckBoxPreference) findPreference(FORMAT_SECONDS);
CheckBoxPreference utmPref = (CheckBoxPreference) findPreference(UTM_FORMAT);
CheckBoxPreference olcPref = (CheckBoxPreference) findPreference(OLC_FORMAT);
CheckBoxPreference utmPref = createUtmFormatPref();
screen.addPreference(utmPref);
Location loc = app.getLocationProvider().getLastKnownLocation();
degreesPref.setSummary(getCoordinatesFormatSummary(loc, PointDescription.FORMAT_DEGREES));
@ -80,24 +79,16 @@ public class CoordinatesFormatFragment extends BaseSettingsFragment {
updateSelectedFormatPrefs(currentPrefKey);
}
private CheckBoxPreference createUtmFormatPref() {
CheckBoxPreference utmPref = new CheckBoxPreference(app) {
@Override
protected void onBindPreferenceViewHolder(Preference preference, PreferenceViewHolder holder) {
super.onBindPreferenceViewHolder(preference, holder);
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
super.onBindViewHolder(holder);
TextView summaryView = (TextView) holder.findViewById(android.R.id.summary);
if (summaryView != null) {
summaryView.setOnTouchListener(getSummaryTouchListener());
}
if (UTM_FORMAT.equals(preference.getKey())) {
TextView summaryView = (TextView) holder.findViewById(android.R.id.summary);
if (summaryView != null) {
summaryView.setOnTouchListener(getSummaryTouchListener());
}
};
utmPref.setKey(UTM_FORMAT);
utmPref.setTitle(R.string.navigate_point_format_utm);
utmPref.setPersistent(false);
utmPref.setOrder(4);
utmPref.setLayoutResource(R.layout.preference_radio_button);
return utmPref;
}
}
private View.OnTouchListener getSummaryTouchListener() {
@ -162,7 +153,10 @@ public class CoordinatesFormatFragment extends BaseSettingsFragment {
ClickableSpan clickableSpan = new ClickableSpan() {
@Override
public void onClick(@NonNull View widget) {
Toast.makeText(widget.getContext(), getString(R.string.shared_string_read_more), Toast.LENGTH_LONG).show();
Context ctx = getContext();
if (ctx != null) {
WikipediaDialogFragment.showFullArticle(ctx, Uri.parse(UTM_FORMAT_WIKI_LINK), isNightMode());
}
}
@Override

View file

@ -4,7 +4,6 @@ import android.content.DialogInterface;
import android.content.pm.ActivityInfo;
import android.graphics.drawable.Drawable;
import android.support.annotation.NonNull;
import android.support.v14.preference.SwitchPreference;
import android.support.v4.app.FragmentManager;
import android.support.v7.app.AlertDialog;
import android.support.v7.preference.Preference;
@ -42,8 +41,8 @@ public class GeneralProfileSettingsFragment extends BaseSettingsFragment {
}
@Override
protected String getToolbarTitle() {
return getString(R.string.general_settings_2);
protected int getToolbarTitle() {
return R.string.general_settings_2;
}
@Override

View file

@ -34,8 +34,8 @@ public class GlobalSettingsFragment extends BaseSettingsFragment implements Send
}
@Override
protected String getToolbarTitle() {
return getString(R.string.osmand_settings);
protected int getToolbarTitle() {
return R.string.osmand_settings;
}
@Override

View file

@ -4,7 +4,6 @@ import android.content.Intent;
import android.support.annotation.ColorRes;
import android.support.v4.app.FragmentManager;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceCategory;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.R;
@ -26,8 +25,8 @@ public class MainSettingsFragment extends BaseSettingsFragment {
}
@Override
protected String getToolbarTitle() {
return getString(R.string.shared_string_settings);
protected int getToolbarTitle() {
return R.string.shared_string_settings;
}
@Override
@ -36,7 +35,7 @@ public class MainSettingsFragment extends BaseSettingsFragment {
}
@ColorRes
protected int getBackgroundColor() {
protected int getBackgroundColorRes() {
return isNightMode() ? R.color.activity_background_color_dark : R.color.activity_background_color_light;
}
@ -58,10 +57,7 @@ public class MainSettingsFragment extends BaseSettingsFragment {
private void setupConfigureProfilePref() {
ApplicationMode selectedMode = getSelectedAppMode();
int iconRes = selectedMode.getIconRes();
int iconColor = getActiveProfileColor();
String title = selectedMode.toHumanString(getContext());
String profileType;
if (selectedMode.isCustomProfile()) {
profileType = String.format(getString(R.string.profile_type_descr_string), Algorithms.capitalizeFirstLetterAndLowercase(selectedMode.getParent().toHumanString(getContext())));
@ -69,8 +65,10 @@ public class MainSettingsFragment extends BaseSettingsFragment {
profileType = getString(R.string.profile_type_base_string);
}
int iconRes = selectedMode.getIconRes();
Preference configureProfile = findPreference("configure_profile");
configureProfile.setIcon(getIcon(iconRes, iconColor));
configureProfile.setIcon(getPaintedIcon(iconRes, getActiveProfileColor()));
configureProfile.setTitle(title);
configureProfile.setSummary(profileType);
}

View file

@ -23,8 +23,8 @@ public class MapDuringNavigationFragment extends BaseSettingsFragment {
}
@Override
protected String getToolbarTitle() {
return getString(R.string.map_during_navigation);
protected int getToolbarTitle() {
return R.string.map_during_navigation;
}
@Override

View file

@ -20,8 +20,8 @@ public class NavigationFragment extends BaseSettingsFragment {
}
@Override
protected String getToolbarTitle() {
return getString(R.string.routing_settings_2);
protected int getToolbarTitle() {
return R.string.routing_settings_2;
}
@Override

View file

@ -1,6 +1,5 @@
package net.osmand.plus.settings;
import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference;
import android.widget.Toast;
@ -25,8 +24,8 @@ public class ProxySettingsFragment extends BaseSettingsFragment {
}
@Override
protected String getToolbarTitle() {
return getString(R.string.proxy_pref_title);
protected int getToolbarTitle() {
return R.string.proxy_pref_title;
}
@Override

View file

@ -52,8 +52,8 @@ public class RouteParametersFragment extends BaseSettingsFragment {
}
@Override
protected String getToolbarTitle() {
return getString(R.string.route_parameters);
protected int getToolbarTitle() {
return R.string.route_parameters;
}
@Override

View file

@ -1,8 +1,12 @@
package net.osmand.plus.settings;
import android.graphics.drawable.ColorDrawable;
import android.support.v14.preference.SwitchPreference;
import android.support.v4.content.ContextCompat;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceViewHolder;
import net.osmand.AndroidUtils;
import net.osmand.plus.R;
public class ScreenAlertsFragment extends BaseSettingsFragment {
@ -19,14 +23,13 @@ public class ScreenAlertsFragment extends BaseSettingsFragment {
return R.layout.profile_preference_toolbar;
}
protected String getToolbarTitle() {
return getString(R.string.screen_alerts);
@Override
protected int getToolbarTitle() {
return R.string.screen_alerts;
}
@Override
protected void setupPreferences() {
setupShowRoutingAlarmsPref();
Preference showRoutingAlarmsInfo = findPreference("show_routing_alarms_info");
SwitchPreference showTrafficWarnings = (SwitchPreference) findPreference(settings.SHOW_TRAFFIC_WARNINGS.getId());
SwitchPreference showPedestrian = (SwitchPreference) findPreference(settings.SHOW_PEDESTRIAN.getId());
@ -40,8 +43,15 @@ public class ScreenAlertsFragment extends BaseSettingsFragment {
showTunnels.setIcon(getIcon(R.drawable.list_warnings_tunnel));
}
private void setupShowRoutingAlarmsPref() {
SwitchPreference showRoutingAlarms = (SwitchPreference) findPreference(settings.SHOW_ROUTING_ALARMS.getId());
@Override
protected void onBindPreferenceViewHolder(Preference preference, PreferenceViewHolder holder) {
super.onBindPreferenceViewHolder(preference, holder);
if (settings.SHOW_ROUTING_ALARMS.getId().equals(preference.getKey())) {
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));
}
}
}

View file

@ -1,8 +1,12 @@
package net.osmand.plus.settings;
import android.graphics.drawable.ColorDrawable;
import android.support.v14.preference.SwitchPreference;
import android.support.v4.content.ContextCompat;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceViewHolder;
import net.osmand.AndroidUtils;
import net.osmand.plus.R;
import net.osmand.plus.settings.preferences.ListPreferenceEx;
import net.osmand.plus.settings.preferences.SwitchPreferenceEx;
@ -22,14 +26,12 @@ public class TurnScreenOnFragment extends BaseSettingsFragment {
}
@Override
protected String getToolbarTitle() {
return getString(R.string.turn_screen_on);
protected int getToolbarTitle() {
return R.string.turn_screen_on;
}
@Override
protected void setupPreferences() {
setupTurnScreenOnPref();
Preference turnScreenOnInfo = findPreference("turn_screen_on_info");
turnScreenOnInfo.setIcon(getContentIcon(R.drawable.ic_action_info_dark));
@ -37,8 +39,16 @@ public class TurnScreenOnFragment extends BaseSettingsFragment {
setupTurnScreenOnSensorPref();
}
private void setupTurnScreenOnPref() {
SwitchPreference turnScreenOn = (SwitchPreference) findPreference(settings.TURN_SCREEN_ON_ENABLED.getId());
@Override
protected void onBindPreferenceViewHolder(Preference preference, PreferenceViewHolder holder) {
super.onBindPreferenceViewHolder(preference, holder);
if (settings.TURN_SCREEN_ON_ENABLED.getId().equals(preference.getKey())) {
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));
}
}
private void setupTurnScreenOnTimePref() {

View file

@ -32,8 +32,8 @@ public class VehicleParametersFragment extends BaseSettingsFragment {
}
@Override
protected String getToolbarTitle() {
return getString(R.string.vehicle_parameters);
protected int getToolbarTitle() {
return R.string.vehicle_parameters;
}
@Override

View file

@ -4,11 +4,15 @@ import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.drawable.ColorDrawable;
import android.media.AudioManager;
import android.support.v14.preference.SwitchPreference;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AlertDialog;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceViewHolder;
import net.osmand.AndroidUtils;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
@ -37,13 +41,12 @@ public class VoiceAnnouncesFragment extends BaseSettingsFragment {
}
@Override
protected String getToolbarTitle() {
return getString(R.string.voice_announces);
protected int getToolbarTitle() {
return R.string.voice_announces;
}
@Override
protected void setupPreferences() {
setupSpeakRoutingAlarmsPref();
Preference voiceAnnouncesInfo = findPreference("voice_announces_info");
voiceAnnouncesInfo.setIcon(getContentIcon(R.drawable.ic_action_info_dark));
@ -59,9 +62,16 @@ public class VoiceAnnouncesFragment extends BaseSettingsFragment {
}
}
private void setupSpeakRoutingAlarmsPref() {
SwitchPreference speakRoutingAlarms = (SwitchPreference) findPreference(settings.SPEAK_ROUTING_ALARMS.getId());
@Override
protected void onBindPreferenceViewHolder(Preference preference, PreferenceViewHolder holder) {
super.onBindPreferenceViewHolder(preference, holder);
if (settings.SPEAK_ROUTING_ALARMS.getId().equals(preference.getKey())) {
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));
}
}
private void setupSpeedLimitExceedPref() {