Add mounted mode image tests and remove some image tests for OneGrid
Bug: 364711064
Flag: com.android.launcher3.one_grid_specs
Test: HomeScreenImageTest, AllAppsImageTest, FolderImageTest
Change-Id: I1d51596d50d63b00614a2efd342cce72d9a4af8e
diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java
index 090fe51..04e4b57 100644
--- a/src/com/android/launcher3/InvariantDeviceProfile.java
+++ b/src/com/android/launcher3/InvariantDeviceProfile.java
@@ -345,6 +345,11 @@
}
private String initGrid(Context context, String gridName) {
+ if (!Flags.oneGridSpecs() && (isFixedLandscapeMode || FIXED_LANDSCAPE_MODE.get(context))) {
+ LauncherPrefs.get(context).put(FIXED_LANDSCAPE_MODE, false);
+ isFixedLandscapeMode = false;
+ }
+
Info displayInfo = DisplayController.INSTANCE.get(context).getInfo();
List<DisplayOption> allOptions = getPredefinedDeviceProfiles(
@@ -539,8 +544,8 @@
}
/**
- * Updates the mounted mode, this triggers a new IDP, reloads the database and triggers a grid
- * migration.
+ * Updates the fixed landscape mode, this triggers a new IDP, reloads the database and triggers
+ * a grid migration.
*/
public void setFixedLandscape(Context context, boolean isFixedLandscape) {
this.isFixedLandscapeMode = isFixedLandscape;
@@ -580,8 +585,7 @@
private static boolean firstGridFilter(GridOption gridOption, int deviceType,
boolean allowDisabledGrid, boolean isFixedLandscapeMode) {
return (gridOption.isEnabled(deviceType) || allowDisabledGrid)
- && ((gridOption.mIsFixedLandscape == isFixedLandscapeMode)
- && gridOption.filterByFlag(deviceType));
+ && gridOption.filterByFlag(deviceType, isFixedLandscapeMode);
}
private static List<DisplayOption> getPredefinedDeviceProfiles(
@@ -755,9 +759,7 @@
return parseAllDefinedGridOptions(context, displayInfo)
.stream()
.filter(go -> go.isEnabled(deviceType))
- // if in fixedLandscape, then only show fixed landscape grids
- .filter(go -> go.mIsFixedLandscape == isFixedLandscapeMode)
- .filter(go -> go.filterByFlag(deviceType))
+ .filter(go -> go.filterByFlag(deviceType, isFixedLandscapeMode))
.collect(Collectors.toList());
}
@@ -1045,18 +1047,20 @@
NumRows numR = getRowCount(resourceHelper, context, displayInfo);
numRows = numR.mNumRowsNew;
dbFile = numR.mDbFile;
+ defaultLayoutId = numR.mDefaultLayoutId;
+ demoModeLayoutId = numR.mDemoModeLayoutId;
} else {
numRows = a.getInt(R.styleable.GridDisplayOption_numRows, 0);
dbFile = a.getString(R.styleable.GridDisplayOption_dbFile);
+ defaultLayoutId = a.getResourceId(
+ R.styleable.GridDisplayOption_defaultLayoutId, 0);
+ demoModeLayoutId = a.getResourceId(
+ R.styleable.GridDisplayOption_demoModeLayoutId, defaultLayoutId);
}
numColumns = a.getInt(R.styleable.GridDisplayOption_numColumns, 0);
numSearchContainerColumns = a.getInt(
R.styleable.GridDisplayOption_numSearchContainerColumns, numColumns);
- defaultLayoutId = a.getResourceId(
- R.styleable.GridDisplayOption_defaultLayoutId, 0);
- demoModeLayoutId = a.getResourceId(
- R.styleable.GridDisplayOption_demoModeLayoutId, defaultLayoutId);
allAppsStyle = a.getResourceId(R.styleable.GridDisplayOption_allAppsStyle,
R.style.AllAppsStyleDefault);
@@ -1203,15 +1207,19 @@
}
public boolean isNewGridOption() {
- Log.d("HHHH", "GRID = " + mIsFixedLandscape);
- return mRowCountSpecsId != INVALID_RESOURCE_HANDLE || mIsFixedLandscape;
+ return mRowCountSpecsId != INVALID_RESOURCE_HANDLE;
}
- public boolean filterByFlag(int deviceType) {
+ public boolean filterByFlag(int deviceType, boolean isFixedLandscape) {
if (deviceType == TYPE_TABLET) {
return Flags.oneGridRotationHandling() == mIsDualGrid;
}
- return Flags.oneGridSpecs() == isNewGridOption();
+
+ if (isFixedLandscape) {
+ return Flags.oneGridSpecs() && mIsFixedLandscape;
+ }
+
+ return ((Flags.oneGridSpecs() == isNewGridOption()) && !mIsFixedLandscape);
}
}
@@ -1220,6 +1228,9 @@
final float mMinDeviceWidthPx;
final float mMinDeviceHeightPx;
final String mDbFile;
+ final int mDefaultLayoutId;
+ final int mDemoModeLayoutId;
+
NumRows(Context context, AttributeSet attrs) {
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.NumRows);
@@ -1228,6 +1239,10 @@
mMinDeviceWidthPx = a.getFloat(R.styleable.NumRows_minDeviceWidthPx, 0);
mMinDeviceHeightPx = a.getFloat(R.styleable.NumRows_minDeviceHeightPx, 0);
mDbFile = a.getString(R.styleable.NumRows_dbFile);
+ mDefaultLayoutId = a.getResourceId(
+ R.styleable.NumRows_defaultLayoutId, 0);
+ mDemoModeLayoutId = a.getResourceId(
+ R.styleable.NumRows_demoModeLayoutId, mDefaultLayoutId);
a.recycle();
}