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
diff --git a/res/drawable/accessibility_color_inversion_banner.gif b/res/drawable/accessibility_color_inversion_banner.gif
new file mode 100644
index 0000000..dc7c8ac
--- /dev/null
+++ b/res/drawable/accessibility_color_inversion_banner.gif
Binary files differ
diff --git a/res/drawable/accessibility_color_inversion_banner.png b/res/drawable/accessibility_color_inversion_banner.png
deleted file mode 100644
index 2d068e3..0000000
--- a/res/drawable/accessibility_color_inversion_banner.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable/accessibility_magnification_banner.gif b/res/drawable/accessibility_magnification_banner.gif
new file mode 100644
index 0000000..f9b7e36
--- /dev/null
+++ b/res/drawable/accessibility_magnification_banner.gif
Binary files differ
diff --git a/res/drawable/accessibility_screen_magnification_background.xml b/res/drawable/accessibility_screen_magnification_background.xml
deleted file mode 100644
index e22cfec..0000000
--- a/res/drawable/accessibility_screen_magnification_background.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<!--
-  ~ Copyright (C) 2016 The Android Open Source Project
-  ~
-  ~ Licensed under the Apache License, Version 2.0 (the "License");
-  ~ you may not use this file except in compliance with the License.
-  ~ You may obtain a copy of the License at
-  ~
-  ~      http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing, software
-  ~ distributed under the License is distributed on an "AS IS" BASIS,
-  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  ~ See the License for the specific language governing permissions and
-  ~ limitations under the License
-  -->
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
-        android:width="360dp"
-        android:height="184dp"
-        android:viewportWidth="360"
-        android:viewportHeight="184">
-
-    <path
-        android:fillColor="#E9F0F9"
-        android:pathData="M 0 0 H 360 V 184 H 0 V 0 Z" />
-    <path
-        android:fillColor="#444445"
-        android:pathData="M217.6,179h-75.1c-5,0-9-4-9-9V14c0-5,4-9,9-9h75.1c5,0,9,4,9,9V170C226.6,174.9,222.5,179,217.6,179z" />
-    <path
-        android:fillColor="#000000"
-        android:pathData="M 180 9.6 C 181.1045695 9.6 182 10.4954305003 182 11.6 C 182 12.7045694997 181.1045695 13.6 180 13.6 C 178.8954305 13.6 178 12.7045694997 178 11.6 C 178 10.4954305003 178.8954305 9.6 180 9.6 Z" />
-</vector>
diff --git a/res/layout/magnification_video_preference.xml b/res/layout/magnification_video_preference.xml
deleted file mode 100644
index ff7089c..0000000
--- a/res/layout/magnification_video_preference.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2016 The Android Open Source Project
-
-     Licensed under the Apache License, Version 2.0 (the "License");
-     you may not use this file except in compliance with the License.
-     You may obtain a copy of the License at
-
-          http://www.apache.org/licenses/LICENSE-2.0
-
-     Unless required by applicable law or agreed to in writing, software
-     distributed under the License is distributed on an "AS IS" BASIS,
-     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     See the License for the specific language governing permissions and
-     limitations under the License.
--->
-<RelativeLayout
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="match_parent"
-    android:layout_height="wrap_content"
-    android:clipChildren="true"
-    android:clipToPadding="true">
-
-    <ImageView
-        android:id="@+id/video_background"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:src="@drawable/accessibility_screen_magnification_background"
-        android:scaleType="fitXY"
-        android:adjustViewBounds="true"
-        android:importantForAccessibility="noHideDescendants" />
-
-    <VideoView
-        android:id="@+id/video"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:layout_alignTop="@id/video_background"
-        android:layout_centerHorizontal="true"
-        android:importantForAccessibility="noHideDescendants" />
-
-</RelativeLayout>
\ No newline at end of file
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index a7e003c..9c990f0 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -280,13 +280,6 @@
     <dimen name="accessibility_layout_margin_start_end">16dp</dimen>
     <dimen name="accessibility_button_preference_padding_top_bottom">18dp</dimen>
 
-    <!-- Accessibility, Screen magnification. These values are meant to be relative values and the actual layout value will be set programmatically. -->
-    <dimen name="screen_magnification_video_background_width">750dp</dimen>
-    <dimen name="screen_magnification_video_background_height">383dp</dimen>
-    <dimen name="screen_magnification_video_width">170dp</dimen>
-    <dimen name="screen_magnification_video_height">311dp</dimen>
-    <dimen name="screen_magnification_video_margin_top">40dp</dimen>
-
     <!-- Restricted icon in switch bar -->
     <dimen name="restricted_icon_margin_end">16dp</dimen>
     <!-- Restricted icon size in switch bar -->
diff --git a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
index 2ca644d..797a332 100644
--- a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
@@ -25,10 +25,6 @@
 import android.content.ContentResolver;
 import android.content.Context;
 import android.content.DialogInterface;
-import android.content.res.Resources;
-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;
@@ -36,18 +32,12 @@
 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;
@@ -81,83 +71,6 @@
     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) {
@@ -169,6 +82,10 @@
     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()));
@@ -178,13 +95,6 @@
 
     @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();
 
         mSettingsPreference = new Preference(getPrefContext());
@@ -209,11 +119,6 @@
                 AccessibilityManager.class);
         am.addTouchExplorationStateChangeListener(mTouchExplorationStateChangeListener);
 
-        VideoView videoView = (VideoView) getView().findViewById(R.id.video);
-        if (videoView != null) {
-            videoView.start();
-        }
-
         updateShortcutPreferenceData();
         updateShortcutPreference();
     }
@@ -438,20 +343,6 @@
     }
 
     @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()) {