forked from organicmaps/organicmaps
[android][locator] refactor: "Use Google Services" setting moved to global storage.
This commit is contained in:
parent
ba2823d1dc
commit
8af6a3d44c
2 changed files with 28 additions and 1 deletions
|
@ -37,8 +37,24 @@ public class MiscPrefsFragment extends BaseXmlSettingsFragment
|
|||
}
|
||||
});
|
||||
|
||||
pref = findPreference(getString(R.string.pref_play_services));
|
||||
|
||||
if (GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(MwmApplication.get()) != ConnectionResult.SUCCESS)
|
||||
getPreferenceScreen().removePreference(findPreference(getString(R.string.pref_play_services)));
|
||||
getPreferenceScreen().removePreference(pref);
|
||||
else
|
||||
{
|
||||
((TwoStatePreference) pref).setChecked(Config.useGoogleServices());
|
||||
pref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener()
|
||||
{
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue)
|
||||
{
|
||||
Config.setUseGoogleService((Boolean) newValue);
|
||||
// TODO (trashkalmar): Reinitialize location provider
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (!MytargetHelper.isShowcaseSwitchedOnServer())
|
||||
getPreferenceScreen().removePreference(findPreference(getString(R.string.pref_showcase_switched_on)));
|
||||
|
|
|
@ -21,6 +21,7 @@ public final class Config
|
|||
|
||||
private static final String KEY_PREF_ZOOM_BUTTONS = "ZoomButtonsEnabled";
|
||||
private static final String KEY_PREF_STATISTICS = "StatisticsEnabled";
|
||||
private static final String KEY_PREF_USE_GS = "UseGoogleServices";
|
||||
|
||||
private static final String KEY_LIKES_RATED_DIALOG = "RatedDialog";
|
||||
private static final String KEY_LIKES_LAST_RATED_SESSION = "LastRatedSession";
|
||||
|
@ -226,6 +227,16 @@ public final class Config
|
|||
setBool(KEY_PREF_STATISTICS, enabled);
|
||||
}
|
||||
|
||||
public static boolean useGoogleServices()
|
||||
{
|
||||
return getBool(KEY_PREF_USE_GS, true);
|
||||
}
|
||||
|
||||
public static void setUseGoogleService(boolean use)
|
||||
{
|
||||
setBool(KEY_PREF_USE_GS, use);
|
||||
}
|
||||
|
||||
public static boolean isRatingApplied(Class<? extends DialogFragment> dialogFragmentClass)
|
||||
{
|
||||
return getBool(KEY_LIKES_RATED_DIALOG + dialogFragmentClass.getSimpleName());
|
||||
|
|
Loading…
Add table
Reference in a new issue