sharing tab stable version 1.1

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

View File

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