mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-28 07:46:55 +00:00
Merge remote-tracking branch 'aosp/android12L-release' into 12.1-dev
This commit is contained in:
@@ -50,13 +50,12 @@ import com.android.launcher3.util.SafeCloseable;
|
||||
import com.android.launcher3.util.SettingsCache;
|
||||
import com.android.launcher3.util.SimpleBroadcastReceiver;
|
||||
import com.android.launcher3.util.Themes;
|
||||
import com.android.launcher3.widget.DatabaseWidgetPreviewLoader;
|
||||
import com.android.launcher3.widget.custom.CustomWidgetManager;
|
||||
|
||||
import app.lawnchair.LawnchairAppKt;
|
||||
import app.lawnchair.icons.LawnchairIconProvider;
|
||||
|
||||
public class LauncherAppState {
|
||||
public class LauncherAppState implements SafeCloseable {
|
||||
|
||||
public static final String ACTION_FORCE_ROLOAD = "force-reload-launcher";
|
||||
private static final String KEY_ICON_STATE = "pref_icon_shape_path";
|
||||
@@ -76,7 +75,6 @@ public class LauncherAppState {
|
||||
private final LauncherModel mModel;
|
||||
private final IconProvider mIconProvider;
|
||||
private final IconCache mIconCache;
|
||||
private final DatabaseWidgetPreviewLoader mWidgetCache;
|
||||
private final InvariantDeviceProfile mInvariantDeviceProfile;
|
||||
private final RunnableList mOnTerminateCallback = new RunnableList();
|
||||
|
||||
@@ -97,7 +95,11 @@ public class LauncherAppState {
|
||||
Log.v(Launcher.TAG, "LauncherAppState initiated");
|
||||
Preconditions.assertUIThread();
|
||||
|
||||
mInvariantDeviceProfile.addOnChangeListener(idp -> refreshAndReloadLauncher());
|
||||
mInvariantDeviceProfile.addOnChangeListener(modelPropertiesChanged -> {
|
||||
if (modelPropertiesChanged) {
|
||||
refreshAndReloadLauncher();
|
||||
}
|
||||
});
|
||||
|
||||
mContext.getSystemService(LauncherApps.class).registerCallback(mModel);
|
||||
|
||||
@@ -151,8 +153,8 @@ public class LauncherAppState {
|
||||
mIconProvider = new LawnchairIconProvider(context, Themes.isThemedIconEnabled(context));
|
||||
mIconCache = new IconCache(mContext, mInvariantDeviceProfile,
|
||||
iconCacheFileName, mIconProvider);
|
||||
mWidgetCache = new DatabaseWidgetPreviewLoader(mContext, mIconCache);
|
||||
mModel = new LauncherModel(context, this, mIconCache, new AppFilter(mContext));
|
||||
mModel = new LauncherModel(context, this, mIconCache, new AppFilter(mContext),
|
||||
iconCacheFileName != null);
|
||||
mOnTerminateCallback.add(mIconCache::close);
|
||||
}
|
||||
|
||||
@@ -167,14 +169,14 @@ public class LauncherAppState {
|
||||
LauncherIcons.clearPool();
|
||||
mIconCache.updateIconParams(
|
||||
mInvariantDeviceProfile.fillResIconDpi, mInvariantDeviceProfile.iconBitmapSize);
|
||||
mWidgetCache.refresh();
|
||||
mModel.forceReload();
|
||||
}
|
||||
|
||||
/**
|
||||
* Call from Application.onTerminate(), which is not guaranteed to ever be called.
|
||||
*/
|
||||
public void onTerminate() {
|
||||
@Override
|
||||
public void close() {
|
||||
mModel.destroy();
|
||||
mContext.getSystemService(LauncherApps.class).unregisterCallback(mModel);
|
||||
CustomWidgetManager.INSTANCE.get(mContext).setWidgetRefreshCallback(null);
|
||||
@@ -201,10 +203,6 @@ public class LauncherAppState {
|
||||
return mModel;
|
||||
}
|
||||
|
||||
public DatabaseWidgetPreviewLoader getWidgetCache() {
|
||||
return mWidgetCache;
|
||||
}
|
||||
|
||||
public InvariantDeviceProfile getInvariantDeviceProfile() {
|
||||
return mInvariantDeviceProfile;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user