mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-01 06:35:42 +00:00
Bug 822421: Lightweight theme based text colors on about:home. [r=mfinkle]
This commit is contained in:
parent
d87a6a4688
commit
526aa978fd
@ -689,11 +689,21 @@ public class AboutHomeContent extends ScrollView
|
||||
|
||||
drawable.setAlpha(255, 0);
|
||||
setBackgroundDrawable(drawable);
|
||||
|
||||
boolean isLight = mActivity.getLightweightTheme().isLightTheme();
|
||||
mAddons.setTheme(isLight);
|
||||
mLastTabs.setTheme(isLight);
|
||||
mRemoteTabs.setTheme(isLight);
|
||||
((GeckoTextView) findViewById(R.id.top_sites_title)).setTheme(isLight);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLightweightThemeReset() {
|
||||
setBackgroundResource(R.drawable.abouthome_bg_repeat);
|
||||
mAddons.resetTheme();
|
||||
mLastTabs.resetTheme();
|
||||
mRemoteTabs.resetTheme();
|
||||
((GeckoTextView) findViewById(R.id.top_sites_title)).resetTheme();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -13,7 +13,7 @@ import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class AboutHomeSection extends LinearLayout {
|
||||
public class AboutHomeSection extends GeckoLinearLayout {
|
||||
private static final String LOGTAG = "GeckoAboutHomeSection";
|
||||
|
||||
private TextView mTitle;
|
||||
|
@ -10,8 +10,12 @@ import android.widget.@VIEWTYPE@;
|
||||
|
||||
public class Gecko@VIEWTYPE@ extends @VIEWTYPE@ {
|
||||
private static final int[] STATE_PRIVATE_MODE = { R.attr.state_private };
|
||||
private static final int[] STATE_LIGHT = { R.attr.state_light };
|
||||
private static final int[] STATE_DARK = { R.attr.state_dark };
|
||||
|
||||
private boolean mIsPrivate = false;
|
||||
private boolean mIsLight = false;
|
||||
private boolean mIsDark = false;
|
||||
|
||||
public Gecko@VIEWTYPE@(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
@ -23,6 +27,10 @@ public class Gecko@VIEWTYPE@ extends @VIEWTYPE@ {
|
||||
|
||||
if (mIsPrivate)
|
||||
mergeDrawableStates(drawableState, STATE_PRIVATE_MODE);
|
||||
else if (mIsLight)
|
||||
mergeDrawableStates(drawableState, STATE_LIGHT);
|
||||
else if (mIsDark)
|
||||
mergeDrawableStates(drawableState, STATE_DARK);
|
||||
|
||||
return drawableState;
|
||||
}
|
||||
@ -36,5 +44,29 @@ public class Gecko@VIEWTYPE@ extends @VIEWTYPE@ {
|
||||
mIsPrivate = isPrivate;
|
||||
refreshDrawableState();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setTheme(boolean isLight) {
|
||||
// Set the theme only if it is different from existing theme.
|
||||
if ((isLight && mIsLight != isLight) ||
|
||||
(!isLight && mIsDark == isLight)) {
|
||||
if (isLight) {
|
||||
mIsLight = true;
|
||||
mIsDark = false;
|
||||
} else {
|
||||
mIsLight = false;
|
||||
mIsDark = true;
|
||||
}
|
||||
|
||||
refreshDrawableState();
|
||||
}
|
||||
}
|
||||
|
||||
public void resetTheme() {
|
||||
if (mIsLight || mIsDark) {
|
||||
mIsLight = false;
|
||||
mIsDark = false;
|
||||
refreshDrawableState();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -42,6 +42,7 @@ public class LightweightTheme implements GeckoEventListener {
|
||||
private Application mApplication;
|
||||
private Bitmap mBitmap;
|
||||
private int mColor;
|
||||
private boolean mIsLight;
|
||||
|
||||
public static interface OnChangeListener {
|
||||
// This is the View's default post.
|
||||
@ -98,6 +99,11 @@ public class LightweightTheme implements GeckoEventListener {
|
||||
maxWidth, height);
|
||||
mColor = BitmapUtils.getDominantColor(cropped, false);
|
||||
|
||||
double luminance = (0.2125 * ((mColor & 0x00FF0000) >> 16)) +
|
||||
(0.7154 * ((mColor & 0x0000FF00) >> 8)) +
|
||||
(0.0721 * (mColor &0x000000FF));
|
||||
mIsLight = (luminance > 110) ? true : false;
|
||||
|
||||
notifyListeners();
|
||||
} catch(java.net.MalformedURLException e) {
|
||||
mBitmap = null;
|
||||
@ -156,6 +162,10 @@ public class LightweightTheme implements GeckoEventListener {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isLightTheme() {
|
||||
return mIsLight;
|
||||
}
|
||||
|
||||
/**
|
||||
* Crop the image based on the position of the view on the window.
|
||||
* Either the View or one of its ancestors might have scrolled or translated.
|
||||
|
@ -227,6 +227,9 @@ FENNEC_PP_JAVA_FILES = \
|
||||
$(NULL)
|
||||
|
||||
FENNEC_PP_XML_FILES = \
|
||||
res/color/abouthome_section_more_text.xml \
|
||||
res/color/abouthome_section_subtitle.xml \
|
||||
res/color/abouthome_section_title.xml \
|
||||
res/color/awesome_bar_title.xml \
|
||||
res/color/awesome_bar_title_hint.xml \
|
||||
res/drawable/address_bar_bg.xml \
|
||||
|
@ -0,0 +1,19 @@
|
||||
#filter substitution
|
||||
<?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"
|
||||
xmlns:gecko="http://schemas.android.com/apk/res/@ANDROID_PACKAGE_NAME@">
|
||||
|
||||
<!-- dark theme -->
|
||||
<item gecko:state_dark="true" android:color="#80FFFFFF" />
|
||||
|
||||
<!-- light theme -->
|
||||
<item gecko:state_light="true" android:color="#80222222" />
|
||||
|
||||
<!-- default -->
|
||||
<item android:color="#FF22629E"/>
|
||||
|
||||
</selector>
|
@ -0,0 +1,19 @@
|
||||
#filter substitution
|
||||
<?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"
|
||||
xmlns:gecko="http://schemas.android.com/apk/res/@ANDROID_PACKAGE_NAME@">
|
||||
|
||||
<!-- dark theme -->
|
||||
<item gecko:state_dark="true" android:color="#CCFFFFFF" />
|
||||
|
||||
<!-- light theme -->
|
||||
<item gecko:state_light="true" android:color="#CC222222" />
|
||||
|
||||
<!-- default -->
|
||||
<item android:color="#FF666666"/>
|
||||
|
||||
</selector>
|
@ -0,0 +1,19 @@
|
||||
#filter substitution
|
||||
<?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"
|
||||
xmlns:gecko="http://schemas.android.com/apk/res/@ANDROID_PACKAGE_NAME@">
|
||||
|
||||
<!-- dark theme -->
|
||||
<item gecko:state_dark="true" android:color="#FFFFFFFF" />
|
||||
|
||||
<!-- light theme -->
|
||||
<item gecko:state_light="true" android:color="#FF222222" />
|
||||
|
||||
<!-- default -->
|
||||
<item android:color="#FF000000"/>
|
||||
|
||||
</selector>
|
@ -25,16 +25,16 @@
|
||||
android:layout_marginBottom="10dip"
|
||||
android:layout_marginLeft="12dip"/>
|
||||
|
||||
<TextView android:id="@+id/top_sites_title"
|
||||
android:text="@string/abouthome_top_sites_title"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="26dip"
|
||||
android:background="#34FFFFFF"
|
||||
android:paddingLeft="12dip"
|
||||
android:textSize="12sp"
|
||||
android:textColor="#000000"
|
||||
android:textStyle="bold"
|
||||
android:gravity="left|center_vertical"/>
|
||||
<Gecko.TextView android:id="@+id/top_sites_title"
|
||||
android:text="@string/abouthome_top_sites_title"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="26dip"
|
||||
android:background="#34FFFFFF"
|
||||
android:paddingLeft="12dip"
|
||||
android:textSize="12sp"
|
||||
android:textColor="@color/abouthome_section_title"
|
||||
android:textStyle="bold"
|
||||
android:gravity="left|center_vertical"/>
|
||||
|
||||
<view class="org.mozilla.gecko.AboutHomeContent$TopSitesGridView"
|
||||
android:id="@+id/top_sites_grid"
|
||||
|
@ -7,7 +7,8 @@
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="47dip"
|
||||
android:gravity="left|center_vertical"
|
||||
android:background="@drawable/action_bar_button">
|
||||
android:background="@drawable/action_bar_button"
|
||||
android:duplicateParentState="true">
|
||||
|
||||
<ImageView android:id="@+id/addon_icon"
|
||||
android:layout_width="32dp"
|
||||
@ -23,7 +24,8 @@
|
||||
android:layout_marginLeft="12dip"
|
||||
android:gravity="center_vertical"
|
||||
android:textSize="15sp"
|
||||
android:textColor="#222222"/>
|
||||
android:textColor="@color/abouthome_section_title"
|
||||
android:duplicateParentState="true"/>
|
||||
|
||||
<TextView android:id="@+id/addon_version"
|
||||
android:layout_width="wrap_content"
|
||||
@ -33,7 +35,8 @@
|
||||
android:layout_marginLeft="5dip"
|
||||
android:gravity="center_vertical"
|
||||
android:textSize="12sp"
|
||||
android:textColor="#666666"/>
|
||||
android:textColor="@color/abouthome_section_subtitle"
|
||||
android:duplicateParentState="true"/>
|
||||
|
||||
<View android:layout_width="fill_parent"
|
||||
android:layout_height="1dp"
|
||||
|
@ -22,17 +22,17 @@
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentLeft="true"/>
|
||||
|
||||
<TextView android:id="@+id/top_sites_title"
|
||||
android:text="@string/abouthome_top_sites_title"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="26dip"
|
||||
android:background="#34FFFFFF"
|
||||
android:paddingLeft="12dip"
|
||||
android:textSize="12sp"
|
||||
android:textColor="#000000"
|
||||
android:textStyle="bold"
|
||||
android:gravity="left|center_vertical"
|
||||
android:layout_below="@id/abouthome_logo"/>
|
||||
<Gecko.TextView android:id="@+id/top_sites_title"
|
||||
android:text="@string/abouthome_top_sites_title"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="26dip"
|
||||
android:background="#34FFFFFF"
|
||||
android:paddingLeft="12dip"
|
||||
android:textSize="12sp"
|
||||
android:textColor="@color/abouthome_section_title"
|
||||
android:textStyle="bold"
|
||||
android:gravity="left|center_vertical"
|
||||
android:layout_below="@id/abouthome_logo"/>
|
||||
|
||||
<ImageView android:src="@drawable/abouthome_icon"
|
||||
android:layout_width="180dp"
|
||||
|
@ -8,7 +8,8 @@
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="47dip"
|
||||
android:gravity="left|center_vertical"
|
||||
android:background="@drawable/action_bar_button">
|
||||
android:background="@drawable/action_bar_button"
|
||||
android:duplicateParentState="true">
|
||||
|
||||
<ImageView android:id="@+id/last_tab_favicon"
|
||||
android:layout_width="32dip"
|
||||
@ -26,7 +27,8 @@
|
||||
android:layout_marginRight="12dip"
|
||||
android:textSize="15sp"
|
||||
android:singleLine="true"
|
||||
android:textColor="#222222"/>
|
||||
android:textColor="@color/abouthome_section_title"
|
||||
android:duplicateParentState="true"/>
|
||||
|
||||
<TextView android:id="@+id/last_tab_url"
|
||||
android:layout_width="wrap_content"
|
||||
@ -37,7 +39,8 @@
|
||||
android:layout_below="@id/last_tab_title"
|
||||
android:textSize="12sp"
|
||||
android:singleLine="true"
|
||||
android:textColor="#666666"/>
|
||||
android:textColor="@color/abouthome_section_subtitle"
|
||||
android:duplicateParentState="true"/>
|
||||
|
||||
<View android:layout_width="fill_parent"
|
||||
android:layout_height="1dp"
|
||||
|
@ -7,7 +7,8 @@
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="47dip"
|
||||
android:orientation="vertical"
|
||||
android:background="@drawable/action_bar_button">
|
||||
android:background="@drawable/action_bar_button"
|
||||
android:duplicateParentState="true">
|
||||
|
||||
<TextView android:id="@+id/remote_tab_title"
|
||||
android:layout_width="fill_parent"
|
||||
@ -16,9 +17,10 @@
|
||||
android:paddingRight="12dip"
|
||||
android:gravity="center_vertical"
|
||||
android:textSize="15sp"
|
||||
android:textColor="#222222"
|
||||
android:singleLine="true"
|
||||
android:ellipsize="middle"/>
|
||||
android:ellipsize="middle"
|
||||
android:textColor="@color/abouthome_section_title"
|
||||
android:duplicateParentState="true"/>
|
||||
|
||||
<View android:layout_width="fill_parent"
|
||||
android:layout_height="1dp"
|
||||
|
@ -11,9 +11,10 @@
|
||||
android:background="#34FFFFFF"
|
||||
android:paddingLeft="12dip"
|
||||
android:textSize="12sp"
|
||||
android:textColor="#000000"
|
||||
android:textColor="@color/abouthome_section_title"
|
||||
android:textStyle="bold"
|
||||
android:gravity="left|center_vertical"/>
|
||||
android:gravity="left|center_vertical"
|
||||
android:duplicateParentState="true"/>
|
||||
|
||||
<TextView android:id="@+id/subtitle"
|
||||
android:layout_width="fill_parent"
|
||||
@ -22,20 +23,23 @@
|
||||
android:background="#34FFFFFF"
|
||||
android:paddingLeft="12dip"
|
||||
android:textSize="12sp"
|
||||
android:textColor="#666666"
|
||||
android:gravity="left|center_vertical"/>
|
||||
android:textColor="@color/abouthome_section_subtitle"
|
||||
android:gravity="left|center_vertical"
|
||||
android:duplicateParentState="true"/>
|
||||
|
||||
<LinearLayout android:id="@+id/items_container"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:isScrollContainer="false"/>
|
||||
android:isScrollContainer="false"
|
||||
android:duplicateParentState="true"/>
|
||||
|
||||
<org.mozilla.gecko.LinkTextView android:id="@+id/more_text"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="47dip"
|
||||
android:textColor="#22629e"
|
||||
android:textColor="@color/abouthome_section_more_text"
|
||||
android:textSize="12sp"
|
||||
android:gravity="center"/>
|
||||
android:gravity="center"
|
||||
android:duplicateParentState="true"/>
|
||||
|
||||
</merge>
|
||||
|
@ -61,5 +61,10 @@
|
||||
<attr name="state_private" format="boolean"/>
|
||||
</declare-styleable>
|
||||
|
||||
<declare-styleable name="LightweightTheme">
|
||||
<attr name="state_light" format="boolean"/>
|
||||
<attr name="state_dark" format="boolean"/>
|
||||
</declare-styleable>
|
||||
|
||||
</resources>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user