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

Commit a4647b68 authored by Sunny Goyal's avatar Sunny Goyal
Browse files

Adding support for keyboard based drag and drop

For keyboard DnD, we use Accessible DnD implementation.
A placeholder FloatingView draws the focus indicator
for the virtual views

Test: Visible
Bug: 178781566
Change-Id: I632fc7377dffa1e05e3f0a9c3ad18641deb5a1a4
parent d4629656
Loading
Loading
Loading
Loading
+34 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- 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.
-->
<com.android.launcher3.keyboard.KeyboardDragAndDropView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:focusable="true"
    android:orientation="vertical"
    android:elevation="6dp">

    <TextView
        android:id="@+id/label"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:background="?attr/folderFillColor"
        android:padding="8dp"
        android:textColor="?attr/folderTextColor"
        />

</com.android.launcher3.keyboard.KeyboardDragAndDropView>
 No newline at end of file
+1 −0
Original line number Diff line number Diff line
@@ -139,6 +139,7 @@
    <dimen name="drag_flingToDeleteMinVelocity">-1500dp</dimen>

    <dimen name="spring_loaded_panel_border">1dp</dimen>
    <dimen name="keyboard_drag_stroke_width">4dp</dimen>

<!-- Folders -->
    <dimen name="page_indicator_dot_size">8dp</dimen>
+6 −5
Original line number Diff line number Diff line
@@ -76,17 +76,18 @@ public abstract class AbstractFloatingView extends LinearLayout implements Touch
    public static final int TYPE_SNACKBAR = 1 << 7;
    public static final int TYPE_LISTENER = 1 << 8;
    public static final int TYPE_ALL_APPS_EDU = 1 << 9;
    public static final int TYPE_DRAG_DROP_POPUP = 1 << 10;

    // Popups related to quickstep UI
    public static final int TYPE_TASK_MENU = 1 << 10;
    public static final int TYPE_OPTIONS_POPUP = 1 << 11;
    public static final int TYPE_ICON_SURFACE = 1 << 12;
    public static final int TYPE_TASK_MENU = 1 << 11;
    public static final int TYPE_OPTIONS_POPUP = 1 << 12;
    public static final int TYPE_ICON_SURFACE = 1 << 13;

    public static final int TYPE_ALL = TYPE_FOLDER | TYPE_ACTION_POPUP
            | TYPE_WIDGETS_BOTTOM_SHEET | TYPE_WIDGET_RESIZE_FRAME | TYPE_WIDGETS_FULL_SHEET
            | TYPE_ON_BOARD_POPUP | TYPE_DISCOVERY_BOUNCE | TYPE_TASK_MENU
            | TYPE_OPTIONS_POPUP | TYPE_SNACKBAR | TYPE_LISTENER | TYPE_ALL_APPS_EDU
            | TYPE_ICON_SURFACE;
            | TYPE_ICON_SURFACE | TYPE_DRAG_DROP_POPUP;

    // Type of popups which should be kept open during launcher rebind
    public static final int TYPE_REBIND_SAFE = TYPE_WIDGETS_FULL_SHEET
@@ -103,7 +104,7 @@ public abstract class AbstractFloatingView extends LinearLayout implements Touch
    // These view all have particular operation associated with swipe down interaction.
    public static final int TYPE_STATUS_BAR_SWIPE_DOWN_DISALLOW = TYPE_WIDGETS_BOTTOM_SHEET |
            TYPE_WIDGETS_FULL_SHEET | TYPE_WIDGET_RESIZE_FRAME | TYPE_ON_BOARD_POPUP |
            TYPE_DISCOVERY_BOUNCE | TYPE_TASK_MENU ;
            TYPE_DISCOVERY_BOUNCE | TYPE_TASK_MENU | TYPE_DRAG_DROP_POPUP;

    protected boolean mIsOpen;

+1 −1
Original line number Diff line number Diff line
@@ -240,7 +240,7 @@ public abstract class ButtonDropTarget extends TextView

    @Override
    public void onDragStart(DropTarget.DragObject dragObject, DragOptions options) {
        mActive = supportsDrop(dragObject.dragInfo);
        mActive = !options.isKeyboardDrag && supportsDrop(dragObject.dragInfo);
        mDrawable.setColorFilter(null);
        if (mCurrentColorAnim != null) {
            mCurrentColorAnim.cancel();
+7 −0
Original line number Diff line number Diff line
@@ -312,6 +312,13 @@ public class CellLayout extends ViewGroup {
        }
    }

    /**
     * Returns the currently set accessibility delegate
     */
    public DragAndDropAccessibilityDelegate getDragAndDropAccessibilityDelegate() {
        return mTouchHelper;
    }

    @Override
    public boolean dispatchHoverEvent(MotionEvent event) {
        // Always attempt to dispatch hover events to accessibility first.
Loading