From 5844d6eb87ba1662e1933ca2991d843e5e1306f2 Mon Sep 17 00:00:00 2001 From: Thibault Deckers Date: Mon, 26 Aug 2019 23:07:41 +0900 Subject: [PATCH] android: upgraded gradle, removed permission check --- android/app/build.gradle | 6 +- .../channelhandlers/ImageFileHandler.java | 63 +------------------ android/build.gradle | 2 +- .../gradle/wrapper/gradle-wrapper.properties | 4 +- 4 files changed, 8 insertions(+), 67 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 3d3544c9d..1b2f60e06 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -37,7 +37,7 @@ android { targetSdkVersion 28 // same as compileSdkVersion versionCode flutterVersionCode.toInteger() versionName flutterVersionName - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { @@ -61,6 +61,6 @@ dependencies { implementation 'com.google.guava:guava:28.0-android' implementation 'com.karumi:dexter:5.0.0' testImplementation 'junit:junit:4.12' - androidTestImplementation 'com.android.support.test:runner:1.0.2' - androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' + androidTestImplementation 'androidx.test:runner:1.1.0' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0' } diff --git a/android/app/src/main/java/deckers/thibault/aves/channelhandlers/ImageFileHandler.java b/android/app/src/main/java/deckers/thibault/aves/channelhandlers/ImageFileHandler.java index 8131438e9..fdff87275 100644 --- a/android/app/src/main/java/deckers/thibault/aves/channelhandlers/ImageFileHandler.java +++ b/android/app/src/main/java/deckers/thibault/aves/channelhandlers/ImageFileHandler.java @@ -1,23 +1,12 @@ package deckers.thibault.aves.channelhandlers; -import android.Manifest; import android.app.Activity; -import android.app.AlertDialog; -import android.content.Intent; import android.net.Uri; import android.os.Handler; import android.os.Looper; -import android.provider.Settings; import androidx.annotation.NonNull; -import com.karumi.dexter.Dexter; -import com.karumi.dexter.PermissionToken; -import com.karumi.dexter.listener.PermissionDeniedResponse; -import com.karumi.dexter.listener.PermissionGrantedResponse; -import com.karumi.dexter.listener.PermissionRequest; -import com.karumi.dexter.listener.single.PermissionListener; - import java.util.Map; import deckers.thibault.aves.model.ImageEntry; @@ -43,7 +32,8 @@ public class ImageFileHandler implements MethodChannel.MethodCallHandler { public void onMethodCall(@NonNull MethodCall call, @NonNull MethodChannel.Result result) { switch (call.method) { case "getImageEntries": - getPermissionResult(result, activity); + mediaStoreStreamHandler.fetchAll(activity); + result.success(null); break; case "getImageBytes": getImageBytes(call, result); @@ -168,53 +158,4 @@ public class ImageFileHandler implements MethodChannel.MethodCallHandler { } }); } - - private void getPermissionResult(final MethodChannel.Result result, final Activity activity) { - Dexter.withActivity(activity) - .withPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) - .withListener(new PermissionListener() { - @Override - public void onPermissionGranted(PermissionGrantedResponse response) { - mediaStoreStreamHandler.fetchAll(activity); - result.success(null); - } - - @Override - public void onPermissionDenied(PermissionDeniedResponse response) { - AlertDialog.Builder builder = new AlertDialog.Builder(activity); - builder.setMessage("This permission is needed for use this features of the app so please, allow it!"); - builder.setTitle("We need this permission"); - builder.setCancelable(false); - builder.setPositiveButton("OK", (dialog, id) -> { - dialog.cancel(); - Intent intent = new Intent(); - intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); - Uri uri = Uri.fromParts("package", activity.getPackageName(), null); - intent.setData(uri); - activity.startActivity(intent); - }); - builder.setNegativeButton("Cancel", (dialog, id) -> dialog.cancel()); - AlertDialog alert = builder.create(); - alert.show(); - } - - @Override - public void onPermissionRationaleShouldBeShown(PermissionRequest permission, final PermissionToken token) { - AlertDialog.Builder builder = new AlertDialog.Builder(activity); - builder.setMessage("This permission is needed for use this features of the app so please, allow it!"); - builder.setTitle("We need this permission"); - builder.setCancelable(false); - builder.setPositiveButton("OK", (dialog, id) -> { - dialog.cancel(); - token.continuePermissionRequest(); - }); - builder.setNegativeButton("Cancel", (dialog, id) -> { - dialog.cancel(); - token.cancelPermissionRequest(); - }); - AlertDialog alert = builder.create(); - alert.show(); - } - }).check(); - } } \ No newline at end of file diff --git a/android/build.gradle b/android/build.gradle index 6b1a639ef..e0d7ae2c1 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -5,7 +5,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:3.4.2' + classpath 'com.android.tools.build:gradle:3.5.0' } } diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties index 01ad6880f..466aad805 100644 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Sun Jun 30 23:38:35 KST 2019 +#Mon Aug 26 22:57:25 KST 2019 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip