Hide navigation hint checkbox when taskbar is enabled

Change-Id: Idb29572be5f5b070f71d90889a5ad150a222206b
This commit is contained in:
Michael Bestas
2023-07-15 16:19:36 +03:00
parent eecf4a91ad
commit a5ba5dfaad
2 changed files with 28 additions and 6 deletions

View File

@@ -35,6 +35,7 @@ android_app {
"SettingsLib", "SettingsLib",
"setupcompat", "setupcompat",
"setupdesign", "setupdesign",
"SystemUISharedLib",
"org.lineageos.platform.internal", "org.lineageos.platform.internal",
], ],

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2022 The LineageOS Project * Copyright (C) 2022-2023 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -20,6 +20,8 @@ import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_2BUTTON_OVE
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON_OVERLAY; import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON_OVERLAY;
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL_OVERLAY; import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL_OVERLAY;
import static com.android.systemui.shared.recents.utilities.Utilities.isLargeScreen;
import static org.lineageos.internal.util.DeviceKeysConstants.KEY_MASK_APP_SWITCH; import static org.lineageos.internal.util.DeviceKeysConstants.KEY_MASK_APP_SWITCH;
import static org.lineageos.setupwizard.SetupWizardApp.DISABLE_NAV_KEYS; import static org.lineageos.setupwizard.SetupWizardApp.DISABLE_NAV_KEYS;
import static org.lineageos.setupwizard.SetupWizardApp.NAVIGATION_OPTION_KEY; import static org.lineageos.setupwizard.SetupWizardApp.NAVIGATION_OPTION_KEY;
@@ -50,6 +52,8 @@ public class NavigationSettingsActivity extends BaseSetupWizardActivity {
private SetupWizardApp mSetupWizardApp; private SetupWizardApp mSetupWizardApp;
private boolean mIsTaskbarEnabled;
private String mSelection = NAV_BAR_MODE_GESTURAL_OVERLAY; private String mSelection = NAV_BAR_MODE_GESTURAL_OVERLAY;
private CheckBox mHideGesturalHint; private CheckBox mHideGesturalHint;
@@ -63,6 +67,8 @@ public class NavigationSettingsActivity extends BaseSetupWizardActivity {
if (mSetupWizardApp.getSettingsBundle().containsKey(DISABLE_NAV_KEYS)) { if (mSetupWizardApp.getSettingsBundle().containsKey(DISABLE_NAV_KEYS)) {
navBarEnabled = mSetupWizardApp.getSettingsBundle().getBoolean(DISABLE_NAV_KEYS); navBarEnabled = mSetupWizardApp.getSettingsBundle().getBoolean(DISABLE_NAV_KEYS);
} }
mIsTaskbarEnabled = LineageSettings.System.getInt(getContentResolver(),
LineageSettings.System.ENABLE_TASKBAR, isLargeScreen(this) ? 1 : 0) == 1;
int deviceKeys = getResources().getInteger( int deviceKeys = getResources().getInteger(
org.lineageos.platform.internal.R.integer.config_deviceHardwareKeys); org.lineageos.platform.internal.R.integer.config_deviceHardwareKeys);
@@ -89,7 +95,6 @@ public class NavigationSettingsActivity extends BaseSetupWizardActivity {
available--; available--;
} }
// Hide this page if the device has hardware keys but didn't enable navbar // Hide this page if the device has hardware keys but didn't enable navbar
// or if there's <= 1 available navigation modes // or if there's <= 1 available navigation modes
if (!navBarEnabled && hasHomeKey || available <= 1) { if (!navBarEnabled && hasHomeKey || available <= 1) {
@@ -103,6 +108,12 @@ public class NavigationSettingsActivity extends BaseSetupWizardActivity {
findViewById(R.id.navigation_illustration); findViewById(R.id.navigation_illustration);
final RadioGroup radioGroup = findViewById(R.id.navigation_radio_group); final RadioGroup radioGroup = findViewById(R.id.navigation_radio_group);
mHideGesturalHint = findViewById(R.id.hide_navigation_hint); mHideGesturalHint = findViewById(R.id.hide_navigation_hint);
// Hide navigation hint checkbox when taskbar is enabled
if (mIsTaskbarEnabled) {
mHideGesturalHint.setVisibility(View.GONE);
}
radioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() { radioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(RadioGroup group, int checkedId) { public void onCheckedChanged(RadioGroup group, int checkedId) {
@@ -131,6 +142,10 @@ public class NavigationSettingsActivity extends BaseSetupWizardActivity {
} }
private void revealHintCheckbox() { private void revealHintCheckbox() {
if (mIsTaskbarEnabled) {
return;
}
mHideGesturalHint.animate().cancel(); mHideGesturalHint.animate().cancel();
if (mHideGesturalHint.getVisibility() == View.VISIBLE) { if (mHideGesturalHint.getVisibility() == View.VISIBLE) {
@@ -146,6 +161,10 @@ public class NavigationSettingsActivity extends BaseSetupWizardActivity {
} }
private void hideHintCheckBox() { private void hideHintCheckBox() {
if (mIsTaskbarEnabled) {
return;
}
if (mHideGesturalHint.getVisibility() == View.INVISIBLE) { if (mHideGesturalHint.getVisibility() == View.INVISIBLE) {
return; return;
} }
@@ -165,10 +184,12 @@ public class NavigationSettingsActivity extends BaseSetupWizardActivity {
@Override @Override
protected void onNextPressed() { protected void onNextPressed() {
mSetupWizardApp.getSettingsBundle().putString(NAVIGATION_OPTION_KEY, mSelection); mSetupWizardApp.getSettingsBundle().putString(NAVIGATION_OPTION_KEY, mSelection);
boolean hideHint = mHideGesturalHint.isChecked(); if (!mIsTaskbarEnabled) {
LineageSettings.System.putIntForUser(getContentResolver(), boolean hideHint = mHideGesturalHint.isChecked();
LineageSettings.System.NAVIGATION_BAR_HINT, hideHint ? 0 : 1, LineageSettings.System.putIntForUser(getContentResolver(),
UserHandle.USER_CURRENT); LineageSettings.System.NAVIGATION_BAR_HINT, hideHint ? 0 : 1,
UserHandle.USER_CURRENT);
}
Intent intent = WizardManagerHelper.getNextIntent(getIntent(), Activity.RESULT_OK); Intent intent = WizardManagerHelper.getNextIntent(getIntent(), Activity.RESULT_OK);
nextAction(NEXT_REQUEST, intent); nextAction(NEXT_REQUEST, intent);
} }