Merge pull request #7611 from osmandapp/profile_settings

Profile settings improvements
This commit is contained in:
max-klaus 2019-10-01 12:06:55 +03:00 committed by GitHub
commit 2f1249d339
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
65 changed files with 1359 additions and 795 deletions

View file

@ -5,6 +5,7 @@
android:id="@+id/description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:letterSpacing="@dimen/description_letter_spacing"
android:minHeight="@dimen/bottom_sheet_list_item_height"
android:paddingLeft="@dimen/content_padding"
android:paddingTop="@dimen/bottom_sheet_image_text_margin_start"

View file

@ -24,6 +24,7 @@
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:ellipsize="end"
android:letterSpacing="@dimen/title_letter_spacing"
android:maxLines="1"
android:textAppearance="@style/TextAppearance.ListItemTitle"
android:textColor="?attr/active_color_basic"

View file

@ -1,9 +1,65 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<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="match_parent"
android:background="?attr/activity_background_color"
android:orientation="vertical">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="@dimen/toolbar_height"
android:background="?attr/actionModeBackground"
app:contentInsetLeft="0dp"
app:contentInsetStart="0dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageButton
android:id="@+id/close_button"
style="@style/Widget.AppCompat.Toolbar.Button.Navigation"
android:layout_width="@dimen/toolbar_height"
android:layout_height="@dimen/toolbar_height"
android:contentDescription="@string/access_shared_string_navigate_up"
android:src="@drawable/ic_action_mode_back" />
<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:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"
android:textColor="?attr/app_bar_primary_item_color"
android:textSize="@dimen/dialog_header_text_size"
app:typeface="@string/font_roboto_medium"
tools:text="@string/routing_settings_2" />
<ImageButton
android:id="@+id/delete_button"
style="@style/Widget.AppCompat.Toolbar.Button.Navigation"
android:layout_width="@dimen/toolbar_height"
android:layout_height="@dimen/toolbar_height"
android:contentDescription="@string/shared_string_delete"
android:src="@drawable/ic_action_delete_dark" />
</LinearLayout>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/activity_background_color">
@ -226,8 +282,7 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:orientation="horizontal"
android:layout_gravity="center_vertical">
@ -379,7 +434,7 @@
android:textColor="@color/description_font_and_bottom_sheet_icons"/>
<LinearLayout
android:id="@+id/map_config_btn"
android:id="@+id/profile_config_btn"
android:layout_width="match_parent"
android:layout_height="65dp"
android:background="?android:attr/selectableItemBackground"
@ -387,133 +442,37 @@
android:orientation="horizontal">
<ImageView
android:id="@+id/map_config_icon"
android:id="@+id/profile_config_icon"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginStart="@dimen/list_content_padding"
android:layout_marginLeft="@dimen/list_content_padding"
android:src="@drawable/ic_action_layers_dark"
android:src="@drawable/ic_action_settings"
android:tint="?attr/default_icon_color"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginEnd="@dimen/list_content_padding"
android:layout_marginLeft="24dp"
android:layout_marginEnd="@dimen/list_content_padding"
android:layout_marginRight="@dimen/list_content_padding"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/configure_map"
android:text="@string/configure_profile"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/edit_profile_setup_map_subtitle"
android:textColor="@color/description_font_and_bottom_sheet_icons"/>
</LinearLayout>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginStart="64dp"
android:layout_marginLeft="64dp"
android:background="?attr/divider_color"/>
<LinearLayout
android:id="@+id/screen_config_btn"
android:layout_width="match_parent"
android:layout_height="64dp"
android:background="?android:attr/selectableItemBackground"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:id="@+id/screen_config_icon"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginStart="@dimen/list_content_padding"
android:layout_marginLeft="@dimen/list_content_padding"
android:src="@drawable/ic_configure_screen_dark"
android:tint="?attr/default_icon_color"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginEnd="@dimen/list_content_padding"
android:layout_marginLeft="24dp"
android:layout_marginRight="@dimen/list_content_padding"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/map_widget_config"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/edit_profile_screen_options_subtitle"
android:textColor="@color/description_font_and_bottom_sheet_icons"/>
</LinearLayout>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginStart="64dp"
android:layout_marginLeft="64dp"
android:background="?attr/divider_color"
/>
<LinearLayout
android:id="@+id/nav_settings_btn"
android:layout_width="match_parent"
android:layout_height="64dp"
android:background="?android:attr/selectableItemBackground"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:id="@+id/nav_settings_icon"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginStart="@dimen/list_content_padding"
android:layout_marginLeft="@dimen/list_content_padding"
android:src="@drawable/ic_action_gdirections_dark"
android:tint="?attr/default_icon_color"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginEnd="@dimen/list_content_padding"
android:layout_marginLeft="24dp"
android:layout_marginRight="@dimen/list_content_padding"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/routing_settings_2"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/edit_profile_nav_settings_subtitle"
android:textColor="@color/description_font_and_bottom_sheet_icons"/>
android:textColor="@color/description_font_and_bottom_sheet_icons"
android:visibility="gone"
tools:text="@string/configure_profile_info"
tools:visibility="visible" />
</LinearLayout>
</LinearLayout>
@ -613,3 +572,5 @@
</LinearLayout>
</FrameLayout>
</LinearLayout>

View file

@ -5,7 +5,7 @@
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="@dimen/toolbar_height"
android:background="@color/icon_color_osmand_light"
android:background="?attr/actionModeBackground"
app:contentInsetLeft="0dp"
app:contentInsetStart="0dp">

View file

@ -0,0 +1,50 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar 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/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/actionModeBackground"
app:contentInsetLeft="0dp"
app:contentInsetStart="0dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:minHeight="@dimen/toolbar_height"
android:orientation="horizontal">
<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" />
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/toolbar_title"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"
android:textColor="?attr/app_bar_primary_item_color"
android:textSize="@dimen/dialog_header_text_size"
app:typeface="@string/font_roboto_medium"
tools:text="@string/routing_settings_2" />
</LinearLayout>
<include layout="@layout/preference_toolbar_switch" />
</LinearLayout>
</android.support.v7.widget.Toolbar>

View file

@ -29,6 +29,7 @@
android:id="@android:id/title"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:letterSpacing="@dimen/description_letter_spacing"
android:paddingTop="@dimen/list_header_settings_top_margin"
android:singleLine="true"
android:textColor="@color/preference_category_title"
@ -40,6 +41,7 @@
android:id="@android:id/summary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:letterSpacing="@dimen/description_letter_spacing"
android:paddingBottom="@dimen/list_header_settings_top_margin"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_desc_text_size"

View file

@ -22,6 +22,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:letterSpacing="@dimen/description_letter_spacing"
android:paddingLeft="@dimen/content_padding"
android:paddingTop="@dimen/content_padding_small"
android:paddingRight="@dimen/content_padding"

View file

@ -11,6 +11,7 @@
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/content_padding"
android:layout_marginRight="@dimen/content_padding"
android:letterSpacing="@dimen/text_button_letter_spacing"
android:paddingTop="@dimen/content_padding_small"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_sub_text_size"

View file

@ -51,7 +51,7 @@
android:id="@android:id/summary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="4"
android:letterSpacing="@dimen/description_letter_spacing"
android:paddingBottom="@dimen/gpx_small_text_margin"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_list_text_size"

View file

@ -22,37 +22,18 @@
android:layout_marginLeft="@dimen/content_padding"
android:layout_marginRight="@dimen/content_padding" />
<LinearLayout
<net.osmand.plus.widgets.TextViewEx
android:id="@android:id/title"
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">
<net.osmand.plus.widgets.TextViewEx
android:id="@android:id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:singleLine="true"
android:paddingRight="@dimen/content_padding"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size"
osmand:typeface="@string/font_roboto_regular" />
<net.osmand.plus.widgets.TextViewEx
android:id="@android:id/summary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="4"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_regular" />
</LinearLayout>
<android.support.v7.widget.SwitchCompat
android:id="@+id/switchWidget"
android:layout_width="wrap_content"

View file

@ -0,0 +1,71 @@
<?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:minHeight="@dimen/bottom_sheet_list_item_height"
tools:background="?android:attr/selectableItemBackground">
<ImageView
android:id="@android:id/icon"
android:layout_width="@dimen/standard_icon_size"
android:layout_height="@dimen/standard_icon_size"
android:layout_gravity="center"
android:layout_marginLeft="@dimen/content_padding"
android:layout_marginTop="@dimen/bottom_sheet_icon_margin"
android:layout_marginRight="@dimen/content_padding"
android:layout_marginBottom="@dimen/bottom_sheet_icon_margin" />
<LinearLayout
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">
<net.osmand.plus.widgets.TextViewEx
android:id="@android:id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:singleLine="true"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size"
osmand:typeface="@string/font_roboto_regular" />
<net.osmand.plus.widgets.TextViewEx
android:id="@android:id/summary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:letterSpacing="@dimen/description_letter_spacing"
android:maxLines="4"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_regular" />
</LinearLayout>
<android.support.v7.widget.SwitchCompat
android:id="@+id/switchWidget"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@null"
android:clickable="false"
android:focusable="false"
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding" />
</LinearLayout>
</LinearLayout>

View file

@ -1,36 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:osmand="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/toolbar_switch_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/list_background_color"
android:gravity="center_vertical">
android:orientation="vertical">
<LinearLayout
android:id="@+id/selectable_item"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground"
android:minHeight="@dimen/bottom_sheet_selected_item_title_height">
<ImageView
android:id="@android:id/icon"
android:layout_width="@dimen/standard_icon_size"
android:layout_height="@dimen/standard_icon_size"
android:layout_gravity="center"
android:layout_marginLeft="@dimen/content_padding"
android:layout_marginRight="@dimen/content_padding" />
android:minHeight="@dimen/toolbar_height">
<net.osmand.plus.widgets.TextViewEx
android:id="@android:id/summary"
android:id="@+id/switchButtonText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_height="match_parent"
android:layout_marginStart="@dimen/toolbar_height"
android:layout_marginLeft="@dimen/toolbar_height"
android:layout_weight="1"
android:gravity="center_vertical"
android:letterSpacing="@dimen/title_letter_spacing"
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" />
osmand:typeface="@string/font_roboto_medium"
tools:text="@string/shared_string_off" />
<android.support.v7.widget.SwitchCompat
android:id="@+id/switchWidget"

View file

@ -14,15 +14,25 @@
android:minHeight="@dimen/bottom_sheet_list_item_height"
tools:background="?android:attr/selectableItemBackground">
<FrameLayout
android:id="@+id/icon_container"
android:layout_width="@dimen/route_info_toolbar_button_size"
android:layout_height="@dimen/route_info_toolbar_button_size"
android:layout_gravity="center"
android:layout_marginLeft="@dimen/content_padding_half"
android:layout_marginTop="@dimen/content_padding"
android:layout_marginRight="@dimen/content_padding_half"
android:layout_marginBottom="@dimen/content_padding">
<ImageView
android:id="@android:id/icon"
android:layout_width="@dimen/standard_icon_size"
android:layout_height="@dimen/standard_icon_size"
android:layout_gravity="center"
android:layout_marginLeft="@dimen/content_padding"
android:layout_marginTop="@dimen/bottom_sheet_icon_margin"
android:layout_marginRight="@dimen/content_padding"
android:layout_marginBottom="@dimen/bottom_sheet_icon_margin" />
tools:src="@drawable/ic_action_car_dark"
tools:tint="@color/active_color_primary_light" />
</FrameLayout>
<LinearLayout
android:layout_width="0dp"
@ -48,6 +58,7 @@
android:id="@android:id/summary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:letterSpacing="@dimen/description_letter_spacing"
android:maxLines="4"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_desc_text_size"

View file

@ -47,7 +47,7 @@
android:id="@android:id/summary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="4"
android:letterSpacing="@dimen/description_letter_spacing"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_regular" />

View file

@ -0,0 +1,18 @@
<?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:id="@+id/profile_button"
android:layout_width="@dimen/route_info_toolbar_button_size"
android:layout_height="@dimen/route_info_toolbar_button_size"
tools:background="?attr/bg_circle"
tools:backgroundTint="@color/active_buttons_and_links_trans_light">
<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>

View file

@ -31,6 +31,7 @@
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:letterSpacing="@dimen/text_button_letter_spacing"
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"
android:textColor="?android:textColorPrimary"
@ -38,24 +39,12 @@
osmand:typeface="@string/font_roboto_medium"
tools:text="@string/routing_settings_2" />
<FrameLayout
android:id="@+id/switch_profile_button"
<include
layout="@layout/profile_button_small"
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">
<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:layout_marginRight="@dimen/content_padding_half" />
</LinearLayout>

View file

@ -36,6 +36,7 @@
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:letterSpacing="@dimen/text_button_letter_spacing"
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"
android:textColor="?android:textColorPrimary"
@ -46,7 +47,7 @@
</LinearLayout>
<LinearLayout
android:id="@+id/switch_profile_button"
android:id="@+id/profile_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/context_menu_padding_margin_tiny"
@ -76,17 +77,20 @@
android:layout_weight="1"
android:orientation="vertical"
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding">
android:paddingTop="@dimen/content_padding_half"
android:paddingRight="@dimen/content_padding"
android:paddingBottom="@dimen/content_padding_half">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/profile_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:letterSpacing="@dimen/text_button_letter_spacing"
android:maxLines="1"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size"
osmand:typeface="@string/font_roboto_medium"
osmand:typeface="@string/font_roboto_regular"
tools:text="@string/profile_type_base_string" />
<net.osmand.plus.widgets.TextViewEx
@ -94,9 +98,12 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:letterSpacing="@dimen/description_letter_spacing"
android:maxLines="1"
android:paddingTop="@dimen/text_margin_small"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_desc_text_size"
android:visibility="gone"
osmand:typeface="@string/font_roboto_regular"
tools:text="Item additional description" />

View file

@ -0,0 +1,60 @@
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:osmand="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
osmand:contentInsetLeft="0dp"
osmand:contentInsetStart="0dp"
osmand:theme="@style/ThemeOverlay.AppCompat.ActionBar">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/card_and_list_background_basic"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/card_and_list_background_basic"
android:gravity="center_vertical"
android:orientation="horizontal">
<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:letterSpacing="@dimen/text_button_letter_spacing"
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" />
<include
layout="@layout/profile_button_small"
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" />
</LinearLayout>
<include layout="@layout/preference_toolbar_switch" />
</LinearLayout>
</android.support.v7.widget.Toolbar>

View file

@ -1,6 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/activity_background_color"
android:orientation="vertical">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include layout="@layout/global_preference_toolbar" />
</android.support.design.widget.AppBarLayout>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/activity_background_color"
@ -48,3 +62,5 @@
</LinearLayout>
</RelativeLayout>
</LinearLayout>

View file

@ -338,6 +338,8 @@
<dimen name="wikilink_bottom_sheet_padding">14dp</dimen>
<dimen name="text_button_letter_spacing" format="float">0.01</dimen>
<dimen name="description_letter_spacing" format="float">0.02</dimen>
<dimen name="title_letter_spacing" format="float">0.03</dimen>
<dimen name="text_button_line_spacing_multiplier" format="float">1.2</dimen>
<dimen name="pages_item_size">4dp</dimen>

View file

@ -11,6 +11,7 @@
Thx - Hardy
-->
<string name="shared_string_by_default">By default</string>
<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>

View file

@ -1,7 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen 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">
xmlns:tools="http://schemas.android.com/tools"
android:title="@string/configure_profile">
<Preference
android:key="configure_profile_info"
@ -36,6 +37,14 @@
android:title="@string/configure_map"
tools:icon="@drawable/ic_action_layers_dark" />
<Preference
android:key="configure_screen"
android:layout="@layout/preference_with_descr"
android:persistent="false"
android:summary="@string/edit_profile_screen_options_subtitle"
android:title="@string/map_widget_config"
tools:icon="@drawable/ic_configure_screen_dark" />
<Preference
android:layout="@layout/list_item_divider"
android:selectable="false" />

View file

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
xmlns:tools="http://schemas.android.com/tools"
android:title="@string/coordinates_format">
<Preference
android:key="coordinates_format_info"

View file

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
xmlns:app="http://schemas.android.com/apk/res-auto"
android:title="@string/general_settings_2">
<PreferenceCategory
android:key="appearance_category"
@ -84,7 +85,7 @@
<SwitchPreferenceCompat
android:key="do_not_use_animations"
android:layout="@layout/preference_switch"
android:layout="@layout/preference_switch_with_descr"
android:summaryOff="@string/shared_string_off"
android:summaryOn="@string/shared_string_on"
android:title="@string/do_not_use_animations" />

View file

@ -1,7 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen 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">
xmlns:tools="http://schemas.android.com/tools"
android:title="@string/osmand_settings">
<net.osmand.plus.settings.preferences.ListPreferenceEx
android:icon="@drawable/ic_world_globe_dark"
@ -34,7 +35,7 @@
<net.osmand.plus.settings.preferences.SwitchPreferenceEx
android:icon="@drawable/ic_action_privacy_and_security"
android:key="send_anonymous_data"
android:layout="@layout/preference_dialog_and_switch"
android:layout="@layout/preference_with_descr_dialog_and_switch"
android:persistent="false"
android:summaryOff="@string/shared_string_off"
android:summaryOn="@string/shared_string_on"
@ -43,14 +44,14 @@
<SwitchPreferenceCompat
android:icon="@drawable/ic_action_notification"
android:key="do_not_show_startup_messages"
android:layout="@layout/preference_switch"
android:layout="@layout/preference_switch_with_descr"
android:summaryOff="@string/shared_string_off"
android:summaryOn="@string/shared_string_on"
android:title="@string/start_up_message_pref" />
<net.osmand.plus.settings.preferences.SwitchPreferenceEx
android:key="enable_proxy"
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/proxy_pref_title"

View file

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/map_during_navigation">
<Preference
android:key="map_during_navigation_info"

View file

@ -1,7 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen 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">
xmlns:tools="http://schemas.android.com/tools"
android:title="@string/routing_settings_2">
<Preference
android:key="route_parameters"
@ -56,4 +57,11 @@
app:fragment="net.osmand.plus.settings.TurnScreenOnFragment"
tools:icon="@drawable/ic_action_turn_screen_on" />
<net.osmand.plus.settings.preferences.SwitchPreferenceEx
android:key="animate_my_location"
android:layout="@layout/preference_with_descr_dialog_and_switch"
android:summaryOff="@string/shared_string_off"
android:summaryOn="@string/shared_string_on"
android:title="@string/animate_my_location" />
</PreferenceScreen>

View file

@ -5,11 +5,6 @@
android:key="proxy"
android:title="@string/proxy_pref_title">
<SwitchPreferenceCompat
android:key="enable_proxy"
android:summaryOff="@string/shared_string_off"
android:summaryOn="@string/shared_string_on" />
<Preference
android:key="proxy_preferences_info"
android:layout="@layout/preference_info"
@ -19,14 +14,14 @@
tools:icon="@drawable/ic_action_info_dark" />
<net.osmand.plus.settings.preferences.EditTextPreferenceEx
android:dependency="enable_proxy"
android:key="proxy_host"
android:layout="@layout/preference_with_descr"
android:summary="@string/proxy_host_descr"
android:title="@string/proxy_host_title" />
<net.osmand.plus.settings.preferences.EditTextPreferenceEx
android:dependency="enable_proxy"
android:key="proxy_port"
android:layout="@layout/preference_with_descr"
android:summary="@string/proxy_port_descr"
android:title="@string/proxy_port_title" />

View file

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
xmlns:tools="http://schemas.android.com/tools"
android:title="@string/route_parameters">
<Preference
android:key="route_parameters_image"

View file

@ -1,12 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<SwitchPreferenceCompat
android:key="show_routing_alarms"
android:layout="@layout/preference_top_switch"
android:summaryOff="@string/shared_string_off"
android:summaryOn="@string/shared_string_on" />
xmlns:tools="http://schemas.android.com/tools"
android:title="@string/screen_alerts">
<Preference
android:key="screen_alerts_image"
@ -22,25 +17,21 @@
tools:icon="@drawable/ic_action_info_dark" />
<SwitchPreferenceCompat
android:dependency="show_routing_alarms"
android:key="show_traffic_warnings"
android:layout="@layout/preference_switch"
android:title="@string/show_traffic_warnings" />
<SwitchPreferenceCompat
android:dependency="show_routing_alarms"
android:key="show_pedestrian"
android:layout="@layout/preference_switch"
android:title="@string/show_pedestrian_warnings" />
<SwitchPreferenceCompat
android:dependency="show_routing_alarms"
android:key="show_cameras"
android:layout="@layout/preference_switch"
android:title="@string/show_cameras" />
<SwitchPreferenceCompat
android:dependency="show_routing_alarms"
android:key="show_tunnels"
android:layout="@layout/preference_switch"
android:title="@string/show_tunnels" />

View file

@ -1,7 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen 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">
xmlns:tools="http://schemas.android.com/tools"
android:title="@string/shared_string_settings">
<Preference
android:key="global_settings"

View file

@ -1,11 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<SwitchPreferenceCompat
android:key="turn_screen_on_enabled"
android:layout="@layout/preference_top_switch"
android:summaryOff="@string/shared_string_off"
android:summaryOn="@string/shared_string_on" />
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/turn_screen_on">
<Preference
android:key="turn_screen_on_info"
@ -15,13 +10,11 @@
android:title="@string/turn_screen_on_info" />
<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_with_descr_dialog_and_switch"
android:summaryOff="@string/shared_string_off"

View file

@ -1,6 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
xmlns:tools="http://schemas.android.com/tools"
android:title="@string/vehicle_parameters">
<Preference
android:key="vehicle_parameters_info"

View file

@ -1,12 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<SwitchPreferenceCompat
android:key="speak_routing_alarms"
android:layout="@layout/preference_top_switch"
android:summaryOff="@string/shared_string_off"
android:summaryOn="@string/shared_string_on" />
xmlns:tools="http://schemas.android.com/tools"
android:title="@string/voice_announces">
<Preference
android:key="voice_announces_info"
@ -17,19 +12,16 @@
tools:icon="@drawable/ic_action_info_dark" />
<SwitchPreferenceCompat
android:dependency="speak_routing_alarms"
android:key="speak_street_names"
android:layout="@layout/preference_switch"
android:title="@string/speak_street_names" />
<SwitchPreferenceCompat
android:dependency="speak_routing_alarms"
android:key="speak_traffic_warnings"
android:layout="@layout/preference_switch"
android:title="@string/speak_traffic_warnings" />
<SwitchPreferenceCompat
android:dependency="speak_routing_alarms"
android:key="speak_pedestrian"
android:layout="@layout/preference_switch"
android:title="@string/speak_pedestrian" />
@ -39,13 +31,11 @@
android:selectable="false" />
<SwitchPreferenceCompat
android:dependency="speak_routing_alarms"
android:key="speak_speed_limit"
android:layout="@layout/preference_switch"
android:title="@string/speak_speed_limit" />
<net.osmand.plus.settings.preferences.ListPreferenceEx
android:dependency="speak_routing_alarms"
android:key="speed_limit_exceed"
android:layout="@layout/preference_with_descr"
android:title="@string/speed_limit_exceed" />
@ -55,31 +45,26 @@
android:selectable="false" />
<SwitchPreferenceCompat
android:dependency="speak_routing_alarms"
android:key="speak_cameras"
android:layout="@layout/preference_switch"
android:title="@string/speak_cameras" />
<SwitchPreferenceCompat
android:dependency="speak_routing_alarms"
android:key="speak_tunnels"
android:layout="@layout/preference_switch"
android:title="@string/show_tunnels" />
<SwitchPreferenceCompat
android:dependency="speak_routing_alarms"
android:key="announce_wpt"
android:layout="@layout/preference_switch"
android:title="@string/shared_string_gpx_waypoints" />
<SwitchPreferenceCompat
android:dependency="speak_routing_alarms"
android:key="announce_nearby_favorites"
android:layout="@layout/preference_switch"
android:title="@string/speak_favorites" />
<SwitchPreferenceCompat
android:dependency="speak_routing_alarms"
android:key="announce_nearby_poi"
android:layout="@layout/preference_switch"
android:title="@string/speak_poi" />
@ -89,13 +74,11 @@
android:selectable="false" />
<net.osmand.plus.settings.preferences.ListPreferenceEx
android:dependency="speak_routing_alarms"
android:key="keep_informing"
android:layout="@layout/preference_with_descr"
android:title="@string/keep_informing" />
<net.osmand.plus.settings.preferences.ListPreferenceEx
android:dependency="speak_routing_alarms"
android:key="arrival_distance_factor"
android:layout="@layout/preference_with_descr"
android:title="@string/arrival_distance" />
@ -110,7 +93,6 @@
android:title="@string/language_and_output" />
<net.osmand.plus.settings.preferences.ListPreferenceEx
android:dependency="speak_routing_alarms"
android:key="voice_provider"
android:layout="@layout/preference_with_descr"
android:persistent="false"

View file

