Assist: Allow disabling the disclosure animation am: fff9fd87bf

am: cea8891d5a

Change-Id: Ib18f9a866942cc40752b7ff36d2cd6a2aa6e7084
This commit is contained in:
Adrian Roos
2016-08-12 23:18:32 +00:00
committed by android-build-merger
3 changed files with 47 additions and 10 deletions

View File

@@ -6955,6 +6955,11 @@
<!-- Summary for the "screenshot" preference to determine whether assist can access the screenshot of your screen [CHAR LIMIT=NONE] --> <!-- Summary for the "screenshot" preference to determine whether assist can access the screenshot of your screen [CHAR LIMIT=NONE] -->
<string name="assist_access_screenshot_summary">Allow the assist app to access an image of the screen</string> <string name="assist_access_screenshot_summary">Allow the assist app to access an image of the screen</string>
<!-- Title for the "flash" preference to determine whether a flash is shown on screen when an assistant accesses the contents of the screeen. [CHAR LIMIT=40] -->
<string name="assist_flash_title">Flash screen</string>
<!-- Summary for the "flash" preference to determine whether a flash is shown on screen when an assistant accesses the contents of the screeen. [CHAR LIMIT=NONE] -->
<string name="assist_flash_summary">Flash edges of screen when assist app accesses text from screen or screenshot</string>
<!-- Footer text in the manage assist screen. [CHAR LIMIT=NONE] --> <!-- Footer text in the manage assist screen. [CHAR LIMIT=NONE] -->
<string name="assist_footer">Assist apps can help you based on information from the screen you\u2019re viewing. Some apps support both launcher and voice input services to give you integrated assistance.</string> <string name="assist_footer">Assist apps can help you based on information from the screen you\u2019re viewing. Some apps support both launcher and voice input services to give you integrated assistance.</string>
@@ -7763,4 +7768,5 @@
<string name="automatic_storage_manager_freed_bytes"><xliff:g id="size" example="3.25MB">%1$s</xliff:g> total made available\n\nLast ran on <xliff:g id="date" example="Jan 12">%2$s</xliff:g></string> <string name="automatic_storage_manager_freed_bytes"><xliff:g id="size" example="3.25MB">%1$s</xliff:g> total made available\n\nLast ran on <xliff:g id="date" example="Jan 12">%2$s</xliff:g></string>
</resources> </resources>

View File

@@ -36,6 +36,12 @@
android:title="@string/assist_access_screenshot_title" android:title="@string/assist_access_screenshot_title"
android:summary="@string/assist_access_screenshot_summary"/> android:summary="@string/assist_access_screenshot_summary"/>
<SwitchPreference
android:key="flash"
android:title="@string/assist_flash_title"
android:summary="@string/assist_flash_summary"
/>
<com.android.settings.voice.VoiceInputListPreference <com.android.settings.voice.VoiceInputListPreference
android:key="voice_input_settings" android:key="voice_input_settings"
android:title="@string/voice_input_settings_title" android:title="@string/voice_input_settings_title"

View File

