Minimize use of class variables in ViewKey

This commit is contained in:
Dominik Schürmann 2014-04-10 13:58:19 +02:00
parent da4016d565
commit a85b217756

View File

@ -140,7 +140,7 @@ public class ViewKeyActivity extends ActionBarActivity {
uploadToKeyserver(mDataUri); uploadToKeyserver(mDataUri);
return true; return true;
case R.id.menu_key_view_export_file: case R.id.menu_key_view_export_file:
exportToFile(mDataUri); exportToFile(mDataUri, mExportHelper);
return true; return true;
case R.id.menu_key_view_share_default_fingerprint: case R.id.menu_key_view_share_default_fingerprint:
shareKey(mDataUri, true); shareKey(mDataUri, true);
@ -161,14 +161,14 @@ public class ViewKeyActivity extends ActionBarActivity {
copyToClipboard(mDataUri); copyToClipboard(mDataUri);
return true; return true;
case R.id.menu_key_view_delete: { case R.id.menu_key_view_delete: {
deleteKey(mDataUri); deleteKey(mDataUri, mExportHelper);
return true; return true;
} }
} }
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }
private void exportToFile(Uri dataUri) { private void exportToFile(Uri dataUri, ExportHelper exportHelper) {
Uri baseUri = KeychainContract.KeyRings.buildUnifiedKeyRingUri(dataUri); Uri baseUri = KeychainContract.KeyRings.buildUnifiedKeyRingUri(dataUri);
HashMap<String, Object> data = ProviderHelper.getGenericData(this, HashMap<String, Object> data = ProviderHelper.getGenericData(this,
@ -176,7 +176,7 @@ public class ViewKeyActivity extends ActionBarActivity {
new String[]{KeychainContract.Keys.MASTER_KEY_ID, KeychainContract.KeyRings.HAS_SECRET}, new String[]{KeychainContract.Keys.MASTER_KEY_ID, KeychainContract.KeyRings.HAS_SECRET},
new int[]{ProviderHelper.FIELD_TYPE_INTEGER, ProviderHelper.FIELD_TYPE_INTEGER}); new int[]{ProviderHelper.FIELD_TYPE_INTEGER, ProviderHelper.FIELD_TYPE_INTEGER});
mExportHelper.showExportKeysDialog( exportHelper.showExportKeysDialog(
new long[]{(Long) data.get(KeychainContract.KeyRings.MASTER_KEY_ID)}, new long[]{(Long) data.get(KeychainContract.KeyRings.MASTER_KEY_ID)},
Constants.Path.APP_DIR_FILE, Constants.Path.APP_DIR_FILE,
((Long) data.get(KeychainContract.KeyRings.HAS_SECRET) == 1) ((Long) data.get(KeychainContract.KeyRings.HAS_SECRET) == 1)
@ -277,7 +277,7 @@ public class ViewKeyActivity extends ActionBarActivity {
dialog.show(getSupportFragmentManager(), "shareNfcDialog"); dialog.show(getSupportFragmentManager(), "shareNfcDialog");
} }
private void deleteKey(Uri dataUri) { private void deleteKey(Uri dataUri, ExportHelper exportHelper) {
// Message is received after key is deleted // Message is received after key is deleted
Handler returnHandler = new Handler() { Handler returnHandler = new Handler() {
@Override @Override
@ -287,7 +287,7 @@ public class ViewKeyActivity extends ActionBarActivity {
} }
}; };
mExportHelper.deleteKey(dataUri, returnHandler); exportHelper.deleteKey(dataUri, returnHandler);
} }
@Override @Override