summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorŁukasz Paczos <lukas.paczos@gmail.com>2018-03-01 14:42:45 +0100
committerŁukasz Paczos <lukas.paczos@gmail.com>2018-03-01 14:42:45 +0100
commit46359cda049738a9a4e34098cbf6578a9ad194a1 (patch)
tree9106044079095646c25cb9eeb5919efeafc1fa9c
parentf160bff60857062ff5a1542fe690ac9ca0f5ba78 (diff)
downloadqtlocation-mapboxgl-upstream/lp-remove-deprecated-location-view.tar.gz
[android] removed location permission checks from the test appupstream/lp-remove-deprecated-location-view
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/FeatureOverviewActivity.java77
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/activity/Feature.java10
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/categories.xml1
3 files changed, 3 insertions, 85 deletions
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/FeatureOverviewActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/FeatureOverviewActivity.java
index 0ee1f78e0e..c8b15593ec 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/FeatureOverviewActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/FeatureOverviewActivity.java
@@ -7,23 +7,17 @@ import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.os.AsyncTask;
-import android.os.Build;
import android.os.Bundle;
-import android.support.annotation.NonNull;
import android.support.annotation.StringRes;
-import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
-import android.text.TextUtils;
import com.mapbox.mapboxsdk.testapp.R;
import com.mapbox.mapboxsdk.testapp.adapter.FeatureAdapter;
import com.mapbox.mapboxsdk.testapp.adapter.FeatureSectionAdapter;
import com.mapbox.mapboxsdk.testapp.model.activity.Feature;
import com.mapbox.mapboxsdk.testapp.utils.ItemClickSupport;
-import com.mapbox.android.core.permissions.PermissionsListener;
-import com.mapbox.android.core.permissions.PermissionsManager;
import java.util.ArrayList;
import java.util.Collections;
@@ -39,23 +33,19 @@ import timber.log.Timber;
* It uses tags as category and description to order the different entries.
* </p>
*/
-public class FeatureOverviewActivity extends AppCompatActivity implements PermissionsListener {
+public class FeatureOverviewActivity extends AppCompatActivity {
private static final String KEY_STATE_FEATURES = "featureList";
- private PermissionsManager permissionsManager;
private RecyclerView recyclerView;
private FeatureSectionAdapter sectionAdapter;
private List<Feature> features;
- private int locationActivityInList;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_feature_overview);
- permissionsManager = new PermissionsManager(this);
-
recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
recyclerView.addOnItemTouchListener(new RecyclerView.SimpleOnItemTouchListener());
@@ -65,11 +55,6 @@ public class FeatureOverviewActivity extends AppCompatActivity implements Permis
if (!sectionAdapter.isSectionHeaderPosition(position)) {
int itemPosition = sectionAdapter.getConvertedPosition(position);
Feature feature = features.get(itemPosition);
- if (feature.isRequiresLocationPermission()) {
- if (requestLocationPermission(itemPosition)) {
- return;
- }
- }
startFeature(feature);
}
});
@@ -118,45 +103,6 @@ public class FeatureOverviewActivity extends AppCompatActivity implements Permis
startActivity(intent);
}
- private boolean requestLocationPermission(final int positionInList) {
- if (isRuntimePermissionsRequired()) {
- locationActivityInList = positionInList;
- permissionsManager.requestLocationPermissions(this);
- return true;
- }
- return false;
- }
-
- @Override
- public void onExplanationNeeded(List<String> list) {
- Snackbar.make(
- findViewById(android.R.id.content),
- TextUtils.join("", list.toArray()),
- Snackbar.LENGTH_SHORT).show();
- }
-
- @Override
- public void onPermissionResult(boolean isPermissionGranted) {
- if (isPermissionGranted) {
- startFeature(features.get(locationActivityInList));
- } else {
- Snackbar.make(
- findViewById(android.R.id.content),
- "Can't open without accepting the location permission.",
- Snackbar.LENGTH_SHORT).show();
- }
- }
-
- @Override
- public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
- super.onRequestPermissionsResult(requestCode, permissions, grantResults);
- permissionsManager.onRequestPermissionsResult(requestCode, permissions, grantResults);
- }
-
- private boolean isRuntimePermissionsRequired() {
- return android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M;
- }
-
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
@@ -178,8 +124,7 @@ public class FeatureOverviewActivity extends AppCompatActivity implements Permis
String label = getString(info.labelRes);
String description = resolveString(info.descriptionRes);
String category = resolveMetaData(info.metaData, metaDataKey);
- boolean requiresLocationPermission = requiresLocationPermission(label, category);
- features.add(new Feature(info.name, label, description, category, requiresLocationPermission));
+ features.add(new Feature(info.name, label, description, category));
}
}
@@ -213,24 +158,6 @@ public class FeatureOverviewActivity extends AppCompatActivity implements Permis
}
}
- private boolean requiresLocationPermission(String name, String category) {
- final Resources resources = getResources();
-
- List<String> requiresPermissionCategories = new ArrayList<String>() {
- {
- add(resources.getString(R.string.category_userlocation));
- }
- };
-
- List<String> requiresPermissionActivities = new ArrayList<String>() {
- {
- add(resources.getString(R.string.activity_double_map));
- }
- };
-
- return requiresPermissionCategories.contains(category) || requiresPermissionActivities.contains(name);
- }
-
@Override
protected void onPostExecute(List<Feature> features) {
super.onPostExecute(features);
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/activity/Feature.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/activity/Feature.java
index d745982388..f3562b5b15 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/activity/Feature.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/activity/Feature.java
@@ -9,14 +9,12 @@ public class Feature implements Parcelable {
private String label;
private String description;
private String category;
- private boolean requiresLocationPermission;
- public Feature(String name, String label, String description, String category, boolean requiresLocationPermission) {
+ public Feature(String name, String label, String description, String category) {
this.name = name;
this.label = label;
this.description = description;
this.category = category;
- this.requiresLocationPermission = requiresLocationPermission;
}
private Feature(Parcel in) {
@@ -24,7 +22,6 @@ public class Feature implements Parcelable {
label = in.readString();
description = in.readString();
category = in.readString();
- requiresLocationPermission = in.readByte() != 0;
}
public String getName() {
@@ -48,10 +45,6 @@ public class Feature implements Parcelable {
return category;
}
- public boolean isRequiresLocationPermission() {
- return requiresLocationPermission;
- }
-
public int describeContents() {
return 0;
}
@@ -61,7 +54,6 @@ public class Feature implements Parcelable {
out.writeString(label);
out.writeString(description);
out.writeString(category);
- out.writeByte((byte) (requiresLocationPermission ? 1 : 0));
}
public static final Parcelable.Creator<Feature> CREATOR
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/categories.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/categories.xml
index dbc6b59db6..aafeb1cd9c 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/categories.xml
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/categories.xml
@@ -10,7 +10,6 @@
<string name="category_infowindow">Info Window</string>
<string name="category_maplayout">Map Layout</string>
<string name="category_offline">Offline</string>
- <string name="category_userlocation">User Location</string>
<string name="category_style">Styling</string>
<string name="category_features">Features</string>
<string name="category_storage">Storage</string>