Merge branch 'fixUXSharingTab' of s416084/find-my-tutor-android into develop

This commit is contained in:
Marcin Jedyński 2018-12-10 00:53:24 +00:00 committed by Gogs
commit f4a0c71a18
6 changed files with 37 additions and 26 deletions

View File

@ -149,10 +149,9 @@ public class LoginActivity extends AppCompatActivity {
private void loginProcess(String email, String password) { private void loginProcess(String email, String password) {
ValidateUser user = new ValidateUser(email, password); ValidateUser user = new ValidateUser(email, password);
LdapUser fakeUser = new LdapUser(email, password,"wmi","tutor",email,"Fałszywy",email); // LdapUser fakeUser = new LdapUser(email, password,"wmi","tutor",email,"Fałszywy",email);
// disposable.add(ldapService.fakeValidate(fakeUser) // disposable.add(ldapService.fakeValidate(fakeUser)
// disposable.add(ldapService.validate(user) disposable.add(ldapService.validate(user)
disposable.add(ldapService.fakeValidate(fakeUser)
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe(this::handleResponse, this::handleError)); .subscribe(this::handleResponse, this::handleError));

View File

@ -338,6 +338,7 @@ public class MapActivity extends BaseActivity
modalUserInput.requestFocus(); modalUserInput.requestFocus();
} else { } else {
sendLocation(body, latLng); sendLocation(body, latLng);
PrefUtils.putCurrentManualLocationName(getApplicationContext(),body);
alertDialog.dismiss(); alertDialog.dismiss();
} }
}); });

View File

@ -98,11 +98,12 @@ public class SharingFragment extends PreferenceFragment {
else{ else{
setListPreferenceData(manualLocationList.getKey(), stringnames,null); setListPreferenceData(manualLocationList.getKey(), stringnames,null);
} }
Log.d("sharingpref", names.toString());
} }
@Override @Override
public void onError(Throwable e) { public void onError(Throwable e) {
Toast.makeText(getApplicationContext(), R.string.manual_status_error, Toast.LENGTH_SHORT).show(); Toast.makeText(getApplicationContext(), R.string.error_location_fetch, Toast.LENGTH_SHORT).show();
} }
})); }));
@ -123,14 +124,7 @@ public class SharingFragment extends PreferenceFragment {
statusesService = ApiClient.getClient(getApplicationContext()).create(PredefinedStatusesService.class); statusesService = ApiClient.getClient(getApplicationContext()).create(PredefinedStatusesService.class);
disposable = new CompositeDisposable(); disposable = new CompositeDisposable();
getStatuses(disposable); getStatuses(disposable);
if (PrefUtils.getLocationLevel(getApplicationContext()).equals("manual")) {
getLocations(disposable); getLocations(disposable);
}
Log.d("SHAR TAB", (String) statusList.getSummary());
Log.d("SHAR TAB",( String) manualLocationList.getSummary());
// Log.d("SHAR TAB","dupa");
locationLevelMapping = new HashMap<Integer, String>(); locationLevelMapping = new HashMap<Integer, String>();
locationLevelMapping.put(0, SharingLevel.PRESENCE.toString()); locationLevelMapping.put(0, SharingLevel.PRESENCE.toString());
@ -158,9 +152,10 @@ public class SharingFragment extends PreferenceFragment {
PrefUtils.storeLocationMode(getApplicationContext(), locationLevelMapping.get(Integer.parseInt((String) newValue))); PrefUtils.storeLocationMode(getApplicationContext(), locationLevelMapping.get(Integer.parseInt((String) newValue)));
if (PrefUtils.getLocationLevel(getApplicationContext()).equals("manual")) { if (PrefUtils.getLocationLevel(getApplicationContext()).equals("manual")) {
if(!predefinedCoordsList.isEmpty()){
preferenceCategory.addPreference(manualLocationList); preferenceCategory.addPreference(manualLocationList);
getLocations(disposable); }
preferenceCategory.addPreference(manualLocationButton); preferenceCategory.addPreference(manualLocationButton);
} else { } else {
@ -174,6 +169,12 @@ public class SharingFragment extends PreferenceFragment {
if (!PrefUtils.getLocationLevel(getApplicationContext()).equals("manual")) { if (!PrefUtils.getLocationLevel(getApplicationContext()).equals("manual")) {
preferenceCategory.removePreference(manualLocationList); preferenceCategory.removePreference(manualLocationList);
preferenceCategory.removePreference(manualLocationButton); preferenceCategory.removePreference(manualLocationButton);
}else{
// if(predefinedCoordsList.isEmpty()){
//// preferenceCategory.removePreference(manualLocationList);
//
//
// }
} }
/** Custom manual location list change listener **/ /** Custom manual location list change listener **/
@ -217,6 +218,7 @@ public class SharingFragment extends PreferenceFragment {
return true; return true;
}); });
} }
@Override @Override
@ -228,6 +230,7 @@ public class SharingFragment extends PreferenceFragment {
} }
protected void setListPreferenceData(String lp_name, String[] entries, Integer activeId) { protected void setListPreferenceData(String lp_name, String[] entries, Integer activeId) {
try {
ListPreference lp = (ListPreference) findPreference(lp_name); ListPreference lp = (ListPreference) findPreference(lp_name);
lp.setEntries(entries); lp.setEntries(entries);
CharSequence[] entryValues = new CharSequence[entries.length]; CharSequence[] entryValues = new CharSequence[entries.length];
@ -241,6 +244,11 @@ 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){
// Toast.makeText(getApplicationContext(),
// "duupa", Toast.LENGTH_SHORT).show();
}
}; };
private void handleResponse(List<String> resp) { private void handleResponse(List<String> resp) {
@ -250,6 +258,8 @@ public class SharingFragment extends PreferenceFragment {
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));
statusList.setSummary(PrefUtils.getUserStatus(getApplicationContext()));
} }

View File

@ -62,7 +62,7 @@ public class PrefUtils {
} }
public static String getUserStatus(Context context) { public static String getUserStatus(Context context) {
return getSharedPreferences(context).getString("status_entry", "Available"); return getSharedPreferences(context).getString("status_entry", "Dostępny");
} }
public static void storeStatus(Context context, String status) { public static void storeStatus(Context context, String status) {

View File

@ -41,7 +41,7 @@
android:persistent="true" android:persistent="true"
android:title="@string/status_switch_title"/> android:title="@string/status_switch_title"/>
<ListPreference <ListPreference
android:defaultValue="1" android:defaultValue="2"
android:key="@string/key_status_value" android:key="@string/key_status_value"
android:summary="%s" android:summary="%s"
android:title="@string/status_list_title" /> android:title="@string/status_list_title" />

View File

@ -233,6 +233,7 @@
<string name="network_error">Network Error!</string> <string name="network_error">Network Error!</string>
<string name="manual_status_error">Error handling status fetch</string> <string name="manual_status_error">Error handling status fetch</string>
<string name="error_status_fetch">Error handling status fetch</string> <string name="error_status_fetch">Error handling status fetch</string>
<string name="error_location_fetch">Error handling status fetch</string>
<string name="pref_acra_disabled" translatable="false">Auto reporting on issue is OFF</string> <string name="pref_acra_disabled" translatable="false">Auto reporting on issue is OFF</string>
<string name="pref_acra_enabled" translatable="false">Auto reporting on issue is ON</string> <string name="pref_acra_enabled" translatable="false">Auto reporting on issue is ON</string>