Bug 1130203 - Clean up OverlayDialogButton's initialization. r=mhaigh
authorMichael Comella <michael.l.comella@gmail.com>
Thu, 05 Feb 2015 17:44:56 -0800
changeset 265823 6d9a05956ad88a42d9bcd823e63e0d1b89400c23
parent 265822 a4cab686efdd79512e23d5977a01b2fbc5dc9a50
child 265824 9a2166dd61dc9bf3f97f519295c52d2a6ebbdcc7
push id830
push userraliiev@mozilla.com
push dateFri, 19 Jun 2015 19:24:37 +0000
treeherdermozilla-release@932614382a68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmhaigh
bugs1130203
milestone39.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1130203 - Clean up OverlayDialogButton's initialization. r=mhaigh 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
@@ -773,16 +773,17 @@
     </style>
 
     <style name="GeckoActionBar.Buttons">
         <item name="android:background">@android:color/transparent</item>
         <item name="android:textColor">@color/placeholder_active_grey</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>
@@ -793,16 +794,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">