diff options
| author | Leon Scroggins <scroggo@google.com> | 2010-02-08 07:36:05 -0800 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2010-02-08 07:36:05 -0800 |
| commit | 7212e0d00ffd8038baa1e9ea0609d5e0e68590fa (patch) | |
| tree | ea05e5766b918b0cc968224afa9ca12d3344d6c6 | |
| parent | efe5fc95a5f8d958df2e55be2379c32b094f2bca (diff) | |
| parent | f48d44ea4292563616e7f29b50ea94aeaff4fa3c (diff) | |
| download | packages_apps_Browser-7212e0d00ffd8038baa1e9ea0609d5e0e68590fa.tar.gz packages_apps_Browser-7212e0d00ffd8038baa1e9ea0609d5e0e68590fa.tar.bz2 packages_apps_Browser-7212e0d00ffd8038baa1e9ea0609d5e0e68590fa.zip | |
Merge "Update look of title bar when in voice search mode."
| -rw-r--r-- | res/drawable-hdpi/arcs.png | bin | 0 -> 472 bytes | |||
| -rw-r--r-- | res/drawable-mdpi/arcs.png | bin | 0 -> 421 bytes | |||
| -rw-r--r-- | res/drawable/title_voice.xml | 22 | ||||
| -rw-r--r-- | src/com/android/browser/TitleBar.java | 22 |
4 files changed, 42 insertions, 2 deletions
diff --git a/res/drawable-hdpi/arcs.png b/res/drawable-hdpi/arcs.png Binary files differnew file mode 100644 index 000000000..9555a9f11 --- /dev/null +++ b/res/drawable-hdpi/arcs.png diff --git a/res/drawable-mdpi/arcs.png b/res/drawable-mdpi/arcs.png Binary files differnew file mode 100644 index 000000000..5e0d94984 --- /dev/null +++ b/res/drawable-mdpi/arcs.png diff --git a/res/drawable/title_voice.xml b/res/drawable/title_voice.xml new file mode 100644 index 000000000..0bb1ad375 --- /dev/null +++ b/res/drawable/title_voice.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2010 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<selector xmlns:android="http://schemas.android.com/apk/res/android"> + <item android:state_pressed="true" + android:drawable="@*android:drawable/textfield_pressed" /> + <item android:state_pressed="false" + android:drawable="@drawable/textfield_voice_search" /> +</selector> diff --git a/src/com/android/browser/TitleBar.java b/src/com/android/browser/TitleBar.java index 743af9b0c..b86073bc4 100644 --- a/src/com/android/browser/TitleBar.java +++ b/src/com/android/browser/TitleBar.java @@ -32,6 +32,9 @@ import android.graphics.drawable.PaintDrawable; import android.os.Handler; import android.os.Message; import android.speech.RecognizerIntent; +import android.text.SpannableString; +import android.text.Spanned; +import android.text.style.ImageSpan; import android.util.TypedValue; import android.view.ContextMenu; import android.view.LayoutInflater; @@ -69,6 +72,7 @@ public class TitleBar extends LinearLayout { private boolean mInVoiceMode; private Drawable mVoiceModeBackground; private Drawable mNormalBackground; + private ImageSpan mArcsSpan; private static int LONG_PRESS = 1; @@ -113,8 +117,10 @@ public class TitleBar extends LinearLayout { mStopDrawable = resources.getDrawable(R.drawable.ic_btn_stop_v2); mBookmarkDrawable = mRtButton.getDrawable(); mVoiceModeBackground = resources.getDrawable( - R.drawable.textfield_voice_search); + R.drawable.title_voice); mNormalBackground = mTitleBg.getBackground(); + mArcsSpan = new ImageSpan(context, R.drawable.arcs, + ImageSpan.ALIGN_BASELINE); } private class MyHandler extends Handler { @@ -244,6 +250,7 @@ public class TitleBar extends LinearLayout { rightButtonDrawable = mBookmarkDrawable; } } + mTitle.setSingleLine(!mInVoiceMode); mTitleBg.setBackgroundDrawable(titleDrawable); mRtButton.setImageDrawable(rightButtonDrawable); } @@ -300,7 +307,18 @@ public class TitleBar extends LinearLayout { if (title == null) { mTitle.setText(R.string.title_bar_loading); } else { - mTitle.setText(title); + if (mInVoiceMode) { + // Add two spaces. The second one will be replaced with an + // image, and the first one will put space between it and the + // text + SpannableString spannable = new SpannableString(title + " "); + int end = spannable.length(); + spannable.setSpan(mArcsSpan, end - 1, end, + Spanned.SPAN_MARK_POINT); + mTitle.setText(spannable); + } else { + mTitle.setText(title); + } } } |
