Merge branch 'develop' into infoIcons

This commit is contained in:
Domagalski 2018-12-15 14:48:05 +01:00
commit 7dd3e0cc00
2 changed files with 12 additions and 13 deletions

View File

@ -42,7 +42,7 @@ import static com.mapbox.mapboxsdk.Mapbox.getApplicationContext;
public class SharingFragment extends PreferenceFragment { public class SharingFragment extends PreferenceFragment {
protected Preference locationSharing; protected Preference locationSharing;
protected Preference locationMode; protected Preference locationMode;
protected Preference manualLocationList; protected ListPreference manualLocationList;
protected PreferenceCategory preferenceCategory; protected PreferenceCategory preferenceCategory;
protected RightButtonPreference manualLocationButton; protected RightButtonPreference manualLocationButton;
protected Preference manualStatus; protected Preference manualStatus;
@ -66,7 +66,7 @@ public class SharingFragment extends PreferenceFragment {
@Override @Override
public void onSuccess(List<String> strings) { public void onSuccess(List<String> strings) {
String[] statusesArray = strings.toArray(new String[strings.size()]); String[] statusesArray = strings.toArray(new String[strings.size()]);
setListPreferenceData(statusList.getKey(), statusesArray,null); setListPreferenceData(statusList, statusesArray,null);
} }
@Override @Override
@ -94,11 +94,10 @@ public class SharingFragment extends PreferenceFragment {
.filter(v -> v.getSecond().getPredefinedCoordinateId().equals(currentCoordId)).map(IntPair::getFirst).toList(); .filter(v -> v.getSecond().getPredefinedCoordinateId().equals(currentCoordId)).map(IntPair::getFirst).toList();
if(activeId.size() > 0) if(activeId.size() > 0)
setListPreferenceData(manualLocationList.getKey(), stringnames, activeId.get(0)); setListPreferenceData(manualLocationList, stringnames, activeId.get(0));
else{ else{
setListPreferenceData(manualLocationList.getKey(), stringnames,null); setListPreferenceData(manualLocationList, stringnames,null);
} }
Log.d("sharingpref", names.toString());
} }
@Override @Override
@ -117,15 +116,14 @@ public class SharingFragment extends PreferenceFragment {
locationSharing = findPreference("key_sharing_enabled"); locationSharing = findPreference("key_sharing_enabled");
locationMode = findPreference("key_location_level"); locationMode = findPreference("key_location_level");
preferenceCategory = (PreferenceCategory) findPreference("category_sharing"); preferenceCategory = (PreferenceCategory) findPreference("category_sharing");
manualLocationList = findPreference("key_manual_location_value"); manualLocationList = (ListPreference) findPreference("key_manual_location_value");
manualLocationButton = (RightButtonPreference) findPreference("manual_location_button"); manualLocationButton = (RightButtonPreference) findPreference("manual_location_button");
manualStatus = findPreference("key_manual_status"); manualStatus = findPreference("key_manual_status");
statusList = (ListPreference) findPreference("key_status_value"); statusList = (ListPreference) findPreference("key_status_value");
statusesService = ApiClient.getClient(getApplicationContext()).create(PredefinedStatusesService.class); statusesService = ApiClient.getClient(getApplicationContext()).create(PredefinedStatusesService.class);
disposable = new CompositeDisposable(); disposable = new CompositeDisposable();
getStatuses(disposable); getStatuses(disposable);
getLocations(disposable); getLocations(disposable);
locationLevelMapping = new HashMap<Integer, String>(); locationLevelMapping = new HashMap<Integer, String>();
locationLevelMapping.put(0, SharingLevel.PRESENCE.toString()); locationLevelMapping.put(0, SharingLevel.PRESENCE.toString());
locationLevelMapping.put(1, SharingLevel.APPROXIMATED.toString()); locationLevelMapping.put(1, SharingLevel.APPROXIMATED.toString());
@ -229,9 +227,9 @@ public class SharingFragment extends PreferenceFragment {
return view; return view;
} }
protected void setListPreferenceData(String lp_name, String[] entries, Integer activeId) { protected void setListPreferenceData(ListPreference lp, String[] entries, Integer activeId) {
Log.d("setlistpref",lp.getKey());
try { try {
ListPreference lp = (ListPreference) findPreference(lp_name);
lp.setEntries(entries); lp.setEntries(entries);
CharSequence[] entryValues = new CharSequence[entries.length]; CharSequence[] entryValues = new CharSequence[entries.length];
@ -244,9 +242,9 @@ public class SharingFragment extends PreferenceFragment {
if(entries.length > 0 && activeId != null) if(entries.length > 0 && activeId != null)
lp.setValueIndex(activeId); lp.setValueIndex(activeId);
}catch (Exception e){ }catch (Exception e){
// Toast.makeText(getApplicationContext(), Log.e("Failed to set listPref",e.getMessage());
// "duupa", Toast.LENGTH_SHORT).show();
} }
}; };
@ -254,7 +252,7 @@ public class SharingFragment extends PreferenceFragment {
private void handleResponse(List<String> resp) { private void handleResponse(List<String> resp) {
String[] statusesArray = resp.toArray(new String[resp.size()]); String[] statusesArray = resp.toArray(new String[resp.size()]);
setListPreferenceData(statusList.getKey(), statusesArray,resp.size() - 1); setListPreferenceData(statusList, statusesArray,resp.size() - 1);
statusList.setValueIndex(resp.size() - 1); statusList.setValueIndex(resp.size() - 1);
PrefUtils.storeStatus(getApplicationContext(), resp.get(resp.size() - 1)); PrefUtils.storeStatus(getApplicationContext(), resp.get(resp.size() - 1));

View File

@ -26,6 +26,7 @@
android:summary="%s" android:summary="%s"
android:title="@string/title_location_level" /> android:title="@string/title_location_level" />
<ListPreference <ListPreference
android:defaultValue="0"
android:key="key_manual_location_value" android:key="key_manual_location_value"
android:summary="%s" android:summary="%s"
android:title="@string/title_list_manual_location" /> android:title="@string/title_list_manual_location" />