Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 95a8b526 authored by Jagrut Desai's avatar Jagrut Desai
Browse files

Adding Support for Change Navigation Mode Taskbar Divider Menu Option

Invoking setting app with going navigation mode fragment upon clicking "Change navigation mode" from Taskbar Divider menu.

Test: manual
Bug: 279084093
Flag: ENABLE_TASKBAR_PINNING
Change-Id: I17b109231e68459934a5658d74c0061254c7f7a6
parent c6d625b8
Loading
Loading
Loading
Loading
+15 −8
Original line number Diff line number Diff line
@@ -38,10 +38,17 @@ class TaskbarDividerPopupController(private val context: TaskbarActivityContext)
        view.post {
            val popupView = createAndPopulate(view, context)
            popupView.requestFocus()
            popupView.onCloseCallback = {
                context.onPopupVisibilityChanged(false)

            popupView.onCloseCallback =
                callback@{ didPreferenceChange ->
                    context.dragLayer.post { context.onPopupVisibilityChanged(false) }

                    if (!didPreferenceChange) {
                        return@callback
                    }

                    if (launcherPrefs.get(TASKBAR_PINNING)) {
                    animateTransientToPersistentTaskBar()
                        animateTransientToPersistentTaskbar()
                    } else {
                        animatePersistentToTransientTaskbar()
                    }
@@ -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() {}
+15 −4
Original line number Diff line number Diff line
@@ -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()
    }