diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/SharingFragment.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/SharingFragment.java index 1b526a9..692c187 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/activity/SharingFragment.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/activity/SharingFragment.java @@ -143,6 +143,9 @@ public class SharingFragment extends PreferenceFragment { statusMapping.put(1, "consultation"); statusMapping.put(2, "busy"); + statusList.setSummary(PrefUtils.getUserStatus(getApplicationContext())); + manualLocationList.setSummary(PrefUtils.getCurrentManualLocationName(getApplicationContext())); +// manualLocationList.setSummary(PrefUtils.getManualLocation(getApplicationContext())); /** Main sharing switch**/ locationSharing.setOnPreferenceChangeListener((buttonView, newValue) -> { PrefUtils.storeEnableSharingLocalization(getApplicationContext(), (Boolean) newValue); @@ -176,11 +179,12 @@ public class SharingFragment extends PreferenceFragment { /** Custom manual location list change listener **/ manualLocationList.setOnPreferenceChangeListener((preference, newValue) -> { ListPreference lp = (ListPreference) preference; - + CharSequence[] entries = lp.getEntries(); PredefinedCoordViewModel temp = Stream.of(predefinedCoordsList).filter(p -> p.getName().equals(lp.getEntries()[Integer.parseInt((String) newValue)].toString())).toList().get(0); - PrefUtils.putManualLocation(getApplicationContext(), temp.getGeoData(), temp.getApproximatedLocation() ); PrefUtils.putCurrentManualLocation(getApplicationContext(),temp.getPredefinedCoordinateId()); + PrefUtils.putCurrentManualLocationName(getApplicationContext(), (String )lp.getEntries()[Integer.parseInt((String) newValue)]); + lp.setSummary(lp.getEntries()[Integer.parseInt((String) newValue)]); return true; }); @@ -198,7 +202,7 @@ public class SharingFragment extends PreferenceFragment { ListPreference lp = (ListPreference) preference; CharSequence[] entries = lp.getEntries(); PrefUtils.storeStatus(getApplicationContext(), (String) entries[Integer.parseInt((String) newValue)]); - + lp.setSummary(entries[Integer.parseInt((String) newValue)]); return true; }); /** Custom status list change listener **/ diff --git a/app/src/main/java/com/uam/wmi/findmytutor/utils/PrefUtils.java b/app/src/main/java/com/uam/wmi/findmytutor/utils/PrefUtils.java index b60ffbc..76e281e 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/utils/PrefUtils.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/utils/PrefUtils.java @@ -188,5 +188,13 @@ public class PrefUtils { public static String getCurrentManualLocation(Context context) { return getSharedPreferences(context).getString("current_manual_location", null); } + public static void putCurrentManualLocationName(Context context, String locationName) { + SharedPreferences.Editor editor = getSharedPreferences(context).edit(); + editor.putString("current_manual_location_name", locationName); + editor.apply(); + } + public static String getCurrentManualLocationName(Context context) { + return getSharedPreferences(context).getString("current_manual_location_name", null); + } } \ No newline at end of file