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

Commit ae6b3481 authored by Steven Ng's avatar Steven Ng
Browse files

WidgetCell & LiveWidgetPreview cleanup

The fixes are:
1. For widgets shown in TableRow, aligns them center vertically.
   This is useful when widgets of different height are shown in
   the same row.
2. Remove background color from WidgetCell
3. Re-enable swipe in FullWidgetsSheet
4. Use the WidgetCell image as the single & long press area because
   1. Previews are now scaled to their default size. The touch area
      should already be larger for widgets that are bigger than 2.4
      cells
   2. WidgetCells also render description. If the user long press the
      description area, the drag view will not align in the middle of
      the user touch / drag area.

Test: Drag-n-drop widgets from FullWidgetsSheet, BottomWidgetsSheet
      and pin widget flow.
      In FullWidgetsSheet, swipe left and right to switch work /
      personal tab.

Video: https://drive.google.com/file/d/1Ur7PwF1a7iwGGRTZczfc0BSVu-Ta6-Vm/view?usp=sharing

Bug: 179797520
Change-Id: I6fe4bc88d1e1b35b1819d8d7f046105f5ed27043
parent d60299e1
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -46,7 +46,7 @@
                android:background="?android:attr/colorPrimaryDark"
                android:theme="?attr/widgetsTheme">

                <com.android.launcher3.dragndrop.LivePreviewWidgetCell
                <com.android.launcher3.widget.WidgetCell
                    android:id="@+id/widget_cell"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
@@ -59,7 +59,7 @@

                    <include layout="@layout/widget_cell_content"  />

                </com.android.launcher3.dragndrop.LivePreviewWidgetCell>
                </com.android.launcher3.widget.WidgetCell>
            </FrameLayout>
        </LinearLayout>
    </ScrollView>
+0 −30
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.dragndrop.LivePreviewWidgetCell
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:paddingHorizontal="@dimen/widget_cell_horizontal_padding"
    android:paddingVertical="@dimen/widget_cell_vertical_padding"
    android:layout_weight="1"
    android:orientation="vertical"
    android:focusable="true"
    android:background="?android:attr/colorPrimaryDark"
    android:gravity="center_horizontal">

    <include layout="@layout/widget_cell_content" />

</com.android.launcher3.dragndrop.LivePreviewWidgetCell>
 No newline at end of file
+0 −1
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@
    android:layout_weight="1"
    android:orientation="vertical"
    android:focusable="true"
    android:background="?android:attr/colorPrimaryDark"
    android:gravity="center_horizontal">

    <include layout="@layout/widget_cell_content"  />
+0 −12
Original line number Diff line number Diff line
@@ -96,8 +96,6 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou
    private static final int MIN_FLING_VELOCITY = 250;

    private boolean mFreeScroll = false;
    /** If {@code false}, disable swipe gesture to switch between pages. */
    private boolean mSwipeGestureEnabled = true;

    protected final int mFlingThresholdVelocity;
    protected final int mEasyFlingThresholdVelocity;
@@ -859,14 +857,6 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou
        }
    }

    /**
     * If {@code enableSwipeGesture} is {@code true}, enables swipe gesture to navigate between
     * pages. Otherwise, disables the navigation gesture.
     */
    public void setSwipeGestureEnabled(boolean swipeGestureEnabled) {
        mSwipeGestureEnabled = swipeGestureEnabled;
    }

    /**
     * {@inheritDoc}
     */
@@ -889,8 +879,6 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou
         * scrolling there.
         */

        if (!mSwipeGestureEnabled) return false;

        // Skip touch handling if there are no pages to swipe
        if (getChildCount() <= 0) return false;

+5 −3
Original line number Diff line number Diff line
@@ -58,6 +58,7 @@ import com.android.launcher3.widget.LauncherAppWidgetHost;
import com.android.launcher3.widget.LauncherAppWidgetProviderInfo;
import com.android.launcher3.widget.PendingAddShortcutInfo;
import com.android.launcher3.widget.PendingAddWidgetInfo;
import com.android.launcher3.widget.WidgetCell;
import com.android.launcher3.widget.WidgetHostViewLoader;
import com.android.launcher3.widget.WidgetImageView;
import com.android.launcher3.widget.WidgetManagerHelper;
@@ -78,7 +79,7 @@ public class AddItemActivity extends BaseActivity implements OnLongClickListener
    private LauncherAppState mApp;
    private InvariantDeviceProfile mIdp;

    private LivePreviewWidgetCell mWidgetCell;
    private WidgetCell mWidgetCell;

    // Widget request specific options.
    private LauncherAppWidgetHost mAppWidgetHost;
@@ -117,8 +118,9 @@ public class AddItemActivity extends BaseActivity implements OnLongClickListener
            }
        }

        mWidgetCell.setOnTouchListener(this);
        mWidgetCell.setOnLongClickListener(this);
        WidgetImageView preview = mWidgetCell.findViewById(R.id.widget_preview);
        preview.setOnTouchListener(this);
        preview.setOnLongClickListener(this);

        // savedInstanceState is null when the activity is created the first time (i.e., avoids
        // duplicate logging during rotation)
Loading