parent
a2bb8e8400
commit
9a1d6a1c6b
|
@ -158,7 +158,10 @@ public class VoiceProxy implements VoiceInput.UiListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void flushVoiceInputLogs(boolean configurationChanged) {
|
public void flushVoiceInputLogs(boolean configurationChanged) {
|
||||||
if (VOICE_INSTALLED && !configurationChanged) {
|
if (!VOICE_INSTALLED) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!configurationChanged) {
|
||||||
if (mAfterVoiceInput) {
|
if (mAfterVoiceInput) {
|
||||||
mVoiceInput.flushAllTextModificationCounters();
|
mVoiceInput.flushAllTextModificationCounters();
|
||||||
mVoiceInput.logInputEnded();
|
mVoiceInput.logInputEnded();
|
||||||
|
@ -301,6 +304,9 @@ public class VoiceProxy implements VoiceInput.UiListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showPunctuationHintIfNecessary() {
|
public void showPunctuationHintIfNecessary() {
|
||||||
|
if (!VOICE_INSTALLED) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
InputConnection ic = mService.getCurrentInputConnection();
|
InputConnection ic = mService.getCurrentInputConnection();
|
||||||
if (!mImmediatelyAfterVoiceInput && mAfterVoiceInput && ic != null) {
|
if (!mImmediatelyAfterVoiceInput && mAfterVoiceInput && ic != null) {
|
||||||
if (mHints.showPunctuationHintIfNecessary(ic)) {
|
if (mHints.showPunctuationHintIfNecessary(ic)) {
|
||||||
|
@ -375,9 +381,6 @@ public class VoiceProxy implements VoiceInput.UiListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void revertVoiceInput() {
|
private void revertVoiceInput() {
|
||||||
if (!VOICE_INSTALLED) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
InputConnection ic = mService.getCurrentInputConnection();
|
InputConnection ic = mService.getCurrentInputConnection();
|
||||||
if (ic != null) ic.commitText("", 1);
|
if (ic != null) ic.commitText("", 1);
|
||||||
mService.updateSuggestions();
|
mService.updateSuggestions();
|
||||||
|
@ -394,7 +397,10 @@ public class VoiceProxy implements VoiceInput.UiListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean logAndRevertVoiceInput() {
|
public boolean logAndRevertVoiceInput() {
|
||||||
if (VOICE_INSTALLED && mVoiceInputHighlighted) {
|
if (!VOICE_INSTALLED) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (mVoiceInputHighlighted) {
|
||||||
mVoiceInput.incrementTextModificationDeleteCount(
|
mVoiceInput.incrementTextModificationDeleteCount(
|
||||||
mVoiceResults.candidates.get(0).toString().length());
|
mVoiceResults.candidates.get(0).toString().length());
|
||||||
revertVoiceInput();
|
revertVoiceInput();
|
||||||
|
@ -505,7 +511,10 @@ public class VoiceProxy implements VoiceInput.UiListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleClose() {
|
public void handleClose() {
|
||||||
if (VOICE_INSTALLED & mRecognizing) {
|
if (!VOICE_INSTALLED) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (mRecognizing) {
|
||||||
mVoiceInput.cancel();
|
mVoiceInput.cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -553,6 +562,9 @@ public class VoiceProxy implements VoiceInput.UiListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void switchToRecognitionStatusView(final Configuration configuration) {
|
public void switchToRecognitionStatusView(final Configuration configuration) {
|
||||||
|
if (!VOICE_INSTALLED) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
mHandler.post(new Runnable() {
|
mHandler.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -597,6 +609,9 @@ public class VoiceProxy implements VoiceInput.UiListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void switchToLastInputMethod() {
|
private void switchToLastInputMethod() {
|
||||||
|
if (!VOICE_INSTALLED) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
final IBinder token = mService.getWindow().getWindow().getAttributes().token;
|
final IBinder token = mService.getWindow().getWindow().getAttributes().token;
|
||||||
new AsyncTask<Void, Void, Boolean>() {
|
new AsyncTask<Void, Void, Boolean>() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -662,8 +677,10 @@ public class VoiceProxy implements VoiceInput.UiListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startListening(final boolean swipe, IBinder token) {
|
public void startListening(final boolean swipe, IBinder token) {
|
||||||
|
if (!VOICE_INSTALLED) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
// TODO: remove swipe which is no longer used.
|
// TODO: remove swipe which is no longer used.
|
||||||
if (VOICE_INSTALLED) {
|
|
||||||
if (needsToShowWarningDialog()) {
|
if (needsToShowWarningDialog()) {
|
||||||
// Calls reallyStartListening if user clicks OK, does nothing if user clicks Cancel.
|
// Calls reallyStartListening if user clicks OK, does nothing if user clicks Cancel.
|
||||||
showVoiceWarningDialog(swipe, token);
|
showVoiceWarningDialog(swipe, token);
|
||||||
|
@ -671,7 +688,6 @@ public class VoiceProxy implements VoiceInput.UiListener {
|
||||||
reallyStartListening(swipe);
|
reallyStartListening(swipe);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private boolean fieldCanDoVoice(FieldContext fieldContext) {
|
private boolean fieldCanDoVoice(FieldContext fieldContext) {
|
||||||
return !mPasswordText
|
return !mPasswordText
|
||||||
|
@ -704,17 +720,18 @@ public class VoiceProxy implements VoiceInput.UiListener {
|
||||||
mLocaleSupportedForVoiceInput = SubtypeSwitcher.getInstance().isVoiceSupported(
|
mLocaleSupportedForVoiceInput = SubtypeSwitcher.getInstance().isVoiceSupported(
|
||||||
SubtypeSwitcher.getInstance().getInputLocaleStr());
|
SubtypeSwitcher.getInstance().getInputLocaleStr());
|
||||||
|
|
||||||
if (VOICE_INSTALLED) {
|
|
||||||
final String voiceMode = sp.getString(PREF_VOICE_MODE,
|
final String voiceMode = sp.getString(PREF_VOICE_MODE,
|
||||||
mService.getString(R.string.voice_mode_main));
|
mService.getString(R.string.voice_mode_main));
|
||||||
mVoiceButtonEnabled = !voiceMode.equals(mService.getString(R.string.voice_mode_off))
|
mVoiceButtonEnabled = !voiceMode.equals(mService.getString(R.string.voice_mode_off))
|
||||||
&& shouldShowVoiceButton(makeFieldContext(), attribute);
|
&& shouldShowVoiceButton(makeFieldContext(), attribute);
|
||||||
mVoiceButtonOnPrimary = voiceMode.equals(mService.getString(R.string.voice_mode_main));
|
mVoiceButtonOnPrimary = voiceMode.equals(mService.getString(R.string.voice_mode_main));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void destroy() {
|
public void destroy() {
|
||||||
if (VOICE_INSTALLED && mVoiceInput != null) {
|
if (!VOICE_INSTALLED) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (mVoiceInput != null) {
|
||||||
mVoiceInput.destroy();
|
mVoiceInput.destroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -826,10 +843,16 @@ public class VoiceProxy implements VoiceInput.UiListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cancel() {
|
public void cancel() {
|
||||||
|
if (!VOICE_INSTALLED) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (mVoiceInput != null) mVoiceInput.cancel();
|
if (mVoiceInput != null) mVoiceInput.cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reset() {
|
public void reset() {
|
||||||
|
if (!VOICE_INSTALLED) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (mVoiceInput != null) mVoiceInput.reset();
|
if (mVoiceInput != null) mVoiceInput.reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue