-
Notifications
You must be signed in to change notification settings - Fork 410
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature] Request notification permission and target Android 13.
Fixes: #998
- Loading branch information
Showing
11 changed files
with
177 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...roid/files/filelist/ShowRequestNotificationPermissionInSettingsRationaleDialogFragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright (c) 2023 Hai Zhang <dreaming.in.code.zh@gmail.com> | ||
* All Rights Reserved. | ||
*/ | ||
|
||
package me.zhanghai.android.files.filelist | ||
|
||
import android.app.Dialog | ||
import android.os.Bundle | ||
import androidx.appcompat.app.AppCompatDialogFragment | ||
import androidx.fragment.app.Fragment | ||
import com.google.android.material.dialog.MaterialAlertDialogBuilder | ||
import me.zhanghai.android.files.R | ||
import me.zhanghai.android.files.util.show | ||
|
||
class ShowRequestNotificationPermissionInSettingsRationaleDialogFragment : AppCompatDialogFragment() { | ||
private val listener: Listener | ||
get() = requireParentFragment() as Listener | ||
|
||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { | ||
return MaterialAlertDialogBuilder(requireContext(), theme) | ||
.setMessage(R.string.notification_permission_rationale_message) | ||
.setPositiveButton(R.string.open_settings) { _, _ -> | ||
listener.requestNotificationPermissionInSettings() | ||
} | ||
.setNegativeButton(android.R.string.cancel, null) | ||
.create() | ||
} | ||
|
||
companion object { | ||
fun show(fragment: Fragment) { | ||
ShowRequestNotificationPermissionInSettingsRationaleDialogFragment().show(fragment) | ||
} | ||
} | ||
|
||
interface Listener { | ||
fun requestNotificationPermissionInSettings() | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
...anghai/android/files/filelist/ShowRequestNotificationPermissionRationaleDialogFragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright (c) 2023 Hai Zhang <dreaming.in.code.zh@gmail.com> | ||
* All Rights Reserved. | ||
*/ | ||
|
||
package me.zhanghai.android.files.filelist | ||
|
||
import android.app.Dialog | ||
import android.os.Bundle | ||
import androidx.appcompat.app.AppCompatDialogFragment | ||
import androidx.fragment.app.Fragment | ||
import com.google.android.material.dialog.MaterialAlertDialogBuilder | ||
import me.zhanghai.android.files.R | ||
import me.zhanghai.android.files.util.show | ||
|
||
class ShowRequestNotificationPermissionRationaleDialogFragment : AppCompatDialogFragment() { | ||
private val listener: Listener | ||
get() = requireParentFragment() as Listener | ||
|
||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { | ||
return MaterialAlertDialogBuilder(requireContext(), theme) | ||
.setMessage(R.string.notification_permission_rationale_message) | ||
.setPositiveButton(android.R.string.ok) { _, _ -> | ||
listener.requestNotificationPermission() | ||
} | ||
.setNegativeButton(android.R.string.cancel, null) | ||
.create() | ||
} | ||
|
||
companion object { | ||
fun show(fragment: Fragment) { | ||
ShowRequestNotificationPermissionRationaleDialogFragment().show(fragment) | ||
} | ||
} | ||
|
||
interface Listener { | ||
fun requestNotificationPermission() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters