Bug 942270 - Fix gingerbread issues with quickshare. r=bnicholson, a=lsblakk
authorWes Johnston <wjohnston@mozilla.com>
Wed, 26 Mar 2014 10:18:02 -0700
changeset 192873 3827427f7c06cffb023644430120741ebcb0810b
parent 192872 4be0743e206558e517d4a3fb1de95ea9e758bb6d
child 192874 545cc8ee0dc2a55ab563c683bec42fc7e63e8df8
push id474
push userasasaki@mozilla.com
push dateMon, 02 Jun 2014 21:01:02 +0000
treeherdermozilla-release@967f4cf1b31c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbnicholson, lsblakk
bugs942270
milestone30.0a2
Bug 942270 - Fix gingerbread issues with quickshare. r=bnicholson, a=lsblakk
mobile/android/base/menu/MenuItemActionView.java
mobile/android/base/prompts/Prompt.java
mobile/android/base/prompts/PromptListAdapter.java
mobile/android/base/prompts/TabInput.java
mobile/android/base/resources/drawable-hdpi/tab_indicator_background.9.png
mobile/android/base/resources/drawable-mdpi/tab_indicator_background.9.png
mobile/android/base/resources/drawable-xhdpi/tab_indicator_background.9.png
mobile/android/base/resources/layout/tab_prompt_input.xml
mobile/android/base/resources/layout/tab_prompt_tab.xml
mobile/android/base/resources/values-v11/dimens.xml
mobile/android/base/resources/values-v11/styles.xml
mobile/android/base/resources/values/dimens.xml
mobile/android/base/resources/values/styles.xml
mobile/android/base/resources/values/themes.xml
mobile/android/base/widget/ActivityChooserModel.java
--- a/mobile/android/base/menu/MenuItemActionView.java
+++ b/mobile/android/base/menu/MenuItemActionView.java
@@ -14,16 +14,17 @@ import android.annotation.TargetApi;
 import android.content.Context;
 import android.content.res.TypedArray;
 import android.graphics.drawable.Drawable;
 import android.util.AttributeSet;
 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 {
     private static final String LOGTAG = "GeckoMenuItemActionView";
 
     private MenuItemDefault mMenuItem;
     private MenuItemActionBar mMenuButton;
     private List<ImageButton> mActionButtons;
@@ -32,20 +33,30 @@ public class MenuItemActionView extends 
     public MenuItemActionView(Context context) {
         this(context, null);
     }
 
     public MenuItemActionView(Context context, AttributeSet attrs) {
         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);
         mActionButtons = new ArrayList<ImageButton>();
     }
 
     @Override
     protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
