Loading core/java/com/android/internal/accessibility/common/MagnificationConstants.java +6 −0 Original line number Diff line number Diff line Loading @@ -27,4 +27,10 @@ public final class MagnificationConstants { * the min value, there will be no obvious magnification effect. */ public static final float PERSISTED_SCALE_MIN_VALUE = 1.3f; /** Minimum supported value for magnification scale. */ public static final float SCALE_MIN_VALUE = 1.0f; /** Maximum supported value for magnification scale. */ public static final float SCALE_MAX_VALUE = 8.0f; } packages/SystemUI/res/layout/window_magnification_settings_view.xml +4 −2 Original line number Diff line number Diff line Loading @@ -147,10 +147,12 @@ android:id="@+id/magnifier_zoom_slider" android:layout_width="match_parent" android:layout_height="wrap_content" app:max="6" app:progress="0" app:iconStartContentDescription="@string/accessibility_control_zoom_out" app:iconEndContentDescription="@string/accessibility_control_zoom_in"/> app:iconEndContentDescription="@string/accessibility_control_zoom_in" app:tickMark="@android:color/transparent" app:seekBarChangeMagnitude="10" /> <Button android:id="@+id/magnifier_done_button" Loading packages/SystemUI/res/values/attrs.xml +2 −0 Original line number Diff line number Diff line Loading @@ -216,6 +216,8 @@ <attr name="progress" format="integer" /> <attr name="iconStartContentDescription" format="reference" /> <attr name="iconEndContentDescription" format="reference" /> <attr name="tickMark" format="reference" /> <attr name="seekBarChangeMagnitude" format="integer" /> </declare-styleable> </resources> packages/SystemUI/src/com/android/systemui/accessibility/WindowMagnificationController.java +4 −1 Original line number Diff line number Diff line Loading @@ -76,6 +76,7 @@ import android.widget.ImageView; import androidx.core.math.MathUtils; import com.android.internal.accessibility.common.MagnificationConstants; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.graphics.SfVsyncFrameCallbackProvider; import com.android.systemui.R; Loading @@ -101,7 +102,9 @@ class WindowMagnificationController implements View.OnTouchListener, SurfaceHold // Delay to avoid updating state description too frequently. private static final int UPDATE_STATE_DESCRIPTION_DELAY_MS = 100; // It should be consistent with the value defined in WindowMagnificationGestureHandler. private static final Range<Float> A11Y_ACTION_SCALE_RANGE = new Range<>(1.0f, 8.0f); private static final Range<Float> A11Y_ACTION_SCALE_RANGE = new Range<>( MagnificationConstants.SCALE_MIN_VALUE, MagnificationConstants.SCALE_MAX_VALUE); private static final float A11Y_CHANGE_SCALE_DIFFERENCE = 1.0f; private static final float ANIMATION_BOUNCE_EFFECT_SCALE = 1.05f; private final SparseArray<Float> mMagnificationSizeScaleOptions = new SparseArray<>(); Loading packages/SystemUI/src/com/android/systemui/accessibility/WindowMagnificationSettings.java +47 −18 Original line number Diff line number Diff line Loading @@ -22,6 +22,9 @@ import static android.provider.Settings.Secure.ACCESSIBILITY_MAGNIFICATION_MODE_ import static android.provider.Settings.Secure.ACCESSIBILITY_MAGNIFICATION_MODE_WINDOW; import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS; import static com.android.internal.accessibility.common.MagnificationConstants.SCALE_MAX_VALUE; import static com.android.internal.accessibility.common.MagnificationConstants.SCALE_MIN_VALUE; import android.annotation.IntDef; import android.content.BroadcastReceiver; import android.content.Context; Loading Loading @@ -87,7 +90,8 @@ class WindowMagnificationSettings implements MagnificationGestureDetector.OnGest private final MagnificationGestureDetector mGestureDetector; private boolean mSingleTapDetected = false; private SeekBarWithIconButtonsView mZoomSeekbar; @VisibleForTesting SeekBarWithIconButtonsView mZoomSeekbar; private LinearLayout mAllowDiagonalScrollingView; private TextView mAllowDiagonalScrollingTitle; private Switch mAllowDiagonalScrollingSwitch; Loading @@ -102,11 +106,15 @@ class WindowMagnificationSettings implements MagnificationGestureDetector.OnGest private ImageButton mFullScreenButton; private int mLastSelectedButtonIndex = MagnificationSize.NONE; private boolean mAllowDiagonalScrolling = false; private static final float A11Y_CHANGE_SCALE_DIFFERENCE = 1.0f; private static final float A11Y_SCALE_MIN_VALUE = 1.0f; /** * Amount by which magnification scale changes compared to seekbar in settings. * magnitude = 10 means, for every 1 scale increase, 10 progress increase in seekbar. */ private int mSeekBarMagnitude; private WindowMagnificationSettingsCallback mCallback; private ContentObserver mMagnificationCapabilityObserver; private ContentObserver mMagnificationScaleObserver; @Retention(RetentionPolicy.SOURCE) @IntDef({ Loading Loading @@ -156,18 +164,26 @@ class WindowMagnificationSettings implements MagnificationGestureDetector.OnGest }); } }; mMagnificationScaleObserver = new ContentObserver( mContext.getMainThreadHandler()) { @Override public void onChange(boolean selfChange) { setScaleSeekbar(getMagnificationScale()); } }; } private class ZoomSeekbarChangeListener implements SeekBar.OnSeekBarChangeListener { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { float scale = progress * A11Y_CHANGE_SCALE_DIFFERENCE + A11Y_SCALE_MIN_VALUE; float scale = (progress / (float) mSeekBarMagnitude) + SCALE_MIN_VALUE; // Update persisted scale only when scale >= PERSISTED_SCALE_MIN_VALUE const. // We assume if the scale is lower than the PERSISTED_SCALE_MIN_VALUE, there will be // no obvious magnification effect. if (scale >= MagnificationConstants.PERSISTED_SCALE_MIN_VALUE) { Settings.Secure.putFloatForUser(mContext.getContentResolver(), Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_SCALE, scale, mSecureSettings.putFloatForUser( Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_SCALE, scale, UserHandle.USER_CURRENT); } mCallback.onMagnifierScale(scale); Loading Loading @@ -301,6 +317,7 @@ class WindowMagnificationSettings implements MagnificationGestureDetector.OnGest // Unregister observer before removing view mSecureSettings.unregisterContentObserver(mMagnificationCapabilityObserver); mSecureSettings.unregisterContentObserver(mMagnificationScaleObserver); mWindowManager.removeView(mSettingView); mIsVisible = false; if (resetPosition) { Loading Loading @@ -329,7 +346,13 @@ class WindowMagnificationSettings implements MagnificationGestureDetector.OnGest } public void setScaleSeekbar(float scale) { setSeekbarProgress(scale); int index = (int) ((scale - SCALE_MIN_VALUE) * mSeekBarMagnitude); if (index < 0) { index = 0; } else if (index > mZoomSeekbar.getMax()) { index = mZoomSeekbar.getMax(); } mZoomSeekbar.setProgress(index); } private void transitToMagnificationMode(int mode) { Loading @@ -346,6 +369,7 @@ class WindowMagnificationSettings implements MagnificationGestureDetector.OnGest private void showSettingPanel(boolean resetPosition) { if (!mIsVisible) { updateUIControlsIfNeeded(); setScaleSeekbar(getMagnificationScale()); if (resetPosition) { mDraggableWindowBounds.set(getDraggableWindowBounds()); mParams.x = mDraggableWindowBounds.right; Loading @@ -358,6 +382,10 @@ class WindowMagnificationSettings implements MagnificationGestureDetector.OnGest Settings.Secure.ACCESSIBILITY_MAGNIFICATION_CAPABILITY, mMagnificationCapabilityObserver, UserHandle.USER_CURRENT); mSecureSettings.registerContentObserverForUser( Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_SCALE, mMagnificationScaleObserver, UserHandle.USER_CURRENT); // Exclude magnification switch button from system gesture area. setSystemGestureExclusion(); Loading Loading @@ -390,9 +418,15 @@ class WindowMagnificationSettings implements MagnificationGestureDetector.OnGest UserHandle.USER_CURRENT); } private float getMagnificationScale() { return mSecureSettings.getFloatForUser( Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_SCALE, SCALE_MIN_VALUE, UserHandle.USER_CURRENT); } private void updateUIControlsIfNeeded() { int capability = getMagnificationCapability(); int selectedButtonIndex = mLastSelectedButtonIndex; switch (capability) { case ACCESSIBILITY_MAGNIFICATION_MODE_WINDOW: Loading Loading @@ -453,14 +487,6 @@ class WindowMagnificationSettings implements MagnificationGestureDetector.OnGest } }; private void setSeekbarProgress(float scale) { int index = (int) ((scale - A11Y_SCALE_MIN_VALUE) / A11Y_CHANGE_SCALE_DIFFERENCE); if (index < 0) { index = 0; } mZoomSeekbar.setProgress(index); } void inflateView() { mSettingView = (LinearLayout) View.inflate(mContext, R.layout.window_magnification_settings_view, null); Loading @@ -482,10 +508,13 @@ class WindowMagnificationSettings implements MagnificationGestureDetector.OnGest mSettingView.findViewById(R.id.magnifier_horizontal_lock_title); mZoomSeekbar = mSettingView.findViewById(R.id.magnifier_zoom_slider); mZoomSeekbar.setMax((int) (mZoomSeekbar.getChangeMagnitude() * (SCALE_MAX_VALUE - SCALE_MIN_VALUE))); mSeekBarMagnitude = mZoomSeekbar.getChangeMagnitude(); float scale = mSecureSettings.getFloatForUser( Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_SCALE, 0, UserHandle.USER_CURRENT); setSeekbarProgress(scale); setScaleSeekbar(scale); mZoomSeekbar.setOnSeekBarChangeListener(new ZoomSeekbarChangeListener()); mAllowDiagonalScrollingView = Loading Loading @@ -601,7 +630,7 @@ class WindowMagnificationSettings implements MagnificationGestureDetector.OnGest @VisibleForTesting void setDiagonalScrolling(boolean enabled) { Settings.Secure.putIntForUser(mContext.getContentResolver(), mSecureSettings.putIntForUser( Settings.Secure.ACCESSIBILITY_ALLOW_DIAGONAL_SCROLLING, enabled ? 1 : 0, UserHandle.USER_CURRENT); Loading Loading
core/java/com/android/internal/accessibility/common/MagnificationConstants.java +6 −0 Original line number Diff line number Diff line Loading @@ -27,4 +27,10 @@ public final class MagnificationConstants { * the min value, there will be no obvious magnification effect. */ public static final float PERSISTED_SCALE_MIN_VALUE = 1.3f; /** Minimum supported value for magnification scale. */ public static final float SCALE_MIN_VALUE = 1.0f; /** Maximum supported value for magnification scale. */ public static final float SCALE_MAX_VALUE = 8.0f; }
packages/SystemUI/res/layout/window_magnification_settings_view.xml +4 −2 Original line number Diff line number Diff line Loading @@ -147,10 +147,12 @@ android:id="@+id/magnifier_zoom_slider" android:layout_width="match_parent" android:layout_height="wrap_content" app:max="6" app:progress="0" app:iconStartContentDescription="@string/accessibility_control_zoom_out" app:iconEndContentDescription="@string/accessibility_control_zoom_in"/> app:iconEndContentDescription="@string/accessibility_control_zoom_in" app:tickMark="@android:color/transparent" app:seekBarChangeMagnitude="10" /> <Button android:id="@+id/magnifier_done_button" Loading
packages/SystemUI/res/values/attrs.xml +2 −0 Original line number Diff line number Diff line Loading @@ -216,6 +216,8 @@ <attr name="progress" format="integer" /> <attr name="iconStartContentDescription" format="reference" /> <attr name="iconEndContentDescription" format="reference" /> <attr name="tickMark" format="reference" /> <attr name="seekBarChangeMagnitude" format="integer" /> </declare-styleable> </resources>
packages/SystemUI/src/com/android/systemui/accessibility/WindowMagnificationController.java +4 −1 Original line number Diff line number Diff line Loading @@ -76,6 +76,7 @@ import android.widget.ImageView; import androidx.core.math.MathUtils; import com.android.internal.accessibility.common.MagnificationConstants; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.graphics.SfVsyncFrameCallbackProvider; import com.android.systemui.R; Loading @@ -101,7 +102,9 @@ class WindowMagnificationController implements View.OnTouchListener, SurfaceHold // Delay to avoid updating state description too frequently. private static final int UPDATE_STATE_DESCRIPTION_DELAY_MS = 100; // It should be consistent with the value defined in WindowMagnificationGestureHandler. private static final Range<Float> A11Y_ACTION_SCALE_RANGE = new Range<>(1.0f, 8.0f); private static final Range<Float> A11Y_ACTION_SCALE_RANGE = new Range<>( MagnificationConstants.SCALE_MIN_VALUE, MagnificationConstants.SCALE_MAX_VALUE); private static final float A11Y_CHANGE_SCALE_DIFFERENCE = 1.0f; private static final float ANIMATION_BOUNCE_EFFECT_SCALE = 1.05f; private final SparseArray<Float> mMagnificationSizeScaleOptions = new SparseArray<>(); Loading
packages/SystemUI/src/com/android/systemui/accessibility/WindowMagnificationSettings.java +47 −18 Original line number Diff line number Diff line Loading @@ -22,6 +22,9 @@ import static android.provider.Settings.Secure.ACCESSIBILITY_MAGNIFICATION_MODE_ import static android.provider.Settings.Secure.ACCESSIBILITY_MAGNIFICATION_MODE_WINDOW; import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS; import static com.android.internal.accessibility.common.MagnificationConstants.SCALE_MAX_VALUE; import static com.android.internal.accessibility.common.MagnificationConstants.SCALE_MIN_VALUE; import android.annotation.IntDef; import android.content.BroadcastReceiver; import android.content.Context; Loading Loading @@ -87,7 +90,8 @@ class WindowMagnificationSettings implements MagnificationGestureDetector.OnGest private final MagnificationGestureDetector mGestureDetector; private boolean mSingleTapDetected = false; private SeekBarWithIconButtonsView mZoomSeekbar; @VisibleForTesting SeekBarWithIconButtonsView mZoomSeekbar; private LinearLayout mAllowDiagonalScrollingView; private TextView mAllowDiagonalScrollingTitle; private Switch mAllowDiagonalScrollingSwitch; Loading @@ -102,11 +106,15 @@ class WindowMagnificationSettings implements MagnificationGestureDetector.OnGest private ImageButton mFullScreenButton; private int mLastSelectedButtonIndex = MagnificationSize.NONE; private boolean mAllowDiagonalScrolling = false; private static final float A11Y_CHANGE_SCALE_DIFFERENCE = 1.0f; private static final float A11Y_SCALE_MIN_VALUE = 1.0f; /** * Amount by which magnification scale changes compared to seekbar in settings. * magnitude = 10 means, for every 1 scale increase, 10 progress increase in seekbar. */ private int mSeekBarMagnitude; private WindowMagnificationSettingsCallback mCallback; private ContentObserver mMagnificationCapabilityObserver; private ContentObserver mMagnificationScaleObserver; @Retention(RetentionPolicy.SOURCE) @IntDef({ Loading Loading @@ -156,18 +164,26 @@ class WindowMagnificationSettings implements MagnificationGestureDetector.OnGest }); } }; mMagnificationScaleObserver = new ContentObserver( mContext.getMainThreadHandler()) { @Override public void onChange(boolean selfChange) { setScaleSeekbar(getMagnificationScale()); } }; } private class ZoomSeekbarChangeListener implements SeekBar.OnSeekBarChangeListener { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { float scale = progress * A11Y_CHANGE_SCALE_DIFFERENCE + A11Y_SCALE_MIN_VALUE; float scale = (progress / (float) mSeekBarMagnitude) + SCALE_MIN_VALUE; // Update persisted scale only when scale >= PERSISTED_SCALE_MIN_VALUE const. // We assume if the scale is lower than the PERSISTED_SCALE_MIN_VALUE, there will be // no obvious magnification effect. if (scale >= MagnificationConstants.PERSISTED_SCALE_MIN_VALUE) { Settings.Secure.putFloatForUser(mContext.getContentResolver(), Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_SCALE, scale, mSecureSettings.putFloatForUser( Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_SCALE, scale, UserHandle.USER_CURRENT); } mCallback.onMagnifierScale(scale); Loading Loading @@ -301,6 +317,7 @@ class WindowMagnificationSettings implements MagnificationGestureDetector.OnGest // Unregister observer before removing view mSecureSettings.unregisterContentObserver(mMagnificationCapabilityObserver); mSecureSettings.unregisterContentObserver(mMagnificationScaleObserver); mWindowManager.removeView(mSettingView); mIsVisible = false; if (resetPosition) { Loading Loading @@ -329,7 +346,13 @@ class WindowMagnificationSettings implements MagnificationGestureDetector.OnGest } public void setScaleSeekbar(float scale) { setSeekbarProgress(scale); int index = (int) ((scale - SCALE_MIN_VALUE) * mSeekBarMagnitude); if (index < 0) { index = 0; } else if (index > mZoomSeekbar.getMax()) { index = mZoomSeekbar.getMax(); } mZoomSeekbar.setProgress(index); } private void transitToMagnificationMode(int mode) { Loading @@ -346,6 +369,7 @@ class WindowMagnificationSettings implements MagnificationGestureDetector.OnGest private void showSettingPanel(boolean resetPosition) { if (!mIsVisible) { updateUIControlsIfNeeded(); setScaleSeekbar(getMagnificationScale()); if (resetPosition) { mDraggableWindowBounds.set(getDraggableWindowBounds()); mParams.x = mDraggableWindowBounds.right; Loading @@ -358,6 +382,10 @@ class WindowMagnificationSettings implements MagnificationGestureDetector.OnGest Settings.Secure.ACCESSIBILITY_MAGNIFICATION_CAPABILITY, mMagnificationCapabilityObserver, UserHandle.USER_CURRENT); mSecureSettings.registerContentObserverForUser( Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_SCALE, mMagnificationScaleObserver, UserHandle.USER_CURRENT); // Exclude magnification switch button from system gesture area. setSystemGestureExclusion(); Loading Loading @@ -390,9 +418,15 @@ class WindowMagnificationSettings implements MagnificationGestureDetector.OnGest UserHandle.USER_CURRENT); } private float getMagnificationScale() { return mSecureSettings.getFloatForUser( Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_SCALE, SCALE_MIN_VALUE, UserHandle.USER_CURRENT); } private void updateUIControlsIfNeeded() { int capability = getMagnificationCapability(); int selectedButtonIndex = mLastSelectedButtonIndex; switch (capability) { case ACCESSIBILITY_MAGNIFICATION_MODE_WINDOW: Loading Loading @@ -453,14 +487,6 @@ class WindowMagnificationSettings implements MagnificationGestureDetector.OnGest } }; private void setSeekbarProgress(float scale) { int index = (int) ((scale - A11Y_SCALE_MIN_VALUE) / A11Y_CHANGE_SCALE_DIFFERENCE); if (index < 0) { index = 0; } mZoomSeekbar.setProgress(index); } void inflateView() { mSettingView = (LinearLayout) View.inflate(mContext, R.layout.window_magnification_settings_view, null); Loading @@ -482,10 +508,13 @@ class WindowMagnificationSettings implements MagnificationGestureDetector.OnGest mSettingView.findViewById(R.id.magnifier_horizontal_lock_title); mZoomSeekbar = mSettingView.findViewById(R.id.magnifier_zoom_slider); mZoomSeekbar.setMax((int) (mZoomSeekbar.getChangeMagnitude() * (SCALE_MAX_VALUE - SCALE_MIN_VALUE))); mSeekBarMagnitude = mZoomSeekbar.getChangeMagnitude(); float scale = mSecureSettings.getFloatForUser( Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_SCALE, 0, UserHandle.USER_CURRENT); setSeekbarProgress(scale); setScaleSeekbar(scale); mZoomSeekbar.setOnSeekBarChangeListener(new ZoomSeekbarChangeListener()); mAllowDiagonalScrollingView = Loading Loading @@ -601,7 +630,7 @@ class WindowMagnificationSettings implements MagnificationGestureDetector.OnGest @VisibleForTesting void setDiagonalScrolling(boolean enabled) { Settings.Secure.putIntForUser(mContext.getContentResolver(), mSecureSettings.putIntForUser( Settings.Secure.ACCESSIBILITY_ALLOW_DIAGONAL_SCROLLING, enabled ? 1 : 0, UserHandle.USER_CURRENT); Loading