android: upgraded gradle, removed permission check
This commit is contained in:
parent
b021c4d893
commit
5844d6eb87
4 changed files with 8 additions and 67 deletions
|
@ -37,7 +37,7 @@ android {
|
||||||
targetSdkVersion 28 // same as compileSdkVersion
|
targetSdkVersion 28 // same as compileSdkVersion
|
||||||
versionCode flutterVersionCode.toInteger()
|
versionCode flutterVersionCode.toInteger()
|
||||||
versionName flutterVersionName
|
versionName flutterVersionName
|
||||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
|
|
||||||
buildTypes {
|
buildTypes {
|
||||||
|
@ -61,6 +61,6 @@ dependencies {
|
||||||
implementation 'com.google.guava:guava:28.0-android'
|
implementation 'com.google.guava:guava:28.0-android'
|
||||||
implementation 'com.karumi:dexter:5.0.0'
|
implementation 'com.karumi:dexter:5.0.0'
|
||||||
testImplementation 'junit:junit:4.12'
|
testImplementation 'junit:junit:4.12'
|
||||||
androidTestImplementation 'com.android.support.test:runner:1.0.2'
|
androidTestImplementation 'androidx.test:runner:1.1.0'
|
||||||
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
|
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,23 +1,12 @@
|
||||||
package deckers.thibault.aves.channelhandlers;
|
package deckers.thibault.aves.channelhandlers;
|
||||||
|
|
||||||
import android.Manifest;
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.provider.Settings;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
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 java.util.Map;
|
||||||
|
|
||||||
import deckers.thibault.aves.model.ImageEntry;
|
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) {
|
public void onMethodCall(@NonNull MethodCall call, @NonNull MethodChannel.Result result) {
|
||||||
switch (call.method) {
|
switch (call.method) {
|
||||||
case "getImageEntries":
|
case "getImageEntries":
|
||||||
getPermissionResult(result, activity);
|
mediaStoreStreamHandler.fetchAll(activity);
|
||||||
|
result.success(null);
|
||||||
break;
|
break;
|
||||||
case "getImageBytes":
|
case "getImageBytes":
|
||||||
getImageBytes(call, result);
|
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();
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -5,7 +5,7 @@ buildscript {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:3.4.2'
|
classpath 'com.android.tools.build:gradle:3.5.0'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#Sun Jun 30 23:38:35 KST 2019
|
#Mon Aug 26 22:57:25 KST 2019
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
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
|
||||||
|
|
Loading…
Reference in a new issue