Add a switch to control suggested apps showing (#3803)

This commit is contained in:
Goooler
2023-12-01 14:49:17 +08:00
committed by GitHub
parent ffacafc22c
commit b7a32a0711
6 changed files with 29 additions and 2 deletions

View File

@@ -43,11 +43,14 @@ import com.android.launcher3.model.data.ItemInfoWithIcon;
import com.android.launcher3.model.data.WorkspaceItemInfo;
import com.android.launcher3.touch.ItemLongClickListener;
import com.android.launcher3.views.ActivityContext;
import com.patrykmichalik.opto.core.PreferenceExtensionsKt;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import app.lawnchair.preferences2.PreferenceManager2;
@TargetApi(Build.VERSION_CODES.P)
public class PredictionRowView<T extends Context & ActivityContext>
extends LinearLayout implements OnDeviceProfileChangeListener, FloatingHeaderRow {
@@ -66,6 +69,8 @@ public class PredictionRowView<T extends Context & ActivityContext>
private boolean mPredictionsEnabled = false;
private OnLongClickListener mOnIconLongClickListener = ItemLongClickListener.INSTANCE_ALL_APPS;
private final PreferenceManager2 prefs2 = PreferenceManager2.getInstance(getContext());
public PredictionRowView(@NonNull Context context) {
this(context, null);
}
@@ -97,9 +102,10 @@ public class PredictionRowView<T extends Context & ActivityContext>
}
private void updateVisibility() {
setVisibility(mPredictionsEnabled ? VISIBLE : GONE);
boolean enabled = mPredictionsEnabled && PreferenceExtensionsKt.firstBlocking(prefs2.getShowSuggestedAppsInDrawer());
setVisibility(enabled ? VISIBLE : GONE);
if (mActivityContext.getAppsView() != null) {
if (mPredictionsEnabled) {
if (enabled) {
mActivityContext.getAppsView().getAppsStore().registerIconContainer(this);
} else {
mActivityContext.getAppsView().getAppsStore().unregisterIconContainer(this);