зеркало из https://github.com/mozilla/gecko-dev.git
Bug 701982: AwesomeBar Tabs color mismatch [r=mfinkle]
This commit is contained in:
Родитель
b991b8fb2b
Коммит
10951abe26
|
@ -43,7 +43,6 @@ import android.content.res.Resources;
|
|||
import android.database.Cursor;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.LightingColorFilter;
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
@ -82,8 +81,6 @@ public class AwesomeBarTabs extends TabHost {
|
|||
|
||||
private static final String LOG_NAME = "AwesomeBarTabs";
|
||||
|
||||
private static final LightingColorFilter tabColorFilter;
|
||||
|
||||
private Context mContext;
|
||||
private OnUrlOpenListener mUrlOpenListener;
|
||||
|
||||
|
@ -91,48 +88,6 @@ public class AwesomeBarTabs extends TabHost {
|
|||
private SimpleCursorAdapter mBookmarksAdapter;
|
||||
private SimpleExpandableListAdapter mHistoryAdapter;
|
||||
|
||||
static {
|
||||
// We want to use the same color on the list items (in pressed state)
|
||||
// and the awesome screen tabs. This code is run only once to pick
|
||||
// the color of list view's pressed state.
|
||||
|
||||
Resources resources = GeckoApp.mAppContext.getResources();
|
||||
|
||||
// Load image resource that is used in list items in awesome screen
|
||||
Drawable listBackground =
|
||||
resources.getDrawable(android.R.drawable.list_selector_background);
|
||||
|
||||
// Set state of drawable to pressed state so that we can pick its
|
||||
// color to use in our tabs.
|
||||
listBackground.setState(new int[] { android.R.attr.state_pressed,
|
||||
android.R.attr.state_window_focused,
|
||||
android.R.attr.state_enabled });
|
||||
|
||||
// This number is arbitrary. We just need the image to
|
||||
// have some size for picking its color.
|
||||
int imageBounds = 40;
|
||||
|
||||
// Get currently used drawable (pressed state) and set bounds
|
||||
// to create a bitmap.
|
||||
Drawable current = listBackground.getCurrent();
|
||||
current.setBounds(0, 0, imageBounds, imageBounds);
|
||||
|
||||
Bitmap bitmap =
|
||||
Bitmap.createBitmap(imageBounds, imageBounds, Bitmap.Config.ARGB_8888);
|
||||
|
||||
// Draw the current drawable in the bitmap
|
||||
Canvas canvas = new Canvas(bitmap);
|
||||
current.draw(canvas);
|
||||
|
||||
// Pick color at central position
|
||||
int tabColor = bitmap.getPixel(imageBounds / 2, imageBounds / 2);
|
||||
|
||||
// Release bitmap to be garbage collected
|
||||
bitmap.recycle();
|
||||
|
||||
tabColorFilter = new LightingColorFilter(Color.WHITE, tabColor);
|
||||
}
|
||||
|
||||
// FIXME: This value should probably come from a
|
||||
// prefs key (just like XUL-based fennec)
|
||||
private static final int MAX_RESULTS = 100;
|
||||
|
@ -501,7 +456,7 @@ public class AwesomeBarTabs extends TabHost {
|
|||
|
||||
View indicatorView = inflater.inflate(R.layout.awesomebar_tab_indicator, null);
|
||||
Drawable background = indicatorView.getBackground();
|
||||
background.setColorFilter(tabColorFilter);
|
||||
background.setColorFilter(new LightingColorFilter(Color.WHITE, GeckoApp.mBrowserToolbar.getHighlightColor()));
|
||||
|
||||
TextView title = (TextView) indicatorView.findViewById(R.id.title);
|
||||
title.setText(titleId);
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
package org.mozilla.gecko;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.AnimationDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
@ -49,6 +50,7 @@ import android.os.Handler;
|
|||
import android.util.AttributeSet;
|
||||
import android.view.animation.TranslateAnimation;
|
||||
import android.view.Gravity;
|
||||
import android.view.ContextThemeWrapper;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
|
@ -67,6 +69,7 @@ public class BrowserToolbar extends LinearLayout {
|
|||
|
||||
final private Context mContext;
|
||||
final private Handler mHandler;
|
||||
final private int mColor;
|
||||
|
||||
final private TranslateAnimation mSlideUpIn;
|
||||
final private TranslateAnimation mSlideUpOut;
|
||||
|
@ -80,6 +83,11 @@ public class BrowserToolbar extends LinearLayout {
|
|||
|
||||
mContext = context;
|
||||
|
||||
// Get the device's highlight color
|
||||
ContextThemeWrapper wrapper = new ContextThemeWrapper(mContext, android.R.style.TextAppearance);
|
||||
TypedArray typedArray = wrapper.getTheme().obtainStyledAttributes(new int[] { android.R.attr.textColorHighlight });
|
||||
mColor = typedArray.getColor(typedArray.getIndex(0), 0);
|
||||
|
||||
// Load layout into the custom view
|
||||
LayoutInflater inflater =
|
||||
(LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
|
@ -144,6 +152,10 @@ public class BrowserToolbar extends LinearLayout {
|
|||
private void showTabs() {
|
||||
GeckoApp.mAppContext.showTabs();
|
||||
}
|
||||
|
||||
public int getHighlightColor() {
|
||||
return mColor;
|
||||
}
|
||||
|
||||
public void updateTabs(int count) {
|
||||
if (mCount > count) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче