summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeon Scroggins <scroggo@google.com>2010-03-31 14:50:47 -0400
committerLeon Scroggins <scroggo@google.com>2010-03-31 14:50:47 -0400
commitcd663ea13aa707547f74d5ab028e9e460a6ee03c (patch)
tree7aedba5748b2bb548b3729b73e02b323635682e3
parentfa52d17a04294c245d6b00180bbe03560390c967 (diff)
downloadpackages_apps_browser-cd663ea13aa707547f74d5ab028e9e460a6ee03c.zip
packages_apps_browser-cd663ea13aa707547f74d5ab028e9e460a6ee03c.tar.gz
packages_apps_browser-cd663ea13aa707547f74d5ab028e9e460a6ee03c.tar.bz2
Lessen the difference in appearance of title bar during load.
Change to using textfield_search_empty assets, which have margin values that better match the assets used outside of a load. As a result, there is no longer a need to edit the LayoutParams in TitleBar.java. However, do set the padding in TitleBar.java, since it needs to be set for each of the different backgrounds used. Fixes http://b/issue?id=2558919 Change-Id: Idf0d8bea59bcc76c32e1e03bf736a4b64bf31887
-rw-r--r--res/drawable/title_text.xml4
-rw-r--r--res/layout/title_bar.xml5
-rw-r--r--src/com/android/browser/TitleBar.java49
3 files changed, 14 insertions, 44 deletions
diff --git a/res/drawable/title_text.xml b/res/drawable/title_text.xml
index 6a214d9..b435e4d 100644
--- a/res/drawable/title_text.xml
+++ b/res/drawable/title_text.xml
@@ -18,7 +18,7 @@
pressed state even without window focus -->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
- android:drawable="@*android:drawable/textfield_pressed" />
+ android:drawable="@*android:drawable/textfield_search_empty_pressed" />
<item android:state_pressed="false"
- android:drawable="@*android:drawable/textfield_default" />
+ android:drawable="@*android:drawable/textfield_search_empty_default" />
</selector>
diff --git a/res/layout/title_bar.xml b/res/layout/title_bar.xml
index c251250..9f0cb51 100644
--- a/res/layout/title_bar.xml
+++ b/res/layout/title_bar.xml
@@ -44,6 +44,7 @@
android:layout_width="0dip"
android:layout_weight="1.0"
android:layout_height="wrap_content"
+ android:layout_marginBottom="4dip"
android:gravity="center_vertical"
android:orientation="horizontal"
>
@@ -63,8 +64,7 @@
android:layout_height="wrap_content"
android:layout_width="0dip"
android:layout_weight="1.0"
- android:paddingLeft="8dip"
- android:paddingRight="6dip"
+ android:layout_marginLeft="3dip"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@color/black"
android:gravity="center_vertical"
@@ -76,6 +76,7 @@
android:background="@drawable/stop_background"
android:layout_width="wrap_content"
android:layout_height="match_parent"
+ android:layout_marginBottom="4dip"
android:src="@drawable/ic_btn_stop_v2"
android:visibility="gone"
/>
diff --git a/src/com/android/browser/TitleBar.java b/src/com/android/browser/TitleBar.java
index 0f19864..b377a71 100644
--- a/src/com/android/browser/TitleBar.java
+++ b/src/com/android/browser/TitleBar.java
@@ -44,7 +44,6 @@ import android.view.MenuInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
-import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
@@ -79,7 +78,8 @@ public class TitleBar extends LinearLayout {
private Drawable mNormalBackground;
private Drawable mLoadingBackground;
private ImageSpan mArcsSpan;
- private int mExtraMargin;
+ private int mLeftMargin;
+ private int mRightMargin;
private static int LONG_PRESS = 1;
@@ -103,8 +103,10 @@ public class TitleBar extends LinearLayout {
mCircularProgress = (Drawable) resources.getDrawable(
com.android.internal.R.drawable.search_spinner);
DisplayMetrics metrics = resources.getDisplayMetrics();
- mExtraMargin = (int) TypedValue.applyDimension(
- TypedValue.COMPLEX_UNIT_DIP, 6.5f, metrics);
+ mLeftMargin = (int) TypedValue.applyDimension(
+ TypedValue.COMPLEX_UNIT_DIP, 8f, metrics);
+ mRightMargin = (int) TypedValue.applyDimension(
+ TypedValue.COMPLEX_UNIT_DIP, 6f, metrics);
mIconDimension = (int) TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP, 20f, metrics);
mCircularProgress.setBounds(0, 0, mIconDimension, mIconDimension);
@@ -267,44 +269,28 @@ public class TitleBar extends LinearLayout {
if (mInVoiceMode == inVoiceMode) return;
mInVoiceMode = inVoiceMode && mVoiceSearchIntent != null;
Drawable titleDrawable;
- ViewGroup.MarginLayoutParams params
- = (ViewGroup.MarginLayoutParams) mTitleBg.getLayoutParams();
if (mInVoiceMode) {
mRtButton.setImageDrawable(mVoiceDrawable);
titleDrawable = mVoiceModeBackground;
mTitle.setEllipsize(null);
mRtButton.setVisibility(View.VISIBLE);
mStopButton.setVisibility(View.GONE);
- if (params != null) {
- params.setMargins(0, 0, 0, 0);
- }
} else {
if (mInLoad) {
titleDrawable = mLoadingBackground;
mRtButton.setVisibility(View.GONE);
mStopButton.setVisibility(View.VISIBLE);
- ViewGroup.MarginLayoutParams stopParams
- = (ViewGroup.MarginLayoutParams)
- mStopButton.getLayoutParams();
- if (stopParams != null) {
- stopParams.setMargins(0,0,0, mExtraMargin);
- }
- if (params != null) {
- params.setMargins(0, 0, 0, mExtraMargin);
- }
} else {
titleDrawable = mNormalBackground;
mRtButton.setVisibility(View.VISIBLE);
mStopButton.setVisibility(View.GONE);
mRtButton.setImageDrawable(mBookmarkDrawable);
- if (params != null) {
- params.setMargins(0, 0, 0, 0);
- }
}
mTitle.setEllipsize(TextUtils.TruncateAt.END);
}
mTitle.setSingleLine(!mInVoiceMode);
mTitleBg.setBackgroundDrawable(titleDrawable);
+ mTitleBg.setPadding(mLeftMargin, 0, mRightMargin, 0);
}
/**
@@ -323,8 +309,6 @@ public class TitleBar extends LinearLayout {
* Update the progress, from 0 to 100.
*/
/* package */ void setProgress(int newProgress) {
- ViewGroup.MarginLayoutParams params
- = (ViewGroup.MarginLayoutParams) mTitleBg.getLayoutParams();
if (newProgress >= mHorizontalProgress.getMax()) {
mTitle.setCompoundDrawables(null, null, null, null);
((Animatable) mCircularProgress).stop();
@@ -334,11 +318,7 @@ public class TitleBar extends LinearLayout {
mRtButton.setVisibility(View.VISIBLE);
mStopButton.setVisibility(View.GONE);
mTitleBg.setBackgroundDrawable(mNormalBackground);
- // Set the margin for the textfield to 0, which is appropriate
- // for the normal background
- if (params != null) {
- params.setMargins(0, 0, 0, 0);
- }
+ mTitleBg.setPadding(mLeftMargin, 0, mRightMargin, 0);
}
mInLoad = false;
} else {
@@ -354,20 +334,9 @@ public class TitleBar extends LinearLayout {
mHorizontalProgress.setVisibility(View.VISIBLE);
if (!mInVoiceMode) {
mTitleBg.setBackgroundDrawable(mLoadingBackground);
+ mTitleBg.setPadding(mLeftMargin, 0, mRightMargin, 0);
mRtButton.setVisibility(View.GONE);
mStopButton.setVisibility(View.VISIBLE);
- // Set a margin for the bottom of the textfield and the stop
- // button so that the total height matches that of the
- // title bar when the normal background is showing.
- if (params != null) {
- params.setMargins(0,0,0, mExtraMargin);
- }
- ViewGroup.MarginLayoutParams stopParams
- = (ViewGroup.MarginLayoutParams)
- mStopButton.getLayoutParams();
- if (stopParams != null) {
- stopParams.setMargins(0,0,0, mExtraMargin);
- }
}
mInLoad = true;
}