Merge branch 'master' of github.com:osmandapp/Osmand

This commit is contained in:
Victor Shcherb 2020-02-01 18:50:24 +01:00
commit 954c985712
63 changed files with 1223 additions and 3167 deletions

View file

@ -391,7 +391,6 @@
<activity android:name="net.osmand.plus.activities.SettingsGeneralActivity" android:configChanges="keyboardHidden|orientation" />
<activity android:name="net.osmand.plus.activities.SettingsNavigationActivity" android:configChanges="keyboardHidden|orientation" />
<activity android:name="net.osmand.plus.monitoring.SettingsMonitoringActivity" android:configChanges="keyboardHidden|orientation" />
<activity android:name="net.osmand.plus.rastermaps.SettingsRasterMapsActivity" android:configChanges="keyboardHidden|orientation" />
<activity android:name="net.osmand.plus.osmedit.SettingsOsmEditingActivity" android:configChanges="keyboardHidden|orientation" />
<activity android:name="net.osmand.plus.development.SettingsDevelopmentActivity" android:configChanges="keyboardHidden|orientation" />
@ -986,15 +985,6 @@
<receiver android:name="net.osmand.plus.liveupdates.LiveUpdatesAlarmReceiver"/>
<activity
android:configChanges="keyboardHidden|orientation"
android:label="Application profiles"
android:name=".profiles.SettingsProfileActivity"/>
<activity
android:name=".profiles.EditProfileActivity"
android:label="Application profiles"/>
<activity android:name=".activities.PrivacyAndSecurityActivity"
android:configChanges="keyboardHidden|orientation" />

View file

@ -1,576 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/activity_background_color"
android:orientation="vertical">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="@dimen/toolbar_height"
android:background="?attr/actionModeBackground"
app:contentInsetLeft="0dp"
app:contentInsetStart="0dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageButton
android:id="@+id/close_button"
style="@style/Widget.AppCompat.Toolbar.Button.Navigation"
android:layout_width="@dimen/toolbar_height"
android:layout_height="@dimen/toolbar_height"
android:contentDescription="@string/access_shared_string_navigate_up"
android:src="@drawable/ic_action_mode_back" />
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/toolbar_title"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"
android:textColor="?attr/app_bar_primary_item_color"
android:textSize="@dimen/dialog_header_text_size"
app:typeface="@string/font_roboto_medium"
tools:text="@string/routing_settings_2" />
<ImageButton
android:id="@+id/delete_button"
style="@style/Widget.AppCompat.Toolbar.Button.Navigation"
android:layout_width="@dimen/toolbar_height"
android:layout_height="@dimen/toolbar_height"
android:contentDescription="@string/shared_string_delete"
android:src="@drawable/ic_action_delete_dark" />
</LinearLayout>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/activity_background_color">
<ScrollView
android:id="@+id/scroll_view_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/setting_profile_item_height"
android:layout_gravity="top"
android:focusable="true"
android:focusableInTouchMode="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="@+id/type_selection_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/bg_color"
android:clickable="true"
android:focusable="true"
android:foreground="?attr/selectableItemBackground"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="64dp"
android:paddingStart="@dimen/content_padding"
android:paddingEnd="@dimen/content_padding_small"
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding_small"
android:orientation="horizontal">
<ImageView
android:id="@+id/mode_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
android:layout_gravity="center_vertical"
android:tint="?attr/default_icon_color"
tools:src="@drawable/ic_action_coordinates_latitude"/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginEnd="@dimen/content_padding"
android:layout_marginRight="@dimen/content_padding"
android:layout_gravity="center_vertical"
android:gravity="center_vertical"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="?android:textColorPrimary"
android:ellipsize="end"
android:maxLines="1"
android:text="@string/profile_type_base_string"/>
<TextView
android:id="@+id/mode_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:textColor="?android:textColorPrimary"
android:textSize="18sp"
tools:text="Item additional description"/>
</LinearLayout>
<ImageView
android:id="@+id/type_down_arrow2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:layout_gravity="center_vertical"
android:src="@drawable/ic_action_arrow_drop_down"
android:tint="@color/settings_divider"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/activity_background_color"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="fitXY"
android:src="@drawable/bg_shadow_list_bottom"/>
<View
android:layout_width="match_parent"
android:layout_height="10dp"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="fitXY"
android:src="@drawable/bg_shadow_list_top"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/bg_color"
android:orientation="vertical">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
<net.osmand.plus.widgets.OsmandTextFieldBoxes
android:id="@+id/profile_name_otfb"
android:layout_width="0dp"
android:layout_height="60dp"
android:layout_weight="1"
android:layout_margin="@dimen/list_content_padding"
app:primaryColor="@color/active_color_primary_dark"
app:secondaryColor="?android:textColorSecondary"
app:labelText="@string/profile_name_hint">
<studio.carbonylgroup.textfieldboxes.ExtendedEditText
android:id="@+id/profile_name_et"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="1"
tools:text="@string/lorem_ipsum"/>
</net.osmand.plus.widgets.OsmandTextFieldBoxes>
</LinearLayout>
</FrameLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginStart="@dimen/list_content_padding"
android:layout_marginEnd="@dimen/list_content_padding"
android:layout_marginLeft="@dimen/list_content_padding"
android:layout_marginRight="@dimen/list_content_padding">
<ImageView
android:id="@+id/type_down_arrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|right"
android:paddingRight="@dimen/content_padding"
android:src="@drawable/ic_action_arrow_drop_down"
android:tint="@color/settings_divider"/>
<net.osmand.plus.widgets.OsmandTextFieldBoxes
android:id="@+id/master_profile_otfb"
android:layout_width="match_parent"
android:layout_height="60dp"
app:primaryColor="@color/active_color_primary_dark"
app:secondaryColor="?android:textColorSecondary"
app:labelText="@string/nav_type_hint">
<studio.carbonylgroup.textfieldboxes.ExtendedEditText
android:id="@+id/master_profile_et"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="false"
android:maxLines="1"
tools:text="Car"/>
</net.osmand.plus.widgets.OsmandTextFieldBoxes>
<FrameLayout
android:id="@+id/select_nav_type_btn"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true"
android:focusable="true"/>
</FrameLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="@dimen/context_menu_action_buttons_h"
android:layout_marginTop="8dp"
android:layout_marginBottom="@dimen/list_content_padding"
android:layout_marginLeft="@dimen/list_content_padding"
android:layout_marginRight="@dimen/list_content_padding"
android:orientation="vertical">
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/divider_color"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:layout_gravity="center_vertical">
<LinearLayout
android:id="@+id/select_icon_button"
android:layout_width="0dp"
android:layout_height="match_parent"
android:background="?attr/selectableItemBackground"
android:layout_weight="1"
android:clickable="true"
android:focusable="true"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:layout_weight="1"
android:textSize="@dimen/default_list_text_size"
android:text="@string/shared_string_icon"
android:textColor="?android:textColorPrimary"/>
<ImageView
android:id="@+id/profile_icon_img"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="@dimen/list_content_padding"
tools:src="@drawable/ic_action_horse"
tools:tint="@color/A400red"/>
</LinearLayout>
<View
android:layout_width="1dp"
android:layout_height="36dp"
android:layout_gravity="center_vertical"
android:background="?attr/divider_color"/>
<LinearLayout
android:id="@+id/select_icon_color_button"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:focusable="true"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:paddingLeft="@dimen/list_content_padding"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:textSize="@dimen/default_list_text_size"
android:text="@string/shared_string_color"
android:textColor="?android:textColorPrimary"/>
<ImageView
android:id="@+id/color_sample_img"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="@dimen/list_content_padding"
tools:src = "@drawable/ic_action_circle"
tools:tint="@color/A400red"/>
</LinearLayout>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/divider_color"/>
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="12dp"
android:layout_marginStart="@dimen/list_content_padding"
android:layout_marginEnd="@dimen/list_content_padding"
android:layout_marginLeft="@dimen/list_content_padding"
android:layout_marginRight="@dimen/list_content_padding"
android:text="@string/osmand_routing_promo"/>
<FrameLayout
android:id="@+id/click_block_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="false"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/activity_background_color"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="fitXY"
android:src="@drawable/bg_shadow_list_bottom"/>
<View
android:layout_width="match_parent"
android:layout_height="10dp"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="fitXY"
android:src="@drawable/bg_shadow_list_top"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/bg_color"
android:orientation="vertical">
<TextView
android:textStyle="bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/list_content_padding"
android:layout_marginStart="@dimen/list_content_padding"
android:layout_marginEnd="@dimen/list_content_padding"
android:layout_marginLeft="@dimen/list_content_padding"
android:layout_marginRight="@dimen/list_content_padding"
android:text="@string/edit_profile_setup_title"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/list_content_padding"
android:layout_marginStart="@dimen/list_content_padding"
android:layout_marginEnd="@dimen/list_content_padding"
android:layout_marginLeft="@dimen/list_content_padding"
android:layout_marginRight="@dimen/list_content_padding"
android:text="@string/edit_profile_setup_subtitle"
android:textColor="@color/description_font_and_bottom_sheet_icons"/>
<LinearLayout
android:id="@+id/profile_config_btn"
android:layout_width="match_parent"
android:layout_height="65dp"
android:background="?android:attr/selectableItemBackground"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:id="@+id/profile_config_icon"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginStart="@dimen/list_content_padding"
android:layout_marginLeft="@dimen/list_content_padding"
android:src="@drawable/ic_action_settings"
android:tint="?attr/default_icon_color"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginLeft="24dp"
android:layout_marginEnd="@dimen/list_content_padding"
android:layout_marginRight="@dimen/list_content_padding"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/configure_profile"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/description_font_and_bottom_sheet_icons"
android:visibility="gone"
tools:text="@string/configure_profile_info"
tools:visibility="visible" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<include layout="@layout/list_shadow_footer"/>
<LinearLayout
android:id="@+id/buttons_layout_sv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="?attr/bg_color"
android:orientation="horizontal"
android:visibility="gone">
<Button
android:id="@+id/cancel_button_sv"
android:layout_width="0dp"
android:layout_height="42dp"
android:layout_weight="1"
android:layout_marginTop="@dimen/list_content_padding"
android:layout_marginBottom="@dimen/list_content_padding"
android:layout_marginStart="@dimen/list_content_padding"
android:layout_marginEnd="8dp"
android:layout_marginLeft="@dimen/list_content_padding"
android:layout_marginRight="8dp"
android:background="?attr/profile_cancel_btn"
android:text="@string/shared_string_cancel"
android:textAllCaps="false"
android:textColor="@color/map_widget_blue"/>
<Button
android:id="@+id/save_profile_btn_sv"
android:layout_width="0dp"
android:layout_height="42dp"
android:layout_weight="1"
android:layout_marginTop="@dimen/list_content_padding"
android:layout_marginBottom="@dimen/list_content_padding"
android:layout_marginStart="8dp"
android:layout_marginEnd="@dimen/list_content_padding"
android:layout_marginLeft="8dp"
android:layout_marginRight="@dimen/list_content_padding"
android:background="?attr/profile_save_btn"
android:text="@string/shared_string_save"
android:textAllCaps="false"
android:textColor="@color/color_white"/>
</LinearLayout>
</LinearLayout>
</ScrollView>
<LinearLayout
android:id="@+id/buttons_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="?attr/bg_color"
android:orientation="horizontal">
<Button
android:id="@+id/cancel_button"
android:layout_width="0dp"
android:layout_height="42dp"
android:layout_weight="1"
android:layout_marginTop="@dimen/list_content_padding"
android:layout_marginBottom="@dimen/list_content_padding"
android:layout_marginStart="@dimen/list_content_padding"
android:layout_marginEnd="8dp"
android:layout_marginLeft="@dimen/list_content_padding"
android:layout_marginRight="8dp"
android:background="?attr/profile_cancel_btn"
android:text="@string/shared_string_cancel"
android:textAllCaps="false"
android:textColor="?attr/active_color_basic"/>
<Button
android:id="@+id/save_profile_btn"
android:layout_width="0dp"
android:layout_height="42dp"
android:layout_weight="1"
android:layout_marginTop="@dimen/list_content_padding"
android:layout_marginBottom="@dimen/list_content_padding"
android:layout_marginStart="8dp"
android:layout_marginEnd="@dimen/list_content_padding"
android:layout_marginLeft="8dp"
android:layout_marginRight="@dimen/list_content_padding"
android:background="?attr/profile_save_btn"
android:text="@string/shared_string_save"
android:textAllCaps="false"
android:textColor="@color/color_white"/>
</LinearLayout>
</FrameLayout>
</LinearLayout>

View file

@ -51,8 +51,8 @@
<ImageView
android:id="@+id/context_menu_icon_view"
android:layout_width="@dimen/dialog_button_height"
android:layout_height="@dimen/dialog_button_height"
android:layout_width="@dimen/standard_icon_size"
android:layout_height="@dimen/standard_icon_size"
android:src="@drawable/ic_action_building_number"/>
</LinearLayout>

View file

@ -1,66 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/activity_background_color"
android:orientation="vertical">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include layout="@layout/global_preference_toolbar" />
</android.support.design.widget.AppBarLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/list_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:clipToPadding="false"
android:paddingBottom="72dp"/>
<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.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.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"
/>
</LinearLayout>
</RelativeLayout>
</LinearLayout>

View file

@ -1803,7 +1803,7 @@
<string name="av_audio_bitrate_descr">Sélectionnez le bitrate audio</string>
<string name="no_address_found">Impossible de déterminer l\'adresse</string>
<string name="looking_up_address">Recherche de l\'adresse</string>
<string name="update">Fréquence de mise à jour</string>
<string name="update">Mise à jour</string>
<string name="only_download_over_wifi">Télécharger uniquement en WiFi</string>
<string name="live_update">Mise à jour en temps réel</string>
<string name="rendering_attr_horseRoutes_name">Randonnée à cheval</string>

View file

@ -3418,7 +3418,7 @@ Zodpovedá oblasti: %1$s x %2$s</string>
<string name="live_monitoring_descr">Umožňuje zdieľanie polohy a zaznamenávanie výletu.</string>
<string name="live_monitoring">Sledovanie online</string>
<string name="save_track_logging_accuracy">Presnosť záznamu</string>
<string name="tracks_view_descr">Všetky vaše zaznamenané stopy sú v \'Menu\' → \'Moje miesta\' → \'Stopy\', alebo v priečinku OsmAnd.</string>
<string name="tracks_view_descr">Všetky vaše zaznamenané stopy sú v %1$s, alebo v priečinku OsmAnd.</string>
<string name="multimedia_notes_view_descr">Všetky vaše OSM poznámky sú v \'Menu\' → \'Moje miesta\' → \'Zmeny v OSM\'.</string>
<string name="video_notes">Video-poznámky</string>
<string name="photo_notes">Foto-poznámky</string>

View file

@ -422,6 +422,9 @@
<color name="app_bar_main_light">#ff8800</color>
<color name="status_bar_main_dark">#101112</color>
<color name="status_bar_main_light">#E68200</color>
<color name="navigation_bar_bg_light">#CCCCCC</color>
<color name="navigation_bar_bg_dark">#2B2E31</color>
<color name="activity_background_dark">#17181a</color>
<color name="activity_background_light">#f0f0f0</color>
<color name="card_and_list_background_dark">#222526</color>

View file

@ -4184,4 +4184,8 @@
<string name="poi_mountain_rescue">Mountain rescue</string>
<string name="poi_shop_security">Security store</string>
<string name="poi_bowling_alley">Bowling center</string>
<string name="poi_piste_ref">Piste reference number</string>
</resources>

View file

@ -11,6 +11,9 @@
Thx - Hardy
-->
<string name="rendering_attr_streetLightingNight_name">Show only at night</string>
<string name="plugin_prefs_reset_successful">All plugin settings restored to default state.</string>
<string name="profile_prefs_reset_successful">All profile settings restored to default state.</string>
<string name="ltr_or_rtl_combine_via_slash">%1$s/%2$s</string>
<string name="sunset_at">Sunset at %1$s</string>
<string name="sunrise_at">Sunrise at %1$s</string>

View file

@ -33,6 +33,13 @@
android:layout="@layout/preference_category_with_descr"
android:title="@string/save_track_logging_accuracy" />
<net.osmand.plus.settings.preferences.ListPreferenceEx
android:key="save_global_track_interval"
android:layout="@layout/preference_with_descr"
android:title="@string/save_global_track_interval"
tools:icon="@drawable/ic_action_time_span"
tools:summary="3 seconds" />
<net.osmand.plus.settings.preferences.ListPreferenceEx
android:key="save_track_min_distance"
android:layout="@layout/preference_with_descr"

View file

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<Preference android:key="general_settings" android:title="@string/general_settings_2" android:summary="@string/general_settings_descr"/>
<Preference android:key="application_profiles" android:title="@string/application_profiles" android:summary="@string/application_profiles_descr"/>
<Preference android:key="routing_settings" android:title="@string/routing_settings_2" android:summary="@string/routing_settings_descr"/>
<Preference android:key="subscription_settings" android:title="@string/osm_live_subscription" android:summary="@string/osm_live_subscription_desc"/>
<Preference android:key="privacy_and_security" android:title="@string/settings_privacy_and_security" android:summary="@string/settings_privacy_and_security_desc"/>

View file

@ -180,6 +180,7 @@ public class AccessibilitySettingsFragment extends BaseSettingsFragment implemen
OsmandMonitoringPlugin plugin = OsmandPlugin.getPlugin(OsmandMonitoringPlugin.class);
if (plugin != null) {
app.getSettings().copyProfilePreferences(appMode, getSelectedAppMode(), plugin.getPreferences());
updateAllSettings();
}
}
@ -188,6 +189,8 @@ public class AccessibilitySettingsFragment extends BaseSettingsFragment implemen
OsmandMonitoringPlugin plugin = OsmandPlugin.getPlugin(OsmandMonitoringPlugin.class);
if (plugin != null) {
app.getSettings().resetProfilePreferences(appMode, plugin.getPreferences());
app.showToastMessage(R.string.plugin_prefs_reset_successful);
updateAllSettings();
}
}

File diff suppressed because it is too large Load diff

View file

@ -1,5 +1,6 @@
package net.osmand.plus;
import android.app.Activity;
import android.location.GnssNavigationMessage;
import android.location.GnssStatus;
import android.os.Build.VERSION;
@ -1020,4 +1021,12 @@ public class OsmAndLocationProvider implements SensorEventListener {
}
return true;
}
public static void requestFineLocationPermissionIfNeeded(Activity activity) {
if (!isLocationPermissionAvailable(activity)) {
ActivityCompat.requestPermissions(activity,
new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
OsmAndLocationProvider.REQUEST_LOCATION_PERMISSION);
}
}
}

View file

@ -19,6 +19,10 @@ import android.support.annotation.StringRes;
import android.support.v4.util.Pair;
import android.support.v7.preference.PreferenceDataStore;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import net.osmand.IndexConstants;
import net.osmand.StateChangedListener;
import net.osmand.ValueHolder;
@ -30,6 +34,8 @@ import net.osmand.map.ITileSource;
import net.osmand.map.TileSourceManager;
import net.osmand.map.TileSourceManager.TileSourceTemplate;
import net.osmand.osm.io.NetworkUtils;
import net.osmand.plus.ApplicationMode.ApplicationModeBean;
import net.osmand.plus.ApplicationMode.ApplicationModeBuilder;
import net.osmand.plus.access.AccessibilityMode;
import net.osmand.plus.access.RelativeDirectionStyle;
import net.osmand.plus.api.SettingsAPI;
@ -39,7 +45,11 @@ import net.osmand.plus.dialogs.RateUsBottomSheetDialogFragment;
import net.osmand.plus.helpers.SearchHistoryHelper;
import net.osmand.plus.mapillary.MapillaryPlugin;
import net.osmand.plus.mapmarkers.CoordinateInputFormats.Format;
import net.osmand.plus.profiles.LocationIcon;
import net.osmand.plus.profiles.NavigationIcon;
import net.osmand.plus.profiles.ProfileIconColors;
import net.osmand.plus.render.RendererRegistry;
import net.osmand.plus.routing.RouteProvider.RouteService;
import net.osmand.plus.voice.CommandPlayer;
import net.osmand.render.RenderingRulesStorage;
import net.osmand.util.Algorithms;
@ -50,6 +60,7 @@ import org.json.JSONObject;
import java.io.File;
import java.io.IOException;
import java.lang.ref.WeakReference;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@ -81,6 +92,8 @@ public class OsmandSettings {
void resetToDefault();
void resetModeToDefault(ApplicationMode m);
void overrideDefaultValue(T newDefaultValue);
void addListener(StateChangedListener<T> listener);
@ -212,11 +225,16 @@ public class OsmandSettings {
}
public static String getSharedPreferencesName(ApplicationMode mode) {
String modeKey = mode != null ? mode.getStringKey() : null;
return getSharedPreferencesNameForKey(modeKey);
}
public static String getSharedPreferencesNameForKey(String modeKey) {
String sharedPreferencesName = !Algorithms.isEmpty(CUSTOM_SHARED_PREFERENCES_NAME) ? CUSTOM_SHARED_PREFERENCES_NAME : SHARED_PREFERENCES_NAME;
if (mode == null) {
if (modeKey == null) {
return sharedPreferencesName;
} else {
return sharedPreferencesName + "." + mode.getStringKey().toLowerCase();
return sharedPreferencesName + "." + modeKey.toLowerCase();
}
}
@ -266,6 +284,20 @@ public class OsmandSettings {
}
}
}
String json = settingsAPI.getString(globalPreferences, "custom_app_profiles", "");
if (!Algorithms.isEmpty(json)) {
Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
Type t = new TypeToken<ArrayList<ApplicationModeBean>>() {
}.getType();
List<ApplicationModeBean> customProfiles = gson.fromJson(json, t);
if (!Algorithms.isEmpty(customProfiles)) {
for (ApplicationModeBean modeBean : customProfiles) {
ApplicationModeBuilder builder = ApplicationMode.fromModeBean(ctx, modeBean);
ApplicationMode.saveProfile(builder, ctx);
}
}
}
}
void migrateHomeWorkParkingToFavorites() {
@ -295,6 +327,10 @@ public class OsmandSettings {
return settingsAPI.getPreferenceObject(getSharedPreferencesName(mode));
}
public Object getProfilePreferences(String modeKey) {
return settingsAPI.getPreferenceObject(getSharedPreferencesNameForKey(modeKey));
}
public OsmandPreference getPreference(String key) {
return registeredPreferences.get(key);
}
@ -409,44 +445,41 @@ public class OsmandSettings {
return false;
}
public boolean copyPreferencesFromProfile(ApplicationMode modeFrom, ApplicationMode modeTo) {
return copyProfilePreferences(modeFrom, modeTo, new ArrayList<OsmandPreference>(registeredPreferences.values()));
public void copyPreferencesFromProfile(ApplicationMode modeFrom, ApplicationMode modeTo) {
copyProfilePreferences(modeFrom, modeTo, new ArrayList<OsmandPreference>(registeredPreferences.values()));
}
public boolean copyProfilePreferences(ApplicationMode modeFrom, ApplicationMode modeTo, List<OsmandPreference> profilePreferences) {
SettingsEditor settingsEditor = settingsAPI.edit(getProfilePreferences(modeTo));
public void copyProfilePreferences(ApplicationMode modeFrom, ApplicationMode modeTo, List<OsmandPreference> profilePreferences) {
for (OsmandPreference pref : profilePreferences) {
if (pref instanceof CommonPreference && !((CommonPreference) pref).global) {
if (prefCanBeCopiedOrReset(pref) && !USER_PROFILE_NAME.getId().equals(pref.getId())) {
CommonPreference profilePref = (CommonPreference) pref;
Object copiedValue = profilePref.getModeValue(modeFrom);
if (copiedValue instanceof String) {
settingsEditor.putString(pref.getId(), (String) copiedValue);
} else if (copiedValue instanceof Boolean) {
settingsEditor.putBoolean(pref.getId(), (Boolean) copiedValue);
} else if (copiedValue instanceof Float) {
settingsEditor.putFloat(pref.getId(), (Float) copiedValue);
} else if (copiedValue instanceof Integer) {
settingsEditor.putInt(pref.getId(), (Integer) copiedValue);
} else if (copiedValue instanceof Long) {
settingsEditor.putLong(pref.getId(), (Long) copiedValue);
if (PARENT_APP_MODE.getId().equals(pref.getId())) {
if (modeTo.isCustomProfile()) {
modeTo.setParentAppMode(modeFrom.isCustomProfile() ? modeFrom.getParent() : modeFrom);
}
} else {
Object copiedValue = profilePref.getModeValue(modeFrom);
profilePref.setModeValue(modeTo, copiedValue);
}
}
}
return settingsEditor.commit();
}
public boolean resetPreferencesForProfile(ApplicationMode mode) {
return settingsAPI.edit(getProfilePreferences(mode)).clear().commit();
public void resetPreferencesForProfile(ApplicationMode mode) {
resetProfilePreferences(mode, new ArrayList<OsmandPreference>(registeredPreferences.values()));
}
public boolean resetProfilePreferences(ApplicationMode mode, List<OsmandPreference> profilePreferences) {
SettingsEditor settingsEditor = settingsAPI.edit(getProfilePreferences(mode));
public void resetProfilePreferences(ApplicationMode mode, List<OsmandPreference> profilePreferences) {
for (OsmandPreference pref : profilePreferences) {
if (pref instanceof CommonPreference && !((CommonPreference) pref).global) {
settingsEditor.remove(pref.getId());
if (prefCanBeCopiedOrReset(pref)) {
pref.resetModeToDefault(mode);
}
}
return settingsEditor.commit();
}
private boolean prefCanBeCopiedOrReset(OsmandPreference pref) {
return pref instanceof CommonPreference && !((CommonPreference) pref).global
&& !APP_MODE_ORDER.getId().equals(pref.getId());
}
public ApplicationMode LAST_ROUTING_APPLICATION_MODE = null;
@ -474,6 +507,11 @@ public class OsmandSettings {
set(ApplicationMode.DEFAULT);
}
@Override
public void resetModeToDefault(ApplicationMode m) {
throw new UnsupportedOperationException();
}
@Override
public boolean isSet() {
return true;
@ -747,6 +785,16 @@ public class OsmandSettings {
set(o);
}
@Override
public void resetModeToDefault(ApplicationMode mode) {
if (global) {
resetToDefault();
} else {
T o = getProfileDefaultValue(mode);
setModeValue(mode, o);
}
}
@Override
public boolean set(T obj) {
Object prefs = getPreferences();
@ -1219,11 +1267,7 @@ public class OsmandSettings {
public final OsmandPreference<String> LAST_FAV_CATEGORY_ENTERED = new StringPreference("last_fav_category", "").makeGlobal();
public final OsmandPreference<ApplicationMode> DEFAULT_APPLICATION_MODE = new CommonPreference<ApplicationMode>("default_application_mode_string", ApplicationMode.DEFAULT) {
{
makeGlobal();
}
@Override
protected ApplicationMode getValue(Object prefs, ApplicationMode defaultValue) {
@ -1271,12 +1315,9 @@ public class OsmandSettings {
public ApplicationMode parseString(String s) {
return appModeFromString(s);
}
};
}.makeGlobal();
public final OsmandPreference<ApplicationMode> LAST_ROUTE_APPLICATION_MODE = new CommonPreference<ApplicationMode>("last_route_application_mode_backup_string", ApplicationMode.DEFAULT) {
{
makeGlobal();
}
@Override
protected ApplicationMode getValue(Object prefs, ApplicationMode defaultValue) {
@ -1319,7 +1360,7 @@ public class OsmandSettings {
public ApplicationMode parseString(String s) {
return appModeFromString(s);
}
};
}.makeGlobal();
public final OsmandPreference<Boolean> FIRST_MAP_IS_DOWNLOADED = new BooleanPreference(
"first_map_is_downloaded", false);
@ -1334,8 +1375,6 @@ public class OsmandSettings {
return super.setValue(prefs, val);
}
;
protected DrivingRegion getDefaultValue() {
Locale df = Locale.getDefault();
if (df == null) {
@ -1420,9 +1459,6 @@ public class OsmandSettings {
return SpeedConstants.MILES_PER_HOUR;
}
}
;
}.makeProfile();
@ -1446,8 +1482,17 @@ public class OsmandSettings {
public final OsmandPreference<Float> SPEED_LIMIT_EXCEED =
new FloatPreference("speed_limit_exceed", 5f).makeProfile();
public final OsmandPreference<Float> DEFAULT_SPEED = new FloatPreference(
"default_speed", 0f).makeProfile().cache();
public final CommonPreference<Float> DEFAULT_SPEED = new FloatPreference("default_speed", 10f).makeProfile().cache();
{
DEFAULT_SPEED.setModeDefaultValue(ApplicationMode.DEFAULT, 1.5f);
DEFAULT_SPEED.setModeDefaultValue(ApplicationMode.CAR, 12.5f);
DEFAULT_SPEED.setModeDefaultValue(ApplicationMode.BICYCLE, 2.77f);
DEFAULT_SPEED.setModeDefaultValue(ApplicationMode.PEDESTRIAN, 1.11f);
DEFAULT_SPEED.setModeDefaultValue(ApplicationMode.BOAT, 1.38f);
DEFAULT_SPEED.setModeDefaultValue(ApplicationMode.AIRCRAFT, 40f);
DEFAULT_SPEED.setModeDefaultValue(ApplicationMode.SKI, 1.38f);
}
public final OsmandPreference<Float> MIN_SPEED = new FloatPreference(
"min_speed", 0f).makeProfile().cache();
@ -1455,6 +1500,67 @@ public class OsmandSettings {
public final OsmandPreference<Float> MAX_SPEED = new FloatPreference(
"max_speed", 0f).makeProfile().cache();
public final CommonPreference<String> ICON_RES_NAME = new StringPreference("app_mode_icon_res_name", "ic_world_globe_dark").makeProfile().cache();
{
ICON_RES_NAME.setModeDefaultValue(ApplicationMode.DEFAULT, "ic_world_globe_dark");
ICON_RES_NAME.setModeDefaultValue(ApplicationMode.CAR, "ic_action_car_dark");
ICON_RES_NAME.setModeDefaultValue(ApplicationMode.BICYCLE, "ic_action_bicycle_dark");
ICON_RES_NAME.setModeDefaultValue(ApplicationMode.PEDESTRIAN, "ic_action_pedestrian_dark");
ICON_RES_NAME.setModeDefaultValue(ApplicationMode.PUBLIC_TRANSPORT, "ic_action_bus_dark");
ICON_RES_NAME.setModeDefaultValue(ApplicationMode.BOAT, "ic_action_sail_boat_dark");
ICON_RES_NAME.setModeDefaultValue(ApplicationMode.AIRCRAFT, "ic_action_aircraft");
ICON_RES_NAME.setModeDefaultValue(ApplicationMode.SKI, "ic_action_skiing");
}
public final CommonPreference<ProfileIconColors> ICON_COLOR = new EnumIntPreference<>("app_mode_icon_color", ProfileIconColors.DEFAULT, ProfileIconColors.values()).makeProfile().cache();
public final CommonPreference<String> USER_PROFILE_NAME = new StringPreference("user_profile_name", "").makeProfile().cache();
public final CommonPreference<String> PARENT_APP_MODE = new StringPreference("parent_app_mode", null).makeProfile().cache();
public final CommonPreference<String> ROUTING_PROFILE = new StringPreference("routing_profile", "").makeProfile().cache();
{
ROUTING_PROFILE.setModeDefaultValue(ApplicationMode.CAR, "car");
ROUTING_PROFILE.setModeDefaultValue(ApplicationMode.BICYCLE, "bicycle");
ROUTING_PROFILE.setModeDefaultValue(ApplicationMode.PEDESTRIAN, "pedestrian");
ROUTING_PROFILE.setModeDefaultValue(ApplicationMode.PUBLIC_TRANSPORT, "public_transport");
ROUTING_PROFILE.setModeDefaultValue(ApplicationMode.BOAT, "boat");
ROUTING_PROFILE.setModeDefaultValue(ApplicationMode.AIRCRAFT, "STRAIGHT_LINE_MODE");
ROUTING_PROFILE.setModeDefaultValue(ApplicationMode.SKI, "ski");
}
public final CommonPreference<RouteService> ROUTE_SERVICE = new EnumIntPreference<>("route_service", RouteService.OSMAND, RouteService.values()).makeProfile().cache();
{
ROUTE_SERVICE.setModeDefaultValue(ApplicationMode.AIRCRAFT, RouteService.STRAIGHT);
}
public final CommonPreference<NavigationIcon> NAVIGATION_ICON = new EnumIntPreference<>("navigation_icon", NavigationIcon.DEFAULT, NavigationIcon.values()).makeProfile().cache();
{
NAVIGATION_ICON.setModeDefaultValue(ApplicationMode.DEFAULT, NavigationIcon.DEFAULT);
NAVIGATION_ICON.setModeDefaultValue(ApplicationMode.CAR, NavigationIcon.DEFAULT);
NAVIGATION_ICON.setModeDefaultValue(ApplicationMode.BICYCLE, NavigationIcon.DEFAULT);
NAVIGATION_ICON.setModeDefaultValue(ApplicationMode.BOAT, NavigationIcon.NAUTICAL);
NAVIGATION_ICON.setModeDefaultValue(ApplicationMode.AIRCRAFT, NavigationIcon.DEFAULT);
NAVIGATION_ICON.setModeDefaultValue(ApplicationMode.SKI, NavigationIcon.DEFAULT);
}
public final CommonPreference<LocationIcon> LOCATION_ICON = new EnumIntPreference<>("location_icon", LocationIcon.DEFAULT, LocationIcon.values()).makeProfile().cache();
{
LOCATION_ICON.setModeDefaultValue(ApplicationMode.DEFAULT, LocationIcon.DEFAULT);
LOCATION_ICON.setModeDefaultValue(ApplicationMode.CAR, LocationIcon.CAR);
LOCATION_ICON.setModeDefaultValue(ApplicationMode.BICYCLE, LocationIcon.BICYCLE);
LOCATION_ICON.setModeDefaultValue(ApplicationMode.BOAT, LocationIcon.DEFAULT);
LOCATION_ICON.setModeDefaultValue(ApplicationMode.AIRCRAFT, LocationIcon.CAR);
LOCATION_ICON.setModeDefaultValue(ApplicationMode.SKI, LocationIcon.BICYCLE);
}
public final CommonPreference<Integer> APP_MODE_ORDER = new IntPreference("app_mode_order", 0).makeProfile().cache();
public final OsmandPreference<Float> SWITCH_MAP_DIRECTION_TO_COMPASS =
new FloatPreference("speed_for_map_to_direction_of_movement", 0f).makeProfile();
@ -1610,8 +1716,6 @@ public class OsmandSettings {
}
return -1;
}
;
}.makeGlobal().cache();
public final CommonPreference<Boolean> SNAP_TO_ROAD = new BooleanPreference("snap_to_road", false).makeProfile().cache();
@ -3079,9 +3183,6 @@ public class OsmandSettings {
// this value string is synchronized with settings_pref.xml preference name
public final CommonPreference<String> RENDERER = new StringPreference("renderer", RendererRegistry.DEFAULT_RENDER) {
{
makeProfile();
}
@Override
protected boolean setValue(Object prefs, String val) {
@ -3090,13 +3191,12 @@ public class OsmandSettings {
}
RenderingRulesStorage loaded = ctx.getRendererRegistry().getRenderer(val);
if (loaded != null) {
super.setValue(prefs, val);
return true;
return super.setValue(prefs, val);
}
return false;
}
};
}.makeProfile();
{
RENDERER.setModeDefaultValue(ApplicationMode.BOAT, RendererRegistry.NAUTICAL_RENDER);
@ -3278,12 +3378,18 @@ public class OsmandSettings {
RateUsBottomSheetDialogFragment.RateUsState.INITIAL_STATE, RateUsBottomSheetDialogFragment.RateUsState.values())
.makeGlobal();
public final CommonPreference<String> DEFAULT_APP_PROFILES =
new StringPreference("default_app_profiles", "").makeGlobal().cache();
public final CommonPreference<String> CUSTOM_APP_PROFILES =
new StringPreference("custom_app_profiles", "").makeGlobal().cache();
public final CommonPreference<String> CUSTOM_APP_MODES_KEYS =
new StringPreference("custom_app_modes_keys", "").makeGlobal().cache();
public Set<String> getCustomAppModesKeys() {
String appModesKeys = CUSTOM_APP_MODES_KEYS.get();
StringTokenizer toks = new StringTokenizer(appModesKeys, ",");
Set<String> res = new LinkedHashSet<String>();
while (toks.hasMoreTokens()) {
res.add(toks.nextToken());
}
return res;
}
public enum DayNightMode {
AUTO(R.string.daynight_mode_auto, R.drawable.ic_action_map_sunset),
@ -3577,6 +3683,18 @@ public class OsmandSettings {
DRIVING_REGION_AUTOMATIC
};
String[] appModeBeanPrefsIds = new String[] {
ICON_COLOR.getId(),
ICON_RES_NAME.getId(),
PARENT_APP_MODE.getId(),
ROUTING_PROFILE.getId(),
ROUTE_SERVICE.getId(),
USER_PROFILE_NAME.getId(),
LOCATION_ICON.getId(),
NAVIGATION_ICON.getId(),
APP_MODE_ORDER.getId()
};
public class PreferencesDataStore extends PreferenceDataStore {
private ApplicationMode appMode;

View file

@ -10,6 +10,7 @@ import android.support.annotation.Nullable;
import android.support.v7.app.AlertDialog;
import net.osmand.PlatformUtil;
import net.osmand.plus.ApplicationMode.ApplicationModeBean;
import net.osmand.plus.ApplicationMode.ApplicationModeBuilder;
import net.osmand.plus.OsmandSettings.OsmandPreference;
import net.osmand.util.Algorithms;
@ -34,10 +35,12 @@ import java.io.InputStreamReader;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;
@ -400,15 +403,20 @@ public class SettingsHelper {
private ApplicationMode appMode;
private ApplicationModeBuilder builder;
private ApplicationModeBean modeBean;
private Set<String> appModeBeanPrefsIds;
public ProfileSettingsItem(@NonNull OsmandSettings settings, @NonNull ApplicationMode appMode) {
super(SettingsItemType.PROFILE, settings);
this.appMode = appMode;
appModeBeanPrefsIds = new HashSet<>(Arrays.asList(settings.appModeBeanPrefsIds));
}
public ProfileSettingsItem(@NonNull OsmandSettings settings, @NonNull JSONObject json) throws JSONException {
super(SettingsItemType.PROFILE, settings, json);
readFromJson(settings.getContext(), json);
appModeBeanPrefsIds = new HashSet<>(Arrays.asList(settings.appModeBeanPrefsIds));
}
@NonNull
@ -421,7 +429,7 @@ public class SettingsHelper {
@Override
public String getPublicName(@NonNull Context ctx) {
if (appMode.isCustomProfile()) {
return appMode.getCustomProfileName();
return modeBean.userProfileName;
} else if (appMode.getNameKeyResource() != -1) {
return ctx.getString(appMode.getNameKeyResource());
} else {
@ -437,7 +445,8 @@ public class SettingsHelper {
void readFromJson(@NonNull OsmandApplication app, @NonNull JSONObject json) throws JSONException {
String appModeJson = json.getString("appMode");
builder = ApplicationMode.fromJson(app, appModeJson);
modeBean = ApplicationMode.fromJson(appModeJson);
builder = ApplicationMode.fromModeBean(app, modeBean);
ApplicationMode appMode = builder.getApplicationMode();
if (!appMode.isCustomProfile()) {
appMode = ApplicationMode.valueOfStringKey(appMode.getStringKey(), appMode);
@ -470,7 +479,9 @@ public class SettingsHelper {
return new OsmandSettingsItemReader(this, getSettings()) {
@Override
protected void readPreferenceFromJson(@NonNull OsmandPreference<?> preference, @NonNull JSONObject json) throws JSONException {
preference.readFromJson(json, appMode);
if (!appModeBeanPrefsIds.contains(preference.getId())) {
preference.readFromJson(json, appMode);
}
}
};
}
@ -481,7 +492,9 @@ public class SettingsHelper {
return new OsmandSettingsItemWriter(this, getSettings()) {
@Override
protected void writePreferenceToJson(@NonNull OsmandPreference<?> preference, @NonNull JSONObject json) throws JSONException {
preference.writeToJson(json, appMode);
if (!appModeBeanPrefsIds.contains(preference.getId())) {
preference.writeToJson(json, appMode);
}
}
};
}

View file

@ -116,7 +116,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.quickaction.QuickActionListFragment;
import net.osmand.plus.render.RendererRegistry;
import net.osmand.plus.resources.ResourceManager;
@ -675,13 +674,6 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
chooseRouteFragment.dismiss(true);
return;
}
EditProfileFragment editProfileFragment = getEditProfileFragment();
if (editProfileFragment != null) {
if (!editProfileFragment.onBackPressedAllowed()) {
editProfileFragment.confirmCancelDialog(this);
return;
}
}
ProfileAppearanceFragment profileAppearanceFragment = getProfileAppearanceFragment();
if (profileAppearanceFragment != null) {
if (profileAppearanceFragment.isProfileAppearanceChanged(this)) {
@ -859,21 +851,21 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
}
setIntent(null);
}
if (intent.hasExtra(EditProfileFragment.OPEN_SETTINGS)) {
String settingsType = intent.getStringExtra(EditProfileFragment.OPEN_SETTINGS);
String appMode = intent.getStringExtra(EditProfileFragment.SELECTED_ITEM);
if (EditProfileFragment.OPEN_CONFIG_PROFILE.equals(settingsType)) {
if (intent.hasExtra(BaseSettingsFragment.OPEN_SETTINGS)) {
String settingsType = intent.getStringExtra(BaseSettingsFragment.OPEN_SETTINGS);
String appMode = intent.getStringExtra(BaseSettingsFragment.APP_MODE_KEY);
if (BaseSettingsFragment.OPEN_CONFIG_PROFILE.equals(settingsType)) {
BaseSettingsFragment.showInstance(this, SettingsScreenType.CONFIGURE_PROFILE, ApplicationMode.valueOfStringKey(appMode, null));
}
setIntent(null);
}
if (intent.hasExtra(EditProfileFragment.OPEN_CONFIG_ON_MAP)) {
switch (intent.getStringExtra(EditProfileFragment.OPEN_CONFIG_ON_MAP)) {
case EditProfileFragment.MAP_CONFIG:
if (intent.hasExtra(BaseSettingsFragment.OPEN_CONFIG_ON_MAP)) {
switch (intent.getStringExtra(BaseSettingsFragment.OPEN_CONFIG_ON_MAP)) {
case BaseSettingsFragment.MAP_CONFIG:
this.getDashboard().setDashboardVisibility(true, DashboardType.CONFIGURE_MAP, null);
break;
case EditProfileFragment.SCREEN_CONFIG:
case BaseSettingsFragment.SCREEN_CONFIG:
this.getDashboard().setDashboardVisibility(true, DashboardType.CONFIGURE_SCREEN, null);
break;
}
@ -1520,6 +1512,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
mapLayers.updateLayers(mapView);
mapActions.updateDrawerMenu();
updateNavigationBarColor();
mapView.setComplexZoom(mapView.getZoom(), mapView.getSettingsMapDensity());
app.getDaynightHelper().startSensorIfNeeded(new StateChangedListener<Boolean>() {
@ -1532,6 +1525,16 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
applyScreenOrientation();
}
public void updateNavigationBarColor() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
if (getMyApplication().getDaynightHelper().isNightModeForMapControls() || getMyApplication().getDaynightHelper().isNightMode()) {
getWindow().setNavigationBarColor(ContextCompat.getColor(app, R.color.navigation_bar_bg_dark));
} else {
getWindow().setNavigationBarColor(ContextCompat.getColor(app, R.color.navigation_bar_bg_light));
}
}
}
public void updateMapSettings() {
if (app.isApplicationInitializing()) {
return;
@ -1655,7 +1658,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
}
return super.onKeyUp(keyCode, event);
}
private void scrollMap(int dx, int dy) {
final RotatedTileBox tb = mapView.getCurrentRotatedTileBox();
final QuadPoint cp = tb.getCenterPixelPoint();
@ -2009,7 +2012,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
}
if (requestCode == DataStorageFragment.PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE
&& grantResults.length > 0 && permissions.length > 0
&& permissions.length > 0
&& Manifest.permission.WRITE_EXTERNAL_STORAGE.equals(permissions[0])) {
if (grantResults[0] != PackageManager.PERMISSION_GRANTED) {
Toast.makeText(this,
@ -2017,12 +2020,12 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
Toast.LENGTH_LONG).show();
}
} else if (requestCode == DownloadActivity.PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE
&& grantResults.length > 0 && permissions.length > 0
&& permissions.length > 0
&& Manifest.permission.WRITE_EXTERNAL_STORAGE.equals(permissions[0])) {
permissionAsked = true;
permissionGranted = grantResults[0] == PackageManager.PERMISSION_GRANTED;
} else if (requestCode == FirstUsageWizardFragment.FIRST_USAGE_REQUEST_WRITE_EXTERNAL_STORAGE_PERMISSION
&& grantResults.length > 0 && permissions.length > 0
&& permissions.length > 0
&& Manifest.permission.WRITE_EXTERNAL_STORAGE.equals(permissions[0])) {
new Timer().schedule(new TimerTask() {
@ -2045,7 +2048,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
}
}, 1);
} else if (requestCode == MapActivityActions.REQUEST_LOCATION_FOR_DIRECTIONS_NAVIGATION_PERMISSION
&& grantResults.length > 0 && permissions.length > 0
&& permissions.length > 0
&& Manifest.permission.ACCESS_FINE_LOCATION.equals(permissions[0])) {
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
LatLon latLon = getContextMenu().getLatLon();
@ -2409,10 +2412,6 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
return getFragment(ChooseRouteFragment.TAG);
}
public EditProfileFragment getEditProfileFragment() {
return getFragment(EditProfileFragment.TAG);
}
public ProfileAppearanceFragment getProfileAppearanceFragment() {
return getFragment(ProfileAppearanceFragment.TAG);
}

View file

@ -673,7 +673,7 @@ public class MapActivityActions implements DialogProvider {
for (final ApplicationMode appMode : activeModes) {
if (appMode.isCustomProfile()) {
modeDescription = String.format(app.getString(R.string.profile_type_descr_string),
Algorithms.capitalizeFirstLetterAndLowercase(appMode.getParent().toHumanString(app)));
Algorithms.capitalizeFirstLetterAndLowercase(appMode.getParent().toHumanString()));
} else {
modeDescription = getString(R.string.profile_type_base_string);
}
@ -684,7 +684,7 @@ public class MapActivityActions implements DialogProvider {
.setIcon(appMode.getIconRes())
.setColor(appMode.getIconColorInfo().getColor(nightMode))
.setTag(tag)
.setTitle(appMode.toHumanString(app))
.setTitle(appMode.toHumanString())
.setDescription(modeDescription)
.setListener(new ItemClickListener() {
@Override
@ -994,7 +994,7 @@ public class MapActivityActions implements DialogProvider {
String modeDescription;
if (currentMode.isCustomProfile()) {
modeDescription = String.format(app.getString(R.string.profile_type_descr_string),
Algorithms.capitalizeFirstLetterAndLowercase(currentMode.getParent().toHumanString(app)));
Algorithms.capitalizeFirstLetterAndLowercase(currentMode.getParent().toHumanString()));
} else {
modeDescription = getString(R.string.profile_type_base_string);
}
@ -1004,7 +1004,7 @@ public class MapActivityActions implements DialogProvider {
.setIcon(currentMode.getIconRes())
.setSecondaryIcon(icArrowResId)
.setColor(currentMode.getIconColorInfo().getColor(nightMode))
.setTitle(currentMode.toHumanString(app))
.setTitle(currentMode.toHumanString())
.setDescription(modeDescription)
.setListener(new ItemClickListener() {
@Override

View file

@ -14,7 +14,6 @@ import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R;
import net.osmand.plus.Version;
import net.osmand.plus.liveupdates.OsmLiveActivity;
import net.osmand.plus.profiles.SettingsProfileActivity;
public class SettingsActivity extends SettingsBaseActivity {
@ -29,7 +28,6 @@ public class SettingsActivity extends SettingsBaseActivity {
private Preference general;
private Preference routing;
private Preference subscription;
private Preference profiles;
private Preference privacy;
@ -43,8 +41,6 @@ public class SettingsActivity extends SettingsBaseActivity {
general.setOnPreferenceClickListener(this);
routing = (Preference) screen.findPreference("routing_settings");
routing.setOnPreferenceClickListener(this);
profiles = (Preference) screen.findPreference("application_profiles");
profiles.setOnPreferenceClickListener(this);
subscription = (Preference) screen.findPreference("subscription_settings");
subscription.setOnPreferenceClickListener(this);
privacy = (Preference) screen.findPreference("privacy_and_security");
@ -95,9 +91,6 @@ public class SettingsActivity extends SettingsBaseActivity {
if (preference == general) {
startActivity(new Intent(this, SettingsGeneralActivity.class));
return true;
} else if (preference == profiles){
startActivity(new Intent(this, SettingsProfileActivity.class));
return true;
} else if (preference == routing) {
startActivity(new Intent(this, SettingsNavigationActivity.class));
return true;

View file

@ -386,7 +386,7 @@ public abstract class SettingsBaseActivity extends ActionBarPreferenceActivity
if (am != ApplicationMode.DEFAULT || !(this instanceof SettingsNavigationActivity)) {
activeModes.add(new ProfileDataObject(
am.toHumanString(getMyApplication()),
am.toHumanString(),
getAppModeDescription(am),
am.getStringKey(),
am.getIconRes(),
@ -429,7 +429,7 @@ public abstract class SettingsBaseActivity extends ActionBarPreferenceActivity
void updateModeButton(ApplicationMode mode) {
OsmandApplication app = getMyApplication();
boolean nightMode = !app.getSettings().isLightContent();
String title = mode.toHumanString(SettingsBaseActivity.this);
String title = mode.toHumanString();
getModeTitleTV().setText(title);
getModeSubTitleTV().setText(getAppModeDescription(mode));
@ -448,7 +448,7 @@ public abstract class SettingsBaseActivity extends ActionBarPreferenceActivity
descr = getString(R.string.profile_type_base_string);
} else {
descr = String.format(getString(R.string.profile_type_descr_string),
mode.getParent().toHumanString(getMyApplication()));
mode.getParent().toHumanString());
if (mode.getRoutingProfile() != null && mode.getRoutingProfile().contains("/")) {
descr = descr.concat(", " + mode.getRoutingProfile()
.substring(0, mode.getRoutingProfile().indexOf("/")));

View file

@ -1,7 +1,6 @@
package net.osmand.plus.activities;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
@ -91,7 +90,7 @@ public class SettingsGeneralActivity extends SettingsBaseActivity implements OnR
ApplicationMode[] appModes = ApplicationMode.values(app).toArray(new ApplicationMode[0]);
entries = new String[appModes.length];
for (int i = 0; i < entries.length; i++) {
entries[i] = appModes[i].toHumanString(app);
entries[i] = appModes[i].toHumanString();
}
registerListPreference(settings.DEFAULT_APPLICATION_MODE, screen, entries, appModes);
@ -545,7 +544,7 @@ public class SettingsGeneralActivity extends SettingsBaseActivity implements OnR
super.updateAllSettings();
updateApplicationDirTextAndSummary();
applicationModePreference.setTitle(getString(R.string.settings_preset) + " ["
+ settings.APPLICATION_MODE.get().toHumanString(getMyApplication()) + "]");
+ settings.APPLICATION_MODE.get().toHumanString() + "]");
drivingRegionPreference.setTitle(getString(R.string.driving_region) + " ["
+ getString(settings.DRIVING_REGION_AUTOMATIC.get() ? R.string.driving_region_automatic : settings.DRIVING_REGION.get().name) + "]");
}

View file

@ -755,8 +755,8 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
break;
}
float settingsMinSpeed = settings.MIN_SPEED.getModeValue(mode);
float settingsMaxSpeed = settings.MAX_SPEED.getModeValue(mode);
float settingsMinSpeed = mode.getMinSpeed();
float settingsMaxSpeed = mode.getMaxSpeed();
final int[] defaultValue = {Math.round(mode.getDefaultSpeed() * ratio[0])};
final int[] minValue = new int[1];
@ -783,10 +783,10 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
builder.setPositiveButton(R.string.shared_string_ok, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
mode.setDefaultSpeed(app, defaultValue[0] / ratio[0]);
mode.setDefaultSpeed(defaultValue[0] / ratio[0]);
if (!defaultSpeedOnly) {
settings.MIN_SPEED.setModeValue(mode, minValue[0] / ratio[0]);
settings.MAX_SPEED.setModeValue(mode, maxValue[0] / ratio[0]);
mode.setMinSpeed(minValue[0] / ratio[0]);
mode.setMaxSpeed(maxValue[0] / ratio[0]);
}
RoutingHelper routingHelper = app.getRoutingHelper();
if (mode.equals(routingHelper.getAppMode()) && (routingHelper.isRouteCalculated() || routingHelper.isRouteBeingCalculated())) {
@ -798,10 +798,10 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
builder.setNeutralButton(R.string.shared_string_revert, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
mode.resetDefaultSpeed(app);
mode.resetDefaultSpeed();
if (!defaultSpeedOnly) {
settings.MIN_SPEED.setModeValue(mode,0f);
settings.MAX_SPEED.setModeValue(mode,0f);
mode.setMinSpeed(0f);
mode.setMaxSpeed(0f);
}
RoutingHelper routingHelper = app.getRoutingHelper();
if (mode.equals(routingHelper.getAppMode()) && (routingHelper.isRouteCalculated() || routingHelper.isRouteBeingCalculated())) {

View file

@ -1,7 +1,6 @@
package net.osmand.plus.activities.actions;
import android.app.Activity;
import android.content.res.Configuration;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Build.VERSION_CODES;
@ -117,7 +116,7 @@ public class AppModeDialog {
ImageView iv = (ImageView) tb.findViewById(R.id.app_mode_icon);
if (checked) {
iv.setImageDrawable(ctx.getUIUtilities().getIcon(mode.getIconRes(), mode.getIconColorInfo().getColor(nightMode)));
iv.setContentDescription(String.format("%s %s", mode.toHumanString(ctx), ctx.getString(R.string.item_checked)));
iv.setContentDescription(String.format("%s %s", mode.toHumanString(), ctx.getString(R.string.item_checked)));
selection.setBackgroundResource(mode.getIconColorInfo().getColor(nightMode));
selection.setVisibility(View.VISIBLE);
} else {
@ -127,7 +126,7 @@ public class AppModeDialog {
} else {
iv.setImageDrawable(ctx.getUIUtilities().getThemedIcon(mode.getIconRes()));
}
iv.setContentDescription(String.format("%s %s", mode.toHumanString(ctx), ctx.getString(R.string.item_unchecked)));
iv.setContentDescription(String.format("%s %s", mode.toHumanString(), ctx.getString(R.string.item_unchecked)));
selection.setVisibility(View.INVISIBLE);
}
iv.setOnClickListener(new View.OnClickListener() {
@ -170,7 +169,7 @@ public class AppModeDialog {
Drawable drawable = ctx.getUIUtilities().getIcon(mode.getIconRes(), mode.getIconColorInfo().getColor(nightMode));
if (checked) {
iv.setImageDrawable(drawable);
iv.setContentDescription(String.format("%s %s", mode.toHumanString(ctx), ctx.getString(R.string.item_checked)));
iv.setContentDescription(String.format("%s %s", mode.toHumanString(), ctx.getString(R.string.item_checked)));
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
AndroidUtils.setBackground(ctx, iv, nightMode, R.drawable.btn_checked_border_light, R.drawable.btn_checked_border_light);
AndroidUtils.setBackground(ctx, selection, nightMode, R.drawable.ripple_light, R.drawable.ripple_light);
@ -193,7 +192,7 @@ public class AppModeDialog {
} else {
iv.setImageDrawable(ctx.getUIUtilities().getIcon(mode.getIconRes(), mode.getIconColorInfo().getColor(nightMode)));
}
iv.setContentDescription(String.format("%s %s", mode.toHumanString(ctx), ctx.getString(R.string.item_unchecked)));
iv.setContentDescription(String.format("%s %s", mode.toHumanString(), ctx.getString(R.string.item_unchecked)));
}
tb.setOnClickListener(new View.OnClickListener() {
@ -229,7 +228,7 @@ public class AppModeDialog {
View tb = layoutInflater.inflate(layoutId, null);
ImageView iv = (ImageView) tb.findViewById(R.id.app_mode_icon);
iv.setImageDrawable(ctx.getUIUtilities().getIcon(mode.getIconRes(), mode.getIconColorInfo().getColor(isNightMode(ctx, useMapTheme))));
iv.setContentDescription(mode.toHumanString(ctx));
iv.setContentDescription(mode.toHumanString());
// tb.setCompoundDrawablesWithIntrinsicBounds(null, ctx.getIconsCache().getIcon(mode.getIconId(), R.color.app_mode_icon_color), null, null);
LayoutParams lp = new LinearLayout.LayoutParams(metricsX, metricsY);
// lp.setMargins(left, 0, 0, 0);

View file

@ -475,6 +475,7 @@ public class MultimediaNotesFragment extends BaseSettingsFragment implements Cop
AudioVideoNotesPlugin plugin = OsmandPlugin.getPlugin(AudioVideoNotesPlugin.class);
if (plugin != null) {
app.getSettings().copyProfilePreferences(appMode, getSelectedAppMode(), plugin.getPreferences());
updateAllSettings();
}
}
@ -483,6 +484,8 @@ public class MultimediaNotesFragment extends BaseSettingsFragment implements Cop
AudioVideoNotesPlugin plugin = OsmandPlugin.getPlugin(AudioVideoNotesPlugin.class);
if (plugin != null) {
app.getSettings().resetProfilePreferences(appMode, plugin.getPreferences());
app.showToastMessage(R.string.plugin_prefs_reset_successful);
updateAllSettings();
}
}
}

View file

@ -198,7 +198,7 @@ public class PluginInstalledBottomSheetDialog extends MenuBottomSheetDialogFragm
appModeItem[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder()
.setChecked(ApplicationMode.values(app).contains(mode))
.setDescription(BaseSettingsFragment.getAppModeDescription(app, mode))
.setTitle(mode.toHumanString(app))
.setTitle(mode.toHumanString())
.setIcon(getActiveIcon(mode.getIconRes()))
.setLayoutId(R.layout.bottom_sheet_item_with_descr_and_switch_56dp)
.setOnClickListener(new View.OnClickListener() {

View file

@ -1280,8 +1280,10 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
final ImageView iconView = (ImageView) view.findViewById(R.id.context_menu_icon_view);
Drawable icon = menu.getRightIcon();
int iconId = menu.getRightIconId();
int sizeId = menu.isBigRightIcon() ? R.dimen.context_menu_big_icon_size : R.dimen.dialog_button_height;
int sizeId = menu.isBigRightIcon() ? R.dimen.context_menu_big_icon_size : R.dimen.map_widget_icon;
if (menu.getPointDescription().isFavorite() || menu.getPointDescription().isWpt()) {
sizeId = R.dimen.dialog_button_height;
}
int iconViewSize = getResources().getDimensionPixelSize(sizeId);
ViewGroup.LayoutParams params = iconView.getLayoutParams();
params.width = iconViewSize;

View file

@ -1,9 +1,11 @@
package net.osmand.plus.mapcontextmenu.other;
import android.Manifest;
import android.app.Activity;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
@ -156,7 +158,10 @@ public class FavouritesBottomSheetMenuFragment extends MenuBottomSheetDialogFrag
targetPointsHelper.setStartPoint(ll, true, point.getPointDescription(app));
break;
case TARGET:
targetPointsHelper.navigateToPoint(ll, true, -1, point.getPointDescription(app));
if (getActivity() != null) {
targetPointsHelper.navigateToPoint(ll, true, -1, point.getPointDescription(app));
OsmAndLocationProvider.requestFineLocationPermissionIfNeeded(getActivity());
}
break;
case INTERMEDIATE:
targetPointsHelper.navigateToPoint(ll, true, targetPointsHelper.getIntermediatePoints().size(), point.getPointDescription(app));

View file

@ -53,6 +53,12 @@ public class MultiSelectionArrayAdapter extends ArrayAdapter<MapMultiSelectionMe
UiUtilities iconsCache = menu.getMapActivity().getMyApplication().getUIUtilities();
final View iconLayout = convertView.findViewById(R.id.context_menu_icon_layout);
final ImageView iconView = (ImageView) convertView.findViewById(R.id.context_menu_icon_view);
if (item.getPointDescription().isFavorite() || item.getPointDescription().isWpt()) {
int iconSize = getContext().getResources().getDimensionPixelSize(R.dimen.dialog_button_height);
iconView.getLayoutParams().height = iconSize;
iconView.getLayoutParams().width = iconSize;
iconView.requestLayout();
}
Drawable icon = item.getRightIcon();
int iconId = item.getRightIconId();
if (icon != null) {

View file

@ -80,7 +80,7 @@ public class DirectionIndicationDialogFragment extends BaseOsmAndDialogFragment
TextView appModeTv = (TextView) mainView.findViewById(R.id.app_mode_text_view);
ApplicationMode appMode = settings.APPLICATION_MODE.get();
appModeTv.setText(appMode.toHumanString(getContext()));
appModeTv.setText(appMode.toHumanString());
appModeTv.setCompoundDrawablesWithIntrinsicBounds(null, null, getIconsCache().getIcon(
appMode.getIconRes()), null);

View file

@ -2,11 +2,8 @@ package net.osmand.plus.measurementtool;
import android.app.Dialog;
import android.content.DialogInterface;
import android.graphics.drawable.Drawable;
import android.support.annotation.DrawableRes;
import android.support.design.widget.BottomSheetBehavior;
import android.support.design.widget.BottomSheetDialog;
import android.support.v4.content.ContextCompat;
import android.view.ContextThemeWrapper;
import android.view.View;
import android.view.Window;
@ -19,7 +16,6 @@ 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.activities.MapActivity;
import net.osmand.plus.helpers.AndroidUiHelper;
@ -92,7 +88,7 @@ public class SnapToRoadBottomSheetDialogFragment extends android.support.design.
View row = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.list_item_icon_and_title, null);
((ImageView) row.findViewById(R.id.icon)).setImageDrawable(
app.getUIUtilities().getIcon(mode.getIconRes(), mode.getIconColorInfo().getColor(nightMode)));
((TextView) row.findViewById(R.id.title)).setText(mode.toHumanString(getContext()));
((TextView) row.findViewById(R.id.title)).setText(mode.toHumanString());
row.setOnClickListener(onClickListener);
row.setTag(i);
container.addView(row);

View file

@ -26,6 +26,8 @@ import net.osmand.plus.settings.preferences.SwitchPreferenceEx;
import net.osmand.plus.widgets.style.CustomTypefaceSpan;
import java.io.Serializable;
import java.util.HashMap;
import java.util.LinkedHashMap;
import static net.osmand.plus.OsmandSettings.DAILY_DIRECTORY;
import static net.osmand.plus.OsmandSettings.MONTHLY_DIRECTORY;
@ -38,12 +40,14 @@ public class MonitoringSettingsFragment extends BaseSettingsFragment implements
private static final String COPY_PLUGIN_SETTINGS = "copy_plugin_settings";
private static final String RESET_TO_DEFAULT = "reset_to_default";
private static final String OPEN_TRACKS = "open_tracks";
private static final String SAVE_GLOBAL_TRACK_INTERVAL = "save_global_track_interval";
@Override
protected void setupPreferences() {
setupSaveTrackToGpxPref();
setupSaveTrackIntervalPref();
setupSaveGlobalTrackIntervalPref();
setupSaveTrackMinDistancePref();
setupSaveTrackPrecisionPref();
setupSaveTrackMinSpeedPref();
@ -69,27 +73,37 @@ public class MonitoringSettingsFragment extends BaseSettingsFragment implements
}
private void setupSaveTrackIntervalPref() {
Integer[] entryValues = new Integer[SECONDS.length + MINUTES.length];
String[] entries = new String[entryValues.length];
int k = 0;
for (int second : SECONDS) {
entryValues[k] = second * 1000;
entries[k] = second + " " + getString(R.string.int_seconds);
k++;
}
for (int minute : MINUTES) {
entryValues[k] = (minute * 60) * 1000;
entries[k] = minute + " " + getString(R.string.int_min);
k++;
}
HashMap<Object, String> entry = getTimeValues(false);
ListPreferenceEx saveTrackInterval = (ListPreferenceEx) findPreference(settings.SAVE_TRACK_INTERVAL.getId());
saveTrackInterval.setEntries(entries);
saveTrackInterval.setEntryValues(entryValues);
saveTrackInterval.setEntries(entry.values().toArray(new String[0]));
saveTrackInterval.setEntryValues(entry.keySet().toArray());
saveTrackInterval.setIcon(getActiveIcon(R.drawable.ic_action_time_span));
saveTrackInterval.setDescription(R.string.save_track_interval_descr);
}
private void setupSaveGlobalTrackIntervalPref() {
HashMap<Object, String> entry = getTimeValues(true);
ListPreferenceEx saveTrackInterval = (ListPreferenceEx) findPreference(settings.SAVE_GLOBAL_TRACK_INTERVAL.getId());
saveTrackInterval.setEntries(entry.values().toArray(new String[0]));
saveTrackInterval.setEntryValues(entry.keySet().toArray());
saveTrackInterval.setIcon(getActiveIcon(R.drawable.ic_action_time_span));
saveTrackInterval.setDescription(R.string.save_global_track_interval_descr);
}
private HashMap<Object, String> getTimeValues(boolean alwaysAskEntry) {
HashMap<Object, String> entry = new LinkedHashMap<>();
if (alwaysAskEntry) {
entry.put(settings.SAVE_GLOBAL_TRACK_REMEMBER.getModeValue(getSelectedAppMode()), getString(R.string.confirm_every_run));
}
for (int second : SECONDS) {
entry.put(second * 1000, second + " " + getString(R.string.int_seconds));
}
for (int minute : MINUTES) {
entry.put((minute * 60) * 1000, minute + " " + getString(R.string.int_min));
}
return entry;
}
private void setupSaveTrackMinDistancePref() {
Float[] entryValues = new Float[] {0.f, 2.0f, 5.0f, 10.0f, 20.0f, 30.0f, 50.0f};
String[] entries = new String[entryValues.length];
@ -257,15 +271,20 @@ public class MonitoringSettingsFragment extends BaseSettingsFragment implements
String prefId = preference.getKey();
OsmandSettings.OsmandPreference pref = settings.getPreference(prefId);
if (pref instanceof OsmandSettings.CommonPreference && !((OsmandSettings.CommonPreference) pref).hasDefaultValueForMode(getSelectedAppMode())) {
FragmentManager fragmentManager = getFragmentManager();
if (fragmentManager != null && newValue instanceof Serializable) {
ChangeGeneralProfilesPrefBottomSheet.showInstance(fragmentManager, prefId,
(Serializable) newValue, this, false, getSelectedAppMode());
if (SAVE_GLOBAL_TRACK_INTERVAL.equals(prefId)) {
if (newValue instanceof Boolean) {
prefId = settings.SAVE_GLOBAL_TRACK_REMEMBER.getId();
newValue = Boolean.FALSE;
}
if (pref instanceof OsmandSettings.CommonPreference && !((OsmandSettings.CommonPreference) pref).hasDefaultValueForMode(getSelectedAppMode())) {
FragmentManager fragmentManager = getFragmentManager();
if (fragmentManager != null && newValue instanceof Serializable) {
ChangeGeneralProfilesPrefBottomSheet.showInstance(fragmentManager, prefId,
(Serializable) newValue, this, false, getSelectedAppMode());
}
return false;
}
return false;
}
return true;
}
@ -290,6 +309,7 @@ public class MonitoringSettingsFragment extends BaseSettingsFragment implements
OsmandMonitoringPlugin plugin = OsmandPlugin.getPlugin(OsmandMonitoringPlugin.class);
if (plugin != null) {
app.getSettings().copyProfilePreferences(appMode, getSelectedAppMode(), plugin.getPreferences());
updateAllSettings();
}
}
@ -298,6 +318,8 @@ public class MonitoringSettingsFragment extends BaseSettingsFragment implements
OsmandMonitoringPlugin plugin = OsmandPlugin.getPlugin(OsmandMonitoringPlugin.class);
if (plugin != null) {
app.getSettings().resetProfilePreferences(appMode, plugin.getPreferences());
app.showToastMessage(R.string.plugin_prefs_reset_successful);
updateAllSettings();
}
}
}

View file

@ -553,19 +553,18 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
ll.addView(sp);
if (choice != null) {
final AppCompatCheckBox cb = new AppCompatCheckBox(uiCtx);
cb.setText(R.string.shared_string_remember_my_choice);
cb.setText(R.string.confirm_every_run);
cb.setTextColor(textColorPrimary);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
LayoutParams.WRAP_CONTENT);
lp.setMargins(dp24, dp8, dp24, 0);
cb.setLayoutParams(lp);
cb.setPadding(dp8, 0, 0, 0);
cb.setChecked(!choice.value);
cb.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
choice.value = isChecked;
choice.value = !isChecked;
}
});
UiUtilities.setupCompoundButton(cb, nightMode, PROFILE_DEPENDENT);

View file

@ -40,10 +40,11 @@ import java.util.Map;
import static net.osmand.plus.OsmandSettings.DAILY_DIRECTORY;
import static net.osmand.plus.OsmandSettings.MONTHLY_DIRECTORY;
import static net.osmand.plus.OsmandSettings.REC_DIRECTORY;
import static net.osmand.plus.profiles.SettingsProfileFragment.PROFILE_STRING_KEY;
public class SettingsMonitoringActivity extends SettingsBaseActivity {
public static final String PROFILE_STRING_KEY = "string_key";
private CheckBoxPreference routeServiceEnabled;
private BroadcastReceiver broadcastReceiver;
@ -247,7 +248,7 @@ public class SettingsMonitoringActivity extends SettingsBaseActivity {
protected void showConfirmDialog(final String prefId, final Object newValue) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
String appModeName = selectedAppMode.toHumanString(this);
String appModeName = selectedAppMode.toHumanString();
String currentModeText = getString(R.string.apply_to_current_profile, appModeName);
int start = currentModeText.indexOf(appModeName);

View file

@ -103,7 +103,7 @@ public class ConfigureProfileMenuAdapter extends AbstractProfileMenuAdapter<Conf
holder.compoundButton.setVisibility(View.VISIBLE);
holder.menuIcon.setVisibility(View.VISIBLE);
final ApplicationMode item = (ApplicationMode) obj;
holder.title.setText(item.toHumanString(app));
holder.title.setText(item.toHumanString());
holder.descr.setText(BaseSettingsFragment.getAppModeDescription(app, item));
holder.initSwitcher = true;

View file

@ -1,72 +0,0 @@
package net.osmand.plus.profiles;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.view.MenuItemCompat;
import android.view.Menu;
import android.view.MenuItem;
import net.osmand.plus.R;
import net.osmand.plus.activities.OsmandActionBarActivity;
public class EditProfileActivity extends OsmandActionBarActivity {
public static final int DELETE_ID = 1010;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
getMyApplication().applyTheme(this);
super.onCreate(savedInstanceState);
setContentView(R.layout.single_fragment_layout);
if (savedInstanceState == null) {
EditProfileFragment editProfileFragment = new EditProfileFragment();
editProfileFragment.setArguments(getIntent().getExtras());
getSupportFragmentManager().beginTransaction().add(android.R.id.content,
editProfileFragment, EditProfileFragment.TAG).commit();
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
int activeButtonsAndLinksTextResId = getMyApplication().getSettings().isLightContent() ?
R.color.active_buttons_and_links_text_light : R.color.active_buttons_and_links_text_dark;
Drawable icDelete = getMyApplication().getUIUtilities().getIcon(R.drawable.ic_action_delete_dark, activeButtonsAndLinksTextResId);
MenuItem m = menu.add(0, DELETE_ID, 0, R.string.action_delete)
.setIcon(icDelete);
MenuItemCompat.setShowAsAction(m, MenuItem.SHOW_AS_ACTION_ALWAYS);
super.onCreateOptionsMenu(menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int itemId = item.getItemId();
switch (itemId) {
case android.R.id.home:
onBackPressed();
return true;
case DELETE_ID:
((EditProfileFragment) getSupportFragmentManager().findFragmentByTag(
EditProfileFragment.TAG)).onDeleteProfileClick();
return true;
}
return false;
}
@Override
public void onBackPressed() {
final EditProfileFragment epf = (EditProfileFragment) getSupportFragmentManager()
.findFragmentByTag(EditProfileFragment.TAG);
if (epf.onBackPressedAllowed()) {
super.onBackPressed();
} else {
epf.confirmCancelDialog(this);
}
}
}

View file

@ -1,968 +0,0 @@
package net.osmand.plus.profiles;
import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnDismissListener;
import android.content.Intent;
import android.graphics.Rect;
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.design.widget.AppBarLayout;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.view.ViewCompat;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AlertDialog.Builder;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.ContextThemeWrapper;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
import android.view.inputmethod.InputMethodManager;
import android.widget.AdapterView;
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.base.BaseOsmAndFragment;
import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment.SelectProfileListener;
import net.osmand.plus.routing.RouteProvider.RouteService;
import net.osmand.plus.settings.BaseSettingsFragment;
import net.osmand.plus.settings.BaseSettingsFragment.SettingsScreenType;
import net.osmand.plus.widgets.OsmandTextFieldBoxes;
import net.osmand.router.GeneralRouter;
import net.osmand.util.Algorithms;
import org.apache.commons.logging.Log;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import studio.carbonylgroup.textfieldboxes.ExtendedEditText;
import static net.osmand.aidlapi.OsmAndCustomizationConstants.DRAWER_SETTINGS_ID;
import static net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment.DIALOG_TYPE;
import static net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment.PROFILE_KEY_ARG;
import static net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment.SELECTED_KEY;
import static net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment.TYPE_BASE_APP_PROFILE;
import static net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment.TYPE_NAV_PROFILE;
import static net.osmand.plus.profiles.SettingsProfileFragment.IS_NEW_PROFILE;
import static net.osmand.plus.profiles.SettingsProfileFragment.IS_USER_PROFILE;
import static net.osmand.plus.profiles.SettingsProfileFragment.PROFILE_STRING_KEY;
public class EditProfileFragment extends BaseOsmAndFragment {
private static final Log LOG = PlatformUtil.getLog(EditProfileFragment.class);
public static final String TAG = EditProfileFragment.class.getSimpleName();
public static final String OPEN_CONFIG_PROFILE = "openConfigProfile";
public static final String OPEN_SETTINGS = "openSettings";
public static final String OPEN_CONFIG_ON_MAP = "openConfigOnMap";
public static final String MAP_CONFIG = "openMapConfigMenu";
public static final String NAV_CONFIG = "openNavConfigMenu";
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 dataChanged = false;
private boolean nightMode;
private SelectProfileListener navTypeListener = null;
private SelectProfileListener iconIdListener = null;
private SelectProfileListener baseTypeListener = null;
private TextView toolbarTitle;
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 profileConfigBtn;
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 FragmentActivity activity = getActivity();
int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
Context themedContext = new ContextThemeWrapper(getContext(), themeRes);
final View view = inflater.cloneInContext(themedContext).inflate(R.layout.fragment_selected_profile, container, false);
setupToolbar(view);
toolbarTitle = view.findViewById(R.id.toolbar_title);
profileIcon = view.findViewById(R.id.profile_icon_img);
profileIconBtn = view.findViewById(R.id.select_icon_button);
colorSample = view.findViewById(R.id.color_sample_img);
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.master_profile_et);
navTypeTextBox = view.findViewById(R.id.master_profile_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);
profileConfigBtn = view.findViewById(R.id.profile_config_btn);
buttonsLayout = view.findViewById(R.id.buttons_layout);
clickBlockLayout = view.findViewById(R.id.click_block_layout);
typeSelectionBtn = view.findViewById(R.id.type_selection_button);
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) {
dataChanged = true;
startIconId = profile.parent.getIconRes();
profile.iconId = startIconId;
profile.iconStringName = profile.parent.getIconName();
} else if (isUserProfile) {
title = profile.userProfileTitle;
profileNameEt.setText(title);
dataChanged = false;
} else if (profile.stringKeyName != -1) {
title = getResources().getString(profile.stringKeyName);
profileNameEt.setText(title);
clickBlockLayout.setClickable(true);
}
profile.userProfileTitle = 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(SELECTED_KEY, profile.parent.getStringKey());
}
bundle.putString(DIALOG_TYPE, 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();
updateToolbar(title);
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();
dataChanged = true;
updateToolbar(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(SELECTED_KEY,
profile.routingProfileDataObject.getStringKey());
}
bundle.putString(DIALOG_TYPE, 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(DIALOG_TYPE, 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) {
dataChanged = 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);
}
}
profileConfigBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (dataChanged) {
needSaveDialog();
} else if (getSettings() != null) {
if (activity instanceof EditProfileActivity) {
Intent i = new Intent(getActivity(), MapActivity.class);
i.putExtra(OPEN_SETTINGS, OPEN_CONFIG_PROFILE);
i.putExtra(SELECTED_ITEM, profile.stringKey);
startActivity(i);
} else {
BaseSettingsFragment.showInstance(activity, SettingsScreenType.CONFIGURE_PROFILE, ApplicationMode.valueOfStringKey(profile.stringKey, null));
}
}
}
});
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();
}
}
});
}
final float d = getResources().getDisplayMetrics().density;
view.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
int marginShow = 66;
int marginHide = 0;
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;
}
@Override
public void onResume() {
getBaseProfileListener();
getNavProfileListener();
getIconListener();
super.onResume();
}
@Override
public int getStatusBarColorId() {
return nightMode ? R.color.status_bar_color_dark : R.color.status_bar_color_light;
}
public boolean onBackPressedAllowed() {
return !dataChanged;
}
SelectProfileListener getIconListener() {
if (iconIdListener == null) {
iconIdListener = new SelectProfileListener() {
@Override
public void onSelectedType(Bundle bundle) {
int pos = -1;
dataChanged = true;
profile.iconId = pos;
profile.iconStringName = null;
profileIcon.setImageDrawable(app.getUIUtilities().getIcon(pos,
profile.iconColor.getColor(nightMode)));
}
};
}
return iconIdListener;
}
SelectProfileListener getBaseProfileListener() {
if (baseTypeListener == null) {
baseTypeListener = new SelectProfileListener() {
@Override
public void onSelectedType(Bundle args) {
String profileKey = args.getString(PROFILE_KEY_ARG);
setupBaseProfileView(profileKey);
profile.parent = ApplicationMode.valueOfStringKey(profileKey, ApplicationMode.DEFAULT);
dataChanged = true;
}
};
}
return baseTypeListener;
}
SelectProfileListener getNavProfileListener() {
if (navTypeListener == null) {
navTypeListener = new SelectProfileListener() {
@Override
public void onSelectedType(Bundle args) {
int pos = -1;
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) {
dataChanged = 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 setupToolbar(View view) {
FragmentActivity activity = getActivity();
AppBarLayout appBar = (AppBarLayout) view.findViewById(R.id.appbar);
if ((activity instanceof EditProfileActivity)) {
EditProfileActivity editProfileActivity = (EditProfileActivity) activity;
if (editProfileActivity.getSupportActionBar() != null) {
editProfileActivity.getSupportActionBar().setElevation(5.0f);
}
AndroidUiHelper.updateVisibility(appBar, false);
} else {
AndroidUtils.addStatusBarPadding21v(activity, view);
ViewCompat.setElevation(appBar, 5.0f);
View closeButton = view.findViewById(R.id.close_button);
closeButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
FragmentActivity fragmentActivity = getActivity();
if (fragmentActivity != null) {
fragmentActivity.onBackPressed();
}
}
});
View deleteBtn = view.findViewById(R.id.delete_button);
deleteBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onDeleteProfileClick();
}
});
}
}
private void updateToolbar(String title) {
FragmentActivity activity = getActivity();
if (activity instanceof EditProfileActivity) {
EditProfileActivity editProfileActivity = (EditProfileActivity) activity;
if (editProfileActivity.getSupportActionBar() != null) {
editProfileActivity.getSupportActionBar().setTitle(title);
}
} else {
toolbarTitle.setText(title);
}
}
private void setupBaseProfileView(String stringKey) {
for (ApplicationMode am : ApplicationMode.getDefaultValues()) {
if (am.getStringKey().equals(stringKey)) {
baseModeIcon.setImageDrawable(
app.getUIUtilities().getIcon(am.getIconRes(), R.color.icon_color_default_light));
baseModeTitle.setText(Algorithms.capitalizeFirstLetter(am.toHumanString(app)));
dataChanged = 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.saveProfile(builder, getMyApplication());
if (!ApplicationMode.values(app).contains(mode)) {
ApplicationMode.changeProfileAvailability(mode, true, getMyApplication());
}
dataChanged = false;
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) {
dataChanged = false;
activity.onBackPressed();
}
});
bld.setNegativeButton(R.string.shared_string_cancel, null);
bld.show();
}
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) {
OsmandApplication app = getMyApplication();
if (app != null) {
ApplicationMode.deleteCustomMode(mode, app);
app.getSettings().APPLICATION_MODE.set(ApplicationMode.DEFAULT);
}
if (getActivity() != null) {
getActivity().onBackPressed();
}
}
});
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);
}
}
}
public static boolean showInstance(FragmentManager fragmentManager, boolean newProfile, boolean userProfile, String profileKey) {
try {
Bundle args = new Bundle();
args.putBoolean(IS_NEW_PROFILE, newProfile);
args.putBoolean(IS_USER_PROFILE, userProfile);
args.putString(PROFILE_STRING_KEY, profileKey);
EditProfileFragment editProfileFragment = new EditProfileFragment();
editProfileFragment.setArguments(args);
fragmentManager.beginTransaction()
.replace(R.id.fragmentContainer, editProfileFragment, TAG)
.addToBackStack(DRAWER_SETTINGS_ID + ".new")
.commit();
return true;
} catch (Exception e) {
return false;
}
}
private 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;
}
private 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);
}
}
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;
}
}
}

View file

@ -23,7 +23,6 @@ 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.MapActivity;
@ -150,7 +149,6 @@ public class EditProfilesFragment extends BaseOsmAndFragment {
MapActivity mapActivity = (MapActivity) getActivity();
if (mapActivity != null) {
OsmandApplication app = mapActivity.getMyApplication();
OsmandSettings settings = app.getSettings();
if (!deletedModesKeys.isEmpty()) {
List<ApplicationMode> deletedModes = new ArrayList<>();
@ -161,9 +159,6 @@ public class EditProfilesFragment extends BaseOsmAndFragment {
}
}
ApplicationMode.deleteCustomModes(deletedModes, app);
if (deletedModes.contains(settings.APPLICATION_MODE.get())) {
settings.APPLICATION_MODE.resetToDefault();
}
}
for (ApplicationMode mode : ApplicationMode.allPossibleValues()) {
String modeKey = mode.getStringKey();
@ -174,7 +169,6 @@ public class EditProfilesFragment extends BaseOsmAndFragment {
mode.setOrder(order);
}
ApplicationMode.reorderAppModes();
ApplicationMode.saveAppModesToSettings(app);
mapActivity.onBackPressed();
}
}
@ -239,7 +233,7 @@ public class EditProfilesFragment extends BaseOsmAndFragment {
if (order == null) {
order = mode.getOrder();
}
profiles.add(new EditProfileDataObject(modeKey, mode.toHumanString(getContext()), BaseSettingsFragment.getAppModeDescription(getContext(), mode),
profiles.add(new EditProfileDataObject(modeKey, mode.toHumanString(), BaseSettingsFragment.getAppModeDescription(getContext(), mode),
mode.getIconRes(), false, mode.isCustomProfile(), deleted, mode.getIconColorInfo(), order));
}
}
@ -273,7 +267,7 @@ public class EditProfilesFragment extends BaseOsmAndFragment {
private boolean deleted;
private boolean customProfile;
EditProfileDataObject(String stringKey, String name, String descr, int iconRes, boolean isSelected, boolean customProfile, boolean deleted, ApplicationMode.ProfileIconColors iconColor, int order) {
EditProfileDataObject(String stringKey, String name, String descr, int iconRes, boolean isSelected, boolean customProfile, boolean deleted, ProfileIconColors iconColor, int order) {
super(name, descr, stringKey, iconRes, isSelected, iconColor);
this.customProfile = customProfile;
this.deleted = deleted;

View file

@ -0,0 +1,29 @@
package net.osmand.plus.profiles;
import android.support.annotation.DrawableRes;
import net.osmand.plus.R;
public enum LocationIcon {
DEFAULT(R.drawable.map_location_default, R.drawable.map_location_default_view_angle),
CAR(R.drawable.map_location_car, R.drawable.map_location_car_view_angle),
BICYCLE(R.drawable.map_location_bicycle, R.drawable.map_location_bicycle_view_angle);
LocationIcon(@DrawableRes int iconId, @DrawableRes int headingIconId) {
this.iconId = iconId;
this.headingIconId = headingIconId;
}
@DrawableRes
private final int iconId;
@DrawableRes
private final int headingIconId;
public int getIconId() {
return iconId;
}
public int getHeadingIconId() {
return headingIconId;
}
}

View file

@ -0,0 +1,22 @@
package net.osmand.plus.profiles;
import android.support.annotation.DrawableRes;
import net.osmand.plus.R;
public enum NavigationIcon {
DEFAULT(R.drawable.map_navigation_default),
NAUTICAL(R.drawable.map_navigation_nautical),
CAR(R.drawable.map_navigation_car);
NavigationIcon(@DrawableRes int iconId) {
this.iconId = iconId;
}
@DrawableRes
private final int iconId;
public int getIconId() {
return iconId;
}
}

View file

@ -1,7 +1,6 @@
package net.osmand.plus.profiles;
import android.support.annotation.ColorRes;
import net.osmand.plus.ApplicationMode.ProfileIconColors;
public class ProfileDataObject {

View file

@ -0,0 +1,37 @@
package net.osmand.plus.profiles;
import android.support.annotation.ColorRes;
import android.support.annotation.StringRes;
import net.osmand.plus.R;
public enum ProfileIconColors {
DEFAULT(R.string.rendering_value_default_name, R.color.profile_icon_color_blue_light_default, R.color.profile_icon_color_blue_dark_default),
PURPLE(R.string.rendering_value_purple_name, R.color.profile_icon_color_purple_light, R.color.profile_icon_color_purple_dark),
GREEN(R.string.rendering_value_green_name, R.color.profile_icon_color_green_light, R.color.profile_icon_color_green_dark),
BLUE(R.string.rendering_value_blue_name, R.color.profile_icon_color_blue_light, R.color.profile_icon_color_blue_dark),
RED(R.string.rendering_value_red_name, R.color.profile_icon_color_red_light, R.color.profile_icon_color_red_dark),
DARK_YELLOW(R.string.rendering_value_darkyellow_name, R.color.profile_icon_color_yellow_light, R.color.profile_icon_color_yellow_dark),
MAGENTA(R.string.shared_string_color_magenta, R.color.profile_icon_color_magenta_light, R.color.profile_icon_color_magenta_dark);
@StringRes
private int name;
@ColorRes
private int dayColor;
@ColorRes
private int nightColor;
ProfileIconColors(@StringRes int name, @ColorRes int dayColor, @ColorRes int nightColor) {
this.name = name;
this.dayColor = dayColor;
this.nightColor = nightColor;
}
public int getName() {
return name;
}
public int getColor(boolean nightMode) {
return nightMode ? nightColor : dayColor;
}
}

View file

@ -0,0 +1,80 @@
package net.osmand.plus.profiles;
import android.support.annotation.DrawableRes;
import android.support.annotation.NonNull;
import android.support.annotation.StringRes;
import net.osmand.plus.R;
import java.util.ArrayList;
public enum ProfileIcons {
DEFAULT(R.drawable.ic_world_globe_dark, R.string.app_mode_default, "ic_world_globe_dark"),
CAR(R.drawable.ic_action_car_dark, R.string.app_mode_car, "ic_action_car_dark"),
TAXI(R.drawable.ic_action_taxi, R.string.app_mode_taxi, "ic_action_taxi"),
TRUCK(R.drawable.ic_action_truck_dark, R.string.app_mode_truck, "ic_action_truck_dark"),
SHUTTLE_BUS(R.drawable.ic_action_shuttle_bus, R.string.app_mode_shuttle_bus, "ic_action_shuttle_bus"),
BUS(R.drawable.ic_action_bus_dark, R.string.app_mode_bus, "ic_action_bus_dark"),
SUBWAY(R.drawable.ic_action_subway, R.string.app_mode_subway, "ic_action_subway"),
MOTORCYCLE(R.drawable.ic_action_motorcycle_dark, R.string.app_mode_motorcycle, "ic_action_motorcycle_dark"),
BICYCLE(R.drawable.ic_action_bicycle_dark, R.string.app_mode_bicycle, "ic_action_bicycle_dark"),
HORSE(R.drawable.ic_action_horse, R.string.app_mode_horse, "ic_action_horse"),
PEDESTRIAN(R.drawable.ic_action_pedestrian_dark, R.string.app_mode_pedestrian, "ic_action_pedestrian_dark"),
TREKKING(R.drawable.ic_action_trekking_dark, R.string.app_mode_hiking, "ic_action_trekking_dark"),
SKIING(R.drawable.ic_action_skiing, R.string.app_mode_skiing, "ic_action_skiing"),
SAIL_BOAT(R.drawable.ic_action_sail_boat_dark, R.string.app_mode_boat, "ic_action_sail_boat_dark"),
AIRCRAFT(R.drawable.ic_action_aircraft, R.string.app_mode_aircraft, "ic_action_aircraft"),
HELICOPTER(R.drawable.ic_action_helicopter, R.string.app_mode_helicopter, "ic_action_helicopter"),
TRANSPORTER(R.drawable.ic_action_personal_transporter, R.string.app_mode_personal_transporter, "ic_action_personal_transporter"),
MONOWHEEL(R.drawable.ic_action_monowheel, R.string.app_mode_monowheel, "ic_action_monowheel"),
SCOOTER(R.drawable.ic_action_scooter, R.string.app_mode_scooter, "ic_action_scooter"),
UFO(R.drawable.ic_action_ufo, R.string.app_mode_ufo, "ic_action_ufo"),
OFFROAD(R.drawable.ic_action_offroad, R.string.app_mode_offroad, "ic_action_offroad"),
CAMPERVAN(R.drawable.ic_action_campervan, R.string.app_mode_campervan, "ic_action_campervan"),
CAMPER(R.drawable.ic_action_camper, R.string.app_mode_camper, "ic_action_camper"),
PICKUP_TRUCK(R.drawable.ic_action_pickup_truck, R.string.app_mode_pickup_truck, "ic_action_pickup_truck"),
WAGON(R.drawable.ic_action_wagon, R.string.app_mode_wagon, "ic_action_wagon"),
UTV(R.drawable.ic_action_utv, R.string.app_mode_utv, "ic_action_utv"),
OSM(R.drawable.ic_action_openstreetmap_logo, R.string.app_mode_osm, "ic_action_openstreetmap_logo");
@DrawableRes
private int resId;
@StringRes
private int titleId;
private String resStringId;
ProfileIcons(@DrawableRes int resId, @StringRes int titleId, @NonNull String resStringId) {
this.resId = resId;
this.titleId = titleId;
this.resStringId = resStringId;
}
public static ArrayList<Integer> getIcons() {
ArrayList<Integer> list = new ArrayList<>();
for (ProfileIcons pi : values()) {
list.add(pi.resId);
}
return list;
}
public int getResId() {
return resId;
}
public int getTitleId() {
return titleId;
}
public String getResStringId() {
return resStringId;
}
public static String getResStringByResId(int resId) {
for (ProfileIcons pi : values()) {
if (pi.resId == resId) {
return pi.resStringId;
}
}
return DEFAULT.getResStringId();
}
}

View file

@ -50,7 +50,7 @@ public class SelectCopyProfilesMenuAdapter extends AbstractProfileMenuAdapter<Se
ApplicationMode appMode = items.get(position);
boolean selected = appMode == selectedAppMode;
holder.title.setText(appMode.toHumanString(app));
holder.title.setText(appMode.toHumanString());
holder.compoundButton.setChecked(selected);
updateViewHolder(holder, appMode, selected);

View file

@ -71,7 +71,7 @@ public class SelectProfileBottomSheetDialogFragment extends MenuBottomSheetDialo
if (type.equals(TYPE_NAV_PROFILE)) {
profiles.addAll(NavigationFragment.getRoutingProfiles(app).values());
} else if (type.equals(TYPE_BASE_APP_PROFILE)) {
profiles.addAll(SettingsProfileFragment.getBaseProfiles(app));
profiles.addAll(NavigationFragment.getBaseProfiles(app));
} else {
LOG.error("Check intent data!");
dismiss();
@ -267,14 +267,11 @@ public class SelectProfileBottomSheetDialogFragment extends MenuBottomSheetDialo
FragmentActivity activity = getActivity();
if (activity != null) {
FragmentManager fragmentManager = activity.getSupportFragmentManager();
SettingsProfileFragment settingsProfileFragment = (SettingsProfileFragment) fragmentManager.findFragmentByTag(SettingsProfileFragment.class.getName());
NavigationFragment navigationFragment = (NavigationFragment) fragmentManager.findFragmentByTag(NavigationFragment.class.getName());
ProfileAppearanceFragment profileAppearanceFragment = (ProfileAppearanceFragment) fragmentManager.findFragmentByTag(ProfileAppearanceFragment.TAG);
MainSettingsFragment mainSettingsFragment = (MainSettingsFragment) fragmentManager.findFragmentByTag(MainSettingsFragment.TAG);
if (settingsProfileFragment != null) {
listener = settingsProfileFragment.getBaseProfileListener();
} else if (navigationFragment != null) {
if (navigationFragment != null) {
listener = navigationFragment.getNavProfileListener();
} else if (profileAppearanceFragment != null) {
listener = profileAppearanceFragment.getParentProfileListener();

View file

@ -97,7 +97,7 @@ public class SelectProfileMenuAdapter extends AbstractProfileMenuAdapter<SelectP
holder.compoundButton.setVisibility(View.GONE);
holder.menuIcon.setVisibility(View.GONE);
final ApplicationMode item = (ApplicationMode) obj;
holder.title.setText(item.toHumanString(app));
holder.title.setText(item.toHumanString());
holder.descr.setText(BaseSettingsFragment.getAppModeDescription(app, item));
int profileColorResId = item.getIconColorInfo().getColor(nightMode);

View file

@ -1,43 +0,0 @@
package net.osmand.plus.profiles;
import android.os.Bundle;
import android.view.MenuItem;
import net.osmand.plus.R;
import net.osmand.plus.activities.OsmandActionBarActivity;
public class SettingsProfileActivity extends OsmandActionBarActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
getMyApplication().applyTheme(this);
super.onCreate(savedInstanceState);
setContentView(R.layout.single_fragment_layout);
getSupportActionBar().setElevation(5.0f);
getSupportActionBar().setTitle(R.string.application_profiles);
if (savedInstanceState == null) {
SettingsProfileFragment profileFragment = new SettingsProfileFragment();
profileFragment.setArguments(getIntent().getExtras());
getSupportFragmentManager().beginTransaction()
.add(android.R.id.content, profileFragment, SettingsProfileFragment.class.getName()).commit();
}
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int itemId = item.getItemId();
switch (itemId) {
case android.R.id.home:
finish();
return true;
}
return false;
}
@Override
protected void onResume() {
super.onResume();
}
}

View file

@ -1,213 +0,0 @@
package net.osmand.plus.profiles;
import static net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment.DIALOG_TYPE;
import static net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment.PROFILE_KEY_ARG;
import static net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment.TYPE_BASE_APP_PROFILE;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.AppBarLayout;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.view.ViewCompat;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import net.osmand.AndroidUtils;
import net.osmand.PlatformUtil;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.BaseOsmAndFragment;
import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment.SelectProfileListener;
import org.apache.commons.logging.Log;
public class SettingsProfileFragment extends BaseOsmAndFragment
implements ConfigureProfileMenuAdapter.ProfileSelectedListener, AbstractProfileMenuAdapter.ProfilePressedListener{
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 ConfigureProfileMenuAdapter adapter;
private SelectProfileListener typeListener = null;
private List<ApplicationMode> allAppModes;
private Set<ApplicationMode> availableAppModes;
private List<ProfileDataObject> baseProfiles;
private boolean nightMode;
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
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) {
nightMode = !requireSettings().isLightContent();
int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
Context themedContext = new ContextThemeWrapper(getContext(), themeRes);
View view = inflater.cloneInContext(themedContext).inflate(R.layout.profiles_list_fragment, container, false);
AppBarLayout appBar = (AppBarLayout) view.findViewById(R.id.appbar);
if (!(getActivity() instanceof SettingsProfileActivity)) {
AndroidUtils.addStatusBarPadding21v(getContext(), view);
ViewCompat.setElevation(appBar, 5.0f);
TextView toolbarTitle = (TextView) view.findViewById(R.id.toolbar_title);
toolbarTitle.setText(R.string.application_profiles);
View closeButton = view.findViewById(R.id.close_button);
closeButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
MapActivity mapActivity = (MapActivity) getActivity();
if (mapActivity != null) {
mapActivity.onBackPressed();
}
}
});
} else {
AndroidUiHelper.updateVisibility(appBar, false);
}
RecyclerView recyclerView = view.findViewById(R.id.profiles_list);
LinearLayout addNewProfileBtn = view.findViewById(R.id.add_profile_btn);
addNewProfileBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
final SelectProfileBottomSheetDialogFragment dialog = new SelectProfileBottomSheetDialogFragment();
Bundle bundle = new Bundle();
bundle.putString(DIALOG_TYPE, TYPE_BASE_APP_PROFILE);
dialog.setArguments(bundle);
if (getActivity() != null) {
getActivity().getSupportFragmentManager().beginTransaction()
.add(dialog, "select_base_type").commitAllowingStateLoss();
}
}
});
adapter = new ConfigureProfileMenuAdapter(allAppModes, availableAppModes, getMyApplication(), null, !getMyApplication().getSettings().isLightContent());
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
recyclerView.setAdapter(adapter);
return view;
}
@Override
public void onResume() {
super.onResume();
adapter.setProfilePressedListener(this);
adapter.setProfileSelectedListener(this);
getBaseProfileListener();
allAppModes = new ArrayList<>(ApplicationMode.allPossibleValues());
allAppModes.remove(ApplicationMode.DEFAULT);
adapter.updateItemsList(allAppModes, new LinkedHashSet<>(ApplicationMode.values(getMyApplication())));
}
@Override
public int getStatusBarColorId() {
return nightMode ? R.color.status_bar_color_dark : R.color.status_bar_color_light;
}
SelectProfileListener getBaseProfileListener() {
if (typeListener == null) {
typeListener = new SelectProfileListener() {
@Override
public void onSelectedType(Bundle args) {
FragmentActivity activity = getActivity();
String profileKey = args.getString(PROFILE_KEY_ARG);
if (activity != null) {
if (activity instanceof SettingsProfileActivity) {
Intent intent = new Intent(getActivity(), EditProfileActivity.class);
intent.putExtra(IS_NEW_PROFILE, true);
intent.putExtra(IS_USER_PROFILE, true);
intent.putExtra(PROFILE_STRING_KEY, profileKey);
activity.startActivity(intent);
} else {
FragmentManager fragmentManager = activity.getSupportFragmentManager();
if (fragmentManager != null) {
EditProfileFragment.showInstance(fragmentManager, true, true, profileKey);
}
}
}
}
};
}
return typeListener;
}
public 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;
}
@Override
public void onProfilePressed(ApplicationMode item) {
FragmentActivity activity = getActivity();
if (activity != null) {
if (activity instanceof SettingsProfileActivity) {
Intent intent = new Intent(getActivity(), EditProfileActivity.class);
intent.putExtra(PROFILE_STRING_KEY, item.getStringKey());
intent.putExtra(IS_USER_PROFILE, item.isCustomProfile());
activity.startActivity(intent);
} else {
FragmentManager fragmentManager = activity.getSupportFragmentManager();
if (fragmentManager != null) {
String profileKey = item.getStringKey();
EditProfileFragment.showInstance(fragmentManager, false, item.isCustomProfile(), profileKey);
}
}
}
}
@Override
public void onProfileSelected(ApplicationMode item, boolean isChecked) {
if (isChecked) {
availableAppModes.add(item);
} else {
availableAppModes.remove(item);
}
ApplicationMode.changeProfileAvailability(item, isChecked, getMyApplication());
}
}

View file

@ -1,219 +0,0 @@
package net.osmand.plus.rastermaps;
import android.os.Bundle;
import android.preference.CheckBoxPreference;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceChangeListener;
import android.preference.PreferenceCategory;
import android.preference.PreferenceScreen;
import net.osmand.ResultMatcher;
import net.osmand.map.TileSourceManager.TileSourceTemplate;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.SettingsBaseActivity;
import net.osmand.plus.views.SeekBarPreference;
import java.util.Map;
public class SettingsRasterMapsActivity extends SettingsBaseActivity {
private ListPreference tileSourcePreference;
private ListPreference overlayPreference;
private ListPreference underlayPreference;
public static final String MORE_VALUE = "MORE_VALUE";
public static final String DEFINE_EDIT = "DEFINE_EDIT";
@Override
public void onCreate(Bundle savedInstanceState) {
((OsmandApplication) getApplication()).applyTheme(this);
super.onCreate(savedInstanceState);
getToolbar().setTitle(R.string.shared_string_online_maps);
PreferenceScreen grp = getPreferenceScreen();
OnPreferenceChangeListener listener = createPreferenceListener();
PreferenceCategory cat = new PreferenceCategory(this);
cat.setTitle(R.string.pref_raster_map);
grp.addPreference(cat);
// present on configure map
// addTileSourcePrefs(listener, cat);
// int startZoom = 1;
// int endZoom = 18;
// String[] entries = new String[endZoom - startZoom + 1];
// Integer[] intValues = new Integer[endZoom - startZoom + 1];
// for (int i = startZoom; i <= endZoom; i++) {
// entries[i - startZoom] = i + ""; //$NON-NLS-1$
// intValues[i - startZoom] = i ;
// }
// ListPreference lp = createListPreference(settings.LEVEL_TO_SWITCH_VECTOR_RASTER,
// entries, intValues, R.string.level_to_switch_vector_raster, R.string.level_to_switch_vector_raster_descr);
// cat.addPreference(lp);
// present on configure map
// addOverlayPrefs(grp, listener);
}
@SuppressWarnings("unused")
private void addOverlayPrefs(PreferenceScreen grp, OnPreferenceChangeListener listener) {
PreferenceCategory cat;
cat = new PreferenceCategory(this);
cat.setTitle(R.string.pref_overlay);
grp.addPreference(cat);
overlayPreference = new ListPreference(this);
overlayPreference.setSummary(R.string.map_overlay_descr);
overlayPreference.setTitle(R.string.map_overlay);
overlayPreference.setOnPreferenceChangeListener(listener);
cat.addPreference(overlayPreference);
underlayPreference = new ListPreference(this);
underlayPreference.setSummary(R.string.map_underlay_descr);
underlayPreference.setTitle(R.string.map_underlay);
underlayPreference.setOnPreferenceChangeListener(listener);
cat.addPreference(underlayPreference);
SeekBarPreference sp = createSeekBarPreference(settings.MAP_OVERLAY_TRANSPARENCY, R.string.overlay_transparency, R.string.overlay_transparency_descr,
R.string.modify_transparency, 0, 255);
cat.addPreference(sp);
sp = createSeekBarPreference(settings.MAP_TRANSPARENCY, R.string.map_transparency, R.string.map_transparency_descr,
R.string.modify_transparency, 0, 255);
cat.addPreference(sp);
}
@SuppressWarnings("unused")
private void addTileSourcePrefs(OnPreferenceChangeListener listener, PreferenceCategory cat) {
CheckBoxPreference mapVectorData = createCheckBoxPreference(settings.MAP_ONLINE_DATA,
R.string.map_online_data, R.string.map_online_data_descr);
cat.addPreference(mapVectorData);
tileSourcePreference = new ListPreference(this);
tileSourcePreference.setSummary(R.string.map_tile_source_descr);
tileSourcePreference.setTitle(R.string.map_tile_source);
tileSourcePreference.setOnPreferenceChangeListener(listener);
cat.addPreference(tileSourcePreference);
}
public void updateAllSettings() {
super.updateAllSettings();
updateTileSourceSummary();
}
private void updateTileSourceSummary() {
if (tileSourcePreference != null) {
fillTileSourcesToPreference(tileSourcePreference, settings.MAP_TILE_SOURCES.get(), false);
fillTileSourcesToPreference(overlayPreference, settings.MAP_OVERLAY.get(), true);
fillTileSourcesToPreference(underlayPreference, settings.MAP_UNDERLAY.get(), true);
// String mapName = " " + osmandSettings.MAP_TILE_SOURCES.get(); //$NON-NLS-1$
// String summary = tileSourcePreference.getSummary().toString();
// if (summary.lastIndexOf(':') != -1) {
// summary = summary.substring(0, summary.lastIndexOf(':') + 1);
// }
// tileSourcePreference.setSummary(summary + mapName);
;
tileSourcePreference.setSummary(format(R.string.map_tile_source_descr, settings.MAP_TILE_SOURCES.get()));
overlayPreference.setSummary(format(R.string.map_overlay_descr, settings.MAP_OVERLAY.get()) );
underlayPreference.setSummary(format(R.string.map_underlay_descr, settings.MAP_UNDERLAY.get()) );
}
}
private String format(int r, String string) {
return getString(r) + " [" + (string == null ? "" : string) + "]";
}
private void fillTileSourcesToPreference(ListPreference tileSourcePreference, String value, boolean addNone) {
Map<String, String> entriesMap = settings.getTileSourceEntries();
int add = addNone ? 1 : 0;
String[] entries = new String[entriesMap.size() + 2 + add];
String[] values = new String[entriesMap.size() + 2 + add];
int ki = 0;
if (addNone) {
entries[ki] = getString(R.string.shared_string_none);
values[ki] = "";
ki++;
}
if (value == null) {
value = "";
}
for (Map.Entry<String, String> es : entriesMap.entrySet()) {
entries[ki] = es.getValue();
values[ki] = es.getKey();
ki++;
}
entries[ki] = getMyApplication().getString(R.string.install_more);
values[ki] = MORE_VALUE;
ki++;
entries[ki] = getMyApplication().getString(R.string.maps_define_edit);
values[ki] = DEFINE_EDIT;
fill(tileSourcePreference, entries, values, value);
}
private void fill(ListPreference component, String[] list, String[] values, String selected) {
component.setEntries(list);
component.setEntryValues(values);
component.setValue(selected);
}
private OnPreferenceChangeListener createPreferenceListener() {
return new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
if (preference == tileSourcePreference || preference == overlayPreference
|| preference == underlayPreference) {
if(MORE_VALUE.equals(newValue)){
OsmandRasterMapsPlugin.installMapLayers(SettingsRasterMapsActivity.this, new ResultMatcher<TileSourceTemplate>() {
@Override
public boolean isCancelled() { return false;}
@Override
public boolean publish(TileSourceTemplate object) {
if(object == null){
updateTileSourceSummary();
}
return true;
}
});
} else if(DEFINE_EDIT.equals(newValue)){
OsmandRasterMapsPlugin.defineNewEditLayer(SettingsRasterMapsActivity.this, new ResultMatcher<TileSourceTemplate>() {
@Override
public boolean isCancelled() { return false;}
@Override
public boolean publish(TileSourceTemplate object) {
updateTileSourceSummary();
return true;
}
});
} else if(preference == tileSourcePreference){
settings.MAP_TILE_SOURCES.set((String) newValue);
updateTileSourceSummary();
} else {
if(((String) newValue).length() == 0){
newValue = null;
}
if(preference == underlayPreference){
settings.MAP_UNDERLAY.set(((String) newValue));
underlayPreference.setSummary(getString(R.string.map_underlay_descr) + " [" + settings.MAP_UNDERLAY.get() + "]");
} else if(preference == overlayPreference){
settings.MAP_OVERLAY.set(((String) newValue));
overlayPreference.setSummary(getString(R.string.map_overlay_descr) + " [" + settings.MAP_OVERLAY.get() + "]");
}
}
}
return true;
}
};
}
}

View file

@ -428,7 +428,7 @@ public class AddPointBottomSheetDialog extends MenuBottomSheetDialogFragment {
menu.selectMapMarker((MapMarker) item, pointType);
dismiss();
} else {
TargetPointsHelper helper = mapActivity.getMyApplication().getTargetPointsHelper();
TargetPointsHelper targetPointsHelper = mapActivity.getMyApplication().getTargetPointsHelper();
Pair<LatLon, PointDescription> pair = getLocationAndDescrFromItem(item);
LatLon ll = pair.first;
PointDescription name = pair.second;
@ -442,13 +442,14 @@ public class AddPointBottomSheetDialog extends MenuBottomSheetDialogFragment {
FavouritesDbHelper favorites = requiredMyApplication().getFavorites();
switch (pointType) {
case START:
helper.setStartPoint(ll, true, name);
targetPointsHelper.setStartPoint(ll, true, name);
break;
case TARGET:
helper.navigateToPoint(ll, true, -1, name);
targetPointsHelper.navigateToPoint(ll, true, -1, name);
OsmAndLocationProvider.requestFineLocationPermissionIfNeeded(mapActivity);
break;
case INTERMEDIATE:
helper.navigateToPoint(ll, true, helper.getIntermediatePoints().size(), name);
targetPointsHelper.navigateToPoint(ll, true, targetPointsHelper.getIntermediatePoints().size(), name);
break;
case HOME:
favorites.setSpecialPoint(ll, FavouritePoint.SpecialPointType.HOME, null);

View file

@ -258,29 +258,10 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
public boolean onSingleTap(PointF point, RotatedTileBox tileBox) {
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
OsmandApplication app = mapActivity.getMyApplication();
if (selectFromMapTouch) {
LatLon latlon = tileBox.getLatLonFromPixel(point.x, point.y);
selectFromMapTouch = false;
TargetPointsHelper targets = app.getTargetPointsHelper();
FavouritesDbHelper favorites = app.getFavorites();
switch (selectFromMapPointType) {
case START:
targets.setStartPoint(latlon, true, null);
break;
case TARGET:
targets.navigateToPoint(latlon, true, -1);
break;
case INTERMEDIATE:
targets.navigateToPoint(latlon, true, targets.getIntermediatePoints().size());
break;
case HOME:
favorites.setSpecialPoint(latlon, FavouritePoint.SpecialPointType.HOME, null);
break;
case WORK:
favorites.setSpecialPoint(latlon, FavouritePoint.SpecialPointType.WORK, null);
break;
}
LatLon latLon = tileBox.getLatLonFromPixel(point.x, point.y);
choosePointTypeAction(mapActivity, latLon, selectFromMapPointType, null, null);
if (selectFromMapWaypoints) {
WaypointsFragment.showInstance(mapActivity.getSupportFragmentManager(), true);
} else {
@ -292,6 +273,30 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
return false;
}
private void choosePointTypeAction(MapActivity mapActivity, LatLon latLon, PointType pointType, PointDescription pd, String address) {
OsmandApplication app = getApp();
FavouritesDbHelper favorites = app.getFavorites();
TargetPointsHelper targetPointsHelper = app.getTargetPointsHelper();
switch (pointType) {
case START:
targetPointsHelper.setStartPoint(latLon, true, pd);
break;
case TARGET:
targetPointsHelper.navigateToPoint(latLon, true, -1, pd);
OsmAndLocationProvider.requestFineLocationPermissionIfNeeded(mapActivity);
break;
case INTERMEDIATE:
targetPointsHelper.navigateToPoint(latLon, true, targetPointsHelper.getIntermediatePoints().size(), pd);
break;
case HOME:
favorites.setSpecialPoint(latLon, FavouritePoint.SpecialPointType.HOME, address);
break;
case WORK:
favorites.setSpecialPoint(latLon, FavouritePoint.SpecialPointType.WORK, address);
break;
}
}
public OnMarkerSelectListener getOnMarkerSelectListener() {
return onMarkerSelectListener;
}
@ -1785,29 +1790,11 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
hide();
}
public void selectAddress(@Nullable String name, @NonNull LatLon l, PointType pointType) {
public void selectAddress(@Nullable String name, @NonNull LatLon latLon, PointType pointType) {
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
PointDescription pd = new PointDescription(PointDescription.POINT_TYPE_ADDRESS, name);
FavouritesDbHelper favorites = mapActivity.getMyApplication().getFavorites();
TargetPointsHelper targets = mapActivity.getMyApplication().getTargetPointsHelper();
switch (pointType) {
case START:
targets.setStartPoint(l, true, pd);
break;
case TARGET:
targets.navigateToPoint(l, true, -1, pd);
break;
case INTERMEDIATE:
targets.navigateToPoint(l, true, targets.getIntermediatePoints().size(), pd);
break;
case HOME:
favorites.setSpecialPoint(l, FavouritePoint.SpecialPointType.HOME, name);
break;
case WORK:
favorites.setSpecialPoint(l, FavouritePoint.SpecialPointType.WORK, name);
break;
}
choosePointTypeAction(mapActivity, latLon, pointType, pd, name);
updateMenu();
}
}
@ -1844,30 +1831,13 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
}
}
public void selectMapMarker(@Nullable final MapMarker m, @NonNull final PointType pointType) {
public void selectMapMarker(@Nullable final MapMarker marker, @NonNull final PointType pointType) {
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
if (m != null) {
LatLon point = new LatLon(m.getLatitude(), m.getLongitude());
FavouritesDbHelper favorites = mapActivity.getMyApplication().getFavorites();
TargetPointsHelper targets = mapActivity.getMyApplication().getTargetPointsHelper();
switch (pointType) {
case START:
targets.setStartPoint(point, true, m.getPointDescription(mapActivity));
break;
case TARGET:
targets.navigateToPoint(point, true, -1, m.getPointDescription(mapActivity));
break;
case INTERMEDIATE:
targets.navigateToPoint(point, true, targets.getIntermediatePoints().size(), m.getPointDescription(mapActivity));
break;
case HOME:
favorites.setSpecialPoint(point, FavouritePoint.SpecialPointType.HOME, null);
break;
case WORK:
favorites.setSpecialPoint(point, FavouritePoint.SpecialPointType.WORK, null);
break;
}
if (marker != null) {
LatLon latLon = new LatLon(marker.getLatitude(), marker.getLongitude());
PointDescription pd = marker.getPointDescription(mapActivity);
choosePointTypeAction(mapActivity, latLon, pointType, pd, null);
updateMenu();
} else {
MapMarkerSelectionFragment selectionFragment = MapMarkerSelectionFragment.newInstance(pointType);

View file

@ -1,13 +1,15 @@
package net.osmand.plus.routepreparationmenu.cards;
import android.Manifest;
import android.support.v4.app.ActivityCompat;
import android.view.View;
import android.widget.TextView;
import net.osmand.data.FavouritePoint;
import net.osmand.data.LatLon;
import net.osmand.plus.FavouritesDbHelper;
import net.osmand.plus.OsmAndLocationProvider;
import net.osmand.plus.R;
import net.osmand.plus.TargetPointsHelper;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.routepreparationmenu.AddPointBottomSheetDialog;
import net.osmand.plus.routepreparationmenu.MapRouteInfoMenu.PointType;
@ -25,54 +27,48 @@ public class HomeWorkCard extends BaseCard {
@Override
protected void updateContent() {
final TargetPointsHelper targetPointsHelper = mapActivity.getMyApplication().getTargetPointsHelper();
final FavouritesDbHelper favorites = getMyApplication().getFavorites();
final FavouritePoint homePoint = favorites.getSpecialPoint(FavouritePoint.SpecialPointType.HOME);
final FavouritePoint workPoint = favorites.getSpecialPoint(FavouritePoint.SpecialPointType.WORK);
TextView homeDescr = view.findViewById(R.id.home_button_descr);
final TextView homeDescr = view.findViewById(R.id.home_button_descr);
final TextView workDescr = view.findViewById(R.id.work_button_descr);
homeDescr.setText(homePoint != null ? homePoint.getAddress() : mapActivity.getString(R.string.shared_string_add));
workDescr.setText(workPoint != null ? workPoint.getAddress() : mapActivity.getString(R.string.shared_string_add));
setSpecialButtonOnClickListeners(homePoint, R.id.home_button, PointType.HOME);
setSpecialButtonOnClickListeners(workPoint, R.id.work_button, PointType.WORK);
}
View homeButton = view.findViewById(R.id.home_button);
homeButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (homePoint == null) {
AddPointBottomSheetDialog.showInstance(mapActivity, PointType.HOME);
} else {
targetPointsHelper.navigateToPoint(new LatLon(homePoint.getLatitude(), homePoint.getLongitude()),
true, -1, homePoint.getPointDescription(mapActivity));
}
}
});
private void setSpecialButtonOnClickListeners(FavouritePoint point, int buttonId, final PointType pointType) {
View homeButton = view.findViewById(buttonId);
homeButton.setOnClickListener(new SpecialButtonOnClickListener(point, pointType));
homeButton.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
AddPointBottomSheetDialog.showInstance(mapActivity, PointType.HOME);
return true;
}
});
View workButton = view.findViewById(R.id.work_button);
workButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (workPoint == null) {
AddPointBottomSheetDialog.showInstance(mapActivity, PointType.WORK);
} else {
targetPointsHelper.navigateToPoint(new LatLon(workPoint.getLatitude(), workPoint.getLongitude()),
true, -1, workPoint.getPointDescription(mapActivity));
}
}
});
workButton.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
AddPointBottomSheetDialog.showInstance(mapActivity, PointType.WORK);
AddPointBottomSheetDialog.showInstance(mapActivity, pointType);
return true;
}
});
}
class SpecialButtonOnClickListener implements View.OnClickListener {
FavouritePoint point;
PointType pointType;
SpecialButtonOnClickListener(FavouritePoint point, PointType pointType) {
this.point = point;
this.pointType = pointType;
}
@Override
public void onClick(View v) {
if (point == null) {
AddPointBottomSheetDialog.showInstance(mapActivity, pointType);
} else {
mapActivity.getMyApplication().getTargetPointsHelper().navigateToPoint(
new LatLon(point.getLatitude(), point.getLongitude()),
true, -1, point.getPointDescription(app));
OsmAndLocationProvider.requestFineLocationPermissionIfNeeded(mapActivity);
}
}
}
}

View file

@ -704,11 +704,11 @@ public class RouteProvider {
if (defaultSpeed > 0) {
paramsR.put(GeneralRouter.DEFAULT_SPEED, String.valueOf(defaultSpeed));
}
Float minSpeed = settings.MIN_SPEED.getModeValue(params.mode);
Float minSpeed = params.mode.getMinSpeed();
if (minSpeed > 0) {
paramsR.put(GeneralRouter.MIN_SPEED, String.valueOf(minSpeed));
}
Float maxSpeed = settings.MAX_SPEED.getModeValue(params.mode);
Float maxSpeed = params.mode.getMaxSpeed();
if (maxSpeed > 0) {
paramsR.put(GeneralRouter.MAX_SPEED, String.valueOf(maxSpeed));
}
@ -790,7 +790,7 @@ public class RouteProvider {
}
private RouteCalculationResult applicationModeNotSupported(RouteCalculationParams params) {
return new RouteCalculationResult("Application mode '"+ params.mode.toHumanString(params.ctx)+ "' is not supported.");
return new RouteCalculationResult("Application mode '"+ params.mode.toHumanString()+ "' is not supported.");
}
private RouteCalculationResult interrupted() {

View file

@ -72,7 +72,13 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
OnPreferenceClickListener, AppModeChangedListener {
private static final Log LOG = PlatformUtil.getLog(BaseSettingsFragment.class);
private static final String APP_MODE_KEY = "app_mode_key";
public static final String APP_MODE_KEY = "app_mode_key";
public static final String OPEN_CONFIG_PROFILE = "openConfigProfile";
public static final String OPEN_SETTINGS = "openSettings";
public static final String OPEN_CONFIG_ON_MAP = "openConfigOnMap";
public static final String MAP_CONFIG = "openMapConfigMenu";
public static final String SCREEN_CONFIG = "screenConfig";
protected OsmandApplication app;
protected OsmandSettings settings;
@ -274,6 +280,7 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
Activity activity = getActivity();
if (activity instanceof MapActivity) {
((MapActivity) activity).updateStatusBarColor();
((MapActivity) activity).updateNavigationBarColor();
}
}
}
@ -441,7 +448,7 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
}
TextView profileTitle = (TextView) view.findViewById(R.id.profile_title);
if (profileTitle != null) {
String appName = selectedAppMode.toHumanString(app);
String appName = selectedAppMode.toHumanString();
profileTitle.setText(appName);
}
View toolbarDivider = view.findViewById(R.id.toolbar_divider);
@ -739,7 +746,7 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
String description;
if (mode.isCustomProfile()) {
description = String.format(ctx.getString(R.string.profile_type_descr_string),
Algorithms.capitalizeFirstLetterAndLowercase(mode.getParent().toHumanString(ctx)));
Algorithms.capitalizeFirstLetterAndLowercase(mode.getParent().toHumanString()));
} else {
description = ctx.getString(R.string.profile_type_base_string);
}

View file

@ -49,13 +49,10 @@ import net.osmand.plus.skimapsplugin.SkiMapsPlugin;
import org.apache.commons.logging.Log;
import java.io.File;
import java.util.Collections;
import java.util.List;
import static net.osmand.plus.UiUtilities.CompoundButtonType.TOOLBAR;
import static net.osmand.plus.profiles.EditProfileFragment.MAP_CONFIG;
import static net.osmand.plus.profiles.EditProfileFragment.OPEN_CONFIG_ON_MAP;
import static net.osmand.plus.profiles.EditProfileFragment.SCREEN_CONFIG;
import static net.osmand.plus.profiles.EditProfileFragment.SELECTED_ITEM;
public class ConfigureProfileFragment extends BaseSettingsFragment implements CopyAppModePrefsListener, ResetAppModePrefsListener {
@ -93,7 +90,7 @@ public class ConfigureProfileFragment extends BaseSettingsFragment implements Co
TextView toolbarTitle = view.findViewById(R.id.toolbar_title);
toolbarTitle.setTypeface(FontCache.getRobotoMedium(view.getContext()));
toolbarTitle.setText(getSelectedAppMode().toHumanString(getContext()));
toolbarTitle.setText(getSelectedAppMode().toHumanString());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
float letterSpacing = AndroidUtils.getFloatValueFromRes(view.getContext(), R.dimen.title_letter_spacing);
toolbarTitle.setLetterSpacing(letterSpacing);
@ -146,13 +143,20 @@ public class ConfigureProfileFragment extends BaseSettingsFragment implements Co
@Override
protected void updateToolbar() {
super.updateToolbar();
updateToolbarSwitch();
View view = getView();
if (view != null) {
updateToolbarSwitch();
TextView toolbarTitle = view.findViewById(R.id.toolbar_title);
toolbarTitle.setText(getSelectedAppMode().toHumanString());
}
}
@Override
public void copyAppModePrefs(ApplicationMode appMode) {
if (appMode != null) {
app.getSettings().copyPreferencesFromProfile(appMode, getSelectedAppMode());
ApplicationMode selectedAppMode = getSelectedAppMode();
app.getSettings().copyPreferencesFromProfile(appMode, selectedAppMode);
updateCopiedOrResetPrefs();
}
}
@ -160,6 +164,19 @@ public class ConfigureProfileFragment extends BaseSettingsFragment implements Co
public void resetAppModePrefs(ApplicationMode appMode) {
if (appMode != null) {
app.getSettings().resetPreferencesForProfile(appMode);
app.showToastMessage(R.string.profile_prefs_reset_successful);
updateCopiedOrResetPrefs();
}
}
private void updateCopiedOrResetPrefs() {
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
app.getPoiFilters().loadSelectedPoiFilters();
mapActivity.getMapLayers().getMapWidgetRegistry().updateVisibleWidgets();
mapActivity.updateApplicationModeSettings();
updateToolbar();
updateAllSettings();
}
}
@ -248,7 +265,7 @@ public class ConfigureProfileFragment extends BaseSettingsFragment implements Co
Intent intent = new Intent(ctx, MapActivity.class);
intent.putExtra(OPEN_CONFIG_ON_MAP, MAP_CONFIG);
intent.putExtra(SELECTED_ITEM, getSelectedAppMode().getStringKey());
intent.putExtra(APP_MODE_KEY, getSelectedAppMode().getStringKey());
configureMap.setIntent(intent);
}
@ -262,7 +279,7 @@ public class ConfigureProfileFragment extends BaseSettingsFragment implements Co
Intent intent = new Intent(ctx, MapActivity.class);
intent.putExtra(OPEN_CONFIG_ON_MAP, SCREEN_CONFIG);
intent.putExtra(SELECTED_ITEM, getSelectedAppMode().getStringKey());
intent.putExtra(APP_MODE_KEY, getSelectedAppMode().getStringKey());
configureMap.setIntent(intent);
}
@ -309,7 +326,7 @@ public class ConfigureProfileFragment extends BaseSettingsFragment implements Co
Context ctx = requireContext();
final Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.exported_osmand_profile, profile.toHumanString(ctx)));
sendIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.exported_osmand_profile, profile.toHumanString()));
sendIntent.putExtra(Intent.EXTRA_STREAM, AndroidUtils.getUriForFile(getMyApplication(), file));
sendIntent.setType("*/*");
sendIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
@ -384,7 +401,7 @@ public class ConfigureProfileFragment extends BaseSettingsFragment implements Co
if (!tempDir.exists()) {
tempDir.mkdirs();
}
String fileName = profile.toHumanString(ctx);
String fileName = profile.toHumanString();
app.getSettingsHelper().exportSettings(tempDir, fileName, new SettingsHelper.SettingsExportListener() {
@Override
public void onSettingsExportFinished(@NonNull File file, boolean succeed) {
@ -410,15 +427,14 @@ public class ConfigureProfileFragment extends BaseSettingsFragment implements Co
bld.setTitle(R.string.profile_alert_delete_title);
bld.setMessage(String
.format(getString(R.string.profile_alert_delete_msg),
profile.getCustomProfileName()));
profile.getUserProfileName()));
bld.setPositiveButton(R.string.shared_string_delete,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
OsmandApplication app = getMyApplication();
if (app != null) {
ApplicationMode.deleteCustomMode(ApplicationMode.valueOfStringKey(profile.getStringKey(), ApplicationMode.DEFAULT), app);
app.getSettings().APPLICATION_MODE.set(ApplicationMode.DEFAULT);
ApplicationMode.deleteCustomModes(Collections.singletonList(profile), app);
}
if (getActivity() != null) {

View file

@ -102,7 +102,7 @@ public class GlobalSettingsFragment extends BaseSettingsFragment implements Send
String[] entries = new String[appModes.length];
String[] entryValues = new String[appModes.length];
for (int i = 0; i < entries.length; i++) {
entries[i] = appModes[i].toHumanString(app);
entries[i] = appModes[i].toHumanString();
entryValues[i] = appModes[i].getStringKey();
}

View file

@ -147,7 +147,7 @@ public class MainSettingsFragment extends BaseSettingsFragment {
private void setupConfigureProfilePref() {
ApplicationMode selectedMode = app.getSettings().APPLICATION_MODE.get();
String title = selectedMode.toHumanString(getContext());
String title = selectedMode.toHumanString();
String profileType = getAppModeDescription(getContext(), selectedMode);
int iconRes = selectedMode.getIconRes();
Preference configureProfile = findPreference(CONFIGURE_PROFILE);
@ -181,7 +181,7 @@ public class MainSettingsFragment extends BaseSettingsFragment {
pref.setPersistent(false);
pref.setKey(applicationMode.getStringKey());
pref.setIcon(getAppProfilesIcon(applicationMode, isAppProfileEnabled));
pref.setTitle(applicationMode.toHumanString(getContext()));
pref.setTitle(applicationMode.toHumanString());
pref.setSummary(getAppModeDescription(getContext(), applicationMode));
pref.setChecked(isAppProfileEnabled);
pref.setLayoutResource(R.layout.preference_with_descr_dialog_and_switch);

View file

@ -1,5 +1,6 @@
package net.osmand.plus.settings;
import android.content.Context;
import android.os.Bundle;
import android.support.v7.preference.Preference;
import android.support.v7.preference.SwitchPreferenceCompat;
@ -10,6 +11,7 @@ import net.osmand.plus.ApplicationMode;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.profiles.ProfileDataObject;
import net.osmand.plus.profiles.RoutingProfileDataObject;
import net.osmand.plus.profiles.RoutingProfileDataObject.RoutingProfilesResources;
import net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment;
@ -18,7 +20,9 @@ import net.osmand.plus.settings.preferences.SwitchPreferenceEx;
import net.osmand.router.GeneralRouter;
import net.osmand.util.Algorithms;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment.DIALOG_TYPE;
@ -134,19 +138,18 @@ public class NavigationFragment extends BaseSettingsFragment {
}
navigationType.setSummary(selectedRoutingProfileDataObject.getName());
navigationType.setIcon(getContentIcon(selectedRoutingProfileDataObject.getIconRes()));
ApplicationMode.ApplicationModeBuilder builder = ApplicationMode.changeBaseMode(getSelectedAppMode());
if (profileKey.equals(RoutingProfilesResources.STRAIGHT_LINE_MODE.name())) {
builder.setRouteService(RouteProvider.RouteService.STRAIGHT);
} else if (profileKey.equals(RoutingProfilesResources.BROUTER_MODE.name())) {
builder.setRouteService(RouteProvider.RouteService.BROUTER);
} else {
builder.setRoutingProfile(profileKey);
}
ApplicationMode mode = ApplicationMode.saveProfile(builder, app);
if (!ApplicationMode.values(app).contains(mode)) {
ApplicationMode.changeProfileAvailability(mode, true, app);
ApplicationMode appMode = getSelectedAppMode();
RouteProvider.RouteService routeService;
if (profileKey.equals(RoutingProfilesResources.STRAIGHT_LINE_MODE.name())) {
routeService = RouteProvider.RouteService.STRAIGHT;
} else if (profileKey.equals(RoutingProfilesResources.BROUTER_MODE.name())) {
routeService = RouteProvider.RouteService.BROUTER;
} else {
routeService = RouteProvider.RouteService.OSMAND;
}
appMode.setRouteService(routeService);
appMode.setRoutingProfile(profileKey);
}
public static Map<String, RoutingProfileDataObject> getRoutingProfiles(OsmandApplication context) {
@ -186,6 +189,17 @@ public class NavigationFragment extends BaseSettingsFragment {
return profilesObjects;
}
public 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(), mode.getDescription(),
mode.getStringKey(), mode.getIconRes(), false, mode.getIconColorInfo()));
}
}
return profiles;
}
private void setupVehicleParametersPref() {
Preference vehicleParameters = findPreference("vehicle_parameters");
int iconRes = getSelectedAppMode().getIconRes();

View file

@ -36,6 +36,10 @@ import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.UiUtilities.DialogButtonType;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.profiles.LocationIcon;
import net.osmand.plus.profiles.NavigationIcon;
import net.osmand.plus.profiles.ProfileIconColors;
import net.osmand.plus.profiles.ProfileIcons;
import net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment;
import net.osmand.plus.routing.RouteProvider;
import net.osmand.plus.widgets.FlowLayout;
@ -45,6 +49,7 @@ import net.osmand.util.Algorithms;
import org.apache.commons.logging.Log;
import java.util.ArrayList;
import java.util.Collections;
import static net.osmand.aidlapi.OsmAndCustomizationConstants.DRAWER_SETTINGS_ID;
import static net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment.DIALOG_TYPE;
@ -89,7 +94,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
private FlowLayout navIconItems;
private OsmandTextFieldBoxes profileNameOtfb;
private View saveButton;
private boolean isBaseProfileImported;
@Override
@ -106,7 +111,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
if (baseModeForNewProfile != null) {
profile.stringKey = baseModeForNewProfile.getStringKey() + "_" + System.currentTimeMillis();
profile.parent = baseModeForNewProfile;
profile.name = baseModeForNewProfile.toHumanString(app);
profile.name = baseModeForNewProfile.toHumanString();
profile.color = baseModeForNewProfile.getIconColorInfo();
profile.iconRes = baseModeForNewProfile.getIconRes();
profile.routingProfile = baseModeForNewProfile.getRoutingProfile();
@ -117,7 +122,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
} else {
profile.stringKey = getSelectedAppMode().getStringKey();
profile.parent = getSelectedAppMode().getParent();
profile.name = getSelectedAppMode().toHumanString(getContext());
profile.name = getSelectedAppMode().toHumanString();
profile.color = getSelectedAppMode().getIconColorInfo();
profile.iconRes = getSelectedAppMode().getIconRes();
profile.routingProfile = getSelectedAppMode().getRoutingProfile();
@ -132,7 +137,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
changedProfile.stringKey = profile.stringKey;
changedProfile.parent = profile.parent;
if (baseModeForNewProfile != null) {
changedProfile.name = createNonDuplicateName(baseModeForNewProfile.toHumanString(app));
changedProfile.name = createNonDuplicateName(baseModeForNewProfile.toHumanString());
} else {
changedProfile.name = profile.name;
}
@ -171,7 +176,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
private boolean hasProfileWithName(String newName) {
for (ApplicationMode m : ApplicationMode.allPossibleValues()) {
if (m.toHumanString(app).equals(newName)) {
if (m.toHumanString().equals(newName)) {
return true;
}
}
@ -276,12 +281,12 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
changedProfile.name = savedInstanceState.getString(PROFILE_NAME_KEY);
changedProfile.stringKey = savedInstanceState.getString(PROFILE_STRINGKEY_KEY);
changedProfile.iconRes = savedInstanceState.getInt(PROFILE_ICON_RES_KEY);
changedProfile.color = (ApplicationMode.ProfileIconColors) savedInstanceState.getSerializable(PROFILE_COLOR_KEY);
changedProfile.color = (ProfileIconColors) savedInstanceState.getSerializable(PROFILE_COLOR_KEY);
String parentStringKey = savedInstanceState.getString(PROFILE_PARENT_KEY);
changedProfile.parent = ApplicationMode.valueOfStringKey(parentStringKey, null);
isBaseProfileImported = savedInstanceState.getBoolean(IS_BASE_PROFILE_IMPORTED);
changedProfile.locationIcon = (ApplicationMode.LocationIcon) savedInstanceState.getSerializable(PROFILE_LOCATION_ICON_KEY);
changedProfile.navigationIcon = (ApplicationMode.NavigationIcon) savedInstanceState.getSerializable(PROFILE_NAVIGATION_ICON_KEY);
changedProfile.locationIcon = (LocationIcon) savedInstanceState.getSerializable(PROFILE_LOCATION_ICON_KEY);
changedProfile.navigationIcon = (NavigationIcon) savedInstanceState.getSerializable(PROFILE_NAVIGATION_ICON_KEY);
}
@Override
@ -341,8 +346,8 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
baseProfileName = (EditText) holder.findViewById(R.id.master_profile_et);
baseProfileName.setFocusable(false);
baseProfileName.setText(changedProfile.parent != null
? changedProfile.parent.toHumanString(getContext())
: getSelectedAppMode().toHumanString(getContext()));
? changedProfile.parent.toHumanString()
: getSelectedAppMode().toHumanString());
OsmandTextFieldBoxes baseProfileNameHint = (OsmandTextFieldBoxes) holder.findViewById(R.id.master_profile_otfb);
baseProfileNameHint.setLabelText(getString(R.string.master_profile));
FrameLayout selectNavTypeBtn = (FrameLayout) holder.findViewById(R.id.select_nav_type_btn);
@ -368,7 +373,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
} else if (COLOR_ITEMS.equals(preference.getKey())) {
colorItems = (FlowLayout) holder.findViewById(R.id.color_items);
colorItems.removeAllViews();
for (ApplicationMode.ProfileIconColors color : ApplicationMode.ProfileIconColors.values()) {
for (ProfileIconColors color : ProfileIconColors.values()) {
View colorItem = createColorItemView(color, colorItems);
colorItems.addView(colorItem, new FlowLayout.LayoutParams(0, 0));
@ -377,7 +382,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
} else if (ICON_ITEMS.equals(preference.getKey())) {
iconItems = (FlowLayout) holder.findViewById(R.id.color_items);
iconItems.removeAllViews();
ArrayList<Integer> icons = ApplicationMode.ProfileIcons.getIcons();
ArrayList<Integer> icons = ProfileIcons.getIcons();
for (int iconRes : icons) {
View iconItem = createIconItemView(iconRes, iconItems);
iconItems.addView(iconItem, new FlowLayout.LayoutParams(0, 0));
@ -386,7 +391,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
} else if (LOCATION_ICON_ITEMS.equals(preference.getKey())) {
locationIconItems = (FlowLayout) holder.findViewById(R.id.color_items);
locationIconItems.removeAllViews();
for (ApplicationMode.LocationIcon locationIcon : ApplicationMode.LocationIcon.values()) {
for (LocationIcon locationIcon : LocationIcon.values()) {
View iconItemView = createLocationIconView(locationIcon, locationIconItems);
locationIconItems.addView(iconItemView, new FlowLayout.LayoutParams(0, 0));
}
@ -394,7 +399,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
} else if (NAV_ICON_ITEMS.equals(preference.getKey())) {
navIconItems = (FlowLayout) holder.findViewById(R.id.color_items);
navIconItems.removeAllViews();
for (ApplicationMode.NavigationIcon navigationIcon : ApplicationMode.NavigationIcon.values()) {
for (NavigationIcon navigationIcon : NavigationIcon.values()) {
View iconItemView = createNavigationIconView(navigationIcon, navIconItems);
navIconItems.addView(iconItemView, new FlowLayout.LayoutParams(0, 0));
}
@ -402,7 +407,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
}
}
private View createColorItemView(final ApplicationMode.ProfileIconColors colorRes, ViewGroup rootView) {
private View createColorItemView(final ProfileIconColors colorRes, ViewGroup rootView) {
FrameLayout colorItemView = (FrameLayout) UiUtilities.getInflater(getContext(), isNightMode())
.inflate(R.layout.preference_circle_item, rootView, false);
ImageView coloredCircle = colorItemView.findViewById(R.id.backgroundCircle);
@ -435,7 +440,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
return colorItemView;
}
private void updateColorSelector(ApplicationMode.ProfileIconColors color) {
private void updateColorSelector(ProfileIconColors color) {
View colorItem = colorItems.findViewWithTag(changedProfile.color);
colorItem.findViewById(R.id.outlineCircle).setVisibility(View.GONE);
colorItem.findViewById(R.id.checkMark).setVisibility(View.GONE);
@ -495,7 +500,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
updateProfileButton();
}
private View createLocationIconView(final ApplicationMode.LocationIcon locationIcon, ViewGroup rootView) {
private View createLocationIconView(final LocationIcon locationIcon, ViewGroup rootView) {
FrameLayout locationIconView = (FrameLayout) UiUtilities.getInflater(getContext(), isNightMode())
.inflate(R.layout.preference_select_icon_button, rootView, false);
int changedProfileColor = ContextCompat.getColor(app, changedProfile.color.getColor(
@ -529,7 +534,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
return locationIconView;
}
private void updateLocationIconSelector(ApplicationMode.LocationIcon locationIcon) {
private void updateLocationIconSelector(LocationIcon locationIcon) {
View viewWithTag = locationIconItems.findViewWithTag(changedProfile.locationIcon);
viewWithTag.findViewById(R.id.outlineRect).setVisibility(View.GONE);
viewWithTag = locationIconItems.findViewWithTag(locationIcon);
@ -537,7 +542,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
changedProfile.locationIcon = locationIcon;
}
private View createNavigationIconView(final ApplicationMode.NavigationIcon navigationIcon, ViewGroup rootView) {
private View createNavigationIconView(final NavigationIcon navigationIcon, ViewGroup rootView) {
FrameLayout navigationIconView = (FrameLayout) UiUtilities.getInflater(getContext(), isNightMode())
.inflate(R.layout.preference_select_icon_button, rootView, false);
LayerDrawable navigationIconDrawable = (LayerDrawable) app.getResources().getDrawable(navigationIcon.getIconId());
@ -575,7 +580,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
return navigationIconView;
}
private void updateNavigationIconSelector(ApplicationMode.NavigationIcon navigationIcon) {
private void updateNavigationIconSelector(NavigationIcon navigationIcon) {
View viewWithTag = navIconItems.findViewWithTag(changedProfile.navigationIcon);
viewWithTag.findViewById(R.id.outlineRect).setVisibility(View.GONE);
viewWithTag = navIconItems.findViewWithTag(navigationIcon);
@ -635,7 +640,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
private void setupBaseProfileView(String stringKey) {
for (ApplicationMode am : ApplicationMode.getDefaultValues()) {
if (am.getStringKey().equals(stringKey)) {
baseProfileName.setText(Algorithms.capitalizeFirstLetter(am.toHumanString(app)));
baseProfileName.setText(Algorithms.capitalizeFirstLetter(am.toHumanString()));
}
}
}
@ -648,29 +653,40 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
}
return false;
}
ApplicationMode.ApplicationModeBuilder builder = ApplicationMode
.createCustomMode(changedProfile.parent, changedProfile.name.trim(), changedProfile.stringKey)
.icon(app, ApplicationMode.ProfileIcons.getResStringByResId(changedProfile.iconRes))
.setRouteService(changedProfile.routeService)
.setRoutingProfile(changedProfile.routingProfile)
.setColor(changedProfile.color)
.locationIcon(changedProfile.locationIcon)
.navigationIcon(changedProfile.navigationIcon);
ApplicationMode mode = ApplicationMode.saveProfile(builder, getMyApplication());
if (!ApplicationMode.values(app).contains(mode)) {
ApplicationMode.changeProfileAvailability(mode, true, getMyApplication());
}
if (isNew) {
app.getSettings().copyPreferencesFromProfile(changedProfile.parent, mode);
ApplicationMode.ApplicationModeBuilder builder = ApplicationMode
.createCustomMode(changedProfile.parent, changedProfile.stringKey, app)
.setIconResName(ProfileIcons.getResStringByResId(changedProfile.iconRes))
.setUserProfileName(changedProfile.name.trim())
.setRoutingProfile(changedProfile.routingProfile)
.setRouteService(changedProfile.routeService)
.setIconColor(changedProfile.color)
.setLocationIcon(changedProfile.locationIcon)
.setNavigationIcon(changedProfile.navigationIcon);
app.getSettings().copyPreferencesFromProfile(changedProfile.parent, builder.getApplicationMode());
ApplicationMode mode = ApplicationMode.saveProfile(builder, app);
if (!ApplicationMode.values(app).contains(mode)) {
ApplicationMode.changeProfileAvailability(mode, true, app);
}
} else {
ApplicationMode mode = getSelectedAppMode();
mode.setParentAppMode(changedProfile.parent);
mode.setIconResName(ProfileIcons.getResStringByResId(changedProfile.iconRes));
mode.setUserProfileName(changedProfile.name.trim());
mode.setRoutingProfile(changedProfile.routingProfile);
mode.setRouteService(changedProfile.routeService);
mode.setIconColor(changedProfile.color);
mode.setLocationIcon(changedProfile.locationIcon);
mode.setNavigationIcon(changedProfile.navigationIcon);
}
return true;
}
private boolean hasNameDuplicate() {
for (ApplicationMode m : ApplicationMode.allPossibleValues()) {
if (m.toHumanString(app).equals(changedProfile.name) &&
if (m.toHumanString().equals(changedProfile.name) &&
!m.getStringKey().equals(profile.stringKey)) {
return true;
}
@ -715,8 +731,10 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
private void deleteImportedProfile() {
if (isBaseProfileImported) {
ApplicationMode.deleteCustomMode(ApplicationMode.valueOfStringKey(
changedProfile.parent.getStringKey(), ApplicationMode.DEFAULT), app);
ApplicationMode appMode = ApplicationMode.valueOfStringKey(changedProfile.parent.getStringKey(), null);
if (appMode != null) {
ApplicationMode.deleteCustomModes(Collections.singletonList(appMode), app);
}
}
}
@ -744,12 +762,12 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
String stringKey;
ApplicationMode parent = null;
String name;
ApplicationMode.ProfileIconColors color;
ProfileIconColors color;
int iconRes;
String routingProfile;
RouteProvider.RouteService routeService;
ApplicationMode.NavigationIcon navigationIcon;
ApplicationMode.LocationIcon locationIcon;
NavigationIcon navigationIcon;
LocationIcon locationIcon;
@Override
public boolean equals(Object o) {

View file

@ -79,7 +79,7 @@ public class RouteParametersFragment extends BaseSettingsFragment implements OnP
Preference routeParametersInfo = findPreference(ROUTE_PARAMETERS_INFO);
routeParametersInfo.setIcon(getContentIcon(R.drawable.ic_action_info_dark));
routeParametersInfo.setTitle(getString(R.string.route_parameters_info, getSelectedAppMode().toHumanString(getContext())));
routeParametersInfo.setTitle(getString(R.string.route_parameters_info, getSelectedAppMode().toHumanString()));
setupRoutingPrefs();
setupTimeConditionalRoutingPref();

View file

@ -31,7 +31,7 @@ public class VehicleParametersFragment extends BaseSettingsFragment implements O
Preference vehicleParametersInfo = findPreference("vehicle_parameters_info");
vehicleParametersInfo.setIcon(getContentIcon(R.drawable.ic_action_info_dark));
vehicleParametersInfo.setTitle(getString(R.string.route_parameters_info, getSelectedAppMode().toHumanString(getContext())));
vehicleParametersInfo.setTitle(getString(R.string.route_parameters_info, getSelectedAppMode().toHumanString()));
RouteService routeService = getSelectedAppMode().getRouteService();
if (routeService == RouteService.OSMAND) {

View file

@ -65,7 +65,7 @@ public class ChangeGeneralProfilesPrefBottomSheet extends BasePreferenceBottomSh
ApplicationMode selectedAppMode = getAppMode();
BaseBottomSheetItem applyToCurrentProfile = new SimpleBottomSheetItem.Builder()
.setTitle(getString(R.string.apply_to_current_profile, selectedAppMode.toHumanString(app)))
.setTitle(getString(R.string.apply_to_current_profile, selectedAppMode.toHumanString()))
.setIcon(getActiveIcon(selectedAppMode.getIconRes()))
.setLayoutId(R.layout.bottom_sheet_item_simple)
.setOnClickListener(new View.OnClickListener() {

View file

@ -46,7 +46,7 @@ public class ResetProfilePrefsBottomSheet extends BasePreferenceBottomSheet {
.setButtonTintList(ColorStateList.valueOf(getResolvedColor(profileColor)))
.setDescription(BaseSettingsFragment.getAppModeDescription(ctx, mode))
.setIcon(getIcon(mode.getIconRes(), profileColor))
.setTitle(mode.toHumanString(ctx))
.setTitle(mode.toHumanString())
.setBackground(new LayerDrawable(layers))
.setLayoutId(R.layout.preference_profile_item_with_radio_btn)
.create();

View file

@ -4,7 +4,6 @@ import android.content.Context;
import android.support.annotation.DrawableRes;
import android.support.annotation.NonNull;
import android.support.annotation.StringRes;
import android.support.v4.content.ContextCompat;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
@ -15,11 +14,11 @@ import android.widget.LinearLayout;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.ContextMenuAdapter;
import net.osmand.plus.ContextMenuItem;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.OsmandSettings.OsmandPreference;
import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.dialogs.ConfigureMapMenu;
import net.osmand.plus.mapmarkers.DirectionIndicationDialogFragment;
@ -75,17 +74,7 @@ public class MapWidgetRegistry {
public MapWidgetRegistry(OsmandApplication app) {
this.app = app;
this.settings = app.getSettings();
for (ApplicationMode ms : ApplicationMode.values(app)) {
String mpf = settings.MAP_INFO_CONTROLS.getModeValue(ms);
if (mpf.equals(SHOW_PREFIX)) {
visibleElementsFromSettings.put(ms, null);
} else {
LinkedHashSet<String> set = new LinkedHashSet<>();
visibleElementsFromSettings.put(ms, set);
Collections.addAll(set, mpf.split(SETTINGS_SEPARATOR));
}
}
loadVisibleElementsFromSettings();
}
public void populateStackControl(LinearLayout stack,
@ -220,7 +209,7 @@ public class MapWidgetRegistry {
private void processVisibleModes(String key, MapWidgetRegInfo ii) {
for (ApplicationMode ms : ApplicationMode.values(app)) {
boolean collapse = ms.isWidgetCollapsible(key);
boolean def = ms.isWidgetVisible(app, key);
boolean def = ms.isWidgetVisible(key);
Set<String> set = visibleElementsFromSettings.get(ms);
if (set != null) {
if (set.contains(key)) {
@ -238,6 +227,9 @@ public class MapWidgetRegistry {
ii.visibleModes.add(ms);
} else if (collapse) {
ii.visibleCollapsible.add(ms);
} else {
ii.visibleModes.remove(ms);
ii.visibleCollapsible.remove(ms);
}
}
}
@ -300,6 +292,30 @@ public class MapWidgetRegistry {
}
}
public void updateVisibleWidgets() {
loadVisibleElementsFromSettings();
for (MapWidgetRegInfo ri : leftWidgetSet) {
processVisibleModes(ri.key, ri);
}
for (MapWidgetRegInfo ri : rightWidgetSet) {
processVisibleModes(ri.key, ri);
}
}
private void loadVisibleElementsFromSettings() {
visibleElementsFromSettings.clear();
for (ApplicationMode ms : ApplicationMode.values(app)) {
String mpf = settings.MAP_INFO_CONTROLS.getModeValue(ms);
if (mpf.equals(SHOW_PREFIX)) {
visibleElementsFromSettings.put(ms, null);
} else {
LinkedHashSet<String> set = new LinkedHashSet<>();
visibleElementsFromSettings.put(ms, set);
Collections.addAll(set, mpf.split(SETTINGS_SEPARATOR));
}
}
}
private void saveVisibleElementsToSettings(ApplicationMode mode) {
StringBuilder bs = new StringBuilder();
for (String ks : this.visibleElementsFromSettings.get(mode)) {
@ -313,7 +329,7 @@ public class MapWidgetRegistry {
for (MapWidgetRegInfo ri : set) {
ri.visibleCollapsible.remove(mode);
ri.visibleModes.remove(mode);
if (mode.isWidgetVisible(app, ri.key)) {
if (mode.isWidgetVisible(ri.key)) {
if (mode.isWidgetCollapsible(ri.key)) {
ri.visibleCollapsible.add(mode);
} else {
@ -485,7 +501,7 @@ public class MapWidgetRegistry {
private void addControls(final MapActivity mapActivity, final ContextMenuAdapter contextMenuAdapter,
Set<MapWidgetRegInfo> groupTitle, final ApplicationMode mode) {
for (final MapWidgetRegInfo r : groupTitle) {
if (!mode.isWidgetAvailable(app, r.key)) {
if (!mode.isWidgetAvailable(r.key)) {
continue;
}