@ -1,7 +1,6 @@
package net.osmand;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.KeyguardManager;
import android.content.Context;
@ -426,6 +425,12 @@ public class AndroidUtils {
return outValue.resourceId;
}
public static float getFloatValueFromRes(Context ctx, int resId) {
TypedValue outValue = new TypedValue();
ctx.getResources().getValue(resId, outValue, true);
return outValue.getFloat();
}
public static int getStatusBarHeight(Context ctx) {
int result = 0;
int resourceId = ctx.getResources().getIdentifier("status_bar_height", "dimen", "android");

View file

@ -1852,6 +1852,7 @@ public class OsmandAidlApi {
public void loadConnectedApps() {
try {
connectedApps.clear();
JSONArray array = new JSONArray(app.getSettings().API_CONNECTED_APPS_JSON.get());
for (int i = 0; i < array.length(); i++) {
JSONObject obj = array.getJSONObject(i);

View file

@ -991,15 +991,19 @@ public class OsmandApplication extends MultiDexApplication {
}
}
public void restartApp(Context ctx) {
public void restartApp(final Context ctx) {
AlertDialog.Builder bld = new AlertDialog.Builder(ctx);
bld.setMessage(R.string.restart_is_required);
bld.setPositiveButton(R.string.shared_string_ok, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (ctx instanceof MapActivity) {
MapActivity.doRestart(ctx);
} else {
android.os.Process.killProcess(android.os.Process.myPid());
}
}
});
bld.show();
}

View file

@ -170,6 +170,23 @@ public abstract class OsmandPlugin {
}
}
public static void updateActivatedPlugins(OsmandApplication app) {
Set<String> enabledPlugins = app.getSettings().getEnabledPlugins();
for (OsmandPlugin plugin : allPlugins) {
if (enabledPlugins.contains(plugin.getId())) {
try {
if (plugin.init(app, null)) {
plugin.setActive(true);
}
} catch (Exception e) {
LOG.error("Plugin initialization failed " + plugin.getId(), e);
}
} else if (plugin.isActive()) {
plugin.setActive(false);
}
}
}
private static void checkMarketPlugin(@NonNull OsmandApplication app, @NonNull Set<String> enabledPlugins,
@NonNull OsmandPlugin plugin, boolean paid, String id, String id2) {
boolean marketEnabled = Version.isMarketEnabled(app);

View file

@ -370,7 +370,7 @@ public class OsmandSettings {
OsmandAidlApi aidlApi = ctx.getAidlApi();
if (aidlApi != null) {
aidlApi.loadConnectedApps();
OsmandPlugin.initPlugins(ctx);
OsmandPlugin.updateActivatedPlugins(ctx);
}
fireEvent(oldMode);
@ -1644,7 +1644,7 @@ public class OsmandSettings {
public final CommonPreference<NotesSortByMode> NOTES_SORT_BY_MODE = new EnumIntPreference<>("notes_sort_by_mode", NotesSortByMode.BY_DATE, NotesSortByMode.values());
public final OsmandPreference<Boolean> ANIMATE_MY_LOCATION = new BooleanPreference("animate_my_location", true).makeGlobal().cache();
public final OsmandPreference<Boolean> ANIMATE_MY_LOCATION = new BooleanPreference("animate_my_location", true).makeProfile().cache();
public final OsmandPreference<Integer> EXTERNAL_INPUT_DEVICE = new IntPreference("external_input_device", 0).makeProfile();

View file

@ -128,7 +128,7 @@ import net.osmand.plus.search.QuickSearchDialogFragment;
import net.osmand.plus.search.QuickSearchDialogFragment.QuickSearchTab;
import net.osmand.plus.search.QuickSearchDialogFragment.QuickSearchType;
import net.osmand.plus.settings.BaseSettingsFragment;
import net.osmand.plus.settings.MainSettingsFragment;
import net.osmand.plus.settings.BaseSettingsFragment.SettingsScreenType;
import net.osmand.plus.views.AddGpxPointBottomSheetHelper.NewGpxPoint;
import net.osmand.plus.views.AnimateDraggingMapThread;
import net.osmand.plus.views.MapControlsLayer;
@ -161,6 +161,8 @@ import java.util.concurrent.Executors;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static net.osmand.plus.OsmAndCustomizationConstants.DRAWER_SETTINGS_ID;
public class MapActivity extends OsmandActionBarActivity implements DownloadEvents,
OnRequestPermissionsResultCallback, IRouteInformationListener, AMapPointUpdateListener,
MapMarkerChangedListener, OnDismissDialogFragmentListener, OnDrawMapListener,
@ -639,6 +641,13 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
chooseRouteFragment.dismiss(true);
return;
}
EditProfileFragment editProfileFragment = getEditProfileFragment();
if (editProfileFragment != null) {
if (!editProfileFragment.onBackPressedAllowed()) {
editProfileFragment.confirmCancelDialog(this);
return;
}
}
if (mapContextMenu.isVisible() && mapContextMenu.isClosable()) {
if (mapContextMenu.getCurrentMenuState() != MenuState.HEADER_ONLY) {
mapContextMenu.openMenuHeaderOnly();
@ -804,6 +813,13 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
}
setIntent(null);
}
if (intent.hasExtra(EditProfileFragment.OPEN_SETTINGS)) {
String settingsType = intent.getStringExtra(EditProfileFragment.OPEN_SETTINGS);
if (EditProfileFragment.OPEN_CONFIG_PROFILE.equals(settingsType)) {
BaseSettingsFragment.showInstance(this, SettingsScreenType.CONFIGURE_PROFILE);
}
setIntent(null);
}
if (intent.hasExtra(EditProfileFragment.OPEN_CONFIG_ON_MAP)) {
switch (intent.getStringExtra(EditProfileFragment.OPEN_CONFIG_ON_MAP)) {
case EditProfileFragment.MAP_CONFIG:
@ -936,10 +952,13 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
if (Build.VERSION.SDK_INT >= 21) {
int colorId = -1;
BaseOsmAndFragment fragmentAboveDashboard = getVisibleBaseOsmAndFragment(R.id.fragmentContainer);
BaseSettingsFragment settingsFragmentAboveDashboard = getVisibleBaseSettingsFragment(R.id.fragmentContainer);
BaseOsmAndFragment fragmentBelowDashboard = getVisibleBaseOsmAndFragment(R.id.routeMenuContainer,
R.id.topFragmentContainer, R.id.bottomFragmentContainer);
if (fragmentAboveDashboard != null) {
colorId = fragmentAboveDashboard.getStatusBarColorId();
} else if (settingsFragmentAboveDashboard != null) {
colorId = settingsFragmentAboveDashboard.getStatusBarColorId();
} else if (dashboardOnMap.isVisible()) {
colorId = dashboardOnMap.getStatusBarColor();
} else if (fragmentBelowDashboard != null) {
@ -989,6 +1008,17 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
return null;
}
private BaseSettingsFragment getVisibleBaseSettingsFragment(int... ids) {
for (int id : ids) {
Fragment fragment = getSupportFragmentManager().findFragmentById(id);
if (fragment != null && !fragment.isRemoving() && fragment.isVisible() && fragment instanceof BaseSettingsFragment
&& ((BaseSettingsFragment) fragment).getStatusBarColorId() != -1) {
return (BaseSettingsFragment) fragment;
}
}
return null;
}
public boolean isInAppPurchaseAllowed() {
return true;
}
@ -1943,25 +1973,31 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
@Override
public boolean onPreferenceStartFragment(PreferenceFragmentCompat caller, Preference pref) {
if (caller instanceof BaseSettingsFragment) {
BaseSettingsFragment baseFragment = (BaseSettingsFragment) caller;
ApplicationMode mode = baseFragment.getSelectedAppMode();
if (mode != null) {
try {
String fragmentName = pref.getFragment();
Fragment fragment = Fragment.instantiate(this, fragmentName);
getSupportFragmentManager().beginTransaction()
.replace(R.id.fragmentContainer, fragment, fragmentName)
.addToBackStack(fragmentName)
.commitAllowingStateLoss();
.replace(R.id.fragmentContainer, fragment, fragment.getClass().getSimpleName())
.addToBackStack(DRAWER_SETTINGS_ID + ".new")
.commit();
return true;
} catch (Exception e) {
LOG.error(e);
}
}
return false;
}
public void dismissSettingsScreens() {
try {
getSupportFragmentManager().popBackStack(DRAWER_SETTINGS_ID + ".new", FragmentManager.POP_BACK_STACK_INCLUSIVE);
} catch (Exception e) {
e.printStackTrace();
}
}
private class ScreenOffReceiver extends BroadcastReceiver {
@Override
@ -2179,7 +2215,8 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
}
public void showSettings() {
MainSettingsFragment.showInstance(getSupportFragmentManager());
dismissSettingsScreens();
BaseSettingsFragment.showInstance(this, SettingsScreenType.MAIN_SETTINGS);
}
private void hideContextMenu() {
@ -2218,6 +2255,11 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
return fragment != null && !fragment.isDetached() && !fragment.isRemoving() ? (ChooseRouteFragment) fragment : null;
}
public EditProfileFragment getEditProfileFragment() {
Fragment fragment = getSupportFragmentManager().findFragmentByTag(EditProfileFragment.TAG);
return fragment != null && !fragment.isDetached() && !fragment.isRemoving() ? (EditProfileFragment) fragment : null;
}
public boolean isTopToolbarActive() {
MapInfoLayer mapInfoLayer = getMapLayers().getMapInfoLayer();
return mapInfoLayer.hasTopToolbar();

View file

@ -63,7 +63,7 @@ import net.osmand.plus.routepreparationmenu.MapRouteInfoMenu;
import net.osmand.plus.routepreparationmenu.WaypointsFragment;
import net.osmand.plus.routing.RouteProvider.GPXRouteParamsBuilder;
import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.settings.ConfigureProfileFragment;
import net.osmand.plus.settings.BaseSettingsFragment;
import net.osmand.plus.views.BaseMapLayer;
import net.osmand.plus.views.MapControlsLayer;
import net.osmand.plus.views.MapTileLayer;
@ -1009,7 +1009,8 @@ public class MapActivityActions implements DialogProvider {
.setListener(new ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int position, boolean isChecked, int[] viewCoordinates) {
ConfigureProfileFragment.showInstance(mapActivity.getSupportFragmentManager());
mapActivity.dismissSettingsScreens();
BaseSettingsFragment.showInstance(mapActivity, BaseSettingsFragment.SettingsScreenType.CONFIGURE_PROFILE);
return true;
}
})

View file

@ -1,7 +1,6 @@
package net.osmand.plus.osmedit;
import static net.osmand.plus.osmedit.EditPoiDialogFragment.AMENITY_TEXT_LENGTH;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.annotation.NonNull;
@ -9,6 +8,7 @@ import android.support.annotation.Nullable;
import android.text.Editable;
import android.text.InputFilter;
import android.text.TextWatcher;
import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnFocusChangeListener;
@ -19,6 +19,7 @@ import android.widget.Button;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.TextView;
import net.osmand.PlatformUtil;
import net.osmand.osm.AbstractPoiType;
import net.osmand.osm.MapPoiTypes;
@ -28,7 +29,6 @@ import net.osmand.osm.PoiType;
import net.osmand.osm.edit.OSMSettings;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.base.BaseOsmAndFragment;
import net.osmand.util.Algorithms;
@ -39,6 +39,8 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import static net.osmand.plus.osmedit.EditPoiDialogFragment.AMENITY_TEXT_LENGTH;
public class AdvancedEditPoiFragment extends BaseOsmAndFragment
implements EditPoiDialogFragment.OnFragmentActivatedListener {
private static final String TAG = "AdvancedEditPoiFragment";
@ -60,7 +62,9 @@ public class AdvancedEditPoiFragment extends BaseOsmAndFragment
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.fragment_edit_poi_advanced, container, false);
int themeRes = requireMyApplication().getSettings().isLightActionBar() ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme;
Context themedContext = new ContextThemeWrapper(getContext(), themeRes);
final View view = inflater.cloneInContext(themedContext).inflate(R.layout.fragment_edit_poi_advanced, container, false);
OsmandApplication app = requireMyApplication();
deleteDrawable = app.getUIUtilities().getIcon(R.drawable.ic_action_remove_dark, app.getSettings().isLightContent());

View file

@ -1,5 +1,6 @@
package net.osmand.plus.osmedit;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
@ -11,6 +12,7 @@ import android.text.InputFilter;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.util.TypedValue;
import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -55,10 +57,12 @@ public class BasicEditPoiFragment extends BaseOsmAndFragment
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_edit_poi_normal, container, false);
int themeRes = requireMyApplication().getSettings().isLightActionBar() ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme;
Context themedContext = new ContextThemeWrapper(getContext(), themeRes);
View view = inflater.cloneInContext(themedContext).inflate(R.layout.fragment_edit_poi_normal, container, false);
TypedValue typedValue = new TypedValue();
Resources.Theme theme = getActivity().getTheme();
Resources.Theme theme = themedContext.getTheme();
theme.resolveAttribute(android.R.attr.textColorSecondary, typedValue, true);
int iconColor = typedValue.data;

View file

@ -11,16 +11,19 @@ import android.view.ViewGroup;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import net.osmand.PlatformUtil;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.settings.BaseSettingsFragment;
import net.osmand.util.Algorithms;
import org.apache.commons.logging.Log;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
public class ConfigureProfileMenuAdapter extends AbstractProfileMenuAdapter<ConfigureProfileMenuAdapter.ConfigureProfileViewHolder> {
@ -101,12 +104,7 @@ public class ConfigureProfileMenuAdapter extends AbstractProfileMenuAdapter<Conf
holder.menuIcon.setVisibility(View.VISIBLE);
final ApplicationMode item = (ApplicationMode) obj;
holder.title.setText(item.toHumanString(app));
if (item.isCustomProfile()) {
holder.descr.setText(String.format(app.getString(R.string.profile_type_descr_string),
Algorithms.capitalizeFirstLetterAndLowercase(item.getParent().toHumanString(app))));
} else {
holder.descr.setText(R.string.profile_type_base_string);
}
holder.descr.setText(BaseSettingsFragment.getAppModeDescription(app, item));
holder.initSwitcher = true;
holder.switcher.setChecked(selectedItems.contains(item));

View file

@ -8,14 +8,12 @@ import android.support.v4.view.MenuItemCompat;
import android.view.Menu;
import android.view.MenuItem;
import net.osmand.PlatformUtil;
import net.osmand.plus.R;
import net.osmand.plus.activities.OsmandActionBarActivity;
public class EditProfileActivity extends OsmandActionBarActivity {
public static final int DELETE_ID = 1010;
public static final String EDIT_PROFILE_FRAGMENT_TAG = "editProfileFragment";
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
@ -27,7 +25,7 @@ public class EditProfileActivity extends OsmandActionBarActivity {
EditProfileFragment editProfileFragment = new EditProfileFragment();
editProfileFragment.setArguments(getIntent().getExtras());
getSupportFragmentManager().beginTransaction().add(android.R.id.content,
editProfileFragment, EDIT_PROFILE_FRAGMENT_TAG).commit();
editProfileFragment, EditProfileFragment.TAG).commit();
}
}
@ -53,7 +51,7 @@ public class EditProfileActivity extends OsmandActionBarActivity {
return true;
case DELETE_ID:
((EditProfileFragment) getSupportFragmentManager().findFragmentByTag(
EDIT_PROFILE_FRAGMENT_TAG)).onDeleteProfileClick();
EditProfileFragment.TAG)).onDeleteProfileClick();
return true;
}
@ -63,7 +61,7 @@ public class EditProfileActivity extends OsmandActionBarActivity {
@Override
public void onBackPressed() {
final EditProfileFragment epf = (EditProfileFragment) getSupportFragmentManager()
.findFragmentByTag(EDIT_PROFILE_FRAGMENT_TAG);
.findFragmentByTag(EditProfileFragment.TAG);
if (epf.onBackPressedAllowed()) {
super.onBackPressed();
} else {

View file

@ -1,15 +1,5 @@
package net.osmand.plus.profiles;
import static net.osmand.plus.activities.SettingsNavigationActivity.INTENT_SKIP_DIALOG;
import static net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment.DIALOG_TYPE;
import static net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment.SELECTED_KEY;
import static net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment.TYPE_BASE_APP_PROFILE;
import static net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment.TYPE_ICON;
import static net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment.TYPE_NAV_PROFILE;
import static net.osmand.plus.profiles.SettingsProfileFragment.IS_NEW_PROFILE;
import static net.osmand.plus.profiles.SettingsProfileFragment.IS_USER_PROFILE;
import static net.osmand.plus.profiles.SettingsProfileFragment.PROFILE_STRING_KEY;
import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
@ -22,17 +12,20 @@ import android.os.Build.VERSION_CODES;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.app.ActionBar;
import android.support.design.widget.AppBarLayout;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.view.ViewCompat;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AlertDialog.Builder;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.ContextThemeWrapper;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
import android.view.inputmethod.InputMethodManager;
import android.widget.AdapterView;
@ -46,10 +39,7 @@ import android.widget.ListPopupWindow;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.Toast;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import net.osmand.AndroidUtils;
import net.osmand.PlatformUtil;
import net.osmand.plus.ApplicationMode;
@ -57,21 +47,43 @@ import net.osmand.plus.ApplicationMode.ProfileIconColors;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.OsmandActionBarActivity;
import net.osmand.plus.activities.SettingsNavigationActivity;
import net.osmand.plus.base.BaseOsmAndFragment;
import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment.SelectProfileListener;
import net.osmand.plus.routing.RouteProvider.RouteService;
import net.osmand.plus.settings.BaseSettingsFragment;
import net.osmand.plus.settings.BaseSettingsFragment.SettingsScreenType;
import net.osmand.plus.widgets.OsmandTextFieldBoxes;
import net.osmand.router.GeneralRouter;
import net.osmand.util.Algorithms;
import org.apache.commons.logging.Log;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import studio.carbonylgroup.textfieldboxes.ExtendedEditText;
import static net.osmand.plus.OsmAndCustomizationConstants.DRAWER_SETTINGS_ID;
import static net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment.DIALOG_TYPE;
import static net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment.SELECTED_KEY;
import static net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment.TYPE_BASE_APP_PROFILE;
import static net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment.TYPE_ICON;
import static net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment.TYPE_NAV_PROFILE;
import static net.osmand.plus.profiles.SettingsProfileFragment.IS_NEW_PROFILE;
import static net.osmand.plus.profiles.SettingsProfileFragment.IS_USER_PROFILE;
import static net.osmand.plus.profiles.SettingsProfileFragment.PROFILE_STRING_KEY;
public class EditProfileFragment extends BaseOsmAndFragment {
private static final Log LOG = PlatformUtil.getLog(EditProfileFragment.class);
public static final String TAG = EditProfileFragment.class.getSimpleName();
public static final String OPEN_CONFIG_PROFILE = "openConfigProfile";
public static final String OPEN_SETTINGS = "openSettings";
public static final String OPEN_CONFIG_ON_MAP = "openConfigOnMap";
public static final String MAP_CONFIG = "openMapConfigMenu";
public static final String NAV_CONFIG = "openNavConfigMenu";
@ -96,6 +108,7 @@ public class EditProfileFragment extends BaseOsmAndFragment {
private SelectProfileListener iconIdListener = null;
private SelectProfileListener baseTypeListener = null;
private TextView toolbarTitle;
private ImageView profileIcon;
private LinearLayout profileIconBtn;
private ImageView colorSample;
@ -107,9 +120,7 @@ public class EditProfileFragment extends BaseOsmAndFragment {
private FrameLayout selectNavTypeBtn;
private Button cancelBtn;
private Button saveButton;
private View mapConfigBtn;
private View screenConfigBtn;
private View navConfigBtn;
private View profileConfigBtn;
private LinearLayout buttonsLayout;
private FrameLayout clickBlockLayout;
private LinearLayout typeSelectionBtn;
@ -139,9 +150,15 @@ public class EditProfileFragment extends BaseOsmAndFragment {
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
final EditProfileActivity activity = (EditProfileActivity) getActivity();
final View view = inflater.inflate(R.layout.fragment_selected_profile, container, false);
final FragmentActivity activity = getActivity();
int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
Context themedContext = new ContextThemeWrapper(getContext(), themeRes);
final View view = inflater.cloneInContext(themedContext).inflate(R.layout.fragment_selected_profile, container, false);
setupToolbar(view);
toolbarTitle = view.findViewById(R.id.toolbar_title);
profileIcon = view.findViewById(R.id.profile_icon_img);
profileIconBtn = view.findViewById(R.id.select_icon_button);
colorSample = view.findViewById(R.id.color_sample_img);
@ -153,9 +170,7 @@ public class EditProfileFragment extends BaseOsmAndFragment {
selectNavTypeBtn = view.findViewById(R.id.select_nav_type_btn);
cancelBtn = view.findViewById(R.id.cancel_button);
saveButton = view.findViewById(R.id.save_profile_btn);
mapConfigBtn = view.findViewById(R.id.map_config_btn);
screenConfigBtn = view.findViewById(R.id.screen_config_btn);
navConfigBtn = view.findViewById(R.id.nav_settings_btn);
profileConfigBtn = view.findViewById(R.id.profile_config_btn);
buttonsLayout = view.findViewById(R.id.buttons_layout);
clickBlockLayout = view.findViewById(R.id.click_block_layout);
typeSelectionBtn = view.findViewById(R.id.type_selection_button);
@ -242,11 +257,7 @@ public class EditProfileFragment extends BaseOsmAndFragment {
}
profileNameEt.clearFocus();
if (getActivity() != null
&& ((EditProfileActivity) getActivity()).getSupportActionBar() != null) {
((EditProfileActivity) getActivity()).getSupportActionBar().setTitle(title);
((EditProfileActivity) getActivity()).getSupportActionBar().setElevation(5.0f);
}
updateToolbar(title);
int iconColor = profile.iconColor.getColor(nightMode);
@ -264,15 +275,10 @@ public class EditProfileFragment extends BaseOsmAndFragment {
@Override
public void afterTextChanged(Editable s) {
if (getActivity() instanceof OsmandActionBarActivity) {
ActionBar actionBar = ((OsmandActionBarActivity) getActivity())
.getSupportActionBar();
if (actionBar != null) {
actionBar.setTitle(s.toString());
profile.userProfileTitle = s.toString();
isCancelAllowed = false;
}
}
updateToolbar(s.toString());
}
});
@ -358,7 +364,7 @@ public class EditProfileFragment extends BaseOsmAndFragment {
}
mapConfigBtn.setOnClickListener(new OnClickListener() {
profileConfigBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (isDataChanged) {
@ -366,44 +372,16 @@ public class EditProfileFragment extends BaseOsmAndFragment {
} else if (getSettings() != null) {
activateMode(mode);
getSettings().APPLICATION_MODE.set(mode);
Intent i = new Intent(getActivity(), MapActivity.class);
i.putExtra(OPEN_CONFIG_ON_MAP, MAP_CONFIG);
i.putExtra(SELECTED_ITEM, profile.stringKey);
startActivity(i);
}
}
});
screenConfigBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (isDataChanged) {
needSaveDialog();
} else if (getSettings() != null) {
activateMode(mode);
getSettings().APPLICATION_MODE.set(mode);
if (activity instanceof EditProfileActivity) {
Intent i = new Intent(getActivity(), MapActivity.class);
i.putExtra(OPEN_CONFIG_ON_MAP, SCREEN_CONFIG);
i.putExtra(OPEN_SETTINGS, OPEN_CONFIG_PROFILE);
i.putExtra(SELECTED_ITEM, profile.stringKey);
startActivity(i);
} else {
BaseSettingsFragment.showInstance(activity, SettingsScreenType.CONFIGURE_PROFILE);
}
}
});
navConfigBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (isDataChanged) {
needSaveDialog();
} else if (getSettings() != null) {
activateMode(mode);
getSettings().APPLICATION_MODE.set(mode);
Intent i = new Intent(getActivity(), SettingsNavigationActivity.class);
i.putExtra(INTENT_SKIP_DIALOG, true);
i.putExtra(OPEN_CONFIG_ON_MAP, NAV_CONFIG);
i.putExtra(SELECTED_ITEM, profile.stringKey);
startActivity(i);
}
}
});
@ -450,13 +428,13 @@ public class EditProfileFragment extends BaseOsmAndFragment {
});
}
final float d = getResources().getDisplayMetrics().density;
view.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
int marginShow = 66;
int marginHide = 0;
float d = getResources().getDisplayMetrics().density;
Rect r = new Rect();
view.getWindowVisibleDisplayFrame(r);
int screenHeight = view.getRootView().getHeight();
@ -483,7 +461,12 @@ public class EditProfileFragment extends BaseOsmAndFragment {
super.onResume();
}
boolean onBackPressedAllowed() {
@Override
public int getStatusBarColorId() {
return nightMode ? R.color.status_bar_color_dark : R.color.status_bar_color_light;
}
public boolean onBackPressedAllowed() {
return isCancelAllowed;
}
@ -567,6 +550,53 @@ public class EditProfileFragment extends BaseOsmAndFragment {
}
}
private void setupToolbar(View view) {
FragmentActivity activity = getActivity();
AppBarLayout appBar = (AppBarLayout) view.findViewById(R.id.appbar);
if ((activity instanceof EditProfileActivity)) {
EditProfileActivity editProfileActivity = (EditProfileActivity) activity;
if (editProfileActivity.getSupportActionBar() != null) {
editProfileActivity.getSupportActionBar().setElevation(5.0f);
}
AndroidUiHelper.updateVisibility(appBar, false);
} else {
AndroidUtils.addStatusBarPadding21v(activity, view);
ViewCompat.setElevation(appBar, 5.0f);
View closeButton = view.findViewById(R.id.close_button);
closeButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
FragmentActivity fragmentActivity = getActivity();
if (fragmentActivity != null) {
fragmentActivity.onBackPressed();
}
}
});
View deleteBtn = view.findViewById(R.id.delete_button);
deleteBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onDeleteProfileClick();
}
});
}
}
private void updateToolbar(String title) {
FragmentActivity activity = getActivity();
if (activity instanceof EditProfileActivity) {
EditProfileActivity editProfileActivity = (EditProfileActivity) activity;
if (editProfileActivity.getSupportActionBar() != null) {
editProfileActivity.getSupportActionBar().setTitle(title);
}
} else {
toolbarTitle.setText(title);
}
}
private void setupBaseProfileView(String stringKey) {
for (ApplicationMode am : ApplicationMode.getDefaultValues()) {
if (am.getStringKey().equals(stringKey)) {
@ -671,7 +701,7 @@ public class EditProfileFragment extends BaseOsmAndFragment {
bld.show();
}
void confirmCancelDialog(final Activity activity) {
public void confirmCancelDialog(final Activity activity) {
AlertDialog.Builder bld = new Builder(activity);
bld.setTitle(R.string.shared_string_dismiss);
bld.setMessage(R.string.exit_without_saving);
@ -699,12 +729,15 @@ public class EditProfileFragment extends BaseOsmAndFragment {
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
ApplicationMode
.deleteCustomMode(mode, getMyApplication());
OsmandApplication app = getMyApplication();
if (app != null) {
ApplicationMode.deleteCustomMode(mode, app);
app.getSettings().APPLICATION_MODE.set(ApplicationMode.DEFAULT);
}
if (getActivity() != null) {
getActivity().onBackPressed();
}
getSettings().APPLICATION_MODE.set(ApplicationMode.DEFAULT);
}
});
bld.setNegativeButton(R.string.shared_string_dismiss, null);
@ -726,6 +759,26 @@ public class EditProfileFragment extends BaseOsmAndFragment {
}
}
public static boolean showInstance(FragmentManager fragmentManager, boolean newProfile, boolean userProfile, String profileKey) {
try {
Bundle args = new Bundle();
args.putBoolean(IS_NEW_PROFILE, newProfile);
args.putBoolean(IS_USER_PROFILE, userProfile);
args.putString(PROFILE_STRING_KEY, profileKey);
EditProfileFragment editProfileFragment = new EditProfileFragment();
editProfileFragment.setArguments(args);
fragmentManager.beginTransaction()
.replace(R.id.fragmentContainer, editProfileFragment, TAG)
.addToBackStack(DRAWER_SETTINGS_ID + ".new")
.commit();
return true;
} catch (Exception e) {
return false;
}
}
static List<RoutingProfileDataObject> getRoutingProfiles(OsmandApplication context) {
List<RoutingProfileDataObject> profilesObjects = new ArrayList<>();
profilesObjects.add(new RoutingProfileDataObject(

View file

@ -1,30 +1,30 @@
package net.osmand.plus.profiles;
import static net.osmand.plus.profiles.EditProfileFragment.SELECTED_ICON;
import android.content.res.ColorStateList;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.SwitchCompat;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import net.osmand.PlatformUtil;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithCompoundButton;
import net.osmand.plus.base.bottomsheetmenu.simpleitems.LongDescriptionItem;
import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem;
import org.apache.commons.logging.Log;
import java.util.ArrayList;
import java.util.List;
import static net.osmand.plus.profiles.EditProfileFragment.SELECTED_ICON;
public class SelectProfileBottomSheetDialogFragment extends MenuBottomSheetDialogFragment {
private static final Log LOG = PlatformUtil
@ -217,20 +217,27 @@ public class SelectProfileBottomSheetDialogFragment extends MenuBottomSheetDialo
private void getListener() {
if (getActivity() != null && getActivity() instanceof EditProfileActivity) {
EditProfileFragment f = (EditProfileFragment) getActivity().getSupportFragmentManager()
.findFragmentByTag(EditProfileActivity.EDIT_PROFILE_FRAGMENT_TAG);
if (type.equals(TYPE_BASE_APP_PROFILE)) {
listener = f.getBaseProfileListener();
} else if (type.equals(TYPE_NAV_PROFILE)) {
listener = f.getNavProfileListener();
} else if (type.equals(TYPE_ICON)) {
listener = f.getIconListener();
FragmentActivity activity = getActivity();
if (activity != null) {
FragmentManager fragmentManager = activity.getSupportFragmentManager();
EditProfileFragment editProfileFragment = (EditProfileFragment) fragmentManager.findFragmentByTag(EditProfileFragment.TAG);
SettingsProfileFragment settingsProfileFragment = (SettingsProfileFragment) fragmentManager.findFragmentByTag(SettingsProfileFragment.TAG);
if (editProfileFragment != null) {
switch (type) {
case TYPE_BASE_APP_PROFILE:
listener = editProfileFragment.getBaseProfileListener();
break;
case TYPE_NAV_PROFILE:
listener = editProfileFragment.getNavProfileListener();
break;
case TYPE_ICON:
listener = editProfileFragment.getIconListener();
break;
}
} else if (settingsProfileFragment != null) {
listener = settingsProfileFragment.getBaseProfileListener();
}
} else if (getActivity() != null && getActivity() instanceof SettingsProfileActivity) {
SettingsProfileFragment f = (SettingsProfileFragment) getActivity().getSupportFragmentManager()
.findFragmentByTag(SettingsProfileActivity.SETTINGS_PROFILE_FRAGMENT_TAG);
listener = f.getBaseProfileListener();
}
}

View file

@ -18,6 +18,7 @@ import net.osmand.plus.ApplicationMode;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.settings.BaseSettingsFragment;
import net.osmand.util.Algorithms;
import org.apache.commons.logging.Log;
@ -95,12 +96,7 @@ public class SelectProfileMenuAdapter extends AbstractProfileMenuAdapter<SelectP
holder.menuIcon.setVisibility(View.GONE);
final ApplicationMode item = (ApplicationMode) obj;
holder.title.setText(item.toHumanString(app));
if (item.isCustomProfile()) {
holder.descr.setText(String.format(app.getString(R.string.profile_type_descr_string),
Algorithms.capitalizeFirstLetterAndLowercase(item.getParent().toHumanString(app))));
} else {
holder.descr.setText(R.string.profile_type_base_string);
}
holder.descr.setText(BaseSettingsFragment.getAppModeDescription(app, item));
int profileColorResId = item.getIconColorInfo().getColor(nightMode);
holder.icon.setImageDrawable(app.getUIUtilities().getIcon(profileColorResId, selectedIconColorRes));

View file

@ -2,13 +2,12 @@ package net.osmand.plus.profiles;
import android.os.Bundle;
import android.view.MenuItem;
import net.osmand.plus.R;
import net.osmand.plus.activities.OsmandActionBarActivity;
public class SettingsProfileActivity extends OsmandActionBarActivity {
public static final String SETTINGS_PROFILE_FRAGMENT_TAG = "settingsProfileFragment";
@Override
public void onCreate(Bundle savedInstanceState) {
getMyApplication().applyTheme(this);
@ -20,7 +19,7 @@ public class SettingsProfileActivity extends OsmandActionBarActivity {
SettingsProfileFragment profileFragment = new SettingsProfileFragment();
profileFragment.setArguments(getIntent().getExtras());
getSupportFragmentManager().beginTransaction()
.add(android.R.id.content, profileFragment, SETTINGS_PROFILE_FRAGMENT_TAG).commit();
.add(android.R.id.content, profileFragment, SettingsProfileFragment.TAG).commit();
}
}

View file

@ -10,21 +10,32 @@ import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.AppBarLayout;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.view.ViewCompat;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import net.osmand.AndroidUtils;
import net.osmand.PlatformUtil;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.BaseOsmAndFragment;
import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment.SelectProfileListener;
import org.apache.commons.logging.Log;
@ -34,21 +45,22 @@ public class SettingsProfileFragment extends BaseOsmAndFragment
private static final Log LOG = PlatformUtil.getLog(SettingsProfileFragment.class);
public static final String TAG = "SettingsProfileFragment";
public static final String PROFILE_STRING_KEY = "string_key";
public static final String IS_NEW_PROFILE = "new_profile";
public static final String IS_USER_PROFILE = "user_profile";
private ConfigureProfileMenuAdapter adapter;
private RecyclerView recyclerView;
private LinearLayout addNewProfileBtn;
SelectProfileListener typeListener = null;
private SelectProfileListener typeListener = null;
private List<ApplicationMode> allAppModes;
private Set<ApplicationMode> availableAppModes;
private List<ProfileDataObject> baseProfiles;
private boolean nightMode;
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@ -63,10 +75,36 @@ public class SettingsProfileFragment extends BaseOsmAndFragment
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
nightMode = !requireSettings().isLightContent();
View view = inflater.inflate(R.layout.profiles_list_fragment, container, false);
recyclerView = view.findViewById(R.id.profiles_list);
addNewProfileBtn = view.findViewById(R.id.add_profile_btn);
int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
Context themedContext = new ContextThemeWrapper(getContext(), themeRes);
View view = inflater.cloneInContext(themedContext).inflate(R.layout.profiles_list_fragment, container, false);
AppBarLayout appBar = (AppBarLayout) view.findViewById(R.id.appbar);
if (!(getActivity() instanceof SettingsProfileActivity)) {
AndroidUtils.addStatusBarPadding21v(getContext(), view);
ViewCompat.setElevation(appBar, 5.0f);
TextView toolbarTitle = (TextView) view.findViewById(R.id.toolbar_title);
toolbarTitle.setText(R.string.application_profiles);
View closeButton = view.findViewById(R.id.close_button);
closeButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
MapActivity mapActivity = (MapActivity) getActivity();
if (mapActivity != null) {
mapActivity.onBackPressed();
}
}
});
} else {
AndroidUiHelper.updateVisibility(appBar, false);
}
RecyclerView recyclerView = view.findViewById(R.id.profiles_list);
LinearLayout addNewProfileBtn = view.findViewById(R.id.add_profile_btn);
addNewProfileBtn.setOnClickListener(new OnClickListener() {
@ -102,16 +140,32 @@ public class SettingsProfileFragment extends BaseOsmAndFragment
adapter.updateItemsList(allAppModes, new LinkedHashSet<>(ApplicationMode.values(getMyApplication())));
}
@Override
public int getStatusBarColorId() {
return nightMode ? R.color.status_bar_color_dark : R.color.status_bar_color_light;
}
SelectProfileListener getBaseProfileListener() {
if (typeListener == null) {
typeListener = new SelectProfileListener() {
@Override
public void onSelectedType(int pos, String stringRes) {
FragmentActivity activity = getActivity();
if (activity != null) {
if (activity instanceof SettingsProfileActivity) {
Intent intent = new Intent(getActivity(), EditProfileActivity.class);
intent.putExtra(IS_NEW_PROFILE, true);
intent.putExtra(IS_USER_PROFILE, true);
intent.putExtra(PROFILE_STRING_KEY, baseProfiles.get(pos).getStringKey());
startActivity(intent);
activity.startActivity(intent);
} else {
FragmentManager fragmentManager = activity.getSupportFragmentManager();
if (fragmentManager != null) {
String profileKey = baseProfiles.get(pos).getStringKey();
EditProfileFragment.showInstance(fragmentManager, true, true, profileKey);
}
}
}
}
};
}
@ -131,17 +185,28 @@ public class SettingsProfileFragment extends BaseOsmAndFragment
@Override
public void onProfilePressed(ApplicationMode item) {
FragmentActivity activity = getActivity();
if (activity != null) {
if (activity instanceof SettingsProfileActivity) {
Intent intent = new Intent(getActivity(), EditProfileActivity.class);
intent.putExtra(PROFILE_STRING_KEY, item.getStringKey());
if (item.isCustomProfile()) {
intent.putExtra(IS_USER_PROFILE, true);
}
startActivity(intent);
activity.startActivity(intent);
} else {
FragmentManager fragmentManager = activity.getSupportFragmentManager();
if (fragmentManager != null) {
String profileKey = item.getStringKey();
EditProfileFragment.showInstance(fragmentManager, false, item.isCustomProfile(), profileKey);
}
}
}
}
@Override
public void onProfileSelected(ApplicationMode item, boolean isChecked) {
if(isChecked) {
if (isChecked) {
availableAppModes.add(item);
} else {
availableAppModes.remove(item);

View file

@ -10,15 +10,14 @@ 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.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.ViewCompat;
import android.support.v7.preference.EditTextPreference;
import android.support.v7.preference.ListPreference;
import android.support.v7.preference.Preference;
@ -57,27 +56,64 @@ import net.osmand.plus.settings.bottomsheets.SingleSelectPreferenceBottomSheet;
import net.osmand.plus.settings.preferences.ListPreferenceEx;
import net.osmand.plus.settings.preferences.MultiSelectBooleanPreference;
import net.osmand.plus.settings.preferences.SwitchPreferenceEx;
import net.osmand.util.Algorithms;
import org.apache.commons.logging.Log;
import static net.osmand.plus.OsmAndCustomizationConstants.DRAWER_SETTINGS_ID;
public abstract class BaseSettingsFragment extends PreferenceFragmentCompat implements OnPreferenceChangeListener,
OnPreferenceClickListener, AppModeChangedListener {
protected final Log log = PlatformUtil.getLog(this.getClass());
private static final Log LOG = PlatformUtil.getLog(BaseSettingsFragment.class);
protected OsmandApplication app;
protected OsmandSettings settings;
protected UiUtilities iconsCache;
private int themeRes;
protected int themeRes;
private SettingsScreenType currentScreenType;
private int statusBarColor = -1;
private boolean nightMode;
private boolean wasDrawerDisabled;
public enum SettingsScreenType {
MAIN_SETTINGS(MainSettingsFragment.class.getName(), false, R.xml.settings_main_screen, R.layout.global_preference_toolbar),
GLOBAL_SETTINGS(GlobalSettingsFragment.class.getName(), false, R.xml.global_settings, R.layout.global_preference_toolbar),
CONFIGURE_PROFILE(ConfigureProfileFragment.class.getName(), true, R.xml.configure_profile, R.layout.profile_preference_toolbar_big),
PROXY_SETTINGS(ProxySettingsFragment.class.getName(), false, R.xml.proxy_preferences, R.layout.global_preferences_toolbar_with_switch),
GENERAL_PROFILE(GeneralProfileSettingsFragment.class.getName(), true, R.xml.general_profile_settings, R.layout.profile_preference_toolbar_big),
NAVIGATION(NavigationFragment.class.getName(), true, R.xml.navigation_settings_new, R.layout.profile_preference_toolbar_big),
COORDINATES_FORMAT(CoordinatesFormatFragment.class.getName(), true, R.xml.coordinates_format, R.layout.profile_preference_toolbar),
ROUTE_PARAMETERS(RouteParametersFragment.class.getName(), true, R.xml.route_parameters, R.layout.profile_preference_toolbar),
SCREEN_ALERTS(ScreenAlertsFragment.class.getName(), true, R.xml.screen_alerts, R.layout.profile_preference_toolbar_with_switch),
VOICE_ANNOUNCES(VoiceAnnouncesFragment.class.getName(), true, R.xml.voice_announces, R.layout.profile_preference_toolbar_with_switch),
VEHICLE_PARAMETERS(VehicleParametersFragment.class.getName(), true, R.xml.vehicle_parameters, R.layout.profile_preference_toolbar),
MAP_DURING_NAVIGATION(MapDuringNavigationFragment.class.getName(), true, R.xml.map_during_navigation, R.layout.profile_preference_toolbar),
TURN_SCREEN_ON(TurnScreenOnFragment.class.getName(), true, R.xml.turn_screen_on, R.layout.profile_preference_toolbar_with_switch);
public final String fragmentName;
public final boolean profileDependent;
public final int preferencesResId;
public final int toolbarResId;
SettingsScreenType(String fragmentName, boolean profileDependent, int preferencesResId, int toolbarResId) {
this.fragmentName = fragmentName;
this.profileDependent = profileDependent;
this.preferencesResId = preferencesResId;
this.toolbarResId = toolbarResId;
}
}
@Override
public void onCreate(Bundle savedInstanceState) {
app = requireMyApplication();
settings = app.getSettings();
super.onCreate(savedInstanceState);
currentScreenType = getCurrentScreenType();
}
@Override
@ -93,15 +129,21 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
View view = super.onCreateView(inflater, container, savedInstanceState);
if (view != null) {
AndroidUtils.addStatusBarPadding21v(getContext(), view);
updateAllSettings();
createToolbar(inflater, view);
setDivider(null);
updateAllSettings();
view.setBackgroundColor(ContextCompat.getColor(app, getBackgroundColorRes()));
}
return view;
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
updateToolbar();
}
@Override
public RecyclerView onCreateRecyclerView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {
Context themedContext = new ContextThemeWrapper(getActivity(), themeRes);
@ -133,7 +175,6 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
@Override
public void onResume() {
super.onResume();
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
wasDrawerDisabled = mapActivity.isDrawerDisabled();
@ -141,6 +182,21 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
mapActivity.disableDrawer();
}
}
if (Build.VERSION.SDK_INT >= 21) {
Activity activity = getActivity();
if (activity != null) {
int colorId = getStatusBarColorId();
if (colorId != -1) {
if (activity instanceof MapActivity) {
((MapActivity) activity).updateStatusBarColor();
} else {
statusBarColor = activity.getWindow().getStatusBarColor();
activity.getWindow().setStatusBarColor(ContextCompat.getColor(activity, colorId));
}
}
}
}
}
@Override
@ -151,6 +207,40 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
if (!wasDrawerDisabled && mapActivity != null) {
mapActivity.enableDrawer();
}
if (Build.VERSION.SDK_INT >= 21) {
Activity activity = getActivity();
if (activity != null) {
if (!(activity instanceof MapActivity) && statusBarColor != -1) {
activity.getWindow().setStatusBarColor(statusBarColor);
}
}
}
}
@Override
public void onDetach() {
super.onDetach();
if (Build.VERSION.SDK_INT >= 21 && getStatusBarColorId() != -1) {
Activity activity = getActivity();
if (activity instanceof MapActivity) {
((MapActivity) activity).updateStatusBarColor();
}
}
}
@ColorRes
public int getStatusBarColorId() {
boolean nightMode = isNightMode();
if (currentScreenType.profileDependent) {
View view = getView();
if (view != null && Build.VERSION.SDK_INT >= 23 && !nightMode) {
view.setSystemUiVisibility(view.getSystemUiVisibility() | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
}
return nightMode ? R.color.list_background_color_dark : R.color.list_background_color_light;
} else {
return nightMode ? R.color.status_bar_color_dark : R.color.status_bar_color_light;
}
}
@Override
@ -185,6 +275,7 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
@Override
public void onAppModeChanged() {
updateToolbar();
updateAllSettings();
}
@ -206,15 +297,18 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
adapter.onPreferenceChange(preference);
}
private void createToolbar(LayoutInflater inflater, View view) {
protected void createToolbar(LayoutInflater inflater, View view) {
AppBarLayout appBarLayout = (AppBarLayout) view.findViewById(R.id.appbar);
ViewCompat.setElevation(appBarLayout, 5.0f);
int toolbarRes = getToolbarResId();
if (toolbarRes != -1) {
Context themedContext = new ContextThemeWrapper(getActivity(), themeRes);
View toolbarContainer = inflater.cloneInContext(themedContext).inflate(toolbarRes, appBarLayout);
View toolbarContainer = inflater.cloneInContext(themedContext).inflate(currentScreenType.toolbarResId, appBarLayout);
toolbarContainer.findViewById(R.id.close_button).setOnClickListener(new View.OnClickListener() {
TextView toolbarTitle = (TextView) view.findViewById(R.id.toolbar_title);
toolbarTitle.setText(getPreferenceScreen().getTitle());
View closeButton = view.findViewById(R.id.close_button);
closeButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
MapActivity mapActivity = getMapActivity();
@ -223,8 +317,9 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
}
}
});
View switchProfile = toolbarContainer.findViewById(R.id.switch_profile_button);
View switchProfile = toolbarContainer.findViewById(R.id.profile_button);
if (switchProfile != null) {
switchProfile.setContentDescription(getString(R.string.switch_profile));
switchProfile.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -235,11 +330,10 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
}
});
}
updateToolbar(toolbarContainer);
}
}
private void updateToolbar(View view) {
protected void updateToolbar() {
View view = getView();
if (view == null) {
return;
}
@ -247,10 +341,6 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
ApplicationMode selectedAppMode = getSelectedAppMode();
int iconColor = getActiveProfileColor();
TextView toolbarTitle = (TextView) view.findViewById(R.id.toolbar_title);
if (toolbarTitle != null) {
toolbarTitle.setText(getToolbarTitle());
}
ImageView profileIcon = (ImageView) view.findViewById(R.id.profile_icon);
if (profileIcon != null) {
int iconRes = selectedAppMode.getIconRes();
@ -261,24 +351,30 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
String appName = selectedAppMode.toHumanString(app);
profileTitle.setText(appName);
}
TextView profileType = (TextView) view.findViewById(R.id.profile_type);
if (profileType != null) {
profileType.setVisibility(View.GONE);
}
View toolbarDivider = view.findViewById(R.id.toolbar_divider);
if (toolbarDivider != null) {
toolbarDivider.setBackgroundColor(iconColor);
}
View profileButton = view.findViewById(R.id.switch_profile_button);
updateProfileButton();
}
private void updateProfileButton() {
View view = getView();
if (view == null) {
return;
}
View profileButton = view.findViewById(R.id.profile_button);
if (profileButton != null) {
int toolbarRes = getToolbarResId();
int toolbarRes = currentScreenType.toolbarResId;
int iconColor = getActiveProfileColor();
int bgColor = UiUtilities.getColorWithAlpha(iconColor, 0.1f);
int selectedColor = UiUtilities.getColorWithAlpha(iconColor, 0.3f);
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
int bgResId = 0;
int selectableResId = 0;
if (toolbarRes == R.layout.profile_preference_toolbar) {
if (toolbarRes == R.layout.profile_preference_toolbar || toolbarRes == R.layout.profile_preference_toolbar_with_switch) {
bgResId = R.drawable.circle_background_light;
selectableResId = R.drawable.ripple_circle;
} else if (toolbarRes == R.layout.profile_preference_toolbar_big) {
@ -291,7 +387,7 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
AndroidUtils.setBackground(profileButton, new LayerDrawable(layers));
} else {
int bgResId = 0;
if (toolbarRes == R.layout.profile_preference_toolbar) {
if (toolbarRes == R.layout.profile_preference_toolbar || toolbarRes == R.layout.profile_preference_toolbar_with_switch) {
bgResId = R.drawable.circle_background_light;
} else if (toolbarRes == R.layout.profile_preference_toolbar_big) {
bgResId = R.drawable.rectangle_rounded;
@ -304,14 +400,14 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
private void updatePreferencesScreen() {
if (getSelectedAppMode() != null) {
int resId = getPreferencesResId();
int resId = currentScreenType.preferencesResId;
if (resId != -1) {
addPreferencesFromResource(resId);
}
setupPreferences();
registerPreferences(getPreferenceScreen());
}
}
}
private void registerPreferences(PreferenceGroup preferenceGroup) {
if (preferenceGroup != null) {
@ -331,34 +427,25 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
getPreferenceScreen().removeAll();
}
updatePreferencesScreen();
updateToolbar(getView());
}
@XmlRes
protected int getPreferencesResId() {
return -1;
protected void enableDisablePreferences(boolean enable) {
PreferenceScreen screen = getPreferenceScreen();
if (screen != null) {
for (int i = 0; i < screen.getPreferenceCount(); i++) {
screen.getPreference(i).setEnabled(enable);
}
}
}
@LayoutRes
protected int getToolbarResId() {
return -1;
private SettingsScreenType getCurrentScreenType() {
String fragmentName = this.getClass().getName();
for (SettingsScreenType type : SettingsScreenType.values()) {
if (type.fragmentName.equals(fragmentName)) {
return type;
}
@StringRes
protected int getToolbarTitle() {
return R.string.shared_string_settings;
}
@ColorRes
protected int getStatusBarColorId() {
View view = getView();
if (view != null) {
if (Build.VERSION.SDK_INT >= 23 && !isNightMode()) {
view.setSystemUiVisibility(view.getSystemUiVisibility() | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
}
return isNightMode() ? R.color.list_background_color_dark : R.color.list_background_color_light;
}
return -1;
return null;
}
@ColorInt
@ -451,6 +538,22 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
return iconsCache;
}
@Nullable
protected OsmandSettings getSettings() {
OsmandApplication app = getMyApplication();
if (app != null) {
return app.getSettings();
} else {
return null;
}
}
@NonNull
protected OsmandSettings requireSettings() {
OsmandApplication app = requireMyApplication();
return app.getSettings();
}
protected Drawable getIcon(@DrawableRes int id) {
UiUtilities cache = getIconsCache();
return cache != null ? cache.getIcon(id) : null;
@ -476,22 +579,6 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
return cache != null ? cache.getPaintedIcon(id, color) : null;
}
@Nullable
protected OsmandSettings getSettings() {
OsmandApplication app = getMyApplication();
if (app != null) {
return app.getSettings();
} else {
return null;
}
}
@NonNull
protected OsmandSettings requireSettings() {
OsmandApplication app = requireMyApplication();
return app.getSettings();
}
public SwitchPreferenceCompat createSwitchPreference(OsmandSettings.OsmandPreference<Boolean> b, int title, int summary, int layoutId) {
return createSwitchPreference(b, getString(title), getString(summary), layoutId);
}
@ -509,10 +596,6 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
return createSwitchPreferenceEx(prefId, getString(title), null, layoutId);
}
public SwitchPreferenceEx createSwitchPreferenceEx(String prefId, int title, int summary, int layoutId) {
return createSwitchPreferenceEx(prefId, getString(title), getString(summary), layoutId);
}
public SwitchPreferenceEx createSwitchPreferenceEx(String prefId, String title, String summary, int layoutId) {
SwitchPreferenceEx p = new SwitchPreferenceEx(getContext());
p.setKey(prefId);
@ -540,4 +623,32 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
return listPreference;
}
public static String getAppModeDescription(Context ctx, ApplicationMode mode) {
String description;
if (mode.isCustomProfile()) {
description = String.format(ctx.getString(R.string.profile_type_descr_string),
Algorithms.capitalizeFirstLetterAndLowercase(mode.getParent().toHumanString(ctx)));
} else {
description = ctx.getString(R.string.profile_type_base_string);
}
return description;
}
public static boolean showInstance(FragmentActivity activity, SettingsScreenType screenType) {
try {
Fragment fragment = Fragment.instantiate(activity, screenType.fragmentName);
activity.getSupportFragmentManager().beginTransaction()
.replace(R.id.fragmentContainer, fragment, screenType.fragmentName)
.addToBackStack(DRAWER_SETTINGS_ID + ".new")
.commit();
return true;
} catch (Exception e) {
LOG.error(e);
}
return false;
}
}

View file

@ -7,8 +7,10 @@ import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.ColorRes;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.content.ContextCompat;
import android.support.v7.preference.Preference;
@ -20,8 +22,10 @@ import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import net.osmand.AndroidUtils;
import net.osmand.PlatformUtil;
import net.osmand.aidl.OsmandAidlApi;
import net.osmand.aidl.OsmandAidlApi.ConnectedApp;
import net.osmand.plus.ApplicationMode;
@ -30,34 +34,27 @@ import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.PluginActivity;
import net.osmand.plus.helpers.FontCache;
import net.osmand.plus.settings.preferences.SwitchPreferenceEx;
import org.apache.commons.logging.Log;
import java.util.List;
import static net.osmand.plus.profiles.EditProfileFragment.MAP_CONFIG;
import static net.osmand.plus.profiles.EditProfileFragment.OPEN_CONFIG_ON_MAP;
import static net.osmand.plus.profiles.EditProfileFragment.SCREEN_CONFIG;
import static net.osmand.plus.profiles.EditProfileFragment.SELECTED_ITEM;
public class ConfigureProfileFragment extends BaseSettingsFragment {
public static final String TAG = "ConfigureProfileFragment";
public static final String TAG = ConfigureProfileFragment.class.getSimpleName();
private static final Log log = PlatformUtil.getLog(ConfigureProfileFragment.class);
private static final String PLUGIN_SETTINGS = "plugin_settings";
@Override
protected int getPreferencesResId() {
return R.xml.configure_profile;
}
@Override
protected int getToolbarResId() {
return R.layout.profile_preference_toolbar_big;
}
@Override
protected int getToolbarTitle() {
return R.string.configure_profile;
}
private static final String CONFIGURE_MAP = "configure_map";
private static final String CONFIGURE_SCREEN = "configure_screen";
@ColorRes
protected int getBackgroundColorRes() {
@ -73,6 +70,35 @@ public class ConfigureProfileFragment extends BaseSettingsFragment {
return view;
}
@Override
protected void createToolbar(LayoutInflater inflater, View view) {
super.createToolbar(inflater, view);
TextView toolbarTitle = (TextView) view.findViewById(R.id.profile_title);
toolbarTitle.setTypeface(FontCache.getRobotoMedium(view.getContext()));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
float letterSpacing = AndroidUtils.getFloatValueFromRes(view.getContext(), R.dimen.title_letter_spacing);
toolbarTitle.setLetterSpacing(letterSpacing);
}
TextView profileType = (TextView) view.findViewById(R.id.profile_type);
profileType.setVisibility(View.VISIBLE);
}
@Override
protected void updateToolbar() {
super.updateToolbar();
View view = getView();
if (view != null) {
ApplicationMode selectedMode = getSelectedAppMode();
String appModeType = getAppModeDescription(view.getContext(), selectedMode);
TextView profileType = (TextView) view.findViewById(R.id.profile_type);
profileType.setText(appModeType);
}
}
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));
@ -127,6 +153,7 @@ public class ConfigureProfileFragment extends BaseSettingsFragment {
setupNavigationSettingsPref();
setupConfigureMapPref();
setupConfigureScreenPref();
PreferenceCategory pluginSettings = (PreferenceCategory) findPreference(PLUGIN_SETTINGS);
pluginSettings.setIconSpaceReserved(false);
@ -138,9 +165,7 @@ public class ConfigureProfileFragment extends BaseSettingsFragment {
private void setupNavigationSettingsPref() {
Preference navigationSettings = findPreference("navigation_settings");
navigationSettings.setIcon(getContentIcon(R.drawable.ic_action_gdirections_dark));
if (getSelectedAppMode() == ApplicationMode.DEFAULT) {
navigationSettings.setVisible(false);
}
navigationSettings.setVisible(!getSelectedAppMode().isDerivedRoutingFrom(ApplicationMode.DEFAULT));
}
private void setupConfigureMapPref() {
@ -148,14 +173,27 @@ public class ConfigureProfileFragment extends BaseSettingsFragment {
if (ctx == null) {
return;
}
Preference configureMap = findPreference("configure_map");
Preference configureMap = findPreference(CONFIGURE_MAP);
configureMap.setIcon(getContentIcon(R.drawable.ic_action_layers_dark));
Intent intent = new Intent(ctx, MapActivity.class);
intent.putExtra(OPEN_CONFIG_ON_MAP, MAP_CONFIG);
intent.putExtra(SELECTED_ITEM, getSelectedAppMode().getStringKey());
configureMap.setIntent(intent);
configureMap.setVisible(false);
}
private void setupConfigureScreenPref() {
Context ctx = getContext();
if (ctx == null) {
return;
}
Preference configureMap = findPreference(CONFIGURE_SCREEN);
configureMap.setIcon(getContentIcon(R.drawable.ic_configure_screen_dark));
Intent intent = new Intent(ctx, MapActivity.class);
intent.putExtra(OPEN_CONFIG_ON_MAP, SCREEN_CONFIG);
intent.putExtra(SELECTED_ITEM, getSelectedAppMode().getStringKey());
configureMap.setIntent(intent);
}
private void setupConnectedAppsPref(PreferenceCategory preferenceCategory) {
@ -214,6 +252,30 @@ public class ConfigureProfileFragment extends BaseSettingsFragment {
return intent;
}
@Override
public boolean onPreferenceClick(Preference preference) {
String prefId = preference.getKey();
if (CONFIGURE_MAP.equals(prefId) || CONFIGURE_SCREEN.equals(prefId)) {
FragmentActivity activity = getActivity();
if (activity != null) {
try {
FragmentManager fragmentManager = activity.getSupportFragmentManager();
if (fragmentManager != null) {
fragmentManager.beginTransaction()
.remove(this)
.addToBackStack(TAG)
.commitAllowingStateLoss();
}
} catch (Exception e) {
log.error(e);
}
}
}
return super.onPreferenceClick(preference);
}
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
String key = preference.getKey();
@ -241,17 +303,4 @@ public class ConfigureProfileFragment extends BaseSettingsFragment {
return super.onPreferenceChange(preference, newValue);
}
public static boolean showInstance(FragmentManager fragmentManager) {
try {
ConfigureProfileFragment configureProfileFragment = new ConfigureProfileFragment();
fragmentManager.beginTransaction()
.replace(R.id.fragmentContainer, configureProfileFragment, TAG)
.addToBackStack(TAG)
.commitAllowingStateLoss();
return true;
} catch (Exception e) {
return false;
}
}
}

View file

@ -22,6 +22,7 @@ import android.widget.TextView;
import net.osmand.Location;
import net.osmand.data.PointDescription;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.R;
import net.osmand.plus.settings.bottomsheets.ChangeGeneralProfilesPrefBottomSheet;
@ -30,7 +31,7 @@ import net.osmand.plus.wikipedia.WikipediaDialogFragment;
public class CoordinatesFormatFragment extends BaseSettingsFragment {
public static final String TAG = "CoordinatesFormatFragment";
public static final String TAG = CoordinatesFormatFragment.class.getSimpleName();
private static final String UTM_FORMAT_WIKI_LINK = "https://en.wikipedia.org/wiki/Universal_Transverse_Mercator_coordinate_system";
@ -40,21 +41,6 @@ public class CoordinatesFormatFragment extends BaseSettingsFragment {
private static final String UTM_FORMAT = "utm_format";
private static final String OLC_FORMAT = "olc_format";
@Override
protected int getPreferencesResId() {
return R.xml.coordinates_format;
}
@Override
protected int getToolbarResId() {
return R.layout.profile_preference_toolbar;
}
@Override
protected int getToolbarTitle() {
return R.string.coordinates_format;
}
@Override
protected void setupPreferences() {
Preference generalSettings = findPreference("coordinates_format_info");
@ -178,10 +164,13 @@ public class CoordinatesFormatFragment extends BaseSettingsFragment {
int newFormat = getCoordinatesFormatForKey(key);
if (newFormat != -1) {
if (settings.COORDINATES_FORMAT.isSetForMode(getSelectedAppMode())) {
ApplicationMode selectedAppMode = getSelectedAppMode();
if (settings.COORDINATES_FORMAT.isSetForMode(selectedAppMode)) {
if (!settings.COORDINATES_FORMAT.getModeValue(selectedAppMode).equals(newFormat)) {
settings.COORDINATES_FORMAT.set(newFormat);
updateSelectedFormatPrefs(key);
return true;
}
} else {
FragmentManager fragmentManager = getFragmentManager();
if (fragmentManager != null) {

View file

@ -7,43 +7,36 @@ import android.support.annotation.NonNull;
import android.support.v4.app.FragmentManager;
import android.support.v7.app.AlertDialog;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceViewHolder;
import android.support.v7.preference.TwoStatePreference;
import android.support.v7.widget.AppCompatCheckedTextView;
import android.support.v7.widget.SwitchCompat;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.CompoundButton;
import android.widget.TextView;
import net.osmand.AndroidUtils;
import net.osmand.data.PointDescription;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.base.MapViewTrackingUtilities;
import net.osmand.plus.helpers.FontCache;
import net.osmand.plus.settings.bottomsheets.ChangeGeneralProfilesPrefBottomSheet;
import net.osmand.plus.settings.preferences.ListPreferenceEx;
import net.osmand.plus.settings.preferences.SwitchPreferenceEx;
import net.osmand.plus.widgets.style.CustomTypefaceSpan;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class GeneralProfileSettingsFragment extends BaseSettingsFragment {
public class GeneralProfileSettingsFragment extends BaseSettingsFragment implements OnPreferenceChanged {
public static final String TAG = "GeneralProfileSettingsFragment";
@Override
protected int getPreferencesResId() {
return R.xml.general_profile_settings;
}
@Override
protected int getToolbarResId() {
return R.layout.profile_preference_toolbar_big;
}
@Override
protected int getToolbarTitle() {
return R.string.general_settings_2;
}
public static final String TAG = GeneralProfileSettingsFragment.class.getSimpleName();
@Override
protected void setupPreferences() {
@ -62,6 +55,57 @@ public class GeneralProfileSettingsFragment extends BaseSettingsFragment {
setupExternalInputDevicePref();
}
@Override
protected void onBindPreferenceViewHolder(Preference preference, PreferenceViewHolder holder) {
super.onBindPreferenceViewHolder(preference, holder);
String prefId = preference.getKey();
if (settings.EXTERNAL_INPUT_DEVICE.getId().equals(prefId)) {
boolean checked = settings.EXTERNAL_INPUT_DEVICE.get() != OsmandSettings.NO_EXTERNAL_DEVICE;
SwitchCompat switchView = (SwitchCompat) holder.findViewById(R.id.switchWidget);
switchView.setOnCheckedChangeListener(null);
switchView.setChecked(checked);
switchView.setOnCheckedChangeListener(externalInputDeviceListener);
}
OsmandSettings.OsmandPreference osmandPreference = settings.getPreference(prefId);
TextView summaryView = (TextView) holder.findViewById(android.R.id.summary);
if (osmandPreference != null && summaryView != null) {
CharSequence summary = null;
if (preference instanceof TwoStatePreference) {
TwoStatePreference statePreference = (TwoStatePreference) preference;
summary = statePreference.isChecked() ? statePreference.getSummaryOn() : statePreference.getSummaryOff();
}
if (TextUtils.isEmpty(summary)) {
summary = preference.getSummary();
}
if (!osmandPreference.isSetForMode(getSelectedAppMode())) {
String baseString = getString(R.string.shared_string_by_default) + ": %s";
summary = AndroidUtils.getStyledString(baseString, summary, new CustomTypefaceSpan(FontCache.getRobotoMedium(app)), null);
}
summaryView.setText(summary);
}
}
CompoundButton.OnCheckedChangeListener externalInputDeviceListener = new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
ListPreferenceEx externalInputDevice = (ListPreferenceEx) findPreference(settings.EXTERNAL_INPUT_DEVICE.getId());
if (isChecked) {
getPreferenceManager().showDialog(externalInputDevice);
buttonView.setChecked(false);
} else {
if (externalInputDevice.callChangeListener(OsmandSettings.NO_EXTERNAL_DEVICE)) {
externalInputDevice.setValue(OsmandSettings.NO_EXTERNAL_DEVICE);
} else {
buttonView.setChecked(true);
}
}
}
};
private void setupAppThemePref() {
final ListPreferenceEx appTheme = (ListPreferenceEx) findPreference(settings.OSMAND_THEME.getId());
appTheme.setEntries(new String[] {getString(R.string.dark_theme), getString(R.string.light_theme)});
@ -181,15 +225,14 @@ public class GeneralProfileSettingsFragment extends BaseSettingsFragment {
private void setupExternalInputDevicePref() {
ListPreferenceEx externalInputDevice = (ListPreferenceEx) findPreference(settings.EXTERNAL_INPUT_DEVICE.getId());
externalInputDevice.setSummary(R.string.sett_no_ext_input);
externalInputDevice.setEntries(new String[] {
getString(R.string.sett_no_ext_input),
getString(R.string.sett_generic_ext_input),
getString(R.string.sett_wunderlinq_ext_input),
getString(R.string.sett_parrot_ext_input)
});
externalInputDevice.setEntryValues(new Integer[] {
OsmandSettings.NO_EXTERNAL_DEVICE,
OsmandSettings.GENERIC_EXTERNAL_DEVICE,
OsmandSettings.WUNDERLINQ_EXTERNAL_DEVICE,
OsmandSettings.PARROT_EXTERNAL_DEVICE}
@ -286,4 +329,18 @@ public class GeneralProfileSettingsFragment extends BaseSettingsFragment {
return true;
}
@Override
public void onPreferenceChanged(String prefId) {
Preference preference = findPreference(prefId);
if (preference != null) {
if (settings.OSMAND_THEME.getId().equals(prefId)) {
preference.setIcon(getOsmandThemeIcon());
} else if (settings.ROTATE_MAP.getId().equals(prefId)) {
preference.setIcon(getRotateMapIcon());
} else if (settings.MAP_SCREEN_ORIENTATION.getId().equals(prefId)) {
preference.setIcon(getMapScreenOrientationIcon());
}
}
}
}

View file

@ -19,25 +19,10 @@ import net.osmand.plus.settings.preferences.SwitchPreferenceEx;
public class GlobalSettingsFragment extends BaseSettingsFragment implements SendAnalyticsBottomSheetDialogFragment.OnSendAnalyticsPrefsUpdate, OnPreferenceChanged {
public static final String TAG = "GlobalSettingsFragment";
public static final String TAG = GlobalSettingsFragment.class.getSimpleName();
private static final String SEND_ANONYMOUS_DATA_PREF_ID = "send_anonymous_data";
@Override
protected int getPreferencesResId() {
return R.xml.global_settings;
}
@Override
protected int getToolbarResId() {
return R.layout.global_preference_toolbar;
}
@Override
protected int getToolbarTitle() {
return R.string.osmand_settings;
}
@Override
protected void setupPreferences() {
setupDefaultAppModePref();
@ -96,7 +81,7 @@ public class GlobalSettingsFragment extends BaseSettingsFragment implements Send
OsmandApplication app = getMyApplication();
if (app != null && activity != null) {
app.checkPreferredLocale();
activity.recreate();
app.restartApp(activity);
}
}
}

View file

@ -1,39 +1,26 @@
package net.osmand.plus.settings;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
import android.os.Build;
import android.support.annotation.ColorRes;
import android.support.v4.app.FragmentManager;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceViewHolder;
import android.view.View;
import net.osmand.AndroidUtils;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.R;
import net.osmand.plus.profiles.SettingsProfileActivity;
import net.osmand.util.Algorithms;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.profiles.SettingsProfileFragment;
public class MainSettingsFragment extends BaseSettingsFragment {
public static final String TAG = "MainSettingsFragment";
public static final String TAG = MainSettingsFragment.class.getSimpleName();
private static final String CONFIGURE_PROFILE = "configure_profile";
@Override
protected int getPreferencesResId() {
return R.xml.settings_main_screen;
}
@Override
protected int getToolbarResId() {
return R.layout.global_preference_toolbar;
}
@Override
protected int getToolbarTitle() {
return R.string.shared_string_settings;
}
@Override
public int getStatusBarColorId() {
return isNightMode() ? R.color.status_bar_color_light : R.color.status_bar_color_dark;
}
@ColorRes
protected int getBackgroundColorRes() {
return isNightMode() ? R.color.activity_background_color_dark : R.color.activity_background_color_light;
@ -48,41 +35,47 @@ public class MainSettingsFragment extends BaseSettingsFragment {
setupManageProfilesPref();
}
@Override
protected void onBindPreferenceViewHolder(Preference preference, PreferenceViewHolder holder) {
super.onBindPreferenceViewHolder(preference, holder);
String key = preference.getKey();
if (CONFIGURE_PROFILE.equals(key)) {
View iconContainer = holder.itemView.findViewById(R.id.icon_container);
if (iconContainer != null) {
int profileColor = getActiveProfileColor();
int bgColor = UiUtilities.getColorWithAlpha(profileColor, 0.1f);
Drawable backgroundDrawable;
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
int selectedColor = UiUtilities.getColorWithAlpha(profileColor, 0.3f);
Drawable background = getPaintedIcon(R.drawable.circle_background_light, bgColor);
Drawable ripple = getPaintedIcon(R.drawable.ripple_circle, selectedColor);
backgroundDrawable = new LayerDrawable(new Drawable[] {background, ripple});
} else {
backgroundDrawable = getPaintedIcon(R.drawable.circle_background_light, bgColor);
}
AndroidUtils.setBackground(iconContainer, backgroundDrawable);
}
}
}
private void setupManageProfilesPref() {
Preference manageProfiles = findPreference("manage_profiles");
manageProfiles.setIcon(getIcon(R.drawable.ic_action_manage_profiles));
manageProfiles.setIntent(new Intent(getActivity(), SettingsProfileActivity.class));
manageProfiles.setFragment(SettingsProfileFragment.class.getName());
}
private void setupConfigureProfilePref() {
ApplicationMode selectedMode = getSelectedAppMode();
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())));
} else {
profileType = getString(R.string.profile_type_base_string);
}
String profileType = getAppModeDescription(getContext(), selectedMode);
int iconRes = selectedMode.getIconRes();
Preference configureProfile = findPreference("configure_profile");
Preference configureProfile = findPreference(CONFIGURE_PROFILE);
configureProfile.setIcon(getPaintedIcon(iconRes, getActiveProfileColor()));
configureProfile.setTitle(title);
configureProfile.setSummary(profileType);
}
public static boolean showInstance(FragmentManager fragmentManager) {
try {
MainSettingsFragment MainSettingsFragment = new MainSettingsFragment();
fragmentManager.beginTransaction()
.replace(R.id.fragmentContainer, MainSettingsFragment, TAG)
.addToBackStack(TAG)
.commitAllowingStateLoss();
return true;
} catch (Exception e) {
return false;
}
}
}

View file

@ -10,22 +10,7 @@ import net.osmand.plus.settings.preferences.SwitchPreferenceEx;
public class MapDuringNavigationFragment extends BaseSettingsFragment {
public static final String TAG = "MapDuringNavigationFragment";
@Override
protected int getPreferencesResId() {
return R.xml.map_during_navigation;
}
@Override
protected int getToolbarResId() {
return R.layout.profile_preference_toolbar;
}
@Override
protected int getToolbarTitle() {
return R.string.map_during_navigation;
}
public static final String TAG = MapDuringNavigationFragment.class.getSimpleName();
@Override
protected void setupPreferences() {

View file

@ -4,25 +4,11 @@ import android.support.v7.preference.Preference;
import android.support.v7.preference.SwitchPreferenceCompat;
import net.osmand.plus.R;
import net.osmand.plus.settings.preferences.SwitchPreferenceEx;
public class NavigationFragment extends BaseSettingsFragment {
public static final String TAG = "NavigationFragment";
@Override
protected int getPreferencesResId() {
return R.xml.navigation_settings_new;
}
@Override
protected int getToolbarResId() {
return R.layout.profile_preference_toolbar_big;
}
@Override
protected int getToolbarTitle() {
return R.string.routing_settings_2;
}
public static final String TAG = NavigationFragment.class.getSimpleName();
@Override
protected void setupPreferences() {
@ -30,6 +16,7 @@ public class NavigationFragment extends BaseSettingsFragment {
SwitchPreferenceCompat showRoutingAlarms = (SwitchPreferenceCompat) findPreference(settings.SHOW_ROUTING_ALARMS.getId());
SwitchPreferenceCompat speakRoutingAlarms = (SwitchPreferenceCompat) findPreference(settings.SPEAK_ROUTING_ALARMS.getId());
SwitchPreferenceCompat turnScreenOn = (SwitchPreferenceCompat) findPreference(settings.TURN_SCREEN_ON_ENABLED.getId());
SwitchPreferenceEx animateMyLocation = (SwitchPreferenceEx) findPreference(settings.ANIMATE_MY_LOCATION.getId());
routeParameters.setIcon(getContentIcon(R.drawable.ic_action_route_distance));
showRoutingAlarms.setIcon(getContentIcon(R.drawable.ic_action_alert));
@ -37,6 +24,8 @@ public class NavigationFragment extends BaseSettingsFragment {
turnScreenOn.setIcon(getContentIcon(R.drawable.ic_action_turn_screen_on));
setupVehicleParametersPref();
animateMyLocation.setDescription(getString(R.string.animate_my_location_desc));
}
private void setupVehicleParametersPref() {

View file

@ -1,10 +1,18 @@
package net.osmand.plus.settings;
import android.graphics.drawable.Drawable;
import android.support.v4.content.ContextCompat;
import android.support.v7.preference.Preference;
import android.support.v7.widget.SwitchCompat;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
import net.osmand.AndroidUtils;
import net.osmand.osm.io.NetworkUtils;
import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.settings.preferences.EditTextPreferenceEx;
import static net.osmand.plus.activities.SettingsGeneralActivity.IP_ADDRESS_PATTERN;
@ -13,21 +21,6 @@ public class ProxySettingsFragment extends BaseSettingsFragment {
public static final String TAG = ProxySettingsFragment.class.getSimpleName();
@Override
protected int getPreferencesResId() {
return R.xml.proxy_preferences;
}
@Override
protected int getToolbarResId() {
return R.layout.global_preference_toolbar;
}
@Override
protected int getToolbarTitle() {
return R.string.proxy_pref_title;
}
@Override
protected void setupPreferences() {
Preference mapDuringNavigationInfo = findPreference("proxy_preferences_info");
@ -37,6 +30,48 @@ public class ProxySettingsFragment extends BaseSettingsFragment {
setupProxyPortPref();
}
@Override
protected void createToolbar(LayoutInflater inflater, View view) {
super.createToolbar(inflater, view);
view.findViewById(R.id.toolbar_switch_container).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
boolean checked = !settings.ENABLE_PROXY.get();
settings.ENABLE_PROXY.set(checked);
updateToolbarSwitch();
enableDisablePreferences(checked);
}
});
TextView title = (TextView) view.findViewById(R.id.switchButtonText);
title.setTextColor(ContextCompat.getColor(app, isNightMode() ? R.color.active_color_primary_dark : R.color.active_color_primary_light));
}
@Override
protected void updateToolbar() {
super.updateToolbar();
updateToolbarSwitch();
}
private void updateToolbarSwitch() {
View view = getView();
if (view == null) {
return;
}
boolean checked = settings.ENABLE_PROXY.get();
View selectableView = view.findViewById(R.id.selectable_item);
SwitchCompat switchView = (SwitchCompat) selectableView.findViewById(R.id.switchWidget);
switchView.setChecked(checked);
TextView title = (TextView) selectableView.findViewById(R.id.switchButtonText);
title.setText(checked ? R.string.shared_string_on : R.string.shared_string_off);
Drawable drawable = UiUtilities.getColoredSelectableDrawable(app, getActiveProfileColor(), 0.3f);
AndroidUtils.setBackground(selectableView, drawable);
}
private void setupProxyHostPref() {
EditTextPreferenceEx hostPref = (EditTextPreferenceEx) findPreference(settings.PROXY_HOST.getId());
hostPref.setPersistent(false);

View file

@ -33,7 +33,7 @@ import static net.osmand.plus.activities.SettingsNavigationActivity.getRouter;
public class RouteParametersFragment extends BaseSettingsFragment {
public static final String TAG = "RouteParametersFragment";
public static final String TAG = RouteParametersFragment.class.getSimpleName();
private static final String AVOID_ROUTING_PARAMETER_PREFIX = "avoid_";
private static final String PREFER_ROUTING_PARAMETER_PREFIX = "prefer_";
@ -46,20 +46,6 @@ public class RouteParametersFragment extends BaseSettingsFragment {
private List<GeneralRouter.RoutingParameter> reliefFactorParameters = new ArrayList<GeneralRouter.RoutingParameter>();
private List<GeneralRouter.RoutingParameter> otherRoutingParameters = new ArrayList<GeneralRouter.RoutingParameter>();
@Override
protected int getPreferencesResId() {
return R.xml.route_parameters;
}
@Override
protected int getToolbarResId() {
return R.layout.profile_preference_toolbar;
}
@Override
protected int getToolbarTitle() {
return R.string.route_parameters;
}
@Override
protected void setupPreferences() {

View file

@ -1,38 +1,28 @@
package net.osmand.plus.settings;
import android.annotation.SuppressLint;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.support.v4.content.ContextCompat;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceViewHolder;
import android.support.v7.preference.SwitchPreferenceCompat;
import android.support.v7.widget.SwitchCompat;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import net.osmand.AndroidUtils;
import net.osmand.plus.R;
public class ScreenAlertsFragment extends BaseSettingsFragment {
public static final String TAG = "ScreenAlertsFragment";
public static final String TAG = ScreenAlertsFragment.class.getSimpleName();
private static final String SHOW_ROUTING_ALARMS_INFO = "show_routing_alarms_info";
private static final String SCREEN_ALERTS_IMAGE = "screen_alerts_image";
@Override
protected int getPreferencesResId() {
return R.xml.screen_alerts;
}
@Override
protected int getToolbarResId() {
return R.layout.profile_preference_toolbar;
}
@Override
protected int getToolbarTitle() {
return R.string.screen_alerts;
}
@Override
protected void setupPreferences() {
Preference showRoutingAlarmsInfo = findPreference(SHOW_ROUTING_ALARMS_INFO);
@ -50,17 +40,51 @@ public class ScreenAlertsFragment extends BaseSettingsFragment {
setupScreenAlertsImage();
}
@Override
protected void createToolbar(LayoutInflater inflater, View view) {
super.createToolbar(inflater, view);
view.findViewById(R.id.toolbar_switch_container).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
boolean checked = !settings.SHOW_ROUTING_ALARMS.get();
settings.SHOW_ROUTING_ALARMS.set(checked);
updateToolbarSwitch();
enableDisablePreferences(checked);
}
});
}
@Override
protected void updateToolbar() {
super.updateToolbar();
updateToolbarSwitch();
}
private void updateToolbarSwitch() {
View view = getView();
if (view == null) {
return;
}
boolean checked = settings.SHOW_ROUTING_ALARMS.get();
int color = checked ? getActiveProfileColor() : ContextCompat.getColor(app, R.color.preference_top_switch_off);
View switchContainer = view.findViewById(R.id.toolbar_switch_container);
AndroidUtils.setBackground(switchContainer, new ColorDrawable(color));
SwitchCompat switchView = (SwitchCompat) switchContainer.findViewById(R.id.switchWidget);
switchView.setChecked(checked);
TextView title = switchContainer.findViewById(R.id.switchButtonText);
title.setText(checked ? R.string.shared_string_on : R.string.shared_string_off);
}
@Override
protected void onBindPreferenceViewHolder(Preference preference, PreferenceViewHolder holder) {
super.onBindPreferenceViewHolder(preference, holder);
String key = preference.getKey();
if (settings.SHOW_ROUTING_ALARMS.getId().equals(key)) {
boolean checked = ((SwitchPreferenceCompat) preference).isChecked();
int color = checked ? getActiveProfileColor() : ContextCompat.getColor(app, R.color.preference_top_switch_off);
holder.itemView.setBackgroundColor(color);
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
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));
@ -74,7 +98,6 @@ public class ScreenAlertsFragment extends BaseSettingsFragment {
}
}
@SuppressLint("RestrictedApi")
@Override
public boolean onPreferenceClick(Preference preference) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {

View file

@ -3,8 +3,10 @@ package net.osmand.plus.settings;
import android.graphics.drawable.ColorDrawable;
import android.support.v4.content.ContextCompat;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceViewHolder;
import android.support.v7.preference.SwitchPreferenceCompat;
import android.support.v7.widget.SwitchCompat;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import net.osmand.AndroidUtils;
import net.osmand.plus.R;
@ -13,22 +15,7 @@ import net.osmand.plus.settings.preferences.SwitchPreferenceEx;
public class TurnScreenOnFragment extends BaseSettingsFragment {
public static final String TAG = "TurnScreenOnFragment";
@Override
protected int getPreferencesResId() {
return R.xml.turn_screen_on;
}
@Override
protected int getToolbarResId() {
return R.layout.profile_preference_toolbar;
}
@Override
protected int getToolbarTitle() {
return R.string.turn_screen_on;
}
public static final String TAG = TurnScreenOnFragment.class.getSimpleName();
@Override
protected void setupPreferences() {
@ -40,15 +27,42 @@ public class TurnScreenOnFragment extends BaseSettingsFragment {
}
@Override
protected void onBindPreferenceViewHolder(Preference preference, PreferenceViewHolder holder) {
super.onBindPreferenceViewHolder(preference, holder);
protected void createToolbar(LayoutInflater inflater, View view) {
super.createToolbar(inflater, view);
if (settings.TURN_SCREEN_ON_ENABLED.getId().equals(preference.getKey())) {
boolean checked = ((SwitchPreferenceCompat) preference).isChecked();
int color = checked ? getActiveProfileColor() : ContextCompat.getColor(app, R.color.preference_top_switch_off);
AndroidUtils.setBackground(holder.itemView, new ColorDrawable(color));
view.findViewById(R.id.toolbar_switch_container).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
boolean checked = !settings.TURN_SCREEN_ON_ENABLED.get();
settings.TURN_SCREEN_ON_ENABLED.set(checked);
updateToolbarSwitch();
enableDisablePreferences(checked);
}
});
}
@Override
protected void updateToolbar() {
super.updateToolbar();
updateToolbarSwitch();
}
private void updateToolbarSwitch() {
View view = getView();
if (view == null) {
return;
}
boolean checked = settings.TURN_SCREEN_ON_ENABLED.get();
int color = checked ? getActiveProfileColor() : ContextCompat.getColor(app, R.color.preference_top_switch_off);
View switchContainer = view.findViewById(R.id.toolbar_switch_container);
AndroidUtils.setBackground(switchContainer, new ColorDrawable(color));
SwitchCompat switchView = (SwitchCompat) switchContainer.findViewById(R.id.switchWidget);
switchView.setChecked(checked);
TextView title = switchContainer.findViewById(R.id.switchButtonText);
title.setText(checked ? R.string.shared_string_on : R.string.shared_string_off);
}
private void setupTurnScreenOnTimePref() {

View file

@ -19,22 +19,7 @@ import static net.osmand.plus.activities.SettingsNavigationActivity.showSeekbarS
public class VehicleParametersFragment extends BaseSettingsFragment {
public static final String TAG = "VehicleParametersFragment";
@Override
protected int getPreferencesResId() {
return R.xml.vehicle_parameters;
}
@Override
protected int getToolbarResId() {
return R.layout.profile_preference_toolbar;
}
@Override
protected int getToolbarTitle() {
return R.string.vehicle_parameters;
}
public static final String TAG = VehicleParametersFragment.class.getSimpleName();
@Override
protected void setupPreferences() {

View file

@ -9,8 +9,11 @@ import android.media.AudioManager;
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 android.support.v7.preference.SwitchPreferenceCompat;
import android.support.v7.widget.SwitchCompat;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import net.osmand.AndroidUtils;
import net.osmand.plus.ApplicationMode;
@ -28,21 +31,45 @@ import static net.osmand.plus.activities.SettingsNavigationActivity.MORE_VALUE;
public class VoiceAnnouncesFragment extends BaseSettingsFragment {
public static final String TAG = "VoiceAnnouncesFragment";
public static final String TAG = VoiceAnnouncesFragment.class.getSimpleName();
@Override
protected int getPreferencesResId() {
return R.xml.voice_announces;
protected void createToolbar(LayoutInflater inflater, View view) {
super.createToolbar(inflater, view);
view.findViewById(R.id.toolbar_switch_container).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
boolean checked = !settings.SPEAK_ROUTING_ALARMS.get();
settings.SPEAK_ROUTING_ALARMS.set(checked);
updateToolbarSwitch();
enableDisablePreferences(checked);
}
});
}
@Override
protected int getToolbarResId() {
return R.layout.profile_preference_toolbar;
protected void updateToolbar() {
super.updateToolbar();
updateToolbarSwitch();
}
@Override
protected int getToolbarTitle() {
return R.string.voice_announces;
private void updateToolbarSwitch() {
View view = getView();
if (view == null) {
return;
}
boolean checked = settings.SPEAK_ROUTING_ALARMS.get();
int color = checked ? getActiveProfileColor() : ContextCompat.getColor(app, R.color.preference_top_switch_off);
View switchContainer = view.findViewById(R.id.toolbar_switch_container);
AndroidUtils.setBackground(switchContainer, new ColorDrawable(color));
SwitchCompat switchView = (SwitchCompat) switchContainer.findViewById(R.id.switchWidget);
switchView.setChecked(checked);
TextView title = switchContainer.findViewById(R.id.switchButtonText);
title.setText(checked ? R.string.shared_string_on : R.string.shared_string_off);
}
@Override
@ -60,18 +87,7 @@ public class VoiceAnnouncesFragment extends BaseSettingsFragment {
setupAudioStreamGuidancePref();
setupInterruptMusicPref();
}
}
@Override
protected void onBindPreferenceViewHolder(Preference preference, PreferenceViewHolder holder) {
super.onBindPreferenceViewHolder(preference, holder);
if (settings.SPEAK_ROUTING_ALARMS.getId().equals(preference.getKey())) {
boolean checked = ((SwitchPreferenceCompat) preference).isChecked();
int color = checked ? getActiveProfileColor() : ContextCompat.getColor(app, R.color.preference_top_switch_off);
AndroidUtils.setBackground(holder.itemView, new ColorDrawable(color));
}
enableDisablePreferences(settings.SPEAK_ROUTING_ALARMS.get());
}
private void setupSpeedLimitExceedPref() {
@ -170,18 +186,13 @@ public class VoiceAnnouncesFragment extends BaseSettingsFragment {
ListPreferenceEx audioStreamGuidance = createListPreferenceEx(settings.AUDIO_STREAM_GUIDANCE.getId(), streamTypes, streamIntTypes, R.string.choose_audio_stream, R.layout.preference_with_descr);
audioStreamGuidance.setIconSpaceReserved(true);
getPreferenceScreen().addPreference(audioStreamGuidance);
audioStreamGuidance.setDependency(settings.SPEAK_ROUTING_ALARMS.getId());
}
private void setupInterruptMusicPref() {
Preference interruptMusicPref = createSwitchPreference(settings.INTERRUPT_MUSIC, R.string.interrupt_music, R.string.interrupt_music_descr, R.layout.preference_switch);
Preference interruptMusicPref = createSwitchPreference(settings.INTERRUPT_MUSIC, R.string.interrupt_music, R.string.interrupt_music_descr, R.layout.preference_switch_with_descr);
interruptMusicPref.setIconSpaceReserved(true);
getPreferenceScreen().addPreference(interruptMusicPref);
interruptMusicPref.setDependency(settings.SPEAK_ROUTING_ALARMS.getId());
}
public void confirmSpeedCamerasDlg() {

View file

@ -28,7 +28,7 @@ import java.util.List;
public class ChangeGeneralProfilesPrefBottomSheet extends BasePreferenceBottomSheet {
public static final String TAG = "ChangeGeneralProfilesPrefBottomSheet";
public static final String TAG = ChangeGeneralProfilesPrefBottomSheet.class.getSimpleName();
private static final Log LOG = PlatformUtil.getLog(ChangeGeneralProfilesPrefBottomSheet.class);