Loading res/values/config.xml +2 −14 Original line number Diff line number Diff line Loading @@ -79,27 +79,15 @@ <!-- Hotseat --> <bool name="hotseat_transpose_layout_with_orientation">true</bool> <!-- Name of a subclass of com.android.launcher3.AppFilter used to filter the activities shown in the launcher. Can be empty. --> <!-- Various classes overriden by projects/build flavors. --> <string name="app_filter_class" translatable="false"></string> <!-- Name of an icon provider class. --> <string name="icon_provider_class" translatable="false"></string> <!-- Name of a drawable factory class. --> <string name="drawable_factory_class" translatable="false"></string> <!-- Name of a user event dispatcher class. --> <string name="user_event_dispatcher_class" translatable="false"></string> <!-- Name of an app transition manager class. --> <string name="app_transition_manager_class" translatable="false"></string> <!-- Name of a subclass of com.android.launcher3.util.InstantAppResolver. Can be empty. --> <string name="instant_app_resolver_class" translatable="false"></string> <!-- Name of a main process initializer class. --> <string name="main_process_initializer_class" translatable="false"></string> <string name="system_shortcut_factory_class" translatable="false"></string> <!-- Package name of the default wallpaper picker. --> <string name="wallpaper_picker_package" translatable="false"></string> Loading src/com/android/launcher3/popup/PopupContainerWithArrow.java +10 −8 Original line number Diff line number Diff line Loading @@ -184,17 +184,10 @@ public class PopupContainerWithArrow extends ArrowPopup implements DragSource, return null; } PopupDataProvider popupDataProvider = launcher.getPopupDataProvider(); List<String> shortcutIds = popupDataProvider.getShortcutIdsForItem(itemInfo); List<NotificationKeyData> notificationKeys = popupDataProvider .getNotificationKeysForItem(itemInfo); List<SystemShortcut> systemShortcuts = popupDataProvider .getEnabledSystemShortcutsForItem(itemInfo); final PopupContainerWithArrow container = (PopupContainerWithArrow) launcher.getLayoutInflater().inflate( R.layout.popup_container, launcher.getDragLayer(), false); container.populateAndShow(icon, shortcutIds, notificationKeys, systemShortcuts); container.populateAndShow(icon, itemInfo, SystemShortcutFactory.INSTANCE.get(launcher)); return container; } Loading @@ -219,6 +212,15 @@ public class PopupContainerWithArrow extends ArrowPopup implements DragSource, } } protected void populateAndShow( BubbleTextView icon, ItemInfo item, SystemShortcutFactory factory) { PopupDataProvider popupDataProvider = mLauncher.getPopupDataProvider(); populateAndShow(icon, popupDataProvider.getShortcutIdsForItem(item), popupDataProvider.getNotificationKeysForItem(item), factory.getEnabledShortcuts(mLauncher, item)); } @TargetApi(Build.VERSION_CODES.P) protected void populateAndShow(final BubbleTextView originalIcon, final List<String> shortcutIds, final List<NotificationKeyData> notificationKeys, List<SystemShortcut> systemShortcuts) { Loading src/com/android/launcher3/popup/PopupDataProvider.java +0 −17 Original line number Diff line number Diff line Loading @@ -50,13 +50,6 @@ public class PopupDataProvider implements NotificationListener.NotificationsChan private static final boolean LOGD = false; private static final String TAG = "PopupDataProvider"; /** Note that these are in order of priority. */ private static final SystemShortcut[] SYSTEM_SHORTCUTS = new SystemShortcut[] { new SystemShortcut.AppInfo(), new SystemShortcut.Widgets(), new SystemShortcut.Install() }; private final Launcher mLauncher; /** Maps launcher activity components to their list of shortcut ids. */ Loading Loading @@ -192,16 +185,6 @@ public class PopupDataProvider implements NotificationListener.NotificationsChan : notificationListener.getNotificationsForKeys(notificationKeys); } public @NonNull List<SystemShortcut> getEnabledSystemShortcutsForItem(ItemInfo info) { List<SystemShortcut> systemShortcuts = new ArrayList<>(); for (SystemShortcut systemShortcut : SYSTEM_SHORTCUTS) { if (systemShortcut.getOnClickListener(mLauncher, info) != null) { systemShortcuts.add(systemShortcut); } } return systemShortcuts; } public void cancelNotification(String notificationKey) { NotificationListener notificationListener = NotificationListener.getInstanceIfConnected(); if (notificationListener == null) { Loading src/com/android/launcher3/popup/SystemShortcutFactory.java 0 → 100644 +57 −0 Original line number Diff line number Diff line /* * Copyright (C) 2018 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.popup; import com.android.launcher3.ItemInfo; import com.android.launcher3.Launcher; import com.android.launcher3.R; import com.android.launcher3.util.MainThreadInitializedObject; import com.android.launcher3.util.ResourceBasedOverride; import java.util.ArrayList; import java.util.List; import androidx.annotation.NonNull; public class SystemShortcutFactory implements ResourceBasedOverride { public static final MainThreadInitializedObject<SystemShortcutFactory> INSTANCE = new MainThreadInitializedObject<>(c -> Overrides.getObject( SystemShortcutFactory.class, c, R.string.system_shortcut_factory_class)); /** Note that these are in order of priority. */ private final SystemShortcut[] mAllShortcuts; @SuppressWarnings("unused") public SystemShortcutFactory() { this(new SystemShortcut.AppInfo(), new SystemShortcut.Widgets(), new SystemShortcut.Install()); } protected SystemShortcutFactory(SystemShortcut... shortcuts) { mAllShortcuts = shortcuts; } public @NonNull List<SystemShortcut> getEnabledShortcuts(Launcher launcher, ItemInfo info) { List<SystemShortcut> systemShortcuts = new ArrayList<>(); for (SystemShortcut systemShortcut : mAllShortcuts) { if (systemShortcut.getOnClickListener(launcher, info) != null) { systemShortcuts.add(systemShortcut); } } return systemShortcuts; } } src/com/android/launcher3/util/FlagOp.java +7 −21 Original line number Diff line number Diff line package com.android.launcher3.util; public abstract class FlagOp { public interface FlagOp { public static FlagOp NO_OP = new FlagOp() {}; FlagOp NO_OP = i -> i; private FlagOp() {} int apply(int flags); public int apply(int flags) { return flags; static FlagOp addFlag(int flag) { return i -> i + flag; } public static FlagOp addFlag(final int flag) { return new FlagOp() { @Override public int apply(int flags) { return flags | flag; } }; } public static FlagOp removeFlag(final int flag) { return new FlagOp() { @Override public int apply(int flags) { return flags & ~flag; } }; static FlagOp removeFlag(int flag) { return i -> i & ~flag; } } Loading
res/values/config.xml +2 −14 Original line number Diff line number Diff line Loading @@ -79,27 +79,15 @@ <!-- Hotseat --> <bool name="hotseat_transpose_layout_with_orientation">true</bool> <!-- Name of a subclass of com.android.launcher3.AppFilter used to filter the activities shown in the launcher. Can be empty. --> <!-- Various classes overriden by projects/build flavors. --> <string name="app_filter_class" translatable="false"></string> <!-- Name of an icon provider class. --> <string name="icon_provider_class" translatable="false"></string> <!-- Name of a drawable factory class. --> <string name="drawable_factory_class" translatable="false"></string> <!-- Name of a user event dispatcher class. --> <string name="user_event_dispatcher_class" translatable="false"></string> <!-- Name of an app transition manager class. --> <string name="app_transition_manager_class" translatable="false"></string> <!-- Name of a subclass of com.android.launcher3.util.InstantAppResolver. Can be empty. --> <string name="instant_app_resolver_class" translatable="false"></string> <!-- Name of a main process initializer class. --> <string name="main_process_initializer_class" translatable="false"></string> <string name="system_shortcut_factory_class" translatable="false"></string> <!-- Package name of the default wallpaper picker. --> <string name="wallpaper_picker_package" translatable="false"></string> Loading
src/com/android/launcher3/popup/PopupContainerWithArrow.java +10 −8 Original line number Diff line number Diff line Loading @@ -184,17 +184,10 @@ public class PopupContainerWithArrow extends ArrowPopup implements DragSource, return null; } PopupDataProvider popupDataProvider = launcher.getPopupDataProvider(); List<String> shortcutIds = popupDataProvider.getShortcutIdsForItem(itemInfo); List<NotificationKeyData> notificationKeys = popupDataProvider .getNotificationKeysForItem(itemInfo); List<SystemShortcut> systemShortcuts = popupDataProvider .getEnabledSystemShortcutsForItem(itemInfo); final PopupContainerWithArrow container = (PopupContainerWithArrow) launcher.getLayoutInflater().inflate( R.layout.popup_container, launcher.getDragLayer(), false); container.populateAndShow(icon, shortcutIds, notificationKeys, systemShortcuts); container.populateAndShow(icon, itemInfo, SystemShortcutFactory.INSTANCE.get(launcher)); return container; } Loading @@ -219,6 +212,15 @@ public class PopupContainerWithArrow extends ArrowPopup implements DragSource, } } protected void populateAndShow( BubbleTextView icon, ItemInfo item, SystemShortcutFactory factory) { PopupDataProvider popupDataProvider = mLauncher.getPopupDataProvider(); populateAndShow(icon, popupDataProvider.getShortcutIdsForItem(item), popupDataProvider.getNotificationKeysForItem(item), factory.getEnabledShortcuts(mLauncher, item)); } @TargetApi(Build.VERSION_CODES.P) protected void populateAndShow(final BubbleTextView originalIcon, final List<String> shortcutIds, final List<NotificationKeyData> notificationKeys, List<SystemShortcut> systemShortcuts) { Loading
src/com/android/launcher3/popup/PopupDataProvider.java +0 −17 Original line number Diff line number Diff line Loading @@ -50,13 +50,6 @@ public class PopupDataProvider implements NotificationListener.NotificationsChan private static final boolean LOGD = false; private static final String TAG = "PopupDataProvider"; /** Note that these are in order of priority. */ private static final SystemShortcut[] SYSTEM_SHORTCUTS = new SystemShortcut[] { new SystemShortcut.AppInfo(), new SystemShortcut.Widgets(), new SystemShortcut.Install() }; private final Launcher mLauncher; /** Maps launcher activity components to their list of shortcut ids. */ Loading Loading @@ -192,16 +185,6 @@ public class PopupDataProvider implements NotificationListener.NotificationsChan : notificationListener.getNotificationsForKeys(notificationKeys); } public @NonNull List<SystemShortcut> getEnabledSystemShortcutsForItem(ItemInfo info) { List<SystemShortcut> systemShortcuts = new ArrayList<>(); for (SystemShortcut systemShortcut : SYSTEM_SHORTCUTS) { if (systemShortcut.getOnClickListener(mLauncher, info) != null) { systemShortcuts.add(systemShortcut); } } return systemShortcuts; } public void cancelNotification(String notificationKey) { NotificationListener notificationListener = NotificationListener.getInstanceIfConnected(); if (notificationListener == null) { Loading
src/com/android/launcher3/popup/SystemShortcutFactory.java 0 → 100644 +57 −0 Original line number Diff line number Diff line /* * Copyright (C) 2018 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.popup; import com.android.launcher3.ItemInfo; import com.android.launcher3.Launcher; import com.android.launcher3.R; import com.android.launcher3.util.MainThreadInitializedObject; import com.android.launcher3.util.ResourceBasedOverride; import java.util.ArrayList; import java.util.List; import androidx.annotation.NonNull; public class SystemShortcutFactory implements ResourceBasedOverride { public static final MainThreadInitializedObject<SystemShortcutFactory> INSTANCE = new MainThreadInitializedObject<>(c -> Overrides.getObject( SystemShortcutFactory.class, c, R.string.system_shortcut_factory_class)); /** Note that these are in order of priority. */ private final SystemShortcut[] mAllShortcuts; @SuppressWarnings("unused") public SystemShortcutFactory() { this(new SystemShortcut.AppInfo(), new SystemShortcut.Widgets(), new SystemShortcut.Install()); } protected SystemShortcutFactory(SystemShortcut... shortcuts) { mAllShortcuts = shortcuts; } public @NonNull List<SystemShortcut> getEnabledShortcuts(Launcher launcher, ItemInfo info) { List<SystemShortcut> systemShortcuts = new ArrayList<>(); for (SystemShortcut systemShortcut : mAllShortcuts) { if (systemShortcut.getOnClickListener(launcher, info) != null) { systemShortcuts.add(systemShortcut); } } return systemShortcuts; } }
src/com/android/launcher3/util/FlagOp.java +7 −21 Original line number Diff line number Diff line package com.android.launcher3.util; public abstract class FlagOp { public interface FlagOp { public static FlagOp NO_OP = new FlagOp() {}; FlagOp NO_OP = i -> i; private FlagOp() {} int apply(int flags); public int apply(int flags) { return flags; static FlagOp addFlag(int flag) { return i -> i + flag; } public static FlagOp addFlag(final int flag) { return new FlagOp() { @Override public int apply(int flags) { return flags | flag; } }; } public static FlagOp removeFlag(final int flag) { return new FlagOp() { @Override public int apply(int flags) { return flags & ~flag; } }; static FlagOp removeFlag(int flag) { return i -> i & ~flag; } }