manual loc + black white list string fixes

This commit is contained in:
Domagalski 2019-01-07 20:39:16 +01:00
parent 6bf6bd1856
commit a7f31b3b41
18 changed files with 145 additions and 64 deletions

View File

@ -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'

View File

@ -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();
}
}));

View File

@ -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);
}

View File

@ -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();
}
}));

View File

@ -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 {

View File

@ -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;

View File

@ -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) {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 7.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 5.7 KiB

View File

@ -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"/>
<Switch

View File

@ -40,7 +40,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="Be visible for these users"
android:text="@string/be_visible_for_these_users "
android:textSize="15sp"/>
<Switch

View File

@ -1,42 +1,63 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:padding="10dp"
xmlns:tools="http://schemas.android.com/tools">
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">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="170dp"
android:gravity="center_horizontal"
android:orientation="vertical">
<TextView
android:id="@+id/feedback_modal_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignStart="@+id/feedback_input"
android:layout_marginBottom="@dimen/dimen_10"
android:fontFamily="sans-serif-medium"
android:lineSpacingExtra="8sp"
android:text="@string/manual_modal_title"
android:textColor="@color/colorAccent"
android:textSize="@dimen/lbl_new_note_title"
android:textStyle="normal" />
<TextView
android:id="@+id/feedback_modal_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-medium"
android:padding="5dp"
android:text="@string/manual_modal_title"
android:textColor="@color/colorAccent"
android:textSize="@dimen/lbl_new_note_title"
android:textStyle="normal" />
<EditText
android:id="@+id/manual_input"
android:layout_width="315dp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="50dp"
android:ems="10"
android:hint="@string/modal_manual_hint"
android:maxLength="30"
android:maxLines="1"
android:requiresFadingEdge="vertical"
android:scrollbars="vertical"
android:textColor="@color/note_list_text" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<EditText
android:id="@+id/manual_input"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="@string/modal_manual_hint"
android:layout_gravity="center"
android:maxLength="30"
android:maxLines="1"
android:scrollbars="vertical"
android:textColor="@color/note_list_text" />
</RelativeLayout>
<View
android:layout_width="1dp"
android:layout_height="fill_parent"
android:layout_margin="4dp"
android:background="#a7a7a7" />
<TextView
android:id="@+id/textView2"
android:layout_alignParentRight="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="center"
android:text="@string/floor" />
<NumberPicker
android:id="@+id/manualFloorNumberPicker"
android:layout_width="wrap_content"
android:layout_height="match_parent" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>

View File

@ -276,6 +276,9 @@
<!--(ENG) Blacked/Whited users -->
<string name="add_user_to_list">Użytkownik został dodany!</string>
<string name="user_removed">Użytkownik usunięty!</string>
<string name="floor">Piętro</string>
<string name="block_the_users">Zablokuj użytkowników</string>
<string name="be_visible_for_these_users">Bądź dostępny dla użytkowników</string>
</resources>

View File

@ -223,9 +223,9 @@
<string name="nav_profile">User profile</string>
<string name="remove_manual_location">Remove Manual location</string>
<string name="title_activity_tutor_tab">TutorTab</string>
<string name="manual_modal_title">Do you want to save this localization?</string>
<string name="lbl_ok">Save!</string>
<string name="lbl_cancel">Cancel!</string>
<string name="manual_modal_title">Manual localization</string>
<string name="lbl_ok">Save</string>
<string name="lbl_cancel">Cancel</string>
<string name="manual_marker_info">Your marker will disappear in next couple minutes</string>
<string name="manual_location_selected">Manual Locations selected!</string>
<string name="location_saved">Location saved!</string>
@ -342,7 +342,7 @@
<string name="network_err">Network Error !</string>
<string name="search_null">Search response is empty!</string>
<string name="modal_manual_hint">Insert a name for this localization.</string>
<string name="modal_manual_hint">Name the localization</string>
<string name="online">Online</string>
<string name="offline">Offline</string>
<string name="inactive">Inactive</string>
@ -351,5 +351,9 @@
<!--(ENG) Blacked/Whited users -->
<string name="add_user_to_list">User has been added!</string>
<string name="user_removed">User removed!</string>
<string name="floor">Floor</string>
<string name="block_the_users">Block the users</string>
<string name="be_visible_for_these_users">Be visible for these users</string>
</resources>