Merge with dev
This commit is contained in:
commit
157855d911
@ -11,7 +11,7 @@ android {
|
||||
minSdkVersion 22
|
||||
targetSdkVersion 27
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
versionName "0.9.0-alpha"
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
vectorDrawables.useSupportLibrary = true
|
||||
}
|
||||
|
BIN
app/release/release/app.aab
Normal file
BIN
app/release/release/app.aab
Normal file
Binary file not shown.
@ -37,7 +37,7 @@
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.MapActivity"
|
||||
android:label="@string/title_activity_main"
|
||||
android:label="@string/map_activity_label"
|
||||
android:launchMode="singleTop" />
|
||||
<activity
|
||||
android:name=".activity.LoginActivity"
|
||||
@ -50,10 +50,6 @@
|
||||
android:name=".activity.SettingsActivity"
|
||||
android:label="@string/title_activity_settings" />
|
||||
|
||||
<activity
|
||||
android:name=".service.GoogleLocalizationActivity"
|
||||
android:label="@string/title_activity_settings" />
|
||||
|
||||
<service
|
||||
android:name=".service.BackgroundLocalizationService"
|
||||
android:exported="false"
|
||||
|
@ -25,13 +25,14 @@ import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.uam.wmi.findmytutor.R;
|
||||
import com.uam.wmi.findmytutor.service.BackgroundLocalizationService;
|
||||
import com.uam.wmi.findmytutor.utils.ActiveFragment;
|
||||
import com.uam.wmi.findmytutor.utils.FeedbackUtils;
|
||||
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
||||
import com.uam.wmi.findmytutor.utils.RxSearchObservable;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@ -40,6 +41,7 @@ import java.util.concurrent.TimeUnit;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
|
||||
import static com.uam.wmi.findmytutor.utils.PrefUtils.storeBackgroundLocationStatus;
|
||||
|
||||
|
||||
@ -57,7 +59,11 @@ public abstract class BaseActivity
|
||||
protected DrawerLayout sideDrawer;
|
||||
protected Toolbar toolbar;
|
||||
protected boolean isTutor;
|
||||
|
||||
String tag = getClass().getName();
|
||||
|
||||
protected FeedbackUtils feedbackUtils;
|
||||
|
||||
private ActionBarDrawerToggle actionBarDrawerToggle;
|
||||
private SharingFragment sharingFragment;
|
||||
|
||||
@ -72,7 +78,7 @@ public abstract class BaseActivity
|
||||
setContentView(getContentViewId());
|
||||
drawerNavigationView = findViewById(R.id.nav_view);
|
||||
sideDrawer = findViewById(R.id.activity_container);
|
||||
|
||||
feedbackUtils = new FeedbackUtils(BaseActivity.this);
|
||||
drawerNavigationView.setNavigationItemSelectedListener(
|
||||
item -> {
|
||||
String itemName = (String) item.getTitle();
|
||||
@ -83,7 +89,9 @@ public abstract class BaseActivity
|
||||
} else if (itemName.equals(getResources().getString(R.string.navigation_item_blacklist))) {
|
||||
/* launchIntent = new Intent(getApplicationContext(), BlacklistActivity.class);
|
||||
startActivity(launchIntent);*/
|
||||
|
||||
} else if (itemName.equals(getResources().getString(R.string.navigation_item_profile))) {
|
||||
|
||||
/* launchIntent = new Intent(getApplicationContext(), ProfileActivity.class);
|
||||
startActivity(launchIntent);*/
|
||||
} else if (itemName.equals(getResources().getString(R.string.navigation_item_settings))) {
|
||||
@ -92,6 +100,7 @@ public abstract class BaseActivity
|
||||
|
||||
} else if (itemName.equals(getResources().getString(R.string.navigation_item_logout))) {
|
||||
if(PrefUtils.isBackgroundLocationServiceRunning(getApplicationContext())) {
|
||||
|
||||
stopBackgroundLocalizationTask();
|
||||
}
|
||||
|
||||
@ -105,7 +114,13 @@ public abstract class BaseActivity
|
||||
}
|
||||
startActivity(i);
|
||||
finish();
|
||||
} else if (itemName.equals(getResources().getString(R.string.navigation_item_feedback))) {
|
||||
feedbackUtils.showNoteDialog("FEEDBACK");
|
||||
|
||||
/*showNoteDialog(BaseActivity.this, );*/
|
||||
} else if (itemName.equals(getResources().getString(R.string.navigation_item_bug))) {
|
||||
feedbackUtils.showNoteDialog("BUG REPORT");
|
||||
/*showNoteDialog(BaseActivity.this, "BUG REPORT");*/
|
||||
}
|
||||
|
||||
sideDrawer.closeDrawers();
|
||||
@ -266,6 +281,7 @@ public abstract class BaseActivity
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(this::executeSearch);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -358,6 +374,8 @@ public abstract class BaseActivity
|
||||
item.setChecked(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
abstract int getNavigationMenuItemId();
|
||||
|
||||
abstract int getContentViewId();
|
||||
|
@ -9,7 +9,6 @@ import android.content.SharedPreferences;
|
||||
import android.location.Location;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.support.design.widget.FloatingActionButton;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.util.Log;
|
||||
@ -21,6 +20,7 @@ import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.annimon.stream.Stream;
|
||||
import com.getbase.floatingactionbutton.FloatingActionButton;
|
||||
import com.jakewharton.retrofit2.adapter.rxjava2.HttpException;
|
||||
import com.mapbox.android.core.permissions.PermissionsListener;
|
||||
import com.mapbox.android.core.permissions.PermissionsManager;
|
||||
@ -29,8 +29,6 @@ import com.mapbox.mapboxsdk.annotations.Icon;
|
||||
import com.mapbox.mapboxsdk.annotations.IconFactory;
|
||||
import com.mapbox.mapboxsdk.annotations.Marker;
|
||||
import com.mapbox.mapboxsdk.annotations.MarkerOptions;
|
||||
import com.mapbox.mapboxsdk.camera.CameraPosition;
|
||||
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
import com.mapbox.mapboxsdk.location.LocationComponent;
|
||||
import com.mapbox.mapboxsdk.location.LocationComponentOptions;
|
||||
@ -84,7 +82,7 @@ public class MapActivity extends BaseActivity
|
||||
private HashMap<String, Marker> markerHash = new HashMap<>();
|
||||
private Set<String> previousCoordsIds = new HashSet<>();
|
||||
|
||||
|
||||
// Camera Animation params
|
||||
private int zoomParam = 17;
|
||||
private int bearingParam = 180;
|
||||
private int tiltParam = 30;
|
||||
@ -113,6 +111,7 @@ public class MapActivity extends BaseActivity
|
||||
|
||||
Bundle extras = getIntent().getExtras();
|
||||
|
||||
|
||||
Mapbox.getInstance(this, getString(R.string.access_token));
|
||||
mapView = findViewById(R.id.mapView);
|
||||
mapView.onCreate(savedInstanceState);
|
||||
@ -127,17 +126,34 @@ public class MapActivity extends BaseActivity
|
||||
MapActivity.this.mapboxMap = mapboxMap;
|
||||
mStatusChecker.run();
|
||||
enableLocationPlugin();
|
||||
|
||||
mapboxMap.setOnMarkerClickListener(marker -> {
|
||||
createMarkerModal(marker.getTitle());
|
||||
return true;
|
||||
});
|
||||
|
||||
|
||||
setToggleMapBoundsArea();
|
||||
setOnMapLongClickListener();
|
||||
// addStaticLayer();
|
||||
}
|
||||
|
||||
private void setToggleMapBoundsArea() {
|
||||
|
||||
mapUtils.setMapBoundsArea(getApplicationContext(), mapboxMap, mapView, true);
|
||||
|
||||
FloatingActionButton toggleBoundsAreaFab = findViewById(R.id.fab_toggle_bound_area);
|
||||
toggleBoundsAreaFab.setOnClickListener(view -> {
|
||||
if (toggleBoundsAreaFab.getTitle().equals("Bounds OFF")) {
|
||||
toggleBoundsAreaFab.setTitle("Bounds ON");
|
||||
mapUtils.setMapBoundsArea(getApplicationContext(), mapboxMap, mapView, false);
|
||||
} else {
|
||||
toggleBoundsAreaFab.setTitle("Bounds OFF");
|
||||
mapUtils.setMapBoundsArea(getApplicationContext(), mapboxMap, mapView, true);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
private void createMarkerModal(String userId) {
|
||||
disposable.add(userService.getUserById(userId)
|
||||
.subscribeOn(Schedulers.io())
|
||||
@ -169,6 +185,7 @@ public class MapActivity extends BaseActivity
|
||||
alertDialog.show();
|
||||
}
|
||||
|
||||
|
||||
private void handleError(Throwable error) {
|
||||
showError(error);
|
||||
}
|
||||
@ -187,6 +204,7 @@ public class MapActivity extends BaseActivity
|
||||
Toast.makeText(MapActivity.this, message, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
|
||||
private void setOnMapLongClickListener() {
|
||||
|
||||
final boolean[] cancel = {false};
|
||||
@ -305,9 +323,16 @@ public class MapActivity extends BaseActivity
|
||||
@Override
|
||||
public void onSuccess(List<Coordinate> coordsList) {
|
||||
|
||||
|
||||
if (coordsList.isEmpty() && droppedMarker == null) {
|
||||
Timber.e("200 empty []");
|
||||
mapboxMap.clear();
|
||||
}
|
||||
|
||||
if (coordsList.isEmpty()) {
|
||||
Log.e(tag, "200 empty []");
|
||||
//mapboxMap.clear();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -412,6 +437,67 @@ public class MapActivity extends BaseActivity
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings({"MissingPermission"})
|
||||
private void enableLocationPlugin() {
|
||||
Log.e(tag, "enableLocationPlugin");
|
||||
|
||||
// Check if permissions are enabled and if not request
|
||||
if (PermissionsManager.areLocationPermissionsGranted(this)) {
|
||||
Log.e(tag, "enableLocationPlugin true");
|
||||
|
||||
|
||||
LocationComponentOptions options = LocationComponentOptions.builder(this)
|
||||
.trackingGesturesManagement(false)
|
||||
.accuracyColor(ContextCompat.getColor(this, R.color.mapboxGray))
|
||||
.build();
|
||||
|
||||
// Get an instance of the component
|
||||
locationComponent = mapboxMap.getLocationComponent();
|
||||
|
||||
Log.e(tag + "Last", locationComponent.getLastKnownLocation() + "");
|
||||
|
||||
// Activate with options
|
||||
locationComponent.activateLocationComponent(this, options);
|
||||
|
||||
// Enable to make component visible + camera animation
|
||||
// https://www.mapbox.com/android-docs/maps/overview/location-component/
|
||||
locationComponent.setLocationComponentEnabled(true);
|
||||
|
||||
// Set the component's camera mode
|
||||
locationComponent.setCameraMode(CameraMode.NONE);
|
||||
locationComponent.setRenderMode(RenderMode.COMPASS);
|
||||
|
||||
// Button 4 centring
|
||||
FloatingActionButton myLocFAB = findViewById(R.id.myLocationButton);
|
||||
myLocFAB.setVisibility(View.VISIBLE);
|
||||
myLocFAB.setOnClickListener(v -> {
|
||||
|
||||
Location lastKnownLocation = locationComponent.getLastKnownLocation();
|
||||
if (lastKnownLocation != null) {
|
||||
mapUtils.makeNewCamera(mapboxMap,
|
||||
lastKnownLocation.getLatitude(),
|
||||
lastKnownLocation.getLongitude(),
|
||||
zoomParam,
|
||||
bearingParam,
|
||||
tiltParam,
|
||||
4000);
|
||||
}
|
||||
|
||||
// Camera aniamtion
|
||||
zoomParam = (zoomParam == 17) ? 19 : 17;
|
||||
bearingParam += 90;
|
||||
tiltParam = (tiltParam == 30) ? 0 : 30;
|
||||
});
|
||||
} else {
|
||||
Log.e(tag, "enableLocationPlugin false");
|
||||
|
||||
permissionsManager = new PermissionsManager(this);
|
||||
permissionsManager.requestLocationPermissions(this);
|
||||
permissionsManager.onRequestPermissionsResult(0, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, new int[]{0});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Add the mapView lifecycle to the activity's lifecycle methods
|
||||
@Override
|
||||
public void onResume() {
|
||||
@ -467,69 +553,6 @@ public class MapActivity extends BaseActivity
|
||||
return R.id.nav_map;
|
||||
}
|
||||
|
||||
@SuppressWarnings({"MissingPermission"})
|
||||
private void enableLocationPlugin() {
|
||||
Log.e(tag, "enableLocationPlugin");
|
||||
|
||||
// Check if permissions are enabled and if not request
|
||||
if (PermissionsManager.areLocationPermissionsGranted(this)) {
|
||||
Log.e(tag, "enableLocationPlugin true");
|
||||
|
||||
FloatingActionButton myLocationButton = findViewById(R.id.myLocationButton);
|
||||
myLocationButton.setVisibility(View.VISIBLE);
|
||||
|
||||
LocationComponentOptions options = LocationComponentOptions.builder(this)
|
||||
.trackingGesturesManagement(true)
|
||||
.accuracyColor(ContextCompat.getColor(this, R.color.mapboxGray))
|
||||
.build();
|
||||
|
||||
// Get an instance of the component
|
||||
locationComponent = mapboxMap.getLocationComponent();
|
||||
|
||||
//Log.e(tag + "Last", locationComponent.getLastKnownLocation() + "");
|
||||
|
||||
// Activate with options
|
||||
locationComponent.activateLocationComponent(this, options);
|
||||
// Enable to make component visible
|
||||
locationComponent.setLocationComponentEnabled(true);
|
||||
|
||||
// Set the component's camera mode
|
||||
locationComponent.setCameraMode(CameraMode.TRACKING);
|
||||
locationComponent.setRenderMode(RenderMode.COMPASS);
|
||||
|
||||
// Button 4 centring
|
||||
FloatingActionButton myLocFAB = findViewById(R.id.myLocationButton);
|
||||
myLocFAB.setOnClickListener(v -> {
|
||||
|
||||
Location lastKnownLocation = locationComponent.getLastKnownLocation();
|
||||
if (lastKnownLocation != null) {
|
||||
|
||||
CameraPosition position = new CameraPosition.Builder()
|
||||
.target(new LatLng(lastKnownLocation.getLatitude(), lastKnownLocation.getLongitude())) // Sets the new camera position
|
||||
.zoom(zoomParam) // Sets the zoom
|
||||
.bearing(bearingParam) // Rotate the camera
|
||||
.tilt(tiltParam) // Set the camera tilt
|
||||
.build(); // Creates a CameraPosition from the builder
|
||||
|
||||
mapboxMap.animateCamera(CameraUpdateFactory
|
||||
.newCameraPosition(position), 4000);
|
||||
}
|
||||
|
||||
// Camera aniamtion
|
||||
zoomParam = (zoomParam == 17) ? 19 : 17;
|
||||
bearingParam += 90;
|
||||
tiltParam = (tiltParam == 30) ? 0 : 30;
|
||||
});
|
||||
} else {
|
||||
Log.e(tag, "enableLocationPlugin false");
|
||||
|
||||
permissionsManager = new PermissionsManager(this);
|
||||
permissionsManager.requestLocationPermissions(this);
|
||||
permissionsManager.onRequestPermissionsResult(0, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, new int[]{0});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @android.support.annotation.NonNull String[] permissions, @android.support.annotation.NonNull int[] grantResults) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
@ -551,6 +574,7 @@ public class MapActivity extends BaseActivity
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void searchUser(String textToSearch) {
|
||||
getUserFromApi(textToSearch);
|
||||
@ -597,4 +621,5 @@ public class MapActivity extends BaseActivity
|
||||
marker.setIcon(icon);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,47 @@
|
||||
|
||||
package com.uam.wmi.findmytutor.model;
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class Feedback {
|
||||
|
||||
@SerializedName("isAnonymous")
|
||||
@Expose
|
||||
private Boolean isAnonymous;
|
||||
@SerializedName("header")
|
||||
@Expose
|
||||
private String header;
|
||||
@SerializedName("body")
|
||||
@Expose
|
||||
private String body;
|
||||
|
||||
public Feedback(boolean isAnonymous, String header, String body){
|
||||
this.isAnonymous = isAnonymous;
|
||||
this.header = header;
|
||||
this.body = body;
|
||||
}
|
||||
public Boolean getIsAnonymous() {
|
||||
return isAnonymous;
|
||||
}
|
||||
|
||||
public void setIsAnonymous(Boolean isAnonymous) {
|
||||
this.isAnonymous = isAnonymous;
|
||||
}
|
||||
|
||||
public String getHeader() {
|
||||
return header;
|
||||
}
|
||||
|
||||
public void setHeader(String header) {
|
||||
this.header = header;
|
||||
}
|
||||
|
||||
public String getBody() {
|
||||
return body;
|
||||
}
|
||||
|
||||
public void setBody(String body) {
|
||||
this.body = body;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.uam.wmi.findmytutor.service;
|
||||
|
||||
import com.uam.wmi.findmytutor.model.Feedback;
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.Single;
|
||||
import retrofit2.Response;
|
||||
import retrofit2.http.Body;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.POST;
|
||||
|
||||
public interface FeedbackService {
|
||||
@POST("api/Feedback")
|
||||
Observable<Response<Void>> postFeedback(@Body Feedback feedback);
|
||||
|
||||
@GET("api/Feedback")
|
||||
Single<Feedback> getFeedback();
|
||||
}
|
@ -0,0 +1,122 @@
|
||||
package com.uam.wmi.findmytutor.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Build;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
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;
|
||||
|
||||
import com.jakewharton.retrofit2.adapter.rxjava2.HttpException;
|
||||
import com.uam.wmi.findmytutor.R;
|
||||
import com.uam.wmi.findmytutor.activity.BaseActivity;
|
||||
import com.uam.wmi.findmytutor.model.Feedback;
|
||||
import com.uam.wmi.findmytutor.network.ApiClient;
|
||||
import com.uam.wmi.findmytutor.service.FeedbackService;
|
||||
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.CompositeDisposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import okhttp3.ResponseBody;
|
||||
import retrofit2.Response;
|
||||
|
||||
public class FeedbackUtils {
|
||||
private Context activityContext;
|
||||
public FeedbackUtils(Context context){
|
||||
activityContext = context;
|
||||
}
|
||||
public void showNoteDialog(String subject) {
|
||||
|
||||
LayoutInflater layoutInflaterAndroid = LayoutInflater.from(activityContext);
|
||||
View view = layoutInflaterAndroid.inflate(R.layout.feedback_modal, null);
|
||||
AlertDialog.Builder alertDialogBuilderUserInput = new AlertDialog.Builder(activityContext);
|
||||
alertDialogBuilderUserInput.setView(view).setPositiveButton("SEND",null);
|
||||
final AlertDialog alertDialog = alertDialogBuilderUserInput.create();
|
||||
|
||||
EditText modalUserInput = view.findViewById(R.id.feedback_input);
|
||||
CheckBox modalIsAnonymous = view.findViewById(R.id.feedback_is_anonymous);
|
||||
TextView modalTitle = view.findViewById(R.id.feedback_modal_title);
|
||||
TextView modalSubtitle = view.findViewById(R.id.feedback_modal_subtitle);
|
||||
modalTitle.setText(subject);
|
||||
if( subject == "BUG REPORT"){
|
||||
modalSubtitle.setText("Tell us what you noticed!(max 1000 characters)");
|
||||
} else if (subject == "FEEDBACK")
|
||||
{
|
||||
modalSubtitle.setText("Tell us what you think!(max 1000 characters)");
|
||||
}
|
||||
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, "Please describe your insights.", Toast.LENGTH_SHORT).show();
|
||||
modalUserInput.requestFocus();
|
||||
}else{
|
||||
boolean mode = modalIsAnonymous.isChecked();
|
||||
sendFeedback(subject,body,mode);
|
||||
alertDialog.dismiss();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
alertDialog.show();
|
||||
}
|
||||
|
||||
private void sendFeedback(String header, String body, boolean mode) {
|
||||
String appVersion = null;
|
||||
String metadata = null;
|
||||
try {
|
||||
appVersion = activityContext.getPackageManager().getPackageInfo(activityContext.getPackageName(), 0).versionName;
|
||||
if( !mode ){
|
||||
metadata = "\n-----------------------------\n" +
|
||||
"User ID: " + PrefUtils.getUserId(activityContext) + "\n" +
|
||||
"Device OS: Android\n" +
|
||||
"Device OS version: " + Build.VERSION.RELEASE + "\n" +
|
||||
"App Version: " + appVersion + "\n" +
|
||||
"Device Model: " + Build.MODEL + "\n" +
|
||||
"Device Manufacturer: " + Build.MANUFACTURER + "\n" +
|
||||
"-----------------------------\n";
|
||||
body = metadata + body;
|
||||
header = header + " - " + PrefUtils.getUserFirstName(activityContext) + " " + PrefUtils.getUserLastName(activityContext);
|
||||
}
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
}
|
||||
FeedbackService feedbackService = ApiClient.getClient(activityContext).create(FeedbackService.class);
|
||||
Feedback userFeedback = new Feedback(mode,header,body);
|
||||
CompositeDisposable disposable = new CompositeDisposable();
|
||||
disposable.add(feedbackService.postFeedback(userFeedback)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(this::handleResponse, this::handleError));
|
||||
}
|
||||
private void handleResponse(Response<Void> resp) {
|
||||
Toast.makeText(activityContext, "Thank you for subbmiting your feedback", 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();
|
||||
|
||||
} else {
|
||||
Toast.makeText(activityContext,
|
||||
"Network error " + error.getMessage(), Toast.LENGTH_SHORT).show();
|
||||
Log.d("FEEDBACK",error.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
@ -2,16 +2,88 @@ package com.uam.wmi.findmytutor.utils;
|
||||
|
||||
import android.animation.TypeEvaluator;
|
||||
import android.content.Context;
|
||||
|
||||
import android.content.res.AssetManager;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
|
||||
import com.mapbox.mapboxsdk.annotations.Polygon;
|
||||
import com.mapbox.mapboxsdk.annotations.PolygonOptions;
|
||||
import com.mapbox.mapboxsdk.camera.CameraPosition;
|
||||
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLngBounds;
|
||||
import com.mapbox.mapboxsdk.maps.MapView;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.style.layers.FillLayer;
|
||||
import com.mapbox.mapboxsdk.style.layers.Layer;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
public class mapUtils {
|
||||
|
||||
// Boundires
|
||||
private static final LatLngBounds WMI_BOUNDS = new LatLngBounds.Builder()
|
||||
.include(new LatLng(52.467886048833094, 16.92912980245876))
|
||||
.include(new LatLng(52.46548540224137, 16.925255680881094))
|
||||
.build();
|
||||
|
||||
private static final PolygonOptions boundsArea = new PolygonOptions()
|
||||
.add(WMI_BOUNDS.getNorthWest())
|
||||
.add(WMI_BOUNDS.getNorthEast())
|
||||
.add(WMI_BOUNDS.getSouthEast())
|
||||
.add(WMI_BOUNDS.getSouthWest())
|
||||
.alpha(0.1f)
|
||||
.fillColor(Color.YELLOW);
|
||||
// For adding and removing
|
||||
private static Polygon polygon;
|
||||
private static View crosshair;
|
||||
|
||||
// Map Bounds Area
|
||||
public static void setMapBoundsArea(Context context, MapboxMap mapboxMap, MapView mapView, Boolean check) {
|
||||
|
||||
if (check) {
|
||||
// Set bounds to WMI
|
||||
mapboxMap.setLatLngBoundsForCameraTarget(WMI_BOUNDS);
|
||||
makeNewCamera(mapboxMap, 52.466799, 16.927002, 17, 0, 0,4000);
|
||||
mapboxMap.setMinZoomPreference(16); // TODO export to map config
|
||||
|
||||
// Visualise bounds area
|
||||
// showBoundsArea
|
||||
polygon = mapboxMap.addPolygon(boundsArea);
|
||||
// showCrosshair
|
||||
crosshair = new View(context);
|
||||
crosshair.setLayoutParams(new FrameLayout.LayoutParams(15, 15, Gravity.CENTER));
|
||||
crosshair.setBackgroundColor(Color.GREEN);
|
||||
mapView.addView(crosshair);
|
||||
} else {
|
||||
mapboxMap.setLatLngBoundsForCameraTarget(null);
|
||||
mapboxMap.setMinZoomPreference(2);
|
||||
mapboxMap.removePolygon(polygon);
|
||||
mapView.removeView(crosshair);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static void makeNewCamera(MapboxMap mapboxMap, double lat, double lon, int zoomParam, int bearingParam, int tiltParam, int duration){
|
||||
CameraPosition position = new CameraPosition.Builder()
|
||||
.target(new LatLng(lat, lon)) // Sets the new camera position
|
||||
.zoom(zoomParam) // Sets the zoom
|
||||
.bearing(bearingParam) // Rotate the camera
|
||||
.tilt(tiltParam) // Set the camera tilt
|
||||
.build(); // Creates a CameraPosition from the builder
|
||||
|
||||
mapboxMap.animateCamera(CameraUpdateFactory
|
||||
.newCameraPosition(position), duration);
|
||||
}
|
||||
|
||||
// Function for marker animation
|
||||
public static class LatLngEvaluator implements TypeEvaluator<LatLng> {
|
||||
// Method is used to interpolate the marker animation.
|
||||
|
||||
@ -27,6 +99,7 @@ public class mapUtils {
|
||||
}
|
||||
}
|
||||
|
||||
// read file to JSON
|
||||
public static String loadJsonFromAsset(Context context, String filename) {
|
||||
// Using this method to load in GeoJSON files from the assets folder.
|
||||
try {
|
||||
|
4
app/src/main/res/drawable/bug_icon.xml
Normal file
4
app/src/main/res/drawable/bug_icon.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<vector android:height="24dp" android:viewportHeight="512"
|
||||
android:viewportWidth="512" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="#FF000000" android:pathData="M511.988,288.9c-0.478,17.43 -15.217,31.1 -32.653,31.1H424v16c0,21.864 -4.882,42.584 -13.6,61.145l60.228,60.228c12.496,12.497 12.496,32.758 0,45.255 -12.498,12.497 -32.759,12.496 -45.256,0l-54.736,-54.736C345.886,467.965 314.351,480 280,480V236c0,-6.627 -5.373,-12 -12,-12h-24c-6.627,0 -12,5.373 -12,12v244c-34.351,0 -65.886,-12.035 -90.636,-32.108l-54.736,54.736c-12.498,12.497 -32.759,12.496 -45.256,0 -12.496,-12.497 -12.496,-32.758 0,-45.255l60.228,-60.228C92.882,378.584 88,357.864 88,336v-16H32.666C15.23,320 0.491,306.33 0.013,288.9 -0.484,270.816 14.028,256 32,256h56v-58.745l-46.628,-46.628c-12.496,-12.497 -12.496,-32.758 0,-45.255 12.498,-12.497 32.758,-12.497 45.256,0L141.255,160h229.489l54.627,-54.627c12.498,-12.497 32.758,-12.497 45.256,0 12.496,12.497 12.496,32.758 0,45.255L424,197.255V256h56c17.972,0 32.484,14.816 31.988,32.9zM257,0c-61.856,0 -112,50.144 -112,112h224C369,50.144 318.856,0 257,0z"/>
|
||||
</vector>
|
@ -42,13 +42,11 @@
|
||||
mapbox:srcCompat="@android:drawable/ic_dialog_map"
|
||||
tools:layout_editor_absoluteX="0dp" />
|
||||
|
||||
<android.support.design.widget.FloatingActionButton
|
||||
<com.getbase.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/myLocationButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|right"
|
||||
android:layout_marginRight="20dp"
|
||||
android:layout_marginBottom="20dp"
|
||||
android:background="@color/half_black"
|
||||
android:backgroundTint="@color/materialDarkGrey"
|
||||
android:src="@android:drawable/ic_menu_mylocation"
|
||||
@ -92,13 +90,13 @@
|
||||
fab:fab_title="@string/fab_title_parks" />
|
||||
|
||||
<com.getbase.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/fab_toggle_attractions"
|
||||
android:id="@+id/fab_toggle_bound_area"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
fab:fab_colorNormal="@color/mapboxRed"
|
||||
fab:fab_colorPressed="@color/mapboxWhite"
|
||||
fab:fab_size="mini"
|
||||
fab:fab_title="@string/fab_title_attractions" />
|
||||
fab:fab_title="@string/fab_title_bound_area" />
|
||||
</com.getbase.floatingactionbutton.FloatingActionsMenu>
|
||||
|
||||
|
||||
|
68
app/src/main/res/layout/feedback_modal.xml
Normal file
68
app/src/main/res/layout/feedback_modal.xml
Normal file
@ -0,0 +1,68 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:paddingTop="@dimen/activity_vertical_margin">
|
||||
|
||||
<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="placeholder"
|
||||
android:textColor="@color/colorAccent"
|
||||
android:textSize="@dimen/lbl_new_note_title"
|
||||
android:textStyle="normal" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/feedback_input"
|
||||
android:layout_width="315dp"
|
||||
android:layout_height="150dp"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginTop="50dp"
|
||||
android:ems="10"
|
||||
android:hint="@string/modal_feedback_hint"
|
||||
android:inputType="textMultiLine"
|
||||
android:maxLength="1000"
|
||||
android:maxLines="7"
|
||||
android:requiresFadingEdge="vertical"
|
||||
android:scrollbars="vertical" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView5"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/feedback_input"
|
||||
android:layout_toStartOf="@+id/feedback_is_anonymous"
|
||||
android:text="@string/modal_feedback_question"
|
||||
android:textSize="16sp" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/feedback_is_anonymous"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="22dp"
|
||||
android:layout_below="@+id/feedback_input"
|
||||
android:layout_alignEnd="@+id/feedback_input"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/feedback_modal_subtitle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_above="@+id/feedback_input"
|
||||
android:layout_alignEnd="@+id/feedback_input"
|
||||
android:layout_marginEnd="0dp"
|
||||
android:layout_marginBottom="-50dp"
|
||||
android:text="Tell us what you think (max 1000 characters)"
|
||||
android:textSize="14sp" />
|
||||
</RelativeLayout>
|
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<group>
|
||||
<group android:id="@+id/drawer_group_tutor">
|
||||
<item
|
||||
android:id="@+id/nav_item_one"
|
||||
android:icon="@drawable/ic_people_white"
|
||||
@ -14,13 +14,23 @@
|
||||
android:icon="@drawable/outline_person_white_24dp"
|
||||
android:title="@string/navigation_item_profile" />
|
||||
</group>
|
||||
<group android:id="@+id/group_menu">
|
||||
<group android:id="@+id/drawer_group_feedback">
|
||||
<item
|
||||
android:id="@+id/nav_item_four"
|
||||
android:icon="@android:drawable/ic_dialog_email"
|
||||
android:title="@string/navigation_item_feedback" />
|
||||
<item
|
||||
android:id="@+id/nav_item_five"
|
||||
android:icon="@drawable/bug_icon"
|
||||
android:title="@string/navigation_item_bug" />
|
||||
</group>
|
||||
<group android:id="@+id/drawer_group_utilities">
|
||||
<item
|
||||
android:id="@+id/nav_item_six"
|
||||
android:icon="@drawable/ic_menu_settings_key"
|
||||
android:title="@string/navigation_item_settings" />
|
||||
<item
|
||||
android:id="@+id/nav_item_five"
|
||||
android:id="@+id/nav_item_seven"
|
||||
android:icon="@android:drawable/ic_lock_power_off"
|
||||
android:title="@string/navigation_item_logout" />
|
||||
</group>
|
||||
|
@ -43,7 +43,6 @@
|
||||
<!--PulsingLayerOpacityColorActivity activity-->
|
||||
<string name="fab_title_hotels">Hotele</string>
|
||||
<string name="fab_title_parks">Parkingi</string>
|
||||
<string name="fab_title_attractions">Atrakcje</string>
|
||||
<string name="app_name">FindMyTutor</string>
|
||||
<string name="title_activity_startup">Find My Tutor</string>
|
||||
|
||||
@ -128,6 +127,9 @@
|
||||
<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>
|
||||
<string name="navigation_item_feedback">Wyślij nam feedback</string>
|
||||
<string name="navigation_item_bug">Zgłoś błąd</string>
|
||||
<string name="fab_title_bound_area">Bounds OFF</string>
|
||||
</resources>
|
||||
|
||||
|
||||
|
@ -12,9 +12,19 @@
|
||||
<string name="navigation_drawer_close">Drawer Closed</string>
|
||||
<string name="navigation_item_blacklist">Blacklist</string>
|
||||
<string name="navigation_item_whitelist">Whitelist</string>
|
||||
<string name="navigation_item_feedback">Send us feedback</string>
|
||||
<string name="navigation_item_bug">Report a bug</string>
|
||||
<string name="navigation_item_settings">Settings</string>
|
||||
<string name="navigation_item_profile">Profile</string>
|
||||
<string name="navigation_item_logout">Log out</string>
|
||||
|
||||
<!--Feedback/Bug report-->
|
||||
<string name="email_subject_feedback">Find My Tutor - feedback</string>
|
||||
<string name="email_subject_bug">Find My Tutor - bug report</string>
|
||||
<string name="modal_feedback_hint">Please input your feedback.</string>
|
||||
<string name="modal_feedback_question">Send anonymously</string>
|
||||
|
||||
|
||||
<!-- Tutors list -->
|
||||
<string name="action_settings">Settings</string>
|
||||
<string name="activity_title_home">Notes</string>
|
||||
@ -34,6 +44,7 @@
|
||||
<string name="action_white_list">White List</string>
|
||||
|
||||
<string name="title_activity_settings">Settings</string>
|
||||
<string name="fmt_email">findmytutorwmi@gmail.com</string>
|
||||
|
||||
|
||||
|
||||
@ -170,7 +181,7 @@
|
||||
<!--PulsingLayerOpacityColorActivity activity-->
|
||||
<string name="fab_title_hotels">TODO</string>
|
||||
<string name="fab_title_parks">THIS</string>
|
||||
<string name="fab_title_attractions">TOO</string>
|
||||
<string name="fab_title_bound_area">Bounds OFF</string>
|
||||
<string name="select_a_location">Select a location</string>
|
||||
<string name="user_location_permission_explanation">This app needs location permissions in order to show its functionality.</string>
|
||||
<string name="user_location_permission_not_granted">You didn\'t grant location permissions.</string>
|
||||
@ -194,5 +205,6 @@
|
||||
<string name="permission_rationale">permission should be granted</string>
|
||||
<string name="launch_activity" />
|
||||
<string name="remove_location_updates" />
|
||||
<string name="map_activity_label">MapActivity</string>
|
||||
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user