diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/BaseActivity.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/BaseActivity.java index b8d5ea3..823a869 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/activity/BaseActivity.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/activity/BaseActivity.java @@ -202,13 +202,11 @@ public abstract class BaseActivity } public void handleBackgroundTaskLifeCycle() { - Boolean shouldServiceRun = PrefUtils.isEnableSharingLocalization(getApplicationContext()) - && !PrefUtils.isBackgroundLocationServiceRunning(getApplicationContext()); + Boolean shouldServiceRun = PrefUtils.isEnableSharingLocalization(getApplicationContext()); if (shouldServiceRun) { startBackgroundLocalizationTask(); - } else if (PrefUtils.isBackgroundLocationServiceRunning(getApplicationContext()) && - !PrefUtils.isEnableSharingLocalization(getApplicationContext())) { + } else { stopBackgroundLocalizationTask(); } } 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 4d9e06e..4a8a7e2 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 @@ -10,11 +10,13 @@ import android.os.Bundle; import android.os.Handler; import android.support.v4.content.ContextCompat; import android.support.v7.app.AlertDialog; +import android.text.TextUtils; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.animation.LinearInterpolator; import android.widget.Button; +import android.widget.EditText; import android.widget.TextView; import android.widget.Toast; @@ -42,6 +44,7 @@ import com.uam.wmi.findmytutor.model.PredefinedCoordViewModel; import com.uam.wmi.findmytutor.model.User; import com.uam.wmi.findmytutor.network.ApiClient; import com.uam.wmi.findmytutor.service.CoordinateService; +import com.uam.wmi.findmytutor.service.PredefinedStatusesService; import com.uam.wmi.findmytutor.service.UserService; import com.uam.wmi.findmytutor.utils.FeedbackUtils; import com.uam.wmi.findmytutor.utils.ManualLocationUtils; @@ -115,7 +118,7 @@ public class MapActivity extends BaseActivity } finally { mHandler.postDelayed(mStatusChecker, mInterval); } - manualLocationUtils = new ManualLocationUtils(MapActivity.this); + }; selectLocationButton = findViewById(R.id.select_location_button); @@ -127,6 +130,7 @@ public class MapActivity extends BaseActivity //start background task handleBackgroundTaskLifeCycle(); + manualLocationUtils = new ManualLocationUtils(MapActivity.this); } @Override @@ -144,7 +148,6 @@ public class MapActivity extends BaseActivity removeLocationButton.setVisibility(View.VISIBLE); removeLocationButton.setOnClickListener(view -> { - Log.e(tag + "Manual", "manual coords sending stopped"); stopBackgroundLocalizationTask(); removeLocationButton.setVisibility(View.GONE); @@ -159,6 +162,7 @@ public class MapActivity extends BaseActivity }); setToggleMapBoundsArea(); + if (isTutor) { setOnMapLongClickListener(); } @@ -245,20 +249,26 @@ public class MapActivity extends BaseActivity } - private void setOnMapLongClickListener() { + /* private void setOnMapLongClickListener() { mapboxMap.addOnMapLongClickListener((LatLng latLng) -> { selectLocationButton.setVisibility(View.VISIBLE); removeLocationButton.setVisibility(View.GONE); - Icon icon = IconFactory.getInstance(MapActivity.this).fromResource(R.drawable.my_marker); if (tmpLocalMarker == null) { - tmpLocalMarker = mapboxMap.addMarker(new MarkerOptions() - .position(latLng) - .icon(icon) - .title("My Loc") - .setSnippet("Snipecik")); + String sharingLevel = SharingLevel.MANUAL.toString(); + Icon defaultIcon = getMapIcon(sharingLevel, myId); + + MarkerOptions markerOptions = new MarkerOptions() + .setIcon(defaultIcon) + .position(latLng); + + tmpLocalMarker = mapboxMap.addMarker(markerOptions); + MapMarker marker = new MapMarker(tmpLocalMarker, markerOptions, defaultIcon, sharingLevel); + + markerHash.put(myId, marker); + updateUserHashMap(myId, marker.getMarker().getId()); } else { ValueAnimator markerAnimator = ObjectAnimator.ofObject(tmpLocalMarker, "position", @@ -269,36 +279,13 @@ public class MapActivity extends BaseActivity selectLocationButton.setOnClickListener((View view) -> { if (tmpLocalMarker != null) { - // Toast instructing user to tap on the mapboxMap - // TODO PUT MANUAL CORD try { -// droppedMarkercoordinate = new Coordinate( -// latLng.getLatitude(), -// latLng.getLongitude(), -// latLng.getAltitude(), -// "approx", -// PrefUtils.getUserFirstName(getApplicationContext()) + " " + PrefUtils.getUserLastName(getApplicationContext()), -// PrefUtils.getUserId(getApplicationContext()), -// PrefUtils.getLocationLevel(getApplicationContext()) -// ); manualLocationUtils.showLocationDialog("Name the location", latLng); - handleBackgroundTaskLifeCycle(); - + startBackgroundLocalizationTask(); } catch (IllegalArgumentException e) { Timber.e(String.valueOf(e)); } -// Toast.makeText( -// MapActivity.this, -// "Manual Locations selected!" + latLng, -// Toast.LENGTH_LONG -// ).show(); -// LayoutInflater layoutInflaterAndroid = LayoutInflater.from(MapActivity.this); -// View dialogView = layoutInflaterAndroid.inflate(R.layout.feedback_modal, null); -// AlertDialog.Builder alertDialogBuilderUserInput = new AlertDialog.Builder(MapActivity.this ); -// alertDialogBuilderUserInput.setView(dialogView).setPositiveButton("dupa", null); -// final AlertDialog alertDialog = alertDialogBuilderUserInput.create(); -// alertDialog.show(); selectLocationButton.setVisibility(View.GONE); mapboxMap.removeMarker(tmpLocalMarker); tmpLocalMarker = null; @@ -306,6 +293,141 @@ public class MapActivity extends BaseActivity }); }); + }*/ + + private void setOnMapLongClickListener() { + + mapboxMap.addOnMapLongClickListener((LatLng latLng) -> { + selectLocationButton.setVisibility(View.VISIBLE); + removeLocationButton.setVisibility(View.GONE); + + if (tmpLocalMarker == null) { + String sharingLevel = SharingLevel.MANUAL.toString(); + Icon defaultIcon = getMapIcon(sharingLevel, myId); + + MarkerOptions markerOptions = new MarkerOptions() + .setIcon(defaultIcon) + .position(latLng); + + tmpLocalMarker = mapboxMap.addMarker(markerOptions); + MapMarker marker = new MapMarker(tmpLocalMarker, markerOptions, defaultIcon, sharingLevel); + + updateUserHashMap(myId, marker.getMarker().getId()); + + + } else { + ValueAnimator markerAnimator = ObjectAnimator.ofObject(tmpLocalMarker, "position", + new mapUtils.LatLngEvaluator(), tmpLocalMarker.getPosition(), latLng); + markerAnimator.setDuration(2000); + markerAnimator.start(); + } + + selectLocationButton.setOnClickListener((View view) -> { + if (tmpLocalMarker != null) { + + + try { + droppedMarkercoordinate = new Coordinate( + latLng.getLatitude(), + latLng.getLongitude(), + latLng.getAltitude(), + "approx", + PrefUtils.getUserFirstName(getApplicationContext()) + " " + PrefUtils.getUserLastName(getApplicationContext()), + PrefUtils.getUserId(getApplicationContext()), + PrefUtils.getLocationLevel(getApplicationContext()) + ); + + PrefUtils.putManualLocation(this, latLng); + handleBackgroundTaskLifeCycle(); + + + } catch (IllegalArgumentException e) { + Timber.e(String.valueOf(e)); + } + + Toast.makeText( + MapActivity.this, + "Manual Locations selected!" + latLng, + Toast.LENGTH_LONG + ).show(); + + selectLocationButton.setVisibility(View.GONE); + mapboxMap.removeMarker(tmpLocalMarker); + tmpLocalMarker = null; + + showLocationDialog(latLng); + } + }); + }); + + } + + public void showLocationDialog(LatLng latLng) { + + LayoutInflater layoutInflaterAndroid = LayoutInflater.from(getApplicationContext()); + @SuppressLint("InflateParams") View view = layoutInflaterAndroid.inflate(R.layout.location_modal, null); + AlertDialog.Builder alertDialogBuilderUserInput = new android.support.v7.app.AlertDialog.Builder(this); + + alertDialogBuilderUserInput.setView(view).setPositiveButton(getApplicationContext().getString(R.string.modal_location_send), null); + + alertDialogBuilderUserInput + .setPositiveButton(R.string.lbl_ok, null) + .setNegativeButton(R.string.lbl_cancel, null); + + final AlertDialog alertDialog = alertDialogBuilderUserInput.create(); + + EditText modalUserInput = view.findViewById(R.id.feedback_input); + + alertDialog.setOnShowListener(dialogInterface -> { + Button sendButton = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE); + + Button dismissButton = alertDialog.getButton(AlertDialog.BUTTON_NEGATIVE); + + dismissButton.setOnClickListener(view1 -> alertDialog.dismiss()); + + sendButton.setOnClickListener(view1 -> { + String body = modalUserInput.getText().toString(); + + if (TextUtils.isEmpty(body)) { + Toast.makeText(getApplicationContext(), getApplicationContext().getString(R.string.modal_location_hint), Toast.LENGTH_SHORT).show(); + modalUserInput.requestFocus(); + } else { + PrefUtils.putManualLocation(getApplicationContext(), latLng); + sendLocation(body,latLng); + alertDialog.dismiss(); + } + }); + }); + + + + + + alertDialog.show(); + } + + + private void sendLocation(String body, LatLng latLng) { + PredefinedCoordViewModel droppedMarkercoordinate = new PredefinedCoordViewModel( + latLng.getLatitude(), + latLng.getLongitude(), + latLng.getAltitude(), + PrefUtils.getUserId(getApplicationContext()), + "string", + "predefined", + body + ); + + PredefinedStatusesService predefinedStatusesService = ApiClient.getClient(getApplicationContext()).create(PredefinedStatusesService.class); + CompositeDisposable disposable = new CompositeDisposable(); + disposable.add(predefinedStatusesService.postUserPredefinedCoord(PrefUtils.getUserId(getApplicationContext()), droppedMarkercoordinate) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(this::handleResponse, this::handleError)); + } + + private void handleResponse(List resp) { + Toast.makeText(getApplicationContext(), "Location saved!", Toast.LENGTH_SHORT).show(); } private void fetchTopCoords() { 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 dcab8ae..e9c521c 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 @@ -72,6 +72,7 @@ public class SharingFragment extends PreferenceFragment { protected List predefinedCoordsList= new ArrayList<>(); void getStatuses(CompositeDisposable disposable) { + disposable.add(statusesService.getUserPredefinedStatuses(PrefUtils.getUserId(getApplicationContext())) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) @@ -80,14 +81,11 @@ public class SharingFragment extends PreferenceFragment { public void onSuccess(List strings) { String[] statusesArray = strings.toArray(new String[strings.size()]); setListPreferenceData(statusList.getKey(), statusesArray); - Log.d("GETSTATUSES", Arrays.toString(statusesArray)); - } @Override public void onError(Throwable e) { Toast.makeText(getApplicationContext(), "Error handling status fetch", Toast.LENGTH_SHORT).show(); - } })); @@ -101,15 +99,11 @@ public class SharingFragment extends PreferenceFragment { @Override public void onSuccess(List coords) { - PredefinedCoordViewModel [] statusesArray = (PredefinedCoordViewModel []) coords.toArray(new PredefinedCoordViewModel[0]); -// setListPreferenceData(statusList.getKey(), statusesArray); - List names = Stream.of(coords).map( p -> p.getName()).collect(com.annimon.stream.Collectors.toList()); + List names = Stream.of(coords).map(PredefinedCoordViewModel::getName).collect(com.annimon.stream.Collectors.toList()); predefinedCoordsList.addAll(coords); String [] stringnames = names.toArray(new String[0]); - Log.d("GETLOCATIONS", predefinedCoordsList.toString()); setListPreferenceData(manualLocationList.getKey(),stringnames); - Log.d("GETLOCATIONS", Arrays.toString(stringnames)); } @@ -118,7 +112,6 @@ public class SharingFragment extends PreferenceFragment { Toast.makeText(getApplicationContext(), "Error handling status fetch", Toast.LENGTH_SHORT).show(); } - })); } @@ -138,10 +131,11 @@ public class SharingFragment extends PreferenceFragment { statusesService = ApiClient.getClient(getApplicationContext()).create(PredefinedStatusesService.class); disposable = new CompositeDisposable(); getStatuses(disposable); + if (PrefUtils.getLocationLevel(getApplicationContext()).equals("manual") ) { getLocations(disposable); - } + locationLevelMapping = new HashMap(); locationLevelMapping.put(0, SharingLevel.PRESENCE.toString()); locationLevelMapping.put(1, SharingLevel.APPROXIMATED.toString()); @@ -156,11 +150,11 @@ public class SharingFragment extends PreferenceFragment { /** Main sharing switch**/ locationSharing.setOnPreferenceChangeListener((buttonView, newValue) -> { PrefUtils.storeEnableSharingLocalization(getApplicationContext(), (Boolean) newValue); + ((MapActivity) getActivity()).handleBackgroundTaskLifeCycle(); return true; }); /** Sharing level list **/ -// locationMode.setSummary(PrefUtils.getLocationLevel(getApplicationContext())); locationMode.setOnPreferenceChangeListener((preference, newValue) -> { PrefUtils.storeLocationMode(getApplicationContext(), locationLevelMapping.get(Integer.parseInt((String) newValue))); @@ -185,19 +179,17 @@ public class SharingFragment extends PreferenceFragment { /** Custom manual location list change listener **/ manualLocationList.setOnPreferenceChangeListener((preference, newValue) -> { ListPreference lp = (ListPreference) preference; - Log.d("SELECTEDLOCATION",(lp.getEntries()[Integer.parseInt((String) newValue)].toString())); PredefinedCoordViewModel temp = Stream.of(predefinedCoordsList).filter( p -> p.getName().equals(lp.getEntries()[Integer.parseInt((String) newValue)].toString())).single(); - Log.d("SELECTEDLOCATION",temp.toString()); -// LatLng latLng = new LatLng(latitude, longitude, altitude); + PrefUtils.putManualLocation(getApplicationContext(),temp.getGeoData()); // ((MapActivity) getActivity()).handleBackgroundTaskLifeCycle(); return true; }); + /** Button 'choose from map' button listener **/ manualLocationButton.setOnPreferenceChangeListener((preference, o) -> { - //ToDO wywołanie wybierania lokalizacji z mapy FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction(); fragmentTransaction.hide(SharingFragment.this); fragmentTransaction.commit(); @@ -209,25 +201,16 @@ public class SharingFragment extends PreferenceFragment { ListPreference lp = (ListPreference) preference; CharSequence [] entries = lp.getEntries(); PrefUtils.storeStatus(getApplicationContext(), (String) entries[Integer.parseInt((String) newValue)]); -// PrefUtils.storeStatus(getApplicationContext(),statusMapping.get(Integer.parseInt((String) newValue))); return true; }); /** Custom status list change listener **/ manualStatus.setOnPreferenceChangeListener((preference, newValue) -> { -// ListPreference lp = (ListPreference) findPreference("key_status_value"); -// updateListPreference(lp, newValue, "manual_statuses"); -// PrefUtils.storeStatus(getApplicationContext(),(String) newValue); -// statusList.setValue((String) newValue); + disposable.add(statusesService.postUserPredefinedStatus(PrefUtils.getUserId(getApplicationContext()), (String) newValue) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(this::handleResponse, this::handleError)); -// Log.d("GETSTATUSES", "statusy po dodaniu nowego"); -// getStatuses(disposable); -// CharSequence[] entriesIndexes = statusList.getEntries(); -//// Log.d("GETENTRIES", Arrays.toString(entriesIndexes)); -// Log.d("GETENTRIES ostatni w handle response", (String) entriesIndexes[entriesIndexes.length - 1]); return true; @@ -248,29 +231,6 @@ public class SharingFragment extends PreferenceFragment { return view; } - public String getListPreferenceValue(String key) { - ListPreference lp = (ListPreference) findPreference(key); - return (String) lp.getEntry(); - - } - - protected void updateListPreference(ListPreference lp, Object newValue, String storageKey) { - CharSequence[] entries = lp.getEntries(); - Set defaultEntries = new HashSet(Arrays.asList(entries)); - SharedPreferences sharedPref = getActivity().getPreferences(Context.MODE_PRIVATE); - - Set manualStatusSet = sharedPref.getStringSet(storageKey, defaultEntries); - manualStatusSet.add((String) newValue); - String[] manualStatusArr = manualStatusSet.toArray(new String[0]); - //Arrays.sort(manualStatusArr); - setListPreferenceData(lp.getKey(), manualStatusArr); -// lp.setValue((String) newValue); - - SharedPreferences.Editor editor = sharedPref.edit(); - editor.putStringSet(storageKey, manualStatusSet); - editor.apply(); - } - protected void setListPreferenceData(String lp_name, String [] entries) { //todo bug z pustym statusem ListPreference lp = (ListPreference) findPreference(lp_name); @@ -281,23 +241,21 @@ public class SharingFragment extends PreferenceFragment { entryValues[i] = Integer.toString(i); } - lp.setDefaultValue("1"); + lp.setDefaultValue("0"); lp.setEntryValues(entryValues); } private void handleResponse(List resp) { - String newStatus = resp.toArray(new String[resp.size()])[resp.size() - 1]; - Log.d("GETSTATUSES new status", newStatus); String[] statusesArray = resp.toArray(new String[resp.size()]); setListPreferenceData(statusList.getKey(), statusesArray); -// Log.d("GETSTATUSES nowe lokalne", Arrays.toString(statusList.getEntries())); -// statusList.setValue(newStatus); + statusList.setValueIndex(resp.size() - 1); + PrefUtils.storeStatus(getApplicationContext(), resp.get(resp.size() -1 )); + } private void handleError (Throwable error){ if (error instanceof HttpException) { - ResponseBody responseBody = ((HttpException) error).response().errorBody(); Toast.makeText(getApplicationContext(), RestApiHelper.getErrorMessage(responseBody), Toast.LENGTH_SHORT).show(); diff --git a/app/src/main/java/com/uam/wmi/findmytutor/utils/ManualLocationUtils.java b/app/src/main/java/com/uam/wmi/findmytutor/utils/ManualLocationUtils.java index e88f7d7..6de0208 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/utils/ManualLocationUtils.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/utils/ManualLocationUtils.java @@ -1,16 +1,18 @@ package com.uam.wmi.findmytutor.utils; +import android.annotation.SuppressLint; +import android.app.Activity; +import android.app.Fragment; import android.content.Context; import android.content.DialogInterface; -import android.content.pm.PackageManager; -import android.os.Build; +import android.preference.PreferenceFragment; import android.support.v7.app.AlertDialog; +import android.support.v7.app.AppCompatActivity; import android.text.TextUtils; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.widget.Button; -import android.widget.CheckBox; import android.widget.EditText; import android.widget.TextView; import android.widget.Toast; @@ -19,98 +21,41 @@ import com.jakewharton.retrofit2.adapter.rxjava2.HttpException; import com.mapbox.mapboxsdk.geometry.LatLng; import com.uam.wmi.findmytutor.R; import com.uam.wmi.findmytutor.activity.BaseActivity; -import com.uam.wmi.findmytutor.model.Coordinate; -import com.uam.wmi.findmytutor.model.Feedback; +import com.uam.wmi.findmytutor.activity.MapActivity; import com.uam.wmi.findmytutor.model.PredefinedCoordViewModel; import com.uam.wmi.findmytutor.network.ApiClient; -import com.uam.wmi.findmytutor.service.FeedbackService; import com.uam.wmi.findmytutor.service.PredefinedStatusesService; import java.util.List; -import io.reactivex.Single; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.disposables.CompositeDisposable; import io.reactivex.schedulers.Schedulers; import okhttp3.ResponseBody; -import retrofit2.Response; -public class ManualLocationUtils { - private Context activityContext; +import static com.mapbox.mapboxsdk.Mapbox.getApplicationContext; +import static java.security.AccessController.getContext; - public ManualLocationUtils(Context context) { - activityContext = context; - } +@SuppressLint("ValidFragment") +public class ManualLocationUtils { + private Context activityContext; - public void showLocationDialog(String subject, LatLng latLng) { - - LayoutInflater layoutInflaterAndroid = LayoutInflater.from(activityContext); - View view = layoutInflaterAndroid.inflate(R.layout.location_modal, null); - AlertDialog.Builder alertDialogBuilderUserInput = new AlertDialog.Builder(activityContext); - alertDialogBuilderUserInput.setView(view).setPositiveButton(activityContext.getString(R.string.modal_location_send), null); - final AlertDialog alertDialog = alertDialogBuilderUserInput.create(); - - EditText modalUserInput = view.findViewById(R.id.feedback_input); - TextView modalTitle = view.findViewById(R.id.feedback_modal_title); - modalTitle.setText(subject); - alertDialog.setOnShowListener(new DialogInterface.OnShowListener() { - @Override - public void onShow(DialogInterface dialogInterface) { - Button sendButton = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE); - sendButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - String body = modalUserInput.getText().toString(); - if (TextUtils.isEmpty(body)) { - Toast.makeText(activityContext, activityContext.getString(R.string.modal_location_hint), Toast.LENGTH_SHORT).show(); - modalUserInput.requestFocus(); - } else { - PrefUtils.putManualLocation(activityContext, latLng); - sendLocation(body,latLng); - alertDialog.dismiss(); - } - } - }); - } - }); - alertDialog.show(); - } - - private void sendLocation(String body, LatLng latLng) { - PredefinedCoordViewModel droppedMarkercoordinate = new PredefinedCoordViewModel( - latLng.getLatitude(), - latLng.getLongitude(), - latLng.getAltitude(), - PrefUtils.getUserId(activityContext), - "string", - "predefined", - body - ); - PredefinedStatusesService predefinedStatusesService = ApiClient.getClient(activityContext).create(PredefinedStatusesService.class); - CompositeDisposable disposable = new CompositeDisposable(); - disposable.add(predefinedStatusesService.postUserPredefinedCoord(PrefUtils.getUserId(activityContext),droppedMarkercoordinate) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .subscribe(this::handleResponse, this::handleError)); - } - - private void handleResponse(List resp) { - Toast.makeText(activityContext, "Location saved", Toast.LENGTH_SHORT).show(); - } - - private void handleError(Throwable error) { - if (error instanceof HttpException) { - - ResponseBody responseBody = ((HttpException) error).response().errorBody(); - Toast.makeText(activityContext, - RestApiHelper.getErrorMessage(responseBody), Toast.LENGTH_SHORT).show(); - Log.d("POSTCOORDINATE", error.getMessage()); + public ManualLocationUtils(Context context) { + activityContext = context; + } - } else { - Toast.makeText(activityContext, - "Network error " + error.getMessage(), Toast.LENGTH_SHORT).show(); - Log.d("POSTCOORDINATE", error.getMessage()); - } - } + + private void handleError(Throwable error) { + if (error instanceof HttpException) { + + ResponseBody responseBody = ((HttpException) error).response().errorBody(); + Toast.makeText(activityContext, + RestApiHelper.getErrorMessage(responseBody), Toast.LENGTH_SHORT).show(); + + } else { + Toast.makeText(activityContext, + "Network error " + error.getMessage(), Toast.LENGTH_SHORT).show(); + } + } } diff --git a/app/src/main/res/layout/location_modal.xml b/app/src/main/res/layout/location_modal.xml index cd566f4..5aaf83e 100644 --- a/app/src/main/res/layout/location_modal.xml +++ b/app/src/main/res/layout/location_modal.xml @@ -18,7 +18,7 @@ android:paddingTop="@dimen/activity_vertical_margin"> android:layout_marginBottom="@dimen/dimen_10" android:fontFamily="sans-serif-medium" android:lineSpacingExtra="8sp" - android:text="placeholder" + android:text="@string/manual_modal_title" android:textColor="@color/colorAccent" android:textSize="@dimen/lbl_new_note_title" android:textStyle="normal" /> @@ -34,6 +34,7 @@ android:paddingTop="@dimen/activity_vertical_margin"> android:hint="@string/modal_feedback_hint" android:maxLength="30" android:maxLines="1" + android:textColor="@color/note_list_text" android:requiresFadingEdge="vertical" android:scrollbars="vertical" /> diff --git a/app/src/main/res/layout/pref_sharing.xml b/app/src/main/res/layout/pref_sharing.xml index 73f957b..740abf4 100644 --- a/app/src/main/res/layout/pref_sharing.xml +++ b/app/src/main/res/layout/pref_sharing.xml @@ -24,7 +24,6 @@ android:summary="%s" android:title="@string/title_location_level" /> Angielski Polski Wybierz język - + \"\" O aplikacji Jesteśmy grupą studentów, która chce pomoć w rozwoju naszego wydziału.\nDziękujemy za używanie naszej aplikacji.\nZespół FMT.! diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index fe1b0b8..bc71283 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -219,6 +219,9 @@ User profile Remove Manual location TutorTab + Do you want to save this localization? + Save! + Cancel!