Merge "Simplifying AppFilter" into ub-launcher3-master
This commit is contained in:
committed by
Android (Google) Code Review
commit
681e6517ca
@@ -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>
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -234,7 +234,7 @@ public class WidgetsModel {
|
||||
|
||||
WidgetValidityCheck(LauncherAppState app) {
|
||||
mIdp = app.getInvariantDeviceProfile();
|
||||
mAppFilter = AppFilter.newInstance(app.getContext());
|
||||
mAppFilter = new AppFilter(app.getContext());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user