Fix profile switch visibility and update osm editing icon
This commit is contained in:
parent
92a9f98bed
commit
2b9c871e7d
3 changed files with 19 additions and 5 deletions
|
@ -21,12 +21,12 @@
|
|||
tools:summary="@string/open_street_map_login_descr" />
|
||||
|
||||
<net.osmand.plus.settings.preferences.SwitchPreferenceEx
|
||||
android:icon="@drawable/ic_action_offline"
|
||||
android:key="offline_osm_editing"
|
||||
android:layout="@layout/preference_with_descr_dialog_and_switch"
|
||||
android:summaryOff="@string/shared_string_disabled"
|
||||
android:summaryOn="@string/shared_string_enabled"
|
||||
android:title="@string/offline_edition" />
|
||||
android:title="@string/offline_edition"
|
||||
tools:icon="@drawable/ic_action_offline" />
|
||||
|
||||
<Preference
|
||||
android:layout="@layout/simple_divider_item"
|
||||
|
|
|
@ -2,6 +2,7 @@ package net.osmand.plus.osmedit;
|
|||
|
||||
import android.content.Intent;
|
||||
import android.graphics.Typeface;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.text.SpannableString;
|
||||
|
@ -53,6 +54,11 @@ public class OsmEditingFragment extends BaseSettingsFragment implements OnPrefer
|
|||
private void setupOfflineEditingPref() {
|
||||
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);
|
||||
}
|
||||
|
||||
private void setupOsmEditsDescrPref() {
|
||||
|
@ -92,6 +98,14 @@ 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)) {
|
||||
|
|
|
@ -19,6 +19,7 @@ import net.osmand.plus.R;
|
|||
import net.osmand.plus.SettingsHelper.*;
|
||||
import net.osmand.plus.UiUtilities;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||
import net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment;
|
||||
import net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment.SelectProfileListener;
|
||||
import net.osmand.plus.settings.preferences.SwitchPreferenceEx;
|
||||
|
@ -88,9 +89,8 @@ public class MainSettingsFragment extends BaseSettingsFragment {
|
|||
AndroidUtils.setBackground(selectedProfile, backgroundDrawable);
|
||||
}
|
||||
}
|
||||
if (ApplicationMode.DEFAULT.getStringKey().equals(preference.getKey())) {
|
||||
holder.findViewById(R.id.switchWidget).setVisibility(View.GONE);
|
||||
}
|
||||
boolean visible = !ApplicationMode.DEFAULT.getStringKey().equals(key);
|
||||
AndroidUiHelper.updateVisibility(holder.findViewById(R.id.switchWidget), visible);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue