diff options
author | John Reck <jreck@google.com> | 2011-02-15 11:31:56 -0800 |
---|---|---|
committer | John Reck <jreck@google.com> | 2011-02-15 12:54:26 -0800 |
commit | bb2a345e610ef6600a3708f0d27c9cddb2d7c182 (patch) | |
tree | 5fec2fc1dd3200fea767d58cedc2573a7adaf888 /src/com/android/browser/TitleBar.java | |
parent | 9b20d738a36f883dae29bd08e35eef25e99310f9 (diff) | |
download | android_packages_apps_Gello-bb2a345e610ef6600a3708f0d27c9cddb2d7c182.tar.gz android_packages_apps_Gello-bb2a345e610ef6600a3708f0d27c9cddb2d7c182.tar.bz2 android_packages_apps_Gello-bb2a345e610ef6600a3708f0d27c9cddb2d7c182.zip |
Fix title bar button handling on phone
Change-Id: I1bf298b93a54dd379a06d4752ae4ea7a65ad6950
Diffstat (limited to 'src/com/android/browser/TitleBar.java')
-rw-r--r-- | src/com/android/browser/TitleBar.java | 42 |
1 files changed, 28 insertions, 14 deletions
diff --git a/src/com/android/browser/TitleBar.java b/src/com/android/browser/TitleBar.java index 7b5482a7..56db187c 100644 --- a/src/com/android/browser/TitleBar.java +++ b/src/com/android/browser/TitleBar.java @@ -34,6 +34,7 @@ import android.view.ContextMenu; import android.view.LayoutInflater; import android.view.MenuInflater; import android.view.View; +import android.view.View.OnClickListener; import android.view.View.OnFocusChangeListener; import android.widget.ImageButton; import android.widget.ImageView; @@ -43,13 +44,14 @@ import android.widget.ProgressBar; * This class represents a title bar for a particular "tab" or "window" in the * browser. */ -public class TitleBar extends TitleBarBase implements OnFocusChangeListener { +public class TitleBar extends TitleBarBase implements OnFocusChangeListener, + OnClickListener { private Activity mActivity; - private ImageButton mRtButton; + private ImageButton mBookmarkButton; private Drawable mCircularProgress; private ProgressBar mHorizontalProgress; - private ImageView mStopButton; + private ImageButton mStopButton; private Drawable mBookmarkDrawable; private Drawable mVoiceDrawable; private boolean mInLoad; @@ -78,9 +80,11 @@ public class TitleBar extends TitleBarBase implements OnFocusChangeListener { mTitleBg = findViewById(R.id.title_bg); mLockIcon = (ImageView) findViewById(R.id.lock); mFavicon = (ImageView) findViewById(R.id.favicon); - mStopButton = (ImageView) findViewById(R.id.stop); + mStopButton = (ImageButton) findViewById(R.id.stop); + mBookmarkButton = (ImageButton) findViewById(R.id.bookmark); + mStopButton.setOnClickListener(this); + mBookmarkButton.setOnClickListener(this); - mRtButton = (ImageButton) findViewById(R.id.rt_btn); Resources resources = activity.getResources(); mCircularProgress = resources.getDrawable( com.android.internal.R.drawable.search_spinner); @@ -112,7 +116,7 @@ public class TitleBar extends TitleBarBase implements OnFocusChangeListener { mVoiceDrawable = resources.getDrawable( android.R.drawable.ic_btn_speak_now); } - mBookmarkDrawable = mRtButton.getDrawable(); + mBookmarkDrawable = mBookmarkButton.getDrawable(); mVoiceModeBackground = resources.getDrawable( R.drawable.title_voice); mNormalBackground = mTitleBg.getBackground(); @@ -137,22 +141,22 @@ public class TitleBar extends TitleBarBase implements OnFocusChangeListener { mInVoiceMode = inVoiceMode && mVoiceSearchIntent != null; Drawable titleDrawable; if (mInVoiceMode) { - mRtButton.setImageDrawable(mVoiceDrawable); + mBookmarkButton.setImageDrawable(mVoiceDrawable); titleDrawable = mVoiceModeBackground; mUrlInput.setEllipsize(null); - mRtButton.setVisibility(View.VISIBLE); + mBookmarkButton.setVisibility(View.VISIBLE); mStopButton.setVisibility(View.GONE); mTitleBg.setBackgroundDrawable(titleDrawable); mTitleBg.setPadding(mLeftMargin, mTitleBg.getPaddingTop(), mRightMargin, mTitleBg.getPaddingBottom()); } else { if (mInLoad) { - mRtButton.setVisibility(View.GONE); + mBookmarkButton.setVisibility(View.GONE); mStopButton.setVisibility(View.VISIBLE); } else { - mRtButton.setVisibility(View.VISIBLE); + mBookmarkButton.setVisibility(View.VISIBLE); mStopButton.setVisibility(View.GONE); - mRtButton.setImageDrawable(mBookmarkDrawable); + mBookmarkButton.setImageDrawable(mBookmarkDrawable); } mUrlInput.setEllipsize(TextUtils.TruncateAt.END); mTitleBg.setPadding(mLeftMargin, 0, mRightMargin, 0); @@ -170,8 +174,8 @@ public class TitleBar extends TitleBarBase implements OnFocusChangeListener { ((Animatable) mCircularProgress).stop(); mHorizontalProgress.setVisibility(View.INVISIBLE); if (!mInVoiceMode) { - mRtButton.setImageDrawable(mBookmarkDrawable); - mRtButton.setVisibility(View.VISIBLE); + mBookmarkButton.setImageDrawable(mBookmarkDrawable); + mBookmarkButton.setVisibility(View.VISIBLE); mStopButton.setVisibility(View.GONE); mTitleBg.setBackgroundDrawable(mNormalBackground); mTitleBg.setPadding(mLeftMargin, 0, mRightMargin, 0); @@ -190,7 +194,7 @@ public class TitleBar extends TitleBarBase implements OnFocusChangeListener { mHorizontalProgress.setVisibility(View.VISIBLE); if (!mInVoiceMode) { mTitleBg.setPadding(mLeftMargin, 0, mRightMargin, 0); - mRtButton.setVisibility(View.GONE); + mBookmarkButton.setVisibility(View.GONE); mStopButton.setVisibility(View.VISIBLE); } mInLoad = true; @@ -229,4 +233,14 @@ public class TitleBar extends TitleBarBase implements OnFocusChangeListener { mActivity.closeOptionsMenu(); } } + + @Override + public void onClick(View v) { + if (v == mStopButton) { + mUiController.stopLoading(); + } else if (v == mBookmarkButton) { + mUiController.bookmarkCurrentPage(AddBookmarkPage.DEFAULT_FOLDER_ID, + true); + } + } } |