diff --git a/app/src/main/java/it/danieleverducci/nextcloudmaps/activity/main/MainActivity.java b/app/src/main/java/it/danieleverducci/nextcloudmaps/activity/main/MainActivity.java
index 004578a..5189b14 100644
--- a/app/src/main/java/it/danieleverducci/nextcloudmaps/activity/main/MainActivity.java
+++ b/app/src/main/java/it/danieleverducci/nextcloudmaps/activity/main/MainActivity.java
@@ -61,6 +61,7 @@ import it.danieleverducci.nextcloudmaps.api.ApiProvider;
import it.danieleverducci.nextcloudmaps.model.Geofavorite;
import it.danieleverducci.nextcloudmaps.utils.GeoUriParser;
import it.danieleverducci.nextcloudmaps.utils.IntentGenerator;
+import it.danieleverducci.nextcloudmaps.utils.SettingsManager;
import static android.view.View.GONE;
import static android.view.View.VISIBLE;
@@ -106,8 +107,9 @@ public class MainActivity extends NextcloudMapsStyledActivity implements OnSorti
preferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
- int sortRule = preferences.getInt(getString(R.string.setting_sort_by), SORT_BY_CREATED);
- boolean gridViewEnabled = preferences.getBoolean(getString(R.string.setting_grid_view_enabled), false);
+
+ int sortRule = SettingsManager.getGeofavoriteListSortBy(this);
+ boolean gridViewEnabled = SettingsManager.isGeofavoriteListShownAsGrid(this);
recyclerView = findViewById(R.id.recycler_view);
layoutManager = new StaggeredGridLayoutManager(gridViewEnabled ? 2 : 1, StaggeredGridLayoutManager.VERTICAL);
diff --git a/app/src/main/java/it/danieleverducci/nextcloudmaps/utils/SettingsManager.java b/app/src/main/java/it/danieleverducci/nextcloudmaps/utils/SettingsManager.java
new file mode 100644
index 0000000..031a6d8
--- /dev/null
+++ b/app/src/main/java/it/danieleverducci/nextcloudmaps/utils/SettingsManager.java
@@ -0,0 +1,44 @@
+package it.danieleverducci.nextcloudmaps.utils;
+
+import android.content.Context;
+
+import androidx.preference.PreferenceManager;
+
+import it.danieleverducci.nextcloudmaps.R;
+import it.danieleverducci.nextcloudmaps.activity.main.GeofavoriteAdapter;
+
+public class SettingsManager {
+ static private final String SETTING_SORT_BY = "SETTING_SORT_BY";
+ static private final String SETTING_GRID_VIEW_ENABLED = "SETTING_GRID_VIEW_ENABLED";
+ static private final String SETTING_LAST_SELECTED_LIST_VIEW = "SETTING_LAST_SELECTED_LIST_VIEW";
+
+ public static int getGeofavoriteListSortBy(Context context) {
+ return PreferenceManager.getDefaultSharedPreferences(context)
+ .getInt(SETTING_SORT_BY, GeofavoriteAdapter.SORT_BY_CREATED);
+ }
+
+ public static void setGeofavoriteListSortBy(Context context, int value) {
+ PreferenceManager.getDefaultSharedPreferences(context)
+ .edit().putInt(SETTING_SORT_BY, value).apply();
+ }
+
+ public static boolean isGeofavoriteListShownAsGrid(Context context) {
+ return PreferenceManager.getDefaultSharedPreferences(context)
+ .getBoolean(SETTING_GRID_VIEW_ENABLED, false);
+ }
+
+ public static void setGeofavoriteListShownAsGrid(Context context, boolean value) {
+ PreferenceManager.getDefaultSharedPreferences(context)
+ .edit().putBoolean(SETTING_GRID_VIEW_ENABLED, value).apply();
+ }
+
+ public static boolean isGeofavoriteListShownAsMap(Context context) {
+ return PreferenceManager.getDefaultSharedPreferences(context)
+ .getBoolean(SETTING_LAST_SELECTED_LIST_VIEW, false);
+ }
+
+ public static void setGeofavoriteListShownAsMap(Context context, boolean value) {
+ PreferenceManager.getDefaultSharedPreferences(context)
+ .edit().putBoolean(SETTING_LAST_SELECTED_LIST_VIEW, value).apply();
+ }
+}
diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml
index 970d48f..cff9a01 100644
--- a/app/src/main/res/values-it/strings.xml
+++ b/app/src/main/res/values-it/strings.xml
@@ -93,10 +93,6 @@
https://raw.githubusercontent.com/penguin86/nextcloud-maps-client/master/LICENSE
https://donate.openstreetmap.org
-
- SETTING_SORT_BY
- SETTING_GRID_VIEW_ENABLED
-
Crea dalla posizione corrente
Crea dalla mappa
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index a9e3b85..9eee611 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -92,10 +92,6 @@
https://raw.githubusercontent.com/penguin86/nextcloud-maps-client/master/LICENSE
https://donate.openstreetmap.org
-
- SETTING_SORT_BY
- SETTING_GRID_VIEW_ENABLED
-
New from current position
New from map