Bug 698598: Reskinning stackable doorhangers. r=mfinkle
authorSriram Ramasubramanian <sriram@mozilla.com>
Wed, 09 Nov 2011 14:45:57 -0800
changeset 83440 afe02e3fdc59db6cbe3b5ff302f83125ac7e1d83
parent 83439 3389a8aed11ccc61817ff359f403e07d23b68f63
child 83441 e65b9655e3e89ac8179c97dcae60142edc6f48c9
push id519
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 00:38:35 +0000
treeherdermozilla-beta@788ea1ef610b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs698598
milestone10.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 698598: Reskinning stackable doorhangers. r=mfinkle
embedding/android/BrowserToolbar.java
embedding/android/DoorHanger.java
embedding/android/DoorHangerPopup.java
embedding/android/Makefile.in
embedding/android/resources/drawable/doorhanger_arrow.png
embedding/android/resources/drawable/doorhanger_bg.9.png
embedding/android/resources/drawable/doorhanger_popup_bg.9.png
embedding/android/resources/drawable/doorhanger_shadow_bg.9.png
embedding/android/resources/layout/doorhanger.xml
embedding/android/resources/layout/doorhangerpopup.xml
--- a/embedding/android/BrowserToolbar.java
+++ b/embedding/android/BrowserToolbar.java
@@ -49,17 +49,17 @@ import android.view.LayoutInflater;
 import android.view.View;
 import android.widget.Button;
 import android.widget.ImageButton;
 import android.widget.LinearLayout;
 
 public class BrowserToolbar extends LinearLayout {
     final private Button mAwesomeBar;
     final private ImageButton mTabs;
-    final private ImageButton mFavicon;
+    final public ImageButton mFavicon;
     final private AnimationDrawable mProgressSpinner;
 
     public BrowserToolbar(Context context, AttributeSet attrs) {
         super(context, attrs);
 
         // Load layout into the custom view
         LayoutInflater inflater =
                 (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
--- a/embedding/android/DoorHanger.java
+++ b/embedding/android/DoorHanger.java
@@ -34,22 +34,22 @@
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 package org.mozilla.gecko;
 
 import android.content.Context;
-import android.widget.TextView;
-import android.widget.Button;
 import android.view.LayoutInflater;
 import android.view.View;
+import android.widget.Button;
 import android.widget.LinearLayout;
 import android.widget.LinearLayout.LayoutParams;
+import android.widget.TextView;
 
 public class DoorHanger extends LinearLayout implements Button.OnClickListener {
     private Context mContext;
     private LinearLayout mChoicesLayout;
     private TextView mTextView;
     private Button mButton;
     private LayoutParams mLayoutParams;
     public Tab mTab;
@@ -57,16 +57,19 @@ public class DoorHanger extends LinearLa
     private String mValue;
 
     public DoorHanger(Context aContext, String aValue) {
         super(aContext);
 
         mContext = aContext;
         mValue = aValue;
 
+        setOrientation(VERTICAL);
+        setBackgroundResource(R.drawable.doorhanger_shadow_bg);
+
         // Load layout into the custom view
         LayoutInflater inflater =
                 (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
         inflater.inflate(R.layout.doorhanger, this);
         hidePopup();
 
         mTextView = (TextView) findViewById(R.id.doorhanger_title);
         mChoicesLayout = (LinearLayout) findViewById(R.id.doorhanger_choices);
@@ -94,16 +97,20 @@ public class DoorHanger extends LinearLa
     public void showPopup() {
         setVisibility(View.VISIBLE);
     }
 
     public void hidePopup() {
         setVisibility(View.GONE);
     }
 
+    public boolean isVisible() {
+        return getVisibility() == View.VISIBLE;
+    }
+
     public String getValue() {
         return mValue;
     }
 
     public void setText(String aText) {
         mTextView.setText(aText);
     }
 
--- a/embedding/android/DoorHangerPopup.java
+++ b/embedding/android/DoorHangerPopup.java
@@ -37,39 +37,41 @@
  * ***** END LICENSE BLOCK ***** */
 
 package org.mozilla.gecko;
 
 import java.util.HashMap;
 import java.util.Iterator;
 
 import android.content.Context;
+import android.graphics.drawable.BitmapDrawable;
 import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.ViewGroup;
 import android.widget.PopupWindow;
 import android.widget.LinearLayout;
 import android.widget.LinearLayout.LayoutParams;
-import android.widget.ScrollView;
+import android.widget.RelativeLayout;
 
 public class DoorHangerPopup extends PopupWindow {
     private Context mContext;
     private LinearLayout mContent;
 
     public DoorHangerPopup(Context aContext) {
         super(aContext);
         mContext = aContext;
 
+        setBackgroundDrawable(new BitmapDrawable());
         setWindowLayoutMode(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
 
         LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
-        ScrollView scrollContent = (ScrollView) inflater.inflate(R.layout.doorhangerpopup, null);
-        mContent = (LinearLayout) scrollContent.findViewById(R.id.doorhanger_container);
+        RelativeLayout layout = (RelativeLayout) inflater.inflate(R.layout.doorhangerpopup, null);
+        mContent = (LinearLayout) layout.findViewById(R.id.doorhanger_container);
         
-        setContentView(scrollContent);
+        setContentView(layout);
     }
 
     public DoorHanger addDoorHanger(Tab tab, String value) {
         Log.i("DoorHangerPopup", "Adding a DoorHanger to Tab: " + tab.getId());
 
         DoorHanger dh = tab.getDoorHanger(value);
         if (dh != null) {
             dh.hidePopup();
@@ -85,16 +87,18 @@ public class DoorHangerPopup extends Pop
     }
 
     public void removeDoorHanger(Tab tab, String value) {
         Log.i("DoorHangerPopup", "Removing a DoorHanger from Tab: " + tab.getId());
         tab.removeDoorHanger(value);
 
         if (tab.getDoorHangers().size() == 0)
             hide();
+        else
+            fixBackgroundForFirst(); 
     }
 
     public void showDoorHanger(DoorHanger dh) {
         if (dh == null)
             return;
 
         dh.showPopup();
         show();
@@ -127,20 +131,22 @@ public class DoorHangerPopup extends Pop
         if (isShowing()) {
             Log.i("DoorHangerPopup", "Dismissing the DoorHangerPopup");
             dismiss();
         }
     }
 
     public void show() {
         Log.i("DoorHangerPopup", "Showing the DoorHangerPopup");
+        fixBackgroundForFirst();
+
         if (isShowing())
             update();
         else
-            showAsDropDown(GeckoApp.mBrowserToolbar);
+            showAsDropDown(GeckoApp.mBrowserToolbar.mFavicon);
     }
 
     public void removeForTab(Tab tab) {
         Log.i("DoorHangerPopup", "Removing all doorhangers for tab: " + tab.getId());
         tab.removeAllDoorHangers();
     }
 
     public void showForTab(Tab tab) {
@@ -172,9 +178,19 @@ public class DoorHangerPopup extends Pop
         if (doorHangers == null)
             return;
 
         Iterator keys = doorHangers.keySet().iterator();
         while (keys.hasNext()) {
             ((DoorHanger) doorHangers.get(keys.next())).hidePopup();
         }
     }
+
+    private void fixBackgroundForFirst() {
+        for (int i=0; i < mContent.getChildCount(); i++) {
+            DoorHanger dh = (DoorHanger) mContent.getChildAt(i);
+            if (dh.isVisible()) {
+                dh.setBackgroundResource(R.drawable.doorhanger_bg);
+                break;
+            }
+        }
+    }
 }
--- a/embedding/android/Makefile.in
+++ b/embedding/android/Makefile.in
@@ -276,16 +276,20 @@ MOZ_ANDROID_DRAWABLES += embedding/andro
                          embedding/android/resources/drawable/awesomebar_tab_focus.xml        \
                          embedding/android/resources/drawable/awesomebar_tab_focus_selected.xml \
                          embedding/android/resources/drawable/awesomebar_tab_indicator.xml    \
                          embedding/android/resources/drawable/awesomebar_tab_press.xml        \
                          embedding/android/resources/drawable/awesomebar_tab_press_selected.xml \
                          embedding/android/resources/drawable/awesomebar_tab_selected.xml     \
                          embedding/android/resources/drawable/awesomebar_tab_unselected.xml   \
                          embedding/android/resources/drawable/desktop_notification.png        \
+                         embedding/android/resources/drawable/doorhanger_arrow.png            \
+                         embedding/android/resources/drawable/doorhanger_bg.9.png             \
+                         embedding/android/resources/drawable/doorhanger_shadow_bg.9.png      \
+                         embedding/android/resources/drawable/doorhanger_popup_bg.9.png       \
                          embedding/android/resources/drawable/favicon.png                     \
                          embedding/android/resources/drawable/progress_spinner.xml            \
                          embedding/android/resources/drawable/progress_spinner_1.png          \
                          embedding/android/resources/drawable/progress_spinner_2.png          \
                          embedding/android/resources/drawable/progress_spinner_3.png          \
                          embedding/android/resources/drawable/progress_spinner_4.png          \
                          embedding/android/resources/drawable/progress_spinner_5.png          \
                          embedding/android/resources/drawable/progress_spinner_6.png          \
new file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..c6bc59cd546e1ea11b7057dba5b0c98622e3f8d7
GIT binary patch
literal 1762
zc$}S8c~BE)6b}LtQ4p0PbP$&ylw!&5hJ+kk=2Qj}Zbd<BNH$~#HVK;r0#YkjaZqUm
zl%iM=#tIJLF;c~oL&O5wf`C$#iZUpIc#f!`wi^rf7{@>Q&Fp^Pd;9yn_r7<`=7h?Y
zTUmZ;Nuf}z0#}H_$$csL*idJZ@9ze(50je%A&w>@v??N1jw2MlQX7W=ftWlV2}k70
zw4_$VmqIaBqmj`>v^1Ef&|-AC5kog%I*M`m1{id5MFK(qaY#I>@uNLDQ%?g>r5|k-
zOA1MKLPU+ONXL<gbXlY#Jwd@$(gOSeUjvUcfFXn&Fkp!qJ<s4rduNwNo{egd2E2n1
z34XM{f{K=g0zxg004zG>sers;z?(^jnGl!B{Q_V>Fa*L35Mq165Rb*?K`=12Xrwn>
zsp5r;BvZaf$&aQc2ptauQ&Usvsa|v~9uLA?E*FFtAcNsaB0TkJ8bWUH)aYHNEr<}k
z0!MWOs?`8SSstfNCj4l$=__D5sr0>JjeaUoWXeE;TnEB*2*faO8m%Y75!J`h`p7gL
z0)``cZ8EMP>!EV_hpUfMjX*LQUI>noMUf|pw2EX5(GY<mKN|Uku0)k&iZ~DqvzZW^
z0eN#^m?IJhBz!NfSS%339H#fQjSq3T-jE0qNVt#}B!OWP?j>Of_#9XuV6Y*W%bDf|
zYV?F$qd=y)=-*t<N4Y#9j>riu9;wwPPIo}4T1#m4YOM|sMzH8GAeAdnjZtGP&{V7l
zj;0_=39iL}cNylPABaH0VN3pXb2cpDbHprfG8V3o%c4zjmH#JeAQ=q!pLUs6kv(WU
zzHfd~ct1XfhMXCk9F8Otw?T5|Yyw66NJC%qwV;p%VYZY3pCg3~4BdKyu-tO2#&$M!
zg~)VPx%=MXmgb!=X9wRLUJO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26592620949a57d8616d8318f
GIT binary patch
literal 80
zc%17D@N?(olHy`uVBq!ia0vp^tU%1n!3HFw&5r&6QsSO2jv*Ddk`o*n{_~uW(X0%$
dI5wfhkl{-YhseAcwOT+W44$rjF6*2UngF?}6yyK^
new file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..63c098b47f97a11d2a9007b82e1f9b8ef0170056
GIT binary patch
literal 132
zc%17D@N?(olHy`uVBq!ia0vp^tUxTr!3HEbbi*zHDQ`~~$B>F!$q5b(|9MUvIC%82
zJ<nm*rB6ctA2x_NE+F`)KU7s<jq{;`4WgXJ4?-=)IS)J93bi$BsPM3xc}VbuOf-<;
gP)rnI_|D0Y{L5YQ&Ze1KKw}v^UHx3vIVCg!0Df^N$^ZZW
new file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..e07346fa6d9448cf4af038b903f6a6ad73cf55fb
GIT binary patch
literal 139
zc%17D@N?(olHy`uVBq!ia0vp^tU%1e!3HE(C6wy|sUS}m$B>F!wdXf-H5l-;JWPnv
z>e3JueY2qZ{r`^VCFw5{9!P(hteSTJz^g)jg`?+Wztl@6v1l%<W6<oo%oH@|Gh0wh
oKU2`1)4Z3|pMUlEJ#(74tBKmYkE~rxK+_pKUHx3vIVCg!0Q3bh+W-In
--- a/embedding/android/resources/layout/doorhanger.xml
+++ b/embedding/android/resources/layout/doorhanger.xml
@@ -1,20 +1,17 @@
 <?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-              android:layout_width="match_parent"
-              android:layout_height="wrap_content"
-              android:orientation="vertical"
-              android:background="#3e3e3e">
+<merge xmlns:android="http://schemas.android.com/apk/res/android">
 
     <TextView android:id="@+id/doorhanger_title"
               android:layout_width="match_parent"
               android:layout_height="wrap_content"
               android:textAppearance="?android:attr/textAppearanceMedium"
               android:textColor="?android:attr/textColorPrimary"
               android:padding="10dp"/>
 
     <LinearLayout android:id="@+id/doorhanger_choices"
+                  style="@android:style/ButtonBar"
                   android:layout_width="match_parent"
                   android:layout_height="wrap_content"
                   android:orientation="horizontal"/>
 
-</LinearLayout>
+</merge>
--- a/embedding/android/resources/layout/doorhangerpopup.xml
+++ b/embedding/android/resources/layout/doorhangerpopup.xml
@@ -1,11 +1,27 @@
 <?xml version="1.0" encoding="utf-8"?>
-<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content">
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content">
+
+    <ScrollView android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_marginTop="24dip"
+                android:layout_alignParentTop="true">
 
-    <LinearLayout android:id="@+id/doorhanger_container"
-                  android:layout_width="match_parent"
-                  android:layout_height="wrap_content"
-                  android:orientation="vertical"/>
+        <LinearLayout android:id="@+id/doorhanger_container"
+                      android:layout_width="match_parent"
+                      android:layout_height="wrap_content"
+                      android:orientation="vertical"
+                      android:background="@drawable/doorhanger_popup_bg"/>
+
+    </ScrollView>
 
-</ScrollView>
+    <ImageView android:layout_width="43dip"
+               android:layout_height="15dip"
+               android:layout_marginLeft="50dip"
+               android:layout_marginTop="10dip"
+               android:layout_alignParentTop="true"
+               android:src="@drawable/doorhanger_arrow"
+               android:scaleType="fitXY"/>
+
+</RelativeLayout>