Merge pull request #7536 from osmandapp/ProfileSettings

Profile settings UI improvements
This commit is contained in:
max-klaus 2019-09-10 11:55:29 +03:00 committed by GitHub
commit c09635c0e0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 226 additions and 174 deletions

View file

@ -6,7 +6,8 @@
android:layout_height="wrap_content"
android:background="?attr/list_background_color"
android:gravity="center_vertical"
android:minHeight="@dimen/bottom_sheet_list_item_height">
android:minHeight="@dimen/bottom_sheet_cancel_button_height_small"
android:orientation="horizontal">
<ImageView
android:id="@android:id/icon"
@ -17,34 +18,33 @@
android:layout_marginRight="@dimen/content_padding" />
<LinearLayout
android:layout_width="0dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="@dimen/content_padding"
android:layout_marginRight="@dimen/content_padding"
android:layout_weight="1"
android:orientation="vertical">
android:layout_gravity="top"
android:orientation="vertical"
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding">
<net.osmand.plus.widgets.TextViewEx
android:id="@android:id/title"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:ellipsize="marquee"
android:gravity="center_vertical"
android:paddingTop="@dimen/list_header_settings_top_margin"
android:singleLine="true"
android:textColor="@color/preference_category_title"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_medium"
tools:text="@string/shared_string_other" />
tools:text="@string/plugin_settings" />
<net.osmand.plus.widgets.TextViewEx
android:id="@android:id/summary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="4"
android:paddingBottom="@dimen/list_header_settings_top_margin"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_list_text_size"
osmand:typeface="@string/font_roboto_regular" />
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_regular"
tools:text="@string/list_of_installed_plugins" />
</LinearLayout>

View file

@ -9,8 +9,7 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground"
android:minHeight="@dimen/bottom_sheet_list_item_height">
android:background="?android:attr/selectableItemBackground">
<ImageView
android:id="@android:id/icon"
@ -18,38 +17,28 @@
android:layout_height="@dimen/standard_icon_size"
android:layout_gravity="center"
android:layout_marginLeft="@dimen/content_padding"
android:layout_marginRight="@dimen/content_padding" />
android:layout_marginTop="@dimen/content_padding_small"
android:layout_marginRight="@dimen/content_padding"
android:layout_marginBottom="@dimen/content_padding_small" />
<LinearLayout
<net.osmand.plus.widgets.TextViewEx
android:id="@android:id/title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="@dimen/content_padding"
android:layout_marginRight="@dimen/content_padding"
android:layout_weight="1"
android:orientation="vertical">
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size"
osmand:typeface="@string/font_roboto_regular" />
<net.osmand.plus.widgets.TextViewEx
android:id="@android:id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:singleLine="true"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size"
osmand:typeface="@string/font_roboto_regular" />
<net.osmand.plus.widgets.TextViewEx
android:id="@android:id/summary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="4"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_list_text_size"
osmand:typeface="@string/font_roboto_regular" />
</LinearLayout>
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_marginTop="@dimen/context_menu_padding_margin_tiny"
android:layout_marginBottom="@dimen/context_menu_padding_margin_tiny"
android:background="?attr/divider_color_basic" />
<Switch
android:id="@android:id/switch_widget"
@ -61,13 +50,6 @@
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding" />
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_marginTop="18dp"
android:layout_marginBottom="18dp"
android:background="?attr/divider_color_basic" />
</LinearLayout>
</LinearLayout>

View file

@ -2,7 +2,8 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:osmand="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:orientation="vertical">
<net.osmand.plus.widgets.TextViewEx
android:id="@android:id/title"
@ -10,8 +11,11 @@
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/content_padding"
android:layout_marginRight="@dimen/content_padding"
android:paddingTop="@dimen/content_padding_small"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_desc_text_size"
android:textSize="@dimen/default_sub_text_size"
osmand:typeface="@string/font_roboto_regular" />
<include layout="@layout/card_top_divider" />
</LinearLayout>

View file

@ -46,7 +46,7 @@
android:layout_height="wrap_content"
android:maxLines="4"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_list_text_size"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_regular" />
</LinearLayout>
@ -56,8 +56,8 @@
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@null"
android:clickable="true"
android:focusable="true"
android:clickable="false"
android:focusable="false"
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding" />

View file

@ -18,7 +18,9 @@
android:layout_height="@dimen/standard_icon_size"
android:layout_gravity="center"
android:layout_marginLeft="@dimen/content_padding"
android:layout_marginRight="@dimen/content_padding" />
android:layout_marginTop="@dimen/bottom_sheet_icon_margin"
android:layout_marginRight="@dimen/content_padding"
android:layout_marginBottom="@dimen/bottom_sheet_icon_margin" />
<LinearLayout
android:layout_width="0dp"
@ -46,7 +48,7 @@
android:layout_height="wrap_content"
android:maxLines="4"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_list_text_size"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_regular" />
</LinearLayout>

View file

@ -0,0 +1,74 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:osmand="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/list_background_color"
android:gravity="center_vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground">
<ImageView
android:id="@android:id/icon"
android:layout_width="@dimen/standard_icon_size"
android:layout_height="@dimen/standard_icon_size"
android:layout_gravity="center_vertical"
android:layout_marginLeft="@dimen/content_padding"
android:layout_marginTop="@dimen/bottom_sheet_icon_margin"
android:layout_marginRight="@dimen/content_padding"
android:layout_marginBottom="@dimen/bottom_sheet_icon_margin" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="@dimen/content_padding"
android:layout_marginRight="@dimen/content_padding"
android:layout_weight="1"
android:orientation="vertical">
<net.osmand.plus.widgets.TextViewEx
android:id="@android:id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:singleLine="true"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size"
osmand:typeface="@string/font_roboto_regular" />
<net.osmand.plus.widgets.TextViewEx
android:id="@android:id/summary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="4"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_regular" />
</LinearLayout>
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_marginTop="18dp"
android:layout_marginBottom="18dp"
android:background="?attr/divider_color_basic" />
<Switch
android:id="@android:id/switch_widget"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@null"
android:clickable="true"
android:focusable="true"
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding" />
</LinearLayout>
</LinearLayout>

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<View xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/divider_color_basic"
android:orientation="vertical" />

View file

@ -549,7 +549,8 @@
</style>
<style name="OsmandPreferenceTheme" parent="@style/PreferenceThemeOverlay.v14.Material">
<item name="android:layout">@layout/pref_screen</item>
<item name="android:layout">@layout/preferences_screen</item>
<item name="iconSpaceReserved">true</item>
</style>
<!-- Standard action bar override -->

View file

@ -36,6 +36,10 @@
android:title="@string/configure_map"
tools:icon="@drawable/ic_action_layers_dark" />
<Preference
android:layout="@layout/list_item_divider"
android:selectable="false" />
<PreferenceCategory
android:key="plugin_settings"
android:layout="@layout/preference_category_with_descr"

View file

@ -22,6 +22,10 @@
android:layout="@layout/preference_with_descr"
android:title="@string/map_screen_orientation" />
<Preference
android:layout="@layout/simple_divider_item"
android:selectable="false" />
<PreferenceCategory
android:key="units_and_formats"
android:layout="@layout/preference_category_with_descr"
@ -48,6 +52,10 @@
android:layout="@layout/preference_with_descr"
android:title="@string/angular_measeurement" />
<Preference
android:layout="@layout/simple_divider_item"
android:selectable="false" />
<PreferenceCategory
android:key="other"
android:layout="@layout/preference_category_with_descr"
@ -55,21 +63,21 @@
<net.osmand.plus.settings.preferences.SwitchPreferenceEx
android:key="use_kalman_filter_compass"
android:layout="@layout/preference_dialog_and_switch"
android:layout="@layout/preference_with_descr_dialog_and_switch"
android:summaryOff="@string/shared_string_off"
android:summaryOn="@string/shared_string_on"
android:title="@string/use_kalman_filter_compass" />
<net.osmand.plus.settings.preferences.SwitchPreferenceEx
android:key="use_magnetic_field_sensor_compass"
android:layout="@layout/preference_dialog_and_switch"
android:layout="@layout/preference_with_descr_dialog_and_switch"
android:summaryOff="@string/shared_string_off"
android:summaryOn="@string/shared_string_on"
android:title="@string/use_magnetic_sensor" />
<net.osmand.plus.settings.preferences.SwitchPreferenceEx
android:key="map_empty_state_allowed"
android:layout="@layout/preference_dialog_and_switch"
android:layout="@layout/preference_with_descr_dialog_and_switch"
android:summaryOff="@string/shared_string_off"
android:summaryOn="@string/shared_string_on"
android:title="@string/tap_on_map_to_hide_interface" />
@ -83,7 +91,7 @@
<net.osmand.plus.settings.preferences.ListPreferenceEx
android:key="external_input_device"
android:layout="@layout/preference_dialog_and_switch"
android:layout="@layout/preference_with_descr_dialog_and_switch"
android:title="@string/external_input_device" />
</PreferenceScreen>

