diff --git a/mobile/android/base/AboutHomeContent.java b/mobile/android/base/AboutHomeContent.java index e520c3e30526..1e85cc2289cd 100644 --- a/mobile/android/base/AboutHomeContent.java +++ b/mobile/android/base/AboutHomeContent.java @@ -689,11 +689,27 @@ public class AboutHomeContent extends ScrollView drawable.setAlpha(255, 0); setBackgroundDrawable(drawable); + + boolean isLight = mActivity.getLightweightTheme().isLightTheme(); + + if (mAddons != null) { + 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); + + if (mAddons != null) { + mAddons.resetTheme(); + mLastTabs.resetTheme(); + mRemoteTabs.resetTheme(); + ((GeckoTextView) findViewById(R.id.top_sites_title)).resetTheme(); + } } @Override diff --git a/mobile/android/base/AboutHomeSection.java b/mobile/android/base/AboutHomeSection.java index c812131709bd..dcbbb674289c 100644 --- a/mobile/android/base/AboutHomeSection.java +++ b/mobile/android/base/AboutHomeSection.java @@ -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; diff --git a/mobile/android/base/GeckoView.java.frag b/mobile/android/base/GeckoView.java.frag index d85a634d2252..8793d39dd821 100644 --- a/mobile/android/base/GeckoView.java.frag +++ b/mobile/android/base/GeckoView.java.frag @@ -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(); + } + } } diff --git a/mobile/android/base/LightweightTheme.java b/mobile/android/base/LightweightTheme.java index 96a89b38f7a7..2fd44cc8d3e1 100644 --- a/mobile/android/base/LightweightTheme.java +++ b/mobile/android/base/LightweightTheme.java @@ -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. diff --git a/mobile/android/base/Makefile.in b/mobile/android/base/Makefile.in index d218029d4bda..5aede8fed94b 100644 --- a/mobile/android/base/Makefile.in +++ b/mobile/android/base/Makefile.in @@ -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 \ diff --git a/mobile/android/base/resources/color/abouthome_section_more_text.xml.in b/mobile/android/base/resources/color/abouthome_section_more_text.xml.in new file mode 100644 index 000000000000..3c636a48fcec --- /dev/null +++ b/mobile/android/base/resources/color/abouthome_section_more_text.xml.in @@ -0,0 +1,19 @@ +#filter substitution + + + + + + + + + + + + + + + diff --git a/mobile/android/base/resources/color/abouthome_section_subtitle.xml.in b/mobile/android/base/resources/color/abouthome_section_subtitle.xml.in new file mode 100644 index 000000000000..abaef7b02da3 --- /dev/null +++ b/mobile/android/base/resources/color/abouthome_section_subtitle.xml.in @@ -0,0 +1,19 @@ +#filter substitution + + + + + + + + + + + + + + + diff --git a/mobile/android/base/resources/color/abouthome_section_title.xml.in b/mobile/android/base/resources/color/abouthome_section_title.xml.in new file mode 100644 index 000000000000..f5bfc7cc4c91 --- /dev/null +++ b/mobile/android/base/resources/color/abouthome_section_title.xml.in @@ -0,0 +1,19 @@ +#filter substitution + + + + + + + + + + + + + + + diff --git a/mobile/android/base/resources/layout-xlarge-land-v11/abouthome_content.xml.in b/mobile/android/base/resources/layout-xlarge-land-v11/abouthome_content.xml.in index 69088936a7ca..9b2633d2ae3b 100644 --- a/mobile/android/base/resources/layout-xlarge-land-v11/abouthome_content.xml.in +++ b/mobile/android/base/resources/layout-xlarge-land-v11/abouthome_content.xml.in @@ -25,16 +25,16 @@ android:layout_marginBottom="10dip" android:layout_marginLeft="12dip"/> - + + android:background="@drawable/action_bar_button" + android:duplicateParentState="true"> + android:textColor="@color/abouthome_section_title" + android:duplicateParentState="true"/> + android:textColor="@color/abouthome_section_subtitle" + android:duplicateParentState="true"/> - + + android:background="@drawable/action_bar_button" + android:duplicateParentState="true"> + android:textColor="@color/abouthome_section_title" + android:duplicateParentState="true"/> + android:textColor="@color/abouthome_section_subtitle" + android:duplicateParentState="true"/> + android:background="@drawable/action_bar_button" + android:duplicateParentState="true"> + android:ellipsize="middle" + android:textColor="@color/abouthome_section_title" + android:duplicateParentState="true"/> + android:gravity="left|center_vertical" + android:duplicateParentState="true"/> + android:textColor="@color/abouthome_section_subtitle" + android:gravity="left|center_vertical" + android:duplicateParentState="true"/> + android:isScrollContainer="false" + android:duplicateParentState="true"/> + android:gravity="center" + android:duplicateParentState="true"/> diff --git a/mobile/android/base/resources/values/attrs.xml b/mobile/android/base/resources/values/attrs.xml index 1d6340d07b4c..2d9ba24b873e 100644 --- a/mobile/android/base/resources/values/attrs.xml +++ b/mobile/android/base/resources/values/attrs.xml @@ -61,5 +61,10 @@ + + + + +