back press on first run activity closes app

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
This commit is contained in:
tobiasKaminsky 2019-02-05 12:53:26 +01:00 committed by Andy Scherzinger
parent db8940f6f7
commit b7089df901
No known key found for this signature in database
GPG key ID: 6CADC7E3523C308B
2 changed files with 15 additions and 1 deletions

View file

@ -198,6 +198,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
public static final String EMPTY_STRING = "";
private static final int REQUEST_CODE_QR_SCAN = 101;
public static final int REQUEST_CODE_FIRST_RUN = 102;
/// parameters from EXTRAs in starter Intent
@ -978,6 +979,11 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
@Override
protected void onNewIntent(Intent intent) {
Log_OC.d(TAG, "onNewIntent()");
if (intent.getBooleanExtra(FirstRunActivity.EXTRA_EXIT, false)) {
super.finish();
}
Uri data = intent.getData();
if (data != null && data.toString().startsWith(getString(R.string.oauth2_redirect_uri))) {
mNewCapturedUriFromOAuth2Redirection = data;

View file

@ -54,6 +54,7 @@ import androidx.viewpager.widget.ViewPager;
public class FirstRunActivity extends BaseActivity implements ViewPager.OnPageChangeListener {
public static final String EXTRA_ALLOW_CLOSE = "ALLOW_CLOSE";
public static final String EXTRA_EXIT = "EXIT";
public static final int FIRST_RUN_RESULT_CODE = 199;
private ProgressIndicator progressIndicator;
@ -157,6 +158,12 @@ public class FirstRunActivity extends BaseActivity implements ViewPager.OnPageCh
if (getIntent().getBooleanExtra(EXTRA_ALLOW_CLOSE, false)) {
super.onBackPressed();
} else {
Intent intent = new Intent(getApplicationContext(), AuthenticatorActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.putExtra(EXTRA_EXIT, true);
startActivity(intent);
finish();
}
}
@ -188,7 +195,8 @@ public class FirstRunActivity extends BaseActivity implements ViewPager.OnPageCh
}
if (isFirstRun(context) && context instanceof AuthenticatorActivity) {
context.startActivity(new Intent(context, FirstRunActivity.class));
((AuthenticatorActivity) context).startActivityForResult(new Intent(context, FirstRunActivity.class),
AuthenticatorActivity.REQUEST_CODE_FIRST_RUN);
return true;
} else {
return false;