Bug 701370: Adding affordance to URL bar [r=mfinkle]
|
@ -41,10 +41,14 @@
|
|||
package org.mozilla.gecko;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
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;
|
||||
|
@ -103,6 +107,20 @@ public class BrowserToolbar extends LinearLayout {
|
|||
}
|
||||
});
|
||||
|
||||
Resources resources = getResources();
|
||||
|
||||
int padding[] = { mAwesomeBar.getPaddingLeft(),
|
||||
mAwesomeBar.getPaddingTop(),
|
||||
mAwesomeBar.getPaddingRight(),
|
||||
mAwesomeBar.getPaddingBottom() };
|
||||
|
||||
URLBarStateListDrawable states = new URLBarStateListDrawable();
|
||||
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);
|
||||
|
||||
mAwesomeBar.setPadding(padding[0], padding[1], padding[2], padding[3]);
|
||||
|
||||
mTabs = (ImageButton) findViewById(R.id.tabs);
|
||||
mTabs.setOnClickListener(new Button.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
|
@ -131,7 +149,7 @@ public class BrowserToolbar extends LinearLayout {
|
|||
mTabsCount.setText("0");
|
||||
|
||||
mFavicon = (ImageButton) findViewById(R.id.favicon);
|
||||
mProgressSpinner = (AnimationDrawable) context.getResources().getDrawable(R.drawable.progress_spinner);
|
||||
mProgressSpinner = (AnimationDrawable) resources.getDrawable(R.drawable.progress_spinner);
|
||||
|
||||
mHandler = new Handler();
|
||||
mSlideUpIn = new TranslateAnimation(0, 0, 30, 0);
|
||||
|
@ -146,6 +164,27 @@ 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();
|
||||
}
|
||||
|
|
|
@ -203,6 +203,7 @@ RES_DRAWABLE_MDPI_V8 = \
|
|||
res/drawable-mdpi-v8/tabs_pressed.png \
|
||||
res/drawable-mdpi-v8/tabs_more.png \
|
||||
res/drawable-mdpi-v8/tabs_plus.png \
|
||||
res/drawable-mdpi-v8/address_bar_url_bg.9.png \
|
||||
$(NULL)
|
||||
|
||||
RES_DRAWABLE_HDPI_V8 = \
|
||||
|
@ -212,6 +213,11 @@ RES_DRAWABLE_HDPI_V8 = \
|
|||
res/drawable-hdpi-v8/ic_menu_reload.png \
|
||||
res/drawable-hdpi-v8/ic_menu_save_as_pdf.png \
|
||||
res/drawable-hdpi-v8/ic_menu_share.png \
|
||||
res/drawable-hdpi-v8/tabs_normal.png \
|
||||
res/drawable-hdpi-v8/tabs_pressed.png \
|
||||
res/drawable-hdpi-v8/tabs_more.png \
|
||||
res/drawable-hdpi-v8/tabs_plus.png \
|
||||
res/drawable-hdpi-v8/address_bar_url_bg.9.png \
|
||||
$(NULL)
|
||||
|
||||
RES_DRAWABLE_MDPI_V9 = \
|
||||
|
@ -243,6 +249,7 @@ RES_DRAWABLE_MDPI_V11 = \
|
|||
res/drawable-mdpi-v11/tabs_pressed.png \
|
||||
res/drawable-mdpi-v11/tabs_more.png \
|
||||
res/drawable-mdpi-v11/tabs_plus.png \
|
||||
res/drawable-mdpi-v11/address_bar_url_bg.9.png \
|
||||
$(NULL)
|
||||
|
||||
RES_DRAWABLE_HDPI_V11 = \
|
||||
|
@ -252,6 +259,11 @@ RES_DRAWABLE_HDPI_V11 = \
|
|||
res/drawable-hdpi-v11/ic_menu_reload.png \
|
||||
res/drawable-hdpi-v11/ic_menu_save_as_pdf.png \
|
||||
res/drawable-hdpi-v11/ic_menu_share.png \
|
||||
res/drawable-hdpi-v11/tabs_normal.png \
|
||||
res/drawable-hdpi-v11/tabs_pressed.png \
|
||||
res/drawable-hdpi-v11/tabs_more.png \
|
||||
res/drawable-hdpi-v11/tabs_plus.png \
|
||||
res/drawable-hdpi-v11/address_bar_url_bg.9.png \
|
||||
$(NULL)
|
||||
|
||||
RES_DRAWABLE_XHDPI_V11 = \
|
||||
|
@ -261,6 +273,11 @@ RES_DRAWABLE_XHDPI_V11 = \
|
|||
res/drawable-xhdpi-v11/ic_menu_reload.png \
|
||||
res/drawable-xhdpi-v11/ic_menu_save_as_pdf.png \
|
||||
res/drawable-xhdpi-v11/ic_menu_share.png \
|
||||
res/drawable-xhdpi-v11/tabs_normal.png \
|
||||
res/drawable-xhdpi-v11/tabs_pressed.png \
|
||||
res/drawable-xhdpi-v11/tabs_more.png \
|
||||
res/drawable-xhdpi-v11/tabs_plus.png \
|
||||
res/drawable-xhdpi-v11/address_bar_url_bg.9.png \
|
||||
$(NULL)
|
||||
|
||||
RES_COLOR = \
|
||||
|
@ -282,6 +299,8 @@ RES_LAYOUT += res/layout/crash_reporter.xml
|
|||
endif
|
||||
|
||||
MOZ_ANDROID_DRAWABLES += embedding/android/resources/drawable/address_bar_bg.xml \
|
||||
embedding/android/resources/drawable/address_bar_url_default.xml \
|
||||
embedding/android/resources/drawable/address_bar_url_pressed.xml \
|
||||
embedding/android/resources/drawable/awesomebar_tab_focus.xml \
|
||||
embedding/android/resources/drawable/awesomebar_tab_focus_selected.xml \
|
||||
embedding/android/resources/drawable/awesomebar_tab_indicator.xml \
|
||||
|
|
После Ширина: | Высота: | Размер: 550 B |
После Ширина: | Высота: | Размер: 223 B |
После Ширина: | Высота: | Размер: 2.3 KiB |
После Ширина: | Высота: | Размер: 175 B |
После Ширина: | Высота: | Размер: 2.6 KiB |
После Ширина: | Высота: | Размер: 835 B |
После Ширина: | Высота: | Размер: 348 B |
После Ширина: | Высота: | Размер: 2.3 KiB |
После Ширина: | Высота: | Размер: 591 B |
После Ширина: | Высота: | Размер: 2.6 KiB |
После Ширина: | Высота: | Размер: 550 B |
После Ширина: | Высота: | Размер: 835 B |
После Ширина: | Высота: | Размер: 550 B |
После Ширина: | Высота: | Размер: 223 B |
После Ширина: | Высота: | Размер: 2.3 KiB |
После Ширина: | Высота: | Размер: 175 B |
После Ширина: | Высота: | Размер: 2.6 KiB |
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:id="@+id/background"
|
||||
android:left="8dp"
|
||||
android:top="10dp"
|
||||
android:right="8dp"
|
||||
android:bottom="8dp"
|
||||
android:drawable="@drawable/address_bar_url_bg"/>
|
||||
|
||||
</layer-list>
|
|
@ -0,0 +1,24 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:id="@+id/outline"
|
||||
android:left="6dp"
|
||||
android:top="8dp"
|
||||
android:right="6dp"
|
||||
android:bottom="6dp">
|
||||
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="#000000"/>
|
||||
<corners android:radius="8dp"/>
|
||||
</shape>
|
||||
|
||||
</item>
|
||||
|
||||
<item android:id="@+id/background"
|
||||
android:left="8dp"
|
||||
android:top="10dp"
|
||||
android:right="8dp"
|
||||
android:bottom="8dp"
|
||||
android:drawable="@drawable/address_bar_url_bg"/>
|
||||
|
||||
</layer-list>
|
|
@ -7,39 +7,41 @@
|
|||
<Button android:id="@+id/awesome_bar"
|
||||
style="@style/AddressBar.Button"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_marginRight="50dp"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:singleLine="true"
|
||||
android:gravity="center_vertical|left"
|
||||
android:hint="@string/awesomebar_default_text"
|
||||
android:textColor="#222222"
|
||||
android:paddingLeft="42dip"
|
||||
android:paddingRight="78dip"/>
|
||||
android:paddingRight="8dip"/>
|
||||
|
||||
<ImageButton android:id="@+id/favicon"
|
||||
style="@style/AddressBar.ImageButton"
|
||||
android:layout_width="21.33dip"
|
||||
android:layout_height="21.33dip"
|
||||
android:layout_marginLeft="10dip"
|
||||
android:layout_marginLeft="15dip"
|
||||
android:layout_centerVertical="true"
|
||||
android:src="@drawable/favicon"
|
||||
android:layout_alignLeft="@id/awesome_bar"/>
|
||||
|
||||
<ImageButton android:id="@+id/tabs"
|
||||
style="@style/AddressBar.ImageButton"
|
||||
android:layout_width="70dip"
|
||||
android:layout_width="65dip"
|
||||
android:layout_height="52dip"
|
||||
android:layout_alignParentRight="true"
|
||||
android:background="@drawable/tabs_button"
|
||||
android:gravity="center_vertical|left"
|
||||
android:src="@drawable/tabs_level"
|
||||
android:paddingTop="4dip"
|
||||
android:paddingLeft="25dip"
|
||||
android:paddingLeft="26dip"
|
||||
android:paddingRight="15dip"/>
|
||||
|
||||
<TextSwitcher android:id="@+id/tabs_count"
|
||||
style="@style/AddressBar.ImageButton"
|
||||
android:layout_width="60dip"
|
||||
android:layout_width="54dip"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="15dip"
|
||||
android:layout_alignRight="@id/tabs"
|
||||
|
|