diff options
author | Dominik Schürmann <dominik@dominikschuermann.de> | 2014-10-05 10:59:52 +0200 |
---|---|---|
committer | Dominik Schürmann <dominik@dominikschuermann.de> | 2014-10-05 10:59:52 +0200 |
commit | 276867120681399b86057fbbff9ba02c8d1c57fe (patch) | |
tree | cb95b6a5cc507c06494ae2c0b730aec2fb5aed05 /OpenKeychain/src | |
parent | 0b9308753d7339251f9051316b00f6f0c9b0efbc (diff) | |
download | open-keychain-276867120681399b86057fbbff9ba02c8d1c57fe.tar.gz open-keychain-276867120681399b86057fbbff9ba02c8d1c57fe.tar.bz2 open-keychain-276867120681399b86057fbbff9ba02c8d1c57fe.zip |
UI stuff
Diffstat (limited to 'OpenKeychain/src')
14 files changed, 59 insertions, 81 deletions
diff --git a/OpenKeychain/src/main/AndroidManifest.xml b/OpenKeychain/src/main/AndroidManifest.xml index 959e1cf08..058b0a447 100644 --- a/OpenKeychain/src/main/AndroidManifest.xml +++ b/OpenKeychain/src/main/AndroidManifest.xml @@ -80,7 +80,7 @@ <activity android:name=".ui.KeyListActivity" android:configChanges="orientation|screenSize|keyboardHidden|keyboard" - android:label="@string/app_name" + android:label="@string/nav_keys" android:launchMode="singleTop"> <intent-filter> <action android:name="android.intent.action.MAIN" /> diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/AddKeysActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/AddKeysActivity.java index fd013739e..427fc9315 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/AddKeysActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/AddKeysActivity.java @@ -73,7 +73,6 @@ public class AddKeysActivity extends ActionBarActivity implements ImageView mActionSafeSlingerIcon; View mActionQrCode; View mActionNfc; - View mActionSearchCloud; ProviderHelper mProviderHelper; @@ -103,7 +102,6 @@ public class AddKeysActivity extends ActionBarActivity implements PorterDuff.Mode.SRC_IN); mActionQrCode = findViewById(R.id.add_keys_qr_code); mActionNfc = findViewById(R.id.add_keys_nfc); - mActionSearchCloud = findViewById(R.id.add_keys_search_cloud); mSafeSlingerKeySpinner.setOnKeyChangedListener(new KeySpinner.OnKeyChangedListener() { @Override @@ -135,14 +133,6 @@ public class AddKeysActivity extends ActionBarActivity implements startActivityForResult(intent, REQUEST_CODE_RESULT); } }); - - mActionSearchCloud.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - searchCloud(); - } - }); - } private void startExchange() { @@ -171,12 +161,6 @@ public class AddKeysActivity extends ActionBarActivity implements new IntentIntegrator(this).initiateScan(); } - private void searchCloud() { - finish(); - Intent importIntent = new Intent(this, ImportKeysActivity.class); - startActivity(importIntent); - } - @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { 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 002f85e5d..f0bd2c76c 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java @@ -150,12 +150,13 @@ public class ImportKeysActivity extends ActionBarActivity { } Bundle serverBundle = null; - int showTabOnly = ALL_TABS; + int showTabOnly = TAB_CLOUD; if (ACTION_IMPORT_KEY.equals(action)) { /* Keychain's own Actions */ // display file fragment - mViewPager.setCurrentItem(TAB_FILE); + showTabOnly = TAB_FILE; + mSwitchToTab = TAB_FILE; if (dataUri != null) { // action: directly load data @@ -229,6 +230,7 @@ public class ImportKeysActivity extends ActionBarActivity { } } else if (ACTION_IMPORT_KEY_FROM_FILE.equals(action)) { // NOTE: this only displays the appropriate fragment, no actions are taken + showTabOnly = TAB_FILE; mSwitchToTab = TAB_FILE; // no immediate actions! @@ -243,14 +245,14 @@ public class ImportKeysActivity extends ActionBarActivity { startListFragment(savedInstanceState, null, null, null); } else if (ACTION_IMPORT_KEY_FROM_QR_CODE.equals(action)) { // also exposed in AndroidManifest - + showTabOnly = ALL_TABS; // NOTE: this only displays the appropriate fragment, no actions are taken mSwitchToTab = TAB_QR_CODE; // no immediate actions! startListFragment(savedInstanceState, null, null, null); } else if (ACTION_IMPORT_KEY_FROM_NFC.equals(action)) { - + showTabOnly = ALL_TABS; // NOTE: this only displays the appropriate fragment, no actions are taken mSwitchToTab = TAB_QR_CODE; @@ -334,32 +336,36 @@ public class ImportKeysActivity extends ActionBarActivity { getSupportFragmentManager().executePendingTransactions(); } - private String getFingerprintFromUri(Uri dataUri) { + public static String getFingerprintFromUri(Uri dataUri) { String fingerprint = dataUri.toString().split(":")[1].toLowerCase(Locale.ENGLISH); Log.d(Constants.TAG, "fingerprint: " + fingerprint); return fingerprint; } - public void loadFromFingerprintUri(Uri dataUri) { - String query = "0x" + getFingerprintFromUri(dataUri); + public void loadFromFingerprint(String fingerprint) { +// String fingerprint = "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_CLOUD); - - ImportKeysCloudFragment f = (ImportKeysCloudFragment) - getActiveFragment(mViewPager, TAB_CLOUD); - - // search config - Preferences prefs = Preferences.getPreferences(ImportKeysActivity.this); - Preferences.CloudSearchPrefs cloudPrefs = new Preferences.CloudSearchPrefs(true, true, prefs.getPreferredKeyserver()); - - // search directly - loadCallback(new ImportKeysListFragment.CloudLoaderState(query, cloudPrefs)); +// if (mViewPager.getAdapter() != null) +// mViewPager.setAdapter(null); +// mViewPager.setAdapter(mTabsAdapter); +// mViewPager.setCurrentItem(TAB_CLOUD); + +// ImportKeysCloudFragment f = (ImportKeysCloudFragment) +// getActiveFragment(mViewPager, TAB_CLOUD); + + Intent searchIntent = new Intent(this, ImportKeysActivity.class); + searchIntent.putExtra(ImportKeysActivity.EXTRA_FINGERPRINT, fingerprint); + startActivity(searchIntent); + +// // search config +// Preferences prefs = Preferences.getPreferences(ImportKeysActivity.this); +// Preferences.CloudSearchPrefs cloudPrefs = new Preferences.CloudSearchPrefs(true, true, prefs.getPreferredKeyserver()); +// +// // search directly +// loadCallback(new ImportKeysListFragment.CloudLoaderState(query, cloudPrefs)); } // 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 e5bad16ce..538fa16c7 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysFileFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysFileFragment.java @@ -31,8 +31,6 @@ import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.compatibility.ClipboardReflection; import org.sufficientlysecure.keychain.util.FileHelper; -import java.util.Locale; - public class ImportKeysFileFragment extends Fragment { private ImportKeysActivity mImportActivity; private View mBrowse; @@ -80,12 +78,8 @@ public class ImportKeysFileFragment extends Fragment { String sendText = ""; if (clipboardText != null) { sendText = clipboardText.toString(); - if (sendText.toLowerCase(Locale.ENGLISH).startsWith(Constants.FINGERPRINT_SCHEME)) { - mImportActivity.loadFromFingerprintUri(Uri.parse(sendText)); - return; - } + mImportActivity.loadCallback(new ImportKeysListFragment.BytesLoaderState(sendText.getBytes(), null)); } - mImportActivity.loadCallback(new ImportKeysListFragment.BytesLoaderState(sendText.getBytes(), null)); } }); 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 a52737979..fb4bbfac4 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(dataUri); + mImportActivity.loadFromFingerprint(ImportKeysActivity.getFingerprintFromUri(dataUri)); } } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListActivity.java index ce2aa8368..4419a8a64 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListActivity.java @@ -87,6 +87,10 @@ public class KeyListActivity extends DrawerActivity { addKeys(); return true; + case R.id.menu_key_list_search_cloud: + searchCloud(); + return true; + case R.id.menu_key_list_create: createKey(); return true; @@ -144,6 +148,12 @@ public class KeyListActivity extends DrawerActivity { startActivityForResult(intent, 0); } + private void searchCloud() { + Intent importIntent = new Intent(this, ImportKeysActivity.class); + importIntent.putExtra(ImportKeysActivity.EXTRA_QUERY, (String) null); // hack to show only cloud tab + startActivity(importIntent); + } + private void createKey() { Intent intent = new Intent(this, CreateKeyActivity.class); startActivityForResult(intent, 0); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java index 9c261cc49..8c4278835 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java @@ -470,6 +470,11 @@ public class KeyListFragment extends LoaderFragment MenuItemCompat.setOnActionExpandListener(searchItem, new MenuItemCompat.OnActionExpandListener() { @Override public boolean onMenuItemActionExpand(MenuItem item) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { + hideMenu = true; + getActivity().invalidateOptionsMenu(); + } + // disable swipe-to-refresh // mSwipeRefreshLayout.setIsLocked(true); return true; @@ -479,6 +484,11 @@ public class KeyListFragment extends LoaderFragment public boolean onMenuItemActionCollapse(MenuItem item) { mQuery = null; getLoaderManager().restartLoader(0, null, KeyListFragment.this); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { + hideMenu = false; + getActivity().invalidateOptionsMenu(); + } // enable swipe-to-refresh // mSwipeRefreshLayout.setIsLocked(false); return true; diff --git a/OpenKeychain/src/main/res/drawable-hdpi/ic_action_search_cloud.png b/OpenKeychain/src/main/res/drawable-hdpi/ic_action_search_cloud.png Binary files differnew file mode 100644 index 000000000..ba7236da3 --- /dev/null +++ b/OpenKeychain/src/main/res/drawable-hdpi/ic_action_search_cloud.png diff --git a/OpenKeychain/src/main/res/drawable-mdpi/ic_action_search_cloud.png b/OpenKeychain/src/main/res/drawable-mdpi/ic_action_search_cloud.png Binary files differnew file mode 100644 index 000000000..e1067f73c --- /dev/null +++ b/OpenKeychain/src/main/res/drawable-mdpi/ic_action_search_cloud.png diff --git a/OpenKeychain/src/main/res/drawable-xhdpi/ic_action_search_cloud.png b/OpenKeychain/src/main/res/drawable-xhdpi/ic_action_search_cloud.png Binary files differnew file mode 100644 index 000000000..b81772f20 --- /dev/null +++ b/OpenKeychain/src/main/res/drawable-xhdpi/ic_action_search_cloud.png diff --git a/OpenKeychain/src/main/res/drawable-xxhdpi/ic_action_search_cloud.png b/OpenKeychain/src/main/res/drawable-xxhdpi/ic_action_search_cloud.png Binary files differnew file mode 100644 index 000000000..7c8b36bc0 --- /dev/null +++ b/OpenKeychain/src/main/res/drawable-xxhdpi/ic_action_search_cloud.png diff --git a/OpenKeychain/src/main/res/layout/add_keys_activity.xml b/OpenKeychain/src/main/res/layout/add_keys_activity.xml index eee561390..a5f5dd71a 100644 --- a/OpenKeychain/src/main/res/layout/add_keys_activity.xml +++ b/OpenKeychain/src/main/res/layout/add_keys_activity.xml @@ -135,34 +135,6 @@ android:background="?android:attr/listDivider" android:layout_marginBottom="8dp" /> - <TextView - style="@style/SectionHeader" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_marginTop="32dp" - android:text="@string/add_keys_section_import" /> - - <TextView - android:id="@+id/add_keys_search_cloud" - android:paddingLeft="8dp" - android:paddingRight="8dp" - android:textAppearance="?android:attr/textAppearanceMedium" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:minHeight="?android:attr/listPreferredItemHeight" - android:clickable="true" - style="@style/SelectableItem" - android:text="@string/add_keys_cloud" - android:drawableRight="@drawable/ic_action_search" - android:drawablePadding="8dp" - android:gravity="center_vertical" /> - - <View - android:layout_width="match_parent" - android:layout_height="1dip" - android:background="?android:attr/listDivider" - android:layout_marginBottom="8dp" /> - </LinearLayout> </LinearLayout> </ScrollView>
\ No newline at end of file diff --git a/OpenKeychain/src/main/res/menu/key_list.xml b/OpenKeychain/src/main/res/menu/key_list.xml index 27d96d7d7..3e7d6fc9f 100644 --- a/OpenKeychain/src/main/res/menu/key_list.xml +++ b/OpenKeychain/src/main/res/menu/key_list.xml @@ -7,18 +7,23 @@ android:title="@string/menu_search" android:icon="@drawable/ic_action_search" app:actionViewClass="android.support.v7.widget.SearchView" - app:showAsAction="collapseActionView|ifRoom" /> + app:showAsAction="collapseActionView|always" /> + + <item + android:id="@+id/menu_key_list_search_cloud" + app:showAsAction="always|withText" + android:icon="@drawable/ic_action_search_cloud" + android:title="@string/menu_add_keys" /> <item android:id="@+id/menu_key_list_add" - app:showAsAction="ifRoom|withText" + app:showAsAction="always|withText" android:icon="@drawable/ic_action_new_account" android:title="@string/menu_add_keys" /> <item android:id="@+id/menu_key_list_export" - app:showAsAction="ifRoom|withText" - android:icon="@drawable/ic_action_import_export" + app:showAsAction="never" android:title="@string/menu_export_all_keys" /> <item diff --git a/OpenKeychain/src/main/res/values/strings.xml b/OpenKeychain/src/main/res/values/strings.xml index eaac43f7e..3454988c0 100644 --- a/OpenKeychain/src/main/res/values/strings.xml +++ b/OpenKeychain/src/main/res/values/strings.xml @@ -277,13 +277,10 @@ <!-- Add keys --> <string name="add_keys_section_secure_exchange">"Secure Exchange"</string> <string name="add_keys_section_secure_add">"Secure Add"</string> - <string name="add_keys_section_import">"Import (untrusted)"</string> <string name="add_keys_my_key">"My key:"</string> <string name="add_keys_start_exchange">"Start exchange"</string> <string name="add_keys_qr_code">"Scan QR Code"</string> <string name="add_keys_nfc">"Receive via NFC"</string> - <string name="add_keys_cloud">"Search cloud"</string> - <!-- progress dialogs, usually ending in '…' --> <string name="progress_done">"Done."</string> |