show popups when user receives certain achievements. Fixes #1162
|
|
@ -152,7 +152,7 @@ android {
|
|||
buildConfigField "String", "TESTING_LEVEL", "\"production\""
|
||||
multiDexEnabled true
|
||||
|
||||
versionCode 2219
|
||||
versionCode 2222
|
||||
versionName "2.1"
|
||||
}
|
||||
|
||||
|
|
|
|||
BIN
Habitica/res/drawable-hdpi/sparkles_left.png
Normal file
|
After Width: | Height: | Size: 1.8 KiB |
BIN
Habitica/res/drawable-hdpi/sparkles_right.png
Normal file
|
After Width: | Height: | Size: 1.8 KiB |
BIN
Habitica/res/drawable-mdpi/sparkles_left.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
Habitica/res/drawable-mdpi/sparkles_right.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
Habitica/res/drawable-xhdpi/sparkles_left.png
Normal file
|
After Width: | Height: | Size: 2.1 KiB |
BIN
Habitica/res/drawable-xhdpi/sparkles_right.png
Normal file
|
After Width: | Height: | Size: 2 KiB |
BIN
Habitica/res/drawable-xxhdpi/sparkles_left.png
Normal file
|
After Width: | Height: | Size: 3 KiB |
BIN
Habitica/res/drawable-xxhdpi/sparkles_right.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
Habitica/res/drawable-xxxhdpi/sparkles_left.png
Normal file
|
After Width: | Height: | Size: 4 KiB |
BIN
Habitica/res/drawable-xxxhdpi/sparkles_right.png
Normal file
|
After Width: | Height: | Size: 3.9 KiB |
|
|
@ -3,12 +3,36 @@
|
|||
android:orientation="vertical" android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_horizontal">
|
||||
<com.facebook.drawee.view.SimpleDraweeView
|
||||
android:id="@+id/icon_view"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="52dp"
|
||||
android:scaleType="center"
|
||||
android:layout_marginBottom="@dimen/spacing_large"/>
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:layout_marginTop="@dimen/spacing_small"
|
||||
android:layout_marginBottom="@dimen/spacing_small">
|
||||
<ImageView
|
||||
android:layout_width="41dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/sparkles_left" />
|
||||
<com.facebook.drawee.view.SimpleDraweeView
|
||||
android:id="@+id/icon_view"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="52dp"
|
||||
android:scaleType="center"
|
||||
android:layout_marginStart="@dimen/spacing_large"
|
||||
android:layout_marginEnd="@dimen/spacing_large" />
|
||||
<ImageView
|
||||
android:layout_width="41dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/sparkles_right" />
|
||||
</LinearLayout>
|
||||
<TextView
|
||||
android:id="@+id/title_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/SectionTitle"
|
||||
android:gravity="center_horizontal"
|
||||
android:visibility="gone"
|
||||
android:layout_marginBottom="@dimen/spacing_medium"/>
|
||||
<TextView
|
||||
android:id="@+id/description_view"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@
|
|||
tools:visibility="visible"
|
||||
android:layout_marginStart="@dimen/alert_side_padding"
|
||||
android:layout_marginEnd="@dimen/alert_side_padding"
|
||||
style="@style/Headline6"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
|
|
@ -44,6 +45,8 @@
|
|||
android:paddingBottom="@dimen/spacing_medium"
|
||||
android:paddingStart="@dimen/alert_side_padding"
|
||||
android:paddingEnd="@dimen/alert_side_padding"
|
||||
android:textColor="?textColorSecondary"
|
||||
style="@style/Body2"
|
||||
/>
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:layout_width="match_parent"
|
||||
|
|
@ -101,5 +104,7 @@
|
|||
android:visibility="gone"
|
||||
tools:visibility="visible"
|
||||
android:textSize="16sp"
|
||||
android:textAllCaps="false"/>
|
||||
android:textAllCaps="false"
|
||||
android:textColor="?colorAccent"
|
||||
/>
|
||||
</LinearLayout>
|
||||
|
|
|
|||
|
|
@ -822,15 +822,15 @@
|
|||
<string name="partyOnTitle">Party On</string>
|
||||
<string name="partyOnDescription">Your party grew to 4 members!</string>
|
||||
<string name="beastMasterTitle">Beast Master</string>
|
||||
<string name="beastMasterDescription">You have earned the \\\"Beast Master\\\" Achievement for collecting all the pets!</string>
|
||||
<string name="beastMasterDescription">You have earned the “Beast Master” Achievement for collecting all the pets!</string>
|
||||
<string name="mountMasterTitle">Mount Master</string>
|
||||
<string name="mountMasterDescription">You have earned the \\\"Mount Master\\\" achievement for taming all the mounts!</string>
|
||||
<string name="mountMasterDescription">You have earned the “Mount Master” achievement for taming all the mounts!</string>
|
||||
<string name="triadBingoTitle">Triad Bingo</string>
|
||||
<string name="triadBingoDescription">You have earned the \\\"Triad Bingo\\\" achievement for finding all the pets, taming all the mounts, and finding all the pets again!</string>
|
||||
<string name="triadBingoDescription">You have earned the “Triad Bingo” achievement for finding all the pets, taming all the mounts, and finding all the pets again!</string>
|
||||
<string name="joinedGuildTitle">Joined a Guild</string>
|
||||
<string name="joinedGuildDescription">Ventured into the social side of Habitica by joining a Guild!</string>
|
||||
<string name="joinedChallengeTitle">Joined a Challenge</string>
|
||||
<string name="joinedChallengeDescription">You put themselves to the test by joining a Challenge!</string>
|
||||
<string name="inviteFriendTitle">Invited a Friend</string>
|
||||
<string name="inviteFriendDescription">invitedinvited a friend (or friends) who joined you on your adventure!</string>
|
||||
<string name="inviteFriendDescription">You invited a friend (or friends) who joined you on your adventure!</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@ class NotificationsManager (private val context: Context) {
|
|||
|
||||
private val notifications: BehaviorSubject<List<Notification>>
|
||||
|
||||
private var lastNotificationHandling: Date? = null
|
||||
|
||||
init {
|
||||
this.seenNotifications = HashMap()
|
||||
this.notifications = BehaviorSubject.create()
|
||||
|
|
@ -49,6 +51,11 @@ class NotificationsManager (private val context: Context) {
|
|||
}
|
||||
|
||||
fun handlePopupNotifications(notifications: List<Notification>): Boolean? {
|
||||
val now = Date()
|
||||
if (now.time - (lastNotificationHandling?.time ?: 0) < 500) {
|
||||
return true
|
||||
}
|
||||
lastNotificationHandling = now
|
||||
notifications
|
||||
.filter { !this.seenNotifications.containsKey(it.id) }
|
||||
.map {
|
||||
|
|
|
|||
|
|
@ -1,12 +1,31 @@
|
|||
package com.habitrpg.android.habitica.ui.views.dialogs
|
||||
|
||||
import android.content.Context
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.widget.TextView
|
||||
import com.facebook.drawee.view.SimpleDraweeView
|
||||
import com.habitrpg.android.habitica.R
|
||||
import com.habitrpg.android.habitica.helpers.MainNavigationController
|
||||
import com.habitrpg.android.habitica.models.Notification
|
||||
import com.habitrpg.android.habitica.ui.helpers.DataBindingUtils
|
||||
|
||||
class AchievementDialog(context: Context) : HabiticaAlertDialog(context) {
|
||||
|
||||
private var iconView: SimpleDraweeView?
|
||||
private var titleView: TextView?
|
||||
private var descriptionView: TextView?
|
||||
|
||||
init {
|
||||
val inflater = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as? LayoutInflater
|
||||
val view = inflater?.inflate(R.layout.dialog_achievement_detail, null)
|
||||
iconView = view?.findViewById(R.id.icon_view)
|
||||
titleView = view?.findViewById(R.id.title_view)
|
||||
titleView?.visibility = View.VISIBLE
|
||||
descriptionView = view?.findViewById(R.id.description_view)
|
||||
setAdditionalContentView(view)
|
||||
}
|
||||
|
||||
fun setType(type: String) {
|
||||
when (type) {
|
||||
Notification.Type.ACHIEVEMENT_PARTY_UP.type -> configure(R.string.partyUpTitle, R.string.partyUpDescription, "partyUp")
|
||||
|
|
@ -21,13 +40,13 @@ class AchievementDialog(context: Context) : HabiticaAlertDialog(context) {
|
|||
}
|
||||
|
||||
private fun configure(titleID: Int, descriptionID: Int, iconName: String) {
|
||||
titleView?.text = context.getString(titleID)
|
||||
descriptionView?.text = context.getString(descriptionID)
|
||||
DataBindingUtils.loadImage(iconView, "achievement-${iconName}2x")
|
||||
setTitle(R.string.achievement_title)
|
||||
|
||||
|
||||
addButton(R.string.onwards, true)
|
||||
addButton(R.string.view_achievements, isPrimary = false, isDestructive = false) { _, _ ->
|
||||
MainNavigationController.navigate(R.id.achievementsFragment)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||