minor adjustments

This commit is contained in:
marcin.jedynski 2019-01-04 03:48:16 +01:00
parent 8a88629b9a
commit bc6e5179c7
5 changed files with 19 additions and 29 deletions

View File

@ -93,7 +93,7 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
}else{ }else{
enableStatusPreferences(); enableStatusPreferences();
} }
Log.d("STATUSES",Integer.toString(statusesArray.length )); // Log.d("STATUSES",Integer.toString(statusesArray.length ));
setListPreferenceData(statusList, statusesArray, null); setListPreferenceData(statusList, statusesArray, null);
} }
@ -131,8 +131,6 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
preferenceCategory.removePreference(manualLocationButton); preferenceCategory.removePreference(manualLocationButton);
}else{ }else{
if(predefinedCoordsList.isEmpty()){ if(predefinedCoordsList.isEmpty()){
Log.d("SANITY","yeblo");
Log.d("SANITY",predefinedCoordsList.toString());
locationSharing.setEnabled(false); locationSharing.setEnabled(false);
locationSharing.setChecked(false); locationSharing.setChecked(false);
PrefUtils.disableSharing(getApplicationContext()); PrefUtils.disableSharing(getApplicationContext());
@ -141,8 +139,6 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
manualLocationList.setEnabled(false); manualLocationList.setEnabled(false);
manualLocationList.setSummary(""); manualLocationList.setSummary("");
}else{ }else{
Log.d("SANITY","niepojszo");
Log.d("SANITY",predefinedCoordsList.toString());
manualLocationList.setEnabled(true); manualLocationList.setEnabled(true);
manualLocationList.setSummary(PrefUtils.getCurrentManualLocationName(getApplicationContext())); manualLocationList.setSummary(PrefUtils.getCurrentManualLocationName(getApplicationContext()));
removeManualLocation.setEnabled(true); removeManualLocation.setEnabled(true);
@ -207,14 +203,6 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
statusList.setSummary(PrefUtils.getUserStatus(getApplicationContext())); statusList.setSummary(PrefUtils.getUserStatus(getApplicationContext()));
manualLocationList.setSummary(PrefUtils.getCurrentManualLocationName(getApplicationContext())); manualLocationList.setSummary(PrefUtils.getCurrentManualLocationName(getApplicationContext()));
// Log.d("STATUS",statusesArray[0]);
// && PrefUtils.getLocationLevel(getApplicationContext()).equals("manual"
/* if(predefinedLocationsList.isEmpty()){
manualLocationList.setEnabled(false);
manualLocationList.setSummary("");
removeManualLocation.setEnabled(false);
}*/
/** Main sharing switch**/ /** Main sharing switch**/
locationSharing.setOnPreferenceChangeListener((buttonView, newValue) -> { locationSharing.setOnPreferenceChangeListener((buttonView, newValue) -> {
@ -229,24 +217,21 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
PrefUtils.storeLocationMode(getApplicationContext(), locationLevelMapping.get(Integer.parseInt((String) newValue))); PrefUtils.storeLocationMode(getApplicationContext(), locationLevelMapping.get(Integer.parseInt((String) newValue)));
if (PrefUtils.getLocationLevel(getApplicationContext()).equals(SharingLevel.MANUAL.toString())) { if (PrefUtils.getLocationLevel(getApplicationContext()).equals(SharingLevel.MANUAL.toString())) {
if (!predefinedCoordsList.isEmpty()) { if (!predefinedCoordsList.isEmpty()) {
// Log.d("SANITY","niepojszo");
// Log.d("SANITY",predefinedCoordsList.toString());
preferenceCategory.addPreference(manualLocationList); preferenceCategory.addPreference(manualLocationList);
preferenceCategory.addPreference(removeManualLocation); preferenceCategory.addPreference(removeManualLocation);
}else{ }else{
// Log.d("SANITY","pojszło");
locationSharing.setEnabled(false); locationSharing.setEnabled(false);
locationSharing.setChecked(false);
PrefUtils.disableSharing(getApplicationContext());
((MapActivity) getActivity()).handleBackgroundTaskLifeCycle();
} }
preferenceCategory.addPreference(manualLocationButton); preferenceCategory.addPreference(manualLocationButton);
} else { } else {
locationSharing.setEnabled(true); locationSharing.setEnabled(true);
preferenceCategory.removePreference(manualLocationList); preferenceCategory.removePreference(manualLocationList);
preferenceCategory.removePreference(manualLocationButton); preferenceCategory.removePreference(manualLocationButton);
preferenceCategory.removePreference(removeManualLocation); preferenceCategory.removePreference(removeManualLocation);
} }
return true; return true;
}); });
@ -319,7 +304,7 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
public void showRemoveDialog(CharSequence[] entries, String service){ public void showRemoveDialog(CharSequence[] entries, String service){
boolean [] checked = new boolean[entries.length]; boolean [] checked = new boolean[entries.length];
ArrayList<String> tobeDeleted = new ArrayList<String>(); ArrayList<String> tobeDeleted = new ArrayList<String>();
Log.d("sharingDialog", "no to siup"); // Log.d("sharingDialog", "no to siup");
builder.setPositiveButton("DELETE", new DialogInterface.OnClickListener() { builder.setPositiveButton("DELETE", new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
@ -329,7 +314,7 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
} }
} }
removeEntries(service,tobeDeleted); removeEntries(service,tobeDeleted);
Log.d("MANAGE-PREF",tobeDeleted.toString()); // Log.d("MANAGE-PREF",tobeDeleted.toString());
} }
}); });
builder.setMultiChoiceItems(entries, checked, new DialogInterface.OnMultiChoiceClickListener() { builder.setMultiChoiceItems(entries, checked, new DialogInterface.OnMultiChoiceClickListener() {
@ -351,7 +336,7 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
protected void removeEntries(String service, ArrayList<String> toBeDeleted){ protected void removeEntries(String service, ArrayList<String> toBeDeleted){
Log.d("MANAGE-PREF", toBeDeleted.toString()); // Log.d("MANAGE-PREF", toBeDeleted.toString());
if(service.equals("status")){ if(service.equals("status")){
for (String uuid:toBeDeleted) { for (String uuid:toBeDeleted) {
disposable.add(statusesService.deleteUserPredefinedStatus(PrefUtils.getUserId(getApplicationContext()), uuid) disposable.add(statusesService.deleteUserPredefinedStatus(PrefUtils.getUserId(getApplicationContext()), uuid)
@ -449,12 +434,10 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
getLocations(disposable); getLocations(disposable);
String currentEntry = PrefUtils.getCurrentManualLocation(getApplicationContext()); String currentEntry = PrefUtils.getCurrentManualLocation(getApplicationContext());
if(resp.isEmpty()){ if(resp.isEmpty()){
Log.d("LOKACJE puste",resp.toString());
disableManualLocationPreferences(); disableManualLocationPreferences();
}else{ }else{
if(!Stream.of(resp).filter(x -> x.getName().equals(currentEntry)).toList().isEmpty()) if(!Stream.of(resp).filter(x -> x.getName().equals(currentEntry)).toList().isEmpty())
{ {
Log.d("LOKACJE pełne",resp.toString());
for (PredefinedCoordViewModel location: resp) { for (PredefinedCoordViewModel location: resp) {
if(location.getName().equals(currentEntry)){ if(location.getName().equals(currentEntry)){
manualLocationList.setValueIndex(resp.indexOf(location)); manualLocationList.setValueIndex(resp.indexOf(location));

View File

@ -22,8 +22,10 @@ public class RightButtonPreference extends Preference {
String attr = attrs.getAttributeName(i); String attr = attrs.getAttributeName(i);
String val = attrs.getAttributeValue(i); String val = attrs.getAttributeValue(i);
if (attr.equalsIgnoreCase("text")) { if (attr.equalsIgnoreCase("text")) {
buttonText = val; // buttonText = val;
Log.d("RightButtonPreference", "step = " + val); Log.d("RightButtonPreference", "step = " + val);
buttonText = context.getResources().getString(Integer.parseInt(val.substring(1)));
} }
} }

View File

@ -30,12 +30,12 @@
android:title="@string/title_list_manual_location" /> android:title="@string/title_list_manual_location" />
<com.uam.wmi.findmytutor.utils.RightButtonPreference <com.uam.wmi.findmytutor.utils.RightButtonPreference
android:key="manual_location_button" android:key="manual_location_button"
android:text="CHOOSE FROM MAP" android:text="@string/preference_manual_location_button"
/> />
<com.uam.wmi.findmytutor.utils.RightButtonPreference <com.uam.wmi.findmytutor.utils.RightButtonPreference
android:key="remove_manual_location" android:key="remove_manual_location"
android:text="Manage Saved" android:text="@string/preference_manual_location_button_remove"
/> />
</PreferenceCategory> </PreferenceCategory>
@ -59,7 +59,7 @@
/> />
<com.uam.wmi.findmytutor.utils.RightButtonPreference <com.uam.wmi.findmytutor.utils.RightButtonPreference
android:key="remove_manual_status" android:key="remove_manual_status"
android:text="Manage Saved" android:text="@string/preference_manual_status_button_remove"
/> />
</PreferenceCategory> </PreferenceCategory>

View File

@ -239,6 +239,8 @@
<string name="negative_dialog_button">Nie</string> <string name="negative_dialog_button">Nie</string>
<string name="enable_sharing_question">Aby skorzystać z tej funkcji musisz pozwolić na udostępnianie lokalizacji. Zgadzasz sie?</string> <string name="enable_sharing_question">Aby skorzystać z tej funkcji musisz pozwolić na udostępnianie lokalizacji. Zgadzasz sie?</string>
<string name="sharing_modal_title">Udostępnianie</string> <string name="sharing_modal_title">Udostępnianie</string>
<string name="preference_manual_location_button_remove">Zarządzaj zapisanymi</string>
<string name="preference_manual_status_button_remove">Zarządzaj zapisanymi</string>
</resources> </resources>

View File

@ -69,6 +69,9 @@
<string name="location_level_precise">Exact</string> <string name="location_level_precise">Exact</string>
<string name="location_level_manual">Manual</string> <string name="location_level_manual">Manual</string>
<string name="preference_manual_location_button">Choose from map</string> <string name="preference_manual_location_button">Choose from map</string>
<string name="preference_manual_location_button_remove">Manage saved</string>
<string name="preference_manual_status_button_remove">Manage saved</string>
<string name="settings_location_level">Location level</string> <string name="settings_location_level">Location level</string>
<string name="key_location_level">key_location_level</string> <string name="key_location_level">key_location_level</string>