diff --git a/app/build.gradle b/app/build.gradle index 3c500f0..06927b9 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,7 +10,7 @@ android { applicationId "com.uam.wmi.findmytutor" minSdkVersion 22 targetSdkVersion 27 - versionCode 1 + versionCode 17 versionName "0.9.2-alpha" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" vectorDrawables.useSupportLibrary = true @@ -52,7 +52,8 @@ dependencies { implementation 'com.squareup.retrofit2:converter-gson:2.4.0' implementation 'io.swagger:swagger-annotations:1.5.15' implementation 'org.threeten:threetenbp:1.3.5' - implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:6.6.5' + implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:6.7.2' + implementation 'com.mapbox.mapboxsdk:mapbox-sdk-turf:4.0.0' implementation 'io.reactivex.rxjava2:rxjava:2.2.0' implementation 'com.android.support:recyclerview-v7:27.1.1' implementation 'io.reactivex.rxjava2:rxandroid:2.1.0' @@ -66,7 +67,6 @@ dependencies { implementation 'com.auth0.android:jwtdecode:1.1.1' implementation 'com.annimon:stream:1.2.1' implementation 'com.google.android.gms:play-services-location:16.0.0' - implementation 'com.mapbox.mapboxsdk:mapbox-sdk-turf:4.0.0' // FloatingBarMenu implementation 'com.getbase:floatingactionbutton:1.10.1' implementation 'org.apache.commons:commons-collections4:4.0' diff --git a/app/release/release/app.aab b/app/release/release/app.aab index c0a50db..aa09d96 100644 Binary files a/app/release/release/app.aab and b/app/release/release/app.aab differ diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/LoginActivity.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/LoginActivity.java index 7734dd1..189f28a 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/activity/LoginActivity.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/activity/LoginActivity.java @@ -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,9 @@ public class LoginActivity extends AppCompatActivity { private void loginProcess(String email, String password) { ValidateUser user = new ValidateUser(email, password); - + //LdapUser fakeUser = new LdapUser(email, password,"wmi","tutor",email,"Fałszywy",email); disposable.add(ldapService.validate(user) + //disposable.add(ldapService.fakeValidate(fakeUser) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(this::handleResponse, this::handleError)); diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/MapActivity.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/MapActivity.java index d98fa2f..0d8b299 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/activity/MapActivity.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/activity/MapActivity.java @@ -126,7 +126,6 @@ public class MapActivity extends BaseActivity selectLocationButton = findViewById(R.id.select_location_button); removeLocationButton = findViewById(R.id.remove_location_button); - Mapbox.getInstance(this, getString(R.string.access_token)); mapView = findViewById(R.id.mapView); mapView.onCreate(savedInstanceState); mapView.getMapAsync(this); @@ -339,6 +338,7 @@ public class MapActivity extends BaseActivity modalUserInput.requestFocus(); } else { sendLocation(body, latLng); + PrefUtils.putCurrentManualLocationName(getApplicationContext(),body); alertDialog.dismiss(); } }); @@ -637,6 +637,7 @@ public class MapActivity extends BaseActivity @Override protected int getContentViewId() { + Mapbox.getInstance(this, getString(R.string.access_token)); return R.layout.activity_map; } diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/SharingFragment.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/SharingFragment.java index eb76a2a..494581f 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/activity/SharingFragment.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/activity/SharingFragment.java @@ -66,7 +66,7 @@ public class SharingFragment extends PreferenceFragment { @Override public void onSuccess(List strings) { String[] statusesArray = strings.toArray(new String[strings.size()]); - setListPreferenceData(statusList.getKey(), statusesArray,strings.size() -1); + setListPreferenceData(statusList.getKey(), statusesArray,null); } @Override @@ -98,11 +98,12 @@ public class SharingFragment extends PreferenceFragment { else{ setListPreferenceData(manualLocationList.getKey(), stringnames,null); } + Log.d("sharingpref", names.toString()); } @Override 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(); } })); @@ -120,14 +121,10 @@ 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); - - if (PrefUtils.getLocationLevel(getApplicationContext()).equals("manual")) { - getLocations(disposable); - } + getLocations(disposable); locationLevelMapping = new HashMap(); locationLevelMapping.put(0, SharingLevel.PRESENCE.toString()); @@ -140,6 +137,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); @@ -152,9 +152,10 @@ public class SharingFragment extends PreferenceFragment { PrefUtils.storeLocationMode(getApplicationContext(), locationLevelMapping.get(Integer.parseInt((String) newValue))); if (PrefUtils.getLocationLevel(getApplicationContext()).equals("manual")) { + if(!predefinedCoordsList.isEmpty()){ + preferenceCategory.addPreference(manualLocationList); + } - preferenceCategory.addPreference(manualLocationList); - getLocations(disposable); preferenceCategory.addPreference(manualLocationButton); } else { @@ -168,16 +169,23 @@ public class SharingFragment extends PreferenceFragment { if (!PrefUtils.getLocationLevel(getApplicationContext()).equals("manual")) { preferenceCategory.removePreference(manualLocationList); preferenceCategory.removePreference(manualLocationButton); + }else{ +// if(predefinedCoordsList.isEmpty()){ +//// preferenceCategory.removePreference(manualLocationList); +// +// +// } } /** 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 +203,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 **/ @@ -210,6 +218,7 @@ public class SharingFragment extends PreferenceFragment { return true; }); + } @Override @@ -221,19 +230,25 @@ public class SharingFragment extends PreferenceFragment { } protected void setListPreferenceData(String lp_name, String[] entries, Integer activeId) { - ListPreference lp = (ListPreference) findPreference(lp_name); - lp.setEntries(entries); - CharSequence[] entryValues = new CharSequence[entries.length]; + try { + ListPreference lp = (ListPreference) findPreference(lp_name); + lp.setEntries(entries); + CharSequence[] entryValues = new CharSequence[entries.length]; - for (int i = 0; i < entries.length; i++) { - entryValues[i] = Integer.toString(i); - } + for (int i = 0; i < entries.length; i++) { + entryValues[i] = Integer.toString(i); + } - lp.setDefaultValue(0); - lp.setEntryValues(entryValues); + lp.setDefaultValue(0); + lp.setEntryValues(entryValues); + + if(entries.length > 0 && activeId != null) + lp.setValueIndex(activeId); + }catch (Exception e){ +// Toast.makeText(getApplicationContext(), +// "duupa", Toast.LENGTH_SHORT).show(); + } - if(entries.length > 0 && activeId != null) - lp.setValueIndex(activeId); }; private void handleResponse(List resp) { @@ -243,6 +258,8 @@ public class SharingFragment extends PreferenceFragment { statusList.setValueIndex(resp.size() - 1); PrefUtils.storeStatus(getApplicationContext(), resp.get(resp.size() - 1)); + statusList.setSummary(PrefUtils.getUserStatus(getApplicationContext())); + } diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/UsersListFragment.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/UsersListFragment.java index 4430e89..c6e68fd 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/activity/UsersListFragment.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/activity/UsersListFragment.java @@ -210,6 +210,7 @@ public class UsersListFragment extends Fragment { @Override public void onSuccess(List users) { tutorsList.clear(); + tutorsFiltered.clear(); tutorsList.addAll(users); tutorsFiltered.addAll(users); mAdapter.notifyDataSetChanged(); diff --git a/app/src/main/java/com/uam/wmi/findmytutor/model/Coordinate.java b/app/src/main/java/com/uam/wmi/findmytutor/model/Coordinate.java index 0323cfd..7a75d9d 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/model/Coordinate.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/model/Coordinate.java @@ -20,9 +20,6 @@ public class Coordinate extends BaseResponse { private Range longtitudeRange = Const.buildingLongitudeRange; private List allowedApproximatedLocations = Const.validApproximatedLocations; - @SerializedName("coordinateId") - private UUID coordinateId = null; - @SerializedName("latitude") private Double latitude; @@ -66,23 +63,9 @@ public class Coordinate extends BaseResponse { } public Coordinate coordinateId(UUID coordinateId) { - this.coordinateId = coordinateId; return this; } - /** - * Get coordinateId - * @return coordinateId - **/ - @ApiModelProperty(required = true, value = "") - public UUID getCoordinateId() { - return coordinateId; - } - - public void setCoordinateId(UUID coordinateId) { - this.coordinateId = coordinateId; - } - public Coordinate latitude(Double latitude) { this.latitude = latitude; return this; @@ -236,8 +219,7 @@ public class Coordinate extends BaseResponse { return false; } Coordinate coordinate = (Coordinate) o; - return Objects.equals(this.coordinateId, coordinate.coordinateId) && - Objects.equals(this.latitude, coordinate.latitude) && + return Objects.equals(this.latitude, coordinate.latitude) && Objects.equals(this.longitude, coordinate.longitude) && Objects.equals(this.altitude, coordinate.altitude) && Objects.equals(this.userId, coordinate.userId) && @@ -249,7 +231,7 @@ public class Coordinate extends BaseResponse { @Override public int hashCode() { - return Objects.hash(coordinateId, latitude, longitude, altitude, userId, approximatedLocation, displayMode, timeStamp, label); + return Objects.hash( latitude, longitude, altitude, userId, approximatedLocation, displayMode, timeStamp, label); } @@ -258,7 +240,6 @@ public class Coordinate extends BaseResponse { StringBuilder sb = new StringBuilder(); sb.append("class Coordinate {\n"); - sb.append(" coordinateId: ").append(toIndentedString(coordinateId)).append("\n"); sb.append(" latitude: ").append(toIndentedString(latitude)).append("\n"); sb.append(" longitude: ").append(toIndentedString(longitude)).append("\n"); sb.append(" altitude: ").append(toIndentedString(altitude)).append("\n"); diff --git a/app/src/main/java/com/uam/wmi/findmytutor/service/BackgroundLocalizationService.java b/app/src/main/java/com/uam/wmi/findmytutor/service/BackgroundLocalizationService.java index 3377a35..3d3bdef 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/service/BackgroundLocalizationService.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/service/BackgroundLocalizationService.java @@ -25,6 +25,7 @@ import android.util.Log; import com.annimon.stream.Stream; import com.google.android.gms.location.FusedLocationProviderClient; import com.google.android.gms.location.LocationServices; +import com.jakewharton.retrofit2.adapter.rxjava2.HttpException; import com.mapbox.geojson.Point; import com.mapbox.mapboxsdk.geometry.LatLng; import com.uam.wmi.findmytutor.model.Coordinate; @@ -32,6 +33,7 @@ import com.uam.wmi.findmytutor.network.ApiClient; import com.uam.wmi.findmytutor.utils.ApproximatedLocalization; import com.uam.wmi.findmytutor.utils.MapUtils; import com.uam.wmi.findmytutor.utils.PrefUtils; +import com.uam.wmi.findmytutor.utils.RestApiHelper; import com.uam.wmi.findmytutor.utils.SharingLevel; import org.apache.commons.collections4.queue.CircularFifoQueue; @@ -42,8 +44,10 @@ import java.util.concurrent.atomic.AtomicReference; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.disposables.CompositeDisposable; +import io.reactivex.observers.DisposableCompletableObserver; import io.reactivex.observers.DisposableSingleObserver; import io.reactivex.schedulers.Schedulers; +import okhttp3.ResponseBody; import static com.uam.wmi.findmytutor.utils.Const.offlineBackgroundLocationInterval; import static com.uam.wmi.findmytutor.utils.Const.onlineBackgroundLocationInterval; @@ -51,6 +55,7 @@ import static com.uam.wmi.findmytutor.utils.Const.presenceApproximatedName; import static com.uam.wmi.findmytutor.utils.Const.presenceLatitude; import static com.uam.wmi.findmytutor.utils.Const.presenceLongitude; import static com.uam.wmi.findmytutor.utils.PrefUtils.storeBackgroundLocationStatus; +import static java.lang.String.valueOf; public class BackgroundLocalizationService extends Service { @@ -353,18 +358,21 @@ public class BackgroundLocalizationService extends Service { disposable.add( coordinateService - .postCoordinate(coordinate) + .putCoordinate(coordinate, PrefUtils.getUserId(getApplicationContext())) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) - .subscribeWith(new DisposableSingleObserver() { + .subscribeWith(new DisposableCompletableObserver() { + @Override - public void onSuccess(Coordinate coordinate) { - Log.e(TAG, String.valueOf(coordinate)); + public void onComplete() { + Log.e(TAG, "CoordinateSuccess"); } @Override public void onError(Throwable e) { - Log.e(TAG, e.getMessage()); + + Log.e(TAG,"onErr" + valueOf(e)); + } })); } catch (IllegalArgumentException e) { diff --git a/app/src/main/java/com/uam/wmi/findmytutor/service/CoordinateService.java b/app/src/main/java/com/uam/wmi/findmytutor/service/CoordinateService.java index 18ec984..d49dded 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/service/CoordinateService.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/service/CoordinateService.java @@ -3,6 +3,7 @@ package com.uam.wmi.findmytutor.service; import com.uam.wmi.findmytutor.model.Coordinate; import java.util.List; +import io.reactivex.Completable; import io.reactivex.Single; import retrofit2.http.Body; import retrofit2.http.DELETE; @@ -36,9 +37,9 @@ public interface CoordinateService { Single postCoordinate(@Body Coordinate coordinate); @PUT("api/coordinates/{id}") - Single putCoordinatesById(@Path("id") String id); + Completable putCoordinate(@Body Coordinate coordinate, @Path("id") String id); @DELETE("api/coordinates/{id}") - Single deleteCoordinatesById(@Path("id") String id); + Completable deleteCoordinatesById(@Path("id") String id); } diff --git a/app/src/main/java/com/uam/wmi/findmytutor/utils/PrefUtils.java b/app/src/main/java/com/uam/wmi/findmytutor/utils/PrefUtils.java index b60ffbc..3a12597 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/utils/PrefUtils.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/utils/PrefUtils.java @@ -62,7 +62,7 @@ public class PrefUtils { } 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) { @@ -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); + } } \ No newline at end of file diff --git a/app/src/main/res/layout/pref_main.xml b/app/src/main/res/layout/pref_main.xml index 131685a..2977f17 100644 --- a/app/src/main/res/layout/pref_main.xml +++ b/app/src/main/res/layout/pref_main.xml @@ -15,5 +15,12 @@ android:summary="%s" android:title="@string/title_language" /> + + \ No newline at end of file diff --git a/app/src/main/res/layout/pref_sharing.xml b/app/src/main/res/layout/pref_sharing.xml index 0f03421..b7b41d2 100644 --- a/app/src/main/res/layout/pref_sharing.xml +++ b/app/src/main/res/layout/pref_sharing.xml @@ -26,8 +26,6 @@ android:title="@string/title_location_level" /> Błąd podczas pobierania danych. Błąd podczas pobierania statusów. Upss. Coś poszło nie tak. Pracujemy nad tym! - Brak informacji o dyzurze. + Brak informacji o dyżurze. Brak notatki. Wyszukiwarka Nie przeszkadzać diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 1a1605b..f848cbc 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -233,10 +233,14 @@ Network Error! Error handling status fetch Error handling status fetch + Error handling status fetch + Auto reporting on issue is OFF + Auto reporting on issue is ON + ACRA reporting tool Sorry, the application crashed. A report will be sent to the developers Sorry, the application crashed. A report will be sent to the developers - FMT Crash + FMT Issue FMT Lack information about duty hours No note.