Merge "Style the Magnification Window - Window Mode Drag" into udc-dev

This commit is contained in:
Candice Lo
2023-03-07 00:24:26 +00:00
committed by Android (Google) Code Review
8 changed files with 58 additions and 5 deletions

View File

@@ -27,7 +27,7 @@
<shape android:shape="rectangle">
<corners android:radius="@dimen/magnifier_outer_corner_radius" />
<stroke
android:color="@android:color/black"
android:color="@color/magnification_drag_handle_stroke"
android:width="@dimen/magnifier_stroke_width"/>
</shape>
</item>

View File

@@ -16,7 +16,7 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<stroke
android:color="@android:color/black"
android:color="@color/magnification_drag_handle_stroke"
android:width="@dimen/magnifier_stroke_width"/>
<corners android:radius="@dimen/magnifier_corner_radius" />
<solid android:color="@color/magnification_border_color" />

View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?><!--
~ 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.
-->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<stroke
android:color="@color/magnification_border_color"
android:width="@dimen/magnifier_stroke_width"/>
<corners android:radius="@dimen/magnifier_corner_radius" />
<solid android:color="@color/magnification_drag_handle_background_change" />
</shape>

View File

@@ -20,6 +20,6 @@
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@color/magnification_drag_handle_tint"
android:fillColor="@color/magnification_drag_handle_stroke"
android:pathData="M12,15Q10.75,15 9.875,14.125Q9,13.25 9,12Q9,10.75 9.875,9.875Q10.75,9 12,9Q13.25,9 14.125,9.875Q15,10.75 15,12Q15,13.25 14.125,14.125Q13.25,15 12,15ZM12,22 L7.75,17.75 9.15,16.35 12,19.15 14.85,16.35 16.25,17.75ZM6.25,16.25 L2,12 6.25,7.75 7.65,9.15 4.85,12 7.65,14.85ZM9.15,7.65 L7.75,6.25 12,2 16.25,6.25 14.85,7.65 12,4.85ZM17.75,16.25 L16.35,14.85 19.15,12 16.35,9.15 17.75,7.75 22,12Z"/>
</vector>

View File

@@ -163,8 +163,8 @@
<color name="magnification_border_color">#F29900</color>
<color name="magnification_switch_button_color">#7F000000</color>
<color name="magnification_drag_corner_background">#E5FFFFFF</color>
<color name="magnification_drag_handle_color">#B3000000</color>
<color name="magnification_drag_handle_tint">#111111</color>
<color name="magnification_drag_handle_stroke">#000000</color>
<color name="magnification_drag_handle_background_change">#111111</color>
<color name="accessibility_magnifier_bg">#FCFCFC</color>
<color name="accessibility_magnifier_bg_stroke">#E0E0E0</color>
<color name="accessibility_magnifier_icon_color">#252525</color>

View File

@@ -37,6 +37,8 @@ import android.content.res.Resources;
import android.graphics.Insets;
import android.graphics.Matrix;
import android.graphics.PixelFormat;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Region;
@@ -1398,6 +1400,11 @@ class WindowMagnificationController implements View.OnTouchListener, SurfaceHold
mWindowMagnifierCallback.onPerformScaleAction(mDisplayId,
A11Y_ACTION_SCALE_RANGE.clamp(scale));
}
@Override
public void onSettingsPanelVisibilityChanged(boolean shown) {
updateDragHandleResourcesIfNeeded(/* settingsPanelIsShown= */ shown);
}
};
@Override
@@ -1436,6 +1443,20 @@ class WindowMagnificationController implements View.OnTouchListener, SurfaceHold
}
}
private void updateDragHandleResourcesIfNeeded(boolean settingsPanelIsShown) {
mDragView.setBackground(mContext.getResources().getDrawable(settingsPanelIsShown
? R.drawable.accessibility_window_magnification_drag_handle_background_change
: R.drawable.accessibility_window_magnification_drag_handle_background));
PorterDuffColorFilter filter = new PorterDuffColorFilter(
mContext.getColor(settingsPanelIsShown
? R.color.magnification_border_color
: R.color.magnification_drag_handle_stroke),
PorterDuff.Mode.SRC_ATOP);
mDragView.setColorFilter(filter);
}
private void animateBounceEffect() {
final ObjectAnimator scaleAnimator = ObjectAnimator.ofPropertyValuesHolder(mMirrorView,
PropertyValuesHolder.ofFloat(View.SCALE_X, 1, mBounceEffectAnimationScale, 1),

View File

@@ -323,6 +323,7 @@ class WindowMagnificationSettings implements MagnificationGestureDetector.OnGest
}
mContext.unregisterReceiver(mScreenOffReceiver);
mCallback.onSettingsPanelVisibilityChanged(/* shown= */ false);
}
public void showSettingPanel() {
@@ -361,6 +362,7 @@ class WindowMagnificationSettings implements MagnificationGestureDetector.OnGest
// Exclude magnification switch button from system gesture area.
setSystemGestureExclusion();
mIsVisible = true;
mCallback.onSettingsPanelVisibilityChanged(/* shown= */ true);
}
mContext.registerReceiver(mScreenOffReceiver, new IntentFilter(Intent.ACTION_SCREEN_OFF));
}

View File

@@ -61,4 +61,11 @@ public interface WindowMagnificationSettingsCallback {
* 1 : ACCESSIBILITY_MAGNIFICATION_MODE_FULLSCREEN, 2 : ACCESSIBILITY_MAGNIFICATION_MODE_WINDOW
*/
void onModeSwitch(int newMode);
/**
* Called when the visibility of the magnification settings panel changed.
*
* @param shown The visibility of the magnification settings panel.
*/
void onSettingsPanelVisibilityChanged(boolean shown);
}