View file

@ -15,17 +15,21 @@
android:layout="@layout/preference_with_descr"
android:title="@string/preferred_locale" />
<!-- <Preference-->
<!-- android:icon="@drawable/ic_action_folder"-->
<!-- android:key="external_storage_dir"-->
<!-- android:layout="@layout/preference_with_descr"-->
<!-- android:persistent="false"-->
<!-- android:title="@string/application_dir" />-->
<Preference
android:key="external_storage_dir"
android:layout="@layout/preference_with_descr"
android:persistent="false"
android:title="@string/application_dir"
tools:icon="@drawable/ic_action_folder" />
<Preference
android:layout="@layout/simple_divider_item"
android:selectable="false" />
<PreferenceCategory
android:key="privacy_and_security"
android:layout="@layout/preference_category_with_descr"
android:title="@string/application_profiles" />
android:title="@string/settings_privacy_and_security" />
<net.osmand.plus.settings.preferences.SwitchPreferenceEx
android:icon="@drawable/ic_action_privacy_and_security"

View file

@ -12,6 +12,10 @@
app:fragment="net.osmand.plus.settings.GlobalSettingsFragment"
tools:icon="@drawable/ic_action_settings" />
<Preference
android:layout="@layout/list_item_divider"
android:selectable="false" />
<PreferenceCategory
android:key="application_profiles"
android:layout="@layout/preference_category_with_descr"
@ -33,4 +37,8 @@
android:title="@string/manage_profiles"
tools:icon="@drawable/ic_action_manage_profiles" />
<Preference
android:layout="@layout/card_bottom_divider"
android:selectable="false" />
</PreferenceScreen>

View file

@ -34,6 +34,10 @@
android:layout="@layout/preference_switch"
android:title="@string/speak_pedestrian" />
<Preference
android:layout="@layout/simple_divider_item"
android:selectable="false" />
<SwitchPreference
android:dependency="speak_routing_alarms"
android:key="speak_speed_limit"
@ -46,6 +50,10 @@
android:layout="@layout/preference_with_descr"
android:title="@string/speed_limit_exceed" />
<Preference
android:layout="@layout/simple_divider_item"
android:selectable="false" />
<SwitchPreference
android:dependency="speak_routing_alarms"
android:key="speak_cameras"
@ -76,6 +84,10 @@
android:layout="@layout/preference_switch"
android:title="@string/speak_poi" />
<Preference
android:layout="@layout/simple_divider_item"
android:selectable="false" />
<net.osmand.plus.settings.preferences.ListPreferenceEx
android:dependency="speak_routing_alarms"
android:key="keep_informing"
@ -88,6 +100,10 @@
android:layout="@layout/preference_with_descr"
android:title="@string/arrival_distance" />
<Preference
android:layout="@layout/simple_divider_item"
android:selectable="false" />
<PreferenceCategory
android:key="language_and_output"
android:layout="@layout/preference_category_with_descr"

View file

@ -1944,7 +1944,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
Fragment fragment = Fragment.instantiate(this, fragmentName);
getSupportFragmentManager().beginTransaction()
.add(R.id.fragmentContainer, fragment, fragmentName)
.replace(R.id.fragmentContainer, fragment, fragmentName)
.addToBackStack(fragmentName)
.commitAllowingStateLoss();

View file

@ -5,6 +5,7 @@ import android.content.Context;
import android.graphics.drawable.Drawable;
import android.support.annotation.NonNull;
import android.support.v4.view.ViewCompat;
import android.support.v7.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -45,6 +46,7 @@ public class QuickSearchListAdapter extends ArrayAdapter<QuickSearchListItem> {
private OsmandApplication app;
private Activity activity;
private AccessibilityAssistant accessibilityAssistant;
private LayoutInflater inflater;
private boolean useMapCenter;
@ -70,6 +72,11 @@ public class QuickSearchListAdapter extends ArrayAdapter<QuickSearchListItem> {
super(app, R.layout.search_list_item);
this.app = app;
this.activity = activity;
int themeRes = !app.getSettings().isLightContent() ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
Context themedContext = new ContextThemeWrapper(activity, themeRes);
this.inflater = activity.getLayoutInflater().cloneInContext(themedContext);
dp56 = AndroidUtils.dpToPx(app, 56f);
dp1 = AndroidUtils.dpToPx(app, 1f);
updateLocationViewCache = app.getUIUtilities().getUpdateLocationViewCache();
@ -192,7 +199,6 @@ public class QuickSearchListAdapter extends ArrayAdapter<QuickSearchListItem> {
LinearLayout view;
if (type == QuickSearchListItemType.SEARCH_MORE) {
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) app.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = (LinearLayout) inflater.inflate(R.layout.search_more_list_item, null);
} else {
view = (LinearLayout) convertView;
@ -257,10 +263,7 @@ public class QuickSearchListAdapter extends ArrayAdapter<QuickSearchListItem> {
}
} else if (type == QuickSearchListItemType.BUTTON) {
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) app
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = (LinearLayout) inflater.inflate(
R.layout.search_custom_list_item, null);
view = (LinearLayout) inflater.inflate(R.layout.search_custom_list_item, null);
} else {
view = (LinearLayout) convertView;
}
@ -272,10 +275,7 @@ public class QuickSearchListAdapter extends ArrayAdapter<QuickSearchListItem> {
}
} else if (type == QuickSearchListItemType.SELECT_ALL) {
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) app
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = (LinearLayout) inflater.inflate(
R.layout.select_all_list_item, null);
view = (LinearLayout) inflater.inflate(R.layout.select_all_list_item, null);
} else {
view = (LinearLayout) convertView;
}
@ -291,10 +291,7 @@ public class QuickSearchListAdapter extends ArrayAdapter<QuickSearchListItem> {
});
} else if (type == QuickSearchListItemType.HEADER) {
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) app
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = (LinearLayout) inflater.inflate(
R.layout.search_header_list_item, null);
view = (LinearLayout) inflater.inflate(R.layout.search_header_list_item, null);
} else {
view = (LinearLayout) convertView;
}
@ -307,30 +304,21 @@ public class QuickSearchListAdapter extends ArrayAdapter<QuickSearchListItem> {
}
} else if (type == QuickSearchListItemType.TOP_SHADOW) {
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) app
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = (LinearLayout) inflater.inflate(
R.layout.list_shadow_header, null);
view = (LinearLayout) inflater.inflate(R.layout.list_shadow_header, null);
} else {
view = (LinearLayout) convertView;
}
return view;
} else if (type == QuickSearchListItemType.BOTTOM_SHADOW) {
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) app
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = (LinearLayout) inflater.inflate(
R.layout.list_shadow_footer, null);
view = (LinearLayout) inflater.inflate(R.layout.list_shadow_footer, null);
} else {
view = (LinearLayout) convertView;
}
return view;
} else {
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) app
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = (LinearLayout) inflater.inflate(
R.layout.search_list_item, null);
view = (LinearLayout) inflater.inflate(R.layout.search_list_item, null);
} else {
view = (LinearLayout) convertView;
}

View file

