mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-19 18:58:19 +00:00
Extending the grid migration logic to handle density changes
For hotseat migratino, we simply drop the items with least weight If the workspace row/column decreases by 2 or more, we clear the whole workspace Bug: 25958224 Change-Id: I7131b955023d185ed10955f593184b9238546dc8
This commit is contained in:
@@ -23,26 +23,30 @@ import android.content.IntentFilter;
|
||||
import android.content.res.Configuration;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.launcher3.Utilities;
|
||||
|
||||
/**
|
||||
* {@link BroadcastReceiver} which watches configuration changes and
|
||||
* restarts the process in case changes which affect the device profile.
|
||||
* restarts the process in case changes which affect the device profile occur.
|
||||
*/
|
||||
public class ConfigMonitor extends BroadcastReceiver {
|
||||
|
||||
private final Context mContext;
|
||||
private final float mFontScale;
|
||||
private final int mDensity;
|
||||
|
||||
public ConfigMonitor(Context context) {
|
||||
mContext = context;
|
||||
|
||||
Configuration config = context.getResources().getConfiguration();
|
||||
mFontScale = config.fontScale;
|
||||
mDensity = getDensity(config);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
Configuration config = context.getResources().getConfiguration();
|
||||
if (mFontScale != config.fontScale) {
|
||||
if (mFontScale != config.fontScale || mDensity != getDensity(config)) {
|
||||
Log.d("ConfigMonitor", "Configuration changed, restarting launcher");
|
||||
mContext.unregisterReceiver(this);
|
||||
android.os.Process.killProcess(android.os.Process.myPid());
|
||||
@@ -52,4 +56,8 @@ public class ConfigMonitor extends BroadcastReceiver {
|
||||
public void register() {
|
||||
mContext.registerReceiver(this, new IntentFilter(Intent.ACTION_CONFIGURATION_CHANGED));
|
||||
}
|
||||
|
||||
private static int getDensity(Configuration config) {
|
||||
return Utilities.ATLEAST_JB_MR1 ? config.densityDpi : 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user