From 1e4f3976cd655fa8011c43160f0b102942eed597 Mon Sep 17 00:00:00 2001 From: Irfan Omur Date: Thu, 6 Apr 2023 05:54:24 +0300 Subject: [PATCH 01/14] Add POST_NOTIFICATIONS to AndroidManifest --- WordPress/src/main/AndroidManifest.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/WordPress/src/main/AndroidManifest.xml b/WordPress/src/main/AndroidManifest.xml index 97ad667775c6..b39f3cca8215 100644 --- a/WordPress/src/main/AndroidManifest.xml +++ b/WordPress/src/main/AndroidManifest.xml @@ -19,6 +19,7 @@ + From 3ecad02dc224678e0861aa96c83f43725d9fcf4f Mon Sep 17 00:00:00 2001 From: Irfan Omur Date: Thu, 6 Apr 2023 06:01:21 +0300 Subject: [PATCH 02/14] Add NotificationsPermissionBottomSheetFragment NotificationsPermissionBottomSheetFragment is a bottom sheet to navigate user to the App Settings. --- ...ificationsPermissionBottomSheetFragment.kt | 39 +++++++++++++ .../notifications_permission_bottom_sheet.xml | 57 +++++++++++++++++++ WordPress/src/main/res/values/strings.xml | 6 ++ WordPress/src/main/res/values/styles.xml | 53 ++++++++++------- 4 files changed, 133 insertions(+), 22 deletions(-) create mode 100644 WordPress/src/main/java/org/wordpress/android/ui/notifications/NotificationsPermissionBottomSheetFragment.kt create mode 100644 WordPress/src/main/res/layout/notifications_permission_bottom_sheet.xml diff --git a/WordPress/src/main/java/org/wordpress/android/ui/notifications/NotificationsPermissionBottomSheetFragment.kt b/WordPress/src/main/java/org/wordpress/android/ui/notifications/NotificationsPermissionBottomSheetFragment.kt new file mode 100644 index 000000000000..9ba6f79f6cf2 --- /dev/null +++ b/WordPress/src/main/java/org/wordpress/android/ui/notifications/NotificationsPermissionBottomSheetFragment.kt @@ -0,0 +1,39 @@ +package org.wordpress.android.ui.notifications + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import com.google.android.material.bottomsheet.BottomSheetBehavior +import com.google.android.material.bottomsheet.BottomSheetDialog +import com.google.android.material.bottomsheet.BottomSheetDialogFragment +import org.wordpress.android.R +import org.wordpress.android.databinding.NotificationsPermissionBottomSheetBinding +import org.wordpress.android.util.WPPermissionUtils + +class NotificationsPermissionBottomSheetFragment : BottomSheetDialogFragment() { + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ): View? = inflater.inflate(R.layout.notifications_permission_bottom_sheet, container) + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + + (dialog as? BottomSheetDialog)?.behavior?.state = BottomSheetBehavior.STATE_EXPANDED + with(NotificationsPermissionBottomSheetBinding.bind(view)) { + val appName = getString(R.string.app_name) + description.text = getString(R.string.notifications_permission_bottom_sheet_description_2, appName) + + primaryButton.setOnClickListener { + WPPermissionUtils.showNotificationsSettings(requireActivity()) + dismiss() + } + } + } + + companion object { + const val TAG = "NOTIFICATIONS_PERMISSION_BOTTOM_SHEET_FRAGMENT" + } +} diff --git a/WordPress/src/main/res/layout/notifications_permission_bottom_sheet.xml b/WordPress/src/main/res/layout/notifications_permission_bottom_sheet.xml new file mode 100644 index 000000000000..d1c52dbf057e --- /dev/null +++ b/WordPress/src/main/res/layout/notifications_permission_bottom_sheet.xml @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + diff --git a/WordPress/src/main/res/values/strings.xml b/WordPress/src/main/res/values/strings.xml index 7ab09264aede..bd884e301f84 100644 --- a/WordPress/src/main/res/values/strings.xml +++ b/WordPress/src/main/res/values/strings.xml @@ -1497,6 +1497,12 @@ Follows Likes + + Push notifications are turned off + You’ll need to open the app to see notifications. + Go to Settings → Notifications → App Settings, and turn %1$s on to be notified immediately. + Turn on notifications + Notification Settings On diff --git a/WordPress/src/main/res/values/styles.xml b/WordPress/src/main/res/values/styles.xml index 5dced5d17a6e..cc97e79f5e00 100644 --- a/WordPress/src/main/res/values/styles.xml +++ b/WordPress/src/main/res/values/styles.xml @@ -1571,6 +1571,33 @@ sans-serif + + + + + + + + + - + - + + - +