@ -58,7 +58,6 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
protected OsmandApplication app;
protected OsmandSettings settings;
protected UiUtilities iconsCache;
protected List<ApplicationMode> modes = new ArrayList<ApplicationMode>();
private boolean nightMode;
private boolean wasDrawerDisabled;
@ -67,28 +66,43 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
public void onCreate(Bundle savedInstanceState) {
app = requireMyApplication();
settings = app.getSettings();
nightMode = !settings.isLightContent();
super.onCreate(savedInstanceState);
modes.clear();
modes.addAll(ApplicationMode.values(app));
}
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
getPreferenceManager().setPreferenceDataStore(settings.getDataStore());
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = super.onCreateView(inflater, container, savedInstanceState);
nightMode = !settings.isLightContent();
View view = super.onCreateView(inflater, container, savedInstanceState);
if (view != null) {
AndroidUtils.addStatusBarPadding21v(getContext(), view);
createToolbar(inflater, view);
setDivider(null);
updateAllSettings();
}
return view;
}
@Override
public RecyclerView onCreateRecyclerView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {
int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
Context themedContext = new ContextThemeWrapper(getActivity(), themeRes);
LayoutInflater themedInflater = inflater.cloneInContext(themedContext);
return super.onCreateRecyclerView(themedInflater, parent, savedInstanceState);
}
@Override
public void onResume() {
super.onResume();
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
wasDrawerDisabled = mapActivity.isDrawerDisabled();
@ -114,7 +128,7 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
if (toolbarRes != -1) {
Context activityContext = getActivity();
final int themeRes = nightMode ? darkTheme : lightTheme;
final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
final Context themedContext = new ContextThemeWrapper(activityContext, themeRes);
LayoutInflater themedInflater = LayoutInflater.from(themedContext);
@ -176,27 +190,6 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
view.setBackgroundColor(ContextCompat.getColor(app, getBackgroundColor()));
}
int darkTheme = R.style.OsmandDarkTheme;
int lightTheme = R.style.OsmandLightTheme;
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
getPreferenceManager().setPreferenceDataStore(settings.getDataStore());
updatePreferencesScreen();
}
@Override
public RecyclerView onCreateRecyclerView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {
Context activityContext = getActivity();
final int themeRes = nightMode ? darkTheme : lightTheme;
final Context themedContext = new ContextThemeWrapper(activityContext, themeRes);
LayoutInflater themedInflater = LayoutInflater.from(themedContext);
return super.onCreateRecyclerView(themedInflater, parent, savedInstanceState);
}
protected abstract void setupPreferences();
private void updatePreferencesScreen() {
@ -253,7 +246,7 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
singleSelectDialogBuilder.setAdapter(modeNames, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
ApplicationMode selectedAppMode = modes.get(which);
ApplicationMode selectedAppMode = ApplicationMode.values(app).get(which);
requireSettings().APPLICATION_MODE.set(selectedAppMode);
updateAllSettings();
}
@ -278,7 +271,10 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
public void updateAllSettings() {
getListView().getRecycledViewPool().clear();
getPreferenceScreen().removeAll();
PreferenceScreen screen = getPreferenceScreen();
if (screen != null) {
getPreferenceScreen().removeAll();
}
updatePreferencesScreen();
updateToolbar(getView());
}

View file

@ -52,6 +52,7 @@ public class ConfigureProfileFragment extends BaseSettingsFragment {
protected void setupPreferences() {
Preference generalSettings = findPreference("general_settings");
Preference pluginSettings = findPreference("plugin_settings");
pluginSettings.setIconSpaceReserved(false);
generalSettings.setIcon(getContentIcon(R.drawable.ic_action_settings));
@ -125,7 +126,7 @@ public class ConfigureProfileFragment extends BaseSettingsFragment {
private Drawable getPluginIcon(OsmandPlugin plugin) {
int iconResId = plugin.getLogoResourceId();
return plugin.isActive() ? getActiveIcon(iconResId) : getContentIcon(iconResId);
return plugin.isActive() ? getActiveIcon(iconResId) : getIcon(iconResId, isNightMode() ? R.color.icon_color_secondary_dark : R.color.icon_color_secondary_light);
}
private Intent getPluginIntent(OsmandPlugin plugin) {

View file

@ -52,10 +52,6 @@ public class GeneralProfileSettingsFragment extends BaseSettingsFragment {
Preference unitsAndFormats = findPreference("units_and_formats");
Preference other = findPreference("other");
appearanceCategory.setIconSpaceReserved(true);
unitsAndFormats.setIconSpaceReserved(true);
other.setIconSpaceReserved(true);
setupAppThemePref();
setupRotateMapPref();
setupMapScreenOrientationPref();
@ -68,7 +64,6 @@ public class GeneralProfileSettingsFragment extends BaseSettingsFragment {
setupKalmanFilterPref();
setupMagneticFieldSensorPref();
setupMapEmptyStateAllowedPref();
setupDoNotUseAnimationsPref();
setupExternalInputDevicePref();
}
@ -175,31 +170,22 @@ public class GeneralProfileSettingsFragment extends BaseSettingsFragment {
SwitchPreferenceEx kalmanFilterPref = (SwitchPreferenceEx) findPreference(settings.USE_KALMAN_FILTER_FOR_COMPASS.getId());
kalmanFilterPref.setTitle(getString(R.string.use_kalman_filter_compass));
kalmanFilterPref.setDescription(getString(R.string.use_kalman_filter_compass_descr));
kalmanFilterPref.setIconSpaceReserved(true);
}
private void setupMagneticFieldSensorPref() {
SwitchPreferenceEx useMagneticSensorPref = (SwitchPreferenceEx) findPreference(settings.USE_MAGNETIC_FIELD_SENSOR_COMPASS.getId());
useMagneticSensorPref.setTitle(getString(R.string.use_magnetic_sensor));
useMagneticSensorPref.setDescription(getString(R.string.use_magnetic_sensor_descr));
useMagneticSensorPref.setIconSpaceReserved(true);
}
private void setupMapEmptyStateAllowedPref() {
SwitchPreferenceEx mapEmptyStateAllowedPref = (SwitchPreferenceEx) findPreference(settings.MAP_EMPTY_STATE_ALLOWED.getId());
mapEmptyStateAllowedPref.setTitle(getString(R.string.tap_on_map_to_hide_interface));
mapEmptyStateAllowedPref.setDescription(getString(R.string.tap_on_map_to_hide_interface_descr));
mapEmptyStateAllowedPref.setIconSpaceReserved(true);
}
private void setupDoNotUseAnimationsPref() {
SwitchPreference doNotUseAnimations = (SwitchPreference) findPreference(settings.DO_NOT_USE_ANIMATIONS.getId());
doNotUseAnimations.setIconSpaceReserved(true);
}
private void setupExternalInputDevicePref() {
ListPreferenceEx externalInputDevice = (ListPreferenceEx) findPreference(settings.EXTERNAL_INPUT_DEVICE.getId());
externalInputDevice.setIconSpaceReserved(true);
externalInputDevice.setEntries(new String[]{
getString(R.string.sett_no_ext_input),
getString(R.string.sett_generic_ext_input),

View file

@ -9,6 +9,7 @@ import android.util.Pair;
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.SettingsGeneralActivity;
import net.osmand.plus.dialogs.SendAnalyticsBottomSheetDialogFragment;
@ -41,7 +42,7 @@ public class GlobalSettingsFragment extends BaseSettingsFragment implements Send
protected void setupPreferences() {
setupDefaultAppModePref();
setupPreferredLocalePref();
// setupExternalStorageDirPref();
setupExternalStorageDirPref();
setupSendAnonymousDataPref();
setupEnableProxyPref();
@ -147,6 +148,12 @@ public class GlobalSettingsFragment extends BaseSettingsFragment implements Send
}
}
private void setupExternalStorageDirPref() {
Preference externalStorageDir = (Preference) findPreference(OsmandSettings.EXTERNAL_STORAGE_DIR);
externalStorageDir.setIcon(getContentIcon(R.drawable.ic_action_folder));
}
private void setupSendAnonymousDataPref() {
boolean enabled = settings.SEND_ANONYMOUS_MAP_DOWNLOADS_DATA.get() || settings.SEND_ANONYMOUS_APP_USAGE_DATA.get();

View file

@ -45,9 +45,6 @@ public class MainSettingsFragment extends BaseSettingsFragment {
Preference globalSettings = findPreference("global_settings");
globalSettings.setIcon(getContentIcon(R.drawable.ic_action_settings));
PreferenceCategory applicationProfiles = (PreferenceCategory) findPreference("application_profiles");
applicationProfiles.setIconSpaceReserved(true);
setupConfigureProfilePref();
setupManageProfilesPref();
}

View file

@ -29,8 +29,6 @@ public class NavigationFragment extends BaseSettingsFragment {
Preference routeParameters = findPreference("route_parameters");
SwitchPreference showRoutingAlarms = (SwitchPreference) findPreference(settings.SHOW_ROUTING_ALARMS.getId());
SwitchPreference speakRoutingAlarms = (SwitchPreference) findPreference(settings.SPEAK_ROUTING_ALARMS.getId());
Preference mapDuringNavigation = findPreference("map_during_navigation");
mapDuringNavigation.setIconSpaceReserved(true);
SwitchPreference turnScreenOn = (SwitchPreference) findPreference(settings.TURN_SCREEN_ON_ENABLED.getId());

View file

@ -43,7 +43,6 @@ public class ProxySettingsFragment extends BaseSettingsFragment {
hostPref.setPersistent(false);
hostPref.setSummary(settings.PROXY_HOST.get());
hostPref.setDescription(R.string.proxy_host_descr);
hostPref.setIconSpaceReserved(true);
}
private void setupProxyPortPref() {
@ -51,7 +50,6 @@ public class ProxySettingsFragment extends BaseSettingsFragment {
portPref.setPersistent(false);
portPref.setSummary(String.valueOf(settings.PROXY_PORT.get()));
portPref.setDescription(R.string.proxy_port_descr);
portPref.setIconSpaceReserved(true);
}
@Override

View file

@ -67,7 +67,7 @@ public class RouteParametersFragment extends BaseSettingsFragment {
}
private void setupTimeConditionalRoutingPref() {
SwitchPreference timeConditionalRouting = createSwitchPreferenceEx(settings.ENABLE_TIME_CONDITIONAL_ROUTING.getId(), R.string.temporary_conditional_routing, R.layout.preference_dialog_and_switch);
SwitchPreference timeConditionalRouting = createSwitchPreferenceEx(settings.ENABLE_TIME_CONDITIONAL_ROUTING.getId(), R.string.temporary_conditional_routing, R.layout.preference_with_descr_dialog_and_switch);
timeConditionalRouting.setIcon(getRoutingPrefIcon(settings.ENABLE_TIME_CONDITIONAL_ROUTING.getId()));
timeConditionalRouting.setSummaryOn(R.string.shared_string_enable);
timeConditionalRouting.setSummaryOff(R.string.shared_string_disable);
@ -81,7 +81,7 @@ public class RouteParametersFragment extends BaseSettingsFragment {
}
PreferenceScreen screen = getPreferenceScreen();
SwitchPreferenceEx fastRoute = createSwitchPreferenceEx(app.getSettings().FAST_ROUTE_MODE.getId(), R.string.fast_route_mode, R.layout.preference_dialog_and_switch);
SwitchPreferenceEx fastRoute = createSwitchPreferenceEx(app.getSettings().FAST_ROUTE_MODE.getId(), R.string.fast_route_mode, R.layout.preference_with_descr_dialog_and_switch);
fastRoute.setIcon(getRoutingPrefIcon(app.getSettings().FAST_ROUTE_MODE.getId()));
fastRoute.setDescription(getString(R.string.fast_route_mode_descr));
fastRoute.setSummaryOn(R.string.shared_string_enable);
@ -142,7 +142,6 @@ public class RouteParametersFragment extends BaseSettingsFragment {
avoidRouting.setEntries(entries);
avoidRouting.setEntryValues(prefsIds);
avoidRouting.setValues(enabledPrefsIds);
avoidRouting.setIconSpaceReserved(true);
screen.addPreference(avoidRouting);
}
@ -187,7 +186,7 @@ public class RouteParametersFragment extends BaseSettingsFragment {
if (p.getType() == GeneralRouter.RoutingParameterType.BOOLEAN) {
OsmandSettings.OsmandPreference pref = settings.getCustomRoutingBooleanProperty(p.getId(), p.getDefaultBoolean());
SwitchPreferenceEx switchPreferenceEx = (SwitchPreferenceEx) createSwitchPreferenceEx(pref.getId(), title, description, R.layout.preference_dialog_and_switch);
SwitchPreferenceEx switchPreferenceEx = (SwitchPreferenceEx) createSwitchPreferenceEx(pref.getId(), title, description, R.layout.preference_with_descr_dialog_and_switch);
switchPreferenceEx.setDescription(description);
switchPreferenceEx.setIcon(getRoutingPrefIcon(p.getId()));
switchPreferenceEx.setSummaryOn(R.string.shared_string_enable);

View file

@ -46,33 +46,9 @@ public class VoiceAnnouncesFragment extends BaseSettingsFragment {
Preference voiceAnnouncesInfo = findPreference("voice_announces_info");
voiceAnnouncesInfo.setIcon(getContentIcon(R.drawable.ic_action_info_dark));
Preference languageAndOutput = findPreference("language_and_output");
SwitchPreference speakStreetNames = (SwitchPreference) findPreference(settings.SPEAK_STREET_NAMES.getId());
SwitchPreference speakTrafficWarnings = (SwitchPreference) findPreference(settings.SPEAK_TRAFFIC_WARNINGS.getId());
SwitchPreference speakPedestrian = (SwitchPreference) findPreference(settings.SPEAK_PEDESTRIAN.getId());
SwitchPreference speakSpeedLimit = (SwitchPreference) findPreference(settings.SPEAK_SPEED_LIMIT.getId());
speakStreetNames.setIconSpaceReserved(true);
speakTrafficWarnings.setIconSpaceReserved(true);
speakPedestrian.setIconSpaceReserved(true);
speakSpeedLimit.setIconSpaceReserved(true);
languageAndOutput.setIconSpaceReserved(true);
setupSpeedLimitExceedPref();
SwitchPreference speakSpeedCamera = (SwitchPreference) findPreference(settings.SPEAK_SPEED_CAMERA.getId());
SwitchPreference speakTunnels = (SwitchPreference) findPreference(settings.SPEAK_TUNNELS.getId());
SwitchPreference announceWpt = (SwitchPreference) findPreference(settings.ANNOUNCE_WPT.getId());
SwitchPreference announceNearbyFavorites = (SwitchPreference) findPreference(settings.ANNOUNCE_NEARBY_FAVORITES.getId());
SwitchPreference announceNearbyPoi = (SwitchPreference) findPreference(settings.ANNOUNCE_NEARBY_POI.getId());
speakSpeedCamera.setIconSpaceReserved(true);
speakTunnels.setIconSpaceReserved(true);
announceWpt.setIconSpaceReserved(true);
announceNearbyFavorites.setIconSpaceReserved(true);
announceNearbyPoi.setIconSpaceReserved(true);
setupKeepInformingPref();
setupArrivalAnnouncementPref();
setupVoiceProviderPref();
@ -111,7 +87,6 @@ public class VoiceAnnouncesFragment extends BaseSettingsFragment {
ListPreferenceEx voiceProvider = (ListPreferenceEx) findPreference(settings.SPEED_LIMIT_EXCEED.getId());
voiceProvider.setEntries(speedLimitNames);
voiceProvider.setEntryValues(speedLimitValues);
voiceProvider.setIconSpaceReserved(true);
}
private void setupKeepInformingPref() {
@ -125,7 +100,6 @@ public class VoiceAnnouncesFragment extends BaseSettingsFragment {
ListPreferenceEx keepInforming = (ListPreferenceEx) findPreference(settings.KEEP_INFORMING.getId());
keepInforming.setEntries(keepInformingNames);
keepInforming.setEntryValues(keepInformingValues);
keepInforming.setIconSpaceReserved(true);
}
private void setupArrivalAnnouncementPref() {
@ -140,7 +114,6 @@ public class VoiceAnnouncesFragment extends BaseSettingsFragment {
ListPreferenceEx arrivalDistanceFactor = (ListPreferenceEx) findPreference(settings.ARRIVAL_DISTANCE_FACTOR.getId());
arrivalDistanceFactor.setEntries(arrivalNames);
arrivalDistanceFactor.setEntryValues(arrivalValues);
arrivalDistanceFactor.setIconSpaceReserved(true);
}
private void setupVoiceProviderPref() {