Bug 783092: Lightweight theme for awesomebar. [r=mfinkle]

--HG--
rename : mobile/android/base/resources/layout-large-v11/awesomebar_search.xml => mobile/android/base/resources/layout-large-v11/awesomebar_search.xml.in
rename : mobile/android/base/resources/layout/awesomebar_search.xml => mobile/android/base/resources/layout/awesomebar_search.xml.in
This commit is contained in:
Sriram Ramasubramanian 2012-10-31 22:12:45 -07:00
parent 4ef31ba27b
commit de53080208
7 changed files with 94 additions and 13 deletions

View File

@ -6,6 +6,7 @@
package org.mozilla.gecko;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.util.AttributeSet;
import android.util.Log;
@ -14,6 +15,7 @@ import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.InputMethodManager;
import android.widget.LinearLayout;
import android.widget.TabHost;
import android.widget.TabWidget;
import android.widget.TextView;
@ -221,4 +223,58 @@ public class AwesomeBarTabs extends TabHost {
public boolean isInReadingList() {
return getBookmarksTab().isInReadingList();
}
public static class Background extends LinearLayout
implements LightweightTheme.OnChangeListener {
private GeckoActivity mActivity;
public Background(Context context, AttributeSet attrs) {
super(context, attrs);
mActivity = (GeckoActivity) context;
}
@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;
int[] padding = new int[] { getPaddingLeft(),
getPaddingTop(),
getPaddingRight(),
getPaddingBottom()
};
setBackgroundDrawable(drawable);
setPadding(padding[0], padding[1], padding[2], padding[3]);
}
@Override
public void onLightweightThemeReset() {
int[] padding = new int[] { getPaddingLeft(),
getPaddingTop(),
getPaddingRight(),
getPaddingBottom()
};
setBackgroundResource(R.drawable.abouthome_bg_repeat);
setPadding(padding[0], padding[1], padding[2], padding[3]);
}
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
onLightweightThemeChanged();
}
}
}

View File

@ -48,6 +48,8 @@ public final class GeckoViewsFactory implements LayoutInflater.Factory {
return new AboutHomeSection(context, attrs);
else if (TextUtils.equals(viewName, "AwesomeBarTabs"))
return new AwesomeBarTabs(context, attrs);
else if (TextUtils.equals(viewName, "AwesomeBarTabs.Background"))
return new AwesomeBarTabs.Background(context, attrs);
else if (TextUtils.equals(viewName, "BrowserToolbarBackground"))
return new BrowserToolbarBackground(context, attrs);
else if (TextUtils.equals(viewName, "BrowserToolbar$RightEdge"))

View File

@ -210,11 +210,13 @@ FENNEC_PP_JAVA_FILES = \
FENNEC_PP_XML_FILES = \
res/layout/abouthome_content.xml \
res/layout/awesomebar_search.xml \
res/layout/awesomebar_suggestion_row.xml \
res/layout/browser_toolbar.xml \
res/layout/browser_toolbar_menu.xml \
res/layout-land-v14/browser_toolbar.xml \
res/layout-land-v14/browser_toolbar_menu.xml \
res/layout-large-v11/awesomebar_search.xml \
res/layout-large-v11/browser_toolbar_menu.xml \
res/layout-xlarge-v11/browser_toolbar_menu.xml \
res/layout/gecko_app.xml \
@ -344,7 +346,6 @@ RES_LAYOUT = \
res/layout/awesomebar_row.xml \
res/layout/awesomebar_suggestion_item.xml \
res/layout/awesomebar_suggestion_prompt.xml \
res/layout/awesomebar_search.xml \
res/layout/awesomebar_tab_indicator.xml \
res/layout/awesomebar_tabs.xml \
res/layout/bookmark_edit.xml \
@ -394,7 +395,6 @@ RES_LAYOUT_LAND_V14 = \
$(NULL)
RES_LAYOUT_LARGE_V11 = \
res/layout-large-v11/awesomebar_search.xml \
res/layout-large-v11/doorhangerpopup.xml \
res/layout-large-v11/site_identity_popup.xml \
res/layout-large-v11/tabs_panel_toolbar_menu.xml \

View File

@ -1,11 +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/. -->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/AwesomeBar"
android:background="@drawable/address_bar_bg">
xmlns:gecko="http://schemas.android.com/apk/res/@ANDROID_PACKAGE_NAME@"
style="@style/AwesomeBar">
<org.mozilla.gecko.BrowserToolbarBackground android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
gecko:curveTowards="none"
android:background="@drawable/address_bar_bg"/>
<view class="org.mozilla.gecko.CustomEditText"
android:id="@+id/awesomebar_text"

View File

@ -6,8 +6,14 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:gecko="http://schemas.android.com/apk/res/@ANDROID_PACKAGE_NAME@"
style="@style/AwesomeBar"
android:background="@drawable/address_bar_bg">
style="@style/AwesomeBar">
<org.mozilla.gecko.BrowserToolbarBackground android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
gecko:curveTowards="none"
android:background="@drawable/address_bar_bg"/>
<org.mozilla.gecko.TabsButton android:id="@+id/dummy_tab"
style="@style/AddressBar.ImageButton"

View File

@ -1,11 +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/. -->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/AwesomeBar"
android:background="@drawable/address_bar_bg">
xmlns:gecko="http://schemas.android.com/apk/res/@ANDROID_PACKAGE_NAME@"
style="@style/AwesomeBar">
<org.mozilla.gecko.BrowserToolbarBackground android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
gecko:curveTowards="none"
android:background="@drawable/address_bar_bg"/>
<view class="org.mozilla.gecko.CustomEditText"
android:id="@+id/awesomebar_text"

View File

@ -8,7 +8,8 @@
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout android:orientation="vertical"
<view class="org.mozilla.gecko.AwesomeBarTabs.Background"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/abouthome_bg_repeat">
@ -32,6 +33,6 @@
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
</LinearLayout>
</view>
</org.mozilla.gecko.AwesomeBarTabs>