am d07ab27a: am 0dd0ea63: Merge "Always display the VoiceIME language in the Speak Now pop-up" into honeycomb

* commit 'd07ab27af1ef362b6d48275802cde97c97e858b3':
  Always display the VoiceIME language in the Speak Now pop-up
main
Satoshi Kataoka 2011-01-24 13:29:46 -08:00 committed by Android Git Automerger
commit 20d7142f21
2 changed files with 39 additions and 4 deletions

View File

@ -70,6 +70,22 @@
android:layout_centerInParent="true" android:layout_centerInParent="true"
android:visibility="gone"/> android:visibility="gone"/>
</RelativeLayout> </RelativeLayout>
<!--
The text is set by the code. We specify a random text (voice_error), so the
text view does not have a zero height. This is necessary to keep the slash
mic and the recording mic is the same position
-->
<TextView
android:id="@+id/language"
android:text="@string/voice_error"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:singleLine="true"
android:textSize="14sp"
android:layout_marginBottom="3dip"
android:layout_gravity="center"
android:textColor="#ffffff"
android:visibility="invisible"/>
<Button <Button
android:id="@+id/button" android:id="@+id/button"
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@ -16,6 +16,9 @@
package com.android.inputmethod.voice; package com.android.inputmethod.voice;
import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.SubtypeSwitcher;
import android.content.Context; import android.content.Context;
import android.content.res.Resources; import android.content.res.Resources;
import android.graphics.Bitmap; import android.graphics.Bitmap;
@ -35,13 +38,11 @@ import android.widget.ImageView;
import android.widget.ProgressBar; import android.widget.ProgressBar;
import android.widget.TextView; import android.widget.TextView;
import com.android.inputmethod.latin.R;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.ByteOrder; import java.nio.ByteOrder;
import java.nio.ShortBuffer; import java.nio.ShortBuffer;
import java.util.List; import java.util.Locale;
/** /**
* The user interface for the "Speak now" and "working" states. * The user interface for the "Speak now" and "working" states.
@ -60,6 +61,7 @@ public class RecognitionView {
private ImageView mImage; private ImageView mImage;
private View mProgress; private View mProgress;
private SoundIndicator mSoundIndicator; private SoundIndicator mSoundIndicator;
private TextView mLanguage;
private Button mButton; private Button mButton;
private Drawable mInitializing; private Drawable mInitializing;
@ -105,6 +107,7 @@ public class RecognitionView {
mButton = (Button) mView.findViewById(R.id.button); mButton = (Button) mView.findViewById(R.id.button);
mButton.setOnClickListener(clickListener); mButton.setOnClickListener(clickListener);
mText = (TextView) mView.findViewById(R.id.text); mText = (TextView) mView.findViewById(R.id.text);
mLanguage = (TextView) mView.findViewById(R.id.language);
mContext = context; mContext = context;
} }
@ -184,9 +187,14 @@ public class RecognitionView {
private void prepareDialog(CharSequence text, Drawable image, private void prepareDialog(CharSequence text, Drawable image,
CharSequence btnTxt) { CharSequence btnTxt) {
/*
* The mic of INIT and of LISTENING has to be displayed in the same position. To accomplish
* that, some text visibility are not set as GONE but as INVISIBLE.
*/
switch (mState) { switch (mState) {
case INIT: case INIT:
mText.setVisibility(View.GONE); mText.setVisibility(View.INVISIBLE);
mProgress.setVisibility(View.GONE); mProgress.setVisibility(View.GONE);
@ -196,6 +204,8 @@ public class RecognitionView {
mSoundIndicator.setVisibility(View.GONE); mSoundIndicator.setVisibility(View.GONE);
mSoundIndicator.stop(); mSoundIndicator.stop();
mLanguage.setVisibility(View.INVISIBLE);
mPopupLayout.setBackgroundDrawable(mListeningBorder); mPopupLayout.setBackgroundDrawable(mListeningBorder);
break; break;
case LISTENING: case LISTENING:
@ -209,6 +219,11 @@ public class RecognitionView {
mSoundIndicator.setVisibility(View.VISIBLE); mSoundIndicator.setVisibility(View.VISIBLE);
mSoundIndicator.start(); mSoundIndicator.start();
Locale locale = SubtypeSwitcher.getInstance().getInputLocale();
mLanguage.setVisibility(View.VISIBLE);
mLanguage.setText(SubtypeSwitcher.getFullDisplayName(locale, true));
mPopupLayout.setBackgroundDrawable(mListeningBorder); mPopupLayout.setBackgroundDrawable(mListeningBorder);
break; break;
case WORKING: case WORKING:
@ -223,6 +238,8 @@ public class RecognitionView {
mSoundIndicator.setVisibility(View.GONE); mSoundIndicator.setVisibility(View.GONE);
mSoundIndicator.stop(); mSoundIndicator.stop();
mLanguage.setVisibility(View.GONE);
mPopupLayout.setBackgroundDrawable(mWorkingBorder); mPopupLayout.setBackgroundDrawable(mWorkingBorder);
break; break;
case READY: case READY:
@ -237,6 +254,8 @@ public class RecognitionView {
mSoundIndicator.setVisibility(View.GONE); mSoundIndicator.setVisibility(View.GONE);
mSoundIndicator.stop(); mSoundIndicator.stop();
mLanguage.setVisibility(View.GONE);
mPopupLayout.setBackgroundDrawable(mErrorBorder); mPopupLayout.setBackgroundDrawable(mErrorBorder);
break; break;
default: default: