Merge branch 'r3.5' of ssh://github.com/osmandapp/Osmand into plugins_fixes

This commit is contained in:
Chumva 2019-11-14 09:04:15 +02:00
commit 15fc1f0b15
13 changed files with 151 additions and 47 deletions

View file

@ -13,6 +13,7 @@ import android.net.NetworkInfo;
import android.os.Build;
import android.os.Environment;
import android.support.annotation.DrawableRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.StringRes;
import android.support.v4.util.Pair;
@ -149,7 +150,6 @@ public class OsmandSettings {
/// Settings variables
private final OsmandApplication ctx;
private PreferencesDataStore dataStore;
private SettingsAPI settingsAPI;
private Object defaultProfilePreferences;
private Object globalPreferences;
@ -166,7 +166,6 @@ public class OsmandSettings {
protected OsmandSettings(OsmandApplication clientContext, SettingsAPI settinsAPI) {
ctx = clientContext;
this.settingsAPI = settinsAPI;
dataStore = new PreferencesDataStore();
initPrefs();
}
@ -174,7 +173,6 @@ public class OsmandSettings {
ctx = clientContext;
this.settingsAPI = settinsAPI;
CUSTOM_SHARED_PREFERENCES_NAME = CUSTOM_SHARED_PREFERENCES_PREFIX + sharedPreferencesName;
dataStore = new PreferencesDataStore();
initPrefs();
setCustomized();
}
@ -210,8 +208,8 @@ public class OsmandSettings {
return settingsAPI;
}
public PreferencesDataStore getDataStore() {
return dataStore;
public PreferencesDataStore getDataStore(@Nullable ApplicationMode appMode) {
return new PreferencesDataStore(appMode != null ? appMode : APPLICATION_MODE.get());
}
public static String getSharedPreferencesName(ApplicationMode mode) {
@ -3507,38 +3505,44 @@ public class OsmandSettings {
public class PreferencesDataStore extends PreferenceDataStore {
private ApplicationMode appMode;
public PreferencesDataStore(@NonNull ApplicationMode appMode) {
this.appMode = appMode;
}
@Override
public void putString(String key, @Nullable String value) {
setPreference(key, value);
setPreference(key, value, appMode);
}
@Override
public void putStringSet(String key, @Nullable Set<String> values) {
setPreference(key, values);
setPreference(key, values, appMode);
}
@Override
public void putInt(String key, int value) {
setPreference(key, value);
setPreference(key, value, appMode);
}
@Override
public void putLong(String key, long value) {
setPreference(key, value);
setPreference(key, value, appMode);
}
@Override
public void putFloat(String key, float value) {
setPreference(key, value);
setPreference(key, value, appMode);
}
@Override
public void putBoolean(String key, boolean value) {
setPreference(key, value);
setPreference(key, value, appMode);
}
public void putValue(String key, Object value) {
setPreference(key, value);
setPreference(key, value, appMode);
}
@Nullable
@ -3546,9 +3550,9 @@ public class OsmandSettings {
public String getString(String key, @Nullable String defValue) {
OsmandPreference preference = getPreference(key);
if (preference instanceof StringPreference) {
return ((StringPreference) preference).get();
return ((StringPreference) preference).getModeValue(appMode);
} else {
Object value = preference.get();
Object value = preference.getModeValue(appMode);
if (value != null) {
return value.toString();
}
@ -3566,7 +3570,7 @@ public class OsmandSettings {
public int getInt(String key, int defValue) {
OsmandPreference preference = getPreference(key);
if (preference instanceof IntPreference) {
return ((IntPreference) preference).get();
return ((IntPreference) preference).getModeValue(appMode);
}
return defValue;
}
@ -3575,7 +3579,7 @@ public class OsmandSettings {
public long getLong(String key, long defValue) {
OsmandPreference preference = getPreference(key);
if (preference instanceof LongPreference) {
return ((LongPreference) preference).get();
return ((LongPreference) preference).getModeValue(appMode);
}
return defValue;
}
@ -3584,7 +3588,7 @@ public class OsmandSettings {
public float getFloat(String key, float defValue) {
OsmandPreference preference = getPreference(key);
if (preference instanceof FloatPreference) {
return ((FloatPreference) preference).get();
return ((FloatPreference) preference).getModeValue(appMode);
}
return defValue;
}
@ -3593,7 +3597,7 @@ public class OsmandSettings {
public boolean getBoolean(String key, boolean defValue) {
OsmandPreference preference = getPreference(key);
if (preference instanceof BooleanPreference) {
return ((BooleanPreference) preference).get();
return ((BooleanPreference) preference).getModeValue(appMode);
}
return defValue;
}
@ -3602,7 +3606,7 @@ public class OsmandSettings {
public Object getValue(String key, Object defValue) {
OsmandPreference preference = getPreference(key);
if (preference != null) {
return preference.get();
return preference.getModeValue(appMode);
}
return defValue;
}

View file

@ -1,6 +1,8 @@
package net.osmand.plus.profiles;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
@ -18,9 +20,26 @@ public class SelectAppModesBottomSheetDialogFragment extends AppModesBottomSheet
public static final String TAG = "SelectAppModesBottomSheetDialogFragment";
private static final String APP_MODE_KEY = "app_mode_key";
private static final String APP_MODE_CHANGEABLE_KEY = "app_mode_changeable_key";
private static final Log LOG = PlatformUtil.getLog(SelectAppModesBottomSheetDialogFragment.class);
private List<ApplicationMode> activeModes = new ArrayList<>();
private ApplicationMode appMode;
private boolean appModeChangeable;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (savedInstanceState != null) {
appMode = ApplicationMode.valueOfStringKey(savedInstanceState.getString(APP_MODE_KEY), null);
appModeChangeable = savedInstanceState.getBoolean(APP_MODE_CHANGEABLE_KEY);
}
if (appMode == null) {
appMode = requiredMyApplication().getSettings().getApplicationMode();
}
}
@Override
public void onResume() {
@ -30,6 +49,22 @@ public class SelectAppModesBottomSheetDialogFragment extends AppModesBottomSheet
setupHeightAndBackground(getView());
}
public ApplicationMode getAppMode() {
return appMode;
}
public void setAppMode(ApplicationMode appMode) {
this.appMode = appMode;
}
public boolean isAppModeChangeable() {
return appModeChangeable;
}
public void setAppModeChangeable(boolean appModeChangeable) {
this.appModeChangeable = appModeChangeable;
}
@Override
protected void getData() {
activeModes.addAll(ApplicationMode.values(getMyApplication()));
@ -37,7 +72,7 @@ public class SelectAppModesBottomSheetDialogFragment extends AppModesBottomSheet
@Override
protected SelectProfileMenuAdapter getMenuAdapter() {
return new SelectProfileMenuAdapter(activeModes, getMyApplication(), getString(R.string.shared_string_manage), nightMode);
return new SelectProfileMenuAdapter(activeModes, requiredMyApplication(), getString(R.string.shared_string_manage), nightMode, appMode);
}
@Override
@ -48,9 +83,10 @@ public class SelectAppModesBottomSheetDialogFragment extends AppModesBottomSheet
@Override
public void onProfilePressed(ApplicationMode appMode) {
OsmandSettings settings = getMyApplication().getSettings();
if (appMode != settings.APPLICATION_MODE.get()) {
settings.APPLICATION_MODE.set(appMode);
if (appMode != this.appMode) {
if (appModeChangeable) {
settings.APPLICATION_MODE.set(appMode);
}
Fragment targetFragment = getTargetFragment();
if (targetFragment instanceof AppModeChangedListener) {
AppModeChangedListener listener = (AppModeChangedListener) targetFragment;
@ -60,12 +96,24 @@ public class SelectAppModesBottomSheetDialogFragment extends AppModesBottomSheet
dismiss();
}
public static void showInstance(@NonNull FragmentManager fm, Fragment target, boolean usedOnMap) {
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
if (appMode != null) {
outState.putString(APP_MODE_KEY, appMode.getStringKey());
}
outState.putBoolean(APP_MODE_CHANGEABLE_KEY, appModeChangeable);
}
public static void showInstance(@NonNull FragmentManager fm, Fragment target, boolean usedOnMap,
@Nullable ApplicationMode appMode, boolean appModeChangeable) {
try {
if (fm.findFragmentByTag(SelectAppModesBottomSheetDialogFragment.TAG) == null) {
SelectAppModesBottomSheetDialogFragment fragment = new SelectAppModesBottomSheetDialogFragment();
fragment.setTargetFragment(target, 0);
fragment.setUsedOnMap(usedOnMap);
fragment.setAppMode(appMode);
fragment.setAppModeChangeable(appModeChangeable);
fragment.show(fm, SelectAppModesBottomSheetDialogFragment.TAG);
}
} catch (RuntimeException e) {

View file

@ -31,8 +31,8 @@ public class SelectProfileMenuAdapter extends AbstractProfileMenuAdapter<SelectP
private static final Log LOG = PlatformUtil.getLog(SelectProfileMenuAdapter.class);
private List<Object> items = new ArrayList<>();
@Nullable
private final OsmandApplication app;
private ApplicationMode appMode;
@ColorRes
private int selectedIconColorRes;
private boolean bottomButton;
@ -41,13 +41,15 @@ public class SelectProfileMenuAdapter extends AbstractProfileMenuAdapter<SelectP
private boolean nightMode;
public SelectProfileMenuAdapter(List<ApplicationMode> items, OsmandApplication app,
String bottomButtonText, boolean nightMode) {
public SelectProfileMenuAdapter(List<ApplicationMode> items, @NonNull OsmandApplication app,
String bottomButtonText, boolean nightMode,
@Nullable ApplicationMode appMode) {
this.items.addAll(items);
if (bottomButton) {
this.items.add(BUTTON_ITEM);
}
this.app = app;
this.appMode = appMode != null ? appMode : app.getSettings().getApplicationMode();
this.bottomButton = !Algorithms.isEmpty(bottomButtonText);
this.bottomButtonText = bottomButtonText;
this.nightMode = nightMode;
@ -103,7 +105,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;
boolean selectedMode = appMode == item;
Drawable drawable = UiUtilities.getColoredSelectableDrawable(app, colorNoAlpha, 0.3f);
if (selectedMode) {

View file

@ -131,7 +131,7 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
getPreferenceManager().setPreferenceDataStore(settings.getDataStore());
getPreferenceManager().setPreferenceDataStore(settings.getDataStore(getSelectedAppMode()));
}
@Override
@ -291,14 +291,15 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
return;
}
ApplicationMode appMode = getSelectedAppMode();
if (preference instanceof ListPreferenceEx) {
SingleSelectPreferenceBottomSheet.showInstance(fragmentManager, preference.getKey(), this, false);
SingleSelectPreferenceBottomSheet.showInstance(fragmentManager, preference.getKey(), this, false, appMode);
} else if (preference instanceof SwitchPreferenceEx) {
BooleanPreferenceBottomSheet.showInstance(fragmentManager, preference.getKey(), this, false);
BooleanPreferenceBottomSheet.showInstance(fragmentManager, preference.getKey(), this, false, appMode);
} else if (preference instanceof EditTextPreference) {
EditTextPreferenceBottomSheet.showInstance(fragmentManager, preference.getKey(), this, false);
EditTextPreferenceBottomSheet.showInstance(fragmentManager, preference.getKey(), this, false, appMode);
} else if (preference instanceof MultiSelectBooleanPreference) {
MultiSelectPreferencesBottomSheet.showInstance(fragmentManager, preference.getKey(), this, false);
MultiSelectPreferencesBottomSheet.showInstance(fragmentManager, preference.getKey(), this, false, appMode);
} else {
super.onDisplayPreferenceDialog(preference);
}
@ -380,7 +381,8 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
public void onClick(View v) {
FragmentManager fragmentManager = getFragmentManager();
if (fragmentManager != null) {
SelectAppModesBottomSheetDialogFragment.showInstance(fragmentManager, BaseSettingsFragment.this, false);
SelectAppModesBottomSheetDialogFragment.showInstance(fragmentManager,
BaseSettingsFragment.this, false, getSelectedAppMode(), false);
}
}
});

View file

@ -121,7 +121,8 @@ public class CoordinatesFormatFragment extends BaseSettingsFragment {
FragmentManager fragmentManager = getFragmentManager();
if (fragmentManager != null) {
ChangeGeneralProfilesPrefBottomSheet.showInstance(fragmentManager, settings.COORDINATES_FORMAT.getId(), newFormat, this, false);
ChangeGeneralProfilesPrefBottomSheet.showInstance(fragmentManager,
settings.COORDINATES_FORMAT.getId(), newFormat, this, false, getSelectedAppMode());
}
}
}

View file

@ -379,7 +379,8 @@ public class GeneralProfileSettingsFragment extends BaseSettingsFragment impleme
if (pref instanceof CommonPreference && !((CommonPreference) pref).hasDefaultValueForMode(getSelectedAppMode())) {
FragmentManager fragmentManager = getFragmentManager();
if (fragmentManager != null && newValue instanceof Serializable) {
ChangeGeneralProfilesPrefBottomSheet.showInstance(fragmentManager, prefId, (Serializable) newValue, this, false);
ChangeGeneralProfilesPrefBottomSheet.showInstance(fragmentManager, prefId,
(Serializable) newValue, this, false, getSelectedAppMode());
}
return false;
}

View file

@ -102,7 +102,7 @@ public class GlobalSettingsFragment extends BaseSettingsFragment implements Send
if (app == null) {
return;
}
ApplicationMode selectedMode = settings.DEFAULT_APPLICATION_MODE.get();
ApplicationMode selectedMode = getSelectedAppMode();
ApplicationMode[] appModes = ApplicationMode.values(app).toArray(new ApplicationMode[0]);
String[] entries = new String[appModes.length];

View file

@ -7,6 +7,7 @@ import android.support.v4.app.FragmentManager;
import android.support.v7.preference.DialogPreference.TargetFragment;
import android.support.v7.preference.Preference;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
import java.util.List;
@ -14,9 +15,35 @@ import java.util.List;
public abstract class BasePreferenceBottomSheet extends MenuBottomSheetDialogFragment {
public static final String PREFERENCE_ID = "preference_id";
private static final String APP_MODE_KEY = "app_mode_key";
private String prefId;
private Preference preference;
private ApplicationMode appMode;
protected void setAppMode(ApplicationMode appMode) {
this.appMode = appMode;
}
public ApplicationMode getAppMode() {
return appMode != null ? appMode : requiredMyApplication().getSettings().getApplicationMode();
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (savedInstanceState != null) {
appMode = ApplicationMode.valueOfStringKey(savedInstanceState.getString(APP_MODE_KEY), null);
}
}
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
if (appMode != null) {
outState.putString(APP_MODE_KEY, appMode.getStringKey());
}
}
public String getPrefId() {
if (prefId == null) {

View file

@ -5,6 +5,7 @@ import android.graphics.drawable.LayerDrawable;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.view.ContextThemeWrapper;
@ -12,6 +13,7 @@ import android.view.View;
import net.osmand.AndroidUtils;
import net.osmand.PlatformUtil;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.OsmandSettings.BooleanPreference;
@ -54,7 +56,7 @@ public class BooleanPreferenceBottomSheet extends BasePreferenceBottomSheet {
final OsmandSettings.BooleanPreference pref = (BooleanPreference) preference;
final String on = getString(R.string.shared_string_on);
final String off = getString(R.string.shared_string_off);
boolean checked = pref.get();
boolean checked = pref.getModeValue(getAppMode());
final BottomSheetItemWithCompoundButton[] preferenceBtn = new BottomSheetItemWithCompoundButton[1];
preferenceBtn[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder()
@ -64,7 +66,7 @@ public class BooleanPreferenceBottomSheet extends BasePreferenceBottomSheet {
.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
boolean newValue = !pref.get();
boolean newValue = !pref.getModeValue(getAppMode());
if (switchPreference.callChangeListener(newValue)) {
switchPreference.setChecked(newValue);
preferenceBtn[0].setTitle(newValue ? on : off);
@ -100,7 +102,7 @@ public class BooleanPreferenceBottomSheet extends BasePreferenceBottomSheet {
View customView = View.inflate(new ContextThemeWrapper(app, themeRes), R.layout.bottom_sheet_item_preference_switch, null);
View buttonView = customView.findViewById(R.id.button_container);
int colorRes = app.getSettings().APPLICATION_MODE.get().getIconColorInfo().getColor(nightMode);
int colorRes = getAppMode().getIconColorInfo().getColor(nightMode);
int color = getResolvedColor(colorRes);
int bgColor = UiUtilities.getColorWithAlpha(color, 0.1f);
int selectedColor = UiUtilities.getColorWithAlpha(color, 0.3f);
@ -126,7 +128,8 @@ public class BooleanPreferenceBottomSheet extends BasePreferenceBottomSheet {
return (SwitchPreferenceEx) getPreference();
}
public static void showInstance(@NonNull FragmentManager fm, String prefId, Fragment target, boolean usedOnMap) {
public static void showInstance(@NonNull FragmentManager fm, String prefId, Fragment target, boolean usedOnMap,
@Nullable ApplicationMode appMode) {
try {
if (fm.findFragmentByTag(BooleanPreferenceBottomSheet.TAG) == null) {
Bundle args = new Bundle();
@ -135,6 +138,7 @@ public class BooleanPreferenceBottomSheet extends BasePreferenceBottomSheet {
BooleanPreferenceBottomSheet fragment = new BooleanPreferenceBottomSheet();
fragment.setArguments(args);
fragment.setUsedOnMap(usedOnMap);
fragment.setAppMode(appMode);
fragment.setTargetFragment(target, 0);
fragment.show(fm, BooleanPreferenceBottomSheet.TAG);
}

View file

@ -2,6 +2,7 @@ package net.osmand.plus.settings.bottomsheets;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.view.View;
@ -61,7 +62,7 @@ public class ChangeGeneralProfilesPrefBottomSheet extends BasePreferenceBottomSh
.create();
items.add(applyToAllProfiles);
ApplicationMode selectedAppMode = getMyApplication().getSettings().APPLICATION_MODE.get();
ApplicationMode selectedAppMode = getAppMode();
BaseBottomSheetItem applyToCurrentProfile = new SimpleBottomSheetItem.Builder()
.setTitle(getString(R.string.apply_to_current_profile, selectedAppMode.toHumanString(app)))
@ -70,7 +71,7 @@ public class ChangeGeneralProfilesPrefBottomSheet extends BasePreferenceBottomSh
.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
app.getSettings().setPreference(prefId, newValue);
app.getSettings().setPreference(prefId, newValue, getAppMode());
updateTargetSettings(false);
dismiss();
}
@ -124,7 +125,8 @@ public class ChangeGeneralProfilesPrefBottomSheet extends BasePreferenceBottomSh
}
}
public static void showInstance(@NonNull FragmentManager fm, String prefId, Serializable newValue, Fragment target, boolean usedOnMap) {
public static void showInstance(@NonNull FragmentManager fm, String prefId, Serializable newValue, Fragment target,
boolean usedOnMap, @Nullable ApplicationMode appMode) {
try {
if (fm.findFragmentByTag(ChangeGeneralProfilesPrefBottomSheet.TAG) == null) {
Bundle args = new Bundle();
@ -134,6 +136,7 @@ public class ChangeGeneralProfilesPrefBottomSheet extends BasePreferenceBottomSh
ChangeGeneralProfilesPrefBottomSheet fragment = new ChangeGeneralProfilesPrefBottomSheet();
fragment.setArguments(args);
fragment.setUsedOnMap(usedOnMap);
fragment.setAppMode(appMode);
fragment.setTargetFragment(target, 0);
fragment.show(fm, ChangeGeneralProfilesPrefBottomSheet.TAG);
}

View file

@ -3,10 +3,12 @@ package net.osmand.plus.settings.bottomsheets;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.widget.EditText;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.R;
import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem;
import net.osmand.plus.base.bottomsheetmenu.simpleitems.LongDescriptionItem;
@ -87,7 +89,8 @@ public class EditTextPreferenceBottomSheet extends BasePreferenceBottomSheet {
return (EditTextPreferenceEx) getPreference();
}
public static boolean showInstance(@NonNull FragmentManager fragmentManager, String key, Fragment target, boolean usedOnMap) {
public static boolean showInstance(@NonNull FragmentManager fragmentManager, String key, Fragment target,
boolean usedOnMap, @Nullable ApplicationMode appMode) {
try {
Bundle args = new Bundle();
args.putString(PREFERENCE_ID, key);
@ -95,6 +98,7 @@ public class EditTextPreferenceBottomSheet extends BasePreferenceBottomSheet {
EditTextPreferenceBottomSheet fragment = new EditTextPreferenceBottomSheet();
fragment.setArguments(args);
fragment.setUsedOnMap(usedOnMap);
fragment.setAppMode(appMode);
fragment.setTargetFragment(target, 0);
fragment.show(fragmentManager, TAG);
return true;

View file

@ -2,11 +2,13 @@ package net.osmand.plus.settings.bottomsheets;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.view.View;
import net.osmand.PlatformUtil;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
@ -155,7 +157,8 @@ public class MultiSelectPreferencesBottomSheet extends BasePreferenceBottomSheet
}
}
public static boolean showInstance(@NonNull FragmentManager fragmentManager, String prefId, Fragment target, boolean usedOnMap) {
public static boolean showInstance(@NonNull FragmentManager fragmentManager, String prefId, Fragment target,
boolean usedOnMap, @Nullable ApplicationMode appMode) {
try {
Bundle args = new Bundle();
args.putString(PREFERENCE_ID, prefId);
@ -163,6 +166,7 @@ public class MultiSelectPreferencesBottomSheet extends BasePreferenceBottomSheet
MultiSelectPreferencesBottomSheet fragment = new MultiSelectPreferencesBottomSheet();
fragment.setArguments(args);
fragment.setUsedOnMap(usedOnMap);
fragment.setAppMode(appMode);
fragment.setTargetFragment(target, 0);
fragment.show(fragmentManager, TAG);
return true;

View file

@ -3,11 +3,13 @@ package net.osmand.plus.settings.bottomsheets;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.view.View;
import net.osmand.AndroidUtils;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.R;
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithCompoundButton;
@ -122,7 +124,8 @@ public class SingleSelectPreferenceBottomSheet extends BasePreferenceBottomSheet
return (ListPreferenceEx) getPreference();
}
public static boolean showInstance(@NonNull FragmentManager fragmentManager, String key, Fragment target, boolean usedOnMap) {
public static boolean showInstance(@NonNull FragmentManager fragmentManager, String key, Fragment target,
boolean usedOnMap, @Nullable ApplicationMode appMode) {
try {
Bundle args = new Bundle();
args.putString(PREFERENCE_ID, key);
@ -130,6 +133,7 @@ public class SingleSelectPreferenceBottomSheet extends BasePreferenceBottomSheet
SingleSelectPreferenceBottomSheet fragment = new SingleSelectPreferenceBottomSheet();
fragment.setArguments(args);
fragment.setUsedOnMap(usedOnMap);
fragment.setAppMode(appMode);
fragment.setTargetFragment(target, 0);
fragment.show(fragmentManager, TAG);
return true;