@@ -146,7 +146,7 @@ internal fun PhotoReasoningRoute(
146146
147147 // Hoisted: var showNotificationRationaleDialog by rememberSaveable { mutableStateOf(false) }
148148 // This state will now be managed in PhotoReasoningRoute and passed down.
149- var showNotificationRationaleDialogStateInRoute by rememberSaveable { mutableStateOf(false ) }
149+ // var showNotificationRationaleDialogStateInRoute by rememberSaveable { mutableStateOf(false) } // Removed
150150
151151
152152 val coroutineScope = rememberCoroutineScope()
@@ -208,8 +208,8 @@ internal fun PhotoReasoningRoute(
208208 },
209209 isKeyboardOpen = isKeyboardOpen,
210210 onStopClicked = { viewModel.onStopClicked() },
211- showNotificationRationaleDialog = showNotificationRationaleDialogStateInRoute,
212- onShowNotificationRationaleDialogChange = { showNotificationRationaleDialogStateInRoute = it },
211+ // showNotificationRationaleDialog = showNotificationRationaleDialogStateInRoute, // Removed
212+ // onShowNotificationRationaleDialogChange = { showNotificationRationaleDialogStateInRoute = it }, // Removed
213213 isInitialized = isInitialized // Pass the collected state
214214 )
215215}
@@ -228,8 +228,8 @@ fun PhotoReasoningScreen(
228228 onClearChatHistory : () -> Unit = {},
229229 isKeyboardOpen : Boolean ,
230230 onStopClicked : () -> Unit = {},
231- showNotificationRationaleDialog : Boolean , // New parameter
232- onShowNotificationRationaleDialogChange : (Boolean ) -> Unit , // New parameter
231+ // showNotificationRationaleDialog: Boolean, // Removed
232+ // onShowNotificationRationaleDialogChange: (Boolean) -> Unit, // Removed
233233 isInitialized : Boolean = true // Added parameter with default for preview
234234) {
235235 var userQuestion by rememberSaveable { mutableStateOf(" " ) }
@@ -363,37 +363,14 @@ fun PhotoReasoningScreen(
363363 modifier = Modifier .weight(1f ).padding(end = 8 .dp)
364364 )
365365 IconButton (onClick = {
366- val activity = context as ? MainActivity
367- if (activity != null && ! activity.isNotificationPermissionGranted()) {
368- if (! activity.hasShownNotificationRationale()) {
369- onShowNotificationRationaleDialogChange(true ) // Use new callback
370- } else {
371- // Rationale already shown, or user previously denied.
372- // Directly request permission or decide if reasoning should be blocked.
373- // For now, let's request again. System handles "don't ask again".
374- activity.requestNotificationPermission()
375- // Optionally, delay onReasonClicked until permission result,
376- // but for now, let it proceed as notification is a value-add.
377- if (isAccessibilityServiceEnabled) {
378- if (userQuestion.isNotBlank()) {
379- onReasonClicked(userQuestion, imageUris.toList())
380- userQuestion = " "
381- }
382- } else {
383- onEnableAccessibilityService()
384- Toast .makeText(context, " Enable the Accessibility service for Screen Operator" , Toast .LENGTH_LONG ).show()
385- }
386- }
387- } else { // Permission granted or not needed (older OS)
388- if (isAccessibilityServiceEnabled) {
389- if (userQuestion.isNotBlank()) {
390- onReasonClicked(userQuestion, imageUris.toList())
391- userQuestion = " "
392- }
393- } else {
394- onEnableAccessibilityService()
395- Toast .makeText(context, " Enable the Accessibility service for Screen Operator" , Toast .LENGTH_LONG ).show()
366+ if (isAccessibilityServiceEnabled) {
367+ if (userQuestion.isNotBlank()) {
368+ onReasonClicked(userQuestion, imageUris.toList())
369+ userQuestion = " "
396370 }
371+ } else {
372+ onEnableAccessibilityService()
373+ Toast .makeText(context, " Enable the Accessibility service for Screen Operator" , Toast .LENGTH_LONG ).show()
397374 }
398375 },
399376 enabled = isInitialized && isAccessibilityServiceEnabled && userQuestion.isNotBlank(), // Modified enabled state
@@ -493,40 +470,7 @@ fun PhotoReasoningScreen(
493470 }
494471 }
495472
496- if (showNotificationRationaleDialog) { // Use new parameter
497- AlertDialog (
498- onDismissRequest = { onShowNotificationRationaleDialogChange(false ) }, // Use new callback
499- title = { Text (" Notification Permission" ) },
500- text = { Text (" You can grant notification permission if you want to be able to stop Screen Operator via notifications." ) },
501- confirmButton = {
502- TextButton (
503- onClick = {
504- onShowNotificationRationaleDialogChange(false ) // Use new callback
505- val activity = context as ? MainActivity
506- activity?.setNotificationRationaleShown(true )
507- activity?.requestNotificationPermission()
508- // Proceed with reasonClicked after user acknowledges rationale and permission is requested
509- // This is a choice: either proceed or wait for permission result.
510- // For simplicity and as it's a value-add, let's allow proceeding.
511- if (isAccessibilityServiceEnabled) {
512- if (userQuestion.isNotBlank()) { // Check again, user might have cleared it
513- onReasonClicked(userQuestion, imageUris.toList())
514- userQuestion = " "
515- }
516- } else {
517- onEnableAccessibilityService()
518- Toast .makeText(context, " Enable the Accessibility service for Screen Operator" , Toast .LENGTH_LONG ).show()
519- }
520- }
521- ) {
522- Text (" OK" )
523- }
524- },
525- dismissButton = {
526- TextButton (onClick = { onShowNotificationRationaleDialogChange(false ) }) { Text (" Cancel" ) } // Use new callback
527- }
528- )
529- }
473+ // Removed AlertDialog for notification rationale
530474}
531475
532476@Composable
@@ -1069,8 +1013,6 @@ fun PhotoReasoningScreenPreviewWithContent() {
10691013 ),
10701014 isKeyboardOpen = false ,
10711015 onStopClicked = {},
1072- showNotificationRationaleDialog = false ,
1073- onShowNotificationRationaleDialogChange = {},
10741016 isInitialized = true
10751017 )
10761018 }
@@ -1173,8 +1115,6 @@ fun PhotoReasoningScreenPreviewEmpty() {
11731115 PhotoReasoningScreen (
11741116 isKeyboardOpen = false ,
11751117 onStopClicked = {},
1176- showNotificationRationaleDialog = false ,
1177- onShowNotificationRationaleDialogChange = {},
11781118 isInitialized = true
11791119 )
11801120 }
0 commit comments