@@ -24,6 +24,8 @@ import android.os.Handler;
import android.provider.Settings; import android.provider.Settings;
import android.support.v14.preference.SwitchPreference; import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference; import android.support.v7.preference.Preference;
import com.android.internal.app.AssistUtils;
import com.android.internal.logging.MetricsProto.MetricsEvent; import com.android.internal.logging.MetricsProto.MetricsEvent;
import com.android.settings.R; import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment; import com.android.settings.SettingsPreferenceFragment;
@@ -39,10 +41,12 @@ public class ManageAssist extends SettingsPreferenceFragment
private static final String KEY_CONTEXT = "context"; private static final String KEY_CONTEXT = "context";
private static final String KEY_SCREENSHOT = "screenshot"; private static final String KEY_SCREENSHOT = "screenshot";
private static final String KEY_VOICE_INPUT = "voice_input_settings"; private static final String KEY_VOICE_INPUT = "voice_input_settings";
private static final String KEY_FLASH = "flash";
private DefaultAssistPreference mDefaultAssitPref; private DefaultAssistPreference mDefaultAssitPref;
private SwitchPreference mContextPref; private SwitchPreference mContextPref;
private SwitchPreference mScreenshotPref; private SwitchPreference mScreenshotPref;
private SwitchPreference mFlashPref;
private VoiceInputListPreference mVoiceInputPref; private VoiceInputListPreference mVoiceInputPref;
private Handler mHandler = new Handler(); private Handler mHandler = new Handler();
@@ -62,6 +66,9 @@ public class ManageAssist extends SettingsPreferenceFragment
mScreenshotPref = (SwitchPreference) findPreference(KEY_SCREENSHOT); mScreenshotPref = (SwitchPreference) findPreference(KEY_SCREENSHOT);
mScreenshotPref.setOnPreferenceChangeListener(this); mScreenshotPref.setOnPreferenceChangeListener(this);
mFlashPref = (SwitchPreference) findPreference(KEY_FLASH);
mFlashPref.setOnPreferenceChangeListener(this);
mVoiceInputPref = (VoiceInputListPreference) findPreference(KEY_VOICE_INPUT); mVoiceInputPref = (VoiceInputListPreference) findPreference(KEY_VOICE_INPUT);
updateUi(); updateUi();
} }
@@ -76,7 +83,10 @@ public class ManageAssist extends SettingsPreferenceFragment
if (preference == mContextPref) { if (preference == mContextPref) {
Settings.Secure.putInt(getContentResolver(), Settings.Secure.ASSIST_STRUCTURE_ENABLED, Settings.Secure.putInt(getContentResolver(), Settings.Secure.ASSIST_STRUCTURE_ENABLED,
(boolean) newValue ? 1 : 0); (boolean) newValue ? 1 : 0);
postGuardScreenshotPref(); mHandler.post(() -> {
guardScreenshotPref();
guardFlashPref();
});
return true; return true;
} }
if (preference == mScreenshotPref) { if (preference == mScreenshotPref) {
@@ -84,6 +94,11 @@ public class ManageAssist extends SettingsPreferenceFragment
(boolean) newValue ? 1 : 0); (boolean) newValue ? 1 : 0);
return true; return true;
} }
if (preference == mFlashPref) {
Settings.Secure.putInt(getContentResolver(), Settings.Secure.ASSIST_DISCLOSURE_ENABLED,
(boolean) newValue ? 1 : 0);
return true;
}
if (preference == mDefaultAssitPref) { if (preference == mDefaultAssitPref) {
String newAssitPackage = (String)newValue; String newAssitPackage = (String)newValue;
if (newAssitPackage == null || if (newAssitPackage == null ||
@@ -101,15 +116,6 @@ public class ManageAssist extends SettingsPreferenceFragment
return false; return false;
} }
private void postGuardScreenshotPref() {
mHandler.post(new Runnable() {
@Override
public void run() {
guardScreenshotPref();
}
});
}
private void guardScreenshotPref() { private void guardScreenshotPref() {
boolean isChecked = mContextPref.isChecked(); boolean isChecked = mContextPref.isChecked();
boolean screenshotPrefWasSet = Settings.Secure.getInt( boolean screenshotPrefWasSet = Settings.Secure.getInt(
@@ -118,6 +124,17 @@ public class ManageAssist extends SettingsPreferenceFragment
mScreenshotPref.setChecked(isChecked && screenshotPrefWasSet); mScreenshotPref.setChecked(isChecked && screenshotPrefWasSet);
} }
private void guardFlashPref() {
ComponentName assistant = mDefaultAssitPref.getCurrentAssist();
boolean isContextChecked = mContextPref.isChecked();
boolean willShowFlash = AssistUtils.shouldDisclose(getContext(), assistant);
boolean isSystemAssistant = AssistUtils.isPreinstalledAssistant(getContext(), assistant);
mFlashPref.setEnabled(isContextChecked && isSystemAssistant);
mFlashPref.setChecked(willShowFlash);
}
private void updateUi() { private void updateUi() {
mDefaultAssitPref.refreshAssistApps(); mDefaultAssitPref.refreshAssistApps();
mVoiceInputPref.refreshVoiceInputs(); mVoiceInputPref.refreshVoiceInputs();
@@ -130,6 +147,13 @@ public class ManageAssist extends SettingsPreferenceFragment
} else { } else {
getPreferenceScreen().removePreference(mContextPref); getPreferenceScreen().removePreference(mContextPref);
getPreferenceScreen().removePreference(mScreenshotPref); getPreferenceScreen().removePreference(mScreenshotPref);
getPreferenceScreen().removePreference(mFlashPref);
}
if (hasAssistant && AssistUtils.allowDisablingAssistDisclosure(getContext())) {
getPreferenceScreen().addPreference(mFlashPref);
} else {
getPreferenceScreen().removePreference(mFlashPref);
} }
if (isCurrentAssistVoiceService()) { if (isCurrentAssistVoiceService()) {
@@ -140,6 +164,7 @@ public class ManageAssist extends SettingsPreferenceFragment
} }
guardScreenshotPref(); guardScreenshotPref();
guardFlashPref();
} }
private boolean isCurrentAssistVoiceService() { private boolean isCurrentAssistVoiceService() {