summaryrefslogtreecommitdiffstats
path: root/src/com/android
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2011-02-16 16:43:03 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-02-16 16:43:03 -0800
commit15c0f987a09f24658946ce58dfb5a71dc0f04450 (patch)
tree5f2c4bd88fdd24e94d5b7b766fcff832687938ad /src/com/android
parent745f3704dccfb228d358bbe25bba90ffa88eeb97 (diff)
parent94b7e04932d77d73f348efecf7f2dd6b4ee5e5a1 (diff)
downloadpackages_apps_Browser-15c0f987a09f24658946ce58dfb5a71dc0f04450.zip
packages_apps_Browser-15c0f987a09f24658946ce58dfb5a71dc0f04450.tar.gz
packages_apps_Browser-15c0f987a09f24658946ce58dfb5a71dc0f04450.tar.bz2
Merge "Phone UI title bar work"
Diffstat (limited to 'src/com/android')
-rw-r--r--src/com/android/browser/BaseUi.java5
-rw-r--r--src/com/android/browser/TitleBar.java61
-rw-r--r--src/com/android/browser/TitleBarBase.java6
-rw-r--r--src/com/android/browser/TitleBarXLarge.java3
-rw-r--r--src/com/android/browser/XLargeUi.java8
5 files changed, 24 insertions, 59 deletions
diff --git a/src/com/android/browser/BaseUi.java b/src/com/android/browser/BaseUi.java
index 9bce3cd..6e8f603 100644
--- a/src/com/android/browser/BaseUi.java
+++ b/src/com/android/browser/BaseUi.java
@@ -193,7 +193,10 @@ public abstract class BaseUi implements UI, WebViewFactory {
@Override
public void bookmarkedStatusHasChanged(Tab tab) {
- // no op in base case
+ if (tab.inForeground()) {
+ boolean isBookmark = tab.isBookmarkedSite();
+ getTitleBar().setCurrentUrlIsBookmark(isBookmark);
+ }
}
@Override
diff --git a/src/com/android/browser/TitleBar.java b/src/com/android/browser/TitleBar.java
index 56db187..686416c 100644
--- a/src/com/android/browser/TitleBar.java
+++ b/src/com/android/browser/TitleBar.java
@@ -21,15 +21,12 @@ import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.res.Resources;
-import android.graphics.drawable.Animatable;
import android.graphics.drawable.Drawable;
import android.speech.RecognizerIntent;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.TextUtils;
import android.text.style.ImageSpan;
-import android.util.DisplayMetrics;
-import android.util.TypedValue;
import android.view.ContextMenu;
import android.view.LayoutInflater;
import android.view.MenuInflater;
@@ -38,7 +35,6 @@ import android.view.View.OnClickListener;
import android.view.View.OnFocusChangeListener;
import android.widget.ImageButton;
import android.widget.ImageView;
-import android.widget.ProgressBar;
/**
* This class represents a title bar for a particular "tab" or "window" in the
@@ -49,19 +45,13 @@ public class TitleBar extends TitleBarBase implements OnFocusChangeListener,
private Activity mActivity;
private ImageButton mBookmarkButton;
- private Drawable mCircularProgress;
- private ProgressBar mHorizontalProgress;
+ private PageProgressView mHorizontalProgress;
private ImageButton mStopButton;
private Drawable mBookmarkDrawable;
private Drawable mVoiceDrawable;
private boolean mInLoad;
- private View mTitleBg;
private Intent mVoiceSearchIntent;
- private Drawable mVoiceModeBackground;
- private Drawable mNormalBackground;
private ImageSpan mArcsSpan;
- private int mLeftMargin;
- private int mRightMargin;
public TitleBar(Activity activity, UiController controller, PhoneUi ui) {
super(activity, controller, ui);
@@ -77,7 +67,6 @@ public class TitleBar extends TitleBarBase implements OnFocusChangeListener,
mUrlInput.setUrlInputListener(this);
mUrlInput.setOnFocusChangeListener(this);
- mTitleBg = findViewById(R.id.title_bg);
mLockIcon = (ImageView) findViewById(R.id.lock);
mFavicon = (ImageView) findViewById(R.id.favicon);
mStopButton = (ImageButton) findViewById(R.id.stop);
@@ -85,18 +74,7 @@ public class TitleBar extends TitleBarBase implements OnFocusChangeListener,
mStopButton.setOnClickListener(this);
mBookmarkButton.setOnClickListener(this);
- Resources resources = activity.getResources();
- mCircularProgress = resources.getDrawable(
- com.android.internal.R.drawable.search_spinner);
- DisplayMetrics metrics = resources.getDisplayMetrics();
- mLeftMargin = (int) TypedValue.applyDimension(
- TypedValue.COMPLEX_UNIT_DIP, 8f, metrics);
- mRightMargin = (int) TypedValue.applyDimension(
- TypedValue.COMPLEX_UNIT_DIP, 6f, metrics);
- int iconDimension = (int) TypedValue.applyDimension(
- TypedValue.COMPLEX_UNIT_DIP, 20f, metrics);
- mCircularProgress.setBounds(0, 0, iconDimension, iconDimension);
- mHorizontalProgress = (ProgressBar) findViewById(
+ mHorizontalProgress = (PageProgressView) findViewById(
R.id.progress_horizontal);
mVoiceSearchIntent = new Intent(RecognizerIntent.ACTION_WEB_SEARCH);
mVoiceSearchIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
@@ -110,6 +88,7 @@ public class TitleBar extends TitleBarBase implements OnFocusChangeListener,
PackageManager pm = activity.getPackageManager();
ResolveInfo ri = pm.resolveActivity(mVoiceSearchIntent,
PackageManager.MATCH_DEFAULT_ONLY);
+ Resources resources = getResources();
if (ri == null) {
mVoiceSearchIntent = null;
} else {
@@ -117,9 +96,6 @@ public class TitleBar extends TitleBarBase implements OnFocusChangeListener,
android.R.drawable.ic_btn_speak_now);
}
mBookmarkDrawable = mBookmarkButton.getDrawable();
- mVoiceModeBackground = resources.getDrawable(
- R.drawable.title_voice);
- mNormalBackground = mTitleBg.getBackground();
mArcsSpan = new ImageSpan(activity, R.drawable.arcs,
ImageSpan.ALIGN_BASELINE);
}
@@ -142,13 +118,9 @@ public class TitleBar extends TitleBarBase implements OnFocusChangeListener,
Drawable titleDrawable;
if (mInVoiceMode) {
mBookmarkButton.setImageDrawable(mVoiceDrawable);
- titleDrawable = mVoiceModeBackground;
mUrlInput.setEllipsize(null);
mBookmarkButton.setVisibility(View.VISIBLE);
mStopButton.setVisibility(View.GONE);
- mTitleBg.setBackgroundDrawable(titleDrawable);
- mTitleBg.setPadding(mLeftMargin, mTitleBg.getPaddingTop(),
- mRightMargin, mTitleBg.getPaddingBottom());
} else {
if (mInLoad) {
mBookmarkButton.setVisibility(View.GONE);
@@ -159,7 +131,6 @@ public class TitleBar extends TitleBarBase implements OnFocusChangeListener,
mBookmarkButton.setImageDrawable(mBookmarkDrawable);
}
mUrlInput.setEllipsize(TextUtils.TruncateAt.END);
- mTitleBg.setPadding(mLeftMargin, 0, mRightMargin, 0);
}
mUrlInput.setSingleLine(!mInVoiceMode);
}
@@ -169,31 +140,20 @@ public class TitleBar extends TitleBarBase implements OnFocusChangeListener,
*/
@Override
void setProgress(int newProgress) {
- if (newProgress >= mHorizontalProgress.getMax()) {
- mUrlInput.setCompoundDrawables(null, null, null, null);
- ((Animatable) mCircularProgress).stop();
- mHorizontalProgress.setVisibility(View.INVISIBLE);
+ if (newProgress >= PROGRESS_MAX) {
+ mHorizontalProgress.setVisibility(View.GONE);
if (!mInVoiceMode) {
mBookmarkButton.setImageDrawable(mBookmarkDrawable);
mBookmarkButton.setVisibility(View.VISIBLE);
mStopButton.setVisibility(View.GONE);
- mTitleBg.setBackgroundDrawable(mNormalBackground);
- mTitleBg.setPadding(mLeftMargin, 0, mRightMargin, 0);
}
mInLoad = false;
} else {
- mHorizontalProgress.setProgress(newProgress);
- if (!mInLoad && getWindowToken() != null) {
- // checking the window token lets us be sure that we
- // are attached to a window before starting the animation,
- // preventing a potential race condition
- // (fix for bug http://b/2115736)
- mUrlInput.setCompoundDrawables(null, null, mCircularProgress,
- null);
- ((Animatable) mCircularProgress).start();
+ mHorizontalProgress.setProgress(newProgress * PageProgressView.MAX_PROGRESS
+ / PROGRESS_MAX);
+ if (!mInLoad) {
mHorizontalProgress.setVisibility(View.VISIBLE);
if (!mInVoiceMode) {
- mTitleBg.setPadding(mLeftMargin, 0, mRightMargin, 0);
mBookmarkButton.setVisibility(View.GONE);
mStopButton.setVisibility(View.VISIBLE);
}
@@ -243,4 +203,9 @@ public class TitleBar extends TitleBarBase implements OnFocusChangeListener,
true);
}
}
+
+ @Override
+ public void setCurrentUrlIsBookmark(boolean isBookmark) {
+ mBookmarkButton.setActivated(isBookmark);
+ }
}
diff --git a/src/com/android/browser/TitleBarBase.java b/src/com/android/browser/TitleBarBase.java
index f62e0e4..2b64aa3 100644
--- a/src/com/android/browser/TitleBarBase.java
+++ b/src/com/android/browser/TitleBarBase.java
@@ -39,6 +39,9 @@ import android.widget.LinearLayout;
* Base class for a title bar used by the browser.
*/
public class TitleBarBase extends LinearLayout implements UrlInputListener {
+
+ protected static final int PROGRESS_MAX = 100;
+
// These need to be set by the subclass.
protected ImageView mFavicon;
protected ImageView mLockIcon;
@@ -168,4 +171,7 @@ public class TitleBarBase extends LinearLayout implements UrlInputListener {
}
}
+ public void setCurrentUrlIsBookmark(boolean isBookmark) {
+ }
+
}
diff --git a/src/com/android/browser/TitleBarXLarge.java b/src/com/android/browser/TitleBarXLarge.java
index 3931526..c732da8 100644
--- a/src/com/android/browser/TitleBarXLarge.java
+++ b/src/com/android/browser/TitleBarXLarge.java
@@ -48,8 +48,6 @@ public class TitleBarXLarge extends TitleBarBase
implements OnClickListener, OnFocusChangeListener,
TextWatcher {
- private static final int PROGRESS_MAX = 100;
-
private XLargeUi mUi;
private Drawable mStopDrawable;
@@ -210,6 +208,7 @@ public class TitleBarXLarge extends TitleBarBase
mUrlInput.clearNeedsUpdate();
}
+ @Override
public void setCurrentUrlIsBookmark(boolean isBookmark) {
mStar.setActivated(isBookmark);
}
diff --git a/src/com/android/browser/XLargeUi.java b/src/com/android/browser/XLargeUi.java
index f361e57..90e3683 100644
--- a/src/com/android/browser/XLargeUi.java
+++ b/src/com/android/browser/XLargeUi.java
@@ -161,14 +161,6 @@ public class XLargeUi extends BaseUi implements ScrollListener {
// WebView callbacks
@Override
- public void bookmarkedStatusHasChanged(Tab tab) {
- if (tab.inForeground()) {
- boolean isBookmark = tab.isBookmarkedSite();
- mTitleBar.setCurrentUrlIsBookmark(isBookmark);
- }
- }
-
- @Override
public void onProgressChanged(Tab tab) {
int progress = tab.getLoadProgress();
mTabBar.onProgress(tab, progress);