From e9da61ad8504bfb554b06f6b72998bb93a56231b Mon Sep 17 00:00:00 2001 From: Wes Johnston Date: Wed, 26 Mar 2014 10:18:02 -0700 Subject: [PATCH] Bug 942270 - Fix gingerbread issues with quickshare. r=bnicholson --- .../android/base/menu/MenuItemActionView.java | 13 ++++++++- mobile/android/base/prompts/Prompt.java | 14 ++-------- .../base/prompts/PromptListAdapter.java | 2 +- mobile/android/base/prompts/TabInput.java | 26 ++++++++++++------ .../tab_indicator_background.9.png | Bin 0 -> 164 bytes .../tab_indicator_background.9.png | Bin 0 -> 163 bytes .../tab_indicator_background.9.png | Bin 0 -> 167 bytes .../resources/layout/tab_prompt_input.xml | 1 + .../base/resources/layout/tab_prompt_tab.xml | 9 ++++++ .../base/resources/values-v11/dimens.xml | 4 +++ .../base/resources/values-v11/styles.xml | 9 ++++++ .../android/base/resources/values/dimens.xml | 6 ++-- .../android/base/resources/values/styles.xml | 13 +++++++++ .../android/base/resources/values/themes.xml | 1 + .../base/widget/ActivityChooserModel.java | 6 ++-- 15 files changed, 78 insertions(+), 26 deletions(-) create mode 100644 mobile/android/base/resources/drawable-hdpi/tab_indicator_background.9.png create mode 100644 mobile/android/base/resources/drawable-mdpi/tab_indicator_background.9.png create mode 100644 mobile/android/base/resources/drawable-xhdpi/tab_indicator_background.9.png create mode 100644 mobile/android/base/resources/layout/tab_prompt_tab.xml diff --git a/mobile/android/base/menu/MenuItemActionView.java b/mobile/android/base/menu/MenuItemActionView.java index e6989d32878a..47aa76fd3694 100644 --- a/mobile/android/base/menu/MenuItemActionView.java +++ b/mobile/android/base/menu/MenuItemActionView.java @@ -19,6 +19,7 @@ import android.view.LayoutInflater; import android.view.View; import android.widget.ImageButton; import android.widget.LinearLayout; +import android.os.Build; public class MenuItemActionView extends LinearLayout implements GeckoMenuItem.Layout { @@ -37,10 +38,20 @@ public class MenuItemActionView extends LinearLayout this(context, attrs, R.attr.menuItemActionViewStyle); } - @TargetApi(11) + @TargetApi(14) public MenuItemActionView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs); + // Set these explicitly, since setting a style isn't supported for LinearLayouts until V11. + if (Build.VERSION.SDK_INT >= 11) { + setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE); + setDividerDrawable(getResources().getDrawable(R.drawable.divider_vertical)); + } + + if (Build.VERSION.SDK_INT >= 14) { + setDividerPadding(0); + } + LayoutInflater.from(context).inflate(R.layout.menu_item_action_view, this); mMenuItem = (MenuItemDefault) findViewById(R.id.menu_item); mMenuButton = (MenuItemActionBar) findViewById(R.id.menu_item_button); diff --git a/mobile/android/base/prompts/Prompt.java b/mobile/android/base/prompts/Prompt.java index 94385b9226e7..d196d59709c9 100644 --- a/mobile/android/base/prompts/Prompt.java +++ b/mobile/android/base/prompts/Prompt.java @@ -53,13 +53,7 @@ public class Prompt implements OnClickListener, OnCancelListener, OnItemClickLis private PromptListAdapter mAdapter; private static boolean mInitialized = false; - private static int mGroupPaddingSize; - private static int mLeftRightTextWithIconPadding; - private static int mTopBottomTextWithIconPadding; - private static int mIconTextPadding; - private static int mIconSize; private static int mInputPaddingSize; - private static int mMinRowSize; public Prompt(Context context, PromptCallback callback) { this(context); @@ -72,13 +66,7 @@ public class Prompt implements OnClickListener, OnCancelListener, OnItemClickLis if (!mInitialized) { Resources res = mContext.getResources(); - mGroupPaddingSize = (int) (res.getDimension(R.dimen.prompt_service_group_padding_size)); - mLeftRightTextWithIconPadding = (int) (res.getDimension(R.dimen.prompt_service_left_right_text_with_icon_padding)); - mTopBottomTextWithIconPadding = (int) (res.getDimension(R.dimen.prompt_service_top_bottom_text_with_icon_padding)); - mIconTextPadding = (int) (res.getDimension(R.dimen.prompt_service_icon_text_padding)); - mIconSize = (int) (res.getDimension(R.dimen.prompt_service_icon_size)); mInputPaddingSize = (int) (res.getDimension(R.dimen.prompt_service_inputs_padding)); - mMinRowSize = (int) (res.getDimension(R.dimen.prompt_service_min_list_item_height)); mInitialized = true; } } @@ -340,6 +328,8 @@ public class Prompt implements OnClickListener, OnCancelListener, OnItemClickLis } if (scrollable) { + // If we're showing some sort of scrollable list, force an inverse background. + builder.setInverseBackgroundForced(true); builder.setView(root); } else { ScrollView view = new ScrollView(mContext); diff --git a/mobile/android/base/prompts/PromptListAdapter.java b/mobile/android/base/prompts/PromptListAdapter.java index 8ee36d9c3011..945f9b14de1a 100644 --- a/mobile/android/base/prompts/PromptListAdapter.java +++ b/mobile/android/base/prompts/PromptListAdapter.java @@ -62,7 +62,7 @@ public class PromptListAdapter extends ArrayAdapter { mTopBottomTextWithIconPadding = (int) (res.getDimension(R.dimen.prompt_service_top_bottom_text_with_icon_padding)); mIconTextPadding = (int) (res.getDimension(R.dimen.prompt_service_icon_text_padding)); mIconSize = (int) (res.getDimension(R.dimen.prompt_service_icon_size)); - mMinRowSize = (int) (res.getDimension(R.dimen.prompt_service_min_list_item_height)); + mMinRowSize = (int) (res.getDimension(R.dimen.menu_item_row_height)); mTextSize = res.getDimension(R.dimen.menu_item_textsize); mInitialized = true; diff --git a/mobile/android/base/prompts/TabInput.java b/mobile/android/base/prompts/TabInput.java index 41f0637eaacb..c112647be9b1 100644 --- a/mobile/android/base/prompts/TabInput.java +++ b/mobile/android/base/prompts/TabInput.java @@ -13,18 +13,21 @@ import org.json.JSONObject; import org.json.JSONException; import android.content.Context; +import android.os.Build; +import android.util.Log; import android.view.View; import android.view.LayoutInflater; +import android.widget.AdapterView; import android.widget.Button; +import android.widget.FrameLayout; import android.widget.LinearLayout; +import android.widget.LinearLayout.LayoutParams; +import android.widget.ListView; import android.widget.TabHost; import android.widget.TabWidget; -import android.widget.FrameLayout; -import android.widget.ListView; -import android.widget.LinearLayout.LayoutParams; +import android.widget.TextView; + import java.util.LinkedHashMap; -import android.util.Log; -import android.widget.AdapterView; public class TabInput extends PromptInput implements AdapterView.OnItemClickListener { public static final String INPUT_TYPE = "tabs"; @@ -54,7 +57,7 @@ public class TabInput extends PromptInput implements AdapterView.OnItemClickList @Override public View getView(final Context context) throws UnsupportedOperationException { - LayoutInflater inflater = LayoutInflater.from(context); + final LayoutInflater inflater = LayoutInflater.from(context); mHost = (TabHost) inflater.inflate(R.layout.tab_prompt_input, null); mHost.setup(); @@ -65,14 +68,21 @@ public class TabInput extends PromptInput implements AdapterView.OnItemClickList public View createTabContent(final String tag) { PromptListAdapter adapter = new PromptListAdapter(context, android.R.layout.simple_list_item_1, mTabs.get(tag)); ListView listView = new ListView(context); + listView.setCacheColorHint(0); listView.setOnItemClickListener(TabInput.this); - listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); listView.setAdapter(adapter); return listView; } }); - spec.setIndicator(title); + // On older android versions, we use a custom style for the tabs. + if (Build.VERSION.SDK_INT < 11) { + TextView textview = (TextView) inflater.inflate(R.layout.tab_prompt_tab, null); + textview.setText(title); + spec.setIndicator(textview); + } else { + spec.setIndicator(title); + } mHost.addTab(spec); } mView = mHost; diff --git a/mobile/android/base/resources/drawable-hdpi/tab_indicator_background.9.png b/mobile/android/base/resources/drawable-hdpi/tab_indicator_background.9.png new file mode 100644 index 0000000000000000000000000000000000000000..349bf65f918a7ec954ac52e5ab584bf5bf3563dd GIT binary patch literal 164 zcmeAS@N?(olHy`uVBq!ia0vp^tU%1i#0(^79kbgCq&Ne7LR=Xb(*I8dau^H(X0QV( z#*!evUYh7ML)4-T$BW| z7)yfuf*Bm1-ADs*lDyqr7&=&GJwVC}JR*x37`TN&n2}-D90{Nxdx@v7EBifW31I`x yt(A!{fkMKbE{-7_*OLVj3s{`oEUu&oFfwrEFx=cGaQOmIn!(f6&t;ucLK6Udn?NMQuI%@iC4}|$ zp1J?J0u&PWba4#fxSo6=DgTe~DWM4f Dk8LM5 literal 0 HcmV?d00001 diff --git a/mobile/android/base/resources/layout/tab_prompt_input.xml b/mobile/android/base/resources/layout/tab_prompt_input.xml index a0dd53e2b967..72a73b7028d1 100644 --- a/mobile/android/base/resources/layout/tab_prompt_input.xml +++ b/mobile/android/base/resources/layout/tab_prompt_input.xml @@ -16,6 +16,7 @@ diff --git a/mobile/android/base/resources/layout/tab_prompt_tab.xml b/mobile/android/base/resources/layout/tab_prompt_tab.xml new file mode 100644 index 000000000000..132cfe1f80cd --- /dev/null +++ b/mobile/android/base/resources/layout/tab_prompt_tab.xml @@ -0,0 +1,9 @@ + + + + diff --git a/mobile/android/base/resources/values-v11/dimens.xml b/mobile/android/base/resources/values-v11/dimens.xml index 3abad7528dcb..6c4f71f8d5c8 100644 --- a/mobile/android/base/resources/values-v11/dimens.xml +++ b/mobile/android/base/resources/values-v11/dimens.xml @@ -7,5 +7,9 @@ 22sp 6sp + + 44dp diff --git a/mobile/android/base/resources/values-v11/styles.xml b/mobile/android/base/resources/values-v11/styles.xml index 63ba00a57910..0f26a9da22ab 100644 --- a/mobile/android/base/resources/values-v11/styles.xml +++ b/mobile/android/base/resources/values-v11/styles.xml @@ -100,4 +100,13 @@ @drawable/menu_light + + + + diff --git a/mobile/android/base/resources/values/dimens.xml b/mobile/android/base/resources/values/dimens.xml index c2ac37c88d23..f8052f2f675d 100644 --- a/mobile/android/base/resources/values/dimens.xml +++ b/mobile/android/base/resources/values/dimens.xml @@ -48,7 +48,10 @@ 21dp 16sp 18dp - 44dp + + 64dip 240dp 5dp 8dp @@ -63,7 +66,6 @@ 16dp 10dp 8dp - 48dp 64dp 26dp 32dp diff --git a/mobile/android/base/resources/values/styles.xml b/mobile/android/base/resources/values/styles.xml index 0ad1506e8ebd..eed75a1d0136 100644 --- a/mobile/android/base/resources/values/styles.xml +++ b/mobile/android/base/resources/values/styles.xml @@ -604,4 +604,17 @@ right + + + + + + diff --git a/mobile/android/base/resources/values/themes.xml b/mobile/android/base/resources/values/themes.xml index c0ff408f71da..6a3430d4b34c 100644 --- a/mobile/android/base/resources/values/themes.xml +++ b/mobile/android/base/resources/values/themes.xml @@ -91,6 +91,7 @@ @style/Widget.MenuItemDefault @style/Widget.MenuItemActionBar @style/GeckoActionBar.Button + @style/Widget.MenuItemSecondaryActionBar