Merge branch 'aosp-rebase-11' of https://github.com/LawnchairLauncher/LawnchairAlpha into aosp-rebase-11

This commit is contained in:
Patryk Michalik
2021-03-15 13:56:28 +01:00
5 changed files with 28 additions and 1 deletions
@@ -2,6 +2,7 @@ package ch.deletescape.lawnchair.util.preferences
import android.content.Context
import android.content.SharedPreferences
import android.util.Log
import com.android.launcher3.LauncherAppState
import com.android.launcher3.Utilities
@@ -17,6 +18,10 @@ class LawnchairPreferences(val context: Context) {
LauncherAppState.getInstance(context).model.clearIconCache()
LauncherAppState.getInstance(context).model.forceReload()
}
WORKSPACE_ROWS, WORKSPACE_COLUMNS, ALL_APPS_COLUMNS, FOLDER_ROWS, FOLDER_COLUMNS, HOTSEAT_COLUMNS -> {
LauncherAppState.getInstance(context).invariantDeviceProfile.reInitGrid()
LauncherAppState.getInstance(context).model.forceReload()
}
}
}
@@ -140,6 +140,8 @@ public class InvariantDeviceProfile {
private ConfigMonitor mConfigMonitor;
private OverlayMonitor mOverlayMonitor;
private Context mContext;
@VisibleForTesting
public InvariantDeviceProfile() {}
@@ -162,10 +164,12 @@ public class InvariantDeviceProfile {
demoModeLayoutId = p.demoModeLayoutId;
mExtraAttrs = p.mExtraAttrs;
mOverlayMonitor = p.mOverlayMonitor;
mContext = p.mContext;
}
@TargetApi(23)
private InvariantDeviceProfile(Context context) {
mContext = context;
String gridName = getCurrentGridName(context);
String newGridName = initGrid(context, gridName);
if (!newGridName.equals(gridName)) {
@@ -185,6 +189,7 @@ public class InvariantDeviceProfile {
* This constructor should NOT have any monitors by design.
*/
public InvariantDeviceProfile(Context context, String gridName) {
mContext = context;
String newName = initGrid(context, gridName);
if (newName == null || !newName.equals(gridName)) {
throw new IllegalArgumentException("Unknown grid name");
@@ -195,6 +200,7 @@ public class InvariantDeviceProfile {
* This constructor should NOT have any monitors by design.
*/
public InvariantDeviceProfile(Context context, Display display) {
mContext = context;
// Ensure that the main device profile is initialized
InvariantDeviceProfile originalProfile = INSTANCE.get(context);
String gridName = getCurrentGridName(context);
@@ -322,6 +328,10 @@ public class InvariantDeviceProfile {
}
public void reInitGrid() {
initGrid(mContext, getCurrentGridName(mContext));
}
@Nullable
public TypedValue getAttrValue(int attr) {
return mExtraAttrs == null ? null : mExtraAttrs.get(attr);
@@ -175,6 +175,7 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo
public void onDeviceProfileChanged(DeviceProfile dp) {
for (AdapterHolder holder : mAH) {
if (holder.recyclerView != null) {
holder.adapter.setAllAppsColumns();
// Remove all views and clear the pool, while keeping the data same. After this
// call, all the viewHolders will be recreated.
holder.recyclerView.swapAdapter(holder.recyclerView.getAdapter(), true);
@@ -201,7 +201,17 @@ public class AllAppsGridAdapter extends RecyclerView.Adapter<AllAppsGridAdapter.
mOnIconClickListener = launcher.getItemOnClickListener();
setAppsPerRow(mLauncher.getDeviceProfile().inv.numAllAppsColumns);
setAllAppsColumns();
}
private int mColumns = 0;
public void setAllAppsColumns() {
int newColumns = mLauncher.getDeviceProfile().inv.numAllAppsColumns;
if (newColumns != mColumns) {
mColumns = newColumns;
setAppsPerRow(mColumns);
}
}
public void setAppsPerRow(int appsPerRow) {
@@ -281,6 +281,7 @@ public class AlphabeticalAppsList implements AllAppsStore.OnUpdateListener {
private void refreshRecyclerView() {
if (mAdapter != null) {
mAdapter.setAllAppsColumns();
mAdapter.notifyDataSetChanged();
}
}