Bug 1874388 - Remove unused notification pre prompt
parent
5d0b4517d6
commit
ab56ebe21c
@ -1,64 +0,0 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package org.mozilla.fenix.onboarding
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.pm.ActivityInfo
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.compose.ui.platform.ComposeView
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.ext.requireComponents
|
||||
import org.mozilla.fenix.ext.settings
|
||||
import org.mozilla.fenix.onboarding.view.NotificationPermissionDialogScreen
|
||||
import org.mozilla.fenix.theme.FirefoxTheme
|
||||
|
||||
/**
|
||||
* Dialog displaying notification pre-permission prompt.
|
||||
*/
|
||||
class HomeNotificationPermissionDialogFragment : DialogFragment() {
|
||||
|
||||
@SuppressLint("SourceLockedOrientationActivity")
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setStyle(STYLE_NO_TITLE, R.style.HomeOnboardingDialogStyle)
|
||||
activity?.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
activity?.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.TIRAMISU)
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?,
|
||||
): View = ComposeView(requireContext()).apply {
|
||||
setContent {
|
||||
FirefoxTheme {
|
||||
NotificationPermissionDialogScreen(
|
||||
onDismiss = ::onDismiss,
|
||||
grantNotificationPermission = {
|
||||
ensureMarketingChannelExists(context.applicationContext)
|
||||
requireComponents.notificationsDelegate.requestNotificationPermission()
|
||||
onDismiss()
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun onDismiss() {
|
||||
dismiss()
|
||||
context?.settings()?.isNotificationPrePermissionShown = true
|
||||
}
|
||||
}
|
@ -1,75 +0,0 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package org.mozilla.fenix.onboarding.view
|
||||
|
||||
import androidx.compose.foundation.layout.navigationBarsPadding
|
||||
import androidx.compose.foundation.layout.statusBarsPadding
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import mozilla.components.service.glean.private.NoExtras
|
||||
import org.mozilla.fenix.GleanMetrics.Onboarding
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.compose.annotation.LightDarkPreview
|
||||
import org.mozilla.fenix.theme.FirefoxTheme
|
||||
|
||||
/**
|
||||
* A screen for displaying notification pre permission prompt.
|
||||
*
|
||||
* @param onDismiss Invoked when the user clicks on the close or the negative button.
|
||||
* @param grantNotificationPermission Invoked when the user clicks on the positive button.
|
||||
*/
|
||||
@Composable
|
||||
fun NotificationPermissionDialogScreen(
|
||||
onDismiss: () -> Unit,
|
||||
grantNotificationPermission: () -> Unit,
|
||||
) {
|
||||
OnboardingPage(
|
||||
pageState = OnboardingPageState(
|
||||
imageRes = R.drawable.ic_notification_permission,
|
||||
title = stringResource(
|
||||
id = R.string.onboarding_home_enable_notifications_title,
|
||||
formatArgs = arrayOf(stringResource(R.string.app_name)),
|
||||
),
|
||||
description = stringResource(
|
||||
id = R.string.onboarding_home_enable_notifications_description,
|
||||
formatArgs = arrayOf(stringResource(R.string.app_name)),
|
||||
),
|
||||
primaryButton = Action(
|
||||
text = stringResource(id = R.string.onboarding_home_enable_notifications_positive_button),
|
||||
onClick = {
|
||||
grantNotificationPermission()
|
||||
Onboarding.notifPppPositiveBtnClick.record(NoExtras())
|
||||
},
|
||||
),
|
||||
secondaryButton = Action(
|
||||
text = stringResource(id = R.string.onboarding_home_enable_notifications_negative_button),
|
||||
onClick = {
|
||||
onDismiss()
|
||||
Onboarding.notifPppNegativeBtnClick.record(NoExtras())
|
||||
},
|
||||
),
|
||||
onRecordImpressionEvent = { Onboarding.notifPppImpression.record(NoExtras()) },
|
||||
),
|
||||
onDismiss = {
|
||||
onDismiss()
|
||||
Onboarding.notifPppCloseClick.record(NoExtras())
|
||||
},
|
||||
modifier = Modifier
|
||||
.statusBarsPadding()
|
||||
.navigationBarsPadding(),
|
||||
)
|
||||
}
|
||||
|
||||
@LightDarkPreview
|
||||
@Composable
|
||||
private fun NotificationPermissionScreenPreview() {
|
||||
FirefoxTheme {
|
||||
NotificationPermissionDialogScreen(
|
||||
grantNotificationPermission = {},
|
||||
onDismiss = { },
|
||||
)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue