Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: mobile/android/base/toolbar/ShapedButtonFrameLayout.java

Issue 29348083: Issue 3769 - UI colours gone bad (Closed)
Patch Set: Created July 21, 2016, 2:09 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* This Source Code Form is subject to the terms of the Mozilla Public 1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this file, 2 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
3 * You can obtain one at http://mozilla.org/MPL/2.0/. */ 3 * You can obtain one at http://mozilla.org/MPL/2.0/. */
4 4
5 package org.mozilla.gecko.toolbar; 5 package org.mozilla.gecko.toolbar;
6 6
7 import org.mozilla.gecko.R; 7 import org.mozilla.gecko.R;
8 import org.mozilla.gecko.lwt.LightweightThemeDrawable; 8 import org.mozilla.gecko.lwt.LightweightThemeDrawable;
9 import org.mozilla.gecko.util.ColorUtils; 9 import org.mozilla.gecko.util.ColorUtils;
10 import org.mozilla.gecko.widget.themed.ThemedFrameLayout; 10 import org.mozilla.gecko.widget.themed.ThemedFrameLayout;
11 11
12 import android.content.Context; 12 import android.content.Context;
13 import android.graphics.drawable.Drawable; 13 import android.graphics.drawable.Drawable;
14 import android.graphics.drawable.StateListDrawable; 14 import android.graphics.drawable.StateListDrawable;
15 import android.util.AttributeSet; 15 import android.util.AttributeSet;
16 16
17 /** A FrameLayout with lightweight theme support. Note that {@link ShapedButton} 's lwt support is basically the same so 17 /** A FrameLayout with lightweight theme support. Note that {@link ShapedButton} 's lwt support is basically the same so
18 * if you change it here, you should probably change it there. Note also that th is doesn't have ShapedButton's path code 18 * if you change it here, you should probably change it there. Note also that th is doesn't have ShapedButton's path code
19 * so shouldn't have "ShapedButton" in the name, but I wanted to make the connec tion apparent so I left it. 19 * so shouldn't have "ShapedButton" in the name, but I wanted to make the connec tion apparent so I left it.
20 */ 20 */
21 public class ShapedButtonFrameLayout extends ThemedFrameLayout { 21 public class ShapedButtonFrameLayout extends ThemedFrameLayout {
22 22
23 public ShapedButtonFrameLayout(Context context, AttributeSet attrs) { 23 public ShapedButtonFrameLayout(Context context, AttributeSet attrs) {
24 super(context, attrs); 24 super(context, attrs);
25 } 25 }
26 26
27 // The drawable is constructed as per @drawable/shaped_button. 27 // The drawable is constructed as per @drawable/shaped_button.
28 @Override 28 @Override
29 public void onLightweightThemeChanged() { 29 public void onLightweightThemeChanged() {
30 final int background = ColorUtils.getColor(getContext(), R.color.text_an d_tabs_tray_grey); 30 // Using ABB color palette. See https://issues.adblockplus.org/ticket/37 69
31 final int background = ColorUtils.getColor(getContext(), R.color.abb_bac kground_light_grey);
31 final LightweightThemeDrawable lightWeight = getTheme().getColorDrawable (this, background); 32 final LightweightThemeDrawable lightWeight = getTheme().getColorDrawable (this, background);
32 33
33 if (lightWeight == null) 34 if (lightWeight == null)
34 return; 35 return;
35 36
36 lightWeight.setAlpha(34, 34); 37 lightWeight.setAlpha(34, 34);
37 38
38 final StateListDrawable stateList = new StateListDrawable(); 39 final StateListDrawable stateList = new StateListDrawable();
39 stateList.addState(PRESSED_ENABLED_STATE_SET, getColorDrawable(R.color.h ighlight_shaped)); 40 stateList.addState(PRESSED_ENABLED_STATE_SET, getColorDrawable(R.color.h ighlight_shaped));
40 stateList.addState(FOCUSED_STATE_SET, getColorDrawable(R.color.highlight _shaped_focused)); 41 stateList.addState(FOCUSED_STATE_SET, getColorDrawable(R.color.highlight _shaped_focused));
41 stateList.addState(PRIVATE_STATE_SET, getColorDrawable(R.color.text_and_ tabs_tray_grey)); 42 // Using ABB color palette. See https://issues.adblockplus.org/ticket/37 69
43 stateList.addState(PRIVATE_STATE_SET, getColorDrawable(R.color.abb_backg round_light_grey));
42 stateList.addState(EMPTY_STATE_SET, lightWeight); 44 stateList.addState(EMPTY_STATE_SET, lightWeight);
43 45
44 setBackgroundDrawable(stateList); 46 setBackgroundDrawable(stateList);
45 } 47 }
46 48
47 @Override 49 @Override
48 public void onLightweightThemeReset() { 50 public void onLightweightThemeReset() {
49 setBackgroundResource(R.drawable.shaped_button); 51 setBackgroundResource(R.drawable.shaped_button);
50 } 52 }
51 53
(...skipping 13 matching lines...) Expand all
65 super.setBackgroundDrawable(drawable); 67 super.setBackgroundDrawable(drawable);
66 68
67 setPadding(padding[0], padding[1], padding[2], padding[3]); 69 setPadding(padding[0], padding[1], padding[2], padding[3]);
68 } 70 }
69 71
70 @Override 72 @Override
71 public void setBackgroundResource(int resId) { 73 public void setBackgroundResource(int resId) {
72 setBackgroundDrawable(getResources().getDrawable(resId)); 74 setBackgroundDrawable(getResources().getDrawable(resId));
73 } 75 }
74 } 76 }
OLDNEW

Powered by Google App Engine
This is Rietveld