Remove unused preference and set default prefs via dialog
This commit is contained in:
parent
56fb98cc56
commit
50f4e9cc27
2 changed files with 34 additions and 32 deletions
|
@ -8,6 +8,8 @@ import android.view.View;
|
|||
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
||||
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
|
||||
|
@ -16,6 +18,8 @@ import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem;
|
|||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ChangeProfilesPreferenceBottomSheet extends MenuBottomSheetDialogFragment {
|
||||
|
||||
public static final String TAG = "ChangeProfilesPreferenceBottomSheet";
|
||||
|
@ -32,6 +36,12 @@ public class ChangeProfilesPreferenceBottomSheet extends MenuBottomSheetDialogFr
|
|||
if (context == null) {
|
||||
return;
|
||||
}
|
||||
Bundle args = getArguments();
|
||||
if (args == null || !args.containsKey(PREFERENCE_ID)) {
|
||||
return;
|
||||
}
|
||||
final String prefId = args.getString(PREFERENCE_ID);
|
||||
|
||||
items.add(new TitleItem(getString(R.string.change_default_settings)));
|
||||
|
||||
BaseBottomSheetItem applyToAllProfiles = new SimpleBottomSheetItem.Builder()
|
||||
|
@ -41,7 +51,19 @@ public class ChangeProfilesPreferenceBottomSheet extends MenuBottomSheetDialogFr
|
|||
.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
getMyApplication().showShortToastMessage("applyToAllProfiles");
|
||||
OsmandApplication app = getMyApplication();
|
||||
if (app != null) {
|
||||
OsmandSettings settings = app.getSettings();
|
||||
OsmandSettings.OsmandPreference pref = settings.getPreference(prefId);
|
||||
if (pref instanceof OsmandSettings.CommonPreference) {
|
||||
OsmandSettings.CommonPreference commonPref = (OsmandSettings.CommonPreference) pref;
|
||||
final List<ApplicationMode> values = ApplicationMode.values(app);
|
||||
for (ApplicationMode mode : values) {
|
||||
commonPref.setModeDefaultValue(mode, newValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
})
|
||||
.create();
|
||||
|
@ -56,7 +78,16 @@ public class ChangeProfilesPreferenceBottomSheet extends MenuBottomSheetDialogFr
|
|||
.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
getMyApplication().showShortToastMessage("applyToCurrentProfile");
|
||||
OsmandApplication app = getMyApplication();
|
||||
if (app != null) {
|
||||
OsmandSettings settings = app.getSettings();
|
||||
OsmandSettings.OsmandPreference pref = settings.getPreference(prefId);
|
||||
if (pref instanceof OsmandSettings.CommonPreference) {
|
||||
OsmandSettings.CommonPreference commonPref = (OsmandSettings.CommonPreference) pref;
|
||||
commonPref.setModeDefaultValue(settings.APPLICATION_MODE.get(), newValue);
|
||||
}
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
})
|
||||
.create();
|
||||
|
@ -64,7 +95,7 @@ public class ChangeProfilesPreferenceBottomSheet extends MenuBottomSheetDialogFr
|
|||
|
||||
BaseBottomSheetItem discardChanges = new SimpleBottomSheetItem.Builder()
|
||||
.setTitle(getString(R.string.discard_changes))
|
||||
.setIcon(getActiveIcon(R.drawable.ic_action_copy))
|
||||
.setIcon(getActiveIcon(R.drawable.ic_action_undo_dark))
|
||||
.setLayoutId(R.layout.bottom_sheet_item_simple)
|
||||
.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
package net.osmand.plus.views;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.v14.preference.SwitchPreference;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
public class SwitchFragmentPreference extends SwitchPreference {
|
||||
|
||||
public SwitchFragmentPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
}
|
||||
|
||||
public SwitchFragmentPreference(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
public SwitchFragmentPreference(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public SwitchFragmentPreference(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onClick() {
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue