diff options
author | Peter_Liang <peterliang@google.com> | 2020-05-13 16:31:53 +0800 |
---|---|---|
committer | Peter_Liang <peterliang@google.com> | 2020-05-18 19:04:28 +0800 |
commit | f78e7f59760372b65dfb8c38b15f96d9083752b7 (patch) | |
tree | 1362487ba0a0b5af14fade1621a623de33896c3a /src/com/android/settings/accessibility | |
parent | 966f0527acd651b9bf8cedfed2c643d7937f5ef3 (diff) | |
download | packages_apps_Settings-f78e7f59760372b65dfb8c38b15f96d9083752b7.tar.gz packages_apps_Settings-f78e7f59760372b65dfb8c38b15f96d9083752b7.tar.bz2 packages_apps_Settings-f78e7f59760372b65dfb8c38b15f96d9083752b7.zip |
Refine the banner view for accessibility features.
1. Replace the video with the gif for Magnification.
2. Replace the static image with the gif for Color Inversion.
Bug: 153293657
Bug: 155946967
Test: manual test & robo test
Change-Id: Ic51c0ec45c10a7fd2b9f1ffb63865ebc764846ba
Merged-In: Ic51c0ec45c10a7fd2b9f1ffb63865ebc764846ba
Diffstat (limited to 'src/com/android/settings/accessibility')
-rw-r--r-- | src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java | 118 |
1 files changed, 4 insertions, 114 deletions
diff --git a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java index 262165aab0..0b221e561d 100644 --- a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java +++ b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java @@ -25,11 +25,7 @@ import android.app.settings.SettingsEnums; import android.content.ContentResolver; import android.content.Context; import android.content.DialogInterface; -import android.content.res.Resources; import android.icu.text.CaseMap; -import android.media.AudioManager; -import android.media.MediaPlayer; -import android.media.MediaPlayer.OnPreparedListener; import android.net.Uri; import android.os.Bundle; import android.provider.Settings; @@ -37,18 +33,11 @@ import android.text.TextUtils; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.view.ViewTreeObserver.OnGlobalLayoutListener; import android.view.accessibility.AccessibilityManager; import android.view.accessibility.AccessibilityManager.TouchExplorationStateChangeListener; import android.widget.CheckBox; -import android.widget.ImageView; -import android.widget.RelativeLayout.LayoutParams; -import android.widget.VideoView; import androidx.appcompat.app.AlertDialog; -import androidx.preference.Preference; -import androidx.preference.PreferenceScreen; -import androidx.preference.PreferenceViewHolder; import com.android.internal.annotations.VisibleForTesting; import com.android.settings.R; @@ -83,83 +72,6 @@ public class ToggleScreenMagnificationPreferenceFragment extends private static final char COMPONENT_NAME_SEPARATOR = ':'; private static final TextUtils.SimpleStringSplitter sStringColonSplitter = new TextUtils.SimpleStringSplitter(COMPONENT_NAME_SEPARATOR); - protected VideoPreference mVideoPreference; - - protected class VideoPreference extends Preference { - private ImageView mVideoBackgroundView; - private OnGlobalLayoutListener mLayoutListener; - - public VideoPreference(Context context) { - super(context); - } - - @Override - public void onBindViewHolder(PreferenceViewHolder view) { - super.onBindViewHolder(view); - Resources res = getPrefContext().getResources(); - final int backgroundAssetWidth = res.getDimensionPixelSize( - R.dimen.screen_magnification_video_background_width); - final int videoAssetWidth = res - .getDimensionPixelSize(R.dimen.screen_magnification_video_width); - final int videoAssetHeight = res - .getDimensionPixelSize(R.dimen.screen_magnification_video_height); - final int videoAssetMarginTop = res.getDimensionPixelSize( - R.dimen.screen_magnification_video_margin_top); - view.setDividerAllowedAbove(false); - view.setDividerAllowedBelow(false); - mVideoBackgroundView = (ImageView) view.findViewById(R.id.video_background); - final VideoView videoView = (VideoView) view.findViewById(R.id.video); - - // Loop the video. - videoView.setOnPreparedListener(new OnPreparedListener() { - @Override - public void onPrepared(MediaPlayer mediaPlayer) { - mediaPlayer.setLooping(true); - } - }); - - // Make sure the VideoView does not request audio focus. - videoView.setAudioFocusRequest(AudioManager.AUDIOFOCUS_NONE); - - // Resolve and set the video content - Bundle args = getArguments(); - if ((args != null) && args.containsKey( - AccessibilitySettings.EXTRA_VIDEO_RAW_RESOURCE_ID)) { - videoView.setVideoURI(Uri.parse(String.format("%s://%s/%s", - ContentResolver.SCHEME_ANDROID_RESOURCE, - getPrefContext().getPackageName(), - args.getInt(AccessibilitySettings.EXTRA_VIDEO_RAW_RESOURCE_ID)))); - } - - // Make sure video controls (e.g. for pausing) are not displayed. - videoView.setMediaController(null); - - // LayoutListener for adjusting the position of the VideoView on the background image. - mLayoutListener = new OnGlobalLayoutListener() { - @Override - public void onGlobalLayout() { - final int backgroundViewWidth = mVideoBackgroundView.getWidth(); - - LayoutParams videoLp = (LayoutParams) videoView.getLayoutParams(); - videoLp.width = videoAssetWidth * backgroundViewWidth / backgroundAssetWidth; - videoLp.height = videoAssetHeight * backgroundViewWidth / backgroundAssetWidth; - videoLp.setMargins(0, - videoAssetMarginTop * backgroundViewWidth / backgroundAssetWidth, 0, 0); - videoView.setLayoutParams(videoLp); - videoView.invalidate(); - videoView.start(); - } - }; - - mVideoBackgroundView.getViewTreeObserver().addOnGlobalLayoutListener(mLayoutListener); - } - - @Override - protected void onPrepareForRemoval() { - mVideoBackgroundView.getViewTreeObserver() - .removeOnGlobalLayoutListener(mLayoutListener); - } - } @Override public void onCreate(Bundle savedInstanceState) { @@ -171,6 +83,10 @@ public class ToggleScreenMagnificationPreferenceFragment extends public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mPackageName = getString(R.string.accessibility_screen_magnification_title); + mImageUri = new Uri.Builder().scheme(ContentResolver.SCHEME_ANDROID_RESOURCE) + .authority(getPrefContext().getPackageName()) + .appendPath(String.valueOf(R.drawable.accessibility_magnification_banner)) + .build(); mTouchExplorationStateChangeListener = isTouchExplorationEnabled -> { removeDialog(DialogEnums.EDIT_SHORTCUT); mShortcutPreference.setSummary(getShortcutTypeSummary(getPrefContext())); @@ -180,13 +96,6 @@ public class ToggleScreenMagnificationPreferenceFragment extends @Override public void onViewCreated(View view, Bundle savedInstanceState) { - final PreferenceScreen preferenceScreen = getPreferenceScreen(); - mVideoPreference = new VideoPreference(getPrefContext()); - mVideoPreference.setSelectable(false); - mVideoPreference.setPersistent(false); - mVideoPreference.setLayoutResource(R.layout.magnification_video_preference); - preferenceScreen.addPreference(mVideoPreference); - initShortcutPreference(); super.onViewCreated(view, savedInstanceState); @@ -206,11 +115,6 @@ public class ToggleScreenMagnificationPreferenceFragment extends AccessibilityManager.class); am.addTouchExplorationStateChangeListener(mTouchExplorationStateChangeListener); - VideoView videoView = (VideoView) getView().findViewById(R.id.video); - if (videoView != null) { - videoView.start(); - } - updateShortcutPreferenceData(); updateShortcutPreference(); } @@ -437,20 +341,6 @@ public class ToggleScreenMagnificationPreferenceFragment extends } @Override - protected void onProcessArguments(Bundle arguments) { - super.onProcessArguments(arguments); - if (arguments == null) { - return; - } - - if (arguments.containsKey(AccessibilitySettings.EXTRA_VIDEO_RAW_RESOURCE_ID)) { - mVideoPreference.setVisible(true); - } else { - mVideoPreference.setVisible(false); - } - } - - @Override public void onToggleClicked(ShortcutPreference preference) { final int shortcutTypes = getUserShortcutTypes(getPrefContext(), UserShortcutType.SOFTWARE); if (preference.isChecked()) { |