From 0013caa05f1d94223687a1db0b975707236a32d8 Mon Sep 17 00:00:00 2001 From: m2049r <30435443+m2049r@users.noreply.github.com> Date: Mon, 4 Sep 2017 22:30:37 +0200 Subject: [PATCH] request and respond to permissions marshmallow style --- .../java/com/m2049r/xmrwallet/LoginActivity.java | 13 ++++++++++++- .../java/com/m2049r/xmrwallet/WalletActivity.java | 12 +++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/m2049r/xmrwallet/LoginActivity.java b/app/src/main/java/com/m2049r/xmrwallet/LoginActivity.java index 8ed4a0a8..3e8519e3 100644 --- a/app/src/main/java/com/m2049r/xmrwallet/LoginActivity.java +++ b/app/src/main/java/com/m2049r/xmrwallet/LoginActivity.java @@ -593,7 +593,7 @@ public class LoginActivity extends AppCompatActivity // If request is cancelled, the result arrays are empty. if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { - startLoginFragment(); + startLoginFragment = true; } else { String msg = getString(R.string.message_strorage_not_permitted); Log.e(TAG, msg); @@ -605,6 +605,17 @@ public class LoginActivity extends AppCompatActivity } } + private boolean startLoginFragment = false; + + @Override + protected void onResumeFragments() { + super.onResumeFragments(); + if (startLoginFragment) { + startLoginFragment(); + startLoginFragment = false; + } + } + void startLoginFragment() { Fragment fragment = new LoginFragment(); getSupportFragmentManager().beginTransaction() diff --git a/app/src/main/java/com/m2049r/xmrwallet/WalletActivity.java b/app/src/main/java/com/m2049r/xmrwallet/WalletActivity.java index af2985ca..2ebed53c 100644 --- a/app/src/main/java/com/m2049r/xmrwallet/WalletActivity.java +++ b/app/src/main/java/com/m2049r/xmrwallet/WalletActivity.java @@ -612,6 +612,16 @@ public class WalletActivity extends AppCompatActivity implements WalletFragment. getWallet().disposePendingTransaction(); } + private boolean startScanFragment = false; + + @Override + protected void onResumeFragments() { + super.onResumeFragments(); + if (startScanFragment) { + startScanFragment(); + startScanFragment = false; + } + } private void startScanFragment() { Bundle extras = new Bundle(); @@ -703,7 +713,7 @@ public class WalletActivity extends AppCompatActivity implements WalletFragment. // If request is cancelled, the result arrays are empty. if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { - startScanFragment(); + startScanFragment = true; } else { String msg = getString(R.string.message_camera_not_permitted); Log.e(TAG, msg);