mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-20 11:18:21 +00:00
Merge "Adding Support for Change Navigation Mode Taskbar Divider Menu Option" into udc-dev
This commit is contained in:
@@ -38,14 +38,21 @@ class TaskbarDividerPopupController(private val context: TaskbarActivityContext)
|
||||
view.post {
|
||||
val popupView = createAndPopulate(view, context)
|
||||
popupView.requestFocus()
|
||||
popupView.onCloseCallback = {
|
||||
context.onPopupVisibilityChanged(false)
|
||||
if (launcherPrefs.get(TASKBAR_PINNING)) {
|
||||
animateTransientToPersistentTaskBar()
|
||||
} else {
|
||||
animatePersistentToTransientTaskbar()
|
||||
|
||||
popupView.onCloseCallback =
|
||||
callback@{ didPreferenceChange ->
|
||||
context.dragLayer.post { context.onPopupVisibilityChanged(false) }
|
||||
|
||||
if (!didPreferenceChange) {
|
||||
return@callback
|
||||
}
|
||||
|
||||
if (launcherPrefs.get(TASKBAR_PINNING)) {
|
||||
animateTransientToPersistentTaskbar()
|
||||
} else {
|
||||
animatePersistentToTransientTaskbar()
|
||||
}
|
||||
}
|
||||
}
|
||||
popupView.changePreference = {
|
||||
launcherPrefs.put(TASKBAR_PINNING, !launcherPrefs.get(TASKBAR_PINNING))
|
||||
}
|
||||
@@ -55,7 +62,7 @@ class TaskbarDividerPopupController(private val context: TaskbarActivityContext)
|
||||
}
|
||||
|
||||
// TODO(b/265436799): provide animation/transition from transient taskbar to persistent one
|
||||
private fun animateTransientToPersistentTaskBar() {}
|
||||
private fun animateTransientToPersistentTaskbar() {}
|
||||
|
||||
// TODO(b/265436799): provide animation/transition from persistent taskbar to transient one
|
||||
private fun animatePersistentToTransientTaskbar() {}
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.android.launcher3.taskbar
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.graphics.Rect
|
||||
import android.util.AttributeSet
|
||||
import android.view.Gravity
|
||||
@@ -42,6 +43,9 @@ constructor(
|
||||
companion object {
|
||||
private const val TAG = "TaskbarDividerPopupView"
|
||||
private const val DIVIDER_POPUP_CLOSING_DELAY = 500L
|
||||
private const val SETTINGS_PACKAGE_NAME = "com.android.settings"
|
||||
private const val CHANGE_NAVIGATION_MODE_ACTION =
|
||||
"com.android.settings.NAVIGATION_MODE_SETTINGS"
|
||||
|
||||
@JvmStatic
|
||||
fun createAndPopulate(
|
||||
@@ -71,7 +75,7 @@ constructor(
|
||||
private var didPreferenceChange = false
|
||||
|
||||
/** Callback invoked when the pinning popup view is closing. */
|
||||
var onCloseCallback: () -> Unit = {}
|
||||
var onCloseCallback: (preferenceChanged: Boolean) -> Unit = {}
|
||||
|
||||
/**
|
||||
* Callback invoked when the user preference changes in popup view. Preference change will be
|
||||
@@ -98,12 +102,21 @@ constructor(
|
||||
super.onFinishInflate()
|
||||
val taskbarSwitchOption = findViewById<LinearLayout>(R.id.taskbar_switch_option)
|
||||
val alwaysShowTaskbarSwitch = findViewById<Switch>(R.id.taskbar_pinning_switch)
|
||||
val navigationModeChangeOption =
|
||||
findViewById<LinearLayout>(R.id.navigation_mode_switch_option)
|
||||
alwaysShowTaskbarSwitch.isChecked = alwaysShowTaskbarOn
|
||||
taskbarSwitchOption.setOnClickListener {
|
||||
alwaysShowTaskbarSwitch.isClickable = true
|
||||
alwaysShowTaskbarSwitch.isChecked = !alwaysShowTaskbarOn
|
||||
onClickAlwaysShowTaskbarSwitchOption()
|
||||
}
|
||||
navigationModeChangeOption.setOnClickListener {
|
||||
context.startActivity(
|
||||
Intent(CHANGE_NAVIGATION_MODE_ACTION)
|
||||
.setPackage(SETTINGS_PACKAGE_NAME)
|
||||
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/** Orient object as usual and then center object horizontally. */
|
||||
@@ -156,9 +169,7 @@ constructor(
|
||||
}
|
||||
|
||||
override fun closeComplete() {
|
||||
if (didPreferenceChange) {
|
||||
onCloseCallback()
|
||||
}
|
||||
onCloseCallback(didPreferenceChange)
|
||||
super.closeComplete()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user