--- a/mobile/android/base/prompts/Prompt.java
+++ b/mobile/android/base/prompts/Prompt.java
@@ -48,42 +48,30 @@ public class Prompt implements OnClickLi
 
     private final LayoutInflater mInflater;
     private final Context mContext;
     private PromptCallback mCallback;
     private String mGuid;
     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);
         mCallback = callback;
     }
 
     private Prompt(Context context) {
         mContext = context;
         mInflater = LayoutInflater.from(mContext);
 
         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;
         }
     }
 
     private View applyInputStyle(View view, PromptInput input) {
         // Don't add padding to color picker views
         if (input.canApplyInputStyle()) {
             view.setPadding(mInputPaddingSize, 0, mInputPaddingSize, 0);
@@ -334,16 +322,18 @@ public class Prompt implements OnClickLi
                     View content = wrapInput(mInputs[i]);
                     linearLayout.addView(content);
                     scrollable |= mInputs[i].getScrollable();
                 }
                 root = linearLayout;
             }
 
             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);
                 view.addView(root);
                 builder.setView(view);
             }
         } catch(Exception ex) {
             Log.e(LOGTAG, "Error showing prompt inputs", ex);
--- a/mobile/android/base/prompts/PromptListAdapter.java
+++ b/mobile/android/base/prompts/PromptListAdapter.java
@@ -57,17 +57,17 @@ public class PromptListAdapter extends A
     private void init() {
         if (!mInitialized) {
             Resources res = getContext().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));
-            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;
         }
     }
 
     @Override
     public int getItemViewType(int position) {
--- a/mobile/android/base/prompts/TabInput.java
+++ b/mobile/android/base/prompts/TabInput.java
@@ -8,28 +8,31 @@ package org.mozilla.gecko.prompts;
 import org.mozilla.gecko.R;
 import org.mozilla.gecko.util.ThreadUtils;
 
 import org.json.JSONArray;
 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";
     public static final String LOGTAG = "GeckoTabInput";
 
     /* Keeping the order of this in sync with the JSON is important. */
     final private LinkedHashMap<String, PromptListItem[]> mTabs;
 
@@ -49,35 +52,42 @@ public class TabInput extends PromptInpu
             }
         } catch(JSONException ex) {
             Log.e(LOGTAG, "Exception", ex);
         }
     }
 
     @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();
 
         for (String title : mTabs.keySet()) {
             final TabHost.TabSpec spec = mHost.newTabSpec(title);
             spec.setContent(new TabHost.TabContentFactory() {
                 @Override
                 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;
         return mHost;
     }
 
     @Override
     public Object getValue() {
new file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..349bf65f918a7ec954ac52e5ab584bf5bf3563dd
GIT binary patch
literal 164
zc%17D@N?(olHy`uVBq!ia0vp^tU%1i#0(^79kbgCq&Ne7LR=Xb(*I8dau^H(X0QV(
z#*!evU<QY0H_||yByV>Yh7ML)50LT#kH}&M25w;xW@MN(M*=9wUgGKN%6^YoSe#wh
yxXOGJP)Nkn#W95Adh&&&gp7;>?JfsBx)~Y%p5(5VOL)WvvdPoc&t;ucLK6T;NhN9k
new file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..33fc478cd0f92644ab59c8fb845d575dcbe9f45a
GIT binary patch
literal 163
zc%17D@N?(olHy`uVBq!ia0vp^EI`b~#0(_gO%<ODq&Ne7LR=Xb(t*tXQyJ>-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<V}K
new file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..8d666215f0ae788945ac8ded4ff491631c3efe89
GIT binary patch
literal 167
zc%17D@N?(olHy`uVBq!ia0vp^Y(Ol;#0(@^pSp(uDb4_&5LX6<^#4<V90r4c8SFrc
zu_VYZn8D%MjWiG^$=lt9p@UV{1EjpbBeIx*fm;}a85w5HkpK#^mw5WRvfpEt5Z2dw
z=KkvnP)OX<#W95Adh&&=gp2?O1-3mNCX6jxq!_mMvi?8(ah4m%GEY}Omvv4FO#qK=
BCpG{8
--- a/mobile/android/base/resources/layout/tab_prompt_input.xml
+++ b/mobile/android/base/resources/layout/tab_prompt_input.xml
@@ -11,16 +11,17 @@
     <LinearLayout
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:orientation="vertical"
         android:minHeight="100dp">
 
         <TabWidget
             android:id="@android:id/tabs"
+            style="@style/TabInput.TabWidget"
             android:layout_width="match_parent"
             android:layout_height="wrap_content" >
         </TabWidget>
 
         <FrameLayout
             android:id="@android:id/tabcontent"
             android:layout_width="match_parent"
             android:layout_height="match_parent" >
new file mode 100644
--- /dev/null
+++ b/mobile/android/base/resources/layout/tab_prompt_tab.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- This Source Code Form is subject to the terms of the Mozilla Public
+   - License, v. 2.0. If a copy of the MPL was not distributed with this
+   - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
+
+<TextView xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    style="@style/TabInput.Tab"/>
--- a/mobile/android/base/resources/values-v11/dimens.xml
+++ b/mobile/android/base/resources/values-v11/dimens.xml
@@ -2,10 +2,14 @@
 <!-- This Source Code Form is subject to the terms of the Mozilla Public
    - License, v. 2.0. If a copy of the MPL was not distributed with this
    - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
 
 <resources>
 
     <dimen name="tabs_counter_size">22sp</dimen>
     <dimen name="doorhanger_spinner_textsize">6sp</dimen>
+    <!-- This is chosen to be close to Android's listPreferredItemHeightSmall.
+         TODO: We should inherit these from the system.
+         http://androidxref.com/4.2.2_r1/xref/frameworks/base/core/res/res/values/themes.xml#1287 -->
+    <dimen name="menu_item_row_height">44dp</dimen>
 
 </resources>
--- a/mobile/android/base/resources/values-v11/styles.xml
+++ b/mobile/android/base/resources/values-v11/styles.xml
@@ -95,9 +95,18 @@
     </style>
 
     <style name="GeckoActionBar.Button.MenuButton" parent="android:style/Widget.Holo.Light.ActionButton.Overflow">
         <item name="android:scaleType">center</item>
         <item name="android:background">@android:color/transparent</item>
         <item name="android:src">@drawable/menu_light</item>
     </style>
 
+    <style name="TabInput"></style>
+
+    <style name="TabInput.TabWidget" parent="android:style/Widget.Holo.Light.TabWidget"/>
+
+    <style name="TabInput.Tab" parent="android:style/Widget.Holo.Light.Tab">
+        <item name="android:minHeight">@dimen/menu_item_row_height</item>
+        <item name="android:textAllCaps">true</item>
+    </style>
+
 </resources>
--- a/mobile/android/base/resources/values/dimens.xml
+++ b/mobile/android/base/resources/values/dimens.xml
@@ -43,17 +43,20 @@
     <dimen name="doorhanger_spinner_textsize">9sp</dimen>
     <dimen name="doorhanger_padding">15dp</dimen>
     <dimen name="doorhanger_textsize_small">8sp</dimen>
 
     <dimen name="flow_layout_spacing">6dp</dimen>
     <dimen name="menu_item_icon">21dp</dimen>
     <dimen name="menu_item_textsize">16sp</dimen>
     <dimen name="menu_item_state_icon">18dp</dimen>
-    <dimen name="menu_item_row_height">44dp</dimen>
+    <!-- This is chosen to match Android's listPreferredItemHeight.
+         TODO: We should inherit these from the system.
+         http://androidxref.com/4.2.2_r1/xref/frameworks/base/core/res/res/values/themes.xml#123 -->
+    <dimen name="menu_item_row_height">64dip</dimen>
     <dimen name="menu_item_row_width">240dp</dimen>
     <dimen name="menu_item_more_offset">5dp</dimen>
     <dimen name="menu_item_textsize">16sp</dimen>
     <dimen name="menu_popup_arrow_offset">8dp</dimen>
     <dimen name="menu_popup_arrow_margin">5dip</dimen>
     <dimen name="menu_popup_arrow_width">40dip</dimen>
     <dimen name="menu_popup_offset">12dp</dimen>
     <dimen name="menu_popup_width">256dp</dimen>
--- a/mobile/android/base/resources/values/styles.xml
+++ b/mobile/android/base/resources/values/styles.xml
@@ -599,9 +599,22 @@
     </style>
 
     <style name="GeckoActionBar.Buttons">
         <item name="android:background">@android:color/transparent</item>
         <item name="android:textColor">@color/text_color_primary</item>
         <item name="android:gravity">right</item>
     </style>
 
+    <style name="TabInput"></style>
+
+    <style name="TabInput.TabWidget">
+        <item name="android:divider">@drawable/divider_vertical</item>
+        <item name="android:background">@drawable/tab_indicator_background</item>
+    </style>
+
+    <style name="TabInput.Tab">
+        <item name="android:background">@drawable/tabs_panel_indicator</item>
+        <item name="android:gravity">center</item>
+        <item name="android:minHeight">@dimen/menu_item_row_height</item>
+    </style>
+
 </resources>
--- a/mobile/android/base/resources/values/themes.xml
+++ b/mobile/android/base/resources/values/themes.xml
@@ -86,13 +86,14 @@
         <item name="topSitesGridViewStyle">@style/Widget.TopSitesGridView</item>
         <item name="panelGridViewStyle">@style/Widget.PanelGridView</item>
         <item name="topSitesThumbnailViewStyle">@style/Widget.TopSitesThumbnailView</item>
         <item name="homeListViewStyle">@style/Widget.HomeListView</item>
         <item name="geckoMenuListViewStyle">@style/Widget.GeckoMenuListView</item>
         <item name="menuItemDefaultStyle">@style/Widget.MenuItemDefault</item>
         <item name="menuItemActionBarStyle">@style/Widget.MenuItemActionBar</item>
         <item name="menuItemActionModeStyle">@style/GeckoActionBar.Button</item>
+        <item name="menuItemShareActionButtonStyle">@style/Widget.MenuItemSecondaryActionBar</item>
     </style>
 
     <style name="Gecko.Preferences" parent="GeckoPreferencesBase"/>
 
 </resources>
--- a/mobile/android/base/widget/ActivityChooserModel.java
+++ b/mobile/android/base/widget/ActivityChooserModel.java
@@ -593,18 +593,20 @@ public class ActivityChooserModel extend
         if (!mReadShareHistoryCalled) {
             throw new IllegalStateException("No preceding call to #readHistoricalData");
         }
         if (!mHistoricalRecordsChanged) {
             return;
         }
         mHistoricalRecordsChanged = false;
         if (!TextUtils.isEmpty(mHistoryFileName)) {
-            new PersistHistoryAsyncTask().executeOnExecutor(AsyncTask.SERIAL_EXECUTOR,
-                    new ArrayList<HistoricalRecord>(mHistoricalRecords), mHistoryFileName);
+            /**
+             * Mozilla: Converted to a normal task.execute call so that this works on < ICS phones.
+             */
+            new PersistHistoryAsyncTask().execute(new ArrayList<HistoricalRecord>(mHistoricalRecords), mHistoryFileName);
         }
     }
 
     /**
      * Sets the sorter for ordering activities based on historical data and an intent.
      *
      * @param activitySorter The sorter.
      *