aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain/src/main/java/org
diff options
context:
space:
mode:
authorDominik Schürmann <dominik@dominikschuermann.de>2014-06-20 23:01:35 +0200
committerDominik Schürmann <dominik@dominikschuermann.de>2014-06-20 23:01:35 +0200
commita1525bffe23fd0f86e77250f894eacbc481aed77 (patch)
tree66db8574680ec47d7ffbe431e2d861d0603d89af /OpenKeychain/src/main/java/org
parent0d644e37b1ca69a21384ec1590ce45dfd23a6ada (diff)
downloadopen-keychain-a1525bffe23fd0f86e77250f894eacbc481aed77.tar.gz
open-keychain-a1525bffe23fd0f86e77250f894eacbc481aed77.tar.bz2
open-keychain-a1525bffe23fd0f86e77250f894eacbc481aed77.zip
Fix qr code finally
Diffstat (limited to 'OpenKeychain/src/main/java/org')
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java43
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysFileFragment.java2
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysQrCodeFragment.java2
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysServerFragment.java3
4 files changed, 31 insertions, 19 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java
index 6d3b7c340..f7455905d 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java
@@ -135,16 +135,21 @@ public class ImportKeysActivity extends ActionBarActivity {
if (Intent.ACTION_VIEW.equals(action)) {
// Android's Action when opening file associated to Keychain (see AndroidManifest.xml)
- // override action to delegate it to Keychain's ACTION_IMPORT_KEY
+ // delegate action to ACTION_IMPORT_KEY
action = ACTION_IMPORT_KEY;
}
- Bundle serverBundle = null;
- boolean serverOnly = false;
if (scheme != null && scheme.toLowerCase(Locale.ENGLISH).equals(Constants.FINGERPRINT_SCHEME)) {
/* Scanning a fingerprint directly with Barcode Scanner */
- loadFromFingerprintUri(savedInstanceState, dataUri);
- } else if (ACTION_IMPORT_KEY.equals(action)) {
+ // delegate action to ACTION_IMPORT_KEY_FROM_KEYSERVER
+ String fingerprint = getFingerprintFromUri(dataUri);
+ action = ACTION_IMPORT_KEY_FROM_KEYSERVER;
+ extras.putString(EXTRA_FINGERPRINT, fingerprint);
+ }
+
+ Bundle serverBundle = null;
+ boolean serverOnly = false;
+ if (ACTION_IMPORT_KEY.equals(action)) {
/* Keychain's own Actions */
// display file fragment
@@ -154,7 +159,7 @@ public class ImportKeysActivity extends ActionBarActivity {
// action: directly load data
startListFragment(savedInstanceState, null, dataUri, null);
} else if (extras.containsKey(EXTRA_KEY_BYTES)) {
- byte[] importData = intent.getByteArrayExtra(EXTRA_KEY_BYTES);
+ byte[] importData = extras.getByteArray(EXTRA_KEY_BYTES);
// action: directly load data
startListFragment(savedInstanceState, importData, null, null);
@@ -173,7 +178,7 @@ public class ImportKeysActivity extends ActionBarActivity {
if (extras.containsKey(EXTRA_QUERY)) {
query = extras.getString(EXTRA_QUERY);
} else if (extras.containsKey(EXTRA_KEY_ID)) {
- long keyId = intent.getLongExtra(EXTRA_KEY_ID, 0);
+ long keyId = extras.getLong(EXTRA_KEY_ID, 0);
if (keyId != 0) {
query = PgpKeyHelper.convertKeyIdToHex(keyId);
}
@@ -197,7 +202,7 @@ public class ImportKeysActivity extends ActionBarActivity {
* if the right key has been downloaded
*/
- String fingerprint = intent.getStringExtra(EXTRA_FINGERPRINT);
+ String fingerprint = extras.getString(EXTRA_FINGERPRINT);
if (isFingerprintValid(fingerprint)) {
String query = "0x" + fingerprint;
@@ -325,18 +330,23 @@ public class ImportKeysActivity extends ActionBarActivity {
return OtherHelper.pxToDp(this, params.height);
}
- public void loadFromFingerprintUri(Bundle savedInstanceState, Uri dataUri) {
+ private String getFingerprintFromUri(Uri dataUri) {
String fingerprint = dataUri.toString().split(":")[1].toLowerCase(Locale.ENGLISH);
-
Log.d(Constants.TAG, "fingerprint: " + fingerprint);
+ return fingerprint;
+ }
- final String query = "0x" + fingerprint;
+ public void loadFromFingerprintUri(Uri dataUri) {
+ String query = "0x" + getFingerprintFromUri(dataUri);
+ // setCurrentItem does not work directly after onResume (from qr code scanner)
+ // see http://stackoverflow.com/q/19316729
+ // so, reset adapter completely!
+ if (mViewPager.getAdapter() != null)
+ mViewPager.setAdapter(null);
+ mViewPager.setAdapter(mTabsAdapter);
mViewPager.setCurrentItem(TAB_KEYSERVER);
- // update layout after operations
- mSlidingTabLayout.setViewPager(mViewPager);
-
ImportKeysServerFragment f = (ImportKeysServerFragment)
getActiveFragment(mViewPager, TAB_KEYSERVER);
@@ -344,7 +354,10 @@ public class ImportKeysActivity extends ActionBarActivity {
String keyserver = Preferences.getPreferences(ImportKeysActivity.this)
.getKeyServers()[0];
- f.searchCallback(query, keyserver);
+ // set fields of ImportKeysServerFragment
+ f.setQueryAndKeyserver(query, keyserver);
+ // search directly
+ loadCallback(new ImportKeysListFragment.KeyserverLoaderState(query, keyserver));
}
// http://stackoverflow.com/a/9293207
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysFileFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysFileFragment.java
index 60e5324c5..ce885c419 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysFileFragment.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysFileFragment.java
@@ -81,7 +81,7 @@ public class ImportKeysFileFragment extends Fragment {
if (clipboardText != null) {
sendText = clipboardText.toString();
if (sendText.toLowerCase(Locale.ENGLISH).startsWith(Constants.FINGERPRINT_SCHEME)) {
- mImportActivity.loadFromFingerprintUri(null, Uri.parse(sendText));
+ mImportActivity.loadFromFingerprintUri(Uri.parse(sendText));
return;
}
}
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysQrCodeFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysQrCodeFragment.java
index 5766fc189..5f54daa3c 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysQrCodeFragment.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysQrCodeFragment.java
@@ -132,7 +132,7 @@ public class ImportKeysQrCodeFragment extends Fragment {
}
public void importFingerprint(Uri dataUri) {
- mImportActivity.loadFromFingerprintUri(null, dataUri);
+ mImportActivity.loadFromFingerprintUri(dataUri);
}
}
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysServerFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysServerFragment.java
index ff694cb4f..d339bc132 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysServerFragment.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysServerFragment.java
@@ -174,11 +174,10 @@ public class ImportKeysServerFragment extends Fragment {
mImportActivity.loadCallback(new ImportKeysListFragment.KeyserverLoaderState(query, keyserver));
}
- public void searchCallback(String query, String keyserver) {
+ public void setQueryAndKeyserver(String query, String keyserver) {
mQueryEditText.setText(query, TextView.BufferType.EDITABLE);
int keyServerPos = mServerAdapter.getPosition(keyserver);
mServerSpinner.setSelection(keyServerPos);
- search(query, keyserver);
}
}