change wording of export dialog, remove "export secret" checkbox

This commit is contained in:
Vincent Breitmoser
2015-07-08 17:25:07 +02:00
parent e0cb891a1f
commit 20cebc2788
17 changed files with 53 additions and 72 deletions

View File

@@ -39,7 +39,6 @@ public class BackupFragment extends Fragment {
// This ids for multiple key export.
private ArrayList<Long> mIdsForRepeatAskPassphrase;
private ArrayList<Long> mIdsForExport;
// This index for remembering the number of master key.
private int mIndex;

View File

@@ -95,7 +95,7 @@ public class ViewKeyActivity extends BaseNfcActivity implements
public static final String EXTRA_NFC_FINGERPRINTS = "nfc_fingerprints";
static final int REQUEST_QR_FINGERPRINT = 1;
static final int REQUEST_EXPORT = 2;
static final int REQUEST_BACKUP = 2;
static final int REQUEST_CERTIFY = 3;
public static final String EXTRA_DISPLAY_RESULT = "display_result";
@@ -325,7 +325,7 @@ public class ViewKeyActivity extends BaseNfcActivity implements
return true;
}
case R.id.menu_key_view_export_file: {
startPassphraseActivity(REQUEST_EXPORT);
startPassphraseActivity(REQUEST_BACKUP);
return true;
}
case R.id.menu_key_view_delete: {
@@ -413,23 +413,9 @@ public class ViewKeyActivity extends BaseNfcActivity implements
startActivityForResult(intent, requestCode);
}
private void exportToFile(Uri dataUri, ProviderHelper providerHelper) {
try {
Uri baseUri = KeychainContract.KeyRings.buildUnifiedKeyRingUri(dataUri);
HashMap<String, Object> data = providerHelper.getGenericData(
baseUri,
new String[]{KeychainContract.Keys.MASTER_KEY_ID, KeychainContract.KeyRings.HAS_SECRET},
new int[]{ProviderHelper.FIELD_TYPE_INTEGER, ProviderHelper.FIELD_TYPE_INTEGER});
new ExportHelper(this).showExportKeysDialog(
new long[]{(Long) data.get(KeychainContract.KeyRings.MASTER_KEY_ID)},
Constants.Path.APP_DIR_FILE, ((Long) data.get(KeychainContract.KeyRings.HAS_SECRET) != 0)
);
} catch (ProviderHelper.NotFoundException e) {
Notify.create(this, R.string.error_key_not_found, Notify.Style.ERROR).show();
Log.e(Constants.TAG, "Key not found", e);
}
private void backupToFile() {
new ExportHelper(this).showExportKeysDialog(
mMasterKeyId, Constants.Path.APP_DIR_FILE, true);
}
private void deleteKey() {
@@ -489,8 +475,8 @@ public class ViewKeyActivity extends BaseNfcActivity implements
return;
}
case REQUEST_EXPORT: {
exportToFile(mDataUri, mProviderHelper);
case REQUEST_BACKUP: {
backupToFile();
return;
}

View File

@@ -22,7 +22,6 @@ import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.util.HashMap;
import android.app.Activity;
import android.app.ActivityOptions;
@@ -84,6 +83,7 @@ public class ViewKeyAdvShareFragment extends LoaderFragment implements
private Uri mDataUri;
private byte[] mFingerprint;
private long mMasterKeyId;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup superContainer, Bundle savedInstanceState) {
@@ -135,7 +135,7 @@ public class ViewKeyAdvShareFragment extends LoaderFragment implements
vKeySafeButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
exportToFile(mDataUri, new ProviderHelper(getActivity()));
exportToFile();
}
});
vKeyClipboardButton.setOnClickListener(new View.OnClickListener() {
@@ -173,23 +173,9 @@ public class ViewKeyAdvShareFragment extends LoaderFragment implements
return root;
}
private void exportToFile(Uri dataUri, ProviderHelper providerHelper) {
try {
Uri baseUri = KeychainContract.KeyRings.buildUnifiedKeyRingUri(dataUri);
HashMap<String, Object> data = providerHelper.getGenericData(
baseUri,
new String[]{KeychainContract.Keys.MASTER_KEY_ID, KeychainContract.KeyRings.HAS_SECRET},
new int[]{ProviderHelper.FIELD_TYPE_INTEGER, ProviderHelper.FIELD_TYPE_INTEGER});
new ExportHelper(getActivity()).showExportKeysDialog(
new long[]{(Long) data.get(KeychainContract.KeyRings.MASTER_KEY_ID)},
Constants.Path.APP_DIR_FILE, ((Long) data.get(KeychainContract.KeyRings.HAS_SECRET) != 0)
);
} catch (ProviderHelper.NotFoundException e) {
Notify.create(getActivity(), R.string.error_key_not_found, Notify.Style.ERROR).show();
Log.e(Constants.TAG, "Key not found", e);
}
private void exportToFile() {
new ExportHelper(getActivity()).showExportKeysDialog(
mMasterKeyId, Constants.Path.APP_DIR_FILE, false);
}
private void startSafeSlinger(Uri dataUri) {
@@ -383,6 +369,7 @@ public class ViewKeyAdvShareFragment extends LoaderFragment implements
/** Load QR Code asynchronously and with a fade in animation */
private void setFingerprint(byte[] fingerprintBlob) {
mFingerprint = fingerprintBlob;
mMasterKeyId = KeyFormattingUtils.getKeyIdFromFingerprint(fingerprintBlob);
final String fingerprint = KeyFormattingUtils.convertFingerprintToHex(fingerprintBlob);
mFingerprintView.setText(KeyFormattingUtils.colorizeFingerprint(fingerprint));