Some minor code cleanup

This commit is contained in:
Jakob Nixdorf 2020-02-02 12:55:17 +01:00
parent e1aa30967d
commit 63b4ecca5f
No known key found for this signature in database
GPG key ID: BE99BF86574A7DBC
3 changed files with 7 additions and 11 deletions

View file

@ -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();
}

View file

@ -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;
}

View file

@ -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 {