Merge "Show a toast upon stylus button click or keyboard shortcut when the default note app is set to none." into udc-dev

This commit is contained in:
Steven Ng
2023-04-13 15:35:34 +00:00
committed by Android (Google) Code Review
3 changed files with 26 additions and 6 deletions

View File

@@ -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>

View File

@@ -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].

View File

@@ -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)
}