mirror of
https://github.com/beemdevelopment/Aegis.git
synced 2025-05-04 20:30:36 +00:00
Get external storage read permissions before selecting an image to scan
Fixes #150
This commit is contained in:
parent
eb29be587f
commit
9e4ad1495d
1 changed files with 17 additions and 6 deletions
|
@ -65,6 +65,7 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
|
|||
|
||||
// permission request codes
|
||||
private static final int CODE_PERM_CAMERA = 0;
|
||||
private static final int CODE_PERM_READ_STORAGE = 1;
|
||||
|
||||
private AegisApplication _app;
|
||||
private DatabaseManager _db;
|
||||
|
@ -106,12 +107,7 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
|
|||
});
|
||||
findViewById(R.id.fab_scan_image).setOnClickListener(view -> {
|
||||
_fabMenu.collapse();
|
||||
|
||||
Intent galleryIntent = new Intent(Intent.ACTION_PICK);
|
||||
galleryIntent.setDataAndType(android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI, "image/*");
|
||||
|
||||
Intent chooserIntent = Intent.createChooser(galleryIntent, getString(R.string.select_picture));
|
||||
startActivityForResult(Intent.createChooser(chooserIntent, getString(R.string.select_picture)), CODE_SCAN_IMAGE);
|
||||
startScanImageActivity();
|
||||
});
|
||||
findViewById(R.id.fab_scan).setOnClickListener(view -> {
|
||||
_fabMenu.collapse();
|
||||
|
@ -195,6 +191,9 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
|
|||
case CODE_PERM_CAMERA:
|
||||
startScanActivity();
|
||||
break;
|
||||
case CODE_PERM_READ_STORAGE:
|
||||
startScanImageActivity();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -371,6 +370,18 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
|
|||
startActivityForResult(scannerActivity, CODE_SCAN);
|
||||
}
|
||||
|
||||
private void startScanImageActivity() {
|
||||
if (!PermissionHelper.request(this, CODE_PERM_READ_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Intent galleryIntent = new Intent(Intent.ACTION_PICK);
|
||||
galleryIntent.setDataAndType(android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI, "image/*");
|
||||
|
||||
Intent chooserIntent = Intent.createChooser(galleryIntent, getString(R.string.select_picture));
|
||||
startActivityForResult(Intent.createChooser(chooserIntent, getString(R.string.select_picture)), CODE_SCAN_IMAGE);
|
||||
}
|
||||
|
||||
private void doShortcutActions() {
|
||||
Intent intent = getIntent();
|
||||
String action = intent.getStringExtra("action");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue