From 1516ebf26afdd10cab81da945251015af2aa819d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Wed, 14 Jan 2015 20:18:03 +0100 Subject: [PATCH] Toolbar for settings --- Graphics/get-material-icons.sh | 3 +- OpenKeychain/src/main/AndroidManifest.xml | 4 +- .../keychain/ui/DrawerActivity.java | 3 +- .../keychain/ui/ImportKeysCloudFragment.java | 2 +- ...cesActivity.java => SettingsActivity.java} | 48 ++++++++++++++---- ...ty.java => SettingsKeyServerActivity.java} | 2 +- .../ic_arrow_back_white_24dp.png | Bin 0 -> 287 bytes .../ic_arrow_back_white_24dp.png | Bin 0 -> 240 bytes .../ic_arrow_back_white_24dp.png | Bin 0 -> 336 bytes .../ic_arrow_back_white_24dp.png | Bin 0 -> 410 bytes .../ic_arrow_back_white_24dp.png | Bin 0 -> 530 bytes .../layout/preference_toolbar_activity.xml | 10 ++++ OpenKeychain/src/main/res/values/strings.xml | 2 +- .../src/main/res/xml/preference_headers.xml | 4 +- 14 files changed, 58 insertions(+), 20 deletions(-) rename OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/{PreferencesActivity.java => SettingsActivity.java} (92%) rename OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/{PreferencesKeyServerActivity.java => SettingsKeyServerActivity.java} (98%) create mode 100644 OpenKeychain/src/main/res/drawable-hdpi/ic_arrow_back_white_24dp.png create mode 100644 OpenKeychain/src/main/res/drawable-mdpi/ic_arrow_back_white_24dp.png create mode 100644 OpenKeychain/src/main/res/drawable-xhdpi/ic_arrow_back_white_24dp.png create mode 100644 OpenKeychain/src/main/res/drawable-xxhdpi/ic_arrow_back_white_24dp.png create mode 100644 OpenKeychain/src/main/res/drawable-xxxhdpi/ic_arrow_back_white_24dp.png create mode 100644 OpenKeychain/src/main/res/layout/preference_toolbar_activity.xml diff --git a/Graphics/get-material-icons.sh b/Graphics/get-material-icons.sh index 2fcad6c1d..8e905ed69 100755 --- a/Graphics/get-material-icons.sh +++ b/Graphics/get-material-icons.sh @@ -1,2 +1,3 @@ cd ./android-icon-copier/ -python copy OpenKeychain action white search 24 \ No newline at end of file +python copy OpenKeychain action white search 24 +python copy OpenKeychain navigation white arrow_back 24 \ No newline at end of file diff --git a/OpenKeychain/src/main/AndroidManifest.xml b/OpenKeychain/src/main/AndroidManifest.xml index ab6c4334b..536b66319 100644 --- a/OpenKeychain/src/main/AndroidManifest.xml +++ b/OpenKeychain/src/main/AndroidManifest.xml @@ -418,7 +418,7 @@ android:label="@string/title_advanced_key_info"> @@ -431,7 +431,7 @@ diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DrawerActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DrawerActivity.java index b3521ebcc..712516b8d 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DrawerActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DrawerActivity.java @@ -27,7 +27,6 @@ import android.support.v4.app.ActionBarDrawerToggle; import android.support.v4.view.GravityCompat; import android.support.v4.widget.DrawerLayout; import android.support.v4.widget.FixedDrawerLayout; -import android.support.v7.app.ActionBarActivity; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; @@ -179,7 +178,7 @@ public abstract class DrawerActivity extends BaseActivity { switch (item.getItemId()) { case MENU_ID_PREFERENCE: { - Intent intent = new Intent(this, PreferencesActivity.class); + Intent intent = new Intent(this, SettingsActivity.class); startActivity(intent); return true; } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysCloudFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysCloudFragment.java index 03aba344a..89826b8e9 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysCloudFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysCloudFragment.java @@ -110,7 +110,7 @@ public class ImportKeysCloudFragment extends Fragment { mConfigButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { - Intent i = new Intent(mImportActivity, PreferencesActivity.class); + Intent i = new Intent(mImportActivity, SettingsActivity.class); // GRR, for some reason I can’t set the Action or I get an incomprehensible // exception about “modern two-pane layouts” // i.setAction(PreferencesActivity.ACTION_PREFS_CLOUD); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/PreferencesActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/SettingsActivity.java similarity index 92% rename from OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/PreferencesActivity.java rename to OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/SettingsActivity.java index 1769caa47..8ef6ec187 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/PreferencesActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/SettingsActivity.java @@ -17,7 +17,6 @@ package org.sufficientlysecure.keychain.ui; -import android.annotation.SuppressLint; import android.content.Context; import android.content.Intent; import android.os.Bundle; @@ -26,6 +25,10 @@ import android.preference.Preference; import android.preference.PreferenceActivity; import android.preference.PreferenceFragment; import android.preference.PreferenceScreen; +import android.support.v7.widget.Toolbar; +import android.view.View; +import android.view.ViewGroup; +import android.widget.LinearLayout; import org.spongycastle.bcpg.CompressionAlgorithmTags; import org.spongycastle.bcpg.HashAlgorithmTags; @@ -37,8 +40,7 @@ import org.sufficientlysecure.keychain.util.Preferences; import java.util.List; -@SuppressLint("NewApi") -public class PreferencesActivity extends PreferenceActivity { +public class SettingsActivity extends PreferenceActivity { public static final String ACTION_PREFS_CLOUD = "org.sufficientlysecure.keychain.ui.PREFS_CLOUD"; public static final String ACTION_PREFS_ADV = "org.sufficientlysecure.keychain.ui.PREFS_ADV"; @@ -53,6 +55,8 @@ public class PreferencesActivity extends PreferenceActivity { sPreferences = Preferences.getPreferences(this); super.onCreate(savedInstanceState); + setupToolbar(); + String action = getIntent().getAction(); if (action != null && action.equals(ACTION_PREFS_CLOUD)) { @@ -63,9 +67,9 @@ public class PreferencesActivity extends PreferenceActivity { mKeyServerPreference .setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { public boolean onPreferenceClick(Preference preference) { - Intent intent = new Intent(PreferencesActivity.this, - PreferencesKeyServerActivity.class); - intent.putExtra(PreferencesKeyServerActivity.EXTRA_KEY_SERVERS, + Intent intent = new Intent(SettingsActivity.this, + SettingsKeyServerActivity.class); + intent.putExtra(SettingsKeyServerActivity.EXTRA_KEY_SERVERS, sPreferences.getKeyServers()); startActivityForResult(intent, REQUEST_CODE_KEYSERVER_PREF); return false; @@ -132,6 +136,30 @@ public class PreferencesActivity extends PreferenceActivity { } } + /** + * Hack to get Toolbar in PreferenceActivity. See http://stackoverflow.com/a/26614696 + */ + private void setupToolbar() { + ViewGroup root = (ViewGroup) findViewById(android.R.id.content); + LinearLayout content = (LinearLayout) root.getChildAt(0); + LinearLayout toolbarContainer = (LinearLayout) View.inflate(this, R.layout.preference_toolbar_activity, null); + + root.removeAllViews(); + toolbarContainer.addView(content); + root.addView(toolbarContainer); + + Toolbar toolbar = (Toolbar) toolbarContainer.findViewById(R.id.toolbar); + toolbar.setTitle(R.string.title_preferences); + toolbar.setNavigationIcon(getResources().getDrawable(R.drawable.ic_arrow_back_white_24dp)); + toolbar.setNavigationOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + //What to do on back clicked + finish(); + } + }); + } + @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { @@ -140,7 +168,7 @@ public class PreferencesActivity extends PreferenceActivity { return; } String servers[] = data - .getStringArrayExtra(PreferencesKeyServerActivity.EXTRA_KEY_SERVERS); + .getStringArrayExtra(SettingsKeyServerActivity.EXTRA_KEY_SERVERS); sPreferences.setKeyServers(servers); mKeyServerPreference.setSummary(keyserverSummary(this)); break; @@ -181,8 +209,8 @@ public class PreferencesActivity extends PreferenceActivity { .setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { public boolean onPreferenceClick(Preference preference) { Intent intent = new Intent(getActivity(), - PreferencesKeyServerActivity.class); - intent.putExtra(PreferencesKeyServerActivity.EXTRA_KEY_SERVERS, + SettingsKeyServerActivity.class); + intent.putExtra(SettingsKeyServerActivity.EXTRA_KEY_SERVERS, sPreferences.getKeyServers()); startActivityForResult(intent, REQUEST_CODE_KEYSERVER_PREF); return false; @@ -204,7 +232,7 @@ public class PreferencesActivity extends PreferenceActivity { return; } String servers[] = data - .getStringArrayExtra(PreferencesKeyServerActivity.EXTRA_KEY_SERVERS); + .getStringArrayExtra(SettingsKeyServerActivity.EXTRA_KEY_SERVERS); sPreferences.setKeyServers(servers); mKeyServerPreference.setSummary(keyserverSummary(getActivity())); break; diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/PreferencesKeyServerActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/SettingsKeyServerActivity.java similarity index 98% rename from OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/PreferencesKeyServerActivity.java rename to OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/SettingsKeyServerActivity.java index 9e2e443af..365e8026c 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/PreferencesKeyServerActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/SettingsKeyServerActivity.java @@ -35,7 +35,7 @@ import org.sufficientlysecure.keychain.ui.widget.KeyServerEditor; import java.util.Vector; -public class PreferencesKeyServerActivity extends BaseActivity implements OnClickListener, +public class SettingsKeyServerActivity extends BaseActivity implements OnClickListener, EditorListener { public static final String EXTRA_KEY_SERVERS = "key_servers"; diff --git a/OpenKeychain/src/main/res/drawable-hdpi/ic_arrow_back_white_24dp.png b/OpenKeychain/src/main/res/drawable-hdpi/ic_arrow_back_white_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..5fa4948788afb7189dd55faae57aa7d0600921ee GIT binary patch literal 287 zcmeAS@N?(olHy`uVBq!ia0vp^Dj>|k0wldT1B8K;Lb6AYF9SoB8UsT^3j@P1pisjL z28L1t28LG&3=CE?7#PG0=Ijcz0ZK3>dAqwX{BQ3+vmeOgEbxddW?O=~G=WkL6 z;pyTSVsSe8$9V^-6bUOSsfGzGyuAN`;BS0)1h2qT#Ur;E0_D8c$a848Uk9?>ax@yJ z{6Dx}CX(61(#~Ng+l22WQ%mvv4FO#tcCM$7;J literal 0 HcmV?d00001 diff --git a/OpenKeychain/src/main/res/drawable-xhdpi/ic_arrow_back_white_24dp.png b/OpenKeychain/src/main/res/drawable-xhdpi/ic_arrow_back_white_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..addbfc886115c892c3e634d5589866d29f35210b GIT binary patch literal 336 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA0wn)(8}a}tg=CK)Uj~LMH3o);76yi2K%s^g z3=E|}g|8AA7_4S6Fo+k-*%fF5lweBoc6VX;-`;;_Kaj^+;1OBOz`!jG!i)^F=12eq zPk6dGhD02Gd)=0+*+HP~q5p}ydnQg$3(R4%j5tx~RCQg6QSi##{5pk}$PKmgo$g4^ zZn|+iTv_IUs^X@em>9by`luS6`%@DkgPvW!b zfjRbUGN0TVyzAr(PQ7Q$`+5>pwyY_k-Ol$zHn(Snn10uVwSBVhCZ2xJn*8KfoWT=$KPJwC abT&1XX2zgueSe^z7(8A5T-G@yGywnI(3)EF2VS{N990fib~ zFff!FFfhDIU|_JC!N4G1FlSew4N!t9$=lt9;eUJonf*W>XMsm#F#`j)FbFd;%$g&? zz`!Wv>EalYaqsP|i+oK6JggTIYrb)R@xQ9`Z`m*1uaaViZ{5A!x8(8G?Up@)5{VOy zu3NY=3r$(TqN*V^VSz?~uILp{0e4ZsiCr&RA2)b-@U^r&?b!2Fh%?Lb`Uy#;0yhVd zK3SJX5soH(ye>~7976i!T%Kh(mh|yGIdHKd#^SGnx}W}u-plMoPrfw7SpHT>KPQ)Q z+L4dBI(3)EF2VS{N990fib~ zFff!FFfhDIU|_JC!N4G1FlSew4N!t9$=lt9;eUJonf*W>XMsm#F#`j)FbFd;%$g&? zz`)q$>EaktaqI1^Xs;sk=09NZU(~$fJp;$t=gdu?Z#I0W(Nj>I&*^dUIpd^HkqujF_!JE1GkTnj=l3`l z&+TzOo?TY z$%Z{OTnfhX8BUxvf50TSkh`MuzjBR3?TNCbe<#Qm_HO5s-?WM4Sd!k<1Cf5}LJ{^R znJoA8Q-vCT2G4hTkhfYz;D&VcLzaKnk_;R-?v(brkh7j$D1==mk>##nuz+Lb32~pHc(G}U$4(xD0}RYCqT%Ih;k!#%1!{N2{02r9gQu&X J%Q~loCID`b$R+>) literal 0 HcmV?d00001 diff --git a/OpenKeychain/src/main/res/layout/preference_toolbar_activity.xml b/OpenKeychain/src/main/res/layout/preference_toolbar_activity.xml new file mode 100644 index 000000000..a328d15c6 --- /dev/null +++ b/OpenKeychain/src/main/res/layout/preference_toolbar_activity.xml @@ -0,0 +1,10 @@ + + + + + \ No newline at end of file diff --git a/OpenKeychain/src/main/res/values/strings.xml b/OpenKeychain/src/main/res/values/strings.xml index 7f38d40a1..5bc3c0601 100644 --- a/OpenKeychain/src/main/res/values/strings.xml +++ b/OpenKeychain/src/main/res/values/strings.xml @@ -17,7 +17,7 @@ "Unlock Key" "Add subkey" "Edit Key" - "Preferences" + "Settings" "Cloud Search Preferences" "Apps" "Keyserver Preference" diff --git a/OpenKeychain/src/main/res/xml/preference_headers.xml b/OpenKeychain/src/main/res/xml/preference_headers.xml index dd7f1c3e6..347394b06 100644 --- a/OpenKeychain/src/main/res/xml/preference_headers.xml +++ b/OpenKeychain/src/main/res/xml/preference_headers.xml @@ -1,8 +1,8 @@