mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-25 07:06:01 +00:00
fainting tweaks
This commit is contained in:
parent
fd4c49ecde
commit
3967789158
4 changed files with 53 additions and 10 deletions
|
|
@ -167,7 +167,7 @@ android {
|
|||
buildConfigField "String", "TESTING_LEVEL", "\"production\""
|
||||
resConfigs 'en', 'bg', 'de', 'en-rGB', 'es', 'fr', 'hr-rHR', 'in', 'it', 'iw', 'ja', 'ko', 'lt', 'nl', 'pl', 'pt-rBR', 'pt-rPT', 'ru', 'tr', 'zh', 'zh-rTW'
|
||||
|
||||
versionCode 3509
|
||||
versionCode 3510
|
||||
versionName "3.6"
|
||||
|
||||
targetSdkVersion 32
|
||||
|
|
|
|||
|
|
@ -1,13 +1,20 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:background="@color/content_background"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center_horizontal"
|
||||
android:paddingHorizontal="23dp">
|
||||
android:background="@color/content_background">
|
||||
<FrameLayout
|
||||
android:id="@+id/confetti_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center_horizontal"
|
||||
android:paddingHorizontal="23dp">
|
||||
<androidx.legacy.widget.Space
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="0dp"
|
||||
|
|
@ -22,6 +29,7 @@
|
|||
android:src="@drawable/death_ghost"
|
||||
android:layout_centerHorizontal="true" />
|
||||
<ImageView
|
||||
android:id="@+id/heart_view"
|
||||
android:layout_width="110dp"
|
||||
android:layout_height="110dp"
|
||||
android:src="@drawable/ic_broken_heart"
|
||||
|
|
@ -81,4 +89,5 @@
|
|||
android:textColor="@color/text_quad"
|
||||
android:text="@string/faint_broken_equipment"
|
||||
android:layout_margin="@dimen/spacing_large"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</FrameLayout>
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
package com.habitrpg.android.habitica.ui.activities
|
||||
|
||||
import android.graphics.drawable.BitmapDrawable
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
import android.view.animation.AccelerateInterpolator
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import com.habitrpg.android.habitica.R
|
||||
import com.habitrpg.android.habitica.components.UserComponent
|
||||
|
|
@ -16,7 +18,9 @@ import com.habitrpg.android.habitica.helpers.Animations
|
|||
import com.habitrpg.android.habitica.helpers.AppConfigManager
|
||||
import com.habitrpg.android.habitica.helpers.RxErrorHandler
|
||||
import com.habitrpg.android.habitica.ui.viewmodels.MainUserViewModel
|
||||
import com.habitrpg.android.habitica.ui.views.HabiticaIconsHelper
|
||||
import com.habitrpg.android.habitica.ui.views.ads.AdButton
|
||||
import com.plattysoft.leonids.ParticleSystem
|
||||
import javax.inject.Inject
|
||||
|
||||
class DeathActivity: BaseActivity() {
|
||||
|
|
@ -42,8 +46,6 @@ class DeathActivity: BaseActivity() {
|
|||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
binding.ghostView.startAnimation(Animations.bobbingAnimation())
|
||||
|
||||
userViewModel.user.observeOnce(this) { user ->
|
||||
binding.lossDescription.text = getString(R.string.faint_loss_description, (user?.stats?.lvl ?: 2).toInt() - 1, user?.stats?.gp?.toInt()).fromHtml()
|
||||
}
|
||||
|
|
@ -82,5 +84,32 @@ class DeathActivity: BaseActivity() {
|
|||
finish()
|
||||
}, RxErrorHandler.handleEmptyError())
|
||||
}
|
||||
startAnimating()
|
||||
}
|
||||
|
||||
private fun startAnimating() {
|
||||
binding.ghostView.startAnimation(Animations.bobbingAnimation())
|
||||
makeCoins(305)
|
||||
makeCoins(160)
|
||||
}
|
||||
|
||||
private fun makeCoins(startAngle: Int) {
|
||||
ParticleSystem(
|
||||
binding.confettiContainer,
|
||||
14,
|
||||
BitmapDrawable(resources, HabiticaIconsHelper.imageOfGold()),
|
||||
5000
|
||||
)
|
||||
.setInitialRotationRange(0, 200)
|
||||
.setScaleRange(0.5f, 0.8f)
|
||||
.setSpeedRange(0.01f, 0.03f)
|
||||
.setFadeOut(4000, AccelerateInterpolator())
|
||||
.setSpeedModuleAndAngleRange(0.01f, 0.03f, startAngle, startAngle+80)
|
||||
.emit(550, 680, 3, 6000)
|
||||
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
moveTaskToBack(true)
|
||||
}
|
||||
}
|
||||
|
|
@ -66,6 +66,7 @@ import kotlinx.coroutines.Dispatchers
|
|||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import java.util.Date
|
||||
import javax.inject.Inject
|
||||
import kotlin.time.DurationUnit
|
||||
import kotlin.time.toDuration
|
||||
|
|
@ -444,12 +445,16 @@ open class MainActivity : BaseActivity(), SnackbarActivity {
|
|||
)
|
||||
}
|
||||
|
||||
private var lastDeathDialogDisplay = 0L
|
||||
|
||||
private fun displayDeathDialogIfNeeded() {
|
||||
if (!viewModel.userViewModel.isUserFainted) {
|
||||
return
|
||||
}
|
||||
|
||||
if (!this.isFinishing) {
|
||||
val now = Date().time
|
||||
if (!this.isFinishing && now - lastDeathDialogDisplay > 60000) {
|
||||
lastDeathDialogDisplay = now
|
||||
MainNavigationController.navigate(R.id.deathActivity)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue