Add instruction video to Screen Magnification a.k.a. Tap to Zoom screen.
Change-Id: Id02796ea44e48fe04351c9ea6bda66526f77a5cf
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
<!--
|
||||
~ 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>
|
@@ -13,11 +13,10 @@
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<TextView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@android:id/summary"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="@android:style/TextAppearance.Material.Body1"
|
||||
android:padding="16dip" />
|
||||
|
27
res/layout/video_preference.xml
Normal file
27
res/layout/video_preference.xml
Normal file
@@ -0,0 +1,27 @@
|
||||
<?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:id="@+id/video_background"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<VideoView
|
||||
android:id="@+id/video"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</RelativeLayout>
|
BIN
res/raw/accessibility_screen_magnification.mp4
Normal file
BIN
res/raw/accessibility_screen_magnification.mp4
Normal file
Binary file not shown.
@@ -268,4 +268,11 @@
|
||||
|
||||
<!-- Accessibility, Font size -->
|
||||
<dimen name="font_size_preview_height">240dp</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>
|
||||
</resources>
|
||||
|
@@ -16,15 +16,111 @@
|
||||
|
||||
package com.android.settings.accessibility;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Point;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
|
||||
import android.media.MediaPlayer;
|
||||
import android.media.MediaPlayer.OnPreparedListener;
|
||||
import android.net.Uri;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.PreferenceScreen;
|
||||
import android.support.v7.preference.PreferenceViewHolder;
|
||||
import android.view.Display;
|
||||
import android.view.Gravity;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.MediaController;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.VideoView;
|
||||
import com.android.internal.logging.MetricsProto.MetricsEvent;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.widget.ToggleSwitch;
|
||||
import com.android.settings.widget.ToggleSwitch.OnBeforeCheckedChangeListener;
|
||||
|
||||
public class ToggleScreenMagnificationPreferenceFragment
|
||||
extends ToggleFeaturePreferenceFragment {
|
||||
|
||||
protected class VideoPreference extends Preference {
|
||||
public VideoPreference(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(PreferenceViewHolder view) {
|
||||
super.onBindViewHolder(view);
|
||||
view.setDividerAllowedAbove(false);
|
||||
view.setDividerAllowedBelow(false);
|
||||
final RelativeLayout background =
|
||||
(RelativeLayout) view.findViewById(R.id.video_background);
|
||||
final VideoView videoView = (VideoView) view.findViewById(R.id.video);
|
||||
|
||||
// Hacky adjustment for using VideoView in recycle view and positioning
|
||||
// it on the background image
|
||||
Resources res = getPrefContext().getResources();
|
||||
final int backgroundWidth = res.getDimensionPixelSize(
|
||||
R.dimen.screen_magnification_video_background_width);
|
||||
final int backgroundHeight = res.getDimensionPixelSize(
|
||||
R.dimen.screen_magnification_video_background_height);
|
||||
final int videoWidth = res.getDimensionPixelSize(
|
||||
R.dimen.screen_magnification_video_width);
|
||||
final int videoHeight = res.getDimensionPixelSize(
|
||||
R.dimen.screen_magnification_video_height);
|
||||
final int videoMarginTop = res.getDimensionPixelSize(
|
||||
R.dimen.screen_magnification_video_margin_top);
|
||||
final int screenWidth = getScreenWidth(getPrefContext());
|
||||
|
||||
RelativeLayout.LayoutParams videoLp = new RelativeLayout.LayoutParams(
|
||||
screenWidth * videoWidth / backgroundWidth,
|
||||
screenWidth * videoHeight / backgroundWidth);
|
||||
videoLp.setMargins(0, screenWidth * videoMarginTop / backgroundWidth, 0, 0);
|
||||
videoView.setLayoutParams(videoLp);
|
||||
|
||||
RelativeLayout.LayoutParams backgroundLp = new RelativeLayout.LayoutParams(
|
||||
screenWidth,
|
||||
screenWidth * backgroundHeight / backgroundWidth);
|
||||
background.setLayoutParams(backgroundLp);
|
||||
background.setBackgroundResource(
|
||||
R.drawable.accessibility_screen_magnification_background);
|
||||
background.setGravity(Gravity.CENTER_HORIZONTAL);
|
||||
|
||||
// Loop the video.
|
||||
videoView.setOnPreparedListener(new OnPreparedListener() {
|
||||
@Override
|
||||
public void onPrepared(MediaPlayer mediaPlayer) {
|
||||
mediaPlayer.setLooping(true);
|
||||
}
|
||||
});
|
||||
|
||||
videoView.setVideoURI(Uri.parse(String.format("%s://%s/%s",
|
||||
ContentResolver.SCHEME_ANDROID_RESOURCE,
|
||||
getPrefContext().getPackageName(),
|
||||
R.raw.accessibility_screen_magnification)));
|
||||
videoView.setMediaController(new MediaController(getPrefContext()));
|
||||
videoView.start();
|
||||
}
|
||||
}
|
||||
|
||||
protected VideoPreference mVideoPreference;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
mVideoPreference = new VideoPreference(getPrefContext());
|
||||
mVideoPreference.setSelectable(false);
|
||||
mVideoPreference.setPersistent(false);
|
||||
mVideoPreference.setLayoutResource(R.layout.video_preference);
|
||||
|
||||
final PreferenceScreen preferenceScreen = getPreferenceManager().getPreferenceScreen();
|
||||
preferenceScreen.setOrderingAsAdded(false);
|
||||
mVideoPreference.setOrder(0);
|
||||
mSummaryPreference.setOrder(1);
|
||||
preferenceScreen.addPreference(mVideoPreference);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPreferenceToggled(String preferenceKey, boolean enabled) {
|
||||
// Do nothing.
|
||||
@@ -72,4 +168,12 @@ public class ToggleScreenMagnificationPreferenceFragment
|
||||
protected int getMetricsCategory() {
|
||||
return MetricsEvent.ACCESSIBILITY_TOGGLE_SCREEN_MAGNIFICATION;
|
||||
}
|
||||
|
||||
private static int getScreenWidth(Context context) {
|
||||
WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
|
||||
Display display = wm.getDefaultDisplay();
|
||||
Point size = new Point();
|
||||
display.getSize(size);
|
||||
return size.x;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user