Loading res/layout/search_result_shortcut.xml→res/layout/search_result_icon_row.xml +31 −0 Original line number Diff line number Diff line Loading @@ -12,31 +12,20 @@ See the License for the specific language governing permissions and limitations under the License. --> <com.android.launcher3.views.SearchResultShortcut xmlns:android="http://schemas.android.com/apk/res/android" <com.android.launcher3.views.SearchResultIconRow xmlns:android="http://schemas.android.com/apk/res/android" xmlns:launcher="http://schemas.android.com/apk/res-auto" style="@style/BaseIcon" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:gravity="center_vertical" android:padding="@dimen/dynamic_grid_edge_margin"> <com.android.launcher3.BubbleTextView android:id="@+id/bubble_text" style="@style/BaseIcon" android:drawablePadding="@dimen/dynamic_grid_icon_drawable_padding" android:gravity="start|center_vertical" android:textAlignment="viewStart" android:textColor="?android:attr/textColorPrimary" android:textSize="16sp" android:layout_height="wrap_content" android:padding="@dimen/dynamic_grid_edge_margin" launcher:iconDisplay="hero_app" launcher:layoutHorizontal="true" /> <View android:id="@+id/icon" android:layout_width="@dimen/deep_shortcut_icon_size" android:layout_height="@dimen/deep_shortcut_icon_size" android:layout_gravity="start|center_vertical" android:background="@drawable/ic_deepshortcut_placeholder" /> launcher:layoutHorizontal="true" > </com.android.launcher3.views.SearchResultShortcut> No newline at end of file </com.android.launcher3.views.SearchResultIconRow> No newline at end of file src/com/android/launcher3/BubbleTextView.java +11 −0 Original line number Diff line number Diff line Loading @@ -65,6 +65,7 @@ import com.android.launcher3.model.data.ItemInfo; import com.android.launcher3.model.data.ItemInfoWithIcon; import com.android.launcher3.model.data.PackageItemInfo; import com.android.launcher3.model.data.PromiseAppInfo; import com.android.launcher3.model.data.RemoteActionItemInfo; import com.android.launcher3.model.data.WorkspaceItemInfo; import com.android.launcher3.util.SafeCloseable; import com.android.launcher3.views.ActivityContext; Loading Loading @@ -300,6 +301,14 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, verifyHighRes(); } /** * Apply label and tag using a {@link RemoteActionItemInfo} */ public void applyFromRemoteActionInfo(RemoteActionItemInfo remoteActionItemInfo) { applyIconAndLabel(remoteActionItemInfo); setTag(remoteActionItemInfo); } private void applyIconAndLabel(ItemInfoWithIcon info) { FastBitmapDrawable iconDrawable = newIcon(getContext(), info); mDotParams.color = IconPalette.getMutedColor(info.bitmap.color, 0.54f); Loading Loading @@ -681,6 +690,8 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, mActivity.invalidateParent(info); } else if (info instanceof PackageItemInfo) { applyFromItemInfoWithIcon((PackageItemInfo) info); } else if (info instanceof RemoteActionItemInfo) { applyFromRemoteActionInfo((RemoteActionItemInfo) info); } mDisableRelayout = false; Loading src/com/android/launcher3/allapps/AllAppsGridAdapter.java +7 −7 Original line number Diff line number Diff line Loading @@ -92,7 +92,7 @@ public class AllAppsGridAdapter extends public static final int VIEW_TYPE_SEARCH_SLICE = 1 << 9; public static final int VIEW_TYPE_SEARCH_SHORTCUT = 1 << 10; public static final int VIEW_TYPE_SEARCH_ICON_ROW = 1 << 10; public static final int VIEW_TYPE_SEARCH_PEOPLE = 1 << 11; Loading Loading @@ -189,7 +189,7 @@ public class AllAppsGridAdapter extends || viewType == VIEW_TYPE_SEARCH_ROW || viewType == VIEW_TYPE_SEARCH_PEOPLE || viewType == VIEW_TYPE_SEARCH_THUMBNAIL || viewType == VIEW_TYPE_SEARCH_SHORTCUT; || viewType == VIEW_TYPE_SEARCH_ICON_ROW; } } Loading Loading @@ -458,9 +458,9 @@ public class AllAppsGridAdapter extends case VIEW_TYPE_SEARCH_SLICE: return new ViewHolder(mLayoutInflater.inflate( R.layout.search_result_slice, parent, false)); case VIEW_TYPE_SEARCH_SHORTCUT: case VIEW_TYPE_SEARCH_ICON_ROW: return new ViewHolder(mLayoutInflater.inflate( R.layout.search_result_shortcut, parent, false)); R.layout.search_result_icon_row, parent, false)); case VIEW_TYPE_SEARCH_PEOPLE: return new ViewHolder(mLayoutInflater.inflate( R.layout.search_result_people_item, parent, false)); Loading Loading @@ -551,7 +551,7 @@ public class AllAppsGridAdapter extends case VIEW_TYPE_SEARCH_ROW_WITH_BUTTON: case VIEW_TYPE_SEARCH_HERO_APP: case VIEW_TYPE_SEARCH_ROW: case VIEW_TYPE_SEARCH_SHORTCUT: case VIEW_TYPE_SEARCH_ICON_ROW: case VIEW_TYPE_SEARCH_PEOPLE: case VIEW_TYPE_SEARCH_THUMBNAIL: AdapterItemWithPayload item = Loading @@ -571,8 +571,8 @@ public class AllAppsGridAdapter extends if (!FeatureFlags.ENABLE_DEVICE_SEARCH.get()) return; if (holder.itemView instanceof BubbleTextView) { BubbleTextView icon = (BubbleTextView) holder.itemView; icon.setOnClickListener(mOnIconClickListener); icon.setOnLongClickListener(mOnIconLongClickListener); icon.setOnClickListener(null); icon.setOnLongClickListener(null); } else if (holder.itemView instanceof SliceView) { SliceView sliceView = (SliceView) holder.itemView; sliceView.setOnSliceActionListener(null); Loading src/com/android/launcher3/model/data/RemoteActionItemInfo.java 0 → 100644 +64 −0 Original line number Diff line number Diff line /* * Copyright (C) 2020 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.model.data; import android.app.RemoteAction; import android.os.Process; /** * Represents a launchable {@link RemoteAction} */ public class RemoteActionItemInfo extends ItemInfoWithIcon { private final RemoteAction mRemoteAction; private final String mToken; private final boolean mShouldStart; public RemoteActionItemInfo(RemoteAction remoteAction, String token, boolean shouldStart) { mShouldStart = shouldStart; mToken = token; mRemoteAction = remoteAction; title = remoteAction.getTitle(); user = Process.myUserHandle(); } public RemoteActionItemInfo(RemoteActionItemInfo info) { super(info); this.mShouldStart = info.mShouldStart; this.mRemoteAction = info.mRemoteAction; this.mToken = info.mToken; } @Override public ItemInfoWithIcon clone() { return new RemoteActionItemInfo(this); } public RemoteAction getRemoteAction() { return mRemoteAction; } public String getToken() { return mToken; } /** * Getter method for mShouldStart */ public boolean shouldStartInLauncher() { return mShouldStart; } } src/com/android/launcher3/touch/ItemClickHandler.java +24 −0 Original line number Diff line number Diff line Loading @@ -25,7 +25,9 @@ import static com.android.launcher3.model.data.ItemInfoWithIcon.FLAG_DISABLED_SA import static com.android.launcher3.model.data.ItemInfoWithIcon.FLAG_DISABLED_SUSPENDED; import android.app.AlertDialog; import android.app.PendingIntent; import android.content.Intent; import android.content.IntentSender; import android.content.pm.LauncherApps; import android.content.pm.PackageInstaller.SessionInfo; import android.os.Process; Loading @@ -49,6 +51,7 @@ import com.android.launcher3.model.data.FolderInfo; import com.android.launcher3.model.data.ItemInfo; import com.android.launcher3.model.data.LauncherAppWidgetInfo; import com.android.launcher3.model.data.PromiseAppInfo; import com.android.launcher3.model.data.RemoteActionItemInfo; import com.android.launcher3.model.data.WorkspaceItemInfo; import com.android.launcher3.pm.InstallSessionHelper; import com.android.launcher3.testing.TestLogging; Loading Loading @@ -236,6 +239,27 @@ public class ItemClickHandler { startAppShortcutOrInfoActivity(v, shortcut, launcher); } /** * Event handler for a {@link android.app.RemoteAction} click * */ public static void onClickRemoteAction(Launcher launcher, RemoteActionItemInfo remoteActionInfo) { try { PendingIntent pendingIntent = remoteActionInfo.getRemoteAction().getActionIntent(); if (remoteActionInfo.shouldStartInLauncher()) { launcher.startIntentSenderForResult(pendingIntent.getIntentSender(), 0, null, 0, 0, 0); } else { pendingIntent.send(); } } catch (PendingIntent.CanceledException | IntentSender.SendIntentException e) { Toast.makeText(launcher, launcher.getResources().getText(R.string.shortcut_not_available), Toast.LENGTH_SHORT).show(); } } private static void startAppShortcutOrInfoActivity(View v, ItemInfo item, Launcher launcher) { TestLogging.recordEvent( TestProtocol.SEQUENCE_MAIN, "start: startAppShortcutOrInfoActivity"); Loading Loading
res/layout/search_result_shortcut.xml→res/layout/search_result_icon_row.xml +31 −0 Original line number Diff line number Diff line Loading @@ -12,31 +12,20 @@ See the License for the specific language governing permissions and limitations under the License. --> <com.android.launcher3.views.SearchResultShortcut xmlns:android="http://schemas.android.com/apk/res/android" <com.android.launcher3.views.SearchResultIconRow xmlns:android="http://schemas.android.com/apk/res/android" xmlns:launcher="http://schemas.android.com/apk/res-auto" style="@style/BaseIcon" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:gravity="center_vertical" android:padding="@dimen/dynamic_grid_edge_margin"> <com.android.launcher3.BubbleTextView android:id="@+id/bubble_text" style="@style/BaseIcon" android:drawablePadding="@dimen/dynamic_grid_icon_drawable_padding" android:gravity="start|center_vertical" android:textAlignment="viewStart" android:textColor="?android:attr/textColorPrimary" android:textSize="16sp" android:layout_height="wrap_content" android:padding="@dimen/dynamic_grid_edge_margin" launcher:iconDisplay="hero_app" launcher:layoutHorizontal="true" /> <View android:id="@+id/icon" android:layout_width="@dimen/deep_shortcut_icon_size" android:layout_height="@dimen/deep_shortcut_icon_size" android:layout_gravity="start|center_vertical" android:background="@drawable/ic_deepshortcut_placeholder" /> launcher:layoutHorizontal="true" > </com.android.launcher3.views.SearchResultShortcut> No newline at end of file </com.android.launcher3.views.SearchResultIconRow> No newline at end of file
src/com/android/launcher3/BubbleTextView.java +11 −0 Original line number Diff line number Diff line Loading @@ -65,6 +65,7 @@ import com.android.launcher3.model.data.ItemInfo; import com.android.launcher3.model.data.ItemInfoWithIcon; import com.android.launcher3.model.data.PackageItemInfo; import com.android.launcher3.model.data.PromiseAppInfo; import com.android.launcher3.model.data.RemoteActionItemInfo; import com.android.launcher3.model.data.WorkspaceItemInfo; import com.android.launcher3.util.SafeCloseable; import com.android.launcher3.views.ActivityContext; Loading Loading @@ -300,6 +301,14 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, verifyHighRes(); } /** * Apply label and tag using a {@link RemoteActionItemInfo} */ public void applyFromRemoteActionInfo(RemoteActionItemInfo remoteActionItemInfo) { applyIconAndLabel(remoteActionItemInfo); setTag(remoteActionItemInfo); } private void applyIconAndLabel(ItemInfoWithIcon info) { FastBitmapDrawable iconDrawable = newIcon(getContext(), info); mDotParams.color = IconPalette.getMutedColor(info.bitmap.color, 0.54f); Loading Loading @@ -681,6 +690,8 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, mActivity.invalidateParent(info); } else if (info instanceof PackageItemInfo) { applyFromItemInfoWithIcon((PackageItemInfo) info); } else if (info instanceof RemoteActionItemInfo) { applyFromRemoteActionInfo((RemoteActionItemInfo) info); } mDisableRelayout = false; Loading
src/com/android/launcher3/allapps/AllAppsGridAdapter.java +7 −7 Original line number Diff line number Diff line Loading @@ -92,7 +92,7 @@ public class AllAppsGridAdapter extends public static final int VIEW_TYPE_SEARCH_SLICE = 1 << 9; public static final int VIEW_TYPE_SEARCH_SHORTCUT = 1 << 10; public static final int VIEW_TYPE_SEARCH_ICON_ROW = 1 << 10; public static final int VIEW_TYPE_SEARCH_PEOPLE = 1 << 11; Loading Loading @@ -189,7 +189,7 @@ public class AllAppsGridAdapter extends || viewType == VIEW_TYPE_SEARCH_ROW || viewType == VIEW_TYPE_SEARCH_PEOPLE || viewType == VIEW_TYPE_SEARCH_THUMBNAIL || viewType == VIEW_TYPE_SEARCH_SHORTCUT; || viewType == VIEW_TYPE_SEARCH_ICON_ROW; } } Loading Loading @@ -458,9 +458,9 @@ public class AllAppsGridAdapter extends case VIEW_TYPE_SEARCH_SLICE: return new ViewHolder(mLayoutInflater.inflate( R.layout.search_result_slice, parent, false)); case VIEW_TYPE_SEARCH_SHORTCUT: case VIEW_TYPE_SEARCH_ICON_ROW: return new ViewHolder(mLayoutInflater.inflate( R.layout.search_result_shortcut, parent, false)); R.layout.search_result_icon_row, parent, false)); case VIEW_TYPE_SEARCH_PEOPLE: return new ViewHolder(mLayoutInflater.inflate( R.layout.search_result_people_item, parent, false)); Loading Loading @@ -551,7 +551,7 @@ public class AllAppsGridAdapter extends case VIEW_TYPE_SEARCH_ROW_WITH_BUTTON: case VIEW_TYPE_SEARCH_HERO_APP: case VIEW_TYPE_SEARCH_ROW: case VIEW_TYPE_SEARCH_SHORTCUT: case VIEW_TYPE_SEARCH_ICON_ROW: case VIEW_TYPE_SEARCH_PEOPLE: case VIEW_TYPE_SEARCH_THUMBNAIL: AdapterItemWithPayload item = Loading @@ -571,8 +571,8 @@ public class AllAppsGridAdapter extends if (!FeatureFlags.ENABLE_DEVICE_SEARCH.get()) return; if (holder.itemView instanceof BubbleTextView) { BubbleTextView icon = (BubbleTextView) holder.itemView; icon.setOnClickListener(mOnIconClickListener); icon.setOnLongClickListener(mOnIconLongClickListener); icon.setOnClickListener(null); icon.setOnLongClickListener(null); } else if (holder.itemView instanceof SliceView) { SliceView sliceView = (SliceView) holder.itemView; sliceView.setOnSliceActionListener(null); Loading
src/com/android/launcher3/model/data/RemoteActionItemInfo.java 0 → 100644 +64 −0 Original line number Diff line number Diff line /* * Copyright (C) 2020 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.model.data; import android.app.RemoteAction; import android.os.Process; /** * Represents a launchable {@link RemoteAction} */ public class RemoteActionItemInfo extends ItemInfoWithIcon { private final RemoteAction mRemoteAction; private final String mToken; private final boolean mShouldStart; public RemoteActionItemInfo(RemoteAction remoteAction, String token, boolean shouldStart) { mShouldStart = shouldStart; mToken = token; mRemoteAction = remoteAction; title = remoteAction.getTitle(); user = Process.myUserHandle(); } public RemoteActionItemInfo(RemoteActionItemInfo info) { super(info); this.mShouldStart = info.mShouldStart; this.mRemoteAction = info.mRemoteAction; this.mToken = info.mToken; } @Override public ItemInfoWithIcon clone() { return new RemoteActionItemInfo(this); } public RemoteAction getRemoteAction() { return mRemoteAction; } public String getToken() { return mToken; } /** * Getter method for mShouldStart */ public boolean shouldStartInLauncher() { return mShouldStart; } }
src/com/android/launcher3/touch/ItemClickHandler.java +24 −0 Original line number Diff line number Diff line Loading @@ -25,7 +25,9 @@ import static com.android.launcher3.model.data.ItemInfoWithIcon.FLAG_DISABLED_SA import static com.android.launcher3.model.data.ItemInfoWithIcon.FLAG_DISABLED_SUSPENDED; import android.app.AlertDialog; import android.app.PendingIntent; import android.content.Intent; import android.content.IntentSender; import android.content.pm.LauncherApps; import android.content.pm.PackageInstaller.SessionInfo; import android.os.Process; Loading @@ -49,6 +51,7 @@ import com.android.launcher3.model.data.FolderInfo; import com.android.launcher3.model.data.ItemInfo; import com.android.launcher3.model.data.LauncherAppWidgetInfo; import com.android.launcher3.model.data.PromiseAppInfo; import com.android.launcher3.model.data.RemoteActionItemInfo; import com.android.launcher3.model.data.WorkspaceItemInfo; import com.android.launcher3.pm.InstallSessionHelper; import com.android.launcher3.testing.TestLogging; Loading Loading @@ -236,6 +239,27 @@ public class ItemClickHandler { startAppShortcutOrInfoActivity(v, shortcut, launcher); } /** * Event handler for a {@link android.app.RemoteAction} click * */ public static void onClickRemoteAction(Launcher launcher, RemoteActionItemInfo remoteActionInfo) { try { PendingIntent pendingIntent = remoteActionInfo.getRemoteAction().getActionIntent(); if (remoteActionInfo.shouldStartInLauncher()) { launcher.startIntentSenderForResult(pendingIntent.getIntentSender(), 0, null, 0, 0, 0); } else { pendingIntent.send(); } } catch (PendingIntent.CanceledException | IntentSender.SendIntentException e) { Toast.makeText(launcher, launcher.getResources().getText(R.string.shortcut_not_available), Toast.LENGTH_SHORT).show(); } } private static void startAppShortcutOrInfoActivity(View v, ItemInfo item, Launcher launcher) { TestLogging.recordEvent( TestProtocol.SEQUENCE_MAIN, "start: startAppShortcutOrInfoActivity"); Loading