Merge pull request #1666 from open-keychain/file-import-fix

Fixed File Import issue due to onResumeFragments
This commit is contained in:
Dominik Schürmann
2016-01-11 17:39:53 +01:00

View File

@@ -21,6 +21,7 @@ import android.app.Activity;
import android.content.Intent; import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentManager;
import android.view.View; import android.view.View;
@@ -89,10 +90,15 @@ public class ImportKeysActivity extends BaseSecurityTokenNfcActivity
private CryptoOperationHelper<ImportKeyringParcel, ImportKeyResult> mOperationHelper; private CryptoOperationHelper<ImportKeyringParcel, ImportKeyResult> mOperationHelper;
private boolean mFreshIntent;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
// we're started with a new Intent that needs to be handled by onResumeFragments
mFreshIntent = true;
setFullScreenDialogClose(Activity.RESULT_CANCELED, true); setFullScreenDialogClose(Activity.RESULT_CANCELED, true);
findViewById(R.id.import_import).setOnClickListener(new OnClickListener() { findViewById(R.id.import_import).setOnClickListener(new OnClickListener() {
@Override @Override
@@ -116,15 +122,22 @@ public class ImportKeysActivity extends BaseSecurityTokenNfcActivity
public void onNewIntent(Intent intent) { public void onNewIntent(Intent intent) {
super.onNewIntent(intent); super.onNewIntent(intent);
setIntent(intent); setIntent(intent);
// new Intent, so onResumeFragments needs to handle it with handleActions(Intent)
mFreshIntent = true;
} }
@Override @Override
protected void onResumeFragments() { protected void onResumeFragments() {
super.onResumeFragments(); super.onResumeFragments();
handleActions(getIntent()); if (mFreshIntent) {
handleActions(getIntent());
// we've consumed this Intent, we don't want to repeat the action it represents
// every time the activity is resumed
mFreshIntent = false;
}
} }
protected void handleActions(Intent intent) { protected void handleActions(@NonNull Intent intent) {
String action = intent.getAction(); String action = intent.getAction();
Bundle extras = intent.getExtras(); Bundle extras = intent.getExtras();
Uri dataUri = intent.getData(); Uri dataUri = intent.getData();