Updates the icon of magnification button by magnification mode
When the current magnification mode is fullscreen mode, magnification button will use "open in new window magnification" icon. It means that the current magnifion mode will be changed to window mode when clicking the button in full screen mode. And vice versa for the case that the current mode is window mode. Bug: 145780606 Test: none Change-Id: I4a4b082465546135afa36f1751bcf4c85e78b1c4
This commit is contained in:
77
packages/SystemUI/res/drawable/ic_open_in_new_window.xml
Normal file
77
packages/SystemUI/res/drawable/ic_open_in_new_window.xml
Normal file
@@ -0,0 +1,77 @@
|
||||
<!--
|
||||
~ Copyright (C) 2020 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.
|
||||
-->
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item>
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="@color/magnification_switch_button_color" />
|
||||
<size
|
||||
android:width="40dp"
|
||||
android:height="40dp" />
|
||||
</shape>
|
||||
</item>
|
||||
|
||||
<item>
|
||||
<vector
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
|
||||
<group
|
||||
android:translateX="1.500000"
|
||||
android:translateY="1.500000">
|
||||
<path
|
||||
android:fillType="evenOdd"
|
||||
android:strokeColor="#FFFFFF"
|
||||
android:strokeWidth="2"
|
||||
android:pathData="M 3.5 1.5 L 17.5 1.5 Q 19.5 1.5 19.5 3.5 L 19.5 17.5 Q 19.5 19.5 17.5 19.5 L 3.5 19.5 Q 1.5 19.5 1.5 17.5 L 1.5 3.5 Q 1.5 1.5 3.5 1.5 Z" />
|
||||
<path
|
||||
android:fillType="evenOdd"
|
||||
android:strokeColor="#FFFFFF"
|
||||
android:strokeWidth="1.5"
|
||||
android:pathData="M 4.25 4.25 H 8.75 V 8.75 H 4.25 V 4.25 Z" />
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:fillType="evenOdd"
|
||||
android:strokeWidth="1"
|
||||
android:pathData="M 12.5 13.92 L 15.59 17 L 17 15.59 L 13.91 12.5 L 16.5 12.5 L 16.5 10.5 L 10.5 10.5 L 10.5 16.5 L 12.5 16.5 Z" />
|
||||
</group>
|
||||
<group
|
||||
android:translateX="22.000000"
|
||||
android:translateY="2.000000">
|
||||
<group
|
||||
android:translateX="3.000000"
|
||||
android:translateY="3.000000">
|
||||
<group
|
||||
android:translateX="-3.000000"
|
||||
android:translateY="-3.000000">
|
||||
<path
|
||||
android:fillColor="#80868B"
|
||||
android:fillType="evenOdd"
|
||||
android:strokeWidth="1"
|
||||
android:pathData="M 0 0 H 24 V 24 H 0 V 0 Z" />
|
||||
</group>
|
||||
</group>
|
||||
</group>
|
||||
</vector>
|
||||
</item>
|
||||
|
||||
<item>
|
||||
<ripple android:color="@color/GM2_grey_600"></ripple>
|
||||
</item>
|
||||
|
||||
</layer-list>
|
||||
@@ -145,12 +145,10 @@ public class ModeSwitchesController {
|
||||
|
||||
void showButton(int mode) {
|
||||
if (mImageView == null) {
|
||||
createView();
|
||||
createView(mode);
|
||||
mWindowManager.addView(mImageView, mParams);
|
||||
} else if (mMagnificationMode != mode) {
|
||||
// TODO(b/145780606): wait for designer provide icon asset for window mode.
|
||||
final int resId = R.drawable.ic_open_in_new_fullscreen;
|
||||
mImageView.setImageResource(resId);
|
||||
mImageView.setImageResource(getIconResId(mode));
|
||||
}
|
||||
mMagnificationMode = mode;
|
||||
|
||||
@@ -167,17 +165,13 @@ public class ModeSwitchesController {
|
||||
() -> removeButton());
|
||||
}
|
||||
|
||||
private void createView() {
|
||||
// TODO(b/145780606): wait for designer provide icon asset for window mode.
|
||||
final int resId = R.drawable.ic_open_in_new_fullscreen;
|
||||
private void createView(int mode) {
|
||||
mImageView = new ImageView(mContext);
|
||||
mImageView.setImageResource(resId);
|
||||
mImageView.setImageResource(getIconResId(mode));
|
||||
mImageView.setClickable(true);
|
||||
mImageView.setFocusable(true);
|
||||
mImageView.setPadding(mPadding, mPadding, mPadding, mPadding);
|
||||
mImageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
|
||||
// TODO(b/145780606): switch magnification mode between full-screen and window by
|
||||
// clicking the button.
|
||||
mImageView.setOnClickListener(
|
||||
view -> {
|
||||
if (view != null) {
|
||||
@@ -188,6 +182,12 @@ public class ModeSwitchesController {
|
||||
});
|
||||
}
|
||||
|
||||
private int getIconResId(int mode) {
|
||||
return (mode == Settings.Secure.ACCESSIBILITY_MAGNIFICATION_MODE_FULLSCREEN)
|
||||
? R.drawable.ic_open_in_new_window
|
||||
: R.drawable.ic_open_in_new_fullscreen;
|
||||
}
|
||||
|
||||
private void toggleMagnificationMode() {
|
||||
final int newMode =
|
||||
mMagnificationMode ^ Settings.Secure.ACCESSIBILITY_MAGNIFICATION_MODE_ALL;
|
||||
|
||||
Reference in New Issue
Block a user