diff --git a/app/src/main/java/org/shadowice/flocke/andotp/Activities/MainActivity.java b/app/src/main/java/org/shadowice/flocke/andotp/Activities/MainActivity.java index 0a4cf93b..c4de6913 100644 --- a/app/src/main/java/org/shadowice/flocke/andotp/Activities/MainActivity.java +++ b/app/src/main/java/org/shadowice/flocke/andotp/Activities/MainActivity.java @@ -82,7 +82,6 @@ import javax.crypto.SecretKey; import static org.shadowice.flocke.andotp.Utilities.Constants.AuthMethod; import static org.shadowice.flocke.andotp.Utilities.Constants.EncryptionType; -import static org.shadowice.flocke.andotp.Utilities.Constants.INTENT_QR_OPEN_IMAGE; import static org.shadowice.flocke.andotp.Utilities.Constants.SortMode; public class MainActivity extends BaseActivity @@ -221,7 +220,7 @@ public class MainActivity extends BaseActivity ManualEntryDialog.show(MainActivity.this, settings, adapter); return false; case R.id.fabScanQRFromImage: - openFileWithPermissions(INTENT_QR_OPEN_IMAGE); + openFileWithPermissions(Constants.INTENT_MAIN_QR_OPEN_IMAGE); return false; default: return false; @@ -449,7 +448,7 @@ public class MainActivity extends BaseActivity updateEncryption(authKey); } - } else if (requestCode == INTENT_QR_OPEN_IMAGE && resultCode == RESULT_OK) { + } else if (requestCode == Constants.INTENT_MAIN_QR_OPEN_IMAGE && resultCode == RESULT_OK) { if (intent != null) { addQRCode(ScanQRCodeFromFile.scanQRImage(this, intent.getData())); } @@ -753,7 +752,7 @@ public class MainActivity extends BaseActivity if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) { showOpenFileSelector(intentId); } else { - ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, Constants.PERMISSIONS_QR_READ_IMAGE); + ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, Constants.PERMISSIONS_MAIN_QR_READ_IMAGE); } } @@ -766,9 +765,9 @@ public class MainActivity extends BaseActivity @Override public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { - if (requestCode == Constants.PERMISSIONS_QR_READ_IMAGE) { + if (requestCode == Constants.PERMISSIONS_MAIN_QR_READ_IMAGE) { if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { - showOpenFileSelector(INTENT_QR_OPEN_IMAGE); + showOpenFileSelector(Constants.INTENT_MAIN_QR_OPEN_IMAGE); } else { Toast.makeText(this, R.string.backup_toast_storage_permissions, Toast.LENGTH_LONG).show(); } diff --git a/app/src/main/java/org/shadowice/flocke/andotp/Utilities/Constants.java b/app/src/main/java/org/shadowice/flocke/andotp/Utilities/Constants.java index ba1f7a73..d12be4ec 100644 --- a/app/src/main/java/org/shadowice/flocke/andotp/Utilities/Constants.java +++ b/app/src/main/java/org/shadowice/flocke/andotp/Utilities/Constants.java @@ -69,6 +69,7 @@ public class Constants { public final static int INTENT_MAIN_SETTINGS = 101; public final static int INTENT_MAIN_BACKUP = 102; public final static int INTENT_MAIN_INTRO = 103; + public final static int INTENT_MAIN_QR_OPEN_IMAGE = 104; public final static int INTENT_BACKUP_OPEN_DOCUMENT_PLAIN = 200; public final static int INTENT_BACKUP_SAVE_DOCUMENT_PLAIN = 201; @@ -83,6 +84,7 @@ public class Constants { public static final int INTENT_SETTINGS_AUTHENTICATE = 300; // Permission requests (Format: A1x with A = parent Activity, x = number of the request) + public final static int PERMISSIONS_MAIN_QR_READ_IMAGE = 111; public final static int PERMISSIONS_BACKUP_READ_IMPORT_PLAIN = 210; public final static int PERMISSIONS_BACKUP_WRITE_EXPORT_PLAIN = 211; public final static int PERMISSIONS_BACKUP_READ_IMPORT_CRYPT = 212; @@ -143,7 +145,4 @@ public class Constants { public final static String BACKUP_MIMETYPE_PLAIN = "application/json"; public final static String BACKUP_MIMETYPE_CRYPT = "binary/aes"; public final static String BACKUP_MIMETYPE_PGP = "application/pgp-encrypted"; - - public final static int INTENT_QR_OPEN_IMAGE = 400; - public final static int PERMISSIONS_QR_READ_IMAGE = 401; } diff --git a/app/src/main/java/org/shadowice/flocke/andotp/Utilities/ScanQRCodeFromFile.java b/app/src/main/java/org/shadowice/flocke/andotp/Utilities/ScanQRCodeFromFile.java index 95c5247a..242e0b4b 100644 --- a/app/src/main/java/org/shadowice/flocke/andotp/Utilities/ScanQRCodeFromFile.java +++ b/app/src/main/java/org/shadowice/flocke/andotp/Utilities/ScanQRCodeFromFile.java @@ -18,8 +18,6 @@ import com.google.zxing.Result; import com.google.zxing.common.HybridBinarizer; import org.shadowice.flocke.andotp.R; -import org.shadowice.flocke.andotp.Utilities.StorageAccessHelper; -import org.shadowice.flocke.andotp.Utilities.Tools; import java.io.IOException; public class ScanQRCodeFromFile {