Preferences ui improvements initial commit

This commit is contained in:
Chumva 2019-09-11 18:58:31 +03:00
parent 6b3dfbe0a3
commit a4c2a79ac6
16 changed files with 200 additions and 114 deletions

View file

@ -7,6 +7,7 @@
android:gravity="center_vertical">
<LinearLayout
android:id="@+id/selectable_list_item"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground">

View file

@ -7,6 +7,7 @@
android:gravity="center_vertical">
<LinearLayout
android:id="@+id/selectable_list_item"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground"

View file

@ -7,6 +7,7 @@
android:gravity="center_vertical">
<LinearLayout
android:id="@+id/selectable_list_item"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground"

View file

@ -7,6 +7,7 @@
android:gravity="center_vertical">
<LinearLayout
android:id="@+id/selectable_list_item"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground"

View file

@ -7,6 +7,7 @@
android:gravity="center_vertical">
<LinearLayout
android:id="@+id/selectable_list_item"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground">

View file

@ -50,15 +50,14 @@
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginLeft="@dimen/content_padding_half"
android:layout_marginRight="@dimen/content_padding_half"
android:background="@drawable/bg_transparent_rounded_profile">
android:layout_marginRight="@dimen/content_padding_half">
<ImageView
android:id="@+id/profile_icon"
android:layout_width="@dimen/standard_icon_size"
android:layout_height="@dimen/standard_icon_size"
android:layout_gravity="center"
android:src="@drawable/ic_action_car_dark"
tools:src="@drawable/ic_action_car_dark"
tools:tint="@color/active_color_primary_light" />
</FrameLayout>

View file

@ -196,13 +196,12 @@ public class ContextMenuAdapter {
desc.setText(item.getDescription());
}
if (layoutId == R.layout.main_menu_drawer_btn_configure_profile) {
int colorAlpha50 = UiUtilities.getColorWithAlpha(colorNoAlpha, 0.5f);
View fatDivider = convertView.findViewById(R.id.fatDivider);
fatDivider.setBackgroundColor(colorAlpha50);
fatDivider.setBackgroundColor(colorNoAlpha);
}
int colorListBackground = ContextCompat.getColor(app, lightTheme ? R.color.list_background_color_light : R.color.list_background_color_dark);
convertView.setBackgroundDrawable(UiUtilities.getAlphaStateDrawable(colorListBackground, colorNoAlpha, true, true));
// convertView.setBackgroundDrawable(UiUtilities.getAlphaStateDrawable(colorListBackground, colorNoAlpha));
return convertView;
}
if (layoutId == R.layout.help_to_improve_item) {

View file

@ -3,11 +3,11 @@ package net.osmand.plus;
import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.Color;
import android.graphics.PorterDuff;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
import android.graphics.drawable.RippleDrawable;
import android.graphics.drawable.StateListDrawable;
import android.hardware.Sensor;
import android.hardware.SensorManager;
import android.os.Build;
@ -17,6 +17,7 @@ import android.support.annotation.DrawableRes;
import android.support.annotation.StringRes;
import android.support.v4.content.ContextCompat;
import android.support.v4.graphics.drawable.DrawableCompat;
import android.support.v4.graphics.drawable.TintAwareDrawable;
import android.support.v7.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.View;
@ -109,6 +110,41 @@ public class UiUtilities {
return getDrawable(id, light ? R.color.icon_color_default_light : R.color.icon_color_default_dark);
}
public Drawable colorDrawable(Drawable drawable, int color) {
Drawable wrappedDrawable = DrawableCompat.wrap(drawable);
DrawableCompat.setTint(wrappedDrawable.mutate(), color);
return wrappedDrawable;
}
public static void setBackgroundDrawable(View view, Drawable drawable) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
view.setBackgroundDrawable(drawable);
} else {
view.setBackground(drawable);
}
}
public Drawable setRippleColor(@DrawableRes int id, int rippleColor) {
return setRippleColor(getIcon(id), rippleColor);
}
public Drawable setRippleColor(Drawable drawable, int rippleColor) {
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP && drawable instanceof RippleDrawable) {
((RippleDrawable) drawable).setColor(ColorStateList.valueOf(rippleColor));
} else {
if (drawable != null) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
drawable.setTintList(ColorStateList.valueOf(rippleColor));
} else if (drawable instanceof TintAwareDrawable) {
((TintAwareDrawable) drawable).setTintList(ColorStateList.valueOf(rippleColor));
} else {
drawable.setColorFilter(rippleColor, PorterDuff.Mode.DST_ATOP);
}
}
}
return drawable;
}
@ColorRes
public static int getDefaultColorRes(Context context) {
final OsmandApplication app = (OsmandApplication) context.getApplicationContext();
@ -156,33 +192,16 @@ public class UiUtilities {
return a << ALPHA_CHANNEL | r << RED_CHANNEL | g << GREEN_CHANNEL | b << BLUE_CHANNEL;
}
public static Drawable getAlphaStateDrawable(@ColorInt int colorNoAlpha) {
return getAlphaStateDrawable(colorNoAlpha, false, true);
}
public static Drawable getAlphaStateDrawable(@ColorInt int colorNoAlpha, boolean highlightOnNormal, boolean highlightOnPressed) {
int colorAlpha25 = getColorWithAlpha(colorNoAlpha, 0.25f);
int colorAlpha30 = getColorWithAlpha(colorNoAlpha, 0.3f);
return getAlphaStateDrawableImpl(colorAlpha25, colorAlpha30, highlightOnNormal, highlightOnPressed);
public static Drawable getAlphaStateDrawable(@ColorInt int colorNoAlpha, float normalAlphaRatio, float pressedAlphaRatio) {
int colorAlpha25 = getColorWithAlpha(colorNoAlpha, normalAlphaRatio);
int colorAlpha30 = getColorWithAlpha(colorNoAlpha, pressedAlphaRatio);
return AndroidUtils.createPressedStateListDrawable(new ColorDrawable(colorAlpha25), new ColorDrawable(colorAlpha30));
}
public static Drawable getAlphaStateDrawable(@ColorInt int colorBackground, @ColorInt int colorForeground, boolean highlightOnNormal, boolean highlightOnPressed) {
public static Drawable getAlphaStateDrawable(@ColorInt int colorBackground, @ColorInt int colorForeground) {
int colorAlpha25 = UiUtilities.mixTwoColors(colorForeground, colorBackground, 0.125f);
int colorAlpha30 = UiUtilities.mixTwoColors(colorForeground, colorBackground, 0.15f);
return getAlphaStateDrawableImpl(colorAlpha25, colorAlpha30, highlightOnNormal, highlightOnPressed);
}
private static Drawable getAlphaStateDrawableImpl(@ColorInt int colorMode1, @ColorInt int colorMode2, boolean highlightOnNormal, boolean highlightOnPressed) {
StateListDrawable sld = new StateListDrawable();
if (highlightOnNormal && highlightOnPressed) {
sld.addState(new int[]{android.R.attr.state_pressed}, new ColorDrawable(colorMode2));
sld.addState(new int[]{}, new ColorDrawable(colorMode1));
} else if (highlightOnPressed) {
sld.addState(new int[]{android.R.attr.state_pressed}, new ColorDrawable(colorMode1));
} else if (highlightOnNormal) {
sld.addState(new int[]{}, new ColorDrawable(colorMode1));
}
return sld;
return AndroidUtils.createPressedStateListDrawable(new ColorDrawable(colorAlpha25), new ColorDrawable(colorAlpha30));
}
public UpdateLocationViewCache getUpdateLocationViewCache(){

View file

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

View file

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

View file

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

View file

@ -106,7 +106,7 @@ public class SelectProfileMenuAdapter extends AbstractProfileMenuAdapter<SelectP
//set up cell color
int colorNoAlpha = ContextCompat.getColor(app, profileColorResId);
boolean selectedMode = app.getSettings().APPLICATION_MODE.get() == item;
holder.profileOptions.setBackgroundDrawable(UiUtilities.getAlphaStateDrawable(colorNoAlpha, selectedMode, true));
holder.profileOptions.setBackgroundDrawable(UiUtilities.getAlphaStateDrawable(colorNoAlpha, selectedMode ? 0.25f : 0, 0.3f));
updateViewHolder(holder, item);
} else {

View file

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

View file

@ -1,9 +1,10 @@
package net.osmand.plus.settings;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.RippleDrawable;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.ColorRes;
@ -17,12 +18,13 @@ import android.support.v14.preference.SwitchPreference;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AlertDialog;
import android.support.v7.preference.EditTextPreference;
import android.support.v7.preference.ListPreference;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceFragmentCompat;
import android.support.v7.preference.PreferenceGroupAdapter;
import android.support.v7.preference.PreferenceScreen;
import android.support.v7.preference.PreferenceViewHolder;
import android.support.v7.view.ContextThemeWrapper;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
@ -32,6 +34,7 @@ import android.widget.ImageView;
import android.widget.TextView;
import net.osmand.AndroidUtils;
import net.osmand.PlatformUtil;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
@ -40,8 +43,7 @@ import net.osmand.plus.UiUtilities;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.OsmandActionBarActivity;
import net.osmand.plus.activities.OsmandInAppPurchaseActivity;
import net.osmand.plus.profiles.AppProfileArrayAdapter;
import net.osmand.plus.profiles.ProfileDataObject;
import net.osmand.plus.profiles.SelectAppModesBottomSheetDialogFragment;
import net.osmand.plus.settings.bottomsheets.BooleanPreferenceBottomSheet;
import net.osmand.plus.settings.bottomsheets.EditTextPreferenceBottomSheet;
import net.osmand.plus.settings.bottomsheets.MultiSelectPreferencesBottomSheet;
@ -50,10 +52,11 @@ import net.osmand.plus.settings.preferences.ListPreferenceEx;
import net.osmand.plus.settings.preferences.MultiSelectBooleanPreference;
import net.osmand.plus.settings.preferences.SwitchPreferenceEx;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.logging.Log;
public abstract class BaseSettingsFragment extends PreferenceFragmentCompat implements Preference.OnPreferenceChangeListener, Preference.OnPreferenceClickListener {
public abstract class BaseSettingsFragment extends PreferenceFragmentCompat implements Preference.OnPreferenceChangeListener, Preference.OnPreferenceClickListener, SelectAppModesBottomSheetDialogFragment.AppModeChangedListener {
private final Log log = PlatformUtil.getLog(this.getClass());
protected OsmandApplication app;
protected OsmandSettings settings;
@ -99,6 +102,45 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
return super.onCreateRecyclerView(themedInflater, parent, savedInstanceState);
}
@SuppressLint("RestrictedApi")
@Override
protected RecyclerView.Adapter onCreateAdapter(PreferenceScreen preferenceScreen) {
return new PreferenceGroupAdapter(preferenceScreen) {
@Override
public void onBindViewHolder(PreferenceViewHolder holder, int position) {
super.onBindViewHolder(holder, position);
if (BaseSettingsFragment.this.getClass().equals(ConfigureProfileFragment.class)) {
View selectableView = holder.itemView.findViewById(R.id.selectable_list_item);
if (selectableView != null) {
Drawable selectableBg = selectableView.getBackground();
int color = ContextCompat.getColor(app, getActiveProfileColor());
int colorWithAlpha;
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP && selectableBg instanceof RippleDrawable) {
colorWithAlpha = UiUtilities.getColorWithAlpha(color, 0.4f);
}else {
colorWithAlpha = UiUtilities.getColorWithAlpha(color, 0.2f);
}
if (selectableBg != null) {
Drawable drawable = app.getUIUtilities().setRippleColor(selectableBg, colorWithAlpha);
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
selectableView.setBackground(drawable);
} else {
selectableView.setBackgroundDrawable(drawable);
}
selectableView.invalidate();
}
}
}
}
};
}
@Override
public void onResume() {
super.onResume();
@ -146,10 +188,40 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
});
View switchProfile = view.findViewById(R.id.switch_profile_button);
if (switchProfile != null) {
if (this.getClass().equals(ConfigureProfileFragment.class)) {
int drawableId;
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
drawableId = nightMode ? R.drawable.ripple_dark : R.drawable.ripple_light;
} else {
drawableId = nightMode ? R.drawable.btn_border_trans_dark : R.drawable.btn_border_trans_light;
}
int color = ContextCompat.getColor(app, getActiveProfileColor());
int colorWithAlpha = UiUtilities.getColorWithAlpha(color, 0.40f);
Drawable drawable = app.getUIUtilities().setRippleColor(drawableId, colorWithAlpha);
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
switchProfile.setBackground(drawable);
} else {
switchProfile.setBackgroundDrawable(drawable);
}
} else {
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
AndroidUtils.setBackground(app, switchProfile, nightMode, R.drawable.ripple_light, R.drawable.ripple_dark);
} else {
AndroidUtils.setBackground(app, switchProfile, nightMode, R.drawable.btn_border_trans_light, R.drawable.btn_border_trans_dark);
}
}
switchProfile.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
selectAppModeDialog().show();
FragmentManager fragmentManager = getFragmentManager();
if (fragmentManager != null) {
SelectAppModesBottomSheetDialogFragment.showInstance(fragmentManager, BaseSettingsFragment.this);
}
}
});
}
@ -213,64 +285,7 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
}
}
protected AlertDialog.Builder selectAppModeDialog() {
AlertDialog.Builder singleSelectDialogBuilder = new AlertDialog.Builder(getContext());
singleSelectDialogBuilder.setTitle(R.string.profile_settings);
final List<ProfileDataObject> activeModes = new ArrayList<>();
for (ApplicationMode am : ApplicationMode.values(getMyApplication())) {
boolean isSelected = false;
if (am == getSelectedAppMode()) {
isSelected = true;
}
activeModes.add(new ProfileDataObject(
am.toHumanString(getMyApplication()),
getAppModeDescription(am),
am.getStringKey(),
am.getIconRes(),
isSelected,
am.getIconColorInfo()
));
}
final AppProfileArrayAdapter modeNames = new AppProfileArrayAdapter(
getActivity(), R.layout.bottom_sheet_item_with_descr_and_radio_btn, activeModes, true);
singleSelectDialogBuilder.setNegativeButton(R.string.shared_string_cancel,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
singleSelectDialogBuilder.setAdapter(modeNames, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
ApplicationMode selectedAppMode = ApplicationMode.values(app).get(which);
requireSettings().APPLICATION_MODE.set(selectedAppMode);
updateAllSettings();
}
});
return singleSelectDialogBuilder;
}
private String getAppModeDescription(ApplicationMode mode) {
String descr;
if (!mode.isCustomProfile()) {
descr = getString(R.string.profile_type_base_string);
} else {
descr = String.format(getString(R.string.profile_type_descr_string),
mode.getParent().toHumanString(getMyApplication()));
if (mode.getRoutingProfile() != null && mode.getRoutingProfile().contains("/")) {
descr = descr.concat(", " + mode.getRoutingProfile()
.substring(0, mode.getRoutingProfile().indexOf("/")));
}
}
return descr;
}
public void updateAllSettings() {
getListView().getRecycledViewPool().clear();
PreferenceScreen screen = getPreferenceScreen();
if (screen != null) {
getPreferenceScreen().removeAll();
@ -463,6 +478,11 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
return false;
}
@Override
public void onAppModeChanged() {
updateAllSettings();
}
public SwitchPreference createSwitchPreference(OsmandSettings.OsmandPreference<Boolean> b, int title, int summary, int layoutId) {
return createSwitchPreference(b, getString(title), getString(summary), layoutId);
}

View file

@ -1,5 +1,7 @@
package net.osmand.plus.settings;
import android.content.Context;
import android.net.Uri;
import android.support.annotation.NonNull;
import android.support.v4.app.FragmentManager;
import android.support.v7.preference.CheckBoxPreference;
@ -17,19 +19,21 @@ import android.text.style.ClickableSpan;
import android.view.MotionEvent;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
import net.osmand.Location;
import net.osmand.data.PointDescription;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.R;
import net.osmand.plus.settings.bottomsheets.ChangeGeneralProfilesPrefBottomSheet;
import net.osmand.plus.wikipedia.WikipediaDialogFragment;
public class CoordinatesFormatFragment extends BaseSettingsFragment {
public static final String TAG = "CoordinatesFormatFragment";
private static final String UTM_FORMAT_WIKI_LINK = "https://en.wikipedia.org/wiki/Universal_Transverse_Mercator_coordinate_system";
private static final String FORMAT_DEGREES = "format_degrees";
private static final String FORMAT_MINUTES = "format_minutes";
private static final String FORMAT_SECONDS = "format_seconds";
@ -162,7 +166,10 @@ public class CoordinatesFormatFragment extends BaseSettingsFragment {
ClickableSpan clickableSpan = new ClickableSpan() {
@Override
public void onClick(@NonNull View widget) {
Toast.makeText(widget.getContext(), getString(R.string.shared_string_read_more), Toast.LENGTH_LONG).show();
Context ctx = getContext();
if (ctx != null) {
WikipediaDialogFragment.showFullArticle(ctx, Uri.parse(UTM_FORMAT_WIKI_LINK), isNightMode());
}
}
@Override

View file

@ -1,10 +1,10 @@
package net.osmand.plus.settings;
import android.content.Context;
import android.content.DialogInterface;
import android.content.pm.ActivityInfo;
import android.graphics.drawable.Drawable;
import android.support.annotation.NonNull;
import android.support.v14.preference.SwitchPreference;
import android.support.v4.app.FragmentManager;
import android.support.v7.app.AlertDialog;
import android.support.v7.preference.Preference;
@ -48,6 +48,10 @@ public class GeneralProfileSettingsFragment extends BaseSettingsFragment {
@Override
protected void setupPreferences() {
Context ctx = getContext();
if (ctx == null) {
return;
}
Preference appearanceCategory = findPreference("appearance_category");
Preference unitsAndFormats = findPreference("units_and_formats");
Preference other = findPreference("other");
@ -68,9 +72,9 @@ public class GeneralProfileSettingsFragment extends BaseSettingsFragment {
}
private void setupAppThemePref() {
final ListPreferenceEx appTheme = (ListPreferenceEx) findPreference(settings.OSMAND_THEME.getId());
appTheme.setEntries(new String[]{getString(R.string.dark_theme), getString(R.string.light_theme)});
appTheme.setEntryValues(new Integer[]{OsmandSettings.OSMAND_DARK_THEME, OsmandSettings.OSMAND_LIGHT_THEME});
ListPreferenceEx appTheme = (ListPreferenceEx) findPreference(settings.OSMAND_THEME.getId());
appTheme.setEntries(new String[] {getString(R.string.dark_theme), getString(R.string.light_theme)});
appTheme.setEntryValues(new Integer[] {OsmandSettings.OSMAND_DARK_THEME, OsmandSettings.OSMAND_LIGHT_THEME});
appTheme.setIcon(getOsmandThemeIcon());
}
@ -79,9 +83,9 @@ public class GeneralProfileSettingsFragment extends BaseSettingsFragment {
}
private void setupRotateMapPref() {
final ListPreferenceEx rotateMap = (ListPreferenceEx) findPreference(settings.ROTATE_MAP.getId());
rotateMap.setEntries(new String[]{getString(R.string.rotate_map_none_opt), getString(R.string.rotate_map_bearing_opt), getString(R.string.rotate_map_compass_opt)});
rotateMap.setEntryValues(new Integer[]{OsmandSettings.ROTATE_MAP_NONE, OsmandSettings.ROTATE_MAP_BEARING, OsmandSettings.ROTATE_MAP_COMPASS});
ListPreferenceEx rotateMap = (ListPreferenceEx) findPreference(settings.ROTATE_MAP.getId());
rotateMap.setEntries(new String[] {getString(R.string.rotate_map_none_opt), getString(R.string.rotate_map_bearing_opt), getString(R.string.rotate_map_compass_opt)});
rotateMap.setEntryValues(new Integer[] {OsmandSettings.ROTATE_MAP_NONE, OsmandSettings.ROTATE_MAP_BEARING, OsmandSettings.ROTATE_MAP_COMPASS});
rotateMap.setIcon(getRotateMapIcon());
}
@ -97,9 +101,9 @@ public class GeneralProfileSettingsFragment extends BaseSettingsFragment {
}
private void setupMapScreenOrientationPref() {
final ListPreferenceEx mapScreenOrientation = (ListPreferenceEx) findPreference(settings.MAP_SCREEN_ORIENTATION.getId());
mapScreenOrientation.setEntries(new String[]{getString(R.string.map_orientation_portrait), getString(R.string.map_orientation_landscape), getString(R.string.map_orientation_default)});
mapScreenOrientation.setEntryValues(new Integer[]{ActivityInfo.SCREEN_ORIENTATION_PORTRAIT, ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE, ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED});
ListPreferenceEx mapScreenOrientation = (ListPreferenceEx) findPreference(settings.MAP_SCREEN_ORIENTATION.getId());
mapScreenOrientation.setEntries(new String[] {getString(R.string.map_orientation_portrait), getString(R.string.map_orientation_landscape), getString(R.string.map_orientation_default)});
mapScreenOrientation.setEntryValues(new Integer[] {ActivityInfo.SCREEN_ORIENTATION_PORTRAIT, ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE, ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED});
mapScreenOrientation.setIcon(getMapScreenOrientationIcon());
}
@ -186,14 +190,14 @@ public class GeneralProfileSettingsFragment extends BaseSettingsFragment {
private void setupExternalInputDevicePref() {
ListPreferenceEx externalInputDevice = (ListPreferenceEx) findPreference(settings.EXTERNAL_INPUT_DEVICE.getId());
externalInputDevice.setEntries(new String[]{
externalInputDevice.setEntries(new String[] {
getString(R.string.sett_no_ext_input),
getString(R.string.sett_generic_ext_input),
getString(R.string.sett_wunderlinq_ext_input),
getString(R.string.sett_parrot_ext_input)
});
externalInputDevice.setEntryValues(new Integer[]{
externalInputDevice.setEntryValues(new Integer[] {
OsmandSettings.NO_EXTERNAL_DEVICE,
OsmandSettings.GENERIC_EXTERNAL_DEVICE,
OsmandSettings.WUNDERLINQ_EXTERNAL_DEVICE,