Profile settings initial commit
This commit is contained in:
parent
d198b596fc
commit
a4855199a5
49 changed files with 5285 additions and 680 deletions
|
@ -36,6 +36,8 @@ public class GeneralRouter implements VehicleRouter {
|
|||
public static final String DEFAULT_SPEED = "default_speed";
|
||||
public static final String MIN_SPEED = "min_speed";
|
||||
public static final String MAX_SPEED = "max_speed";
|
||||
public static final String VEHICLE_HEIGHT = "height";
|
||||
public static final String VEHICLE_WEIGHT = "weight";
|
||||
|
||||
private final RouteAttributeContext[] objectAttributes;
|
||||
public final Map<String, String> attributes;
|
||||
|
|
|
@ -384,6 +384,7 @@ dependencies {
|
|||
implementation 'com.android.support:appcompat-v7:27.1.1'
|
||||
implementation 'com.android.support:design:27.1.1'
|
||||
implementation 'com.android.support:customtabs:27.1.1'
|
||||
implementation 'com.android.support:preference-v7:27.1.1'
|
||||
implementation fileTree(include: ['gnu-trove-osmand.jar', 'icu4j-49_1_patched.jar'], dir: 'libs')
|
||||
|
||||
implementation group: 'commons-logging', name: 'commons-logging', version: '1.2'
|
||||
|
|
9
OsmAnd/res/drawable/bg_transparent_rounded_profile.xml
Normal file
9
OsmAnd/res/drawable/bg_transparent_rounded_profile.xml
Normal file
|
@ -0,0 +1,9 @@
|
|||
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:color="#D9F0B400">
|
||||
<item android:id="@android:id/mask">
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="@color/active_color_primary_light" />
|
||||
<corners android:radius="4dp" />
|
||||
</shape>
|
||||
</item>
|
||||
</ripple>
|
File diff suppressed because it is too large
Load diff
293
OsmAnd/res/layout/fragment_settings_main.xml
Normal file
293
OsmAnd/res/layout/fragment_settings_main.xml
Normal file
|
@ -0,0 +1,293 @@
|
|||
<?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="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="wrap_content"
|
||||
android:background="?attr/colorPrimary"
|
||||
android:minHeight="56dp"
|
||||
osmand:theme="@style/ThemeOverlay.AppCompat.ActionBar">
|
||||
|
||||
</android.support.v7.widget.Toolbar>
|
||||
|
||||
</android.support.design.widget.AppBarLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/list_background_color"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/personal_account_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:gravity="center_vertical"
|
||||
android:minHeight="72dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/personal_account_icon"
|
||||
android:layout_width="@dimen/standard_icon_size"
|
||||
android:layout_height="@dimen/standard_icon_size"
|
||||
android:layout_marginStart="@dimen/content_padding"
|
||||
android:layout_marginLeft="@dimen/content_padding"
|
||||
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
|
||||
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
|
||||
android:src="@drawable/ic_person"
|
||||
android:tint="?attr/default_icon_color" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/list_content_padding"
|
||||
android:layout_marginRight="@dimen/list_content_padding"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/personal_account_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/personal_account"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textSize="@dimen/default_list_text_size" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/personal_account_description"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/personal_account_descr"
|
||||
android:textColor="@color/description_font_and_bottom_sheet_icons" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/global_settings_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:gravity="center_vertical"
|
||||
android:minHeight="72dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/global_settings_icon"
|
||||
android:layout_width="@dimen/standard_icon_size"
|
||||
android:layout_height="@dimen/standard_icon_size"
|
||||
android:layout_marginStart="@dimen/content_padding"
|
||||
android:layout_marginLeft="@dimen/content_padding"
|
||||
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
|
||||
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
|
||||
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_marginEnd="@dimen/list_content_padding"
|
||||
android:layout_marginRight="@dimen/list_content_padding"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/global_settings_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/osmand_settings"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textSize="@dimen/default_list_text_size" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/global_settings_description"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/osmand_settings_descr"
|
||||
android:textColor="@color/description_font_and_bottom_sheet_icons" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<include layout="@layout/list_item_divider" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/list_background_color"
|
||||
android:orientation="vertical">
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:minHeight="36dp"
|
||||
android:paddingLeft="64dp"
|
||||
android:paddingRight="64dp"
|
||||
android:text="@string/application_profiles"
|
||||
android:textColor="#7E33FF"
|
||||
osmand:typeface="@string/font_roboto_medium" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/browse_map_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:gravity="center_vertical"
|
||||
android:minHeight="72dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/browse_map_icon"
|
||||
android:layout_width="@dimen/standard_icon_size"
|
||||
android:layout_height="@dimen/standard_icon_size"
|
||||
android:layout_marginStart="@dimen/content_padding"
|
||||
android:layout_marginLeft="@dimen/content_padding"
|
||||
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
|
||||
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
|
||||
android:src="@drawable/ic_action_car_dark"
|
||||
android:tint="?attr/default_icon_color" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/list_content_padding"
|
||||
android:layout_marginRight="@dimen/list_content_padding"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/browse_map_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/rendering_value_browse_map_name"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textSize="@dimen/default_list_text_size" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/browse_map_description"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/osmand_settings_descr"
|
||||
android:textColor="@color/description_font_and_bottom_sheet_icons" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="?attr/divider_color_basic" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/configure_profile_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:gravity="center_vertical"
|
||||
android:minHeight="72dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/configure_profile_icon"
|
||||
android:layout_width="@dimen/standard_icon_size"
|
||||
android:layout_height="@dimen/standard_icon_size"
|
||||
android:layout_marginStart="@dimen/content_padding"
|
||||
android:layout_marginLeft="@dimen/content_padding"
|
||||
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
|
||||
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
|
||||
tools:src="@drawable/ic_world_globe_dark"
|
||||
tools:tint="?attr/default_icon_color" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/list_content_padding"
|
||||
android:layout_marginRight="@dimen/list_content_padding"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/configure_profile_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textSize="@dimen/default_list_text_size"
|
||||
tools:text="Off Road" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/configure_profile_description"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/description_font_and_bottom_sheet_icons"
|
||||
tools:text="@string/osmand_settings_descr" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/manage_profiles_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:gravity="center_vertical"
|
||||
android:minHeight="72dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/manage_profiles_icon"
|
||||
android:layout_width="@dimen/standard_icon_size"
|
||||
android:layout_height="@dimen/standard_icon_size"
|
||||
android:layout_marginStart="@dimen/content_padding"
|
||||
android:layout_marginLeft="@dimen/content_padding"
|
||||
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
|
||||
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
|
||||
android:src="@drawable/ic_action_copy"
|
||||
android:tint="?attr/default_icon_color" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/list_content_padding"
|
||||
android:layout_marginRight="@dimen/list_content_padding"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/manage_profiles_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/manage_profiles"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textSize="@dimen/default_list_text_size" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/manage_profiles_description"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/manage_profiles_descr"
|
||||
android:textColor="@color/description_font_and_bottom_sheet_icons" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<include layout="@layout/card_bottom_divider" />
|
||||
|
||||
</LinearLayout>
|
31
OsmAnd/res/layout/global_preference_toolbar.xml
Normal file
31
OsmAnd/res/layout/global_preference_toolbar.xml
Normal file
|
@ -0,0 +1,31 @@
|
|||
<?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="@dimen/dashboard_map_toolbar"
|
||||
android:background="@color/app_bar_color_light"
|
||||
app:contentInsetLeft="4dp"
|
||||
app:contentInsetStart="4dp">
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/toolbar_back"
|
||||
style="@style/Widget.AppCompat.Toolbar.Button.Navigation"
|
||||
android:layout_width="56dp"
|
||||
android:layout_height="56dp"
|
||||
android:contentDescription="@string/access_shared_string_navigate_up"
|
||||
android:src="@drawable/ic_action_mode_back" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/toolbar_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="left"
|
||||
android:scaleType="center"
|
||||
android:textColor="@color/abc_primary_text_material_dark"
|
||||
android:textSize="@dimen/abc_text_size_large_material"
|
||||
tools:text="Toolbar"
|
||||
tools:visibility="visible" />
|
||||
|
||||
</android.support.v7.widget.Toolbar>
|
19
OsmAnd/res/layout/pref_screen.xml
Normal file
19
OsmAnd/res/layout/pref_screen.xml
Normal file
|
@ -0,0 +1,19 @@
|
|||
<?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/card_and_list_background_basic"
|
||||
android:orientation="vertical">
|
||||
|
||||
<android.support.design.widget.AppBarLayout
|
||||
android:id="@+id/appbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@android:id/list_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical" />
|
||||
|
||||
</LinearLayout>
|
67
OsmAnd/res/layout/preference_fragment_and_switch.xml
Normal file
67
OsmAnd/res/layout/preference_fragment_and_switch.xml
Normal file
|
@ -0,0 +1,67 @@
|
|||
<?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"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:gravity="center_vertical"
|
||||
android:minHeight="72dp">
|
||||
|
||||
<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_marginStart="@dimen/content_padding"
|
||||
android:layout_marginLeft="@dimen/content_padding"
|
||||
android:layout_marginEnd="@dimen/content_padding_half"
|
||||
android:layout_marginRight="@dimen/content_padding_half" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
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:maxLines="4"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:textSize="@dimen/default_list_text_size"
|
||||
osmand:typeface="@string/font_roboto_regular" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="1dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="18dp"
|
||||
android:layout_marginBottom="18dp"
|
||||
android:background="?attr/divider_color_basic" />
|
||||
|
||||
<Switch
|
||||
android:id="@android:id/switch_widget"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@null"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:paddingLeft="@dimen/content_padding"
|
||||
android:paddingRight="@dimen/content_padding" />
|
||||
|
||||
</LinearLayout>
|
50
OsmAnd/res/layout/preference_with_descr.xml
Normal file
50
OsmAnd/res/layout/preference_with_descr.xml
Normal file
|
@ -0,0 +1,50 @@
|
|||
<?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"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:gravity="center_vertical"
|
||||
android:minHeight="72dp">
|
||||
|
||||
<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_marginStart="@dimen/content_padding"
|
||||
android:layout_marginLeft="@dimen/content_padding"
|
||||
android:layout_marginEnd="@dimen/content_padding_half"
|
||||
android:layout_marginRight="@dimen/content_padding_half" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
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:maxLines="4"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:textSize="@dimen/default_list_text_size"
|
||||
osmand:typeface="@string/font_roboto_regular" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
70
OsmAnd/res/layout/profile_preference_toolbar.xml
Normal file
70
OsmAnd/res/layout/profile_preference_toolbar.xml
Normal file
|
@ -0,0 +1,70 @@
|
|||
<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"
|
||||
android:background="?attr/colorPrimary"
|
||||
android:minHeight="56dp"
|
||||
osmand:contentInsetLeft="0dp"
|
||||
osmand:contentInsetStart="0dp"
|
||||
osmand:theme="@style/ThemeOverlay.AppCompat.ActionBar">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/card_and_list_background_basic"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:minHeight="@dimen/dashboard_map_toolbar"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/close_button"
|
||||
style="@style/Widget.AppCompat.Toolbar.Button.Navigation"
|
||||
android:layout_width="56dp"
|
||||
android:layout_height="56dp"
|
||||
android: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="wrap_content"
|
||||
android:layout_marginLeft="@dimen/content_padding_half"
|
||||
android:layout_marginRight="@dimen/content_padding_half"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/routing_settings_2"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textSize="@dimen/default_list_text_size_large"
|
||||
android:textStyle="bold"
|
||||
osmand:typeface="@string/font_roboto_regular" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/switch_profile_button"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_marginLeft="@dimen/content_padding_half"
|
||||
android:layout_marginRight="@dimen/content_padding_half"
|
||||
android:background="@drawable/bg_transparent_rounded_profile">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/profile_icon"
|
||||
android:layout_width="@dimen/standard_icon_size"
|
||||
android:layout_height="@dimen/standard_icon_size"
|
||||
android:layout_gravity="center"
|
||||
android:src="@drawable/ic_action_car_dark"
|
||||
tools:tint="@color/active_color_primary_light" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</android.support.v7.widget.Toolbar>
|
144
OsmAnd/res/layout/profile_preference_toolbar_big.xml
Normal file
144
OsmAnd/res/layout/profile_preference_toolbar_big.xml
Normal file
|
@ -0,0 +1,144 @@
|
|||
<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"
|
||||
android:background="?attr/colorPrimary"
|
||||
android:minHeight="56dp"
|
||||
osmand:contentInsetLeft="0dp"
|
||||
osmand:contentInsetStart="0dp"
|
||||
osmand:theme="@style/ThemeOverlay.AppCompat.ActionBar">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/card_and_list_background_basic"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:minHeight="@dimen/dashboard_map_toolbar"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/close_button"
|
||||
style="@style/Widget.AppCompat.Toolbar.Button.Navigation"
|
||||
android:layout_width="56dp"
|
||||
android:layout_height="56dp"
|
||||
android: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="wrap_content"
|
||||
android:layout_marginLeft="@dimen/content_padding_half"
|
||||
android:layout_marginRight="@dimen/content_padding_half"
|
||||
android:layout_weight="1"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textSize="@dimen/default_list_text_size_large"
|
||||
android:textStyle="bold"
|
||||
osmand:typeface="@string/font_roboto_regular"
|
||||
tools:text="@string/routing_settings_2" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/menu_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:padding="@dimen/content_padding"
|
||||
android:src="@drawable/ic_overflow_menu_dark" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/profile_button"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/switch_profile_button"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp"
|
||||
android:layout_marginLeft="6dp"
|
||||
android:layout_marginRight="6dp"
|
||||
android:layout_marginBottom="6dp"
|
||||
android:background="@drawable/bg_transparent_rounded_profile"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/profile_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginStart="@dimen/bottom_sheet_image_text_margin_start"
|
||||
android:layout_marginLeft="@dimen/bottom_sheet_image_text_margin_start"
|
||||
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
|
||||
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
|
||||
android:src="@drawable/ic_action_coordinates_latitude"
|
||||
tools:tint="?attr/default_icon_color" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginEnd="@dimen/content_padding"
|
||||
android:layout_marginRight="@dimen/content_padding"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="vertical">
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/profile_title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:text="@string/profile_type_base_string"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textSize="@dimen/default_list_text_size"
|
||||
osmand:typeface="@string/font_roboto_medium" />
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/profile_type"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:textSize="@dimen/default_desc_text_size"
|
||||
osmand:typeface="@string/font_roboto_regular"
|
||||
tools:text="Item additional description" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView
|
||||
android:layout_width="@dimen/standard_icon_size"
|
||||
android:layout_height="@dimen/standard_icon_size"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="@dimen/bottom_sheet_image_text_margin_start"
|
||||
android:layout_marginRight="@dimen/bottom_sheet_image_text_margin_start"
|
||||
android:src="@drawable/ic_action_arrow_drop_down"
|
||||
android:tint="?attr/default_icon_color" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:id="@+id/toolbar_divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="2dp"
|
||||
android:background="?attr/active_color_basic"
|
||||
android:visibility="visible" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</android.support.v7.widget.Toolbar>
|
|
@ -1,50 +1,68 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<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"
|
||||
android:orientation="vertical">
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/activity_background_color"
|
||||
android:orientation="vertical">
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/profiles_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
<android.support.design.widget.AppBarLayout
|
||||
android:id="@+id/appbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
android:clipToPadding="false"
|
||||
android:paddingBottom="72dp"/>
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/colorPrimary"
|
||||
android:minHeight="56dp"
|
||||
osmand:theme="@style/ThemeOverlay.AppCompat.ActionBar">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/add_profile_btn"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:layout_gravity="bottom|center_horizontal"
|
||||
android:background="@drawable/fab_extended_drawable"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center_vertical">
|
||||
</android.support.v7.widget.Toolbar>
|
||||
|
||||
<android.support.v7.widget.AppCompatImageView
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginLeft="14dp"
|
||||
android:layout_marginStart="14dp"
|
||||
android:src="@drawable/ic_action_plus"/>
|
||||
</android.support.design.widget.AppBarLayout>
|
||||
|
||||
<android.support.v7.widget.AppCompatTextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/shared_string_add"
|
||||
android:textColor="@color/color_white"
|
||||
android:layout_marginRight="20dp"
|
||||
android:layout_marginEnd="20dp"
|
||||
/>
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
</LinearLayout>
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/profiles_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:clipToPadding="false"
|
||||
android:paddingBottom="72dp" />
|
||||
|
||||
</RelativeLayout>
|
||||
<LinearLayout
|
||||
android:id="@+id/add_profile_btn"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|end"
|
||||
android:background="@drawable/fab_extended_drawable"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<android.support.v7.widget.AppCompatImageView
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginStart="14dp"
|
||||
android:layout_marginLeft="14dp"
|
||||
android:src="@drawable/ic_action_plus" />
|
||||
|
||||
<android.support.v7.widget.AppCompatTextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="20dp"
|
||||
android:layout_marginRight="20dp"
|
||||
android:text="@string/shared_string_add"
|
||||
android:textColor="@color/color_white" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
</LinearLayout>
|
27
OsmAnd/res/layout/simple_preference_category.xml
Normal file
27
OsmAnd/res/layout/simple_preference_category.xml
Normal file
|
@ -0,0 +1,27 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:gravity="center_vertical"
|
||||
android:minHeight="36dp">
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@android:id/title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginStart="@dimen/empty_state_text_button_padding_left"
|
||||
android:layout_marginLeft="@dimen/empty_state_text_button_padding_left"
|
||||
android:ellipsize="marquee"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingLeft="@dimen/content_padding"
|
||||
android:paddingRight="@dimen/content_padding"
|
||||
android:singleLine="true"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textSize="@dimen/default_desc_text_size"
|
||||
osmand:typeface="@string/font_roboto_medium"
|
||||
tools:text="@string/shared_string_other" />
|
||||
|
||||
</LinearLayout>
|
|
@ -11,6 +11,37 @@
|
|||
Thx - Hardy
|
||||
|
||||
-->
|
||||
<string name="units_and_formats">Units & formats</string>
|
||||
<string name="appearance">Appearance</string>
|
||||
<string name="map_look_descr">icons, widgets</string>
|
||||
<string name="map_look">Map look</string>
|
||||
<string name="list_of_installed_plugins">List of installed plugins</string>
|
||||
<string name="configure_navigation">Configure navigation</string>
|
||||
<string name="general_settings_profile_descr">App theme, units, region</string>
|
||||
<string name="configure_profile">Configure profile</string>
|
||||
<string name="screen_alerts_descr">Alerts will be shown on left bottom corner of the screen during the navigation.</string>
|
||||
<string name="switch_profile">Switch profile</string>
|
||||
<string name="language_and_output">Language and output</string>
|
||||
<string name="reset_to_default">Reset to default</string>
|
||||
<string name="manage_profiles_descr">Create, import, edit profiles</string>
|
||||
<string name="manage_profiles">Manage application profiles…</string>
|
||||
<string name="osmand_settings_descr">Affect the entire application</string>
|
||||
<string name="osmand_settings">OsmAnd settings</string>
|
||||
<string name="personal_account_descr">Create or Log in into personal account</string>
|
||||
<string name="personal_account">Personal account</string>
|
||||
<string name="copy_from_other_profile">Copy from other profile</string>
|
||||
<string name="turn_screen_on">Turn screen on</string>
|
||||
<string name="map_during_navigation_descr">Map during navigation</string>
|
||||
<string name="map_during_navigation">Map during navigation</string>
|
||||
<string name="shared_string_other">Other</string>
|
||||
<string name="vehicle_parameters_descr">Weight, height, speed</string>
|
||||
<string name="vehicle_parameters">Vehicle parameters</string>
|
||||
<string name="voice_announces_info">Voice announces are played only during navigation.</string>
|
||||
<string name="voice_announces_descr">Navigation instruction and announces</string>
|
||||
<string name="voice_announces">Voice announces</string>
|
||||
<string name="screen_alerts">Screen alerts</string>
|
||||
<string name="route_parameters_descr">Configure route parameters</string>
|
||||
<string name="route_parameters">Route parameters</string>
|
||||
<string name="shared_string_default">Default</string>
|
||||
<string name="gpx_join_gaps">Join gaps</string>
|
||||
<string name="app_mode_camper">Camper</string>
|
||||
|
|
|
@ -100,8 +100,18 @@
|
|||
<item name="android:textColor">@color/active_color_primary_dark</item>
|
||||
</style>
|
||||
|
||||
<!-- Custom Preference Theme -->
|
||||
<style name="AppPreferenceTheme" parent="@style/PreferenceThemeOverlay.v14.Material">
|
||||
<item name="preferenceFragmentCompatStyle">@style/AppPreferenceFragmentCompatStyle</item>
|
||||
</style>
|
||||
<!-- Custom Style for PreferenceFragmentCompat -->
|
||||
<style name="AppPreferenceFragmentCompatStyle" parent="@style/PreferenceFragment.Material">
|
||||
<item name="android:layout">@layout/pref_screen</item>
|
||||
</style>
|
||||
|
||||
<!-- Osmand themes styles -->
|
||||
<style name="OsmandLightTheme" parent="Theme.AppCompat.Light">
|
||||
<item name="preferenceTheme">@style/AppPreferenceTheme</item>
|
||||
<item name="android:statusBarColor">@color/status_bar_color_light</item>
|
||||
<item name="mapBackground">@color/map_background_color_light</item>
|
||||
<item name="chart_marker_background">@drawable/chart_marker_background_light</item>
|
||||
|
@ -375,6 +385,7 @@
|
|||
</style>
|
||||
|
||||
<style name="OsmandDarkTheme" parent="Theme.AppCompat">
|
||||
<item name="preferenceTheme">@style/AppPreferenceTheme</item>
|
||||
<item name="android:statusBarColor">@color/status_bar_color_dark</item>
|
||||
<item name="mapBackground">@color/map_background_color_dark</item>
|
||||
<item name="chart_marker_background">@drawable/chart_marker_background_dark</item>
|
||||
|
|
36
OsmAnd/res/xml/configure_profile.xml
Normal file
36
OsmAnd/res/xml/configure_profile.xml
Normal file
|
@ -0,0 +1,36 @@
|
|||
<?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">
|
||||
|
||||
<Preference
|
||||
android:key="general_settings"
|
||||
android:layout="@layout/preference_with_descr"
|
||||
android:summary="@string/general_settings_profile_descr"
|
||||
android:title="@string/general_settings_2"
|
||||
app:fragment="net.osmand.plus.settings.GeneralProfileSettings"
|
||||
tools:icon="@drawable/ic_action_settings" />
|
||||
|
||||
<Preference
|
||||
android:key="navigation_settings"
|
||||
android:layout="@layout/preference_with_descr"
|
||||
android:summary="@string/configure_navigation"
|
||||
android:title="@string/routing_settings_2"
|
||||
app:fragment="net.osmand.plus.settings.SettingsNavigationFragment"
|
||||
tools:icon="@drawable/ic_action_gdirections_dark" />
|
||||
|
||||
<Preference
|
||||
android:key="map_look"
|
||||
android:layout="@layout/preference_with_descr"
|
||||
android:summary="@string/map_look_descr"
|
||||
android:title="@string/map_look"
|
||||
app:fragment="net.osmand.plus.settings.SettingsRouteParametersFragment"
|
||||
tools:icon="@drawable/ic_action_layers_dark" />
|
||||
|
||||
<Preference
|
||||
android:key="plugin_settings"
|
||||
android:selectable="false"
|
||||
android:summary="@string/list_of_installed_plugins"
|
||||
android:title="@string/plugin_settings" />
|
||||
|
||||
</PreferenceScreen>
|
65
OsmAnd/res/xml/general_profile_settings.xml
Normal file
65
OsmAnd/res/xml/general_profile_settings.xml
Normal file
|
@ -0,0 +1,65 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<Preference
|
||||
android:key="appearance_category"
|
||||
android:layout="@layout/simple_preference_category"
|
||||
android:selectable="false"
|
||||
android:title="@string/appearance" />
|
||||
|
||||
<net.osmand.plus.views.ListIntPreference
|
||||
android:defaultValue="1"
|
||||
android:key="osmand_theme"
|
||||
android:layout="@layout/preference_with_descr"
|
||||
android:summary="@string/choose_osmand_theme_descr"
|
||||
android:title="@string/choose_osmand_theme" />
|
||||
|
||||
<net.osmand.plus.views.ListIntPreference
|
||||
android:key="rotate_map"
|
||||
android:layout="@layout/preference_with_descr"
|
||||
android:summary="@string/rotate_map_to_bearing_descr"
|
||||
android:title="@string/rotate_map_to_bearing" />
|
||||
|
||||
<net.osmand.plus.views.ListIntPreference
|
||||
android:key="map_screen_orientation"
|
||||
android:layout="@layout/preference_with_descr"
|
||||
android:summary="@string/map_screen_orientation_descr"
|
||||
android:title="@string/map_screen_orientation" />
|
||||
|
||||
<Preference
|
||||
android:key="units_and_formats"
|
||||
android:layout="@layout/simple_preference_category"
|
||||
android:selectable="false"
|
||||
android:title="@string/units_and_formats" />
|
||||
|
||||
<Preference
|
||||
android:key="default_driving_region"
|
||||
android:layout="@layout/preference_with_descr"
|
||||
android:summary="@string/driving_region_descr"
|
||||
android:title="@string/driving_region" />
|
||||
|
||||
<ListPreference
|
||||
android:key="default_metric_system"
|
||||
android:layout="@layout/preference_with_descr"
|
||||
android:summary="@string/unit_of_length_descr"
|
||||
android:title="@string/unit_of_length" />
|
||||
|
||||
<net.osmand.plus.views.ListIntPreference
|
||||
android:key="coordinates_format"
|
||||
android:layout="@layout/preference_with_descr"
|
||||
android:summary="@string/coords_format_descr"
|
||||
android:title="@string/coords_format" />
|
||||
|
||||
<ListPreference
|
||||
android:key="angular_measurement"
|
||||
android:layout="@layout/preference_with_descr"
|
||||
android:summary="@string/angular_measeurement_descr"
|
||||
android:title="@string/angular_measeurement" />
|
||||
|
||||
<Preference
|
||||
android:key="other"
|
||||
android:layout="@layout/simple_preference_category"
|
||||
android:selectable="false"
|
||||
android:title="@string/shared_string_other" />
|
||||
|
||||
</PreferenceScreen>
|
29
OsmAnd/res/xml/map_during_navigation.xml
Normal file
29
OsmAnd/res/xml/map_during_navigation.xml
Normal file
|
@ -0,0 +1,29 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<net.osmand.plus.views.ListIntPreference
|
||||
android:key="auto_follow_route"
|
||||
android:summary="@string/choose_auto_follow_route_descr"
|
||||
android:title="@string/choose_auto_follow_route" />
|
||||
|
||||
<Preference
|
||||
android:key="auto_zoom_map_on_off"
|
||||
android:summary="@string/auto_zoom_map_descr"
|
||||
android:title="@string/auto_zoom_map" />
|
||||
|
||||
<SwitchPreference
|
||||
android:key="snap_to_road"
|
||||
android:summary="@string/snap_to_road_descr"
|
||||
android:title="@string/snap_to_road" />
|
||||
|
||||
<net.osmand.plus.views.ListFloatPreference
|
||||
android:key="speed_for_map_to_direction_of_movement"
|
||||
android:summary="@string/map_orientation_change_in_accordance_with_speed_descr"
|
||||
android:title="@string/map_orientation_change_in_accordance_with_speed" />
|
||||
|
||||
<!--<CheckBoxPreference-->
|
||||
<!--android:key="show_zoom_buttons_navigation"-->
|
||||
<!--android:summary="@string/show_zoom_buttons_navigation_descr"-->
|
||||
<!--android:title="@string/show_zoom_buttons_navigation" />-->
|
||||
|
||||
</PreferenceScreen>
|
|
@ -1,106 +1,72 @@
|
|||
<?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"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="routing_preferences"
|
||||
android:title="@string/routing_preferences_descr">
|
||||
<CheckBoxPreference
|
||||
android:key="fast_route_mode"
|
||||
android:summary="@string/fast_route_mode_descr"
|
||||
android:title="@string/fast_route_mode"/>
|
||||
<Preference
|
||||
android:key="avoid_in_routing"
|
||||
android:summary="@string/avoid_in_routing_descr"
|
||||
android:title="@string/avoid_in_routing_title"/>
|
||||
<Preference
|
||||
android:key="prefer_in_routing"
|
||||
android:summary="@string/prefer_in_routing_descr"
|
||||
android:title="@string/prefer_in_routing_title"/>
|
||||
</PreferenceCategory>
|
||||
<Preference
|
||||
android:key="route_parameters"
|
||||
android:layout="@layout/preference_with_descr"
|
||||
android:summary="@string/route_parameters_descr"
|
||||
android:title="@string/route_parameters"
|
||||
app:fragment="net.osmand.plus.settings.SettingsRouteParametersFragment"
|
||||
tools:icon="@drawable/ic_action_track_16" />
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="guidance_preferences"
|
||||
android:title="@string/guidance_preferences_descr">
|
||||
<ListPreference
|
||||
android:key="auto_follow_route"
|
||||
android:summary="@string/choose_auto_follow_route_descr"
|
||||
android:title="@string/choose_auto_follow_route"/>
|
||||
<Preference
|
||||
android:key="auto_zoom_map_on_off"
|
||||
android:summary="@string/auto_zoom_map_descr"
|
||||
android:title="@string/auto_zoom_map"/>
|
||||
<CheckBoxPreference
|
||||
android:key="snap_to_road"
|
||||
android:summary="@string/snap_to_road_descr"
|
||||
android:title="@string/snap_to_road"/>
|
||||
<CheckBoxPreference
|
||||
android:key="enable_time_conditional_routing"
|
||||
android:title="@string/temporary_conditional_routing"/>
|
||||
<Preference
|
||||
android:key="show_routing_alarms"
|
||||
android:summary="@string/show_warnings_descr"
|
||||
android:title="@string/show_warnings_title"/>
|
||||
<Preference
|
||||
android:key="speak_routing_alarms"
|
||||
android:summary="@string/speak_descr"
|
||||
android:title="@string/speak_title"/>
|
||||
<ListPreference
|
||||
android:key="keep_informing"
|
||||
android:summary="@string/keep_informing_descr"
|
||||
android:title="@string/keep_informing"/>
|
||||
<ListPreference
|
||||
android:key="arrival_distance_factor"
|
||||
android:summary="@string/arrival_distance_descr"
|
||||
android:title="@string/arrival_distance"/>
|
||||
<ListPreference
|
||||
android:key="default_speed_system"
|
||||
android:summary="@string/default_speed_system_descr"
|
||||
android:title="@string/default_speed_system"/>
|
||||
<ListPreference
|
||||
android:key="speed_limit_exceed"
|
||||
android:summary="@string/speed_limit_exceed_message"
|
||||
android:title="@string/speed_limit_exceed"/>
|
||||
<ListPreference
|
||||
android:key="speed_for_map_to_direction_of_movement"
|
||||
android:summary="@string/map_orientation_change_in_accordance_with_speed_descr"
|
||||
android:title="@string/map_orientation_change_in_accordance_with_speed"/>
|
||||
<!--
|
||||
<CheckBoxPreference android:title="@string/show_zoom_buttons_navigation" android:summary="@string/show_zoom_buttons_navigation_descr" android:key="show_zoom_buttons_navigation" />
|
||||
-->
|
||||
<!--
|
||||
<ListPreference
|
||||
android:key="delay_to_start_navigation"
|
||||
android:title="@string/delay_to_start_navigation"
|
||||
android:summary="@string/delay_to_start_navigation_descr" />
|
||||
-->
|
||||
</PreferenceCategory>
|
||||
<net.osmand.plus.views.SwitchFragmentPreference
|
||||
android:key="show_routing_alarms"
|
||||
android:layout="@layout/preference_fragment_and_switch"
|
||||
android:switchTextOff="@string/shared_string_off"
|
||||
android:switchTextOn="@string/shared_string_on"
|
||||
android:title="@string/screen_alerts"
|
||||
app:fragment="net.osmand.plus.settings.SettingsScreenAlertsFragment"
|
||||
tools:icon="@drawable/ic_action_alert" />
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="turn_screen_on"
|
||||
android:title="@string/wake_on_voice">
|
||||
<net.osmand.plus.views.SwitchFragmentPreference
|
||||
android:key="speak_routing_alarms"
|
||||
android:layout="@layout/preference_fragment_and_switch"
|
||||
android:summary="@string/voice_announces_descr"
|
||||
android:title="@string/voice_announces"
|
||||
app:fragment="net.osmand.plus.settings.SettingsVoiceAnnouncesFragment"
|
||||
tools:icon="@drawable/ic_action_volume_up" />
|
||||
|
||||
<Preference
|
||||
android:selectable="false"
|
||||
android:summary="@string/wake_on_voice_descr" />
|
||||
<Preference
|
||||
android:key="vehicle_parameters"
|
||||
android:layout="@layout/preference_with_descr"
|
||||
android:summary="@string/vehicle_parameters_descr"
|
||||
android:title="@string/vehicle_parameters"
|
||||
app:fragment="net.osmand.plus.settings.SettingsVehicleParametersFragment"
|
||||
tools:icon="@drawable/ic_action_car_dark" />
|
||||
|
||||
<ListPreference
|
||||
android:key="turn_screen_on_time_int"
|
||||
android:summary="@string/turn_screen_on_time_descr"
|
||||
android:title="@string/shared_string_time"/>
|
||||
|
||||
<CheckBoxPreference
|
||||
android:key="turn_screen_on_sensor"
|
||||
android:summary="@string/turn_screen_on_sensor_descr"
|
||||
android:title="@string/turn_screen_on_sensor"/>
|
||||
</PreferenceCategory>
|
||||
<Preference
|
||||
android:key="other"
|
||||
android:layout="@layout/simple_preference_category"
|
||||
android:selectable="false"
|
||||
android:title="@string/shared_string_other" />
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="voice"
|
||||
android:title="@string/voice_pref_title">
|
||||
<ListPreference
|
||||
android:key="voice_provider"
|
||||
android:summary="@string/voice_provider_descr"
|
||||
android:title="@string/voice_provider"/>
|
||||
</PreferenceCategory>
|
||||
<Preference
|
||||
android:key="map_during_navigation"
|
||||
android:layout="@layout/preference_with_descr"
|
||||
android:summary="@string/map_during_navigation"
|
||||
android:title="@string/map_during_navigation"
|
||||
app:fragment="net.osmand.plus.settings.SettingsMapDuringNavigationFragment"
|
||||
tools:icon="@drawable/ic_action_copy" />
|
||||
|
||||
<net.osmand.plus.views.SwitchFragmentPreference
|
||||
android:key="turn_screen_on"
|
||||
android:layout="@layout/preference_fragment_and_switch"
|
||||
android:switchTextOff="@string/shared_string_off"
|
||||
android:switchTextOn="@string/shared_string_on"
|
||||
android:title="@string/turn_screen_on"
|
||||
app:fragment="net.osmand.plus.settings.SettingsTurnScreenOnFragment"
|
||||
tools:icon="@drawable/ic_action_copy" />
|
||||
|
||||
<Preference
|
||||
android:key="copy_from_other_profile"
|
||||
android:title="@string/copy_from_other_profile"
|
||||
tools:icon="@drawable/ic_action_copy" />
|
||||
|
||||
<Preference
|
||||
android:key="reset_to_default"
|
||||
android:title="@string/reset_to_default"
|
||||
tools:icon="@drawable/ic_action_undo_dark" />
|
||||
|
||||
</PreferenceScreen>
|
||||
|
|
106
OsmAnd/res/xml/navigation_settings_old.xml
Normal file
106
OsmAnd/res/xml/navigation_settings_old.xml
Normal file
|
@ -0,0 +1,106 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="routing_preferences"
|
||||
android:title="@string/routing_preferences_descr">
|
||||
<CheckBoxPreference
|
||||
android:key="fast_route_mode"
|
||||
android:summary="@string/fast_route_mode_descr"
|
||||
android:title="@string/fast_route_mode" />
|
||||
<Preference
|
||||
android:key="avoid_in_routing"
|
||||
android:summary="@string/avoid_in_routing_descr"
|
||||
android:title="@string/avoid_in_routing_title" />
|
||||
<Preference
|
||||
android:key="prefer_in_routing"
|
||||
android:summary="@string/prefer_in_routing_descr"
|
||||
android:title="@string/prefer_in_routing_title" />
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="guidance_preferences"
|
||||
android:title="@string/guidance_preferences_descr">
|
||||
<ListPreference
|
||||
android:key="auto_follow_route"
|
||||
android:summary="@string/choose_auto_follow_route_descr"
|
||||
android:title="@string/choose_auto_follow_route" />
|
||||
<Preference
|
||||
android:key="auto_zoom_map_on_off"
|
||||
android:summary="@string/auto_zoom_map_descr"
|
||||
android:title="@string/auto_zoom_map" />
|
||||
<CheckBoxPreference
|
||||
android:key="snap_to_road"
|
||||
android:summary="@string/snap_to_road_descr"
|
||||
android:title="@string/snap_to_road" />
|
||||
<CheckBoxPreference
|
||||
android:key="enable_time_conditional_routing"
|
||||
android:title="@string/temporary_conditional_routing" />
|
||||
<Preference
|
||||
android:key="show_routing_alarms"
|
||||
android:summary="@string/show_warnings_descr"
|
||||
android:title="@string/show_warnings_title" />
|
||||
<Preference
|
||||
android:key="speak_routing_alarms"
|
||||
android:summary="@string/speak_descr"
|
||||
android:title="@string/speak_title" />
|
||||
<ListPreference
|
||||
android:key="keep_informing"
|
||||
android:summary="@string/keep_informing_descr"
|
||||
android:title="@string/keep_informing" />
|
||||
<ListPreference
|
||||
android:key="arrival_distance_factor"
|
||||
android:summary="@string/arrival_distance_descr"
|
||||
android:title="@string/arrival_distance" />
|
||||
<ListPreference
|
||||
android:key="default_speed_system"
|
||||
android:summary="@string/default_speed_system_descr"
|
||||
android:title="@string/default_speed_system" />
|
||||
<ListPreference
|
||||
android:key="speed_limit_exceed"
|
||||
android:summary="@string/speed_limit_exceed_message"
|
||||
android:title="@string/speed_limit_exceed" />
|
||||
<ListPreference
|
||||
android:key="speed_for_map_to_direction_of_movement"
|
||||
android:summary="@string/map_orientation_change_in_accordance_with_speed_descr"
|
||||
android:title="@string/map_orientation_change_in_accordance_with_speed" />
|
||||
<!--
|
||||
<CheckBoxPreference android:title="@string/show_zoom_buttons_navigation" android:summary="@string/show_zoom_buttons_navigation_descr" android:key="show_zoom_buttons_navigation" />
|
||||
-->
|
||||
<!--
|
||||
<ListPreference
|
||||
android:key="delay_to_start_navigation"
|
||||
android:title="@string/delay_to_start_navigation"
|
||||
android:summary="@string/delay_to_start_navigation_descr" />
|
||||
-->
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="turn_screen_on"
|
||||
android:title="@string/wake_on_voice">
|
||||
|
||||
<Preference
|
||||
android:selectable="false"
|
||||
android:summary="@string/wake_on_voice_descr" />
|
||||
|
||||
<ListPreference
|
||||
android:key="turn_screen_on_time_int"
|
||||
android:summary="@string/turn_screen_on_time_descr"
|
||||
android:title="@string/shared_string_time" />
|
||||
|
||||
<CheckBoxPreference
|
||||
android:key="turn_screen_on_sensor"
|
||||
android:summary="@string/turn_screen_on_sensor_descr"
|
||||
android:title="@string/turn_screen_on_sensor" />
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="voice"
|
||||
android:title="@string/voice_pref_title">
|
||||
<ListPreference
|
||||
android:key="voice_provider"
|
||||
android:summary="@string/voice_provider_descr"
|
||||
android:title="@string/voice_provider" />
|
||||
</PreferenceCategory>
|
||||
|
||||
</PreferenceScreen>
|
32
OsmAnd/res/xml/route_parameters.xml
Normal file
32
OsmAnd/res/xml/route_parameters.xml
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<SwitchPreference
|
||||
android:key="fast_route_mode"
|
||||
android:summary="@string/fast_route_mode_descr"
|
||||
android:title="@string/fast_route_mode"
|
||||
tools:icon="@drawable/ic_action_fastest_route" />
|
||||
|
||||
<Preference
|
||||
android:key="avoid_in_routing"
|
||||
android:summary="@string/avoid_in_routing_descr"
|
||||
android:title="@string/avoid_in_routing_title"
|
||||
tools:icon="@drawable/ic_action_alert" />
|
||||
|
||||
<Preference
|
||||
android:key="prefer_in_routing"
|
||||
android:summary="@string/prefer_in_routing_descr"
|
||||
android:title="@string/prefer_in_routing_title" />
|
||||
|
||||
<SwitchPreference
|
||||
android:key="enable_time_conditional_routing"
|
||||
android:title="@string/temporary_conditional_routing"
|
||||
tools:icon="@drawable/ic_action_road_works_dark" />
|
||||
|
||||
<!--<ListPreference-->
|
||||
<!--android:key="delay_to_start_navigation"-->
|
||||
<!--android:title="@string/delay_to_start_navigation"-->
|
||||
<!--android:summary="@string/delay_to_start_navigation_descr" />-->
|
||||
|
||||
</PreferenceScreen>
|
34
OsmAnd/res/xml/screen_alerts.xml
Normal file
34
OsmAnd/res/xml/screen_alerts.xml
Normal file
|
@ -0,0 +1,34 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<SwitchPreference
|
||||
android:key="show_routing_alarms"
|
||||
android:title="@string/shared_string_on" />
|
||||
|
||||
<Preference
|
||||
android:icon="@drawable/ic_action_info_dark"
|
||||
android:key="show_routing_alarms_descr"
|
||||
android:selectable="false"
|
||||
android:summary="@string/screen_alerts_descr" />
|
||||
|
||||
<SwitchPreference
|
||||
android:key="show_traffic_warnings"
|
||||
android:title="@string/show_traffic_warnings" />
|
||||
|
||||
<SwitchPreference
|
||||
android:key="show_pedestrian"
|
||||
android:title="@string/show_pedestrian_warnings" />
|
||||
|
||||
<SwitchPreference
|
||||
android:key="show_cameras"
|
||||
android:title="@string/show_cameras" />
|
||||
|
||||
<SwitchPreference
|
||||
android:key="show_lanes"
|
||||
android:title="@string/show_lanes" />
|
||||
|
||||
<SwitchPreference
|
||||
android:key="show_tunnels"
|
||||
android:title="@string/show_tunnels" />
|
||||
|
||||
</PreferenceScreen>
|
23
OsmAnd/res/xml/turn_screen_on.xml
Normal file
23
OsmAnd/res/xml/turn_screen_on.xml
Normal file
|
@ -0,0 +1,23 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<SwitchPreference
|
||||
android:key="turn_screen_on"
|
||||
android:title="@string/shared_string_on" />
|
||||
|
||||
<Preference
|
||||
android:key="turn_screen_on_descr"
|
||||
android:selectable="false"
|
||||
android:summary="@string/wake_on_voice_descr" />
|
||||
|
||||
<net.osmand.plus.views.ListIntPreference
|
||||
android:key="turn_screen_on_time_int"
|
||||
android:summary="@string/turn_screen_on_time_descr"
|
||||
android:title="@string/shared_string_time" />
|
||||
|
||||
<SwitchPreference
|
||||
android:key="turn_screen_on_sensor"
|
||||
android:summary="@string/turn_screen_on_sensor_descr"
|
||||
android:title="@string/turn_screen_on_sensor" />
|
||||
|
||||
</PreferenceScreen>
|
9
OsmAnd/res/xml/vehicle_parameters.xml
Normal file
9
OsmAnd/res/xml/vehicle_parameters.xml
Normal file
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<Preference
|
||||
android:key="default_speed"
|
||||
android:summary="@string/default_speed_setting_descr"
|
||||
android:title="@string/default_speed_setting_title" />
|
||||
|
||||
</PreferenceScreen>
|
77
OsmAnd/res/xml/voice_announces.xml
Normal file
77
OsmAnd/res/xml/voice_announces.xml
Normal file
|
@ -0,0 +1,77 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<SwitchPreference
|
||||
android:key="speak_routing_alarms"
|
||||
android:title="@string/shared_string_on" />
|
||||
|
||||
<Preference
|
||||
android:key="voice_announces_info"
|
||||
android:selectable="false"
|
||||
android:summary="@string/voice_announces_info"
|
||||
tools:icon="@drawable/ic_action_info_dark" />
|
||||
|
||||
<SwitchPreference
|
||||
android:key="speak_street_names"
|
||||
android:title="@string/speak_street_names" />
|
||||
|
||||
<SwitchPreference
|
||||
android:key="speak_traffic_warnings"
|
||||
android:title="@string/speak_traffic_warnings" />
|
||||
|
||||
<SwitchPreference
|
||||
android:key="speak_pedestrian"
|
||||
android:title="@string/speak_pedestrian" />
|
||||
|
||||
<SwitchPreference
|
||||
android:key="speak_speed_limit"
|
||||
android:title="@string/speak_speed_limit" />
|
||||
|
||||
<net.osmand.plus.views.ListFloatPreference
|
||||
android:key="speed_limit_exceed"
|
||||
android:summary="@string/speed_limit_exceed_message"
|
||||
android:title="@string/speed_limit_exceed" />
|
||||
|
||||
<SwitchPreference
|
||||
android:key="speak_cameras"
|
||||
android:title="@string/speak_cameras" />
|
||||
|
||||
<SwitchPreference
|
||||
android:key="speak_tunnels"
|
||||
android:title="@string/show_tunnels" />
|
||||
|
||||
<SwitchPreference
|
||||
android:key="announce_wpt"
|
||||
android:title="@string/shared_string_gpx_waypoints" />
|
||||
|
||||
<SwitchPreference
|
||||
android:key="announce_nearby_favorites"
|
||||
android:title="@string/speak_favorites" />
|
||||
|
||||
<SwitchPreference
|
||||
android:key="announce_nearby_poi"
|
||||
android:title="@string/speak_poi" />
|
||||
|
||||
<net.osmand.plus.views.ListIntPreference
|
||||
android:key="keep_informing"
|
||||
android:summary="@string/keep_informing_descr"
|
||||
android:title="@string/keep_informing" />
|
||||
|
||||
<net.osmand.plus.views.ListFloatPreference
|
||||
android:key="arrival_distance_factor"
|
||||
android:summary="@string/arrival_distance_descr"
|
||||
android:title="@string/arrival_distance" />
|
||||
|
||||
<Preference
|
||||
android:key="language_and_output"
|
||||
android:layout="@layout/simple_preference_category"
|
||||
android:selectable="false"
|
||||
android:title="@string/language_and_output" />
|
||||
|
||||
<ListPreference
|
||||
android:key="voice_provider"
|
||||
android:summary="@string/voice_provider_descr"
|
||||
android:title="@string/voice_provider" />
|
||||
|
||||
</PreferenceScreen>
|
|
@ -1792,6 +1792,16 @@ public class OsmandAidlApi {
|
|||
app.getAppCustomization().registerNavDrawerItems(activity, adapter);
|
||||
}
|
||||
|
||||
public ConnectedApp getConnectedApp(@NonNull String pack) {
|
||||
List<ConnectedApp> connectedApps = getConnectedApps();
|
||||
for (ConnectedApp app : connectedApps) {
|
||||
if (app.pack.equals(pack)) {
|
||||
return app;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<ConnectedApp> getConnectedApps() {
|
||||
List<ConnectedApp> res = new ArrayList<>(connectedApps.size());
|
||||
PackageManager pm = app.getPackageManager();
|
||||
|
@ -1809,9 +1819,9 @@ public class OsmandAidlApi {
|
|||
return res;
|
||||
}
|
||||
|
||||
public void switchEnabled(@NonNull ConnectedApp app) {
|
||||
public boolean switchEnabled(@NonNull ConnectedApp app) {
|
||||
app.enabled = !app.enabled;
|
||||
saveConnectedApps();
|
||||
return saveConnectedApps();
|
||||
}
|
||||
|
||||
boolean isAppEnabled(@NonNull String pack) {
|
||||
|
@ -1824,7 +1834,7 @@ public class OsmandAidlApi {
|
|||
return app.enabled;
|
||||
}
|
||||
|
||||
private void saveConnectedApps() {
|
||||
private boolean saveConnectedApps() {
|
||||
try {
|
||||
JSONArray array = new JSONArray();
|
||||
for (ConnectedApp app : connectedApps.values()) {
|
||||
|
@ -1833,10 +1843,11 @@ public class OsmandAidlApi {
|
|||
obj.put(ConnectedApp.PACK_KEY, app.pack);
|
||||
array.put(obj);
|
||||
}
|
||||
app.getSettings().API_CONNECTED_APPS_JSON.set(array.toString());
|
||||
return app.getSettings().API_CONNECTED_APPS_JSON.set(array.toString());
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void loadConnectedApps() {
|
||||
|
@ -2281,6 +2292,10 @@ public class OsmandAidlApi {
|
|||
return name;
|
||||
}
|
||||
|
||||
public String getPack() {
|
||||
return pack;
|
||||
}
|
||||
|
||||
public Drawable getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
|
|
@ -156,6 +156,19 @@ public abstract class OsmandPlugin {
|
|||
activatePlugins(app, enabledPlugins);
|
||||
}
|
||||
|
||||
public static void updateActivatedPlugins(@NonNull OsmandApplication app) {
|
||||
Set<String> enabledPlugins = app.getSettings().getEnabledPlugins();
|
||||
for (OsmandPlugin plugin : allPlugins) {
|
||||
try {
|
||||
if (plugin.init(app, null)) {
|
||||
plugin.setActive(enabledPlugins.contains(plugin.getId()));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOG.error("Plugin initialization failed " + plugin.getId(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void activatePlugins(OsmandApplication app, Set<String> enabledPlugins) {
|
||||
for (OsmandPlugin plugin : allPlugins) {
|
||||
if (enabledPlugins.contains(plugin.getId()) || plugin.isActive()) {
|
||||
|
|
|
@ -728,7 +728,7 @@ public class OsmandSettings {
|
|||
public static final String NUMBER_OF_FREE_DOWNLOADS_ID = "free_downloads_v3";
|
||||
|
||||
// this value string is synchronized with settings_pref.xml preference name
|
||||
private final OsmandPreference<String> PLUGINS = new StringPreference("enabled_plugins", MapillaryPlugin.ID).makeGlobal();
|
||||
private final OsmandPreference<String> PLUGINS = new StringPreference("enabled_plugins", MapillaryPlugin.ID).makeProfile();
|
||||
|
||||
public Set<String> getEnabledPlugins() {
|
||||
String plugs = PLUGINS.get();
|
||||
|
@ -860,7 +860,7 @@ public class OsmandSettings {
|
|||
public final CommonPreference<Boolean> SHOW_OSMAND_WELCOME_SCREEN = new BooleanPreference("show_osmand_welcome_screen", true).makeGlobal();
|
||||
|
||||
public final CommonPreference<String> API_NAV_DRAWER_ITEMS_JSON = new StringPreference("api_nav_drawer_items_json", "{}").makeGlobal();
|
||||
public final CommonPreference<String> API_CONNECTED_APPS_JSON = new StringPreference("api_connected_apps_json", "[]").makeGlobal();
|
||||
public final CommonPreference<String> API_CONNECTED_APPS_JSON = new StringPreference("api_connected_apps_json", "[]").makeProfile();
|
||||
|
||||
public final CommonPreference<Integer> NUMBER_OF_STARTS_FIRST_XMAS_SHOWN = new IntPreference("number_of_starts_first_xmas_shown", 0).makeGlobal();
|
||||
|
||||
|
@ -1224,7 +1224,9 @@ public class OsmandSettings {
|
|||
public final OsmandPreference<Boolean> FAST_ROUTE_MODE = new BooleanPreference("fast_route_mode", true).makeProfile();
|
||||
// dev version
|
||||
public final CommonPreference<Boolean> DISABLE_COMPLEX_ROUTING = new BooleanPreference("disable_complex_routing", false).makeGlobal();
|
||||
public final CommonPreference<Boolean> ENABLE_TIME_CONDITIONAL_ROUTING = new BooleanPreference("enable_time_conditional_routing", true).makeGlobal();
|
||||
public final CommonPreference<Boolean> ENABLE_TIME_CONDITIONAL_ROUTING = new BooleanPreference("enable_time_conditional_routing", true).makeProfile();
|
||||
|
||||
public final CommonPreference<Boolean> SHOW_ROUTING_ALARMS = new BooleanPreference("show_routing_alarms", true).makeProfile().cache();
|
||||
|
||||
public final CommonPreference<Boolean> SHOW_TRAFFIC_WARNINGS = new BooleanPreference("show_traffic_warnings", false).makeProfile().cache();
|
||||
|
||||
|
@ -1256,6 +1258,7 @@ public class OsmandSettings {
|
|||
public final OsmandPreference<Boolean> SHOW_NEARBY_FAVORITES = new BooleanPreference("show_nearby_favorites", false).makeProfile().cache();
|
||||
public final OsmandPreference<Boolean> SHOW_NEARBY_POI = new BooleanPreference("show_nearby_poi", false).makeProfile().cache();
|
||||
|
||||
public final OsmandPreference<Boolean> SPEAK_ROUTING_ALARMS = new BooleanPreference("speak_routing_alarms", true).makeProfile().cache();
|
||||
public final OsmandPreference<Boolean> SPEAK_STREET_NAMES = new BooleanPreference("speak_street_names", true).makeProfile().cache();
|
||||
public final CommonPreference<Boolean> SPEAK_TRAFFIC_WARNINGS = new BooleanPreference("speak_traffic_warnings", true).makeProfile().cache();
|
||||
{
|
||||
|
@ -1268,7 +1271,7 @@ public class OsmandSettings {
|
|||
public final OsmandPreference<Boolean> SPEAK_SPEED_LIMIT = new BooleanPreference("speak_speed_limit", false).makeProfile().cache();
|
||||
public final OsmandPreference<Boolean> SPEAK_SPEED_CAMERA = new BooleanPreference("speak_cameras", false).makeProfile().cache();
|
||||
public final OsmandPreference<Boolean> SPEAK_TUNNELS = new BooleanPreference("speak_tunnels", false).makeProfile().cache();
|
||||
public final OsmandPreference<Boolean> ANNOUNCE_WPT = new BooleanPreference("announce_wpt", true).makeGlobal().cache();
|
||||
public final OsmandPreference<Boolean> ANNOUNCE_WPT = new BooleanPreference("announce_wpt", true).makeProfile().cache();
|
||||
public final OsmandPreference<Boolean> ANNOUNCE_NEARBY_FAVORITES = new BooleanPreference("announce_nearby_favorites", false).makeProfile().cache();
|
||||
public final OsmandPreference<Boolean> ANNOUNCE_NEARBY_POI = new BooleanPreference("announce_nearby_poi", false).makeProfile().cache();
|
||||
|
||||
|
@ -1396,6 +1399,8 @@ public class OsmandSettings {
|
|||
KEEP_INFORMING.setModeDefaultValue(ApplicationMode.PEDESTRIAN, 0);
|
||||
}
|
||||
|
||||
public final CommonPreference<Boolean> TURN_SCREEN_ON = new BooleanPreference("turn_screen_on", false).makeProfile();
|
||||
|
||||
public final CommonPreference<Integer> TURN_SCREEN_ON_TIME_INT = new IntPreference("turn_screen_on_time_int", 0).makeProfile();
|
||||
|
||||
{
|
||||
|
@ -2603,9 +2608,7 @@ public class OsmandSettings {
|
|||
}
|
||||
return "en-tts";
|
||||
}
|
||||
|
||||
;
|
||||
}.makeGlobal();
|
||||
}.makeProfile();
|
||||
|
||||
|
||||
// this value string is synchronized with settings_pref.xml preference name
|
||||
|
@ -2770,7 +2773,7 @@ public class OsmandSettings {
|
|||
new IntPreference("FAVORITES_TAB", 0).makeGlobal().cache();
|
||||
|
||||
public final CommonPreference<Integer> OSMAND_THEME =
|
||||
new IntPreference("osmand_theme", OSMAND_LIGHT_THEME).makeGlobal().cache();
|
||||
new IntPreference("osmand_theme", OSMAND_LIGHT_THEME).makeProfile().cache();
|
||||
|
||||
public boolean isLightActionBar() {
|
||||
return isLightContent();
|
||||
|
|
|
@ -29,6 +29,8 @@ import android.support.v4.app.FragmentManager;
|
|||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v4.widget.DrawerLayout;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.PreferenceFragmentCompat;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.Gravity;
|
||||
import android.view.KeyEvent;
|
||||
|
@ -111,7 +113,6 @@ import net.osmand.plus.mapmarkers.PlanRouteFragment;
|
|||
import net.osmand.plus.measurementtool.MeasurementEditingContext;
|
||||
import net.osmand.plus.measurementtool.MeasurementToolFragment;
|
||||
import net.osmand.plus.measurementtool.NewGpxData;
|
||||
import net.osmand.plus.profiles.EditProfileFragment;
|
||||
import net.osmand.plus.render.RendererRegistry;
|
||||
import net.osmand.plus.resources.ResourceManager;
|
||||
import net.osmand.plus.routepreparationmenu.ChooseRouteFragment;
|
||||
|
@ -124,6 +125,9 @@ import net.osmand.plus.routing.TransportRoutingHelper.TransportRouteCalculationP
|
|||
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.SettingsBaseProfileDependentFragment;
|
||||
import net.osmand.plus.settings.SettingsMainFragment;
|
||||
import net.osmand.plus.settings.profiles.EditProfileFragment;
|
||||
import net.osmand.plus.views.AddGpxPointBottomSheetHelper.NewGpxPoint;
|
||||
import net.osmand.plus.views.AnimateDraggingMapThread;
|
||||
import net.osmand.plus.views.MapControlsLayer;
|
||||
|
@ -156,9 +160,14 @@ import java.util.concurrent.Executors;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static net.osmand.plus.settings.profiles.SettingsProfileFragment.IS_USER_PROFILE;
|
||||
import static net.osmand.plus.settings.profiles.SettingsProfileFragment.PROFILE_STRING_KEY;
|
||||
|
||||
public class MapActivity extends OsmandActionBarActivity implements DownloadEvents,
|
||||
OnRequestPermissionsResultCallback, IRouteInformationListener, AMapPointUpdateListener,
|
||||
MapMarkerChangedListener, OnDismissDialogFragmentListener, OnDrawMapListener, OsmAndAppCustomizationListener, LockHelper.LockUIAdapter {
|
||||
MapMarkerChangedListener, OnDismissDialogFragmentListener, OnDrawMapListener,
|
||||
OsmAndAppCustomizationListener, LockHelper.LockUIAdapter, PreferenceFragmentCompat.OnPreferenceStartFragmentCallback {
|
||||
|
||||
public static final String INTENT_KEY_PARENT_MAP_ACTIVITY = "intent_parent_map_activity_key";
|
||||
public static final String INTENT_PARAMS = "intent_prarams";
|
||||
|
||||
|
@ -1398,6 +1407,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
|||
|
||||
public void updateApplicationModeSettings() {
|
||||
updateMapSettings();
|
||||
OsmandPlugin.updateActivatedPlugins(app);
|
||||
mapViewTrackingUtilities.updateSettings();
|
||||
//app.getRoutingHelper().setAppMode(settings.getApplicationMode());
|
||||
if (mapLayers.getMapInfoLayer() != null) {
|
||||
|
@ -1913,6 +1923,32 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
|||
changeKeyguardFlags(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceStartFragment(PreferenceFragmentCompat caller, Preference pref) {
|
||||
if (caller instanceof SettingsBaseProfileDependentFragment) {
|
||||
SettingsBaseProfileDependentFragment baseFragment = (SettingsBaseProfileDependentFragment) caller;
|
||||
|
||||
ApplicationMode mode = baseFragment.getSelectedMode();
|
||||
if (mode != null) {
|
||||
Bundle args = new Bundle();
|
||||
args.putString(PROFILE_STRING_KEY, mode.getStringKey());
|
||||
args.putBoolean(IS_USER_PROFILE, mode.isCustomProfile());
|
||||
|
||||
String fragmentName = pref.getFragment();
|
||||
final Fragment fragment = Fragment.instantiate(this, fragmentName);
|
||||
fragment.setArguments(args);
|
||||
|
||||
getSupportFragmentManager().beginTransaction()
|
||||
.add(R.id.fragmentContainer, fragment, fragmentName)
|
||||
.addToBackStack(fragmentName)
|
||||
.commitAllowingStateLoss();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private class ScreenOffReceiver extends BroadcastReceiver {
|
||||
|
||||
@Override
|
||||
|
@ -2128,6 +2164,10 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
|||
}
|
||||
}
|
||||
|
||||
public void showSettings() {
|
||||
SettingsMainFragment.showInstance(getSupportFragmentManager());
|
||||
}
|
||||
|
||||
private void hideContextMenu() {
|
||||
if (mapContextMenu.isVisible()) {
|
||||
mapContextMenu.hide();
|
||||
|
|
|
@ -23,6 +23,9 @@ import android.widget.ListView;
|
|||
import android.widget.Toast;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.GPXUtilities;
|
||||
import net.osmand.GPXUtilities.GPXFile;
|
||||
import net.osmand.GPXUtilities.WptPt;
|
||||
import net.osmand.IndexConstants;
|
||||
import net.osmand.Location;
|
||||
import net.osmand.PlatformUtil;
|
||||
|
@ -36,9 +39,6 @@ import net.osmand.plus.ContextMenuAdapter;
|
|||
import net.osmand.plus.ContextMenuAdapter.ItemClickListener;
|
||||
import net.osmand.plus.ContextMenuItem;
|
||||
import net.osmand.plus.ContextMenuItem.ItemBuilder;
|
||||
import net.osmand.GPXUtilities;
|
||||
import net.osmand.GPXUtilities.GPXFile;
|
||||
import net.osmand.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.MapMarkersHelper;
|
||||
import net.osmand.plus.OsmAndLocationProvider;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
|
@ -79,8 +79,6 @@ import java.util.ArrayList;
|
|||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import static net.osmand.plus.OsmAndCustomizationConstants.MAP_CONTEXT_MENU_ADD_GPX_WAYPOINT;
|
||||
import static net.osmand.plus.OsmAndCustomizationConstants.MAP_CONTEXT_MENU_DIRECTIONS_FROM_ID;
|
||||
import static net.osmand.plus.OsmAndCustomizationConstants.DRAWER_CONFIGURE_MAP_ID;
|
||||
import static net.osmand.plus.OsmAndCustomizationConstants.DRAWER_CONFIGURE_SCREEN_ID;
|
||||
import static net.osmand.plus.OsmAndCustomizationConstants.DRAWER_DASHBOARD_ID;
|
||||
|
@ -96,6 +94,8 @@ import static net.osmand.plus.OsmAndCustomizationConstants.DRAWER_PLUGINS_ID;
|
|||
import static net.osmand.plus.OsmAndCustomizationConstants.DRAWER_SEARCH_ID;
|
||||
import static net.osmand.plus.OsmAndCustomizationConstants.DRAWER_SETTINGS_ID;
|
||||
import static net.osmand.plus.OsmAndCustomizationConstants.DRAWER_TRAVEL_GUIDES_ID;
|
||||
import static net.osmand.plus.OsmAndCustomizationConstants.MAP_CONTEXT_MENU_ADD_GPX_WAYPOINT;
|
||||
import static net.osmand.plus.OsmAndCustomizationConstants.MAP_CONTEXT_MENU_DIRECTIONS_FROM_ID;
|
||||
import static net.osmand.plus.OsmAndCustomizationConstants.MAP_CONTEXT_MENU_EDIT_GPX_WP;
|
||||
import static net.osmand.plus.OsmAndCustomizationConstants.MAP_CONTEXT_MENU_MEASURE_DISTANCE;
|
||||
import static net.osmand.plus.OsmAndCustomizationConstants.MAP_CONTEXT_MENU_SEARCH_NEARBY;
|
||||
|
@ -841,6 +841,18 @@ public class MapActivityActions implements DialogProvider {
|
|||
}
|
||||
}).createItem());
|
||||
|
||||
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.shared_string_settings, mapActivity)
|
||||
.setId(DRAWER_SETTINGS_ID)
|
||||
.setIcon(R.drawable.ic_action_compass)
|
||||
.setListener(new ItemClickListener() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
|
||||
app.logEvent("drawer_settings_open");
|
||||
mapActivity.showSettings();
|
||||
return true;
|
||||
}
|
||||
}).createItem());
|
||||
|
||||
/*
|
||||
optionsMenuHelper.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.configure_map, mapActivity)
|
||||
.setIcon(R.drawable.ic_action_layers_dark)
|
||||
|
|
|
@ -104,7 +104,7 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
|
|||
}
|
||||
|
||||
private void createUI() {
|
||||
addPreferencesFromResource(R.xml.navigation_settings);
|
||||
addPreferencesFromResource(R.xml.navigation_settings_old);
|
||||
PreferenceScreen screen = getPreferenceScreen();
|
||||
RouteService[] vls = RouteService.getAvailableRouters(getMyApplication());
|
||||
String[] entries = new String[vls.length];
|
||||
|
@ -769,13 +769,13 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
|
|||
builder.show();
|
||||
}
|
||||
|
||||
private enum SpeedSliderType {
|
||||
public enum SpeedSliderType {
|
||||
DEFAULT_SPEED,
|
||||
MIN_SPEED,
|
||||
MAX_SPEED,
|
||||
}
|
||||
|
||||
private void setupSpeedSlider(final SpeedSliderType type, String speedUnits, final int[] minValue, final int[] defaultValue, final int[] maxValue, final int min, final int max, View seekbarView) {
|
||||
public static void setupSpeedSlider(final SpeedSliderType type, String speedUnits, final int[] minValue, final int[] defaultValue, final int[] maxValue, final int min, final int max, View seekbarView) {
|
||||
View seekbarLayout;
|
||||
int titleId;
|
||||
final int[] speedValue;
|
||||
|
|
|
@ -183,6 +183,11 @@ public class BaseOsmAndFragment extends Fragment implements TransitionAnimator {
|
|||
return cache != null ? cache.getIcon(id, colorId) : null;
|
||||
}
|
||||
|
||||
protected Drawable getIcon(@DrawableRes int id) {
|
||||
UiUtilities cache = getIconsCache();
|
||||
return cache != null ? cache.getIcon(id) : null;
|
||||
}
|
||||
|
||||
protected Drawable getContentIcon(@DrawableRes int id) {
|
||||
UiUtilities cache = getIconsCache();
|
||||
return cache != null ? cache.getThemedIcon(id) : null;
|
||||
|
|
104
OsmAnd/src/net/osmand/plus/settings/GeneralProfileSettings.java
Normal file
104
OsmAnd/src/net/osmand/plus/settings/GeneralProfileSettings.java
Normal file
|
@ -0,0 +1,104 @@
|
|||
package net.osmand.plus.settings;
|
||||
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.PreferenceScreen;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.views.ListIntPreference;
|
||||
|
||||
public class GeneralProfileSettings extends SettingsBaseProfileDependentFragment {
|
||||
|
||||
public static final String TAG = "GeneralProfileSettings";
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View view = super.onCreateView(inflater, container, savedInstanceState);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getPreferenceResId() {
|
||||
return R.xml.general_profile_settings;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getToolbarResId() {
|
||||
return R.layout.profile_preference_toolbar;
|
||||
}
|
||||
|
||||
protected String getToolbarTitle() {
|
||||
return getString(R.string.general_settings_2);
|
||||
}
|
||||
|
||||
protected void createUI() {
|
||||
PreferenceScreen screen = getPreferenceScreen();
|
||||
|
||||
ListIntPreference appTheme = (ListIntPreference) screen.findPreference(settings.OSMAND_THEME.getId());
|
||||
appTheme.setEntries(new String[]{getString(R.string.dark_theme), getString(R.string.light_theme)});
|
||||
appTheme.setEntryValues(new int[]{OsmandSettings.OSMAND_DARK_THEME, OsmandSettings.OSMAND_LIGHT_THEME});
|
||||
|
||||
ListIntPreference rotateMap = (ListIntPreference) screen.findPreference(settings.ROTATE_MAP.getId());
|
||||
rotateMap.setEntries(new String[]{getString(R.string.rotate_map_none_opt), getString(R.string.rotate_map_bearing_opt), getString(R.string.rotate_map_compass_opt)});
|
||||
rotateMap.setEntryValues(new int[]{OsmandSettings.ROTATE_MAP_NONE, OsmandSettings.ROTATE_MAP_BEARING, OsmandSettings.ROTATE_MAP_COMPASS});
|
||||
|
||||
ListIntPreference mapScreenOrientation = (ListIntPreference) screen.findPreference(settings.MAP_SCREEN_ORIENTATION.getId());
|
||||
mapScreenOrientation.setEntries(new String[]{getString(R.string.map_orientation_portrait), getString(R.string.map_orientation_landscape), getString(R.string.map_orientation_default)});
|
||||
mapScreenOrientation.setEntryValues(new int[]{ActivityInfo.SCREEN_ORIENTATION_PORTRAIT, ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE, ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED});
|
||||
|
||||
|
||||
|
||||
|
||||
int[] cvls = new int[5];
|
||||
cvls[0] = PointDescription.FORMAT_DEGREES;
|
||||
cvls[1] = PointDescription.FORMAT_MINUTES;
|
||||
cvls[2] = PointDescription.FORMAT_SECONDS;
|
||||
cvls[3] = PointDescription.UTM_FORMAT;
|
||||
cvls[4] = PointDescription.OLC_FORMAT;
|
||||
String[] entries = new String[5];
|
||||
entries[0] = PointDescription.formatToHumanString(getContext(), PointDescription.FORMAT_DEGREES);
|
||||
entries[1] = PointDescription.formatToHumanString(getContext(), PointDescription.FORMAT_MINUTES);
|
||||
entries[2] = PointDescription.formatToHumanString(getContext(), PointDescription.FORMAT_SECONDS);
|
||||
entries[3] = PointDescription.formatToHumanString(getContext(), PointDescription.UTM_FORMAT);
|
||||
entries[4] = PointDescription.formatToHumanString(getContext(), PointDescription.OLC_FORMAT);
|
||||
|
||||
ListIntPreference coordinatesFormat = (ListIntPreference) screen.findPreference(settings.COORDINATES_FORMAT.getId());
|
||||
coordinatesFormat.setEntries(entries);
|
||||
coordinatesFormat.setEntryValues(cvls);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisplayPreferenceDialog(Preference preference) {
|
||||
String key = preference.getKey();
|
||||
|
||||
super.onDisplayPreferenceDialog(preference);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
String key = preference.getKey();
|
||||
|
||||
return super.onPreferenceClick(preference);
|
||||
}
|
||||
|
||||
public static boolean showInstance(FragmentManager fragmentManager) {
|
||||
try {
|
||||
GeneralProfileSettings generalProfileSettings = new GeneralProfileSettings();
|
||||
fragmentManager.beginTransaction()
|
||||
.add(R.id.fragmentContainer, generalProfileSettings, GeneralProfileSettings.TAG)
|
||||
.addToBackStack(GeneralProfileSettings.TAG)
|
||||
.commitAllowingStateLoss();
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,419 @@
|
|||
package net.osmand.plus.settings;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.DialogInterface;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.ColorInt;
|
||||
import android.support.annotation.ColorRes;
|
||||
import android.support.annotation.DrawableRes;
|
||||
import android.support.annotation.LayoutRes;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.annotation.XmlRes;
|
||||
import android.support.design.widget.AppBarLayout;
|
||||
import android.support.v14.preference.SwitchPreference;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.preference.ListPreference;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.PreferenceFragmentCompat;
|
||||
import android.support.v7.preference.PreferenceGroup;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.UiUtilities;
|
||||
import net.osmand.plus.activities.OsmandActionBarActivity;
|
||||
import net.osmand.plus.activities.OsmandInAppPurchaseActivity;
|
||||
import net.osmand.plus.profiles.AppProfileArrayAdapter;
|
||||
import net.osmand.plus.profiles.ProfileDataObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
|
||||
import static net.osmand.plus.settings.profiles.SettingsProfileFragment.PROFILE_STRING_KEY;
|
||||
|
||||
public abstract class SettingsBaseProfileDependentFragment extends PreferenceFragmentCompat implements Preference.OnPreferenceChangeListener, Preference.OnPreferenceClickListener {
|
||||
|
||||
protected OsmandApplication app;
|
||||
protected OsmandSettings settings;
|
||||
protected UiUtilities iconsCache;
|
||||
protected List<ApplicationMode> modes = new ArrayList<ApplicationMode>();
|
||||
protected ApplicationMode selectedAppMode = null;
|
||||
|
||||
private boolean nightMode;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
app = requireMyApplication();
|
||||
settings = app.getSettings();
|
||||
nightMode = !settings.isLightContent();
|
||||
String modeName = "";
|
||||
if (getArguments() != null) {
|
||||
modeName = getArguments().getString(PROFILE_STRING_KEY, ApplicationMode.CAR.getStringKey());
|
||||
}
|
||||
selectedAppMode = ApplicationMode.valueOfStringKey(modeName, ApplicationMode.DEFAULT);
|
||||
settings.APPLICATION_MODE.set(selectedAppMode);
|
||||
super.onCreate(savedInstanceState);
|
||||
modes.clear();
|
||||
for (ApplicationMode a : ApplicationMode.values(app)) {
|
||||
if (a != ApplicationMode.DEFAULT) {
|
||||
modes.add(a);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View view = super.onCreateView(inflater, container, savedInstanceState);
|
||||
|
||||
if (view != null) {
|
||||
AndroidUtils.addStatusBarPadding21v(getContext(), view);
|
||||
createToolbar(inflater, view);
|
||||
}
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
private void createToolbar(LayoutInflater inflater, View view) {
|
||||
AppBarLayout appBarLayout = (AppBarLayout) view.findViewById(R.id.appbar);
|
||||
|
||||
int toolbarRes = getToolbarResId();
|
||||
if (toolbarRes != -1) {
|
||||
View toolbarContainer = inflater.inflate(toolbarRes, null);
|
||||
appBarLayout.addView(toolbarContainer);
|
||||
|
||||
view.findViewById(R.id.close_button).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
getActivity().getSupportFragmentManager().popBackStack();
|
||||
}
|
||||
});
|
||||
view.findViewById(R.id.switch_profile_button).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
selectAppModeDialog().show();
|
||||
}
|
||||
});
|
||||
updateToolbar(view);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateToolbar(View view) {
|
||||
if (view == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
int iconRes = selectedAppMode.getIconRes();
|
||||
int iconColor = selectedAppMode.getIconColorInfo().getColor(nightMode);
|
||||
String title = selectedAppMode.isCustomProfile() ? selectedAppMode.getCustomProfileName() : getResources().getString(selectedAppMode.getNameKeyResource());
|
||||
|
||||
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) {
|
||||
profileIcon.setImageDrawable(getIcon(iconRes, iconColor));
|
||||
}
|
||||
TextView profileTitle = (TextView) view.findViewById(R.id.profile_title);
|
||||
if (profileTitle != null) {
|
||||
profileTitle.setText(title);
|
||||
}
|
||||
TextView profileType = (TextView) view.findViewById(R.id.profile_type);
|
||||
if (profileType != null) {
|
||||
profileType.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||
updatePreferencesScreen();
|
||||
}
|
||||
|
||||
private void updatePreferencesScreen() {
|
||||
if (selectedAppMode != null) {
|
||||
String sharedPreferencesName = OsmandSettings.getSharedPreferencesName(selectedAppMode);
|
||||
getPreferenceManager().setSharedPreferencesName(sharedPreferencesName);
|
||||
int resId = getPreferenceResId();
|
||||
if (resId != -1) {
|
||||
addPreferencesFromResource(getPreferenceResId());
|
||||
}
|
||||
createUI();
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void createUI();
|
||||
|
||||
@XmlRes
|
||||
protected int getPreferenceResId() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@LayoutRes
|
||||
protected int getToolbarResId() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
protected String getToolbarTitle() {
|
||||
return getString(R.string.shared_string_settings);
|
||||
}
|
||||
|
||||
@ColorRes
|
||||
protected int getStatusBarColorId() {
|
||||
View view = getView();
|
||||
if (view != null) {
|
||||
if (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;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public ApplicationMode getSelectedMode() {
|
||||
return selectedAppMode;
|
||||
}
|
||||
|
||||
public boolean isNightMode() {
|
||||
return nightMode;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected OsmandApplication getMyApplication() {
|
||||
FragmentActivity activity = getActivity();
|
||||
if (activity != null) {
|
||||
return (OsmandApplication) activity.getApplication();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
protected OsmandApplication requireMyApplication() {
|
||||
FragmentActivity activity = requireActivity();
|
||||
return (OsmandApplication) activity.getApplication();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected OsmandActionBarActivity getMyActivity() {
|
||||
return (OsmandActionBarActivity) getActivity();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
protected OsmandActionBarActivity requireMyActivity() {
|
||||
return (OsmandActionBarActivity) requireActivity();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected OsmandInAppPurchaseActivity getInAppPurchaseActivity() {
|
||||
Activity activity = getActivity();
|
||||
if (activity instanceof OsmandInAppPurchaseActivity) {
|
||||
return (OsmandInAppPurchaseActivity) getActivity();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected UiUtilities getIconsCache() {
|
||||
OsmandApplication app = getMyApplication();
|
||||
if (iconsCache == null && app != null) {
|
||||
iconsCache = app.getUIUtilities();
|
||||
}
|
||||
return iconsCache;
|
||||
}
|
||||
|
||||
protected Drawable getPaintedContentIcon(@DrawableRes int id, @ColorInt int color) {
|
||||
UiUtilities cache = getIconsCache();
|
||||
return cache != null ? cache.getPaintedIcon(id, color) : null;
|
||||
}
|
||||
|
||||
protected Drawable getIcon(@DrawableRes int id, @ColorRes int colorId) {
|
||||
UiUtilities cache = getIconsCache();
|
||||
return cache != null ? cache.getIcon(id, colorId) : null;
|
||||
}
|
||||
|
||||
protected Drawable getIcon(@DrawableRes int id) {
|
||||
UiUtilities cache = getIconsCache();
|
||||
return cache != null ? cache.getIcon(id) : null;
|
||||
}
|
||||
|
||||
protected Drawable getContentIcon(@DrawableRes int id) {
|
||||
UiUtilities cache = getIconsCache();
|
||||
return cache != null ? cache.getThemedIcon(id) : null;
|
||||
}
|
||||
|
||||
protected void setThemedDrawable(View view, @DrawableRes int iconId) {
|
||||
((ImageView) view).setImageDrawable(getContentIcon(iconId));
|
||||
}
|
||||
|
||||
@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 SwitchPreference registerBooleanPreference(OsmandSettings.OsmandPreference<Boolean> b, PreferenceGroup screen) {
|
||||
SwitchPreference p = (SwitchPreference) screen.findPreference(b.getId());
|
||||
p.setOnPreferenceChangeListener(this);
|
||||
return p;
|
||||
}
|
||||
|
||||
public SwitchPreference createSwitchPreference(OsmandSettings.OsmandPreference<Boolean> b, int title, int summary) {
|
||||
SwitchPreference p = new SwitchPreference(getContext());
|
||||
p.setTitle(title);
|
||||
p.setKey(b.getId());
|
||||
p.setSummary(summary);
|
||||
p.setOnPreferenceChangeListener(this);
|
||||
return p;
|
||||
}
|
||||
|
||||
public SwitchPreference createSwitchPreference(OsmandSettings.OsmandPreference<Boolean> b) {
|
||||
SwitchPreference p = new SwitchPreference(getContext());
|
||||
p.setKey(b.getId());
|
||||
p.setOnPreferenceChangeListener(this);
|
||||
p.setSelectable(true);
|
||||
return p;
|
||||
}
|
||||
|
||||
public <T> ListPreference createListPreference(OsmandSettings.OsmandPreference<T> b, String[] names, T[] values, int title, int summary) {
|
||||
ListPreference p = new ListPreference(getContext());
|
||||
p.setTitle(title);
|
||||
p.setKey(b.getId());
|
||||
p.setDialogTitle(title);
|
||||
p.setSummary(summary);
|
||||
prepareListPreference(b, names, values, p);
|
||||
return p;
|
||||
}
|
||||
|
||||
public <T> ListPreference createListPreference(OsmandSettings.OsmandPreference<T> b, String[] names, T[] values, String title, String summary) {
|
||||
ListPreference p = new ListPreference(getContext());
|
||||
p.setTitle(title);
|
||||
p.setKey(b.getId());
|
||||
p.setDialogTitle(title);
|
||||
p.setSummary(summary);
|
||||
prepareListPreference(b, names, values, p);
|
||||
return p;
|
||||
}
|
||||
|
||||
private <T> void prepareListPreference(OsmandSettings.OsmandPreference<T> b, String[] names, T[] values, ListPreference p) {
|
||||
p.setOnPreferenceChangeListener(this);
|
||||
LinkedHashMap<String, Object> vals = new LinkedHashMap<String, Object>();
|
||||
assert names.length == values.length;
|
||||
for (int i = 0; i < names.length; i++) {
|
||||
vals.put(names[i], values[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
int itemId = item.getItemId();
|
||||
switch (itemId) {
|
||||
case android.R.id.home:
|
||||
// finish();
|
||||
return true;
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected AlertDialog.Builder selectAppModeDialog() {
|
||||
AlertDialog.Builder singleSelectDialogBuilder = new AlertDialog.Builder(getContext());
|
||||
singleSelectDialogBuilder.setTitle(R.string.profile_settings);
|
||||
|
||||
final List<ProfileDataObject> activeModes = new ArrayList<>();
|
||||
for (ApplicationMode am : ApplicationMode.values(getMyApplication())) {
|
||||
boolean isSelected = false;
|
||||
if (am == selectedAppMode) {
|
||||
isSelected = true;
|
||||
}
|
||||
if (am != ApplicationMode.DEFAULT) {
|
||||
activeModes.add(new ProfileDataObject(
|
||||
am.toHumanString(getMyApplication()),
|
||||
getAppModeDescription(am),
|
||||
am.getStringKey(),
|
||||
am.getIconRes(),
|
||||
isSelected,
|
||||
am.getIconColorInfo()
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
final AppProfileArrayAdapter modeNames = new AppProfileArrayAdapter(
|
||||
getActivity(), R.layout.bottom_sheet_item_with_descr_and_radio_btn, activeModes, true);
|
||||
|
||||
singleSelectDialogBuilder.setNegativeButton(R.string.shared_string_cancel,
|
||||
new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
singleSelectDialogBuilder.setAdapter(modeNames, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
selectedAppMode = modes.get(which);
|
||||
requireSettings().APPLICATION_MODE.set(selectedAppMode);
|
||||
updateAllSettings();
|
||||
}
|
||||
});
|
||||
return singleSelectDialogBuilder;
|
||||
}
|
||||
|
||||
private String getAppModeDescription(ApplicationMode mode) {
|
||||
String descr;
|
||||
if (!mode.isCustomProfile()) {
|
||||
descr = getString(R.string.profile_type_base_string);
|
||||
} else {
|
||||
descr = String.format(getString(R.string.profile_type_descr_string),
|
||||
mode.getParent().toHumanString(getMyApplication()));
|
||||
if (mode.getRoutingProfile() != null && mode.getRoutingProfile().contains("/")) {
|
||||
descr = descr.concat(", " + mode.getRoutingProfile()
|
||||
.substring(0, mode.getRoutingProfile().indexOf("/")));
|
||||
}
|
||||
}
|
||||
return descr;
|
||||
}
|
||||
|
||||
public void updateAllSettings() {
|
||||
updateToolbar(getView());
|
||||
getPreferenceScreen().removeAll();
|
||||
updatePreferencesScreen();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
// handle boolean preferences
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,126 @@
|
|||
package net.osmand.plus.settings;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.v14.preference.SwitchPreference;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.PreferenceScreen;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Toast;
|
||||
|
||||
import net.osmand.aidl.OsmandAidlApi.ConnectedApp;
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.PluginActivity;
|
||||
import net.osmand.plus.views.SwitchFragmentPreference;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static net.osmand.plus.settings.profiles.SettingsProfileFragment.PROFILE_STRING_KEY;
|
||||
|
||||
public class SettingsConfigureProfileFragment extends SettingsBaseProfileDependentFragment {
|
||||
|
||||
public static final String TAG = "SettingsConfigureProfileFragment";
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View view = super.onCreateView(inflater, container, savedInstanceState);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getPreferenceResId() {
|
||||
return R.xml.configure_profile;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getToolbarResId() {
|
||||
return R.layout.profile_preference_toolbar_big;
|
||||
}
|
||||
|
||||
protected String getToolbarTitle() {
|
||||
return getString(R.string.configure_profile);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createUI() {
|
||||
PreferenceScreen screen = getPreferenceScreen();
|
||||
|
||||
List<ConnectedApp> connectedApps = getMyApplication().getAidlApi().getConnectedApps();
|
||||
List<OsmandPlugin> plugins = OsmandPlugin.getVisiblePlugins();
|
||||
|
||||
for (ConnectedApp connectedApp : connectedApps) {
|
||||
SwitchPreference preference = new SwitchPreference(getContext());
|
||||
|
||||
preference.setKey(connectedApp.getPack());
|
||||
preference.setTitle(connectedApp.getName());
|
||||
preference.setIcon(connectedApp.getIcon());
|
||||
preference.setChecked(connectedApp.isEnabled());
|
||||
preference.setLayoutResource(R.layout.preference_fragment_and_switch);
|
||||
preference.setOnPreferenceChangeListener(this);
|
||||
|
||||
screen.addPreference(preference);
|
||||
}
|
||||
for (OsmandPlugin plugin : plugins) {
|
||||
SwitchFragmentPreference preference = new SwitchFragmentPreference(getContext());
|
||||
preference.setKey(plugin.getId());
|
||||
preference.setPersistent(false);
|
||||
preference.setTitle(plugin.getName());
|
||||
preference.setIcon(getContentIcon(plugin.getLogoResourceId()));
|
||||
preference.setChecked(plugin.isActive());
|
||||
preference.setOnPreferenceChangeListener(this);
|
||||
preference.setLayoutResource(R.layout.preference_fragment_and_switch);
|
||||
|
||||
Intent intent = new Intent(getContext(), PluginActivity.class);
|
||||
intent.putExtra(PluginActivity.EXTRA_PLUGIN_ID, plugin.getId());
|
||||
preference.setIntent(intent);
|
||||
|
||||
screen.addPreference(preference);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
String key = preference.getKey();
|
||||
OsmandPlugin plugin = OsmandPlugin.getPlugin(key);
|
||||
if (plugin != null) {
|
||||
Toast.makeText(getActivity(), "Change " + plugin.getId(), Toast.LENGTH_LONG).show();
|
||||
return OsmandPlugin.enablePlugin(getActivity(), app, plugin, (Boolean) newValue);
|
||||
}
|
||||
ConnectedApp connectedApp = getMyApplication().getAidlApi().getConnectedApp(key);
|
||||
if (connectedApp != null) {
|
||||
return getMyApplication().getAidlApi().switchEnabled(connectedApp);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
Toast.makeText(getActivity(), "Click " + preference.getKey(), Toast.LENGTH_LONG).show();
|
||||
return super.onPreferenceClick(preference);
|
||||
}
|
||||
|
||||
public static boolean showInstance(FragmentManager fragmentManager, ApplicationMode mode) {
|
||||
try {
|
||||
Bundle args = new Bundle();
|
||||
args.putString(PROFILE_STRING_KEY, mode.getStringKey());
|
||||
|
||||
SettingsConfigureProfileFragment settingsConfigureProfileFragment = new SettingsConfigureProfileFragment();
|
||||
settingsConfigureProfileFragment.setArguments(args);
|
||||
|
||||
fragmentManager.beginTransaction()
|
||||
.add(R.id.fragmentContainer, settingsConfigureProfileFragment, SettingsConfigureProfileFragment.TAG)
|
||||
.addToBackStack(SettingsConfigureProfileFragment.TAG)
|
||||
.commitAllowingStateLoss();
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
139
OsmAnd/src/net/osmand/plus/settings/SettingsMainFragment.java
Normal file
139
OsmAnd/src/net/osmand/plus/settings/SettingsMainFragment.java
Normal file
|
@ -0,0 +1,139 @@
|
|||
package net.osmand.plus.settings;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.util.TypedValue;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.base.BaseOsmAndFragment;
|
||||
import net.osmand.plus.settings.profiles.SettingsProfileFragment;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
public class SettingsMainFragment extends BaseOsmAndFragment {
|
||||
|
||||
public static final String TAG = "SettingsMainFragment";
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.fragment_settings_main, null);
|
||||
|
||||
AndroidUtils.addStatusBarPadding21v(getContext(), view);
|
||||
|
||||
Toolbar tb = (Toolbar) view.findViewById(R.id.toolbar);
|
||||
|
||||
tb.setTitle(R.string.shared_string_settings);
|
||||
tb.setClickable(true);
|
||||
tb.setNavigationIcon(getIcon(R.drawable.ic_arrow_back));
|
||||
tb.setNavigationContentDescription(R.string.access_shared_string_navigate_up);
|
||||
tb.setBackgroundColor(getResources().getColor(resolveResourceId(getActivity(), R.attr.pstsTabBackground)));
|
||||
tb.setTitleTextColor(getResources().getColor(resolveResourceId(getActivity(), R.attr.pstsTextColor)));
|
||||
tb.setNavigationOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(final View v) {
|
||||
getActivity().getSupportFragmentManager().popBackStack();
|
||||
}
|
||||
});
|
||||
|
||||
View personal_account_container = view.findViewById(R.id.personal_account_container);
|
||||
personal_account_container.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
getMyApplication().showShortToastMessage("personal_account_container");
|
||||
}
|
||||
});
|
||||
View global_settings_container = view.findViewById(R.id.global_settings_container);
|
||||
global_settings_container.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
getMyApplication().showShortToastMessage("global_settings_container");
|
||||
}
|
||||
});
|
||||
View browse_map_container = view.findViewById(R.id.browse_map_container);
|
||||
browse_map_container.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
getMyApplication().showShortToastMessage("browse_map_container");
|
||||
}
|
||||
});
|
||||
|
||||
final ApplicationMode selectedMode = getSettings().APPLICATION_MODE.get();
|
||||
View configure_profile_container = view.findViewById(R.id.configure_profile_container);
|
||||
|
||||
int iconRes = selectedMode.getIconRes();
|
||||
int iconColor = selectedMode.getIconColorInfo().getColor(!getSettings().isLightContent());
|
||||
String title = selectedMode.isCustomProfile() ? selectedMode.getCustomProfileName() : getResources().getString(selectedMode.getNameKeyResource());
|
||||
|
||||
TextView profileTitle = (TextView) view.findViewById(R.id.configure_profile_title);
|
||||
profileTitle.setText(title);
|
||||
|
||||
String profileType = null;
|
||||
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);
|
||||
}
|
||||
|
||||
TextView profileDescription = (TextView) view.findViewById(R.id.configure_profile_description);
|
||||
profileDescription.setText(profileType);
|
||||
|
||||
ImageView profileIcon = (ImageView) view.findViewById(R.id.configure_profile_icon);
|
||||
profileIcon.setImageDrawable(getIcon(iconRes, iconColor));
|
||||
|
||||
configure_profile_container.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
SettingsConfigureProfileFragment.showInstance(getActivity().getSupportFragmentManager(), selectedMode);
|
||||
}
|
||||
});
|
||||
View manage_profiles_container = view.findViewById(R.id.manage_profiles_container);
|
||||
manage_profiles_container.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
SettingsProfileFragment profileFragment = new SettingsProfileFragment();
|
||||
getActivity().getSupportFragmentManager()
|
||||
.beginTransaction()
|
||||
.replace(R.id.fragmentContainer, profileFragment, SettingsProfileFragment.TAG)
|
||||
.addToBackStack(SettingsProfileFragment.TAG)
|
||||
.commit();
|
||||
}
|
||||
});
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStatusBarColorId() {
|
||||
return getSettings().isLightContent() ? R.color.status_bar_color_light : R.color.status_bar_color_dark;
|
||||
}
|
||||
|
||||
private int resolveResourceId(final Activity activity, final int attr) {
|
||||
final TypedValue typedvalueattr = new TypedValue();
|
||||
activity.getTheme().resolveAttribute(attr, typedvalueattr, true);
|
||||
return typedvalueattr.resourceId;
|
||||
}
|
||||
|
||||
public static boolean showInstance(FragmentManager fragmentManager) {
|
||||
try {
|
||||
SettingsMainFragment settingsMainFragment = new SettingsMainFragment();
|
||||
fragmentManager.beginTransaction()
|
||||
.replace(R.id.fragmentContainer, settingsMainFragment, SettingsMainFragment.TAG)
|
||||
.addToBackStack(SettingsMainFragment.TAG)
|
||||
.commitAllowingStateLoss();
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,118 @@
|
|||
package net.osmand.plus.settings;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v14.preference.SwitchPreference;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.PreferenceScreen;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Toast;
|
||||
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.views.ListFloatPreference;
|
||||
import net.osmand.plus.views.ListIntPreference;
|
||||
|
||||
public class SettingsMapDuringNavigationFragment extends SettingsBaseProfileDependentFragment {
|
||||
|
||||
public static final String TAG = "SettingsMapDuringNavigationFragment";
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View view = super.onCreateView(inflater, container, savedInstanceState);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getPreferenceResId() {
|
||||
return R.xml.map_during_navigation;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getToolbarResId() {
|
||||
return R.layout.profile_preference_toolbar;
|
||||
}
|
||||
|
||||
protected String getToolbarTitle() {
|
||||
return getString(R.string.map_during_navigation);
|
||||
}
|
||||
|
||||
protected void createUI() {
|
||||
PreferenceScreen screen = getPreferenceScreen();
|
||||
|
||||
int[] intValues = new int[]{0, 5, 10, 15, 20, 25, 30, 45, 60, 90};
|
||||
String[] entries = new String[intValues.length];
|
||||
entries[0] = getString(R.string.shared_string_never);
|
||||
for (int i = 1; i < intValues.length; i++) {
|
||||
entries[i] = intValues[i] + " " + getString(R.string.int_seconds);
|
||||
}
|
||||
ListIntPreference autoFollowRoute = (ListIntPreference) screen.findPreference(settings.AUTO_FOLLOW_ROUTE.getId());
|
||||
autoFollowRoute.setEntries(entries);
|
||||
autoFollowRoute.setEntryValues(intValues);
|
||||
|
||||
Preference autoZoomMap = screen.findPreference(settings.AUTO_ZOOM_MAP.getId());
|
||||
autoZoomMap.setOnPreferenceClickListener(this);
|
||||
|
||||
SwitchPreference snapToRoad = (SwitchPreference) screen.findPreference(settings.SNAP_TO_ROAD.getId());
|
||||
|
||||
String[] speedNamesPos;
|
||||
float[] speedLimitsPos;
|
||||
if (settings.METRIC_SYSTEM.get() == OsmandSettings.MetricsConstants.KILOMETERS_AND_METERS) {
|
||||
speedLimitsPos = new float[]{0f, 5f, 7f, 10f, 15f, 20f};
|
||||
speedNamesPos = new String[speedLimitsPos.length];
|
||||
for (int i = 0; i < speedLimitsPos.length; i++) {
|
||||
speedNamesPos[i] = (int) speedLimitsPos[i] + " " + getString(R.string.km_h);
|
||||
}
|
||||
} else {
|
||||
Float[] speedLimitsMiles = new Float[]{-7f, -5f, -3f, 0f, 3f, 5f, 7f, 10f, 15f};
|
||||
speedLimitsPos = new float[]{0f, 3f, 5f, 7f, 10f, 15f};
|
||||
|
||||
String[] speedNames = new String[speedLimitsMiles.length];
|
||||
for (int i = 0; i < speedNames.length; i++) {
|
||||
speedNames[i] = speedLimitsMiles[i].intValue() + " " + getString(R.string.mile_per_hour);
|
||||
}
|
||||
speedNamesPos = new String[speedLimitsPos.length];
|
||||
for (int i = 0; i < speedNamesPos.length; i++) {
|
||||
speedNamesPos[i] = speedLimitsMiles[i].intValue() + " " + getString(R.string.mile_per_hour);
|
||||
}
|
||||
}
|
||||
|
||||
ListFloatPreference switchMapDirectionToCompass = (ListFloatPreference) screen.findPreference(settings.SWITCH_MAP_DIRECTION_TO_COMPASS.getId());
|
||||
switchMapDirectionToCompass.setEntries(speedNamesPos);
|
||||
switchMapDirectionToCompass.setEntryValues(speedLimitsPos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisplayPreferenceDialog(Preference preference) {
|
||||
String key = preference.getKey();
|
||||
if (key != null && key.equals(settings.AUTO_ZOOM_MAP.getId())) {
|
||||
Toast.makeText(getContext(), "onDisplayPreferenceDialog AUTO_ZOOM_MAP", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
super.onDisplayPreferenceDialog(preference);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
String key = preference.getKey();
|
||||
if (key != null && key.equals(settings.AUTO_ZOOM_MAP.getId())) {
|
||||
Toast.makeText(getContext(), "onPreferenceClick AUTO_ZOOM_MAP", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
return super.onPreferenceClick(preference);
|
||||
}
|
||||
|
||||
public static boolean showInstance(FragmentManager fragmentManager) {
|
||||
try {
|
||||
SettingsMapDuringNavigationFragment settingsNavigationFragment = new SettingsMapDuringNavigationFragment();
|
||||
fragmentManager.beginTransaction()
|
||||
.add(R.id.fragmentContainer, settingsNavigationFragment, SettingsMapDuringNavigationFragment.TAG)
|
||||
.addToBackStack(SettingsMapDuringNavigationFragment.TAG)
|
||||
.commitAllowingStateLoss();
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,103 @@
|
|||
package net.osmand.plus.settings;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v14.preference.SwitchPreference;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.PreferenceScreen;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Toast;
|
||||
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.R;
|
||||
|
||||
import static net.osmand.plus.settings.profiles.SettingsProfileFragment.IS_USER_PROFILE;
|
||||
import static net.osmand.plus.settings.profiles.SettingsProfileFragment.PROFILE_STRING_KEY;
|
||||
|
||||
public class SettingsNavigationFragment extends SettingsBaseProfileDependentFragment {
|
||||
|
||||
public static final String TAG = "SettingsNavigationFragment";
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View view = super.onCreateView(inflater, container, savedInstanceState);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getPreferenceResId() {
|
||||
return R.xml.navigation_settings;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected int getToolbarResId() {
|
||||
return R.layout.profile_preference_toolbar_big;
|
||||
}
|
||||
|
||||
protected String getToolbarTitle() {
|
||||
return getString(R.string.routing_settings_2);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createUI() {
|
||||
PreferenceScreen screen = getPreferenceScreen();
|
||||
|
||||
Preference route_parameters = screen.findPreference("route_parameters");
|
||||
|
||||
SwitchPreference show_routing_alarms = (SwitchPreference) screen.findPreference("show_routing_alarms");
|
||||
SwitchPreference speak_routing_alarms = (SwitchPreference) screen.findPreference("speak_routing_alarms");
|
||||
Preference vehicle_parameters = screen.findPreference("vehicle_parameters");
|
||||
Preference map_during_navigation = screen.findPreference("map_during_navigation");
|
||||
SwitchPreference turn_screen_on = (SwitchPreference) screen.findPreference("turn_screen_on");
|
||||
Preference reset_to_default = screen.findPreference("reset_to_default");
|
||||
|
||||
route_parameters.setOnPreferenceChangeListener(this);
|
||||
show_routing_alarms.setOnPreferenceChangeListener(this);
|
||||
speak_routing_alarms.setOnPreferenceChangeListener(this);
|
||||
vehicle_parameters.setOnPreferenceChangeListener(this);
|
||||
map_during_navigation.setOnPreferenceChangeListener(this);
|
||||
turn_screen_on.setOnPreferenceChangeListener(this);
|
||||
|
||||
route_parameters.setIcon(getContentIcon(R.drawable.ic_action_track_16));
|
||||
show_routing_alarms.setIcon(getContentIcon(R.drawable.ic_action_alert));
|
||||
speak_routing_alarms.setIcon(getContentIcon(R.drawable.ic_action_volume_up));
|
||||
vehicle_parameters.setIcon(getContentIcon(R.drawable.ic_action_car_dark));
|
||||
map_during_navigation.setIcon(getContentIcon(R.drawable.ic_action_mapillary));
|
||||
turn_screen_on.setIcon(getContentIcon(R.drawable.ic_action_appearance));
|
||||
reset_to_default.setIcon(getContentIcon(R.drawable.ic_action_undo_dark));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
Toast.makeText(getActivity(), "Change " + preference.getKey(), Toast.LENGTH_LONG).show();
|
||||
return super.onPreferenceChange(preference, newValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
Toast.makeText(getActivity(), "Click " + preference.getKey(), Toast.LENGTH_LONG).show();
|
||||
return super.onPreferenceClick(preference);
|
||||
}
|
||||
|
||||
public static boolean showInstance(FragmentManager fragmentManager, ApplicationMode mode) {
|
||||
try {
|
||||
Bundle args = new Bundle();
|
||||
args.putString(PROFILE_STRING_KEY, mode.getStringKey());
|
||||
|
||||
SettingsNavigationFragment settingsNavigationFragment = new SettingsNavigationFragment();
|
||||
settingsNavigationFragment.setArguments(args);
|
||||
|
||||
fragmentManager.beginTransaction()
|
||||
.add(R.id.fragmentContainer, settingsNavigationFragment, SettingsNavigationFragment.TAG)
|
||||
.addToBackStack(SettingsNavigationFragment.TAG)
|
||||
.commitAllowingStateLoss();
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,179 @@
|
|||
package net.osmand.plus.settings;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v14.preference.SwitchPreference;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v7.preference.ListPreference;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.PreferenceScreen;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Toast;
|
||||
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.SettingsBaseActivity;
|
||||
import net.osmand.plus.routepreparationmenu.AvoidRoadsBottomSheetDialogFragment;
|
||||
import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper;
|
||||
import net.osmand.plus.routing.RouteProvider;
|
||||
import net.osmand.router.GeneralRouter;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static net.osmand.plus.activities.SettingsNavigationActivity.getRouter;
|
||||
|
||||
public class SettingsRouteParametersFragment extends SettingsBaseProfileDependentFragment {
|
||||
|
||||
public static final String TAG = "SettingsRouteParametersFragment";
|
||||
private List<GeneralRouter.RoutingParameter> avoidParameters = new ArrayList<GeneralRouter.RoutingParameter>();
|
||||
private List<GeneralRouter.RoutingParameter> preferParameters = new ArrayList<GeneralRouter.RoutingParameter>();
|
||||
private List<GeneralRouter.RoutingParameter> reliefFactorParameters = new ArrayList<GeneralRouter.RoutingParameter>();
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View view = super.onCreateView(inflater, container, savedInstanceState);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getPreferenceResId() {
|
||||
return R.xml.route_parameters;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getToolbarResId() {
|
||||
return R.layout.profile_preference_toolbar;
|
||||
}
|
||||
|
||||
protected String getToolbarTitle() {
|
||||
return getString(R.string.route_parameters);
|
||||
}
|
||||
|
||||
public static boolean showInstance(FragmentManager fragmentManager) {
|
||||
try {
|
||||
SettingsRouteParametersFragment settingsNavigationFragment = new SettingsRouteParametersFragment();
|
||||
fragmentManager.beginTransaction()
|
||||
.add(R.id.fragmentContainer, settingsNavigationFragment, SettingsRouteParametersFragment.TAG)
|
||||
.addToBackStack(SettingsRouteParametersFragment.TAG)
|
||||
.commitAllowingStateLoss();
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createUI() {
|
||||
PreferenceScreen screen = getPreferenceScreen();
|
||||
|
||||
SwitchPreference fastRoute = (SwitchPreference) screen.findPreference(settings.FAST_ROUTE_MODE.getId());
|
||||
fastRoute.setIcon(getContentIcon(R.drawable.ic_action_fastest_route));
|
||||
if (settings.getApplicationMode().getRouteService() != RouteProvider.RouteService.OSMAND) {
|
||||
screen.addPreference(fastRoute);
|
||||
} else {
|
||||
ApplicationMode am = settings.getApplicationMode();
|
||||
GeneralRouter router = getRouter(getMyApplication().getRoutingConfig(), am);
|
||||
clearParameters();
|
||||
if (router != null) { Map<String, GeneralRouter.RoutingParameter> parameters = router.getParameters();
|
||||
if (parameters.containsKey(GeneralRouter.USE_SHORTEST_WAY)) {
|
||||
screen.addPreference(fastRoute);
|
||||
} else {
|
||||
screen.removePreference(fastRoute);
|
||||
}
|
||||
List<GeneralRouter.RoutingParameter> others = new ArrayList<GeneralRouter.RoutingParameter>();
|
||||
for (Map.Entry<String, GeneralRouter.RoutingParameter> e : parameters.entrySet()) {
|
||||
String param = e.getKey();
|
||||
GeneralRouter.RoutingParameter routingParameter = e.getValue();
|
||||
if (param.startsWith("avoid_")) {
|
||||
avoidParameters.add(routingParameter);
|
||||
} else if (param.startsWith("prefer_")) {
|
||||
preferParameters.add(routingParameter);
|
||||
} else if ("relief_smoothness_factor".equals(routingParameter.getGroup())) {
|
||||
reliefFactorParameters.add(routingParameter);
|
||||
} else if (!param.equals(GeneralRouter.USE_SHORTEST_WAY)
|
||||
&& !RoutingOptionsHelper.DRIVING_STYLE.equals(routingParameter.getGroup())
|
||||
&& !param.equals(GeneralRouter.VEHICLE_WEIGHT)
|
||||
&& !param.equals(GeneralRouter.VEHICLE_HEIGHT)) {
|
||||
others.add(routingParameter);
|
||||
}
|
||||
}
|
||||
Preference avoidRouting = screen.findPreference("avoid_in_routing");
|
||||
if (avoidParameters.size() > 0) {
|
||||
avoidRouting.setOnPreferenceClickListener(this);
|
||||
avoidRouting.setIcon(getContentIcon(R.drawable.ic_action_alert));
|
||||
} else {
|
||||
screen.removePreference(avoidRouting);
|
||||
}
|
||||
Preference preferRouting = screen.findPreference("prefer_in_routing");
|
||||
if (preferParameters.size() > 0) {
|
||||
preferRouting.setOnPreferenceClickListener(this);
|
||||
} else {
|
||||
screen.removePreference(preferRouting);
|
||||
}
|
||||
if (reliefFactorParameters.size() > 0) {
|
||||
Preference reliefFactorRouting = new Preference(getContext());
|
||||
reliefFactorRouting.setTitle(SettingsBaseActivity.getRoutingStringPropertyName(getContext(), reliefFactorParameters.get(0).getGroup(),
|
||||
Algorithms.capitalizeFirstLetterAndLowercase(reliefFactorParameters.get(0).getGroup().replace('_', ' '))));
|
||||
reliefFactorRouting.setSummary(R.string.relief_smoothness_factor_descr);
|
||||
screen.addPreference(reliefFactorRouting);
|
||||
}
|
||||
for (GeneralRouter.RoutingParameter p : others) {
|
||||
Preference basePref;
|
||||
if (p.getType() == GeneralRouter.RoutingParameterType.BOOLEAN) {
|
||||
basePref = createSwitchPreference(settings.getCustomRoutingBooleanProperty(p.getId(), p.getDefaultBoolean()));
|
||||
} else {
|
||||
Object[] vls = p.getPossibleValues();
|
||||
String[] svlss = new String[vls.length];
|
||||
int i = 0;
|
||||
for (Object o : vls) {
|
||||
svlss[i++] = o.toString();
|
||||
}
|
||||
basePref = createListPreference(settings.getCustomRoutingProperty(p.getId(),
|
||||
p.getType() == GeneralRouter.RoutingParameterType.NUMERIC ? "0.0" : "-"),
|
||||
p.getPossibleValueDescriptions(), svlss,
|
||||
SettingsBaseActivity.getRoutingStringPropertyName(getContext(), p.getId(), p.getName()),
|
||||
SettingsBaseActivity.getRoutingStringPropertyDescription(getContext(), p.getId(), p.getDescription()));
|
||||
((ListPreference) basePref).setEntries(p.getPossibleValueDescriptions());
|
||||
((ListPreference) basePref).setEntryValues(svlss);
|
||||
}
|
||||
basePref.setTitle(SettingsBaseActivity.getRoutingStringPropertyName(getContext(), p.getId(), p.getName()));
|
||||
basePref.setSummary(SettingsBaseActivity.getRoutingStringPropertyDescription(getContext(), p.getId(), p.getDescription()));
|
||||
screen.addPreference(basePref);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
String key = preference.getKey();
|
||||
switch (key) {
|
||||
case "avoid_in_routing": {
|
||||
AvoidRoadsBottomSheetDialogFragment avoidRoadsFragment = new AvoidRoadsBottomSheetDialogFragment(false);
|
||||
avoidRoadsFragment.setTargetFragment(SettingsRouteParametersFragment.this, AvoidRoadsBottomSheetDialogFragment.REQUEST_CODE);
|
||||
avoidRoadsFragment.show(getActivity().getSupportFragmentManager(), AvoidRoadsBottomSheetDialogFragment.TAG);
|
||||
return true;
|
||||
}
|
||||
case "prefer_in_routing": {
|
||||
// AvoidRoadsBottomSheetDialogFragment avoidRoadsFragment = new AvoidRoadsBottomSheetDialogFragment(true);
|
||||
// avoidRoadsFragment.setTargetFragment(SettingsRouteParametersFragment.this, AvoidRoadsBottomSheetDialogFragment.REQUEST_CODE);
|
||||
// avoidRoadsFragment.show(getActivity().getSupportFragmentManager(), AvoidRoadsBottomSheetDialogFragment.TAG);
|
||||
Toast.makeText(getContext(), "prefer_in_routing", Toast.LENGTH_LONG).show();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void clearParameters() {
|
||||
preferParameters.clear();
|
||||
avoidParameters.clear();
|
||||
reliefFactorParameters.clear();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
package net.osmand.plus.settings;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v14.preference.SwitchPreference;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.PreferenceScreen;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import net.osmand.plus.R;
|
||||
|
||||
public class SettingsScreenAlertsFragment extends SettingsBaseProfileDependentFragment {
|
||||
|
||||
public static final String TAG = "SettingsScreenAlertsFragment";
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View view = super.onCreateView(inflater, container, savedInstanceState);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getPreferenceResId() {
|
||||
return R.xml.screen_alerts;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getToolbarResId() {
|
||||
return R.layout.profile_preference_toolbar;
|
||||
}
|
||||
|
||||
protected String getToolbarTitle() {
|
||||
return getString(R.string.screen_alerts);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createUI() {
|
||||
PreferenceScreen screen = getPreferenceScreen();
|
||||
|
||||
SwitchPreference SHOW_ROUTING_ALARMS = (SwitchPreference) screen.findPreference(settings.SHOW_ROUTING_ALARMS.getId());
|
||||
Preference SHOW_TRAFFIC_WARNINGS_DESCR = screen.findPreference("show_routing_alarms_descr");
|
||||
SwitchPreference SHOW_TRAFFIC_WARNINGS = (SwitchPreference) screen.findPreference(settings.SHOW_TRAFFIC_WARNINGS.getId());
|
||||
SwitchPreference SHOW_PEDESTRIAN = (SwitchPreference) screen.findPreference(settings.SHOW_PEDESTRIAN.getId());
|
||||
SwitchPreference SHOW_CAMERAS = (SwitchPreference) screen.findPreference(settings.SHOW_CAMERAS.getId());
|
||||
SwitchPreference SHOW_LANES = (SwitchPreference) screen.findPreference(settings.SHOW_LANES.getId());
|
||||
SwitchPreference SHOW_TUNNELS = (SwitchPreference) screen.findPreference(settings.SHOW_TUNNELS.getId());
|
||||
|
||||
SHOW_ROUTING_ALARMS.setOnPreferenceChangeListener(this);
|
||||
SHOW_TRAFFIC_WARNINGS.setOnPreferenceChangeListener(this);
|
||||
SHOW_PEDESTRIAN.setOnPreferenceChangeListener(this);
|
||||
SHOW_CAMERAS.setOnPreferenceChangeListener(this);
|
||||
SHOW_LANES.setOnPreferenceChangeListener(this);
|
||||
SHOW_TUNNELS.setOnPreferenceChangeListener(this);
|
||||
|
||||
SHOW_TRAFFIC_WARNINGS_DESCR.setIcon(getContentIcon(R.drawable.ic_action_info_dark));
|
||||
SHOW_TRAFFIC_WARNINGS.setIcon(getIcon(R.drawable.list_warnings_traffic_calming));
|
||||
SHOW_PEDESTRIAN.setIcon(getIcon(R.drawable.list_warnings_pedestrian));
|
||||
SHOW_CAMERAS.setIcon(getIcon(R.drawable.list_warnings_speed_camera));
|
||||
SHOW_LANES.setIcon(getIcon(R.drawable.ic_action_lanes));
|
||||
SHOW_TUNNELS.setIcon(getIcon(R.drawable.list_warnings_tunnel));
|
||||
}
|
||||
|
||||
public static boolean showInstance(FragmentManager fragmentManager) {
|
||||
try {
|
||||
SettingsScreenAlertsFragment settingsNavigationFragment = new SettingsScreenAlertsFragment();
|
||||
fragmentManager.beginTransaction()
|
||||
.add(R.id.fragmentContainer, settingsNavigationFragment, SettingsScreenAlertsFragment.TAG)
|
||||
.addToBackStack(SettingsScreenAlertsFragment.TAG)
|
||||
.commitAllowingStateLoss();
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
package net.osmand.plus.settings;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v14.preference.SwitchPreference;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v7.preference.PreferenceScreen;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.views.ListIntPreference;
|
||||
|
||||
public class SettingsTurnScreenOnFragment extends SettingsBaseProfileDependentFragment {
|
||||
|
||||
public static final String TAG = "SettingsTurnScreenOnFragment";
|
||||
|
||||
@Override
|
||||
protected int getPreferenceResId() {
|
||||
return R.xml.turn_screen_on;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View view = super.onCreateView(inflater, container, savedInstanceState);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getToolbarResId() {
|
||||
return R.layout.profile_preference_toolbar;
|
||||
}
|
||||
|
||||
protected String getToolbarTitle() {
|
||||
return getString(R.string.turn_screen_on);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createUI() {
|
||||
PreferenceScreen screen = getPreferenceScreen();
|
||||
|
||||
SwitchPreference turnScreenOn = (SwitchPreference) screen.findPreference(settings.TURN_SCREEN_ON.getId());
|
||||
|
||||
int[] screenPowerSaveValues = new int[]{0, 5, 10, 15, 20, 30, 45, 60};
|
||||
String[] screenPowerSaveNames = new String[screenPowerSaveValues.length];
|
||||
screenPowerSaveNames[0] = getString(R.string.shared_string_never);
|
||||
for (int i = 1; i < screenPowerSaveValues.length; i++) {
|
||||
screenPowerSaveNames[i] = screenPowerSaveValues[i] + " " + getString(R.string.int_seconds);
|
||||
}
|
||||
|
||||
ListIntPreference turnScreenOnTime = (ListIntPreference) screen.findPreference(settings.TURN_SCREEN_ON_TIME_INT.getId());
|
||||
turnScreenOnTime.setEntries(screenPowerSaveNames);
|
||||
turnScreenOnTime.setEntryValues(screenPowerSaveValues);
|
||||
|
||||
SwitchPreference turnScreenOnSensor = (SwitchPreference) screen.findPreference(settings.TURN_SCREEN_ON_SENSOR.getId());
|
||||
}
|
||||
|
||||
public static boolean showInstance(FragmentManager fragmentManager) {
|
||||
try {
|
||||
SettingsTurnScreenOnFragment settingsNavigationFragment = new SettingsTurnScreenOnFragment();
|
||||
fragmentManager.beginTransaction()
|
||||
.add(R.id.fragmentContainer, settingsNavigationFragment, SettingsTurnScreenOnFragment.TAG)
|
||||
.addToBackStack(SettingsTurnScreenOnFragment.TAG)
|
||||
.commitAllowingStateLoss();
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,189 @@
|
|||
package net.osmand.plus.settings;
|
||||
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.preference.ListPreference;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.PreferenceScreen;
|
||||
import android.view.ContextThemeWrapper;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.SettingsBaseActivity;
|
||||
import net.osmand.plus.activities.SettingsNavigationActivity;
|
||||
import net.osmand.router.GeneralRouter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static net.osmand.plus.activities.SettingsNavigationActivity.getRouter;
|
||||
import static net.osmand.plus.activities.SettingsNavigationActivity.setupSpeedSlider;
|
||||
|
||||
public class SettingsVehicleParametersFragment extends SettingsBaseProfileDependentFragment {
|
||||
|
||||
public static final String TAG = "SettingsVehicleParametersFragment";
|
||||
|
||||
@Override
|
||||
protected int getPreferenceResId() {
|
||||
return R.xml.vehicle_parameters;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View view = super.onCreateView(inflater, container, savedInstanceState);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getToolbarResId() {
|
||||
return R.layout.profile_preference_toolbar;
|
||||
}
|
||||
|
||||
protected String getToolbarTitle() {
|
||||
return getString(R.string.vehicle_parameters);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createUI() {
|
||||
PreferenceScreen screen = getPreferenceScreen();
|
||||
|
||||
GeneralRouter router = getRouter(getMyApplication().getRoutingConfig(), getSelectedMode());
|
||||
if (router != null) {
|
||||
Map<String, GeneralRouter.RoutingParameter> parameters = router.getParameters();
|
||||
List<GeneralRouter.RoutingParameter> others = new ArrayList<GeneralRouter.RoutingParameter>();
|
||||
|
||||
for (Map.Entry<String, GeneralRouter.RoutingParameter> e : parameters.entrySet()) {
|
||||
String param = e.getKey();
|
||||
GeneralRouter.RoutingParameter routingParameter = e.getValue();
|
||||
if (param.equals(GeneralRouter.VEHICLE_HEIGHT) || param.equals(GeneralRouter.VEHICLE_WEIGHT)) {
|
||||
others.add(routingParameter);
|
||||
}
|
||||
}
|
||||
|
||||
for (GeneralRouter.RoutingParameter p : others) {
|
||||
Preference basePref;
|
||||
if (p.getType() == GeneralRouter.RoutingParameterType.BOOLEAN) {
|
||||
basePref = createSwitchPreference(settings.getCustomRoutingBooleanProperty(p.getId(), p.getDefaultBoolean()));
|
||||
} else {
|
||||
Object[] vls = p.getPossibleValues();
|
||||
String[] svlss = new String[vls.length];
|
||||
int i = 0;
|
||||
for (Object o : vls) {
|
||||
svlss[i++] = o.toString();
|
||||
}
|
||||
basePref = createListPreference(settings.getCustomRoutingProperty(p.getId(),
|
||||
p.getType() == GeneralRouter.RoutingParameterType.NUMERIC ? "0.0" : "-"),
|
||||
p.getPossibleValueDescriptions(), svlss,
|
||||
SettingsBaseActivity.getRoutingStringPropertyName(getActivity(), p.getId(), p.getName()),
|
||||
SettingsBaseActivity.getRoutingStringPropertyDescription(getActivity(), p.getId(), p.getDescription()));
|
||||
|
||||
((ListPreference) basePref).setEntries(p.getPossibleValueDescriptions());
|
||||
((ListPreference) basePref).setEntryValues(svlss);
|
||||
}
|
||||
basePref.setTitle(SettingsBaseActivity.getRoutingStringPropertyName(getActivity(), p.getId(), p.getName()));
|
||||
basePref.setSummary(SettingsBaseActivity.getRoutingStringPropertyDescription(getActivity(), p.getId(), p.getDescription()));
|
||||
screen.addPreference(basePref);
|
||||
}
|
||||
GeneralRouter.GeneralRouterProfile routerProfile = router.getProfile();
|
||||
Preference defaultSpeed = screen.findPreference("default_speed");
|
||||
if (routerProfile != GeneralRouter.GeneralRouterProfile.PUBLIC_TRANSPORT) {
|
||||
defaultSpeed.setOnPreferenceClickListener(this);
|
||||
} else {
|
||||
screen.removePreference(defaultSpeed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void showSeekbarSettingsDialog() {
|
||||
final ApplicationMode mode = settings.getApplicationMode();
|
||||
GeneralRouter router = getRouter(getMyApplication().getRoutingConfig(), mode);
|
||||
OsmandSettings.SpeedConstants units = settings.SPEED_SYSTEM.get();
|
||||
String speedUnits = units.toShortString(getActivity());
|
||||
final float[] ratio = new float[1];
|
||||
switch (units) {
|
||||
case MILES_PER_HOUR:
|
||||
ratio[0] = 3600 / OsmAndFormatter.METERS_IN_ONE_MILE;
|
||||
break;
|
||||
case KILOMETERS_PER_HOUR:
|
||||
ratio[0] = 3600 / OsmAndFormatter.METERS_IN_KILOMETER;
|
||||
break;
|
||||
case MINUTES_PER_KILOMETER:
|
||||
ratio[0] = 3600 / OsmAndFormatter.METERS_IN_KILOMETER;
|
||||
speedUnits = getString(R.string.km_h);
|
||||
break;
|
||||
case NAUTICALMILES_PER_HOUR:
|
||||
ratio[0] = 3600 / OsmAndFormatter.METERS_IN_ONE_NAUTICALMILE;
|
||||
break;
|
||||
}
|
||||
|
||||
float settingsMinSpeed = settings.MIN_SPEED.get();
|
||||
float settingsMaxSpeed = settings.MAX_SPEED.get();
|
||||
|
||||
final int[] defaultValue = {Math.round(mode.getDefaultSpeed() * ratio[0])};
|
||||
final int[] minValue = {Math.round((settingsMinSpeed > 0 ? settingsMinSpeed : router.getMinSpeed()) * ratio[0])};
|
||||
final int[] maxValue = {Math.round((settingsMaxSpeed > 0 ? settingsMaxSpeed : router.getMaxSpeed()) * ratio[0])};
|
||||
final int min = Math.round(router.getMinSpeed() * ratio[0] / 2f);
|
||||
final int max = Math.round(router.getMaxSpeed() * ratio[0] * 1.5f);
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
boolean lightMode = getMyApplication().getSettings().isLightContent();
|
||||
int themeRes = lightMode ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme;
|
||||
View seekbarView = LayoutInflater.from(new ContextThemeWrapper(getActivity(), themeRes))
|
||||
.inflate(R.layout.default_speed_dialog, null, false);
|
||||
builder.setView(seekbarView);
|
||||
builder.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
mode.setDefaultSpeed(getMyApplication(), defaultValue[0] / ratio[0]);
|
||||
settings.MIN_SPEED.set(minValue[0] / ratio[0]);
|
||||
settings.MAX_SPEED.set(maxValue[0] / ratio[0]);
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(R.string.shared_string_cancel, null);
|
||||
builder.setNeutralButton("Revert", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
mode.resetDefaultSpeed(getMyApplication());
|
||||
settings.MIN_SPEED.set(0f);
|
||||
settings.MAX_SPEED.set(0f);
|
||||
}
|
||||
});
|
||||
|
||||
setupSpeedSlider(SettingsNavigationActivity.SpeedSliderType.MIN_SPEED, speedUnits, minValue, defaultValue, maxValue, min, max, seekbarView);
|
||||
setupSpeedSlider(SettingsNavigationActivity.SpeedSliderType.DEFAULT_SPEED, speedUnits, minValue, defaultValue, maxValue, min, max, seekbarView);
|
||||
setupSpeedSlider(SettingsNavigationActivity.SpeedSliderType.MAX_SPEED, speedUnits, minValue, defaultValue, maxValue, min, max, seekbarView);
|
||||
|
||||
builder.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
if (preference.getKey().equals("default_speed")) {
|
||||
showSeekbarSettingsDialog();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean showInstance(FragmentManager fragmentManager) {
|
||||
try {
|
||||
SettingsVehicleParametersFragment settingsNavigationFragment = new SettingsVehicleParametersFragment();
|
||||
fragmentManager.beginTransaction()
|
||||
.add(R.id.fragmentContainer, settingsNavigationFragment, SettingsVehicleParametersFragment.TAG)
|
||||
.addToBackStack(SettingsVehicleParametersFragment.TAG)
|
||||
.commitAllowingStateLoss();
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,203 @@
|
|||
package net.osmand.plus.settings;
|
||||
|
||||
import android.media.AudioAttributes;
|
||||
import android.media.AudioManager;
|
||||
import android.os.Bundle;
|
||||
import android.support.v14.preference.SwitchPreference;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v7.preference.ListPreference;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.PreferenceScreen;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.Version;
|
||||
import net.osmand.plus.helpers.FileNameTranslationHelper;
|
||||
import net.osmand.plus.views.ListFloatPreference;
|
||||
import net.osmand.plus.views.ListIntPreference;
|
||||
import net.osmand.plus.voice.CommandPlayer;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import static net.osmand.plus.activities.SettingsNavigationActivity.MORE_VALUE;
|
||||
|
||||
public class SettingsVoiceAnnouncesFragment extends SettingsBaseProfileDependentFragment {
|
||||
|
||||
public static final String TAG = "SettingsVoiceAnnouncesFragment";
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View view = super.onCreateView(inflater, container, savedInstanceState);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getPreferenceResId() {
|
||||
return R.xml.voice_announces;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getToolbarResId() {
|
||||
return R.layout.profile_preference_toolbar;
|
||||
}
|
||||
|
||||
protected String getToolbarTitle() {
|
||||
return getString(R.string.voice_announces);
|
||||
}
|
||||
|
||||
protected void createUI() {
|
||||
PreferenceScreen screen = getPreferenceScreen();
|
||||
|
||||
SwitchPreference SPEAK_ROUTING_ALARMS = (SwitchPreference) screen.findPreference(settings.SPEAK_ROUTING_ALARMS.getId());
|
||||
|
||||
Preference voiceAnnouncesInfo = screen.findPreference("voice_announces_info");
|
||||
voiceAnnouncesInfo.setIcon(getContentIcon(R.drawable.ic_action_info_dark));
|
||||
|
||||
SwitchPreference SPEAK_STREET_NAMES = (SwitchPreference) screen.findPreference(settings.SPEAK_STREET_NAMES.getId());
|
||||
SwitchPreference SPEAK_TRAFFIC_WARNINGS = (SwitchPreference) screen.findPreference(settings.SPEAK_TRAFFIC_WARNINGS.getId());
|
||||
SwitchPreference SPEAK_PEDESTRIAN = (SwitchPreference) screen.findPreference(settings.SPEAK_PEDESTRIAN.getId());
|
||||
SwitchPreference SPEAK_SPEED_LIMIT = (SwitchPreference) screen.findPreference(settings.SPEAK_SPEED_LIMIT.getId());
|
||||
SwitchPreference SPEAK_SPEED_CAMERA = (SwitchPreference) screen.findPreference(settings.SPEAK_SPEED_CAMERA.getId());
|
||||
SwitchPreference SPEAK_TUNNELS = (SwitchPreference) screen.findPreference(settings.SPEAK_TUNNELS.getId());
|
||||
SwitchPreference ANNOUNCE_WPT = (SwitchPreference) screen.findPreference(settings.ANNOUNCE_WPT.getId());
|
||||
SwitchPreference ANNOUNCE_NEARBY_FAVORITES = (SwitchPreference) screen.findPreference(settings.ANNOUNCE_NEARBY_FAVORITES.getId());
|
||||
SwitchPreference ANNOUNCE_NEARBY_POI = (SwitchPreference) screen.findPreference(settings.ANNOUNCE_NEARBY_POI.getId());
|
||||
|
||||
String[] speedNames;
|
||||
float[] speedLimits;
|
||||
if (settings.METRIC_SYSTEM.get() == OsmandSettings.MetricsConstants.KILOMETERS_AND_METERS) {
|
||||
speedLimits = new float[]{-10f, -7f, -5f, 0f, 5f, 7f, 10f, 15f, 20f};
|
||||
speedNames = new String[speedLimits.length];
|
||||
for (int i = 0; i < speedLimits.length; i++) {
|
||||
speedNames[i] = (int) speedLimits[i] + " " + getString(R.string.km_h);
|
||||
}
|
||||
} else {
|
||||
speedLimits = new float[]{-7f, -5f, -3f, 0f, 3f, 5f, 7f, 10f, 15f};
|
||||
speedNames = new String[speedLimits.length];
|
||||
for (int i = 0; i < speedNames.length; i++) {
|
||||
speedNames[i] = (int) speedLimits[i] + " " + getString(R.string.mile_per_hour);
|
||||
}
|
||||
}
|
||||
ListFloatPreference SPEED_LIMIT_EXCEED = (ListFloatPreference) screen.findPreference(settings.SPEED_LIMIT_EXCEED.getId());
|
||||
SPEED_LIMIT_EXCEED.setEntries(speedNames);
|
||||
SPEED_LIMIT_EXCEED.setEntryValues(speedLimits);
|
||||
|
||||
//keep informing option:
|
||||
int[] keepInformingValues = new int[]{0, 1, 2, 3, 5, 7, 10, 15, 20, 25, 30};
|
||||
String[] keepInformingNames = new String[keepInformingValues.length];
|
||||
keepInformingNames[0] = getString(R.string.keep_informing_never);
|
||||
for (int i = 1; i < keepInformingValues.length; i++) {
|
||||
keepInformingNames[i] = keepInformingValues[i] + " " + getString(R.string.int_min);
|
||||
}
|
||||
ListIntPreference KEEP_INFORMING = (ListIntPreference) screen.findPreference(settings.KEEP_INFORMING.getId());
|
||||
KEEP_INFORMING.setEntries(keepInformingNames);
|
||||
KEEP_INFORMING.setEntryValues(keepInformingValues);
|
||||
|
||||
float[] arrivalValues = new float[]{1.5f, 1f, 0.5f, 0.25f};
|
||||
String[] arrivalNames = new String[]{
|
||||
getString(R.string.arrival_distance_factor_early),
|
||||
getString(R.string.arrival_distance_factor_normally),
|
||||
getString(R.string.arrival_distance_factor_late),
|
||||
getString(R.string.arrival_distance_factor_at_last)
|
||||
};
|
||||
|
||||
ListFloatPreference ARRIVAL_DISTANCE_FACTOR = (ListFloatPreference) screen.findPreference(settings.ARRIVAL_DISTANCE_FACTOR.getId());
|
||||
ARRIVAL_DISTANCE_FACTOR.setEntries(arrivalNames);
|
||||
ARRIVAL_DISTANCE_FACTOR.setEntryValues(arrivalValues);
|
||||
|
||||
reloadVoiceListPreference(screen);
|
||||
addVoicePrefs(screen);
|
||||
}
|
||||
|
||||
private void reloadVoiceListPreference(PreferenceScreen screen) {
|
||||
String[] entries;
|
||||
String[] entrieValues;
|
||||
Set<String> voiceFiles = getMyApplication().getRoutingOptionsHelper().getVoiceFiles(getActivity());
|
||||
entries = new String[voiceFiles.size() + 2];
|
||||
entrieValues = new String[voiceFiles.size() + 2];
|
||||
int k = 0;
|
||||
// entries[k++] = getString(R.string.shared_string_none);
|
||||
entrieValues[k] = OsmandSettings.VOICE_PROVIDER_NOT_USE;
|
||||
entries[k++] = getString(R.string.shared_string_do_not_use);
|
||||
for (String s : voiceFiles) {
|
||||
entries[k] = (s.contains("tts") ? getString(R.string.ttsvoice) + " " : "") +
|
||||
FileNameTranslationHelper.getVoiceName(getMyActivity(), s);
|
||||
entrieValues[k] = s;
|
||||
k++;
|
||||
}
|
||||
entrieValues[k] = MORE_VALUE;
|
||||
entries[k] = getString(R.string.install_more);
|
||||
ListPreference voiceProvider = (ListPreference) screen.findPreference(settings.VOICE_PROVIDER.getId());
|
||||
voiceProvider.setEntries(entries);
|
||||
voiceProvider.setEntryValues(entrieValues);
|
||||
voiceProvider.setIcon(getContentIcon(R.drawable.ic_action_volume_mute));
|
||||
}
|
||||
|
||||
private void addVoicePrefs(PreferenceScreen screen) {
|
||||
if (!Version.isBlackberry(getMyApplication())) {
|
||||
String[] streamTypes = new String[]{getString(R.string.voice_stream_music),
|
||||
getString(R.string.voice_stream_notification), getString(R.string.voice_stream_voice_call)};
|
||||
//getString(R.string.shared_string_default)};
|
||||
Integer[] streamIntTypes = new Integer[]{AudioManager.STREAM_MUSIC,
|
||||
AudioManager.STREAM_NOTIFICATION, AudioManager.STREAM_VOICE_CALL};
|
||||
String[] streamIntTypesStr = new String[]{String.valueOf(AudioManager.STREAM_MUSIC),
|
||||
String.valueOf(AudioManager.STREAM_NOTIFICATION), String.valueOf(AudioManager.STREAM_VOICE_CALL)};
|
||||
//AudioManager.USE_DEFAULT_STREAM_TYPE};
|
||||
ListIntPreference lp = new ListIntPreference(getContext());
|
||||
lp.setTitle(R.string.choose_audio_stream);
|
||||
lp.setKey(settings.AUDIO_STREAM_GUIDANCE.getId());
|
||||
lp.setDialogTitle(R.string.choose_audio_stream);
|
||||
lp.setSummary(R.string.choose_audio_stream_descr);
|
||||
lp.setEntries(streamTypes);
|
||||
lp.setEntryValues(streamIntTypesStr);
|
||||
// final Preference.OnPreferenceChangeListener prev = lp.getOnPreferenceChangeListener();
|
||||
lp.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
// prev.onPreferenceChange(preference, newValue);
|
||||
CommandPlayer player = getMyApplication().getPlayer();
|
||||
if (player != null) {
|
||||
player.updateAudioStream(settings.AUDIO_STREAM_GUIDANCE.get());
|
||||
}
|
||||
// Sync corresponding AUDIO_USAGE value
|
||||
ApplicationMode mode = getMyApplication().getSettings().getApplicationMode();
|
||||
int stream = settings.AUDIO_STREAM_GUIDANCE.getModeValue(mode);
|
||||
if (stream == AudioManager.STREAM_MUSIC) {
|
||||
settings.AUDIO_USAGE.setModeValue(mode, AudioAttributes.USAGE_ASSISTANCE_NAVIGATION_GUIDANCE);
|
||||
} else if (stream == AudioManager.STREAM_NOTIFICATION) {
|
||||
settings.AUDIO_USAGE.setModeValue(mode, AudioAttributes.USAGE_NOTIFICATION);
|
||||
} else if (stream == AudioManager.STREAM_VOICE_CALL) {
|
||||
settings.AUDIO_USAGE.setModeValue(mode, AudioAttributes.USAGE_VOICE_COMMUNICATION);
|
||||
}
|
||||
|
||||
// Sync DEFAULT value with CAR value, as we have other way to set it for now
|
||||
settings.AUDIO_STREAM_GUIDANCE.setModeValue(ApplicationMode.DEFAULT, settings.AUDIO_STREAM_GUIDANCE.getModeValue(ApplicationMode.CAR));
|
||||
settings.AUDIO_USAGE.setModeValue(ApplicationMode.DEFAULT, settings.AUDIO_USAGE.getModeValue(ApplicationMode.CAR));
|
||||
return true;
|
||||
}
|
||||
});
|
||||
screen.addPreference(lp);
|
||||
screen.addPreference(createSwitchPreference(settings.INTERRUPT_MUSIC, R.string.interrupt_music,
|
||||
R.string.interrupt_music_descr));
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean showInstance(FragmentManager fragmentManager) {
|
||||
try {
|
||||
SettingsVoiceAnnouncesFragment settingsNavigationFragment = new SettingsVoiceAnnouncesFragment();
|
||||
fragmentManager.beginTransaction()
|
||||
.add(R.id.fragmentContainer, settingsNavigationFragment, SettingsVoiceAnnouncesFragment.TAG)
|
||||
.addToBackStack(SettingsVoiceAnnouncesFragment.TAG)
|
||||
.commitAllowingStateLoss();
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,936 @@
|
|||
package net.osmand.plus.settings.profiles;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.DialogInterface.OnDismissListener;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.os.Build.VERSION;
|
||||
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.v7.app.AlertDialog;
|
||||
import android.support.v7.app.AlertDialog.Builder;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.TypedValue;
|
||||
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;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ListPopupWindow;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
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.base.BaseOsmAndFragment;
|
||||
import net.osmand.plus.profiles.RoutingProfileDataObject;
|
||||
import net.osmand.plus.routing.RouteProvider.RouteService;
|
||||
import net.osmand.plus.settings.SettingsNavigationFragment;
|
||||
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.settings.profiles.SettingsProfileFragment.IS_NEW_PROFILE;
|
||||
import static net.osmand.plus.settings.profiles.SettingsProfileFragment.IS_USER_PROFILE;
|
||||
import static net.osmand.plus.settings.profiles.SettingsProfileFragment.PROFILE_STRING_KEY;
|
||||
|
||||
public class EditProfileFragment extends BaseOsmAndFragment {
|
||||
|
||||
public static final String TAG = "EditProfileFragment";
|
||||
|
||||
private static final Log LOG = PlatformUtil.getLog(EditProfileFragment.class);
|
||||
|
||||
public static final String OPEN_CONFIG_ON_MAP = "openConfigOnMap";
|
||||
public static final String MAP_CONFIG = "openMapConfigMenu";
|
||||
public static final String NAV_CONFIG = "openNavConfigMenu";
|
||||
public static final String SCREEN_CONFIG = "openScreenConfigMenu";
|
||||
public static final String SELECTED_ITEM = "editedProfile";
|
||||
public static final String SELECTED_ICON = "selectedIcon";
|
||||
|
||||
OsmandApplication app;
|
||||
|
||||
ApplicationMode mode = null;
|
||||
ApplicationProfileObject profile = null;
|
||||
List<RoutingProfileDataObject> routingProfileDataObjects;
|
||||
RoutingProfileDataObject selectedRoutingProfileDataObject = null;
|
||||
|
||||
private boolean isNew = false;
|
||||
private boolean isUserProfile = false;
|
||||
private boolean isDataChanged = false;
|
||||
private boolean isCancelAllowed = true;
|
||||
private boolean nightMode;
|
||||
|
||||
private SelectProfileBottomSheetDialogFragment.SelectProfileListener navTypeListener = null;
|
||||
private SelectProfileBottomSheetDialogFragment.SelectProfileListener iconIdListener = null;
|
||||
private SelectProfileBottomSheetDialogFragment.SelectProfileListener baseTypeListener = null;
|
||||
|
||||
private ImageView profileIcon;
|
||||
private LinearLayout profileIconBtn;
|
||||
private ImageView colorSample;
|
||||
private LinearLayout selectColorBtn;
|
||||
private ExtendedEditText profileNameEt;
|
||||
private OsmandTextFieldBoxes profileNameTextBox;
|
||||
private ExtendedEditText navTypeEt;
|
||||
private OsmandTextFieldBoxes navTypeTextBox;
|
||||
private FrameLayout selectNavTypeBtn;
|
||||
private Button cancelBtn;
|
||||
private Button saveButton;
|
||||
private View mapConfigBtn;
|
||||
private View screenConfigBtn;
|
||||
private View navConfigBtn;
|
||||
private LinearLayout buttonsLayout;
|
||||
private FrameLayout clickBlockLayout;
|
||||
private LinearLayout typeSelectionBtn;
|
||||
private ImageView baseModeIcon;
|
||||
private TextView baseModeTitle;
|
||||
private ScrollView scrollContainer;
|
||||
private LinearLayout buttonsLayoutSV;
|
||||
private Button cancelBtnSV;
|
||||
private Button saveButtonSV;
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
app = getMyApplication();
|
||||
if (getArguments() != null) {
|
||||
String modeName = getArguments().getString(PROFILE_STRING_KEY, "car");
|
||||
isNew = getArguments().getBoolean(IS_NEW_PROFILE, false);
|
||||
isUserProfile = getArguments().getBoolean(IS_USER_PROFILE, false);
|
||||
mode = ApplicationMode.valueOfStringKey(modeName, ApplicationMode.DEFAULT);
|
||||
profile = new ApplicationProfileObject(mode, isNew, isUserProfile);
|
||||
}
|
||||
nightMode = !app.getSettings().isLightContent();
|
||||
routingProfileDataObjects = getRoutingProfiles(app);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
final MapActivity activity = (MapActivity) getActivity();
|
||||
final View view = inflater.inflate(R.layout.fragment_selected_profile, container, false);
|
||||
|
||||
AndroidUtils.addStatusBarPadding21v(activity, view);
|
||||
|
||||
Toolbar tb = (Toolbar) view.findViewById(R.id.toolbar);
|
||||
|
||||
tb.setClickable(true);
|
||||
tb.setNavigationIcon(getIcon(R.drawable.ic_arrow_back));
|
||||
tb.setNavigationContentDescription(R.string.access_shared_string_navigate_up);
|
||||
tb.setBackgroundColor(getResources().getColor(resolveResourceId(getActivity(), R.attr.pstsTabBackground)));
|
||||
tb.setTitleTextColor(getResources().getColor(resolveResourceId(getActivity(), R.attr.pstsTextColor)));
|
||||
tb.setNavigationOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(final View v) {
|
||||
getActivity().getSupportFragmentManager().popBackStack();
|
||||
}
|
||||
});
|
||||
|
||||
profileIcon = view.findViewById(R.id.profile_icon_img);
|
||||
profileIconBtn = view.findViewById(R.id.select_icon_button);
|
||||
colorSample = view.findViewById(R.id.color_sample_img);
|
||||
selectColorBtn = view.findViewById(R.id.select_icon_color_button);
|
||||
profileNameEt = view.findViewById(R.id.profile_name_et);
|
||||
profileNameTextBox = view.findViewById(R.id.profile_name_otfb);
|
||||
navTypeEt = view.findViewById(R.id.navigation_type_et);
|
||||
navTypeTextBox = view.findViewById(R.id.navigation_type_otfb);
|
||||
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);
|
||||
buttonsLayout = view.findViewById(R.id.buttons_layout);
|
||||
clickBlockLayout = view.findViewById(R.id.click_block_layout);
|
||||
typeSelectionBtn = view.findViewById(R.id.type_selection_button);
|
||||
baseModeIcon = view.findViewById(R.id.mode_icon);
|
||||
baseModeTitle = view.findViewById(R.id.mode_title);
|
||||
scrollContainer = view.findViewById(R.id.scroll_view_container);
|
||||
buttonsLayoutSV = view.findViewById(R.id.buttons_layout_sv);
|
||||
cancelBtnSV = view.findViewById(R.id.cancel_button_sv);
|
||||
saveButtonSV = view.findViewById(R.id.save_profile_btn_sv);
|
||||
|
||||
profileNameEt.setFocusable(true);
|
||||
profileNameTextBox.getEditText().setSelection(profileNameEt.getText().length());
|
||||
|
||||
String title = getResources().getString(R.string.new_profile);
|
||||
|
||||
int startIconId = profile.iconId;
|
||||
|
||||
if (isNew) {
|
||||
isDataChanged = true;
|
||||
startIconId = profile.parent.getIconRes();
|
||||
profile.iconId = startIconId;
|
||||
profile.iconStringName = profile.parent.getIconName();
|
||||
} else if (isUserProfile) {
|
||||
title = profile.userProfileTitle;
|
||||
profileNameEt.setText(title);
|
||||
isDataChanged = false;
|
||||
} else if (profile.stringKeyName != -1) {
|
||||
title = getResources().getString(profile.stringKeyName);
|
||||
profileNameEt.setText(title);
|
||||
clickBlockLayout.setClickable(true);
|
||||
}
|
||||
profile.userProfileTitle = title;
|
||||
|
||||
tb.setTitle(title);
|
||||
|
||||
if (profile.parent != null) {
|
||||
setupBaseProfileView(profile.parent.getStringKey());
|
||||
} else if (profile.stringKeyName != -1) {
|
||||
baseModeTitle.setText(profile.stringKeyName);
|
||||
baseModeIcon.setImageDrawable(
|
||||
app.getUIUtilities().getIcon(profile.iconId, R.color.icon_color_default_light));
|
||||
}
|
||||
if (isUserProfile || isNew) {
|
||||
typeSelectionBtn.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
final SelectProfileBottomSheetDialogFragment dialog = new SelectProfileBottomSheetDialogFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
if (profile.parent != null) {
|
||||
bundle.putString(SelectProfileBottomSheetDialogFragment.SELECTED_KEY, profile.parent.getStringKey());
|
||||
}
|
||||
bundle.putString(SelectProfileBottomSheetDialogFragment.DIALOG_TYPE, SelectProfileBottomSheetDialogFragment.TYPE_BASE_APP_PROFILE);
|
||||
dialog.setArguments(bundle);
|
||||
if (getActivity() != null) {
|
||||
getActivity().getSupportFragmentManager().beginTransaction()
|
||||
.add(dialog, "select_base_type").commitAllowingStateLoss();
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
typeSelectionBtn.setClickable(false);
|
||||
}
|
||||
|
||||
if (!Algorithms.isEmpty(mode.getRoutingProfile()) || mode.getRouteService() != RouteService.OSMAND) {
|
||||
for (RoutingProfileDataObject r : routingProfileDataObjects) {
|
||||
if (mode.getRoutingProfile() != null && mode.getRoutingProfile().equals(r.getStringKey())
|
||||
|| (mode.getRouteService() == RouteService.BROUTER
|
||||
&& r.getStringKey().equals(RoutingProfilesResources.BROUTER_MODE.name()))
|
||||
|| (mode.getRouteService() == RouteService.STRAIGHT
|
||||
&& r.getStringKey().equals(RoutingProfilesResources.STRAIGHT_LINE_MODE.name()))) {
|
||||
profile.routingProfileDataObject = r;
|
||||
r.setSelected(true);
|
||||
navTypeEt.setText(r.getName());
|
||||
navTypeEt.clearFocus();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (RoutingProfileDataObject rp : routingProfileDataObjects) {
|
||||
if (profile.stringKey.equals(rp.getStringKey())) {
|
||||
navTypeEt.setText(
|
||||
RoutingProfilesResources.valueOf(rp.getStringKey().toUpperCase())
|
||||
.getStringRes());
|
||||
}
|
||||
}
|
||||
navTypeEt.clearFocus();
|
||||
}
|
||||
profileNameEt.clearFocus();
|
||||
|
||||
int iconColor = profile.iconColor.getColor(nightMode);
|
||||
|
||||
profileIcon.setImageDrawable(app.getUIUtilities().getIcon(startIconId, iconColor));
|
||||
colorSample.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_circle, iconColor));
|
||||
|
||||
profileNameEt.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
profile.userProfileTitle = s.toString();
|
||||
isCancelAllowed = false;
|
||||
|
||||
if (getActivity() instanceof OsmandActionBarActivity) {
|
||||
ActionBar actionBar = ((OsmandActionBarActivity) getActivity()).getSupportActionBar();
|
||||
if (actionBar != null) {
|
||||
actionBar.setTitle(s.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
selectNavTypeBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (isNew || isUserProfile) {
|
||||
hideKeyboard();
|
||||
final SelectProfileBottomSheetDialogFragment fragment = new SelectProfileBottomSheetDialogFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
if (profile.routingProfileDataObject != null) {
|
||||
bundle.putString(SelectProfileBottomSheetDialogFragment.SELECTED_KEY,
|
||||
profile.routingProfileDataObject.getStringKey());
|
||||
}
|
||||
bundle.putString(SelectProfileBottomSheetDialogFragment.DIALOG_TYPE, SelectProfileBottomSheetDialogFragment.TYPE_NAV_PROFILE);
|
||||
fragment.setArguments(bundle);
|
||||
if (getActivity() != null) {
|
||||
getActivity().getSupportFragmentManager().beginTransaction()
|
||||
.add(fragment, "select_nav_type").commitAllowingStateLoss();
|
||||
}
|
||||
navTypeEt.setCursorVisible(false);
|
||||
navTypeEt.setTextIsSelectable(false);
|
||||
navTypeEt.clearFocus();
|
||||
navTypeEt.requestFocus(ExtendedEditText.FOCUS_UP);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (isUserProfile || isNew) {
|
||||
profileIconBtn.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
final SelectProfileBottomSheetDialogFragment iconSelectDialog = new SelectProfileBottomSheetDialogFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(SelectProfileBottomSheetDialogFragment.DIALOG_TYPE, SelectProfileBottomSheetDialogFragment.TYPE_ICON);
|
||||
bundle.putString(SELECTED_ICON, profile.iconStringName);
|
||||
iconSelectDialog.setArguments(bundle);
|
||||
hideKeyboard();
|
||||
if (getActivity() != null) {
|
||||
getActivity().getSupportFragmentManager().beginTransaction()
|
||||
.add(iconSelectDialog, "select_icon")
|
||||
.commitAllowingStateLoss();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
selectColorBtn.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
final ListPopupWindow popupWindow = new ListPopupWindow(activity);
|
||||
popupWindow.setAnchorView(selectColorBtn);
|
||||
popupWindow.setContentWidth(AndroidUtils.dpToPx(activity, 200f));
|
||||
popupWindow.setModal(true);
|
||||
if (Build.VERSION.SDK_INT >= VERSION_CODES.KITKAT) {
|
||||
popupWindow.setDropDownGravity(Gravity.TOP | Gravity.RIGHT);
|
||||
}
|
||||
popupWindow.setVerticalOffset(AndroidUtils.dpToPx(activity, -48f));
|
||||
popupWindow.setHorizontalOffset(AndroidUtils.dpToPx(activity, -6f));
|
||||
final ProfileColorAdapter profileColorAdapter = new ProfileColorAdapter(activity, mode.getIconColorInfo());
|
||||
popupWindow.setAdapter(profileColorAdapter);
|
||||
popupWindow.setOnItemClickListener(new OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
isDataChanged = true;
|
||||
profile.iconColor = ProfileIconColors.values()[position];
|
||||
profileIcon.setImageDrawable(app.getUIUtilities().getIcon(profile.iconId, profile.iconColor.getColor(nightMode)));
|
||||
colorSample.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_circle, profile.iconColor.getColor(nightMode)));
|
||||
popupWindow.dismiss();
|
||||
}
|
||||
});
|
||||
popupWindow.show();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (VERSION.SDK_INT > VERSION_CODES.LOLLIPOP) {
|
||||
selectColorBtn.setBackground(null);
|
||||
profileIconBtn.setBackground(null);
|
||||
} else {
|
||||
selectColorBtn.setBackgroundDrawable(null);
|
||||
profileIconBtn.setBackgroundDrawable(null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
mapConfigBtn.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(), 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);
|
||||
Intent i = new Intent(getActivity(), MapActivity.class);
|
||||
i.putExtra(OPEN_CONFIG_ON_MAP, SCREEN_CONFIG);
|
||||
i.putExtra(SELECTED_ITEM, profile.stringKey);
|
||||
startActivity(i);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
navConfigBtn.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (isDataChanged) {
|
||||
needSaveDialog();
|
||||
} else if (getSettings() != null) {
|
||||
activateMode(mode);
|
||||
getSettings().APPLICATION_MODE.set(mode);
|
||||
SettingsNavigationFragment.showInstance(getActivity().getSupportFragmentManager(), mode);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
cancelBtn.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (getActivity() != null) {
|
||||
getActivity().onBackPressed();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
cancelBtnSV.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (getActivity() != null) {
|
||||
getActivity().onBackPressed();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (!isNew && !isUserProfile) {
|
||||
saveButtonSV.setEnabled(false);
|
||||
saveButton.setEnabled(false);
|
||||
} else {
|
||||
saveButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (saveNewProfile()) {
|
||||
activateMode(mode);
|
||||
getActivity().onBackPressed();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
saveButtonSV.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (saveNewProfile()) {
|
||||
activateMode(mode);
|
||||
getActivity().onBackPressed();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
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();
|
||||
// int keypadHeight = screenHeight - r.bottom;
|
||||
// if (keypadHeight > screenHeight * 0.15) {
|
||||
// buttonsLayout.setVisibility(View.GONE);
|
||||
// buttonsLayoutSV.setVisibility(View.VISIBLE);
|
||||
// setMargins(scrollContainer, 0, 0, 0, (int) (marginHide * d));
|
||||
// } else {
|
||||
// buttonsLayoutSV.setVisibility(View.GONE);
|
||||
// buttonsLayout.setVisibility(View.VISIBLE);
|
||||
// setMargins(scrollContainer, 0, 0, 0, (int) (marginShow * d));
|
||||
// }
|
||||
}
|
||||
});
|
||||
return view;
|
||||
}
|
||||
|
||||
private int resolveResourceId(final Activity activity, final int attr) {
|
||||
final TypedValue typedvalueattr = new TypedValue();
|
||||
activity.getTheme().resolveAttribute(attr, typedvalueattr, true);
|
||||
return typedvalueattr.resourceId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
getBaseProfileListener();
|
||||
getNavProfileListener();
|
||||
getIconListener();
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStatusBarColorId() {
|
||||
return getSettings().isLightContent() ? R.color.status_bar_color_light : R.color.status_bar_color_dark;
|
||||
}
|
||||
|
||||
public boolean onBackPressedAllowed() {
|
||||
return isCancelAllowed;
|
||||
}
|
||||
|
||||
SelectProfileBottomSheetDialogFragment.SelectProfileListener getIconListener() {
|
||||
if (iconIdListener == null) {
|
||||
iconIdListener = new SelectProfileBottomSheetDialogFragment.SelectProfileListener() {
|
||||
@Override
|
||||
public void onSelectedType(int pos, String stringRes) {
|
||||
isDataChanged = true;
|
||||
profile.iconId = pos;
|
||||
profile.iconStringName = stringRes;
|
||||
profileIcon.setImageDrawable(app.getUIUtilities().getIcon(pos,
|
||||
profile.iconColor.getColor(nightMode)));
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
return iconIdListener;
|
||||
}
|
||||
|
||||
SelectProfileBottomSheetDialogFragment.SelectProfileListener getBaseProfileListener() {
|
||||
if (baseTypeListener == null) {
|
||||
baseTypeListener = new SelectProfileBottomSheetDialogFragment.SelectProfileListener() {
|
||||
@Override
|
||||
public void onSelectedType(int pos, String stringRes) {
|
||||
String key = SettingsProfileFragment.getBaseProfiles(getMyApplication())
|
||||
.get(pos).getStringKey();
|
||||
setupBaseProfileView(key);
|
||||
profile.parent = ApplicationMode.valueOfStringKey(key, ApplicationMode.DEFAULT);
|
||||
}
|
||||
};
|
||||
}
|
||||
return baseTypeListener;
|
||||
}
|
||||
|
||||
SelectProfileBottomSheetDialogFragment.SelectProfileListener getNavProfileListener() {
|
||||
if (navTypeListener == null) {
|
||||
navTypeListener = new SelectProfileBottomSheetDialogFragment.SelectProfileListener() {
|
||||
@Override
|
||||
public void onSelectedType(int pos, String stringRes) {
|
||||
updateRoutingProfile(pos);
|
||||
}
|
||||
};
|
||||
}
|
||||
return navTypeListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
if (!isUserProfile && !isNew) {
|
||||
profileNameEt.setFocusable(false);
|
||||
navTypeEt.setFocusable(false);
|
||||
}
|
||||
|
||||
if (isNew) {
|
||||
profileNameEt.requestFocus();
|
||||
} else {
|
||||
scrollContainer.requestFocus();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void updateRoutingProfile(int pos) {
|
||||
isDataChanged = true;
|
||||
for (int i = 0; i < routingProfileDataObjects.size(); i++) {
|
||||
if (i == pos) {
|
||||
routingProfileDataObjects.get(i).setSelected(true);
|
||||
} else {
|
||||
routingProfileDataObjects.get(i).setSelected(false);
|
||||
}
|
||||
}
|
||||
selectedRoutingProfileDataObject = routingProfileDataObjects.get(pos);
|
||||
navTypeEt.setText(selectedRoutingProfileDataObject.getName());
|
||||
profile.routingProfileDataObject = selectedRoutingProfileDataObject;
|
||||
}
|
||||
|
||||
void activateMode(ApplicationMode mode) {
|
||||
if (!ApplicationMode.values(app).contains(mode)) {
|
||||
ApplicationMode.changeProfileAvailability(mode, true, getMyApplication());
|
||||
}
|
||||
}
|
||||
|
||||
private void setupBaseProfileView(String stringKey) {
|
||||
for (ApplicationMode am : ApplicationMode.getDefaultValues()) {
|
||||
if (am.getStringKey().equals(stringKey)) {
|
||||
baseModeIcon.setImageDrawable(
|
||||
app.getUIUtilities().getIcon(am.getIconRes(), R.color.icon_color_default_light));
|
||||
baseModeTitle.setText(Algorithms.capitalizeFirstLetter(am.toHumanString(app)));
|
||||
isDataChanged = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setMargins(View v, int l, int t, int r, int b) {
|
||||
if (v.getLayoutParams() instanceof ViewGroup.MarginLayoutParams) {
|
||||
ViewGroup.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) v.getLayoutParams();
|
||||
p.setMargins(l, t, r, b);
|
||||
v.requestLayout();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean saveNewProfile() {
|
||||
if (profile.routingProfileDataObject == null) {
|
||||
showSaveWarningDialog(
|
||||
getString(R.string.profile_alert_need_routing_type_title),
|
||||
getString(R.string.profile_alert_need_routing_type_msg),
|
||||
getActivity());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (profile.userProfileTitle.isEmpty()
|
||||
|| profile.userProfileTitle.replace(" ", "").length() < 1
|
||||
|| profileNameEt.getText().toString().replace(" ", "").length() < 1) {
|
||||
showSaveWarningDialog(
|
||||
getString(R.string.profile_alert_need_profile_name_title),
|
||||
getString(R.string.profile_alert_need_profile_name_msg),
|
||||
getActivity()
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
for (ApplicationMode m : ApplicationMode.allPossibleValues()) {
|
||||
if (m.getCustomProfileName() != null && getActivity() != null &&
|
||||
m.getCustomProfileName().equals(profile.userProfileTitle) && isNew) {
|
||||
AlertDialog.Builder bld = new AlertDialog.Builder(getActivity());
|
||||
bld.setTitle(R.string.profile_alert_duplicate_name_title);
|
||||
bld.setMessage(R.string.profile_alert_duplicate_name_msg);
|
||||
bld.setNegativeButton(R.string.shared_string_dismiss, null);
|
||||
bld.show();
|
||||
bld.setOnDismissListener(new OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss(DialogInterface dialog) {
|
||||
profileNameEt.requestFocus();
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
}
|
||||
String customStringKey = profile.stringKey;
|
||||
if (isNew) {
|
||||
customStringKey =
|
||||
profile.parent.getStringKey() + "_" + System.currentTimeMillis();
|
||||
}
|
||||
|
||||
ApplicationMode.ApplicationModeBuilder builder = ApplicationMode
|
||||
.createCustomMode(profile.parent, profile.userProfileTitle.trim(), customStringKey)
|
||||
.icon(app, profile.iconStringName);
|
||||
|
||||
if (profile.routingProfileDataObject.getStringKey().equals(
|
||||
RoutingProfilesResources.STRAIGHT_LINE_MODE.name())) {
|
||||
builder.setRouteService(RouteService.STRAIGHT);
|
||||
} else if (profile.routingProfileDataObject.getStringKey().equals(
|
||||
RoutingProfilesResources.BROUTER_MODE.name())) {
|
||||
builder.setRouteService(RouteService.BROUTER);
|
||||
} else if (profile.routingProfileDataObject != null) {
|
||||
builder.setRoutingProfile(profile.routingProfileDataObject.getStringKey());
|
||||
}
|
||||
builder.setColor(profile.iconColor);
|
||||
|
||||
mode = ApplicationMode.saveCustomProfile(builder, getMyApplication());
|
||||
if (!ApplicationMode.values(app).contains(mode)) {
|
||||
ApplicationMode.changeProfileAvailability(mode, true, getMyApplication());
|
||||
}
|
||||
isDataChanged = false;
|
||||
isCancelAllowed = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
private void needSaveDialog() {
|
||||
if (getActivity() != null) {
|
||||
AlertDialog.Builder bld = new AlertDialog.Builder(getActivity());
|
||||
bld.setTitle(R.string.profile_alert_need_save_title);
|
||||
bld.setMessage(R.string.profile_alert_need_save_msg);
|
||||
bld.setNegativeButton(R.string.shared_string_ok, null);
|
||||
bld.show();
|
||||
}
|
||||
}
|
||||
|
||||
private void showSaveWarningDialog(String title, String message, Activity activity) {
|
||||
AlertDialog.Builder bld = new AlertDialog.Builder(activity);
|
||||
bld.setTitle(title);
|
||||
bld.setMessage(message);
|
||||
bld.setNegativeButton(R.string.shared_string_dismiss, null);
|
||||
bld.show();
|
||||
}
|
||||
|
||||
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);
|
||||
bld.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
isCancelAllowed = true;
|
||||
activity.onBackPressed();
|
||||
}
|
||||
});
|
||||
bld.setNegativeButton(R.string.shared_string_cancel, null);
|
||||
bld.show();
|
||||
|
||||
}
|
||||
|
||||
public void onDeleteProfileClick() {
|
||||
if (getActivity() != null) {
|
||||
if (isUserProfile) {
|
||||
AlertDialog.Builder bld = new AlertDialog.Builder(getActivity());
|
||||
bld.setTitle(R.string.profile_alert_delete_title);
|
||||
bld.setMessage(String
|
||||
.format(getString(R.string.profile_alert_delete_msg),
|
||||
profile.userProfileTitle));
|
||||
bld.setPositiveButton(R.string.shared_string_delete,
|
||||
new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
ApplicationMode
|
||||
.deleteCustomMode(mode, getMyApplication());
|
||||
if (getActivity() != null) {
|
||||
getActivity().onBackPressed();
|
||||
}
|
||||
getSettings().APPLICATION_MODE.set(ApplicationMode.DEFAULT);
|
||||
}
|
||||
});
|
||||
bld.setNegativeButton(R.string.shared_string_dismiss, null);
|
||||
bld.show();
|
||||
} else {
|
||||
Toast.makeText(getActivity(), R.string.profile_alert_cant_delete_base,
|
||||
Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void hideKeyboard() {
|
||||
View cf = getActivity().getCurrentFocus();
|
||||
if (cf != null) {
|
||||
InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
if (imm != null) {
|
||||
imm.hideSoftInputFromWindow(cf.getWindowToken(), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static List<RoutingProfileDataObject> getRoutingProfiles(OsmandApplication context) {
|
||||
List<RoutingProfileDataObject> profilesObjects = new ArrayList<>();
|
||||
profilesObjects.add(new RoutingProfileDataObject(
|
||||
RoutingProfilesResources.STRAIGHT_LINE_MODE.name(),
|
||||
context.getString(RoutingProfilesResources.STRAIGHT_LINE_MODE.getStringRes()),
|
||||
context.getString(R.string.special_routing_type),
|
||||
RoutingProfilesResources.STRAIGHT_LINE_MODE.getIconRes(),
|
||||
false, null));
|
||||
if (context.getBRouterService() != null) {
|
||||
profilesObjects.add(new RoutingProfileDataObject(
|
||||
RoutingProfilesResources.BROUTER_MODE.name(),
|
||||
context.getString(RoutingProfilesResources.BROUTER_MODE.getStringRes()),
|
||||
context.getString(R.string.third_party_routing_type),
|
||||
RoutingProfilesResources.BROUTER_MODE.getIconRes(),
|
||||
false, null));
|
||||
}
|
||||
|
||||
Map<String, GeneralRouter> inputProfiles = context.getRoutingConfig().getAllRouters();
|
||||
for (Entry<String, GeneralRouter> e : inputProfiles.entrySet()) {
|
||||
if (!e.getKey().equals("geocoding")) {
|
||||
int iconRes = R.drawable.ic_action_gdirections_dark;
|
||||
String name = e.getValue().getProfileName();
|
||||
String description = context.getString(R.string.osmand_default_routing);
|
||||
if (!Algorithms.isEmpty(e.getValue().getFilename())) {
|
||||
description = e.getValue().getFilename();
|
||||
} else if (RoutingProfilesResources.isRpValue(name.toUpperCase())) {
|
||||
iconRes = RoutingProfilesResources.valueOf(name.toUpperCase()).getIconRes();
|
||||
name = context
|
||||
.getString(RoutingProfilesResources.valueOf(name.toUpperCase()).getStringRes());
|
||||
}
|
||||
profilesObjects.add(new RoutingProfileDataObject(e.getKey(), name, description,
|
||||
iconRes, false, e.getValue().getFilename()));
|
||||
}
|
||||
}
|
||||
return profilesObjects;
|
||||
}
|
||||
|
||||
public enum RoutingProfilesResources {
|
||||
STRAIGHT_LINE_MODE(R.string.routing_profile_straightline, R.drawable.ic_action_split_interval),
|
||||
BROUTER_MODE(R.string.routing_profile_broutrer, R.drawable.ic_action_split_interval),
|
||||
CAR(R.string.rendering_value_car_name, R.drawable.ic_action_car_dark),
|
||||
PEDESTRIAN(R.string.rendering_value_pedestrian_name, R.drawable.ic_action_pedestrian_dark),
|
||||
BICYCLE(R.string.rendering_value_bicycle_name, R.drawable.ic_action_bicycle_dark),
|
||||
SKI(R.string.routing_profile_ski, R.drawable.ic_action_skiing),
|
||||
PUBLIC_TRANSPORT(R.string.app_mode_public_transport, R.drawable.ic_action_bus_dark),
|
||||
BOAT(R.string.app_mode_boat, R.drawable.ic_action_sail_boat_dark),
|
||||
GEOCODING(R.string.routing_profile_geocoding, R.drawable.ic_action_world_globe);
|
||||
|
||||
int stringRes;
|
||||
int iconRes;
|
||||
|
||||
RoutingProfilesResources(int stringRes, int iconRes) {
|
||||
this.stringRes = stringRes;
|
||||
this.iconRes = iconRes;
|
||||
}
|
||||
|
||||
public int getStringRes() {
|
||||
return stringRes;
|
||||
}
|
||||
|
||||
public int getIconRes() {
|
||||
return iconRes;
|
||||
}
|
||||
|
||||
private static final List<String> rpValues = new ArrayList<>();
|
||||
|
||||
static {
|
||||
for (RoutingProfilesResources rpr : RoutingProfilesResources.values()) {
|
||||
rpValues.add(rpr.name());
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isRpValue(String value) {
|
||||
return rpValues.contains(value);
|
||||
}
|
||||
}
|
||||
|
||||
private class ApplicationProfileObject {
|
||||
|
||||
int stringKeyName = -1;
|
||||
String stringKey;
|
||||
String userProfileTitle = "";
|
||||
ApplicationMode parent = null;
|
||||
int iconId = R.drawable.ic_world_globe_dark;
|
||||
String iconStringName = "ic_world_globe_dark";
|
||||
ProfileIconColors iconColor = ProfileIconColors.DEFAULT;
|
||||
RoutingProfileDataObject routingProfileDataObject = null;
|
||||
|
||||
ApplicationProfileObject(ApplicationMode mode, boolean isNew, boolean isUserProfile) {
|
||||
if (isNew) {
|
||||
stringKey = mode.getStringKey() + System.currentTimeMillis();
|
||||
parent = mode;
|
||||
iconStringName = parent.getIconName();
|
||||
} else if (isUserProfile) {
|
||||
stringKey = mode.getStringKey();
|
||||
parent = mode.getParent();
|
||||
iconId = mode.getIconRes();
|
||||
iconStringName = mode.getIconName();
|
||||
iconColor = mode.getIconColorInfo() == null ? ProfileIconColors.DEFAULT : mode.getIconColorInfo();
|
||||
userProfileTitle = mode.getCustomProfileName();
|
||||
} else {
|
||||
stringKeyName = mode.getNameKeyResource();
|
||||
stringKey = mode.getStringKey();
|
||||
iconId = mode.getIconRes();
|
||||
iconStringName = mode.getIconName();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class ProfileColorAdapter extends ArrayAdapter<ColorListItem> {
|
||||
|
||||
private OsmandApplication app;
|
||||
private ProfileIconColors currentColorData;
|
||||
|
||||
|
||||
public ProfileColorAdapter(Context context, ProfileIconColors iconColorData) {
|
||||
super(context, R.layout.rendering_prop_menu_item);
|
||||
this.app = (OsmandApplication) getContext().getApplicationContext();
|
||||
this.currentColorData = iconColorData;
|
||||
init();
|
||||
}
|
||||
|
||||
public void init() {
|
||||
boolean nightMode = !app.getSettings().isLightContent();
|
||||
String currentColorName = app.getString(ProfileIconColors.DEFAULT.getName());
|
||||
ColorListItem item = new ColorListItem(currentColorName, currentColorName, ProfileIconColors.DEFAULT.getColor(nightMode));
|
||||
add(item);
|
||||
for (ProfileIconColors pic : ProfileIconColors.values()) {
|
||||
if (pic != ProfileIconColors.DEFAULT) {
|
||||
item = new ColorListItem(currentColorName, app.getString(pic.getName()), pic.getColor(nightMode));
|
||||
add(item);
|
||||
}
|
||||
}
|
||||
item.setLastItem(true);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public View getView(int position, View convertView, @NonNull ViewGroup parent) {
|
||||
ColorListItem item = getItem(position);
|
||||
View v = convertView;
|
||||
if (v == null) {
|
||||
v = LayoutInflater.from(getContext()).inflate(R.layout.rendering_prop_menu_item, null);
|
||||
}
|
||||
if (item != null) {
|
||||
TextView textView = (TextView) v.findViewById(R.id.text1);
|
||||
textView.setText(item.valueName);
|
||||
if (item.color == -1) {
|
||||
textView.setCompoundDrawablesWithIntrinsicBounds(null, null,
|
||||
app.getUIUtilities().getThemedIcon(R.drawable.ic_action_circle), null);
|
||||
} else {
|
||||
textView.setCompoundDrawablesWithIntrinsicBounds(null, null,
|
||||
app.getUIUtilities().getIcon(R.drawable.ic_action_circle, item.color), null);
|
||||
}
|
||||
|
||||
textView.setCompoundDrawablePadding(AndroidUtils.dpToPx(getContext(), 10f));
|
||||
v.findViewById(R.id.divider).setVisibility(item.lastItem
|
||||
&& position < getCount() - 1 ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
return v;
|
||||
}
|
||||
}
|
||||
|
||||
public static class ColorListItem {
|
||||
private String currentValueName;
|
||||
private String valueName;
|
||||
private int color;
|
||||
private boolean lastItem;
|
||||
|
||||
public ColorListItem(String currentValueName, String valueName, int color) {
|
||||
this.currentValueName = currentValueName;
|
||||
this.valueName = valueName;
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
|
||||
public int getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public boolean isLastItem() {
|
||||
return lastItem;
|
||||
}
|
||||
|
||||
public void setLastItem(boolean lastItem) {
|
||||
this.lastItem = lastItem;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,286 @@
|
|||
package net.osmand.plus.settings.profiles;
|
||||
|
||||
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.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
|
||||
import net.osmand.PlatformUtil;
|
||||
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 net.osmand.plus.profiles.ProfileDataObject;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static net.osmand.plus.settings.profiles.EditProfileFragment.SELECTED_ICON;
|
||||
|
||||
public class SelectProfileBottomSheetDialogFragment extends MenuBottomSheetDialogFragment {
|
||||
|
||||
private static final Log LOG = PlatformUtil
|
||||
.getLog(SelectProfileBottomSheetDialogFragment.class);
|
||||
public static final String TAG = "SelectProfileBottomSheetDialogFragment";
|
||||
|
||||
public final static String DIALOG_TYPE = "dialog_type";
|
||||
public final static String TYPE_BASE_APP_PROFILE = "base_profiles";
|
||||
public final static String TYPE_NAV_PROFILE = "routing_profiles";
|
||||
public final static String TYPE_ICON = "icon_type";
|
||||
public final static String SELECTED_KEY = "selected_base";
|
||||
|
||||
String type;
|
||||
int bottomButtonText = R.string.shared_string_cancel;
|
||||
|
||||
private SelectProfileListener listener;
|
||||
|
||||
private final List<ProfileDataObject> profiles = new ArrayList<>();
|
||||
|
||||
private List<IconResWithDescr> icons;
|
||||
private String selectedItemKey;
|
||||
private String selectedIconRes;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
OsmandApplication app = getMyApplication();
|
||||
Bundle args = getArguments();
|
||||
if (args != null && args.get(DIALOG_TYPE) != null) {
|
||||
type = args.getString(DIALOG_TYPE);
|
||||
selectedItemKey = args.getString(SELECTED_KEY, null);
|
||||
if (type.equals(TYPE_NAV_PROFILE)) {
|
||||
profiles.addAll(EditProfileFragment.getRoutingProfiles(app));
|
||||
} else if (type.equals(TYPE_BASE_APP_PROFILE)) {
|
||||
profiles.addAll(SettingsProfileFragment.getBaseProfiles(app));
|
||||
} else if (type.equals(TYPE_ICON)) {
|
||||
selectedIconRes = args.getString(SELECTED_ICON, "");
|
||||
icons = getProfileIcons();
|
||||
} else {
|
||||
LOG.error("Check intent data!");
|
||||
dismiss();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
view.findViewById(R.id.dismiss_button).setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
onDismissButtonClickAction();
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
if (type.equals(TYPE_NAV_PROFILE) || type.equals(TYPE_BASE_APP_PROFILE)) {
|
||||
if (items.get(items.size()-1).getView() != null) {
|
||||
items.get(items.size()-1).getView().findViewById(R.id.divider_bottom).setVisibility(View.INVISIBLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createMenuItems(Bundle savedInstanceState) {
|
||||
|
||||
if (type.equals(TYPE_BASE_APP_PROFILE)) {
|
||||
items.add(new TitleItem(getString(R.string.select_base_profile_dialog_title)));
|
||||
items.add(new LongDescriptionItem(getString(R.string.select_base_profile_dialog_message)));
|
||||
for (int i = 0; i < profiles.size(); i++) {
|
||||
final int pos = i;
|
||||
final ProfileDataObject profile = profiles.get(i);
|
||||
final boolean isSelected = profile.getStringKey().equals(selectedItemKey);
|
||||
final Drawable drawableIcon;
|
||||
if (isSelected) {
|
||||
drawableIcon = getMyApplication().getUIUtilities()
|
||||
.getIcon(profile.getIconRes(), nightMode
|
||||
? R.color.active_color_primary_dark
|
||||
: R.color.active_color_primary_light);
|
||||
} else {
|
||||
drawableIcon = getMyApplication().getUIUtilities()
|
||||
.getIcon(profile.getIconRes(), R.color.icon_color_default_light);
|
||||
}
|
||||
|
||||
items.add(new BottomSheetItemWithCompoundButton.Builder()
|
||||
.setChecked(isSelected)
|
||||
.setButtonTintList(isSelected
|
||||
? ColorStateList.valueOf(getResolvedColor(getActiveColorId()))
|
||||
: null)
|
||||
.setDescription(profile.getDescription())
|
||||
.setTitle(profile.getName())
|
||||
.setIcon(drawableIcon)
|
||||
.setLayoutId(R.layout.bottom_sheet_item_with_descr_and_radio_btn)
|
||||
.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (listener == null) {
|
||||
getListener();
|
||||
}
|
||||
if (listener != null) {
|
||||
listener.onSelectedType(pos, "");
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
})
|
||||
.create());
|
||||
}
|
||||
|
||||
} else if (type.equals(TYPE_NAV_PROFILE)){
|
||||
items.add(new TitleItem(getString(R.string.select_nav_profile_dialog_title)));
|
||||
for (int i = 0; i < profiles.size(); i++) {
|
||||
final int pos = i;
|
||||
final ProfileDataObject profile = profiles.get(i);
|
||||
final boolean isSelected = profile.getStringKey().equals(selectedItemKey);
|
||||
final Drawable drawableIcon;
|
||||
if (isSelected) {
|
||||
drawableIcon = getMyApplication().getUIUtilities()
|
||||
.getIcon(profile.getIconRes(), nightMode
|
||||
? R.color.active_color_primary_dark
|
||||
: R.color.active_color_primary_light);
|
||||
} else {
|
||||
drawableIcon = getMyApplication().getUIUtilities()
|
||||
.getIcon(profile.getIconRes(), R.color.icon_color_default_light);
|
||||
}
|
||||
|
||||
items.add(new BottomSheetItemWithCompoundButton.Builder()
|
||||
.setChecked(isSelected)
|
||||
.setButtonTintList(isSelected
|
||||
? ColorStateList.valueOf(getResolvedColor(getActiveColorId()))
|
||||
: null)
|
||||
.setDescription(profile.getDescription())
|
||||
.setTitle(profile.getName())
|
||||
.setIcon(drawableIcon)
|
||||
.setLayoutId(R.layout.bottom_sheet_item_with_descr_and_radio_btn)
|
||||
.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (listener == null) {
|
||||
getListener();
|
||||
}
|
||||
if (listener != null) {
|
||||
listener.onSelectedType(pos, "");
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
})
|
||||
.create());
|
||||
}
|
||||
} else if (type.equals(TYPE_ICON)) {
|
||||
items.add(new TitleItem(getString(R.string.select_icon_profile_dialog_title)));
|
||||
for (final IconResWithDescr icon : icons) {
|
||||
Drawable drawableIcon;
|
||||
boolean isSelected = icon.resStringId.equals(selectedIconRes);
|
||||
int iconRes = icon.resId;
|
||||
if (isSelected) {
|
||||
drawableIcon = getMyApplication().getUIUtilities()
|
||||
.getIcon(iconRes, nightMode
|
||||
? R.color.active_color_primary_dark
|
||||
: R.color.active_color_primary_light);
|
||||
} else {
|
||||
drawableIcon = getMyApplication().getUIUtilities()
|
||||
.getIcon(iconRes, R.color.icon_color_default_light);
|
||||
}
|
||||
|
||||
items.add(new BottomSheetItemWithCompoundButton.Builder()
|
||||
.setChecked(icon.resStringId.equals(selectedIconRes))
|
||||
.setButtonTintList(isSelected
|
||||
? ColorStateList.valueOf(getResolvedColor(getActiveColorId()))
|
||||
: null)
|
||||
.setTitle(getMyApplication().getString(icon.titleId))
|
||||
.setIcon(drawableIcon)
|
||||
.setLayoutId(R.layout.bottom_sheet_item_with_radio_btn)
|
||||
.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if(listener == null) {
|
||||
getListener();
|
||||
}
|
||||
if (listener != null) {
|
||||
listener.onSelectedType(icon.resId, icon.resStringId);
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
})
|
||||
.create()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void getListener() {
|
||||
if (getActivity() != null) {
|
||||
EditProfileFragment f = (EditProfileFragment) getActivity().getSupportFragmentManager().findFragmentByTag(EditProfileFragment.TAG);
|
||||
if (f != null) {
|
||||
switch (type) {
|
||||
case TYPE_BASE_APP_PROFILE:
|
||||
listener = f.getBaseProfileListener();
|
||||
break;
|
||||
case TYPE_NAV_PROFILE:
|
||||
listener = f.getNavProfileListener();
|
||||
break;
|
||||
case TYPE_ICON:
|
||||
listener = f.getIconListener();
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
SettingsProfileFragment f2 = (SettingsProfileFragment) getActivity().getSupportFragmentManager()
|
||||
.findFragmentByTag(SettingsProfileFragment.TAG);
|
||||
listener = f2.getBaseProfileListener();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<IconResWithDescr> getProfileIcons() {
|
||||
List<IconResWithDescr> icons = new ArrayList<>();
|
||||
icons.add(new IconResWithDescr(R.drawable.ic_action_car_dark, R.string.app_mode_car, "ic_action_car_dark", false));
|
||||
icons.add(new IconResWithDescr(R.drawable.ic_action_taxi, R.string.app_mode_taxi, "ic_action_taxi", false));
|
||||
icons.add(new IconResWithDescr(R.drawable.ic_action_truck_dark, R.string.app_mode_truck, "ic_action_truck_dark", false));
|
||||
icons.add(new IconResWithDescr(R.drawable.ic_action_shuttle_bus, R.string.app_mode_shuttle_bus, "ic_action_shuttle_bus", false));
|
||||
icons.add(new IconResWithDescr(R.drawable.ic_action_bus_dark, R.string.app_mode_bus, "ic_action_bus_dark",false));
|
||||
icons.add(new IconResWithDescr(R.drawable.ic_action_subway, R.string.app_mode_subway, "ic_action_subway", false));
|
||||
icons.add(new IconResWithDescr(R.drawable.ic_action_motorcycle_dark, R.string.app_mode_motorcycle, "ic_action_motorcycle_dark", false));
|
||||
icons.add(new IconResWithDescr(R.drawable.ic_action_bicycle_dark, R.string.app_mode_bicycle, "ic_action_bicycle_dark", false));
|
||||
icons.add(new IconResWithDescr(R.drawable.ic_action_horse, R.string.app_mode_horse, "ic_action_horse", false));
|
||||
icons.add(new IconResWithDescr(R.drawable.ic_action_pedestrian_dark, R.string.app_mode_pedestrian,"ic_action_pedestrian_dark", false));
|
||||
icons.add(new IconResWithDescr(R.drawable.ic_action_trekking_dark, R.string.app_mode_hiking, "ic_action_trekking_dark", false));
|
||||
icons.add(new IconResWithDescr(R.drawable.ic_action_skiing, R.string.app_mode_skiing, "ic_action_skiing", false));
|
||||
icons.add(new IconResWithDescr(R.drawable.ic_action_sail_boat_dark, R.string.app_mode_boat, "ic_action_sail_boat_dark", false));
|
||||
icons.add(new IconResWithDescr(R.drawable.ic_action_aircraft, R.string.app_mode_aircraft, "ic_action_aircraft", false));
|
||||
icons.add(new IconResWithDescr(R.drawable.ic_action_helicopter, R.string.app_mode_helicopter, "ic_action_helicopter", false));
|
||||
icons.add(new IconResWithDescr(R.drawable.ic_action_personal_transporter, R.string.app_mode_personal_transporter, "ic_action_personal_transporter", false));
|
||||
icons.add(new IconResWithDescr(R.drawable.ic_action_monowheel, R.string.app_mode_monowheel, "ic_action_monowheel", false));
|
||||
icons.add(new IconResWithDescr(R.drawable.ic_action_scooter, R.string.app_mode_scooter, "ic_action_scooter", false));
|
||||
icons.add(new IconResWithDescr(R.drawable.ic_action_ufo, R.string.app_mode_ufo, "ic_action_ufo", false));
|
||||
icons.add(new IconResWithDescr(R.drawable.ic_action_offroad, R.string.app_mode_offroad, "ic_action_offroad", false));
|
||||
icons.add(new IconResWithDescr(R.drawable.ic_action_campervan, R.string.app_mode_campervan, "ic_action_campervan", false));
|
||||
icons.add(new IconResWithDescr(R.drawable.ic_action_camper, R.string.app_mode_camper, "ic_action_camper", false));
|
||||
return icons;
|
||||
}
|
||||
|
||||
interface SelectProfileListener {
|
||||
void onSelectedType(int pos, String stringRes);
|
||||
}
|
||||
|
||||
private class IconResWithDescr {
|
||||
private int resId;
|
||||
private int titleId;
|
||||
private String resStringId;
|
||||
private boolean isSelected;
|
||||
|
||||
public IconResWithDescr(int resId, int titleId, String resStringId, boolean isSelected) {
|
||||
this.resId = resId;
|
||||
this.titleId = titleId;
|
||||
this.isSelected = isSelected;
|
||||
this.resStringId = resStringId;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,205 @@
|
|||
package net.osmand.plus.settings.profiles;
|
||||
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.util.TypedValue;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.base.BaseOsmAndFragment;
|
||||
import net.osmand.plus.profiles.ProfileDataObject;
|
||||
import net.osmand.plus.profiles.ProfileMenuAdapter;
|
||||
import net.osmand.plus.profiles.ProfileMenuAdapter.ProfileMenuAdapterListener;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class SettingsProfileFragment extends BaseOsmAndFragment {
|
||||
|
||||
public static final String TAG = "SettingsProfileFragment";
|
||||
|
||||
private static final Log LOG = PlatformUtil.getLog(SettingsProfileFragment.class);
|
||||
|
||||
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 ProfileMenuAdapter adapter;
|
||||
private RecyclerView recyclerView;
|
||||
private LinearLayout addNewProfileBtn;
|
||||
|
||||
ProfileMenuAdapterListener listener = null;
|
||||
SelectProfileBottomSheetDialogFragment.SelectProfileListener typeListener = null;
|
||||
|
||||
private List<ApplicationMode> allAppModes;
|
||||
private Set<ApplicationMode> availableAppModes;
|
||||
private List<ProfileDataObject> baseProfiles;
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
allAppModes = new ArrayList<>(ApplicationMode.allPossibleValues());
|
||||
allAppModes.remove(ApplicationMode.DEFAULT);
|
||||
availableAppModes = new LinkedHashSet<>(ApplicationMode.values(getMyApplication()));
|
||||
availableAppModes.remove(ApplicationMode.DEFAULT);
|
||||
baseProfiles = getBaseProfiles(getMyActivity());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
|
||||
View view = inflater.inflate(R.layout.profiles_list_fragment, container, false);
|
||||
|
||||
AndroidUtils.addStatusBarPadding21v(getContext(), view);
|
||||
|
||||
Toolbar tb = (Toolbar) view.findViewById(R.id.toolbar);
|
||||
tb.setTitle(R.string.application_profiles);
|
||||
|
||||
tb.setClickable(true);
|
||||
tb.setNavigationIcon(getIcon(R.drawable.ic_arrow_back));
|
||||
tb.setNavigationContentDescription(R.string.access_shared_string_navigate_up);
|
||||
tb.setBackgroundColor(getResources().getColor(resolveResourceId(getActivity(), R.attr.pstsTabBackground)));
|
||||
tb.setTitleTextColor(getResources().getColor(resolveResourceId(getActivity(), R.attr.pstsTextColor)));
|
||||
tb.setNavigationOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(final View v) {
|
||||
getActivity().getSupportFragmentManager().popBackStack();
|
||||
}
|
||||
});
|
||||
|
||||
recyclerView = view.findViewById(R.id.profiles_list);
|
||||
addNewProfileBtn = view.findViewById(R.id.add_profile_btn);
|
||||
|
||||
addNewProfileBtn.setOnClickListener(new OnClickListener() {
|
||||
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
final SelectProfileBottomSheetDialogFragment dialog = new SelectProfileBottomSheetDialogFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(SelectProfileBottomSheetDialogFragment.DIALOG_TYPE, SelectProfileBottomSheetDialogFragment.TYPE_BASE_APP_PROFILE);
|
||||
dialog.setArguments(bundle);
|
||||
if (getActivity() != null) {
|
||||
getActivity().getSupportFragmentManager().beginTransaction()
|
||||
.add(dialog, "select_base_type").commitAllowingStateLoss();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
adapter = new ProfileMenuAdapter(allAppModes, availableAppModes, getMyApplication(), null);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
recyclerView.setAdapter(adapter);
|
||||
return view;
|
||||
}
|
||||
|
||||
private int resolveResourceId(final Activity activity, final int attr) {
|
||||
final TypedValue typedvalueattr = new TypedValue();
|
||||
activity.getTheme().resolveAttribute(attr, typedvalueattr, true);
|
||||
return typedvalueattr.resourceId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStatusBarColorId() {
|
||||
return getSettings().isLightContent() ? R.color.status_bar_color_light : R.color.status_bar_color_dark;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
if (listener == null) {
|
||||
listener = new ProfileMenuAdapterListener() {
|
||||
@Override
|
||||
public void onProfileSelected(ApplicationMode am, boolean selected) {
|
||||
if (selected) {
|
||||
availableAppModes.add(am);
|
||||
} else {
|
||||
availableAppModes.remove(am);
|
||||
}
|
||||
ApplicationMode.changeProfileAvailability(am, selected, getMyApplication());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProfilePressed(ApplicationMode item) {
|
||||
Bundle args = new Bundle();
|
||||
args.putString(PROFILE_STRING_KEY, item.getStringKey());
|
||||
if (item.isCustomProfile()) {
|
||||
args.putBoolean(IS_USER_PROFILE, true);
|
||||
}
|
||||
EditProfileFragment editProfileFragment = new EditProfileFragment();
|
||||
editProfileFragment.setArguments(args);
|
||||
getActivity().getSupportFragmentManager()
|
||||
.beginTransaction()
|
||||
.add(R.id.fragmentContainer, editProfileFragment, EditProfileFragment.TAG)
|
||||
.addToBackStack(EditProfileFragment.TAG)
|
||||
.commit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onButtonPressed() {
|
||||
}
|
||||
};
|
||||
}
|
||||
adapter.setListener(listener);
|
||||
|
||||
getBaseProfileListener();
|
||||
|
||||
allAppModes = new ArrayList<>(ApplicationMode.allPossibleValues());
|
||||
allAppModes.remove(ApplicationMode.DEFAULT);
|
||||
adapter.updateItemsList(allAppModes, new LinkedHashSet<>(ApplicationMode.values(getMyApplication())));
|
||||
}
|
||||
|
||||
SelectProfileBottomSheetDialogFragment.SelectProfileListener getBaseProfileListener() {
|
||||
if (typeListener == null) {
|
||||
typeListener = new SelectProfileBottomSheetDialogFragment.SelectProfileListener() {
|
||||
@Override
|
||||
public void onSelectedType(int pos, String stringRes) {
|
||||
Bundle args = new Bundle();
|
||||
args.putBoolean(IS_NEW_PROFILE, true);
|
||||
args.putBoolean(IS_USER_PROFILE, true);
|
||||
args.putString(PROFILE_STRING_KEY, baseProfiles.get(pos).getStringKey());
|
||||
|
||||
EditProfileFragment editProfileFragment = new EditProfileFragment();
|
||||
editProfileFragment.setArguments(args);
|
||||
getActivity().getSupportFragmentManager()
|
||||
.beginTransaction()
|
||||
.add(R.id.fragmentContainer, editProfileFragment, EditProfileFragment.TAG)
|
||||
.addToBackStack(EditProfileFragment.TAG)
|
||||
.commit();
|
||||
}
|
||||
};
|
||||
}
|
||||
return typeListener;
|
||||
}
|
||||
|
||||
static List<ProfileDataObject> getBaseProfiles(Context ctx) {
|
||||
List<ProfileDataObject> profiles = new ArrayList<>();
|
||||
for (ApplicationMode mode : ApplicationMode.getDefaultValues()) {
|
||||
if (mode != ApplicationMode.DEFAULT) {
|
||||
profiles.add(new ProfileDataObject(mode.toHumanString(ctx), mode.getDescription(ctx),
|
||||
mode.getStringKey(), mode.getIconRes(), false, mode.getIconColorInfo()));
|
||||
}
|
||||
}
|
||||
return profiles;
|
||||
}
|
||||
}
|
85
OsmAnd/src/net/osmand/plus/views/ListFloatPreference.java
Normal file
85
OsmAnd/src/net/osmand/plus/views/ListFloatPreference.java
Normal file
|
@ -0,0 +1,85 @@
|
|||
package net.osmand.plus.views;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.support.v7.preference.ListPreference;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
public class ListFloatPreference extends ListPreference {
|
||||
|
||||
public ListFloatPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
}
|
||||
|
||||
public ListFloatPreference(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
public ListFloatPreference(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public ListFloatPreference(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEntries(CharSequence[] entries) {
|
||||
super.setEntries(entries);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEntries(int entriesResId) {
|
||||
super.setEntries(entriesResId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEntryValues(CharSequence[] entryValues) {
|
||||
super.setEntryValues(entryValues);
|
||||
}
|
||||
|
||||
public void setEntryValues(float[] entryValues) {
|
||||
String[] strings = new String[entryValues.length];
|
||||
for (int i = 0; i < entryValues.length; ++i) {
|
||||
strings[i] = Float.toString(entryValues[i]);
|
||||
}
|
||||
super.setEntryValues(strings);
|
||||
}
|
||||
|
||||
public void setEntryValues(int[] entryValues) {
|
||||
String[] strings = new String[entryValues.length];
|
||||
for (int i = 0; i < entryValues.length; ++i) {
|
||||
strings[i] = Float.toString(entryValues[i]);
|
||||
}
|
||||
super.setEntryValues(strings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEntryValues(int entryValuesResId) {
|
||||
setEntryValues(getContext().getResources().getIntArray(entryValuesResId));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean persistString(String value) {
|
||||
if (value == null) {
|
||||
return false;
|
||||
} else {
|
||||
return persistFloat(Float.valueOf(value));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getPersistedString(String defaultReturnValue) {
|
||||
if (getSharedPreferences().contains(getKey())) {
|
||||
float floatValue = getPersistedFloat(0f);
|
||||
return String.valueOf(floatValue);
|
||||
} else {
|
||||
return defaultReturnValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object onGetDefaultValue(TypedArray a, int index) {
|
||||
return String.valueOf(a.getFloat(index, 0f));
|
||||
}
|
||||
}
|
77
OsmAnd/src/net/osmand/plus/views/ListIntPreference.java
Normal file
77
OsmAnd/src/net/osmand/plus/views/ListIntPreference.java
Normal file
|
@ -0,0 +1,77 @@
|
|||
package net.osmand.plus.views;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.support.v7.preference.ListPreference;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
public class ListIntPreference extends ListPreference {
|
||||
|
||||
public ListIntPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
}
|
||||
|
||||
public ListIntPreference(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
public ListIntPreference(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public ListIntPreference(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEntries(CharSequence[] entries) {
|
||||
super.setEntries(entries);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEntries(int entriesResId) {
|
||||
super.setEntries(entriesResId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEntryValues(CharSequence[] entryValues) {
|
||||
super.setEntryValues(entryValues);
|
||||
}
|
||||
|
||||
public void setEntryValues(int[] entryValues) {
|
||||
String[] strings = new String[entryValues.length];
|
||||
for (int i = 0; i < entryValues.length; ++i) {
|
||||
strings[i] = Integer.toString(entryValues[i]);
|
||||
}
|
||||
super.setEntryValues(strings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEntryValues(int entryValuesResId) {
|
||||
setEntryValues(getContext().getResources().getIntArray(entryValuesResId));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean persistString(String value) {
|
||||
if (value == null) {
|
||||
return false;
|
||||
} else {
|
||||
return persistInt(Integer.valueOf(value));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getPersistedString(String defaultReturnValue) {
|
||||
if (getSharedPreferences().contains(getKey())) {
|
||||
int intValue = getPersistedInt(0);
|
||||
return String.valueOf(intValue);
|
||||
} else {
|
||||
return defaultReturnValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object onGetDefaultValue(TypedArray a, int index) {
|
||||
return String.valueOf(a.getInt(index, 0));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package net.osmand.plus.views;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.v14.preference.SwitchPreference;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
public class SwitchFragmentPreference extends SwitchPreference {
|
||||
|
||||
public SwitchFragmentPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
}
|
||||
|
||||
public SwitchFragmentPreference(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
public SwitchFragmentPreference(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public SwitchFragmentPreference(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onClick() {
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue