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

Commit fc7d9f4b authored by Roy Chou's avatar Roy Chou Committed by Android (Google) Code Review
Browse files

Merge changes I995a059c,Ibf78c90b into udc-qpr-dev

* changes:
  chore(#MagSettingsPanel): change persisting scale timing
  chore(#MagSettingsPanel): make seekbar index reflect the controlling magnifier scale
parents 22483677 58b977cf
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -57,8 +57,9 @@ import android.graphics.Rect;
     *
     * @param displayId The logical display id.
     * @param scale the target scale, or {@link Float#NaN} to leave unchanged
     * @param updatePersistence whether the new scale should be persisted in Settings
     */
    void onPerformScaleAction(int displayId, float scale);
    void onPerformScaleAction(int displayId, float scale, boolean updatePersistence);

    /**
     * Called when the accessibility action is performed.
+8 −3
Original line number Diff line number Diff line
@@ -107,6 +107,10 @@ public class MagnificationSettingsController implements ComponentCallbacks {
        return mWindowMagnificationSettings.isSettingPanelShowing();
    }

    void setMagnificationScale(float scale) {
        mWindowMagnificationSettings.setMagnificationScale(scale);
    }

    @Override
    public void onConfigurationChanged(@NonNull Configuration newConfig) {
        final int configDiff = newConfig.diff(mConfiguration);
@@ -160,8 +164,9 @@ public class MagnificationSettingsController implements ComponentCallbacks {
         *
         * @param displayId The logical display id.
         * @param scale Magnification scale value.
         * @param updatePersistence whether the new scale should be persisted.
         */
        void onMagnifierScale(int displayId, float scale);
        void onMagnifierScale(int displayId, float scale, boolean updatePersistence);

        /**
         * Called when magnification mode changed.
@@ -211,9 +216,9 @@ public class MagnificationSettingsController implements ComponentCallbacks {
        }

        @Override
        public void onMagnifierScale(float scale) {
        public void onMagnifierScale(float scale, boolean updatePersistence) {
            mSettingsControllerCallback.onMagnifierScale(mDisplayId,
                    A11Y_ACTION_SCALE_RANGE.clamp(scale));
                    A11Y_ACTION_SCALE_RANGE.clamp(scale), updatePersistence);
        }
    };
}
+10 −4
Original line number Diff line number Diff line
@@ -310,6 +310,10 @@ public class WindowMagnification implements CoreStartable, CommandQueue.Callback
            return;
        }
        scales.put(displayId, scale);

        final MagnificationSettingsController magnificationSettingsController =
                mMagnificationSettingsSupplier.get(displayId);
        magnificationSettingsController.setMagnificationScale(scale);
    }

    @VisibleForTesting
@@ -329,9 +333,10 @@ public class WindowMagnification implements CoreStartable, CommandQueue.Callback
        }

        @Override
        public void onPerformScaleAction(int displayId, float scale) {
        public void onPerformScaleAction(int displayId, float scale, boolean updatePersistence) {
            if (mWindowMagnificationConnectionImpl != null) {
                mWindowMagnificationConnectionImpl.onPerformScaleAction(displayId, scale);
                mWindowMagnificationConnectionImpl.onPerformScaleAction(
                        displayId, scale, updatePersistence);
            }
        }

@@ -380,9 +385,10 @@ public class WindowMagnification implements CoreStartable, CommandQueue.Callback
        }

        @Override
        public void onMagnifierScale(int displayId, float scale) {
        public void onMagnifierScale(int displayId, float scale, boolean updatePersistence) {
            if (mWindowMagnificationConnectionImpl != null) {
                mWindowMagnificationConnectionImpl.onPerformScaleAction(displayId, scale);
                mWindowMagnificationConnectionImpl.onPerformScaleAction(
                        displayId, scale, updatePersistence);
            }
        }

+2 −2
Original line number Diff line number Diff line
@@ -129,10 +129,10 @@ class WindowMagnificationConnectionImpl extends IWindowMagnificationConnection.S
        }
    }

    void onPerformScaleAction(int displayId, float scale) {
    void onPerformScaleAction(int displayId, float scale, boolean updatePersistence) {
        if (mConnectionCallback != null) {
            try {
                mConnectionCallback.onPerformScaleAction(displayId, scale);
                mConnectionCallback.onPerformScaleAction(displayId, scale, updatePersistence);
            } catch (RemoteException e) {
                Log.e(TAG, "Failed to inform performing scale action", e);
            }
+8 −6
Original line number Diff line number Diff line
@@ -1491,13 +1491,9 @@ class WindowMagnificationController implements View.OnTouchListener, SurfaceHold
                // Simulate tapping the drag view so it opens the Settings.
                handleSingleTap(mDragView);
            } else if (action == R.id.accessibility_action_zoom_in) {
                final float scale = mScale + A11Y_CHANGE_SCALE_DIFFERENCE;
                mWindowMagnifierCallback.onPerformScaleAction(mDisplayId,
                        A11Y_ACTION_SCALE_RANGE.clamp(scale));
                performScale(mScale + A11Y_CHANGE_SCALE_DIFFERENCE);
            } else if (action == R.id.accessibility_action_zoom_out) {
                final float scale = mScale - A11Y_CHANGE_SCALE_DIFFERENCE;
                mWindowMagnifierCallback.onPerformScaleAction(mDisplayId,
                        A11Y_ACTION_SCALE_RANGE.clamp(scale));
                performScale(mScale - A11Y_CHANGE_SCALE_DIFFERENCE);
            } else if (action == R.id.accessibility_action_move_up) {
                move(0, -mSourceBounds.height());
            } else if (action == R.id.accessibility_action_move_down) {
@@ -1512,5 +1508,11 @@ class WindowMagnificationController implements View.OnTouchListener, SurfaceHold
            mWindowMagnifierCallback.onAccessibilityActionPerformed(mDisplayId);
            return true;
        }

        private void performScale(float scale) {
            scale = A11Y_ACTION_SCALE_RANGE.clamp(scale);
            mWindowMagnifierCallback.onPerformScaleAction(
                    mDisplayId, scale, /* updatePersistence= */ true);
        }
    }
}
 No newline at end of file
Loading