Skip to content

Commit 51e6523

Browse files
committed
add fullscreen permission setting
Goal is that the call notification screen is shown without to unlock the phone. I encountered the following behavior: USE_FULL_SCREEN_INTENT is granted when running via debug in Android Studio. It is not granted when building the app and running the apk. So the unlock screen is shown instead when a call comes in. However google play console has a setting to allow USE_FULL_SCREEN_INTENT by default for this app, as it is a call app. Hopefully this will work and USE_FULL_SCREEN_INTENT is granted when installed via Google Play. However even if this works it might still make sense for the generic build variant and for f-droid to include this setting (or find another solution). Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
1 parent af319a8 commit 51e6523

4 files changed

Lines changed: 68 additions & 0 deletions

File tree

app/src/main/java/com/nextcloud/talk/conversationlist/ConversationsListActivity.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ package com.nextcloud.talk.conversationlist
88

99
import android.Manifest
1010
import android.annotation.SuppressLint
11+
import android.app.NotificationManager
1112
import android.content.ActivityNotFoundException
1213
import android.content.Intent
1314
import android.content.pm.PackageManager
@@ -913,6 +914,8 @@ class ConversationsListActivity : BaseActivity() {
913914
val notificationPermissionNotGranted = Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU &&
914915
!platformPermissionUtil.isPostNotificationsPermissionGranted()
915916
val batteryOptimizationNotIgnored = !PowerManagerUtils().isIgnoringBatteryOptimizations()
917+
val fullScreenIntentNotGranted = Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE &&
918+
!getSystemService(NotificationManager::class.java).canUseFullScreenIntent()
916919

917920
val messagesChannelNotEnabled = !NotificationUtils.isMessagesNotificationChannelEnabled(this)
918921
val callsChannelNotEnabled = !NotificationUtils.isCallsNotificationChannelEnabled(this)
@@ -922,6 +925,7 @@ class ConversationsListActivity : BaseActivity() {
922925

923926
val settingsOfUserAreWrong = notificationPermissionNotGranted ||
924927
batteryOptimizationNotIgnored ||
928+
fullScreenIntentNotGranted ||
925929
messagesChannelNotEnabled ||
926930
callsChannelNotEnabled ||
927931
!serverNotificationAppInstalled

app/src/main/java/com/nextcloud/talk/settings/SettingsActivity.kt

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import android.animation.Animator
1515
import android.animation.AnimatorListenerAdapter
1616
import android.annotation.SuppressLint
1717
import android.app.KeyguardManager
18+
import android.app.NotificationManager
1819
import android.content.Context
1920
import android.content.DialogInterface
2021
import android.content.Intent
@@ -432,6 +433,36 @@ class SettingsActivity :
432433
}
433434
}
434435

436+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
437+
val notificationManager = getSystemService(NotificationManager::class.java)
438+
if (notificationManager.canUseFullScreenIntent()) {
439+
binding.fullScreenIntentPermissionSubtitle.text =
440+
resources.getString(R.string.full_screen_intent_permission_granted)
441+
binding.fullScreenIntentPermissionSubtitle.setTextColor(
442+
resources.getColor(R.color.high_emphasis_text, null)
443+
)
444+
} else {
445+
binding.fullScreenIntentPermissionSubtitle.text =
446+
resources.getString(R.string.full_screen_intent_permission_not_granted)
447+
binding.fullScreenIntentPermissionSubtitle.setTextColor(
448+
resources.getColor(R.color.nc_darkRed, null)
449+
)
450+
451+
if (openedByNotificationWarning) {
452+
DrawableUtils.blinkDrawable(binding.settingsFullScreenIntentWrapper.background)
453+
}
454+
455+
binding.settingsFullScreenIntentWrapper.setOnClickListener {
456+
val intent = Intent(Settings.ACTION_MANAGE_APP_USE_FULL_SCREEN_INTENT).apply {
457+
data = "package:$packageName".toUri()
458+
}
459+
startActivity(intent)
460+
}
461+
}
462+
} else {
463+
binding.settingsFullScreenIntentWrapper.visibility = View.GONE
464+
}
465+
435466
// handle notification permission on API level >= 33
436467
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
437468
if (platformPermissionUtil.isPostNotificationsPermissionGranted()) {
@@ -572,15 +603,24 @@ class SettingsActivity :
572603
)
573604
}
574605

606+
val canUseFullScreenIntent = Build.VERSION.SDK_INT < Build.VERSION_CODES.UPSIDE_DOWN_CAKE ||
607+
getSystemService(NotificationManager::class.java).canUseFullScreenIntent()
608+
575609
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
576610
if (platformPermissionUtil.isPostNotificationsPermissionGranted() &&
577611
PowerManagerUtils().isIgnoringBatteryOptimizations()
578612
) {
579613
binding.settingsNotificationsPermissionWrapper.setOnClickListener { click() }
580614
binding.settingsBatteryOptimizationWrapper.setOnClickListener { click() }
615+
if (canUseFullScreenIntent) {
616+
binding.settingsFullScreenIntentWrapper.setOnClickListener { click() }
617+
}
581618
}
582619
} else if (PowerManagerUtils().isIgnoringBatteryOptimizations()) {
583620
binding.settingsBatteryOptimizationWrapper.setOnClickListener { click() }
621+
if (canUseFullScreenIntent) {
622+
binding.settingsFullScreenIntentWrapper.setOnClickListener { click() }
623+
}
584624
}
585625
}
586626

app/src/main/res/layout/activity_settings.xml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,27 @@
373373
tools:text="@string/battery_optimization_ignored"/>
374374
</LinearLayout>
375375

376+
<LinearLayout
377+
android:id="@+id/settings_full_screen_intent_wrapper"
378+
android:layout_width="match_parent"
379+
android:layout_height="wrap_content"
380+
android:background="?android:attr/selectableItemBackground"
381+
android:orientation="vertical"
382+
android:padding="@dimen/standard_padding">
383+
384+
<com.google.android.material.textview.MaterialTextView
385+
android:layout_width="wrap_content"
386+
android:layout_height="wrap_content"
387+
android:text="@string/full_screen_intent_permission_title"
388+
android:textSize="@dimen/headline_text_size" />
389+
390+
<com.google.android.material.textview.MaterialTextView
391+
android:id="@+id/full_screen_intent_permission_subtitle"
392+
android:layout_width="wrap_content"
393+
android:layout_height="wrap_content"
394+
tools:text="@string/full_screen_intent_permission_granted" />
395+
</LinearLayout>
396+
376397
</LinearLayout>
377398

378399
<LinearLayout

app/src/main/res/values/strings.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ How to translate with transifex:
123123
<string name="battery_optimization_not_ignored">Battery optimization is enabled which might cause issues. You should disable battery optimization!</string>
124124
<string name="battery_optimization_ignored">Battery optimization is ignored, all fine</string>
125125
<string name="notification_permission">Notification permissions</string>
126+
<string name="full_screen_intent_permission_title">Show incoming call screen</string>
127+
<string name="full_screen_intent_permission_granted">Incoming call screen over lock screen is granted, all fine</string>
128+
<string name="full_screen_intent_permission_not_granted">Incoming call screen over lock screen is not granted. Please grant this so incoming calls appear on the lock screen!</string>
126129

127130

128131
<string name="nc_settings_appearance">Appearance</string>

0 commit comments

Comments
 (0)