Bug 1085771 - Part 3: Update LWT UI for new tablet browser toolbar. r=lucasr

This commit is contained in:
Michael Comella 2014-12-10 09:35:37 -08:00
parent 40a4768f10
commit 1801e8d094
6 changed files with 78 additions and 6 deletions

View File

@ -23,6 +23,14 @@
android:state_checked="true"
android:color="@color/new_tablet_highlight" />
<!-- Lightweight Themes -->
<item android:state_checked="true"
gecko:state_light="true"
android:color="@color/background_normal_lwt" />
<item android:state_checked="true"
gecko:state_dark="true"
android:color="@color/background_normal_lwt" />
<item android:state_checked="true"
android:color="@color/background_normal" />

View File

@ -5,7 +5,11 @@
<resources>
<color name="background_light">#FFF5F5F5</color>
<!-- If you update one, update the other. -->
<color name="background_normal">#FFEBEBF0</color>
<color name="background_normal_lwt">#DDEBEBF0</color>
<color name="background_private">#FF292C29</color>
<color name="background_tabs">#FF363B40</color>
<color name="highlight">#33000000</color>

View File

@ -6,6 +6,8 @@
package org.mozilla.gecko.tabs;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.StateListDrawable;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.LayoutInflater;
@ -128,4 +130,24 @@ public class TabStrip extends ThemedLinearLayout {
}
}
}
@Override
public void onLightweightThemeChanged() {
final Drawable drawable = getTheme().getDrawable(this);
if (drawable == null) {
return;
}
final StateListDrawable stateList = new StateListDrawable();
stateList.addState(PRIVATE_STATE_SET, getColorDrawable(R.color.background_tabs));
stateList.addState(EMPTY_STATE_SET, drawable);
setBackgroundDrawable(stateList);
}
@Override
public void onLightweightThemeReset() {
final int defaultBackgroundColor = getResources().getColor(R.color.background_tabs);
setBackgroundColor(defaultBackgroundColor);
}
}

View File

@ -9,7 +9,6 @@ import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import org.json.JSONObject;
import org.mozilla.gecko.AppConstants.Versions;
import org.mozilla.gecko.BrowserApp;
import org.mozilla.gecko.GeckoAppShell;
@ -24,6 +23,7 @@ import org.mozilla.gecko.animation.PropertyAnimator;
import org.mozilla.gecko.animation.PropertyAnimator.PropertyAnimationListener;
import org.mozilla.gecko.animation.ViewHelper;
import org.mozilla.gecko.lwt.LightweightTheme;
import org.mozilla.gecko.lwt.LightweightThemeDrawable;
import org.mozilla.gecko.menu.GeckoMenu;
import org.mozilla.gecko.menu.MenuPopup;
import org.mozilla.gecko.tabs.TabHistoryController;
@ -78,6 +78,8 @@ public abstract class BrowserToolbar extends ThemedRelativeLayout
GeckoMenu.ActionItemBarPresenter {
private static final String LOGTAG = "GeckoToolbar";
private static final int LIGHTWEIGHT_THEME_INVERT_ALPHA = 34; // 255 - alpha = invert_alpha
public interface OnActivateListener {
public void onActivate();
}
@ -151,6 +153,13 @@ public abstract class BrowserToolbar extends ThemedRelativeLayout
protected abstract void triggerStopEditingTransition();
public abstract void triggerTabsPanelTransition(PropertyAnimator animator, boolean areTabsShown);
/**
* Returns a Drawable overlaid with the theme's bitmap.
*/
protected Drawable getLWTDefaultStateSetDrawable() {
return getTheme().getDrawable(this);
}
public static BrowserToolbar create(final Context context, final AttributeSet attrs) {
final BrowserToolbar toolbar;
if (NewTabletUI.isEnabled(context)) {
@ -910,11 +919,12 @@ public abstract class BrowserToolbar extends ThemedRelativeLayout
@Override
public void onLightweightThemeChanged() {
Drawable drawable = theme.getDrawable(this);
if (drawable == null)
final Drawable drawable = getLWTDefaultStateSetDrawable();
if (drawable == null) {
return;
}
StateListDrawable stateList = new StateListDrawable();
final StateListDrawable stateList = new StateListDrawable();
stateList.addState(PRIVATE_STATE_SET, getColorDrawable(R.color.background_private));
stateList.addState(EMPTY_STATE_SET, drawable);
@ -929,6 +939,18 @@ public abstract class BrowserToolbar extends ThemedRelativeLayout
editCancel.onLightweightThemeReset();
}
public static LightweightThemeDrawable getLightweightThemeDrawable(final View view,
final Resources res, final LightweightTheme theme, final int colorResID) {
final int color = res.getColor(colorResID);
final LightweightThemeDrawable drawable = theme.getColorDrawable(view, color);
if (drawable != null) {
drawable.setAlpha(LIGHTWEIGHT_THEME_INVERT_ALPHA, LIGHTWEIGHT_THEME_INVERT_ALPHA);
}
return drawable;
}
public static class TabEditingState {
// The edited text from the most recent time this tab was unselected.
protected String lastEditingText;

View File

@ -11,6 +11,7 @@ import org.mozilla.gecko.animation.ViewHelper;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
/**
@ -204,4 +205,10 @@ class BrowserToolbarNewTablet extends BrowserToolbarTabletBase {
// forward button is set to the proper value.
setButtonEnabled(forwardButton, true);
}
@Override
protected Drawable getLWTDefaultStateSetDrawable() {
return BrowserToolbar.getLightweightThemeDrawable(this, getResources(), getTheme(),
R.color.background_normal);
}
}

View File

@ -4,6 +4,7 @@
package org.mozilla.gecko.toolbar;
import org.mozilla.gecko.NewTabletUI;
import org.mozilla.gecko.R;
import android.content.Context;
@ -60,9 +61,17 @@ abstract class NavButton extends ShapedButton {
// The drawable is constructed as per @drawable/url_bar_nav_button.
@Override
public void onLightweightThemeChanged() {
final Drawable drawable = mTheme.getDrawable(this);
if (drawable == null)
final Drawable drawable;
if (!NewTabletUI.isEnabled(getContext())) {
drawable = mTheme.getDrawable(this);
} else {
drawable = BrowserToolbar.getLightweightThemeDrawable(this, getResources(), getTheme(),
R.color.background_normal);
}
if (drawable == null) {
return;
}
final StateListDrawable stateList = new StateListDrawable();
stateList.addState(PRIVATE_PRESSED_STATE_SET, getColorDrawable(R.color.highlight_nav_pb));