mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-20 12:49:02 +00:00
minor event improvements
This commit is contained in:
parent
52b411a836
commit
b1c6f21557
8 changed files with 85 additions and 26 deletions
BIN
Habitica/res/drawable-xhdpi/birthday_gems.png
Normal file
BIN
Habitica/res/drawable-xhdpi/birthday_gems.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.5 KiB |
BIN
Habitica/res/drawable-xxhdpi/birthday_gems.png
Normal file
BIN
Habitica/res/drawable-xxhdpi/birthday_gems.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 8 KiB |
|
|
@ -47,6 +47,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:text="@string/dismiss_tutorial"
|
||||
android:textColor="?textColorTintedSecondary"
|
||||
android:theme="@style/DialogButton"/>
|
||||
|
||||
<Button
|
||||
|
|
@ -57,6 +58,7 @@
|
|||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/complete_tutorial"
|
||||
android:textColor="?textColorTintedSecondary"
|
||||
android:theme="@style/DialogButton" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
|
|
|||
|
|
@ -1313,10 +1313,10 @@
|
|||
<string name="third">third</string>
|
||||
<string name="fourth">fourth</string>
|
||||
<string name="fifth">fifth</string>
|
||||
<string name="animated_gryphatrice_pet">Animated Gryphatrice Pet</string>
|
||||
<string name="animated_gryphatrice_pet">Jubilant Gryphatrice Pet</string>
|
||||
<string name="birthday_title_description">Celebrate Habitica’s 10th birthday with gifts and exclusive items below!</string>
|
||||
<string name="limited_edition">Limited Edition</string>
|
||||
<string name="gryphatrice_description">The rare, mystical Gryphatrice joins the birthday bash! Don’t miss your chance to own this exclusive animated Pet.</string>
|
||||
<string name="gryphatrice_description">The rare, Jubilant Gryphatrice joins the birthday bash! Don’t miss your chance to own this exclusive animated Pet.</string>
|
||||
<string name="thanks_for_support">Thanks for your support!</string>
|
||||
<string name="plenty_of_potions">Plenty of Potions</string>
|
||||
<string name="for_for_free">Four for Free</string>
|
||||
|
|
@ -1324,7 +1324,7 @@
|
|||
<string name="buy_for">Buy for</string>
|
||||
<string name="plenty_of_potions_description">We’re bringing back 10 of the community’s favorite Magic Hatching Potions. Head over to the Market to fill out your collection!</string>
|
||||
<string name="for_for_free_description">To keep the party going, we’ll be giving away Party Robes, 20 Gems, and a limited edition Cape set and Background!</string>
|
||||
<string name="birthday_limitations">This is a limited time event that starts on January 23rd at 8:00 AM ET (13:00 UTC) and will end February 1st at 8:00 PM ET (01:00 UTC). The Limited Edition Gryphatrice and ten Magic Hatching Potions will be available to buy during this time. The other Gifts will be automatically delivered to all accounts active in the previous 30 days.</string>
|
||||
<string name="birthday_limitations">This is a limited time event that starts on %1$s and will end %2$s. The Limited Edition Jubilant Gryphatrice and ten Magic Hatching Potions will be available to buy during this time. The other Gifts listed in the Four for Free section will be automatically delivered to all accounts that were active in the 30 days prior to day the gift is sent. Accounts created after the gifts are sent will not be able to claim them.</string>
|
||||
<string name="visit_the_market">Visit the Market</string>
|
||||
<string name="exclusive_items_await">Exclusive items and gifts await</string>
|
||||
<string name="ends_in_x">Ends in %s</string>
|
||||
|
|
@ -1339,6 +1339,7 @@
|
|||
<string name="background">Background</string>
|
||||
<string name="birthday_set">Birthday Set</string>
|
||||
<string name="you_equipped_x">You equipped %s</string>
|
||||
<string name="purchase_gryphatrice_confirmation">Purchase the Jubilant Gryphatrice for %d Gems?</string>
|
||||
|
||||
<plurals name="you_x_others">
|
||||
<item quantity="zero">You</item>
|
||||
|
|
|
|||
|
|
@ -474,7 +474,7 @@
|
|||
|
||||
<style name="DialogButton" parent="android:Widget.Button">
|
||||
<item name="android:background">@android:color/transparent</item>
|
||||
<item name="android:textColor">@color/brand_100</item>
|
||||
<item name="android:textColor">?colorAccent</item>
|
||||
</style>
|
||||
|
||||
<style name="DialogTheme" parent="Theme.AppCompat.DayNight.Dialog">
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ class UserRepositoryImpl(
|
|||
override suspend fun sleep(user: User): User {
|
||||
val newValue = !(user.preferences?.sleep ?: false)
|
||||
localRepository.modify(user) { it.preferences?.sleep = newValue }
|
||||
if (apiClient.sleep() != true) {
|
||||
if (apiClient.sleep() == null) {
|
||||
localRepository.modify(user) { it.preferences?.sleep = !newValue }
|
||||
}
|
||||
return user
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ import androidx.compose.ui.draw.scale
|
|||
import androidx.compose.ui.graphics.Brush
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.ColorFilter
|
||||
import androidx.compose.ui.graphics.painter.Painter
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.colorResource
|
||||
import androidx.compose.ui.res.painterResource
|
||||
|
|
@ -61,6 +62,7 @@ import com.google.accompanist.systemuicontroller.rememberSystemUiController
|
|||
import com.habitrpg.android.habitica.R
|
||||
import com.habitrpg.android.habitica.components.UserComponent
|
||||
import com.habitrpg.android.habitica.data.InventoryRepository
|
||||
import com.habitrpg.android.habitica.extensions.addCloseButton
|
||||
import com.habitrpg.android.habitica.helpers.AppConfigManager
|
||||
import com.habitrpg.android.habitica.helpers.MainNavigationController
|
||||
import com.habitrpg.android.habitica.helpers.PurchaseHandler
|
||||
|
|
@ -69,10 +71,12 @@ import com.habitrpg.android.habitica.ui.theme.HabiticaTheme
|
|||
import com.habitrpg.android.habitica.ui.viewmodels.MainUserViewModel
|
||||
import com.habitrpg.android.habitica.ui.views.CurrencyText
|
||||
import com.habitrpg.android.habitica.ui.views.PixelArtView
|
||||
import com.habitrpg.android.habitica.ui.views.dialogs.HabiticaAlertDialog
|
||||
import com.habitrpg.common.habitica.extensions.DataBindingUtils
|
||||
import kotlinx.coroutines.MainScope
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.flow.map
|
||||
import java.text.DateFormat
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
import javax.inject.Inject
|
||||
|
|
@ -90,10 +94,12 @@ class BirthdayActivity : BaseActivity() {
|
|||
@Inject
|
||||
lateinit var configManager: AppConfigManager
|
||||
|
||||
val scaffoldState: ScaffoldState = ScaffoldState(DrawerState(DrawerValue.Closed), SnackbarHostState())
|
||||
val scaffoldState: ScaffoldState =
|
||||
ScaffoldState(DrawerState(DrawerValue.Closed), SnackbarHostState())
|
||||
private val isPurchasing = mutableStateOf(false)
|
||||
private val price = mutableStateOf("")
|
||||
private val hasGryphatrice = mutableStateOf(false)
|
||||
private val hasEquipped = mutableStateOf(false)
|
||||
private var gryphatriceProductDetails: ProductDetails? = null
|
||||
|
||||
override fun getLayoutResId(): Int? = null
|
||||
|
|
@ -107,6 +113,7 @@ class BirthdayActivity : BaseActivity() {
|
|||
scaffoldState,
|
||||
isPurchasing.value,
|
||||
hasGryphatrice.value,
|
||||
hasEquipped.value,
|
||||
price.value,
|
||||
event?.start ?: Date(),
|
||||
event?.end ?: Date(),
|
||||
|
|
@ -121,15 +128,30 @@ class BirthdayActivity : BaseActivity() {
|
|||
isPurchasing.value = false
|
||||
}) {
|
||||
isPurchasing.value = true
|
||||
inventoryRepository.purchaseItem("pets", "Gryphatrice-Jubilant", 1)
|
||||
userRepository.retrieveUser(false, true)
|
||||
isPurchasing.value = false
|
||||
val dialog = HabiticaAlertDialog(this@BirthdayActivity)
|
||||
dialog.setTitle(
|
||||
getString(
|
||||
R.string.purchase_gryphatrice_confirmation,
|
||||
60
|
||||
)
|
||||
)
|
||||
dialog.addButton(
|
||||
getString(R.string.buy_for_x, "60 Gems"),
|
||||
true
|
||||
) { _, _ ->
|
||||
lifecycleScope.launchCatching {
|
||||
purchaseWithGems()
|
||||
}
|
||||
}
|
||||
dialog.addCloseButton { _, _ ->
|
||||
isPurchasing.value = false
|
||||
}
|
||||
purchaseWithGems()
|
||||
}
|
||||
}
|
||||
) {
|
||||
lifecycleScope.launchCatching {
|
||||
inventoryRepository.equip("pet", "Gryphatrice-Jubilant")
|
||||
scaffoldState.snackbarHostState.showSnackbar(getString(R.string.you_equipped_x, getString(R.string.animated_gryphatrice_pet)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -145,12 +167,23 @@ class BirthdayActivity : BaseActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
userViewModel.user.observe(this) {
|
||||
hasEquipped.value = it?.items?.currentPet == "Gryphatrice-Jubilant"
|
||||
}
|
||||
|
||||
lifecycleScope.launchCatching {
|
||||
gryphatriceProductDetails = purchaseHandler.getGryphatriceSKU()
|
||||
price.value = gryphatriceProductDetails?.oneTimePurchaseOfferDetails?.formattedPrice ?: ""
|
||||
price.value =
|
||||
gryphatriceProductDetails?.oneTimePurchaseOfferDetails?.formattedPrice ?: ""
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun purchaseWithGems() {
|
||||
inventoryRepository.purchaseItem("pets", "Gryphatrice-Jubilant", 1)
|
||||
userRepository.retrieveUser(false, true)
|
||||
isPurchasing.value = false
|
||||
}
|
||||
|
||||
override fun injectActivity(component: UserComponent?) {
|
||||
component?.inject(this)
|
||||
}
|
||||
|
|
@ -192,6 +225,7 @@ fun BirthdayActivityView(
|
|||
scaffoldState: ScaffoldState,
|
||||
isPurchasing: Boolean,
|
||||
hasGryphatrice: Boolean,
|
||||
hasEquipped: Boolean,
|
||||
price: String,
|
||||
startDate: Date,
|
||||
endDate: Date,
|
||||
|
|
@ -201,6 +235,8 @@ fun BirthdayActivityView(
|
|||
) {
|
||||
val activity = LocalContext.current as? Activity
|
||||
val dateFormat = SimpleDateFormat("MMM dd", java.util.Locale.getDefault())
|
||||
val complexDateFormat = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL)
|
||||
|
||||
val textColor = Color.White
|
||||
val specialTextColor = colorResource(R.color.yellow_50)
|
||||
|
||||
|
|
@ -304,7 +340,10 @@ fun BirthdayActivityView(
|
|||
.size(161.dp, 129.dp)
|
||||
.background(colorResource(R.color.brand_50), RoundedCornerShape(8.dp))
|
||||
) {
|
||||
PixelArtView(imageName = "stable_Pet-Gryphatrice-Jubilant", Modifier.size(104.dp))
|
||||
PixelArtView(
|
||||
imageName = "stable_Pet-Gryphatrice-Jubilant",
|
||||
Modifier.size(104.dp)
|
||||
)
|
||||
}
|
||||
Text(
|
||||
stringResource(R.string.limited_edition).toUpperCase(Locale.current),
|
||||
|
|
@ -335,7 +374,10 @@ fun BirthdayActivityView(
|
|||
},
|
||||
modifier = Modifier.padding(top = 20.dp)
|
||||
) {
|
||||
Text(stringResource(R.string.equip), fontSize = 18.sp)
|
||||
Text(
|
||||
stringResource(if (hasEquipped) R.string.unequip else R.string.equip),
|
||||
fontSize = 18.sp
|
||||
)
|
||||
}
|
||||
} else if (isPurchasing) {
|
||||
CircularProgressIndicator()
|
||||
|
|
@ -368,7 +410,10 @@ fun BirthdayActivityView(
|
|||
},
|
||||
modifier = Modifier.padding(top = 20.dp)
|
||||
) {
|
||||
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(4.dp)) {
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(4.dp)
|
||||
) {
|
||||
Text(stringResource(R.string.buy_for), fontSize = 18.sp)
|
||||
CurrencyText(currency = "gems", value = 60, fontSize = 18.sp)
|
||||
}
|
||||
|
|
@ -422,7 +467,7 @@ fun BirthdayActivityView(
|
|||
FourFreeItem(
|
||||
day = 1,
|
||||
title = stringResource(R.string.twenty_gems),
|
||||
imageName = "birthday10_gems",
|
||||
image = painterResource(R.drawable.birthday_gems),
|
||||
modifier = Modifier.weight(1f)
|
||||
)
|
||||
}
|
||||
|
|
@ -461,7 +506,11 @@ fun BirthdayActivityView(
|
|||
textAlign = TextAlign.Center
|
||||
)
|
||||
Text(
|
||||
stringResource(R.string.birthday_limitations),
|
||||
stringResource(
|
||||
R.string.birthday_limitations,
|
||||
complexDateFormat.format(startDate),
|
||||
complexDateFormat.format(endDate)
|
||||
),
|
||||
fontSize = 14.sp,
|
||||
color = colorResource(R.color.brand_600),
|
||||
lineHeight = 20.sp,
|
||||
|
|
@ -515,8 +564,9 @@ fun PotionGrid() {
|
|||
fun FourFreeItem(
|
||||
day: Int,
|
||||
title: String,
|
||||
imageName: String,
|
||||
modifier: Modifier = Modifier
|
||||
modifier: Modifier = Modifier,
|
||||
imageName: String? = null,
|
||||
image: Painter? = null
|
||||
) {
|
||||
Column(
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
|
|
@ -534,12 +584,18 @@ fun FourFreeItem(
|
|||
Box(
|
||||
contentAlignment = Alignment.Center,
|
||||
modifier = Modifier
|
||||
.size(121.dp, 84.dp)
|
||||
.background(colorResource(R.color.brand_100), HabiticaTheme.shapes.medium)) {
|
||||
PixelArtView(imageName,
|
||||
Modifier
|
||||
.size(68.dp)
|
||||
)
|
||||
.size(121.dp, 84.dp)
|
||||
.background(colorResource(R.color.brand_100), HabiticaTheme.shapes.medium)
|
||||
) {
|
||||
if (image != null) {
|
||||
Image(image, null)
|
||||
} else {
|
||||
PixelArtView(
|
||||
imageName,
|
||||
Modifier
|
||||
.size(84.dp)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Text(title, color = Color.White, fontSize = 16.sp)
|
||||
|
|
@ -576,6 +632,6 @@ fun HabiticaButton(
|
|||
@Composable
|
||||
private fun Preview() {
|
||||
val scaffoldState = rememberScaffoldState()
|
||||
BirthdayActivityView(scaffoldState, true, false, "", Date(), Date(), {
|
||||
BirthdayActivityView(scaffoldState, true, false, false, "", Date(), Date(), {
|
||||
}, {}) {}
|
||||
}
|
||||
|
|
@ -1,2 +1,2 @@
|
|||
NAME=4.1
|
||||
CODE=5031
|
||||
CODE=5051
|
||||
Loading…
Reference in a new issue