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

Commit adad00ef authored by Peter_Liang's avatar Peter_Liang
Browse files

Add new floating action menu for Accessibility targets. (4/n)

Patch action:
1. Drag and drop anywhere on the screen.
2. Stick on the closest left side or right side of the screen when dropping.
3. Apply the different styles.
 - Half oval style when dropping.
 - Oval style when dragging.

Bug: 173958541
Test: atest AccessibilityFloatingMenuTest
AccessibilityFloatingMenuViewTest AccessibilityTargetAdapterTest

Change-Id: I5f207b86b9ca4342f1414230c4d7524c59f48953
parent fbcc2822
Loading
Loading
Loading
Loading
+10 −15
Original line number Diff line number Diff line
@@ -15,11 +15,8 @@
    limitations under the License.
-->

<layer-list
    xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:id="@+id/menu_background_item">
        <shape android:shape="rectangle">
<shape xmlns:android="http://schemas.android.com/apk/res/android"
       android:shape="rectangle">
    <corners
        android:bottomLeftRadius="@dimen/accessibility_floating_menu_small_single_radius"
        android:bottomRightRadius="0dp"
@@ -28,5 +25,3 @@
    <solid
        android:color="@color/accessibility_floating_menu_background"/>
</shape>
    </item>
</layer-list>
 No newline at end of file
+1 −1
Original line number Diff line number Diff line
@@ -140,7 +140,7 @@ public class AccessibilityFloatingMenu implements IAccessibilityFloatingMenu {
    private static int getShapeType(Context context) {
        return Settings.Secure.getInt(
                context.getContentResolver(), ACCESSIBILITY_FLOATING_MENU_ICON_TYPE,
                ShapeType.CIRCLE);
                ShapeType.OVAL);
    }

    private void registerContentObservers() {
+301 −60

File changed.

Preview size limit exceeded, changes collapsed.

+37 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2021 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.systemui.accessibility.floatingmenu;

import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;

/**
 * A drawable that forces to update the bounds {@link #onBoundsChange(Rect)} immediately after
 * {@link #setLayerInset} dynamically.
 */
public class InstantInsetLayerDrawable extends LayerDrawable {
    public InstantInsetLayerDrawable(Drawable[] layers) {
        super(layers);
    }

    @Override
    public void setLayerInset(int index, int l, int t, int r, int b) {
        super.setLayerInset(index, l, t, r, b);
        onBoundsChange(getBounds());
    }
}
+3 −3
Original line number Diff line number Diff line
@@ -23,11 +23,11 @@ import com.android.internal.annotations.GuardedBy;
import java.util.ArrayList;
import java.util.List;

class MotionEventHelper {
public class MotionEventHelper {
    @GuardedBy("this")
    private final List<MotionEvent> mMotionEvents = new ArrayList<>();

    void recycleEvents() {
    public void recycleEvents() {
        for (MotionEvent event:mMotionEvents) {
            event.recycle();
        }
@@ -36,7 +36,7 @@ class MotionEventHelper {
        }
    }

    MotionEvent obtainMotionEvent(long downTime, long eventTime, int action, float x,
    public MotionEvent obtainMotionEvent(long downTime, long eventTime, int action, float x,
            float y) {
        MotionEvent event = MotionEvent.obtain(downTime, eventTime, action, x, y, 0);
        synchronized (this) {
Loading