Sensible default for geouri/gmaps setting
This commit is contained in:
@@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
<queries>
|
<queries>
|
||||||
<package android:name="com.nextcloud.client" />
|
<package android:name="com.nextcloud.client" />
|
||||||
|
<!-- To see if Google Maps is installed, as it needs a specific intent Uri) -->
|
||||||
|
<package android:name="com.google.android.apps.maps" />
|
||||||
</queries>
|
</queries>
|
||||||
|
|
||||||
<application
|
<application
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package it.danieleverducci.nextcloudmaps.utils;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
|
||||||
import androidx.preference.PreferenceManager;
|
import androidx.preference.PreferenceManager;
|
||||||
import it.danieleverducci.nextcloudmaps.activity.main.GeofavoriteAdapter;
|
import it.danieleverducci.nextcloudmaps.activity.main.GeofavoriteAdapter;
|
||||||
@@ -50,7 +51,7 @@ public class SettingsManager {
|
|||||||
|
|
||||||
public static boolean isUseGoogleMaps(Context context) {
|
public static boolean isUseGoogleMaps(Context context) {
|
||||||
return PreferenceManager.getDefaultSharedPreferences(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) {
|
public static void setUseGoogleMaps(Context context, boolean value) {
|
||||||
@@ -65,4 +66,13 @@ public class SettingsManager {
|
|||||||
.putFloat(SETTING_LAST_MAP_POSITION_ZOOM, (float)zoom)
|
.putFloat(SETTING_LAST_MAP_POSITION_ZOOM, (float)zoom)
|
||||||
.apply();
|
.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