Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9f03aebb authored by mincheli's avatar mincheli
Browse files

Updates magnification button when the magnification activation state is changed

When the a11y shortcut or triple-tap gesture is trggerred, it also
change the magnification activation state.
If the activation state is off, the magnification button can be removed.
If the activation state is on, the magnification button can be shown.
And remove unsed callbacks of MagnificationGestureHandler, onShortcutTriggered
and onTripleTapped.

Bug: 201045813
Test: atest MagnificationControllerTest, atest FullScreenMagnificationControllerTest
Change-Id: I2edc918f32ab9a8de02305bff121aedd483f70bb
parent 66879294
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -353,7 +353,7 @@ public class FullScreenMagnificationController {
            mMagnificationActivated = spec.scale > 1.0f;
            if (mMagnificationActivated != lastMagnificationActivated) {
                mMagnificationInfoChangedCallback.onFullScreenMagnificationActivationState(
                        mMagnificationActivated);
                        mDisplayId, mMagnificationActivated);
            }
        }

@@ -1614,9 +1614,10 @@ public class FullScreenMagnificationController {
         * Called when the state of the magnification activation is changed.
         * It is for the logging data of the magnification activation state.
         *
         * @param displayId The logical display id.
         * @param activated {@code true} if the magnification is activated, otherwise {@code false}.
         */
        void onFullScreenMagnificationActivationState(boolean activated);
        void onFullScreenMagnificationActivationState(int displayId, boolean activated);

        /**
         * Called when the IME window visibility changed.
+0 −2
Original line number Diff line number Diff line
@@ -869,8 +869,6 @@ public class FullScreenMagnificationGestureHandler extends MagnificationGestureH
                mPromptController.showNotificationIfNeeded();
                zoomOn(up.getX(), up.getY());
            }

            mCallback.onTripleTapped(mDisplayId, getMode());
        }

        private boolean isMagnifying() {
+9 −16
Original line number Diff line number Diff line
@@ -48,11 +48,12 @@ import com.android.server.accessibility.AccessibilityManagerService;
 *   the user touch interaction starts if magnification capabilities is all. </li>
 *   <li> 2. {@link #onTouchInteractionEnd} shows magnification switch UI when
 *   the user touch interaction ends if magnification capabilities is all. </li>
 *   <li> 3. {@link #onShortcutTriggered} updates magnification switch UI depending on
 *   magnification capabilities and magnification active state when magnification shortcut
 *   is triggered.</li>
 *   <li> 4. {@link #onTripleTapped} updates magnification switch UI depending on magnification
 *   capabilities and magnification active state when triple-tap gesture is detected. </li>
 *   <li> 3. {@link #onWindowMagnificationActivationState} updates magnification switch UI
 *   depending on magnification capabilities and magnification active state when window
 *   magnification activation state change.</li>
 *   <li> 4. {@link #onFullScreenMagnificationActivationState} updates magnification switch UI
 *   depending on magnification capabilities and magnification active state when fullscreen
 *   magnification activation state change.</li>
 *   <li> 4. {@link #onRequestMagnificationSpec} updates magnification switch UI depending on
 *   magnification capabilities and magnification active state when new magnification spec is
 *   changed by external request from calling public APIs. </li>
@@ -142,16 +143,6 @@ public class MagnificationController implements WindowMagnificationManager.Callb
        }
    }

    @Override
    public void onShortcutTriggered(int displayId, int mode) {
        updateMagnificationButton(displayId, mode);
    }

    @Override
    public void onTripleTapped(int displayId, int mode) {
        updateMagnificationButton(displayId, mode);
    }

    private void updateMagnificationButton(int displayId, int mode) {
        final boolean isActivated = isActivated(displayId, mode);
        final boolean showButton;
@@ -250,6 +241,7 @@ public class MagnificationController implements WindowMagnificationManager.Callb
                mActivatedMode = ACCESSIBILITY_MAGNIFICATION_MODE_NONE;
            }
        }
        updateMagnificationButton(displayId, ACCESSIBILITY_MAGNIFICATION_MODE_WINDOW);
    }

    private void disableFullScreenMagnificationIfNeeded(int displayId) {
@@ -264,7 +256,7 @@ public class MagnificationController implements WindowMagnificationManager.Callb
    }

    @Override
    public void onFullScreenMagnificationActivationState(boolean activated) {
    public void onFullScreenMagnificationActivationState(int displayId, boolean activated) {
        if (activated) {
            mFullScreenModeEnabledTime = SystemClock.uptimeMillis();

@@ -280,6 +272,7 @@ public class MagnificationController implements WindowMagnificationManager.Callb
                mActivatedMode = ACCESSIBILITY_MAGNIFICATION_MODE_NONE;
            }
        }
        updateMagnificationButton(displayId, ACCESSIBILITY_MAGNIFICATION_MODE_FULLSCREEN);
    }

    @Override
+0 −20
Original line number Diff line number Diff line
@@ -80,25 +80,6 @@ public abstract class MagnificationGestureHandler extends BaseEventStreamTransfo
         * @param mode The magnification mode
         */
        void onTouchInteractionEnd(int displayId, int mode);

        /**
         * Called when the magnification shortcut is triggered by a user. The magnification
         * shortcut can be accessibility button or volume shortcut.
         *
         * @param displayId The logical display id
         * @param mode The magnification mode
         */
        void onShortcutTriggered(int displayId, int mode);

        /**
         * Called when the triple-tap gesture is handled. The magnification
         * shortcut can be a triple-tap gesture or accessibility button.
         * Called when the triple-tap gesture is handled
         *
         * @param displayId The logical display id
         * @param mode The magnification mode
         */
        void onTripleTapped(int displayId, int mode);
    }

    private final AccessibilityTraceManager mTrace;
@@ -192,7 +173,6 @@ public abstract class MagnificationGestureHandler extends BaseEventStreamTransfo
        }
        if (mDetectShortcutTrigger) {
            handleShortcutTriggered();
            mCallback.onShortcutTriggered(mDisplayId, getMode());
        }
    }

+0 −1
Original line number Diff line number Diff line
@@ -202,7 +202,6 @@ public class WindowMagnificationGestureHandler extends MagnificationGestureHandl
            Slog.i(mLogTag, "onTripleTap()");
        }
        toggleMagnification(up.getX(), up.getY());
        mCallback.onTripleTapped(mDisplayId, getMode());
    }

    void resetToDetectState() {
Loading