Bug 696461: Primary UI: Reskinning the browser toolbar and awesomebar [r=mfinkle]

This commit is contained in:
Sriram Ramasubramanian 2011-10-27 16:53:09 -07:00
parent 11508ddfb4
commit f0faac4a87
18 changed files with 104 additions and 62 deletions

View File

@ -53,7 +53,7 @@ import android.widget.ProgressBar;
public class BrowserToolbar extends LinearLayout { public class BrowserToolbar extends LinearLayout {
final private ProgressBar mProgressBar; final private ProgressBar mProgressBar;
final private Button mAwesomeBar; final private Button mAwesomeBar;
final private Button mTabs; final private ImageButton mTabs;
final private ImageButton mFavicon; final private ImageButton mFavicon;
public BrowserToolbar(Context context, AttributeSet attrs) { public BrowserToolbar(Context context, AttributeSet attrs) {
@ -74,11 +74,13 @@ public class BrowserToolbar extends LinearLayout {
} }
}); });
mTabs = (Button) findViewById(R.id.tabs); mTabs = (ImageButton) findViewById(R.id.tabs);
mTabs.setText("1");
mTabs.setOnClickListener(new Button.OnClickListener() { mTabs.setOnClickListener(new Button.OnClickListener() {
public void onClick(View v) { public void onClick(View v) {
showTabs(); if (Tabs.getInstance().getCount() > 1)
showTabs();
else
addTab();
} }
}); });
@ -89,12 +91,19 @@ public class BrowserToolbar extends LinearLayout {
GeckoApp.mAppContext.onEditRequested(); GeckoApp.mAppContext.onEditRequested();
} }
private void addTab() {
GeckoApp.mAppContext.addTab();
}
private void showTabs() { private void showTabs() {
GeckoApp.mAppContext.showTabs(); GeckoApp.mAppContext.showTabs();
} }
public void updateTabs(int count) { public void updateTabs(int count) {
mTabs.setText("" + count); if (count == 1)
mTabs.setImageResource(R.drawable.tabs_plus);
else
mTabs.setImageResource(R.drawable.tabs_menu);
} }
public void updateProgress(int progress, int total) { public void updateProgress(int progress, int total) {

View File

@ -595,6 +595,13 @@ abstract public class GeckoApp
}); });
} }
void addTab() {
Intent intent = new Intent(mAppContext, AwesomeBar.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION | Intent.FLAG_ACTIVITY_NO_HISTORY);
intent.putExtra(AwesomeBar.TYPE_KEY, AwesomeBar.Type.ADD.name());
startActivityForResult(intent, AWESOMEBAR_REQUEST);
}
void showTabs() { void showTabs() {
DisplayMetrics metrics = new DisplayMetrics(); DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics); getWindowManager().getDefaultDisplay().getMetrics(metrics);
@ -615,10 +622,7 @@ abstract public class GeckoApp
addTab.setOnClickListener(new View.OnClickListener() { addTab.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) { public void onClick(View v) {
hideTabs(); hideTabs();
Intent intent = new Intent(mAppContext, AwesomeBar.class); addTab();
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION | Intent.FLAG_ACTIVITY_NO_HISTORY);
intent.putExtra(AwesomeBar.TYPE_KEY, AwesomeBar.Type.ADD.name());
startActivityForResult(intent, AWESOMEBAR_REQUEST);
} }
}); });

View File

@ -174,10 +174,7 @@ RES_LAYOUT += res/layout/crash_reporter.xml
endif endif
MOZ_ANDROID_DRAWABLES += embedding/android/resources/drawable/addons.png \ MOZ_ANDROID_DRAWABLES += embedding/android/resources/drawable/addons.png \
embedding/android/resources/drawable/address_bar_bg.9.png \ embedding/android/resources/drawable/address_bar_bg.xml \
embedding/android/resources/drawable/address_bar_button_left.9.png \
embedding/android/resources/drawable/address_bar_button_middle.9.png \
embedding/android/resources/drawable/address_bar_button_right.9.png \
embedding/android/resources/drawable/bookmark_add.png \ embedding/android/resources/drawable/bookmark_add.png \
embedding/android/resources/drawable/bookmark_remove.png \ embedding/android/resources/drawable/bookmark_remove.png \
embedding/android/resources/drawable/desktop_notification.png \ embedding/android/resources/drawable/desktop_notification.png \
@ -186,6 +183,12 @@ MOZ_ANDROID_DRAWABLES += embedding/android/resources/drawable/addons.png
embedding/android/resources/drawable/reload.png \ embedding/android/resources/drawable/reload.png \
embedding/android/resources/drawable/share.png \ embedding/android/resources/drawable/share.png \
embedding/android/resources/drawable/start.png \ embedding/android/resources/drawable/start.png \
embedding/android/resources/drawable/tabs_button.xml \
embedding/android/resources/drawable/tabs_normal.png \
embedding/android/resources/drawable/tabs_pressed.png \
embedding/android/resources/drawable/tabs_off.png \
embedding/android/resources/drawable/tabs_plus.png \
embedding/android/resources/drawable/tabs_menu.png \
$(NULL) $(NULL)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 90 B

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient android:type="linear"
android:startColor="#d5d5d5"
android:endColor="#fefefe"
android:angle="90"/>
</shape>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 667 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 438 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 670 B

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="@drawable/tabs_pressed"/>
<item android:drawable="@drawable/tabs_normal"/>
</selector>

Binary file not shown.

After

