Making PS container tappable when locked.

Currently only the lock button in contianer
is tappable when PS is locked.
This change makes both the container and
button tappable.
In unlock state, the container is not tappable.

Bug: 313859437
Flag: ACONFIG com.android.launcher3.Flags.enable_private_space TRUNKFOOD
Test: Launcher3 test.
Change-Id: I1ae267d50a999e723932136dffa3ae8243d439c0
This commit is contained in:
Himanshu Gupta
2024-02-02 10:53:52 +00:00
parent ea73bf5d77
commit 65f1f81300
@@ -55,6 +55,9 @@ public class PrivateSpaceHeaderViewController {
assert quietModeButton != null;
addQuietModeButton(quietModeButton);
//Trigger lock/unlock action from header.
addHeaderOnClickListener(parent);
//Add image and action for private space settings button
ImageButton settingsButton = parent.findViewById(R.id.ps_settings_button);
assert settingsButton != null;
@@ -71,26 +74,35 @@ public class PrivateSpaceHeaderViewController {
case STATE_ENABLED -> {
quietModeButton.setVisibility(View.VISIBLE);
quietModeButton.setImageResource(R.drawable.bg_ps_lock_button);
quietModeButton.setOnClickListener(
view -> {
mPrivateProfileManager.logEvents(LAUNCHER_PRIVATE_SPACE_LOCK_TAP);
mPrivateProfileManager.lockPrivateProfile();
});
quietModeButton.setOnClickListener(view -> lockAction());
}
case STATE_DISABLED -> {
quietModeButton.setVisibility(View.VISIBLE);
quietModeButton.setImageResource(R.drawable.bg_ps_unlock_button);
quietModeButton.setOnClickListener(
view -> {
mPrivateProfileManager.logEvents(LAUNCHER_PRIVATE_SPACE_UNLOCK_TAP);
mPrivateProfileManager.unlockPrivateProfile((this::
onPrivateProfileUnlocked));
});
quietModeButton.setOnClickListener(view -> unLockAction());
}
default -> quietModeButton.setVisibility(View.GONE);
}
}
private void addHeaderOnClickListener(RelativeLayout header) {
if (mPrivateProfileManager.getCurrentState() == STATE_DISABLED) {
header.setOnClickListener(view -> unLockAction());
} else {
header.setOnClickListener(null);
}
}
private void unLockAction() {
mPrivateProfileManager.logEvents(LAUNCHER_PRIVATE_SPACE_UNLOCK_TAP);
mPrivateProfileManager.unlockPrivateProfile((this::onPrivateProfileUnlocked));
}
private void lockAction() {
mPrivateProfileManager.logEvents(LAUNCHER_PRIVATE_SPACE_LOCK_TAP);
mPrivateProfileManager.lockPrivateProfile();
}
private void addPrivateSpaceSettingsButton(ImageButton settingsButton) {
if (mPrivateProfileManager.getCurrentState() == STATE_ENABLED
&& mPrivateProfileManager.isPrivateSpaceSettingsAvailable()) {