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

Commit 7250ff26 authored by Steven Ng's avatar Steven Ng Committed by Android (Google) Code Review
Browse files

Merge "Show a toast upon stylus button click or keyboard shortcut when the...

Merge "Show a toast upon stylus button click or keyboard shortcut when the default note app is set to none." into udc-dev
parents 21cb4246 86328aff
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -3086,4 +3086,7 @@

    <!-- Content description for when assistant attention is active [CHAR LIMIT=NONE] -->
    <string name="assistant_attention_content_description">Assistant attention on</string>

    <!--- Content of toast triggered when the notes app entry point is triggered without setting a default notes app. [CHAR LIMIT=NONE] -->
    <string name="set_default_notes_app_toast_content">Set default notes app in Settings</string>
</resources>
+15 −1
Original line number Diff line number Diff line
@@ -34,7 +34,9 @@ import android.os.Build
import android.os.UserHandle
import android.os.UserManager
import android.util.Log
import android.widget.Toast
import androidx.annotation.VisibleForTesting
import com.android.systemui.R
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.devicepolicy.areKeyguardShortcutsDisabled
import com.android.systemui.notetask.NoteTaskRoleManagerExt.createNoteShortcutInfoAsUser
@@ -170,7 +172,13 @@ constructor(
            return
        }

        val info = resolver.resolveInfo(entryPoint, isKeyguardLocked) ?: return
        val info = resolver.resolveInfo(entryPoint, isKeyguardLocked)

        if (info == null) {
            logDebug { "Default notes app isn't set" }
            showNoDefaultNotesAppToast()
            return
        }

        infoReference.set(info)

@@ -207,6 +215,12 @@ constructor(
        logDebug { "onShowNoteTask - completed: $info" }
    }

    @VisibleForTesting
    fun showNoDefaultNotesAppToast() {
        Toast.makeText(context, R.string.set_default_notes_app_toast_content, Toast.LENGTH_SHORT)
            .show()
    }

    /**
     * Set `android:enabled` property in the `AndroidManifest` associated with the Shortcut
     * component to [value].
+8 −5
Original line number Diff line number Diff line
@@ -63,8 +63,10 @@ import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.ArgumentMatchers.anyInt
import org.mockito.Mock
import org.mockito.Mockito.doNothing
import org.mockito.Mockito.isNull
import org.mockito.Mockito.never
import org.mockito.Mockito.spy
import org.mockito.Mockito.verify
import org.mockito.Mockito.verifyZeroInteractions
import org.mockito.MockitoAnnotations
@@ -109,6 +111,7 @@ internal class NoteTaskControllerTest : SysuiTestCase() {
            .thenReturn(listOf(NOTE_TASK_PACKAGE_NAME))
        whenever(activityManager.getRunningTasks(anyInt())).thenReturn(emptyList())
        whenever(userManager.isManagedProfile(workUserInfo.id)).thenReturn(true)
        whenever(context.resources).thenReturn(getContext().resources)
    }

    private fun createNoteTaskController(
@@ -339,14 +342,14 @@ internal class NoteTaskControllerTest : SysuiTestCase() {
    }

    @Test
    fun showNoteTask_intentResolverReturnsNull_shouldDoNothing() {
    fun showNoteTask_intentResolverReturnsNull_shouldShowToast() {
        whenever(resolver.resolveInfo(any(), any())).thenReturn(null)
        val noteTaskController = spy(createNoteTaskController())
        doNothing().whenever(noteTaskController).showNoDefaultNotesAppToast()

        createNoteTaskController()
            .showNoteTask(
                entryPoint = NoteTaskEntryPoint.TAIL_BUTTON,
            )
        noteTaskController.showNoteTask(entryPoint = NoteTaskEntryPoint.TAIL_BUTTON)

        verify(noteTaskController).showNoDefaultNotesAppToast()
        verifyZeroInteractions(context, bubbles, eventLogger)
    }