Sensible default for geouri/gmaps setting
This commit is contained in:
@@ -2,6 +2,7 @@ package it.danieleverducci.nextcloudmaps.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
|
||||
import androidx.preference.PreferenceManager;
|
||||
import it.danieleverducci.nextcloudmaps.activity.main.GeofavoriteAdapter;
|
||||
@@ -50,7 +51,7 @@ public class SettingsManager {
|
||||
|
||||
public static boolean isUseGoogleMaps(Context context) {
|
||||
return PreferenceManager.getDefaultSharedPreferences(context)
|
||||
.getBoolean(SETTING_USE_GOOGLE_MAPS, true);
|
||||
.getBoolean(SETTING_USE_GOOGLE_MAPS, isGoogleMapsInstalled(context));
|
||||
}
|
||||
|
||||
public static void setUseGoogleMaps(Context context, boolean value) {
|
||||
@@ -65,4 +66,13 @@ public class SettingsManager {
|
||||
.putFloat(SETTING_LAST_MAP_POSITION_ZOOM, (float)zoom)
|
||||
.apply();
|
||||
}
|
||||
|
||||
private static boolean isGoogleMapsInstalled(Context context) {
|
||||
try {
|
||||
context.getPackageManager().getApplicationInfo("com.google.android.apps.maps", 0);
|
||||
return true;
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user