Commit cf09bfbc authored by Aurimas Liutikas's avatar Aurimas Liutikas

Switch to using TintedImageButton where possible.

BUG=427719
R=dtrainor@chromium.org

Review URL: https://codereview.chromium.org/690123002

Cr-Commit-Position: refs/heads/master@{#302680}
parent 04a9350d
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2014 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false" android:drawable="@drawable/btn_menu_disabled" />
<item android:state_pressed="true" android:drawable="@drawable/btn_menu_pressed" />
<item android:state_selected="true" android:drawable="@drawable/btn_menu_pressed" />
<item android:state_focused="true" android:drawable="@drawable/btn_menu_pressed" />
<item android:drawable="@drawable/btn_menu_normal" />
</selector>
\ No newline at end of file
<item android:color="@color/default_active_button_color"/>
</selector>
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2014 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false" android:drawable="@drawable/btn_back_disabled" />
<item android:state_pressed="true" android:drawable="@drawable/btn_back_pressed" />
<item android:state_selected="true" android:drawable="@drawable/btn_back_pressed" />
<item android:state_focused="true" android:drawable="@drawable/btn_back_pressed" />
<item android:drawable="@drawable/btn_back_normal" />
</selector>
\ No newline at end of file
<item android:state_selected="true" android:color="#80FFFFFF" />
<item android:state_focused="true" android:color="#80FFFFFF" />
<item android:state_pressed="true" android:color="#80FFFFFF" />
<item android:state_enabled="false" android:color="#33FFFFFF" />
<item android:color="#FFFFFF"/>
</selector>
......@@ -4,9 +4,9 @@
found in the LICENSE file.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="true" android:color="#4285F4" />
<item android:state_focused="true" android:color="#4285F4" />
<item android:state_pressed="true" android:color="#4285F4" />
<item android:state_enabled="false" android:color="#515a5a5a" />
<item android:color="#5a5a5a"/>
</selector>
\ No newline at end of file
<item android:state_selected="true" android:color="@color/default_active_button_color" />
<item android:state_focused="true" android:color="@color/default_active_button_color" />
<item android:state_pressed="true" android:color="@color/default_active_button_color" />
<item android:state_enabled="false" android:color="#335a5a5a" />
<item android:color="@color/default_normal_button_color"/>
</selector>
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2014 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false" android:drawable="@drawable/btn_forward_disabled" />
<item android:state_pressed="true" android:drawable="@drawable/btn_forward_pressed" />
<item android:state_selected="true" android:drawable="@drawable/btn_forward_pressed" />
<item android:state_focused="true" android:drawable="@drawable/btn_forward_pressed" />
<item android:drawable="@drawable/btn_forward_normal" />
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2014 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false" android:drawable="@drawable/btn_back_disabled" />
<item android:state_pressed="true" android:drawable="@drawable/btn_back_pressed" />
<item android:state_selected="true" android:drawable="@drawable/btn_back_pressed" />
<item android:state_focused="true" android:drawable="@drawable/btn_back_pressed" />
<item android:drawable="@drawable/btn_back_normal" />
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2014 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false" android:drawable="@drawable/btn_forward_disabled" />
<item android:state_pressed="true" android:drawable="@drawable/btn_forward_pressed" />
<item android:state_selected="true" android:drawable="@drawable/btn_forward_pressed" />
<item android:state_focused="true" android:drawable="@drawable/btn_forward_pressed" />
<item android:drawable="@drawable/btn_forward_normal" />
</selector>
\ No newline at end of file
......@@ -10,7 +10,7 @@
android:layout_gravity="top|start"
android:orientation="horizontal">
<ImageButton
<org.chromium.chrome.browser.widget.TintedImageButton
android:id="@+id/button_one"
android:layout_width="59dp"
android:layout_height="match_parent"
......@@ -18,7 +18,7 @@
android:background="?android:attr/listChoiceBackgroundIndicator"
android:scaleType="center" />
<ImageButton
<org.chromium.chrome.browser.widget.TintedImageButton
android:id="@+id/button_two"
android:layout_width="70dp"
android:layout_height="match_parent"
......@@ -27,7 +27,7 @@
android:background="?android:attr/listChoiceBackgroundIndicator"
android:scaleType="center" />
<ImageButton
<org.chromium.chrome.browser.widget.TintedImageButton
android:id="@+id/button_three"
android:layout_width="70dp"
android:layout_height="match_parent"
......@@ -36,7 +36,7 @@
android:background="?android:attr/listChoiceBackgroundIndicator"
android:scaleType="center" />
<ImageButton
<org.chromium.chrome.browser.widget.TintedImageButton
android:id="@+id/button_four"
android:layout_width="59dp"
android:layout_height="match_parent"
......
......@@ -10,7 +10,7 @@
android:layout_gravity="top|start"
android:orientation="horizontal">
<ImageButton
<org.chromium.chrome.browser.widget.TintedImageButton
android:id="@+id/button_one"
android:layout_width="0dp"
android:layout_height="match_parent"
......@@ -18,7 +18,7 @@
android:background="?android:attr/listChoiceBackgroundIndicator"
android:scaleType="center" />
<ImageButton
<org.chromium.chrome.browser.widget.TintedImageButton
android:id="@+id/button_two"
android:layout_width="0dp"
android:layout_height="match_parent"
......@@ -26,7 +26,7 @@
android:background="?android:attr/listChoiceBackgroundIndicator"
android:scaleType="center" />
<ImageButton
<org.chromium.chrome.browser.widget.TintedImageButton
android:id="@+id/button_three"
android:layout_width="0dp"
android:layout_height="match_parent"
......
......@@ -20,7 +20,7 @@
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceLargePopupMenu" />
<ImageButton
<org.chromium.chrome.browser.widget.TintedImageButton
android:id="@+id/button"
android:layout_width="56dp"
android:layout_height="match_parent"
......
......@@ -10,7 +10,7 @@
android:layout_gravity="top|start"
android:orientation="horizontal">
<ImageButton
<org.chromium.chrome.browser.widget.TintedImageButton
android:id="@+id/button_one"
android:layout_width="0dp"
android:layout_height="match_parent"
......@@ -18,7 +18,7 @@
android:background="?android:attr/listChoiceBackgroundIndicator"
android:scaleType="center" />
<ImageButton
<org.chromium.chrome.browser.widget.TintedImageButton
android:id="@+id/button_two"
android:layout_width="0dp"
android:layout_height="match_parent"
......
......@@ -7,6 +7,8 @@
<resources>
<!-- Common colors -->
<color name="default_text_color">#333</color>
<color name="default_normal_button_color">#5A5A5A</color>
<color name="default_active_button_color">#4285F4</color>
<!-- Infobar colors -->
<color name="infobar_background">#fff</color>
......
......@@ -24,6 +24,7 @@ import android.widget.TextView;
import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.widget.TintedImageButton;
import org.chromium.ui.base.LocalizationUtils;
import org.chromium.ui.interpolators.BakedBezierInterpolator;
......@@ -183,8 +184,10 @@ class AppMenuAdapter extends BaseAdapter {
if (convertView == null) {
holder = new TwoButtonMenuItemViewHolder();
convertView = mInflater.inflate(R.layout.two_button_menu_item, parent, false);
holder.buttons[0] = (ImageButton) convertView.findViewById(R.id.button_one);
holder.buttons[1] = (ImageButton) convertView.findViewById(R.id.button_two);
holder.buttons[0] =
(TintedImageButton) convertView.findViewById(R.id.button_one);
holder.buttons[1] =
(TintedImageButton) convertView.findViewById(R.id.button_two);
convertView.setTag(holder);
convertView.setTag(R.id.menu_item_enter_anim_id,
buildIconItemEnterAnimator(holder.buttons, hasMenuButton));
......@@ -207,9 +210,12 @@ class AppMenuAdapter extends BaseAdapter {
if (convertView == null) {
holder = new ThreeButtonMenuItemViewHolder();
convertView = mInflater.inflate(R.layout.three_button_menu_item, parent, false);
holder.buttons[0] = (ImageButton) convertView.findViewById(R.id.button_one);
holder.buttons[1] = (ImageButton) convertView.findViewById(R.id.button_two);
holder.buttons[2] = (ImageButton) convertView.findViewById(R.id.button_three);
holder.buttons[0] =
(TintedImageButton) convertView.findViewById(R.id.button_one);
holder.buttons[1] =
(TintedImageButton) convertView.findViewById(R.id.button_two);
holder.buttons[2] =
(TintedImageButton) convertView.findViewById(R.id.button_three);
convertView.setTag(holder);
convertView.setTag(R.id.menu_item_enter_anim_id,
buildIconItemEnterAnimator(holder.buttons, hasMenuButton));
......@@ -233,10 +239,14 @@ class AppMenuAdapter extends BaseAdapter {
if (convertView == null) {
holder = new FourButtonMenuItemViewHolder();
convertView = mInflater.inflate(R.layout.four_button_menu_item, parent, false);
holder.buttons[0] = (ImageButton) convertView.findViewById(R.id.button_one);
holder.buttons[1] = (ImageButton) convertView.findViewById(R.id.button_two);
holder.buttons[2] = (ImageButton) convertView.findViewById(R.id.button_three);
holder.buttons[3] = (ImageButton) convertView.findViewById(R.id.button_four);
holder.buttons[0] =
(TintedImageButton) convertView.findViewById(R.id.button_one);
holder.buttons[1] =
(TintedImageButton) convertView.findViewById(R.id.button_two);
holder.buttons[2] =
(TintedImageButton) convertView.findViewById(R.id.button_three);
holder.buttons[3] =
(TintedImageButton) convertView.findViewById(R.id.button_four);
convertView.setTag(holder);
convertView.setTag(R.id.menu_item_enter_anim_id,
buildIconItemEnterAnimator(holder.buttons, hasMenuButton));
......@@ -263,7 +273,7 @@ class AppMenuAdapter extends BaseAdapter {
holder = new TitleButtonMenuItemViewHolder();
convertView = mInflater.inflate(R.layout.title_button_menu_item, parent, false);
holder.title = (TextView) convertView.findViewById(R.id.title);
holder.button = (ImageButton) convertView.findViewById(R.id.button);
holder.button = (TintedImageButton) convertView.findViewById(R.id.button);
View animatedView = hasMenuButton ? holder.title : convertView;
......@@ -321,8 +331,9 @@ class AppMenuAdapter extends BaseAdapter {
});
}
private void setupMenuButton(ImageButton button) {
button.setImageResource(R.drawable.btn_menu_pressed);
private void setupMenuButton(TintedImageButton button) {
button.setImageResource(R.drawable.btn_menu);
button.setTint(button.getResources().getColorStateList(R.color.button_tint_menu));
button.setContentDescription(button.getResources().getString(R.string.menu_dismiss_btn));
button.setEnabled(true);
button.setFocusable(true);
......@@ -422,19 +433,19 @@ class AppMenuAdapter extends BaseAdapter {
}
static class TwoButtonMenuItemViewHolder {
public ImageButton[] buttons = new ImageButton[2];
public TintedImageButton[] buttons = new TintedImageButton[2];
}
static class ThreeButtonMenuItemViewHolder {
public ImageButton[] buttons = new ImageButton[3];
public TintedImageButton[] buttons = new TintedImageButton[3];
}
static class FourButtonMenuItemViewHolder {
public ImageButton[] buttons = new ImageButton[4];
public TintedImageButton[] buttons = new TintedImageButton[4];
}
static class TitleButtonMenuItemViewHolder {
public TextView title;
public ImageButton button;
public TintedImageButton button;
}
}
\ No newline at end of file
......@@ -68,7 +68,6 @@ public class TintedImageButton extends ImageButton {
private void setTintInternal(ColorStateList tint) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
setImageTintList(tint);
setImageTintMode(PorterDuff.Mode.SRC_ATOP);
} else {
mTint = tint;
}
......@@ -76,6 +75,6 @@ public class TintedImageButton extends ImageButton {
private void updateTintColor() {
if (mTint == null || !mTint.isStateful()) return;
setColorFilter(mTint.getColorForState(getDrawableState(), 0));
setColorFilter(mTint.getColorForState(getDrawableState(), 0), PorterDuff.Mode.SRC_IN);
}
}
......@@ -48,7 +48,7 @@
android:id="@+id/menu_button"
android:layout_width="38dp"
android:layout_height="38dp"
android:src="@drawable/btn_menu_white_normal"
android:src="@drawable/btn_menu"
android:background="?android:attr/selectableItemBackground"
android:scaleType="center"/>
</org.chromium.chrome.shell.ChromeShellToolbar>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment