diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateSecurityTokenImportResetFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateSecurityTokenImportResetFragment.java index 2ebd2e944..f2eba1386 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateSecurityTokenImportResetFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateSecurityTokenImportResetFragment.java @@ -27,6 +27,7 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.CompoundButton; +import android.widget.ProgressBar; import android.widget.RadioButton; import android.widget.TextView; @@ -67,11 +68,11 @@ public class CreateSecurityTokenImportResetFragment private byte[] mTokenAid; private String mTokenUserId; private String mTokenFingerprint; - private ImportKeysListFragment mListFragment; private TextView vSerNo; private TextView vUserId; private TextView mNextButton; private RadioButton mRadioImport; + private RadioButton mRadioFile; private RadioButton mRadioReset; private View mResetWarning; @@ -116,6 +117,7 @@ public class CreateSecurityTokenImportResetFragment vUserId = (TextView) view.findViewById(R.id.token_userid); mNextButton = (TextView) view.findViewById(R.id.create_key_next_button); mRadioImport = (RadioButton) view.findViewById(R.id.token_decision_import); + mRadioFile = (RadioButton) view.findViewById(R.id.token_decision_file); mRadioReset = (RadioButton) view.findViewById(R.id.token_decision_reset); mResetWarning = view.findViewById(R.id.token_import_reset_warning); @@ -137,15 +139,14 @@ public class CreateSecurityTokenImportResetFragment public void onClick(View v) { if (mRadioReset.isChecked()) { resetCard(); - } else { + } else if (mRadioImport.isChecked()){ importKey(); + } else { + importFile(); } } }); - mListFragment = ImportKeysListFragment.newInstance(null, null, - "0x" + mTokenFingerprint, true, null); - mRadioImport.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { @@ -154,13 +155,17 @@ public class CreateSecurityTokenImportResetFragment mNextButton.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_key_plus_grey600_24dp, 0); mNextButton.setVisibility(View.VISIBLE); mResetWarning.setVisibility(View.GONE); - - getFragmentManager().beginTransaction() - .replace(R.id.security_token_import_fragment, mListFragment, "token_import") - .commit(); - - getFragmentManager().executePendingTransactions(); - refreshSearch(); + } + } + }); + mRadioFile.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + if (isChecked) { + mNextButton.setText(R.string.key_list_fab_import); + mNextButton.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_folder_grey_24dp, 0); + mNextButton.setVisibility(View.VISIBLE); + mResetWarning.setVisibility(View.GONE); } } }); @@ -172,10 +177,6 @@ public class CreateSecurityTokenImportResetFragment mNextButton.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_close_grey_24dp, 0); mNextButton.setVisibility(View.VISIBLE); mResetWarning.setVisibility(View.VISIBLE); - - getFragmentManager().beginTransaction() - .remove(mListFragment) - .commit(); } } }); @@ -212,13 +213,7 @@ public class CreateSecurityTokenImportResetFragment } } - public void refreshSearch() { - mListFragment.loadState(new CloudLoaderState("0x" + mTokenFingerprint, - Preferences.getPreferences(getActivity()).getCloudSearchPrefs())); - } - public void importKey() { - ArrayList keyList = new ArrayList<>(); keyList.add(new ParcelableKeyRing(mTokenFingerprint, null, null, null)); mKeyList = keyList; @@ -228,7 +223,12 @@ public class CreateSecurityTokenImportResetFragment super.setProgressMessageResource(R.string.progress_importing); super.cryptoOperation(); + } + public void importFile() { + Intent intent = new Intent(getActivity(), ImportKeysActivity.class); + intent.setAction(ImportKeysActivity.ACTION_IMPORT_KEY_FROM_FILE); + startActivity(intent); } public void resetCard() { diff --git a/OpenKeychain/src/main/res/layout/create_security_token_import_reset_fragment.xml b/OpenKeychain/src/main/res/layout/create_security_token_import_reset_fragment.xml index e97b99076..8fd7b1479 100644 --- a/OpenKeychain/src/main/res/layout/create_security_token_import_reset_fragment.xml +++ b/OpenKeychain/src/main/res/layout/create_security_token_import_reset_fragment.xml @@ -82,6 +82,13 @@ android:layout_marginTop="16dp" android:text="@string/security_token_import_radio" /> + + + diff --git a/OpenKeychain/src/main/res/values/strings.xml b/OpenKeychain/src/main/res/values/strings.xml index 6b836ef3c..7b9a0cf8b 100644 --- a/OpenKeychain/src/main/res/values/strings.xml +++ b/OpenKeychain/src/main/res/values/strings.xml @@ -1576,9 +1576,10 @@ "Security Token matches, can be bound to key" "Security Token matches, partly bound to key" "Hold Security Token against the back of your device." - "This Security Token already contains a key. You can import the key using the cloud or reset the Security Token." + "This Security Token already contains a key. To use it, we need additional key information. These information can be searched on a keyserver or imported from a file." "Reset" - "Import key" + "Search key information on keyserver" + "Import key information from file" "Reset Security Token" "Resetting the Security Token completely destroys the keys on it. Afterwards, you will not be able to decrypt messages/files encrypted with this key!" Different key stored on Security Token!