Loading core/java/com/android/internal/accessibility/common/MagnificationConstants.java 0 → 100644 +30 −0 Original line number Diff line number Diff line /* * Copyright (C) 2023 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. */ package com.android.internal.accessibility.common; /** * Collection of common constants for accessibility shortcut. */ public final class MagnificationConstants { private MagnificationConstants() {} /** * The min value for the magnification persisted scale. We assume if the scale is lower than * the min value, there will be no obvious magnification effect. */ public static final float PERSISTED_SCALE_MIN_VALUE = 1.3f; } packages/SystemUI/src/com/android/systemui/accessibility/WindowMagnificationSettings.java +5 −2 Original line number Diff line number Diff line Loading @@ -50,6 +50,7 @@ import android.widget.LinearLayout; import android.widget.SeekBar; import android.widget.Switch; 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 Loading @@ -139,8 +140,10 @@ class WindowMagnificationSettings implements MagnificationGestureDetector.OnGest @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { float scale = progress * A11Y_CHANGE_SCALE_DIFFERENCE + A11Y_SCALE_MIN_VALUE; // update persisted scale only when scale >= 2.0 if (scale >= 2.0f) { // 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, UserHandle.USER_CURRENT); Loading services/accessibility/java/com/android/server/accessibility/magnification/FullScreenMagnificationController.java +8 −3 Original line number Diff line number Diff line Loading @@ -52,6 +52,7 @@ import android.view.accessibility.MagnificationAnimationCallback; import android.view.animation.DecelerateInterpolator; import com.android.internal.R; import com.android.internal.accessibility.common.MagnificationConstants; import com.android.internal.annotations.GuardedBy; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.util.function.pooled.PooledLambda; Loading Loading @@ -1157,11 +1158,14 @@ public class FullScreenMagnificationController implements } /** * Persists the default display magnification scale to the current user's settings. * Persists the default display magnification scale to the current user's settings * <strong>if scale is >= {@link MagnificationConstants.PERSISTED_SCALE_MIN_VALUE}</strong>. * We assume if the scale is < {@link MagnificationConstants.PERSISTED_SCALE_MIN_VALUE}, there * will be no obvious magnification effect. */ public void persistScale(int displayId) { final float scale = getScale(Display.DEFAULT_DISPLAY); if (scale < 2.0f) { if (scale < MagnificationConstants.PERSISTED_SCALE_MIN_VALUE) { return; } mScaleProvider.putScale(scale, displayId); Loading @@ -1176,7 +1180,8 @@ public class FullScreenMagnificationController implements */ public float getPersistedScale(int displayId) { return MathUtils.constrain(mScaleProvider.getScale(displayId), 2.0f, MagnificationScaleProvider.MAX_SCALE); MagnificationConstants.PERSISTED_SCALE_MIN_VALUE, MagnificationScaleProvider.MAX_SCALE); } /** Loading services/accessibility/java/com/android/server/accessibility/magnification/FullScreenMagnificationGestureHandler.java +2 −3 Original line number Diff line number Diff line Loading @@ -992,9 +992,8 @@ public class FullScreenMagnificationGestureHandler extends MagnificationGestureH mFullScreenMagnificationController.getPersistedScale(mDisplayId), MIN_SCALE, MAX_SCALE); final float scale = MathUtils.constrain(Math.max(currentScale + 1.0f, persistedScale), MIN_SCALE, MAX_SCALE); final boolean isActivated = mFullScreenMagnificationController.isActivated(mDisplayId); final float scale = isActivated ? (currentScale + 1.0f) : persistedScale; zoomToScale(scale, centerX, centerY); } Loading services/accessibility/java/com/android/server/accessibility/magnification/WindowMagnificationManager.java +8 −4 Original line number Diff line number Diff line Loading @@ -46,6 +46,7 @@ import android.view.accessibility.IWindowMagnificationConnection; import android.view.accessibility.IWindowMagnificationConnectionCallback; import android.view.accessibility.MagnificationAnimationCallback; import com.android.internal.accessibility.common.MagnificationConstants; import com.android.internal.accessibility.util.AccessibilityStatsLogUtils; import com.android.internal.annotations.GuardedBy; import com.android.internal.annotations.VisibleForTesting; Loading Loading @@ -716,17 +717,20 @@ public class WindowMagnificationManager implements */ float getPersistedScale(int displayId) { return MathUtils.constrain(mScaleProvider.getScale(displayId), 2.0f, MagnificationScaleProvider.MAX_SCALE); MagnificationConstants.PERSISTED_SCALE_MIN_VALUE, MagnificationScaleProvider.MAX_SCALE); } /** * Persists the default display magnification scale to the current user's settings * <strong>if scale is >= 2.0</strong>. Only the * value of the default display is persisted in user's settings. * <strong>if scale is >= {@link MagnificationConstants.PERSISTED_SCALE_MIN_VALUE}</strong>. * We assume if the scale is < {@link MagnificationConstants.PERSISTED_SCALE_MIN_VALUE}, there * will be no obvious magnification effect. * Only the value of the default display is persisted in user's settings. */ void persistScale(int displayId) { float scale = getScale(displayId); if (scale < 2.0f) { if (scale < MagnificationConstants.PERSISTED_SCALE_MIN_VALUE) { return; } mScaleProvider.putScale(scale, displayId); Loading Loading
core/java/com/android/internal/accessibility/common/MagnificationConstants.java 0 → 100644 +30 −0 Original line number Diff line number Diff line /* * Copyright (C) 2023 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. */ package com.android.internal.accessibility.common; /** * Collection of common constants for accessibility shortcut. */ public final class MagnificationConstants { private MagnificationConstants() {} /** * The min value for the magnification persisted scale. We assume if the scale is lower than * the min value, there will be no obvious magnification effect. */ public static final float PERSISTED_SCALE_MIN_VALUE = 1.3f; }
packages/SystemUI/src/com/android/systemui/accessibility/WindowMagnificationSettings.java +5 −2 Original line number Diff line number Diff line Loading @@ -50,6 +50,7 @@ import android.widget.LinearLayout; import android.widget.SeekBar; import android.widget.Switch; 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 Loading @@ -139,8 +140,10 @@ class WindowMagnificationSettings implements MagnificationGestureDetector.OnGest @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { float scale = progress * A11Y_CHANGE_SCALE_DIFFERENCE + A11Y_SCALE_MIN_VALUE; // update persisted scale only when scale >= 2.0 if (scale >= 2.0f) { // 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, UserHandle.USER_CURRENT); Loading
services/accessibility/java/com/android/server/accessibility/magnification/FullScreenMagnificationController.java +8 −3 Original line number Diff line number Diff line Loading @@ -52,6 +52,7 @@ import android.view.accessibility.MagnificationAnimationCallback; import android.view.animation.DecelerateInterpolator; import com.android.internal.R; import com.android.internal.accessibility.common.MagnificationConstants; import com.android.internal.annotations.GuardedBy; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.util.function.pooled.PooledLambda; Loading Loading @@ -1157,11 +1158,14 @@ public class FullScreenMagnificationController implements } /** * Persists the default display magnification scale to the current user's settings. * Persists the default display magnification scale to the current user's settings * <strong>if scale is >= {@link MagnificationConstants.PERSISTED_SCALE_MIN_VALUE}</strong>. * We assume if the scale is < {@link MagnificationConstants.PERSISTED_SCALE_MIN_VALUE}, there * will be no obvious magnification effect. */ public void persistScale(int displayId) { final float scale = getScale(Display.DEFAULT_DISPLAY); if (scale < 2.0f) { if (scale < MagnificationConstants.PERSISTED_SCALE_MIN_VALUE) { return; } mScaleProvider.putScale(scale, displayId); Loading @@ -1176,7 +1180,8 @@ public class FullScreenMagnificationController implements */ public float getPersistedScale(int displayId) { return MathUtils.constrain(mScaleProvider.getScale(displayId), 2.0f, MagnificationScaleProvider.MAX_SCALE); MagnificationConstants.PERSISTED_SCALE_MIN_VALUE, MagnificationScaleProvider.MAX_SCALE); } /** Loading
services/accessibility/java/com/android/server/accessibility/magnification/FullScreenMagnificationGestureHandler.java +2 −3 Original line number Diff line number Diff line Loading @@ -992,9 +992,8 @@ public class FullScreenMagnificationGestureHandler extends MagnificationGestureH mFullScreenMagnificationController.getPersistedScale(mDisplayId), MIN_SCALE, MAX_SCALE); final float scale = MathUtils.constrain(Math.max(currentScale + 1.0f, persistedScale), MIN_SCALE, MAX_SCALE); final boolean isActivated = mFullScreenMagnificationController.isActivated(mDisplayId); final float scale = isActivated ? (currentScale + 1.0f) : persistedScale; zoomToScale(scale, centerX, centerY); } Loading
services/accessibility/java/com/android/server/accessibility/magnification/WindowMagnificationManager.java +8 −4 Original line number Diff line number Diff line Loading @@ -46,6 +46,7 @@ import android.view.accessibility.IWindowMagnificationConnection; import android.view.accessibility.IWindowMagnificationConnectionCallback; import android.view.accessibility.MagnificationAnimationCallback; import com.android.internal.accessibility.common.MagnificationConstants; import com.android.internal.accessibility.util.AccessibilityStatsLogUtils; import com.android.internal.annotations.GuardedBy; import com.android.internal.annotations.VisibleForTesting; Loading Loading @@ -716,17 +717,20 @@ public class WindowMagnificationManager implements */ float getPersistedScale(int displayId) { return MathUtils.constrain(mScaleProvider.getScale(displayId), 2.0f, MagnificationScaleProvider.MAX_SCALE); MagnificationConstants.PERSISTED_SCALE_MIN_VALUE, MagnificationScaleProvider.MAX_SCALE); } /** * Persists the default display magnification scale to the current user's settings * <strong>if scale is >= 2.0</strong>. Only the * value of the default display is persisted in user's settings. * <strong>if scale is >= {@link MagnificationConstants.PERSISTED_SCALE_MIN_VALUE}</strong>. * We assume if the scale is < {@link MagnificationConstants.PERSISTED_SCALE_MIN_VALUE}, there * will be no obvious magnification effect. * Only the value of the default display is persisted in user's settings. */ void persistScale(int displayId) { float scale = getScale(displayId); if (scale < 2.0f) { if (scale < MagnificationConstants.PERSISTED_SCALE_MIN_VALUE) { return; } mScaleProvider.putScale(scale, displayId); Loading