Alert fixes

This commit is contained in:
Phillip Thelen 2020-11-23 18:13:49 +01:00
parent baef77c7f9
commit 17764880e7
21 changed files with 86 additions and 32 deletions

View file

@ -150,7 +150,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 2647
versionCode 2653
versionName "3.1"
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

View file

@ -27,7 +27,7 @@
android:layout_alignParentEnd="true"
android:layout_marginEnd="6dp"
android:layout_alignParentTop="true"
android:layout_marginTop="30dp"
android:layout_marginTop="40dp"
android:textColor="@android:color/white"
android:background="@color/transparent" />

View file

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="60dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp"
android:letterSpacing="0.02"
android:fontFamily="@string/font_family_medium"
android:text="@string/hatch"
android:textColor="?attr/colorAccent"
android:layout_marginEnd="6dp"
/>
<com.habitrpg.android.habitica.ui.views.CurrencyView
android:id="@+id/currencyView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>

View file

@ -193,7 +193,7 @@
android:layout_height="wrap_content"
android:gravity="center"
android:textSize="14sp"
android:textColor="@color/textColorSecondaryDark" />
android:textColor="?textColorSecondaryDark" />
<TextView
android:layout_width="0dp"
android:layout_height="0dp"
@ -212,7 +212,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:textColor="@color/textColorSecondaryDark"
android:textColor="?textColorSecondaryDark"
style="@style/CurrencyTextView"
/>
@ -226,7 +226,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:textColor="@color/textColorSecondaryDark"
android:textColor="?textColorSecondaryDark"
style="@style/CurrencyTextView"
/>
@ -239,7 +239,7 @@
android:id="@+id/gold_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/textColorSecondaryDark"
android:textColor="?textColorSecondaryDark"
style="@style/CurrencyTextView"
/>
</LinearLayout>

View file

@ -72,11 +72,6 @@
<color name="xpColor">@color/yellow_100</color>
<color name="mpColor">@color/blue_100</color>
<color name="colorPrimary">@color/brand_300</color>
<color name="colorPrimaryDark">@color/brand_50</color>
<!-- text -->
<color name="textColorSecondaryDark">@color/brand_500</color>
<!-- Cards -->
<color name="text_light">#66000000</color>
<color name="card_text">@color/text_ternary</color>

View file

@ -1125,7 +1125,7 @@
<string name="hurray">Hurray!</string>
<string name="you_won_challenge">You won a Challenge</string>
<string name="congratulations">Congratulations!</string>
<string name="won_achievement_description"><b>%s</b> selected you as the winner! Your win has been recorded in your Achievements.</string>
<string name="won_achievement_description"><![CDATA[<b>%s</b> selected you as the winner! Your win has been recorded in your Achievements.]]></string>
<string name="won_achievement_description_noname">You were selected as the winner! Your win has been recorded in your Achievements.</string>
<string name="claim_x_gems">Claim %d Gems</string>
</resources>

View file

@ -138,6 +138,7 @@ override fun getUser(userID: String): Flowable<User> {
val habitClass = if (user.preferences?.disableClasses == true) "none" else user.stats?.habitClass
return RxJavaBridge.toV3Flowable(realm.where(Skill::class.java)
.equalTo("habitClass", habitClass)
.sort("lvl")
.findAll()
.asFlowable()
.filter { it.isLoaded })

View file

@ -5,6 +5,8 @@ import com.google.firebase.messaging.FirebaseMessagingService
import com.google.firebase.messaging.RemoteMessage
import com.habitrpg.android.habitica.HabiticaBaseApplication
import com.habitrpg.android.habitica.components.UserComponent
import com.habitrpg.android.habitica.data.UserRepository
import com.habitrpg.android.habitica.helpers.RxErrorHandler
import javax.inject.Inject
class HabiticaFirebaseMessagingService : FirebaseMessagingService() {
@ -15,10 +17,17 @@ class HabiticaFirebaseMessagingService : FirebaseMessagingService() {
@Inject
internal lateinit var pushNotificationManager: PushNotificationManager
@Inject
internal lateinit var userRepository: UserRepository
override fun onMessageReceived(remoteMessage: RemoteMessage) {
userComponent?.inject(this)
if (this::pushNotificationManager.isInitialized) {
pushNotificationManager.displayNotification(remoteMessage)
if (remoteMessage.data["identifier"]?.contains(PushNotificationManager.WON_CHALLENGE_PUSH_NOTIFICATION_KEY) == true) {
userRepository.retrieveUser(true).subscribe({}, RxErrorHandler.handleEmptyError())
}
}
}

View file

@ -47,6 +47,7 @@ import com.habitrpg.android.habitica.models.Notification
import com.habitrpg.android.habitica.models.TutorialStep
import com.habitrpg.android.habitica.models.inventory.Egg
import com.habitrpg.android.habitica.models.inventory.HatchingPotion
import com.habitrpg.android.habitica.models.notifications.ChallengeWonData
import com.habitrpg.android.habitica.models.notifications.LoginIncentiveData
import com.habitrpg.android.habitica.models.responses.MaintenanceResponse
import com.habitrpg.android.habitica.models.responses.TaskScoringResult
@ -76,6 +77,10 @@ import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
import io.reactivex.rxjava3.functions.Consumer
import io.reactivex.rxjava3.schedulers.Schedulers
import io.realm.kotlin.isValid
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import org.greenrobot.eventbus.EventBus
import org.greenrobot.eventbus.Subscribe
import java.util.*
@ -377,6 +382,23 @@ open class MainActivity : BaseActivity(), TutorialView.OnTutorialReaction {
if (binding.toolbarTitle.text?.isNotBlank() != true) {
navigationController.currentDestination?.let { updateToolbarTitle(it, null) }
}
val alert1 = HabiticaAlertDialog(this)
alert1.setTitle("1")
alert1.addCloseButton()
alert1.enqueue()
val alert2 = HabiticaAlertDialog(this)
alert2.setTitle("2")
alert2.addCloseButton()
alert2.enqueue()
GlobalScope.launch(context = Dispatchers.Main) {
delay(500L)
val alert3 = HabiticaAlertDialog(this@MainActivity)
alert3.setTitle("3")
alert3.addCloseButton()
alert3.enqueue()
}
}
override fun onPause() {

View file

@ -180,7 +180,7 @@ class StableRecyclerAdapter : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
val animal = this.animal
if (animal != null) {
val color = if (animal.type == "special") animal.color else null
if (animal.numberOwned > 0 || ownedEggs?.containsKey(animal.animal) == true) {
if (animal.numberOwned > 0) {
if (itemType == "pets") {
MainNavigationController.navigate(StableFragmentDirections.openPetDetail(animal.animal, animal.type ?: "", color))
} else {

View file

@ -290,7 +290,7 @@ open class TaskRecyclerViewFragment : BaseFragment<FragmentRefreshRecyclerviewBi
if (!task.isValid) {
return
}
taskRepository.getTasksForChallenge(task.challengeID).subscribe({ tasks ->
taskRepository.getTasksForChallenge(task.challengeID).firstElement().subscribe({ tasks ->
val taskCount = tasks.size
val dialog = HabiticaAlertDialog(it)
dialog.setTitle(R.string.broken_challenge)

View file

@ -13,8 +13,14 @@ import com.habitrpg.android.habitica.R
import com.habitrpg.android.habitica.extensions.dpToPx
import com.habitrpg.android.habitica.extensions.inflate
import com.habitrpg.android.habitica.extensions.layoutInflater
import com.habitrpg.android.habitica.helpers.MainNavigationController
import com.habitrpg.android.habitica.ui.fragments.social.challenges.ChallengesOverviewFragmentDirections
import com.habitrpg.android.habitica.ui.views.login.LockableScrollView
import com.plattysoft.leonids.ParticleSystem
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import java.lang.ref.WeakReference
@ -269,8 +275,11 @@ open class HabiticaAlertDialog(context: Context) : AlertDialog(context, R.style.
dialogQueue.removeAt(0)
}
if (dialogQueue.size > 0) {
if ((dialogQueue[0].context as? Activity)?.isFinishing == false) {
dialogQueue[0].show()
if ((dialogQueue[0].context as? Activity)?.isFinishing != true) {
GlobalScope.launch(context = Dispatchers.Main) {
delay(500L)
dialogQueue[0].show()
}
}
}
}

View file

@ -4,12 +4,15 @@ import android.content.Context
import android.graphics.drawable.BitmapDrawable
import android.view.LayoutInflater
import android.view.View
import android.widget.Button
import android.widget.LinearLayout
import android.widget.TextView
import androidx.core.content.ContextCompat
import com.habitrpg.android.habitica.R
import com.habitrpg.android.habitica.databinding.DialogPetSuggestHatchBinding
import com.habitrpg.android.habitica.extensions.dpToPx
import com.habitrpg.android.habitica.extensions.getThemeColor
import com.habitrpg.android.habitica.extensions.inflate
import com.habitrpg.android.habitica.helpers.RxErrorHandler
import com.habitrpg.android.habitica.models.inventory.Animal
import com.habitrpg.android.habitica.models.inventory.Egg
@ -109,18 +112,11 @@ class PetSuggestHatchDialog(context: Context) : HabiticaAlertDialog(context) {
addButton(R.string.close, true)
if (hatchPrice > 0) {
val linearLayout = LinearLayout(context)
val label = TextView(context)
label.setText(R.string.hatch)
label.setTextColor(ContextCompat.getColor(context, R.color.colorPrimary))
linearLayout.addView(label)
val layoutParams: LinearLayout.LayoutParams = LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT)
layoutParams.setMargins(0, 0, 4.dpToPx(context), 0)
label.layoutParams = layoutParams
val priceView = CurrencyView(context, "gems", true)
priceView.value = hatchPrice.toDouble()
linearLayout.addView(priceView)
val linearLayout = layoutInflater.inflate(R.layout.dialog_hatch_pet_button, null) as? LinearLayout ?: return
val priceView = linearLayout.findViewById<CurrencyView>(R.id.currencyView)
priceView?.value = hatchPrice.toDouble()
priceView?.currency = "gems"
addButton(linearLayout, true) { _, _ ->
val activity = (getActivity() as? MainActivity) ?: return@addButton
val thisPotion = potion ?: return@addButton

View file

@ -13,6 +13,9 @@ import com.habitrpg.android.habitica.ui.helpers.DataBindingUtils
class WonChallengeDialog(context: Context) : HabiticaAlertDialog(context) {
fun configure(data: ChallengeWonData?) {
val imageView = additionalContentView?.findViewById<SimpleDraweeView>(R.id.achievement_view);
DataBindingUtils.loadImage(imageView, "achievement-karaoke-2x")
if (data?.name != null) {
additionalContentView?.findViewById<TextView>(R.id.description_view)?.text = context.getString(R.string.won_achievement_description, data.name).fromHtml()
}
@ -30,9 +33,6 @@ class WonChallengeDialog(context: Context) : HabiticaAlertDialog(context) {
val inflater = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as? LayoutInflater
val view = inflater?.inflate(R.layout.dialog_won_challenge, null)
setTitle(R.string.you_won_challenge)
DataBindingUtils.loadImage(view?.findViewById(R.id.achievement_view), "achievement-karaoke2x")
setAdditionalContentView(view)
}
}

View file

@ -10,7 +10,7 @@
{
"type": "SINGLE",
"filters": [],
"versionCode": 2644,
"versionCode": 2650,
"versionName": "3.1",
"outputFile": "Habitica-staff-release.apk"
}