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
This commit is contained in:
BIN
res/drawable/accessibility_color_inversion_banner.gif
Normal file
BIN
res/drawable/accessibility_color_inversion_banner.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 692 KiB |
Binary file not shown.
Before Width: | Height: | Size: 4.8 KiB |
BIN
res/drawable/accessibility_magnification_banner.gif
Normal file
BIN
res/drawable/accessibility_magnification_banner.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.6 MiB |
@@ -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>
|
@@ -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>
|
@@ -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 -->
|
||||
|
@@ -25,10 +25,6 @@ import android.app.settings.SettingsEnums;
|
||||
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.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;
|
||||
@@ -81,83 +71,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) {
|
||||
@@ -169,6 +82,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()));
|
||||
@@ -178,13 +95,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();
|
||||
|
||||
mSettingsPreference = new Preference(getPrefContext());
|
||||
@@ -209,11 +119,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 +342,6 @@ public class ToggleScreenMagnificationPreferenceFragment extends
|
||||
mToggleServiceDividerSwitchPreference.setVisible(false);
|
||||
}
|
||||
|
||||
@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);
|
||||
|
Reference in New Issue
Block a user