Bug 848707: Add focused states for buttons. [r=mfinkle]

This commit is contained in:
Sriram Ramasubramanian 2013-03-13 12:28:01 -07:00
parent 14ed094e9c
commit 0a3144fdbf
11 changed files with 46 additions and 7 deletions

View File

@ -83,6 +83,7 @@ public class BackButton extends ShapedButton {
StateListDrawable stateList = new StateListDrawable(); StateListDrawable stateList = new StateListDrawable();
stateList.addState(new int[] { android.R.attr.state_pressed }, new ColorDrawable(resources.getColor(R.color.highlight))); stateList.addState(new int[] { android.R.attr.state_pressed }, new ColorDrawable(resources.getColor(R.color.highlight)));
stateList.addState(new int[] { android.R.attr.state_focused }, new ColorDrawable(resources.getColor(R.color.highlight_focused)));
stateList.addState(new int[] { R.attr.state_private }, new ColorDrawable(resources.getColor(R.color.background_private))); stateList.addState(new int[] { R.attr.state_private }, new ColorDrawable(resources.getColor(R.color.background_private)));
stateList.addState(new int[] {}, drawable); stateList.addState(new int[] {}, drawable);

View File

@ -77,6 +77,7 @@ public class ForwardButton extends ShapedButton {
StateListDrawable stateList = new StateListDrawable(); StateListDrawable stateList = new StateListDrawable();
stateList.addState(new int[] { android.R.attr.state_pressed }, new ColorDrawable(resources.getColor(R.color.highlight))); stateList.addState(new int[] { android.R.attr.state_pressed }, new ColorDrawable(resources.getColor(R.color.highlight)));
stateList.addState(new int[] { android.R.attr.state_focused }, new ColorDrawable(resources.getColor(R.color.highlight_focused)));
stateList.addState(new int[] { R.attr.state_private }, new ColorDrawable(resources.getColor(R.color.background_private))); stateList.addState(new int[] { R.attr.state_private }, new ColorDrawable(resources.getColor(R.color.background_private)));
stateList.addState(new int[] {}, drawable); stateList.addState(new int[] {}, drawable);

View File

@ -64,6 +64,7 @@ public class MenuButton extends ShapedButton {
Resources resources = getContext().getResources(); Resources resources = getContext().getResources();
StateListDrawable stateList = new StateListDrawable(); StateListDrawable stateList = new StateListDrawable();
stateList.addState(new int[] { android.R.attr.state_pressed }, new ColorDrawable(resources.getColor(R.color.highlight_dark))); stateList.addState(new int[] { android.R.attr.state_pressed }, new ColorDrawable(resources.getColor(R.color.highlight_dark)));
stateList.addState(new int[] { android.R.attr.state_focused }, new ColorDrawable(resources.getColor(R.color.highlight_dark_focused)));
stateList.addState(new int[] { R.attr.state_private }, new ColorDrawable(Color.BLACK)); stateList.addState(new int[] { R.attr.state_private }, new ColorDrawable(Color.BLACK));
stateList.addState(new int[] {}, drawable); stateList.addState(new int[] {}, drawable);

View File

@ -171,11 +171,13 @@ public class TabsButton extends ShapedButton {
Resources resources = this.getContext().getResources(); Resources resources = this.getContext().getResources();
StateListDrawable stateList1 = new StateListDrawable(); StateListDrawable stateList1 = new StateListDrawable();
stateList1.addState(new int[] { android.R.attr.state_pressed }, new ColorDrawable(resources.getColor(R.color.highlight_dark))); stateList1.addState(new int[] { android.R.attr.state_pressed }, new ColorDrawable(resources.getColor(R.color.highlight_dark)));
stateList1.addState(new int[] { android.R.attr.state_focused }, new ColorDrawable(resources.getColor(R.color.highlight_dark_focused)));
stateList1.addState(new int[] { R.attr.state_private }, new ColorDrawable(resources.getColor(R.color.background_tabs_light))); stateList1.addState(new int[] { R.attr.state_private }, new ColorDrawable(resources.getColor(R.color.background_tabs_light)));
stateList1.addState(new int[] {}, lightWeight1); stateList1.addState(new int[] {}, lightWeight1);
StateListDrawable stateList2 = new StateListDrawable(); StateListDrawable stateList2 = new StateListDrawable();
stateList2.addState(new int[] { android.R.attr.state_pressed }, new ColorDrawable(resources.getColor(R.color.highlight_dark))); stateList2.addState(new int[] { android.R.attr.state_pressed }, new ColorDrawable(resources.getColor(R.color.highlight_dark)));
stateList2.addState(new int[] { android.R.attr.state_focused }, new ColorDrawable(resources.getColor(R.color.highlight_dark_focused)));
stateList2.addState(new int[] { R.attr.state_private }, new ColorDrawable(resources.getColor(R.color.background_tabs_dark))); stateList2.addState(new int[] { R.attr.state_private }, new ColorDrawable(resources.getColor(R.color.background_tabs_dark)));
stateList2.addState(new int[] {}, lightWeight2); stateList2.addState(new int[] {}, lightWeight2);

View File

@ -12,6 +12,10 @@
<item android:state_pressed="true" <item android:state_pressed="true"
android:drawable="@color/highlight_dark"/> android:drawable="@color/highlight_dark"/>
<item android:state_focused="true"
android:state_pressed="false"
android:drawable="@color/highlight_dark_focused"/>
<item android:drawable="@color/background_tabs_light"/> <item android:drawable="@color/background_tabs_light"/>
</selector> </selector>
@ -25,6 +29,10 @@
<item android:state_pressed="true" <item android:state_pressed="true"
android:drawable="@color/highlight_dark"/> android:drawable="@color/highlight_dark"/>
<item android:state_focused="true"
android:state_pressed="false"
android:drawable="@color/highlight_dark_focused"/>
<item android:drawable="@color/background_tabs_dark"/> <item android:drawable="@color/background_tabs_dark"/>
</selector> </selector>

View File

@ -5,7 +5,13 @@
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="@color/highlight"/> <item android:state_pressed="true"
android:drawable="@color/highlight"/>
<item android:state_focused="true"
android:state_pressed="false"
android:drawable="@color/highlight_focused"/>
<item android:drawable="@android:color/transparent"/> <item android:drawable="@android:color/transparent"/>
</selector> </selector>

View File

@ -5,7 +5,13 @@
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="@color/highlight_dark"/> <item android:state_pressed="true"
android:drawable="@color/highlight_dark"/>
<item android:state_focused="true"
android:state_pressed="false"
android:drawable="@color/highlight_dark_focused"/>
<item android:drawable="@android:color/transparent"/> <item android:drawable="@android:color/transparent"/>
</selector> </selector>

View File

@ -6,10 +6,20 @@
<level-list xmlns:android="http://schemas.android.com/apk/res/android"> <level-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:maxLevel="1"> <item android:maxLevel="1">
<selector> <selector>
<item android:state_pressed="true" android:drawable="@color/highlight_dark"/>
<item android:state_pressed="true"
android:drawable="@color/highlight_dark"/>
<item android:state_focused="true"
android:state_pressed="false"
android:drawable="@color/highlight_dark_focused"/>
<item android:drawable="@android:color/black"/> <item android:drawable="@android:color/black"/>
</selector> </selector>
</item> </item>
<item android:maxLevel="2" android:drawable="@android:color/transparent"/> <item android:maxLevel="2" android:drawable="@android:color/transparent"/>

View File

@ -12,6 +12,10 @@
<item android:state_pressed="true" <item android:state_pressed="true"
android:drawable="@color/highlight_dark"/> android:drawable="@color/highlight_dark"/>
<item android:state_focused="true"
android:state_pressed="false"
android:drawable="@color/highlight_dark_focused"/>
<item android:drawable="@color/background_tabs_light"/> <item android:drawable="@color/background_tabs_light"/>
</selector> </selector>

View File

@ -8,7 +8,7 @@
<item android:state_focused="false" <item android:state_focused="false"
android:state_selected="false" android:state_selected="false"
android:state_pressed="false" android:state_pressed="false"
android:drawable="@color/tab_indicator_unselected"/> android:drawable="@android:color/transparent"/>
<item android:state_focused="false" <item android:state_focused="false"
android:state_selected="true" android:state_selected="true"
@ -18,7 +18,7 @@
<item android:state_focused="true" <item android:state_focused="true"
android:state_selected="false" android:state_selected="false"
android:state_pressed="false" android:state_pressed="false"
android:drawable="@color/tab_indicator_unselected_focused"/> android:drawable="@color/highlight_dark_focused"/>
<item android:state_focused="true" <item android:state_focused="true"
android:state_selected="true" android:state_selected="true"

View File

@ -9,7 +9,9 @@
<color name="background_tabs_dark">#FF363B40</color> <color name="background_tabs_dark">#FF363B40</color>
<color name="background_tabs_light">#FF43484E</color> <color name="background_tabs_light">#FF43484E</color>
<color name="highlight">#33000000</color> <color name="highlight">#33000000</color>
<color name="highlight_focused">#1A000000</color>
<color name="highlight_dark">#33FFFFFF</color> <color name="highlight_dark">#33FFFFFF</color>
<color name="highlight_dark_focused">#1AFFFFFF</color>
<color name="autocomplete_listitem_text">#000000</color> <color name="autocomplete_listitem_text">#000000</color>
<color name="splash_background">#000000</color> <color name="splash_background">#000000</color>
<color name="splash_msgfont">#ffffff</color> <color name="splash_msgfont">#ffffff</color>
@ -26,8 +28,6 @@
<color name="suggestion_pressed">#bbbbbb</color> <color name="suggestion_pressed">#bbbbbb</color>
<color name="abouthome_thumbnail_bg">#5FFF</color> <color name="abouthome_thumbnail_bg">#5FFF</color>
<color name="abouthome_topsite_shadow">#1000</color> <color name="abouthome_topsite_shadow">#1000</color>
<color name="tab_indicator_unselected">@android:color/transparent</color>
<color name="tab_indicator_unselected_focused">#34FF9500</color>
<color name="tab_row_pressed">#4D000000</color> <color name="tab_row_pressed">#4D000000</color>
<color name="abouthome_topsite_pin">#55000000</color> <color name="abouthome_topsite_pin">#55000000</color>
<color name="dialogtitle_textcolor">#ffffff</color> <color name="dialogtitle_textcolor">#ffffff</color>