зеркало из https://github.com/mozilla/gecko-dev.git
Bug 783092: Lightweight theme for tabs-tray. [r=mfinkle]
This commit is contained in:
Родитель
7c399a8d64
Коммит
178f70f70b
|
@ -8,9 +8,13 @@ package org.mozilla.gecko;
|
|||
import org.mozilla.gecko.sync.setup.SyncAccounts;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.LayerDrawable;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
@ -21,7 +25,8 @@ import android.widget.LinearLayout;
|
|||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class TabsPanel extends LinearLayout {
|
||||
public class TabsPanel extends LinearLayout
|
||||
implements LightweightTheme.OnChangeListener {
|
||||
private static final String LOGTAG = "GeckoTabsPanel";
|
||||
|
||||
public static enum Panel {
|
||||
|
@ -116,6 +121,41 @@ public class TabsPanel extends LinearLayout {
|
|||
Math.min(windowHeight - 2.5f * actionBarHeight, windowHeight * 0.8f) - actionBarHeight);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
mActivity.getLightweightTheme().addListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
mActivity.getLightweightTheme().removeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLightweightThemeChanged() {
|
||||
Drawable drawable = mActivity.getLightweightTheme().getDrawableWithAlpha(this, 255, 0);
|
||||
if (drawable == null)
|
||||
return;
|
||||
|
||||
drawable.setAlpha(30);
|
||||
|
||||
LayerDrawable layers = new LayerDrawable(new Drawable[] { mContext.getResources().getDrawable(R.drawable.tabs_tray_bg_repeat), drawable });
|
||||
setBackgroundDrawable(layers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLightweightThemeReset() {
|
||||
setBackgroundResource(R.drawable.tabs_tray_bg_repeat);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
||||
super.onLayout(changed, left, top, right, bottom);
|
||||
onLightweightThemeChanged();
|
||||
}
|
||||
|
||||
// Tabs List Container holds the ListView
|
||||
public static class TabsListContainer extends LinearLayout {
|
||||
private Context mContext;
|
||||
|
@ -177,12 +217,14 @@ public class TabsPanel extends LinearLayout {
|
|||
if (drawable == null)
|
||||
return;
|
||||
|
||||
setBackgroundDrawable(drawable);
|
||||
Resources resources = this.getContext().getResources();
|
||||
LayerDrawable layers = new LayerDrawable(new Drawable[] { resources.getDrawable(R.drawable.tabs_tray_bg_repeat), drawable });
|
||||
setBackgroundDrawable(layers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLightweightThemeReset() {
|
||||
setBackgroundResource(R.drawable.tabs_tray_bg_repeat);
|
||||
setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -6,6 +6,6 @@
|
|||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:state_pressed="true" android:drawable="@drawable/highlight"/>
|
||||
<item android:drawable="@drawable/tabs_tray_bg_repeat"/>
|
||||
<item android:drawable="@android:color/transparent"/>
|
||||
|
||||
</selector>
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
<ExpandableListView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/list"
|
||||
style="@style/TabsList"
|
||||
android:background="@android:color/transparent"
|
||||
android:childDivider="@drawable/tabs_tray_list_divider"
|
||||
android:dividerHeight="2dip"
|
||||
android:groupIndicator="@android:color/transparent"/>
|
||||
|
|
|
@ -8,8 +8,7 @@
|
|||
<view class="org.mozilla.gecko.TabsPanel$TabsPanelToolbar"
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="@dimen/browser_toolbar_height"
|
||||
android:background="@drawable/tabs_tray_bg_repeat"/>
|
||||
android:layout_height="@dimen/browser_toolbar_height"/>
|
||||
|
||||
<RelativeLayout android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent">
|
||||
|
@ -18,8 +17,7 @@
|
|||
android:id="@+id/list_container"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical"
|
||||
android:background="@drawable/tabs_tray_bg_repeat"/>
|
||||
android:orientation="vertical"/>
|
||||
|
||||
<View android:layout_width="fill_parent"
|
||||
android:layout_height="3dp"
|
||||
|
|
|
@ -6,5 +6,5 @@
|
|||
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/list"
|
||||
style="@style/TabsList"
|
||||
android:background="@drawable/tabs_tray_bg_repeat"
|
||||
android:background="@android:color/transparent"
|
||||
android:divider="@drawable/tabs_tray_list_divider"/>
|
||||
|
|
Загрузка…
Ссылка в новой задаче