--- /dev/null
+<?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>
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;
private boolean mInVoiceMode;
private Drawable mVoiceModeBackground;
private Drawable mNormalBackground;
+ private ImageSpan mArcsSpan;
private static int LONG_PRESS = 1;
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 {
rightButtonDrawable = mBookmarkDrawable;
}
}
+ mTitle.setSingleLine(!mInVoiceMode);
mTitleBg.setBackgroundDrawable(titleDrawable);
mRtButton.setImageDrawable(rightButtonDrawable);
}
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);
+ }
}
}