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

Commit 50e5165b authored by Tony Wickham's avatar Tony Wickham
Browse files

Add WidgetsAndMore bottom sheet

- Contains two rows, one for widgets, and one for "configurable
  shortcuts" that have customization activities
- Extends AbstractFloatingView and uses VerticalPullDetector for
  touch interactions
- No way to show this currently; will add options to popup in followup

Bug: 34940468
Change-Id: Iab62c2cb89428f91119c9c86f9db886496c321fd
parent 8eb0de13
Loading
Loading
Loading
Loading
+80 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2017 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.widget.WidgetsAndMore
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:padding="8dp"
    android:background="?android:attr/colorPrimary"
    android:elevation="@dimen/deep_shortcuts_elevation"
    android:layout_gravity="bottom">

    <TextView
        android:id="@+id/title"
        android:layout_width="match_parent"
        android:layout_height="48dp"
        android:gravity="center_horizontal|bottom"
        android:fontFamily="sans-serif"
        android:textStyle="bold"
        android:textColor="?android:attr/textColorPrimary"
        android:textSize="20sp"/>

    <TextView
        android:layout_width="match_parent"
        android:layout_height="48dp"
        android:gravity="center_horizontal|top"
        android:fontFamily="sans-serif"
        android:textColor="?android:attr/textColorPrimary"
        android:textSize="16sp"
        android:text="@string/long_press_widget_to_add"/>

    <TextView
        android:id="@+id/widgets_header"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fontFamily="sans-serif"
        android:textColor="?android:attr/textColorPrimary"
        android:textSize="16sp"
        android:textStyle="bold"
        android:text="@string/widget_button_text"/>

    <include layout="@layout/widgets_scroll_container"
         android:id="@+id/widgets"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_marginTop="@dimen/widget_row_padding"
         android:layout_marginBottom="@dimen/widget_row_padding"/>

    <TextView
        android:id="@+id/shortcuts_header"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fontFamily="sans-serif"
        android:textColor="?android:attr/textColorPrimary"
        android:textSize="16sp"
        android:textStyle="bold"
        android:text="@string/widgets_bottom_sheet_custom_shortcuts_section_title"/>

    <include layout="@layout/widgets_scroll_container"
             android:id="@+id/shortcuts"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:layout_marginTop="@dimen/widget_row_padding"
             android:layout_marginBottom="@dimen/widget_row_padding" />

</com.android.launcher3.widget.WidgetsAndMore>
 No newline at end of file
+32 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2017 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.
-->

<HorizontalScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/widgets_scroll_container"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="?android:attr/colorPrimaryDark"
    android:scrollbars="none">
    <LinearLayout
        android:id="@+id/widgets_cell_list"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingStart="0dp"
        android:paddingEnd="0dp"
        android:orientation="horizontal"
        android:showDividers="none"/>
</HorizontalScrollView>
 No newline at end of file
+4 −0
Original line number Diff line number Diff line
@@ -203,6 +203,10 @@
    <!-- Title for an app whose download has been started. -->
    <string name="app_waiting_download_title"><xliff:g id="name" example="Messenger">%1$s</xliff:g> waiting to install</string>

    <!-- Strings for widgets & more in the popup container/bottom sheet -->
    <string name="widgets_and_more" translatable="false">Widgets &amp; more</string>
    <string name="widgets_bottom_sheet_custom_shortcuts_section_title" translatable="false">Custom shortcuts</string>

<!-- Strings for accessibility actions -->
    <!-- Accessibility action to add an app to workspace. [CHAR_LIMIT=30] -->
    <string name="action_add_to_workspace">Add to Home screen</string>
+19 −2
Original line number Diff line number Diff line
@@ -16,9 +16,11 @@

package com.android.launcher3;

import android.annotation.SuppressLint;
import android.content.Context;
import android.support.annotation.IntDef;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.widget.LinearLayout;

@@ -32,11 +34,16 @@ import java.lang.annotation.RetentionPolicy;
 */
public abstract class AbstractFloatingView extends LinearLayout {

    @IntDef(flag = true, value = {TYPE_FOLDER, TYPE_POPUP_CONTAINER_WITH_ARROW})
    @IntDef(flag = true, value = {
            TYPE_FOLDER,
            TYPE_POPUP_CONTAINER_WITH_ARROW,
            TYPE_WIDGETS_AND_MORE
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface FloatingViewType {}
    public static final int TYPE_FOLDER = 1 << 0;
    public static final int TYPE_POPUP_CONTAINER_WITH_ARROW = 1 << 1;
    public static final int TYPE_WIDGETS_AND_MORE = 1 << 2;

    protected boolean mIsOpen;

@@ -48,6 +55,15 @@ public abstract class AbstractFloatingView extends LinearLayout {
        super(context, attrs, defStyleAttr);
    }

    /**
     * We need to handle touch events to prevent them from falling through to the workspace below.
     */
    @SuppressLint("ClickableViewAccessibility")
    @Override
    public boolean onTouchEvent(MotionEvent ev) {
        return true;
    }

    public final void close(boolean animate) {
        animate &= !Utilities.isPowerSaverOn(getContext());
        handleClose(animate);
@@ -119,7 +135,8 @@ public abstract class AbstractFloatingView extends LinearLayout {
    }

    public static AbstractFloatingView getTopOpenView(Launcher launcher) {
        return getOpenView(launcher, TYPE_FOLDER | TYPE_POPUP_CONTAINER_WITH_ARROW);
        return getOpenView(launcher, TYPE_FOLDER | TYPE_POPUP_CONTAINER_WITH_ARROW
                | TYPE_WIDGETS_AND_MORE);
    }

    public abstract int getLogContainerType();
+0 −1
Original line number Diff line number Diff line
@@ -89,7 +89,6 @@ import com.android.launcher3.anim.AnimationLayerSet;
import com.android.launcher3.compat.AppWidgetManagerCompat;
import com.android.launcher3.compat.LauncherAppsCompat;
import com.android.launcher3.compat.PinItemRequestCompat;
import com.android.launcher3.compat.UserManagerCompat;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.config.ProviderConfig;
import com.android.launcher3.dragndrop.DragController;
Loading