Fix issue where turning off fixed landscape goes to default grid

Bug: 390091751
Test: manually verified on device
Flag: com.android.launcher3.one_grid_specs
Change-Id: Id9de8cadc6fc1ee0ac0124638b2c487b8f8357bb
This commit is contained in:
Federico Baron committed 2025-02-07 09:22:42 +00:00
1 parent 026930cd14
commit 54b09dc41f
2 files changed
+22 -1

No files matched your search

@@ -20,6 +20,7 @@ import static com.android.launcher3.LauncherPrefs.DB_FILE;
import static com.android.launcher3.LauncherPrefs.ENABLE_TWOLINE_ALLAPPS_TOGGLE;
import static com.android.launcher3.LauncherPrefs.FIXED_LANDSCAPE_MODE;
import static com.android.launcher3.LauncherPrefs.GRID_NAME;
import static com.android.launcher3.LauncherPrefs.NON_FIXED_LANDSCAPE_GRID_NAME;
import static com.android.launcher3.Utilities.dpiFromPx;
import static com.android.launcher3.testing.shared.ResourceUtils.INVALID_RESOURCE_HANDLE;
import static com.android.launcher3.util.DisplayController.CHANGE_DENSITY;
@@ -93,6 +94,8 @@ public class InvariantDeviceProfile implements SafeCloseable {
new MainThreadInitializedObject<>(InvariantDeviceProfile::new);
public static final String GRID_NAME_PREFS_KEY = "idp_grid_name";
public static final String NON_FIXED_LANDSCAPE_GRID_NAME_PREFS_KEY =
"idp_non_fixed_landscape_grid_name";
@Retention(RetentionPolicy.SOURCE)
@IntDef({TYPE_PHONE, TYPE_MULTI_DISPLAY, TYPE_TABLET})
@@ -268,7 +271,14 @@ public class InvariantDeviceProfile implements SafeCloseable {
if (FIXED_LANDSCAPE_MODE.getSharedPrefKey().equals(key)
&& isFixedLandscape != FIXED_LANDSCAPE_MODE.get(context)) {
Trace.beginSection("InvariantDeviceProfile#setFixedLandscape");
onConfigChanged(context);
if (isFixedLandscape) {
setCurrentGrid(
context, LauncherPrefs.get(context).get(NON_FIXED_LANDSCAPE_GRID_NAME));
} else {
LauncherPrefs.get(context)
.put(NON_FIXED_LANDSCAPE_GRID_NAME, getCurrentGridName(context));
onConfigChanged(context);
}
Trace.endSection();
} else if (ENABLE_TWOLINE_ALLAPPS_TOGGLE.getSharedPrefKey().equals(key)
&& enableTwoLinesInAllApps != ENABLE_TWOLINE_ALLAPPS_TOGGLE.get(context)) {
@@ -21,6 +21,7 @@ import android.content.SharedPreferences
import androidx.annotation.VisibleForTesting
import com.android.launcher3.BuildConfig.WIDGET_ON_FIRST_SCREEN
import com.android.launcher3.InvariantDeviceProfile.GRID_NAME_PREFS_KEY
import com.android.launcher3.InvariantDeviceProfile.NON_FIXED_LANDSCAPE_GRID_NAME_PREFS_KEY
import com.android.launcher3.LauncherFiles.DEVICE_PREFERENCES_KEY
import com.android.launcher3.LauncherFiles.SHARED_PREFERENCES_KEY
import com.android.launcher3.dagger.ApplicationContext
@@ -304,6 +305,16 @@ constructor(@ApplicationContext private val encryptedContext: Context) {
@JvmField
val FIXED_LANDSCAPE_MODE = backedUpItem(SettingsActivity.FIXED_LANDSCAPE_MODE, false)
@JvmField
val NON_FIXED_LANDSCAPE_GRID_NAME =
ConstantItem(
NON_FIXED_LANDSCAPE_GRID_NAME_PREFS_KEY,
isBackedUp = true,
defaultValue = null,
encryptionType = EncryptionType.ENCRYPTED,
type = String::class.java,
)
// Preferences for widget configurations
@JvmField
val RECONFIGURABLE_WIDGET_EDUCATION_TIP_SEEN =