mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-24 14:45:46 +00:00
Subscription bottom sheet for death activity & armoire
This commit is contained in:
parent
a89368ec9c
commit
d3a4071683
6 changed files with 57 additions and 22 deletions
|
|
@ -109,7 +109,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginTop="@dimen/spacing_small"
|
||||
android:gravity="center"
|
||||
android:lineSpacingExtra="4dp"
|
||||
android:text="@string/subscribe_prompt_2"
|
||||
|
|
|
|||
|
|
@ -1415,10 +1415,12 @@
|
|||
<string name="subscribe_listitemArmoire_description">Get two chances at new equipment from the Armoire for the price of one</string>
|
||||
<string name="subscribe_incentive_button_armoire">Subscribe to open again for free!</string>
|
||||
<string name="subscribe_incentive_text_armoire">Get an extra chance at the Armoire each time you buy it with a subscription</string>
|
||||
<string name="subscribe_second_armoire_open_text">Subscribers get extra chances at the Armoire and these other benefits!</string>
|
||||
<string name="subscriber_button_armoire">Open again for free!</string>
|
||||
<string name="subscriber_button_faint">Second chance: Hold on with 1HP!</string>
|
||||
<string name="sub_perk">SUB PERK</string>
|
||||
<string name="subscribe_incentive_text_faint">Get a second chance each day to avoid running out of HP with a subscription</string>
|
||||
<string name="subscribe_second_chance_incentive_text">Subscribers get a second chance at life each day and these other benefits!</string>
|
||||
<string name="subscriber_benefit_used_faint">You already used your second chance today. It’s available again in %s</string>
|
||||
<string name="subriber_benefit_notification_faint">You got a second chance with 1HP!</string>
|
||||
<string name="watch_ad_to_hang_on">Watch ad to hold on with 1HP!</string>
|
||||
|
|
|
|||
|
|
@ -16,8 +16,14 @@ import com.habitrpg.android.habitica.databinding.ActivityArmoireBinding
|
|||
import com.habitrpg.android.habitica.extensions.observeOnce
|
||||
import com.habitrpg.android.habitica.helpers.AdHandler
|
||||
import com.habitrpg.android.habitica.helpers.AdType
|
||||
import com.habitrpg.android.habitica.helpers.Analytics
|
||||
import com.habitrpg.android.habitica.helpers.AppConfigManager
|
||||
import com.habitrpg.android.habitica.helpers.EventCategory
|
||||
import com.habitrpg.android.habitica.helpers.HitType
|
||||
import com.habitrpg.android.habitica.helpers.ReviewManager
|
||||
import com.habitrpg.android.habitica.ui.fragments.purchases.EventOutcomeSubscriptionBottomSheetFragment
|
||||
import com.habitrpg.android.habitica.ui.fragments.purchases.EventOutcomeSubscriptionBottomSheetFragment.Companion.EVENT_ARMOIRE_OPENED
|
||||
import com.habitrpg.android.habitica.ui.fragments.purchases.SubscriptionBottomSheetFragment
|
||||
import com.habitrpg.android.habitica.ui.viewmodels.MainUserViewModel
|
||||
import com.habitrpg.android.habitica.ui.views.ads.AdButton
|
||||
import com.habitrpg.android.habitica.ui.views.dialogs.HabiticaBottomSheetDialog
|
||||
|
|
@ -130,7 +136,10 @@ class ArmoireActivity : BaseActivity() {
|
|||
}
|
||||
|
||||
binding.subscribeModalButton.setOnClickListener {
|
||||
MainNavigationController.navigate(R.id.subscriptionPurchaseActivity)
|
||||
val subscriptionBottomSheet = EventOutcomeSubscriptionBottomSheetFragment().apply {
|
||||
eventType = EVENT_ARMOIRE_OPENED
|
||||
}
|
||||
subscriptionBottomSheet.show(supportFragmentManager, EventOutcomeSubscriptionBottomSheetFragment.TAG)
|
||||
}
|
||||
|
||||
binding.closeButton.setOnClickListener {
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import com.habitrpg.android.habitica.extensions.observeOnce
|
|||
import com.habitrpg.android.habitica.helpers.AdHandler
|
||||
import com.habitrpg.android.habitica.helpers.AdType
|
||||
import com.habitrpg.android.habitica.helpers.AppConfigManager
|
||||
import com.habitrpg.android.habitica.ui.fragments.purchases.EventOutcomeSubscriptionBottomSheetFragment
|
||||
import com.habitrpg.android.habitica.ui.viewmodels.MainUserViewModel
|
||||
import com.habitrpg.android.habitica.ui.views.HabiticaIconsHelper
|
||||
import com.habitrpg.android.habitica.ui.views.HabiticaSnackbar
|
||||
|
|
@ -115,6 +116,12 @@ class DeathActivity : BaseActivity() {
|
|||
} else if (it?.isSubscribed == false) {
|
||||
binding.reviveSubscriberWrapper.visibility = View.GONE
|
||||
binding.unsubbedWrapper.visibility = View.VISIBLE
|
||||
binding.subscribeModalButton.setOnClickListener {
|
||||
val subscriptionBottomSheet = EventOutcomeSubscriptionBottomSheetFragment().apply {
|
||||
eventType = EventOutcomeSubscriptionBottomSheetFragment.EVENT_DEATH_SCREEN
|
||||
}
|
||||
subscriptionBottomSheet.show(supportFragmentManager, EventOutcomeSubscriptionBottomSheetFragment.TAG)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,35 @@
|
|||
package com.habitrpg.android.habitica.ui.fragments.purchases
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import com.habitrpg.android.habitica.R
|
||||
|
||||
class EventOutcomeSubscriptionBottomSheetFragment : SubscriptionBottomSheetFragment() {
|
||||
|
||||
var eventType: String = ""
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
when (eventType) {
|
||||
EVENT_ARMOIRE_OPENED -> setArmoireEventSubscriptionViews()
|
||||
EVENT_DEATH_SCREEN -> setDeathScreenEventSubscriptionViews()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun setArmoireEventSubscriptionViews() {
|
||||
binding.subscriberBenefitBanner.visibility = View.GONE
|
||||
binding.subscribeBenefits.text = getString(R.string.subscribe_second_armoire_open_text)
|
||||
}
|
||||
|
||||
private fun setDeathScreenEventSubscriptionViews() {
|
||||
binding.subscriberBenefitBanner.visibility = View.GONE
|
||||
binding.subscribeBenefits.text = getString(R.string.subscribe_second_chance_incentive_text)
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val TAG = "EventOutcomeSubscriptionBottomSheet"
|
||||
const val EVENT_ARMOIRE_OPENED = "armoire_opened"
|
||||
const val EVENT_DEATH_SCREEN = "death_screen"
|
||||
}
|
||||
}
|
||||
|
|
@ -1,20 +1,12 @@
|
|||
package com.habitrpg.android.habitica.ui.fragments.purchases
|
||||
|
||||
import android.app.Dialog
|
||||
import android.content.Context
|
||||
import android.content.DialogInterface
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.EditText
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import com.android.billingclient.api.ProductDetails
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||
|
|
@ -23,23 +15,13 @@ import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
|||
import com.habitrpg.android.habitica.R
|
||||
import com.habitrpg.android.habitica.data.InventoryRepository
|
||||
import com.habitrpg.android.habitica.data.UserRepository
|
||||
import com.habitrpg.android.habitica.databinding.DialogHabiticaAccountBinding
|
||||
import com.habitrpg.android.habitica.databinding.FragmentBottomsheetSubscriptionBinding
|
||||
import com.habitrpg.android.habitica.databinding.FragmentSubscriptionBinding
|
||||
import com.habitrpg.android.habitica.extensions.addCancelButton
|
||||
import com.habitrpg.android.habitica.helpers.Analytics
|
||||
import com.habitrpg.android.habitica.helpers.AppConfigManager
|
||||
import com.habitrpg.android.habitica.helpers.PurchaseHandler
|
||||
import com.habitrpg.android.habitica.helpers.PurchaseTypes
|
||||
import com.habitrpg.android.habitica.models.user.User
|
||||
import com.habitrpg.android.habitica.ui.activities.GiftSubscriptionActivity
|
||||
import com.habitrpg.android.habitica.ui.fragments.PromoInfoFragment
|
||||
import com.habitrpg.android.habitica.ui.theme.HabiticaTheme
|
||||
import com.habitrpg.android.habitica.ui.views.dialogs.HabiticaAlertDialog
|
||||
import com.habitrpg.android.habitica.ui.views.promo.BirthdayBanner
|
||||
import com.habitrpg.android.habitica.ui.views.subscriptions.SubscriptionOptionView
|
||||
import com.habitrpg.common.habitica.extensions.isUsingNightModeResources
|
||||
import com.habitrpg.common.habitica.extensions.layoutInflater
|
||||
import com.habitrpg.common.habitica.extensions.loadImage
|
||||
import com.habitrpg.common.habitica.helpers.ExceptionHandler
|
||||
import com.habitrpg.common.habitica.helpers.MainNavigationController
|
||||
|
|
@ -52,10 +34,10 @@ import kotlinx.coroutines.withContext
|
|||
import javax.inject.Inject
|
||||
|
||||
@AndroidEntryPoint
|
||||
class SubscriptionBottomSheetFragment : BottomSheetDialogFragment() {
|
||||
open class SubscriptionBottomSheetFragment : BottomSheetDialogFragment() {
|
||||
|
||||
private var _binding: FragmentBottomsheetSubscriptionBinding? = null
|
||||
private val binding get() = _binding!!
|
||||
val binding get() = _binding!!
|
||||
|
||||
@Inject
|
||||
lateinit var userRepository: UserRepository
|
||||
|
|
|
|||
Loading…
Reference in a new issue