Bug 703094: AwesomeScreen should use same background as URL bar [r=mfinkle]

This commit is contained in:
Sriram Ramasubramanian 2011-11-17 11:18:23 -08:00
parent a5515e2446
commit 5e053ea2f7
6 changed files with 87 additions and 31 deletions

View File

@ -44,6 +44,7 @@ import java.io.File;
import android.app.Activity;
import android.content.Intent;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.Configuration;
import android.os.Bundle;
import android.text.Editable;
@ -86,6 +87,22 @@ public class AwesomeBar extends Activity {
mText = (EditText)findViewById(R.id.awesomebar_text);
Resources resources = getResources();
int padding[] = { mText.getPaddingLeft(),
mText.getPaddingTop(),
mText.getPaddingRight(),
mText.getPaddingBottom() };
GeckoStateListDrawable states = new GeckoStateListDrawable();
states.initializeFilter(GeckoApp.mBrowserToolbar.getHighlightColor());
states.addState(new int[] { android.R.attr.state_focused }, resources.getDrawable(R.drawable.address_bar_url_pressed));
states.addState(new int[] { android.R.attr.state_pressed }, resources.getDrawable(R.drawable.address_bar_url_pressed));
states.addState(new int[] { }, resources.getDrawable(R.drawable.address_bar_url_default));
mText.setBackgroundDrawable(states);
mText.setPadding(padding[0], padding[1], padding[2], padding[3]);
Intent intent = getIntent();
String currentUrl = intent.getStringExtra(CURRENT_URL_KEY);
mType = intent.getStringExtra(TYPE_KEY);

View File

@ -46,9 +46,6 @@ import android.content.res.TypedArray;
import android.graphics.Color;
import android.graphics.drawable.AnimationDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
import android.graphics.drawable.StateListDrawable;
import android.graphics.LightingColorFilter;
import android.graphics.Typeface;
import android.os.Handler;
import android.util.AttributeSet;
@ -116,7 +113,8 @@ public class BrowserToolbar extends LinearLayout {
mAwesomeBar.getPaddingRight(),
mAwesomeBar.getPaddingBottom() };
URLBarStateListDrawable states = new URLBarStateListDrawable();
GeckoStateListDrawable states = new GeckoStateListDrawable();
states.initializeFilter(mColor);
states.addState(new int[] { android.R.attr.state_pressed }, resources.getDrawable(R.drawable.address_bar_url_pressed));
states.addState(new int[] { }, resources.getDrawable(R.drawable.address_bar_url_default));
mAwesomeBar.setBackgroundDrawable(states);
@ -174,27 +172,6 @@ public class BrowserToolbar extends LinearLayout {
mSlideDownOut.setDuration(mDuration);
}
private class URLBarStateListDrawable extends StateListDrawable {
final private LightingColorFilter mFilter;
public URLBarStateListDrawable() {
mFilter = new LightingColorFilter(Color.WHITE, mColor);
}
@Override
protected boolean onStateChange(int[] stateSet) {
for (int state: stateSet) {
if (state == android.R.attr.state_pressed) {
super.onStateChange(stateSet);
((LayerDrawable) getCurrent()).getDrawable(0).setColorFilter(mFilter);
return true;
}
}
return super.onStateChange(stateSet);
}
}
private void onAwesomeBarSearch() {
GeckoApp.mAppContext.onEditRequested();
}

View File

@ -0,0 +1,64 @@
/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Android code.
*
* The Initial Developer of the Original Code is Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2009-2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Sriram Ramasubramanian <sriram@mozilla.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
package org.mozilla.gecko;
import android.graphics.Color;
import android.graphics.drawable.LayerDrawable;
import android.graphics.drawable.StateListDrawable;
import android.graphics.LightingColorFilter;
public class GeckoStateListDrawable extends StateListDrawable {
private LightingColorFilter mFilter;
public void initializeFilter(int color) {
mFilter = new LightingColorFilter(Color.WHITE, color);
}
@Override
protected boolean onStateChange(int[] stateSet) {
for (int state: stateSet) {
if (state == android.R.attr.state_pressed || state == android.R.attr.state_focused) {
super.onStateChange(stateSet);
((LayerDrawable) getCurrent()).getDrawable(0).setColorFilter(mFilter);
return true;
}
}
return super.onStateChange(stateSet);
}
}

View File

@ -61,6 +61,7 @@ JAVAFILES = \
GeckoEventListener.java \
GeckoInputConnection.java \
GeckoPreferences.java \
GeckoStateListDrawable.java \
GlobalHistory.java \
PromptService.java \
SurfaceLockInfo.java \

View File

@ -9,13 +9,10 @@
<EditText android:id="@+id/awesomebar_text"
style="@style/AddressBar.Button"
android:layout_width="fill_parent"
android:layout_marginLeft="6dip"
android:layout_marginRight="6dip"
android:layout_marginTop="6dip"
android:layout_marginBottom="1dip"
android:layout_alignParentBottom="true"
android:layout_centerVertical="true"
android:background="@android:drawable/edit_text"
android:paddingLeft="15dip"
android:paddingRight="15dip"
android:hint="@string/awesomebar_default_text"
android:inputType="textUri"
android:imeOptions="actionGo"

View File

@ -4,6 +4,6 @@
<color name="splash_msgfont">#ffffff</color>
<color name="splash_urlfont">#000000</color>
<color name="splash_content">#ffffff</color>
<color name="awesomebar_background">#3f3f3f</color>
<color name="awesomebar_background">#000000</color>
</resources>