diff --git a/embedding/android/AwesomeBar.java b/embedding/android/AwesomeBar.java index cde59ea7d4d0..f99409191182 100644 --- a/embedding/android/AwesomeBar.java +++ b/embedding/android/AwesomeBar.java @@ -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); diff --git a/embedding/android/BrowserToolbar.java b/embedding/android/BrowserToolbar.java index b7dd84c09303..4b8a55357972 100644 --- a/embedding/android/BrowserToolbar.java +++ b/embedding/android/BrowserToolbar.java @@ -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(); } diff --git a/embedding/android/GeckoStateListDrawable.java b/embedding/android/GeckoStateListDrawable.java new file mode 100644 index 000000000000..25868dd980ed --- /dev/null +++ b/embedding/android/GeckoStateListDrawable.java @@ -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 + * + * 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); + } +} diff --git a/embedding/android/Makefile.in b/embedding/android/Makefile.in index 51ec89f932cd..735321593158 100644 --- a/embedding/android/Makefile.in +++ b/embedding/android/Makefile.in @@ -61,6 +61,7 @@ JAVAFILES = \ GeckoEventListener.java \ GeckoInputConnection.java \ GeckoPreferences.java \ + GeckoStateListDrawable.java \ GlobalHistory.java \ PromptService.java \ SurfaceLockInfo.java \ diff --git a/embedding/android/resources/layout/awesomebar_search.xml b/embedding/android/resources/layout/awesomebar_search.xml index f308d7dcb2d5..67f5a8f2588d 100644 --- a/embedding/android/resources/layout/awesomebar_search.xml +++ b/embedding/android/resources/layout/awesomebar_search.xml @@ -9,13 +9,10 @@ #ffffff #000000 #ffffff - #3f3f3f + #000000