mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-04-14 11:46:32 +00:00
fix formatting
This commit is contained in:
parent
c9fea5872a
commit
afb2b234d9
329 changed files with 1782 additions and 1622 deletions
2
.github/workflows/android.yml
vendored
2
.github/workflows/android.yml
vendored
|
|
@ -87,7 +87,7 @@ jobs:
|
|||
- name: Run with Gradle
|
||||
uses: gradle/gradle-build-action@v2
|
||||
with:
|
||||
arguments: ktlint
|
||||
arguments: ktlintCheck
|
||||
|
||||
detekt:
|
||||
runs-on: ubuntu-latest
|
||||
|
|
|
|||
|
|
@ -21,10 +21,6 @@ repositories {
|
|||
maven { url "https://jitpack.io" }
|
||||
}
|
||||
|
||||
configurations {
|
||||
ktlint
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(include: ['*.jar'], dir: '../common/libs')
|
||||
//Networking
|
||||
|
|
@ -42,15 +38,15 @@ dependencies {
|
|||
compileOnly 'javax.annotation:javax.annotation-api:1.3.2'
|
||||
//App Compatibility and Material Design
|
||||
implementation "androidx.appcompat:appcompat:$appcompat_version"
|
||||
implementation 'com.google.android.material:material:1.7.0'
|
||||
implementation 'com.google.android.material:material:1.8.0'
|
||||
implementation "androidx.recyclerview:recyclerview:$recyclerview_version"
|
||||
implementation "androidx.preference:preference-ktx:$preferences_version"
|
||||
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
|
||||
|
||||
//Desugaring
|
||||
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.6'
|
||||
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.2'
|
||||
|
||||
implementation('com.jaredrummler:android-device-names:2.1.0')
|
||||
implementation('com.jaredrummler:android-device-names:2.1.1')
|
||||
|
||||
// IAP Handling / Verification
|
||||
implementation "com.android.billingclient:billing-ktx:5.1.0"
|
||||
|
|
@ -62,38 +58,38 @@ dependencies {
|
|||
implementation "com.amplitude:analytics-android:$amplitude_version"
|
||||
|
||||
//Tests
|
||||
testImplementation 'io.kotest:kotest-runner-junit5:5.3.0'
|
||||
testImplementation 'io.kotest:kotest-runner-junit5:5.5.5'
|
||||
testImplementation 'androidx.test:core:1.5.0'
|
||||
testImplementation 'io.mockk:mockk:1.13.3'
|
||||
testImplementation 'io.mockk:mockk-android:1.13.3'
|
||||
testImplementation 'io.kotest:kotest-assertions-core:5.3.0'
|
||||
testImplementation 'io.kotest:kotest-framework-datatest:5.3.0'
|
||||
androidTestImplementation ('com.kaspersky.android-components:kaspresso:1.4.1') {
|
||||
testImplementation 'io.mockk:mockk:1.13.4'
|
||||
testImplementation 'io.mockk:mockk-android:1.13.4'
|
||||
testImplementation 'io.kotest:kotest-assertions-core:5.5.5'
|
||||
testImplementation 'io.kotest:kotest-framework-datatest:5.5.5'
|
||||
androidTestImplementation ('com.kaspersky.android-components:kaspresso:1.5.1') {
|
||||
exclude module: "protobuf-lite"
|
||||
}
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.0'
|
||||
androidTestImplementation 'androidx.test:runner:1.5.1'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
|
||||
androidTestImplementation 'androidx.test:runner:1.5.2'
|
||||
androidTestImplementation 'androidx.test:rules:1.5.0'
|
||||
debugImplementation 'androidx.fragment:fragment-testing:1.5.5'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.4'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
|
||||
androidTestImplementation 'androidx.test:core-ktx:1.5.0'
|
||||
androidTestImplementation 'androidx.test.ext:junit-ktx:1.1.4'
|
||||
androidTestImplementation 'io.mockk:mockk-android:1.13.3'
|
||||
androidTestImplementation 'io.kotest:kotest-assertions-core:5.3.0'
|
||||
androidTestImplementation 'androidx.test.ext:junit-ktx:1.1.5'
|
||||
androidTestImplementation 'io.mockk:mockk-android:1.13.4'
|
||||
androidTestImplementation 'io.kotest:kotest-assertions-core:5.5.5'
|
||||
androidTestUtil("androidx.test:orchestrator:1.4.2")
|
||||
|
||||
implementation 'com.facebook.shimmer:shimmer:0.5.0'
|
||||
|
||||
//Leak Detection
|
||||
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.9.1'
|
||||
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.10'
|
||||
//Push Notifications
|
||||
implementation platform("com.google.firebase:firebase-bom:$firebase_bom")
|
||||
implementation 'com.google.firebase:firebase-analytics-ktx'
|
||||
implementation 'com.google.firebase:firebase-crashlytics-ktx'
|
||||
implementation 'com.google.firebase:firebase-core'
|
||||
implementation 'com.google.firebase:firebase-messaging-ktx'
|
||||
implementation 'com.google.firebase:firebase-config-ktx'
|
||||
implementation 'com.google.firebase:firebase-perf-ktx'
|
||||
implementation 'com.google.android.gms:play-services-ads:21.4.0'
|
||||
implementation 'com.google.android.gms:play-services-ads:21.5.0'
|
||||
implementation "com.google.android.gms:play-services-auth:$play_auth_version"
|
||||
implementation 'com.google.android.flexbox:flexbox:3.0.0'
|
||||
implementation "com.google.android.gms:play-services-wearable:$play_wearables_version"
|
||||
|
|
@ -114,7 +110,7 @@ dependencies {
|
|||
|
||||
implementation 'androidx.activity:activity-compose:1.6.1'
|
||||
implementation "androidx.compose.runtime:runtime-livedata:$compose_version"
|
||||
implementation "androidx.compose.material:material:$compose_version"
|
||||
implementation "androidx.compose.material:material:1.3.1"
|
||||
implementation "androidx.compose.animation:animation:$compose_version"
|
||||
implementation "androidx.compose.ui:ui-tooling:$compose_version"
|
||||
implementation "androidx.lifecycle:lifecycle-viewmodel-compose:$lifecycle_version"
|
||||
|
|
@ -124,18 +120,12 @@ dependencies {
|
|||
implementation project(':common')
|
||||
implementation project(':shared')
|
||||
|
||||
ktlint('com.pinterest:ktlint:0.45.2') {
|
||||
attributes {
|
||||
attribute(Bundling.BUNDLING_ATTRIBUTE, getObjects().named(Bundling, Bundling.EXTERNAL))
|
||||
}
|
||||
}
|
||||
androidTestImplementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion target_sdk
|
||||
buildToolsVersion '30.0.3'
|
||||
buildToolsVersion '33.0.2'
|
||||
testOptions {
|
||||
unitTests {
|
||||
includeAndroidResources = true
|
||||
|
|
@ -169,7 +159,7 @@ android {
|
|||
}
|
||||
|
||||
composeOptions {
|
||||
kotlinCompilerExtensionVersion = "1.4.0-alpha02"
|
||||
kotlinCompilerExtensionVersion = "1.4.2"
|
||||
}
|
||||
|
||||
signingConfigs {
|
||||
|
|
@ -388,23 +378,3 @@ gradle.projectsEvaluated {
|
|||
}
|
||||
|
||||
apply plugin: 'com.google.gms.google-services'
|
||||
|
||||
task ktlint(type: JavaExec, group: "verification") {
|
||||
description = "Check Kotlin code style."
|
||||
classpath = configurations.ktlint
|
||||
mainClass.set("com.pinterest.ktlint.Main")
|
||||
args "--disabled_rules=max-line-length", "--android", "--reporter=plain?group_by_file", "src/**/*.kt"
|
||||
// to generate report in checkstyle format prepend following args:
|
||||
// "--reporter=plain", "--reporter=checkstyle,output=${buildDir}/ktlint.xml"
|
||||
// to add a baseline to check against prepend following args:
|
||||
// "--baseline=ktlint-baseline.xml"
|
||||
// see https://github.com/pinterest/ktlint#usage for more
|
||||
}
|
||||
check.dependsOn ktlint
|
||||
|
||||
task ktlintFormat(type: JavaExec, group: "formatting") {
|
||||
description = "Fix Kotlin code style deviations."
|
||||
classpath = configurations.ktlint
|
||||
mainClass.set("com.pinterest.ktlint.Main")
|
||||
args "--disabled_rules=max-lint-length", "--android", "-F", "src/**/*.kt"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@ import androidx.test.filters.LargeTest
|
|||
import com.habitrpg.android.habitica.HabiticaBaseApplication
|
||||
import com.habitrpg.android.habitica.R
|
||||
import com.habitrpg.android.habitica.components.UserComponent
|
||||
import com.habitrpg.shared.habitica.models.tasks.Frequency
|
||||
import com.habitrpg.android.habitica.models.tasks.Task
|
||||
import com.habitrpg.shared.habitica.models.tasks.Frequency
|
||||
import com.habitrpg.shared.habitica.models.tasks.TaskType
|
||||
import io.github.kakaocup.kakao.common.assertions.BaseAssertions
|
||||
import io.github.kakaocup.kakao.common.matchers.ChildCountMatcher
|
||||
|
|
@ -31,12 +31,12 @@ import io.mockk.mockkObject
|
|||
import io.mockk.slot
|
||||
import io.mockk.verify
|
||||
import io.reactivex.rxjava3.core.Flowable
|
||||
import java.util.Date
|
||||
import java.util.UUID
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import java.util.Date
|
||||
import java.util.UUID
|
||||
|
||||
class TaskFormScreen : Screen<TaskFormScreen>() {
|
||||
val toolbar = KToolbar { withId(R.id.toolbar) }
|
||||
|
|
|
|||
|
|
@ -26,9 +26,9 @@ class NavigationDrawerScreen : Screen<NavigationDrawerScreen>() {
|
|||
val recycler: KRecyclerView = KRecyclerView({
|
||||
withId(R.id.recyclerView)
|
||||
}, itemTypeBuilder = {
|
||||
itemType(::SectionHeaderItem)
|
||||
itemType(::MainItem)
|
||||
})
|
||||
itemType(::SectionHeaderItem)
|
||||
itemType(::MainItem)
|
||||
})
|
||||
}
|
||||
|
||||
@LargeTest
|
||||
|
|
|
|||
|
|
@ -63,8 +63,8 @@ class ItemScreen : Screen<ItemScreen>() {
|
|||
val recycler: KRecyclerView = KRecyclerView({
|
||||
withId(R.id.recyclerView)
|
||||
}, itemTypeBuilder = {
|
||||
itemType(::ItemItem)
|
||||
})
|
||||
itemType(::ItemItem)
|
||||
})
|
||||
}
|
||||
|
||||
internal class ItemRecyclerFragmentTest : FragmentTestCase<ItemRecyclerFragment, FragmentRecyclerviewBinding, ItemScreen>(false) {
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ import io.mockk.every
|
|||
import io.mockk.mockk
|
||||
import io.mockk.mockkObject
|
||||
import io.mockk.spyk
|
||||
import io.mockk.verify
|
||||
import kotlinx.coroutines.flow.flowOf
|
||||
import org.junit.Test
|
||||
|
||||
|
|
@ -29,9 +28,9 @@ class PetDetailScreen : Screen<PetDetailScreen>() {
|
|||
val recycler: KRecyclerView = KRecyclerView({
|
||||
withId(R.id.recyclerView)
|
||||
}, itemTypeBuilder = {
|
||||
itemType(::SectionItem)
|
||||
itemType(::PetItem)
|
||||
})
|
||||
itemType(::SectionItem)
|
||||
itemType(::PetItem)
|
||||
})
|
||||
}
|
||||
|
||||
internal class PetDetailRecyclerFragmentTest :
|
||||
|
|
|
|||
|
|
@ -33,9 +33,9 @@ class StableScreen : Screen<StableScreen>() {
|
|||
val recycler: KRecyclerView = KRecyclerView({
|
||||
withId(R.id.recyclerView)
|
||||
}, itemTypeBuilder = {
|
||||
itemType(::SectionItem)
|
||||
itemType(::PetItem)
|
||||
})
|
||||
itemType(::SectionItem)
|
||||
itemType(::PetItem)
|
||||
})
|
||||
}
|
||||
|
||||
internal class StableRecyclerFragmentTest : FragmentTestCase<StableRecyclerFragment, FragmentRecyclerviewBinding, StableScreen>(false) {
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@ import com.habitrpg.android.habitica.R
|
|||
import com.habitrpg.android.habitica.databinding.FragmentRefreshRecyclerviewBinding
|
||||
import com.habitrpg.android.habitica.models.tasks.Task
|
||||
import com.habitrpg.android.habitica.models.tasks.TaskList
|
||||
import com.habitrpg.shared.habitica.models.tasks.TaskType
|
||||
import com.habitrpg.android.habitica.ui.fragments.FragmentTestCase
|
||||
import com.habitrpg.shared.habitica.models.tasks.TaskType
|
||||
import io.github.kakaocup.kakao.common.views.KView
|
||||
import io.github.kakaocup.kakao.recycler.KRecyclerItem
|
||||
import io.github.kakaocup.kakao.recycler.KRecyclerView
|
||||
|
|
@ -30,8 +30,8 @@ class TaskListScreen : Screen<TaskListScreen>() {
|
|||
val recycler: KRecyclerView = KRecyclerView({
|
||||
withId(R.id.recyclerView)
|
||||
}, itemTypeBuilder = {
|
||||
itemType(::TaskItem)
|
||||
})
|
||||
itemType(::TaskItem)
|
||||
})
|
||||
}
|
||||
|
||||
internal class TaskRecyclerViewFragmentTest : FragmentTestCase<TaskRecyclerViewFragment, FragmentRefreshRecyclerviewBinding, TaskListScreen>(false) {
|
||||
|
|
|
|||
|
|
@ -81,7 +81,6 @@ abstract class HabiticaBaseApplication : Application(), Application.ActivityLife
|
|||
|
||||
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true)
|
||||
|
||||
|
||||
setupCoil()
|
||||
|
||||
ExceptionHandler.init(analyticsManager)
|
||||
|
|
|
|||
|
|
@ -461,5 +461,5 @@ interface ApiService {
|
|||
suspend fun getHallMember(@Path("memberID") memberID: String): HabitResponse<Member>
|
||||
|
||||
@POST("tasks/{taskID}/needs-work/{userID}")
|
||||
suspend fun markTaskNeedsWork(@Path("taskID") taskID: String, @Path("userID") userID: String): HabitResponse<Task>
|
||||
suspend fun markTaskNeedsWork(@Path("taskID") taskID: String, @Path("userID") userID: String): HabitResponse<Task>
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import com.habitrpg.android.habitica.models.ContentResult
|
|||
import com.habitrpg.android.habitica.models.WorldState
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
interface ContentRepository: BaseRepository {
|
||||
interface ContentRepository : BaseRepository {
|
||||
suspend fun retrieveContent(forced: Boolean = false): ContentResult?
|
||||
|
||||
suspend fun retrieveWorldState(forced: Boolean = false): WorldState?
|
||||
|
|
|
|||
|
|
@ -68,5 +68,4 @@ interface TaskRepository : BaseRepository {
|
|||
fun getTasksForChallenge(challengeID: String?): Flow<List<Task>>
|
||||
suspend fun bulkScoreTasks(data: List<Map<String, String>>): BulkTaskScoringData?
|
||||
suspend fun markTaskNeedsWork(task: Task, userID: String)
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ class ApiClientImpl(
|
|||
private val analyticsManager: AnalyticsManager,
|
||||
private val notificationsManager: NotificationsManager,
|
||||
private val context: Context
|
||||
): ApiClient {
|
||||
) : ApiClient {
|
||||
|
||||
private lateinit var retrofitAdapter: Retrofit
|
||||
|
||||
|
|
@ -325,7 +325,7 @@ class ApiClientImpl(
|
|||
override suspend fun getStatus(): Status? = process { apiService.getStatus() }
|
||||
|
||||
override suspend fun getContent(language: String?): ContentResult? {
|
||||
return process { apiService.getContent(language ?: this.languageCode) }
|
||||
return process { apiService.getContent(language ?: this.languageCode) }
|
||||
}
|
||||
|
||||
override suspend fun updateUser(updateDictionary: Map<String, Any>): User? {
|
||||
|
|
@ -479,11 +479,11 @@ class ApiClientImpl(
|
|||
|
||||
override suspend fun revive(): User? = process { apiService.revive() }
|
||||
|
||||
suspend override fun useSkill(skillName: String, targetType: String, targetId: String): SkillResponse? {
|
||||
override suspend fun useSkill(skillName: String, targetType: String, targetId: String): SkillResponse? {
|
||||
return process { apiService.useSkill(skillName, targetType, targetId) }
|
||||
}
|
||||
|
||||
suspend override fun useSkill(skillName: String, targetType: String): SkillResponse? {
|
||||
override suspend fun useSkill(skillName: String, targetType: String): SkillResponse? {
|
||||
return process { apiService.useSkill(skillName, targetType) }
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ class ChallengeRepositoryImpl(
|
|||
return tasksOrder
|
||||
}
|
||||
|
||||
private suspend fun addChallengeTasks(challenge: Challenge, addedTaskList: List<Task>) {
|
||||
private suspend fun addChallengeTasks(challenge: Challenge, addedTaskList: List<Task>) {
|
||||
when {
|
||||
addedTaskList.count() == 1 -> apiClient.createChallengeTask(challenge.id ?: "", addedTaskList[0])
|
||||
addedTaskList.count() > 1 -> apiClient.createChallengeTasks(challenge.id ?: "", addedTaskList)
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ class InventoryRepositoryImpl(
|
|||
}
|
||||
|
||||
override suspend fun retrieveInAppRewards(): List<ShopItem>? {
|
||||
val rewards = apiClient.retrieveInAppRewards()
|
||||
val rewards = apiClient.retrieveInAppRewards()
|
||||
if (rewards != null) {
|
||||
localRepository.saveInAppRewards(rewards)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -306,17 +306,17 @@ class SocialRepositoryImpl(
|
|||
|
||||
override suspend fun acceptQuest(user: User?, partyId: String): Void? {
|
||||
apiClient.acceptQuest(partyId)
|
||||
user?.let {
|
||||
localRepository.updateRSVPNeeded(it, false)
|
||||
}
|
||||
user?.let {
|
||||
localRepository.updateRSVPNeeded(it, false)
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
override suspend fun rejectQuest(user: User?, partyId: String): Void? {
|
||||
apiClient.rejectQuest(partyId)
|
||||
user?.let {
|
||||
localRepository.updateRSVPNeeded(it, false)
|
||||
}
|
||||
user?.let {
|
||||
localRepository.updateRSVPNeeded(it, false)
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -43,7 +43,6 @@ class UserRepositoryImpl(
|
|||
private var lastSync: Date? = null
|
||||
}
|
||||
|
||||
|
||||
override fun getUser(): Flow<User?> = getUser(userID)
|
||||
override fun getUser(userID: String): Flow<User?> = localRepository.getUser(userID)
|
||||
|
||||
|
|
@ -126,7 +125,7 @@ class UserRepositoryImpl(
|
|||
val response = apiClient.useSkill(key, target ?: "", taskId) ?: return null
|
||||
val user = getLiveUser() ?: return response
|
||||
response.hpDiff = (response.user?.stats?.hp ?: 0.0) - (user.stats?.hp ?: 0.0)
|
||||
response.expDiff =(response.user?.stats?.exp ?: 0.0) - (user.stats?.exp ?: 0.0)
|
||||
response.expDiff = (response.user?.stats?.exp ?: 0.0) - (user.stats?.exp ?: 0.0)
|
||||
response.goldDiff = (response.user?.stats?.gp ?: 0.0) - (user.stats?.gp ?: 0.0)
|
||||
response.damage = (response.user?.party?.quest?.progress?.up ?: 0.0f) - (user.party?.quest?.progress?.up ?: 0.0f)
|
||||
response.user?.let { mergeUser(user, it) }
|
||||
|
|
@ -137,7 +136,7 @@ class UserRepositoryImpl(
|
|||
val response = apiClient.useSkill(key, target ?: "") ?: return null
|
||||
val user = getLiveUser() ?: return response
|
||||
response.hpDiff = (response.user?.stats?.hp ?: 0.0) - (user.stats?.hp ?: 0.0)
|
||||
response.expDiff =(response.user?.stats?.exp ?: 0.0) - (user.stats?.exp ?: 0.0)
|
||||
response.expDiff = (response.user?.stats?.exp ?: 0.0) - (user.stats?.exp ?: 0.0)
|
||||
response.goldDiff = (response.user?.stats?.gp ?: 0.0) - (user.stats?.gp ?: 0.0)
|
||||
response.damage = (response.user?.party?.quest?.progress?.up ?: 0.0f) - (user.party?.quest?.progress?.up ?: 0.0f)
|
||||
response.user?.let { mergeUser(user, it) }
|
||||
|
|
|
|||
|
|
@ -65,5 +65,4 @@ interface InventoryLocalRepository : ContentLocalRepository {
|
|||
fun getLiveObject(obj: OwnedItem): OwnedItem?
|
||||
fun getItems(itemClass: Class<out Item>): Flow<List<Item>>
|
||||
fun getItems(itemClass: Class<out Item>, keys: Array<String>): Flow<List<Item>>
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ abstract class RealmBaseLocalRepository internal constructor(override var realm:
|
|||
private var pendingSaves = mutableListOf<Any>()
|
||||
}
|
||||
|
||||
private fun <T: RealmModel> copy(realm: Realm, obj: T) {
|
||||
private fun <T : RealmModel> copy(realm: Realm, obj: T) {
|
||||
try {
|
||||
realm.insertOrUpdate(obj)
|
||||
} catch (_: java.lang.IllegalArgumentException) {
|
||||
|
|
@ -119,9 +119,9 @@ abstract class RealmBaseLocalRepository internal constructor(override var realm:
|
|||
|
||||
fun queryUser(userID: String): Flow<User?> {
|
||||
return realm.where(User::class.java)
|
||||
.equalTo("id", userID)
|
||||
.findAll()
|
||||
.toFlow()
|
||||
.equalTo("id", userID)
|
||||
.findAll()
|
||||
.toFlow()
|
||||
.filter { it.isLoaded && it.isValid && !it.isEmpty() }
|
||||
.map { it.firstOrNull() }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,61 +18,61 @@ import kotlinx.coroutines.flow.map
|
|||
class RealmChallengeLocalRepository(realm: Realm) : RealmBaseLocalRepository(realm), ChallengeLocalRepository {
|
||||
|
||||
override fun isChallengeMember(userID: String, challengeID: String): Flow<Boolean> = realm.where(ChallengeMembership::class.java)
|
||||
.equalTo("userID", userID)
|
||||
.equalTo("challengeID", challengeID)
|
||||
.findAll()
|
||||
.toFlow()
|
||||
.filter { it.isLoaded }
|
||||
.equalTo("userID", userID)
|
||||
.equalTo("challengeID", challengeID)
|
||||
.findAll()
|
||||
.toFlow()
|
||||
.filter { it.isLoaded }
|
||||
.map { it.count() > 0 }
|
||||
|
||||
override fun getChallengeMembership(userId: String, id: String) = realm.where(ChallengeMembership::class.java)
|
||||
.equalTo("userID", userId)
|
||||
.equalTo("challengeID", id)
|
||||
.findAll()
|
||||
.toFlow()
|
||||
.filter { it.isLoaded }
|
||||
.map { it.first() }
|
||||
.equalTo("userID", userId)
|
||||
.equalTo("challengeID", id)
|
||||
.findAll()
|
||||
.toFlow()
|
||||
.filter { it.isLoaded }
|
||||
.map { it.first() }
|
||||
.filterNotNull()
|
||||
|
||||
override fun getChallengeMemberships(userId: String) = realm.where(ChallengeMembership::class.java)
|
||||
.equalTo("userID", userId)
|
||||
.findAll()
|
||||
.toFlow()
|
||||
.filter { it.isLoaded }
|
||||
.equalTo("userID", userId)
|
||||
.findAll()
|
||||
.toFlow()
|
||||
.filter { it.isLoaded }
|
||||
|
||||
override fun getChallenge(id: String): Flow<Challenge> {
|
||||
return realm.where(Challenge::class.java)
|
||||
.equalTo("id", id)
|
||||
.findAll()
|
||||
.toFlow()
|
||||
.filter { realmObject -> realmObject.isLoaded && realmObject.isNotEmpty() }
|
||||
.map { it.first() }
|
||||
.equalTo("id", id)
|
||||
.findAll()
|
||||
.toFlow()
|
||||
.filter { realmObject -> realmObject.isLoaded && realmObject.isNotEmpty() }
|
||||
.map { it.first() }
|
||||
.filterNotNull()
|
||||
}
|
||||
|
||||
override fun getTasks(challengeID: String): Flow<List<Task>> {
|
||||
return realm.where(Task::class.java)
|
||||
.equalTo("userId", challengeID)
|
||||
.findAll()
|
||||
.toFlow()
|
||||
.filter { realmObject -> realmObject.isLoaded }
|
||||
.equalTo("userId", challengeID)
|
||||
.findAll()
|
||||
.toFlow()
|
||||
.filter { realmObject -> realmObject.isLoaded }
|
||||
}
|
||||
|
||||
override val challenges: Flow<List<Challenge>>
|
||||
get() = realm.where(Challenge::class.java)
|
||||
.isNotNull("name")
|
||||
.sort("official", Sort.DESCENDING, "createdAt", Sort.DESCENDING)
|
||||
.findAll()
|
||||
.toFlow()
|
||||
.filter { it.isLoaded }
|
||||
.isNotNull("name")
|
||||
.sort("official", Sort.DESCENDING, "createdAt", Sort.DESCENDING)
|
||||
.findAll()
|
||||
.toFlow()
|
||||
.filter { it.isLoaded }
|
||||
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
override fun getUserChallenges(userId: String): Flow<List<Challenge>> {
|
||||
return realm.where(ChallengeMembership::class.java)
|
||||
.equalTo("userID", userId)
|
||||
.findAll()
|
||||
.toFlow()
|
||||
.filter { it.isLoaded }
|
||||
.equalTo("userID", userId)
|
||||
.findAll()
|
||||
.toFlow()
|
||||
.filter { it.isLoaded }
|
||||
.flatMapLatest { it ->
|
||||
val ids = it.map {
|
||||
return@map it.challengeID
|
||||
|
|
|
|||
|
|
@ -39,10 +39,10 @@ open class RealmContentLocalRepository(realm: Realm) : RealmBaseLocalRepository(
|
|||
|
||||
override fun getWorldState(): Flow<WorldState> {
|
||||
return realm.where(WorldState::class.java)
|
||||
.findAll()
|
||||
.toFlow()
|
||||
.filter { it.isLoaded && it.size > 0 }
|
||||
.map { it.first() }
|
||||
.findAll()
|
||||
.toFlow()
|
||||
.filter { it.isLoaded && it.size > 0 }
|
||||
.map { it.first() }
|
||||
.filterNotNull()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,9 +30,9 @@ class RealmCustomizationLocalRepository(realm: Realm) : RealmContentLocalReposit
|
|||
.endGroup()
|
||||
}
|
||||
return query
|
||||
.sort("customizationSet")
|
||||
.findAll()
|
||||
.toFlow()
|
||||
.filter { it.isLoaded }
|
||||
.sort("customizationSet")
|
||||
.findAll()
|
||||
.toFlow()
|
||||
.filter { it.isLoaded }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,17 +12,17 @@ import kotlinx.coroutines.flow.map
|
|||
class RealmFAQLocalRepository(realm: Realm) : RealmContentLocalRepository(realm), FAQLocalRepository {
|
||||
override fun getArticle(position: Int): Flow<FAQArticle> {
|
||||
return realm.where(FAQArticle::class.java)
|
||||
.equalTo("position", position)
|
||||
.findAll()
|
||||
.toFlow()
|
||||
.filter { it.isLoaded && it.count() > 0 }
|
||||
.map { it.firstOrNull() }
|
||||
.equalTo("position", position)
|
||||
.findAll()
|
||||
.toFlow()
|
||||
.filter { it.isLoaded && it.count() > 0 }
|
||||
.map { it.firstOrNull() }
|
||||
.filterNotNull()
|
||||
}
|
||||
|
||||
override val articles: Flow<List<FAQArticle>>
|
||||
get() = realm.where(FAQArticle::class.java)
|
||||
.findAll()
|
||||
.toFlow()
|
||||
.filter { it.isLoaded }
|
||||
.findAll()
|
||||
.toFlow()
|
||||
.filter { it.isLoaded }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,8 @@ import java.text.SimpleDateFormat
|
|||
import java.util.Date
|
||||
import java.util.Locale
|
||||
|
||||
class RealmInventoryLocalRepository(realm: Realm) : RealmContentLocalRepository(realm),
|
||||
class RealmInventoryLocalRepository(realm: Realm) :
|
||||
RealmContentLocalRepository(realm),
|
||||
InventoryLocalRepository {
|
||||
override fun getQuestContent(keys: List<String>): Flow<List<QuestContent>> {
|
||||
return realm.where(QuestContent::class.java)
|
||||
|
|
|
|||
|
|
@ -21,18 +21,18 @@ import kotlinx.coroutines.flow.map
|
|||
class RealmSocialLocalRepository(realm: Realm) : RealmBaseLocalRepository(realm), SocialLocalRepository {
|
||||
|
||||
override fun getGroupMembership(userId: String, id: String) = realm.where(GroupMembership::class.java)
|
||||
.equalTo("userID", userId)
|
||||
.equalTo("groupID", id)
|
||||
.findAll()
|
||||
.toFlow()
|
||||
.filter { it.isLoaded && it.isNotEmpty() }
|
||||
.map { it.first() }
|
||||
.equalTo("userID", userId)
|
||||
.equalTo("groupID", id)
|
||||
.findAll()
|
||||
.toFlow()
|
||||
.filter { it.isLoaded && it.isNotEmpty() }
|
||||
.map { it.first() }
|
||||
|
||||
override fun getGroupMemberships(userId: String): Flow<List<GroupMembership>> = realm.where(GroupMembership::class.java)
|
||||
.equalTo("userID", userId)
|
||||
.findAll()
|
||||
.toFlow()
|
||||
.filter { it.isLoaded }
|
||||
.equalTo("userID", userId)
|
||||
.findAll()
|
||||
.toFlow()
|
||||
.filter { it.isLoaded }
|
||||
|
||||
override fun updateMembership(userId: String, id: String, isMember: Boolean) {
|
||||
if (isMember) {
|
||||
|
|
@ -129,19 +129,19 @@ class RealmSocialLocalRepository(realm: Realm) : RealmBaseLocalRepository(realm)
|
|||
}
|
||||
|
||||
override fun getPublicGuilds() = realm.where(Group::class.java)
|
||||
.equalTo("type", "guild")
|
||||
.equalTo("privacy", "public")
|
||||
.notEqualTo("id", Group.TAVERN_ID)
|
||||
.sort("memberCount", Sort.DESCENDING)
|
||||
.findAll()
|
||||
.toFlow()
|
||||
.filter { it.isLoaded }
|
||||
.equalTo("type", "guild")
|
||||
.equalTo("privacy", "public")
|
||||
.notEqualTo("id", Group.TAVERN_ID)
|
||||
.sort("memberCount", Sort.DESCENDING)
|
||||
.findAll()
|
||||
.toFlow()
|
||||
.filter { it.isLoaded }
|
||||
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
override fun getUserGroups(userID: String, type: String?) = realm.where(GroupMembership::class.java)
|
||||
.equalTo("userID", userID)
|
||||
.findAll()
|
||||
.toFlow()
|
||||
.equalTo("userID", userID)
|
||||
.findAll()
|
||||
.toFlow()
|
||||
.filter { it.isLoaded }
|
||||
.flatMapLatest { memberships ->
|
||||
realm.where(Group::class.java)
|
||||
|
|
@ -160,10 +160,10 @@ class RealmSocialLocalRepository(realm: Realm) : RealmBaseLocalRepository(realm)
|
|||
|
||||
override fun getGroups(type: String): Flow<List<Group>> {
|
||||
return realm.where(Group::class.java)
|
||||
.equalTo("type", type)
|
||||
.findAll()
|
||||
.toFlow()
|
||||
.filter { it.isLoaded }
|
||||
.equalTo("type", type)
|
||||
.findAll()
|
||||
.toFlow()
|
||||
.filter { it.isLoaded }
|
||||
}
|
||||
|
||||
override fun getGroup(id: String): Flow<Group?> {
|
||||
|
|
@ -177,11 +177,11 @@ class RealmSocialLocalRepository(realm: Realm) : RealmBaseLocalRepository(realm)
|
|||
|
||||
override fun getGroupChat(groupId: String): Flow<List<ChatMessage>> {
|
||||
return realm.where(ChatMessage::class.java)
|
||||
.equalTo("groupId", groupId)
|
||||
.sort("timestamp", Sort.DESCENDING)
|
||||
.findAll()
|
||||
.toFlow()
|
||||
.filter { it.isLoaded }
|
||||
.equalTo("groupId", groupId)
|
||||
.sort("timestamp", Sort.DESCENDING)
|
||||
.findAll()
|
||||
.toFlow()
|
||||
.filter { it.isLoaded }
|
||||
}
|
||||
|
||||
override fun deleteMessage(id: String) {
|
||||
|
|
@ -190,9 +190,9 @@ class RealmSocialLocalRepository(realm: Realm) : RealmBaseLocalRepository(realm)
|
|||
}
|
||||
|
||||
override fun getPartyMembers(partyId: String) = realm.where(Member::class.java)
|
||||
.equalTo("party.id", partyId)
|
||||
.findAll()
|
||||
.toFlow()
|
||||
.equalTo("party.id", partyId)
|
||||
.findAll()
|
||||
.toFlow()
|
||||
|
||||
override fun getGroupMembers(groupID: String) = realm.where(GroupMembership::class.java)
|
||||
.equalTo("groupID", groupID)
|
||||
|
|
@ -291,18 +291,18 @@ class RealmSocialLocalRepository(realm: Realm) : RealmBaseLocalRepository(realm)
|
|||
}
|
||||
|
||||
override fun getInboxMessages(userId: String, replyToUserID: String?) = realm.where(ChatMessage::class.java)
|
||||
.equalTo("isInboxMessage", true)
|
||||
.equalTo("uuid", replyToUserID)
|
||||
.equalTo("userID", userId)
|
||||
.sort("timestamp", Sort.DESCENDING)
|
||||
.findAll()
|
||||
.toFlow()
|
||||
.filter { it.isLoaded }
|
||||
.equalTo("isInboxMessage", true)
|
||||
.equalTo("uuid", replyToUserID)
|
||||
.equalTo("userID", userId)
|
||||
.sort("timestamp", Sort.DESCENDING)
|
||||
.findAll()
|
||||
.toFlow()
|
||||
.filter { it.isLoaded }
|
||||
|
||||
override fun getInboxConversation(userId: String) = realm.where(InboxConversation::class.java)
|
||||
.equalTo("userID", userId)
|
||||
.sort("timestamp", Sort.DESCENDING)
|
||||
.findAll()
|
||||
.toFlow()
|
||||
.filter { it.isLoaded }
|
||||
.equalTo("userID", userId)
|
||||
.sort("timestamp", Sort.DESCENDING)
|
||||
.findAll()
|
||||
.toFlow()
|
||||
.filter { it.isLoaded }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,10 +56,10 @@ class RealmTaskLocalRepository(realm: Realm) : RealmBaseLocalRepository(realm),
|
|||
override fun getTasks(userId: String): Flow<List<Task>> {
|
||||
if (realm.isClosed) return emptyFlow()
|
||||
return realm.where(Task::class.java).equalTo("userId", userId)
|
||||
.sort("position", Sort.ASCENDING, "dateCreated", Sort.DESCENDING)
|
||||
.findAll()
|
||||
.toFlow()
|
||||
.filter { it.isLoaded }
|
||||
.sort("position", Sort.ASCENDING, "dateCreated", Sort.DESCENDING)
|
||||
.findAll()
|
||||
.toFlow()
|
||||
.filter { it.isLoaded }
|
||||
}
|
||||
|
||||
override fun saveTasks(ownerID: String, tasksOrder: TasksOrder, tasks: TaskList) {
|
||||
|
|
@ -218,10 +218,10 @@ class RealmTaskLocalRepository(realm: Realm) : RealmBaseLocalRepository(realm),
|
|||
|
||||
override fun getTaskAtPosition(taskType: String, position: Int): Flow<Task> {
|
||||
return realm.where(Task::class.java).equalTo("typeValue", taskType).equalTo("position", position)
|
||||
.findAll()
|
||||
.toFlow()
|
||||
.filter { realmObject -> realmObject.isLoaded && realmObject.isNotEmpty() }
|
||||
.map { it.first() }
|
||||
.findAll()
|
||||
.toFlow()
|
||||
.filter { realmObject -> realmObject.isLoaded && realmObject.isNotEmpty() }
|
||||
.map { it.first() }
|
||||
.filterNotNull()
|
||||
}
|
||||
|
||||
|
|
@ -244,12 +244,12 @@ class RealmTaskLocalRepository(realm: Realm) : RealmBaseLocalRepository(realm),
|
|||
|
||||
override fun getErroredTasks(userID: String): Flow<List<Task>> {
|
||||
return realm.where(Task::class.java)
|
||||
.equalTo("userId", userID)
|
||||
.equalTo("hasErrored", true)
|
||||
.sort("position")
|
||||
.findAll()
|
||||
.toFlow()
|
||||
.filter { it.isLoaded }
|
||||
.equalTo("userId", userID)
|
||||
.equalTo("hasErrored", true)
|
||||
.sort("position")
|
||||
.findAll()
|
||||
.toFlow()
|
||||
.filter { it.isLoaded }
|
||||
}
|
||||
|
||||
override fun getUser(userID: String): Flow<User> {
|
||||
|
|
@ -264,10 +264,10 @@ class RealmTaskLocalRepository(realm: Realm) : RealmBaseLocalRepository(realm),
|
|||
|
||||
override fun getTasksForChallenge(challengeID: String?, userID: String?): Flow<List<Task>> {
|
||||
return realm.where(Task::class.java)
|
||||
.equalTo("challengeID", challengeID)
|
||||
.equalTo("userId", userID)
|
||||
.findAll()
|
||||
.toFlow()
|
||||
.filter { it.isLoaded }
|
||||
.equalTo("challengeID", challengeID)
|
||||
.equalTo("userId", userID)
|
||||
.findAll()
|
||||
.toFlow()
|
||||
.filter { it.isLoaded }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,19 +15,19 @@ class RealmTutorialLocalRepository(realm: Realm) : RealmBaseLocalRepository(real
|
|||
override fun getTutorialStep(key: String): Flow<TutorialStep> {
|
||||
if (realm.isClosed) return emptyFlow()
|
||||
return realm.where(TutorialStep::class.java).equalTo("identifier", key)
|
||||
.findAll()
|
||||
.toFlow()
|
||||
.filter { realmObject -> realmObject.isLoaded && realmObject.isValid && realmObject.isNotEmpty() }
|
||||
.map { steps -> steps.first() }
|
||||
.findAll()
|
||||
.toFlow()
|
||||
.filter { realmObject -> realmObject.isLoaded && realmObject.isValid && realmObject.isNotEmpty() }
|
||||
.map { steps -> steps.first() }
|
||||
.filterNotNull()
|
||||
}
|
||||
|
||||
override fun getTutorialSteps(keys: List<String>): Flow<out List<TutorialStep>> {
|
||||
if (realm.isClosed) return emptyFlow()
|
||||
return realm.where(TutorialStep::class.java)
|
||||
.`in`("identifier", keys.toTypedArray())
|
||||
.findAll()
|
||||
.toFlow()
|
||||
.filter { it.isLoaded }
|
||||
.`in`("identifier", keys.toTypedArray())
|
||||
.findAll()
|
||||
.toFlow()
|
||||
.filter { it.isLoaded }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,8 @@ import kotlinx.coroutines.flow.filterNotNull
|
|||
import kotlinx.coroutines.flow.flatMapLatest
|
||||
import kotlinx.coroutines.flow.map
|
||||
|
||||
class RealmUserLocalRepository(realm: Realm) : RealmBaseLocalRepository(realm),
|
||||
class RealmUserLocalRepository(realm: Realm) :
|
||||
RealmBaseLocalRepository(realm),
|
||||
UserLocalRepository {
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
override fun getUserQuestStatus(userID: String): Flow<UserQuestStatus> {
|
||||
|
|
@ -30,13 +31,13 @@ class RealmUserLocalRepository(realm: Realm) : RealmBaseLocalRepository(realm),
|
|||
.map { it.party?.id ?: "" }
|
||||
.filter { it.isNotBlank() }
|
||||
.flatMapLatest {
|
||||
realm.where(Group::class.java)
|
||||
.equalTo("id", it)
|
||||
.findAll()
|
||||
.toFlow()
|
||||
.filter { groups -> groups.size > 0 }
|
||||
.map { it.firstOrNull() }
|
||||
.filterNotNull()
|
||||
realm.where(Group::class.java)
|
||||
.equalTo("id", it)
|
||||
.findAll()
|
||||
.toFlow()
|
||||
.filter { groups -> groups.size > 0 }
|
||||
.map { it.firstOrNull() }
|
||||
.filterNotNull()
|
||||
}
|
||||
.map {
|
||||
when {
|
||||
|
|
@ -127,22 +128,22 @@ class RealmUserLocalRepository(realm: Realm) : RealmBaseLocalRepository(realm),
|
|||
override fun getTeamPlan(teamID: String): Flow<Group?> {
|
||||
if (realm.isClosed) return emptyFlow()
|
||||
return realm.where(Group::class.java)
|
||||
.equalTo("id", teamID)
|
||||
.findAll()
|
||||
.toFlow()
|
||||
.filter { realmObject -> realmObject.isLoaded && realmObject.isValid }
|
||||
.map { teams -> teams.firstOrNull() }
|
||||
.equalTo("id", teamID)
|
||||
.findAll()
|
||||
.toFlow()
|
||||
.filter { realmObject -> realmObject.isLoaded && realmObject.isValid }
|
||||
.map { teams -> teams.firstOrNull() }
|
||||
}
|
||||
|
||||
override fun getSkills(user: User): Flow<List<Skill>> {
|
||||
val habitClass =
|
||||
if (user.preferences?.disableClasses == true) "none" else user.stats?.habitClass
|
||||
return realm.where(Skill::class.java)
|
||||
.equalTo("habitClass", habitClass)
|
||||
.sort("lvl")
|
||||
.findAll()
|
||||
.toFlow()
|
||||
.filter { it.isLoaded }
|
||||
.equalTo("habitClass", habitClass)
|
||||
.sort("lvl")
|
||||
.findAll()
|
||||
.toFlow()
|
||||
.filter { it.isLoaded }
|
||||
}
|
||||
|
||||
override fun getSpecialItems(user: User): Flow<List<Skill>> {
|
||||
|
|
@ -154,9 +155,9 @@ class RealmUserLocalRepository(realm: Realm) : RealmBaseLocalRepository(realm),
|
|||
}
|
||||
}
|
||||
return realm.where(Skill::class.java)
|
||||
.`in`("key", ownedItems.toTypedArray())
|
||||
.findAll()
|
||||
.toFlow()
|
||||
.filter { it.isLoaded }
|
||||
.`in`("key", ownedItems.toTypedArray())
|
||||
.findAll()
|
||||
.toFlow()
|
||||
.filter { it.isLoaded }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ import com.habitrpg.common.habitica.helpers.AppTestingLevel
|
|||
import kotlinx.coroutines.MainScope
|
||||
import java.util.Date
|
||||
|
||||
class AppConfigManager(contentRepository: ContentRepository?): com.habitrpg.common.habitica.helpers.AppConfigManager() {
|
||||
class AppConfigManager(contentRepository: ContentRepository?) : com.habitrpg.common.habitica.helpers.AppConfigManager() {
|
||||
|
||||
private var worldState: WorldState? = null
|
||||
|
||||
|
|
@ -24,8 +24,8 @@ class AppConfigManager(contentRepository: ContentRepository?): com.habitrpg.comm
|
|||
try {
|
||||
MainScope().launchCatching {
|
||||
contentRepository?.getWorldState()?.collect {
|
||||
worldState = it
|
||||
}
|
||||
worldState = it
|
||||
}
|
||||
}
|
||||
} catch (_: java.lang.IllegalStateException) {
|
||||
// pass
|
||||
|
|
|
|||
|
|
@ -7,13 +7,8 @@ import kotlinx.coroutines.CancellationException
|
|||
import kotlinx.coroutines.CoroutineExceptionHandler
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.launch
|
||||
import okhttp3.internal.http2.ConnectionShutdownException
|
||||
import okhttp3.internal.http2.StreamResetException
|
||||
import retrofit2.HttpException
|
||||
import java.io.EOFException
|
||||
import java.io.IOException
|
||||
import java.net.SocketTimeoutException
|
||||
import java.net.UnknownHostException
|
||||
|
||||
class ExceptionHandler {
|
||||
private var analyticsManager: AnalyticsManager? = null
|
||||
|
|
@ -52,7 +47,12 @@ class ExceptionHandler {
|
|||
}
|
||||
|
||||
fun CoroutineScope.launchCatching(errorHandler: ((Throwable) -> Unit)? = null, function: suspend CoroutineScope.() -> Unit) {
|
||||
launch((ExceptionHandler.coroutine {
|
||||
errorHandler?.invoke(it)
|
||||
}), block = function)
|
||||
launch(
|
||||
(
|
||||
ExceptionHandler.coroutine {
|
||||
errorHandler?.invoke(it)
|
||||
}
|
||||
),
|
||||
block = function
|
||||
)
|
||||
}
|
||||
|
|
@ -20,7 +20,7 @@ object MainNavigationController {
|
|||
get() { return controllerReference?.get() }
|
||||
|
||||
val isReady: Boolean
|
||||
get() = controllerReference?.get() != null
|
||||
get() = controllerReference?.get() != null
|
||||
|
||||
fun setup(navController: NavController) {
|
||||
this.controllerReference = WeakReference(navController)
|
||||
|
|
|
|||
|
|
@ -24,31 +24,31 @@ interface NotificationsManager {
|
|||
fun dismissTaskNotification(context: Context, task: Task)
|
||||
}
|
||||
|
||||
class MainNotificationsManager: NotificationsManager {
|
||||
class MainNotificationsManager : NotificationsManager {
|
||||
|
||||
private val seenNotifications: MutableMap<String, Boolean>
|
||||
override var apiClient: WeakReference<ApiClient>? = null
|
||||
|
||||
private var lastNotificationHandling: Date? = null
|
||||
val _notifications = MutableStateFlow<List<Notification>?>(null)
|
||||
val _displaynotificationEvents = Channel<Notification>()
|
||||
override val displayNotificationEvents: Flow<Notification> = _displaynotificationEvents.receiveAsFlow().filterNotNull()
|
||||
private val notificationsFlow = MutableStateFlow<List<Notification>?>(null)
|
||||
private val displayedNotificationEvents = Channel<Notification>()
|
||||
override val displayNotificationEvents: Flow<Notification> = displayedNotificationEvents.receiveAsFlow().filterNotNull()
|
||||
|
||||
init {
|
||||
this.seenNotifications = HashMap()
|
||||
}
|
||||
|
||||
override fun setNotifications(current: List<Notification>) {
|
||||
_notifications.value = current
|
||||
notificationsFlow.value = current
|
||||
this.handlePopupNotifications(current)
|
||||
}
|
||||
|
||||
override fun getNotifications(): Flow<List<Notification>> {
|
||||
return _notifications.filterNotNull()
|
||||
return notificationsFlow.filterNotNull()
|
||||
}
|
||||
|
||||
override fun getNotification(id: String): Notification? {
|
||||
return _notifications.value?.find { it.id == id }
|
||||
return notificationsFlow.value?.find { it.id == id }
|
||||
}
|
||||
|
||||
override fun dismissTaskNotification(context: Context, task: Task) {
|
||||
|
|
@ -92,7 +92,6 @@ class MainNotificationsManager: NotificationsManager {
|
|||
Notification.Type.ACHIEVEMENT_FRESHWATER_FRIENDS.type -> true
|
||||
Notification.Type.ACHIEVEMENT_GOOD_AS_GOLD.type -> true
|
||||
Notification.Type.ACHIEVEMENT_ALL_THAT_GLITTERS.type -> true
|
||||
Notification.Type.ACHIEVEMENT_GOOD_AS_GOLD.type -> true
|
||||
Notification.Type.ACHIEVEMENT_BONE_COLLECTOR.type -> true
|
||||
Notification.Type.ACHIEVEMENT_SKELETON_CREW.type -> true
|
||||
Notification.Type.ACHIEVEMENT_SEEING_RED.type -> true
|
||||
|
|
@ -115,7 +114,7 @@ class MainNotificationsManager: NotificationsManager {
|
|||
|
||||
private fun readNotification(notification: Notification) {
|
||||
MainScope().launchCatching {
|
||||
_displaynotificationEvents.send(notification)
|
||||
displayedNotificationEvents.send(notification)
|
||||
seenNotifications[notification.id] = true
|
||||
apiClient?.get()?.readNotification(notification.id)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -121,9 +121,9 @@ class PurchaseHandler(
|
|||
}
|
||||
|
||||
fun startListening() {
|
||||
if (billingClient.connectionState == BillingClient.ConnectionState.CONNECTING
|
||||
|| billingClient.connectionState == BillingClient.ConnectionState.CONNECTED
|
||||
|| billingClientState == BillingClientState.UNAVAILABLE
|
||||
if (billingClient.connectionState == BillingClient.ConnectionState.CONNECTING ||
|
||||
billingClient.connectionState == BillingClient.ConnectionState.CONNECTED ||
|
||||
billingClientState == BillingClientState.UNAVAILABLE
|
||||
) {
|
||||
// Don't connect again if it's already connected
|
||||
return
|
||||
|
|
@ -209,9 +209,11 @@ class PurchaseHandler(
|
|||
}
|
||||
billingClientState.canMaybePurchase && billingClient.isReady
|
||||
}
|
||||
val params = QueryProductDetailsParams.newBuilder().setProductList(skus.map {
|
||||
Product.newBuilder().setProductId(it).setProductType(type).build()
|
||||
}).build()
|
||||
val params = QueryProductDetailsParams.newBuilder().setProductList(
|
||||
skus.map {
|
||||
Product.newBuilder().setProductId(it).setProductType(type).build()
|
||||
}
|
||||
).build()
|
||||
val skuDetailsResult = withContext(Dispatchers.IO) {
|
||||
billingClient.queryProductDetails(params)
|
||||
}
|
||||
|
|
@ -230,12 +232,14 @@ class PurchaseHandler(
|
|||
addGift(skuDetails.productId, it, recipientUsername ?: it)
|
||||
}
|
||||
val flowParams =
|
||||
BillingFlowParams.newBuilder().setProductDetailsParamsList(listOf(skuDetails).map {
|
||||
BillingFlowParams.ProductDetailsParams.newBuilder()
|
||||
.setProductDetails(skuDetails).setOfferToken(
|
||||
skuDetails.subscriptionOfferDetails?.first()?.offerToken ?: ""
|
||||
).build()
|
||||
}).build()
|
||||
BillingFlowParams.newBuilder().setProductDetailsParamsList(
|
||||
listOf(skuDetails).map {
|
||||
BillingFlowParams.ProductDetailsParams.newBuilder()
|
||||
.setProductDetails(skuDetails).setOfferToken(
|
||||
skuDetails.subscriptionOfferDetails?.first()?.offerToken ?: ""
|
||||
).build()
|
||||
}
|
||||
).build()
|
||||
billingClient.launchBillingFlow(activity, flowParams)
|
||||
}
|
||||
|
||||
|
|
@ -555,9 +559,11 @@ class PurchaseHandler(
|
|||
}
|
||||
|
||||
suspend fun retryUntil(
|
||||
times: Int = Int.MAX_VALUE, initialDelay: Long = 100, // 0.1 second
|
||||
times: Int = Int.MAX_VALUE,
|
||||
initialDelay: Long = 100, // 0.1 second
|
||||
maxDelay: Long = 1000, // 1 second
|
||||
factor: Double = 2.0, block: suspend () -> Boolean
|
||||
factor: Double = 2.0,
|
||||
block: suspend () -> Boolean
|
||||
) {
|
||||
var currentDelay = initialDelay
|
||||
repeat(times - 1) {
|
||||
|
|
|
|||
|
|
@ -27,39 +27,39 @@ class SoundFileLoader(private val context: Context) {
|
|||
@SuppressLint("SetWorldReadable", "ReturnCount")
|
||||
suspend fun download(files: List<SoundFile>): List<SoundFile> {
|
||||
return files.map { audioFile ->
|
||||
withContext(Dispatchers.IO) {
|
||||
val file = File(getFullAudioFilePath(audioFile))
|
||||
if (file.exists() && file.length() > 5000) {
|
||||
// Important, or else the MediaPlayer can't access this file
|
||||
file.setReadable(true, false)
|
||||
audioFile.file = file
|
||||
return@withContext audioFile
|
||||
}
|
||||
val request = Request.Builder().url(audioFile.webUrl).build()
|
||||
|
||||
val response: Response
|
||||
try {
|
||||
response = client.newCall(request).execute()
|
||||
if (!response.isSuccessful) {
|
||||
throw IOException()
|
||||
}
|
||||
} catch (io: IOException) {
|
||||
return@withContext audioFile
|
||||
}
|
||||
|
||||
try {
|
||||
val sink = file.sink().buffer()
|
||||
sink.writeAll(response.body!!.source())
|
||||
sink.flush()
|
||||
sink.close()
|
||||
} catch (io: IOException) {
|
||||
return@withContext audioFile
|
||||
}
|
||||
|
||||
withContext(Dispatchers.IO) {
|
||||
val file = File(getFullAudioFilePath(audioFile))
|
||||
if (file.exists() && file.length() > 5000) {
|
||||
// Important, or else the MediaPlayer can't access this file
|
||||
file.setReadable(true, false)
|
||||
audioFile.file = file
|
||||
return@withContext audioFile
|
||||
}
|
||||
val request = Request.Builder().url(audioFile.webUrl).build()
|
||||
|
||||
val response: Response
|
||||
try {
|
||||
response = client.newCall(request).execute()
|
||||
if (!response.isSuccessful) {
|
||||
throw IOException()
|
||||
}
|
||||
} catch (io: IOException) {
|
||||
return@withContext audioFile
|
||||
}
|
||||
|
||||
try {
|
||||
val sink = file.sink().buffer()
|
||||
sink.writeAll(response.body!!.source())
|
||||
sink.flush()
|
||||
sink.close()
|
||||
} catch (io: IOException) {
|
||||
return@withContext audioFile
|
||||
}
|
||||
|
||||
file.setReadable(true, false)
|
||||
audioFile.file = file
|
||||
return@withContext audioFile
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -99,9 +99,9 @@ class TaskAlarmManager(
|
|||
private fun setAlarmForRemindersItem(reminderItemTask: Task, remindersItem: RemindersItem?) {
|
||||
val now = ZonedDateTime.now().withZoneSameLocal(ZoneId.systemDefault())?.toInstant()
|
||||
val zonedTime = remindersItem?.getLocalZonedDateTimeInstant()
|
||||
if (remindersItem == null
|
||||
|| (reminderItemTask.type == TaskType.DAILY && zonedTime?.isBefore(now) == true && reminderItemTask.nextDue?.firstOrNull() != null)
|
||||
|| (reminderItemTask.type == TaskType.TODO && zonedTime?.isBefore(now) == true)
|
||||
if (remindersItem == null ||
|
||||
(reminderItemTask.type == TaskType.DAILY && zonedTime?.isBefore(now) == true && reminderItemTask.nextDue?.firstOrNull() != null) ||
|
||||
(reminderItemTask.type == TaskType.TODO && zonedTime?.isBefore(now) == true)
|
||||
) {
|
||||
return
|
||||
}
|
||||
|
|
@ -226,7 +226,7 @@ class TaskAlarmManager(
|
|||
try {
|
||||
alarmManager?.setAlarmClock(AlarmClockInfo(time, pendingIntent), pendingIntent)
|
||||
} catch (ex: Exception) {
|
||||
when(ex) {
|
||||
when (ex) {
|
||||
is IllegalStateException, is SecurityException -> {
|
||||
alarmManager?.setWindow(AlarmManager.RTC_WAKEUP, time, 60000, pendingIntent)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,11 +94,13 @@ class TaskDescriptionBuilder(private val context: Context) {
|
|||
""
|
||||
}
|
||||
}
|
||||
Frequency.YEARLY -> " " + context.getString(R.string.on_x,
|
||||
Frequency.YEARLY -> " " + context.getString(
|
||||
R.string.on_x,
|
||||
task.startDate?.let {
|
||||
val flags = DateUtils.FORMAT_SHOW_DATE + DateUtils.FORMAT_NO_YEAR
|
||||
DateUtils.formatDateTime(context, it.time, flags)
|
||||
} ?: "")
|
||||
} ?: ""
|
||||
)
|
||||
else -> ""
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ class HabiticaFirebaseMessagingService : FirebaseMessagingService() {
|
|||
|
||||
if (remoteMessage.data["identifier"]?.contains(PushNotificationManager.WON_CHALLENGE_PUSH_NOTIFICATION_KEY) == true) {
|
||||
// if (this::userRepository.isInitialized) {
|
||||
// userRepository.retrieveUser(true).subscribe({}, RxErrorHandler.handleEmptyError())
|
||||
// userRepository.retrieveUser(true).subscribe({}, RxErrorHandler.handleEmptyError())
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ class PushNotificationManager(
|
|||
addRefreshToken()
|
||||
} catch (_: IOException) {
|
||||
// catchy catch-catch
|
||||
} catch (_: Exception){
|
||||
} catch (_: Exception) {
|
||||
// catchy catch-catch-cat, I'm out of breath.
|
||||
}
|
||||
}
|
||||
|
|
@ -85,7 +85,7 @@ class PushNotificationManager(
|
|||
if (this.refreshedToken.isEmpty() || !userHasPushDevice()) {
|
||||
return
|
||||
}
|
||||
apiClient.deletePushDevice(refreshedToken)
|
||||
apiClient.deletePushDevice(refreshedToken)
|
||||
}
|
||||
|
||||
private fun userHasPushDevice(): Boolean {
|
||||
|
|
@ -133,7 +133,8 @@ class PushNotificationManager(
|
|||
val remoteMessageIdentifier = remoteMessage.data["identifier"]
|
||||
|
||||
val notificationFactory = HabiticaLocalNotificationFactory()
|
||||
val notification = notificationFactory.build(remoteMessageIdentifier,
|
||||
val notification = notificationFactory.build(
|
||||
remoteMessageIdentifier,
|
||||
context
|
||||
)
|
||||
if (pushNotificationManager?.userIsSubscribedToNotificationType(remoteMessageIdentifier) != false) {
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import kotlinx.coroutines.launch
|
|||
import javax.inject.Inject
|
||||
|
||||
class DisplayItemDropUseCase @Inject
|
||||
constructor(private val soundManager: SoundManager):
|
||||
constructor(private val soundManager: SoundManager) :
|
||||
UseCase<DisplayItemDropUseCase.RequestValues, Unit>() {
|
||||
|
||||
override suspend fun run(requestValues: RequestValues) {
|
||||
|
|
|
|||
|
|
@ -20,7 +20,8 @@ import javax.inject.Inject
|
|||
|
||||
class HatchPetUseCase @Inject
|
||||
constructor(
|
||||
private val inventoryRepository: InventoryRepository) : UseCase<HatchPetUseCase.RequestValues, Items?>() {
|
||||
private val inventoryRepository: InventoryRepository
|
||||
) : UseCase<HatchPetUseCase.RequestValues, Items?>() {
|
||||
override suspend fun run(requestValues: RequestValues): Items? {
|
||||
return inventoryRepository.hatchPet(requestValues.egg, requestValues.potion) {
|
||||
val petWrapper = View.inflate(requestValues.context, R.layout.pet_imageview, null) as? FrameLayout
|
||||
|
|
|
|||
|
|
@ -52,10 +52,10 @@ open class Member : RealmObject(), Avatar, BaseMainObject, Assignable {
|
|||
} else this.profile?.name ?: ""
|
||||
|
||||
override val identifiableName: String
|
||||
get() = username ?: ""
|
||||
get() = username ?: ""
|
||||
|
||||
override val avatar: Avatar
|
||||
get() = this
|
||||
get() = this
|
||||
|
||||
val petsFoundCount: Int
|
||||
get() = this.items?.pets?.size ?: 0
|
||||
|
|
|
|||
|
|
@ -6,7 +6,8 @@ import io.realm.RealmObject
|
|||
import io.realm.annotations.RealmClass
|
||||
|
||||
@RealmClass(embedded = true)
|
||||
open class MemberPreferences : RealmObject(),
|
||||
open class MemberPreferences :
|
||||
RealmObject(),
|
||||
AvatarPreferences {
|
||||
|
||||
override var hair: Hair? = null
|
||||
|
|
|
|||
|
|
@ -10,11 +10,11 @@ import com.habitrpg.android.habitica.databinding.FragmentGemPurchaseBinding
|
|||
import com.habitrpg.android.habitica.databinding.FragmentSubscriptionBinding
|
||||
import com.habitrpg.android.habitica.databinding.PurchaseGemViewBinding
|
||||
import com.habitrpg.android.habitica.extensions.DateUtils
|
||||
import com.habitrpg.common.habitica.extensions.isUsingNightModeResources
|
||||
import com.habitrpg.android.habitica.helpers.MainNavigationController
|
||||
import com.habitrpg.android.habitica.ui.fragments.PromoInfoFragment
|
||||
import com.habitrpg.android.habitica.ui.fragments.purchases.SubscriptionFragment
|
||||
import com.habitrpg.android.habitica.ui.views.promo.PromoMenuView
|
||||
import com.habitrpg.common.habitica.extensions.isUsingNightModeResources
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
import java.util.Locale
|
||||
|
|
|
|||
|
|
@ -166,7 +166,7 @@ open class ShopItem : RealmObject(), BaseObject {
|
|||
item.notes = customization.notes
|
||||
item.value = customization.price ?: 0
|
||||
item.path = customization.path
|
||||
item.unlockPath = customization.unlockPath
|
||||
item.unlockPath = customization.unlockPath
|
||||
item.pinType = customization.type
|
||||
if (customization.type == "background") {
|
||||
item.purchaseType = "background"
|
||||
|
|
|
|||
|
|
@ -13,9 +13,9 @@ import io.realm.annotations.PrimaryKey
|
|||
open class Group : RealmObject(), BaseMainObject {
|
||||
|
||||
val isGroupPlan: Boolean
|
||||
get() {
|
||||
return purchased?.isActive == true
|
||||
}
|
||||
get() {
|
||||
return purchased?.isActive == true
|
||||
}
|
||||
override val realmClass: Class<Group>
|
||||
get() = Group::class.java
|
||||
override val primaryIdentifier: String?
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import com.habitrpg.android.habitica.R
|
|||
@io.realm.annotations.RealmClass(embedded = true)
|
||||
open class Days() : io.realm.RealmObject(), Parcelable {
|
||||
val isEveryDay: Boolean
|
||||
get() = m && t && w && th && f && s && su
|
||||
get() = m && t && w && th && f && s && su
|
||||
val isOnlyWeekdays: Boolean
|
||||
get() = m && t && w && th && f && !s && !su
|
||||
val isOnlyWeekends: Boolean
|
||||
|
|
|
|||
|
|
@ -96,7 +96,6 @@ open class Task : RealmObject, BaseMainObject, Parcelable, BaseTask {
|
|||
.equals(ZonedDateTime.now().withZoneSameLocal(ZoneId.systemDefault()).toLocalDate())
|
||||
}
|
||||
|
||||
|
||||
// Needed for offline creating/updating
|
||||
var isSaving: Boolean = false
|
||||
var hasErrored: Boolean = false
|
||||
|
|
@ -307,14 +306,14 @@ open class Task : RealmObject, BaseMainObject, Parcelable, BaseTask {
|
|||
val now = ZonedDateTime.now().withZoneSameLocal(ZoneId.systemDefault())?.toInstant()
|
||||
val nextDate = nextDue?.firstOrNull()
|
||||
|
||||
//If task !isDisplayedActive or if isDisplayedActive but reminder passed,
|
||||
//set a updated reminder with nextDate
|
||||
// If task !isDisplayedActive or if isDisplayedActive but reminder passed,
|
||||
// set a updated reminder with nextDate
|
||||
return if (nextDate != null && (!isDisplayedActive || remindersItem.getLocalZonedDateTimeInstant()?.isBefore(now) == true)) {
|
||||
val nextDueCalendar = GregorianCalendar()
|
||||
nextDueCalendar.time = nextDate
|
||||
parse(oldTime)
|
||||
?.withYear(nextDueCalendar.get(Calendar.YEAR))
|
||||
?.withMonth(nextDueCalendar.get(Calendar.MONTH) + 1) //+1 to handle Gregorian Calendar month range from 0-11
|
||||
?.withMonth(nextDueCalendar.get(Calendar.MONTH) + 1) // +1 to handle Gregorian Calendar month range from 0-11
|
||||
?.withDayOfMonth(nextDueCalendar.get(Calendar.DAY_OF_MONTH))
|
||||
} else {
|
||||
return parse(oldTime)
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import io.realm.annotations.RealmClass
|
|||
import java.util.Date
|
||||
|
||||
@RealmClass(embedded = true)
|
||||
open class GroupAssignedDetails: RealmObject(), BaseObject {
|
||||
open class GroupAssignedDetails : RealmObject(), BaseObject {
|
||||
var assignedDate: Date? = null
|
||||
var assignedUsername: String? = null
|
||||
var assignedUserID: String? = null
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package com.habitrpg.android.habitica.models.user
|
|||
import com.habitrpg.android.habitica.models.BaseObject
|
||||
import io.realm.RealmObject
|
||||
|
||||
open class Permissions: RealmObject(), BaseObject {
|
||||
open class Permissions : RealmObject(), BaseObject {
|
||||
var userSupport: Boolean = false
|
||||
var fullAccess: Boolean = false
|
||||
|
||||
|
|
|
|||
|
|
@ -56,17 +56,17 @@ open class SubscriptionPlan : RealmObject(), BaseObject {
|
|||
*/
|
||||
|
||||
val subMonthCount: Int
|
||||
get() {
|
||||
return when (planId) {
|
||||
"basic_earned" -> 1
|
||||
"basic_3mo" -> 3
|
||||
"basic_6mo" -> 6
|
||||
"google_6mo" -> 6
|
||||
"basic_12mo" -> 12
|
||||
"group_plan_auto" -> 1
|
||||
else -> 0
|
||||
get() {
|
||||
return when (planId) {
|
||||
"basic_earned" -> 1
|
||||
"basic_3mo" -> 3
|
||||
"basic_6mo" -> 6
|
||||
"google_6mo" -> 6
|
||||
"basic_12mo" -> 12
|
||||
"group_plan_auto" -> 1
|
||||
else -> 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val monthsUntilNextHourglass: Int
|
||||
get() {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import io.realm.RealmObject
|
|||
import io.realm.annotations.RealmClass
|
||||
|
||||
@RealmClass(embedded = true)
|
||||
open class UserTaskPreferences: RealmObject(), BaseObject {
|
||||
open class UserTaskPreferences : RealmObject(), BaseObject {
|
||||
var confirmScoreNotes: Boolean = false
|
||||
var mirrorGroupTasks: RealmList<String> = RealmList()
|
||||
var groupByChallenge: Boolean = false
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ import androidx.appcompat.app.AppCompatActivity
|
|||
import androidx.core.content.edit
|
||||
import androidx.preference.PreferenceManager
|
||||
import com.habitrpg.android.habitica.databinding.WidgetConfigureAddTaskBinding
|
||||
import com.habitrpg.shared.habitica.models.tasks.TaskType
|
||||
import com.habitrpg.android.habitica.widget.AddTaskWidgetProvider
|
||||
import com.habitrpg.shared.habitica.models.tasks.TaskType
|
||||
|
||||
class AddTaskWidgetActivity : AppCompatActivity() {
|
||||
|
||||
|
|
|
|||
|
|
@ -214,7 +214,7 @@ class ArmoireActivity : BaseActivity() {
|
|||
}
|
||||
else -> {
|
||||
@SuppressLint("SetTextI18n")
|
||||
binding.titleView.text = "+${value} ${binding.titleView.text}"
|
||||
binding.titleView.text = "+$value ${binding.titleView.text}"
|
||||
binding.subtitleView.text = getString(R.string.armoireExp)
|
||||
binding.iconView.setImageResource(R.drawable.armoire_experience)
|
||||
val layoutParams = RelativeLayout.LayoutParams(108.dpToPx(this), 122.dpToPx(this))
|
||||
|
|
|
|||
|
|
@ -4,10 +4,8 @@ import android.content.Context
|
|||
import android.content.Intent
|
||||
import android.content.SharedPreferences
|
||||
import android.content.res.Configuration
|
||||
import android.content.res.Resources
|
||||
import android.graphics.Bitmap
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.provider.MediaStore
|
||||
import android.view.LayoutInflater
|
||||
|
|
@ -40,7 +38,6 @@ import com.habitrpg.common.habitica.extensions.isUsingNightModeResources
|
|||
import com.habitrpg.common.habitica.helpers.LanguageHelper
|
||||
import kotlinx.coroutines.launch
|
||||
import java.util.Date
|
||||
import java.util.Locale
|
||||
import javax.inject.Inject
|
||||
|
||||
abstract class BaseActivity : AppCompatActivity() {
|
||||
|
|
@ -96,12 +93,12 @@ abstract class BaseActivity : AppCompatActivity() {
|
|||
}
|
||||
lifecycleScope.launchCatching {
|
||||
notificationsManager.displayNotificationEvents.collect {
|
||||
if (ShowNotificationInteractor(this@BaseActivity, lifecycleScope).handleNotification(it)) {
|
||||
lifecycleScope.launch(ExceptionHandler.coroutine()) {
|
||||
userRepository.retrieveUser(false, true)
|
||||
}
|
||||
if (ShowNotificationInteractor(this@BaseActivity, lifecycleScope).handleNotification(it)) {
|
||||
lifecycleScope.launch(ExceptionHandler.coroutine()) {
|
||||
userRepository.retrieveUser(false, true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -198,7 +198,8 @@ class BirthdayActivity : BaseActivity() {
|
|||
@Composable
|
||||
fun BirthdayTitle(text: String) {
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically, modifier = Modifier
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(top = 20.dp, bottom = 8.dp)
|
||||
) {
|
||||
|
|
@ -259,7 +260,8 @@ fun BirthdayActivityView(
|
|||
scaffoldState = scaffoldState
|
||||
) { padding ->
|
||||
Column(
|
||||
horizontalAlignment = Alignment.CenterHorizontally, modifier = Modifier
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
modifier = Modifier
|
||||
.background(
|
||||
Brush.verticalGradient(
|
||||
Pair(0.0f, colorResource(id = R.color.brand_300)),
|
||||
|
|
@ -291,7 +293,8 @@ fun BirthdayActivityView(
|
|||
)
|
||||
}
|
||||
Column(
|
||||
horizontalAlignment = Alignment.CenterHorizontally, modifier = Modifier
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
modifier = Modifier
|
||||
.padding(horizontal = 20.dp)
|
||||
.fillMaxWidth()
|
||||
) {
|
||||
|
|
@ -388,16 +391,19 @@ fun BirthdayActivityView(
|
|||
} else if (isPurchasing) {
|
||||
CircularProgressIndicator()
|
||||
} else {
|
||||
Text(buildAnnotatedString {
|
||||
append("Buy for ")
|
||||
withStyle(SpanStyle(fontWeight = FontWeight.Bold)) {
|
||||
append(price)
|
||||
}
|
||||
append(" or ")
|
||||
withStyle(SpanStyle(fontWeight = FontWeight.Bold)) {
|
||||
append("60 Gems")
|
||||
}
|
||||
}, color = Color.White)
|
||||
Text(
|
||||
buildAnnotatedString {
|
||||
append("Buy for ")
|
||||
withStyle(SpanStyle(fontWeight = FontWeight.Bold)) {
|
||||
append(price)
|
||||
}
|
||||
append(" or ")
|
||||
withStyle(SpanStyle(fontWeight = FontWeight.Bold)) {
|
||||
append("60 Gems")
|
||||
}
|
||||
},
|
||||
color = Color.White
|
||||
)
|
||||
HabiticaButton(
|
||||
Color.White,
|
||||
colorResource(R.color.brand_200),
|
||||
|
|
@ -557,7 +563,8 @@ fun PotionGrid() {
|
|||
AsyncImage(
|
||||
model = DataBindingUtils.BASE_IMAGE_URL + DataBindingUtils.getFullFilename(
|
||||
"Pet_HatchingPotion_$potion"
|
||||
), null, Modifier.size(68.dp)
|
||||
),
|
||||
null, Modifier.size(68.dp)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -616,11 +623,14 @@ fun HabiticaButton(
|
|||
modifier: Modifier = Modifier,
|
||||
content: @Composable () -> Unit
|
||||
) {
|
||||
Box(contentAlignment = Alignment.Center, modifier = modifier
|
||||
.background(background, HabiticaTheme.shapes.medium)
|
||||
.clickable { onClick() }
|
||||
.fillMaxWidth()
|
||||
.padding(8.dp)) {
|
||||
Box(
|
||||
contentAlignment = Alignment.Center,
|
||||
modifier = modifier
|
||||
.background(background, HabiticaTheme.shapes.medium)
|
||||
.clickable { onClick() }
|
||||
.fillMaxWidth()
|
||||
.padding(8.dp)
|
||||
) {
|
||||
ProvideTextStyle(
|
||||
value = TextStyle(
|
||||
fontSize = 18.sp,
|
||||
|
|
|
|||
|
|
@ -396,15 +396,15 @@ class ChallengeFormActivity : BaseActivity() {
|
|||
}
|
||||
|
||||
binding.createChallengeTaskList.addOnItemTouchListener(object :
|
||||
androidx.recyclerview.widget.RecyclerView.SimpleOnItemTouchListener() {
|
||||
override fun onInterceptTouchEvent(
|
||||
rv: androidx.recyclerview.widget.RecyclerView,
|
||||
e: MotionEvent
|
||||
): Boolean {
|
||||
// Stop only scrolling.
|
||||
return rv.scrollState == androidx.recyclerview.widget.RecyclerView.SCROLL_STATE_DRAGGING
|
||||
}
|
||||
})
|
||||
androidx.recyclerview.widget.RecyclerView.SimpleOnItemTouchListener() {
|
||||
override fun onInterceptTouchEvent(
|
||||
rv: androidx.recyclerview.widget.RecyclerView,
|
||||
e: MotionEvent
|
||||
): Boolean {
|
||||
// Stop only scrolling.
|
||||
return rv.scrollState == androidx.recyclerview.widget.RecyclerView.SCROLL_STATE_DRAGGING
|
||||
}
|
||||
})
|
||||
binding.createChallengeTaskList.adapter = challengeTasks
|
||||
binding.createChallengeTaskList.layoutManager =
|
||||
androidx.recyclerview.widget.LinearLayoutManager(this)
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import com.plattysoft.leonids.ParticleSystem
|
|||
import kotlinx.coroutines.launch
|
||||
import javax.inject.Inject
|
||||
|
||||
class DeathActivity: BaseActivity() {
|
||||
class DeathActivity : BaseActivity() {
|
||||
private lateinit var binding: ActivityDeathBinding
|
||||
|
||||
@Inject
|
||||
|
|
@ -109,9 +109,8 @@ class DeathActivity: BaseActivity() {
|
|||
.setScaleRange(0.5f, 0.8f)
|
||||
.setSpeedRange(0.01f, 0.03f)
|
||||
.setFadeOut(4000, AccelerateInterpolator())
|
||||
.setSpeedModuleAndAngleRange(0.01f, 0.03f, startAngle, startAngle+80)
|
||||
.emit(binding.root.width / 2, positionArray[1] + (binding.heartView.height/2), 3, 6000)
|
||||
|
||||
.setSpeedModuleAndAngleRange(0.01f, 0.03f, startAngle, startAngle + 80)
|
||||
.emit(binding.root.width / 2, positionArray[1] + (binding.heartView.height / 2), 3, 6000)
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
|
|
|
|||
|
|
@ -13,9 +13,8 @@ import com.habitrpg.android.habitica.databinding.ActivityFixcharacterBinding
|
|||
import com.habitrpg.android.habitica.extensions.setTintWith
|
||||
import com.habitrpg.android.habitica.models.user.Stats
|
||||
import com.habitrpg.android.habitica.models.user.User
|
||||
import com.habitrpg.android.habitica.ui.views.HabiticaIconsHelper
|
||||
import com.habitrpg.android.habitica.ui.viewmodels.MainUserViewModel
|
||||
|
||||
import com.habitrpg.android.habitica.ui.views.HabiticaIconsHelper
|
||||
import javax.inject.Inject
|
||||
|
||||
class FixCharacterValuesActivity : BaseActivity() {
|
||||
|
|
|
|||
|
|
@ -147,11 +147,11 @@ class FullProfileActivity : BaseActivity() {
|
|||
}
|
||||
|
||||
private suspend fun refresh() {
|
||||
val member = socialRepository.retrieveMember(userID)
|
||||
if (member != null) {
|
||||
updateView(member)
|
||||
}
|
||||
this@FullProfileActivity.member.value = member
|
||||
val member = socialRepository.retrieveMember(userID)
|
||||
if (member != null) {
|
||||
updateView(member)
|
||||
}
|
||||
this@FullProfileActivity.member.value = member
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
|
|
@ -174,21 +174,27 @@ class FullProfileActivity : BaseActivity() {
|
|||
}
|
||||
menu.setGroupVisible(R.id.admin_items, isModerator)
|
||||
if (isModerator) {
|
||||
menu.findItem(R.id.ban_user)?.title = getString(if (member.value?.authentication?.blocked == true) {
|
||||
R.string.unban_user
|
||||
} else {
|
||||
R.string.ban_user
|
||||
})
|
||||
menu.findItem(R.id.shadow_mute_user)?.title = getString(if (member.value?.flags?.chatShadowMuted == true) {
|
||||
R.string.unshadowmute_user
|
||||
} else {
|
||||
R.string.shadow_mute_user
|
||||
})
|
||||
menu.findItem(R.id.mute_user)?.title = getString(if (member.value?.flags?.chatRevoked == true) {
|
||||
R.string.unmute_user
|
||||
} else {
|
||||
R.string.mute_user
|
||||
})
|
||||
menu.findItem(R.id.ban_user)?.title = getString(
|
||||
if (member.value?.authentication?.blocked == true) {
|
||||
R.string.unban_user
|
||||
} else {
|
||||
R.string.ban_user
|
||||
}
|
||||
)
|
||||
menu.findItem(R.id.shadow_mute_user)?.title = getString(
|
||||
if (member.value?.flags?.chatShadowMuted == true) {
|
||||
R.string.unshadowmute_user
|
||||
} else {
|
||||
R.string.shadow_mute_user
|
||||
}
|
||||
)
|
||||
menu.findItem(R.id.mute_user)?.title = getString(
|
||||
if (member.value?.flags?.chatRevoked == true) {
|
||||
R.string.unmute_user
|
||||
} else {
|
||||
R.string.mute_user
|
||||
}
|
||||
)
|
||||
}
|
||||
return super.onCreateOptionsMenu(menu)
|
||||
}
|
||||
|
|
@ -357,7 +363,7 @@ class FullProfileActivity : BaseActivity() {
|
|||
if (imageUrl == null || imageUrl.isEmpty()) {
|
||||
binding.profileImage.visibility = View.GONE
|
||||
} else {
|
||||
//binding.profileImage.load(imageUrl)
|
||||
// binding.profileImage.load(imageUrl)
|
||||
}
|
||||
|
||||
val blurbText = profile.blurb
|
||||
|
|
|
|||
|
|
@ -81,10 +81,12 @@ class LoginActivity : BaseActivity() {
|
|||
showValidationError(R.string.login_validation_error_fieldsmissing)
|
||||
return
|
||||
}
|
||||
lifecycleScope.launch(ExceptionHandler.coroutine {
|
||||
hideProgress()
|
||||
ExceptionHandler.reportError(it)
|
||||
}) {
|
||||
lifecycleScope.launch(
|
||||
ExceptionHandler.coroutine {
|
||||
hideProgress()
|
||||
ExceptionHandler.reportError(it)
|
||||
}
|
||||
) {
|
||||
val response = apiClient.connectUser(username, password)
|
||||
if (response != null) {
|
||||
handleAuthResponse(response)
|
||||
|
|
@ -112,10 +114,12 @@ class LoginActivity : BaseActivity() {
|
|||
)
|
||||
return
|
||||
}
|
||||
lifecycleScope.launch(ExceptionHandler.coroutine {
|
||||
hideProgress()
|
||||
ExceptionHandler.reportError(it)
|
||||
}) {
|
||||
lifecycleScope.launch(
|
||||
ExceptionHandler.coroutine {
|
||||
hideProgress()
|
||||
ExceptionHandler.reportError(it)
|
||||
}
|
||||
) {
|
||||
val response = apiClient.registerUser(username, email, password, confirmPassword)
|
||||
if (response != null) {
|
||||
handleAuthResponse(response)
|
||||
|
|
|
|||
|
|
@ -96,9 +96,11 @@ class ReportMessageActivity : BaseActivity() {
|
|||
}
|
||||
isReporting = true
|
||||
messageID?.let {
|
||||
lifecycleScope.launch(ExceptionHandler.coroutine {
|
||||
isReporting = false
|
||||
}) {
|
||||
lifecycleScope.launch(
|
||||
ExceptionHandler.coroutine {
|
||||
isReporting = false
|
||||
}
|
||||
) {
|
||||
socialRepository.flagMessage(messageID ?: "", binding.additionalInfoEdittext.text.toString(), groupID)
|
||||
finish()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -206,7 +206,6 @@ class SetupActivity : BaseActivity(), ViewPager.OnPageChangeListener {
|
|||
|
||||
override fun onPageScrollStateChanged(state: Int) = Unit
|
||||
|
||||
|
||||
private var hasCompleted = false
|
||||
private fun onUserReceived(user: User?) {
|
||||
if (completedSetup && !hasCompleted) {
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ class SkillTasksActivity : BaseActivity() {
|
|||
else -> TaskType.TODO
|
||||
}
|
||||
fragment.onTaskSelection = {
|
||||
taskSelected(it)
|
||||
taskSelected(it)
|
||||
}
|
||||
viewFragmentsDictionary.put(position, fragment)
|
||||
return fragment
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ class TaskFormActivity : BaseActivity() {
|
|||
if (granted) {
|
||||
pushNotificationManager.addPushDeviceUsingStoredToken()
|
||||
} else {
|
||||
//If user denies notification settings originally - they must manually enable it through notification settings.
|
||||
// If user denies notification settings originally - they must manually enable it through notification settings.
|
||||
val alert = HabiticaAlertDialog(this)
|
||||
alert.setTitle(R.string.push_notification_system_settings_title)
|
||||
alert.setMessage(R.string.push_notification_system_settings_description)
|
||||
|
|
@ -340,7 +340,8 @@ class TaskFormActivity : BaseActivity() {
|
|||
HabiticaTheme {
|
||||
TaskDifficultySelector(
|
||||
viewModel.taskDifficulty.value,
|
||||
onSelect = { viewModel.taskDifficulty.value = it })
|
||||
onSelect = { viewModel.taskDifficulty.value = it }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -351,32 +352,38 @@ class TaskFormActivity : BaseActivity() {
|
|||
viewModel.habitScoringPositive.value,
|
||||
viewModel.habitScoringNegative.value,
|
||||
{ viewModel.habitScoringPositive.value = !viewModel.habitScoringPositive.value },
|
||||
{ viewModel.habitScoringNegative.value = !viewModel.habitScoringNegative.value })
|
||||
{ viewModel.habitScoringNegative.value = !viewModel.habitScoringNegative.value }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
binding.habitResetStreakButtons.setContent {
|
||||
HabiticaTheme {
|
||||
TaskFormSelector(
|
||||
viewModel.habitResetOption.value, listOf(
|
||||
viewModel.habitResetOption.value,
|
||||
listOf(
|
||||
LabeledValue(getString(R.string.repeat_daily), HabitResetOption.DAILY),
|
||||
LabeledValue(getString(R.string.weekly), HabitResetOption.WEEKLY),
|
||||
LabeledValue(getString(R.string.monthly), HabitResetOption.MONTHLY)
|
||||
), { viewModel.habitResetOption.value = it }, columnSize = 3
|
||||
),
|
||||
{ viewModel.habitResetOption.value = it }, columnSize = 3
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
binding.statsSelector.setContent {
|
||||
HabiticaTheme {
|
||||
TaskFormSelector(viewModel.selectedAttribute.value, listOf(
|
||||
LabeledValue(getString(R.string.strength), Attribute.STRENGTH),
|
||||
LabeledValue(getString(R.string.constitution), Attribute.CONSTITUTION),
|
||||
LabeledValue(getString(R.string.intelligence), Attribute.INTELLIGENCE),
|
||||
LabeledValue(getString(R.string.perception), Attribute.PERCEPTION)
|
||||
), { viewModel.selectedAttribute.value = it })
|
||||
TaskFormSelector(
|
||||
viewModel.selectedAttribute.value,
|
||||
listOf(
|
||||
LabeledValue(getString(R.string.strength), Attribute.STRENGTH),
|
||||
LabeledValue(getString(R.string.constitution), Attribute.CONSTITUTION),
|
||||
LabeledValue(getString(R.string.intelligence), Attribute.INTELLIGENCE),
|
||||
LabeledValue(getString(R.string.perception), Attribute.PERCEPTION)
|
||||
),
|
||||
{ viewModel.selectedAttribute.value = it }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -240,7 +240,8 @@ fun TaskSummaryView(viewModel: TaskSummaryViewModel) {
|
|||
.fillMaxWidth()
|
||||
) {
|
||||
Image(HabiticaIconsHelper.imageOfGold().asImageBitmap(), null)
|
||||
Text("${task?.value}",
|
||||
Text(
|
||||
"${task?.value}",
|
||||
fontSize = 16.sp,
|
||||
fontWeight = FontWeight.Medium,
|
||||
color = darkestColor
|
||||
|
|
@ -285,7 +286,8 @@ fun TaskSummaryView(viewModel: TaskSummaryViewModel) {
|
|||
for (item in task?.group?.assignedUsersDetail ?: emptyList()) {
|
||||
val member = viewModel.getMember(item.assignedUserID).collectAsState(null)
|
||||
UserRow(
|
||||
item.assignedUsername ?: "", member.value, Modifier
|
||||
item.assignedUsername ?: "", member.value,
|
||||
Modifier
|
||||
.padding(vertical = 4.dp)
|
||||
.background(
|
||||
HabiticaTheme.colors.windowBackgroundFor(task),
|
||||
|
|
@ -295,9 +297,11 @@ fun TaskSummaryView(viewModel: TaskSummaryViewModel) {
|
|||
.heightIn(min = 24.dp)
|
||||
.fillMaxWidth(),
|
||||
color = darkestColor,
|
||||
extraContent = if (item.completed) ({
|
||||
CompletedAt(item.completedDate)
|
||||
}) else null
|
||||
extraContent = if (item.completed) (
|
||||
{
|
||||
CompletedAt(item.completedDate)
|
||||
}
|
||||
) else null
|
||||
)
|
||||
}
|
||||
task?.group?.assignedUsersDetail?.find { it.assignedUserID == viewModel.userViewModel.userID }
|
||||
|
|
|
|||
|
|
@ -11,9 +11,9 @@ import com.habitrpg.android.habitica.databinding.AchievementSectionHeaderBinding
|
|||
import com.habitrpg.android.habitica.extensions.inflate
|
||||
import com.habitrpg.android.habitica.models.Achievement
|
||||
import com.habitrpg.android.habitica.models.QuestAchievement
|
||||
import com.habitrpg.android.habitica.ui.views.dialogs.AchievementDetailDialog
|
||||
import com.habitrpg.common.habitica.extensions.loadImage
|
||||
import com.habitrpg.common.habitica.views.PixelArtView
|
||||
import com.habitrpg.android.habitica.ui.views.dialogs.AchievementDetailDialog
|
||||
|
||||
class AchievementsAdapter : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
|
||||
|
||||
|
|
|
|||
|
|
@ -25,9 +25,9 @@ class CustomizationEquipmentRecyclerViewAdapter : androidx.recyclerview.widget.R
|
|||
var equipmentList: MutableList<Equipment> =
|
||||
ArrayList()
|
||||
set(value) {
|
||||
field = value
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
field = value
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
var activeEquipment: String? = null
|
||||
set(value) {
|
||||
field = value
|
||||
|
|
@ -119,7 +119,8 @@ class CustomizationEquipmentRecyclerViewAdapter : androidx.recyclerview.widget.R
|
|||
priceLabel?.text = itemValue.toString()
|
||||
|
||||
(dialogContent.findViewById<View>(R.id.gem_icon) as? ImageView)?.setImageBitmap(
|
||||
HabiticaIconsHelper.imageOfGem())
|
||||
HabiticaIconsHelper.imageOfGem()
|
||||
)
|
||||
|
||||
val dialog = HabiticaAlertDialog(itemView.context)
|
||||
dialog.addButton(R.string.purchase_button, true) { _, _ ->
|
||||
|
|
|
|||
|
|
@ -113,9 +113,15 @@ class CustomizationRecyclerViewAdapter() : androidx.recyclerview.widget.Recycler
|
|||
val isOwned = ownedCustomizations.contains(customization.id)
|
||||
val isUsable = customization.isUsable(isOwned)
|
||||
if (customization.availableFrom != null || customization.availableUntil != null) {
|
||||
if (((customization.availableFrom?.compareTo(today)
|
||||
?: 0) > 0 || (customization.availableUntil?.compareTo(today)
|
||||
?: 0) < 0) && !isUsable
|
||||
if ((
|
||||
(
|
||||
customization.availableFrom?.compareTo(today)
|
||||
?: 0
|
||||
) > 0 || (
|
||||
customization.availableUntil?.compareTo(today)
|
||||
?: 0
|
||||
) < 0
|
||||
) && !isUsable
|
||||
) {
|
||||
continue
|
||||
}
|
||||
|
|
@ -218,7 +224,7 @@ class CustomizationRecyclerViewAdapter() : androidx.recyclerview.widget.Recycler
|
|||
return
|
||||
}
|
||||
|
||||
if (customization?.type == "background"){
|
||||
if (customization?.type == "background") {
|
||||
val alert = HabiticaAlertDialog(context = itemView.context)
|
||||
val purchasedCustomizationView: View = LayoutInflater.from(itemView.context).inflate(R.layout.purchased_equip_dialog, null)
|
||||
val layerMap = EnumMap<AvatarView.LayerType, String>(AvatarView.LayerType::class.java)
|
||||
|
|
@ -263,12 +269,12 @@ class CustomizationRecyclerViewAdapter() : androidx.recyclerview.widget.Recycler
|
|||
var additionalSetItems: List<Customization>? = null
|
||||
|
||||
var buttonWidth: Int
|
||||
get() = binding.purchaseSetButton.width
|
||||
set(value) {
|
||||
val params = binding.purchaseSetButton.layoutParams
|
||||
params.width = value
|
||||
binding.purchaseSetButton.layoutParams = params
|
||||
}
|
||||
get() = binding.purchaseSetButton.width
|
||||
set(value) {
|
||||
val params = binding.purchaseSetButton.layoutParams
|
||||
params.width = value
|
||||
binding.purchaseSetButton.layoutParams = params
|
||||
}
|
||||
|
||||
init {
|
||||
binding.purchaseSetButton.setOnClickListener(this)
|
||||
|
|
|
|||
|
|
@ -111,7 +111,6 @@ class NavigationDrawerAdapter(tintColor: Int, backgroundTintColor: Int) : Recycl
|
|||
|
||||
private fun getItem(position: Int) = items.filter { it.isVisible }[position]
|
||||
|
||||
|
||||
override fun getItemCount(): Int = items.count { it.isVisible }
|
||||
|
||||
override fun getItemViewType(position: Int): Int {
|
||||
|
|
|
|||
|
|
@ -99,11 +99,11 @@ class ItemRecyclerAdapter(val context: Context) : BaseRecyclerViewAdapter<OwnedI
|
|||
binding.ownedTextView.text = ownedItem.numberOwned.toString()
|
||||
|
||||
val disabled = if (isHatching) {
|
||||
!this.canHatch
|
||||
} else false
|
||||
!this.canHatch
|
||||
} else false
|
||||
val imageName = if (item != null) {
|
||||
getImageName(item = item) }
|
||||
else {
|
||||
getImageName(item = item)
|
||||
} else {
|
||||
getImageName(ownedItem = ownedItem)
|
||||
}
|
||||
binding.imageView.loadImage(imageName)
|
||||
|
|
@ -130,7 +130,7 @@ class ItemRecyclerAdapter(val context: Context) : BaseRecyclerViewAdapter<OwnedI
|
|||
"inventory_quest_scroll_" + item.key
|
||||
}
|
||||
is SpecialItem -> {
|
||||
//Mystery Item (Inventory Present)
|
||||
// Mystery Item (Inventory Present)
|
||||
val sdf = SimpleDateFormat("MM", Locale.getDefault())
|
||||
val month = sdf.format(Date())
|
||||
"inventory_present_$month"
|
||||
|
|
@ -153,8 +153,8 @@ class ItemRecyclerAdapter(val context: Context) : BaseRecyclerViewAdapter<OwnedI
|
|||
val menu = BottomSheetMenu(context)
|
||||
menu.setTitle(item?.text)
|
||||
val imageName = if (item != null) {
|
||||
getImageName(item = item) }
|
||||
else {
|
||||
getImageName(item = item)
|
||||
} else {
|
||||
getImageName(ownedItem = ownedItem)
|
||||
}
|
||||
menu.setImage(imageName)
|
||||
|
|
|
|||
|
|
@ -43,14 +43,13 @@ class StableRecyclerAdapter : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
|
|||
field = value
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
var onEquip: ((String) -> Unit)? = null
|
||||
var onEquip: ((String) -> Unit)? = null
|
||||
private var existingMounts: List<Mount>? = null
|
||||
private var ownedMounts: Map<String, OwnedMount>? = null
|
||||
private var ownedItems: Map<String, OwnedItem>? = null
|
||||
private var ownsSaddles: Boolean = false
|
||||
private var itemList: List<Any> = ArrayList()
|
||||
|
||||
|
||||
private fun canRaiseToMount(pet: Pet): Boolean {
|
||||
if (pet.type == "special") return false
|
||||
for (mount in existingMounts ?: emptyList()) {
|
||||
|
|
|
|||
|
|
@ -8,9 +8,9 @@ import com.habitrpg.android.habitica.databinding.ProfileAchievementItemBinding
|
|||
import com.habitrpg.android.habitica.extensions.inflate
|
||||
import com.habitrpg.android.habitica.models.Achievement
|
||||
import com.habitrpg.android.habitica.ui.activities.MainActivity
|
||||
import com.habitrpg.common.habitica.extensions.loadImage
|
||||
import com.habitrpg.android.habitica.ui.viewHolders.SectionViewHolder
|
||||
import com.habitrpg.android.habitica.ui.views.dialogs.AchievementDetailDialog
|
||||
import com.habitrpg.common.habitica.extensions.loadImage
|
||||
|
||||
class AchievementProfileAdapter : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ import com.habitrpg.android.habitica.ui.adapter.BaseRecyclerViewAdapter
|
|||
import com.habitrpg.android.habitica.ui.fragments.social.challenges.ChallengeFilterOptions
|
||||
import com.habitrpg.android.habitica.ui.views.HabiticaIconsHelper
|
||||
import com.habitrpg.common.habitica.helpers.EmojiParser
|
||||
|
||||
import io.realm.OrderedRealmCollection
|
||||
|
||||
class ChallengesListViewAdapter(
|
||||
|
|
|
|||
|
|
@ -13,12 +13,13 @@ class DailiesRecyclerViewHolder(layoutResource: Int, viewModel: TasksViewModel)
|
|||
getContentView(parent), { task, direction -> taskScoreEvents?.invoke(task, direction) },
|
||||
{ task, item -> checklistItemScoreEvents?.invoke(task, item) },
|
||||
{
|
||||
task ->
|
||||
task ->
|
||||
taskOpenEvents?.invoke(task.first, task.second)
|
||||
}, {
|
||||
task ->
|
||||
task ->
|
||||
brokenTaskEvents?.invoke(task)
|
||||
}, viewModel)
|
||||
}, viewModel
|
||||
)
|
||||
} else {
|
||||
super.onCreateViewHolder(parent, viewType)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,12 +12,13 @@ class HabitsRecyclerViewAdapter(layoutResource: Int, viewModel: TasksViewModel)
|
|||
HabitViewHolder(
|
||||
getContentView(parent), { task, direction -> taskScoreEvents?.invoke(task, direction) },
|
||||
{
|
||||
task ->
|
||||
task ->
|
||||
taskOpenEvents?.invoke(task.first, task.second)
|
||||
}, {
|
||||
task ->
|
||||
brokenTaskEvents?.invoke(task)
|
||||
}, viewModel)
|
||||
task ->
|
||||
brokenTaskEvents?.invoke(task)
|
||||
}, viewModel
|
||||
)
|
||||
} else {
|
||||
super.onCreateViewHolder(parent, viewType)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,9 +73,10 @@ class RewardsRecyclerViewAdapter(
|
|||
}
|
||||
},
|
||||
{ task -> taskOpenEvents?.invoke(task.first, task.second) }, {
|
||||
task ->
|
||||
brokenTaskEvents?.invoke(task)
|
||||
}, viewModel)
|
||||
task ->
|
||||
brokenTaskEvents?.invoke(task)
|
||||
}, viewModel
|
||||
)
|
||||
} else {
|
||||
val viewHolder = ShopItemViewHolder(LayoutInflater.from(parent.context).inflate(R.layout.row_shopitem, parent, false))
|
||||
viewHolder.purchaseCardAction = { purchaseCardEvents?.invoke(it) }
|
||||
|
|
|
|||
|
|
@ -13,12 +13,13 @@ class TodosRecyclerViewAdapter(layoutResource: Int, viewModel: TasksViewModel) :
|
|||
getContentView(parent), { task, direction -> taskScoreEvents?.invoke(task, direction) },
|
||||
{ task, item -> checklistItemScoreEvents?.invoke(task, item) },
|
||||
{
|
||||
task ->
|
||||
task ->
|
||||
taskOpenEvents?.invoke(task.first, task.second)
|
||||
}, {
|
||||
task ->
|
||||
brokenTaskEvents?.invoke(task)
|
||||
}, viewModel)
|
||||
task ->
|
||||
brokenTaskEvents?.invoke(task)
|
||||
}, viewModel
|
||||
)
|
||||
} else {
|
||||
super.onCreateViewHolder(parent, viewType)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -97,9 +97,11 @@ class AchievementsFragment : BaseMainFragment<FragmentRefreshRecyclerviewBinding
|
|||
lifecycleScope.launch(ExceptionHandler.coroutine()) {
|
||||
userRepository.getAchievements().combine(userRepository.getQuestAchievements()) { achievements, questAchievements ->
|
||||
return@combine Pair(achievements, questAchievements)
|
||||
}.combine(userRepository.getQuestAchievements()
|
||||
.map { it.mapNotNull { achievement -> achievement.questKey } }
|
||||
.map { inventoryRepository.getQuestContent(it).firstOrNull() }) { achievements, content ->
|
||||
}.combine(
|
||||
userRepository.getQuestAchievements()
|
||||
.map { it.mapNotNull { achievement -> achievement.questKey } }
|
||||
.map { inventoryRepository.getQuestContent(it).firstOrNull() }
|
||||
) { achievements, content ->
|
||||
Pair(achievements, content)
|
||||
}.collect {
|
||||
val achievements = it.first.first
|
||||
|
|
|
|||
|
|
@ -141,14 +141,14 @@ class NavigationDrawerFragment : DialogFragment() {
|
|||
initializeMenuItems()
|
||||
|
||||
adapter.itemSelectedEvents = {
|
||||
setSelection(it.transitionId, it.bundle, true)
|
||||
}
|
||||
setSelection(it.transitionId, it.bundle, true)
|
||||
}
|
||||
adapter.promoClosedSubject = {
|
||||
sharedPreferences.edit {
|
||||
putBoolean("hide$it", true)
|
||||
}
|
||||
updatePromo()
|
||||
sharedPreferences.edit {
|
||||
putBoolean("hide$it", true)
|
||||
}
|
||||
updatePromo()
|
||||
}
|
||||
|
||||
lifecycleScope.launchCatching {
|
||||
contentRepository.getWorldState()
|
||||
|
|
@ -285,8 +285,10 @@ class NavigationDrawerFragment : DialogFragment() {
|
|||
if (!user.hasClass && !hasSpecialItems) {
|
||||
item.isVisible = false
|
||||
} else {
|
||||
if ((user.stats?.lvl
|
||||
?: 0) < HabiticaSnackbar.MIN_LEVEL_FOR_SKILLS && (!hasSpecialItems)
|
||||
if ((
|
||||
user.stats?.lvl
|
||||
?: 0
|
||||
) < HabiticaSnackbar.MIN_LEVEL_FOR_SKILLS && (!hasSpecialItems)
|
||||
) {
|
||||
item.pillText = getString(R.string.unlock_lvl_11)
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ class NewsFragment : BaseMainFragment<FragmentNewsBinding>() {
|
|||
if (url?.contains("/static/new-stuff") == true) {
|
||||
view?.loadUrl(url)
|
||||
} else if (url != null) {
|
||||
MainNavigationController.navigate(url)
|
||||
MainNavigationController.navigate(url)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,22 +80,22 @@ class AvatarCustomizationFragment :
|
|||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
showsBackButton = true
|
||||
adapter.onCustomizationSelected = { customization ->
|
||||
lifecycleScope.launchCatching {
|
||||
if (customization.identifier?.isNotBlank() != true) {
|
||||
userRepository.useCustomization(customization.type ?: "", customization.category, activeCustomization ?: "")
|
||||
} else if (customization.type == "background" && ownedCustomizations.value.firstOrNull { it.key == customization.identifier } == null) {
|
||||
userRepository.unlockPath(customization)
|
||||
userRepository.retrieveUser(false, true, true)
|
||||
} else {
|
||||
userRepository.useCustomization(
|
||||
customization.type ?: "",
|
||||
customization.category,
|
||||
customization.identifier ?: ""
|
||||
)
|
||||
}
|
||||
adapter.onCustomizationSelected = { customization ->
|
||||
lifecycleScope.launchCatching {
|
||||
if (customization.identifier?.isNotBlank() != true) {
|
||||
userRepository.useCustomization(customization.type ?: "", customization.category, activeCustomization ?: "")
|
||||
} else if (customization.type == "background" && ownedCustomizations.value.firstOrNull { it.key == customization.identifier } == null) {
|
||||
userRepository.unlockPath(customization)
|
||||
userRepository.retrieveUser(false, true, true)
|
||||
} else {
|
||||
userRepository.useCustomization(
|
||||
customization.type ?: "",
|
||||
customization.category,
|
||||
customization.identifier ?: ""
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lifecycleScope.launchCatching {
|
||||
inventoryRepository.getInAppRewards()
|
||||
|
|
@ -195,31 +195,31 @@ class AvatarCustomizationFragment :
|
|||
.combine(currentFilter) { customizations, filter -> Pair(customizations, filter) }
|
||||
.combine(ownedCustomizations) { pair, ownedCustomizations -> Triple(pair.first, pair.second, ownedCustomizations) }
|
||||
.collect { (customizations, filter, ownedCustomizations) ->
|
||||
adapter.ownedCustomizations =
|
||||
ownedCustomizations.map { it.key + "_" + it.type + "_" + it.category }
|
||||
if (filter.isFiltering) {
|
||||
val displayedCustomizations = mutableListOf<Customization>()
|
||||
for (customization in customizations) {
|
||||
if (shouldSkip(filter, ownedCustomizations, customization)) continue
|
||||
displayedCustomizations.add(customization)
|
||||
}
|
||||
adapter.setCustomizations(
|
||||
if (!filter.ascending) {
|
||||
displayedCustomizations.reversed()
|
||||
} else {
|
||||
displayedCustomizations
|
||||
}
|
||||
)
|
||||
} else {
|
||||
adapter.setCustomizations(
|
||||
if (!filter.ascending) {
|
||||
customizations.reversed()
|
||||
} else {
|
||||
customizations
|
||||
}
|
||||
)
|
||||
adapter.ownedCustomizations =
|
||||
ownedCustomizations.map { it.key + "_" + it.type + "_" + it.category }
|
||||
if (filter.isFiltering) {
|
||||
val displayedCustomizations = mutableListOf<Customization>()
|
||||
for (customization in customizations) {
|
||||
if (shouldSkip(filter, ownedCustomizations, customization)) continue
|
||||
displayedCustomizations.add(customization)
|
||||
}
|
||||
adapter.setCustomizations(
|
||||
if (!filter.ascending) {
|
||||
displayedCustomizations.reversed()
|
||||
} else {
|
||||
displayedCustomizations
|
||||
}
|
||||
)
|
||||
} else {
|
||||
adapter.setCustomizations(
|
||||
if (!filter.ascending) {
|
||||
customizations.reversed()
|
||||
} else {
|
||||
customizations
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (type == "hair" && (category == "beard" || category == "mustache")) {
|
||||
val otherCategory = if (category == "mustache") "beard" else "mustache"
|
||||
|
|
|
|||
|
|
@ -39,7 +39,8 @@ import com.habitrpg.android.habitica.ui.views.equipment.EquipmentOverviewView
|
|||
import kotlinx.coroutines.flow.firstOrNull
|
||||
import javax.inject.Inject
|
||||
|
||||
open class AvatarOverviewFragment : BaseMainFragment<FragmentComposeScrollingBinding>(),
|
||||
open class AvatarOverviewFragment :
|
||||
BaseMainFragment<FragmentComposeScrollingBinding>(),
|
||||
AdapterView.OnItemSelectedListener {
|
||||
|
||||
@Inject
|
||||
|
|
@ -71,16 +72,18 @@ open class AvatarOverviewFragment : BaseMainFragment<FragmentComposeScrollingBin
|
|||
setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed)
|
||||
setContent {
|
||||
HabiticaTheme {
|
||||
AvatarOverviewView(userViewModel,
|
||||
AvatarOverviewView(
|
||||
userViewModel,
|
||||
showCustomization, !showCustomization,
|
||||
battleGearWeapon.value?.twoHanded == true, costumeWeapon.value?.twoHanded == true,
|
||||
{ type, category ->
|
||||
displayCustomizationFragment(type, category)
|
||||
}, { type, category ->
|
||||
displayAvatarEquipmentFragment(type, category)
|
||||
}, { type, equipped, isCostume ->
|
||||
displayCustomizationFragment(type, category)
|
||||
}, { type, category ->
|
||||
displayAvatarEquipmentFragment(type, category)
|
||||
}, { type, equipped, isCostume ->
|
||||
displayEquipmentFragment(type, equipped, isCostume)
|
||||
})
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -137,7 +140,8 @@ open class AvatarOverviewFragment : BaseMainFragment<FragmentComposeScrollingBin
|
|||
}
|
||||
|
||||
@Composable
|
||||
fun AvatarOverviewView(userViewModel: MainUserViewModel,
|
||||
fun AvatarOverviewView(
|
||||
userViewModel: MainUserViewModel,
|
||||
showCustomization: Boolean = true,
|
||||
showEquipment: Boolean = true,
|
||||
battleGearTwoHanded: Boolean = false,
|
||||
|
|
@ -145,12 +149,13 @@ fun AvatarOverviewView(userViewModel: MainUserViewModel,
|
|||
onCustomizationTap: (String, String?) -> Unit,
|
||||
onAvatarEquipmentTap: (String, String?) -> Unit,
|
||||
onEquipmentTap: (String, String?, Boolean) -> Unit
|
||||
) {
|
||||
) {
|
||||
val user by userViewModel.user.observeAsState()
|
||||
Column(
|
||||
Modifier
|
||||
.padding(horizontal = 8.dp)
|
||||
.padding(bottom = 16.dp)) {
|
||||
.padding(bottom = 16.dp)
|
||||
) {
|
||||
if (showCustomization) {
|
||||
Row(
|
||||
Modifier.padding(horizontal = 12.dp, vertical = 15.dp),
|
||||
|
|
@ -162,18 +167,21 @@ fun AvatarOverviewView(userViewModel: MainUserViewModel,
|
|||
color = HabiticaTheme.colors.textSecondary
|
||||
)
|
||||
Spacer(modifier = Modifier.weight(1f))
|
||||
SegmentedControl(items = listOf(
|
||||
stringResource(R.string.avatar_size_slim), stringResource(
|
||||
R.string.avatar_size_broad
|
||||
)
|
||||
),
|
||||
SegmentedControl(
|
||||
items = listOf(
|
||||
stringResource(R.string.avatar_size_slim),
|
||||
stringResource(
|
||||
R.string.avatar_size_broad
|
||||
)
|
||||
),
|
||||
defaultSelectedItemIndex = if (user?.preferences?.size == "slim") 0 else 1,
|
||||
onItemSelection = {
|
||||
userViewModel.updateUser(
|
||||
"preferences.size",
|
||||
if (it == 0) "slim" else "broad"
|
||||
)
|
||||
})
|
||||
}
|
||||
)
|
||||
}
|
||||
AvatarCustomizationOverviewView(user?.preferences, user?.items?.gear?.equipped, onCustomizationTap, onAvatarEquipmentTap)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -269,37 +269,36 @@ class ItemDialogFragment : BaseDialogFragment<FragmentItemsDialogBinding>() {
|
|||
else -> Egg::class.java
|
||||
}
|
||||
itemType?.let { type ->
|
||||
lifecycleScope.launch(ExceptionHandler.coroutine()) {
|
||||
inventoryRepository.getOwnedItems(type)
|
||||
.onEach { items ->
|
||||
val filteredItems = if (isFeeding) {
|
||||
items.filter { it.key != "Saddle" }
|
||||
} else {
|
||||
items
|
||||
}
|
||||
adapter?.data = filteredItems
|
||||
lifecycleScope.launch(ExceptionHandler.coroutine()) {
|
||||
inventoryRepository.getOwnedItems(type)
|
||||
.onEach { items ->
|
||||
val filteredItems = if (isFeeding) {
|
||||
items.filter { it.key != "Saddle" }
|
||||
} else {
|
||||
items
|
||||
}
|
||||
.map { items -> items.mapNotNull { it.key } }
|
||||
.map { inventoryRepository.getItems(itemClass, it.toTypedArray()).firstOrNull() }
|
||||
.collect {
|
||||
val itemMap = mutableMapOf<String, Item>()
|
||||
for (item in it ?: emptyList()) {
|
||||
itemMap[item.key] = item
|
||||
}
|
||||
adapter?.items = itemMap
|
||||
adapter?.data = filteredItems
|
||||
}
|
||||
.map { items -> items.mapNotNull { it.key } }
|
||||
.map { inventoryRepository.getItems(itemClass, it.toTypedArray()).firstOrNull() }
|
||||
.collect {
|
||||
val itemMap = mutableMapOf<String, Item>()
|
||||
for (item in it ?: emptyList()) {
|
||||
itemMap[item.key] = item
|
||||
}
|
||||
|
||||
}
|
||||
lifecycleScope.launch(ExceptionHandler.coroutine()) {
|
||||
inventoryRepository.getPets().collect { adapter?.setExistingPets(it) }
|
||||
}
|
||||
lifecycleScope.launch(ExceptionHandler.coroutine()) {
|
||||
inventoryRepository.getOwnedPets().map { ownedPets ->
|
||||
val petMap = mutableMapOf<String, OwnedPet>()
|
||||
ownedPets.forEach { petMap[it.key ?: ""] = it }
|
||||
return@map petMap
|
||||
}.collect { adapter?.setOwnedPets(it) }
|
||||
}
|
||||
adapter?.items = itemMap
|
||||
}
|
||||
}
|
||||
lifecycleScope.launch(ExceptionHandler.coroutine()) {
|
||||
inventoryRepository.getPets().collect { adapter?.setExistingPets(it) }
|
||||
}
|
||||
lifecycleScope.launch(ExceptionHandler.coroutine()) {
|
||||
inventoryRepository.getOwnedPets().map { ownedPets ->
|
||||
val petMap = mutableMapOf<String, OwnedPet>()
|
||||
ownedPets.forEach { petMap[it.key ?: ""] = it }
|
||||
return@map petMap
|
||||
}.collect { adapter?.setOwnedPets(it) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -225,7 +225,7 @@ class ItemRecyclerFragment : BaseFragment<FragmentItemsBinding>(), SwipeRefreshL
|
|||
alert?.setMessage(R.string.quest_party_required_description)
|
||||
alert?.addButton(R.string.create_new_party, true, false) { _, _ ->
|
||||
lifecycleScope.launch(ExceptionHandler.coroutine()) {
|
||||
val group = socialRepository.createGroup(
|
||||
socialRepository.createGroup(
|
||||
getString(R.string.usernames_party, user?.profile?.name),
|
||||
"",
|
||||
user?.id,
|
||||
|
|
|
|||
|
|
@ -276,7 +276,7 @@ open class ShopFragment : BaseMainFragment<FragmentRefreshRecyclerviewBinding>()
|
|||
lifecycleScope.launchCatching {
|
||||
val shop = inventoryRepository.retrieveMarketGear()
|
||||
inventoryRepository.getOwnedEquipment()
|
||||
.map { equipment -> equipment.map { it.key } }
|
||||
.map { equipment -> equipment.map { it.key } }
|
||||
.collect { equipment ->
|
||||
for (category in shop?.categories ?: emptyList()) {
|
||||
val items = category.items.asSequence().filter {
|
||||
|
|
|
|||
|
|
@ -138,7 +138,7 @@ class MountDetailRecyclerFragment :
|
|||
if (animalType != null || animalGroup != null) {
|
||||
lifecycleScope.launch(ExceptionHandler.coroutine()) {
|
||||
val mounts = inventoryRepository.getMounts(animalType, animalGroup, animalColor).firstOrNull() ?: emptyList()
|
||||
inventoryRepository.getOwnedMounts().map { ownedMounts ->
|
||||
inventoryRepository.getOwnedMounts().map { ownedMounts ->
|
||||
val mountMap = mutableMapOf<String, OwnedMount>()
|
||||
ownedMounts.forEach { mountMap[it.key ?: ""] = it }
|
||||
return@map mountMap
|
||||
|
|
|
|||
|
|
@ -218,7 +218,6 @@ class PetDetailRecyclerFragment :
|
|||
}
|
||||
adapter.setItemList(items)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -172,8 +172,6 @@ class StableRecyclerFragment :
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
companion object {
|
||||
private const val ITEM_TYPE_KEY = "CLASS_TYPE_KEY"
|
||||
private const val HEADER_VIEW_TYPE = 0
|
||||
|
|
|
|||
|
|
@ -24,8 +24,6 @@ import com.habitrpg.android.habitica.R
|
|||
import com.habitrpg.android.habitica.data.ApiClient
|
||||
import com.habitrpg.android.habitica.extensions.addCancelButton
|
||||
import com.habitrpg.android.habitica.extensions.addCloseButton
|
||||
import com.habitrpg.common.habitica.extensions.dpToPx
|
||||
import com.habitrpg.common.habitica.extensions.layoutInflater
|
||||
import com.habitrpg.android.habitica.helpers.ExceptionHandler
|
||||
import com.habitrpg.android.habitica.helpers.MainNavigationController
|
||||
import com.habitrpg.android.habitica.helpers.launchCatching
|
||||
|
|
@ -41,6 +39,8 @@ import com.habitrpg.android.habitica.ui.views.ValidatingEditText
|
|||
import com.habitrpg.android.habitica.ui.views.dialogs.HabiticaAlertDialog
|
||||
import com.habitrpg.android.habitica.ui.views.dialogs.HabiticaProgressDialog
|
||||
import com.habitrpg.common.habitica.api.HostConfig
|
||||
import com.habitrpg.common.habitica.extensions.dpToPx
|
||||
import com.habitrpg.common.habitica.extensions.layoutInflater
|
||||
import kotlinx.coroutines.launch
|
||||
import retrofit2.HttpException
|
||||
import javax.inject.Inject
|
||||
|
|
@ -48,7 +48,7 @@ import javax.inject.Inject
|
|||
class AccountPreferenceFragment :
|
||||
BasePreferencesFragment(),
|
||||
SharedPreferences.OnSharedPreferenceChangeListener,
|
||||
AccountUpdateConfirmed {
|
||||
AccountUpdateConfirmed {
|
||||
@Inject
|
||||
lateinit var hostConfig: HostConfig
|
||||
@Inject
|
||||
|
|
@ -334,7 +334,7 @@ class AccountPreferenceFragment :
|
|||
user?.username ?: "",
|
||||
email ?: "",
|
||||
passwordEditText.text ?: "",
|
||||
passwordRepeatEditText?.text ?: ""
|
||||
passwordRepeatEditText.text ?: ""
|
||||
)
|
||||
(activity as? SnackbarActivity)?.showSnackbar(
|
||||
content = context.getString(R.string.password_added),
|
||||
|
|
@ -454,10 +454,10 @@ class AccountPreferenceFragment :
|
|||
ExceptionHandler.reportError(throwable)
|
||||
}) {
|
||||
userRepository.deleteAccount(password)
|
||||
dialog?.dismiss()
|
||||
accountDialog.dismiss()
|
||||
context?.let { HabiticaBaseApplication.logout(it) }
|
||||
activity?.finish()
|
||||
dialog?.dismiss()
|
||||
accountDialog.dismiss()
|
||||
context?.let { HabiticaBaseApplication.logout(it) }
|
||||
activity?.finish()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -471,7 +471,6 @@ class AccountPreferenceFragment :
|
|||
if (habiticaAccountDialog != null) {
|
||||
accountDialog = habiticaAccountDialog
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun showConfirmUsernameDialog() {
|
||||
|
|
@ -519,5 +518,4 @@ class AccountPreferenceFragment :
|
|||
override fun deletionConfirmClicked(confirmationString: String) {
|
||||
deleteAccount(confirmationString)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ import com.habitrpg.android.habitica.R
|
|||
import com.habitrpg.android.habitica.databinding.DialogHabiticaAccountBinding
|
||||
import com.habitrpg.android.habitica.models.user.User
|
||||
|
||||
|
||||
class HabiticaAccountDialog(private var thisContext: Context) : DialogFragment(R.layout.dialog_habitica_account) {
|
||||
private var _binding: DialogHabiticaAccountBinding? = null
|
||||
private val binding get() = _binding!!
|
||||
|
|
@ -46,7 +45,7 @@ class HabiticaAccountDialog(private var thisContext: Context) : DialogFragment(R
|
|||
"delete_account" -> setDeleteAccountViews()
|
||||
}
|
||||
|
||||
binding.backImagebutton.setOnClickListener{dismiss()}
|
||||
binding.backImagebutton.setOnClickListener { dismiss() }
|
||||
}
|
||||
|
||||
private fun setResetAccountViews() {
|
||||
|
|
@ -103,7 +102,8 @@ class HabiticaAccountDialog(private var thisContext: Context) : DialogFragment(R
|
|||
override fun onTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {
|
||||
if (binding.confirmationInputEdittext.text.toString().isNotEmpty()) {
|
||||
if ((user?.authentication?.hasPassword != true && binding.confirmationInputEdittext.text.toString() == context?.getString(R.string.delete_caps)) ||
|
||||
user?.authentication?.hasPassword == true) {
|
||||
user?.authentication?.hasPassword == true
|
||||
) {
|
||||
binding.confirmActionTextview.setTextColor(ContextCompat.getColor(thisContext, R.color.red_100))
|
||||
binding.confirmActionTextview.alpha = 1.0f
|
||||
}
|
||||
|
|
@ -127,7 +127,6 @@ class HabiticaAccountDialog(private var thisContext: Context) : DialogFragment(R
|
|||
accountUpdateConfirmed?.deletionConfirmClicked(confirmationString)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -135,10 +134,8 @@ class HabiticaAccountDialog(private var thisContext: Context) : DialogFragment(R
|
|||
return R.style.HabiticaAccountDialogTheme
|
||||
}
|
||||
|
||||
|
||||
interface AccountUpdateConfirmed {
|
||||
fun resetConfirmedClicked()
|
||||
fun deletionConfirmClicked(confirmationString: String)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,16 +9,23 @@ import android.provider.Settings
|
|||
import android.view.View
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.preference.*
|
||||
import androidx.preference.CheckBoxPreference
|
||||
import androidx.preference.ListPreference
|
||||
import androidx.preference.Preference
|
||||
import androidx.preference.PreferenceCategory
|
||||
import androidx.preference.PreferenceScreen
|
||||
import com.habitrpg.android.habitica.BuildConfig
|
||||
import com.habitrpg.android.habitica.HabiticaBaseApplication
|
||||
import com.habitrpg.android.habitica.R
|
||||
import com.habitrpg.android.habitica.data.ApiClient
|
||||
import com.habitrpg.android.habitica.data.ContentRepository
|
||||
import com.habitrpg.android.habitica.extensions.addCancelButton
|
||||
import com.habitrpg.android.habitica.helpers.*
|
||||
import com.habitrpg.android.habitica.helpers.AppConfigManager
|
||||
import com.habitrpg.android.habitica.helpers.ExceptionHandler
|
||||
import com.habitrpg.android.habitica.helpers.SoundManager
|
||||
import com.habitrpg.android.habitica.helpers.TaskAlarmManager
|
||||
import com.habitrpg.android.habitica.helpers.launchCatching
|
||||
import com.habitrpg.android.habitica.helpers.notifications.PushNotificationManager
|
||||
import com.habitrpg.android.habitica.models.user.User
|
||||
import com.habitrpg.android.habitica.prefs.TimePreference
|
||||
|
|
@ -33,7 +40,7 @@ import com.habitrpg.common.habitica.helpers.AppTestingLevel
|
|||
import com.habitrpg.common.habitica.helpers.LanguageHelper
|
||||
import kotlinx.coroutines.flow.firstOrNull
|
||||
import kotlinx.coroutines.launch
|
||||
import java.util.*
|
||||
import java.util.Locale
|
||||
import javax.inject.Inject
|
||||
|
||||
class PreferencesFragment : BasePreferencesFragment(), SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
|
|
@ -195,7 +202,7 @@ class PreferencesFragment : BasePreferencesFragment(), SharedPreferences.OnShare
|
|||
usePushPreference?.isChecked = true
|
||||
pushNotificationManager.addPushDeviceUsingStoredToken()
|
||||
} else {
|
||||
//If user denies notification settings originally - they must manually enable it through notification settings.
|
||||
// If user denies notification settings originally - they must manually enable it through notification settings.
|
||||
val alert = context?.let { HabiticaAlertDialog(it) }
|
||||
alert?.setTitle(R.string.push_notification_system_settings_title)
|
||||
alert?.setMessage(R.string.push_notification_system_settings_description)
|
||||
|
|
@ -335,10 +342,10 @@ class PreferencesFragment : BasePreferencesFragment(), SharedPreferences.OnShare
|
|||
|
||||
override fun onDisplayPreferenceDialog(preference: Preference) {
|
||||
if (preference is TimePreference) {
|
||||
if (parentFragmentManager.findFragmentByTag(TimePreferenceDialogFragment.TAG) == null) {
|
||||
TimePreferenceDialogFragment.newInstance(this, preference.getKey())
|
||||
.show(parentFragmentManager, TimePreferenceDialogFragment.TAG)
|
||||
}
|
||||
if (parentFragmentManager.findFragmentByTag(TimePreferenceDialogFragment.TAG) == null) {
|
||||
TimePreferenceDialogFragment.newInstance(this, preference.getKey())
|
||||
.show(parentFragmentManager, TimePreferenceDialogFragment.TAG)
|
||||
}
|
||||
} else {
|
||||
super.onDisplayPreferenceDialog(preference)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -103,8 +103,11 @@ class GemsPurchaseFragment : BaseFragment<FragmentGemPurchaseBinding>() {
|
|||
if (birthdayEventEnd != null) {
|
||||
binding?.promoComposeView?.setContent {
|
||||
HabiticaTheme {
|
||||
BirthdayBanner(endDate = birthdayEventEnd, Modifier.padding(horizontal = 20.dp).clip(HabiticaTheme.shapes.medium)
|
||||
.padding(bottom = 20.dp))
|
||||
BirthdayBanner(
|
||||
endDate = birthdayEventEnd,
|
||||
Modifier.padding(horizontal = 20.dp).clip(HabiticaTheme.shapes.medium)
|
||||
.padding(bottom = 20.dp)
|
||||
)
|
||||
}
|
||||
}
|
||||
binding?.promoComposeView?.isVisible = true
|
||||
|
|
|
|||
|
|
@ -104,8 +104,11 @@ class SubscriptionFragment : BaseFragment<FragmentSubscriptionBinding>() {
|
|||
if (birthdayEventEnd != null) {
|
||||
binding?.promoComposeView?.setContent {
|
||||
HabiticaTheme {
|
||||
BirthdayBanner(endDate = birthdayEventEnd, Modifier.padding(horizontal = 20.dp).clip(HabiticaTheme.shapes.medium)
|
||||
.padding(bottom = 10.dp))
|
||||
BirthdayBanner(
|
||||
endDate = birthdayEventEnd,
|
||||
Modifier.padding(horizontal = 20.dp).clip(HabiticaTheme.shapes.medium)
|
||||
.padding(bottom = 10.dp)
|
||||
)
|
||||
}
|
||||
}
|
||||
binding?.promoComposeView?.isVisible = true
|
||||
|
|
@ -115,16 +118,16 @@ class SubscriptionFragment : BaseFragment<FragmentSubscriptionBinding>() {
|
|||
|
||||
lifecycleScope.launchCatching {
|
||||
inventoryRepository.getLatestMysteryItem().collect {
|
||||
binding?.subBenefitsMysteryItemIcon?.loadImage(
|
||||
"shop_set_mystery_${
|
||||
it.key?.split(
|
||||
"_"
|
||||
)?.last()
|
||||
}"
|
||||
)
|
||||
binding?.subBenefitsMysteryItemText?.text =
|
||||
context?.getString(R.string.subscribe_listitem3_description_new, it.text)
|
||||
}
|
||||
binding?.subBenefitsMysteryItemIcon?.loadImage(
|
||||
"shop_set_mystery_${
|
||||
it.key?.split(
|
||||
"_"
|
||||
)?.last()
|
||||
}"
|
||||
)
|
||||
binding?.subBenefitsMysteryItemText?.text =
|
||||
context?.getString(R.string.subscribe_listitem3_description_new, it.text)
|
||||
}
|
||||
}
|
||||
|
||||
AmplitudeManager.sendNavigationEvent("subscription screen")
|
||||
|
|
|
|||
|
|
@ -10,14 +10,14 @@ import com.habitrpg.android.habitica.R
|
|||
import com.habitrpg.android.habitica.components.UserComponent
|
||||
import com.habitrpg.android.habitica.databinding.FragmentSetupTasksBinding
|
||||
import com.habitrpg.android.habitica.models.tasks.Days
|
||||
import com.habitrpg.shared.habitica.models.tasks.Frequency
|
||||
import com.habitrpg.android.habitica.models.tasks.Task
|
||||
import com.habitrpg.shared.habitica.models.tasks.TaskType
|
||||
import com.habitrpg.android.habitica.models.user.User
|
||||
import com.habitrpg.android.habitica.ui.activities.SetupActivity
|
||||
import com.habitrpg.android.habitica.ui.adapter.setup.TaskSetupAdapter
|
||||
import com.habitrpg.android.habitica.ui.fragments.BaseFragment
|
||||
import com.habitrpg.android.habitica.ui.views.HabiticaIconsHelper
|
||||
import com.habitrpg.shared.habitica.models.tasks.Frequency
|
||||
import com.habitrpg.shared.habitica.models.tasks.TaskType
|
||||
import java.util.Date
|
||||
|
||||
class TaskSetupFragment : BaseFragment<FragmentSetupTasksBinding>() {
|
||||
|
|
|
|||
|
|
@ -103,9 +103,9 @@ class InboxMessageListFragment : BaseMainFragment<FragmentInboxMessageListBindin
|
|||
binding?.recyclerView?.adapter = chatAdapter
|
||||
binding?.recyclerView?.itemAnimator = SafeDefaultItemAnimator()
|
||||
chatAdapter?.let { adapter ->
|
||||
adapter.onOpenProfile = {
|
||||
FullProfileActivity.open(it)
|
||||
}
|
||||
adapter.onOpenProfile = {
|
||||
FullProfileActivity.open(it)
|
||||
}
|
||||
adapter.onDeleteMessage = { showDeleteConfirmationDialog(it) }
|
||||
adapter.onFlagMessage = { showFlagConfirmationDialog(it) }
|
||||
adapter.onCopyMessage = { copyMessageToClipboard(it) }
|
||||
|
|
@ -117,7 +117,6 @@ class InboxMessageListFragment : BaseMainFragment<FragmentInboxMessageListBindin
|
|||
chatAdapter?.submitList(it)
|
||||
}
|
||||
|
||||
|
||||
binding?.chatBarView?.sendAction = { sendMessage(it) }
|
||||
binding?.chatBarView?.maxChatLength = configManager.maxChatLength()
|
||||
|
||||
|
|
@ -183,17 +182,19 @@ class InboxMessageListFragment : BaseMainFragment<FragmentInboxMessageListBindin
|
|||
|
||||
private fun sendMessage(chatText: String) {
|
||||
viewModel.memberID?.let { userID ->
|
||||
lifecycleScope.launch(ExceptionHandler.coroutine { error ->
|
||||
ExceptionHandler.reportError(error)
|
||||
binding?.let {
|
||||
val alert = HabiticaAlertDialog(it.chatBarView.context)
|
||||
alert.setTitle("You cannot reply to this conversation")
|
||||
alert.setMessage("This user is unable to receive your private message")
|
||||
alert.addOkButton()
|
||||
alert.show()
|
||||
lifecycleScope.launch(
|
||||
ExceptionHandler.coroutine { error ->
|
||||
ExceptionHandler.reportError(error)
|
||||
binding?.let {
|
||||
val alert = HabiticaAlertDialog(it.chatBarView.context)
|
||||
alert.setTitle("You cannot reply to this conversation")
|
||||
alert.setMessage("This user is unable to receive your private message")
|
||||
alert.addOkButton()
|
||||
alert.show()
|
||||
}
|
||||
binding?.chatBarView?.message = chatText
|
||||
}
|
||||
binding?.chatBarView?.message = chatText
|
||||
}) {
|
||||
) {
|
||||
socialRepository.postPrivateMessage(userID, chatText)
|
||||
delay(200.toDuration(DurationUnit.MILLISECONDS))
|
||||
viewModel.invalidateDataSource()
|
||||
|
|
@ -227,7 +228,7 @@ class InboxMessageListFragment : BaseMainFragment<FragmentInboxMessageListBindin
|
|||
if (context != null) {
|
||||
val dialog = HabiticaAlertDialog(context)
|
||||
dialog.setTitle(R.string.confirm_delete_tag_title)
|
||||
dialog.setMessage(R.string.confirm_delete_tag_message)
|
||||
dialog.setMessage(R.string.confirm_delete_tag_message)
|
||||
dialog.addButton(R.string.yes, true, true) { _, _ ->
|
||||
lifecycleScope.launchCatching {
|
||||
socialRepository.deleteMessage(chatMessage)
|
||||
|
|
|
|||
|
|
@ -74,8 +74,8 @@ class InboxOverviewFragment : BaseMainFragment<FragmentInboxBinding>(), androidx
|
|||
private fun loadMessages() {
|
||||
lifecycleScope.launch(ExceptionHandler.coroutine()) {
|
||||
socialRepository.getInboxConversations().collect {
|
||||
setInboxMessages(it)
|
||||
}
|
||||
setInboxMessages(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -109,39 +109,39 @@ class ChallengeDetailFragment : BaseMainFragment<FragmentChallengeDetailBinding>
|
|||
}
|
||||
lifecycleScope.launchCatching {
|
||||
challengeRepository.getChallengeTasks(id).collect { taskList ->
|
||||
binding?.taskGroupLayout?.removeAllViewsInLayout()
|
||||
binding?.taskGroupLayout?.removeAllViewsInLayout()
|
||||
|
||||
val todos = ArrayList<Task>()
|
||||
val habits = ArrayList<Task>()
|
||||
val dailies = ArrayList<Task>()
|
||||
val rewards = ArrayList<Task>()
|
||||
val todos = ArrayList<Task>()
|
||||
val habits = ArrayList<Task>()
|
||||
val dailies = ArrayList<Task>()
|
||||
val rewards = ArrayList<Task>()
|
||||
|
||||
for (entry in taskList) {
|
||||
val type = entry.type ?: continue
|
||||
when (type) {
|
||||
TaskType.TODO -> todos.add(entry)
|
||||
TaskType.HABIT -> habits.add(entry)
|
||||
TaskType.DAILY -> dailies.add(entry)
|
||||
TaskType.REWARD -> rewards.add(entry)
|
||||
}
|
||||
}
|
||||
|
||||
if (habits.size > 0) {
|
||||
addHabits(habits)
|
||||
}
|
||||
|
||||
if (dailies.size > 0) {
|
||||
addDailys(dailies)
|
||||
}
|
||||
|
||||
if (todos.size > 0) {
|
||||
addTodos(todos)
|
||||
}
|
||||
|
||||
if (rewards.size > 0) {
|
||||
addRewards(rewards)
|
||||
for (entry in taskList) {
|
||||
val type = entry.type ?: continue
|
||||
when (type) {
|
||||
TaskType.TODO -> todos.add(entry)
|
||||
TaskType.HABIT -> habits.add(entry)
|
||||
TaskType.DAILY -> dailies.add(entry)
|
||||
TaskType.REWARD -> rewards.add(entry)
|
||||
}
|
||||
}
|
||||
|
||||
if (habits.size > 0) {
|
||||
addHabits(habits)
|
||||
}
|
||||
|
||||
if (dailies.size > 0) {
|
||||
addDailys(dailies)
|
||||
}
|
||||
|
||||
if (todos.size > 0) {
|
||||
addTodos(todos)
|
||||
}
|
||||
|
||||
if (rewards.size > 0) {
|
||||
addRewards(rewards)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lifecycleScope.launchCatching {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,8 @@ package com.habitrpg.android.habitica.ui.fragments.social.challenges
|
|||
|
||||
import com.habitrpg.android.habitica.models.social.Group
|
||||
|
||||
data class ChallengeFilterOptions(var showByGroups: List<Group>,
|
||||
data class ChallengeFilterOptions(
|
||||
var showByGroups: List<Group>,
|
||||
var showOwned: Boolean = false,
|
||||
var notOwned: Boolean = false
|
||||
)
|
||||
|
|
@ -27,7 +27,8 @@ import kotlinx.coroutines.launch
|
|||
import javax.inject.Inject
|
||||
import javax.inject.Named
|
||||
|
||||
class ChallengeListFragment : BaseFragment<FragmentRefreshRecyclerviewBinding>(),
|
||||
class ChallengeListFragment :
|
||||
BaseFragment<FragmentRefreshRecyclerviewBinding>(),
|
||||
androidx.swiperefreshlayout.widget.SwipeRefreshLayout.OnRefreshListener {
|
||||
|
||||
@Inject
|
||||
|
|
@ -96,10 +97,10 @@ class ChallengeListFragment : BaseFragment<FragmentRefreshRecyclerviewBinding>()
|
|||
.combine(socialRepository.getUserGroups("guild")) { tavern, guilds ->
|
||||
return@combine Pair(tavern, guilds)
|
||||
}.collect {
|
||||
this@ChallengeListFragment.filterGroups = mutableListOf()
|
||||
it.first?.let { tavern -> filterGroups?.add(tavern) }
|
||||
filterGroups?.addAll(it.second)
|
||||
}
|
||||
this@ChallengeListFragment.filterGroups = mutableListOf()
|
||||
it.first?.let { tavern -> filterGroups?.add(tavern) }
|
||||
filterGroups?.addAll(it.second)
|
||||
}
|
||||
}
|
||||
|
||||
binding?.recyclerView?.itemAnimator = SafeDefaultItemAnimator()
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ class GuildFragment : BaseMainFragment<FragmentViewpagerBinding>() {
|
|||
return true
|
||||
}
|
||||
R.id.menu_guild_refresh -> {
|
||||
viewModel.retrieveGroupChat { }
|
||||
viewModel.retrieveGroupChat { }
|
||||
viewModel.retrieveGroup { }
|
||||
return true
|
||||
}
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue