diff --git a/app/build.gradle b/app/build.gradle index f019038..02412b7 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -26,7 +26,7 @@ android { repositories { maven { url 'http://dl.bintray.com/amulyakhare/maven' - } + } } def acraVersion = '5.2.1' @@ -36,8 +36,6 @@ dependencies { implementation "ch.acra:acra-notification:$acraVersion" implementation "ch.acra:acra-limiter:$acraVersion" - - implementation fileTree(include: ['*.jar'], dir: 'libs') implementation 'com.android.support:preference-v7:27.1.1' implementation 'com.android.support:appcompat-v7:27.1.1' diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/BlackList.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/BlackList.java index ce91562..47f2d79 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/activity/BlackList.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/activity/BlackList.java @@ -104,11 +104,11 @@ public class BlackList extends AppCompatActivity { .create(UserService.class); if (PrefUtils.isBlackListing(this)){ - aSwitch.setText(getString(R.string.action_black_list) +" ON"); + aSwitch.setText(getString(R.string.action_black_list) + " " +getString(R.string.on) ); aSwitch.setChecked(true); handleChangeRequest(true); }else{ - aSwitch.setText(getString(R.string.action_black_list) +" OFF"); + aSwitch.setText(getString(R.string.action_black_list) + " " +getString(R.string.off) ); aSwitch.setChecked(false); handleChangeRequest(false); } @@ -184,6 +184,7 @@ public class BlackList extends AppCompatActivity { @Override public void onComplete() { Collections.sort(blacklistedUsers, (a, b) -> sortByUserName(a,b)); + didFetched = true; refreshUI(); } })); 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 2822ed9..bf3f3ca 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 @@ -4,6 +4,7 @@ import android.Manifest; import android.animation.ObjectAnimator; import android.animation.ValueAnimator; import android.annotation.SuppressLint; +import android.graphics.Typeface; import android.location.Location; import android.os.Bundle; import android.os.Handler; @@ -13,9 +14,11 @@ import android.text.TextUtils; import android.util.Log; import android.view.LayoutInflater; import android.view.View; +import android.view.WindowManager; import android.view.animation.LinearInterpolator; import android.widget.Button; import android.widget.EditText; +import android.widget.NumberPicker; import android.widget.TextView; import android.widget.Toast; @@ -49,6 +52,7 @@ import com.uam.wmi.findmytutor.service.PredefinedStatusesService; import com.uam.wmi.findmytutor.service.UserService; import com.uam.wmi.findmytutor.utils.ApproximatedLocalization; +import com.uam.wmi.findmytutor.utils.Const; import com.uam.wmi.findmytutor.utils.EnableSharingDialog; import com.uam.wmi.findmytutor.utils.ManualLocationUtils; @@ -58,6 +62,8 @@ import com.uam.wmi.findmytutor.utils.PrefUtils; import com.uam.wmi.findmytutor.utils.RestApiHelper; import com.uam.wmi.findmytutor.utils.SharingLevel; +import org.jetbrains.annotations.NotNull; + import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -101,9 +107,11 @@ public class MapActivity extends BaseActivity private int zoomParam = 17; private int bearingParam = 180; private int tiltParam = 30; + private int floor = Const.defaultFloor; private String myId; private boolean isTutor; private ApproximatedLocalization approximatedLocalization; + String approximatedLocation; private boolean shouldFetchNewCoords = true; @Override @@ -247,9 +255,9 @@ public class MapActivity extends BaseActivity selectLocationButton.setVisibility(View.VISIBLE); removeLocationButton.setVisibility(View.GONE); + String sharingLevel = SharingLevel.MANUAL.toString(); + Icon defaultIcon = getMapIcon(sharingLevel, myId, floor); if (tmpLocalMarker == null) { - String sharingLevel = SharingLevel.MANUAL.toString(); - Icon defaultIcon = getMapIcon(sharingLevel, myId); MarkerOptions markerOptions = new MarkerOptions() .setIcon(defaultIcon) @@ -259,6 +267,7 @@ public class MapActivity extends BaseActivity new MapMarker(tmpLocalMarker, markerOptions, defaultIcon, sharingLevel); } else { + tmpLocalMarker.setIcon(defaultIcon); ValueAnimator markerAnimator = ObjectAnimator.ofObject(tmpLocalMarker, "position", new MapUtils.LatLngEvaluator(), tmpLocalMarker.getPosition(), latLng); markerAnimator.setDuration(2000); @@ -268,7 +277,7 @@ public class MapActivity extends BaseActivity selectLocationButton.setOnClickListener((View view) -> { if (tmpLocalMarker != null) { - String approximatedLocation = approximatedLocalization.getNameOfBuildingPart(Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude())); + approximatedLocation = approximatedLocalization.getNameOfBuildingPart(Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude())); try { droppedMarkercoordinate = new Coordinate( @@ -312,7 +321,7 @@ public class MapActivity extends BaseActivity } public void showLocationDialog(LatLng latLng) { - + floor = Const.defaultFloor; 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); @@ -322,10 +331,31 @@ public class MapActivity extends BaseActivity alertDialogBuilderUserInput .setPositiveButton(R.string.lbl_ok, null) .setNegativeButton(R.string.lbl_cancel, null); - final AlertDialog alertDialog = alertDialogBuilderUserInput.create(); - + alertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE); EditText modalUserInput = view.findViewById(R.id.manual_input); + NumberPicker numberPicker = view.findViewById(R.id.manualFloorNumberPicker); + //Initializing a new string array with elements + final String[] values= {"-1","0","1", "2", "3"}; +// modifyDataForNumberPicker(values); + //Populate NumberPicker values from String array values + //Set the minimum value of NumberPicker + numberPicker.setMinValue(0); //from array first value + //Specify the maximum value/number of NumberPicker + numberPicker.setMaxValue(values.length-1); //to array last value + //Specify the NumberPicker data source as array elements + numberPicker.setDisplayedValues(values); + numberPicker.setValue(1); + //Gets whether the selector wheel wraps when reaching the min/max value. + numberPicker.setWrapSelectorWheel(false); + //Set a value change listener for NumberPicker + numberPicker.setOnValueChangedListener(new NumberPicker.OnValueChangeListener() { + @Override + public void onValueChange(NumberPicker picker, int oldVal, int newVal){ + //Display the newly selected value from picker + floor = newVal-1; + } + }); alertDialog.setOnShowListener(dialogInterface -> { Button sendButton = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE); @@ -345,8 +375,12 @@ public class MapActivity extends BaseActivity Toast.makeText(getApplicationContext(), getApplicationContext().getString(R.string.modal_location_hint), Toast.LENGTH_SHORT).show(); modalUserInput.requestFocus(); } else { + latLng.setAltitude((double) floor); sendLocation(body, latLng); +// Toast.makeText(getApplicationContext(), "Flooor: "+floor, Toast.LENGTH_SHORT).show(); PrefUtils.putCurrentManualLocationName(getApplicationContext(), body); + PrefUtils.putManualLocation(getApplicationContext(),latLng, approximatedLocation); + handleBackgroundTaskLifeCycle(); alertDialog.dismiss(); } }); @@ -427,10 +461,11 @@ public class MapActivity extends BaseActivity String newLabel = element.getLabel(); String newSharingLevel = element.getDisplayMode(); + Coordinate coordinate = coordsMap.get(id); Log.e(tag, "hashMapSize: " + coordsMap.size()); - Log.e(tag, "markerMapSize: " + coordsMap.size()); + Log.e(tag, "markerMapSize: " + markerHash.size()); if (coordinate != null) { @@ -446,7 +481,7 @@ public class MapActivity extends BaseActivity showModalAfterAnimation = true; } - LatLng toDestination = new LatLng(element.getLatitude(), element.getLongitude()); + LatLng toDestination = new LatLng(element.getLatitude(), element.getLongitude(), element.getAltitude()); ValueAnimator markerAnimator = ObjectAnimator.ofObject(marker, "position", new MapUtils.LatLngEvaluator(), @@ -456,8 +491,8 @@ public class MapActivity extends BaseActivity markerAnimator.setInterpolator(new LinearInterpolator()); markerAnimator.start(); - coordsMap.put(id, element); + marker.setIcon(getMapIcon(element.getDisplayMode(), id, element.getAltitude())); marker.setPosition(toDestination); @@ -474,7 +509,7 @@ public class MapActivity extends BaseActivity coordsMap.put(id, element); String sharingLevel = coordsMap.get(id).getDisplayMode(); - Icon defaultIcon = getMapIcon(sharingLevel, id); + Icon defaultIcon = getMapIcon(sharingLevel, id, element.getAltitude()); MarkerOptions markerOptions = new MarkerOptions() .setIcon(defaultIcon) @@ -493,7 +528,7 @@ public class MapActivity extends BaseActivity Boolean newLocalizationMode = markerHash.get(id).getMarkerType().equals(newSharingLevel); if (!newLocalizationMode) { - Icon defaultIcon = getMapIcon(newSharingLevel, id); + Icon defaultIcon = getMapIcon(newSharingLevel, id, element.getAltitude()); MapMarker marker = markerHash.get(id); coordsMap.get(id).setDisplayMode(newSharingLevel); @@ -519,14 +554,27 @@ public class MapActivity extends BaseActivity ); } - private Icon getMapIcon(String sharingLevel, String id) { + private Icon getMapIcon(String sharingLevel, String id, double Altitude ) { Icon defaultIcon = IconFactory.getInstance(MapActivity.this).fromResource(R.drawable.exact_localization_marker); if (sharingLevel.equals(SharingLevel.APPROXIMATED.toString())) { defaultIcon = IconFactory.getInstance(MapActivity.this).fromResource(R.drawable.approximate_localization_marker); } else if (sharingLevel.equals(SharingLevel.MANUAL.toString()) || sharingLevel.equals(SharingLevel.PREDEFINED.toString())) { - defaultIcon = IconFactory.getInstance(MapActivity.this).fromResource(R.drawable.manual_localization_marker); + + if (Altitude == (double) -1){ + defaultIcon = IconFactory.getInstance(MapActivity.this).fromResource(R.drawable.manual_localization_marker_minus_1); + }else if (Altitude == (double) 0) { + defaultIcon = IconFactory.getInstance(MapActivity.this).fromResource(R.drawable.manual_localization_marker_0); + }else if (Altitude == (double) 1) { + defaultIcon = IconFactory.getInstance(MapActivity.this).fromResource(R.drawable.manual_localization_marker_1); + }else if (Altitude == (double) 2) { + defaultIcon = IconFactory.getInstance(MapActivity.this).fromResource(R.drawable.manual_localization_marker_2); + }else if (Altitude == (double) 3) { + defaultIcon = IconFactory.getInstance(MapActivity.this).fromResource(R.drawable.manual_localization_marker_3); + } else { + defaultIcon = IconFactory.getInstance(MapActivity.this).fromResource(R.drawable.manual_localization_marker); + } } else if (id.equals(myId)) { defaultIcon = IconFactory.getInstance(MapActivity.this).fromResource(R.drawable.my_marker); } diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/WhiteList.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/WhiteList.java index aad7e70..c2c9e47 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/activity/WhiteList.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/activity/WhiteList.java @@ -91,11 +91,11 @@ public class WhiteList extends AppCompatActivity { .create(UserService.class); if (PrefUtils.isWhiteListing(this)){ - aSwitch.setText(getString(R.string.action_white_list) +" ON"); + aSwitch.setText(getString(R.string.action_white_list) +" "+getString(R.string.on) ); aSwitch.setChecked(true); handleChangeRequest(true); }else{ - aSwitch.setText(getString(R.string.action_white_list) +" OFF"); + aSwitch.setText(getString(R.string.action_white_list) +" "+getString(R.string.off) ); aSwitch.setChecked(false); handleChangeRequest(false); } @@ -169,6 +169,7 @@ public class WhiteList extends AppCompatActivity { @Override public void onComplete() { Collections.sort(whitelistedUsers, (a, b) -> sortByUserName(a,b)); + didFetched = true; refreshUI(); } })); 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 81fecf3..b3e0fb1 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 @@ -320,13 +320,15 @@ public class BackgroundLocalizationService extends Service { LatLng latLng = PrefUtils.getManualLocation(getApplicationContext()); latitude = latLng.getLatitude(); longitude = latLng.getLongitude(); + altitude = latLng.getAltitude(); + fakeLoc.setAltitude(altitude); approximatedBuildingPart = PrefUtils.getManualLocationApproximation(getApplicationContext()); } Location fakeLoc = new Location(""); - fakeLoc.setLatitude(latitude); fakeLoc.setLongitude(longitude); + coordinatesHistory.add(fakeLoc); try { diff --git a/app/src/main/java/com/uam/wmi/findmytutor/utils/Const.java b/app/src/main/java/com/uam/wmi/findmytutor/utils/Const.java index b6c0dab..70f72aa 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/utils/Const.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/utils/Const.java @@ -7,6 +7,7 @@ import java.util.List; public class Const { public final static String BASE_URL = "https://s416084.projektstudencki.pl/master/"; + public final static Integer defaultFloor = -255; public final static Integer mapRefreshInterval = 6000; public final static Integer onlineBackgroundLocationInterval = 7000; public final static Integer offlineBackgroundLocationInterval = 360000; 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 2ae7c57..4d0b717 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 @@ -180,14 +180,16 @@ public class PrefUtils { /*editor.putBoolean("key_sharing_enabled", true);*/ editor.putLong("longitude_manual_location", Double.doubleToRawLongBits(latLng.getLongitude())); editor.putLong("latitude_manual_location", Double.doubleToRawLongBits(latLng.getLatitude())); + editor.putLong("altitude_manual_location", Double.doubleToRawLongBits(latLng.getAltitude())); editor.apply(); } public static LatLng getManualLocation(Context context) { return new LatLng( Double.longBitsToDouble(getSharedPreferences(context).getLong("latitude_manual_location", 0)), - Double.longBitsToDouble(getSharedPreferences(context).getLong("longitude_manual_location", 0)) - ); + Double.longBitsToDouble(getSharedPreferences(context).getLong("longitude_manual_location", 0)), + Double.longBitsToDouble(getSharedPreferences(context).getLong("altitude_manual_location", Const.defaultFloor)) + ); } public static String getManualLocationApproximation(Context context) { diff --git a/app/src/main/res/drawable/exact_localization_marker_minus_1.png b/app/src/main/res/drawable/exact_localization_marker_minus_1.png index be49182..f86da6a 100644 Binary files a/app/src/main/res/drawable/exact_localization_marker_minus_1.png and b/app/src/main/res/drawable/exact_localization_marker_minus_1.png differ diff --git a/app/src/main/res/drawable/manual_localization_marker_0.png b/app/src/main/res/drawable/manual_localization_marker_0.png new file mode 100644 index 0000000..46cd50b Binary files /dev/null and b/app/src/main/res/drawable/manual_localization_marker_0.png differ diff --git a/app/src/main/res/drawable/manual_localization_marker_1.png b/app/src/main/res/drawable/manual_localization_marker_1.png new file mode 100644 index 0000000..84212fc Binary files /dev/null and b/app/src/main/res/drawable/manual_localization_marker_1.png differ diff --git a/app/src/main/res/drawable/manual_localization_marker_2.png b/app/src/main/res/drawable/manual_localization_marker_2.png new file mode 100644 index 0000000..a1cfd70 Binary files /dev/null and b/app/src/main/res/drawable/manual_localization_marker_2.png differ diff --git a/app/src/main/res/drawable/manual_localization_marker_3.png b/app/src/main/res/drawable/manual_localization_marker_3.png new file mode 100644 index 0000000..5c1df0a Binary files /dev/null and b/app/src/main/res/drawable/manual_localization_marker_3.png differ diff --git a/app/src/main/res/drawable/manual_localization_marker_minus_1.png b/app/src/main/res/drawable/manual_localization_marker_minus_1.png index 89adebf..e85cf2c 100644 Binary files a/app/src/main/res/drawable/manual_localization_marker_minus_1.png and b/app/src/main/res/drawable/manual_localization_marker_minus_1.png differ diff --git a/app/src/main/res/layout/activity_black_list.xml b/app/src/main/res/layout/activity_black_list.xml index b4c9188..60c0e30 100644 --- a/app/src/main/res/layout/activity_black_list.xml +++ b/app/src/main/res/layout/activity_black_list.xml @@ -40,7 +40,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" - android:text="Block the users" + android:text="@string/block_the_users" android:textSize="15sp"/> - android:layout_width="match_parent" - android:layout_height="match_parent" - android:fontFamily="@font/lato_regular" - android:orientation="vertical" - android:paddingLeft="@dimen/activity_horizontal_margin" - android:paddingTop="@dimen/activity_vertical_margin" - android:paddingRight="@dimen/activity_horizontal_margin" - android:paddingBottom="@dimen/activity_vertical_margin"> + - + - + + - \ No newline at end of file + + + + + + + + + + diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index ba3c288..ac2f6f9 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -276,6 +276,9 @@ Użytkownik został dodany! Użytkownik usunięty! + Piętro + Zablokuj użytkowników + Bądź dostępny dla użytkowników diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 52f5d89..57d1b5b 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -223,9 +223,9 @@ User profile Remove Manual location TutorTab - Do you want to save this localization? - Save! - Cancel! + Manual localization + Save + Cancel Your marker will disappear in next couple minutes Manual Locations selected! Location saved! @@ -342,7 +342,7 @@ Network Error ! Search response is empty! - Insert a name for this localization. + Name the localization Online Offline Inactive @@ -351,5 +351,9 @@ User has been added! User removed! + Floor + Block the users + Be visible for these users +