Adding Launcher Mode settings to Launcher settings
Bug: 364711735 Test: NA Flag: com.android.launcher3.one_grid_specs Change-Id: Iab688ebdb8449f9258b61f59a0afe97875f82a81
This commit is contained in:
@@ -311,6 +311,9 @@
|
||||
<!-- defaults to allAppsCellSpecsId, if not specified -->
|
||||
<attr name="allAppsCellSpecsTwoPanelId" format="reference" />
|
||||
|
||||
<!-- defaults to false, if not specified -->
|
||||
<attr name="isFixedLandscape" format="boolean" />
|
||||
|
||||
<!-- By default all categories are enabled -->
|
||||
<attr name="deviceCategory" format="integer">
|
||||
<!-- Enable on phone only -->
|
||||
|
||||
@@ -317,6 +317,12 @@
|
||||
<string name="allow_rotation_title">Allow home screen rotation</string>
|
||||
<!-- Text explaining when the home screen will get rotated. [CHAR LIMIT=100] -->
|
||||
<string name="allow_rotation_desc">When phone is rotated</string>
|
||||
|
||||
<!-- Title for Landscape Mode setting. [CHAR LIMIT=50] -->
|
||||
<string name="landscape_mode_title">Landscape mode</string>
|
||||
<!-- [CHAR LIMIT=100] -->
|
||||
<string name="landscape_mode_desc">Set phone into landscape mode</string>
|
||||
|
||||
<!-- Title for Notification dots setting. Tapping this will link to the system Notifications settings screen where the user can turn off notification dots globally. [CHAR LIMIT=50] -->
|
||||
<string name="notification_dots_title">Notification dots</string>
|
||||
<!-- Text to indicate that the system notification dots setting is on [CHAR LIMIT=100] -->
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
<include domain="database" path="launcher_4_by_4.db" />
|
||||
<include domain="database" path="launcher_3_by_3.db" />
|
||||
<include domain="database" path="launcher_2_by_2.db" />
|
||||
<include domain="database" path="launcher_7_by_3.db" />
|
||||
<include domain="sharedpref" path="com.android.launcher3.prefs.xml" />
|
||||
<include domain="file" path="downgrade_schema.json" />
|
||||
|
||||
|
||||
@@ -617,7 +617,7 @@ public class DeviceProfile {
|
||||
|| inv.inlineQsb[INDEX_TWO_PANEL_LANDSCAPE]
|
||||
: inv.inlineQsb[INDEX_DEFAULT] || inv.inlineQsb[INDEX_LANDSCAPE])
|
||||
&& hotseatQsbHeight > 0;
|
||||
isQsbInline = mIsScalableGrid && inv.inlineQsb[mTypeIndex] && canQsbInline;
|
||||
isQsbInline = isQsbInline(inv);
|
||||
|
||||
areNavButtonsInline = isTaskbarPresent && !isGestureMode;
|
||||
numShownHotseatIcons =
|
||||
@@ -850,6 +850,24 @@ public class DeviceProfile {
|
||||
mDotRendererAllApps = createDotRenderer(context, allAppsIconSizePx, dotRendererCache);
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes care of the logic that determines if we show a the QSB inline or not.
|
||||
*/
|
||||
private boolean isQsbInline(InvariantDeviceProfile inv) {
|
||||
// For foldable (two panel), we inline the qsb if we have the screen open and we are in
|
||||
// either Landscape or Portrait. This cal also be disabled in the device_profile.xml
|
||||
boolean twoPanelCanInline = inv.inlineQsb[INDEX_TWO_PANEL_PORTRAIT]
|
||||
|| inv.inlineQsb[INDEX_TWO_PANEL_LANDSCAPE];
|
||||
|
||||
// In tablets we inline in both orientations but only if we have enough space in the QSB
|
||||
boolean tabletInlineQsb = inv.inlineQsb[INDEX_DEFAULT] || inv.inlineQsb[INDEX_LANDSCAPE];
|
||||
boolean canQsbInline = isTwoPanels ? twoPanelCanInline : tabletInlineQsb;
|
||||
canQsbInline = canQsbInline && hotseatQsbHeight > 0;
|
||||
|
||||
return (mIsScalableGrid && inv.inlineQsb[mTypeIndex] && canQsbInline)
|
||||
|| inv.isFixedLandscapeMode;
|
||||
}
|
||||
|
||||
private static DotRenderer createDotRenderer(
|
||||
@NonNull Context context, int size, @NonNull SparseArray<DotRenderer> cache) {
|
||||
DotRenderer renderer = cache.get(size);
|
||||
@@ -1903,7 +1921,7 @@ public class DeviceProfile {
|
||||
hotseatBarPadding.set(mHotseatBarWorkspaceSpacePx, paddingTop,
|
||||
mInsets.right + mHotseatBarEdgePaddingPx, paddingBottom);
|
||||
}
|
||||
} else if (isTaskbarPresent) {
|
||||
} else if (isTaskbarPresent || inv.isFixedLandscapeMode) {
|
||||
// Center the QSB vertically with hotseat
|
||||
int hotseatBarBottomPadding = getHotseatBarBottomPadding();
|
||||
int hotseatBarTopPadding =
|
||||
@@ -1922,6 +1940,13 @@ public class DeviceProfile {
|
||||
}
|
||||
startSpacing += getAdditionalQsbSpace();
|
||||
|
||||
if (inv.isFixedLandscapeMode) {
|
||||
endSpacing += workspacePadding.right + cellLayoutPaddingPx.right
|
||||
+ mInsets.right;
|
||||
startSpacing += workspacePadding.left + cellLayoutPaddingPx.left
|
||||
+ mInsets.left;
|
||||
}
|
||||
|
||||
hotseatBarPadding.top = hotseatBarTopPadding;
|
||||
hotseatBarPadding.bottom = hotseatBarBottomPadding;
|
||||
boolean isRtl = Utilities.isRtl(context.getResources());
|
||||
@@ -2517,7 +2542,8 @@ public class DeviceProfile {
|
||||
throw new IllegalArgumentException("Window bounds not set");
|
||||
}
|
||||
if (mTransposeLayoutWithOrientation == null) {
|
||||
mTransposeLayoutWithOrientation = !mInfo.isTablet(mWindowBounds);
|
||||
mTransposeLayoutWithOrientation =
|
||||
!(mInfo.isTablet(mWindowBounds) || mInv.isFixedLandscapeMode);
|
||||
}
|
||||
if (mIsGestureMode == null) {
|
||||
mIsGestureMode = mInfo.getNavigationMode().hasGestures;
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.android.launcher3;
|
||||
|
||||
import static com.android.launcher3.LauncherPrefs.FIXED_LANDSCAPE_MODE;
|
||||
import static com.android.launcher3.LauncherPrefs.GRID_NAME;
|
||||
import static com.android.launcher3.Utilities.dpiFromPx;
|
||||
import static com.android.launcher3.testing.shared.ResourceUtils.INVALID_RESOURCE_HANDLE;
|
||||
@@ -86,7 +87,8 @@ public class InvariantDeviceProfile implements SafeCloseable {
|
||||
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@IntDef({TYPE_PHONE, TYPE_MULTI_DISPLAY, TYPE_TABLET})
|
||||
public @interface DeviceType {}
|
||||
public @interface DeviceType {
|
||||
}
|
||||
|
||||
public static final int TYPE_PHONE = 0;
|
||||
public static final int TYPE_MULTI_DISPLAY = 1;
|
||||
@@ -210,6 +212,13 @@ public class InvariantDeviceProfile implements SafeCloseable {
|
||||
@XmlRes
|
||||
public int allAppsCellSpecsTwoPanelId = INVALID_RESOURCE_HANDLE;
|
||||
|
||||
|
||||
/**
|
||||
* Fixed landscape mode is the landscape on the phones.
|
||||
*/
|
||||
public boolean isFixedLandscapeMode = false;
|
||||
private LauncherPrefChangeListener mLandscapeModePreferenceListener;
|
||||
|
||||
public String dbFile;
|
||||
public int defaultLayoutId;
|
||||
public int demoModeLayoutId;
|
||||
@@ -225,7 +234,8 @@ public class InvariantDeviceProfile implements SafeCloseable {
|
||||
private final ArrayList<OnIDPChangeListener> mChangeListeners = new ArrayList<>();
|
||||
|
||||
@VisibleForTesting
|
||||
public InvariantDeviceProfile() { }
|
||||
public InvariantDeviceProfile() {
|
||||
}
|
||||
|
||||
@TargetApi(23)
|
||||
private InvariantDeviceProfile(Context context) {
|
||||
@@ -243,6 +253,18 @@ public class InvariantDeviceProfile implements SafeCloseable {
|
||||
onConfigChanged(displayContext);
|
||||
}
|
||||
});
|
||||
if (Flags.oneGridSpecs()) {
|
||||
mLandscapeModePreferenceListener = (String s) -> {
|
||||
boolean newFixedLandscapeValue = FIXED_LANDSCAPE_MODE.get(context);
|
||||
if (isFixedLandscapeMode != newFixedLandscapeValue) {
|
||||
setFixedLandscape(context, newFixedLandscapeValue);
|
||||
}
|
||||
};
|
||||
LauncherPrefs.INSTANCE.get(context).addListener(
|
||||
mLandscapeModePreferenceListener,
|
||||
FIXED_LANDSCAPE_MODE
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -268,8 +290,13 @@ public class InvariantDeviceProfile implements SafeCloseable {
|
||||
@DeviceType int defaultDeviceType = defaultInfo.getDeviceType();
|
||||
DisplayOption defaultDisplayOption = invDistWeightedInterpolate(
|
||||
defaultInfo,
|
||||
getPredefinedDeviceProfiles(context, gridName, defaultInfo,
|
||||
/*allowDisabledGrid=*/false),
|
||||
getPredefinedDeviceProfiles(
|
||||
context,
|
||||
gridName,
|
||||
defaultInfo,
|
||||
/*allowDisabledGrid=*/false,
|
||||
isFixedLandscapeMode
|
||||
),
|
||||
defaultDeviceType);
|
||||
|
||||
Context displayContext = context.createDisplayContext(display);
|
||||
@@ -277,8 +304,13 @@ public class InvariantDeviceProfile implements SafeCloseable {
|
||||
@DeviceType int deviceType = myInfo.getDeviceType();
|
||||
DisplayOption myDisplayOption = invDistWeightedInterpolate(
|
||||
myInfo,
|
||||
getPredefinedDeviceProfiles(context, gridName, myInfo,
|
||||
/*allowDisabledGrid=*/false),
|
||||
getPredefinedDeviceProfiles(
|
||||
context,
|
||||
gridName,
|
||||
myInfo,
|
||||
/*allowDisabledGrid=*/false,
|
||||
isFixedLandscapeMode
|
||||
),
|
||||
deviceType);
|
||||
|
||||
DisplayOption result = new DisplayOption(defaultDisplayOption.grid)
|
||||
@@ -301,6 +333,11 @@ public class InvariantDeviceProfile implements SafeCloseable {
|
||||
@Override
|
||||
public void close() {
|
||||
DisplayController.INSTANCE.executeIfCreated(dc -> dc.setPriorityListener(null));
|
||||
if (mLandscapeModePreferenceListener != null) {
|
||||
LauncherPrefs.INSTANCE.executeIfCreated(
|
||||
lp -> lp.removeListener(mLandscapeModePreferenceListener, FIXED_LANDSCAPE_MODE)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public static String getCurrentGridName(Context context) {
|
||||
@@ -310,8 +347,13 @@ public class InvariantDeviceProfile implements SafeCloseable {
|
||||
private String initGrid(Context context, String gridName) {
|
||||
Info displayInfo = DisplayController.INSTANCE.get(context).getInfo();
|
||||
|
||||
List<DisplayOption> allOptions = getPredefinedDeviceProfiles(context, gridName,
|
||||
displayInfo, RestoreDbTask.isPending(context));
|
||||
List<DisplayOption> allOptions = getPredefinedDeviceProfiles(
|
||||
context,
|
||||
gridName,
|
||||
displayInfo,
|
||||
RestoreDbTask.isPending(context),
|
||||
FIXED_LANDSCAPE_MODE.get(context)
|
||||
);
|
||||
|
||||
// Filter out options that don't have the same number of columns as the grid
|
||||
DeviceGridState deviceGridState = new DeviceGridState(context);
|
||||
@@ -320,8 +362,8 @@ public class InvariantDeviceProfile implements SafeCloseable {
|
||||
|
||||
DisplayOption displayOption =
|
||||
invDistWeightedInterpolate(displayInfo, allOptionsFilteredByColCount.isEmpty()
|
||||
? new ArrayList<>(allOptions)
|
||||
: new ArrayList<>(allOptionsFilteredByColCount),
|
||||
? new ArrayList<>(allOptions)
|
||||
: new ArrayList<>(allOptionsFilteredByColCount),
|
||||
displayInfo.getDeviceType());
|
||||
initGrid(context, displayInfo, displayOption);
|
||||
return displayOption.grid.name;
|
||||
@@ -425,6 +467,9 @@ public class InvariantDeviceProfile implements SafeCloseable {
|
||||
|
||||
startAlignTaskbar = displayOption.startAlignTaskbar;
|
||||
|
||||
// Fixed Landscape mode
|
||||
isFixedLandscapeMode = FIXED_LANDSCAPE_MODE.get(context) && Flags.oneGridSpecs();
|
||||
|
||||
// If the partner customization apk contains any grid overrides, apply them
|
||||
// Supported overrides: numRows, numColumns, iconSize
|
||||
applyPartnerDeviceProfileOverrides(context, metrics);
|
||||
@@ -480,8 +525,12 @@ public class InvariantDeviceProfile implements SafeCloseable {
|
||||
mChangeListeners.remove(listener);
|
||||
}
|
||||
|
||||
public void setCurrentGrid(Context context, String gridName) {
|
||||
LauncherPrefs.get(context).put(GRID_NAME, gridName);
|
||||
/**
|
||||
* Updates the current grid, this triggers a new IDP, reloads the database and triggers a grid
|
||||
* migration.
|
||||
*/
|
||||
public void setCurrentGrid(Context context, String newGridName) {
|
||||
LauncherPrefs.get(context).put(GRID_NAME, newGridName);
|
||||
MAIN_EXECUTOR.execute(() -> {
|
||||
Trace.beginSection("InvariantDeviceProfile#setCurrentGrid");
|
||||
onConfigChanged(context.getApplicationContext());
|
||||
@@ -489,6 +538,24 @@ public class InvariantDeviceProfile implements SafeCloseable {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the mounted mode, this triggers a new IDP, reloads the database and triggers a grid
|
||||
* migration.
|
||||
*/
|
||||
public void setFixedLandscape(Context context, boolean isFixedLandscape) {
|
||||
this.isFixedLandscapeMode = isFixedLandscape;
|
||||
if (isFixedLandscape) {
|
||||
// When in isFixedLandscape there should only be one default grid to choose from
|
||||
MAIN_EXECUTOR.execute(() -> {
|
||||
Trace.beginSection("InvariantDeviceProfile#setFixedLandscape");
|
||||
onConfigChanged(context.getApplicationContext());
|
||||
Trace.endSection();
|
||||
});
|
||||
} else {
|
||||
setCurrentGrid(context, LauncherPrefs.get(context).get(GRID_NAME));
|
||||
}
|
||||
}
|
||||
|
||||
private Object[] toModelState() {
|
||||
return new Object[]{
|
||||
numColumns, numRows, numSearchContainerColumns, numDatabaseHotseatIcons,
|
||||
@@ -510,8 +577,20 @@ public class InvariantDeviceProfile implements SafeCloseable {
|
||||
}
|
||||
}
|
||||
|
||||
private static List<DisplayOption> getPredefinedDeviceProfiles(Context context, String gridName,
|
||||
Info displayInfo, boolean allowDisabledGrid) {
|
||||
private static boolean firstGridFilter(GridOption gridOption, int deviceType,
|
||||
boolean allowDisabledGrid, boolean isFixedLandscapeMode) {
|
||||
return (gridOption.isEnabled(deviceType) || allowDisabledGrid)
|
||||
&& ((gridOption.mIsFixedLandscape == isFixedLandscapeMode)
|
||||
&& gridOption.filterByFlag(deviceType));
|
||||
}
|
||||
|
||||
private static List<DisplayOption> getPredefinedDeviceProfiles(
|
||||
Context context,
|
||||
String gridName,
|
||||
Info displayInfo,
|
||||
boolean allowDisabledGrid,
|
||||
boolean isFixedLandscapeMode
|
||||
) {
|
||||
ArrayList<DisplayOption> profiles = new ArrayList<>();
|
||||
|
||||
try (XmlResourceParser parser = context.getResources().getXml(R.xml.device_profiles)) {
|
||||
@@ -521,11 +600,10 @@ public class InvariantDeviceProfile implements SafeCloseable {
|
||||
parser.getDepth() > depth) && type != XmlPullParser.END_DOCUMENT) {
|
||||
if ((type == XmlPullParser.START_TAG)
|
||||
&& GridOption.TAG_NAME.equals(parser.getName())) {
|
||||
|
||||
GridOption gridOption = new GridOption(
|
||||
context, Xml.asAttributeSet(parser), displayInfo);
|
||||
if ((gridOption.isEnabled(displayInfo.getDeviceType()) || allowDisabledGrid)
|
||||
&& gridOption.filterByFlag(displayInfo.getDeviceType())) {
|
||||
if (firstGridFilter(gridOption, displayInfo.getDeviceType(), allowDisabledGrid,
|
||||
isFixedLandscapeMode)) {
|
||||
final int displayDepth = parser.getDepth();
|
||||
while (((type = parser.next()) != XmlPullParser.END_TAG
|
||||
|| parser.getDepth() > displayDepth)
|
||||
@@ -542,7 +620,6 @@ public class InvariantDeviceProfile implements SafeCloseable {
|
||||
} catch (IOException | XmlPullParserException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
ArrayList<DisplayOption> filteredProfiles = new ArrayList<>();
|
||||
if (!TextUtils.isEmpty(gridName)) {
|
||||
for (DisplayOption option : profiles) {
|
||||
@@ -650,7 +727,6 @@ public class InvariantDeviceProfile implements SafeCloseable {
|
||||
* supported. Ej. 4x4 -> normal, 5x4 -> practical, etc.
|
||||
* (Note: the name of the grid can be different for the same grid size depending of
|
||||
* the values of the InvariantDeviceProfile)
|
||||
*
|
||||
*/
|
||||
public String getGridNameFromSize(Context context, Point size) {
|
||||
return parseAllGridOptions(context).stream()
|
||||
@@ -679,6 +755,8 @@ public class InvariantDeviceProfile implements SafeCloseable {
|
||||
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))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
@@ -950,6 +1028,7 @@ public class InvariantDeviceProfile implements SafeCloseable {
|
||||
private final int mAllAppsCellSpecsId;
|
||||
private final int mAllAppsCellSpecsTwoPanelId;
|
||||
private final int mRowCountSpecsId;
|
||||
private final boolean mIsFixedLandscape;
|
||||
|
||||
public GridOption(Context context, AttributeSet attrs, Info displayInfo) {
|
||||
TypedArray a = context.obtainStyledAttributes(
|
||||
@@ -1091,6 +1170,8 @@ public class InvariantDeviceProfile implements SafeCloseable {
|
||||
mNumAllAppsRowsForCellHeightCalculation = numRows;
|
||||
}
|
||||
|
||||
mIsFixedLandscape = a.getBoolean(R.styleable.GridDisplayOption_isFixedLandscape, false);
|
||||
|
||||
int inlineForRotation = a.getInt(R.styleable.GridDisplayOption_inlineQsb,
|
||||
DONT_INLINE_QSB);
|
||||
inlineQsb[INDEX_DEFAULT] =
|
||||
@@ -1122,7 +1203,8 @@ public class InvariantDeviceProfile implements SafeCloseable {
|
||||
}
|
||||
|
||||
public boolean isNewGridOption() {
|
||||
return mRowCountSpecsId != INVALID_RESOURCE_HANDLE;
|
||||
Log.d("HHHH", "GRID = " + mIsFixedLandscape);
|
||||
return mRowCountSpecsId != INVALID_RESOURCE_HANDLE || mIsFixedLandscape;
|
||||
}
|
||||
|
||||
public boolean filterByFlag(int deviceType) {
|
||||
|
||||
@@ -96,6 +96,7 @@ import static com.android.launcher3.popup.SystemShortcut.APP_INFO;
|
||||
import static com.android.launcher3.popup.SystemShortcut.INSTALL;
|
||||
import static com.android.launcher3.popup.SystemShortcut.WIDGETS;
|
||||
import static com.android.launcher3.states.RotationHelper.REQUEST_LOCK;
|
||||
import static com.android.launcher3.states.RotationHelper.REQUEST_FIXED_LANDSCAPE;
|
||||
import static com.android.launcher3.states.RotationHelper.REQUEST_NONE;
|
||||
import static com.android.launcher3.testing.shared.TestProtocol.LAUNCHER_ACTIVITY_STOPPED_MESSAGE;
|
||||
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
|
||||
@@ -279,6 +280,7 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.function.Supplier;
|
||||
@@ -761,7 +763,6 @@ public class Launcher extends StatefulActivity<LauncherState>
|
||||
if (!initDeviceProfile(mDeviceProfile.inv) && !mForceConfigUpdate) {
|
||||
return;
|
||||
}
|
||||
|
||||
dispatchDeviceProfileChanged();
|
||||
reapplyUi();
|
||||
mDragLayer.recreateControllers();
|
||||
@@ -777,6 +778,18 @@ public class Launcher extends StatefulActivity<LauncherState>
|
||||
}
|
||||
}
|
||||
|
||||
private void updateFixedLandscape() {
|
||||
if (!com.android.launcher3.Flags.oneGridSpecs()) {
|
||||
return;
|
||||
}
|
||||
if (Objects.requireNonNull(mDeviceProfile.inv).isFixedLandscapeMode) {
|
||||
// Set rotation fixed
|
||||
getRotationHelper().setStateHandlerRequest(REQUEST_FIXED_LANDSCAPE);
|
||||
} else {
|
||||
getRotationHelper().setStateHandlerRequest(REQUEST_NONE);
|
||||
}
|
||||
}
|
||||
|
||||
public void onAssistantVisibilityChanged(float visibility) {
|
||||
mHotseat.getQsb().setAlpha(1f - visibility);
|
||||
}
|
||||
@@ -805,6 +818,7 @@ public class Launcher extends StatefulActivity<LauncherState>
|
||||
mDeviceProfile.numShownHotseatIcons);
|
||||
}
|
||||
mModelWriter = mModel.getWriter(true, mCellPosMapper, this);
|
||||
updateFixedLandscape();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ public class LauncherFiles {
|
||||
public static final String LAUNCHER_4_BY_4_DB = "launcher_4_by_4.db";
|
||||
public static final String LAUNCHER_3_BY_3_DB = "launcher_3_by_3.db";
|
||||
public static final String LAUNCHER_2_BY_2_DB = "launcher_2_by_2.db";
|
||||
public static final String LAUNCHER_7_BY_3_DB = "launcher_7_by_3.db";
|
||||
public static final String BACKUP_DB = "backup.db";
|
||||
public static final String SHARED_PREFERENCES_KEY = "com.android.launcher3.prefs";
|
||||
public static final String MANAGED_USER_PREFERENCES_KEY =
|
||||
@@ -43,7 +44,8 @@ public class LauncherFiles {
|
||||
LAUNCHER_5_BY_6_DB,
|
||||
LAUNCHER_4_BY_4_DB,
|
||||
LAUNCHER_3_BY_3_DB,
|
||||
LAUNCHER_2_BY_2_DB));
|
||||
LAUNCHER_2_BY_2_DB,
|
||||
LAUNCHER_7_BY_3_DB));
|
||||
|
||||
public static final List<String> OTHER_FILES = Collections.unmodifiableList(Arrays.asList(
|
||||
BACKUP_DB,
|
||||
|
||||
@@ -26,6 +26,7 @@ import com.android.launcher3.model.DeviceGridState
|
||||
import com.android.launcher3.pm.InstallSessionHelper
|
||||
import com.android.launcher3.provider.RestoreDbTask
|
||||
import com.android.launcher3.provider.RestoreDbTask.FIRST_LOAD_AFTER_RESTORE_KEY
|
||||
import com.android.launcher3.settings.SettingsActivity
|
||||
import com.android.launcher3.states.RotationHelper
|
||||
import com.android.launcher3.util.DisplayController
|
||||
import com.android.launcher3.util.MainThreadInitializedObject
|
||||
@@ -133,6 +134,7 @@ abstract class LauncherPrefs : SafeCloseable {
|
||||
nonRestorableItem(FIRST_LOAD_AFTER_RESTORE_KEY, false, EncryptionType.ENCRYPTED)
|
||||
@JvmField val APP_WIDGET_IDS = backedUpItem(RestoreDbTask.APPWIDGET_IDS, "")
|
||||
@JvmField val OLD_APP_WIDGET_IDS = backedUpItem(RestoreDbTask.APPWIDGET_OLD_IDS, "")
|
||||
|
||||
@JvmField
|
||||
val GRID_NAME =
|
||||
ConstantItem(
|
||||
@@ -148,6 +150,9 @@ abstract class LauncherPrefs : SafeCloseable {
|
||||
RotationHelper.getAllowRotationDefaultValue(DisplayController.INSTANCE.get(it).info)
|
||||
}
|
||||
|
||||
@JvmField
|
||||
val FIXED_LANDSCAPE_MODE = backedUpItem(SettingsActivity.FIXED_LANDSCAPE_MODE, false)
|
||||
|
||||
// Preferences for widget configurations
|
||||
@JvmField
|
||||
val RECONFIGURABLE_WIDGET_EDUCATION_TIP_SEEN =
|
||||
|
||||
@@ -26,6 +26,7 @@ import static com.android.launcher3.states.RotationHelper.ALLOW_ROTATION_PREFERE
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
@@ -66,6 +67,8 @@ public class SettingsActivity extends FragmentActivity
|
||||
@VisibleForTesting
|
||||
static final String DEVELOPER_OPTIONS_KEY = "pref_developer_options";
|
||||
|
||||
public static final String FIXED_LANDSCAPE_MODE = "pref_fixed_landscape_mode";
|
||||
|
||||
private static final String NOTIFICATION_DOTS_PREFERENCE_KEY = "pref_icon_badging";
|
||||
|
||||
public static final String EXTRA_FRAGMENT_ARGS = ":settings:fragment_args";
|
||||
@@ -236,7 +239,7 @@ public class SettingsActivity extends FragmentActivity
|
||||
/**
|
||||
* Finds the parent preference screen for the given target key.
|
||||
*
|
||||
* @param parent the parent preference screen
|
||||
* @param parent the parent preference screen
|
||||
* @param targetKey the key of the preference to find
|
||||
* @return the parent preference screen that contains the target preference
|
||||
*/
|
||||
@@ -286,13 +289,11 @@ public class SettingsActivity extends FragmentActivity
|
||||
* will remove that preference from the list.
|
||||
*/
|
||||
protected boolean initPreference(Preference preference) {
|
||||
DisplayController.Info info = DisplayController.INSTANCE.get(getContext()).getInfo();
|
||||
switch (preference.getKey()) {
|
||||
case NOTIFICATION_DOTS_PREFERENCE_KEY:
|
||||
return BuildConfig.NOTIFICATION_DOTS_ENABLED;
|
||||
|
||||
case ALLOW_ROTATION_PREFERENCE_KEY:
|
||||
DisplayController.Info info =
|
||||
DisplayController.INSTANCE.get(getContext()).getInfo();
|
||||
if (info.isTablet(info.realBounds)) {
|
||||
// Launcher supports rotation by default. No need to show this setting.
|
||||
return false;
|
||||
@@ -300,14 +301,29 @@ public class SettingsActivity extends FragmentActivity
|
||||
// Initialize the UI once
|
||||
preference.setDefaultValue(RotationHelper.getAllowRotationDefaultValue(info));
|
||||
return true;
|
||||
|
||||
case DEVELOPER_OPTIONS_KEY:
|
||||
if (IS_STUDIO_BUILD) {
|
||||
preference.setOrder(0);
|
||||
}
|
||||
return mDeveloperOptionsEnabled;
|
||||
case FIXED_LANDSCAPE_MODE:
|
||||
if (!Flags.oneGridSpecs()) {
|
||||
return false;
|
||||
}
|
||||
// When the setting changes rotate the screen accordingly to showcase the result
|
||||
// of the setting
|
||||
preference.setOnPreferenceChangeListener(
|
||||
(pref, newValue) -> {
|
||||
getActivity().setRequestedOrientation(
|
||||
(boolean) newValue
|
||||
? ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
|
||||
: ActivityInfo.SCREEN_ORIENTATION_USER
|
||||
);
|
||||
return true;
|
||||
}
|
||||
);
|
||||
return !info.isTablet(info.realBounds);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.android.launcher3.states;
|
||||
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LOCKED;
|
||||
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_NOSENSOR;
|
||||
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
|
||||
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE;
|
||||
import static android.util.DisplayMetrics.DENSITY_DEVICE_STABLE;
|
||||
|
||||
import static com.android.launcher3.LauncherPrefs.ALLOW_ROTATION;
|
||||
@@ -62,6 +63,7 @@ public class RotationHelper implements LauncherPrefChangeListener,
|
||||
public static final int REQUEST_NONE = 0;
|
||||
public static final int REQUEST_ROTATE = 1;
|
||||
public static final int REQUEST_LOCK = 2;
|
||||
public static final int REQUEST_FIXED_LANDSCAPE = 3;
|
||||
|
||||
@NonNull
|
||||
private final BaseActivity mActivity;
|
||||
@@ -195,7 +197,9 @@ public class RotationHelper implements LauncherPrefChangeListener,
|
||||
}
|
||||
|
||||
final int activityFlags;
|
||||
if (mStateHandlerRequest != REQUEST_NONE) {
|
||||
if (mStateHandlerRequest == REQUEST_FIXED_LANDSCAPE) {
|
||||
activityFlags = SCREEN_ORIENTATION_USER_LANDSCAPE;
|
||||
} else if (mStateHandlerRequest != REQUEST_NONE) {
|
||||
activityFlags = mStateHandlerRequest == REQUEST_LOCK ?
|
||||
SCREEN_ORIENTATION_LOCKED : SCREEN_ORIENTATION_UNSPECIFIED;
|
||||
} else if (mCurrentTransitionRequest != REQUEST_NONE) {
|
||||
|
||||
@@ -307,6 +307,7 @@ abstract class AbstractDeviceProfileTest {
|
||||
|
||||
whenever(launcherPrefs.get(LauncherPrefs.TASKBAR_PINNING)).thenReturn(false)
|
||||
whenever(launcherPrefs.get(LauncherPrefs.TASKBAR_PINNING_IN_DESKTOP_MODE)).thenReturn(true)
|
||||
whenever(launcherPrefs.get(LauncherPrefs.FIXED_LANDSCAPE_MODE)).thenReturn(false)
|
||||
whenever(launcherPrefs.get(LauncherPrefs.HOTSEAT_COUNT)).thenReturn(-1)
|
||||
whenever(launcherPrefs.get(LauncherPrefs.DEVICE_TYPE)).thenReturn(-1)
|
||||
whenever(launcherPrefs.get(LauncherPrefs.WORKSPACE_SIZE)).thenReturn("")
|
||||
|
||||
Reference in New Issue
Block a user