mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-04-14 19:56:32 +00:00
Fix formatting
This commit is contained in:
parent
3cfa8ac669
commit
49c2dd1a40
62 changed files with 299 additions and 312 deletions
|
|
@ -18,7 +18,6 @@
|
|||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/MainAppTheme"
|
||||
tools:replace="android:name"
|
||||
android:fullBackupContent="@xml/backup_descriptor"
|
||||
android:configChanges="orientation"
|
||||
android:networkSecurityConfig="@xml/network_security_config">
|
||||
|
|
|
|||
|
|
@ -121,8 +121,8 @@ abstract class HabiticaBaseApplication : Application(), Application.ActivityLife
|
|||
val configuration: Configuration = resources.configuration
|
||||
val languageHelper = LanguageHelper(sharedPrefs.getString("language", "en"))
|
||||
if (if (SDK_INT >= Build.VERSION_CODES.N) {
|
||||
configuration.locales.isEmpty || configuration.locales[0] != languageHelper.locale
|
||||
} else {
|
||||
configuration.locales.isEmpty || configuration.locales[0] != languageHelper.locale
|
||||
} else {
|
||||
@Suppress("DEPRECATION")
|
||||
configuration.locale != languageHelper.locale
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,14 +57,6 @@ import io.reactivex.rxjava3.core.Flowable
|
|||
import io.reactivex.rxjava3.core.FlowableTransformer
|
||||
import io.reactivex.rxjava3.functions.Consumer
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers
|
||||
import okhttp3.Cache
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.Request
|
||||
import okhttp3.logging.HttpLoggingInterceptor
|
||||
import retrofit2.HttpException
|
||||
import retrofit2.Retrofit
|
||||
import retrofit2.adapter.rxjava3.RxJava3CallAdapterFactory
|
||||
import retrofit2.converter.gson.GsonConverterFactory
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
import java.net.SocketException
|
||||
|
|
@ -73,6 +65,14 @@ import java.net.UnknownHostException
|
|||
import java.util.GregorianCalendar
|
||||
import java.util.concurrent.TimeUnit
|
||||
import javax.net.ssl.SSLException
|
||||
import okhttp3.Cache
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.Request
|
||||
import okhttp3.logging.HttpLoggingInterceptor
|
||||
import retrofit2.HttpException
|
||||
import retrofit2.Retrofit
|
||||
import retrofit2.adapter.rxjava3.RxJava3CallAdapterFactory
|
||||
import retrofit2.converter.gson.GsonConverterFactory
|
||||
|
||||
class ApiClientImpl(
|
||||
private val gsonConverter: GsonConverterFactory,
|
||||
|
|
|
|||
|
|
@ -5,10 +5,13 @@ import androidx.lifecycle.LiveData
|
|||
import androidx.lifecycle.Observer
|
||||
|
||||
fun <T> LiveData<T>.observeOnce(lifecycleOwner: LifecycleOwner, observer: Observer<T>) {
|
||||
observe(lifecycleOwner, object : Observer<T> {
|
||||
override fun onChanged(t: T?) {
|
||||
observer.onChanged(t)
|
||||
removeObserver(this)
|
||||
observe(
|
||||
lifecycleOwner,
|
||||
object : Observer<T> {
|
||||
override fun onChanged(t: T?) {
|
||||
observer.onChanged(t)
|
||||
removeObserver(this)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -116,4 +116,4 @@ fun Long.getShortRemainingString(): String {
|
|||
|
||||
fun Duration.getMinuteOrSeconds(): DurationUnit {
|
||||
return if (this.inWholeHours < 1) DurationUnit.SECONDS else DurationUnit.MINUTES
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,4 +7,4 @@ import io.reactivex.rxjava3.functions.Consumer
|
|||
|
||||
fun <T : Any> Flowable<T>.subscribeWithErrorHandler(function: Consumer<T>): Disposable {
|
||||
return subscribe(function, RxErrorHandler.handleEmptyError())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,9 +4,9 @@ data class Optional<T>(val value: T?) {
|
|||
val isEmpty = value == null
|
||||
|
||||
val assertedValue: T
|
||||
get() {
|
||||
assert(!isEmpty)
|
||||
return value!!
|
||||
}
|
||||
get() {
|
||||
assert(!isEmpty)
|
||||
return value!!
|
||||
}
|
||||
}
|
||||
fun <T> T?.asOptional() = Optional(this)
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ import android.util.Log
|
|||
import androidx.core.content.edit
|
||||
import androidx.core.os.bundleOf
|
||||
import com.google.android.gms.ads.AdRequest
|
||||
import com.google.android.gms.ads.FullScreenContentCallback
|
||||
import com.google.android.gms.ads.LoadAdError
|
||||
import com.google.android.gms.ads.MobileAds
|
||||
import com.google.android.gms.ads.OnUserEarnedRewardListener
|
||||
|
|
@ -32,21 +31,21 @@ enum class AdType {
|
|||
FAINT;
|
||||
|
||||
val adUnitID: String
|
||||
get() {
|
||||
return when (this) {
|
||||
ARMOIRE -> "ca-app-pub-5911973472413421/9392092486"
|
||||
SPELL -> "ca-app-pub-5911973472413421/1738504765"
|
||||
FAINT -> "ca-app-pub-5911973472413421/1738504765"
|
||||
get() {
|
||||
return when (this) {
|
||||
ARMOIRE -> "ca-app-pub-5911973472413421/9392092486"
|
||||
SPELL -> "ca-app-pub-5911973472413421/1738504765"
|
||||
FAINT -> "ca-app-pub-5911973472413421/1738504765"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val cooldownTime: Date?
|
||||
get() {
|
||||
return when (this) {
|
||||
SPELL -> Date(Date().time + 1.toDuration(DurationUnit.HOURS).inWholeMilliseconds)
|
||||
else -> null
|
||||
get() {
|
||||
return when (this) {
|
||||
SPELL -> Date(Date().time + 1.toDuration(DurationUnit.HOURS).inWholeMilliseconds)
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun String.md5(): String? {
|
||||
|
|
@ -59,12 +58,13 @@ fun String.md5(): String? {
|
|||
}
|
||||
return sb.toString()
|
||||
} catch (e: java.security.NoSuchAlgorithmException) {
|
||||
return null
|
||||
} catch (ex: UnsupportedEncodingException) {
|
||||
return null
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
class AdHandler(val activity: Activity, val type: AdType, val rewardAction: (Boolean) -> Unit): OnUserEarnedRewardListener {
|
||||
class AdHandler(val activity: Activity, val type: AdType, val rewardAction: (Boolean) -> Unit) : OnUserEarnedRewardListener {
|
||||
private var rewardedAd: RewardedAd? = null
|
||||
|
||||
companion object {
|
||||
|
|
@ -170,19 +170,22 @@ class AdHandler(val activity: Activity, val type: AdType, val rewardAction: (Boo
|
|||
}
|
||||
}
|
||||
|
||||
RewardedAd.load(activity, type.adUnitID, adRequest, object : RewardedAdLoadCallback() {
|
||||
override fun onAdFailedToLoad(adError: LoadAdError) {
|
||||
FirebaseCrashlytics.getInstance().recordException(Throwable(adError.message))
|
||||
rewardAction(false)
|
||||
onComplete?.invoke(false)
|
||||
}
|
||||
RewardedAd.load(
|
||||
activity, type.adUnitID, adRequest,
|
||||
object : RewardedAdLoadCallback() {
|
||||
override fun onAdFailedToLoad(adError: LoadAdError) {
|
||||
FirebaseCrashlytics.getInstance().recordException(Throwable(adError.message))
|
||||
rewardAction(false)
|
||||
onComplete?.invoke(false)
|
||||
}
|
||||
|
||||
override fun onAdLoaded(rewardedAd: RewardedAd) {
|
||||
this@AdHandler.rewardedAd = rewardedAd
|
||||
configureReward()
|
||||
onComplete?.invoke(true)
|
||||
override fun onAdLoaded(rewardedAd: RewardedAd) {
|
||||
this@AdHandler.rewardedAd = rewardedAd
|
||||
configureReward()
|
||||
onComplete?.invoke(true)
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -207,10 +210,7 @@ class AdHandler(val activity: Activity, val type: AdType, val rewardAction: (Boo
|
|||
}
|
||||
|
||||
private fun configureReward() {
|
||||
rewardedAd?.run {
|
||||
fullScreenContentCallback = object : FullScreenContentCallback() {
|
||||
}
|
||||
}
|
||||
rewardedAd?.run { }
|
||||
}
|
||||
|
||||
private fun showRewardedAd() {
|
||||
|
|
@ -226,12 +226,18 @@ class AdHandler(val activity: Activity, val type: AdType, val rewardAction: (Boo
|
|||
}
|
||||
|
||||
override fun onUserEarnedReward(rewardItem: RewardItem) {
|
||||
analyticsManager.logEvent("adRewardEarned", bundleOf(
|
||||
Pair("type", type.name)
|
||||
))
|
||||
FirebaseAnalytics.getInstance(activity).logEvent("adRewardEarned", bundleOf(
|
||||
Pair("type", type.name)
|
||||
))
|
||||
analyticsManager.logEvent(
|
||||
"adRewardEarned",
|
||||
bundleOf(
|
||||
Pair("type", type.name)
|
||||
)
|
||||
)
|
||||
FirebaseAnalytics.getInstance(activity).logEvent(
|
||||
"adRewardEarned",
|
||||
bundleOf(
|
||||
Pair("type", type.name)
|
||||
)
|
||||
)
|
||||
rewardAction(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -85,4 +85,4 @@ object Animations {
|
|||
anim.interpolator = AccelerateDecelerateInterpolator()
|
||||
return anim
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,21 +1,17 @@
|
|||
package com.habitrpg.android.habitica.helpers
|
||||
|
||||
import android.app.NotificationManager
|
||||
import android.content.Context
|
||||
import androidx.core.app.NotificationManagerCompat
|
||||
import com.habitrpg.android.habitica.data.ApiClient
|
||||
import com.habitrpg.android.habitica.models.Notification
|
||||
import com.habitrpg.android.habitica.models.tasks.RemindersItem
|
||||
import com.habitrpg.android.habitica.models.tasks.Task
|
||||
import io.reactivex.rxjava3.core.BackpressureStrategy
|
||||
import io.reactivex.rxjava3.core.Flowable
|
||||
import io.reactivex.rxjava3.subjects.BehaviorSubject
|
||||
import io.reactivex.rxjava3.subjects.PublishSubject
|
||||
import io.realm.RealmList
|
||||
import java.lang.ref.WeakReference
|
||||
import java.util.*
|
||||
|
||||
|
||||
class NotificationsManager {
|
||||
private val displayNotificationSubject = PublishSubject.create<Notification>()
|
||||
|
||||
|
|
|
|||
|
|
@ -35,6 +35,9 @@ import com.habitrpg.android.habitica.ui.activities.PurchaseActivity
|
|||
import com.habitrpg.android.habitica.ui.viewmodels.MainUserViewModel
|
||||
import com.habitrpg.android.habitica.ui.views.dialogs.HabiticaAlertDialog
|
||||
import io.reactivex.rxjava3.core.Flowable
|
||||
import java.util.Date
|
||||
import kotlin.time.DurationUnit
|
||||
import kotlin.time.toDuration
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.delay
|
||||
|
|
@ -42,9 +45,6 @@ import kotlinx.coroutines.launch
|
|||
import kotlinx.coroutines.withContext
|
||||
import org.json.JSONObject
|
||||
import retrofit2.HttpException
|
||||
import java.util.Date
|
||||
import kotlin.time.DurationUnit
|
||||
import kotlin.time.toDuration
|
||||
|
||||
class PurchaseHandler(
|
||||
private val context: Context,
|
||||
|
|
|
|||
|
|
@ -121,7 +121,6 @@ class TaskAlarmManager(
|
|||
)
|
||||
|
||||
setAlarm(context, cal.timeInMillis, sender)
|
||||
|
||||
}
|
||||
|
||||
private fun removeAlarmForRemindersItem(remindersItem: RemindersItem) {
|
||||
|
|
|
|||
|
|
@ -1,5 +0,0 @@
|
|||
package com.habitrpg.android.habitica.helpers
|
||||
|
||||
class TaskFilterHelper {
|
||||
|
||||
}
|
||||
|
|
@ -5,7 +5,6 @@ import android.graphics.Bitmap
|
|||
import android.graphics.Canvas
|
||||
import android.view.View
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.ImageView
|
||||
import com.habitrpg.android.habitica.R
|
||||
import com.habitrpg.android.habitica.data.InventoryRepository
|
||||
import com.habitrpg.android.habitica.executors.PostExecutionThread
|
||||
|
|
@ -13,7 +12,6 @@ import com.habitrpg.android.habitica.models.inventory.Food
|
|||
import com.habitrpg.android.habitica.models.inventory.Pet
|
||||
import com.habitrpg.android.habitica.models.responses.FeedResponse
|
||||
import com.habitrpg.android.habitica.ui.activities.BaseActivity
|
||||
import com.habitrpg.android.habitica.ui.helpers.DataBindingUtils
|
||||
import com.habitrpg.android.habitica.ui.helpers.loadImage
|
||||
import com.habitrpg.android.habitica.ui.views.PixelArtView
|
||||
import com.habitrpg.android.habitica.ui.views.SnackbarActivity
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ data class CustomizationFilter(
|
|||
var months: MutableList<String> = mutableListOf()
|
||||
) {
|
||||
val isFiltering: Boolean
|
||||
get() {
|
||||
return onlyPurchased || months.isNotEmpty()
|
||||
}
|
||||
get() {
|
||||
return onlyPurchased || months.isNotEmpty()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,11 +57,11 @@ open class RemindersItem : RealmObject, Parcelable {
|
|||
|
||||
fun getZonedDateTime(): ZonedDateTime? {
|
||||
val formatter: DateTimeFormatter =
|
||||
DateTimeFormatterBuilder().append(DateTimeFormatter.ISO_LOCAL_DATE)
|
||||
.appendPattern("['T'][' ']")
|
||||
.append(DateTimeFormatter.ISO_LOCAL_TIME)
|
||||
.appendPattern("[XX]")
|
||||
.toFormatter()
|
||||
DateTimeFormatterBuilder().append(DateTimeFormatter.ISO_LOCAL_DATE)
|
||||
.appendPattern("['T'][' ']")
|
||||
.append(DateTimeFormatter.ISO_LOCAL_TIME)
|
||||
.appendPattern("[XX]")
|
||||
.toFormatter()
|
||||
|
||||
val parsed: TemporalAccessor = formatter.parseBest(
|
||||
time,
|
||||
|
|
|
|||
|
|
@ -13,17 +13,17 @@ import io.realm.RealmList
|
|||
import io.realm.RealmObject
|
||||
import io.realm.annotations.Ignore
|
||||
import io.realm.annotations.PrimaryKey
|
||||
import java.util.Calendar
|
||||
import java.util.Date
|
||||
import java.util.GregorianCalendar
|
||||
import org.json.JSONArray
|
||||
import org.json.JSONException
|
||||
import java.time.LocalDateTime
|
||||
import java.time.ZoneId
|
||||
import java.time.ZonedDateTime
|
||||
import java.time.format.DateTimeFormatter
|
||||
import java.time.format.DateTimeFormatterBuilder
|
||||
import java.time.temporal.TemporalAccessor
|
||||
import java.util.Calendar
|
||||
import java.util.Date
|
||||
import java.util.GregorianCalendar
|
||||
import org.json.JSONArray
|
||||
import org.json.JSONException
|
||||
|
||||
open class Task : RealmObject, BaseMainObject, Parcelable {
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ import com.habitrpg.android.habitica.extensions.dpToPx
|
|||
import com.habitrpg.android.habitica.helpers.AppConfigManager
|
||||
import com.habitrpg.android.habitica.models.Avatar
|
||||
import com.habitrpg.android.habitica.ui.helpers.DataBindingUtils
|
||||
import io.reactivex.rxjava3.functions.Consumer
|
||||
import java.util.Date
|
||||
import java.util.EnumMap
|
||||
import java.util.concurrent.atomic.AtomicInteger
|
||||
|
|
|
|||
|
|
@ -25,11 +25,11 @@ import com.habitrpg.android.habitica.ui.viewmodels.MainUserViewModel
|
|||
import com.habitrpg.android.habitica.ui.views.ads.AdButton
|
||||
import com.habitrpg.android.habitica.ui.views.dialogs.HabiticaBottomSheetDialog
|
||||
import com.plattysoft.leonids.ParticleSystem
|
||||
import kotlinx.coroutines.launch
|
||||
import java.util.Locale
|
||||
import javax.inject.Inject
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
class ArmoireActivity: BaseActivity() {
|
||||
class ArmoireActivity : BaseActivity() {
|
||||
|
||||
private var equipmentKey: String? = null
|
||||
private var gold: Double? = null
|
||||
|
|
@ -78,18 +78,22 @@ class ArmoireActivity: BaseActivity() {
|
|||
Log.d("AdHandler", "Giving Armoire")
|
||||
val user = userViewModel.user.value ?: return@AdHandler
|
||||
val currentGold = user.stats?.gp ?: return@AdHandler
|
||||
compositeSubscription.add(userRepository.updateUser("stats.gp", currentGold + 100)
|
||||
.flatMap { inventoryRepository.buyItem(user, "armoire", 100.0, 1) }
|
||||
.subscribe({
|
||||
configure(it.armoire["type"] ?: "",
|
||||
it.armoire["dropKey"] ?: "",
|
||||
it.armoire["dropText"] ?: "",
|
||||
it.armoire["value"] ?: "")
|
||||
binding.adButton.state = AdButton.State.UNAVAILABLE
|
||||
binding.adButton.visibility = View.INVISIBLE
|
||||
hasAnimatedChanges = false
|
||||
gold = null
|
||||
}, RxErrorHandler.handleEmptyError()))
|
||||
compositeSubscription.add(
|
||||
userRepository.updateUser("stats.gp", currentGold + 100)
|
||||
.flatMap { inventoryRepository.buyItem(user, "armoire", 100.0, 1) }
|
||||
.subscribe({
|
||||
configure(
|
||||
it.armoire["type"] ?: "",
|
||||
it.armoire["dropKey"] ?: "",
|
||||
it.armoire["dropText"] ?: "",
|
||||
it.armoire["value"] ?: ""
|
||||
)
|
||||
binding.adButton.state = AdButton.State.UNAVAILABLE
|
||||
binding.adButton.visibility = View.INVISIBLE
|
||||
hasAnimatedChanges = false
|
||||
gold = null
|
||||
}, RxErrorHandler.handleEmptyError())
|
||||
)
|
||||
}
|
||||
handler.prepare {
|
||||
if (it && binding.adButton.state == AdButton.State.LOADING) {
|
||||
|
|
@ -217,4 +221,4 @@ class ArmoireActivity: BaseActivity() {
|
|||
dialog.setContentView(R.layout.armoire_drop_rate_dialog)
|
||||
dialog.show()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -236,7 +236,6 @@ abstract class BaseActivity : AppCompatActivity() {
|
|||
}
|
||||
|
||||
open fun hideConnectionProblem() {
|
||||
|
||||
}
|
||||
|
||||
fun shareContent(identifier: String, message: String, image: Bitmap? = null) {
|
||||
|
|
|
|||
|
|
@ -41,12 +41,12 @@ import com.habitrpg.android.habitica.ui.views.HabiticaIconsHelper
|
|||
import com.habitrpg.android.habitica.ui.views.dialogs.HabiticaAlertDialog
|
||||
import com.habitrpg.android.habitica.ui.views.dialogs.HabiticaProgressDialog
|
||||
import io.reactivex.rxjava3.core.Flowable
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import java.util.UUID
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Named
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
class ChallengeFormActivity : BaseActivity() {
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ import android.view.Menu
|
|||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import android.widget.TableLayout
|
||||
import android.widget.TableRow
|
||||
import android.widget.TextView
|
||||
|
|
@ -42,13 +41,13 @@ import com.habitrpg.android.habitica.ui.views.HabiticaSnackbar.SnackbarDisplayTy
|
|||
import com.habitrpg.android.habitica.ui.views.PixelArtView
|
||||
import com.habitrpg.android.habitica.ui.views.dialogs.HabiticaAlertDialog
|
||||
import io.reactivex.rxjava3.core.Flowable
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import java.text.SimpleDateFormat
|
||||
import javax.inject.Inject
|
||||
import kotlin.math.floor
|
||||
import kotlin.math.min
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
class FullProfileActivity : BaseActivity() {
|
||||
private var blocks: List<String> = listOf()
|
||||
|
|
|
|||
|
|
@ -68,13 +68,13 @@ import com.habitrpg.android.habitica.widget.AvatarStatsWidgetProvider
|
|||
import com.habitrpg.android.habitica.widget.DailiesWidgetProvider
|
||||
import com.habitrpg.android.habitica.widget.HabitButtonWidgetProvider
|
||||
import com.habitrpg.android.habitica.widget.TodoListWidgetProvider
|
||||
import javax.inject.Inject
|
||||
import kotlin.time.DurationUnit
|
||||
import kotlin.time.toDuration
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import javax.inject.Inject
|
||||
import kotlin.time.DurationUnit
|
||||
import kotlin.time.toDuration
|
||||
|
||||
open class MainActivity : BaseActivity(), SnackbarActivity {
|
||||
private var launchScreen: String? = null
|
||||
|
|
@ -288,7 +288,6 @@ open class MainActivity : BaseActivity(), SnackbarActivity {
|
|||
MainNavigationController.setup(navigationController)
|
||||
navigationController.addOnDestinationChangedListener { _, destination, arguments -> updateToolbarTitle(destination, arguments) }
|
||||
|
||||
|
||||
if (launchScreen == "/party") {
|
||||
viewModel.user.observeOnce(this) {
|
||||
if (viewModel.userViewModel.isUserInParty) {
|
||||
|
|
|
|||
|
|
@ -88,7 +88,8 @@ class CustomizationRecyclerViewAdapter() : androidx.recyclerview.widget.Recycler
|
|||
override fun getItemViewType(position: Int): Int {
|
||||
if (customizationList.size <= position) return 0
|
||||
return if (this.customizationList[position] is CustomizationSet &&
|
||||
(position < customizationList.size && customizationList[position+1] is CustomizationSet)) {
|
||||
(position < customizationList.size && customizationList[position + 1] is CustomizationSet)
|
||||
) {
|
||||
1
|
||||
} else if (this.customizationList[position] is CustomizationSet) {
|
||||
0
|
||||
|
|
|
|||
|
|
@ -112,7 +112,6 @@ class PetDetailRecyclerAdapter : androidx.recyclerview.widget.RecyclerView.Adapt
|
|||
currentPet
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ class ChatRecyclerViewAdapter(user: User?, private val isTavern: Boolean) : Base
|
|||
return copyMessageEvents.toFlowable(BackpressureStrategy.DROP)
|
||||
}
|
||||
|
||||
private fun expandMessage(message:ChatMessage) {
|
||||
private fun expandMessage(message: ChatMessage) {
|
||||
expandedMessageId = if (expandedMessageId == message.id) {
|
||||
null
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -128,11 +128,13 @@ class GuildListAdapter : BaseRecyclerViewAdapter<Group, RecyclerView.ViewHolder>
|
|||
binding.tagWrapper.removeAllViews()
|
||||
guild.categories?.forEach { category ->
|
||||
val textView = PillTextviewBinding.inflate(itemView.context.layoutInflater, binding.tagWrapper, true)
|
||||
textView.root.text = category.name?.split("_")?.joinToString(" ") { it.replaceFirstChar {
|
||||
if (it.isLowerCase()) it.titlecase(
|
||||
Locale.getDefault()
|
||||
) else it.toString()
|
||||
} }
|
||||
textView.root.text = category.name?.split("_")?.joinToString(" ") {
|
||||
it.replaceFirstChar {
|
||||
if (it.isLowerCase()) it.titlecase(
|
||||
Locale.getDefault()
|
||||
) else it.toString()
|
||||
}
|
||||
}
|
||||
textView.root.background = if (category.slug == "habitica_official") {
|
||||
textView.root.setTextColor(ContextCompat.getColor(itemView.context, R.color.white))
|
||||
ContextCompat.getDrawable(itemView.context, R.drawable.pill_bg_purple_400)
|
||||
|
|
|
|||
|
|
@ -50,10 +50,6 @@ import com.habitrpg.android.habitica.ui.viewmodels.NotificationsViewModel
|
|||
import com.habitrpg.android.habitica.ui.views.HabiticaSnackbar
|
||||
import io.reactivex.rxjava3.core.Flowable
|
||||
import io.reactivex.rxjava3.disposables.CompositeDisposable
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import java.util.Calendar
|
||||
import java.util.Date
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
|
@ -62,6 +58,10 @@ import kotlin.time.Duration
|
|||
import kotlin.time.DurationUnit
|
||||
import kotlin.time.ExperimentalTime
|
||||
import kotlin.time.toDuration
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
class NavigationDrawerFragment : DialogFragment() {
|
||||
|
||||
|
|
@ -230,7 +230,8 @@ class NavigationDrawerFragment : DialogFragment() {
|
|||
|
||||
subscriptions?.add(
|
||||
Flowable.combineLatest(
|
||||
contentRepository.getWorldState(), inventoryRepository.getAvailableLimitedItems()) { state, items ->
|
||||
contentRepository.getWorldState(), inventoryRepository.getAvailableLimitedItems()
|
||||
) { state, items ->
|
||||
return@combineLatest Pair(state, items)
|
||||
}.subscribe(
|
||||
{ pair ->
|
||||
|
|
|
|||
|
|
@ -165,8 +165,10 @@ class AvatarCustomizationFragment :
|
|||
val type = this.type ?: return
|
||||
compositeSubscription.add(
|
||||
customizationRepository.getCustomizations(type, category, false)
|
||||
.combineLatest(currentFilter.toFlowable(BackpressureStrategy.DROP),
|
||||
ownedCustomizations.toFlowable(BackpressureStrategy.DROP))
|
||||
.combineLatest(
|
||||
currentFilter.toFlowable(BackpressureStrategy.DROP),
|
||||
ownedCustomizations.toFlowable(BackpressureStrategy.DROP)
|
||||
)
|
||||
.subscribe(
|
||||
{ (customizations, filter, ownedCustomizations) ->
|
||||
adapter.ownedCustomizations = ownedCustomizations.map { it.key + "_" + it.type + "_" + it.category }
|
||||
|
|
@ -202,8 +204,8 @@ class AvatarCustomizationFragment :
|
|||
)
|
||||
}
|
||||
},
|
||||
RxErrorHandler.handleEmptyError()
|
||||
)
|
||||
RxErrorHandler.handleEmptyError()
|
||||
)
|
||||
)
|
||||
if (type == "hair" && (category == "beard" || category == "mustache")) {
|
||||
val otherCategory = if (category == "mustache") "beard" else "mustache"
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ class ItemDialogFragment : BaseDialogFragment<FragmentItemsBinding>(), SwipeRefr
|
|||
binding?.recyclerView?.itemAnimator = SafeDefaultItemAnimator()
|
||||
|
||||
userViewModel.user.observeOnce(this) {
|
||||
if (it != null){
|
||||
if (it != null) {
|
||||
user = it
|
||||
setAdapter()
|
||||
}
|
||||
|
|
@ -158,7 +158,7 @@ class ItemDialogFragment : BaseDialogFragment<FragmentItemsBinding>(), SwipeRefr
|
|||
this.loadItems()
|
||||
}
|
||||
|
||||
private fun setAdapter(){
|
||||
private fun setAdapter() {
|
||||
val context = activity
|
||||
|
||||
adapter = binding?.recyclerView?.adapter as? ItemRecyclerAdapter
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ class ItemRecyclerFragment : BaseFragment<FragmentItemsBinding>(), SwipeRefreshL
|
|||
binding?.recyclerView?.itemAnimator = SafeDefaultItemAnimator()
|
||||
|
||||
userViewModel.user.observeOnce(this) {
|
||||
if (it != null){
|
||||
if (it != null) {
|
||||
user = it
|
||||
setAdapter()
|
||||
}
|
||||
|
|
@ -128,7 +128,7 @@ class ItemRecyclerFragment : BaseFragment<FragmentItemsBinding>(), SwipeRefreshL
|
|||
this.loadItems()
|
||||
}
|
||||
|
||||
private fun setAdapter(){
|
||||
private fun setAdapter() {
|
||||
val context = activity
|
||||
|
||||
adapter = binding?.recyclerView?.adapter as? ItemRecyclerAdapter
|
||||
|
|
@ -179,7 +179,7 @@ class ItemRecyclerFragment : BaseFragment<FragmentItemsBinding>(), SwipeRefreshL
|
|||
)
|
||||
compositeSubscription.add(adapter.startHatchingEvents.subscribeWithErrorHandler { showHatchingDialog(it) })
|
||||
compositeSubscription.add(adapter.hatchPetEvents.subscribeWithErrorHandler { hatchPet(it.first, it.second) })
|
||||
compositeSubscription.addAll(adapter.startNewPartyEvents.subscribeWithErrorHandler { createNewParty(it) })
|
||||
compositeSubscription.addAll(adapter.startNewPartyEvents.subscribeWithErrorHandler { createNewParty() })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -227,7 +227,7 @@ class ItemRecyclerFragment : BaseFragment<FragmentItemsBinding>(), SwipeRefreshL
|
|||
}
|
||||
}
|
||||
|
||||
private fun createNewParty(isCreateNewParty: Boolean) {
|
||||
private fun createNewParty() {
|
||||
val alert = context?.let { HabiticaAlertDialog(it) }
|
||||
alert?.setTitle(R.string.quest_party_required_title)
|
||||
alert?.setMessage(R.string.quest_party_required_description)
|
||||
|
|
|
|||
|
|
@ -29,11 +29,11 @@ import com.habitrpg.android.habitica.ui.fragments.PromoInfoFragment
|
|||
import com.habitrpg.android.habitica.ui.helpers.loadImage
|
||||
import com.habitrpg.android.habitica.ui.views.dialogs.HabiticaAlertDialog
|
||||
import com.habitrpg.android.habitica.ui.views.subscriptions.SubscriptionOptionView
|
||||
import javax.inject.Inject
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import javax.inject.Inject
|
||||
|
||||
class SubscriptionFragment : BaseFragment<FragmentSubscriptionBinding>() {
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ import com.habitrpg.android.habitica.models.members.Member
|
|||
import com.habitrpg.android.habitica.models.social.Group
|
||||
import com.habitrpg.android.habitica.modules.AppModule
|
||||
import com.habitrpg.android.habitica.ui.fragments.BaseMainFragment
|
||||
import com.habitrpg.android.habitica.ui.helpers.DataBindingUtils
|
||||
import com.habitrpg.android.habitica.ui.helpers.MarkdownParser
|
||||
import com.habitrpg.android.habitica.ui.helpers.loadImage
|
||||
import com.habitrpg.android.habitica.ui.viewmodels.MainUserViewModel
|
||||
|
|
|
|||
|
|
@ -37,8 +37,8 @@ import com.habitrpg.android.habitica.ui.viewHolders.tasks.TodoViewHolder
|
|||
import com.habitrpg.android.habitica.ui.viewmodels.MainUserViewModel
|
||||
import com.habitrpg.android.habitica.ui.views.HabiticaIconsHelper
|
||||
import com.habitrpg.android.habitica.ui.views.dialogs.HabiticaAlertDialog
|
||||
import retrofit2.HttpException
|
||||
import javax.inject.Inject
|
||||
import retrofit2.HttpException
|
||||
|
||||
class ChallengeDetailFragment : BaseMainFragment<FragmentChallengeDetailBinding>() {
|
||||
|
||||
|
|
|
|||
|
|
@ -54,16 +54,6 @@ internal class ChallengeFilterDialogHolder private constructor(
|
|||
binding.challengeFilterRecyclerView.adapter = adapter
|
||||
}
|
||||
|
||||
private fun doneClicked() {
|
||||
val options = ChallengeFilterOptions()
|
||||
options.showByGroups = this.adapter?.checkedEntries
|
||||
options.showOwned = binding.challengeFilterOwned.isChecked
|
||||
options.notOwned = binding.challengeFilterNotOwned.isChecked
|
||||
|
||||
selectedGroupsCallback?.call(options)
|
||||
this.dialog?.hide()
|
||||
}
|
||||
|
||||
private fun allClicked() {
|
||||
this.adapter?.selectAll()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,11 +41,11 @@ import com.habitrpg.android.habitica.ui.viewHolders.GroupMemberViewHolder
|
|||
import com.habitrpg.android.habitica.ui.viewmodels.PartyViewModel
|
||||
import com.habitrpg.android.habitica.ui.views.HabiticaSnackbar
|
||||
import com.habitrpg.android.habitica.ui.views.dialogs.HabiticaAlertDialog
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Named
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Named
|
||||
|
||||
class PartyDetailFragment : BaseFragment<FragmentPartyDetailBinding>() {
|
||||
|
||||
|
|
|
|||
|
|
@ -22,9 +22,9 @@ import com.habitrpg.android.habitica.modules.AppModule
|
|||
import com.habitrpg.android.habitica.ui.fragments.BaseMainFragment
|
||||
import com.habitrpg.android.habitica.ui.viewmodels.MainUserViewModel
|
||||
import com.jaredrummler.android.device.DeviceName
|
||||
import kotlinx.coroutines.launch
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Named
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
class BugFixFragment : BaseMainFragment<FragmentSupportBugFixBinding>() {
|
||||
private var deviceInfo: DeviceName.DeviceInfo? = null
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ class SupportMainFragment : BaseMainFragment<FragmentSupportMainBinding>() {
|
|||
}
|
||||
|
||||
binding?.resetTutorialButton?.setOnClickListener {
|
||||
userRepository.resetTutorial().subscribe( {
|
||||
userRepository.resetTutorial().subscribe({
|
||||
activity?.showSnackbar(null, getString(R.string.tutorial_reset_confirmation))
|
||||
}, RxErrorHandler.handleEmptyError())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ import androidx.core.content.ContextCompat
|
|||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.habitrpg.android.habitica.R
|
||||
import com.habitrpg.android.habitica.data.InventoryRepository
|
||||
import com.habitrpg.android.habitica.extensions.subscribeWithErrorHandler
|
||||
import com.habitrpg.android.habitica.helpers.RxErrorHandler
|
||||
import com.habitrpg.android.habitica.models.shops.ShopItem
|
||||
|
|
@ -24,7 +23,6 @@ import com.habitrpg.android.habitica.ui.helpers.SafeDefaultItemAnimator
|
|||
import com.habitrpg.android.habitica.ui.viewmodels.TasksViewModel
|
||||
import com.habitrpg.android.habitica.ui.views.HabiticaSnackbar
|
||||
import io.reactivex.rxjava3.functions.Consumer
|
||||
import javax.inject.Inject
|
||||
|
||||
class RewardsRecyclerviewFragment : TaskRecyclerViewFragment() {
|
||||
|
||||
|
|
|
|||
|
|
@ -319,13 +319,12 @@ open class TaskRecyclerViewFragment : BaseFragment<FragmentRefreshRecyclerviewBi
|
|||
)
|
||||
}
|
||||
|
||||
|
||||
private fun updateTaskSubscription(ownerID: String?) {
|
||||
taskSubscription = taskRepository.getTasks(this.taskType, ownerID).subscribe(
|
||||
{
|
||||
this.recyclerAdapter?.updateUnfilteredData(it)
|
||||
},
|
||||
RxErrorHandler.handleEmptyError()
|
||||
{
|
||||
this.recyclerAdapter?.updateUnfilteredData(it)
|
||||
},
|
||||
RxErrorHandler.handleEmptyError()
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -182,7 +182,7 @@ class TasksFragment : BaseMainFragment<FragmentViewpagerBinding>(), SearchView.O
|
|||
}
|
||||
R.id.action_reload -> {
|
||||
refreshItem = item
|
||||
viewModel.refreshData { }
|
||||
viewModel.refreshData { }
|
||||
true
|
||||
}
|
||||
R.id.action_team_info -> {
|
||||
|
|
|
|||
|
|
@ -56,17 +56,17 @@ class AutocompleteAdapter(
|
|||
userResults = chatMessages
|
||||
.filter { it.isValid }
|
||||
.distinctBy {
|
||||
it.username
|
||||
}.filter { it.username?.startsWith(constraint.toString().drop(1)) ?: false }.map { message ->
|
||||
val result = FindUsernameResult()
|
||||
result.authentication = Authentication()
|
||||
result.authentication?.localAuthentication = LocalAuthentication()
|
||||
result.authentication?.localAuthentication?.username = message.username
|
||||
result.contributor = message.contributor
|
||||
result.profile = Profile()
|
||||
result.profile?.name = message.user
|
||||
result
|
||||
}
|
||||
it.username
|
||||
}.filter { it.username?.startsWith(constraint.toString().drop(1)) ?: false }.map { message ->
|
||||
val result = FindUsernameResult()
|
||||
result.authentication = Authentication()
|
||||
result.authentication?.localAuthentication = LocalAuthentication()
|
||||
result.authentication?.localAuthentication?.username = message.username
|
||||
result.contributor = message.contributor
|
||||
result.profile = Profile()
|
||||
result.profile?.name = message.user
|
||||
result
|
||||
}
|
||||
filterResults.values = userResults
|
||||
filterResults.count = userResults.size
|
||||
} else if (constraint[0] == ':') {
|
||||
|
|
|
|||
|
|
@ -41,9 +41,6 @@ class PetViewHolder(
|
|||
|
||||
private var canRaiseToMount: Boolean = false
|
||||
|
||||
private val canHatch: Boolean
|
||||
get() = eggCount > 0 && potionCount > 0
|
||||
|
||||
init {
|
||||
itemView.setOnClickListener(this)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,12 +5,6 @@ import com.habitrpg.android.habitica.models.responses.TaskDirection
|
|||
import com.habitrpg.android.habitica.models.tasks.ChecklistItem
|
||||
import com.habitrpg.android.habitica.models.tasks.Task
|
||||
import java.text.DateFormat
|
||||
import java.time.LocalDateTime
|
||||
import java.time.ZoneId
|
||||
import java.time.ZonedDateTime
|
||||
import java.time.format.DateTimeFormatter
|
||||
import java.time.format.DateTimeFormatterBuilder
|
||||
import java.time.temporal.TemporalAccessor
|
||||
import java.util.Calendar
|
||||
import java.util.Date
|
||||
|
||||
|
|
@ -43,12 +37,14 @@ class DailyViewHolder(
|
|||
val calendar = Calendar.getInstance()
|
||||
val nextReminder = data.reminders?.firstOrNull {
|
||||
calendar.time = now
|
||||
calendar.set(calendar.get(Calendar.YEAR),
|
||||
calendar.set(
|
||||
calendar.get(Calendar.YEAR),
|
||||
calendar.get(Calendar.MONTH),
|
||||
calendar.get(Calendar.DATE),
|
||||
it.getZonedDateTime()?.hour ?: 0,
|
||||
it.getZonedDateTime()?.minute ?: 0,
|
||||
0)
|
||||
0
|
||||
)
|
||||
now < calendar.time
|
||||
} ?: data.reminders?.first()
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ import java.util.Date
|
|||
import javax.inject.Inject
|
||||
import javax.inject.Named
|
||||
|
||||
class TasksViewModel: BaseViewModel() {
|
||||
class TasksViewModel : BaseViewModel() {
|
||||
private var compositeSubscription: CompositeDisposable = CompositeDisposable()
|
||||
|
||||
override fun inject(component: UserComponent) {
|
||||
|
|
@ -56,23 +56,25 @@ class TasksViewModel: BaseViewModel() {
|
|||
return ownerID.value == userID
|
||||
}
|
||||
val ownerTitle: CharSequence
|
||||
get() {
|
||||
return owners.firstOrNull { it.first == ownerID.value }?.second ?: ""
|
||||
}
|
||||
get() {
|
||||
return owners.firstOrNull { it.first == ownerID.value }?.second ?: ""
|
||||
}
|
||||
|
||||
init {
|
||||
compositeSubscription.add(userRepository.getTeamPlans()
|
||||
.subscribe({
|
||||
owners = listOf(Pair(userID, userViewModel.displayName)) + it.map {
|
||||
Pair(
|
||||
it.id,
|
||||
it.summary
|
||||
)
|
||||
}
|
||||
if (owners.size > 1 && canSwitchOwners.value != false) {
|
||||
canSwitchOwners.value = owners.size > 1
|
||||
}
|
||||
}, RxErrorHandler.handleEmptyError()))
|
||||
compositeSubscription.add(
|
||||
userRepository.getTeamPlans()
|
||||
.subscribe({
|
||||
owners = listOf(Pair(userID, userViewModel.displayName)) + it.map {
|
||||
Pair(
|
||||
it.id,
|
||||
it.summary
|
||||
)
|
||||
}
|
||||
if (owners.size > 1 && canSwitchOwners.value != false) {
|
||||
canSwitchOwners.value = owners.size > 1
|
||||
}
|
||||
}, RxErrorHandler.handleEmptyError())
|
||||
)
|
||||
compositeSubscription.add(userRepository.retrieveTeamPlans().subscribe({}, RxErrorHandler.handleEmptyError()))
|
||||
}
|
||||
|
||||
|
|
@ -135,23 +137,23 @@ class TasksViewModel: BaseViewModel() {
|
|||
}
|
||||
|
||||
var searchQuery: String? = null
|
||||
set(value) {
|
||||
field = value
|
||||
filterSets.forEach {
|
||||
val old = it.value.value
|
||||
it.value.value = Triple(value, old?.second, old?.third ?: listOf())
|
||||
set(value) {
|
||||
field = value
|
||||
filterSets.forEach {
|
||||
val old = it.value.value
|
||||
it.value.value = Triple(value, old?.second, old?.third ?: listOf())
|
||||
}
|
||||
}
|
||||
}
|
||||
private val activeFilters = HashMap<TaskType, String>()
|
||||
|
||||
var tags: MutableList<String> = mutableListOf()
|
||||
set(value) {
|
||||
field = value
|
||||
filterSets.forEach {
|
||||
val old = it.value.value
|
||||
it.value.value = Triple(old?.first, old?.second, field)
|
||||
set(value) {
|
||||
field = value
|
||||
filterSets.forEach {
|
||||
val old = it.value.value
|
||||
it.value.value = Triple(old?.first, old?.second, field)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun addActiveTag(tagID: String) {
|
||||
if (!tags.contains(tagID)) {
|
||||
|
|
|
|||
|
|
@ -8,12 +8,12 @@ import androidx.preference.ListPreference
|
|||
import com.habitrpg.android.habitica.R
|
||||
import com.habitrpg.android.habitica.extensions.setScaledPadding
|
||||
|
||||
class HabiticaListPreference: ListPreference {
|
||||
class HabiticaListPreference : ListPreference {
|
||||
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int) :
|
||||
super(context, attrs, defStyleAttr, defStyleRes)
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) :
|
||||
super(context,attrs,defStyleAttr)
|
||||
super(context, attrs, defStyleAttr)
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
|
||||
|
||||
|
|
@ -22,8 +22,7 @@ class HabiticaListPreference: ListPreference {
|
|||
override fun onClick() {
|
||||
val subtitleText = TextView(context)
|
||||
subtitleText.setText(R.string.cds_subtitle)
|
||||
val builder = AlertDialog.Builder(context).setSingleChoiceItems(entries,getValueIndex())
|
||||
{ dialog, index ->
|
||||
val builder = AlertDialog.Builder(context).setSingleChoiceItems(entries, getValueIndex()) { dialog, index ->
|
||||
if (callChangeListener(entryValues[index].toString())) {
|
||||
setValueIndex(index)
|
||||
}
|
||||
|
|
@ -40,4 +39,4 @@ class HabiticaListPreference: ListPreference {
|
|||
}
|
||||
|
||||
private fun getValueIndex() = entryValues.indexOf(value)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,19 +46,19 @@ class HabiticaProgressBar(context: Context, attrs: AttributeSet?) : FrameLayout(
|
|||
}
|
||||
|
||||
var currentValue: Double = 0.0
|
||||
set(value) {
|
||||
if (field != value) {
|
||||
field = value
|
||||
updateBar()
|
||||
set(value) {
|
||||
if (field != value) {
|
||||
field = value
|
||||
updateBar()
|
||||
}
|
||||
}
|
||||
}
|
||||
var maxValue: Double = 0.0
|
||||
set(value) {
|
||||
if (field != value) {
|
||||
field = value
|
||||
updateBar()
|
||||
set(value) {
|
||||
if (field != value) {
|
||||
field = value
|
||||
updateBar()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var pendingValue: Double = 0.0
|
||||
set(value) {
|
||||
|
|
|
|||
|
|
@ -8,17 +8,19 @@ import android.graphics.Rect
|
|||
import android.util.AttributeSet
|
||||
|
||||
class PixelArtView @JvmOverloads constructor(
|
||||
context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = 0
|
||||
) : androidx.appcompat.widget.AppCompatImageView(context, attrs, defStyleAttr) {
|
||||
|
||||
private var targetRect = Rect(0, 0, 0, 0)
|
||||
|
||||
var bitmap: Bitmap? = null
|
||||
set(value) {
|
||||
field = value
|
||||
updateTargetRect()
|
||||
invalidate()
|
||||
}
|
||||
set(value) {
|
||||
field = value
|
||||
updateTargetRect()
|
||||
invalidate()
|
||||
}
|
||||
|
||||
private val paint: Paint by lazy {
|
||||
val paint = Paint()
|
||||
|
|
@ -37,15 +39,15 @@ class PixelArtView @JvmOverloads constructor(
|
|||
var targetHeight = bitmap?.height ?: 0
|
||||
|
||||
if (width > 0 && targetWidth > 0 && width != targetWidth) {
|
||||
targetWidth = (targetWidth/3) * (width / (targetWidth/3))
|
||||
targetWidth = (targetWidth / 3) * (width / (targetWidth / 3))
|
||||
}
|
||||
if (height > 0 && targetHeight > 0 && height != targetHeight) {
|
||||
targetHeight = (targetHeight/3) * (height / (targetHeight/3))
|
||||
targetHeight = (targetHeight / 3) * (height / (targetHeight / 3))
|
||||
}
|
||||
|
||||
val left = (width-targetWidth)/2
|
||||
val top = (height-targetHeight)/2
|
||||
targetRect = Rect(left, top, left+targetWidth, top+targetHeight)
|
||||
val left = (width - targetWidth) / 2
|
||||
val top = (height - targetHeight) / 2
|
||||
targetRect = Rect(left, top, left + targetWidth, top + targetHeight)
|
||||
}
|
||||
|
||||
override fun onDraw(canvas: Canvas?) {
|
||||
|
|
@ -56,4 +58,4 @@ class PixelArtView @JvmOverloads constructor(
|
|||
val bitmap = bitmap ?: return
|
||||
canvas?.drawBitmap(bitmap, null, targetRect, paint)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,13 +15,15 @@ import com.habitrpg.android.habitica.extensions.dpToPx
|
|||
import kotlin.math.min
|
||||
|
||||
class SparkView @JvmOverloads constructor(
|
||||
context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = 0
|
||||
) : View(context, attrs, defStyleAttr) {
|
||||
private var spacing: Float = 0f
|
||||
set(value) {
|
||||
field = value
|
||||
invalidate()
|
||||
}
|
||||
set(value) {
|
||||
field = value
|
||||
invalidate()
|
||||
}
|
||||
private var paint: Paint = Paint()
|
||||
|
||||
var thickness = 3.dpToPx(context)
|
||||
|
|
@ -32,9 +34,9 @@ class SparkView @JvmOverloads constructor(
|
|||
get() {
|
||||
return paint.color
|
||||
}
|
||||
set(value) {
|
||||
paint.color = value
|
||||
}
|
||||
set(value) {
|
||||
paint.color = value
|
||||
}
|
||||
|
||||
init {
|
||||
spacing = maxSpacing.toFloat()
|
||||
|
|
@ -86,7 +88,7 @@ class SparkView @JvmOverloads constructor(
|
|||
val thisCanvas = canvas ?: return
|
||||
val centerHorizontal = width / 2f
|
||||
val centerVertical = height / 2f
|
||||
val offset = (maxSpacing - spacing)/2
|
||||
val offset = (maxSpacing - spacing) / 2
|
||||
drawHorizontal(thisCanvas, offset, centerVertical)
|
||||
drawHorizontal(thisCanvas, width - length.toFloat() - offset, centerVertical)
|
||||
|
||||
|
|
@ -95,10 +97,10 @@ class SparkView @JvmOverloads constructor(
|
|||
}
|
||||
|
||||
private fun drawVertical(canvas: Canvas, x: Float, y: Float) {
|
||||
canvas.drawRoundRect(x-(thickness/2), y, x+(thickness/2), y+length, thickness/2f, thickness/2f, paint)
|
||||
canvas.drawRoundRect(x - (thickness / 2), y, x + (thickness / 2), y + length, thickness / 2f, thickness / 2f, paint)
|
||||
}
|
||||
|
||||
private fun drawHorizontal(canvas: Canvas, x: Float, y: Float) {
|
||||
canvas.drawRoundRect(x, y-(thickness/2), x+length, y+(thickness/2), thickness/2f, thickness/2f, paint)
|
||||
canvas.drawRoundRect(x, y - (thickness / 2), x + length, y + (thickness / 2), thickness / 2f, thickness / 2f, paint)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,13 +29,13 @@ class ValueBar(context: Context, attrs: AttributeSet?) : FrameLayout(context, at
|
|||
private val formatter = NumberFormat.getInstance()
|
||||
|
||||
val progressBar: HabiticaProgressBar
|
||||
get() = binding.progressBar
|
||||
get() = binding.progressBar
|
||||
|
||||
var currentValue: Double
|
||||
get() = binding.progressBar.currentValue
|
||||
set(value) {
|
||||
binding.progressBar.currentValue = value
|
||||
}
|
||||
get() = binding.progressBar.currentValue
|
||||
set(value) {
|
||||
binding.progressBar.currentValue = value
|
||||
}
|
||||
var maxValue: Double
|
||||
get() = binding.progressBar.maxValue
|
||||
set(value) {
|
||||
|
|
|
|||
|
|
@ -13,13 +13,13 @@ import com.habitrpg.android.habitica.extensions.getShortRemainingString
|
|||
import com.habitrpg.android.habitica.extensions.layoutInflater
|
||||
import com.habitrpg.android.habitica.helpers.AdHandler
|
||||
import com.habitrpg.android.habitica.helpers.AdType
|
||||
import java.util.Date
|
||||
import kotlin.time.DurationUnit
|
||||
import kotlin.time.toDuration
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import java.util.Date
|
||||
import kotlin.time.DurationUnit
|
||||
import kotlin.time.toDuration
|
||||
|
||||
class AdButton @JvmOverloads constructor(
|
||||
context: Context,
|
||||
|
|
@ -43,10 +43,10 @@ class AdButton @JvmOverloads constructor(
|
|||
private val binding = AdButtonBinding.inflate(context.layoutInflater, this)
|
||||
|
||||
var text: String = ""
|
||||
set(value) {
|
||||
field = value
|
||||
updateViews()
|
||||
}
|
||||
set(value) {
|
||||
field = value
|
||||
updateViews()
|
||||
}
|
||||
|
||||
init {
|
||||
context.theme?.obtainStyledAttributes(
|
||||
|
|
@ -113,4 +113,4 @@ class AdButton @JvmOverloads constructor(
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,10 +25,10 @@ import com.habitrpg.android.habitica.extensions.layoutInflater
|
|||
import com.habitrpg.android.habitica.ui.activities.BaseActivity
|
||||
import com.habitrpg.android.habitica.ui.views.login.LockableScrollView
|
||||
import com.plattysoft.leonids.ParticleSystem
|
||||
import java.lang.ref.WeakReference
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import java.lang.ref.WeakReference
|
||||
|
||||
open class HabiticaAlertDialog(context: Context) : AlertDialog(context, R.style.HabiticaAlertDialogTheme) {
|
||||
|
||||
|
|
|
|||
|
|
@ -14,10 +14,10 @@ open class HabiticaBottomSheetDialog(context: Context) : BottomSheetDialog(conte
|
|||
}
|
||||
|
||||
var grabberVisibility: Int
|
||||
get() = wrapperBinding.grabber.visibility
|
||||
set(value) {
|
||||
wrapperBinding.grabber.visibility = value
|
||||
}
|
||||
get() = wrapperBinding.grabber.visibility
|
||||
set(value) {
|
||||
wrapperBinding.grabber.visibility = value
|
||||
}
|
||||
|
||||
override fun setContentView(view: View) {
|
||||
wrapperBinding.container.addView(view)
|
||||
|
|
@ -28,4 +28,4 @@ open class HabiticaBottomSheetDialog(context: Context) : BottomSheetDialog(conte
|
|||
layoutInflater.inflate(layoutResId, wrapperBinding.container)
|
||||
super.setContentView(wrapperBinding.root)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -89,7 +89,7 @@ class HabiticaBottomNavigationView @JvmOverloads constructor(
|
|||
}
|
||||
binding.cutoutSpace.visibility = View.INVISIBLE
|
||||
binding.addButtonBackground.animate()
|
||||
.translationY(-binding.addButtonBackground.height.toFloat()/2)
|
||||
.translationY(-binding.addButtonBackground.height.toFloat() / 2)
|
||||
.alpha(0.0f)
|
||||
.setDuration(200)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,16 +41,16 @@ import com.habitrpg.android.habitica.ui.views.tasks.form.StepperValueFormView
|
|||
import io.reactivex.rxjava3.core.Flowable
|
||||
import io.reactivex.rxjava3.core.Maybe
|
||||
import io.reactivex.rxjava3.disposables.CompositeDisposable
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import java.util.Date
|
||||
import javax.inject.Inject
|
||||
import kotlin.math.max
|
||||
import kotlin.time.DurationUnit
|
||||
import kotlin.time.toDuration
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
class PurchaseDialog(context: Context, component: UserComponent?, val item: ShopItem) : HabiticaAlertDialog(context) {
|
||||
|
||||
|
|
@ -372,10 +372,15 @@ class PurchaseDialog(context: Context, component: UserComponent?, val item: Shop
|
|||
} else if ("gold" == shopItem.currency && "gem" != shopItem.key) {
|
||||
observable = inventoryRepository.buyItem(user, shopItem.key, shopItem.value.toDouble(), quantity).map { buyResponse ->
|
||||
if (shopItem.key == "armoire" && configManager.enableNewArmoire()) {
|
||||
MainNavigationController.navigate(R.id.armoireActivity, ArmoireActivityDirections.openArmoireActivity(buyResponse.armoire["type"] ?: "",
|
||||
buyResponse.armoire["dropText"] ?: "",
|
||||
buyResponse.armoire["dropKey"] ?: "",
|
||||
buyResponse.armoire["value"] ?: "").arguments)
|
||||
MainNavigationController.navigate(
|
||||
R.id.armoireActivity,
|
||||
ArmoireActivityDirections.openArmoireActivity(
|
||||
buyResponse.armoire["type"] ?: "",
|
||||
buyResponse.armoire["dropText"] ?: "",
|
||||
buyResponse.armoire["dropKey"] ?: "",
|
||||
buyResponse.armoire["value"] ?: ""
|
||||
).arguments
|
||||
)
|
||||
}
|
||||
buyResponse
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,4 +23,4 @@ class PurchaseDialogBackgroundContent(context: Context) : PurchaseDialogContent(
|
|||
fun setAvatar(avatar: Avatar) {
|
||||
binding.avatarView.setAvatar(avatar)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,4 +12,4 @@ class PurchaseDialogCustomizationContent(context: Context) : PurchaseDialogConte
|
|||
get() = binding.imageView
|
||||
override val titleTextView: TextView
|
||||
get() = binding.titleTextView
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,4 +29,4 @@ class PurchaseDialogCustomizationSetContent(context: Context) : PurchaseDialogCo
|
|||
binding.imageViewWrapper.addView(imageView)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package com.habitrpg.android.habitica.ui.views.shops
|
||||
|
||||
import android.content.Context
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.habitrpg.android.habitica.R
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package com.habitrpg.android.habitica.ui.views.shops
|
||||
|
||||
import android.content.Context
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import com.habitrpg.android.habitica.databinding.DialogPurchaseGemsBinding
|
||||
import com.habitrpg.android.habitica.extensions.asDrawable
|
||||
|
|
|
|||
|
|
@ -44,30 +44,30 @@ class TaskFilterDialog(context: Context, component: UserComponent?) : HabiticaBo
|
|||
lateinit var repository: TagRepository
|
||||
|
||||
var taskType: TaskType = TaskType.HABIT
|
||||
set(value) {
|
||||
field = value
|
||||
when (value) {
|
||||
TaskType.HABIT -> {
|
||||
binding.taskTypeTitle.setText(R.string.habits)
|
||||
binding.allTaskFilter.setText(R.string.all)
|
||||
binding.secondTaskFilter.setText(R.string.weak)
|
||||
binding.thirdTaskFilter.setText(R.string.strong)
|
||||
}
|
||||
TaskType.DAILY -> {
|
||||
binding.taskTypeTitle.setText(R.string.dailies)
|
||||
binding.allTaskFilter.setText(R.string.all)
|
||||
binding.secondTaskFilter.setText(R.string.due)
|
||||
binding.thirdTaskFilter.setText(R.string.gray)
|
||||
}
|
||||
TaskType.TODO -> {
|
||||
binding.taskTypeTitle.setText(R.string.todos)
|
||||
binding.allTaskFilter.setText(R.string.active)
|
||||
binding.secondTaskFilter.setText(R.string.dated)
|
||||
binding.thirdTaskFilter.setText(R.string.completed)
|
||||
set(value) {
|
||||
field = value
|
||||
when (value) {
|
||||
TaskType.HABIT -> {
|
||||
binding.taskTypeTitle.setText(R.string.habits)
|
||||
binding.allTaskFilter.setText(R.string.all)
|
||||
binding.secondTaskFilter.setText(R.string.weak)
|
||||
binding.thirdTaskFilter.setText(R.string.strong)
|
||||
}
|
||||
TaskType.DAILY -> {
|
||||
binding.taskTypeTitle.setText(R.string.dailies)
|
||||
binding.allTaskFilter.setText(R.string.all)
|
||||
binding.secondTaskFilter.setText(R.string.due)
|
||||
binding.thirdTaskFilter.setText(R.string.gray)
|
||||
}
|
||||
TaskType.TODO -> {
|
||||
binding.taskTypeTitle.setText(R.string.todos)
|
||||
binding.allTaskFilter.setText(R.string.active)
|
||||
binding.secondTaskFilter.setText(R.string.dated)
|
||||
binding.thirdTaskFilter.setText(R.string.completed)
|
||||
}
|
||||
}
|
||||
setActiveFilter(viewModel.getActiveFilter(value))
|
||||
}
|
||||
setActiveFilter(viewModel.getActiveFilter(value))
|
||||
}
|
||||
|
||||
private var tags = mutableListOf<Tag>()
|
||||
private val editedTags = HashMap<String, Tag>()
|
||||
|
|
@ -103,7 +103,7 @@ class TaskFilterDialog(context: Context, component: UserComponent?) : HabiticaBo
|
|||
}
|
||||
|
||||
override fun show() {
|
||||
tagDisposale = viewModel.tagRepository.getTags().subscribe( {
|
||||
tagDisposale = viewModel.tagRepository.getTags().subscribe({
|
||||
setTags(it)
|
||||
}, RxErrorHandler.handleEmptyError())
|
||||
super.show()
|
||||
|
|
@ -292,7 +292,7 @@ class TaskFilterDialog(context: Context, component: UserComponent?) : HabiticaBo
|
|||
R.id.second_task_filter -> when (taskType) {
|
||||
TaskType.HABIT -> Task.FILTER_WEAK
|
||||
TaskType.DAILY -> Task.FILTER_ACTIVE
|
||||
TaskType.TODO -> Task.FILTER_DATED
|
||||
TaskType.TODO -> Task.FILTER_DATED
|
||||
else -> Task.FILTER_ALL
|
||||
}
|
||||
R.id.third_task_filter -> when (taskType) {
|
||||
|
|
|
|||
|
|
@ -158,5 +158,4 @@ class ReminderItemFormView @JvmOverloads constructor(
|
|||
timePickerDialog.show()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue