From 3cad8b6248d136f21ef4bc4697feada299c8a58e Mon Sep 17 00:00:00 2001 From: uberspot Date: Tue, 11 Mar 2014 00:42:03 +0200 Subject: Appropriate save Icon in EditKeyActivity --- .../keychain/helper/ActionBarHelper.java | 60 ++++++++++++++++++++++ 1 file changed, 60 insertions(+) (limited to 'OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ActionBarHelper.java') diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ActionBarHelper.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ActionBarHelper.java index b55075e6c..6aa8e7d74 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ActionBarHelper.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ActionBarHelper.java @@ -113,4 +113,64 @@ public class ActionBarHelper { actionBar.setCustomView(customActionBarView); } + /** + * Sets custom view on ActionBar for Save activities + * + * @param actionBar + * @param saveText + * @param saveOnClickListener + */ + public static void setSaveView(ActionBar actionBar, int saveText, + OnClickListener saveOnClickListener) { + // Inflate a "Save" custom action bar view to serve as the "Up" affordance. + final LayoutInflater inflater = (LayoutInflater) actionBar.getThemedContext() + .getSystemService(Activity.LAYOUT_INFLATER_SERVICE); + final View customActionBarView = inflater + .inflate(R.layout.actionbar_custom_view_save, null); + + ((TextView) customActionBarView.findViewById(R.id.actionbar_save_text)).setText(saveText); + customActionBarView.findViewById(R.id.actionbar_save).setOnClickListener( + saveOnClickListener); + + // Show the custom action bar view and hide the normal Home icon and title. + actionBar.setDisplayShowTitleEnabled(false); + actionBar.setDisplayShowHomeEnabled(false); + actionBar.setDisplayShowCustomEnabled(true); + actionBar.setCustomView(customActionBarView); + } + + /** + * Sets custom view on ActionBar for Save/Cancel activities + * + * @param actionBar + * @param saveText + * @param saveOnClickListener + * @param cancelText + * @param cancelOnClickListener + */ + public static void setSaveCancelView(ActionBar actionBar, int saveText, + OnClickListener saveOnClickListener, int cancelText, + OnClickListener cancelOnClickListener) { + + // Inflate a "Done"/"Cancel" custom action bar view + final LayoutInflater inflater = (LayoutInflater) actionBar.getThemedContext() + .getSystemService(Activity.LAYOUT_INFLATER_SERVICE); + final View customActionBarView = inflater.inflate( + R.layout.actionbar_custom_view_save_cancel, null); + + ((TextView) customActionBarView.findViewById(R.id.actionbar_save_text)).setText(saveText); + customActionBarView.findViewById(R.id.actionbar_save).setOnClickListener( + saveOnClickListener); + ((TextView) customActionBarView.findViewById(R.id.actionbar_cancel_text)) + .setText(cancelText); + customActionBarView.findViewById(R.id.actionbar_cancel).setOnClickListener( + cancelOnClickListener); + + // Show the custom action bar view and hide the normal Home icon and title. + actionBar.setDisplayShowTitleEnabled(false); + actionBar.setDisplayShowHomeEnabled(false); + actionBar.setDisplayShowCustomEnabled(true); + actionBar.setCustomView(customActionBarView, new ActionBar.LayoutParams( + ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); + } } -- cgit v1.2.3 From d93731701255e082b02bf80c5c029db8838b15b0 Mon Sep 17 00:00:00 2001 From: uberspot Date: Tue, 11 Mar 2014 01:50:17 +0200 Subject: Remove duplicate code from ActionBarHelper. You can now set the drawables via the method calls --- .../keychain/helper/ActionBarHelper.java | 107 ++++++--------------- 1 file changed, 27 insertions(+), 80 deletions(-) (limited to 'OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ActionBarHelper.java') diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ActionBarHelper.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ActionBarHelper.java index 6aa8e7d74..2276e0f8a 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ActionBarHelper.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ActionBarHelper.java @@ -22,6 +22,7 @@ import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.util.Log; import android.app.Activity; +import android.graphics.drawable.Drawable; import android.support.v7.app.ActionBar; import android.support.v7.app.ActionBarActivity; import android.view.LayoutInflater; @@ -56,28 +57,33 @@ public class ActionBarHelper { * Sets custom view on ActionBar for Done/Cancel activities * * @param actionBar - * @param doneText - * @param doneOnClickListener - * @param cancelText - * @param cancelOnClickListener + * @param firstText + * @param firstDrawableId + * @param firstOnClickListener + * @param secondText + * @param secondDrawableId + * @param secondOnClickListener */ - public static void setDoneCancelView(ActionBar actionBar, int doneText, - OnClickListener doneOnClickListener, int cancelText, - OnClickListener cancelOnClickListener) { + public static void setTwoButtonView(ActionBar actionBar, int firstText, int firstDrawableId, + OnClickListener firstOnClickListener, int secondText, int secondDrawableId, + OnClickListener secondOnClickListener) { - // Inflate a "Done"/"Cancel" custom action bar view + // Inflate the custom action bar view final LayoutInflater inflater = (LayoutInflater) actionBar.getThemedContext() .getSystemService(Activity.LAYOUT_INFLATER_SERVICE); final View customActionBarView = inflater.inflate( R.layout.actionbar_custom_view_done_cancel, null); - ((TextView) customActionBarView.findViewById(R.id.actionbar_done_text)).setText(doneText); + TextView firstTextView = ((TextView) customActionBarView.findViewById(R.id.actionbar_done_text)); + firstTextView.setText(firstText); + firstTextView.setCompoundDrawablesWithIntrinsicBounds(firstDrawableId, 0, 0, 0); customActionBarView.findViewById(R.id.actionbar_done).setOnClickListener( - doneOnClickListener); - ((TextView) customActionBarView.findViewById(R.id.actionbar_cancel_text)) - .setText(cancelText); + firstOnClickListener); + TextView secondTextView = ((TextView) customActionBarView.findViewById(R.id.actionbar_cancel_text)); + secondTextView.setText(secondText); + secondTextView.setCompoundDrawablesWithIntrinsicBounds(secondDrawableId, 0, 0, 0); customActionBarView.findViewById(R.id.actionbar_cancel).setOnClickListener( - cancelOnClickListener); + secondOnClickListener); // Show the custom action bar view and hide the normal Home icon and title. actionBar.setDisplayShowTitleEnabled(false); @@ -91,20 +97,22 @@ public class ActionBarHelper { * Sets custom view on ActionBar for Done activities * * @param actionBar - * @param doneText - * @param doneOnClickListener + * @param firstText + * @param firstOnClickListener */ - public static void setDoneView(ActionBar actionBar, int doneText, - OnClickListener doneOnClickListener) { + public static void setOneButtonView(ActionBar actionBar, int firstText, int firstDrawableId, + OnClickListener firstOnClickListener) { // Inflate a "Done" custom action bar view to serve as the "Up" affordance. final LayoutInflater inflater = (LayoutInflater) actionBar.getThemedContext() .getSystemService(Activity.LAYOUT_INFLATER_SERVICE); final View customActionBarView = inflater .inflate(R.layout.actionbar_custom_view_done, null); - ((TextView) customActionBarView.findViewById(R.id.actionbar_done_text)).setText(doneText); + TextView firstTextView = ((TextView) customActionBarView.findViewById(R.id.actionbar_done_text)); + firstTextView.setText(firstText); + firstTextView.setCompoundDrawablesWithIntrinsicBounds(firstDrawableId, 0, 0, 0); customActionBarView.findViewById(R.id.actionbar_done).setOnClickListener( - doneOnClickListener); + firstOnClickListener); // Show the custom action bar view and hide the normal Home icon and title. actionBar.setDisplayShowTitleEnabled(false); @@ -112,65 +120,4 @@ public class ActionBarHelper { actionBar.setDisplayShowCustomEnabled(true); actionBar.setCustomView(customActionBarView); } - - /** - * Sets custom view on ActionBar for Save activities - * - * @param actionBar - * @param saveText - * @param saveOnClickListener - */ - public static void setSaveView(ActionBar actionBar, int saveText, - OnClickListener saveOnClickListener) { - // Inflate a "Save" custom action bar view to serve as the "Up" affordance. - final LayoutInflater inflater = (LayoutInflater) actionBar.getThemedContext() - .getSystemService(Activity.LAYOUT_INFLATER_SERVICE); - final View customActionBarView = inflater - .inflate(R.layout.actionbar_custom_view_save, null); - - ((TextView) customActionBarView.findViewById(R.id.actionbar_save_text)).setText(saveText); - customActionBarView.findViewById(R.id.actionbar_save).setOnClickListener( - saveOnClickListener); - - // Show the custom action bar view and hide the normal Home icon and title. - actionBar.setDisplayShowTitleEnabled(false); - actionBar.setDisplayShowHomeEnabled(false); - actionBar.setDisplayShowCustomEnabled(true); - actionBar.setCustomView(customActionBarView); - } - - /** - * Sets custom view on ActionBar for Save/Cancel activities - * - * @param actionBar - * @param saveText - * @param saveOnClickListener - * @param cancelText - * @param cancelOnClickListener - */ - public static void setSaveCancelView(ActionBar actionBar, int saveText, - OnClickListener saveOnClickListener, int cancelText, - OnClickListener cancelOnClickListener) { - - // Inflate a "Done"/"Cancel" custom action bar view - final LayoutInflater inflater = (LayoutInflater) actionBar.getThemedContext() - .getSystemService(Activity.LAYOUT_INFLATER_SERVICE); - final View customActionBarView = inflater.inflate( - R.layout.actionbar_custom_view_save_cancel, null); - - ((TextView) customActionBarView.findViewById(R.id.actionbar_save_text)).setText(saveText); - customActionBarView.findViewById(R.id.actionbar_save).setOnClickListener( - saveOnClickListener); - ((TextView) customActionBarView.findViewById(R.id.actionbar_cancel_text)) - .setText(cancelText); - customActionBarView.findViewById(R.id.actionbar_cancel).setOnClickListener( - cancelOnClickListener); - - // Show the custom action bar view and hide the normal Home icon and title. - actionBar.setDisplayShowTitleEnabled(false); - actionBar.setDisplayShowHomeEnabled(false); - actionBar.setDisplayShowCustomEnabled(true); - actionBar.setCustomView(customActionBarView, new ActionBar.LayoutParams( - ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); - } } -- cgit v1.2.3 From d586ad288d2a6db803c12c8ae4a600630004f7bc Mon Sep 17 00:00:00 2001 From: uberspot Date: Tue, 11 Mar 2014 23:42:45 +0200 Subject: fix plenty of lint warnings, make some for loops into foreach, remove unused imports and throw exceptions --- .../java/org/sufficientlysecure/keychain/helper/ActionBarHelper.java | 1 - 1 file changed, 1 deletion(-) (limited to 'OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ActionBarHelper.java') diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ActionBarHelper.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ActionBarHelper.java index 2276e0f8a..24e8ff4c7 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ActionBarHelper.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ActionBarHelper.java @@ -22,7 +22,6 @@ import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.util.Log; import android.app.Activity; -import android.graphics.drawable.Drawable; import android.support.v7.app.ActionBar; import android.support.v7.app.ActionBarActivity; import android.view.LayoutInflater; -- cgit v1.2.3 From f26ba217e567aa35a6bcee2665c12c612440cbda Mon Sep 17 00:00:00 2001 From: uberspot Date: Thu, 13 Mar 2014 19:59:27 +0200 Subject: Fix code style in /helper --- .../keychain/helper/ActionBarHelper.java | 23 +++++++++++----------- 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ActionBarHelper.java') diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ActionBarHelper.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ActionBarHelper.java index 24e8ff4c7..91e50637e 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ActionBarHelper.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ActionBarHelper.java @@ -17,24 +17,23 @@ package org.sufficientlysecure.keychain.helper; -import org.sufficientlysecure.keychain.Constants; -import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.util.Log; - import android.app.Activity; import android.support.v7.app.ActionBar; import android.support.v7.app.ActionBarActivity; import android.view.LayoutInflater; import android.view.View; -import android.view.ViewGroup; import android.view.View.OnClickListener; +import android.view.ViewGroup; import android.widget.TextView; +import org.sufficientlysecure.keychain.Constants; +import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.util.Log; public class ActionBarHelper { /** * Set actionbar without home button if called from another app - * + * * @param activity */ public static void setBackButton(ActionBarActivity activity) { @@ -54,7 +53,7 @@ public class ActionBarHelper { /** * Sets custom view on ActionBar for Done/Cancel activities - * + * * @param actionBar * @param firstText * @param firstDrawableId @@ -63,9 +62,9 @@ public class ActionBarHelper { * @param secondDrawableId * @param secondOnClickListener */ - public static void setTwoButtonView(ActionBar actionBar, int firstText, int firstDrawableId, - OnClickListener firstOnClickListener, int secondText, int secondDrawableId, - OnClickListener secondOnClickListener) { + public static void setTwoButtonView(ActionBar actionBar, + int firstText, int firstDrawableId, OnClickListener firstOnClickListener, + int secondText, int secondDrawableId, OnClickListener secondOnClickListener) { // Inflate the custom action bar view final LayoutInflater inflater = (LayoutInflater) actionBar.getThemedContext() @@ -94,13 +93,13 @@ public class ActionBarHelper { /** * Sets custom view on ActionBar for Done activities - * + * * @param actionBar * @param firstText * @param firstOnClickListener */ public static void setOneButtonView(ActionBar actionBar, int firstText, int firstDrawableId, - OnClickListener firstOnClickListener) { + OnClickListener firstOnClickListener) { // Inflate a "Done" custom action bar view to serve as the "Up" affordance. final LayoutInflater inflater = (LayoutInflater) actionBar.getThemedContext() .getSystemService(Activity.LAYOUT_INFLATER_SERVICE); -- cgit v1.2.3 From cea62b1857a9b5dbade8dcff6009f72e309b7469 Mon Sep 17 00:00:00 2001 From: uberspot Date: Sun, 16 Mar 2014 23:35:14 +0200 Subject: Lock drawer as open in tablets --- .../java/org/sufficientlysecure/keychain/helper/ActionBarHelper.java | 1 - 1 file changed, 1 deletion(-) (limited to 'OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ActionBarHelper.java') diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ActionBarHelper.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ActionBarHelper.java index 91e50637e..a26df556d 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ActionBarHelper.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ActionBarHelper.java @@ -37,7 +37,6 @@ public class ActionBarHelper { * @param activity */ public static void setBackButton(ActionBarActivity activity) { - // set actionbar without home button if called from another app final ActionBar actionBar = activity.getSupportActionBar(); Log.d(Constants.TAG, "calling package (only set when using startActivityForResult)=" + activity.getCallingPackage()); -- cgit v1.2.3