Bug 1077755 - Change pressed/focused private browsing colors of new tablet menu items. r=lucasr
--- a/mobile/android/base/menu/MenuItemActionBar.java
+++ b/mobile/android/base/menu/MenuItemActionBar.java
@@ -1,23 +1,24 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.gecko.menu;
import org.mozilla.gecko.NewTabletUI;
import org.mozilla.gecko.R;
+import org.mozilla.gecko.widget.ThemedImageButton;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.widget.ImageButton;
-public class MenuItemActionBar extends ImageButton
+public class MenuItemActionBar extends ThemedImageButton
implements GeckoMenuItem.Layout {
private static final String LOGTAG = "GeckoMenuItemActionBar";
public MenuItemActionBar(Context context) {
this(context, null);
}
public MenuItemActionBar(Context context, AttributeSet attrs) {
--- a/mobile/android/base/newtablet/res/drawable-large-v11/new_tablet_action_bar_button.xml
+++ b/mobile/android/base/newtablet/res/drawable-large-v11/new_tablet_action_bar_button.xml
@@ -1,14 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
-<selector xmlns:android="http://schemas.android.com/apk/res/android">
+<selector xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:gecko="http://schemas.android.com/apk/res-auto">
+
+ <item gecko:state_private="true"
+ android:state_pressed="true"
+ android:state_enabled="true">
+
+ <inset android:insetTop="@dimen/new_tablet_browser_toolbar_menu_item_inset_vertical"
+ android:insetBottom="@dimen/new_tablet_browser_toolbar_menu_item_inset_vertical"
+ android:insetLeft="@dimen/new_tablet_browser_toolbar_menu_item_inset_horizontal"
+ android:insetRight="@dimen/new_tablet_browser_toolbar_menu_item_inset_horizontal">
+ <shape android:shape="rectangle">
+ <solid android:color="@color/new_tablet_highlight_pb"/>
+ <corners android:radius="@dimen/new_tablet_browser_toolbar_menu_item_corner_radius"/>
+ </shape>
+ </inset>
+
+ </item>
+
+ <item gecko:state_private="true"
+ android:state_focused="true"
+ android:state_pressed="false">
+
+ <inset android:insetTop="@dimen/new_tablet_browser_toolbar_menu_item_inset_vertical"
+ android:insetBottom="@dimen/new_tablet_browser_toolbar_menu_item_inset_vertical"
+ android:insetLeft="@dimen/new_tablet_browser_toolbar_menu_item_inset_horizontal"
+ android:insetRight="@dimen/new_tablet_browser_toolbar_menu_item_inset_horizontal">
+ <shape android:shape="rectangle">
+ <solid android:color="@color/new_tablet_highlight_focused_pb"/>
+ <corners android:radius="@dimen/new_tablet_browser_toolbar_menu_item_corner_radius"/>
+ </shape>
+ </inset>
+
+ </item>
<item android:state_pressed="true"
android:state_enabled="true">
<inset android:insetTop="@dimen/new_tablet_browser_toolbar_menu_item_inset_vertical"
android:insetBottom="@dimen/new_tablet_browser_toolbar_menu_item_inset_vertical"
android:insetLeft="@dimen/new_tablet_browser_toolbar_menu_item_inset_horizontal"
android:insetRight="@dimen/new_tablet_browser_toolbar_menu_item_inset_horizontal">
--- a/mobile/android/base/toolbar/BrowserToolbarTabletBase.java
+++ b/mobile/android/base/toolbar/BrowserToolbarTabletBase.java
@@ -5,16 +5,17 @@
package org.mozilla.gecko.toolbar;
import java.util.Arrays;
import org.mozilla.gecko.R;
import org.mozilla.gecko.Tab;
import org.mozilla.gecko.Tabs;
+import org.mozilla.gecko.menu.MenuItemActionBar;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.LinearLayout;
@@ -116,18 +117,23 @@ abstract class BrowserToolbarTabletBase
super.setNextFocusDownId(nextId);
backButton.setNextFocusDownId(nextId);
forwardButton.setNextFocusDownId(nextId);
}
@Override
public void setPrivateMode(final boolean isPrivate) {
super.setPrivateMode(isPrivate);
+
backButton.setPrivateMode(isPrivate);
forwardButton.setPrivateMode(isPrivate);
+ for (int i = 0; i < actionItemBar.getChildCount(); ++i) {
+ final MenuItemActionBar child = (MenuItemActionBar) actionItemBar.getChildAt(i);
+ child.setPrivateMode(isPrivate);
+ }
}
protected boolean canDoBack(final Tab tab) {
return (tab.canDoBack() && !isEditing());
}
protected boolean canDoForward(final Tab tab) {
return (tab.canDoForward() && !isEditing());
--- a/mobile/android/base/widget/ThemedEditText.java.in
+++ b/mobile/android/base/widget/ThemedEditText.java.in
@@ -1,4 +1,5 @@
#filter substitution
#define VIEW_NAME_SUFFIX EditText
#define BASE_TYPE android.widget.EditText
+#define STYLE_CONSTRUCTOR 1
#include ThemedView.java.frag
--- a/mobile/android/base/widget/ThemedImageButton.java.in
+++ b/mobile/android/base/widget/ThemedImageButton.java.in
@@ -1,4 +1,5 @@
#filter substitution
#define VIEW_NAME_SUFFIX ImageButton
#define BASE_TYPE android.widget.ImageButton
+#define STYLE_CONSTRUCTOR 1
#include ThemedView.java.frag
--- a/mobile/android/base/widget/ThemedImageView.java.in
+++ b/mobile/android/base/widget/ThemedImageView.java.in
@@ -1,4 +1,5 @@
#filter substitution
#define VIEW_NAME_SUFFIX ImageView
#define BASE_TYPE android.widget.ImageView
+#define STYLE_CONSTRUCTOR 1
#include ThemedView.java.frag
--- a/mobile/android/base/widget/ThemedRelativeLayout.java.in
+++ b/mobile/android/base/widget/ThemedRelativeLayout.java.in
@@ -1,4 +1,5 @@
#filter substitution
#define VIEW_NAME_SUFFIX RelativeLayout
#define BASE_TYPE android.widget.RelativeLayout
+#define STYLE_CONSTRUCTOR 1
#include ThemedView.java.frag
--- a/mobile/android/base/widget/ThemedTextView.java.in
+++ b/mobile/android/base/widget/ThemedTextView.java.in
@@ -1,4 +1,5 @@
#filter substitution
#define VIEW_NAME_SUFFIX TextView
#define BASE_TYPE android.widget.TextView
+#define STYLE_CONSTRUCTOR 1
#include ThemedView.java.frag
--- a/mobile/android/base/widget/ThemedView.java.frag
+++ b/mobile/android/base/widget/ThemedView.java.frag
@@ -26,17 +26,26 @@ public class Themed@VIEW_NAME_SUFFIX@ ex
protected static final int[] PRIVATE_STATE_SET = { R.attr.state_private };
private boolean mIsPrivate;
private boolean mIsLight;
private boolean mIsDark;
private boolean mAutoUpdateTheme = true;
public Themed@VIEW_NAME_SUFFIX@(Context context, AttributeSet attrs) {
+ this(context, attrs, 0);
+ }
+
+ public Themed@VIEW_NAME_SUFFIX@(Context context, AttributeSet attrs, int defStyle) {
+#ifdef STYLE_CONSTRUCTOR
+ super(context, attrs, defStyle);
+#else
super(context, attrs);
+#endif
+
mTheme = ((GeckoApplication) context.getApplicationContext()).getLightweightTheme();
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.LightweightTheme);
mAutoUpdateTheme = a.getBoolean(R.styleable.LightweightTheme_autoUpdateTheme, true);
a.recycle();
}
@Override
--- a/mobile/android/base/widget/ThemedView.java.in
+++ b/mobile/android/base/widget/ThemedView.java.in
@@ -1,4 +1,5 @@
#filter substitution
#define VIEW_NAME_SUFFIX View
#define BASE_TYPE android.view.View
+#define STYLE_CONSTRUCTOR 1
#include ThemedView.java.frag