Bug 1130203 - Clean up OverlayDialogButton's initialization. r=mhaigh a=sylvestre
authorMichael Comella <michael.l.comella@gmail.com>
Thu, 05 Feb 2015 17:44:56 -0800
changeset 258334 4f2f00d1331c
parent 258333 6d1efbb2c76c
child 258335 d6200a67e007
push id4648
push usermichael.l.comella@gmail.com
push date2015-04-08 16:26 +0000
treeherdermozilla-beta@e399294c9df3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmhaigh, sylvestre
bugs1130203
milestone38.0
Bug 1130203 - Clean up OverlayDialogButton's initialization. r=mhaigh a=sylvestre Note that a TODO was added to clean up styles, which should be completed before this bug lands.
mobile/android/base/overlays/ui/OverlayDialogButton.java
mobile/android/base/resources/layout/overlay_share_dialog.xml
mobile/android/base/resources/values/styles.xml
--- a/mobile/android/base/overlays/ui/OverlayDialogButton.java
+++ b/mobile/android/base/overlays/ui/OverlayDialogButton.java
@@ -25,18 +25,18 @@ import android.widget.TextView;
  *
  * When disabled, tapping results in a "pop" animation causing the icon to pulse. When enabled,
  * tapping calls the OnClickListener set by the consumer in the usual way.
  */
 public class OverlayDialogButton extends LinearLayout {
     private static final String LOGTAG = "GeckoOverlayDialogButton";
 
     // The views making up this button.
-    private ImageView icon;
-    private TextView label;
+    private final ImageView icon;
+    private final TextView label;
 
     // Label/icon used when enabled.
     private String enabledLabel;
     private Drawable enabledIcon;
 
     // Label/icon used when disabled.
     private String disabledLabel;
     private Drawable disabledIcon;
@@ -44,36 +44,24 @@ public class OverlayDialogButton extends
     // Click listeners used when enabled/disabled. Currently, disabledOnClickListener is set
     // internally to something that causes the icon to pulse.
     private OnClickListener enabledOnClickListener;
     private OnClickListener disabledOnClickListener;
 
     private boolean isEnabled = true;
 
     public OverlayDialogButton(Context context) {
-        super(context);
-        init(context);
+        this(context, null);
     }
 
     public OverlayDialogButton(Context context, AttributeSet attrs) {
         super(context, attrs);
-        init(context);
-    }
-
-    public OverlayDialogButton(Context context, AttributeSet attrs, int defStyle) {
-        super(context, attrs, defStyle);
-        init(context);
-    }
-
-    private void init(Context context) {
-        setOrientation(HORIZONTAL);
-        setPadding(0, 0, 0, 0);
-        setBackgroundResource(R.drawable.overlay_share_button_background);
 
         LayoutInflater.from(context).inflate(R.layout.overlay_share_button, this);
+
         icon = (ImageView) findViewById(R.id.overlaybtn_icon);
         label = (TextView) findViewById(R.id.overlaybtn_label);
     }
 
     public void setEnabledLabelAndIcon(String s, Drawable d) {
         enabledLabel = s;
         enabledIcon = d;
 
--- a/mobile/android/base/resources/layout/overlay_share_dialog.xml
+++ b/mobile/android/base/resources/layout/overlay_share_dialog.xml
@@ -79,29 +79,29 @@
             <!-- Evil separator -->
             <View
                 android:layout_width="match_parent"
                 android:layout_height="1dp"
                 android:background="@color/background_light"/>
 
             <!-- "Add to reading list" -->
             <org.mozilla.gecko.overlays.ui.OverlayDialogButton
-                style="@style/ShareOverlayButton.Text"
+                style="@style/ShareOverlayButton.Text.Container"
                 android:id="@+id/overlay_share_reading_list_btn"
                 android:enabled="false"/>
 
             <!-- Evil separator -->
             <View
                 android:layout_width="match_parent"
                 android:layout_height="1dp"
                 android:background="@color/background_light"/>
 
             <!-- "Add bookmark" -->
             <org.mozilla.gecko.overlays.ui.OverlayDialogButton
-                style="@style/ShareOverlayButton.Text"
+                style="@style/ShareOverlayButton.Text.Container"
                 android:id="@+id/overlay_share_bookmark_btn"
                 android:enabled="false"/>
 
         </LinearLayout>
     </LinearLayout>
 
     <!-- Firefox logo (has to appear higher in the z-order than the content. -->
     <ImageView
--- a/mobile/android/base/resources/values/styles.xml
+++ b/mobile/android/base/resources/values/styles.xml
@@ -771,16 +771,17 @@
     </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>
 
+    <!-- TODO: Clean up this and inherited styles. -->
     <style name="ShareOverlayButton">
         <item name="android:layout_width">match_parent</item>
         <item name="android:layout_height">wrap_content</item>
         <item name="android:minHeight">60dp</item>
         <item name="android:gravity">center_vertical</item>
         <item name="android:paddingLeft">15dp</item>
         <item name="android:paddingRight">15dp</item>
         <item name="android:paddingTop">17dp</item>
@@ -791,16 +792,22 @@
 
     <style name="ShareOverlayButton.Text">
         <item name="android:drawablePadding">15dp</item>
         <item name="android:maxLines">1</item>
         <item name="android:textSize">14sp</item>
         <item name="android:textColor">@color/overlay_btn_text</item>
     </style>
 
+    <style name="ShareOverlayButton.Text.Container">
+        <item name="android:padding">0dp</item>
+        <item name="android:orientation">horizontal</item>
+        <item name="android:background">@drawable/overlay_share_button_background</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">