Lawnchair: Fix icon size and label size reload, implement launcher restart
This commit is contained in:
1 parent
15c5ae0356
commit
480ac2c76b
17 files changed
+207
-46
No files matched your search
@@ -17,6 +17,7 @@
|
||||
package com.android.launcher3;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Point;
|
||||
@@ -31,6 +32,8 @@ import com.android.launcher3.icons.IconNormalizer;
|
||||
import com.android.launcher3.util.DefaultDisplay;
|
||||
import com.android.launcher3.util.WindowBounds;
|
||||
|
||||
import app.lawnchair.util.preferences.LawnchairPreferences;
|
||||
|
||||
public class DeviceProfile {
|
||||
|
||||
private static final float TABLET_MIN_DPS = 600;
|
||||
@@ -140,10 +143,13 @@ public class DeviceProfile {
|
||||
public DotRenderer mDotRendererWorkSpace;
|
||||
public DotRenderer mDotRendererAllApps;
|
||||
|
||||
private final Context mContext;
|
||||
|
||||
DeviceProfile(Context context, InvariantDeviceProfile inv, DefaultDisplay.Info info,
|
||||
Point minSize, Point maxSize, int width, int height, boolean isLandscape,
|
||||
boolean isMultiWindowMode, boolean transposeLayoutWithOrientation,
|
||||
Point windowPosition) {
|
||||
mContext = context;
|
||||
|
||||
this.inv = inv;
|
||||
this.isLandscape = isLandscape;
|
||||
@@ -241,7 +247,6 @@ public class DeviceProfile {
|
||||
updateAvailableDimensions(res);
|
||||
}
|
||||
updateWorkspacePadding();
|
||||
|
||||
// This is done last, after iconSizePx is calculated above.
|
||||
mDotRendererWorkSpace = new DotRenderer(iconSizePx, IconShape.getShapePath(),
|
||||
IconShape.DEFAULT_PATH_SIZE);
|
||||
@@ -408,6 +413,16 @@ public class DeviceProfile {
|
||||
// Folder icon
|
||||
folderIconSizePx = IconNormalizer.getNormalizedCircleSize(iconSizePx);
|
||||
folderIconOffsetYPx = (iconSizePx - folderIconSizePx) / 2;
|
||||
|
||||
// Lawnchair prefs
|
||||
SharedPreferences prefs = LawnchairPreferences.Companion.getInstance(mContext);
|
||||
if (prefs == null) return;
|
||||
|
||||
// Lawnchair icon and text sizes
|
||||
iconSizePx *= prefs.getFloat(LawnchairPreferences.ICON_SIZE_FACTOR, 1f);
|
||||
iconTextSizePx *= prefs.getFloat(LawnchairPreferences.TEXT_SIZE_FACTOR, 1f);;
|
||||
allAppsIconSizePx *= prefs.getFloat(LawnchairPreferences.ALL_APPS_ICON_SIZE_FACTOR, 1f);
|
||||
allAppsIconTextSizePx *= prefs.getFloat(LawnchairPreferences.ALL_APPS_TEXT_SIZE_FACTOR, 1f);
|
||||
}
|
||||
|
||||
private void updateAvailableFolderCellDimensions(Resources res) {
|
||||
|
||||
@@ -319,13 +319,6 @@ public class InvariantDeviceProfile {
|
||||
numAllAppsColumns = Math.round(prefs.getFloat(LawnchairPreferences.ALL_APPS_COLUMNS, numAllAppsColumns));
|
||||
numFolderRows = Math.round(prefs.getFloat(LawnchairPreferences.FOLDER_ROWS, numFolderRows));
|
||||
numFolderColumns = Math.round(prefs.getFloat(LawnchairPreferences.FOLDER_COLUMNS, numFolderColumns));
|
||||
|
||||
// Lawnchair icon and text sizes
|
||||
iconSize *= prefs.getFloat(LawnchairPreferences.ICON_SIZE_FACTOR, 1f);
|
||||
iconTextSize *= prefs.getFloat(LawnchairPreferences.TEXT_SIZE_FACTOR, 1f);;
|
||||
allAppsIconSize *= prefs.getFloat(LawnchairPreferences.ALL_APPS_ICON_SIZE_FACTOR, 1f);
|
||||
allAppsIconTextSize *= prefs.getFloat(LawnchairPreferences.ALL_APPS_TEXT_SIZE_FACTOR, 1f);
|
||||
|
||||
}
|
||||
|
||||
public void reInitGrid() {
|
||||
|
||||
@@ -372,6 +372,7 @@ public class Launcher extends StatefulActivity<LauncherState> implements Launche
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
LauncherAppState app = LauncherAppState.getInstance(this);
|
||||
app.setLauncher(this);
|
||||
mOldConfig = new Configuration(getResources().getConfiguration());
|
||||
mModel = app.getModel();
|
||||
|
||||
|
||||
@@ -45,13 +45,21 @@ import com.android.launcher3.util.SecureSettingsObserver;
|
||||
import com.android.launcher3.util.SimpleBroadcastReceiver;
|
||||
import com.android.launcher3.widget.custom.CustomWidgetManager;
|
||||
|
||||
import app.lawnchair.LawnchairAppKt;
|
||||
|
||||
public class LauncherAppState {
|
||||
|
||||
public static final String ACTION_FORCE_ROLOAD = "force-reload-launcher";
|
||||
|
||||
// We do not need any synchronization for this variable as its only written on UI thread.
|
||||
public static final MainThreadInitializedObject<LauncherAppState> INSTANCE =
|
||||
new MainThreadInitializedObject<>(LauncherAppState::new);
|
||||
new MainThreadInitializedObject<LauncherAppState>(LauncherAppState::new) {
|
||||
@Override
|
||||
protected void onPostInit(Context context) {
|
||||
super.onPostInit(context);
|
||||
LawnchairAppKt.getLawnchairApp(context).onLauncherAppStateCreated();
|
||||
}
|
||||
};
|
||||
|
||||
private final Context mContext;
|
||||
private final LauncherModel mModel;
|
||||
@@ -65,6 +73,7 @@ public class LauncherAppState {
|
||||
private SimpleBroadcastReceiver mModelChangeReceiver;
|
||||
private SafeCloseable mCalendarChangeTracker;
|
||||
private SafeCloseable mUserChangeListener;
|
||||
private Launcher mLauncher;
|
||||
|
||||
public static LauncherAppState getInstance(final Context context) {
|
||||
return INSTANCE.get(context);
|
||||
@@ -177,6 +186,14 @@ public class LauncherAppState {
|
||||
}
|
||||
}
|
||||
|
||||
public void setLauncher(Launcher launcher) {
|
||||
mLauncher = launcher;
|
||||
}
|
||||
|
||||
public Launcher getLauncher() {
|
||||
return mLauncher;
|
||||
}
|
||||
|
||||
public IconCache getIconCache() {
|
||||
return mIconCache;
|
||||
}
|
||||
|
||||
@@ -48,6 +48,7 @@ public class MainThreadInitializedObject<T> {
|
||||
if (Looper.myLooper() == Looper.getMainLooper()) {
|
||||
mValue = TraceHelper.allowIpcs("main.thread.object",
|
||||
() -> mProvider.get(context.getApplicationContext()));
|
||||
onPostInit(context);
|
||||
} else {
|
||||
try {
|
||||
return MAIN_EXECUTOR.submit(() -> get(context)).get();
|
||||
@@ -59,6 +60,8 @@ public class MainThreadInitializedObject<T> {
|
||||
return mValue;
|
||||
}
|
||||
|
||||
protected void onPostInit(Context context) { }
|
||||
|
||||
public T getNoCreate() {
|
||||
return mValue;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user