Namespace fix;
This commit is contained in:
parent
56c1c24ea3
commit
7a0256afe9
|
@ -25,7 +25,7 @@
|
||||||
</value>
|
</value>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectType">
|
<component name="ProjectType">
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="com.example.filepicker">
|
package="com.mr.filepicker">
|
||||||
</manifest>
|
</manifest>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package com.example.filepicker;
|
package com.mr.filepicker;
|
||||||
|
|
||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
@ -53,6 +53,7 @@ public class FilePickerPlugin implements MethodCallHandler {
|
||||||
public void onMethodCall(MethodCall call, Result result) {
|
public void onMethodCall(MethodCall call, Result result) {
|
||||||
if (call.method.equals("pickPDF")) {
|
if (call.method.equals("pickPDF")) {
|
||||||
this.result = result;
|
this.result = result;
|
||||||
|
|
||||||
startFileExplorer();
|
startFileExplorer();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -60,6 +61,16 @@ public class FilePickerPlugin implements MethodCallHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String resolveFileType(String type) {
|
||||||
|
switch (type) {
|
||||||
|
case "PDF":
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "IMAGES":
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private boolean checkPermission() {
|
private boolean checkPermission() {
|
||||||
Activity activity = instance.activity();
|
Activity activity = instance.activity();
|
||||||
Log.i("SimplePermission", "Checking permission : " + permission);
|
Log.i("SimplePermission", "Checking permission : " + permission);
|
||||||
|
@ -69,18 +80,18 @@ public class FilePickerPlugin implements MethodCallHandler {
|
||||||
private void requestPermission() {
|
private void requestPermission() {
|
||||||
Activity activity = instance.activity();
|
Activity activity = instance.activity();
|
||||||
Log.i("File_Picker", "Requesting permission : " + permission);
|
Log.i("File_Picker", "Requesting permission : " + permission);
|
||||||
String[] perm = {permission};
|
String[] perm = { permission };
|
||||||
ActivityCompat.requestPermissions(activity, perm, 0);
|
ActivityCompat.requestPermissions(activity, perm, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startFileExplorer() {
|
private void startFileExplorer() {
|
||||||
|
|
||||||
if(checkPermission()) {
|
if (checkPermission()) {
|
||||||
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
|
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
|
||||||
intent.setType("application/pdf");
|
intent.setType("application/pdf");
|
||||||
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
||||||
instance.activity().startActivityForResult(intent, REQUEST_CODE);
|
instance.activity().startActivityForResult(intent, REQUEST_CODE);
|
||||||
}else {
|
} else {
|
||||||
requestPermission();
|
requestPermission();
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue