Skip to content

Commit 614546d

Browse files
committed
Improve background handling
1 parent b65a360 commit 614546d

File tree

6 files changed

+26
-8
lines changed

6 files changed

+26
-8
lines changed

Habitica/res/navigation/navigation.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,12 @@
110110
<fragment
111111
android:id="@+id/shopsFragment"
112112
android:name="com.habitrpg.android.habitica.ui.fragments.inventory.shops.ShopsFragment"
113-
android:label="@string/sidebar_shops" />
113+
android:label="@string/sidebar_shops" >
114+
<argument
115+
android:name="selectedTab"
116+
app:argType="integer"
117+
android:defaultValue="0" />
118+
</fragment>
114119
<fragment
115120
android:id="@+id/avatarOverviewFragment"
116121
android:name="com.habitrpg.android.habitica.ui.fragments.inventory.customization.AvatarOverviewFragment"

Habitica/res/values/styles.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,11 +272,11 @@
272272
</style>
273273

274274
<style name="AlertDialogTheme" parent="Theme.AppCompat.Light.Dialog.Alert">
275-
<item name="colorAccent">@color/brand_100</item>
275+
<item name="colorAccent">@color/brand_400</item>
276276
</style>
277277

278278
<style name="HabiticaAlertDialogTheme" parent="Theme.AppCompat.Light.Dialog.Alert">
279-
<item name="colorAccent">@color/brand_100</item>
279+
<item name="colorAccent">@color/brand_400</item>
280280
<item name="android:windowFrame">@null</item>
281281
<item name="android:windowIsFloating">true</item>
282282
<item name="android:windowContentOverlay">@null</item>

Habitica/src/main/java/com/habitrpg/android/habitica/ui/adapter/CustomizationRecyclerViewAdapter.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ class CustomizationRecyclerViewAdapter : androidx.recyclerview.widget.RecyclerVi
163163
val dialog = HabiticaAlertDialog(itemView.context)
164164
dialog.setMessage(R.string.purchase_from_timetravel_shop)
165165
dialog.addButton(R.string.go_shopping, true) { _, _ ->
166-
MainNavigationController.navigate(R.id.shopsFragment)
166+
MainNavigationController.navigate(R.id.shopsFragment, bundleOf(Pair("selectedTab", 3)))
167167
}
168168
dialog.addButton(R.string.reward_dialog_dismiss, false)
169169
dialog.show()

Habitica/src/main/java/com/habitrpg/android/habitica/ui/fragments/inventory/shops/ShopsFragment.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@ class ShopsFragment : BaseMainFragment() {
3939
setViewPagerAdapter()
4040
toolbarAccessoryContainer?.addView(currencyView)
4141

42+
arguments?.let {
43+
val args = ShopsFragmentArgs.fromBundle(it)
44+
if (args.selectedTab > 0) {
45+
viewPager.currentItem = args.selectedTab
46+
}
47+
}
48+
4249
compositeSubscription.add(userRepository.getUser().subscribe(Consumer { updateCurrencyView(it) }, RxErrorHandler.handleEmptyError()))
4350
}
4451

Habitica/src/main/java/com/habitrpg/android/habitica/ui/views/shops/PurchaseDialog.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ class PurchaseDialog(context: Context, component: UserComponent?, val item: Shop
206206
val gemsLeft = if (shopItem.limitedNumberLeft != null) shopItem.limitedNumberLeft else 0
207207
if ((gemsLeft == 0 && shopItem.purchaseType == "gems") || shopItem.canAfford(user, false)) {
208208
val observable: Flowable<Any>
209-
if (shopIdentifier != null && shopIdentifier == Shop.TIME_TRAVELERS_SHOP || "mystery_set" == shopItem.purchaseType) {
209+
if (shopIdentifier != null && shopIdentifier == Shop.TIME_TRAVELERS_SHOP || "mystery_set" == shopItem.purchaseType || shopItem.currency == "hourglasses") {
210210
observable = if (shopItem.purchaseType == "gear") {
211211
inventoryRepository.purchaseMysterySet(shopItem.key)
212212
} else {
@@ -253,7 +253,7 @@ class PurchaseDialog(context: Context, component: UserComponent?, val item: Shop
253253
.flatMap { userRepository.retrieveUser(withTasks = false, forced = true) }
254254
.flatMap { inventoryRepository.retrieveInAppRewards() }
255255
.subscribe({
256-
if (item.isTypeGear) {
256+
if (item.isTypeGear || item.currency == "hourglasses") {
257257
EventBus.getDefault().post(GearPurchasedEvent(item))
258258
}
259259
}) { throwable ->
@@ -280,9 +280,9 @@ class PurchaseDialog(context: Context, component: UserComponent?, val item: Shop
280280

281281
private fun setBuyButtonEnabled(enabled: Boolean) {
282282
if (enabled) {
283-
buyButton.alpha = 0.5f
284-
} else {
285283
buyButton.alpha = 1.0f
284+
} else {
285+
buyButton.alpha = 0.5f
286286
}
287287
}
288288
}

Habitica/src/main/java/com/habitrpg/android/habitica/ui/views/shops/PurchaseDialogContent.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@ import android.widget.TextView
88
import com.facebook.drawee.backends.pipeline.Fresco
99
import com.facebook.drawee.view.SimpleDraweeView
1010
import com.habitrpg.android.habitica.R
11+
import com.habitrpg.android.habitica.extensions.dpToPx
1112
import com.habitrpg.android.habitica.models.inventory.QuestContent
1213
import com.habitrpg.android.habitica.models.shops.ShopItem
1314
import com.habitrpg.android.habitica.ui.helpers.DataBindingUtils
1415
import com.habitrpg.android.habitica.ui.helpers.bindView
1516

17+
1618
abstract class PurchaseDialogContent : LinearLayout {
1719

1820
private val imageView: SimpleDraweeView by bindView(R.id.imageView)
@@ -43,6 +45,10 @@ abstract class PurchaseDialogContent : LinearLayout {
4345
.setAutoPlayAnimations(true)
4446
.build()
4547
imageView.controller = controller
48+
val params = imageView.layoutParams
49+
params.height = 147.dpToPx(context)
50+
params.width = 140.dpToPx(context)
51+
imageView.layoutParams = params
4652
} else {
4753
DataBindingUtils.loadImage(imageView, item.imageName)
4854
}

0 commit comments

Comments
 (0)