Skip to content

Commit

Permalink
Add preference for giving SYSTEM_ALERT_WINDOW permission
Browse files Browse the repository at this point in the history
  • Loading branch information
cyb3rko committed Oct 3, 2023
1 parent b85ce16 commit 9fbb475
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
12 changes: 12 additions & 0 deletions app/src/main/kotlin/com/github/gotify/settings/SettingsActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import android.content.DialogInterface
import android.content.Intent
import android.content.SharedPreferences
import android.content.SharedPreferences.OnSharedPreferenceChangeListener
import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.view.MenuItem
Expand Down Expand Up @@ -97,6 +98,17 @@ internal class SettingsActivity : AppCompatActivity(), OnSharedPreferenceChangeL
Utils.setExcludeFromRecent(requireContext(), value as Boolean)
return@OnPreferenceChangeListener true
}
findPreference<Preference>(
getString(R.string.setting_key_intent_dialog_permission)
)?.setOnPreferenceClickListener {
Intent(
android.provider.Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
Uri.parse("package:${requireContext().packageName}")
).apply {
startActivity(this)
}
true
}
}

override fun onDisplayPreferenceDialog(preference: Preference) {
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@
<string name="setting_key_notification_channels">notification_channels</string>
<string name="setting_key_exclude_from_recent">exclude_from_recent</string>
<string name="setting_exclude_from_recent">Exclude from recents</string>
<string name="setting_intent_dialog_permission">Intent Action Permission</string>
<string name="setting_key_intent_dialog_permission">intent_dialog_permission</string>
<string name="setting_summary_intent_dialog_permission">To always show incoming intent URLs, give permission to show this app on top of other apps.</string>
<string name="push_message">Push message</string>
<string name="appListDescription">App:</string>
<string name="priorityDescription">Priority:</string>
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/xml/root_preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@
android:key="@string/setting_key_notification_channels"
android:title="@string/setting_notification_channels"
app:singleLineTitle="false" />

<Preference
android:key="@string/setting_key_intent_dialog_permission"
android:title="@string/setting_intent_dialog_permission"
android:summary="@string/setting_summary_intent_dialog_permission" />
</PreferenceCategory>

</PreferenceScreen>

0 comments on commit 9fbb475

Please sign in to comment.