Width:  |  Height:  |  Size: 571 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 450 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@ -3,17 +3,32 @@
android:id="@+id/awesome_screen" android:id="@+id/awesome_screen"
style="@style/Screen"> style="@style/Screen">
<LinearLayout style="@style/AddressBar"> <RelativeLayout style="@style/AddressBar">
<EditText android:id="@+id/awesomebar_text" <EditText android:id="@+id/awesomebar_text"
style="@style/AddressBar.URL" style="@style/AddressBar.Button"
android:layout_width="fill_parent"
android:layout_marginLeft="60dip"
android:layout_marginRight="12dip"
android:layout_marginTop="4dip"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_centerVertical="true"
android:background="@android:drawable/edit_text" android:background="@android:drawable/edit_text"
android:inputType="textUri" android:inputType="textUri"
android:imeOptions="actionGo"> android:imeOptions="actionGo"
android:singleLine="true"
android:gravity="center_vertical|left">
<requestFocus/> <requestFocus/>
</EditText> </EditText>
</LinearLayout> <ImageButton style="@style/AddressBar.ImageButton"
android:layout_width="68dip"
android:layout_alignParentLeft="true"
android:background="@drawable/tabs_off"
android:gravity="center_vertical|left"/>
</RelativeLayout>
<org.mozilla.gecko.AwesomeBarTabs android:id="@+id/awesomebar_tabs" <org.mozilla.gecko.AwesomeBarTabs android:id="@+id/awesomebar_tabs"
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@ -7,20 +7,42 @@
android:layout_height="10dip" android:layout_height="10dip"
android:visibility="gone"/> android:visibility="gone"/>
<LinearLayout android:id="@+id/address_bar" <RelativeLayout android:id="@+id/address_bar"
style="@style/AddressBar"> style="@style/AddressBar">
<Button android:id="@+id/tabs" <Button android:id="@+id/awesome_bar"
style="@style/AddressBar.Button.Left"/> style="@style/AddressBar.Button"
android:layout_width="fill_parent"
android:layout_marginLeft="60dip"
android:layout_marginRight="12dip"
android:layout_marginTop="4dip"
android:layout_marginBottom="4dip"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:singleLine="true"
android:gravity="center_vertical|left"
android:textColor="#000"
android:paddingLeft="32dp"/>
<ImageButton android:id="@+id/tabs"
style="@style/AddressBar.ImageButton"
android:layout_width="68dip"
android:layout_alignParentLeft="true"
android:background="@drawable/tabs_button"
android:gravity="center_vertical|left"
android:src="@drawable/tabs_plus"
android:paddingLeft="12dip"
android:paddingRight="38dip"/>
<ImageButton android:id="@+id/favicon" <ImageButton android:id="@+id/favicon"
style="@style/AddressBar.ImageButton.Middle" style="@style/AddressBar.ImageButton"
android:src="@drawable/favicon"/> android:layout_width="24dip"
android:layout_height="24dip"
android:layout_marginLeft="0dip"
android:layout_centerVertical="true"
android:src="@drawable/favicon"
android:layout_alignLeft="@id/awesome_bar"/>
<Button android:id="@+id/awesome_bar" </RelativeLayout>
style="@style/AddressBar.URL"
android:textColor="#666"/>
</LinearLayout>
</merge> </merge>

View File

@ -3,7 +3,7 @@
android:id="@+id/list" android:id="@+id/list"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@drawable/address_bar_button_middle" android:background="#fff"
android:cacheColorHint="#fff" android:cacheColorHint="#fff"
android:divider="#666666" android:divider="#666666"
android:dividerHeight="1dp"/> android:dividerHeight="1dp"/>

View File

@ -37,17 +37,16 @@
<!-- Address bar --> <!-- Address bar -->
<style name="AddressBar"> <style name="AddressBar">
<item name="android:layout_width">match_parent</item> <item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item> <item name="android:layout_height">54dip</item>
<item name="android:orientation">horizontal</item> <item name="android:orientation">horizontal</item>
<item name="android:background">@drawable/address_bar_bg</item> <item name="android:background">@drawable/address_bar_bg</item>
<item name="android:padding">5dp</item>
</style> </style>
<!-- Address bar - Button --> <!-- Address bar - Button -->
<style name="AddressBar.Button"> <style name="AddressBar.Button">
<item name="android:layout_width">40dip</item> <item name="android:layout_height">match_parent</item>
<item name="android:layout_height">43dip</item> <item name="android:textSize">18sp</item>
<item name="android:textSize">16sp</item> <item name="android:background">#00000000</item>
</style> </style>
<!-- Address bar - Image Button --> <!-- Address bar - Image Button -->
@ -55,33 +54,6 @@
<item name="android:scaleType">fitCenter</item> <item name="android:scaleType">fitCenter</item>
</style> </style>
<!-- Address bar - Left Button -->
<style name="AddressBar.Button.Left">
<item name="android:background">@drawable/address_bar_button_left</item>
</style>
<!-- Address bar - Right Button -->
<style name="AddressBar.Button.Right">
<item name="android:background">@drawable/address_bar_button_right</item>
</style>
<!-- Address bar - Middle Button -->
<style name="AddressBar.ImageButton.Middle">
<item name="android:background">@drawable/address_bar_button_middle</item>
</style>
<!-- Address bar - URL -->
<style name="AddressBar.URL" parent="AddressBar.Button.Right">
<item name="android:layout_width">wrap_content</item>
<item name="android:orientation">horizontal</item>
<item name="android:layout_weight">1</item>
<item name="android:paddingLeft">10dip</item>
<item name="android:paddingRight">10dip</item>
<item name="android:singleLine">true</item>
<item name="android:textSize">18sp</item>
<item name="android:gravity">center_vertical|left</item>
</style>
<!-- Lists in AwesomeBar --> <!-- Lists in AwesomeBar -->
<style name="AwesomeBarList"> <style name="AwesomeBarList">
<item name="android:layout_width">match_parent</item> <item name="android:layout_width">match_parent</item>