commit
3f0725a253
18 changed files with 255 additions and 98 deletions
|
@ -298,6 +298,10 @@ public class AndroidUtils {
|
|||
return createStateListDrawable(normal, pressed, android.R.attr.state_pressed);
|
||||
}
|
||||
|
||||
public static StateListDrawable createEnabledStateListDrawable(Drawable disabled, Drawable enabled) {
|
||||
return createStateListDrawable(disabled, enabled, android.R.attr.state_enabled);
|
||||
}
|
||||
|
||||
private static StateListDrawable createStateListDrawable(Drawable normal, Drawable stateDrawable, int state) {
|
||||
StateListDrawable res = new StateListDrawable();
|
||||
res.addState(new int[]{state}, stateDrawable);
|
||||
|
|
|
@ -144,6 +144,10 @@ public class UiUtilities {
|
|||
return drawable;
|
||||
}
|
||||
|
||||
public static Drawable createTintedDrawable(Context context, @DrawableRes int resId, int color) {
|
||||
return tintDrawable(ContextCompat.getDrawable(context, resId), color);
|
||||
}
|
||||
|
||||
public static Drawable tintDrawable(Drawable drawable, int color) {
|
||||
Drawable coloredDrawable = null;
|
||||
if (drawable != null) {
|
||||
|
|
|
@ -1230,6 +1230,9 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
|||
boolean editToShow = settings.getAndClearEditObjectToShow();
|
||||
int status = settings.isRouteToPointNavigateAndClear();
|
||||
String searchRequestToShow = settings.getAndClearSearchRequestToShow();
|
||||
if (status != 0 || searchRequestToShow != null || latLonToShow != null) {
|
||||
dismissSettingsScreens();
|
||||
}
|
||||
if (status != 0) {
|
||||
// always enable and follow and let calculate it (i.e.GPS is not accessible in a garage)
|
||||
Location loc = new Location("map");
|
||||
|
|
|
@ -11,6 +11,7 @@ import android.hardware.Camera;
|
|||
import android.media.CamcorderProfile;
|
||||
import android.media.MediaRecorder;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.StatFs;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.ActivityCompat;
|
||||
|
@ -27,6 +28,7 @@ import net.osmand.plus.OsmAndAppCustomization;
|
|||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.UiUtilities;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.helpers.FontCache;
|
||||
import net.osmand.plus.profiles.SelectCopyAppModeBottomSheet;
|
||||
import net.osmand.plus.profiles.SelectCopyAppModeBottomSheet.CopyAppModePrefsListener;
|
||||
|
@ -52,6 +54,7 @@ import static net.osmand.plus.audionotes.AudioVideoNotesPlugin.AV_CAMERA_FOCUS_I
|
|||
import static net.osmand.plus.audionotes.AudioVideoNotesPlugin.AV_CAMERA_FOCUS_MACRO;
|
||||
import static net.osmand.plus.audionotes.AudioVideoNotesPlugin.NOTES_TAB;
|
||||
import static net.osmand.plus.audionotes.AudioVideoNotesPlugin.cameraPictureSizeDefault;
|
||||
import static net.osmand.plus.myplaces.FavoritesActivity.TAB_ID;
|
||||
|
||||
public class MultimediaNotesFragment extends BaseSettingsFragment implements CopyAppModePrefsListener, ResetAppModePrefsListener {
|
||||
|
||||
|
@ -113,14 +116,14 @@ public class MultimediaNotesFragment extends BaseSettingsFragment implements Cop
|
|||
private void setupExternalPhotoCamPref(Camera cam, AudioVideoNotesPlugin plugin) {
|
||||
SwitchPreferenceEx externalPhotoCam = (SwitchPreferenceEx) findPreference(plugin.AV_EXTERNAL_PHOTO_CAM.getId());
|
||||
externalPhotoCam.setDescription(getString(R.string.av_use_external_camera_descr));
|
||||
externalPhotoCam.setIcon(getActiveIcon(R.drawable.ic_action_photo_dark));
|
||||
externalPhotoCam.setIcon(getPersistentPrefIcon(R.drawable.ic_action_photo_dark));
|
||||
externalPhotoCam.setEnabled(cam != null);
|
||||
}
|
||||
|
||||
private void setupCameraPictureSizePref(Camera cam, AudioVideoNotesPlugin plugin) {
|
||||
ListPreferenceEx cameraPictureSize = (ListPreferenceEx) findPreference(plugin.AV_CAMERA_PICTURE_SIZE.getId());
|
||||
cameraPictureSize.setDescription(R.string.av_camera_pic_size_descr);
|
||||
cameraPictureSize.setIcon(getActiveIcon(R.drawable.ic_action_picture_size));
|
||||
cameraPictureSize.setIcon(getPersistentPrefIcon(R.drawable.ic_action_picture_size));
|
||||
|
||||
if (cam == null) {
|
||||
cameraPictureSize.setEnabled(false);
|
||||
|
@ -192,7 +195,7 @@ public class MultimediaNotesFragment extends BaseSettingsFragment implements Cop
|
|||
private void setupCameraFocusTypePref(Camera cam, AudioVideoNotesPlugin plugin) {
|
||||
ListPreferenceEx cameraFocusType = (ListPreferenceEx) findPreference(plugin.AV_CAMERA_FOCUS_TYPE.getId());
|
||||
cameraFocusType.setDescription(R.string.av_camera_focus_descr);
|
||||
cameraFocusType.setIcon(getActiveIcon(R.drawable.ic_action_camera_focus));
|
||||
cameraFocusType.setIcon(getPersistentPrefIcon(R.drawable.ic_action_camera_focus));
|
||||
|
||||
if (cam == null) {
|
||||
cameraFocusType.setEnabled(false);
|
||||
|
@ -243,7 +246,7 @@ public class MultimediaNotesFragment extends BaseSettingsFragment implements Cop
|
|||
private void setupPhotoPlaySoundPref(Camera cam, AudioVideoNotesPlugin plugin) {
|
||||
SwitchPreferenceEx photoPlaySound = (SwitchPreferenceEx) findPreference(plugin.AV_PHOTO_PLAY_SOUND.getId());
|
||||
photoPlaySound.setDescription(getString(R.string.av_photo_play_sound_descr));
|
||||
photoPlaySound.setIcon(getContentIcon(R.drawable.ic_action_music_off));
|
||||
photoPlaySound.setIcon(getPersistentPrefIcon(R.drawable.ic_action_music_off));
|
||||
photoPlaySound.setEnabled(cam != null);
|
||||
}
|
||||
|
||||
|
@ -270,7 +273,7 @@ public class MultimediaNotesFragment extends BaseSettingsFragment implements Cop
|
|||
private void setupExternalRecorderPref(AudioVideoNotesPlugin plugin) {
|
||||
SwitchPreferenceEx externalRecorder = (SwitchPreferenceEx) findPreference(plugin.AV_EXTERNAL_RECORDER.getId());
|
||||
externalRecorder.setDescription(getString(R.string.av_use_external_recorder_descr));
|
||||
externalRecorder.setIcon(getContentIcon(R.drawable.ic_action_video_dark));
|
||||
externalRecorder.setIcon(getPersistentPrefIcon(R.drawable.ic_action_video_dark));
|
||||
}
|
||||
|
||||
private void setupVideoQualityPref(AudioVideoNotesPlugin plugin) {
|
||||
|
@ -308,7 +311,7 @@ public class MultimediaNotesFragment extends BaseSettingsFragment implements Cop
|
|||
videoQuality.setEntries(entries);
|
||||
videoQuality.setEntryValues(entryValues);
|
||||
videoQuality.setDescription(R.string.av_video_quality_descr);
|
||||
videoQuality.setIcon(getContentIcon(R.drawable.ic_action_picture_size));
|
||||
videoQuality.setIcon(getActiveIcon(R.drawable.ic_action_picture_size));
|
||||
}
|
||||
|
||||
private void setupRecorderSplitPref(AudioVideoNotesPlugin plugin) {
|
||||
|
@ -366,7 +369,7 @@ public class MultimediaNotesFragment extends BaseSettingsFragment implements Cop
|
|||
storageSize.setEntries(entries);
|
||||
storageSize.setEntryValues(entryValues);
|
||||
storageSize.setDescription(R.string.rec_split_storage_size_desc);
|
||||
storageSize.setIcon(getContentIcon(R.drawable.ic_sdcard));
|
||||
storageSize.setIcon(getActiveIcon(R.drawable.ic_sdcard));
|
||||
} else {
|
||||
storageSize.setVisible(false);
|
||||
}
|
||||
|
@ -404,10 +407,13 @@ public class MultimediaNotesFragment extends BaseSettingsFragment implements Cop
|
|||
public boolean onPreferenceClick(Preference preference) {
|
||||
String prefId = preference.getKey();
|
||||
if (OPEN_NOTES.equals(prefId)) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putInt(TAB_ID, NOTES_TAB);
|
||||
|
||||
OsmAndAppCustomization appCustomization = app.getAppCustomization();
|
||||
Intent favorites = new Intent(preference.getContext(), appCustomization.getFavoritesActivity());
|
||||
favorites.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||
app.getSettings().FAVORITES_TAB.set(NOTES_TAB);
|
||||
favorites.putExtra(MapActivity.INTENT_PARAMS, bundle);
|
||||
startActivity(favorites);
|
||||
return true;
|
||||
} else if (COPY_PLUGIN_SETTINGS.equals(prefId)) {
|
||||
|
|
|
@ -82,7 +82,6 @@ import net.osmand.plus.srtmplugin.SRTMPlugin;
|
|||
import net.osmand.plus.views.DownloadedRegionsLayer;
|
||||
import net.osmand.plus.views.MapInfoLayer;
|
||||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
import net.osmand.plus.views.controls.DynamicListView;
|
||||
import net.osmand.plus.views.mapwidgets.MapWidgetRegistry;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
@ -224,6 +223,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, IRouteInfo
|
|||
@Override
|
||||
public void onClick(View v) {
|
||||
hideDashboard();
|
||||
mapActivity.dismissSettingsScreens();
|
||||
}
|
||||
};
|
||||
toolbar = ((Toolbar) dashboardView.findViewById(R.id.toolbar));
|
||||
|
@ -1041,21 +1041,22 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, IRouteInfo
|
|||
|
||||
public boolean onBackPressed() {
|
||||
if (isVisible()) {
|
||||
backPressed();
|
||||
return true;
|
||||
return backPressed();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void backPressed() {
|
||||
private boolean backPressed() {
|
||||
if (previousVisibleType != visibleType && previousVisibleType != null) {
|
||||
if (visibleType == DashboardType.MAPILLARY) {
|
||||
hideKeyboard();
|
||||
}
|
||||
visibleType = null;
|
||||
setDashboardVisibility(true, previousVisibleType);
|
||||
return true;
|
||||
} else {
|
||||
hideDashboard();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,16 +2,20 @@ package net.osmand.plus.monitoring;
|
|||
|
||||
import android.content.Intent;
|
||||
import android.graphics.Typeface;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.text.SpannableString;
|
||||
import android.text.SpannableStringBuilder;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.OsmAndAppCustomization;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.helpers.FontCache;
|
||||
import net.osmand.plus.myplaces.FavoritesActivity;
|
||||
import net.osmand.plus.profiles.SelectCopyAppModeBottomSheet;
|
||||
|
@ -33,6 +37,7 @@ import static net.osmand.plus.OsmandSettings.MONTHLY_DIRECTORY;
|
|||
import static net.osmand.plus.OsmandSettings.REC_DIRECTORY;
|
||||
import static net.osmand.plus.monitoring.OsmandMonitoringPlugin.MINUTES;
|
||||
import static net.osmand.plus.monitoring.OsmandMonitoringPlugin.SECONDS;
|
||||
import static net.osmand.plus.myplaces.FavoritesActivity.TAB_ID;
|
||||
|
||||
public class MonitoringSettingsFragment extends BaseSettingsFragment implements CopyAppModePrefsListener, ResetAppModePrefsListener {
|
||||
|
||||
|
@ -68,7 +73,7 @@ public class MonitoringSettingsFragment extends BaseSettingsFragment implements
|
|||
private void setupSaveTrackToGpxPref() {
|
||||
SwitchPreferenceEx saveTrackToGpx = (SwitchPreferenceEx) findPreference(settings.SAVE_TRACK_TO_GPX.getId());
|
||||
saveTrackToGpx.setDescription(getString(R.string.save_track_to_gpx_descrp));
|
||||
saveTrackToGpx.setIcon(getContentIcon(R.drawable.ic_action_gdirections_dark));
|
||||
saveTrackToGpx.setIcon(getPersistentPrefIcon(R.drawable.ic_action_gdirections_dark));
|
||||
}
|
||||
|
||||
private void setupSaveTrackIntervalPref() {
|
||||
|
@ -190,7 +195,7 @@ public class MonitoringSettingsFragment extends BaseSettingsFragment implements
|
|||
private void setupShowTripRecNotificationPref() {
|
||||
SwitchPreferenceEx showTripRecNotification = (SwitchPreferenceEx) findPreference(settings.SHOW_TRIP_REC_NOTIFICATION.getId());
|
||||
showTripRecNotification.setDescription(getString(R.string.trip_rec_notification_settings));
|
||||
showTripRecNotification.setIcon(getContentIcon(R.drawable.ic_action_notification));
|
||||
showTripRecNotification.setIcon(getPersistentPrefIcon(R.drawable.ic_action_notification));
|
||||
}
|
||||
|
||||
private void setupTrackStorageDirectoryPref() {
|
||||
|
@ -208,9 +213,13 @@ public class MonitoringSettingsFragment extends BaseSettingsFragment implements
|
|||
}
|
||||
|
||||
private void setupLiveMonitoringPref() {
|
||||
Drawable disabled = getContentIcon(R.drawable.ic_action_offline);
|
||||
Drawable enabled = getActiveIcon(R.drawable.ic_world_globe_dark);
|
||||
Drawable icon = AndroidUtils.createEnabledStateListDrawable(disabled, enabled);
|
||||
|
||||
SwitchPreferenceEx liveMonitoring = (SwitchPreferenceEx) findPreference(settings.LIVE_MONITORING.getId());
|
||||
liveMonitoring.setDescription(getString(R.string.live_monitoring_m_descr));
|
||||
liveMonitoring.setIcon(getContentIcon(R.drawable.ic_world_globe_dark));
|
||||
liveMonitoring.setIcon(icon);
|
||||
}
|
||||
|
||||
private void setupOpenNotesDescrPref() {
|
||||
|
@ -245,10 +254,13 @@ public class MonitoringSettingsFragment extends BaseSettingsFragment implements
|
|||
public boolean onPreferenceClick(Preference preference) {
|
||||
String prefId = preference.getKey();
|
||||
if (OPEN_TRACKS.equals(prefId)) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putInt(TAB_ID, FavoritesActivity.GPX_TAB);
|
||||
|
||||
OsmAndAppCustomization appCustomization = app.getAppCustomization();
|
||||
Intent favorites = new Intent(preference.getContext(), appCustomization.getFavoritesActivity());
|
||||
favorites.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||
app.getSettings().FAVORITES_TAB.set(FavoritesActivity.GPX_TAB);
|
||||
favorites.putExtra(MapActivity.INTENT_PARAMS, bundle);
|
||||
startActivity(favorites);
|
||||
return true;
|
||||
} else if (COPY_PLUGIN_SETTINGS.equals(prefId)) {
|
||||
|
|
|
@ -3,6 +3,7 @@ package net.osmand.plus.osmedit;
|
|||
import android.content.Intent;
|
||||
import android.graphics.Typeface;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.PreferenceViewHolder;
|
||||
|
@ -11,8 +12,10 @@ import android.view.LayoutInflater;
|
|||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.plus.OsmAndAppCustomization;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||
import net.osmand.plus.helpers.FontCache;
|
||||
import net.osmand.plus.settings.BaseSettingsFragment;
|
||||
|
@ -21,6 +24,9 @@ import net.osmand.plus.settings.bottomsheets.OsmLoginDataBottomSheet;
|
|||
import net.osmand.plus.settings.preferences.SwitchPreferenceEx;
|
||||
import net.osmand.plus.widgets.style.CustomTypefaceSpan;
|
||||
|
||||
import static net.osmand.plus.myplaces.FavoritesActivity.TAB_ID;
|
||||
import static net.osmand.plus.osmedit.OsmEditingPlugin.OSM_EDIT_TAB;
|
||||
|
||||
public class OsmEditingFragment extends BaseSettingsFragment implements OnPreferenceChanged {
|
||||
|
||||
private static final String OSM_EDITING_INFO = "osm_editing_info";
|
||||
|
@ -63,13 +69,13 @@ public class OsmEditingFragment extends BaseSettingsFragment implements OnPrefer
|
|||
}
|
||||
|
||||
private void setupOfflineEditingPref() {
|
||||
Drawable disabled = getContentIcon(R.drawable.ic_action_offline);
|
||||
Drawable enabled = getActiveIcon(R.drawable.ic_world_globe_dark);
|
||||
Drawable icon = AndroidUtils.createEnabledStateListDrawable(disabled, enabled);
|
||||
|
||||
SwitchPreferenceEx offlineEditingPref = (SwitchPreferenceEx) findPreference(settings.OFFLINE_EDITION.getId());
|
||||
offlineEditingPref.setDescription(getString(R.string.offline_edition_descr));
|
||||
offlineEditingPref.setIcon(getOfflineEditingIcon(settings.OFFLINE_EDITION.get()));
|
||||
}
|
||||
|
||||
private Drawable getOfflineEditingIcon(boolean enabled) {
|
||||
return enabled ? getActiveIcon(R.drawable.ic_world_globe_dark) : getContentIcon(R.drawable.ic_action_offline);
|
||||
offlineEditingPref.setIcon(icon);
|
||||
}
|
||||
|
||||
private void setupOsmEditsDescrPref() {
|
||||
|
@ -93,10 +99,13 @@ public class OsmEditingFragment extends BaseSettingsFragment implements OnPrefer
|
|||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
if (OPEN_OSM_EDITS.equals(preference.getKey())) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putInt(TAB_ID, OSM_EDIT_TAB);
|
||||
|
||||
OsmAndAppCustomization appCustomization = app.getAppCustomization();
|
||||
Intent favorites = new Intent(preference.getContext(), appCustomization.getFavoritesActivity());
|
||||
favorites.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||
app.getSettings().FAVORITES_TAB.set(R.string.osm_edits);
|
||||
favorites.putExtra(MapActivity.INTENT_PARAMS, bundle);
|
||||
startActivity(favorites);
|
||||
return true;
|
||||
} else if (OSM_LOGIN_DATA.equals(preference.getKey())) {
|
||||
|
@ -109,14 +118,6 @@ public class OsmEditingFragment extends BaseSettingsFragment implements OnPrefer
|
|||
return super.onPreferenceClick(preference);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
if (settings.OFFLINE_EDITION.getId().equals(preference.getKey()) && newValue instanceof Boolean) {
|
||||
preference.setIcon(getOfflineEditingIcon((Boolean) newValue));
|
||||
}
|
||||
return super.onPreferenceChange(preference, newValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPreferenceChanged(String prefId) {
|
||||
if (OSM_LOGIN_DATA.equals(prefId)) {
|
||||
|
|
|
@ -13,6 +13,7 @@ import android.support.annotation.DrawableRes;
|
|||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.design.widget.AppBarLayout;
|
||||
import android.support.v14.preference.MultiSelectListPreference;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
|
@ -23,6 +24,7 @@ import android.support.v7.preference.ListPreference;
|
|||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.Preference.OnPreferenceChangeListener;
|
||||
import android.support.v7.preference.Preference.OnPreferenceClickListener;
|
||||
import android.support.v7.preference.PreferenceCategory;
|
||||
import android.support.v7.preference.PreferenceFragmentCompat;
|
||||
import android.support.v7.preference.PreferenceGroup;
|
||||
import android.support.v7.preference.PreferenceGroupAdapter;
|
||||
|
@ -30,6 +32,7 @@ import android.support.v7.preference.PreferenceManager;
|
|||
import android.support.v7.preference.PreferenceScreen;
|
||||
import android.support.v7.preference.PreferenceViewHolder;
|
||||
import android.support.v7.preference.SwitchPreferenceCompat;
|
||||
import android.support.v7.preference.TwoStatePreference;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
@ -376,17 +379,34 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
|
|||
AndroidUtils.setBackground(selectableView, drawable);
|
||||
}
|
||||
}
|
||||
TextView tvPreferenceTitle = (TextView) holder.itemView.findViewById(android.R.id.title);
|
||||
if (tvPreferenceTitle != null) {
|
||||
tvPreferenceTitle.setSingleLine(false);
|
||||
TextView titleView = (TextView) holder.findViewById(android.R.id.title);
|
||||
if (titleView != null) {
|
||||
titleView.setSingleLine(false);
|
||||
}
|
||||
boolean enabled = preference.isEnabled();
|
||||
if (currentScreenType.profileDependent) {
|
||||
View cb = holder.itemView.findViewById(R.id.switchWidget);
|
||||
if (cb == null) {
|
||||
cb = holder.findViewById(android.R.id.checkbox);
|
||||
}
|
||||
if (cb instanceof CompoundButton) {
|
||||
UiUtilities.setupCompoundButton(isNightMode(), getActiveProfileColor(), (CompoundButton) cb);
|
||||
int color = enabled ? getActiveProfileColor() : getDisabledTextColor();
|
||||
UiUtilities.setupCompoundButton(isNightMode(), color, (CompoundButton) cb);
|
||||
}
|
||||
}
|
||||
if ((preference.isPersistent() || preference instanceof TwoStatePreference) && !(preference instanceof PreferenceCategory)) {
|
||||
if (titleView != null) {
|
||||
titleView.setTextColor(enabled ? getActiveTextColor() : getDisabledTextColor());
|
||||
}
|
||||
if (preference instanceof TwoStatePreference) {
|
||||
enabled = enabled & ((TwoStatePreference) preference).isChecked();
|
||||
}
|
||||
if (preference instanceof MultiSelectListPreference) {
|
||||
enabled = enabled & !((MultiSelectListPreference) preference).getValues().isEmpty();
|
||||
}
|
||||
ImageView imageView = (ImageView) holder.findViewById(android.R.id.icon);
|
||||
if (imageView != null) {
|
||||
imageView.setEnabled(enabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -578,6 +598,16 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
|
|||
return isNightMode() ? R.color.list_background_color_dark : R.color.list_background_color_light;
|
||||
}
|
||||
|
||||
@ColorInt
|
||||
protected int getActiveTextColor() {
|
||||
return ContextCompat.getColor(app, isNightMode() ? R.color.text_color_primary_dark : R.color.text_color_primary_light);
|
||||
}
|
||||
|
||||
@ColorInt
|
||||
protected int getDisabledTextColor() {
|
||||
return ContextCompat.getColor(app, isNightMode() ? R.color.text_color_secondary_dark : R.color.text_color_secondary_light);
|
||||
}
|
||||
|
||||
protected void registerPreference(Preference preference) {
|
||||
if (preference != null) {
|
||||
preference.setOnPreferenceChangeListener(this);
|
||||
|
@ -694,6 +724,12 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
|
|||
return cache != null ? cache.getPaintedIcon(id, color) : null;
|
||||
}
|
||||
|
||||
protected Drawable getPersistentPrefIcon(@DrawableRes int iconId) {
|
||||
Drawable disabled = UiUtilities.createTintedDrawable(app, iconId, ContextCompat.getColor(app, R.color.icon_color_default_light));
|
||||
Drawable enabled = UiUtilities.createTintedDrawable(app, iconId, getActiveProfileColor());
|
||||
return AndroidUtils.createEnabledStateListDrawable(disabled, enabled);
|
||||
}
|
||||
|
||||
public SwitchPreferenceCompat createSwitchPreference(OsmandSettings.OsmandPreference<Boolean> b, int title, int summary, int layoutId) {
|
||||
return createSwitchPreference(b, getString(title), getString(summary), layoutId);
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ import android.view.LayoutInflater;
|
|||
import android.view.View;
|
||||
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.settings.preferences.SwitchPreferenceEx;
|
||||
|
||||
public class DialogsAndNotificationsSettingsFragment extends BaseSettingsFragment {
|
||||
|
||||
|
@ -31,11 +30,12 @@ public class DialogsAndNotificationsSettingsFragment extends BaseSettingsFragmen
|
|||
boolean enabled = !settings.DO_NOT_SHOW_STARTUP_MESSAGES.get(); // pref ui was inverted
|
||||
SwitchPreferenceCompat sendAnonymousData = (SwitchPreferenceCompat) findPreference(settings.DO_NOT_SHOW_STARTUP_MESSAGES.getId());
|
||||
sendAnonymousData.setChecked(enabled);
|
||||
sendAnonymousData.setIcon(getPersistentPrefIcon(R.drawable.ic_action_notification));
|
||||
}
|
||||
|
||||
private void setupShowDownloadMapDialogPref() {
|
||||
SwitchPreferenceCompat showDownloadMapDialog = (SwitchPreferenceCompat) findPreference(settings.SHOW_DOWNLOAD_MAP_DIALOG.getId());
|
||||
showDownloadMapDialog.setIcon(getContentIcon(R.drawable.ic_action_import));
|
||||
showDownloadMapDialog.setIcon(getPersistentPrefIcon(R.drawable.ic_action_import));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -21,6 +21,7 @@ import android.widget.ArrayAdapter;
|
|||
import android.widget.CompoundButton;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
|
@ -102,7 +103,7 @@ public class GeneralProfileSettingsFragment extends BaseSettingsFragment impleme
|
|||
}
|
||||
|
||||
private Drawable getOsmandThemeIcon() {
|
||||
return getContentIcon(settings.isLightContent() ? R.drawable.ic_action_sun : R.drawable.ic_action_moon);
|
||||
return getActiveIcon(settings.isLightContent() ? R.drawable.ic_action_sun : R.drawable.ic_action_moon);
|
||||
}
|
||||
|
||||
private void setupRotateMapPref() {
|
||||
|
@ -115,22 +116,21 @@ public class GeneralProfileSettingsFragment extends BaseSettingsFragment impleme
|
|||
private Drawable getRotateMapIcon() {
|
||||
switch (settings.ROTATE_MAP.getModeValue(getSelectedAppMode())) {
|
||||
case OsmandSettings.ROTATE_MAP_NONE:
|
||||
return getContentIcon(R.drawable.ic_action_direction_north);
|
||||
return getActiveIcon(R.drawable.ic_action_direction_north);
|
||||
case OsmandSettings.ROTATE_MAP_BEARING:
|
||||
return getContentIcon(R.drawable.ic_action_direction_movement);
|
||||
return getActiveIcon(R.drawable.ic_action_direction_movement);
|
||||
default:
|
||||
return getContentIcon(R.drawable.ic_action_direction_compass);
|
||||
return getActiveIcon(R.drawable.ic_action_direction_compass);
|
||||
}
|
||||
}
|
||||
|
||||
private void setupCenterPositionOnMapPref() {
|
||||
Drawable disabled = getContentIcon(R.drawable.ic_action_display_position_bottom);
|
||||
Drawable enabled = getActiveIcon(R.drawable.ic_action_display_position_center);
|
||||
Drawable icon = AndroidUtils.createEnabledStateListDrawable(disabled, enabled);
|
||||
|
||||
SwitchPreferenceCompat centerPositionOnMap = (SwitchPreferenceCompat) findPreference(settings.CENTER_POSITION_ON_MAP.getId());
|
||||
centerPositionOnMap.setIcon(getCenterPositionOnMapIcon());
|
||||
}
|
||||
|
||||
|
||||
private Drawable getCenterPositionOnMapIcon() {
|
||||
return getContentIcon(settings.CENTER_POSITION_ON_MAP.getModeValue(getSelectedAppMode()) ? R.drawable.ic_action_display_position_center : R.drawable.ic_action_display_position_bottom);
|
||||
centerPositionOnMap.setIcon(icon);
|
||||
}
|
||||
|
||||
private void setupMapScreenOrientationPref() {
|
||||
|
@ -143,18 +143,18 @@ public class GeneralProfileSettingsFragment extends BaseSettingsFragment impleme
|
|||
private Drawable getMapScreenOrientationIcon() {
|
||||
switch (settings.MAP_SCREEN_ORIENTATION.getModeValue(getSelectedAppMode())) {
|
||||
case ActivityInfo.SCREEN_ORIENTATION_PORTRAIT:
|
||||
return getContentIcon(R.drawable.ic_action_phone_portrait_orientation);
|
||||
return getActiveIcon(R.drawable.ic_action_phone_portrait_orientation);
|
||||
case ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE:
|
||||
return getContentIcon(R.drawable.ic_action_phone_landscape_orientation);
|
||||
return getActiveIcon(R.drawable.ic_action_phone_landscape_orientation);
|
||||
default:
|
||||
return getContentIcon(R.drawable.ic_action_phone_device_orientation);
|
||||
return getActiveIcon(R.drawable.ic_action_phone_device_orientation);
|
||||
}
|
||||
}
|
||||
|
||||
private void setupDrivingRegionPref() {
|
||||
ApplicationMode selectedMode = getSelectedAppMode();
|
||||
Preference defaultDrivingRegion = findPreference(settings.DRIVING_REGION.getId());
|
||||
defaultDrivingRegion.setIcon(getContentIcon(R.drawable.ic_action_car_dark));
|
||||
defaultDrivingRegion.setIcon(getActiveIcon(R.drawable.ic_action_car_dark));
|
||||
defaultDrivingRegion.setSummary(getString(settings.DRIVING_REGION_AUTOMATIC.getModeValue(selectedMode) ? R.string.driving_region_automatic : settings.DRIVING_REGION.getModeValue(selectedMode).name));
|
||||
}
|
||||
|
||||
|
@ -171,12 +171,12 @@ public class GeneralProfileSettingsFragment extends BaseSettingsFragment impleme
|
|||
ListPreferenceEx unitsOfLength = (ListPreferenceEx) findPreference(settings.METRIC_SYSTEM.getId());
|
||||
unitsOfLength.setEntries(entries);
|
||||
unitsOfLength.setEntryValues(entryValues);
|
||||
unitsOfLength.setIcon(getContentIcon(R.drawable.ic_action_ruler_unit));
|
||||
unitsOfLength.setIcon(getActiveIcon(R.drawable.ic_action_ruler_unit));
|
||||
}
|
||||
|
||||
private void setupCoordinatesFormatPref() {
|
||||
Preference coordinatesFormat = findPreference(settings.COORDINATES_FORMAT.getId());
|
||||
coordinatesFormat.setIcon(getContentIcon(R.drawable.ic_action_coordinates_widget));
|
||||
coordinatesFormat.setIcon(getActiveIcon(R.drawable.ic_action_coordinates_widget));
|
||||
coordinatesFormat.setSummary(PointDescription.formatToHumanString(app, settings.COORDINATES_FORMAT.getModeValue(getSelectedAppMode())));
|
||||
}
|
||||
|
||||
|
@ -201,7 +201,7 @@ public class GeneralProfileSettingsFragment extends BaseSettingsFragment impleme
|
|||
ListPreferenceEx angularUnits = (ListPreferenceEx) findPreference(settings.ANGULAR_UNITS.getId());
|
||||
angularUnits.setEntries(entries);
|
||||
angularUnits.setEntryValues(entryValues);
|
||||
angularUnits.setIcon(getContentIcon(R.drawable.ic_action_angular_unit));
|
||||
angularUnits.setIcon(getActiveIcon(R.drawable.ic_action_angular_unit));
|
||||
}
|
||||
|
||||
private void setupSpeedSystemPref() {
|
||||
|
@ -218,7 +218,7 @@ public class GeneralProfileSettingsFragment extends BaseSettingsFragment impleme
|
|||
speedSystem.setEntries(entries);
|
||||
speedSystem.setEntryValues(entryValues);
|
||||
speedSystem.setDescription(R.string.default_speed_system_descr);
|
||||
speedSystem.setIcon(getContentIcon(R.drawable.ic_action_speed));
|
||||
speedSystem.setIcon(getActiveIcon(R.drawable.ic_action_speed));
|
||||
}
|
||||
|
||||
private void setupKalmanFilterPref() {
|
||||
|
@ -378,8 +378,6 @@ public class GeneralProfileSettingsFragment extends BaseSettingsFragment impleme
|
|||
preference.setIcon(getRotateMapIcon());
|
||||
} else if (settings.MAP_SCREEN_ORIENTATION.getId().equals(prefId)) {
|
||||
preference.setIcon(getMapScreenOrientationIcon());
|
||||
} else if (settings.CENTER_POSITION_ON_MAP.getId().equals(prefId)) {
|
||||
preference.setIcon(getCenterPositionOnMapIcon());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,8 +4,10 @@ import android.app.Activity;
|
|||
import android.content.Context;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.PreferenceViewHolder;
|
||||
import android.support.v7.preference.SwitchPreferenceCompat;
|
||||
import android.util.Pair;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
|
@ -50,6 +52,18 @@ public class GlobalSettingsFragment extends BaseSettingsFragment implements Send
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onBindPreferenceViewHolder(Preference preference, PreferenceViewHolder holder) {
|
||||
super.onBindPreferenceViewHolder(preference, holder);
|
||||
if (DIALOGS_AND_NOTIFICATIONS_PREF_ID.equals(preference.getKey())) {
|
||||
ImageView imageView = (ImageView) holder.findViewById(android.R.id.icon);
|
||||
if (imageView != null) {
|
||||
boolean enabled = preference.isEnabled() && (!settings.DO_NOT_SHOW_STARTUP_MESSAGES.get() || settings.SHOW_DOWNLOAD_MAP_DIALOG.get());
|
||||
imageView.setEnabled(enabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
String prefId = preference.getKey();
|
||||
|
@ -108,7 +122,7 @@ public class GlobalSettingsFragment extends BaseSettingsFragment implements Send
|
|||
}
|
||||
|
||||
ListPreferenceEx defaultApplicationMode = (ListPreferenceEx) findPreference(settings.DEFAULT_APPLICATION_MODE.getId());
|
||||
defaultApplicationMode.setIcon(getContentIcon(settings.DEFAULT_APPLICATION_MODE.get().getIconRes()));
|
||||
defaultApplicationMode.setIcon(getActiveIcon(settings.DEFAULT_APPLICATION_MODE.get().getIconRes()));
|
||||
defaultApplicationMode.setEntries(entries);
|
||||
defaultApplicationMode.setEntryValues(entryValues);
|
||||
}
|
||||
|
@ -119,7 +133,7 @@ public class GlobalSettingsFragment extends BaseSettingsFragment implements Send
|
|||
return;
|
||||
}
|
||||
ListPreferenceEx preferredLocale = (ListPreferenceEx) findPreference(settings.PREFERRED_LOCALE.getId());
|
||||
preferredLocale.setIcon(getContentIcon(R.drawable.ic_action_map_language));
|
||||
preferredLocale.setIcon(getActiveIcon(R.drawable.ic_action_map_language));
|
||||
preferredLocale.setSummary(settings.PREFERRED_LOCALE.get());
|
||||
|
||||
Pair<String[], String[]> preferredLocaleInfo = SettingsGeneralActivity.getPreferredLocaleIdsAndValues(ctx);
|
||||
|
@ -136,7 +150,7 @@ 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));
|
||||
externalStorageDir.setIcon(getActiveIcon(R.drawable.ic_action_folder));
|
||||
|
||||
DataStorageHelper holder = new DataStorageHelper(app);
|
||||
DataStorageMenuItem currentStorage = holder.getCurrentStorage();
|
||||
|
@ -164,16 +178,17 @@ public class GlobalSettingsFragment extends BaseSettingsFragment implements Send
|
|||
|
||||
SwitchPreferenceCompat sendAnonymousData = (SwitchPreferenceCompat) findPreference(SEND_ANONYMOUS_DATA_PREF_ID);
|
||||
sendAnonymousData.setChecked(enabled);
|
||||
sendAnonymousData.setIcon(getPersistentPrefIcon(R.drawable.ic_action_privacy_and_security));
|
||||
}
|
||||
|
||||
private void setupDialogsAndNotificationsPref() {
|
||||
Preference dialogsAndNotifications = (Preference) findPreference(DIALOGS_AND_NOTIFICATIONS_PREF_ID);
|
||||
dialogsAndNotifications.setIcon(getContentIcon(R.drawable.ic_action_notification));
|
||||
dialogsAndNotifications.setIcon(getPersistentPrefIcon(R.drawable.ic_action_notification));
|
||||
}
|
||||
|
||||
private void setupEnableProxyPref() {
|
||||
SwitchPreferenceEx enableProxy = (SwitchPreferenceEx) findPreference(settings.ENABLE_PROXY.getId());
|
||||
enableProxy.setIcon(getContentIcon(R.drawable.ic_action_proxy));
|
||||
enableProxy.setIcon(getPersistentPrefIcon(R.drawable.ic_action_proxy));
|
||||
}
|
||||
|
||||
private void setupUseSystemScreenTimeout() {
|
||||
|
|
|
@ -100,7 +100,7 @@ public class LiveMonitoringFragment extends BaseSettingsFragment {
|
|||
EditTextPreferenceEx liveMonitoringUrl = (EditTextPreferenceEx) findPreference(settings.LIVE_MONITORING_URL.getId());
|
||||
liveMonitoringUrl.setSummary(summary);
|
||||
liveMonitoringUrl.setDescription(R.string.live_monitoring_adress_descr);
|
||||
liveMonitoringUrl.setIcon(getContentIcon(R.drawable.ic_world_globe_dark));
|
||||
liveMonitoringUrl.setIcon(getPersistentPrefIcon(R.drawable.ic_world_globe_dark));
|
||||
}
|
||||
|
||||
private void setupLiveMonitoringIntervalPref() {
|
||||
|
@ -121,7 +121,7 @@ public class LiveMonitoringFragment extends BaseSettingsFragment {
|
|||
ListPreferenceEx liveMonitoringInterval = (ListPreferenceEx) findPreference(settings.LIVE_MONITORING_INTERVAL.getId());
|
||||
liveMonitoringInterval.setEntries(entries);
|
||||
liveMonitoringInterval.setEntryValues(entryValues);
|
||||
liveMonitoringInterval.setIcon(getContentIcon(R.drawable.ic_action_time_span));
|
||||
liveMonitoringInterval.setIcon(getPersistentPrefIcon(R.drawable.ic_action_time_span));
|
||||
liveMonitoringInterval.setDescription(R.string.live_monitoring_interval_descr);
|
||||
}
|
||||
|
||||
|
@ -138,7 +138,7 @@ public class LiveMonitoringFragment extends BaseSettingsFragment {
|
|||
ListPreferenceEx liveMonitoringBuffer = (ListPreferenceEx) findPreference(settings.LIVE_MONITORING_MAX_INTERVAL_TO_SEND.getId());
|
||||
liveMonitoringBuffer.setEntries(entries);
|
||||
liveMonitoringBuffer.setEntryValues(entryValues);
|
||||
liveMonitoringBuffer.setIcon(getContentIcon(R.drawable.ic_action_time_span));
|
||||
liveMonitoringBuffer.setIcon(getPersistentPrefIcon(R.drawable.ic_action_time_span));
|
||||
liveMonitoringBuffer.setDescription(R.string.live_monitoring_max_interval_to_send_desrc);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
package net.osmand.plus.settings;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.SwitchPreferenceCompat;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
|
@ -55,34 +57,44 @@ public class NavigationFragment extends BaseSettingsFragment {
|
|||
@Override
|
||||
protected void setupPreferences() {
|
||||
navigationType = findPreference(NAVIGATION_TYPE);
|
||||
setupNavigationTypePref();
|
||||
|
||||
Preference routeParameters = findPreference("route_parameters");
|
||||
SwitchPreferenceCompat showRoutingAlarms = (SwitchPreferenceCompat) findPreference(settings.SHOW_ROUTING_ALARMS.getId());
|
||||
SwitchPreferenceCompat speakRoutingAlarms = (SwitchPreferenceCompat) findPreference(settings.VOICE_MUTE.getId());
|
||||
SwitchPreferenceCompat turnScreenOn = (SwitchPreferenceCompat) findPreference(settings.TURN_SCREEN_ON_ENABLED.getId());
|
||||
SwitchPreferenceEx animateMyLocation = (SwitchPreferenceEx) findPreference(settings.ANIMATE_MY_LOCATION.getId());
|
||||
if (getSelectedAppMode().getRoutingProfile() != null) {
|
||||
GeneralRouter routingProfile = app.getRoutingConfig().getRouter(getSelectedAppMode().getRoutingProfile());
|
||||
if (routingProfile != null) {
|
||||
String profileNameUC = routingProfile.getProfileName().toUpperCase();
|
||||
if (RoutingProfilesResources.isRpValue(profileNameUC)) {
|
||||
RoutingProfilesResources routingProfilesResources = RoutingProfilesResources.valueOf(profileNameUC);
|
||||
navigationType.setSummary(routingProfilesResources.getStringRes());
|
||||
navigationType.setIcon(getContentIcon(routingProfilesResources.getIconRes()));
|
||||
} else {
|
||||
navigationType.setIcon(getContentIcon(R.drawable.ic_action_gdirections_dark));
|
||||
}
|
||||
}
|
||||
}
|
||||
routeParameters.setIcon(getContentIcon(R.drawable.ic_action_route_distance));
|
||||
showRoutingAlarms.setIcon(getContentIcon(R.drawable.ic_action_alert));
|
||||
speakRoutingAlarms.setIcon(getContentIcon(R.drawable.ic_action_volume_up));
|
||||
turnScreenOn.setIcon(getContentIcon(R.drawable.ic_action_turn_screen_on));
|
||||
|
||||
routeParameters.setIcon(getContentIcon(R.drawable.ic_action_route_distance));
|
||||
showRoutingAlarms.setIcon(getPersistentPrefIcon(R.drawable.ic_action_alert));
|
||||
turnScreenOn.setIcon(getPersistentPrefIcon(R.drawable.ic_action_turn_screen_on));
|
||||
|
||||
setupSpeakRoutingAlarmsPref();
|
||||
setupVehicleParametersPref();
|
||||
speakRoutingAlarms.setChecked(!settings.VOICE_MUTE.getModeValue(getSelectedAppMode()));
|
||||
|
||||
animateMyLocation.setDescription(getString(R.string.animate_my_location_desc));
|
||||
}
|
||||
|
||||
private void setupNavigationTypePref() {
|
||||
String routingProfileKey = getSelectedAppMode().getRoutingProfile();
|
||||
if (!Algorithms.isEmpty(routingProfileKey)) {
|
||||
RoutingProfileDataObject routingProfileDataObject = routingProfileDataObjects.get(routingProfileKey);
|
||||
if (routingProfileDataObject != null) {
|
||||
navigationType.setSummary(routingProfileDataObject.getName());
|
||||
navigationType.setIcon(getActiveIcon(routingProfileDataObject.getIconRes()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setupSpeakRoutingAlarmsPref() {
|
||||
Drawable disabled = getContentIcon(R.drawable.ic_action_volume_mute);
|
||||
Drawable enabled = getActiveIcon(R.drawable.ic_action_volume_up);
|
||||
Drawable icon = AndroidUtils.createEnabledStateListDrawable(disabled, enabled);
|
||||
|
||||
SwitchPreferenceCompat speakRoutingAlarms = (SwitchPreferenceCompat) findPreference(settings.VOICE_MUTE.getId());
|
||||
speakRoutingAlarms.setIcon(icon);
|
||||
speakRoutingAlarms.setChecked(!settings.VOICE_MUTE.getModeValue(getSelectedAppMode()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
String key = preference.getKey();
|
||||
|
@ -137,7 +149,7 @@ public class NavigationFragment extends BaseSettingsFragment {
|
|||
rp.getValue().setSelected(selected);
|
||||
}
|
||||
navigationType.setSummary(selectedRoutingProfileDataObject.getName());
|
||||
navigationType.setIcon(getContentIcon(selectedRoutingProfileDataObject.getIconRes()));
|
||||
navigationType.setIcon(getActiveIcon(selectedRoutingProfileDataObject.getIconRes()));
|
||||
|
||||
ApplicationMode appMode = getSelectedAppMode();
|
||||
RouteProvider.RouteService routeService;
|
||||
|
@ -177,7 +189,7 @@ public class NavigationFragment extends BaseSettingsFragment {
|
|||
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())){
|
||||
} else if (RoutingProfilesResources.isRpValue(name.toUpperCase())) {
|
||||
iconRes = RoutingProfilesResources.valueOf(name.toUpperCase()).getIconRes();
|
||||
name = context
|
||||
.getString(RoutingProfilesResources.valueOf(name.toUpperCase()).getStringRes());
|
||||
|
|
|
@ -9,6 +9,7 @@ import android.support.v7.preference.PreferenceScreen;
|
|||
import android.support.v7.preference.PreferenceViewHolder;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.StateChangedListener;
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
|
@ -339,6 +340,7 @@ public class RouteParametersFragment extends BaseSettingsFragment implements OnP
|
|||
multiSelectPref.setDescription(descr);
|
||||
multiSelectPref.setLayoutResource(R.layout.preference_with_descr);
|
||||
multiSelectPref.setIcon(getRoutingPrefIcon(groupKey));
|
||||
multiSelectPref.setIconSpaceReserved(true);
|
||||
|
||||
String[] entries = new String[routingParameters.size()];
|
||||
String[] prefsIds = new String[routingParameters.size()];
|
||||
|
@ -383,17 +385,24 @@ public class RouteParametersFragment extends BaseSettingsFragment implements OnP
|
|||
private Drawable getRoutingPrefIcon(String prefId) {
|
||||
switch (prefId) {
|
||||
case GeneralRouter.ALLOW_PRIVATE:
|
||||
return getContentIcon(R.drawable.ic_action_private_access);
|
||||
return getPersistentPrefIcon(R.drawable.ic_action_private_access);
|
||||
case GeneralRouter.USE_SHORTEST_WAY:
|
||||
return getContentIcon(R.drawable.ic_action_fuel);
|
||||
return getPersistentPrefIcon(R.drawable.ic_action_fuel);
|
||||
case GeneralRouter.ALLOW_MOTORWAYS:
|
||||
Drawable disabled = getContentIcon(R.drawable.ic_action_avoid_motorways);
|
||||
Drawable enabled = getActiveIcon(R.drawable.ic_action_motorways);
|
||||
return AndroidUtils.createEnabledStateListDrawable(disabled, enabled);
|
||||
case GeneralRouter.USE_HEIGHT_OBSTACLES:
|
||||
case RELIEF_SMOOTHNESS_FACTOR:
|
||||
return getPersistentPrefIcon(R.drawable.ic_action_elevation);
|
||||
case AVOID_ROUTING_PARAMETER_PREFIX:
|
||||
return getContentIcon(R.drawable.ic_action_alert);
|
||||
return getPersistentPrefIcon(R.drawable.ic_action_alert);
|
||||
case DRIVING_STYLE:
|
||||
return getContentIcon(R.drawable.ic_action_bicycle_dark);
|
||||
return getPersistentPrefIcon(R.drawable.ic_action_bicycle_dark);
|
||||
case "fast_route_mode":
|
||||
return getContentIcon(R.drawable.ic_action_fastest_route);
|
||||
return getPersistentPrefIcon(R.drawable.ic_action_fastest_route);
|
||||
case "enable_time_conditional_routing":
|
||||
return getContentIcon(R.drawable.ic_action_road_works_dark);
|
||||
return getPersistentPrefIcon(R.drawable.ic_action_road_works_dark);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -3,9 +3,11 @@ package net.osmand.plus.settings;
|
|||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.PreferenceViewHolder;
|
||||
import android.support.v7.widget.SwitchCompat;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
|
@ -47,6 +49,19 @@ public class TurnScreenOnFragment extends BaseSettingsFragment {
|
|||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onBindPreferenceViewHolder(Preference preference, PreferenceViewHolder holder) {
|
||||
super.onBindPreferenceViewHolder(preference, holder);
|
||||
if (settings.TURN_SCREEN_ON_TIME_INT.getId().equals(preference.getKey()) && preference instanceof ListPreferenceEx) {
|
||||
Object currentValue = ((ListPreferenceEx) preference).getValue();
|
||||
ImageView imageView = (ImageView) holder.findViewById(android.R.id.icon);
|
||||
if (imageView != null && currentValue instanceof Integer) {
|
||||
boolean enabled = preference.isEnabled() && (Integer) currentValue > 0;
|
||||
imageView.setEnabled(enabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateToolbar() {
|
||||
super.updateToolbar();
|
||||
|
@ -84,7 +99,7 @@ public class TurnScreenOnFragment extends BaseSettingsFragment {
|
|||
ListPreferenceEx turnScreenOnTime = (ListPreferenceEx) findPreference(settings.TURN_SCREEN_ON_TIME_INT.getId());
|
||||
turnScreenOnTime.setEntries(entries);
|
||||
turnScreenOnTime.setEntryValues(entryValues);
|
||||
turnScreenOnTime.setIcon(getContentIcon(R.drawable.ic_action_time_span));
|
||||
turnScreenOnTime.setIcon(getPersistentPrefIcon(R.drawable.ic_action_time_span));
|
||||
}
|
||||
|
||||
private void setupTurnScreenOnSensorPref() {
|
||||
|
@ -92,7 +107,7 @@ public class TurnScreenOnFragment extends BaseSettingsFragment {
|
|||
String description = getString(R.string.turn_screen_on_sensor_descr);
|
||||
|
||||
SwitchPreferenceEx turnScreenOnSensor = (SwitchPreferenceEx) findPreference(settings.TURN_SCREEN_ON_SENSOR.getId());
|
||||
turnScreenOnSensor.setIcon(getContentIcon(R.drawable.ic_action_sensor_interaction));
|
||||
turnScreenOnSensor.setIcon(getPersistentPrefIcon(R.drawable.ic_action_sensor_interaction));
|
||||
turnScreenOnSensor.setTitle(title);
|
||||
turnScreenOnSensor.setDescription(description);
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@ package net.osmand.plus.settings;
|
|||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.PreferenceViewHolder;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
|
@ -22,6 +24,9 @@ public class VehicleParametersFragment extends BaseSettingsFragment implements O
|
|||
|
||||
public static final String TAG = VehicleParametersFragment.class.getSimpleName();
|
||||
|
||||
private static final String ROUTING_PARAMETER_NUMERIC_DEFAULT = "0.0";
|
||||
private static final String ROUTING_PARAMETER_SYMBOLIC_DEFAULT = "-";
|
||||
|
||||
@Override
|
||||
protected void setupPreferences() {
|
||||
OsmandApplication app = getMyApplication();
|
||||
|
@ -69,7 +74,7 @@ public class VehicleParametersFragment extends BaseSettingsFragment implements O
|
|||
String title = SettingsBaseActivity.getRoutingStringPropertyName(app, parameterId, parameter.getName());
|
||||
String description = SettingsBaseActivity.getRoutingStringPropertyDescription(app, parameterId, parameter.getDescription());
|
||||
|
||||
String defValue = parameter.getType() == GeneralRouter.RoutingParameterType.NUMERIC ? "0.0" : "-";
|
||||
String defValue = parameter.getType() == GeneralRouter.RoutingParameterType.NUMERIC ? ROUTING_PARAMETER_NUMERIC_DEFAULT : ROUTING_PARAMETER_SYMBOLIC_DEFAULT;
|
||||
OsmandSettings.StringPreference pref = (OsmandSettings.StringPreference) app.getSettings().getCustomRoutingProperty(parameterId, defValue);
|
||||
|
||||
Object[] values = parameter.getPossibleValues();
|
||||
|
@ -98,6 +103,20 @@ public class VehicleParametersFragment extends BaseSettingsFragment implements O
|
|||
getPreferenceScreen().addPreference(defaultSpeedPref);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onBindPreferenceViewHolder(Preference preference, PreferenceViewHolder holder) {
|
||||
super.onBindPreferenceViewHolder(preference, holder);
|
||||
if (!GeneralRouter.DEFAULT_SPEED.equals(preference.getKey()) && preference instanceof ListPreferenceEx) {
|
||||
ImageView imageView = (ImageView) holder.findViewById(android.R.id.icon);
|
||||
if (imageView != null) {
|
||||
Object currentValue = ((ListPreferenceEx) preference).getValue();
|
||||
boolean enabled = preference.isEnabled() && !ROUTING_PARAMETER_NUMERIC_DEFAULT.equals(currentValue)
|
||||
&& !ROUTING_PARAMETER_SYMBOLIC_DEFAULT.equals(currentValue);
|
||||
imageView.setEnabled(enabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
if (preference.getKey().equals(GeneralRouter.DEFAULT_SPEED)) {
|
||||
|
@ -124,13 +143,13 @@ public class VehicleParametersFragment extends BaseSettingsFragment implements O
|
|||
private Drawable getPreferenceIcon(String prefId) {
|
||||
switch (prefId) {
|
||||
case GeneralRouter.DEFAULT_SPEED:
|
||||
return getContentIcon(R.drawable.ic_action_speed);
|
||||
return getPersistentPrefIcon(R.drawable.ic_action_speed);
|
||||
case GeneralRouter.VEHICLE_HEIGHT:
|
||||
return getContentIcon(R.drawable.ic_action_height_limit);
|
||||
return getPersistentPrefIcon(R.drawable.ic_action_height_limit);
|
||||
case GeneralRouter.VEHICLE_WEIGHT:
|
||||
return getContentIcon(R.drawable.ic_action_weight_limit);
|
||||
return getPersistentPrefIcon(R.drawable.ic_action_weight_limit);
|
||||
case GeneralRouter.VEHICLE_WIDTH:
|
||||
return getContentIcon(R.drawable.ic_action_width_limit);
|
||||
return getPersistentPrefIcon(R.drawable.ic_action_width_limit);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -5,14 +5,17 @@ import android.content.Context;
|
|||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.media.AudioManager;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.PreferenceViewHolder;
|
||||
import android.support.v7.preference.SwitchPreferenceCompat;
|
||||
import android.support.v7.widget.SwitchCompat;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
|
@ -169,10 +172,14 @@ public class VoiceAnnouncesFragment extends BaseSettingsFragment {
|
|||
entryValues[k] = MORE_VALUE;
|
||||
entries[k] = getString(R.string.install_more);
|
||||
|
||||
Drawable disabled = getContentIcon(R.drawable.ic_action_volume_mute);
|
||||
Drawable enabled = getActiveIcon(R.drawable.ic_action_volume_up);
|
||||
Drawable icon = AndroidUtils.createEnabledStateListDrawable(disabled, enabled);
|
||||
|
||||
ListPreferenceEx voiceProvider = (ListPreferenceEx) findPreference(settings.VOICE_PROVIDER.getId());
|
||||
voiceProvider.setEntries(entries);
|
||||
voiceProvider.setEntryValues(entryValues);
|
||||
voiceProvider.setIcon(getContentIcon(R.drawable.ic_action_volume_up));
|
||||
voiceProvider.setIcon(icon);
|
||||
}
|
||||
|
||||
private void setupAudioStreamGuidancePref() {
|
||||
|
@ -228,6 +235,19 @@ public class VoiceAnnouncesFragment extends BaseSettingsFragment {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onBindPreferenceViewHolder(Preference preference, PreferenceViewHolder holder) {
|
||||
super.onBindPreferenceViewHolder(preference, holder);
|
||||
if (settings.VOICE_PROVIDER.getId().equals(preference.getKey()) && preference instanceof ListPreferenceEx) {
|
||||
ImageView imageView = (ImageView) holder.findViewById(android.R.id.icon);
|
||||
if (imageView != null) {
|
||||
Object currentValue = ((ListPreferenceEx) preference).getValue();
|
||||
boolean enabled = preference.isEnabled() && !OsmandSettings.VOICE_PROVIDER_NOT_USE.equals(currentValue);
|
||||
imageView.setEnabled(enabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
String prefId = preference.getKey();
|
||||
|
@ -240,6 +260,7 @@ public class VoiceAnnouncesFragment extends BaseSettingsFragment {
|
|||
intent.putExtra(DownloadActivity.TAB_TO_OPEN, DownloadActivity.DOWNLOAD_TAB);
|
||||
intent.putExtra(DownloadActivity.FILTER_CAT, DownloadActivityType.VOICE_FILE.getTag());
|
||||
startActivity(intent);
|
||||
return false;
|
||||
} else if (newValue instanceof String) {
|
||||
settings.VOICE_PROVIDER.setModeValue(selectedMode, (String) newValue);
|
||||
app.initVoiceCommandPlayer(getActivity(), selectedMode, false, null, true, false, false);
|
||||
|
|
|
@ -48,6 +48,7 @@ public class MultiSelectBooleanPreference extends MultiSelectListPreference {
|
|||
getValues().addAll(values);
|
||||
|
||||
persistBooleanPrefs();
|
||||
notifyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue