From 2d93b231979dc93b0d1c223ff93ee8c463f9fb06 Mon Sep 17 00:00:00 2001 From: "marcin.jedynski" Date: Sun, 6 Jan 2019 22:54:01 +0100 Subject: [PATCH 1/2] revered sharing tab UI disabling to wait for api response --- .idea/misc.xml | 2 +- .../findmytutor/activity/SharingFragment.java | 56 +++++++++++-------- 2 files changed, 33 insertions(+), 25 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index dc44dda..b0c7b20 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -29,7 +29,7 @@ - + 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 5e900e7..1033d9e 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 @@ -123,7 +123,26 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere List predefinedLocationsNames = Stream.of(coords).map(PredefinedCoordViewModel::getName).toList(); List predefinedLocationsUUIDs = Stream.of(coords).map(PredefinedCoordViewModel::getPredefinedCoordinateId).toList(); predefinedCoordsList.addAll(coords); - + if (!PrefUtils.getLocationLevel(getApplicationContext()).equals("manual")) { + preferenceCategory.removePreference(manualLocationList); + preferenceCategory.removePreference(removeManualLocation); + preferenceCategory.removePreference(manualLocationButton); + }else{ + if(predefinedCoordsList.isEmpty()){ + locationSharing.setEnabled(false); + locationSharing.setChecked(false); + PrefUtils.disableSharing(getApplicationContext()); + ((MapActivity) getActivity()).handleBackgroundTaskLifeCycle(); + removeManualLocation.setEnabled(false); + manualLocationList.setEnabled(false); + manualLocationList.setSummary(""); + }else{ + manualLocationList.setEnabled(true); + manualLocationList.setSummary(PrefUtils.getCurrentManualLocationName(getApplicationContext())); + removeManualLocation.setEnabled(true); + locationSharing.setEnabled(true); + } + } String[] stringnames = predefinedLocationsNames.toArray(new String[0]); predefinedLocationsList = new ArrayList<>(Arrays.asList(stringnames)); List activesId = Stream.of(coords).indexed() @@ -180,26 +199,7 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere statusMapping.put(0, "available"); statusMapping.put(1, "consultation"); statusMapping.put(2, "busy"); - if (!PrefUtils.getLocationLevel(getApplicationContext()).equals("manual")) { - preferenceCategory.removePreference(manualLocationList); - preferenceCategory.removePreference(removeManualLocation); - preferenceCategory.removePreference(manualLocationButton); - }else{ - if(predefinedCoordsList.isEmpty()){ - locationSharing.setEnabled(false); - locationSharing.setChecked(false); - PrefUtils.disableSharing(getApplicationContext()); - ((MapActivity) getActivity()).handleBackgroundTaskLifeCycle(); - removeManualLocation.setEnabled(false); - manualLocationList.setEnabled(false); - manualLocationList.setSummary(""); - }else{ - manualLocationList.setEnabled(true); - manualLocationList.setSummary(PrefUtils.getCurrentManualLocationName(getApplicationContext())); - removeManualLocation.setEnabled(true); - locationSharing.setEnabled(true); - } - } + statusList.setSummary(PrefUtils.getUserStatus(getApplicationContext())); manualLocationList.setSummary(PrefUtils.getCurrentManualLocationName(getApplicationContext())); @@ -214,10 +214,18 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere /** Sharing level list **/ locationMode.setOnPreferenceChangeListener((preference, newValue) -> { - ((MapActivity) getActivity()).stopBackgroundLocalizationTask(); - ((MapActivity) getActivity()).startBackgroundLocalizationTask(); + PrefUtils.storeLocationMode(getApplicationContext(), locationLevelMapping.get(Integer.parseInt((String) newValue))); + +// if(PrefUtils.getLocationLevel(getApplicationContext()).equals(SharingLevel.MANUAL.toString()) && predefinedCoordsList.isEmpty()){ +/* Log.d("OTSOCHOZI","pyklo"); + }else{ + Log.d("OTSOCHOZI","niepyklo");*/ + + ((MapActivity) getActivity()).stopBackgroundLocalizationTask(); + ((MapActivity) getActivity()).startBackgroundLocalizationTask(); +// } + - PrefUtils.storeLocationMode(getApplicationContext(), locationLevelMapping.get(Integer.parseInt((String) newValue))); if (PrefUtils.getLocationLevel(getApplicationContext()).equals(SharingLevel.MANUAL.toString())) { if (!predefinedCoordsList.isEmpty()) { preferenceCategory.addPreference(manualLocationList); From 3e7e77a430d6a8dabf401ec182304948e2f03ead Mon Sep 17 00:00:00 2001 From: "marcin.jedynski" Date: Sun, 6 Jan 2019 22:55:36 +0100 Subject: [PATCH 2/2] revered sharing tab UI disabling to wait for api response, minor fix --- .../com/uam/wmi/findmytutor/activity/SharingFragment.java | 8 -------- 1 file changed, 8 deletions(-) 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 1033d9e..53bf08f 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 @@ -216,16 +216,8 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere locationMode.setOnPreferenceChangeListener((preference, newValue) -> { PrefUtils.storeLocationMode(getApplicationContext(), locationLevelMapping.get(Integer.parseInt((String) newValue))); -// if(PrefUtils.getLocationLevel(getApplicationContext()).equals(SharingLevel.MANUAL.toString()) && predefinedCoordsList.isEmpty()){ -/* Log.d("OTSOCHOZI","pyklo"); - }else{ - Log.d("OTSOCHOZI","niepyklo");*/ - ((MapActivity) getActivity()).stopBackgroundLocalizationTask(); ((MapActivity) getActivity()).startBackgroundLocalizationTask(); -// } - - if (PrefUtils.getLocationLevel(getApplicationContext()).equals(SharingLevel.MANUAL.toString())) { if (!predefinedCoordsList.isEmpty()) { preferenceCategory.addPreference(manualLocationList);