am 8505d4a5: Merge "Disable voice input if assist is voice service" into mnc-dev

* commit '8505d4a51d1112ea71f7df680cf85378a9567bde':
  Disable voice input if assist is voice service
This commit is contained in:
Jorim Jaggi
2015-07-14 18:05:05 +00:00
committed by Android Git Automerger
2 changed files with 24 additions and 2 deletions

View File

@@ -104,6 +104,7 @@ public class ManageAssist extends SettingsPreferenceFragment
private void updateUi() {
mDefaultAssitPref.refreshAssistApps();
mVoiceInputPref.refreshVoiceInputs();
final ComponentName currentAssist = mDefaultAssitPref.getCurrentAssist();
final boolean hasAssistant = currentAssist != null;
@@ -115,8 +116,19 @@ public class ManageAssist extends SettingsPreferenceFragment
getPreferenceScreen().removePreference(mScreenshotPref);
}
if (isCurrentAssistVoiceService()) {
getPreferenceScreen().removePreference(mVoiceInputPref);
} else {
getPreferenceScreen().addPreference(mVoiceInputPref);
mVoiceInputPref.setAssistRestrict(currentAssist);
mVoiceInputPref.refreshVoiceInputs();
}
}
private boolean isCurrentAssistVoiceService() {
ComponentName currentAssist = mDefaultAssitPref.getCurrentAssist();
ComponentName activeService = mVoiceInputPref.getCurrentService();
return currentAssist == null && activeService == null ||
currentAssist != null && currentAssist.equals(activeService);
}
private void confirmNewAssist(final String newAssitPackage) {

View File

@@ -121,6 +121,16 @@ public class VoiceInputListPreference extends AppListPreferenceWithSettings {
}
}
public ComponentName getCurrentService() {
if (mHelper.mCurrentVoiceInteraction != null) {
return mHelper.mCurrentVoiceInteraction;
} else if (mHelper.mCurrentRecognizer != null) {
return mHelper.mCurrentRecognizer;
} else {
return null;
}
}
private class CustomAdapter extends ArrayAdapter<CharSequence> {
public CustomAdapter(Context context, CharSequence[] objects) {