Merge branch 'fixUXSharingTab' of s416084/find-my-tutor-android into develop
This commit is contained in:
commit
5fe12a3f4b
@ -21,6 +21,7 @@ import com.auth0.android.jwt.JWT;
|
||||
import com.jakewharton.retrofit2.adapter.rxjava2.HttpException;
|
||||
import com.uam.wmi.findmytutor.R;
|
||||
import com.uam.wmi.findmytutor.model.JwtToken;
|
||||
import com.uam.wmi.findmytutor.model.LdapUser;
|
||||
import com.uam.wmi.findmytutor.model.User;
|
||||
import com.uam.wmi.findmytutor.model.ValidateUser;
|
||||
import com.uam.wmi.findmytutor.network.ApiClient;
|
||||
@ -148,8 +149,10 @@ public class LoginActivity extends AppCompatActivity {
|
||||
|
||||
private void loginProcess(String email, String password) {
|
||||
ValidateUser user = new ValidateUser(email, password);
|
||||
|
||||
disposable.add(ldapService.validate(user)
|
||||
LdapUser fakeUser = new LdapUser(email, password,"wmi","tutor",email,"Fałszywy",email);
|
||||
// disposable.add(ldapService.fakeValidate(fakeUser)
|
||||
// disposable.add(ldapService.validate(user)
|
||||
disposable.add(ldapService.fakeValidate(fakeUser)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(this::handleResponse, this::handleError));
|
||||
|
@ -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,strings.size() -1);
|
||||
setListPreferenceData(statusList.getKey(), statusesArray,null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -120,7 +120,6 @@ public class SharingFragment extends PreferenceFragment {
|
||||
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);
|
||||
@ -128,6 +127,10 @@ public class SharingFragment extends PreferenceFragment {
|
||||
if (PrefUtils.getLocationLevel(getApplicationContext()).equals("manual")) {
|
||||
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.put(0, SharingLevel.PRESENCE.toString());
|
||||
@ -140,6 +143,9 @@ public class SharingFragment extends PreferenceFragment {
|
||||
statusMapping.put(1, "consultation");
|
||||
statusMapping.put(2, "busy");
|
||||
|
||||
statusList.setSummary(PrefUtils.getUserStatus(getApplicationContext()));
|
||||
manualLocationList.setSummary(PrefUtils.getCurrentManualLocationName(getApplicationContext()));
|
||||
// manualLocationList.setSummary(PrefUtils.getManualLocation(getApplicationContext()));
|
||||
/** Main sharing switch**/
|
||||
locationSharing.setOnPreferenceChangeListener((buttonView, newValue) -> {
|
||||
PrefUtils.storeEnableSharingLocalization(getApplicationContext(), (Boolean) newValue);
|
||||
@ -173,11 +179,12 @@ public class SharingFragment extends PreferenceFragment {
|
||||
/** Custom manual location list change listener **/
|
||||
manualLocationList.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
ListPreference lp = (ListPreference) preference;
|
||||
|
||||
CharSequence[] entries = lp.getEntries();
|
||||
PredefinedCoordViewModel temp = Stream.of(predefinedCoordsList).filter(p -> p.getName().equals(lp.getEntries()[Integer.parseInt((String) newValue)].toString())).toList().get(0);
|
||||
|
||||
PrefUtils.putManualLocation(getApplicationContext(), temp.getGeoData(), temp.getApproximatedLocation() );
|
||||
PrefUtils.putCurrentManualLocation(getApplicationContext(),temp.getPredefinedCoordinateId());
|
||||
PrefUtils.putCurrentManualLocationName(getApplicationContext(), (String )lp.getEntries()[Integer.parseInt((String) newValue)]);
|
||||
lp.setSummary(lp.getEntries()[Integer.parseInt((String) newValue)]);
|
||||
|
||||
return true;
|
||||
});
|
||||
@ -195,7 +202,7 @@ public class SharingFragment extends PreferenceFragment {
|
||||
ListPreference lp = (ListPreference) preference;
|
||||
CharSequence[] entries = lp.getEntries();
|
||||
PrefUtils.storeStatus(getApplicationContext(), (String) entries[Integer.parseInt((String) newValue)]);
|
||||
|
||||
lp.setSummary(entries[Integer.parseInt((String) newValue)]);
|
||||
return true;
|
||||
});
|
||||
/** Custom status list change listener **/
|
||||
|
@ -188,5 +188,13 @@ public class PrefUtils {
|
||||
public static String getCurrentManualLocation(Context context) {
|
||||
return getSharedPreferences(context).getString("current_manual_location", null);
|
||||
}
|
||||
public static void putCurrentManualLocationName(Context context, String locationName) {
|
||||
SharedPreferences.Editor editor = getSharedPreferences(context).edit();
|
||||
editor.putString("current_manual_location_name", locationName);
|
||||
editor.apply();
|
||||
}
|
||||
public static String getCurrentManualLocationName(Context context) {
|
||||
return getSharedPreferences(context).getString("current_manual_location_name", null);
|
||||
}
|
||||
|
||||
}
|
@ -26,8 +26,6 @@
|
||||
android:title="@string/title_location_level" />
|
||||
<ListPreference
|
||||
android:key="key_manual_location_value"
|
||||
android:entries="@array/manual_location_entries"
|
||||
android:entryValues="@array/manual_location_values"
|
||||
android:summary="%s"
|
||||
android:title="@string/title_list_manual_location" />
|
||||
<com.uam.wmi.findmytutor.utils.RightButtonPreference
|
||||
@ -45,8 +43,6 @@
|
||||
<ListPreference
|
||||
android:defaultValue="1"
|
||||
android:key="@string/key_status_value"
|
||||
android:entries="@array/status_entries"
|
||||
android:entryValues="@array/status_values"
|
||||
android:summary="%s"
|
||||
android:title="@string/status_list_title" />
|
||||
<EditTextPreference
|
||||
|
Loading…
Reference in New Issue
Block a user