summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2020-08-25 23:22:18 -0700
committerSunny Goyal <sunnygoyal@google.com>2020-09-08 16:31:17 -0700
commit4484015f482772e2a493cc1dda525c929398b4f2 (patch)
tree828eaddf135cda8acb0e5c3a6fa14f253aaacb2a
parent7aa577d8836c624abd876ff3914b14c232cca860 (diff)
downloadLauncher3-4484015f482772e2a493cc1dda525c929398b4f2.tar.gz
Simplifying AppFilter
Change-Id: I36217a42aa67f2b3bc3a3226ace2ef7e194956a6
-rw-r--r--res/values/config.xml3
-rw-r--r--src/com/android/launcher3/AppFilter.java20
-rw-r--r--src/com/android/launcher3/LauncherAppState.java2
-rw-r--r--src_shortcuts_overrides/com/android/launcher3/model/WidgetsModel.java2
4 files changed, 19 insertions, 8 deletions
diff --git a/res/values/config.xml b/res/values/config.xml
index fc0a5e10dc..325b62f9dc 100644
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -59,7 +59,6 @@
<bool name="hotseat_transpose_layout_with_orientation">true</bool>
<!-- Various classes overriden by projects/build flavors. -->
- <string name="app_filter_class" translatable="false"></string>
<string name="user_event_dispatcher_class" translatable="false"></string>
<string name="folder_name_provider_class" translatable="false"></string>
<string name="stats_log_manager_class" translatable="false"></string>
@@ -187,4 +186,6 @@
<string-array name="live_wallpapers_remove_sysui_scrims">
</string-array>
+
+ <string-array name="filtered_components" ></string-array>
</resources>
diff --git a/src/com/android/launcher3/AppFilter.java b/src/com/android/launcher3/AppFilter.java
index 9b6166ffcf..3db456cbdb 100644
--- a/src/com/android/launcher3/AppFilter.java
+++ b/src/com/android/launcher3/AppFilter.java
@@ -3,15 +3,25 @@ package com.android.launcher3;
import android.content.ComponentName;
import android.content.Context;
-import com.android.launcher3.util.ResourceBasedOverride;
+import java.util.Arrays;
+import java.util.Set;
+import java.util.stream.Collectors;
-public class AppFilter implements ResourceBasedOverride {
+/**
+ * Utility class to filter out components from various lists
+ */
+public class AppFilter {
- public static AppFilter newInstance(Context context) {
- return Overrides.getObject(AppFilter.class, context, R.string.app_filter_class);
+ private final Set<ComponentName> mFilteredComponents;
+
+ public AppFilter(Context context) {
+ mFilteredComponents = Arrays.stream(
+ context.getResources().getStringArray(R.array.filtered_components))
+ .map(ComponentName::unflattenFromString)
+ .collect(Collectors.toSet());
}
public boolean shouldShowApp(ComponentName app) {
- return true;
+ return !mFilteredComponents.contains(app);
}
}
diff --git a/src/com/android/launcher3/LauncherAppState.java b/src/com/android/launcher3/LauncherAppState.java
index b278e81655..bfe327e40d 100644
--- a/src/com/android/launcher3/LauncherAppState.java
+++ b/src/com/android/launcher3/LauncherAppState.java
@@ -122,7 +122,7 @@ public class LauncherAppState {
mInvariantDeviceProfile = InvariantDeviceProfile.INSTANCE.get(context);
mIconCache = new IconCache(mContext, mInvariantDeviceProfile, iconCacheFileName);
mWidgetCache = new WidgetPreviewLoader(mContext, mIconCache);
- mModel = new LauncherModel(context, this, mIconCache, AppFilter.newInstance(mContext));
+ mModel = new LauncherModel(context, this, mIconCache, new AppFilter(mContext));
}
protected void onNotificationSettingsChanged(boolean areNotificationDotsEnabled) {
diff --git a/src_shortcuts_overrides/com/android/launcher3/model/WidgetsModel.java b/src_shortcuts_overrides/com/android/launcher3/model/WidgetsModel.java
index 34ebbac59a..b4e45f835a 100644
--- a/src_shortcuts_overrides/com/android/launcher3/model/WidgetsModel.java
+++ b/src_shortcuts_overrides/com/android/launcher3/model/WidgetsModel.java
@@ -234,7 +234,7 @@ public class WidgetsModel {
WidgetValidityCheck(LauncherAppState app) {
mIdp = app.getInvariantDeviceProfile();
- mAppFilter = AppFilter.newInstance(app.getContext());
+ mAppFilter = new AppFilter(app.getContext());
}
@Override