Merge from develop & add label to coordinate on map
This commit is contained in:
commit
b23d82d74d
@ -183,9 +183,11 @@ public abstract class BaseActivity
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void handleBackgroundTaskLifeCycle() {
|
||||
if (PrefUtils.isEnableSharingLocalization(getApplicationContext())
|
||||
&& !PrefUtils.isBackgroundLocationServiceRunning(getApplicationContext())) {
|
||||
|
||||
startBackgroundLocalizationTask();
|
||||
} else if(PrefUtils.isBackgroundLocationServiceRunning(getApplicationContext())) {
|
||||
stopBackgroundLocalizationTask();
|
||||
|
@ -167,6 +167,7 @@ public class MapActivity extends BaseActivity
|
||||
|
||||
private void createMarkerModal(User user) {
|
||||
String cordStatus = coordsMap.get(user.getId()).getLabel();
|
||||
|
||||
LayoutInflater layoutInflaterAndroid = LayoutInflater.from(getApplicationContext());
|
||||
@SuppressLint("InflateParams") View view = layoutInflaterAndroid.inflate(R.layout.marker_modal, null);
|
||||
|
||||
@ -247,7 +248,8 @@ public class MapActivity extends BaseActivity
|
||||
latLng.getLongitude(),
|
||||
latLng.getAltitude(),
|
||||
PrefUtils.getUserFirstName(getApplicationContext()) + " " + PrefUtils.getUserLastName(getApplicationContext()),
|
||||
PrefUtils.getUserId(getApplicationContext())
|
||||
PrefUtils.getUserId(getApplicationContext()),
|
||||
PrefUtils.getLocationLevel(getApplicationContext())
|
||||
);
|
||||
|
||||
disposable.add(
|
||||
@ -361,6 +363,7 @@ public class MapActivity extends BaseActivity
|
||||
|
||||
for (Coordinate element : coordsList) {
|
||||
String id = element.getUserId();
|
||||
String newLabel = element.getLabel();
|
||||
|
||||
Coordinate coordinate = coordsMap.get(id);
|
||||
Log.e(tag, "hashMapSize: " + coordsMap.size());
|
||||
@ -377,6 +380,7 @@ public class MapActivity extends BaseActivity
|
||||
if (!statement) {
|
||||
Log.e(tag, "replace and animate");
|
||||
Marker marker = markerHash.get(id);
|
||||
|
||||
LatLng toDestination = new LatLng(element.getLatitude(), element.getLongitude());
|
||||
// TODO fix flickiering markers
|
||||
ValueAnimator markerAnimator = ObjectAnimator.ofObject(marker, "position",
|
||||
@ -390,7 +394,6 @@ public class MapActivity extends BaseActivity
|
||||
// chba niepotrzbene
|
||||
mapboxMap.getMarkerViewManager().update();
|
||||
|
||||
|
||||
coordsMap.put(id, element);
|
||||
marker.setPosition(toDestination);
|
||||
|
||||
@ -405,6 +408,8 @@ public class MapActivity extends BaseActivity
|
||||
.position(new LatLng(element.getLatitude(), element.getLongitude())));
|
||||
markerHash.put(id, marker);
|
||||
}
|
||||
|
||||
coordsMap.get(id).setLabel(newLabel);
|
||||
}
|
||||
|
||||
/* for (Coordinate coordinate : coordsMap.values()) {
|
||||
|
@ -14,13 +14,17 @@ import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.uam.wmi.findmytutor.R;
|
||||
import com.uam.wmi.findmytutor.service.BackgroundLocalizationService;
|
||||
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
@ -28,25 +32,45 @@ import static com.mapbox.mapboxsdk.Mapbox.getApplicationContext;
|
||||
|
||||
|
||||
public class SharingFragment extends PreferenceFragment {
|
||||
private HashMap<Integer, String> locationLevelMapping;
|
||||
// private HashMap<Integer, String> statusMapping;
|
||||
|
||||
@SuppressLint("ResourceType")
|
||||
@Override
|
||||
public void onCreate(final Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
locationLevelMapping = new HashMap<Integer, String>();
|
||||
locationLevelMapping.put(0,"presence");
|
||||
locationLevelMapping.put(1,"approximated");
|
||||
locationLevelMapping.put(2,"exact");
|
||||
|
||||
addPreferencesFromResource(R.layout.pref_sharing);
|
||||
Preference manualStatus = findPreference("key_manual_status");
|
||||
Preference locationSharing = findPreference("key_sharing_enabled");
|
||||
Preference locationMode = findPreference("key_location_level");
|
||||
Preference statusList = findPreference("key_status_value");
|
||||
|
||||
|
||||
manualStatus.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
ListPreference lp = (ListPreference) findPreference("key_status_value");
|
||||
updateListPreference(lp, newValue, "manual_statuses");
|
||||
return true;
|
||||
});
|
||||
locationMode.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
ListPreference lp = (ListPreference) preference;
|
||||
PrefUtils.storeLocationMode(getApplicationContext(),locationLevelMapping.get(Integer.parseInt((String) newValue)));
|
||||
return true;
|
||||
});
|
||||
statusList.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
ListPreference lp = (ListPreference) preference;
|
||||
CharSequence [] entries = lp.getEntries();
|
||||
PrefUtils.storeStatus(getApplicationContext(),(String) entries[Integer.parseInt((String) newValue)]);
|
||||
return true;
|
||||
});
|
||||
|
||||
locationSharing.setOnPreferenceChangeListener((buttonView, isChecked) -> {
|
||||
PrefUtils.storeEnableSharingLocalization(getApplicationContext(), (Boolean) isChecked);
|
||||
locationSharing.setOnPreferenceChangeListener((buttonView, newValue) -> {
|
||||
PrefUtils.storeEnableSharingLocalization(getApplicationContext(), (Boolean) newValue);
|
||||
((MapActivity)getActivity()).handleBackgroundTaskLifeCycle();
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
@ -64,15 +88,22 @@ 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<String> defaultEntries = new HashSet(Arrays.asList(entries));
|
||||
SharedPreferences sharedPref = getActivity().getPreferences(Context.MODE_PRIVATE);
|
||||
|
||||
Set <String> manualStatusSet = sharedPref.getStringSet(storageKey,defaultEntries);
|
||||
manualStatusSet.add((String) newValue);
|
||||
String [] manualStatusArr = manualStatusSet.toArray(new String[0]);
|
||||
Arrays.sort(manualStatusArr);
|
||||
setListPreferenceData(lp.getKey(),manualStatusArr);
|
||||
|
||||
SharedPreferences.Editor editor = sharedPref.edit();
|
||||
editor.putStringSet(storageKey,manualStatusSet);
|
||||
editor.apply();
|
||||
@ -84,7 +115,7 @@ public class SharingFragment extends PreferenceFragment {
|
||||
CharSequence[] entryValues = new CharSequence [entries.length];
|
||||
|
||||
for (int i = 0; i < entries.length; i++){
|
||||
entryValues[i] = Integer.toString(i+1);
|
||||
entryValues[i] = Integer.toString(i);
|
||||
}
|
||||
|
||||
lp.setDefaultValue("1");
|
||||
|
@ -44,7 +44,7 @@ public class Coordinate extends BaseResponse {
|
||||
@SerializedName("label")
|
||||
private String label;
|
||||
|
||||
public Coordinate (Double latitude, Double longitude, Double altitude, String label, String userId) {
|
||||
public Coordinate (Double latitude, Double longitude, Double altitude, String label, String userId, String displayMode) {
|
||||
//if (!latitudeRange.contains(latitude)) throw new IllegalArgumentException("Inappropriate latitude value" + latitude);
|
||||
//if (!longtitudeRange.contains(longitude)) throw new IllegalArgumentException("Inappropriate longitude value" + longitude);
|
||||
|
||||
@ -53,6 +53,7 @@ public class Coordinate extends BaseResponse {
|
||||
this.altitude = altitude;
|
||||
this.label = label;
|
||||
this.userId = userId;
|
||||
this.displayMode = displayMode;
|
||||
}
|
||||
|
||||
public Coordinate (Double latitude) {
|
||||
|
@ -285,8 +285,9 @@ public class BackgroundLocalizationService extends Service {
|
||||
latitude,
|
||||
longitude,
|
||||
altitude,
|
||||
"Jestem zajęty",
|
||||
PrefUtils.getUserId(getApplicationContext())
|
||||
PrefUtils.getUserStatus(getApplicationContext()),
|
||||
PrefUtils.getUserId(getApplicationContext()),
|
||||
PrefUtils.getLocationLevel(getApplicationContext())
|
||||
);
|
||||
|
||||
disposable.add(
|
||||
|
@ -2,8 +2,10 @@ package com.uam.wmi.findmytutor.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.ListPreference;
|
||||
import android.preference.PreferenceFragment;
|
||||
import android.util.Log;
|
||||
|
||||
import com.uam.wmi.findmytutor.activity.SharingFragment;
|
||||
import com.auth0.android.jwt.Claim;
|
||||
import com.auth0.android.jwt.JWT;
|
||||
|
||||
@ -15,7 +17,7 @@ public class PrefUtils {
|
||||
}
|
||||
|
||||
public static SharedPreferences getSharedPreferences(Context context) {
|
||||
return context.getSharedPreferences("APP_PREF", Context.MODE_PRIVATE);
|
||||
return context.getSharedPreferences("com.uam.wmi.findmytutor_preferences", Context.MODE_PRIVATE);
|
||||
}
|
||||
|
||||
|
||||
@ -57,7 +59,12 @@ public class PrefUtils {
|
||||
}
|
||||
|
||||
public static String getUserStatus(Context context) {
|
||||
return getSharedPreferences(context).getString("USER_STATUS", "Android");
|
||||
return getSharedPreferences(context).getString("status_entry", "Available");
|
||||
}
|
||||
public static void storeStatus(Context context, String status){
|
||||
SharedPreferences.Editor editor = getSharedPreferences(context).edit();
|
||||
editor.putString("status_entry", status);
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public static void storeIsTutor(Context applicationContext, boolean isTutor) {
|
||||
@ -81,12 +88,20 @@ public class PrefUtils {
|
||||
}
|
||||
|
||||
public static boolean isEnableSharingLocalization(Context context) {
|
||||
return getSharedPreferences(context).getBoolean("IS_ENABLE_SHARING_LOCALIZATION", false);
|
||||
return getSharedPreferences(context).getBoolean("key_sharing_enabled", false);
|
||||
}
|
||||
|
||||
public static void storeEnableSharingLocalization(Context context,Boolean isChecked) {
|
||||
SharedPreferences.Editor editor = getSharedPreferences(context).edit();
|
||||
editor.putBoolean("IS_ENABLE_SHARING_LOCALIZATION", isChecked);
|
||||
editor.putBoolean("key_sharing_enabled", isChecked);
|
||||
editor.apply();
|
||||
}
|
||||
public static String getLocationLevel(Context context){
|
||||
return getSharedPreferences(context).getString("location_mode", "exact");
|
||||
}
|
||||
public static void storeLocationMode(Context context, String mode){
|
||||
SharedPreferences.Editor editor = getSharedPreferences(context).edit();
|
||||
editor.putString("location_mode", mode);
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
tools:ignore="MissingDefaultResource"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<PreferenceCategory android:title="@string/settings_category_location">
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
@ -20,6 +21,9 @@
|
||||
android:key="@string/key_location_level"
|
||||
android:summary="%s"
|
||||
android:title="@string/title_location_level" />
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory android:title="@string/settings_category_status">
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:disableDependentsState="false"
|
||||
@ -39,6 +43,9 @@
|
||||
android:singleLine="true"
|
||||
android:title="@string/title_manual_status"
|
||||
/>
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory android:title="@string/settings_category_manuallocation">
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:disableDependentsState="false"
|
||||
@ -47,7 +54,7 @@
|
||||
android:title="@string/manual_location"/>
|
||||
<ListPreference
|
||||
android:defaultValue="1"
|
||||
android:key="manual_location_list_title"
|
||||
android:key="key_manual_location_value"
|
||||
android:entries="@array/manual_location_entries"
|
||||
android:entryValues="@array/manual_location_values"
|
||||
android:summary="%s"
|
||||
@ -58,8 +65,6 @@
|
||||
android:singleLine="true"
|
||||
android:title="@string/title_manual_location"
|
||||
/>
|
||||
|
||||
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
</PreferenceScreen>
|
@ -123,6 +123,11 @@
|
||||
<string name="action_log_in">Zaloguj!</string>
|
||||
<string name="error_invalid_login_name">Niepoprawny format loginu.</string>
|
||||
<string name="user_list_nav">Lista użytkowników</string>
|
||||
<string name="select_a_location">Wybierz lokalizacje</string>
|
||||
<string name="user_location_permission_not_granted">Nie dodano uprawnień do lokalizacji.</string>
|
||||
<string name="user_location_permission_explanation">Ta aplikacja potrzebuje uprawnień do lokalizacji.</string>
|
||||
<string name="settings_category_status">Ustawienia statusu</string>
|
||||
<string name="settings_category_manuallocation">Ręczny wybór lokalizacji</string>
|
||||
</resources>
|
||||
|
||||
|
||||
|
@ -47,6 +47,8 @@
|
||||
<string name="title_sharing">Sharing</string>
|
||||
|
||||
<string name="settings_category_location">Location sharing</string>
|
||||
<string name="settings_category_status">Status settings</string>
|
||||
<string name="settings_category_manuallocation">Manual location override</string>
|
||||
<string name="title_location_level">Sharing level</string>
|
||||
<string name="location_level_presence">Only presence</string>
|
||||
<string name="location_level_approximated">Approximated</string>
|
||||
|
Loading…
Reference in New Issue
Block a user