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

Commit 377ed3f6 authored by Tony Wickham's avatar Tony Wickham
Browse files

Add drag handle to shortcuts.

Also use short text if long text is ellipsized.

Bug: 30212144
Bug: 28980830
Change-Id: I213766bca0561d284d1da883ca37b0a42d886129
parent 2eeae10e
Loading
Loading
Loading
Loading
+26 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2016 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.
-->

<vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:width="24dp"
        android:height="24dp"
        android:viewportWidth="24.0"
        android:viewportHeight="24.0">

    <path
        android:pathData="M20 9H4v2h16V9zM4 15h16v-2H4v2z"
        android:fillColor="#757575"/>
</vector>
 No newline at end of file
+1 −1
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@
    android:elevation="@dimen/deep_shortcuts_elevation"
    android:background="@drawable/bg_white_pill">

    <com.android.launcher3.BubbleTextView
    <com.android.launcher3.shortcuts.DeepShortcutTextView
        android:id="@+id/deep_shortcut"
        style="@style/Icon.DeepShortcut"
        android:focusable="true"/>
+2 −1
Original line number Diff line number Diff line
@@ -81,7 +81,8 @@
        <item name="android:gravity">start|center_vertical</item>
        <item name="android:elevation">@dimen/deep_shortcuts_elevation</item>
        <item name="android:paddingLeft">7dp</item>
        <item name="android:drawablePadding">12dp</item>
        <item name="android:paddingRight">12dp</item>
        <item name="android:drawablePadding">9dp</item>
        <item name="android:textColor">@color/quantum_panel_text_color</item>
        <item name="android:shadowRadius">0</item>
        <item name="customShadows">false</item>
+8 −4
Original line number Diff line number Diff line
@@ -526,19 +526,23 @@ public class BubbleTextView extends TextView
     * Sets the icon for this view based on the layout direction.
     */
    @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
    public void setIcon(Drawable icon) {
    private void setIcon(Drawable icon) {
        mIcon = icon;
        if (mIconSize != -1) {
            mIcon.setBounds(0, 0, mIconSize, mIconSize);
        }
        applyCompoundDrawables(mIcon);
    }

    protected void applyCompoundDrawables(Drawable icon) {
        if (mLayoutHorizontal) {
            if (Utilities.ATLEAST_JB_MR1) {
                setCompoundDrawablesRelative(mIcon, null, null, null);
                setCompoundDrawablesRelative(icon, null, null, null);
            } else {
                setCompoundDrawables(mIcon, null, null, null);
                setCompoundDrawables(icon, null, null, null);
            }
        } else {
            setCompoundDrawables(null, mIcon, null, null);
            setCompoundDrawables(null, icon, null, null);
        }
    }

+50 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2016 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.launcher3.shortcuts;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;

import com.android.launcher3.BubbleTextView;
import com.android.launcher3.R;

/**
 * A {@link BubbleTextView} that has the shortcut icon on the left and drag handle on the right.
 */
public class DeepShortcutTextView extends BubbleTextView {

    public DeepShortcutTextView(Context context) {
        this(context, null, 0);
    }

    public DeepShortcutTextView(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public DeepShortcutTextView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    @Override
    /** Use the BubbleTextView icon for the start and the drag handle for the end. */
    protected void applyCompoundDrawables(Drawable icon) {
        Drawable dragHandle = getResources().getDrawable(R.drawable.deep_shortcuts_drag_handle);
        dragHandle.setBounds(0, 0, dragHandle.getIntrinsicWidth(), dragHandle.getIntrinsicHeight());
        setCompoundDrawablesRelative(icon, null, dragHandle, null);
    }
}
Loading