mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-04-14 19:56:32 +00:00
Adventure guide improvements
This commit is contained in:
parent
f0f7d8228a
commit
1c93ffdc4f
16 changed files with 70 additions and 40 deletions
BIN
Habitica/res/drawable-hdpi/onboarding_done_art.png
Normal file
BIN
Habitica/res/drawable-hdpi/onboarding_done_art.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 19 KiB |
BIN
Habitica/res/drawable-mdpi/onboarding_done_art.png
Normal file
BIN
Habitica/res/drawable-mdpi/onboarding_done_art.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.7 KiB |
BIN
Habitica/res/drawable-xhdpi/onboarding_done_art.png
Normal file
BIN
Habitica/res/drawable-xhdpi/onboarding_done_art.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 8.1 KiB |
BIN
Habitica/res/drawable-xxhdpi/onboarding_done_art.png
Normal file
BIN
Habitica/res/drawable-xxhdpi/onboarding_done_art.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 25 KiB |
|
|
@ -5,9 +5,7 @@
|
|||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingBottom="8dp">
|
||||
android:gravity="center_vertical">
|
||||
<RelativeLayout
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="86dp">
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@
|
|||
android:layout_marginEnd="30dp"
|
||||
android:layout_marginBottom="@dimen/spacing_medium"/>
|
||||
<TextView
|
||||
android:id="@+id/description_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_horizontal"
|
||||
|
|
@ -88,7 +89,7 @@
|
|||
android:layout_marginBottom="@dimen/spacing_medium"
|
||||
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
|
||||
android:progressBackgroundTint="@color/gray_600"
|
||||
android:progressBackgroundTintMode="src_in"
|
||||
android:progressBackgroundTintMode="src_over"
|
||||
android:progressTint="@color/yellow_50"/>
|
||||
|
||||
<LinearLayout
|
||||
|
|
|
|||
|
|
@ -10,16 +10,16 @@
|
|||
android:layout_width="52dp"
|
||||
android:layout_height="56dp"
|
||||
app:actualImageScaleType="fitCenter"
|
||||
android:layout_marginTop="6dp"
|
||||
android:layout_marginBottom="6dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:layout_marginStart="30dp"/>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginTop="6dp"
|
||||
android:layout_marginBottom="6dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:layout_marginStart="17dp"
|
||||
android:layout_marginEnd="30dp">
|
||||
<TextView
|
||||
|
|
|
|||
|
|
@ -38,10 +38,10 @@
|
|||
android:layout_marginBottom="10dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/description_view"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/complete_for_gold"
|
||||
android:textColor="@color/gray_50"
|
||||
android:textSize="12sp" />
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:gravity="center_horizontal">
|
||||
<LinearLayout
|
||||
android:id="@+id/achievement_wrapper"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
|
|
@ -27,6 +28,11 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/sparkles_right" />
|
||||
</LinearLayout>
|
||||
<ImageView
|
||||
android:id="@+id/onboarding_done_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/onboarding_done_art" />
|
||||
<TextView
|
||||
android:id="@+id/title_view"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
|||
|
|
@ -11,21 +11,27 @@
|
|||
android:gravity="center"
|
||||
android:layout_marginTop="@dimen/spacing_small"
|
||||
android:layout_marginBottom="@dimen/spacing_large">
|
||||
|
||||
<com.facebook.drawee.view.SimpleDraweeView
|
||||
android:id="@+id/egg_view"
|
||||
<FrameLayout
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="80dp"
|
||||
android:scaleType="center"
|
||||
android:layout_marginEnd="@dimen/spacing_large"
|
||||
app:actualImageScaleType="center"
|
||||
android:background="@drawable/layout_rounded_bg_gray_700"/>
|
||||
<com.facebook.drawee.view.SimpleDraweeView
|
||||
android:id="@+id/hatchingPotion_view"
|
||||
android:background="@drawable/layout_rounded_bg_gray_700"
|
||||
android:layout_marginEnd="@dimen/spacing_large">
|
||||
<com.facebook.drawee.view.SimpleDraweeView
|
||||
android:id="@+id/egg_view"
|
||||
android:layout_width="@dimen/gear_image_size"
|
||||
android:layout_height="@dimen/gear_image_size"
|
||||
android:layout_gravity="center"/>
|
||||
</FrameLayout>
|
||||
<FrameLayout
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="80dp"
|
||||
app:actualImageScaleType="center"
|
||||
android:background="@drawable/layout_rounded_bg_gray_700" />
|
||||
android:background="@drawable/layout_rounded_bg_gray_700">
|
||||
<com.facebook.drawee.view.SimpleDraweeView
|
||||
android:id="@+id/hatchingPotion_view"
|
||||
android:layout_width="@dimen/gear_image_size"
|
||||
android:layout_height="@dimen/gear_image_size"
|
||||
android:layout_gravity="center" />
|
||||
</FrameLayout>
|
||||
</LinearLayout>
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
|||
|
|
@ -1018,10 +1018,10 @@
|
|||
<string name="pet_ownership_fraction">%1$d/%2$d</string>
|
||||
<string name="task_display">Task list display</string>
|
||||
<string name="onboarding_tasks">Onboarding Tasks</string>
|
||||
<string name="complete_for_gold">Complete to earn 100 Gold!</string>
|
||||
<string name="complete_for_gold"><![CDATA[Complete to earn <font color="#EE9109"><b>100 Gold</b></font>!]]></string>
|
||||
<string name="delete_checklist_entry">Delete…</string>
|
||||
<string name="getting_started">Getting Started</string>
|
||||
<string name="adventure_guide_description">Complete these onboarding tasks and you’ll earn 5 Achievements and 100 Gold once you’re done!</string>
|
||||
<string name="adventure_guide_description"><![CDATA[Complete these onboarding tasks and you’ll earn <b>5 Achievements</b> and <font color="#EE9109"><b>100 Gold</b></font> once you’re done!]]></string>
|
||||
<string name="your_progress">Your Progress</string>
|
||||
<string name="lets_get_started">Let\'s get started</string>
|
||||
<string name="percent_completed">%d%% Complete</string>
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ class UserRepositoryImpl(localRepository: UserLocalRepository, apiClient: ApiCli
|
|||
|
||||
@Suppress("ReturnCount")
|
||||
override fun retrieveUser(withTasks: Boolean, forced: Boolean): Flowable<User> {
|
||||
// Only retrieve again after 3 minutes or it's forced.
|
||||
if (forced || this.lastSync == null || Date().time - (this.lastSync?.time ?: 0) > 180000) {
|
||||
lastSync = Date()
|
||||
return apiClient.retrieveUser(withTasks)
|
||||
|
|
|
|||
|
|
@ -1,9 +1,12 @@
|
|||
package com.habitrpg.android.habitica.ui.activities
|
||||
|
||||
import android.graphics.Paint
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.text.Html
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.widget.TextView
|
||||
import androidx.core.app.NavUtils
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.habitrpg.android.habitica.R
|
||||
|
|
@ -60,6 +63,13 @@ class AdventureGuideActivity : BaseActivity() {
|
|||
Pair("fedPet", getString(R.string.feedPet_description)),
|
||||
Pair("purchasedEquipment", getString(R.string.purchase_equipment_description))
|
||||
)
|
||||
|
||||
val descriptionText = getString(R.string.adventure_guide_description)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
binding.descriptionView.setText(Html.fromHtml(descriptionText, Html.FROM_HTML_MODE_LEGACY), TextView.BufferType.SPANNABLE)
|
||||
} else {
|
||||
binding.descriptionView.setText(Html.fromHtml(descriptionText), TextView.BufferType.SPANNABLE)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
|
|
|
|||
|
|
@ -509,9 +509,9 @@ open class MainActivity : BaseActivity(), TutorialView.OnTutorialReaction {
|
|||
return super.onKeyUp(keyCode, event)
|
||||
}
|
||||
|
||||
protected fun retrieveUser() {
|
||||
protected fun retrieveUser(forced: Boolean = false) {
|
||||
if (hostConfig.hasAuthentication()) {
|
||||
compositeSubscription.add(this.userRepository.retrieveUser(true)
|
||||
compositeSubscription.add(this.userRepository.retrieveUser(true, forced)
|
||||
.doOnNext { user1 ->
|
||||
FirebaseAnalytics.getInstance(this).setUserProperty("has_party", if (user1.party?.id?.isNotEmpty() == true) "true" else "false")
|
||||
FirebaseAnalytics.getInstance(this).setUserProperty("is_subscribed", if (user1.isSubscribed) "true" else "false")
|
||||
|
|
@ -693,7 +693,7 @@ open class MainActivity : BaseActivity(), TutorialView.OnTutorialReaction {
|
|||
compositeSubscription.add(Completable.complete()
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(Action {
|
||||
retrieveUser()
|
||||
retrieveUser(true)
|
||||
val dialog = AchievementDialog(this)
|
||||
dialog.setType(event.type)
|
||||
dialog.enqueue()
|
||||
|
|
@ -707,7 +707,7 @@ open class MainActivity : BaseActivity(), TutorialView.OnTutorialReaction {
|
|||
compositeSubscription.add(Completable.complete()
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(Action {
|
||||
retrieveUser()
|
||||
retrieveUser(true)
|
||||
val dialog = FirstDropDialog(this)
|
||||
dialog.configure(event.egg, event.hatchingPotion)
|
||||
dialog.enqueue()
|
||||
|
|
|
|||
|
|
@ -1,8 +1,11 @@
|
|||
package com.habitrpg.android.habitica.ui.views.adventureGuide
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import android.text.Html
|
||||
import android.util.AttributeSet
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.TextView
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.habitrpg.android.habitica.R
|
||||
import com.habitrpg.android.habitica.databinding.AdventureGuideMenuBannerBinding
|
||||
|
|
@ -18,6 +21,12 @@ class AdventureGuideMenuBanner @JvmOverloads constructor(
|
|||
|
||||
init {
|
||||
background = ContextCompat.getDrawable(context, R.drawable.adventure_guide_menu_bg)
|
||||
val descriptionText = context.getString(R.string.complete_for_gold)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
binding.descriptionView.setText(Html.fromHtml(descriptionText, Html.FROM_HTML_MODE_LEGACY), TextView.BufferType.SPANNABLE)
|
||||
} else {
|
||||
binding.descriptionView.setText(Html.fromHtml(descriptionText), TextView.BufferType.SPANNABLE)
|
||||
}
|
||||
}
|
||||
|
||||
fun updateData(user: User) {
|
||||
|
|
|
|||
|
|
@ -7,24 +7,19 @@ 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.databinding.DialogAchievementDetailBinding
|
||||
import com.habitrpg.android.habitica.extensions.layoutInflater
|
||||
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?
|
||||
private val binding: DialogAchievementDetailBinding = DialogAchievementDetailBinding.inflate(context.layoutInflater)
|
||||
|
||||
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)
|
||||
binding.titleView.visibility = View.VISIBLE
|
||||
setAdditionalContentView(binding.root)
|
||||
}
|
||||
|
||||
fun setType(type: String) {
|
||||
|
|
@ -47,14 +42,18 @@ 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")
|
||||
binding.titleView.text = context.getString(titleID)
|
||||
binding.descriptionView.text = context.getString(descriptionID)
|
||||
DataBindingUtils.loadImage(binding.iconView, "achievement-${iconName}2x")
|
||||
if (iconName == "onboardingComplete") {
|
||||
setTitle(R.string.onboardingComplete_achievement_title)
|
||||
titleView?.setTextSize(TypedValue.COMPLEX_UNIT_SP,14f)
|
||||
binding.titleView.setTextSize(TypedValue.COMPLEX_UNIT_SP,14f)
|
||||
binding.achievementWrapper.visibility = View.GONE
|
||||
binding.onboardingDoneIcon.visibility = View.VISIBLE
|
||||
} else {
|
||||
setTitle(R.string.achievement_title)
|
||||
binding.achievementWrapper.visibility = View.VISIBLE
|
||||
binding.onboardingDoneIcon.visibility = View.GONE
|
||||
}
|
||||
addButton(R.string.view_achievements, isPrimary = true, isDestructive = false) { _, _ ->
|
||||
MainNavigationController.navigate(R.id.achievementsFragment)
|
||||
|
|
|
|||
Loading…
Reference in a new issue