mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-04-14 11:46:32 +00:00
formatting fixes
This commit is contained in:
parent
c112c4d416
commit
d91be2d7fe
526 changed files with 11518 additions and 11538 deletions
|
|
@ -106,7 +106,7 @@ open class HabiticaTestCase : TestCase() {
|
|||
|
||||
internal fun <T> loadJsonFile(
|
||||
s: String,
|
||||
type: Type,
|
||||
type: Type
|
||||
): T {
|
||||
val userStream = javaClass.classLoader?.getResourceAsStream("$s.json")
|
||||
return gson.fromJson(gson.newJsonReader(InputStreamReader(userStream)), type)
|
||||
|
|
@ -138,7 +138,7 @@ open class HabiticaTestCase : TestCase() {
|
|||
private fun <P, C> assign(
|
||||
it: KCallable<*>,
|
||||
obj: C,
|
||||
value: P,
|
||||
value: P
|
||||
) {
|
||||
if ((it as KMutableProperty1<C, P>).javaField!!.get(obj) == null) {
|
||||
it.set(obj, value)
|
||||
|
|
|
|||
|
|
@ -296,7 +296,7 @@ class TaskFormActivityTest : ActivityTestCase() {
|
|||
}
|
||||
KSpinner(
|
||||
builder = { withId(R.id.repeats_every_spinner) },
|
||||
itemTypeBuilder = { itemType(::KSpinnerItem) },
|
||||
itemTypeBuilder = { itemType(::KSpinnerItem) }
|
||||
) perform {
|
||||
open()
|
||||
childAt<KSpinnerItem>(1) {
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import io.github.kakaocup.kakao.screen.Screen
|
|||
import org.junit.Before
|
||||
|
||||
abstract class FragmentTestCase<F : Fragment, VB : ViewBinding, S : Screen<S>>(
|
||||
val shouldLaunchFragment: Boolean = true,
|
||||
val shouldLaunchFragment: Boolean = true
|
||||
) : HabiticaTestCase() {
|
||||
lateinit var scenario: FragmentScenario<F>
|
||||
lateinit var fragment: F
|
||||
|
|
|
|||
|
|
@ -27,9 +27,9 @@ class NavigationDrawerScreen : Screen<NavigationDrawerScreen>() {
|
|||
KRecyclerView({
|
||||
withId(R.id.recyclerView)
|
||||
}, itemTypeBuilder = {
|
||||
itemType(::SectionHeaderItem)
|
||||
itemType(::MainItem)
|
||||
})
|
||||
itemType(::SectionHeaderItem)
|
||||
itemType(::MainItem)
|
||||
})
|
||||
}
|
||||
|
||||
@LargeTest
|
||||
|
|
|
|||
|
|
@ -46,14 +46,14 @@ private val KTextView.text: CharSequence?
|
|||
|
||||
override fun perform(
|
||||
uiController: UiController?,
|
||||
view: View?,
|
||||
view: View?
|
||||
) {
|
||||
val tv = view as TextView
|
||||
string = tv.text
|
||||
}
|
||||
},
|
||||
}
|
||||
)
|
||||
)
|
||||
)
|
||||
return string
|
||||
}
|
||||
|
||||
|
|
@ -67,8 +67,8 @@ class ItemScreen : Screen<ItemScreen>() {
|
|||
KRecyclerView({
|
||||
withId(R.id.recyclerView)
|
||||
}, itemTypeBuilder = {
|
||||
itemType(::ItemItem)
|
||||
})
|
||||
itemType(::ItemItem)
|
||||
})
|
||||
}
|
||||
|
||||
internal class ItemRecyclerFragmentTest : FragmentTestCase<ItemRecyclerFragment, FragmentRecyclerviewBinding, ItemScreen>(false) {
|
||||
|
|
|
|||
|
|
@ -25,9 +25,9 @@ class PetDetailScreen : Screen<PetDetailScreen>() {
|
|||
KRecyclerView({
|
||||
withId(R.id.recyclerView)
|
||||
}, itemTypeBuilder = {
|
||||
itemType(::SectionItem)
|
||||
itemType(::PetItem)
|
||||
})
|
||||
itemType(::SectionItem)
|
||||
itemType(::PetItem)
|
||||
})
|
||||
}
|
||||
|
||||
internal class PetDetailRecyclerFragmentTest :
|
||||
|
|
@ -43,9 +43,9 @@ internal class PetDetailRecyclerFragmentTest :
|
|||
mapOf(
|
||||
Pair(
|
||||
"Saddle-food",
|
||||
saddle,
|
||||
),
|
||||
),
|
||||
saddle
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
fragment = spyk()
|
||||
|
|
@ -69,18 +69,18 @@ internal class PetDetailRecyclerFragmentTest :
|
|||
inventoryRepository.getPets(
|
||||
any(),
|
||||
any(),
|
||||
any(),
|
||||
any()
|
||||
)
|
||||
} returns flowOf(content.pets.filter { it.animal == "Cactus" })
|
||||
every {
|
||||
inventoryRepository.getMounts(
|
||||
any(),
|
||||
any(),
|
||||
any(),
|
||||
any()
|
||||
)
|
||||
} returns flowOf(content.mounts.filter { it.animal == "Cactus" })
|
||||
launchFragment(
|
||||
PetDetailRecyclerFragmentArgs.Builder("cactus", "drop", "").build().toBundle(),
|
||||
PetDetailRecyclerFragmentArgs.Builder("cactus", "drop", "").build().toBundle()
|
||||
)
|
||||
screen {
|
||||
recycler {
|
||||
|
|
@ -102,14 +102,14 @@ internal class PetDetailRecyclerFragmentTest :
|
|||
inventoryRepository.getPets(
|
||||
any(),
|
||||
any(),
|
||||
any(),
|
||||
any()
|
||||
)
|
||||
} returns flowOf(content.pets.filter { it.animal == "Fox" })
|
||||
every {
|
||||
inventoryRepository.getMounts(
|
||||
any(),
|
||||
any(),
|
||||
any(),
|
||||
any()
|
||||
)
|
||||
} returns flowOf(content.mounts.filter { it.animal == "Fox" })
|
||||
launchFragment(PetDetailRecyclerFragmentArgs.Builder("fox", "drop", "").build().toBundle())
|
||||
|
|
|
|||
|
|
@ -34,9 +34,9 @@ class StableScreen : Screen<StableScreen>() {
|
|||
KRecyclerView({
|
||||
withId(R.id.recyclerView)
|
||||
}, itemTypeBuilder = {
|
||||
itemType(::SectionItem)
|
||||
itemType(::PetItem)
|
||||
})
|
||||
itemType(::SectionItem)
|
||||
itemType(::PetItem)
|
||||
})
|
||||
}
|
||||
|
||||
internal class StableRecyclerFragmentTest : FragmentTestCase<StableRecyclerFragment, FragmentRecyclerviewBinding, StableScreen>(false) {
|
||||
|
|
|
|||
|
|
@ -32,8 +32,8 @@ class TaskListScreen : Screen<TaskListScreen>() {
|
|||
KRecyclerView({
|
||||
withId(R.id.recyclerView)
|
||||
}, itemTypeBuilder = {
|
||||
itemType(::TaskItem)
|
||||
})
|
||||
itemType(::TaskItem)
|
||||
})
|
||||
}
|
||||
|
||||
internal class TaskRecyclerViewFragmentTest : FragmentTestCase<TaskRecyclerViewFragment, FragmentRefreshRecyclerviewBinding, TaskListScreen>(false) {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ import android.database.sqlite.SQLiteDatabase
|
|||
import android.os.Build
|
||||
import android.os.Build.VERSION.SDK_INT
|
||||
import android.os.Bundle
|
||||
import android.provider.Settings
|
||||
import android.util.Log
|
||||
import androidx.appcompat.app.AppCompatDelegate
|
||||
import androidx.core.content.edit
|
||||
|
|
@ -39,7 +38,6 @@ import com.habitrpg.android.habitica.modules.AuthenticationHandler
|
|||
import com.habitrpg.android.habitica.ui.activities.BaseActivity
|
||||
import com.habitrpg.android.habitica.ui.activities.LoginActivity
|
||||
import com.habitrpg.android.habitica.ui.views.HabiticaIconsHelper
|
||||
import com.habitrpg.common.habitica.extensions.DataBindingUtils
|
||||
import com.habitrpg.common.habitica.extensions.setupCoil
|
||||
import com.habitrpg.common.habitica.helpers.ExceptionHandler
|
||||
import com.habitrpg.common.habitica.helpers.LanguageHelper
|
||||
|
|
@ -161,8 +159,8 @@ abstract class HabiticaBaseApplication : Application(), Application.ActivityLife
|
|||
val configuration: Configuration = resources.configuration
|
||||
val languageHelper = LanguageHelper(sharedPrefs.getString("language", "en"))
|
||||
if (if (SDK_INT >= Build.VERSION_CODES.N) {
|
||||
configuration.locales.isEmpty || configuration.locales[0] != languageHelper.locale
|
||||
} else {
|
||||
configuration.locales.isEmpty || configuration.locales[0] != languageHelper.locale
|
||||
} else {
|
||||
@Suppress("DEPRECATION")
|
||||
configuration.locale != languageHelper.locale
|
||||
}
|
||||
|
|
@ -216,7 +214,7 @@ abstract class HabiticaBaseApplication : Application(), Application.ActivityLife
|
|||
override fun openOrCreateDatabase(
|
||||
name: String,
|
||||
mode: Int,
|
||||
factory: SQLiteDatabase.CursorFactory?,
|
||||
factory: SQLiteDatabase.CursorFactory?
|
||||
): SQLiteDatabase {
|
||||
return super.openOrCreateDatabase(getDatabasePath(name).absolutePath, mode, factory)
|
||||
}
|
||||
|
|
@ -225,13 +223,13 @@ abstract class HabiticaBaseApplication : Application(), Application.ActivityLife
|
|||
name: String,
|
||||
mode: Int,
|
||||
factory: SQLiteDatabase.CursorFactory?,
|
||||
errorHandler: DatabaseErrorHandler?,
|
||||
errorHandler: DatabaseErrorHandler?
|
||||
): SQLiteDatabase {
|
||||
return super.openOrCreateDatabase(
|
||||
getDatabasePath(name).absolutePath,
|
||||
mode,
|
||||
factory,
|
||||
errorHandler,
|
||||
errorHandler
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -299,7 +297,7 @@ abstract class HabiticaBaseApplication : Application(), Application.ActivityLife
|
|||
|
||||
override fun onActivityCreated(
|
||||
p0: Activity,
|
||||
p1: Bundle?,
|
||||
p1: Bundle?
|
||||
) {
|
||||
}
|
||||
|
||||
|
|
@ -308,7 +306,7 @@ abstract class HabiticaBaseApplication : Application(), Application.ActivityLife
|
|||
|
||||
override fun onActivitySaveInstanceState(
|
||||
p0: Activity,
|
||||
p1: Bundle,
|
||||
p1: Bundle
|
||||
) {
|
||||
}
|
||||
|
||||
|
|
@ -350,7 +348,7 @@ abstract class HabiticaBaseApplication : Application(), Application.ActivityLife
|
|||
|
||||
private fun startActivity(
|
||||
activityClass: Class<*>,
|
||||
context: Context,
|
||||
context: Context
|
||||
) {
|
||||
val intent = Intent(context, activityClass)
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ interface ApiService {
|
|||
@GET("inbox/messages")
|
||||
suspend fun getInboxMessages(
|
||||
@Query("conversation") uuid: String,
|
||||
@Query("page") page: Int,
|
||||
@Query("page") page: Int
|
||||
): HabitResponse<List<ChatMessage>>
|
||||
|
||||
@GET("inbox/conversations")
|
||||
|
|
@ -77,17 +77,17 @@ interface ApiService {
|
|||
|
||||
@GET("content")
|
||||
suspend fun getContent(
|
||||
@Query("language") language: String?,
|
||||
@Query("language") language: String?
|
||||
): HabitResponse<ContentResult>
|
||||
|
||||
@PUT("user/")
|
||||
suspend fun updateUser(
|
||||
@Body updateDictionary: Map<String, Any?>,
|
||||
@Body updateDictionary: Map<String, Any?>
|
||||
): HabitResponse<User>
|
||||
|
||||
@PUT("user/")
|
||||
suspend fun registrationLanguage(
|
||||
@Header("Accept-Language") registrationLanguage: String,
|
||||
@Header("Accept-Language") registrationLanguage: String
|
||||
): HabitResponse<User>
|
||||
|
||||
@GET("user/in-app-rewards")
|
||||
|
|
@ -96,171 +96,171 @@ interface ApiService {
|
|||
@POST("user/equip/{type}/{key}")
|
||||
suspend fun equipItem(
|
||||
@Path("type") type: String,
|
||||
@Path("key") itemKey: String,
|
||||
@Path("key") itemKey: String
|
||||
): HabitResponse<Items>
|
||||
|
||||
@POST("user/buy/{key}")
|
||||
suspend fun buyItem(
|
||||
@Path("key") itemKey: String,
|
||||
@Body quantity: Map<String, Int>,
|
||||
@Body quantity: Map<String, Int>
|
||||
): HabitResponse<BuyResponse>
|
||||
|
||||
@POST("user/purchase/{type}/{key}")
|
||||
suspend fun purchaseItem(
|
||||
@Path("type") type: String,
|
||||
@Path("key") itemKey: String,
|
||||
@Body quantity: Map<String, Int>,
|
||||
@Body quantity: Map<String, Int>
|
||||
): HabitResponse<Void>
|
||||
|
||||
@POST("user/purchase-hourglass/{type}/{key}")
|
||||
suspend fun purchaseHourglassItem(
|
||||
@Path("type") type: String,
|
||||
@Path("key") itemKey: String,
|
||||
@Path("key") itemKey: String
|
||||
): HabitResponse<Void>
|
||||
|
||||
@POST("user/buy-mystery-set/{key}")
|
||||
suspend fun purchaseMysterySet(
|
||||
@Path("key") itemKey: String,
|
||||
@Path("key") itemKey: String
|
||||
): HabitResponse<Void>
|
||||
|
||||
@POST("user/buy-quest/{key}")
|
||||
suspend fun purchaseQuest(
|
||||
@Path("key") key: String,
|
||||
@Path("key") key: String
|
||||
): HabitResponse<Void>
|
||||
|
||||
@POST("user/buy-special-spell/{key}")
|
||||
suspend fun purchaseSpecialSpell(
|
||||
@Path("key") key: String,
|
||||
@Path("key") key: String
|
||||
): HabitResponse<Void>
|
||||
|
||||
@POST("user/sell/{type}/{key}")
|
||||
suspend fun sellItem(
|
||||
@Path("type") itemType: String,
|
||||
@Path("key") itemKey: String,
|
||||
@Path("key") itemKey: String
|
||||
): HabitResponse<User>
|
||||
|
||||
@POST("user/feed/{pet}/{food}")
|
||||
suspend fun feedPet(
|
||||
@Path("pet") petKey: String,
|
||||
@Path("food") foodKey: String,
|
||||
@Path("food") foodKey: String
|
||||
): HabitResponse<FeedResponse>
|
||||
|
||||
@POST("user/hatch/{egg}/{hatchingPotion}")
|
||||
suspend fun hatchPet(
|
||||
@Path("egg") eggKey: String,
|
||||
@Path("hatchingPotion") hatchingPotionKey: String,
|
||||
@Path("hatchingPotion") hatchingPotionKey: String
|
||||
): HabitResponse<Items>
|
||||
|
||||
@GET("tasks/user")
|
||||
suspend fun getTasks(
|
||||
@Query("type") type: String,
|
||||
@Query("type") type: String
|
||||
): HabitResponse<TaskList>
|
||||
|
||||
@GET("tasks/user")
|
||||
suspend fun getTasks(
|
||||
@Query("type") type: String,
|
||||
@Query("dueDate") dueDate: String,
|
||||
@Query("dueDate") dueDate: String
|
||||
): HabitResponse<TaskList>
|
||||
|
||||
@POST("user/unlock")
|
||||
suspend fun unlockPath(
|
||||
@Query("path") path: String,
|
||||
@Query("path") path: String
|
||||
): HabitResponse<UnlockResponse>
|
||||
|
||||
@GET("tasks/{id}")
|
||||
suspend fun getTask(
|
||||
@Path("id") id: String,
|
||||
@Path("id") id: String
|
||||
): HabitResponse<Task>
|
||||
|
||||
@POST("tasks/{id}/score/{direction}")
|
||||
suspend fun postTaskDirection(
|
||||
@Path("id") id: String,
|
||||
@Path("direction") direction: String,
|
||||
@Path("direction") direction: String
|
||||
): HabitResponse<TaskDirectionData>
|
||||
|
||||
@POST("tasks/bulk-score")
|
||||
suspend fun bulkScoreTasks(
|
||||
@Body data: List<Map<String, String>>,
|
||||
@Body data: List<Map<String, String>>
|
||||
): HabitResponse<BulkTaskScoringData>
|
||||
|
||||
@POST("tasks/{id}/move/to/{position}")
|
||||
suspend fun postTaskNewPosition(
|
||||
@Path("id") id: String,
|
||||
@Path("position") position: Int,
|
||||
@Path("position") position: Int
|
||||
): HabitResponse<List<String>>
|
||||
|
||||
@POST("tasks/{taskId}/checklist/{itemId}/score")
|
||||
suspend fun scoreChecklistItem(
|
||||
@Path("taskId") taskId: String,
|
||||
@Path("itemId") itemId: String,
|
||||
@Path("itemId") itemId: String
|
||||
): HabitResponse<Task>
|
||||
|
||||
@POST("tasks/user")
|
||||
suspend fun createTask(
|
||||
@Body item: Task,
|
||||
@Body item: Task
|
||||
): HabitResponse<Task>
|
||||
|
||||
@POST("tasks/group/{groupId}")
|
||||
suspend fun createGroupTask(
|
||||
@Path("groupId") groupId: String,
|
||||
@Body item: Task,
|
||||
@Body item: Task
|
||||
): HabitResponse<Task>
|
||||
|
||||
@POST("tasks/user")
|
||||
suspend fun createTasks(
|
||||
@Body tasks: List<Task>,
|
||||
@Body tasks: List<Task>
|
||||
): HabitResponse<List<Task>>
|
||||
|
||||
@PUT("tasks/{id}")
|
||||
suspend fun updateTask(
|
||||
@Path("id") id: String,
|
||||
@Body item: Task,
|
||||
@Body item: Task
|
||||
): HabitResponse<Task>
|
||||
|
||||
@DELETE("tasks/{id}")
|
||||
suspend fun deleteTask(
|
||||
@Path("id") id: String,
|
||||
@Path("id") id: String
|
||||
): HabitResponse<Void>
|
||||
|
||||
@POST("tags")
|
||||
suspend fun createTag(
|
||||
@Body tag: Tag,
|
||||
@Body tag: Tag
|
||||
): HabitResponse<Tag>
|
||||
|
||||
@PUT("tags/{id}")
|
||||
suspend fun updateTag(
|
||||
@Path("id") id: String,
|
||||
@Body tag: Tag,
|
||||
@Body tag: Tag
|
||||
): HabitResponse<Tag>
|
||||
|
||||
@DELETE("tags/{id}")
|
||||
suspend fun deleteTag(
|
||||
@Path("id") id: String,
|
||||
@Path("id") id: String
|
||||
): HabitResponse<Void>
|
||||
|
||||
@POST("user/auth/local/register")
|
||||
suspend fun registerUser(
|
||||
@Body auth: UserAuth,
|
||||
@Body auth: UserAuth
|
||||
): HabitResponse<UserAuthResponse>
|
||||
|
||||
@POST("user/auth/local/login")
|
||||
suspend fun connectLocal(
|
||||
@Body auth: UserAuth,
|
||||
@Body auth: UserAuth
|
||||
): HabitResponse<UserAuthResponse>
|
||||
|
||||
@POST("user/auth/social")
|
||||
suspend fun connectSocial(
|
||||
@Body auth: UserAuthSocial,
|
||||
@Body auth: UserAuthSocial
|
||||
): HabitResponse<UserAuthResponse>
|
||||
|
||||
@DELETE("user/auth/social/{network}")
|
||||
suspend fun disconnectSocial(
|
||||
@Path("network") network: String,
|
||||
@Path("network") network: String
|
||||
): HabitResponse<Void>
|
||||
|
||||
@POST("user/auth/apple")
|
||||
suspend fun loginApple(
|
||||
@Body auth: Map<String, Any>,
|
||||
@Body auth: Map<String, Any>
|
||||
): HabitResponse<UserAuthResponse>
|
||||
|
||||
@POST("user/sleep")
|
||||
|
|
@ -273,13 +273,13 @@ interface ApiService {
|
|||
suspend fun useSkill(
|
||||
@Path("skill") skillName: String,
|
||||
@Query("targetType") targetType: String,
|
||||
@Query("targetId") targetId: String,
|
||||
@Query("targetId") targetId: String
|
||||
): HabitResponse<SkillResponse>
|
||||
|
||||
@POST("user/class/cast/{skill}")
|
||||
suspend fun useSkill(
|
||||
@Path("skill") skillName: String,
|
||||
@Query("targetType") targetType: String,
|
||||
@Query("targetType") targetType: String
|
||||
): HabitResponse<SkillResponse>
|
||||
|
||||
@POST("user/change-class")
|
||||
|
|
@ -287,7 +287,7 @@ interface ApiService {
|
|||
|
||||
@POST("user/change-class")
|
||||
suspend fun changeClass(
|
||||
@Query("class") className: String,
|
||||
@Query("class") className: String
|
||||
): HabitResponse<User>
|
||||
|
||||
@POST("user/disable-classes")
|
||||
|
|
@ -300,164 +300,164 @@ interface ApiService {
|
|||
|
||||
@GET("groups")
|
||||
suspend fun listGroups(
|
||||
@Query("type") type: String,
|
||||
@Query("type") type: String
|
||||
): HabitResponse<List<Group>>
|
||||
|
||||
@GET("groups/{gid}")
|
||||
suspend fun getGroup(
|
||||
@Path("gid") groupId: String,
|
||||
@Path("gid") groupId: String
|
||||
): HabitResponse<Group>
|
||||
|
||||
@POST("groups")
|
||||
suspend fun createGroup(
|
||||
@Body item: Group,
|
||||
@Body item: Group
|
||||
): HabitResponse<Group>
|
||||
|
||||
@PUT("groups/{id}")
|
||||
suspend fun updateGroup(
|
||||
@Path("id") id: String,
|
||||
@Body item: Group,
|
||||
@Body item: Group
|
||||
): HabitResponse<Group>
|
||||
|
||||
@POST("groups/{groupID}/removeMember/{userID}")
|
||||
suspend fun removeMemberFromGroup(
|
||||
@Path("groupID") groupID: String,
|
||||
@Path("userID") userID: String,
|
||||
@Path("userID") userID: String
|
||||
): HabitResponse<Void>
|
||||
|
||||
@GET("groups/{gid}/chat")
|
||||
suspend fun listGroupChat(
|
||||
@Path("gid") groupId: String,
|
||||
@Path("gid") groupId: String
|
||||
): HabitResponse<List<ChatMessage>>
|
||||
|
||||
@POST("groups/{gid}/join")
|
||||
suspend fun joinGroup(
|
||||
@Path("gid") groupId: String,
|
||||
@Path("gid") groupId: String
|
||||
): HabitResponse<Group>
|
||||
|
||||
@POST("groups/{gid}/leave")
|
||||
suspend fun leaveGroup(
|
||||
@Path("gid") groupId: String,
|
||||
@Query("keepChallenges") keepChallenges: String,
|
||||
@Query("keepChallenges") keepChallenges: String
|
||||
): HabitResponse<Void>
|
||||
|
||||
@POST("groups/{gid}/chat")
|
||||
suspend fun postGroupChat(
|
||||
@Path("gid") groupId: String,
|
||||
@Body message: Map<String, String>,
|
||||
@Body message: Map<String, String>
|
||||
): HabitResponse<PostChatMessageResult>
|
||||
|
||||
@DELETE("groups/{gid}/chat/{messageId}")
|
||||
suspend fun deleteMessage(
|
||||
@Path("gid") groupId: String,
|
||||
@Path("messageId") messageId: String,
|
||||
@Path("messageId") messageId: String
|
||||
): HabitResponse<Void>
|
||||
|
||||
@DELETE("inbox/messages/{messageId}")
|
||||
suspend fun deleteInboxMessage(
|
||||
@Path("messageId") messageId: String,
|
||||
@Path("messageId") messageId: String
|
||||
): HabitResponse<Void>
|
||||
|
||||
@GET("groups/{gid}/members")
|
||||
suspend fun getGroupMembers(
|
||||
@Path("gid") groupId: String,
|
||||
@Query("includeAllPublicFields") includeAllPublicFields: Boolean?,
|
||||
@Query("includeAllPublicFields") includeAllPublicFields: Boolean?
|
||||
): HabitResponse<List<Member>>
|
||||
|
||||
@GET("groups/{gid}/members")
|
||||
suspend fun getGroupMembers(
|
||||
@Path("gid") groupId: String,
|
||||
@Query("includeAllPublicFields") includeAllPublicFields: Boolean?,
|
||||
@Query("lastId") lastId: String,
|
||||
@Query("lastId") lastId: String
|
||||
): HabitResponse<List<Member>>
|
||||
|
||||
// Like returns the full chat list
|
||||
@POST("groups/{gid}/chat/{mid}/like")
|
||||
suspend fun likeMessage(
|
||||
@Path("gid") groupId: String,
|
||||
@Path("mid") mid: String,
|
||||
@Path("mid") mid: String
|
||||
): HabitResponse<ChatMessage>
|
||||
|
||||
@POST("groups/{gid}/chat/{mid}/flag")
|
||||
suspend fun flagMessage(
|
||||
@Path("gid") groupId: String,
|
||||
@Path("mid") mid: String,
|
||||
@Body data: Map<String, String>,
|
||||
@Body data: Map<String, String>
|
||||
): HabitResponse<Void>
|
||||
|
||||
@POST("members/{mid}/flag")
|
||||
suspend fun reportMember(
|
||||
@Path("mid") mid: String,
|
||||
@Body data: Map<String, String>,
|
||||
@Body data: Map<String, String>
|
||||
): HabitResponse<Void>
|
||||
|
||||
@POST("groups/{gid}/chat/seen")
|
||||
suspend fun seenMessages(
|
||||
@Path("gid") groupId: String,
|
||||
@Path("gid") groupId: String
|
||||
): HabitResponse<Void>
|
||||
|
||||
@POST("groups/{gid}/invite")
|
||||
suspend fun inviteToGroup(
|
||||
@Path("gid") groupId: String,
|
||||
@Body inviteData: Map<String, Any>,
|
||||
@Body inviteData: Map<String, Any>
|
||||
): HabitResponse<List<InviteResponse>>
|
||||
|
||||
@POST("groups/{gid}/reject-invite")
|
||||
suspend fun rejectGroupInvite(
|
||||
@Path("gid") groupId: String,
|
||||
@Path("gid") groupId: String
|
||||
): HabitResponse<Void>
|
||||
|
||||
@POST("groups/{gid}/quests/accept")
|
||||
suspend fun acceptQuest(
|
||||
@Path("gid") groupId: String,
|
||||
@Path("gid") groupId: String
|
||||
): HabitResponse<Void>
|
||||
|
||||
@POST("groups/{gid}/quests/reject")
|
||||
suspend fun rejectQuest(
|
||||
@Path("gid") groupId: String,
|
||||
@Path("gid") groupId: String
|
||||
): HabitResponse<Void>
|
||||
|
||||
@POST("groups/{gid}/quests/cancel")
|
||||
suspend fun cancelQuest(
|
||||
@Path("gid") groupId: String,
|
||||
@Path("gid") groupId: String
|
||||
): HabitResponse<Void>
|
||||
|
||||
@POST("groups/{gid}/quests/force-start")
|
||||
suspend fun forceStartQuest(
|
||||
@Path("gid") groupId: String,
|
||||
@Body group: Group,
|
||||
@Body group: Group
|
||||
): HabitResponse<Quest>
|
||||
|
||||
@POST("groups/{gid}/quests/invite/{questKey}")
|
||||
suspend fun inviteToQuest(
|
||||
@Path("gid") groupId: String,
|
||||
@Path("questKey") questKey: String,
|
||||
@Path("questKey") questKey: String
|
||||
): HabitResponse<Quest>
|
||||
|
||||
@GET("groups/{gid}/invites")
|
||||
suspend fun getGroupInvites(
|
||||
@Path("gid") groupId: String,
|
||||
@Query("includeAllPublicFields") includeAllPublicFields: Boolean?,
|
||||
@Query("includeAllPublicFields") includeAllPublicFields: Boolean?
|
||||
): HabitResponse<List<Member>>
|
||||
|
||||
@POST("groups/{gid}/quests/abort")
|
||||
suspend fun abortQuest(
|
||||
@Path("gid") groupId: String,
|
||||
@Path("gid") groupId: String
|
||||
): HabitResponse<Quest>
|
||||
|
||||
@POST("groups/{gid}/quests/leave")
|
||||
suspend fun leaveQuest(
|
||||
@Path("gid") groupId: String,
|
||||
@Path("gid") groupId: String
|
||||
): HabitResponse<Void>
|
||||
|
||||
@POST("/iap/android/verify")
|
||||
suspend fun validatePurchase(
|
||||
@Body request: PurchaseValidationRequest,
|
||||
@Body request: PurchaseValidationRequest
|
||||
): HabitResponse<PurchaseValidationResult>
|
||||
|
||||
@POST("/iap/android/subscribe")
|
||||
suspend fun validateSubscription(
|
||||
@Body request: PurchaseValidationRequest,
|
||||
@Body request: PurchaseValidationRequest
|
||||
): HabitResponse<Void>
|
||||
|
||||
@GET("/iap/android/subscribe/cancel")
|
||||
|
|
@ -465,69 +465,69 @@ interface ApiService {
|
|||
|
||||
@POST("/iap/android/norenew-subscribe")
|
||||
suspend fun validateNoRenewSubscription(
|
||||
@Body request: PurchaseValidationRequest,
|
||||
@Body request: PurchaseValidationRequest
|
||||
): HabitResponse<Void>
|
||||
|
||||
@POST("user/custom-day-start")
|
||||
suspend fun changeCustomDayStart(
|
||||
@Body updateObject: Map<String, Any>,
|
||||
@Body updateObject: Map<String, Any>
|
||||
): HabitResponse<Void>
|
||||
|
||||
// Members URL
|
||||
@GET("members/{mid}")
|
||||
suspend fun getMember(
|
||||
@Path("mid") memberId: String,
|
||||
@Path("mid") memberId: String
|
||||
): HabitResponse<Member>
|
||||
|
||||
@GET("members/username/{username}")
|
||||
suspend fun getMemberWithUsername(
|
||||
@Path("username") username: String,
|
||||
@Path("username") username: String
|
||||
): HabitResponse<Member>
|
||||
|
||||
@GET("members/{mid}/achievements")
|
||||
suspend fun getMemberAchievements(
|
||||
@Path("mid") memberId: String,
|
||||
@Query("lang") language: String?,
|
||||
@Query("lang") language: String?
|
||||
): HabitResponse<List<Achievement>>
|
||||
|
||||
@POST("members/send-private-message")
|
||||
suspend fun postPrivateMessage(
|
||||
@Body messageDetails: Map<String, String>,
|
||||
@Body messageDetails: Map<String, String>
|
||||
): HabitResponse<PostChatMessageResult>
|
||||
|
||||
@GET("members/find/{username}")
|
||||
suspend fun findUsernames(
|
||||
@Path("username") username: String,
|
||||
@Query("context") context: String?,
|
||||
@Query("id") id: String?,
|
||||
@Query("id") id: String?
|
||||
): HabitResponse<List<FindUsernameResult>>
|
||||
|
||||
@POST("members/flag-private-message/{mid}")
|
||||
suspend fun flagInboxMessage(
|
||||
@Path("mid") mid: String,
|
||||
@Body data: Map<String, String>,
|
||||
@Body data: Map<String, String>
|
||||
): HabitResponse<Void>
|
||||
|
||||
@GET("shops/{identifier}")
|
||||
suspend fun retrieveShopInventory(
|
||||
@Path("identifier") identifier: String,
|
||||
@Query("lang") language: String?,
|
||||
@Query("lang") language: String?
|
||||
): HabitResponse<Shop>
|
||||
|
||||
@GET("shops/market-gear")
|
||||
suspend fun retrieveMarketGear(
|
||||
@Query("lang") language: String?,
|
||||
@Query("lang") language: String?
|
||||
): HabitResponse<Shop>
|
||||
|
||||
// Push notifications
|
||||
@POST("user/push-devices")
|
||||
suspend fun addPushDevice(
|
||||
@Body pushDeviceData: Map<String, String>,
|
||||
@Body pushDeviceData: Map<String, String>
|
||||
): HabitResponse<List<Void>>
|
||||
|
||||
@DELETE("user/push-devices/{regId}")
|
||||
suspend fun deletePushDevice(
|
||||
@Path("regId") regId: String,
|
||||
@Path("regId") regId: String
|
||||
): HabitResponse<List<Void>>
|
||||
|
||||
// challenges api
|
||||
|
|
@ -535,61 +535,61 @@ interface ApiService {
|
|||
@GET("challenges/user")
|
||||
suspend fun getUserChallenges(
|
||||
@Query("page") page: Int?,
|
||||
@Query("member") memberOnly: Boolean,
|
||||
@Query("member") memberOnly: Boolean
|
||||
): HabitResponse<List<Challenge>>
|
||||
|
||||
@GET("challenges/user")
|
||||
suspend fun getUserChallenges(
|
||||
@Query("page") page: Int?,
|
||||
@Query("page") page: Int?
|
||||
): HabitResponse<List<Challenge>>
|
||||
|
||||
@GET("tasks/challenge/{challengeId}")
|
||||
suspend fun getChallengeTasks(
|
||||
@Path("challengeId") challengeId: String,
|
||||
@Path("challengeId") challengeId: String
|
||||
): HabitResponse<TaskList>
|
||||
|
||||
@GET("challenges/{challengeId}")
|
||||
suspend fun getChallenge(
|
||||
@Path("challengeId") challengeId: String,
|
||||
@Path("challengeId") challengeId: String
|
||||
): HabitResponse<Challenge>
|
||||
|
||||
@POST("challenges/{challengeId}/join")
|
||||
suspend fun joinChallenge(
|
||||
@Path("challengeId") challengeId: String,
|
||||
@Path("challengeId") challengeId: String
|
||||
): HabitResponse<Challenge>
|
||||
|
||||
@POST("challenges/{challengeId}/leave")
|
||||
suspend fun leaveChallenge(
|
||||
@Path("challengeId") challengeId: String,
|
||||
@Body body: LeaveChallengeBody,
|
||||
@Body body: LeaveChallengeBody
|
||||
): HabitResponse<Void>
|
||||
|
||||
@POST("challenges")
|
||||
suspend fun createChallenge(
|
||||
@Body challenge: Challenge,
|
||||
@Body challenge: Challenge
|
||||
): HabitResponse<Challenge>
|
||||
|
||||
@POST("tasks/challenge/{challengeId}")
|
||||
suspend fun createChallengeTasks(
|
||||
@Path("challengeId") challengeId: String,
|
||||
@Body tasks: List<Task>,
|
||||
@Body tasks: List<Task>
|
||||
): HabitResponse<List<Task>>
|
||||
|
||||
@POST("tasks/challenge/{challengeId}")
|
||||
suspend fun createChallengeTask(
|
||||
@Path("challengeId") challengeId: String,
|
||||
@Body task: Task,
|
||||
@Body task: Task
|
||||
): HabitResponse<Task>
|
||||
|
||||
@PUT("challenges/{challengeId}")
|
||||
suspend fun updateChallenge(
|
||||
@Path("challengeId") challengeId: String,
|
||||
@Body challenge: Challenge,
|
||||
@Body challenge: Challenge
|
||||
): HabitResponse<Challenge>
|
||||
|
||||
@DELETE("challenges/{challengeId}")
|
||||
suspend fun deleteChallenge(
|
||||
@Path("challengeId") challengeId: String,
|
||||
@Path("challengeId") challengeId: String
|
||||
): HabitResponse<Void>
|
||||
|
||||
// DEBUG: These calls only work on a local development server
|
||||
|
|
@ -603,17 +603,17 @@ interface ApiService {
|
|||
// Notifications
|
||||
@POST("notifications/{notificationId}/read")
|
||||
suspend fun readNotification(
|
||||
@Path("notificationId") notificationId: String,
|
||||
@Path("notificationId") notificationId: String
|
||||
): HabitResponse<List<Any>>
|
||||
|
||||
@POST("notifications/read")
|
||||
suspend fun readNotifications(
|
||||
@Body notificationIds: Map<String, List<String>>,
|
||||
@Body notificationIds: Map<String, List<String>>
|
||||
): HabitResponse<List<Any>>
|
||||
|
||||
@POST("notifications/see")
|
||||
suspend fun seeNotifications(
|
||||
@Body notificationIds: Map<String, List<String>>,
|
||||
@Body notificationIds: Map<String, List<String>>
|
||||
): HabitResponse<List<Any>>
|
||||
|
||||
@POST("user/open-mystery-item")
|
||||
|
|
@ -624,69 +624,69 @@ interface ApiService {
|
|||
|
||||
@POST("user/reset")
|
||||
suspend fun resetAccount(
|
||||
@Body body: Map<String, String>,
|
||||
@Body body: Map<String, String>
|
||||
): HabitResponse<Void>
|
||||
|
||||
@HTTP(method = "DELETE", path = "user", hasBody = true)
|
||||
suspend fun deleteAccount(
|
||||
@Body body: Map<String, String>,
|
||||
@Body body: Map<String, String>
|
||||
): HabitResponse<Void>
|
||||
|
||||
@GET("user/toggle-pinned-item/{pinType}/{path}")
|
||||
suspend fun togglePinnedItem(
|
||||
@Path("pinType") pinType: String,
|
||||
@Path("path") path: String,
|
||||
@Path("path") path: String
|
||||
): HabitResponse<Void>
|
||||
|
||||
@POST("user/reset-password")
|
||||
suspend fun sendPasswordResetEmail(
|
||||
@Body data: Map<String, String>,
|
||||
@Body data: Map<String, String>
|
||||
): HabitResponse<Void>
|
||||
|
||||
@PUT("user/auth/update-username")
|
||||
suspend fun updateLoginName(
|
||||
@Body data: Map<String, String>,
|
||||
@Body data: Map<String, String>
|
||||
): HabitResponse<Void>
|
||||
|
||||
@POST("user/auth/verify-username")
|
||||
suspend fun verifyUsername(
|
||||
@Body data: Map<String, String>,
|
||||
@Body data: Map<String, String>
|
||||
): HabitResponse<VerifyUsernameResponse>
|
||||
|
||||
@PUT("user/auth/update-email")
|
||||
suspend fun updateEmail(
|
||||
@Body data: Map<String, String>,
|
||||
@Body data: Map<String, String>
|
||||
): HabitResponse<Void>
|
||||
|
||||
@PUT("user/auth/update-password")
|
||||
suspend fun updatePassword(
|
||||
@Body data: Map<String, String>,
|
||||
@Body data: Map<String, String>
|
||||
): HabitResponse<Void>
|
||||
|
||||
@POST("user/allocate")
|
||||
suspend fun allocatePoint(
|
||||
@Query("stat") stat: String,
|
||||
@Query("stat") stat: String
|
||||
): HabitResponse<Stats>
|
||||
|
||||
@POST("user/allocate-bulk")
|
||||
suspend fun bulkAllocatePoints(
|
||||
@Body stats: Map<String, Map<String, Int>>,
|
||||
@Body stats: Map<String, Map<String, Int>>
|
||||
): HabitResponse<Stats>
|
||||
|
||||
@POST("members/transfer-gems")
|
||||
suspend fun transferGems(
|
||||
@Body data: Map<String, Any>,
|
||||
@Body data: Map<String, Any>
|
||||
): HabitResponse<Void>
|
||||
|
||||
@POST("tasks/unlink-all/{challengeID}")
|
||||
suspend fun unlinkAllTasks(
|
||||
@Path("challengeID") challengeID: String?,
|
||||
@Query("keep") keepOption: String,
|
||||
@Query("keep") keepOption: String
|
||||
): HabitResponse<Void>
|
||||
|
||||
@POST("user/block/{userID}")
|
||||
suspend fun blockMember(
|
||||
@Path("userID") userID: String,
|
||||
@Path("userID") userID: String
|
||||
): HabitResponse<List<String>>
|
||||
|
||||
@POST("user/reroll")
|
||||
|
|
@ -699,46 +699,46 @@ interface ApiService {
|
|||
|
||||
@GET("tasks/group/{groupID}")
|
||||
suspend fun getTeamPlanTasks(
|
||||
@Path("groupID") groupId: String,
|
||||
@Path("groupID") groupId: String
|
||||
): HabitResponse<TaskList>
|
||||
|
||||
@POST("tasks/{taskID}/assign")
|
||||
suspend fun assignToTask(
|
||||
@Path("taskID") taskId: String?,
|
||||
@Body ids: List<String>,
|
||||
@Body ids: List<String>
|
||||
): HabitResponse<Task>
|
||||
|
||||
@POST("tasks/{taskID}/unassign/{userID}")
|
||||
suspend fun unassignFromTask(
|
||||
@Path("taskID") taskID: String,
|
||||
@Path("userID") userID: String,
|
||||
@Path("userID") userID: String
|
||||
): HabitResponse<Task>
|
||||
|
||||
@PUT("hall/heroes/{memberID}")
|
||||
suspend fun updateUser(
|
||||
@Path("memberID") memberID: String,
|
||||
@Body updateData: Map<String, Map<String, Boolean>>,
|
||||
@Body updateData: Map<String, Map<String, Boolean>>
|
||||
): HabitResponse<Member>
|
||||
|
||||
@GET("hall/heroes/{memberID}")
|
||||
suspend fun getHallMember(
|
||||
@Path("memberID") memberID: String,
|
||||
@Path("memberID") memberID: String
|
||||
): HabitResponse<Member>
|
||||
|
||||
@POST("tasks/{taskID}/needs-work/{userID}")
|
||||
suspend fun markTaskNeedsWork(
|
||||
@Path("taskID") taskID: String,
|
||||
@Path("userID") userID: String,
|
||||
@Path("userID") userID: String
|
||||
): HabitResponse<Task>
|
||||
|
||||
@GET("looking-for-party")
|
||||
suspend fun retrievePartySeekingUsers(
|
||||
@Query("page") page: Int,
|
||||
@Query("page") page: Int
|
||||
): HabitResponse<List<Member>>
|
||||
|
||||
@POST("challenges/{challengeId}/flag")
|
||||
suspend fun reportChallenge(
|
||||
@Path("challengeId") challengeid: String,
|
||||
@Body updateData: Map<String, String>,
|
||||
@Body updateData: Map<String, String>
|
||||
): HabitResponse<Void>
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ interface ApiClient {
|
|||
|
||||
suspend fun getUserChallenges(
|
||||
page: Int,
|
||||
memberOnly: Boolean,
|
||||
memberOnly: Boolean
|
||||
): List<Challenge>?
|
||||
|
||||
suspend fun getWorldState(): WorldState?
|
||||
|
|
@ -68,23 +68,23 @@ interface ApiClient {
|
|||
|
||||
suspend fun equipItem(
|
||||
type: String,
|
||||
itemKey: String,
|
||||
itemKey: String
|
||||
): Items?
|
||||
|
||||
suspend fun buyItem(
|
||||
itemKey: String,
|
||||
purchaseQuantity: Int,
|
||||
purchaseQuantity: Int
|
||||
): BuyResponse?
|
||||
|
||||
suspend fun purchaseItem(
|
||||
type: String,
|
||||
itemKey: String,
|
||||
purchaseQuantity: Int,
|
||||
purchaseQuantity: Int
|
||||
): Void?
|
||||
|
||||
suspend fun purchaseHourglassItem(
|
||||
type: String,
|
||||
itemKey: String,
|
||||
itemKey: String
|
||||
): Void?
|
||||
|
||||
suspend fun purchaseMysterySet(itemKey: String): Void?
|
||||
|
|
@ -101,24 +101,24 @@ interface ApiClient {
|
|||
|
||||
suspend fun sellItem(
|
||||
itemType: String,
|
||||
itemKey: String,
|
||||
itemKey: String
|
||||
): User?
|
||||
|
||||
suspend fun feedPet(
|
||||
petKey: String,
|
||||
foodKey: String,
|
||||
foodKey: String
|
||||
): FeedResponse?
|
||||
|
||||
suspend fun hatchPet(
|
||||
eggKey: String,
|
||||
hatchingPotionKey: String,
|
||||
hatchingPotionKey: String
|
||||
): Items?
|
||||
|
||||
suspend fun getTasks(type: String): TaskList?
|
||||
|
||||
suspend fun getTasks(
|
||||
type: String,
|
||||
dueDate: String,
|
||||
dueDate: String
|
||||
): TaskList?
|
||||
|
||||
suspend fun unlockPath(path: String): UnlockResponse?
|
||||
|
|
@ -127,33 +127,33 @@ interface ApiClient {
|
|||
|
||||
suspend fun postTaskDirection(
|
||||
id: String,
|
||||
direction: String,
|
||||
direction: String
|
||||
): TaskDirectionData?
|
||||
|
||||
suspend fun bulkScoreTasks(data: List<Map<String, String>>): BulkTaskScoringData?
|
||||
|
||||
suspend fun postTaskNewPosition(
|
||||
id: String,
|
||||
position: Int,
|
||||
position: Int
|
||||
): List<String>?
|
||||
|
||||
suspend fun scoreChecklistItem(
|
||||
taskId: String,
|
||||
itemId: String,
|
||||
itemId: String
|
||||
): Task?
|
||||
|
||||
suspend fun createTask(item: Task): Task?
|
||||
|
||||
suspend fun createGroupTask(
|
||||
groupId: String,
|
||||
item: Task,
|
||||
item: Task
|
||||
): Task?
|
||||
|
||||
suspend fun createTasks(tasks: List<Task>): List<Task>?
|
||||
|
||||
suspend fun updateTask(
|
||||
id: String,
|
||||
item: Task,
|
||||
item: Task
|
||||
): Task?
|
||||
|
||||
suspend fun deleteTask(id: String): Void?
|
||||
|
|
@ -162,7 +162,7 @@ interface ApiClient {
|
|||
|
||||
suspend fun updateTag(
|
||||
id: String,
|
||||
tag: Tag,
|
||||
tag: Tag
|
||||
): Tag?
|
||||
|
||||
suspend fun deleteTag(id: String): Void?
|
||||
|
|
@ -171,18 +171,18 @@ interface ApiClient {
|
|||
username: String,
|
||||
email: String,
|
||||
password: String,
|
||||
confirmPassword: String,
|
||||
confirmPassword: String
|
||||
): UserAuthResponse?
|
||||
|
||||
suspend fun connectUser(
|
||||
username: String,
|
||||
password: String,
|
||||
password: String
|
||||
): UserAuthResponse?
|
||||
|
||||
suspend fun connectSocial(
|
||||
network: String,
|
||||
userId: String,
|
||||
accessToken: String,
|
||||
accessToken: String
|
||||
): UserAuthResponse?
|
||||
|
||||
suspend fun disconnectSocial(network: String): Void?
|
||||
|
|
@ -196,12 +196,12 @@ interface ApiClient {
|
|||
suspend fun useSkill(
|
||||
skillName: String,
|
||||
targetType: String,
|
||||
targetId: String,
|
||||
targetId: String
|
||||
): SkillResponse?
|
||||
|
||||
suspend fun useSkill(
|
||||
skillName: String,
|
||||
targetType: String,
|
||||
targetType: String
|
||||
): SkillResponse?
|
||||
|
||||
suspend fun changeClass(className: String?): User?
|
||||
|
|
@ -220,12 +220,12 @@ interface ApiClient {
|
|||
|
||||
suspend fun updateGroup(
|
||||
id: String,
|
||||
item: Group,
|
||||
item: Group
|
||||
): Group?
|
||||
|
||||
suspend fun removeMemberFromGroup(
|
||||
groupID: String,
|
||||
userID: String,
|
||||
userID: String
|
||||
): Void?
|
||||
|
||||
suspend fun listGroupChat(groupId: String): List<ChatMessage>?
|
||||
|
|
@ -234,59 +234,59 @@ interface ApiClient {
|
|||
|
||||
suspend fun leaveGroup(
|
||||
groupId: String,
|
||||
keepChallenges: String,
|
||||
keepChallenges: String
|
||||
): Void?
|
||||
|
||||
suspend fun postGroupChat(
|
||||
groupId: String,
|
||||
message: Map<String, String>,
|
||||
message: Map<String, String>
|
||||
): PostChatMessageResult?
|
||||
|
||||
suspend fun deleteMessage(
|
||||
groupId: String,
|
||||
messageId: String,
|
||||
messageId: String
|
||||
): Void?
|
||||
|
||||
suspend fun deleteInboxMessage(id: String): Void?
|
||||
|
||||
suspend fun getGroupMembers(
|
||||
groupId: String,
|
||||
includeAllPublicFields: Boolean?,
|
||||
includeAllPublicFields: Boolean?
|
||||
): List<Member>?
|
||||
|
||||
suspend fun getGroupMembers(
|
||||
groupId: String,
|
||||
includeAllPublicFields: Boolean?,
|
||||
lastId: String,
|
||||
lastId: String
|
||||
): List<Member>?
|
||||
|
||||
// Like returns the full chat list
|
||||
suspend fun likeMessage(
|
||||
groupId: String,
|
||||
mid: String,
|
||||
mid: String
|
||||
): ChatMessage?
|
||||
|
||||
suspend fun flagMessage(
|
||||
groupId: String,
|
||||
mid: String,
|
||||
data: MutableMap<String, String>,
|
||||
data: MutableMap<String, String>
|
||||
): Void?
|
||||
|
||||
suspend fun flagInboxMessage(
|
||||
mid: String,
|
||||
data: MutableMap<String, String>,
|
||||
data: MutableMap<String, String>
|
||||
): Void?
|
||||
|
||||
suspend fun reportMember(
|
||||
mid: String,
|
||||
data: Map<String, String>,
|
||||
data: Map<String, String>
|
||||
): Void?
|
||||
|
||||
suspend fun seenMessages(groupId: String): Void?
|
||||
|
||||
suspend fun inviteToGroup(
|
||||
groupId: String,
|
||||
inviteData: Map<String, Any>,
|
||||
inviteData: Map<String, Any>
|
||||
): List<InviteResponse>?
|
||||
|
||||
suspend fun rejectGroupInvite(groupId: String): Void?
|
||||
|
|
@ -299,12 +299,12 @@ interface ApiClient {
|
|||
|
||||
suspend fun forceStartQuest(
|
||||
groupId: String,
|
||||
group: Group,
|
||||
group: Group
|
||||
): Quest?
|
||||
|
||||
suspend fun inviteToQuest(
|
||||
groupId: String,
|
||||
questKey: String,
|
||||
questKey: String
|
||||
): Quest?
|
||||
|
||||
suspend fun abortQuest(groupId: String): Quest?
|
||||
|
|
@ -339,19 +339,19 @@ interface ApiClient {
|
|||
|
||||
suspend fun leaveChallenge(
|
||||
challengeId: String,
|
||||
body: LeaveChallengeBody,
|
||||
body: LeaveChallengeBody
|
||||
): Void?
|
||||
|
||||
suspend fun createChallenge(challenge: Challenge): Challenge?
|
||||
|
||||
suspend fun createChallengeTasks(
|
||||
challengeId: String,
|
||||
tasks: List<Task>,
|
||||
tasks: List<Task>
|
||||
): List<Task>?
|
||||
|
||||
suspend fun createChallengeTask(
|
||||
challengeId: String,
|
||||
task: Task,
|
||||
task: Task
|
||||
): Task?
|
||||
|
||||
suspend fun updateChallenge(challenge: Challenge): Challenge?
|
||||
|
|
@ -375,7 +375,7 @@ interface ApiClient {
|
|||
|
||||
fun updateAuthenticationCredentials(
|
||||
userID: String?,
|
||||
apiToken: String?,
|
||||
apiToken: String?
|
||||
)
|
||||
|
||||
fun hasAuthenticationKeys(): Boolean
|
||||
|
|
@ -384,7 +384,7 @@ interface ApiClient {
|
|||
|
||||
suspend fun retrieveInboxMessages(
|
||||
uuid: String,
|
||||
page: Int,
|
||||
page: Int
|
||||
): List<ChatMessage>?
|
||||
|
||||
suspend fun retrieveInboxConversations(): List<InboxConversation>?
|
||||
|
|
@ -401,27 +401,27 @@ interface ApiClient {
|
|||
|
||||
suspend fun togglePinnedItem(
|
||||
pinType: String,
|
||||
path: String,
|
||||
path: String
|
||||
): Void?
|
||||
|
||||
suspend fun sendPasswordResetEmail(email: String): Void?
|
||||
|
||||
suspend fun updateLoginName(
|
||||
newLoginName: String,
|
||||
password: String,
|
||||
password: String
|
||||
): Void?
|
||||
|
||||
suspend fun updateUsername(newLoginName: String): Void?
|
||||
|
||||
suspend fun updateEmail(
|
||||
newEmail: String,
|
||||
password: String,
|
||||
password: String
|
||||
): Void?
|
||||
|
||||
suspend fun updatePassword(
|
||||
oldPassword: String,
|
||||
newPassword: String,
|
||||
newPasswordConfirmation: String,
|
||||
newPasswordConfirmation: String
|
||||
): Void?
|
||||
|
||||
suspend fun allocatePoint(stat: String): Stats?
|
||||
|
|
@ -430,7 +430,7 @@ interface ApiClient {
|
|||
strength: Int,
|
||||
intelligence: Int,
|
||||
constitution: Int,
|
||||
perception: Int,
|
||||
perception: Int
|
||||
): Stats?
|
||||
|
||||
suspend fun retrieveMarketGear(): Shop?
|
||||
|
|
@ -442,17 +442,17 @@ interface ApiClient {
|
|||
suspend fun findUsernames(
|
||||
username: String,
|
||||
context: String?,
|
||||
id: String?,
|
||||
id: String?
|
||||
): List<FindUsernameResult>?
|
||||
|
||||
suspend fun transferGems(
|
||||
giftedID: String,
|
||||
amount: Int,
|
||||
amount: Int
|
||||
): Void?
|
||||
|
||||
suspend fun unlinkAllTasks(
|
||||
challengeID: String?,
|
||||
keepOption: String,
|
||||
keepOption: String
|
||||
): Void?
|
||||
|
||||
suspend fun blockMember(userID: String): List<String>?
|
||||
|
|
@ -463,37 +463,37 @@ interface ApiClient {
|
|||
|
||||
suspend fun assignToTask(
|
||||
taskId: String,
|
||||
ids: List<String>,
|
||||
ids: List<String>
|
||||
): Task?
|
||||
|
||||
suspend fun unassignFromTask(
|
||||
taskId: String,
|
||||
userID: String,
|
||||
userID: String
|
||||
): Task?
|
||||
|
||||
suspend fun updateMember(
|
||||
memberID: String,
|
||||
updateData: Map<String, Map<String, Boolean>>,
|
||||
updateData: Map<String, Map<String, Boolean>>
|
||||
): Member?
|
||||
|
||||
suspend fun getHallMember(userId: String): Member?
|
||||
|
||||
suspend fun markTaskNeedsWork(
|
||||
taskID: String,
|
||||
userID: String,
|
||||
userID: String
|
||||
): Task?
|
||||
|
||||
suspend fun retrievePartySeekingUsers(page: Int): List<Member>?
|
||||
|
||||
suspend fun getGroupInvites(
|
||||
groupId: String,
|
||||
includeAllPublicFields: Boolean?,
|
||||
includeAllPublicFields: Boolean?
|
||||
): List<Member>?
|
||||
|
||||
suspend fun syncUserStats(): User?
|
||||
|
||||
suspend fun reportChallenge(
|
||||
challengeid: String,
|
||||
updateData: Map<String, String>,
|
||||
updateData: Map<String, String>
|
||||
): Void?
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import kotlinx.coroutines.flow.Flow
|
|||
interface ChallengeRepository : BaseRepository {
|
||||
suspend fun retrieveChallenges(
|
||||
page: Int = 0,
|
||||
memberOnly: Boolean,
|
||||
memberOnly: Boolean
|
||||
): List<Challenge>?
|
||||
|
||||
fun getChallenges(): Flow<List<Challenge>>
|
||||
|
|
@ -24,7 +24,7 @@ interface ChallengeRepository : BaseRepository {
|
|||
|
||||
suspend fun createChallenge(
|
||||
challenge: Challenge,
|
||||
taskList: List<Task>,
|
||||
taskList: List<Task>
|
||||
): Challenge?
|
||||
|
||||
/**
|
||||
|
|
@ -41,7 +41,7 @@ interface ChallengeRepository : BaseRepository {
|
|||
fullTaskList: List<Task>,
|
||||
addedTaskList: List<Task>,
|
||||
updatedTaskList: List<Task>,
|
||||
removedTaskList: List<String>,
|
||||
removedTaskList: List<String>
|
||||
): Challenge?
|
||||
|
||||
suspend fun deleteChallenge(challengeId: String): Void?
|
||||
|
|
@ -50,7 +50,7 @@ interface ChallengeRepository : BaseRepository {
|
|||
|
||||
suspend fun leaveChallenge(
|
||||
challenge: Challenge,
|
||||
keepTasks: String,
|
||||
keepTasks: String
|
||||
): Void?
|
||||
|
||||
suspend fun joinChallenge(challenge: Challenge): Challenge?
|
||||
|
|
@ -63,6 +63,6 @@ interface ChallengeRepository : BaseRepository {
|
|||
|
||||
suspend fun reportChallenge(
|
||||
challengeid: String,
|
||||
updateData: Map<String, String>,
|
||||
updateData: Map<String, String>
|
||||
): Void?
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,6 @@ interface CustomizationRepository : BaseRepository {
|
|||
fun getCustomizations(
|
||||
type: String,
|
||||
category: String?,
|
||||
onlyAvailable: Boolean,
|
||||
onlyAvailable: Boolean
|
||||
): Flow<List<Customization>>
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,12 +50,12 @@ interface InventoryRepository : BaseRepository {
|
|||
|
||||
fun getEquipmentType(
|
||||
type: String,
|
||||
set: String,
|
||||
set: String
|
||||
): Flow<List<Equipment>>
|
||||
|
||||
fun getOwnedItems(
|
||||
itemType: String,
|
||||
includeZero: Boolean = false,
|
||||
includeZero: Boolean = false
|
||||
): Flow<List<OwnedItem>>
|
||||
|
||||
fun getOwnedItems(includeZero: Boolean = false): Flow<Map<String, OwnedItem>>
|
||||
|
|
@ -69,13 +69,13 @@ interface InventoryRepository : BaseRepository {
|
|||
fun getMounts(
|
||||
type: String?,
|
||||
group: String?,
|
||||
color: String?,
|
||||
color: String?
|
||||
): Flow<List<Mount>>
|
||||
|
||||
fun getPets(
|
||||
type: String?,
|
||||
group: String?,
|
||||
color: String?,
|
||||
color: String?
|
||||
): Flow<List<Pet>>
|
||||
|
||||
fun updateOwnedEquipment(user: User)
|
||||
|
|
@ -83,35 +83,35 @@ interface InventoryRepository : BaseRepository {
|
|||
suspend fun changeOwnedCount(
|
||||
type: String,
|
||||
key: String,
|
||||
amountToAdd: Int,
|
||||
amountToAdd: Int
|
||||
)
|
||||
|
||||
suspend fun sellItem(
|
||||
type: String,
|
||||
key: String,
|
||||
key: String
|
||||
): User?
|
||||
|
||||
suspend fun sellItem(item: OwnedItem): User?
|
||||
|
||||
suspend fun equipGear(
|
||||
equipment: String,
|
||||
asCostume: Boolean,
|
||||
asCostume: Boolean
|
||||
): Items?
|
||||
|
||||
suspend fun equip(
|
||||
type: String,
|
||||
key: String,
|
||||
key: String
|
||||
): Items?
|
||||
|
||||
suspend fun feedPet(
|
||||
pet: Pet,
|
||||
food: Food,
|
||||
food: Food
|
||||
): FeedResponse?
|
||||
|
||||
suspend fun hatchPet(
|
||||
egg: Egg,
|
||||
hatchingPotion: HatchingPotion,
|
||||
successFunction: () -> Unit,
|
||||
successFunction: () -> Unit
|
||||
): Items?
|
||||
|
||||
suspend fun inviteToQuest(quest: QuestContent): Quest?
|
||||
|
|
@ -120,7 +120,7 @@ interface InventoryRepository : BaseRepository {
|
|||
user: User?,
|
||||
id: String,
|
||||
value: Double,
|
||||
purchaseQuantity: Int,
|
||||
purchaseQuantity: Int
|
||||
): BuyResponse?
|
||||
|
||||
suspend fun retrieveShopInventory(identifier: String): Shop?
|
||||
|
|
@ -131,7 +131,7 @@ interface InventoryRepository : BaseRepository {
|
|||
|
||||
suspend fun purchaseHourglassItem(
|
||||
purchaseType: String,
|
||||
key: String,
|
||||
key: String
|
||||
): Void?
|
||||
|
||||
suspend fun purchaseQuest(key: String): Void?
|
||||
|
|
@ -141,14 +141,14 @@ interface InventoryRepository : BaseRepository {
|
|||
suspend fun purchaseItem(
|
||||
purchaseType: String,
|
||||
key: String,
|
||||
purchaseQuantity: Int,
|
||||
purchaseQuantity: Int
|
||||
): Void?
|
||||
|
||||
suspend fun togglePinnedItem(item: ShopItem): List<ShopItem>?
|
||||
|
||||
fun getItems(
|
||||
itemClass: Class<out Item>,
|
||||
keys: Array<String>,
|
||||
keys: Array<String>
|
||||
): Flow<List<Item>>
|
||||
|
||||
fun getItems(itemClass: Class<out Item>): Flow<List<Item>>
|
||||
|
|
@ -158,7 +158,7 @@ interface InventoryRepository : BaseRepository {
|
|||
|
||||
fun getItem(
|
||||
type: String,
|
||||
key: String,
|
||||
key: String
|
||||
): Flow<Item>
|
||||
|
||||
fun getAvailableLimitedItems(): Flow<List<Item>>
|
||||
|
|
|
|||
|
|
@ -6,13 +6,13 @@ import com.habitrpg.android.habitica.models.user.User
|
|||
interface SetupCustomizationRepository {
|
||||
fun getCustomizations(
|
||||
type: String,
|
||||
user: User,
|
||||
user: User
|
||||
): List<SetupCustomization>
|
||||
|
||||
fun getCustomizations(
|
||||
type: String,
|
||||
subtype: String?,
|
||||
user: User,
|
||||
user: User
|
||||
): List<SetupCustomization>
|
||||
|
||||
companion object {
|
||||
|
|
|
|||
|
|
@ -26,12 +26,12 @@ interface SocialRepository : BaseRepository {
|
|||
suspend fun flagMessage(
|
||||
chatMessageID: String,
|
||||
additionalInfo: String,
|
||||
groupID: String? = null,
|
||||
groupID: String? = null
|
||||
): Void?
|
||||
|
||||
suspend fun reportMember(
|
||||
memberID: String,
|
||||
data: Map<String, String>,
|
||||
data: Map<String, String>
|
||||
): Void?
|
||||
|
||||
suspend fun likeMessage(chatMessage: ChatMessage): ChatMessage?
|
||||
|
|
@ -40,12 +40,12 @@ interface SocialRepository : BaseRepository {
|
|||
|
||||
suspend fun postGroupChat(
|
||||
groupId: String,
|
||||
messageObject: HashMap<String, String>,
|
||||
messageObject: HashMap<String, String>
|
||||
): PostChatMessageResult?
|
||||
|
||||
suspend fun postGroupChat(
|
||||
groupId: String,
|
||||
message: String,
|
||||
message: String
|
||||
): PostChatMessageResult?
|
||||
|
||||
suspend fun retrieveGroup(id: String): Group?
|
||||
|
|
@ -54,7 +54,7 @@ interface SocialRepository : BaseRepository {
|
|||
|
||||
suspend fun leaveGroup(
|
||||
id: String?,
|
||||
keepChallenges: Boolean,
|
||||
keepChallenges: Boolean
|
||||
): Group?
|
||||
|
||||
suspend fun joinGroup(id: String?): Group?
|
||||
|
|
@ -65,7 +65,7 @@ interface SocialRepository : BaseRepository {
|
|||
leader: String?,
|
||||
type: String?,
|
||||
privacy: String?,
|
||||
leaderCreateChallenge: Boolean?,
|
||||
leaderCreateChallenge: Boolean?
|
||||
): Group?
|
||||
|
||||
suspend fun updateGroup(
|
||||
|
|
@ -73,14 +73,14 @@ interface SocialRepository : BaseRepository {
|
|||
name: String?,
|
||||
description: String?,
|
||||
leader: String?,
|
||||
leaderCreateChallenge: Boolean?,
|
||||
leaderCreateChallenge: Boolean?
|
||||
): Group?
|
||||
|
||||
fun getInboxMessages(replyToUserID: String?): Flow<RealmResults<ChatMessage>>
|
||||
|
||||
suspend fun retrieveInboxMessages(
|
||||
uuid: String,
|
||||
page: Int,
|
||||
page: Int
|
||||
): List<ChatMessage>?
|
||||
|
||||
suspend fun retrieveInboxConversations(): List<InboxConversation>?
|
||||
|
|
@ -89,12 +89,12 @@ interface SocialRepository : BaseRepository {
|
|||
|
||||
suspend fun postPrivateMessage(
|
||||
recipientId: String,
|
||||
messageObject: HashMap<String, String>,
|
||||
messageObject: HashMap<String, String>
|
||||
): List<ChatMessage>?
|
||||
|
||||
suspend fun postPrivateMessage(
|
||||
recipientId: String,
|
||||
message: String,
|
||||
message: String
|
||||
): List<ChatMessage>?
|
||||
|
||||
suspend fun getPartyMembers(id: String): Flow<List<Member>>
|
||||
|
|
@ -103,50 +103,50 @@ interface SocialRepository : BaseRepository {
|
|||
|
||||
suspend fun retrievePartyMembers(
|
||||
id: String,
|
||||
includeAllPublicFields: Boolean,
|
||||
includeAllPublicFields: Boolean
|
||||
): List<Member>?
|
||||
|
||||
suspend fun inviteToGroup(
|
||||
id: String,
|
||||
inviteData: Map<String, Any>,
|
||||
inviteData: Map<String, Any>
|
||||
): List<InviteResponse>?
|
||||
|
||||
suspend fun retrieveMember(
|
||||
userId: String?,
|
||||
fromHall: Boolean = false,
|
||||
fromHall: Boolean = false
|
||||
): Member?
|
||||
|
||||
suspend fun findUsernames(
|
||||
username: String,
|
||||
context: String? = null,
|
||||
id: String? = null,
|
||||
id: String? = null
|
||||
): List<FindUsernameResult>?
|
||||
|
||||
suspend fun markPrivateMessagesRead(user: User?)
|
||||
|
||||
fun markSomePrivateMessagesAsRead(
|
||||
user: User?,
|
||||
messages: List<ChatMessage>,
|
||||
messages: List<ChatMessage>
|
||||
)
|
||||
|
||||
suspend fun transferGroupOwnership(
|
||||
groupID: String,
|
||||
userID: String,
|
||||
userID: String
|
||||
): Group?
|
||||
|
||||
suspend fun removeMemberFromGroup(
|
||||
groupID: String,
|
||||
userID: String,
|
||||
userID: String
|
||||
): List<Member>?
|
||||
|
||||
suspend fun acceptQuest(
|
||||
user: User?,
|
||||
partyId: String = "party",
|
||||
partyId: String = "party"
|
||||
): Void?
|
||||
|
||||
suspend fun rejectQuest(
|
||||
user: User?,
|
||||
partyId: String = "party",
|
||||
partyId: String = "party"
|
||||
): Void?
|
||||
|
||||
suspend fun leaveQuest(partyId: String): Void?
|
||||
|
|
@ -163,7 +163,7 @@ interface SocialRepository : BaseRepository {
|
|||
|
||||
suspend fun transferGems(
|
||||
giftedID: String,
|
||||
amount: Int,
|
||||
amount: Int
|
||||
): Void?
|
||||
|
||||
fun getGroupMembership(id: String): Flow<GroupMembership?>
|
||||
|
|
@ -176,13 +176,13 @@ interface SocialRepository : BaseRepository {
|
|||
|
||||
suspend fun updateMember(
|
||||
memberID: String,
|
||||
data: Map<String, Map<String, Boolean>>,
|
||||
data: Map<String, Map<String, Boolean>>
|
||||
): Member?
|
||||
|
||||
suspend fun retrievePartySeekingUsers(page: Int = 0): List<Member>?
|
||||
|
||||
suspend fun retrievegroupInvites(
|
||||
id: String,
|
||||
includeAllPublicFields: Boolean,
|
||||
includeAllPublicFields: Boolean
|
||||
): List<Member>?
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,24 +15,24 @@ interface TaskRepository : BaseRepository {
|
|||
fun getTasks(
|
||||
taskType: TaskType,
|
||||
userID: String? = null,
|
||||
includedGroupIDs: Array<String>,
|
||||
includedGroupIDs: Array<String>
|
||||
): Flow<List<Task>>
|
||||
|
||||
fun saveTasks(
|
||||
userId: String,
|
||||
order: TasksOrder,
|
||||
tasks: TaskList,
|
||||
tasks: TaskList
|
||||
)
|
||||
|
||||
suspend fun retrieveTasks(
|
||||
userId: String,
|
||||
tasksOrder: TasksOrder,
|
||||
tasksOrder: TasksOrder
|
||||
): TaskList?
|
||||
|
||||
suspend fun retrieveTasks(
|
||||
userId: String,
|
||||
tasksOrder: TasksOrder,
|
||||
dueDate: Date,
|
||||
dueDate: Date
|
||||
): TaskList?
|
||||
|
||||
suspend fun taskChecked(
|
||||
|
|
@ -40,7 +40,7 @@ interface TaskRepository : BaseRepository {
|
|||
task: Task,
|
||||
up: Boolean,
|
||||
force: Boolean,
|
||||
notifyFunc: ((TaskScoringResult) -> Unit)?,
|
||||
notifyFunc: ((TaskScoringResult) -> Unit)?
|
||||
): TaskScoringResult?
|
||||
|
||||
suspend fun taskChecked(
|
||||
|
|
@ -48,12 +48,12 @@ interface TaskRepository : BaseRepository {
|
|||
taskId: String,
|
||||
up: Boolean,
|
||||
force: Boolean,
|
||||
notifyFunc: ((TaskScoringResult) -> Unit)?,
|
||||
notifyFunc: ((TaskScoringResult) -> Unit)?
|
||||
): TaskScoringResult?
|
||||
|
||||
suspend fun scoreChecklistItem(
|
||||
taskId: String,
|
||||
itemId: String,
|
||||
itemId: String
|
||||
): Task?
|
||||
|
||||
fun getTask(taskId: String): Flow<Task>
|
||||
|
|
@ -62,12 +62,12 @@ interface TaskRepository : BaseRepository {
|
|||
|
||||
suspend fun createTask(
|
||||
task: Task,
|
||||
force: Boolean = false,
|
||||
force: Boolean = false
|
||||
): Task?
|
||||
|
||||
suspend fun updateTask(
|
||||
task: Task,
|
||||
force: Boolean = false,
|
||||
force: Boolean = false
|
||||
): Task?
|
||||
|
||||
suspend fun deleteTask(taskId: String): Void?
|
||||
|
|
@ -78,35 +78,35 @@ interface TaskRepository : BaseRepository {
|
|||
|
||||
fun markTaskCompleted(
|
||||
taskId: String,
|
||||
isCompleted: Boolean,
|
||||
isCompleted: Boolean
|
||||
)
|
||||
|
||||
fun <T : BaseMainObject> modify(
|
||||
obj: T,
|
||||
transaction: (T) -> Unit,
|
||||
transaction: (T) -> Unit
|
||||
)
|
||||
|
||||
fun swapTaskPosition(
|
||||
firstPosition: Int,
|
||||
secondPosition: Int,
|
||||
secondPosition: Int
|
||||
)
|
||||
|
||||
suspend fun updateTaskPosition(
|
||||
taskType: TaskType,
|
||||
taskID: String,
|
||||
newPosition: Int,
|
||||
newPosition: Int
|
||||
): List<String>?
|
||||
|
||||
fun getUnmanagedTask(taskid: String): Flow<Task>
|
||||
|
||||
fun updateTaskInBackground(
|
||||
task: Task,
|
||||
assignChanges: Map<String, MutableList<String>>,
|
||||
assignChanges: Map<String, MutableList<String>>
|
||||
)
|
||||
|
||||
fun createTaskInBackground(
|
||||
task: Task,
|
||||
assignChanges: Map<String, MutableList<String>>,
|
||||
assignChanges: Map<String, MutableList<String>>
|
||||
)
|
||||
|
||||
fun getTaskCopies(): Flow<List<Task>>
|
||||
|
|
@ -121,7 +121,7 @@ interface TaskRepository : BaseRepository {
|
|||
|
||||
suspend fun unlinkAllTasks(
|
||||
challengeID: String?,
|
||||
keepOption: String,
|
||||
keepOption: String
|
||||
): Void?
|
||||
|
||||
fun getTasksForChallenge(challengeID: String?): Flow<List<Task>>
|
||||
|
|
@ -130,6 +130,6 @@ interface TaskRepository : BaseRepository {
|
|||
|
||||
suspend fun markTaskNeedsWork(
|
||||
task: Task,
|
||||
userID: String,
|
||||
userID: String
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,13 +27,13 @@ interface UserRepository : BaseRepository {
|
|||
|
||||
suspend fun updateUser(
|
||||
key: String,
|
||||
value: Any?,
|
||||
value: Any?
|
||||
): User?
|
||||
|
||||
suspend fun retrieveUser(
|
||||
withTasks: Boolean = false,
|
||||
forced: Boolean = false,
|
||||
overrideExisting: Boolean = false,
|
||||
overrideExisting: Boolean = false
|
||||
): User?
|
||||
|
||||
suspend fun revive(): Equipment?
|
||||
|
|
@ -49,12 +49,12 @@ interface UserRepository : BaseRepository {
|
|||
suspend fun useSkill(
|
||||
key: String,
|
||||
target: String?,
|
||||
taskId: String,
|
||||
taskId: String
|
||||
): SkillResponse?
|
||||
|
||||
suspend fun useSkill(
|
||||
key: String,
|
||||
target: String?,
|
||||
target: String?
|
||||
): SkillResponse?
|
||||
|
||||
suspend fun disableClasses(): User?
|
||||
|
|
@ -63,7 +63,7 @@ interface UserRepository : BaseRepository {
|
|||
|
||||
suspend fun unlockPath(
|
||||
path: String,
|
||||
price: Int,
|
||||
price: Int
|
||||
): UnlockResponse?
|
||||
|
||||
suspend fun unlockPath(customization: Customization): UnlockResponse?
|
||||
|
|
@ -94,18 +94,18 @@ interface UserRepository : BaseRepository {
|
|||
|
||||
suspend fun updateLoginName(
|
||||
newLoginName: String,
|
||||
password: String? = null,
|
||||
password: String? = null
|
||||
): User?
|
||||
|
||||
suspend fun updateEmail(
|
||||
newEmail: String,
|
||||
password: String,
|
||||
password: String
|
||||
): Void?
|
||||
|
||||
suspend fun updatePassword(
|
||||
oldPassword: String,
|
||||
newPassword: String,
|
||||
newPasswordConfirmation: String,
|
||||
newPasswordConfirmation: String
|
||||
): Void?
|
||||
|
||||
suspend fun verifyUsername(username: String): VerifyUsernameResponse?
|
||||
|
|
@ -116,13 +116,13 @@ interface UserRepository : BaseRepository {
|
|||
strength: Int,
|
||||
intelligence: Int,
|
||||
constitution: Int,
|
||||
perception: Int,
|
||||
perception: Int
|
||||
): Stats?
|
||||
|
||||
suspend fun useCustomization(
|
||||
type: String,
|
||||
category: String?,
|
||||
identifier: String,
|
||||
identifier: String
|
||||
): User?
|
||||
|
||||
suspend fun retrieveAchievements(): List<Achievement>?
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ class ApiClientImpl(
|
|||
private val converter: Converter.Factory,
|
||||
override val hostConfig: HostConfig,
|
||||
private val notificationsManager: NotificationsManager,
|
||||
private val context: Context,
|
||||
private val context: Context
|
||||
) : ApiClient {
|
||||
private lateinit var retrofitAdapter: Retrofit
|
||||
|
||||
|
|
@ -115,7 +115,7 @@ class ApiClientImpl(
|
|||
val timezoneOffset =
|
||||
-TimeUnit.MINUTES.convert(
|
||||
timeZone.getOffset(calendar.timeInMillis).toLong(),
|
||||
TimeUnit.MILLISECONDS,
|
||||
TimeUnit.MILLISECONDS
|
||||
)
|
||||
|
||||
val cacheSize: Long = 10 * 1024 * 1024 // 10 MB
|
||||
|
|
@ -199,7 +199,7 @@ class ApiClientImpl(
|
|||
username: String,
|
||||
email: String,
|
||||
password: String,
|
||||
confirmPassword: String,
|
||||
confirmPassword: String
|
||||
): UserAuthResponse? {
|
||||
val auth = UserAuth()
|
||||
auth.username = username
|
||||
|
|
@ -211,7 +211,7 @@ class ApiClientImpl(
|
|||
|
||||
override suspend fun connectUser(
|
||||
username: String,
|
||||
password: String,
|
||||
password: String
|
||||
): UserAuthResponse? {
|
||||
val auth = UserAuth()
|
||||
auth.username = username
|
||||
|
|
@ -222,7 +222,7 @@ class ApiClientImpl(
|
|||
override suspend fun connectSocial(
|
||||
network: String,
|
||||
userId: String,
|
||||
accessToken: String,
|
||||
accessToken: String
|
||||
): UserAuthResponse? {
|
||||
val auth = UserAuthSocial()
|
||||
auth.network = network
|
||||
|
|
@ -257,7 +257,7 @@ class ApiClientImpl(
|
|||
} else if (throwableClass == SocketTimeoutException::class.java || UnknownHostException::class.java == throwableClass || IOException::class.java == throwableClass) {
|
||||
this.showConnectionProblemDialog(
|
||||
R.string.network_error_no_network_body,
|
||||
isUserInputCall,
|
||||
isUserInputCall
|
||||
)
|
||||
} else if (HttpException::class.java.isAssignableFrom(throwable.javaClass)) {
|
||||
val error = throwable as HttpException
|
||||
|
|
@ -286,7 +286,7 @@ class ApiClientImpl(
|
|||
showConnectionProblemDialog(
|
||||
R.string.authentication_error_title,
|
||||
R.string.authentication_error_body,
|
||||
isUserInputCall,
|
||||
isUserInputCall
|
||||
)
|
||||
}
|
||||
} else if (status in 500..599) {
|
||||
|
|
@ -303,7 +303,7 @@ class ApiClientImpl(
|
|||
|
||||
override suspend fun updateMember(
|
||||
memberID: String,
|
||||
updateData: Map<String, Map<String, Boolean>>,
|
||||
updateData: Map<String, Map<String, Boolean>>
|
||||
): Member? {
|
||||
return process { apiService.updateUser(memberID, updateData) }
|
||||
}
|
||||
|
|
@ -333,7 +333,7 @@ class ApiClientImpl(
|
|||
|
||||
override suspend fun retrieveInboxMessages(
|
||||
uuid: String,
|
||||
page: Int,
|
||||
page: Int
|
||||
): List<ChatMessage>? {
|
||||
return process { apiService.getInboxMessages(uuid, page) }
|
||||
}
|
||||
|
|
@ -348,7 +348,7 @@ class ApiClientImpl(
|
|||
|
||||
private fun showConnectionProblemDialog(
|
||||
resourceMessageString: Int,
|
||||
isFromUserInput: Boolean,
|
||||
isFromUserInput: Boolean
|
||||
) {
|
||||
showConnectionProblemDialog(null, context.getString(resourceMessageString), isFromUserInput)
|
||||
}
|
||||
|
|
@ -356,12 +356,12 @@ class ApiClientImpl(
|
|||
private fun showConnectionProblemDialog(
|
||||
resourceTitleString: Int,
|
||||
resourceMessageString: Int,
|
||||
isFromUserInput: Boolean,
|
||||
isFromUserInput: Boolean
|
||||
) {
|
||||
showConnectionProblemDialog(
|
||||
context.getString(resourceTitleString),
|
||||
context.getString(resourceMessageString),
|
||||
isFromUserInput,
|
||||
isFromUserInput
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -370,7 +370,7 @@ class ApiClientImpl(
|
|||
private fun showConnectionProblemDialog(
|
||||
resourceTitleString: String?,
|
||||
resourceMessageString: String,
|
||||
isFromUserInput: Boolean,
|
||||
isFromUserInput: Boolean
|
||||
) {
|
||||
erroredRequestCount += 1
|
||||
val application =
|
||||
|
|
@ -381,7 +381,7 @@ class ApiClientImpl(
|
|||
erroredRequestCount,
|
||||
resourceTitleString,
|
||||
resourceMessageString,
|
||||
isFromUserInput,
|
||||
isFromUserInput
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -402,7 +402,7 @@ class ApiClientImpl(
|
|||
|
||||
override fun updateAuthenticationCredentials(
|
||||
userID: String?,
|
||||
apiToken: String?,
|
||||
apiToken: String?
|
||||
) {
|
||||
this.hostConfig.userID = userID ?: ""
|
||||
this.hostConfig.apiKey = apiToken ?: ""
|
||||
|
|
@ -415,7 +415,7 @@ class ApiClientImpl(
|
|||
|
||||
override suspend fun reportChallenge(
|
||||
challengeid: String,
|
||||
updateData: Map<String, String>,
|
||||
updateData: Map<String, String>
|
||||
): Void? {
|
||||
return process { apiService.reportChallenge(challengeid, updateData) }
|
||||
}
|
||||
|
|
@ -438,21 +438,21 @@ class ApiClientImpl(
|
|||
|
||||
override suspend fun equipItem(
|
||||
type: String,
|
||||
itemKey: String,
|
||||
itemKey: String
|
||||
): Items? {
|
||||
return process { apiService.equipItem(type, itemKey) }
|
||||
}
|
||||
|
||||
override suspend fun buyItem(
|
||||
itemKey: String,
|
||||
purchaseQuantity: Int,
|
||||
purchaseQuantity: Int
|
||||
): BuyResponse? {
|
||||
return process { apiService.buyItem(itemKey, mapOf(Pair("quantity", purchaseQuantity))) }
|
||||
}
|
||||
|
||||
override suspend fun unlinkAllTasks(
|
||||
challengeID: String?,
|
||||
keepOption: String,
|
||||
keepOption: String
|
||||
): Void? {
|
||||
return process { apiService.unlinkAllTasks(challengeID, keepOption) }
|
||||
}
|
||||
|
|
@ -464,13 +464,13 @@ class ApiClientImpl(
|
|||
override suspend fun purchaseItem(
|
||||
type: String,
|
||||
itemKey: String,
|
||||
purchaseQuantity: Int,
|
||||
purchaseQuantity: Int
|
||||
): Void? {
|
||||
return process {
|
||||
apiService.purchaseItem(
|
||||
type,
|
||||
itemKey,
|
||||
mapOf(Pair("quantity", purchaseQuantity)),
|
||||
mapOf(Pair("quantity", purchaseQuantity))
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -499,7 +499,7 @@ class ApiClientImpl(
|
|||
|
||||
override suspend fun purchaseHourglassItem(
|
||||
type: String,
|
||||
itemKey: String,
|
||||
itemKey: String
|
||||
): Void? {
|
||||
return process { apiService.purchaseHourglassItem(type, itemKey) }
|
||||
}
|
||||
|
|
@ -518,14 +518,14 @@ class ApiClientImpl(
|
|||
|
||||
override suspend fun sellItem(
|
||||
itemType: String,
|
||||
itemKey: String,
|
||||
itemKey: String
|
||||
): User? {
|
||||
return process { apiService.sellItem(itemType, itemKey) }
|
||||
}
|
||||
|
||||
override suspend fun feedPet(
|
||||
petKey: String,
|
||||
foodKey: String,
|
||||
foodKey: String
|
||||
): FeedResponse? {
|
||||
val response = apiService.feedPet(petKey, foodKey)
|
||||
response.data?.message = response.message
|
||||
|
|
@ -534,7 +534,7 @@ class ApiClientImpl(
|
|||
|
||||
override suspend fun hatchPet(
|
||||
eggKey: String,
|
||||
hatchingPotionKey: String,
|
||||
hatchingPotionKey: String
|
||||
): Items? {
|
||||
return process { apiService.hatchPet(eggKey, hatchingPotionKey) }
|
||||
}
|
||||
|
|
@ -547,7 +547,7 @@ class ApiClientImpl(
|
|||
|
||||
override suspend fun getTasks(
|
||||
type: String,
|
||||
dueDate: String,
|
||||
dueDate: String
|
||||
): TaskList? {
|
||||
return process { apiService.getTasks(type, dueDate) }
|
||||
}
|
||||
|
|
@ -566,7 +566,7 @@ class ApiClientImpl(
|
|||
|
||||
override suspend fun postTaskDirection(
|
||||
id: String,
|
||||
direction: String,
|
||||
direction: String
|
||||
): TaskDirectionData? {
|
||||
return process { apiService.postTaskDirection(id, direction) }
|
||||
}
|
||||
|
|
@ -577,14 +577,14 @@ class ApiClientImpl(
|
|||
|
||||
override suspend fun postTaskNewPosition(
|
||||
id: String,
|
||||
position: Int,
|
||||
position: Int
|
||||
): List<String>? {
|
||||
return process { apiService.postTaskNewPosition(id, position) }
|
||||
}
|
||||
|
||||
override suspend fun scoreChecklistItem(
|
||||
taskId: String,
|
||||
itemId: String,
|
||||
itemId: String
|
||||
): Task? {
|
||||
return process { apiService.scoreChecklistItem(taskId, itemId) }
|
||||
}
|
||||
|
|
@ -595,7 +595,7 @@ class ApiClientImpl(
|
|||
|
||||
override suspend fun createGroupTask(
|
||||
groupId: String,
|
||||
item: Task,
|
||||
item: Task
|
||||
): Task? {
|
||||
return process { apiService.createGroupTask(groupId, item) }
|
||||
}
|
||||
|
|
@ -606,7 +606,7 @@ class ApiClientImpl(
|
|||
|
||||
override suspend fun updateTask(
|
||||
id: String,
|
||||
item: Task,
|
||||
item: Task
|
||||
): Task? {
|
||||
return process { apiService.updateTask(id, item) }
|
||||
}
|
||||
|
|
@ -621,7 +621,7 @@ class ApiClientImpl(
|
|||
|
||||
override suspend fun updateTag(
|
||||
id: String,
|
||||
tag: Tag,
|
||||
tag: Tag
|
||||
): Tag? {
|
||||
return process { apiService.updateTag(id, tag) }
|
||||
}
|
||||
|
|
@ -637,14 +637,14 @@ class ApiClientImpl(
|
|||
override suspend fun useSkill(
|
||||
skillName: String,
|
||||
targetType: String,
|
||||
targetId: String,
|
||||
targetId: String
|
||||
): SkillResponse? {
|
||||
return process { apiService.useSkill(skillName, targetType, targetId) }
|
||||
}
|
||||
|
||||
override suspend fun useSkill(
|
||||
skillName: String,
|
||||
targetType: String,
|
||||
targetType: String
|
||||
): SkillResponse? {
|
||||
return process { apiService.useSkill(skillName, targetType) }
|
||||
}
|
||||
|
|
@ -679,14 +679,14 @@ class ApiClientImpl(
|
|||
|
||||
override suspend fun updateGroup(
|
||||
id: String,
|
||||
item: Group,
|
||||
item: Group
|
||||
): Group? {
|
||||
return processResponse(apiService.updateGroup(id, item))
|
||||
}
|
||||
|
||||
override suspend fun removeMemberFromGroup(
|
||||
groupID: String,
|
||||
userID: String,
|
||||
userID: String
|
||||
): Void? {
|
||||
return processResponse(apiService.removeMemberFromGroup(groupID, userID))
|
||||
}
|
||||
|
|
@ -701,21 +701,21 @@ class ApiClientImpl(
|
|||
|
||||
override suspend fun leaveGroup(
|
||||
groupId: String,
|
||||
keepChallenges: String,
|
||||
keepChallenges: String
|
||||
): Void? {
|
||||
return processResponse(apiService.leaveGroup(groupId, keepChallenges))
|
||||
}
|
||||
|
||||
override suspend fun postGroupChat(
|
||||
groupId: String,
|
||||
message: Map<String, String>,
|
||||
message: Map<String, String>
|
||||
): PostChatMessageResult? {
|
||||
return process { apiService.postGroupChat(groupId, message) }
|
||||
}
|
||||
|
||||
override suspend fun deleteMessage(
|
||||
groupId: String,
|
||||
messageId: String,
|
||||
messageId: String
|
||||
): Void? {
|
||||
return process { apiService.deleteMessage(groupId, messageId) }
|
||||
}
|
||||
|
|
@ -726,7 +726,7 @@ class ApiClientImpl(
|
|||
|
||||
override suspend fun getGroupMembers(
|
||||
groupId: String,
|
||||
includeAllPublicFields: Boolean?,
|
||||
includeAllPublicFields: Boolean?
|
||||
): List<Member>? {
|
||||
return processResponse(apiService.getGroupMembers(groupId, includeAllPublicFields))
|
||||
}
|
||||
|
|
@ -734,21 +734,21 @@ class ApiClientImpl(
|
|||
override suspend fun getGroupMembers(
|
||||
groupId: String,
|
||||
includeAllPublicFields: Boolean?,
|
||||
lastId: String,
|
||||
lastId: String
|
||||
): List<Member>? {
|
||||
return processResponse(apiService.getGroupMembers(groupId, includeAllPublicFields, lastId))
|
||||
}
|
||||
|
||||
override suspend fun likeMessage(
|
||||
groupId: String,
|
||||
mid: String,
|
||||
mid: String
|
||||
): ChatMessage? {
|
||||
return process { apiService.likeMessage(groupId, mid) }
|
||||
}
|
||||
|
||||
override suspend fun reportMember(
|
||||
mid: String,
|
||||
data: Map<String, String>,
|
||||
data: Map<String, String>
|
||||
): Void? {
|
||||
return process { apiService.reportMember(mid, data) }
|
||||
}
|
||||
|
|
@ -756,14 +756,14 @@ class ApiClientImpl(
|
|||
override suspend fun flagMessage(
|
||||
groupId: String,
|
||||
mid: String,
|
||||
data: MutableMap<String, String>,
|
||||
data: MutableMap<String, String>
|
||||
): Void? {
|
||||
return process { apiService.flagMessage(groupId, mid, data) }
|
||||
}
|
||||
|
||||
override suspend fun flagInboxMessage(
|
||||
mid: String,
|
||||
data: MutableMap<String, String>,
|
||||
data: MutableMap<String, String>
|
||||
): Void? {
|
||||
return process { apiService.flagInboxMessage(mid, data) }
|
||||
}
|
||||
|
|
@ -774,7 +774,7 @@ class ApiClientImpl(
|
|||
|
||||
override suspend fun inviteToGroup(
|
||||
groupId: String,
|
||||
inviteData: Map<String, Any>,
|
||||
inviteData: Map<String, Any>
|
||||
): List<InviteResponse>? {
|
||||
return process { apiService.inviteToGroup(groupId, inviteData) }
|
||||
}
|
||||
|
|
@ -785,7 +785,7 @@ class ApiClientImpl(
|
|||
|
||||
override suspend fun getGroupInvites(
|
||||
groupId: String,
|
||||
includeAllPublicFields: Boolean?,
|
||||
includeAllPublicFields: Boolean?
|
||||
): List<Member>? {
|
||||
return process { apiService.getGroupInvites(groupId, includeAllPublicFields) }
|
||||
}
|
||||
|
|
@ -804,14 +804,14 @@ class ApiClientImpl(
|
|||
|
||||
override suspend fun forceStartQuest(
|
||||
groupId: String,
|
||||
group: Group,
|
||||
group: Group
|
||||
): Quest? {
|
||||
return process { apiService.forceStartQuest(groupId, group) }
|
||||
}
|
||||
|
||||
override suspend fun inviteToQuest(
|
||||
groupId: String,
|
||||
questKey: String,
|
||||
questKey: String
|
||||
): Quest? {
|
||||
return process { apiService.inviteToQuest(groupId, questKey) }
|
||||
}
|
||||
|
|
@ -841,7 +841,7 @@ class ApiClientImpl(
|
|||
|
||||
override suspend fun markTaskNeedsWork(
|
||||
taskID: String,
|
||||
userID: String,
|
||||
userID: String
|
||||
): Task? {
|
||||
return process { apiService.markTaskNeedsWork(taskID, userID) }
|
||||
}
|
||||
|
|
@ -863,7 +863,7 @@ class ApiClientImpl(
|
|||
override suspend fun findUsernames(
|
||||
username: String,
|
||||
context: String?,
|
||||
id: String?,
|
||||
id: String?
|
||||
): List<FindUsernameResult>? {
|
||||
return process { apiService.findUsernames(username, context, id) }
|
||||
}
|
||||
|
|
@ -886,7 +886,7 @@ class ApiClientImpl(
|
|||
|
||||
override suspend fun getUserChallenges(
|
||||
page: Int,
|
||||
memberOnly: Boolean,
|
||||
memberOnly: Boolean
|
||||
): List<Challenge>? {
|
||||
return if (memberOnly) {
|
||||
process { apiService.getUserChallenges(page, memberOnly) }
|
||||
|
|
@ -909,7 +909,7 @@ class ApiClientImpl(
|
|||
|
||||
override suspend fun leaveChallenge(
|
||||
challengeId: String,
|
||||
body: LeaveChallengeBody,
|
||||
body: LeaveChallengeBody
|
||||
): Void? {
|
||||
return process { apiService.leaveChallenge(challengeId, body) }
|
||||
}
|
||||
|
|
@ -920,14 +920,14 @@ class ApiClientImpl(
|
|||
|
||||
override suspend fun createChallengeTasks(
|
||||
challengeId: String,
|
||||
tasks: List<Task>,
|
||||
tasks: List<Task>
|
||||
): List<Task>? {
|
||||
return process { apiService.createChallengeTasks(challengeId, tasks) }
|
||||
}
|
||||
|
||||
override suspend fun createChallengeTask(
|
||||
challengeId: String,
|
||||
task: Task,
|
||||
task: Task
|
||||
): Task? {
|
||||
return process { apiService.createChallengeTask(challengeId, task) }
|
||||
}
|
||||
|
|
@ -984,7 +984,7 @@ class ApiClientImpl(
|
|||
|
||||
override suspend fun togglePinnedItem(
|
||||
pinType: String,
|
||||
path: String,
|
||||
path: String
|
||||
): Void? {
|
||||
return process { apiService.togglePinnedItem(pinType, path) }
|
||||
}
|
||||
|
|
@ -997,7 +997,7 @@ class ApiClientImpl(
|
|||
|
||||
override suspend fun updateLoginName(
|
||||
newLoginName: String,
|
||||
password: String,
|
||||
password: String
|
||||
): Void? {
|
||||
val updateObject = HashMap<String, String>()
|
||||
updateObject["username"] = newLoginName
|
||||
|
|
@ -1019,7 +1019,7 @@ class ApiClientImpl(
|
|||
|
||||
override suspend fun updateEmail(
|
||||
newEmail: String,
|
||||
password: String,
|
||||
password: String
|
||||
): Void? {
|
||||
val updateObject = HashMap<String, String>()
|
||||
updateObject["newEmail"] = newEmail
|
||||
|
|
@ -1032,7 +1032,7 @@ class ApiClientImpl(
|
|||
override suspend fun updatePassword(
|
||||
oldPassword: String,
|
||||
newPassword: String,
|
||||
newPasswordConfirmation: String,
|
||||
newPasswordConfirmation: String
|
||||
): Void? {
|
||||
val updateObject = HashMap<String, String>()
|
||||
updateObject["password"] = oldPassword
|
||||
|
|
@ -1047,14 +1047,14 @@ class ApiClientImpl(
|
|||
|
||||
override suspend fun transferGems(
|
||||
giftedID: String,
|
||||
amount: Int,
|
||||
amount: Int
|
||||
): Void? {
|
||||
return process {
|
||||
apiService.transferGems(
|
||||
mapOf(
|
||||
Pair("toUserId", giftedID),
|
||||
Pair("gemAmount", amount),
|
||||
),
|
||||
Pair("gemAmount", amount)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -1069,14 +1069,14 @@ class ApiClientImpl(
|
|||
|
||||
override suspend fun assignToTask(
|
||||
taskId: String,
|
||||
ids: List<String>,
|
||||
ids: List<String>
|
||||
): Task? {
|
||||
return process { apiService.assignToTask(taskId, ids) }
|
||||
}
|
||||
|
||||
override suspend fun unassignFromTask(
|
||||
taskId: String,
|
||||
userID: String,
|
||||
userID: String
|
||||
): Task? {
|
||||
return process { apiService.unassignFromTask(taskId, userID) }
|
||||
}
|
||||
|
|
@ -1085,7 +1085,7 @@ class ApiClientImpl(
|
|||
strength: Int,
|
||||
intelligence: Int,
|
||||
constitution: Int,
|
||||
perception: Int,
|
||||
perception: Int
|
||||
): Stats? {
|
||||
val body = HashMap<String, Map<String, Int>>()
|
||||
val stats = HashMap<String, Int>()
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import com.habitrpg.android.habitica.modules.AuthenticationHandler
|
|||
abstract class BaseRepositoryImpl<T : BaseLocalRepository>(
|
||||
protected val localRepository: T,
|
||||
protected val apiClient: ApiClient,
|
||||
protected val authenticationHandler: AuthenticationHandler,
|
||||
protected val authenticationHandler: AuthenticationHandler
|
||||
) : BaseRepository {
|
||||
val currentUserID: String
|
||||
get() = authenticationHandler.currentUserID ?: ""
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ import kotlinx.coroutines.flow.Flow
|
|||
class ChallengeRepositoryImpl(
|
||||
localRepository: ChallengeLocalRepository,
|
||||
apiClient: ApiClient,
|
||||
authenticationHandler: AuthenticationHandler,
|
||||
authenticationHandler: AuthenticationHandler
|
||||
) : BaseRepositoryImpl<ChallengeLocalRepository>(localRepository, apiClient, authenticationHandler),
|
||||
ChallengeRepository {
|
||||
override fun isChallengeMember(challengeID: String): Flow<Boolean> {
|
||||
|
|
@ -25,7 +25,7 @@ class ChallengeRepositoryImpl(
|
|||
|
||||
override suspend fun reportChallenge(
|
||||
challengeid: String,
|
||||
updateData: Map<String, String>,
|
||||
updateData: Map<String, String>
|
||||
): Void? {
|
||||
return apiClient.reportChallenge(challengeid, updateData)
|
||||
}
|
||||
|
|
@ -85,18 +85,20 @@ class ChallengeRepositoryImpl(
|
|||
|
||||
private suspend fun addChallengeTasks(
|
||||
challenge: Challenge,
|
||||
addedTaskList: List<Task>,
|
||||
addedTaskList: List<Task>
|
||||
) {
|
||||
val savedTasks: List<Task>? = when {
|
||||
addedTaskList.count() == 1 ->
|
||||
listOf(apiClient.createChallengeTask(
|
||||
challenge.id ?: "",
|
||||
addedTaskList[0],
|
||||
)).filterNotNull()
|
||||
listOf(
|
||||
apiClient.createChallengeTask(
|
||||
challenge.id ?: "",
|
||||
addedTaskList[0]
|
||||
)
|
||||
).filterNotNull()
|
||||
else ->
|
||||
apiClient.createChallengeTasks(
|
||||
challenge.id ?: "",
|
||||
addedTaskList,
|
||||
addedTaskList
|
||||
)
|
||||
}
|
||||
if (savedTasks != null) {
|
||||
|
|
@ -109,7 +111,7 @@ class ChallengeRepositoryImpl(
|
|||
|
||||
override suspend fun createChallenge(
|
||||
challenge: Challenge,
|
||||
taskList: List<Task>,
|
||||
taskList: List<Task>
|
||||
): Challenge? {
|
||||
challenge.tasksOrder = getTaskOrders(taskList)
|
||||
|
||||
|
|
@ -125,7 +127,7 @@ class ChallengeRepositoryImpl(
|
|||
fullTaskList: List<Task>,
|
||||
addedTaskList: List<Task>,
|
||||
updatedTaskList: List<Task>,
|
||||
removedTaskList: List<String>,
|
||||
removedTaskList: List<String>
|
||||
): Challenge? {
|
||||
val savedTasks = updatedTaskList
|
||||
.map { localRepository.getUnmanagedCopy(it) }.mapNotNull { task ->
|
||||
|
|
@ -166,7 +168,7 @@ class ChallengeRepositoryImpl(
|
|||
|
||||
override suspend fun retrieveChallenges(
|
||||
page: Int,
|
||||
memberOnly: Boolean,
|
||||
memberOnly: Boolean
|
||||
): List<Challenge>? {
|
||||
val challenges = apiClient.getUserChallenges(page, memberOnly)
|
||||
if (challenges != null) {
|
||||
|
|
@ -177,7 +179,7 @@ class ChallengeRepositoryImpl(
|
|||
|
||||
override suspend fun leaveChallenge(
|
||||
challenge: Challenge,
|
||||
keepTasks: String,
|
||||
keepTasks: String
|
||||
): Void? {
|
||||
apiClient.leaveChallenge(challenge.id ?: "", LeaveChallengeBody(keepTasks))
|
||||
localRepository.setParticipating(currentUserID, challenge.id ?: "", false)
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ class ContentRepositoryImpl<T : ContentLocalRepository>(
|
|||
localRepository: T,
|
||||
apiClient: ApiClient,
|
||||
context: Context,
|
||||
authenticationHandler: AuthenticationHandler,
|
||||
authenticationHandler: AuthenticationHandler
|
||||
) : BaseRepositoryImpl<T>(localRepository, apiClient, authenticationHandler), ContentRepository {
|
||||
private val mysteryItem = SpecialItem.makeMysteryItem(context)
|
||||
|
||||
|
|
|
|||
|
|
@ -10,17 +10,17 @@ import kotlinx.coroutines.flow.Flow
|
|||
class CustomizationRepositoryImpl(
|
||||
localRepository: CustomizationLocalRepository,
|
||||
apiClient: ApiClient,
|
||||
authenticationHandler: AuthenticationHandler,
|
||||
authenticationHandler: AuthenticationHandler
|
||||
) : BaseRepositoryImpl<CustomizationLocalRepository>(
|
||||
localRepository,
|
||||
apiClient,
|
||||
authenticationHandler,
|
||||
),
|
||||
localRepository,
|
||||
apiClient,
|
||||
authenticationHandler
|
||||
),
|
||||
CustomizationRepository {
|
||||
override fun getCustomizations(
|
||||
type: String,
|
||||
category: String?,
|
||||
onlyAvailable: Boolean,
|
||||
onlyAvailable: Boolean
|
||||
): Flow<List<Customization>> {
|
||||
return localRepository.getCustomizations(type, category, onlyAvailable)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import kotlinx.coroutines.flow.Flow
|
|||
class FAQRepositoryImpl(
|
||||
localRepository: FAQLocalRepository,
|
||||
apiClient: ApiClient,
|
||||
authenticationHandler: AuthenticationHandler,
|
||||
authenticationHandler: AuthenticationHandler
|
||||
) : BaseRepositoryImpl<FAQLocalRepository>(localRepository, apiClient, authenticationHandler),
|
||||
FAQRepository {
|
||||
override fun getArticle(position: Int): Flow<FAQArticle> {
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ class InventoryRepositoryImpl(
|
|||
localRepository: InventoryLocalRepository,
|
||||
apiClient: ApiClient,
|
||||
authenticationHandler: AuthenticationHandler,
|
||||
var appConfigManager: AppConfigManager,
|
||||
var appConfigManager: AppConfigManager
|
||||
) : BaseRepositoryImpl<InventoryLocalRepository>(localRepository, apiClient, authenticationHandler),
|
||||
InventoryRepository {
|
||||
override fun getQuestContent(keys: List<String>) = localRepository.getQuestContent(keys)
|
||||
|
|
@ -76,20 +76,20 @@ class InventoryRepositoryImpl(
|
|||
|
||||
override fun getEquipmentType(
|
||||
type: String,
|
||||
set: String,
|
||||
set: String
|
||||
): Flow<List<Equipment>> {
|
||||
return localRepository.getEquipmentType(type, set)
|
||||
}
|
||||
|
||||
override fun getOwnedItems(
|
||||
itemType: String,
|
||||
includeZero: Boolean,
|
||||
includeZero: Boolean
|
||||
): Flow<List<OwnedItem>> {
|
||||
return authenticationHandler.userIDFlow.flatMapLatest {
|
||||
localRepository.getOwnedItems(
|
||||
itemType,
|
||||
it,
|
||||
includeZero,
|
||||
includeZero
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -98,14 +98,14 @@ class InventoryRepositoryImpl(
|
|||
return authenticationHandler.userIDFlow.flatMapLatest {
|
||||
localRepository.getOwnedItems(
|
||||
it,
|
||||
includeZero,
|
||||
includeZero
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getItems(
|
||||
itemClass: Class<out Item>,
|
||||
keys: Array<String>,
|
||||
keys: Array<String>
|
||||
): Flow<List<Item>> {
|
||||
return localRepository.getItems(itemClass, keys)
|
||||
}
|
||||
|
|
@ -140,7 +140,7 @@ class InventoryRepositoryImpl(
|
|||
override fun getMounts(
|
||||
type: String?,
|
||||
group: String?,
|
||||
color: String?,
|
||||
color: String?
|
||||
): Flow<List<Mount>> {
|
||||
return localRepository.getMounts(type, group, color)
|
||||
}
|
||||
|
|
@ -156,7 +156,7 @@ class InventoryRepositoryImpl(
|
|||
override fun getPets(
|
||||
type: String?,
|
||||
group: String?,
|
||||
color: String?,
|
||||
color: String?
|
||||
): Flow<List<Pet>> {
|
||||
return localRepository.getPets(type, group, color)
|
||||
}
|
||||
|
|
@ -172,14 +172,14 @@ class InventoryRepositoryImpl(
|
|||
override suspend fun changeOwnedCount(
|
||||
type: String,
|
||||
key: String,
|
||||
amountToAdd: Int,
|
||||
amountToAdd: Int
|
||||
) {
|
||||
localRepository.changeOwnedCount(type, key, currentUserID, amountToAdd)
|
||||
}
|
||||
|
||||
override suspend fun sellItem(
|
||||
type: String,
|
||||
key: String,
|
||||
key: String
|
||||
): User? {
|
||||
val item =
|
||||
localRepository.getOwnedItem(currentUserID, type, key, true).firstOrNull()
|
||||
|
|
@ -204,14 +204,14 @@ class InventoryRepositoryImpl(
|
|||
|
||||
override fun getItem(
|
||||
type: String,
|
||||
key: String,
|
||||
key: String
|
||||
): Flow<Item> {
|
||||
return localRepository.getItem(type, key)
|
||||
}
|
||||
|
||||
private suspend fun sellItem(
|
||||
item: Item,
|
||||
ownedItem: OwnedItem,
|
||||
ownedItem: OwnedItem
|
||||
): User? {
|
||||
localRepository.executeTransaction {
|
||||
val liveItem = localRepository.getLiveObject(ownedItem)
|
||||
|
|
@ -223,14 +223,14 @@ class InventoryRepositoryImpl(
|
|||
|
||||
override suspend fun equipGear(
|
||||
equipment: String,
|
||||
asCostume: Boolean,
|
||||
asCostume: Boolean
|
||||
): Items? {
|
||||
return equip(if (asCostume) "costume" else "equipped", equipment)
|
||||
}
|
||||
|
||||
override suspend fun equip(
|
||||
type: String,
|
||||
key: String,
|
||||
key: String
|
||||
): Items? {
|
||||
val liveUser = localRepository.getLiveUser(currentUserID)
|
||||
|
||||
|
|
@ -277,7 +277,7 @@ class InventoryRepositoryImpl(
|
|||
|
||||
override suspend fun feedPet(
|
||||
pet: Pet,
|
||||
food: Food,
|
||||
food: Food
|
||||
): FeedResponse? {
|
||||
val feedResponse = apiClient.feedPet(pet.key, food.key) ?: return null
|
||||
localRepository.feedPet(food.key, pet.key, feedResponse.value ?: 0, currentUserID)
|
||||
|
|
@ -287,7 +287,7 @@ class InventoryRepositoryImpl(
|
|||
override suspend fun hatchPet(
|
||||
egg: Egg,
|
||||
hatchingPotion: HatchingPotion,
|
||||
successFunction: () -> Unit,
|
||||
successFunction: () -> Unit
|
||||
): Items? {
|
||||
if (appConfigManager.enableLocalChanges()) {
|
||||
localRepository.hatchPet(egg.key, hatchingPotion.key, currentUserID)
|
||||
|
|
@ -311,7 +311,7 @@ class InventoryRepositoryImpl(
|
|||
user: User?,
|
||||
id: String,
|
||||
value: Double,
|
||||
purchaseQuantity: Int,
|
||||
purchaseQuantity: Int
|
||||
): BuyResponse? {
|
||||
val buyResponse = apiClient.buyItem(id, purchaseQuantity) ?: return null
|
||||
val foundUser = user ?: localRepository.getLiveUser(currentUserID) ?: return buyResponse
|
||||
|
|
@ -359,7 +359,7 @@ class InventoryRepositoryImpl(
|
|||
|
||||
override suspend fun purchaseHourglassItem(
|
||||
purchaseType: String,
|
||||
key: String,
|
||||
key: String
|
||||
): Void? {
|
||||
return apiClient.purchaseHourglassItem(purchaseType, key)
|
||||
}
|
||||
|
|
@ -375,7 +375,7 @@ class InventoryRepositoryImpl(
|
|||
override suspend fun purchaseItem(
|
||||
purchaseType: String,
|
||||
key: String,
|
||||
purchaseQuantity: Int,
|
||||
purchaseQuantity: Int
|
||||
): Void? {
|
||||
val response = apiClient.purchaseItem(purchaseType, key, purchaseQuantity)
|
||||
if (key == "gem") {
|
||||
|
|
|
|||
|
|
@ -9,204 +9,204 @@ import javax.inject.Inject
|
|||
|
||||
@Suppress("StringLiteralDuplication")
|
||||
class SetupCustomizationRepositoryImpl
|
||||
@Inject
|
||||
constructor(private val context: Context) : SetupCustomizationRepository {
|
||||
private val wheelchairs: List<SetupCustomization>
|
||||
get() =
|
||||
listOf(
|
||||
SetupCustomization.createWheelchair("none", 0),
|
||||
SetupCustomization.createWheelchair("black", R.drawable.creator_chair_black),
|
||||
SetupCustomization.createWheelchair("blue", R.drawable.creator_chair_blue),
|
||||
SetupCustomization.createWheelchair("green", R.drawable.creator_chair_green),
|
||||
SetupCustomization.createWheelchair("pink", R.drawable.creator_chair_pink),
|
||||
SetupCustomization.createWheelchair("red", R.drawable.creator_chair_red),
|
||||
SetupCustomization.createWheelchair("yellow", R.drawable.creator_chair_yellow),
|
||||
)
|
||||
|
||||
private val glasses: List<SetupCustomization>
|
||||
get() =
|
||||
listOf(
|
||||
SetupCustomization.createGlasses("", R.drawable.creator_blank_face),
|
||||
SetupCustomization.createGlasses(
|
||||
"eyewear_special_blackTopFrame",
|
||||
R.drawable.creator_eyewear_special_blacktopframe,
|
||||
),
|
||||
SetupCustomization.createGlasses(
|
||||
"eyewear_special_blueTopFrame",
|
||||
R.drawable.creator_eyewear_special_bluetopframe,
|
||||
),
|
||||
SetupCustomization.createGlasses(
|
||||
"eyewear_special_greenTopFrame",
|
||||
R.drawable.creator_eyewear_special_greentopframe,
|
||||
),
|
||||
SetupCustomization.createGlasses(
|
||||
"eyewear_special_pinkTopFrame",
|
||||
R.drawable.creator_eyewear_special_pinktopframe,
|
||||
),
|
||||
SetupCustomization.createGlasses(
|
||||
"eyewear_special_redTopFrame",
|
||||
R.drawable.creator_eyewear_special_redtopframe,
|
||||
),
|
||||
SetupCustomization.createGlasses(
|
||||
"eyewear_special_yellowTopFrame",
|
||||
R.drawable.creator_eyewear_special_yellowtopframe,
|
||||
),
|
||||
SetupCustomization.createGlasses(
|
||||
"eyewear_special_whiteTopFrame",
|
||||
R.drawable.creator_eyewear_special_whitetopframe,
|
||||
),
|
||||
)
|
||||
|
||||
private val flowers: List<SetupCustomization>
|
||||
get() =
|
||||
listOf(
|
||||
SetupCustomization.createFlower("0", R.drawable.creator_blank_face),
|
||||
SetupCustomization.createFlower("1", R.drawable.creator_hair_flower_1),
|
||||
SetupCustomization.createFlower("2", R.drawable.creator_hair_flower_2),
|
||||
SetupCustomization.createFlower("3", R.drawable.creator_hair_flower_3),
|
||||
SetupCustomization.createFlower("4", R.drawable.creator_hair_flower_4),
|
||||
SetupCustomization.createFlower("5", R.drawable.creator_hair_flower_5),
|
||||
SetupCustomization.createFlower("6", R.drawable.creator_hair_flower_6),
|
||||
)
|
||||
|
||||
private val hairColors: List<SetupCustomization>
|
||||
get() =
|
||||
listOf(
|
||||
SetupCustomization.createHairColor("white", R.color.hair_white),
|
||||
SetupCustomization.createHairColor("brown", R.color.hair_brown),
|
||||
SetupCustomization.createHairColor("blond", R.color.hair_blond),
|
||||
SetupCustomization.createHairColor("red", R.color.hair_red),
|
||||
SetupCustomization.createHairColor("black", R.color.hair_black),
|
||||
)
|
||||
|
||||
private val sizes: List<SetupCustomization>
|
||||
get() =
|
||||
listOf(
|
||||
SetupCustomization.createSize(
|
||||
"slim",
|
||||
R.drawable.creator_slim_shirt_black,
|
||||
context.getString(R.string.avatar_size_slim),
|
||||
),
|
||||
SetupCustomization.createSize(
|
||||
"broad",
|
||||
R.drawable.creator_broad_shirt_black,
|
||||
context.getString(R.string.avatar_size_broad),
|
||||
),
|
||||
)
|
||||
|
||||
private val skins: List<SetupCustomization>
|
||||
get() =
|
||||
listOf(
|
||||
SetupCustomization.createSkin("ddc994", R.color.skin_ddc994),
|
||||
SetupCustomization.createSkin("f5a76e", R.color.skin_f5a76e),
|
||||
SetupCustomization.createSkin("ea8349", R.color.skin_ea8349),
|
||||
SetupCustomization.createSkin("c06534", R.color.skin_c06534),
|
||||
SetupCustomization.createSkin("98461a", R.color.skin_98461a),
|
||||
SetupCustomization.createSkin("915533", R.color.skin_915533),
|
||||
SetupCustomization.createSkin("c3e1dc", R.color.skin_c3e1dc),
|
||||
SetupCustomization.createSkin("6bd049", R.color.skin_6bd049),
|
||||
)
|
||||
|
||||
override fun getCustomizations(
|
||||
type: String,
|
||||
user: User,
|
||||
): List<SetupCustomization> {
|
||||
return getCustomizations(type, null, user)
|
||||
}
|
||||
|
||||
override fun getCustomizations(
|
||||
type: String,
|
||||
subtype: String?,
|
||||
user: User,
|
||||
): List<SetupCustomization> {
|
||||
return when (type) {
|
||||
SetupCustomizationRepository.CATEGORY_BODY -> {
|
||||
when (subtype) {
|
||||
SetupCustomizationRepository.SUBCATEGORY_SIZE -> sizes
|
||||
SetupCustomizationRepository.SUBCATEGORY_SHIRT ->
|
||||
getShirts(
|
||||
user.preferences?.size ?: "slim",
|
||||
)
|
||||
|
||||
else -> emptyList()
|
||||
}
|
||||
}
|
||||
|
||||
SetupCustomizationRepository.CATEGORY_SKIN -> skins
|
||||
SetupCustomizationRepository.CATEGORY_HAIR -> {
|
||||
when (subtype) {
|
||||
SetupCustomizationRepository.SUBCATEGORY_BANGS ->
|
||||
getBangs(
|
||||
user.preferences?.hair?.color ?: "",
|
||||
)
|
||||
|
||||
SetupCustomizationRepository.SUBCATEGORY_PONYTAIL ->
|
||||
getHairBases(
|
||||
user.preferences?.hair?.color ?: "",
|
||||
)
|
||||
|
||||
SetupCustomizationRepository.SUBCATEGORY_COLOR -> hairColors
|
||||
else -> emptyList()
|
||||
}
|
||||
}
|
||||
|
||||
SetupCustomizationRepository.CATEGORY_EXTRAS -> {
|
||||
when (subtype) {
|
||||
SetupCustomizationRepository.SUBCATEGORY_FLOWER -> flowers
|
||||
SetupCustomizationRepository.SUBCATEGORY_GLASSES -> glasses
|
||||
SetupCustomizationRepository.SUBCATEGORY_WHEELCHAIR -> wheelchairs
|
||||
else -> emptyList()
|
||||
}
|
||||
}
|
||||
|
||||
else -> emptyList()
|
||||
}
|
||||
}
|
||||
|
||||
private fun getHairBases(color: String): List<SetupCustomization> {
|
||||
return listOf(
|
||||
SetupCustomization.createHairPonytail("0", R.drawable.creator_blank_face),
|
||||
SetupCustomization.createHairPonytail("1", getResId("creator_hair_base_1_$color")),
|
||||
SetupCustomization.createHairPonytail("3", getResId("creator_hair_base_3_$color")),
|
||||
@Inject
|
||||
constructor(private val context: Context) : SetupCustomizationRepository {
|
||||
private val wheelchairs: List<SetupCustomization>
|
||||
get() =
|
||||
listOf(
|
||||
SetupCustomization.createWheelchair("none", 0),
|
||||
SetupCustomization.createWheelchair("black", R.drawable.creator_chair_black),
|
||||
SetupCustomization.createWheelchair("blue", R.drawable.creator_chair_blue),
|
||||
SetupCustomization.createWheelchair("green", R.drawable.creator_chair_green),
|
||||
SetupCustomization.createWheelchair("pink", R.drawable.creator_chair_pink),
|
||||
SetupCustomization.createWheelchair("red", R.drawable.creator_chair_red),
|
||||
SetupCustomization.createWheelchair("yellow", R.drawable.creator_chair_yellow)
|
||||
)
|
||||
}
|
||||
|
||||
private fun getBangs(color: String): List<SetupCustomization> {
|
||||
return listOf(
|
||||
SetupCustomization.createHairBangs("0", R.drawable.creator_blank_face),
|
||||
SetupCustomization.createHairBangs("1", getResId("creator_hair_bangs_1_$color")),
|
||||
SetupCustomization.createHairBangs("2", getResId("creator_hair_bangs_2_$color")),
|
||||
SetupCustomization.createHairBangs("3", getResId("creator_hair_bangs_3_$color")),
|
||||
private val glasses: List<SetupCustomization>
|
||||
get() =
|
||||
listOf(
|
||||
SetupCustomization.createGlasses("", R.drawable.creator_blank_face),
|
||||
SetupCustomization.createGlasses(
|
||||
"eyewear_special_blackTopFrame",
|
||||
R.drawable.creator_eyewear_special_blacktopframe
|
||||
),
|
||||
SetupCustomization.createGlasses(
|
||||
"eyewear_special_blueTopFrame",
|
||||
R.drawable.creator_eyewear_special_bluetopframe
|
||||
),
|
||||
SetupCustomization.createGlasses(
|
||||
"eyewear_special_greenTopFrame",
|
||||
R.drawable.creator_eyewear_special_greentopframe
|
||||
),
|
||||
SetupCustomization.createGlasses(
|
||||
"eyewear_special_pinkTopFrame",
|
||||
R.drawable.creator_eyewear_special_pinktopframe
|
||||
),
|
||||
SetupCustomization.createGlasses(
|
||||
"eyewear_special_redTopFrame",
|
||||
R.drawable.creator_eyewear_special_redtopframe
|
||||
),
|
||||
SetupCustomization.createGlasses(
|
||||
"eyewear_special_yellowTopFrame",
|
||||
R.drawable.creator_eyewear_special_yellowtopframe
|
||||
),
|
||||
SetupCustomization.createGlasses(
|
||||
"eyewear_special_whiteTopFrame",
|
||||
R.drawable.creator_eyewear_special_whitetopframe
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
private fun getShirts(size: String): List<SetupCustomization> {
|
||||
return if (size == "broad") {
|
||||
listOf(
|
||||
SetupCustomization.createShirt("black", R.drawable.creator_broad_shirt_black),
|
||||
SetupCustomization.createShirt("blue", R.drawable.creator_broad_shirt_blue),
|
||||
SetupCustomization.createShirt("green", R.drawable.creator_broad_shirt_green),
|
||||
SetupCustomization.createShirt("pink", R.drawable.creator_broad_shirt_pink),
|
||||
SetupCustomization.createShirt("white", R.drawable.creator_broad_shirt_white),
|
||||
SetupCustomization.createShirt("yellow", R.drawable.creator_broad_shirt_yellow),
|
||||
)
|
||||
} else {
|
||||
listOf(
|
||||
SetupCustomization.createShirt("black", R.drawable.creator_slim_shirt_black),
|
||||
SetupCustomization.createShirt("blue", R.drawable.creator_slim_shirt_blue),
|
||||
SetupCustomization.createShirt("green", R.drawable.creator_slim_shirt_green),
|
||||
SetupCustomization.createShirt("pink", R.drawable.creator_slim_shirt_pink),
|
||||
SetupCustomization.createShirt("white", R.drawable.creator_slim_shirt_white),
|
||||
SetupCustomization.createShirt("yellow", R.drawable.creator_slim_shirt_yellow),
|
||||
)
|
||||
}
|
||||
}
|
||||
private val flowers: List<SetupCustomization>
|
||||
get() =
|
||||
listOf(
|
||||
SetupCustomization.createFlower("0", R.drawable.creator_blank_face),
|
||||
SetupCustomization.createFlower("1", R.drawable.creator_hair_flower_1),
|
||||
SetupCustomization.createFlower("2", R.drawable.creator_hair_flower_2),
|
||||
SetupCustomization.createFlower("3", R.drawable.creator_hair_flower_3),
|
||||
SetupCustomization.createFlower("4", R.drawable.creator_hair_flower_4),
|
||||
SetupCustomization.createFlower("5", R.drawable.creator_hair_flower_5),
|
||||
SetupCustomization.createFlower("6", R.drawable.creator_hair_flower_6)
|
||||
)
|
||||
|
||||
private fun getResId(resName: String): Int {
|
||||
return try {
|
||||
context.resources.getIdentifier(resName, "drawable", context.packageName)
|
||||
} catch (e: Exception) {
|
||||
-1
|
||||
private val hairColors: List<SetupCustomization>
|
||||
get() =
|
||||
listOf(
|
||||
SetupCustomization.createHairColor("white", R.color.hair_white),
|
||||
SetupCustomization.createHairColor("brown", R.color.hair_brown),
|
||||
SetupCustomization.createHairColor("blond", R.color.hair_blond),
|
||||
SetupCustomization.createHairColor("red", R.color.hair_red),
|
||||
SetupCustomization.createHairColor("black", R.color.hair_black)
|
||||
)
|
||||
|
||||
private val sizes: List<SetupCustomization>
|
||||
get() =
|
||||
listOf(
|
||||
SetupCustomization.createSize(
|
||||
"slim",
|
||||
R.drawable.creator_slim_shirt_black,
|
||||
context.getString(R.string.avatar_size_slim)
|
||||
),
|
||||
SetupCustomization.createSize(
|
||||
"broad",
|
||||
R.drawable.creator_broad_shirt_black,
|
||||
context.getString(R.string.avatar_size_broad)
|
||||
)
|
||||
)
|
||||
|
||||
private val skins: List<SetupCustomization>
|
||||
get() =
|
||||
listOf(
|
||||
SetupCustomization.createSkin("ddc994", R.color.skin_ddc994),
|
||||
SetupCustomization.createSkin("f5a76e", R.color.skin_f5a76e),
|
||||
SetupCustomization.createSkin("ea8349", R.color.skin_ea8349),
|
||||
SetupCustomization.createSkin("c06534", R.color.skin_c06534),
|
||||
SetupCustomization.createSkin("98461a", R.color.skin_98461a),
|
||||
SetupCustomization.createSkin("915533", R.color.skin_915533),
|
||||
SetupCustomization.createSkin("c3e1dc", R.color.skin_c3e1dc),
|
||||
SetupCustomization.createSkin("6bd049", R.color.skin_6bd049)
|
||||
)
|
||||
|
||||
override fun getCustomizations(
|
||||
type: String,
|
||||
user: User
|
||||
): List<SetupCustomization> {
|
||||
return getCustomizations(type, null, user)
|
||||
}
|
||||
|
||||
override fun getCustomizations(
|
||||
type: String,
|
||||
subtype: String?,
|
||||
user: User
|
||||
): List<SetupCustomization> {
|
||||
return when (type) {
|
||||
SetupCustomizationRepository.CATEGORY_BODY -> {
|
||||
when (subtype) {
|
||||
SetupCustomizationRepository.SUBCATEGORY_SIZE -> sizes
|
||||
SetupCustomizationRepository.SUBCATEGORY_SHIRT ->
|
||||
getShirts(
|
||||
user.preferences?.size ?: "slim"
|
||||
)
|
||||
|
||||
else -> emptyList()
|
||||
}
|
||||
}
|
||||
|
||||
SetupCustomizationRepository.CATEGORY_SKIN -> skins
|
||||
SetupCustomizationRepository.CATEGORY_HAIR -> {
|
||||
when (subtype) {
|
||||
SetupCustomizationRepository.SUBCATEGORY_BANGS ->
|
||||
getBangs(
|
||||
user.preferences?.hair?.color ?: ""
|
||||
)
|
||||
|
||||
SetupCustomizationRepository.SUBCATEGORY_PONYTAIL ->
|
||||
getHairBases(
|
||||
user.preferences?.hair?.color ?: ""
|
||||
)
|
||||
|
||||
SetupCustomizationRepository.SUBCATEGORY_COLOR -> hairColors
|
||||
else -> emptyList()
|
||||
}
|
||||
}
|
||||
|
||||
SetupCustomizationRepository.CATEGORY_EXTRAS -> {
|
||||
when (subtype) {
|
||||
SetupCustomizationRepository.SUBCATEGORY_FLOWER -> flowers
|
||||
SetupCustomizationRepository.SUBCATEGORY_GLASSES -> glasses
|
||||
SetupCustomizationRepository.SUBCATEGORY_WHEELCHAIR -> wheelchairs
|
||||
else -> emptyList()
|
||||
}
|
||||
}
|
||||
|
||||
else -> emptyList()
|
||||
}
|
||||
}
|
||||
|
||||
private fun getHairBases(color: String): List<SetupCustomization> {
|
||||
return listOf(
|
||||
SetupCustomization.createHairPonytail("0", R.drawable.creator_blank_face),
|
||||
SetupCustomization.createHairPonytail("1", getResId("creator_hair_base_1_$color")),
|
||||
SetupCustomization.createHairPonytail("3", getResId("creator_hair_base_3_$color"))
|
||||
)
|
||||
}
|
||||
|
||||
private fun getBangs(color: String): List<SetupCustomization> {
|
||||
return listOf(
|
||||
SetupCustomization.createHairBangs("0", R.drawable.creator_blank_face),
|
||||
SetupCustomization.createHairBangs("1", getResId("creator_hair_bangs_1_$color")),
|
||||
SetupCustomization.createHairBangs("2", getResId("creator_hair_bangs_2_$color")),
|
||||
SetupCustomization.createHairBangs("3", getResId("creator_hair_bangs_3_$color"))
|
||||
)
|
||||
}
|
||||
|
||||
private fun getShirts(size: String): List<SetupCustomization> {
|
||||
return if (size == "broad") {
|
||||
listOf(
|
||||
SetupCustomization.createShirt("black", R.drawable.creator_broad_shirt_black),
|
||||
SetupCustomization.createShirt("blue", R.drawable.creator_broad_shirt_blue),
|
||||
SetupCustomization.createShirt("green", R.drawable.creator_broad_shirt_green),
|
||||
SetupCustomization.createShirt("pink", R.drawable.creator_broad_shirt_pink),
|
||||
SetupCustomization.createShirt("white", R.drawable.creator_broad_shirt_white),
|
||||
SetupCustomization.createShirt("yellow", R.drawable.creator_broad_shirt_yellow)
|
||||
)
|
||||
} else {
|
||||
listOf(
|
||||
SetupCustomization.createShirt("black", R.drawable.creator_slim_shirt_black),
|
||||
SetupCustomization.createShirt("blue", R.drawable.creator_slim_shirt_blue),
|
||||
SetupCustomization.createShirt("green", R.drawable.creator_slim_shirt_green),
|
||||
SetupCustomization.createShirt("pink", R.drawable.creator_slim_shirt_pink),
|
||||
SetupCustomization.createShirt("white", R.drawable.creator_slim_shirt_white),
|
||||
SetupCustomization.createShirt("yellow", R.drawable.creator_slim_shirt_yellow)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun getResId(resName: String): Int {
|
||||
return try {
|
||||
context.resources.getIdentifier(resName, "drawable", context.packageName)
|
||||
} catch (e: Exception) {
|
||||
-1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,12 +28,12 @@ import java.util.UUID
|
|||
class SocialRepositoryImpl(
|
||||
localRepository: SocialLocalRepository,
|
||||
apiClient: ApiClient,
|
||||
authenticationHandler: AuthenticationHandler,
|
||||
authenticationHandler: AuthenticationHandler
|
||||
) : BaseRepositoryImpl<SocialLocalRepository>(localRepository, apiClient, authenticationHandler),
|
||||
SocialRepository {
|
||||
override suspend fun transferGroupOwnership(
|
||||
groupID: String,
|
||||
userID: String,
|
||||
userID: String
|
||||
): Group? {
|
||||
val group =
|
||||
localRepository.getGroup(groupID).first()?.let { localRepository.getUnmanagedCopy(it) }
|
||||
|
|
@ -43,7 +43,7 @@ class SocialRepositoryImpl(
|
|||
|
||||
override suspend fun removeMemberFromGroup(
|
||||
groupID: String,
|
||||
userID: String,
|
||||
userID: String
|
||||
): List<Member>? {
|
||||
apiClient.removeMemberFromGroup(groupID, userID)
|
||||
return retrievePartyMembers(groupID, true)
|
||||
|
|
@ -59,7 +59,7 @@ class SocialRepositoryImpl(
|
|||
|
||||
override suspend fun updateMember(
|
||||
memberID: String,
|
||||
data: Map<String, Map<String, Boolean>>,
|
||||
data: Map<String, Map<String, Boolean>>
|
||||
): Member? {
|
||||
return apiClient.updateMember(memberID, data)
|
||||
}
|
||||
|
|
@ -72,14 +72,14 @@ class SocialRepositoryImpl(
|
|||
authenticationHandler.userIDFlow.flatMapLatest {
|
||||
localRepository.getGroupMembership(
|
||||
it,
|
||||
id,
|
||||
id
|
||||
)
|
||||
}
|
||||
|
||||
override fun getGroupMemberships(): Flow<List<GroupMembership>> {
|
||||
return authenticationHandler.userIDFlow.flatMapLatest {
|
||||
localRepository.getGroupMemberships(
|
||||
it,
|
||||
it
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -101,7 +101,7 @@ class SocialRepositoryImpl(
|
|||
override suspend fun flagMessage(
|
||||
chatMessageID: String,
|
||||
additionalInfo: String,
|
||||
groupID: String?,
|
||||
groupID: String?
|
||||
): Void? {
|
||||
return when {
|
||||
chatMessageID.isBlank() -> return null
|
||||
|
|
@ -120,7 +120,7 @@ class SocialRepositoryImpl(
|
|||
|
||||
override suspend fun reportMember(
|
||||
memberID: String,
|
||||
data: Map<String, String>,
|
||||
data: Map<String, String>
|
||||
): Void? {
|
||||
return apiClient.reportMember(memberID, data)
|
||||
}
|
||||
|
|
@ -147,7 +147,7 @@ class SocialRepositoryImpl(
|
|||
|
||||
override suspend fun postGroupChat(
|
||||
groupId: String,
|
||||
messageObject: HashMap<String, String>,
|
||||
messageObject: HashMap<String, String>
|
||||
): PostChatMessageResult? {
|
||||
val result = apiClient.postGroupChat(groupId, messageObject)
|
||||
result?.message?.groupId = groupId
|
||||
|
|
@ -156,7 +156,7 @@ class SocialRepositoryImpl(
|
|||
|
||||
override suspend fun postGroupChat(
|
||||
groupId: String,
|
||||
message: String,
|
||||
message: String
|
||||
): PostChatMessageResult? {
|
||||
val messageObject = HashMap<String, String>()
|
||||
messageObject["message"] = message
|
||||
|
|
@ -179,7 +179,7 @@ class SocialRepositoryImpl(
|
|||
|
||||
override suspend fun leaveGroup(
|
||||
id: String?,
|
||||
keepChallenges: Boolean,
|
||||
keepChallenges: Boolean
|
||||
): Group? {
|
||||
if (id?.isNotBlank() != true) {
|
||||
return null
|
||||
|
|
@ -208,7 +208,7 @@ class SocialRepositoryImpl(
|
|||
leader: String?,
|
||||
type: String?,
|
||||
privacy: String?,
|
||||
leaderCreateChallenge: Boolean?,
|
||||
leaderCreateChallenge: Boolean?
|
||||
): Group? {
|
||||
val group = Group()
|
||||
group.name = name
|
||||
|
|
@ -226,7 +226,7 @@ class SocialRepositoryImpl(
|
|||
name: String?,
|
||||
description: String?,
|
||||
leader: String?,
|
||||
leaderCreateChallenge: Boolean?,
|
||||
leaderCreateChallenge: Boolean?
|
||||
): Group? {
|
||||
if (group == null) {
|
||||
return null
|
||||
|
|
@ -247,13 +247,13 @@ class SocialRepositoryImpl(
|
|||
authenticationHandler.userIDFlow.flatMapLatest {
|
||||
localRepository.getInboxMessages(
|
||||
it,
|
||||
replyToUserID,
|
||||
replyToUserID
|
||||
)
|
||||
}
|
||||
|
||||
override suspend fun retrieveInboxMessages(
|
||||
uuid: String,
|
||||
page: Int,
|
||||
page: Int
|
||||
): List<ChatMessage>? {
|
||||
val messages = apiClient.retrieveInboxMessages(uuid, page) ?: return null
|
||||
messages.forEach {
|
||||
|
|
@ -271,7 +271,7 @@ class SocialRepositoryImpl(
|
|||
|
||||
override suspend fun postPrivateMessage(
|
||||
recipientId: String,
|
||||
messageObject: HashMap<String, String>,
|
||||
messageObject: HashMap<String, String>
|
||||
): List<ChatMessage>? {
|
||||
apiClient.postPrivateMessage(messageObject)
|
||||
return retrieveInboxMessages(recipientId, 0)
|
||||
|
|
@ -279,7 +279,7 @@ class SocialRepositoryImpl(
|
|||
|
||||
override suspend fun postPrivateMessage(
|
||||
recipientId: String,
|
||||
message: String,
|
||||
message: String
|
||||
): List<ChatMessage>? {
|
||||
val messageObject = HashMap<String, String>()
|
||||
messageObject["message"] = message
|
||||
|
|
@ -293,7 +293,7 @@ class SocialRepositoryImpl(
|
|||
|
||||
override suspend fun retrievePartyMembers(
|
||||
id: String,
|
||||
includeAllPublicFields: Boolean,
|
||||
includeAllPublicFields: Boolean
|
||||
): List<Member>? {
|
||||
val members = apiClient.getGroupMembers(id, includeAllPublicFields)
|
||||
members?.let { localRepository.savePartyMembers(id, it) }
|
||||
|
|
@ -302,13 +302,13 @@ class SocialRepositoryImpl(
|
|||
|
||||
override suspend fun inviteToGroup(
|
||||
id: String,
|
||||
inviteData: Map<String, Any>,
|
||||
inviteData: Map<String, Any>
|
||||
) =
|
||||
apiClient.inviteToGroup(id, inviteData)
|
||||
|
||||
override suspend fun retrieveMember(
|
||||
userId: String?,
|
||||
fromHall: Boolean,
|
||||
fromHall: Boolean
|
||||
): Member? {
|
||||
return if (userId == null) {
|
||||
null
|
||||
|
|
@ -328,14 +328,14 @@ class SocialRepositoryImpl(
|
|||
|
||||
override suspend fun retrievegroupInvites(
|
||||
id: String,
|
||||
includeAllPublicFields: Boolean,
|
||||
includeAllPublicFields: Boolean
|
||||
) =
|
||||
apiClient.getGroupInvites(id, includeAllPublicFields)
|
||||
|
||||
override suspend fun findUsernames(
|
||||
username: String,
|
||||
context: String?,
|
||||
id: String?,
|
||||
id: String?
|
||||
): List<FindUsernameResult>? {
|
||||
return apiClient.findUsernames(username, context, id)
|
||||
}
|
||||
|
|
@ -351,7 +351,7 @@ class SocialRepositoryImpl(
|
|||
|
||||
override fun markSomePrivateMessagesAsRead(
|
||||
user: User?,
|
||||
messages: List<ChatMessage>,
|
||||
messages: List<ChatMessage>
|
||||
) {
|
||||
if (user?.isManaged == true) {
|
||||
val numOfUnseenMessages = messages.count { !it.isSeen }
|
||||
|
|
@ -376,7 +376,7 @@ class SocialRepositoryImpl(
|
|||
|
||||
override suspend fun acceptQuest(
|
||||
user: User?,
|
||||
partyId: String,
|
||||
partyId: String
|
||||
): Void? {
|
||||
apiClient.acceptQuest(partyId)
|
||||
user?.let {
|
||||
|
|
@ -387,7 +387,7 @@ class SocialRepositoryImpl(
|
|||
|
||||
override suspend fun rejectQuest(
|
||||
user: User?,
|
||||
partyId: String,
|
||||
partyId: String
|
||||
): Void? {
|
||||
apiClient.rejectQuest(partyId)
|
||||
user?.let {
|
||||
|
|
@ -434,7 +434,7 @@ class SocialRepositoryImpl(
|
|||
|
||||
override suspend fun transferGems(
|
||||
giftedID: String,
|
||||
amount: Int,
|
||||
amount: Int
|
||||
): Void? {
|
||||
return apiClient.transferGems(giftedID, amount)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import kotlinx.coroutines.flow.flatMapLatest
|
|||
class TagRepositoryImpl(
|
||||
localRepository: TagLocalRepository,
|
||||
apiClient: ApiClient,
|
||||
authenticationHandler: AuthenticationHandler,
|
||||
authenticationHandler: AuthenticationHandler
|
||||
) : BaseRepositoryImpl<TagLocalRepository>(localRepository, apiClient, authenticationHandler),
|
||||
TagRepository {
|
||||
override fun getTags() = authenticationHandler.userIDFlow.flatMapLatest { getTags(it) }
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ class TaskRepositoryImpl(
|
|||
localRepository: TaskLocalRepository,
|
||||
apiClient: ApiClient,
|
||||
authenticationHandler: AuthenticationHandler,
|
||||
val appConfigManager: AppConfigManager,
|
||||
val appConfigManager: AppConfigManager
|
||||
) : BaseRepositoryImpl<TaskLocalRepository>(localRepository, apiClient, authenticationHandler),
|
||||
TaskRepository {
|
||||
private var lastTaskAction: Long = 0
|
||||
|
|
@ -46,25 +46,25 @@ class TaskRepositoryImpl(
|
|||
override fun getTasks(
|
||||
taskType: TaskType,
|
||||
userID: String?,
|
||||
includedGroupIDs: Array<String>,
|
||||
includedGroupIDs: Array<String>
|
||||
): Flow<List<Task>> =
|
||||
this.localRepository.getTasks(
|
||||
taskType,
|
||||
userID ?: authenticationHandler.currentUserID ?: "",
|
||||
includedGroupIDs,
|
||||
includedGroupIDs
|
||||
)
|
||||
|
||||
override fun saveTasks(
|
||||
userId: String,
|
||||
order: TasksOrder,
|
||||
tasks: TaskList,
|
||||
tasks: TaskList
|
||||
) {
|
||||
localRepository.saveTasks(userId, order, tasks)
|
||||
}
|
||||
|
||||
override suspend fun retrieveTasks(
|
||||
userId: String,
|
||||
tasksOrder: TasksOrder,
|
||||
tasksOrder: TasksOrder
|
||||
): TaskList? {
|
||||
val tasks = apiClient.getTasks() ?: return null
|
||||
this.localRepository.saveTasks(userId, tasksOrder, tasks)
|
||||
|
|
@ -76,7 +76,7 @@ class TaskRepositoryImpl(
|
|||
val tasks = taskList.tasks
|
||||
this.localRepository.saveCompletedTodos(
|
||||
userId ?: authenticationHandler.currentUserID ?: "",
|
||||
tasks.values,
|
||||
tasks.values
|
||||
)
|
||||
return taskList
|
||||
}
|
||||
|
|
@ -84,7 +84,7 @@ class TaskRepositoryImpl(
|
|||
override suspend fun retrieveTasks(
|
||||
userId: String,
|
||||
tasksOrder: TasksOrder,
|
||||
dueDate: Date,
|
||||
dueDate: Date
|
||||
): TaskList? {
|
||||
val formatter = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZZZZZ", Locale.US)
|
||||
val taskList = this.apiClient.getTasks("dailys", formatter.format(dueDate)) ?: return null
|
||||
|
|
@ -98,14 +98,14 @@ class TaskRepositoryImpl(
|
|||
task: Task,
|
||||
up: Boolean,
|
||||
force: Boolean,
|
||||
notifyFunc: ((TaskScoringResult) -> Unit)?,
|
||||
notifyFunc: ((TaskScoringResult) -> Unit)?
|
||||
): TaskScoringResult? {
|
||||
val localData =
|
||||
if (user != null && appConfigManager.enableLocalTaskScoring()) {
|
||||
ScoreTaskLocallyInteractor.score(
|
||||
user,
|
||||
task,
|
||||
if (up) TaskDirection.UP else TaskDirection.DOWN,
|
||||
if (up) TaskDirection.UP else TaskDirection.DOWN
|
||||
)
|
||||
} else {
|
||||
null
|
||||
|
|
@ -127,7 +127,7 @@ class TaskRepositoryImpl(
|
|||
val res =
|
||||
this.apiClient.postTaskDirection(
|
||||
id,
|
||||
(if (up) TaskDirection.UP else TaskDirection.DOWN).text,
|
||||
(if (up) TaskDirection.UP else TaskDirection.DOWN).text
|
||||
) ?: return null
|
||||
// There are cases where the user object is not set correctly. So the app refetches it as a fallback
|
||||
val thisUser =
|
||||
|
|
@ -142,8 +142,8 @@ class TaskRepositoryImpl(
|
|||
mapOf(
|
||||
"type" to (task.type ?: ""),
|
||||
"scored_up" to up,
|
||||
"value" to task.value,
|
||||
),
|
||||
"value" to task.value
|
||||
)
|
||||
)
|
||||
if (res.lvl == 0) {
|
||||
// Team tasks that require approval have weird data that we should just ignore.
|
||||
|
|
@ -166,7 +166,7 @@ class TaskRepositoryImpl(
|
|||
res: TaskDirectionData,
|
||||
task: Task,
|
||||
up: Boolean,
|
||||
localDelta: Float,
|
||||
localDelta: Float
|
||||
) {
|
||||
this.localRepository.executeTransaction {
|
||||
val bgTask = localRepository.getLiveObject(task) ?: return@executeTransaction
|
||||
|
|
@ -235,13 +235,13 @@ class TaskRepositoryImpl(
|
|||
bgUser.party?.quest?.progress?.up = (
|
||||
bgUser.party?.quest?.progress?.up
|
||||
?: 0F
|
||||
) + (res._tmp?.quest?.progressDelta?.toFloat() ?: 0F)
|
||||
) + (res._tmp?.quest?.progressDelta?.toFloat() ?: 0F)
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun markTaskNeedsWork(
|
||||
task: Task,
|
||||
userID: String,
|
||||
userID: String
|
||||
) {
|
||||
val savedTask = apiClient.markTaskNeedsWork(task.id ?: "", userID)
|
||||
if (savedTask != null) {
|
||||
|
|
@ -260,7 +260,7 @@ class TaskRepositoryImpl(
|
|||
taskId: String,
|
||||
up: Boolean,
|
||||
force: Boolean,
|
||||
notifyFunc: ((TaskScoringResult) -> Unit)?,
|
||||
notifyFunc: ((TaskScoringResult) -> Unit)?
|
||||
): TaskScoringResult? {
|
||||
val task = localRepository.getTask(taskId).firstOrNull() ?: return null
|
||||
return taskChecked(user, task, up, force, notifyFunc)
|
||||
|
|
@ -268,7 +268,7 @@ class TaskRepositoryImpl(
|
|||
|
||||
override suspend fun scoreChecklistItem(
|
||||
taskId: String,
|
||||
itemId: String,
|
||||
itemId: String
|
||||
): Task? {
|
||||
val task = apiClient.scoreChecklistItem(taskId, itemId)
|
||||
val updatedItem: ChecklistItem? = task?.checklist?.lastOrNull { itemId == it.id }
|
||||
|
|
@ -284,7 +284,7 @@ class TaskRepositoryImpl(
|
|||
|
||||
override suspend fun createTask(
|
||||
task: Task,
|
||||
force: Boolean,
|
||||
force: Boolean
|
||||
): Task? {
|
||||
val now = Date().time
|
||||
if (lastTaskAction > now - 500 && !force) {
|
||||
|
|
@ -327,7 +327,7 @@ class TaskRepositoryImpl(
|
|||
@Suppress("ReturnCount")
|
||||
override suspend fun updateTask(
|
||||
task: Task,
|
||||
force: Boolean,
|
||||
force: Boolean
|
||||
): Task? {
|
||||
val now = Date().time
|
||||
if ((lastTaskAction > now - 500 && !force) || !task.isValid) {
|
||||
|
|
@ -368,21 +368,21 @@ class TaskRepositoryImpl(
|
|||
|
||||
override fun markTaskCompleted(
|
||||
taskId: String,
|
||||
isCompleted: Boolean,
|
||||
isCompleted: Boolean
|
||||
) {
|
||||
localRepository.markTaskCompleted(taskId, isCompleted)
|
||||
}
|
||||
|
||||
override fun <T : BaseMainObject> modify(
|
||||
obj: T,
|
||||
transaction: (T) -> Unit,
|
||||
transaction: (T) -> Unit
|
||||
) {
|
||||
localRepository.modify(obj, transaction)
|
||||
}
|
||||
|
||||
override fun swapTaskPosition(
|
||||
firstPosition: Int,
|
||||
secondPosition: Int,
|
||||
secondPosition: Int
|
||||
) {
|
||||
localRepository.swapTaskPosition(firstPosition, secondPosition)
|
||||
}
|
||||
|
|
@ -390,7 +390,7 @@ class TaskRepositoryImpl(
|
|||
override suspend fun updateTaskPosition(
|
||||
taskType: TaskType,
|
||||
taskID: String,
|
||||
newPosition: Int,
|
||||
newPosition: Int
|
||||
): List<String>? {
|
||||
val positions = apiClient.postTaskNewPosition(taskID, newPosition) ?: return null
|
||||
localRepository.updateTaskPositions(positions)
|
||||
|
|
@ -402,7 +402,7 @@ class TaskRepositoryImpl(
|
|||
|
||||
override fun updateTaskInBackground(
|
||||
task: Task,
|
||||
assignChanges: Map<String, MutableList<String>>,
|
||||
assignChanges: Map<String, MutableList<String>>
|
||||
) {
|
||||
MainScope().launchCatching {
|
||||
val updatedTask = updateTask(task) ?: return@launchCatching
|
||||
|
|
@ -412,7 +412,7 @@ class TaskRepositoryImpl(
|
|||
|
||||
override fun createTaskInBackground(
|
||||
task: Task,
|
||||
assignChanges: Map<String, MutableList<String>>,
|
||||
assignChanges: Map<String, MutableList<String>>
|
||||
) {
|
||||
MainScope().launchCatching {
|
||||
val createdTask = createTask(task) ?: return@launchCatching
|
||||
|
|
@ -422,7 +422,7 @@ class TaskRepositoryImpl(
|
|||
|
||||
private suspend fun handleAssignmentChanges(
|
||||
task: Task,
|
||||
assignChanges: Map<String, MutableList<String>>,
|
||||
assignChanges: Map<String, MutableList<String>>
|
||||
) {
|
||||
val taskID = task.id ?: return
|
||||
assignChanges["assign"]?.let { assignments ->
|
||||
|
|
@ -474,7 +474,7 @@ class TaskRepositoryImpl(
|
|||
|
||||
override suspend fun unlinkAllTasks(
|
||||
challengeID: String?,
|
||||
keepOption: String,
|
||||
keepOption: String
|
||||
): Void? {
|
||||
return apiClient.unlinkAllTasks(challengeID, keepOption)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import kotlinx.coroutines.flow.Flow
|
|||
class TutorialRepositoryImpl(
|
||||
localRepository: TutorialLocalRepository,
|
||||
apiClient: ApiClient,
|
||||
authenticationHandler: AuthenticationHandler,
|
||||
authenticationHandler: AuthenticationHandler
|
||||
) : BaseRepositoryImpl<TutorialLocalRepository>(localRepository, apiClient, authenticationHandler),
|
||||
TutorialRepository {
|
||||
override fun getTutorialStep(key: String): Flow<TutorialStep> =
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ class UserRepositoryImpl(
|
|||
apiClient: ApiClient,
|
||||
authenticationHandler: AuthenticationHandler,
|
||||
private val taskRepository: TaskRepository,
|
||||
private val appConfigManager: AppConfigManager,
|
||||
private val appConfigManager: AppConfigManager
|
||||
) : BaseRepositoryImpl<UserLocalRepository>(localRepository, apiClient, authenticationHandler), UserRepository {
|
||||
companion object {
|
||||
private var lastReadNotification: String? = null
|
||||
|
|
@ -65,7 +65,7 @@ class UserRepositoryImpl(
|
|||
|
||||
private suspend fun updateUser(
|
||||
userID: String,
|
||||
updateData: Map<String, Any?>,
|
||||
updateData: Map<String, Any?>
|
||||
): User? {
|
||||
val networkUser = apiClient.updateUser(updateData) ?: return null
|
||||
val oldUser = localRepository.getUser(userID).firstOrNull()
|
||||
|
|
@ -75,7 +75,7 @@ class UserRepositoryImpl(
|
|||
private suspend fun updateUser(
|
||||
userID: String,
|
||||
key: String,
|
||||
value: Any?,
|
||||
value: Any?
|
||||
): User? {
|
||||
return updateUser(userID, mapOf(key to value))
|
||||
}
|
||||
|
|
@ -86,7 +86,7 @@ class UserRepositoryImpl(
|
|||
|
||||
override suspend fun updateUser(
|
||||
key: String,
|
||||
value: Any?,
|
||||
value: Any?
|
||||
): User? {
|
||||
return updateUser(currentUserID, key, value)
|
||||
}
|
||||
|
|
@ -95,7 +95,7 @@ class UserRepositoryImpl(
|
|||
override suspend fun retrieveUser(
|
||||
withTasks: Boolean,
|
||||
forced: Boolean,
|
||||
overrideExisting: Boolean,
|
||||
overrideExisting: Boolean
|
||||
): User? {
|
||||
// Only retrieve again after 3 minutes or it's forced.
|
||||
if (forced || lastSync == null || Date().time - (lastSync?.time ?: 0) > 180000) {
|
||||
|
|
@ -164,7 +164,7 @@ class UserRepositoryImpl(
|
|||
override suspend fun useSkill(
|
||||
key: String,
|
||||
target: String?,
|
||||
taskId: String,
|
||||
taskId: String
|
||||
): SkillResponse? {
|
||||
val response = apiClient.useSkill(key, target ?: "", taskId) ?: return null
|
||||
val user = getLiveUser() ?: return response
|
||||
|
|
@ -178,7 +178,7 @@ class UserRepositoryImpl(
|
|||
|
||||
override suspend fun useSkill(
|
||||
key: String,
|
||||
target: String?,
|
||||
target: String?
|
||||
): SkillResponse? {
|
||||
val response = apiClient.useSkill(key, target ?: "") ?: return null
|
||||
val user = getLiveUser() ?: return response
|
||||
|
|
@ -203,7 +203,7 @@ class UserRepositoryImpl(
|
|||
|
||||
override suspend fun unlockPath(
|
||||
path: String,
|
||||
price: Int,
|
||||
price: Int
|
||||
): UnlockResponse? {
|
||||
val unlockResponse = apiClient.unlockPath(path) ?: return null
|
||||
val user = localRepository.getUser(currentUserID).firstOrNull() ?: return unlockResponse
|
||||
|
|
@ -284,7 +284,7 @@ class UserRepositoryImpl(
|
|||
|
||||
override suspend fun updateLoginName(
|
||||
newLoginName: String,
|
||||
password: String?,
|
||||
password: String?
|
||||
): User? {
|
||||
if (!password.isNullOrEmpty()) {
|
||||
apiClient.updateLoginName(newLoginName.trim(), password.trim())
|
||||
|
|
@ -303,13 +303,13 @@ class UserRepositoryImpl(
|
|||
|
||||
override suspend fun updateEmail(
|
||||
newEmail: String,
|
||||
password: String,
|
||||
password: String
|
||||
) = apiClient.updateEmail(newEmail.trim(), password)
|
||||
|
||||
override suspend fun updatePassword(
|
||||
oldPassword: String,
|
||||
newPassword: String,
|
||||
newPasswordConfirmation: String,
|
||||
newPasswordConfirmation: String
|
||||
) = apiClient.updatePassword(oldPassword.trim(), newPassword.trim(), newPasswordConfirmation.trim())
|
||||
|
||||
override suspend fun allocatePoint(stat: Attribute): Stats? {
|
||||
|
|
@ -343,14 +343,14 @@ class UserRepositoryImpl(
|
|||
strength: Int,
|
||||
intelligence: Int,
|
||||
constitution: Int,
|
||||
perception: Int,
|
||||
perception: Int
|
||||
): Stats? {
|
||||
val stats =
|
||||
apiClient.bulkAllocatePoints(
|
||||
strength,
|
||||
intelligence,
|
||||
constitution,
|
||||
perception,
|
||||
perception
|
||||
) ?: return null
|
||||
val user = getLiveUser()
|
||||
if (user != null) {
|
||||
|
|
@ -391,7 +391,7 @@ class UserRepositoryImpl(
|
|||
override suspend fun useCustomization(
|
||||
type: String,
|
||||
category: String?,
|
||||
identifier: String,
|
||||
identifier: String
|
||||
): User? {
|
||||
if (appConfigManager.enableLocalChanges()) {
|
||||
val liveUser = getLiveUser()
|
||||
|
|
@ -466,7 +466,7 @@ class UserRepositoryImpl(
|
|||
localRepository.save(
|
||||
members.map {
|
||||
GroupMembership(it.id, id)
|
||||
},
|
||||
}
|
||||
)
|
||||
members.let { localRepository.save(members) }
|
||||
return team
|
||||
|
|
@ -494,7 +494,7 @@ class UserRepositoryImpl(
|
|||
|
||||
private fun mergeUser(
|
||||
oldUser: User?,
|
||||
newUser: User,
|
||||
newUser: User
|
||||
): User {
|
||||
if (oldUser == null || !oldUser.isValid) {
|
||||
return oldUser ?: newUser
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ interface BaseLocalRepository {
|
|||
|
||||
fun <T : BaseMainObject> modify(
|
||||
obj: T,
|
||||
transaction: (T) -> Unit,
|
||||
transaction: (T) -> Unit
|
||||
)
|
||||
|
||||
fun <T : BaseObject> getLiveObject(obj: T): T?
|
||||
|
|
|
|||
|
|
@ -17,25 +17,25 @@ interface ChallengeLocalRepository : BaseLocalRepository {
|
|||
fun setParticipating(
|
||||
userID: String,
|
||||
challengeID: String,
|
||||
isParticipating: Boolean,
|
||||
isParticipating: Boolean
|
||||
)
|
||||
|
||||
fun saveChallenges(
|
||||
challenges: List<Challenge>,
|
||||
clearChallenges: Boolean,
|
||||
memberOnly: Boolean,
|
||||
userID: String,
|
||||
userID: String
|
||||
)
|
||||
|
||||
fun getChallengeMembership(
|
||||
userId: String,
|
||||
id: String,
|
||||
id: String
|
||||
): Flow<ChallengeMembership>
|
||||
|
||||
fun getChallengeMemberships(userId: String): Flow<List<ChallengeMembership>>
|
||||
|
||||
fun isChallengeMember(
|
||||
userID: String,
|
||||
challengeID: String,
|
||||
challengeID: String
|
||||
): Flow<Boolean>
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,6 @@ interface CustomizationLocalRepository : ContentLocalRepository {
|
|||
fun getCustomizations(
|
||||
type: String,
|
||||
category: String?,
|
||||
onlyAvailable: Boolean,
|
||||
onlyAvailable: Boolean
|
||||
): Flow<List<Customization>>
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,17 +42,17 @@ interface InventoryLocalRepository : ContentLocalRepository {
|
|||
fun getOwnedItems(
|
||||
itemType: String,
|
||||
userID: String,
|
||||
includeZero: Boolean,
|
||||
includeZero: Boolean
|
||||
): Flow<List<OwnedItem>>
|
||||
|
||||
fun getOwnedItems(
|
||||
userID: String,
|
||||
includeZero: Boolean,
|
||||
includeZero: Boolean
|
||||
): Flow<Map<String, OwnedItem>>
|
||||
|
||||
fun getEquipmentType(
|
||||
type: String,
|
||||
set: String,
|
||||
set: String
|
||||
): Flow<List<Equipment>>
|
||||
|
||||
fun getEquipment(key: String): Flow<Equipment>
|
||||
|
|
@ -60,13 +60,13 @@ interface InventoryLocalRepository : ContentLocalRepository {
|
|||
fun getMounts(
|
||||
type: String?,
|
||||
group: String?,
|
||||
color: String?,
|
||||
color: String?
|
||||
): Flow<List<Mount>>
|
||||
|
||||
fun getPets(
|
||||
type: String?,
|
||||
group: String?,
|
||||
color: String?,
|
||||
color: String?
|
||||
): Flow<List<Pet>>
|
||||
|
||||
fun updateOwnedEquipment(user: User)
|
||||
|
|
@ -75,24 +75,24 @@ interface InventoryLocalRepository : ContentLocalRepository {
|
|||
type: String,
|
||||
key: String,
|
||||
userID: String,
|
||||
amountToAdd: Int,
|
||||
amountToAdd: Int
|
||||
)
|
||||
|
||||
fun changeOwnedCount(
|
||||
item: OwnedItem,
|
||||
amountToAdd: Int?,
|
||||
amountToAdd: Int?
|
||||
)
|
||||
|
||||
fun getItem(
|
||||
type: String,
|
||||
key: String,
|
||||
key: String
|
||||
): Flow<Item>
|
||||
|
||||
fun getOwnedItem(
|
||||
userID: String,
|
||||
type: String,
|
||||
key: String,
|
||||
includeZero: Boolean,
|
||||
includeZero: Boolean
|
||||
): Flow<OwnedItem>
|
||||
|
||||
fun decrementMysteryItemCount(user: User?)
|
||||
|
|
@ -102,20 +102,20 @@ interface InventoryLocalRepository : ContentLocalRepository {
|
|||
fun hatchPet(
|
||||
eggKey: String,
|
||||
potionKey: String,
|
||||
userID: String,
|
||||
userID: String
|
||||
)
|
||||
|
||||
fun unhatchPet(
|
||||
eggKey: String,
|
||||
potionKey: String,
|
||||
userID: String,
|
||||
userID: String
|
||||
)
|
||||
|
||||
fun feedPet(
|
||||
foodKey: String,
|
||||
petKey: String,
|
||||
feedValue: Int,
|
||||
userID: String,
|
||||
userID: String
|
||||
)
|
||||
|
||||
fun getLatestMysteryItem(): Flow<Equipment>
|
||||
|
|
@ -123,14 +123,14 @@ interface InventoryLocalRepository : ContentLocalRepository {
|
|||
|
||||
fun soldItem(
|
||||
userID: String,
|
||||
updatedUser: User,
|
||||
updatedUser: User
|
||||
): User
|
||||
|
||||
fun getAvailableLimitedItems(): Flow<List<Item>>
|
||||
|
||||
fun save(
|
||||
items: Items,
|
||||
userID: String,
|
||||
userID: String
|
||||
)
|
||||
|
||||
fun getLiveObject(obj: OwnedItem): OwnedItem?
|
||||
|
|
@ -139,6 +139,6 @@ interface InventoryLocalRepository : ContentLocalRepository {
|
|||
|
||||
fun getItems(
|
||||
itemClass: Class<out Item>,
|
||||
keys: Array<String>,
|
||||
keys: Array<String>
|
||||
): Flow<List<Item>>
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import kotlinx.coroutines.flow.Flow
|
|||
interface SocialLocalRepository : BaseLocalRepository {
|
||||
fun getUserGroups(
|
||||
userID: String,
|
||||
type: String?,
|
||||
type: String?
|
||||
): Flow<List<Group>>
|
||||
|
||||
fun getGroup(id: String): Flow<Group?>
|
||||
|
|
@ -29,30 +29,30 @@ interface SocialLocalRepository : BaseLocalRepository {
|
|||
|
||||
fun updateRSVPNeeded(
|
||||
user: User?,
|
||||
newValue: Boolean,
|
||||
newValue: Boolean
|
||||
)
|
||||
|
||||
fun likeMessage(
|
||||
chatMessage: ChatMessage,
|
||||
userId: String,
|
||||
liked: Boolean,
|
||||
liked: Boolean
|
||||
)
|
||||
|
||||
fun savePartyMembers(
|
||||
groupId: String?,
|
||||
members: List<Member>,
|
||||
members: List<Member>
|
||||
)
|
||||
|
||||
fun removeQuest(partyId: String)
|
||||
|
||||
fun setQuestActivity(
|
||||
party: Group?,
|
||||
active: Boolean,
|
||||
active: Boolean
|
||||
)
|
||||
|
||||
fun saveChatMessages(
|
||||
groupId: String?,
|
||||
chatMessages: List<ChatMessage>,
|
||||
chatMessages: List<ChatMessage>
|
||||
)
|
||||
|
||||
fun doesGroupExist(id: String): Boolean
|
||||
|
|
@ -60,43 +60,43 @@ interface SocialLocalRepository : BaseLocalRepository {
|
|||
fun updateMembership(
|
||||
userId: String,
|
||||
id: String,
|
||||
isMember: Boolean,
|
||||
isMember: Boolean
|
||||
)
|
||||
|
||||
fun getGroupMembership(
|
||||
userId: String,
|
||||
id: String,
|
||||
id: String
|
||||
): Flow<GroupMembership?>
|
||||
|
||||
fun getGroupMemberships(userId: String): Flow<List<GroupMembership>>
|
||||
|
||||
fun rejectGroupInvitation(
|
||||
userID: String,
|
||||
groupID: String,
|
||||
groupID: String
|
||||
)
|
||||
|
||||
fun getInboxMessages(
|
||||
userId: String,
|
||||
replyToUserID: String?,
|
||||
replyToUserID: String?
|
||||
): Flow<RealmResults<ChatMessage>>
|
||||
|
||||
fun getInboxConversation(userId: String): Flow<RealmResults<InboxConversation>>
|
||||
|
||||
fun saveGroupMemberships(
|
||||
userID: String?,
|
||||
memberships: List<GroupMembership>,
|
||||
memberships: List<GroupMembership>
|
||||
)
|
||||
|
||||
fun saveInboxMessages(
|
||||
userID: String,
|
||||
recipientID: String,
|
||||
messages: List<ChatMessage>,
|
||||
page: Int,
|
||||
page: Int
|
||||
)
|
||||
|
||||
fun saveInboxConversations(
|
||||
userID: String,
|
||||
conversations: List<InboxConversation>,
|
||||
conversations: List<InboxConversation>
|
||||
)
|
||||
|
||||
fun getMember(userID: String?): Flow<Member?>
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ interface TaskLocalRepository : BaseLocalRepository {
|
|||
fun getTasks(
|
||||
taskType: TaskType,
|
||||
userID: String,
|
||||
includedGroupIDs: Array<String>,
|
||||
includedGroupIDs: Array<String>
|
||||
): Flow<List<Task>>
|
||||
|
||||
fun getTasks(userId: String): Flow<List<Task>>
|
||||
|
|
@ -19,7 +19,7 @@ interface TaskLocalRepository : BaseLocalRepository {
|
|||
fun saveTasks(
|
||||
ownerID: String,
|
||||
tasksOrder: TasksOrder,
|
||||
tasks: TaskList,
|
||||
tasks: TaskList
|
||||
)
|
||||
|
||||
fun deleteTask(taskID: String)
|
||||
|
|
@ -30,17 +30,17 @@ interface TaskLocalRepository : BaseLocalRepository {
|
|||
|
||||
fun markTaskCompleted(
|
||||
taskId: String,
|
||||
isCompleted: Boolean,
|
||||
isCompleted: Boolean
|
||||
)
|
||||
|
||||
fun swapTaskPosition(
|
||||
firstPosition: Int,
|
||||
secondPosition: Int,
|
||||
secondPosition: Int
|
||||
)
|
||||
|
||||
fun getTaskAtPosition(
|
||||
taskType: String,
|
||||
position: Int,
|
||||
position: Int
|
||||
): Flow<Task>
|
||||
|
||||
fun updateIsdue(daily: TaskList): TaskList
|
||||
|
|
@ -49,7 +49,7 @@ interface TaskLocalRepository : BaseLocalRepository {
|
|||
|
||||
fun saveCompletedTodos(
|
||||
userId: String,
|
||||
tasks: MutableCollection<Task>,
|
||||
tasks: MutableCollection<Task>
|
||||
)
|
||||
|
||||
fun getErroredTasks(userID: String): Flow<List<Task>>
|
||||
|
|
@ -58,6 +58,6 @@ interface TaskLocalRepository : BaseLocalRepository {
|
|||
|
||||
fun getTasksForChallenge(
|
||||
challengeID: String?,
|
||||
userID: String?,
|
||||
userID: String?
|
||||
): Flow<List<Task>>
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ interface UserLocalRepository : BaseLocalRepository {
|
|||
|
||||
fun saveUser(
|
||||
user: User,
|
||||
overrideExisting: Boolean = true,
|
||||
overrideExisting: Boolean = true
|
||||
)
|
||||
|
||||
fun saveMessages(messages: List<ChatMessage>)
|
||||
|
|
|
|||
|
|
@ -16,129 +16,129 @@ import java.util.concurrent.atomic.AtomicBoolean
|
|||
|
||||
abstract class RealmBaseLocalRepository internal constructor(override var realm: Realm) :
|
||||
BaseLocalRepository {
|
||||
override val isClosed: Boolean
|
||||
get() = realm.isClosed
|
||||
override val isClosed: Boolean
|
||||
get() = realm.isClosed
|
||||
|
||||
override fun close() {
|
||||
realm.close()
|
||||
}
|
||||
override fun close() {
|
||||
realm.close()
|
||||
}
|
||||
|
||||
override fun executeTransaction(transaction: (Realm) -> Unit) {
|
||||
pendingSaves.add(transaction)
|
||||
if (isSaving.compareAndSet(false, true)) {
|
||||
process()
|
||||
}
|
||||
}
|
||||
|
||||
override fun <T : BaseObject> getUnmanagedCopy(managedObject: T): T {
|
||||
return if (managedObject is RealmObject && managedObject.isManaged && managedObject.isValid) {
|
||||
realm.copyFromRealm(managedObject)
|
||||
} else {
|
||||
managedObject
|
||||
}
|
||||
}
|
||||
|
||||
override fun <T : BaseObject> getUnmanagedCopy(list: List<T>): List<T> {
|
||||
if (isClosed) {
|
||||
return emptyList()
|
||||
}
|
||||
return realm.copyFromRealm(list)
|
||||
}
|
||||
|
||||
companion object {
|
||||
private var isSaving = AtomicBoolean(false)
|
||||
private var pendingSaves = mutableListOf<Any>()
|
||||
}
|
||||
|
||||
private fun <T : RealmModel> copy(
|
||||
realm: Realm,
|
||||
obj: T,
|
||||
) {
|
||||
try {
|
||||
realm.insertOrUpdate(obj)
|
||||
} catch (_: java.lang.IllegalArgumentException) {
|
||||
}
|
||||
}
|
||||
|
||||
private fun process() {
|
||||
if (isClosed) {
|
||||
return
|
||||
}
|
||||
realm.executeTransaction {
|
||||
while (pendingSaves.isNotEmpty()) {
|
||||
val pending = pendingSaves.removeFirst()
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
if (pending is RealmModel) {
|
||||
copy(it, pending)
|
||||
} else if (pending as? List<BaseObject> != null) {
|
||||
it.insertOrUpdate(pending)
|
||||
} else if (pending is Function0<*>) {
|
||||
pending.invoke()
|
||||
} else if (pending as? Function1<Realm, *> != null) {
|
||||
pending.invoke(it)
|
||||
}
|
||||
}
|
||||
isSaving.set(false)
|
||||
}
|
||||
}
|
||||
|
||||
override fun <T : BaseObject> save(obj: T) {
|
||||
pendingSaves.add(obj)
|
||||
if (isSaving.compareAndSet(false, true)) {
|
||||
process()
|
||||
}
|
||||
}
|
||||
|
||||
override fun <T : BaseObject> save(objects: List<T>) {
|
||||
pendingSaves.add(objects)
|
||||
if (isSaving.compareAndSet(false, true)) {
|
||||
process()
|
||||
}
|
||||
}
|
||||
|
||||
override fun <T : BaseMainObject> modify(
|
||||
obj: T,
|
||||
transaction: (T) -> Unit,
|
||||
) {
|
||||
if (isClosed) {
|
||||
return
|
||||
}
|
||||
val liveObject = getLiveObject(obj) ?: return
|
||||
executeTransaction {
|
||||
transaction(liveObject)
|
||||
}
|
||||
}
|
||||
|
||||
override fun <T : BaseMainObject> delete(obj: T) {
|
||||
if (isClosed) {
|
||||
return
|
||||
}
|
||||
val liveObject = getLiveObject(obj) ?: return
|
||||
executeTransaction {
|
||||
liveObject.deleteFromRealm()
|
||||
}
|
||||
}
|
||||
|
||||
override fun getLiveUser(id: String): User? {
|
||||
return realm.where(User::class.java).equalTo("id", id).findFirst()
|
||||
}
|
||||
|
||||
override fun <T : BaseObject> getLiveObject(obj: T): T? {
|
||||
if (isClosed) return null
|
||||
if (obj !is RealmObject || !obj.isManaged) return obj
|
||||
val baseObject = obj as? BaseMainObject ?: return null
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return realm.where(baseObject.realmClass)
|
||||
.equalTo(baseObject.primaryIdentifierName, baseObject.primaryIdentifier)
|
||||
.findFirst() as? T
|
||||
}
|
||||
|
||||
fun queryUser(userID: String): Flow<User?> {
|
||||
return realm.where(User::class.java)
|
||||
.equalTo("id", userID)
|
||||
.findAll()
|
||||
.toFlow()
|
||||
.filter { it.isLoaded && it.isValid && !it.isEmpty() }
|
||||
.map { it.firstOrNull() }
|
||||
override fun executeTransaction(transaction: (Realm) -> Unit) {
|
||||
pendingSaves.add(transaction)
|
||||
if (isSaving.compareAndSet(false, true)) {
|
||||
process()
|
||||
}
|
||||
}
|
||||
|
||||
override fun <T : BaseObject> getUnmanagedCopy(managedObject: T): T {
|
||||
return if (managedObject is RealmObject && managedObject.isManaged && managedObject.isValid) {
|
||||
realm.copyFromRealm(managedObject)
|
||||
} else {
|
||||
managedObject
|
||||
}
|
||||
}
|
||||
|
||||
override fun <T : BaseObject> getUnmanagedCopy(list: List<T>): List<T> {
|
||||
if (isClosed) {
|
||||
return emptyList()
|
||||
}
|
||||
return realm.copyFromRealm(list)
|
||||
}
|
||||
|
||||
companion object {
|
||||
private var isSaving = AtomicBoolean(false)
|
||||
private var pendingSaves = mutableListOf<Any>()
|
||||
}
|
||||
|
||||
private fun <T : RealmModel> copy(
|
||||
realm: Realm,
|
||||
obj: T
|
||||
) {
|
||||
try {
|
||||
realm.insertOrUpdate(obj)
|
||||
} catch (_: java.lang.IllegalArgumentException) {
|
||||
}
|
||||
}
|
||||
|
||||
private fun process() {
|
||||
if (isClosed) {
|
||||
return
|
||||
}
|
||||
realm.executeTransaction {
|
||||
while (pendingSaves.isNotEmpty()) {
|
||||
val pending = pendingSaves.removeFirst()
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
if (pending is RealmModel) {
|
||||
copy(it, pending)
|
||||
} else if (pending as? List<BaseObject> != null) {
|
||||
it.insertOrUpdate(pending)
|
||||
} else if (pending is Function0<*>) {
|
||||
pending.invoke()
|
||||
} else if (pending as? Function1<Realm, *> != null) {
|
||||
pending.invoke(it)
|
||||
}
|
||||
}
|
||||
isSaving.set(false)
|
||||
}
|
||||
}
|
||||
|
||||
override fun <T : BaseObject> save(obj: T) {
|
||||
pendingSaves.add(obj)
|
||||
if (isSaving.compareAndSet(false, true)) {
|
||||
process()
|
||||
}
|
||||
}
|
||||
|
||||
override fun <T : BaseObject> save(objects: List<T>) {
|
||||
pendingSaves.add(objects)
|
||||
if (isSaving.compareAndSet(false, true)) {
|
||||
process()
|
||||
}
|
||||
}
|
||||
|
||||
override fun <T : BaseMainObject> modify(
|
||||
obj: T,
|
||||
transaction: (T) -> Unit
|
||||
) {
|
||||
if (isClosed) {
|
||||
return
|
||||
}
|
||||
val liveObject = getLiveObject(obj) ?: return
|
||||
executeTransaction {
|
||||
transaction(liveObject)
|
||||
}
|
||||
}
|
||||
|
||||
override fun <T : BaseMainObject> delete(obj: T) {
|
||||
if (isClosed) {
|
||||
return
|
||||
}
|
||||
val liveObject = getLiveObject(obj) ?: return
|
||||
executeTransaction {
|
||||
liveObject.deleteFromRealm()
|
||||
}
|
||||
}
|
||||
|
||||
override fun getLiveUser(id: String): User? {
|
||||
return realm.where(User::class.java).equalTo("id", id).findFirst()
|
||||
}
|
||||
|
||||
override fun <T : BaseObject> getLiveObject(obj: T): T? {
|
||||
if (isClosed) return null
|
||||
if (obj !is RealmObject || !obj.isManaged) return obj
|
||||
val baseObject = obj as? BaseMainObject ?: return null
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return realm.where(baseObject.realmClass)
|
||||
.equalTo(baseObject.primaryIdentifierName, baseObject.primaryIdentifier)
|
||||
.findFirst() as? T
|
||||
}
|
||||
|
||||
fun queryUser(userID: String): Flow<User?> {
|
||||
return realm.where(User::class.java)
|
||||
.equalTo("id", userID)
|
||||
.findAll()
|
||||
.toFlow()
|
||||
.filter { it.isLoaded && it.isValid && !it.isEmpty() }
|
||||
.map { it.firstOrNull() }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ class RealmChallengeLocalRepository(realm: Realm) :
|
|||
ChallengeLocalRepository {
|
||||
override fun isChallengeMember(
|
||||
userID: String,
|
||||
challengeID: String,
|
||||
challengeID: String
|
||||
): Flow<Boolean> =
|
||||
realm.where(ChallengeMembership::class.java)
|
||||
.equalTo("userID", userID)
|
||||
|
|
@ -32,7 +32,7 @@ class RealmChallengeLocalRepository(realm: Realm) :
|
|||
|
||||
override fun getChallengeMembership(
|
||||
userId: String,
|
||||
id: String,
|
||||
id: String
|
||||
) =
|
||||
realm.where(ChallengeMembership::class.java)
|
||||
.equalTo("userID", userId)
|
||||
|
|
@ -106,7 +106,7 @@ class RealmChallengeLocalRepository(realm: Realm) :
|
|||
override fun setParticipating(
|
||||
userID: String,
|
||||
challengeID: String,
|
||||
isParticipating: Boolean,
|
||||
isParticipating: Boolean
|
||||
) {
|
||||
val user = realm.where(User::class.java).equalTo("id", userID).findFirst() ?: return
|
||||
executeTransaction {
|
||||
|
|
@ -125,7 +125,7 @@ class RealmChallengeLocalRepository(realm: Realm) :
|
|||
challenges: List<Challenge>,
|
||||
clearChallenges: Boolean,
|
||||
memberOnly: Boolean,
|
||||
userID: String,
|
||||
userID: String
|
||||
) {
|
||||
if (clearChallenges || memberOnly) {
|
||||
val localChallenges = realm.where(Challenge::class.java).findAll().createSnapshot()
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ class RealmCustomizationLocalRepository(realm: Realm) :
|
|||
override fun getCustomizations(
|
||||
type: String,
|
||||
category: String?,
|
||||
onlyAvailable: Boolean,
|
||||
onlyAvailable: Boolean
|
||||
): Flow<List<Customization>> {
|
||||
var query =
|
||||
realm.where(Customization::class.java)
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ class RealmInventoryLocalRepository(realm: Realm) :
|
|||
|
||||
override fun getEquipmentType(
|
||||
type: String,
|
||||
set: String,
|
||||
set: String
|
||||
): Flow<out List<Equipment>> {
|
||||
return realm.where(Equipment::class.java)
|
||||
.equalTo("type", type)
|
||||
|
|
@ -103,7 +103,7 @@ class RealmInventoryLocalRepository(realm: Realm) :
|
|||
override fun getOwnedItems(
|
||||
itemType: String,
|
||||
userID: String,
|
||||
includeZero: Boolean,
|
||||
includeZero: Boolean
|
||||
): Flow<List<OwnedItem>> {
|
||||
return queryUser(userID).map {
|
||||
val items =
|
||||
|
|
@ -130,7 +130,7 @@ class RealmInventoryLocalRepository(realm: Realm) :
|
|||
|
||||
override fun getItems(
|
||||
itemClass: Class<out Item>,
|
||||
keys: Array<String>,
|
||||
keys: Array<String>
|
||||
): Flow<List<Item>> {
|
||||
return realm.where(itemClass).`in`("key", keys).findAll().toFlow()
|
||||
.filter { it.isLoaded }
|
||||
|
|
@ -138,7 +138,7 @@ class RealmInventoryLocalRepository(realm: Realm) :
|
|||
|
||||
override fun getOwnedItems(
|
||||
userID: String,
|
||||
includeZero: Boolean,
|
||||
includeZero: Boolean
|
||||
): Flow<Map<String, OwnedItem>> {
|
||||
return queryUser(userID)
|
||||
.filterNotNull()
|
||||
|
|
@ -178,7 +178,7 @@ class RealmInventoryLocalRepository(realm: Realm) :
|
|||
override fun getMounts(
|
||||
type: String?,
|
||||
group: String?,
|
||||
color: String?,
|
||||
color: String?
|
||||
): Flow<List<Mount>> {
|
||||
var query =
|
||||
realm.where(Mount::class.java)
|
||||
|
|
@ -217,7 +217,7 @@ class RealmInventoryLocalRepository(realm: Realm) :
|
|||
override fun getPets(
|
||||
type: String?,
|
||||
group: String?,
|
||||
color: String?,
|
||||
color: String?
|
||||
): Flow<List<Pet>> {
|
||||
var query =
|
||||
realm.where(Pet::class.java)
|
||||
|
|
@ -256,7 +256,7 @@ class RealmInventoryLocalRepository(realm: Realm) :
|
|||
type: String,
|
||||
key: String,
|
||||
userID: String,
|
||||
amountToAdd: Int,
|
||||
amountToAdd: Int
|
||||
) {
|
||||
val item = getOwnedItem(userID, type, key, true).firstOrNull()
|
||||
if (item != null) {
|
||||
|
|
@ -266,7 +266,7 @@ class RealmInventoryLocalRepository(realm: Realm) :
|
|||
|
||||
override fun changeOwnedCount(
|
||||
item: OwnedItem,
|
||||
amountToAdd: Int?,
|
||||
amountToAdd: Int?
|
||||
) {
|
||||
val liveItem = getLiveObject(item) ?: return
|
||||
amountToAdd?.let { amount ->
|
||||
|
|
@ -278,7 +278,7 @@ class RealmInventoryLocalRepository(realm: Realm) :
|
|||
userID: String,
|
||||
type: String,
|
||||
key: String,
|
||||
includeZero: Boolean,
|
||||
includeZero: Boolean
|
||||
): Flow<OwnedItem> {
|
||||
return queryUser(userID)
|
||||
.filterNotNull()
|
||||
|
|
@ -291,7 +291,7 @@ class RealmInventoryLocalRepository(realm: Realm) :
|
|||
"quests" -> it.items?.quests
|
||||
else -> emptyList()
|
||||
} ?: emptyList()
|
||||
)
|
||||
)
|
||||
items = items.filter { it.key == key }
|
||||
if (includeZero) {
|
||||
items
|
||||
|
|
@ -305,7 +305,7 @@ class RealmInventoryLocalRepository(realm: Realm) :
|
|||
|
||||
override fun getItem(
|
||||
type: String,
|
||||
key: String,
|
||||
key: String
|
||||
): Flow<Item> {
|
||||
val itemClass: Class<out RealmObject> =
|
||||
when (type) {
|
||||
|
|
@ -374,7 +374,7 @@ class RealmInventoryLocalRepository(realm: Realm) :
|
|||
override fun hatchPet(
|
||||
eggKey: String,
|
||||
potionKey: String,
|
||||
userID: String,
|
||||
userID: String
|
||||
) {
|
||||
val newPet = OwnedPet()
|
||||
newPet.key = "$eggKey-$potionKey"
|
||||
|
|
@ -399,7 +399,7 @@ class RealmInventoryLocalRepository(realm: Realm) :
|
|||
|
||||
override fun save(
|
||||
items: Items,
|
||||
userID: String,
|
||||
userID: String
|
||||
) {
|
||||
val user = realm.where(User::class.java).equalTo("id", userID).findFirst() ?: return
|
||||
items.setItemTypes()
|
||||
|
|
@ -411,7 +411,7 @@ class RealmInventoryLocalRepository(realm: Realm) :
|
|||
override fun unhatchPet(
|
||||
eggKey: String,
|
||||
potionKey: String,
|
||||
userID: String,
|
||||
userID: String
|
||||
) {
|
||||
val pet = realm.where(OwnedPet::class.java).equalTo("key", "$eggKey-$potionKey").findFirst()
|
||||
val user = realm.where(User::class.java).equalTo("id", userID).findFirst() ?: return
|
||||
|
|
@ -429,7 +429,7 @@ class RealmInventoryLocalRepository(realm: Realm) :
|
|||
foodKey: String,
|
||||
petKey: String,
|
||||
feedValue: Int,
|
||||
userID: String,
|
||||
userID: String
|
||||
) {
|
||||
val user = realm.where(User::class.java).equalTo("id", userID).findFirst() ?: return
|
||||
val pet = user.items?.pets?.firstOrNull { it.key == petKey } ?: return
|
||||
|
|
@ -484,7 +484,7 @@ class RealmInventoryLocalRepository(realm: Realm) :
|
|||
|
||||
override fun soldItem(
|
||||
userID: String,
|
||||
updatedUser: User,
|
||||
updatedUser: User
|
||||
): User {
|
||||
val user =
|
||||
realm.where(User::class.java)
|
||||
|
|
@ -522,7 +522,7 @@ class RealmInventoryLocalRepository(realm: Realm) :
|
|||
realm.where(Food::class.java)
|
||||
.lessThan("event.start", Date())
|
||||
.greaterThan("event.end", Date())
|
||||
.findAll().toFlow(),
|
||||
.findAll().toFlow()
|
||||
) { items, food ->
|
||||
items.addAll(food)
|
||||
items
|
||||
|
|
@ -531,7 +531,7 @@ class RealmInventoryLocalRepository(realm: Realm) :
|
|||
realm.where(HatchingPotion::class.java)
|
||||
.lessThan("event.start", Date())
|
||||
.greaterThan("event.end", Date())
|
||||
.findAll().toFlow(),
|
||||
.findAll().toFlow()
|
||||
) { items, food ->
|
||||
items.addAll(food)
|
||||
items
|
||||
|
|
@ -540,7 +540,7 @@ class RealmInventoryLocalRepository(realm: Realm) :
|
|||
realm.where(QuestContent::class.java)
|
||||
.lessThan("event.start", Date())
|
||||
.greaterThan("event.end", Date())
|
||||
.findAll().toFlow(),
|
||||
.findAll().toFlow()
|
||||
) { items, food ->
|
||||
items.addAll(food)
|
||||
items
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ class RealmSocialLocalRepository(realm: Realm) :
|
|||
SocialLocalRepository {
|
||||
override fun getGroupMembership(
|
||||
userId: String,
|
||||
id: String,
|
||||
id: String
|
||||
) =
|
||||
realm.where(GroupMembership::class.java)
|
||||
.equalTo("userID", userId)
|
||||
|
|
@ -43,7 +43,7 @@ class RealmSocialLocalRepository(realm: Realm) :
|
|||
override fun updateMembership(
|
||||
userId: String,
|
||||
id: String,
|
||||
isMember: Boolean,
|
||||
isMember: Boolean
|
||||
) {
|
||||
if (isMember) {
|
||||
save(GroupMembership(userId, id))
|
||||
|
|
@ -73,7 +73,7 @@ class RealmSocialLocalRepository(realm: Realm) :
|
|||
userID: String,
|
||||
recipientID: String,
|
||||
messages: List<ChatMessage>,
|
||||
page: Int,
|
||||
page: Int
|
||||
) {
|
||||
messages.forEach { it.userID = userID }
|
||||
for (message in messages) {
|
||||
|
|
@ -103,7 +103,7 @@ class RealmSocialLocalRepository(realm: Realm) :
|
|||
|
||||
override fun saveInboxConversations(
|
||||
userID: String,
|
||||
conversations: List<InboxConversation>,
|
||||
conversations: List<InboxConversation>
|
||||
) {
|
||||
conversations.forEach { it.userID = userID }
|
||||
save(conversations)
|
||||
|
|
@ -131,7 +131,7 @@ class RealmSocialLocalRepository(realm: Realm) :
|
|||
|
||||
override fun saveGroupMemberships(
|
||||
userID: String?,
|
||||
memberships: List<GroupMembership>,
|
||||
memberships: List<GroupMembership>
|
||||
) {
|
||||
save(memberships)
|
||||
if (userID != null) {
|
||||
|
|
@ -153,7 +153,7 @@ class RealmSocialLocalRepository(realm: Realm) :
|
|||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
override fun getUserGroups(
|
||||
userID: String,
|
||||
type: String?,
|
||||
type: String?
|
||||
) =
|
||||
realm.where(GroupMembership::class.java)
|
||||
.equalTo("userID", userID)
|
||||
|
|
@ -167,7 +167,7 @@ class RealmSocialLocalRepository(realm: Realm) :
|
|||
"id",
|
||||
memberships.map {
|
||||
return@map it.groupID
|
||||
}.toTypedArray(),
|
||||
}.toTypedArray()
|
||||
)
|
||||
.sort("memberCount", Sort.DESCENDING)
|
||||
.findAll()
|
||||
|
|
@ -213,7 +213,7 @@ class RealmSocialLocalRepository(realm: Realm) :
|
|||
|
||||
override fun updateRSVPNeeded(
|
||||
user: User?,
|
||||
newValue: Boolean,
|
||||
newValue: Boolean
|
||||
) {
|
||||
executeTransaction { user?.party?.quest?.rsvpNeeded = newValue }
|
||||
}
|
||||
|
|
@ -221,7 +221,7 @@ class RealmSocialLocalRepository(realm: Realm) :
|
|||
override fun likeMessage(
|
||||
chatMessage: ChatMessage,
|
||||
userId: String,
|
||||
liked: Boolean,
|
||||
liked: Boolean
|
||||
) {
|
||||
val liveMessage = getLiveObject(chatMessage)
|
||||
if (liveMessage == null) {
|
||||
|
|
@ -253,7 +253,7 @@ class RealmSocialLocalRepository(realm: Realm) :
|
|||
|
||||
override fun savePartyMembers(
|
||||
groupId: String?,
|
||||
members: List<Member>,
|
||||
members: List<Member>
|
||||
) {
|
||||
save(members)
|
||||
if (groupId != null) {
|
||||
|
|
@ -275,7 +275,7 @@ class RealmSocialLocalRepository(realm: Realm) :
|
|||
|
||||
override fun rejectGroupInvitation(
|
||||
userID: String,
|
||||
groupID: String,
|
||||
groupID: String
|
||||
) {
|
||||
val user = realm.where(User::class.java).equalTo("id", userID).findFirst()
|
||||
executeTransaction {
|
||||
|
|
@ -292,7 +292,7 @@ class RealmSocialLocalRepository(realm: Realm) :
|
|||
|
||||
override fun setQuestActivity(
|
||||
party: Group?,
|
||||
active: Boolean,
|
||||
active: Boolean
|
||||
) {
|
||||
if (party == null) return
|
||||
val liveParty = getLiveObject(party)
|
||||
|
|
@ -303,7 +303,7 @@ class RealmSocialLocalRepository(realm: Realm) :
|
|||
|
||||
override fun saveChatMessages(
|
||||
groupId: String?,
|
||||
chatMessages: List<ChatMessage>,
|
||||
chatMessages: List<ChatMessage>
|
||||
) {
|
||||
save(chatMessages)
|
||||
if (groupId != null) {
|
||||
|
|
@ -331,7 +331,7 @@ class RealmSocialLocalRepository(realm: Realm) :
|
|||
|
||||
override fun getInboxMessages(
|
||||
userId: String,
|
||||
replyToUserID: String?,
|
||||
replyToUserID: String?
|
||||
) =
|
||||
realm.where(ChatMessage::class.java)
|
||||
.equalTo("isInboxMessage", true)
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ class RealmTaskLocalRepository(realm: Realm) :
|
|||
override fun getTasks(
|
||||
taskType: TaskType,
|
||||
userID: String,
|
||||
includedGroupIDs: Array<String>,
|
||||
includedGroupIDs: Array<String>
|
||||
): Flow<List<Task>> {
|
||||
if (realm.isClosed) return emptyFlow()
|
||||
return findTasks(taskType, userID)
|
||||
|
|
@ -34,7 +34,7 @@ class RealmTaskLocalRepository(realm: Realm) :
|
|||
|
||||
private fun findTasks(
|
||||
taskType: TaskType,
|
||||
ownerID: String,
|
||||
ownerID: String
|
||||
): RealmResults<Task> {
|
||||
return realm.where(Task::class.java)
|
||||
.equalTo("typeValue", taskType.value)
|
||||
|
|
@ -55,7 +55,7 @@ class RealmTaskLocalRepository(realm: Realm) :
|
|||
override fun saveTasks(
|
||||
ownerID: String,
|
||||
tasksOrder: TasksOrder,
|
||||
tasks: TaskList,
|
||||
tasks: TaskList
|
||||
) {
|
||||
val sortedTasks = mutableListOf<Task>()
|
||||
sortedTasks.addAll(sortTasks(tasks.tasks, tasksOrder.habits))
|
||||
|
|
@ -85,7 +85,7 @@ class RealmTaskLocalRepository(realm: Realm) :
|
|||
|
||||
override fun saveCompletedTodos(
|
||||
userId: String,
|
||||
tasks: MutableCollection<Task>,
|
||||
tasks: MutableCollection<Task>
|
||||
) {
|
||||
removeCompletedTodos(userId, tasks)
|
||||
executeTransaction { realm1 -> realm1.insertOrUpdate(tasks) }
|
||||
|
|
@ -113,7 +113,7 @@ class RealmTaskLocalRepository(realm: Realm) :
|
|||
|
||||
private fun sortTasks(
|
||||
taskMap: MutableMap<String, Task>,
|
||||
taskOrder: List<String>,
|
||||
taskOrder: List<String>
|
||||
): List<Task> {
|
||||
val taskList = ArrayList<Task>()
|
||||
var position = 0
|
||||
|
|
@ -131,7 +131,7 @@ class RealmTaskLocalRepository(realm: Realm) :
|
|||
|
||||
private fun removeOldTasks(
|
||||
ownerID: String,
|
||||
onlineTaskList: List<Task>,
|
||||
onlineTaskList: List<Task>
|
||||
) {
|
||||
if (realm.isClosed) return
|
||||
val localTasks =
|
||||
|
|
@ -157,7 +157,7 @@ class RealmTaskLocalRepository(realm: Realm) :
|
|||
|
||||
private fun removeCompletedTodos(
|
||||
userID: String,
|
||||
onlineTaskList: MutableCollection<Task>,
|
||||
onlineTaskList: MutableCollection<Task>
|
||||
) {
|
||||
val localTasks =
|
||||
realm.where(Task::class.java)
|
||||
|
|
@ -206,7 +206,7 @@ class RealmTaskLocalRepository(realm: Realm) :
|
|||
|
||||
override fun markTaskCompleted(
|
||||
taskId: String,
|
||||
isCompleted: Boolean,
|
||||
isCompleted: Boolean
|
||||
) {
|
||||
val task = realm.where(Task::class.java).equalTo("id", taskId).findFirst()
|
||||
executeTransaction { task?.completed = true }
|
||||
|
|
@ -214,7 +214,7 @@ class RealmTaskLocalRepository(realm: Realm) :
|
|||
|
||||
override fun swapTaskPosition(
|
||||
firstPosition: Int,
|
||||
secondPosition: Int,
|
||||
secondPosition: Int
|
||||
) {
|
||||
val firstTask = realm.where(Task::class.java).equalTo("position", firstPosition).findFirst()
|
||||
val secondTask =
|
||||
|
|
@ -229,7 +229,7 @@ class RealmTaskLocalRepository(realm: Realm) :
|
|||
|
||||
override fun getTaskAtPosition(
|
||||
taskType: String,
|
||||
position: Int,
|
||||
position: Int
|
||||
): Flow<Task> {
|
||||
return realm.where(Task::class.java).equalTo("typeValue", taskType)
|
||||
.equalTo("position", position)
|
||||
|
|
@ -282,7 +282,7 @@ class RealmTaskLocalRepository(realm: Realm) :
|
|||
|
||||
override fun getTasksForChallenge(
|
||||
challengeID: String?,
|
||||
userID: String?,
|
||||
userID: String?
|
||||
): Flow<List<Task>> {
|
||||
return realm.where(Task::class.java)
|
||||
.equalTo("challengeID", challengeID)
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ class RealmUserLocalRepository(realm: Realm) :
|
|||
|
||||
override fun saveUser(
|
||||
user: User,
|
||||
overrideExisting: Boolean,
|
||||
overrideExisting: Boolean
|
||||
) {
|
||||
if (realm.isClosed) return
|
||||
val oldUser =
|
||||
|
|
@ -108,7 +108,7 @@ class RealmUserLocalRepository(realm: Realm) :
|
|||
|
||||
private fun removeOldTags(
|
||||
userId: String,
|
||||
onlineTags: List<Tag>,
|
||||
onlineTags: List<Tag>
|
||||
) {
|
||||
val tags = realm.where(Tag::class.java).equalTo("userId", userId).findAll().createSnapshot()
|
||||
val tagsToDelete = tags.filterNot { onlineTags.contains(it) }
|
||||
|
|
|
|||
|
|
@ -5,21 +5,21 @@ import com.habitrpg.android.habitica.ui.views.dialogs.HabiticaAlertDialog
|
|||
|
||||
fun HabiticaAlertDialog.addOkButton(
|
||||
isPrimary: Boolean = true,
|
||||
listener: ((HabiticaAlertDialog, Int) -> Unit)? = null,
|
||||
listener: ((HabiticaAlertDialog, Int) -> Unit)? = null
|
||||
) {
|
||||
this.addButton(R.string.ok, isPrimary, false, true, listener)
|
||||
}
|
||||
|
||||
fun HabiticaAlertDialog.addCloseButton(
|
||||
isPrimary: Boolean = false,
|
||||
listener: ((HabiticaAlertDialog, Int) -> Unit)? = null,
|
||||
listener: ((HabiticaAlertDialog, Int) -> Unit)? = null
|
||||
) {
|
||||
this.addButton(R.string.close, isPrimary, false, true, listener)
|
||||
}
|
||||
|
||||
fun HabiticaAlertDialog.addCancelButton(
|
||||
isPrimary: Boolean = false,
|
||||
listener: ((HabiticaAlertDialog, Int) -> Unit)? = null,
|
||||
listener: ((HabiticaAlertDialog, Int) -> Unit)? = null
|
||||
) {
|
||||
this.addButton(R.string.cancel, isPrimary, false, true, listener)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ fun Animal.getTranslatedType(c: Context?): String? {
|
|||
|
||||
fun getTranslatedAnimalType(
|
||||
c: Context?,
|
||||
type: String?,
|
||||
type: String?
|
||||
): String? {
|
||||
if (c == null) {
|
||||
return type
|
||||
|
|
|
|||
|
|
@ -6,6 +6,6 @@ import android.util.AttributeSet
|
|||
|
||||
fun AttributeSet.styledAttributes(
|
||||
context: Context?,
|
||||
style: IntArray,
|
||||
style: IntArray
|
||||
): TypedArray? =
|
||||
context?.theme?.obtainStyledAttributes(this, style, 0, 0)
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ class DateUtils {
|
|||
fun createDate(
|
||||
year: Int,
|
||||
month: Int,
|
||||
day: Int,
|
||||
day: Int
|
||||
): Date {
|
||||
val cal = Calendar.getInstance()
|
||||
cal.set(Calendar.YEAR, year)
|
||||
|
|
@ -32,7 +32,7 @@ class DateUtils {
|
|||
|
||||
fun isSameDay(
|
||||
date1: Date,
|
||||
date2: Date,
|
||||
date2: Date
|
||||
): Boolean {
|
||||
val cal1 = Calendar.getInstance()
|
||||
val cal2 = Calendar.getInstance()
|
||||
|
|
|
|||
|
|
@ -3,8 +3,6 @@ package com.habitrpg.android.habitica.extensions
|
|||
import com.habitrpg.common.habitica.helpers.LanguageHelper
|
||||
import java.util.Locale
|
||||
|
||||
|
||||
|
||||
fun Locale.getSystemDefault(): Locale {
|
||||
return LanguageHelper.systemLocale
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import java.util.Locale
|
|||
|
||||
fun Resources.forceLocale(
|
||||
activity: BaseActivity,
|
||||
locale: Locale,
|
||||
locale: Locale
|
||||
) {
|
||||
Locale.setDefault(locale)
|
||||
val configuration = Configuration()
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ class OnChangeTextWatcher(private var function: (CharSequence?, Int, Int, Int) -
|
|||
s: CharSequence?,
|
||||
start: Int,
|
||||
count: Int,
|
||||
after: Int,
|
||||
after: Int
|
||||
) { // no-on
|
||||
}
|
||||
|
||||
|
|
@ -20,7 +20,7 @@ class OnChangeTextWatcher(private var function: (CharSequence?, Int, Int, Int) -
|
|||
s: CharSequence?,
|
||||
start: Int,
|
||||
before: Int,
|
||||
count: Int,
|
||||
count: Int
|
||||
) {
|
||||
function(s, start, before, count)
|
||||
}
|
||||
|
|
@ -35,7 +35,7 @@ class BeforeChangeTextWatcher(private var function: (CharSequence?, Int, Int, In
|
|||
s: CharSequence?,
|
||||
start: Int,
|
||||
count: Int,
|
||||
after: Int,
|
||||
after: Int
|
||||
) {
|
||||
function(s, start, count, after)
|
||||
}
|
||||
|
|
@ -44,7 +44,7 @@ class BeforeChangeTextWatcher(private var function: (CharSequence?, Int, Int, In
|
|||
s: CharSequence?,
|
||||
start: Int,
|
||||
before: Int,
|
||||
count: Int,
|
||||
count: Int
|
||||
) { // no-on
|
||||
}
|
||||
}
|
||||
|
|
@ -58,7 +58,7 @@ class AfterChangeTextWatcher(private var function: (Editable?) -> Unit) : TextWa
|
|||
s: CharSequence?,
|
||||
start: Int,
|
||||
count: Int,
|
||||
after: Int,
|
||||
after: Int
|
||||
) { // no-on
|
||||
}
|
||||
|
||||
|
|
@ -66,7 +66,7 @@ class AfterChangeTextWatcher(private var function: (Editable?) -> Unit) : TextWa
|
|||
s: CharSequence?,
|
||||
start: Int,
|
||||
before: Int,
|
||||
count: Int,
|
||||
count: Int
|
||||
) { // no-on
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import com.habitrpg.common.habitica.extensions.getThemeColor
|
|||
|
||||
fun Window.updateStatusBarColor(
|
||||
color: Int,
|
||||
isLight: Boolean,
|
||||
isLight: Boolean
|
||||
) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
statusBarColor = color
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ fun String.parseToZonedDateTime(): ZonedDateTime? {
|
|||
formatter().parseBest(
|
||||
this,
|
||||
ZonedDateTime::from,
|
||||
LocalDateTime::from,
|
||||
LocalDateTime::from
|
||||
)
|
||||
return if (parsed is ZonedDateTime) {
|
||||
parsed
|
||||
|
|
@ -65,4 +65,4 @@ fun Calendar.matchesRepeatDays(repeatDays: Days?): Boolean {
|
|||
Calendar.SUNDAY -> repeatDays.su
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import kotlin.time.toDuration
|
|||
enum class AdType {
|
||||
ARMOIRE,
|
||||
SPELL,
|
||||
FAINT,
|
||||
FAINT
|
||||
;
|
||||
|
||||
val adUnitID: String
|
||||
|
|
@ -68,7 +68,7 @@ class AdHandler(val activity: Activity, val type: AdType, val rewardAction: (Boo
|
|||
UNINITIALIZED,
|
||||
INITIALIZING,
|
||||
READY,
|
||||
DISABLED,
|
||||
DISABLED
|
||||
}
|
||||
|
||||
private lateinit var sharedPreferences: SharedPreferences
|
||||
|
|
@ -103,7 +103,7 @@ class AdHandler(val activity: Activity, val type: AdType, val rewardAction: (Boo
|
|||
|
||||
fun initialize(
|
||||
context: Context,
|
||||
onComplete: () -> Unit,
|
||||
onComplete: () -> Unit
|
||||
) {
|
||||
if (currentAdStatus != AdStatus.UNINITIALIZED) return
|
||||
|
||||
|
|
@ -125,7 +125,7 @@ class AdHandler(val activity: Activity, val type: AdType, val rewardAction: (Boo
|
|||
|
||||
fun whenAdsInitialized(
|
||||
context: Context,
|
||||
onComplete: () -> Unit,
|
||||
onComplete: () -> Unit
|
||||
) {
|
||||
when (currentAdStatus) {
|
||||
AdStatus.READY -> {
|
||||
|
|
|
|||
|
|
@ -13,12 +13,12 @@ import com.habitrpg.android.habitica.R
|
|||
|
||||
enum class AnalyticsTarget {
|
||||
AMPLITUDE,
|
||||
FIREBASE,
|
||||
FIREBASE
|
||||
}
|
||||
|
||||
enum class EventCategory(val key: String) {
|
||||
BEHAVIOUR("behaviour"),
|
||||
NAVIGATION("navigation"),
|
||||
NAVIGATION("navigation")
|
||||
}
|
||||
|
||||
enum class HitType(val key: String) {
|
||||
|
|
@ -26,7 +26,7 @@ enum class HitType(val key: String) {
|
|||
PAGEVIEW("pageview"),
|
||||
CREATE_WIDGET("create"),
|
||||
REMOVE_WIDGET("remove"),
|
||||
UPDATE_WIDGET("update"),
|
||||
UPDATE_WIDGET("update")
|
||||
}
|
||||
|
||||
object Analytics {
|
||||
|
|
@ -39,7 +39,7 @@ object Analytics {
|
|||
category: EventCategory?,
|
||||
hitType: HitType?,
|
||||
additionalData: Map<String, Any>? = null,
|
||||
target: AnalyticsTarget? = null,
|
||||
target: AnalyticsTarget? = null
|
||||
) {
|
||||
if (BuildConfig.DEBUG) {
|
||||
return
|
||||
|
|
@ -49,7 +49,7 @@ object Analytics {
|
|||
"eventAction" to eventAction,
|
||||
"eventCategory" to category?.key,
|
||||
"hitType" to hitType?.key,
|
||||
"status" to "displayed",
|
||||
"status" to "displayed"
|
||||
)
|
||||
if (additionalData != null) {
|
||||
data.putAll(additionalData)
|
||||
|
|
@ -79,8 +79,8 @@ object Analytics {
|
|||
Amplitude(
|
||||
Configuration(
|
||||
context.getString(R.string.amplitude_app_id),
|
||||
context,
|
||||
),
|
||||
context
|
||||
)
|
||||
)
|
||||
firebase = FirebaseAnalytics.getInstance(context)
|
||||
}
|
||||
|
|
@ -109,7 +109,7 @@ object Analytics {
|
|||
|
||||
fun setUserProperty(
|
||||
identifier: String,
|
||||
value: Any?,
|
||||
value: Any?
|
||||
) {
|
||||
if (this::amplitude.isInitialized) {
|
||||
amplitude.identify(mapOf(identifier to value))
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ class AppConfigManager(contentRepository: ContentRepository) :
|
|||
getHabiticaPromotionFromKey(
|
||||
event.promo ?: event.eventKey ?: "",
|
||||
event.start,
|
||||
event.end,
|
||||
event.end
|
||||
)
|
||||
if (thisPromo != null) {
|
||||
promo = thisPromo
|
||||
|
|
@ -147,7 +147,6 @@ class AppConfigManager(contentRepository: ContentRepository) :
|
|||
return null
|
||||
}
|
||||
|
||||
|
||||
fun knownIssues(): List<Map<String, String>> {
|
||||
val type = object : TypeToken<List<Map<String, String>>>() {}.type
|
||||
return Gson().fromJson(remoteConfig.getString("knownIssues"), type)
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ class AprilFoolsHandler {
|
|||
|
||||
fun handle(
|
||||
name: String?,
|
||||
endDate: Date?,
|
||||
endDate: Date?
|
||||
) {
|
||||
if (endDate != null) {
|
||||
this.eventEnd = endDate
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import com.habitrpg.android.habitica.models.tasks.Task
|
|||
interface GroupPlanInfoProvider {
|
||||
fun assignedTextForTask(
|
||||
resources: Resources,
|
||||
assignedUsers: List<String>,
|
||||
assignedUsers: List<String>
|
||||
): String
|
||||
|
||||
fun canScoreTask(task: Task): Boolean
|
||||
|
|
|
|||
|
|
@ -15,18 +15,18 @@ import kotlin.coroutines.EmptyCoroutineContext
|
|||
@Composable
|
||||
fun <T> rememberFlow(
|
||||
flow: Flow<T>,
|
||||
lifecycleOwner: LifecycleOwner = LocalLifecycleOwner.current,
|
||||
lifecycleOwner: LifecycleOwner = LocalLifecycleOwner.current
|
||||
): Flow<T> {
|
||||
return remember(
|
||||
key1 = flow,
|
||||
key2 = lifecycleOwner,
|
||||
key2 = lifecycleOwner
|
||||
) { flow.flowWithLifecycle(lifecycleOwner.lifecycle, Lifecycle.State.STARTED) }
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun <T : R, R> Flow<T>.collectAsStateLifecycleAware(
|
||||
initial: R,
|
||||
context: CoroutineContext = EmptyCoroutineContext,
|
||||
context: CoroutineContext = EmptyCoroutineContext
|
||||
): State<R> {
|
||||
val lifecycleAwareFlow = rememberFlow(flow = this)
|
||||
return lifecycleAwareFlow.collectAsState(initial = initial, context = context)
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ class NotificationOpenHandler {
|
|||
companion object {
|
||||
fun handleOpenedByNotification(
|
||||
identifier: String,
|
||||
intent: Intent,
|
||||
intent: Intent
|
||||
) {
|
||||
MainScope().launch(context = Dispatchers.Main) {
|
||||
when (identifier) {
|
||||
|
|
@ -22,13 +22,13 @@ class NotificationOpenHandler {
|
|||
PushNotificationManager.QUEST_INVITE_PUSH_NOTIFICATION_KEY -> openPartyScreen()
|
||||
PushNotificationManager.GUILD_INVITE_PUSH_NOTIFICATION_KEY ->
|
||||
openGuildDetailScreen(
|
||||
intent.getStringExtra("groupID"),
|
||||
intent.getStringExtra("groupID")
|
||||
)
|
||||
|
||||
PushNotificationManager.RECEIVED_PRIVATE_MESSAGE_PUSH_NOTIFICATION_KEY ->
|
||||
openPrivateMessageScreen(
|
||||
intent.getStringExtra("replyToUUID"),
|
||||
intent.getStringExtra("replyToUsername"),
|
||||
intent.getStringExtra("replyToUsername")
|
||||
)
|
||||
|
||||
PushNotificationManager.CHANGE_USERNAME_PUSH_NOTIFICATION_KEY -> openSettingsScreen()
|
||||
|
|
@ -36,13 +36,13 @@ class NotificationOpenHandler {
|
|||
PushNotificationManager.CHAT_MENTION_NOTIFICATION_KEY ->
|
||||
handleChatMessage(
|
||||
intent.getStringExtra("type"),
|
||||
intent.getStringExtra("groupID"),
|
||||
intent.getStringExtra("groupID")
|
||||
)
|
||||
|
||||
PushNotificationManager.GROUP_ACTIVITY_NOTIFICATION_KEY ->
|
||||
handleChatMessage(
|
||||
intent.getStringExtra("type"),
|
||||
intent.getStringExtra("groupID"),
|
||||
intent.getStringExtra("groupID")
|
||||
)
|
||||
|
||||
PushNotificationManager.G1G1_PROMO_KEY -> openGiftOneGetOneInfoScreen()
|
||||
|
|
@ -58,18 +58,18 @@ class NotificationOpenHandler {
|
|||
private fun openSubscriptionScreen() {
|
||||
MainNavigationController.navigate(
|
||||
R.id.gemPurchaseActivity,
|
||||
bundleOf(Pair("openSubscription", true)),
|
||||
bundleOf(Pair("openSubscription", true))
|
||||
)
|
||||
}
|
||||
|
||||
private fun openPrivateMessageScreen(
|
||||
userID: String?,
|
||||
userName: String?,
|
||||
userName: String?
|
||||
) {
|
||||
if (userID != null && userName != null) {
|
||||
MainNavigationController.navigate(
|
||||
R.id.inboxMessageListFragment,
|
||||
bundleOf("userID" to userID, "username" to userName),
|
||||
bundleOf("userID" to userID, "username" to userName)
|
||||
)
|
||||
} else {
|
||||
MainNavigationController.navigate(R.id.inboxFragment)
|
||||
|
|
@ -80,7 +80,7 @@ class NotificationOpenHandler {
|
|||
val tabToOpen = if (isChatNotification) 1 else 0
|
||||
MainNavigationController.navigate(
|
||||
R.id.partyFragment,
|
||||
bundleOf("tabToOpen" to tabToOpen),
|
||||
bundleOf("tabToOpen" to tabToOpen)
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -106,7 +106,7 @@ class NotificationOpenHandler {
|
|||
|
||||
private fun handleChatMessage(
|
||||
type: String?,
|
||||
groupID: String?,
|
||||
groupID: String?
|
||||
) {
|
||||
when (type) {
|
||||
"party" -> openPartyScreen()
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ interface NotificationsManager {
|
|||
|
||||
fun dismissTaskNotification(
|
||||
context: Context,
|
||||
task: Task,
|
||||
task: Task
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -60,7 +60,7 @@ class MainNotificationsManager : NotificationsManager {
|
|||
|
||||
override fun dismissTaskNotification(
|
||||
context: Context,
|
||||
task: Task,
|
||||
task: Task
|
||||
) {
|
||||
NotificationManagerCompat.from(context).cancel(task.id.hashCode())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ import com.android.billingclient.api.acknowledgePurchase
|
|||
import com.android.billingclient.api.consumePurchase
|
||||
import com.android.billingclient.api.queryProductDetails
|
||||
import com.android.billingclient.api.queryPurchasesAsync
|
||||
import com.google.api.Billing
|
||||
import com.google.firebase.crashlytics.FirebaseCrashlytics
|
||||
import com.habitrpg.android.habitica.HabiticaBaseApplication
|
||||
import com.habitrpg.android.habitica.R
|
||||
|
|
@ -64,21 +63,21 @@ class PurchaseHandler(
|
|||
|
||||
override fun onPurchasesUpdated(
|
||||
result: BillingResult,
|
||||
purchases: MutableList<Purchase>?,
|
||||
purchases: MutableList<Purchase>?
|
||||
) {
|
||||
purchases?.let { processPurchases(result, it) }
|
||||
}
|
||||
|
||||
override fun onQueryPurchasesResponse(
|
||||
result: BillingResult,
|
||||
purchases: MutableList<Purchase>,
|
||||
purchases: MutableList<Purchase>
|
||||
) {
|
||||
processPurchases(result, purchases)
|
||||
}
|
||||
|
||||
private fun processPurchases(
|
||||
result: BillingResult,
|
||||
purchases: List<Purchase>,
|
||||
purchases: List<Purchase>
|
||||
) {
|
||||
when (result.responseCode) {
|
||||
BillingClient.BillingResponseCode.OK -> {
|
||||
|
|
@ -90,8 +89,8 @@ class PurchaseHandler(
|
|||
for (purchase in purchases) {
|
||||
if (plan?.isActive == true &&
|
||||
PurchaseTypes.allSubscriptionTypes.contains(
|
||||
purchase.products.firstOrNull(),
|
||||
)
|
||||
purchase.products.firstOrNull()
|
||||
)
|
||||
) {
|
||||
if (((plan.dateTerminated != null) == purchase.isAutoRenewing) ||
|
||||
mostRecentSub?.orderId != purchase.orderId ||
|
||||
|
|
@ -139,7 +138,7 @@ class PurchaseHandler(
|
|||
READY,
|
||||
UNAVAILABLE,
|
||||
DISCONNECTED,
|
||||
CONNECTING,
|
||||
CONNECTING
|
||||
;
|
||||
|
||||
val canMaybePurchase: Boolean
|
||||
|
|
@ -203,7 +202,7 @@ class PurchaseHandler(
|
|||
retryListening()
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -228,13 +227,13 @@ class PurchaseHandler(
|
|||
val subResponse =
|
||||
billingClient.queryPurchasesAsync(
|
||||
QueryPurchasesParams.newBuilder().setProductType(BillingClient.ProductType.SUBS)
|
||||
.build(),
|
||||
.build()
|
||||
)
|
||||
processPurchases(subResponse.billingResult, subResponse.purchasesList)
|
||||
val iapResponse =
|
||||
billingClient.queryPurchasesAsync(
|
||||
QueryPurchasesParams.newBuilder().setProductType(BillingClient.ProductType.INAPP)
|
||||
.build(),
|
||||
.build()
|
||||
)
|
||||
processPurchases(iapResponse.billingResult, iapResponse.purchasesList)
|
||||
}
|
||||
|
|
@ -256,13 +255,13 @@ class PurchaseHandler(
|
|||
|
||||
private suspend fun getSKUs(
|
||||
type: String,
|
||||
identifiers: List<String>,
|
||||
identifiers: List<String>
|
||||
) =
|
||||
loadInventory(type, identifiers) ?: emptyList()
|
||||
|
||||
private suspend fun getSKU(
|
||||
type: String,
|
||||
identifier: String,
|
||||
identifier: String
|
||||
): ProductDetails? {
|
||||
val inventory = loadInventory(type, listOf(identifier))
|
||||
return inventory?.firstOrNull()
|
||||
|
|
@ -270,11 +269,12 @@ class PurchaseHandler(
|
|||
|
||||
private suspend fun loadInventory(
|
||||
type: String,
|
||||
skus: List<String>,
|
||||
skus: List<String>
|
||||
): List<ProductDetails>? {
|
||||
retryUntil(8, initialDelay = 500, maxDelay = 2000) {
|
||||
if (billingClient.connectionState == BillingClient.ConnectionState.DISCONNECTED ||
|
||||
billingClient.connectionState == BillingClient.ConnectionState.CLOSED) {
|
||||
billingClient.connectionState == BillingClient.ConnectionState.CLOSED
|
||||
) {
|
||||
startListening()
|
||||
}
|
||||
billingClientState.canMaybePurchase && billingClient.isReady
|
||||
|
|
@ -283,7 +283,7 @@ class PurchaseHandler(
|
|||
QueryProductDetailsParams.newBuilder().setProductList(
|
||||
skus.map {
|
||||
Product.newBuilder().setProductId(it).setProductType(type).build()
|
||||
},
|
||||
}
|
||||
).build()
|
||||
val skuDetailsResult =
|
||||
withContext(Dispatchers.IO) {
|
||||
|
|
@ -293,8 +293,8 @@ class PurchaseHandler(
|
|||
Log.e("PurchaseHandler", "Failed to load inventory: ${skuDetailsResult.billingResult.debugMessage}")
|
||||
FirebaseCrashlytics.getInstance().recordException(
|
||||
Throwable(
|
||||
"Failed to load inventory: ${skuDetailsResult.billingResult.debugMessage}",
|
||||
),
|
||||
"Failed to load inventory: ${skuDetailsResult.billingResult.debugMessage}"
|
||||
)
|
||||
)
|
||||
return null
|
||||
}
|
||||
|
|
@ -306,7 +306,7 @@ class PurchaseHandler(
|
|||
skuDetails: ProductDetails,
|
||||
recipient: String? = null,
|
||||
recipientUsername: String? = null,
|
||||
isSaleGemPurchase: Boolean = false,
|
||||
isSaleGemPurchase: Boolean = false
|
||||
) {
|
||||
this.isSaleGemPurchase = isSaleGemPurchase
|
||||
recipient?.let {
|
||||
|
|
@ -320,14 +320,14 @@ class PurchaseHandler(
|
|||
params = params.setOfferToken(offerToken)
|
||||
}
|
||||
return@map params.build()
|
||||
},
|
||||
}
|
||||
).build()
|
||||
billingClient.launchBillingFlow(activity, flowParams)
|
||||
}
|
||||
|
||||
private suspend fun consume(
|
||||
purchase: Purchase,
|
||||
retries: Int = 4,
|
||||
retries: Int = 4
|
||||
) {
|
||||
retryUntil { billingClientState.canMaybePurchase && billingClient.isReady }
|
||||
val params = ConsumeParams.newBuilder().setPurchaseToken(purchase.purchaseToken).build()
|
||||
|
|
@ -348,8 +348,8 @@ class PurchaseHandler(
|
|||
private fun handle(purchase: Purchase) {
|
||||
if (purchase.purchaseState != Purchase.PurchaseState.PURCHASED ||
|
||||
processedPurchases.contains(
|
||||
purchase.orderId,
|
||||
)
|
||||
purchase.orderId
|
||||
)
|
||||
) {
|
||||
return
|
||||
}
|
||||
|
|
@ -433,7 +433,7 @@ class PurchaseHandler(
|
|||
|
||||
private suspend fun acknowledgePurchase(
|
||||
purchase: Purchase,
|
||||
retries: Int = 4,
|
||||
retries: Int = 4
|
||||
) {
|
||||
val params =
|
||||
AcknowledgePurchaseParams.newBuilder().setPurchaseToken(purchase.purchaseToken).build()
|
||||
|
|
@ -470,7 +470,7 @@ class PurchaseHandler(
|
|||
|
||||
private fun handleError(
|
||||
throwable: Throwable,
|
||||
purchase: Purchase,
|
||||
purchase: Purchase
|
||||
) {
|
||||
when (throwable) {
|
||||
is HttpException -> {
|
||||
|
|
@ -576,7 +576,7 @@ class PurchaseHandler(
|
|||
private fun displayConfirmationDialog(
|
||||
purchase: Purchase,
|
||||
giftedToID: String? = null,
|
||||
giftedTo: String? = null,
|
||||
giftedTo: String? = null
|
||||
) {
|
||||
if (displayedConfirmations.contains(purchase.orderId)) {
|
||||
return
|
||||
|
|
@ -599,7 +599,7 @@ class PurchaseHandler(
|
|||
R.string.gift_confirmation_text_sub
|
||||
},
|
||||
giftedTo,
|
||||
durationString(sku),
|
||||
durationString(sku)
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -609,7 +609,7 @@ class PurchaseHandler(
|
|||
} else {
|
||||
context.getString(
|
||||
R.string.subscription_confirmation_multiple,
|
||||
durationString(sku),
|
||||
durationString(sku)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -619,7 +619,7 @@ class PurchaseHandler(
|
|||
context.getString(
|
||||
R.string.gift_confirmation_text_gems_new,
|
||||
giftedTo,
|
||||
gemAmountString(sku),
|
||||
gemAmountString(sku)
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -648,7 +648,7 @@ class PurchaseHandler(
|
|||
|
||||
private fun displayGryphatriceConfirmationDialog(
|
||||
purchase: Purchase,
|
||||
giftedTo: String? = null,
|
||||
giftedTo: String? = null
|
||||
) {
|
||||
MainScope().launch(ExceptionHandler.coroutine()) {
|
||||
val application =
|
||||
|
|
@ -681,7 +681,7 @@ class PurchaseHandler(
|
|||
fun addGift(
|
||||
sku: String,
|
||||
userID: String,
|
||||
username: String,
|
||||
username: String
|
||||
) {
|
||||
pendingGifts[sku] = Triple(Date(), userID, username)
|
||||
savePendingGifts()
|
||||
|
|
@ -708,7 +708,7 @@ suspend fun retryUntil(
|
|||
initialDelay: Long = 100, // 0.1 second
|
||||
maxDelay: Long = 1000, // 1 second
|
||||
factor: Double = 2.0,
|
||||
block: suspend () -> Boolean,
|
||||
block: suspend () -> Boolean
|
||||
) {
|
||||
var currentDelay = initialDelay
|
||||
repeat(times - 1) {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ object PurchaseTypes {
|
|||
SUBSCRIPTION_1_MONTH,
|
||||
SUBSCRIPTION_3_MONTH,
|
||||
SUBSCRIPTION_6_MONTH,
|
||||
SUBSCRIPTION_12_MONTH,
|
||||
SUBSCRIPTION_12_MONTH
|
||||
)
|
||||
const val SUBSCRIPTION_1_MONTH_NORENEW =
|
||||
"com.habitrpg.android.habitica.norenew_subscription.1month"
|
||||
|
|
@ -31,6 +31,6 @@ object PurchaseTypes {
|
|||
SUBSCRIPTION_1_MONTH_NORENEW,
|
||||
SUBSCRIPTION_3_MONTH_NORENEW,
|
||||
SUBSCRIPTION_6_MONTH_NORENEW,
|
||||
SUBSCRIPTION_12_MONTH_NORENEW,
|
||||
SUBSCRIPTION_12_MONTH_NORENEW
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ class ReviewManager(context: Context, private val configManager: AppConfigManage
|
|||
|
||||
fun requestReview(
|
||||
activity: AppCompatActivity,
|
||||
currentCheckins: Int,
|
||||
currentCheckins: Int
|
||||
) {
|
||||
if (!canRequestReview(currentCheckins)) return
|
||||
|
||||
|
|
|
|||
|
|
@ -7,65 +7,65 @@ import javax.inject.Singleton
|
|||
|
||||
@Singleton
|
||||
class SoundManager
|
||||
@Inject
|
||||
constructor(var soundFileLoader: SoundFileLoader) {
|
||||
var soundTheme: String = SOUND_THEME_OFF
|
||||
@Inject
|
||||
constructor(var soundFileLoader: SoundFileLoader) {
|
||||
var soundTheme: String = SOUND_THEME_OFF
|
||||
|
||||
private val loadedSoundFiles: MutableMap<String, SoundFile> = HashMap()
|
||||
private val loadedSoundFiles: MutableMap<String, SoundFile> = HashMap()
|
||||
|
||||
fun preloadAllFiles() {
|
||||
loadedSoundFiles.clear()
|
||||
if (soundTheme == SOUND_THEME_OFF) {
|
||||
return
|
||||
}
|
||||
|
||||
val soundFiles = ArrayList<SoundFile>()
|
||||
soundFiles.add(SoundFile(soundTheme, SOUND_ACHIEVEMENT_UNLOCKED))
|
||||
soundFiles.add(SoundFile(soundTheme, SOUND_CHAT))
|
||||
soundFiles.add(SoundFile(soundTheme, SOUND_DAILY))
|
||||
soundFiles.add(SoundFile(soundTheme, SOUND_DEATH))
|
||||
soundFiles.add(SoundFile(soundTheme, SOUND_ITEM_DROP))
|
||||
soundFiles.add(SoundFile(soundTheme, SOUND_LEVEL_UP))
|
||||
soundFiles.add(SoundFile(soundTheme, SOUND_MINUS_HABIT))
|
||||
soundFiles.add(SoundFile(soundTheme, SOUND_PLUS_HABIT))
|
||||
soundFiles.add(SoundFile(soundTheme, SOUND_REWARD))
|
||||
soundFiles.add(SoundFile(soundTheme, SOUND_TODO))
|
||||
MainScope().launchCatching {
|
||||
soundFileLoader.download(soundFiles)
|
||||
}
|
||||
fun preloadAllFiles() {
|
||||
loadedSoundFiles.clear()
|
||||
if (soundTheme == SOUND_THEME_OFF) {
|
||||
return
|
||||
}
|
||||
|
||||
fun loadAndPlayAudio(type: String) {
|
||||
if (soundTheme == SOUND_THEME_OFF) {
|
||||
return
|
||||
}
|
||||
|
||||
if (loadedSoundFiles.containsKey(type)) {
|
||||
loadedSoundFiles[type]?.play()
|
||||
} else {
|
||||
val soundFiles = ArrayList<SoundFile>()
|
||||
|
||||
soundFiles.add(SoundFile(soundTheme, type))
|
||||
MainScope().launchCatching {
|
||||
val newFiles = soundFileLoader.download(soundFiles)
|
||||
val file = newFiles[0]
|
||||
loadedSoundFiles[type] = file
|
||||
file.play()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val SOUND_ACHIEVEMENT_UNLOCKED = "Achievement_Unlocked"
|
||||
const val SOUND_CHAT = "Chat"
|
||||
const val SOUND_DAILY = "Daily"
|
||||
const val SOUND_DEATH = "Death"
|
||||
const val SOUND_ITEM_DROP = "Item_Drop"
|
||||
const val SOUND_LEVEL_UP = "Level_Up"
|
||||
const val SOUND_MINUS_HABIT = "Minus_Habit"
|
||||
const val SOUND_PLUS_HABIT = "Plus_Habit"
|
||||
const val SOUND_REWARD = "Reward"
|
||||
const val SOUND_TODO = "Todo"
|
||||
const val SOUND_THEME_OFF = "off"
|
||||
val soundFiles = ArrayList<SoundFile>()
|
||||
soundFiles.add(SoundFile(soundTheme, SOUND_ACHIEVEMENT_UNLOCKED))
|
||||
soundFiles.add(SoundFile(soundTheme, SOUND_CHAT))
|
||||
soundFiles.add(SoundFile(soundTheme, SOUND_DAILY))
|
||||
soundFiles.add(SoundFile(soundTheme, SOUND_DEATH))
|
||||
soundFiles.add(SoundFile(soundTheme, SOUND_ITEM_DROP))
|
||||
soundFiles.add(SoundFile(soundTheme, SOUND_LEVEL_UP))
|
||||
soundFiles.add(SoundFile(soundTheme, SOUND_MINUS_HABIT))
|
||||
soundFiles.add(SoundFile(soundTheme, SOUND_PLUS_HABIT))
|
||||
soundFiles.add(SoundFile(soundTheme, SOUND_REWARD))
|
||||
soundFiles.add(SoundFile(soundTheme, SOUND_TODO))
|
||||
MainScope().launchCatching {
|
||||
soundFileLoader.download(soundFiles)
|
||||
}
|
||||
}
|
||||
|
||||
fun loadAndPlayAudio(type: String) {
|
||||
if (soundTheme == SOUND_THEME_OFF) {
|
||||
return
|
||||
}
|
||||
|
||||
if (loadedSoundFiles.containsKey(type)) {
|
||||
loadedSoundFiles[type]?.play()
|
||||
} else {
|
||||
val soundFiles = ArrayList<SoundFile>()
|
||||
|
||||
soundFiles.add(SoundFile(soundTheme, type))
|
||||
MainScope().launchCatching {
|
||||
val newFiles = soundFileLoader.download(soundFiles)
|
||||
val file = newFiles[0]
|
||||
loadedSoundFiles[type] = file
|
||||
file.play()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val SOUND_ACHIEVEMENT_UNLOCKED = "Achievement_Unlocked"
|
||||
const val SOUND_CHAT = "Chat"
|
||||
const val SOUND_DAILY = "Daily"
|
||||
const val SOUND_DEATH = "Death"
|
||||
const val SOUND_ITEM_DROP = "Item_Drop"
|
||||
const val SOUND_LEVEL_UP = "Level_Up"
|
||||
const val SOUND_MINUS_HABIT = "Minus_Habit"
|
||||
const val SOUND_PLUS_HABIT = "Plus_Habit"
|
||||
const val SOUND_REWARD = "Reward"
|
||||
const val SOUND_TODO = "Todo"
|
||||
const val SOUND_THEME_OFF = "off"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ import java.util.Date
|
|||
class TaskAlarmManager(
|
||||
private var context: Context,
|
||||
private var taskRepository: TaskRepository,
|
||||
private var authenticationHandler: AuthenticationHandler,
|
||||
private var authenticationHandler: AuthenticationHandler
|
||||
) {
|
||||
private val am: AlarmManager? = context.getSystemService(Context.ALARM_SERVICE) as? AlarmManager
|
||||
private val upcomingReminderOccurrencesToSchedule = 3
|
||||
|
|
@ -141,7 +141,7 @@ class TaskAlarmManager(
|
|||
private fun setAlarmForRemindersItem(
|
||||
reminderItemTask: Task,
|
||||
remindersItem: RemindersItem?,
|
||||
occurrenceIndex: Int,
|
||||
occurrenceIndex: Int
|
||||
) {
|
||||
if (remindersItem == null) return
|
||||
|
||||
|
|
@ -166,7 +166,7 @@ class TaskAlarmManager(
|
|||
context,
|
||||
intentId,
|
||||
intent,
|
||||
withImmutableFlag(PendingIntent.FLAG_NO_CREATE),
|
||||
withImmutableFlag(PendingIntent.FLAG_NO_CREATE)
|
||||
)
|
||||
if (previousSender != null) {
|
||||
previousSender.cancel()
|
||||
|
|
@ -178,7 +178,7 @@ class TaskAlarmManager(
|
|||
context,
|
||||
intentId,
|
||||
intent,
|
||||
withImmutableFlag(PendingIntent.FLAG_CANCEL_CURRENT),
|
||||
withImmutableFlag(PendingIntent.FLAG_CANCEL_CURRENT)
|
||||
)
|
||||
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
|
|
@ -188,7 +188,7 @@ class TaskAlarmManager(
|
|||
|
||||
private fun removeAlarmForRemindersItem(
|
||||
remindersItem: RemindersItem,
|
||||
occurrenceIndex: Int? = null,
|
||||
occurrenceIndex: Int? = null
|
||||
) {
|
||||
val intent = Intent(context, TaskReceiver::class.java)
|
||||
intent.action = remindersItem.id
|
||||
|
|
@ -197,19 +197,19 @@ class TaskAlarmManager(
|
|||
(
|
||||
remindersItem.id?.hashCode()
|
||||
?: (0 and 0xfffffff)
|
||||
) + occurrenceIndex
|
||||
) + occurrenceIndex
|
||||
} else {
|
||||
(
|
||||
remindersItem.id?.hashCode()
|
||||
?: (0 and 0xfffffff)
|
||||
)
|
||||
)
|
||||
}
|
||||
val sender =
|
||||
PendingIntent.getBroadcast(
|
||||
context,
|
||||
intentId,
|
||||
intent,
|
||||
withImmutableFlag(PendingIntent.FLAG_UPDATE_CURRENT),
|
||||
withImmutableFlag(PendingIntent.FLAG_UPDATE_CURRENT)
|
||||
)
|
||||
val am = context.getSystemService(Context.ALARM_SERVICE) as? AlarmManager
|
||||
sender.cancel()
|
||||
|
|
@ -250,7 +250,7 @@ class TaskAlarmManager(
|
|||
context,
|
||||
0,
|
||||
notificationIntent,
|
||||
withImmutableFlag(PendingIntent.FLAG_NO_CREATE),
|
||||
withImmutableFlag(PendingIntent.FLAG_NO_CREATE)
|
||||
)
|
||||
if (previousSender != null) {
|
||||
previousSender.cancel()
|
||||
|
|
@ -262,7 +262,7 @@ class TaskAlarmManager(
|
|||
context,
|
||||
0,
|
||||
notificationIntent,
|
||||
withImmutableFlag(PendingIntent.FLAG_UPDATE_CURRENT),
|
||||
withImmutableFlag(PendingIntent.FLAG_UPDATE_CURRENT)
|
||||
)
|
||||
|
||||
setAlarm(context, triggerTime, pendingIntent)
|
||||
|
|
@ -280,7 +280,7 @@ class TaskAlarmManager(
|
|||
private fun setAlarm(
|
||||
context: Context,
|
||||
time: Long,
|
||||
pendingIntent: PendingIntent?,
|
||||
pendingIntent: PendingIntent?
|
||||
) {
|
||||
val alarmManager = context.getSystemService(Context.ALARM_SERVICE) as? AlarmManager
|
||||
|
||||
|
|
@ -297,15 +297,17 @@ class TaskAlarmManager(
|
|||
}
|
||||
if (canScheduleExact) {
|
||||
alarmManager.setExactAndAllowWhileIdle(notificationType, time, pendingIntent)
|
||||
HLogger.log(LogLevel.DEBUG,
|
||||
HLogger.log(
|
||||
LogLevel.DEBUG,
|
||||
"TaskAlarmManager",
|
||||
"setAlarm: Scheduling for $time using setExact ${Date().time}",
|
||||
"setAlarm: Scheduling for $time using setExact ${Date().time}"
|
||||
)
|
||||
} else {
|
||||
alarmManager.setAndAllowWhileIdle(notificationType, time, pendingIntent)
|
||||
HLogger.log(LogLevel.DEBUG,
|
||||
HLogger.log(
|
||||
LogLevel.DEBUG,
|
||||
"TaskAlarmManager",
|
||||
"setAlarm: Scheduling for $time using setAndAllowWhileIdle",
|
||||
"setAlarm: Scheduling for $time using setAndAllowWhileIdle"
|
||||
)
|
||||
}
|
||||
} catch (ex: Exception) {
|
||||
|
|
@ -315,7 +317,7 @@ class TaskAlarmManager(
|
|||
notificationType,
|
||||
time,
|
||||
600000,
|
||||
pendingIntent,
|
||||
pendingIntent
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ import com.habitrpg.shared.habitica.models.tasks.TaskDifficulty
|
|||
import com.habitrpg.shared.habitica.models.tasks.TaskType
|
||||
import java.text.DateFormat
|
||||
import java.util.Date
|
||||
import java.util.Locale
|
||||
|
||||
class TaskDescriptionBuilder(private val context: Context) {
|
||||
fun describe(task: Task): String {
|
||||
|
|
@ -22,7 +21,7 @@ class TaskDescriptionBuilder(private val context: Context) {
|
|||
context.getString(
|
||||
R.string.habit_summary_description,
|
||||
describeHabitDirections(task.up ?: false, task.down ?: false),
|
||||
describeDifficulty(task.priority),
|
||||
describeDifficulty(task.priority)
|
||||
)
|
||||
|
||||
TaskType.TODO -> {
|
||||
|
|
@ -30,12 +29,12 @@ class TaskDescriptionBuilder(private val context: Context) {
|
|||
context.getString(
|
||||
R.string.todo_summary_description_duedate,
|
||||
describeDifficulty(task.priority),
|
||||
describeDate(task.dueDate!!),
|
||||
describeDate(task.dueDate!!)
|
||||
)
|
||||
} else {
|
||||
context.getString(
|
||||
R.string.todo_summary_description,
|
||||
describeDifficulty(task.priority),
|
||||
describeDifficulty(task.priority)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -45,7 +44,7 @@ class TaskDescriptionBuilder(private val context: Context) {
|
|||
R.string.daily_summary_description,
|
||||
describeDifficulty(task.priority),
|
||||
describeRepeatInterval(task.frequency, task.everyX ?: 1),
|
||||
describeRepeatDays(task),
|
||||
describeRepeatDays(task)
|
||||
)
|
||||
|
||||
else -> ""
|
||||
|
|
@ -102,7 +101,7 @@ class TaskDescriptionBuilder(private val context: Context) {
|
|||
context.getString(
|
||||
R.string.on_the_x_of_month,
|
||||
occurrence,
|
||||
joinToCount(dayStrings),
|
||||
joinToCount(dayStrings)
|
||||
)
|
||||
} else {
|
||||
""
|
||||
|
|
@ -116,7 +115,7 @@ class TaskDescriptionBuilder(private val context: Context) {
|
|||
task.startDate?.let {
|
||||
val flags = DateUtils.FORMAT_SHOW_DATE + DateUtils.FORMAT_NO_YEAR
|
||||
DateUtils.formatDateTime(context, it.time, flags)
|
||||
} ?: "",
|
||||
} ?: ""
|
||||
)
|
||||
|
||||
else -> ""
|
||||
|
|
@ -141,7 +140,7 @@ class TaskDescriptionBuilder(private val context: Context) {
|
|||
|
||||
private fun describeRepeatInterval(
|
||||
interval: Frequency?,
|
||||
everyX: Int,
|
||||
everyX: Int
|
||||
): String {
|
||||
if (everyX == 0) {
|
||||
return context.getString(R.string.never)
|
||||
|
|
@ -151,28 +150,28 @@ class TaskDescriptionBuilder(private val context: Context) {
|
|||
context.resources.getQuantityString(
|
||||
R.plurals.repeat_daily,
|
||||
everyX,
|
||||
everyX,
|
||||
everyX
|
||||
)
|
||||
|
||||
Frequency.WEEKLY ->
|
||||
context.resources.getQuantityString(
|
||||
R.plurals.repeat_weekly,
|
||||
everyX,
|
||||
everyX,
|
||||
everyX
|
||||
)
|
||||
|
||||
Frequency.MONTHLY ->
|
||||
context.resources.getQuantityString(
|
||||
R.plurals.repeat_monthly,
|
||||
everyX,
|
||||
everyX,
|
||||
everyX
|
||||
)
|
||||
|
||||
Frequency.YEARLY ->
|
||||
context.resources.getQuantityString(
|
||||
R.plurals.repeat_yearly,
|
||||
everyX,
|
||||
everyX,
|
||||
everyX
|
||||
)
|
||||
|
||||
null -> ""
|
||||
|
|
@ -181,7 +180,7 @@ class TaskDescriptionBuilder(private val context: Context) {
|
|||
|
||||
private fun describeHabitDirections(
|
||||
up: Boolean,
|
||||
down: Boolean,
|
||||
down: Boolean
|
||||
): String {
|
||||
return if (up && down) {
|
||||
context.getString(R.string.positive_and_negative)
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ class UserStatComputer {
|
|||
|
||||
fun computeClassBonus(
|
||||
equipmentList: List<Equipment>?,
|
||||
user: Avatar,
|
||||
user: Avatar
|
||||
): List<StatsRow> {
|
||||
val skillRows = ArrayList<StatsRow>()
|
||||
|
||||
|
|
|
|||
|
|
@ -62,13 +62,13 @@ class GroupActivityNotification(context: Context, identifier: String?) :
|
|||
return NotificationCompat.MessagingStyle.Message(
|
||||
messageText,
|
||||
timestamp.time,
|
||||
sender,
|
||||
sender
|
||||
)
|
||||
}
|
||||
|
||||
override fun setNotificationActions(
|
||||
notificationId: Int,
|
||||
data: Map<String, String>,
|
||||
data: Map<String, String>
|
||||
) {
|
||||
super.setNotificationActions(notificationId, data)
|
||||
val groupID = data["groupID"] ?: return
|
||||
|
|
@ -89,14 +89,14 @@ class GroupActivityNotification(context: Context, identifier: String?) :
|
|||
context,
|
||||
groupID.hashCode(),
|
||||
intent,
|
||||
withMutableFlag(PendingIntent.FLAG_UPDATE_CURRENT),
|
||||
withMutableFlag(PendingIntent.FLAG_UPDATE_CURRENT)
|
||||
)
|
||||
|
||||
val action: NotificationCompat.Action =
|
||||
NotificationCompat.Action.Builder(
|
||||
R.drawable.ic_send_grey_600_24dp,
|
||||
context.getString(R.string.reply),
|
||||
replyPendingIntent,
|
||||
replyPendingIntent
|
||||
)
|
||||
.addRemoteInput(remoteInput)
|
||||
.build()
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ class GuildInviteLocalNotification(context: Context, identifier: String?) :
|
|||
|
||||
override fun setNotificationActions(
|
||||
notificationId: Int,
|
||||
data: Map<String, String>,
|
||||
data: Map<String, String>
|
||||
) {
|
||||
super.setNotificationActions(notificationId, data)
|
||||
val res = context.resources
|
||||
|
|
@ -34,7 +34,7 @@ class GuildInviteLocalNotification(context: Context, identifier: String?) :
|
|||
context,
|
||||
groupID.hashCode(),
|
||||
acceptInviteIntent,
|
||||
withImmutableFlag(PendingIntent.FLAG_UPDATE_CURRENT),
|
||||
withImmutableFlag(PendingIntent.FLAG_UPDATE_CURRENT)
|
||||
)
|
||||
notificationBuilder.addAction(0, "Accept", pendingIntentAccept)
|
||||
|
||||
|
|
@ -47,7 +47,7 @@ class GuildInviteLocalNotification(context: Context, identifier: String?) :
|
|||
context,
|
||||
groupID.hashCode() + 1,
|
||||
rejectInviteIntent,
|
||||
withImmutableFlag(PendingIntent.FLAG_UPDATE_CURRENT),
|
||||
withImmutableFlag(PendingIntent.FLAG_UPDATE_CURRENT)
|
||||
)
|
||||
notificationBuilder.addAction(0, "Reject", pendingIntentReject)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ import java.util.Date
|
|||
*/
|
||||
abstract class HabiticaLocalNotification(
|
||||
protected var context: Context,
|
||||
protected var identifier: String?,
|
||||
protected var identifier: String?
|
||||
) {
|
||||
protected var data: Map<String, String>? = null
|
||||
protected var title: String? = null
|
||||
|
|
@ -40,7 +40,7 @@ abstract class HabiticaLocalNotification(
|
|||
open fun notifyLocally(
|
||||
title: String?,
|
||||
message: String?,
|
||||
data: MutableMap<String, String>,
|
||||
data: MutableMap<String, String>
|
||||
) {
|
||||
this.title = title
|
||||
this.message = message
|
||||
|
|
@ -71,7 +71,7 @@ abstract class HabiticaLocalNotification(
|
|||
|
||||
protected open fun setNotificationActions(
|
||||
notificationId: Int,
|
||||
data: Map<String, String>,
|
||||
data: Map<String, String>
|
||||
) {
|
||||
val intent = Intent(context, MainActivity::class.java)
|
||||
configureMainIntent(intent)
|
||||
|
|
@ -81,7 +81,7 @@ abstract class HabiticaLocalNotification(
|
|||
context,
|
||||
3000,
|
||||
intent,
|
||||
withImmutableFlag(PendingIntent.FLAG_UPDATE_CURRENT),
|
||||
withImmutableFlag(PendingIntent.FLAG_UPDATE_CURRENT)
|
||||
)
|
||||
notificationBuilder.setContentIntent(pendingIntent)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,89 +6,89 @@ class HabiticaLocalNotificationFactory {
|
|||
// use getShape method to get object of type shape
|
||||
fun build(
|
||||
notificationType: String?,
|
||||
context: Context?,
|
||||
context: Context?
|
||||
): HabiticaLocalNotification {
|
||||
return when {
|
||||
PushNotificationManager.PARTY_INVITE_PUSH_NOTIFICATION_KEY.equals(
|
||||
notificationType,
|
||||
true,
|
||||
true
|
||||
) -> {
|
||||
PartyInviteLocalNotification(context!!, notificationType)
|
||||
}
|
||||
|
||||
PushNotificationManager.RECEIVED_PRIVATE_MESSAGE_PUSH_NOTIFICATION_KEY.equals(
|
||||
notificationType,
|
||||
true,
|
||||
true
|
||||
) -> {
|
||||
ReceivedPrivateMessageLocalNotification(context!!, notificationType)
|
||||
}
|
||||
|
||||
PushNotificationManager.RECEIVED_GEMS_PUSH_NOTIFICATION_KEY.equals(
|
||||
notificationType,
|
||||
true,
|
||||
true
|
||||
) -> {
|
||||
ReceivedGemsGiftLocalNotification(context!!, notificationType)
|
||||
}
|
||||
|
||||
PushNotificationManager.RECEIVED_SUBSCRIPTION_GIFT_PUSH_NOTIFICATION_KEY.equals(
|
||||
notificationType,
|
||||
true,
|
||||
true
|
||||
) -> {
|
||||
ReceivedSubscriptionGiftLocalNotification(context!!, notificationType)
|
||||
}
|
||||
|
||||
PushNotificationManager.GUILD_INVITE_PUSH_NOTIFICATION_KEY.equals(
|
||||
notificationType,
|
||||
true,
|
||||
true
|
||||
) -> {
|
||||
GuildInviteLocalNotification(context!!, notificationType)
|
||||
}
|
||||
|
||||
PushNotificationManager.QUEST_INVITE_PUSH_NOTIFICATION_KEY.equals(
|
||||
notificationType,
|
||||
true,
|
||||
true
|
||||
) -> {
|
||||
QuestInviteLocalNotification(context!!, notificationType)
|
||||
}
|
||||
|
||||
PushNotificationManager.QUEST_BEGUN_PUSH_NOTIFICATION_KEY.equals(
|
||||
notificationType,
|
||||
true,
|
||||
true
|
||||
) -> {
|
||||
QuestBegunLocalNotification(context!!, notificationType)
|
||||
}
|
||||
|
||||
PushNotificationManager.WON_CHALLENGE_PUSH_NOTIFICATION_KEY.equals(
|
||||
notificationType,
|
||||
true,
|
||||
true
|
||||
) -> {
|
||||
WonChallengeLocalNotification(context!!, notificationType)
|
||||
}
|
||||
|
||||
PushNotificationManager.CHANGE_USERNAME_PUSH_NOTIFICATION_KEY.equals(
|
||||
notificationType,
|
||||
true,
|
||||
true
|
||||
) -> {
|
||||
ChangeUsernameLocalNotification(context!!, notificationType)
|
||||
}
|
||||
|
||||
PushNotificationManager.GIFT_ONE_GET_ONE_PUSH_NOTIFICATION_KEY.equals(
|
||||
notificationType,
|
||||
true,
|
||||
true
|
||||
) -> {
|
||||
GiftOneGetOneLocalNotification(context!!, notificationType)
|
||||
}
|
||||
|
||||
PushNotificationManager.CHAT_MENTION_NOTIFICATION_KEY.equals(
|
||||
notificationType,
|
||||
true,
|
||||
true
|
||||
) -> {
|
||||
ChatMentionNotification(context!!, notificationType)
|
||||
}
|
||||
|
||||
PushNotificationManager.GROUP_ACTIVITY_NOTIFICATION_KEY.equals(
|
||||
notificationType,
|
||||
true,
|
||||
true
|
||||
) -> {
|
||||
GroupActivityNotification(context!!, notificationType)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ class PartyInviteLocalNotification(context: Context, identifier: String?) :
|
|||
HabiticaLocalNotification(context, identifier) {
|
||||
override fun setNotificationActions(
|
||||
notificationId: Int,
|
||||
data: Map<String, String>,
|
||||
data: Map<String, String>
|
||||
) {
|
||||
super.setNotificationActions(notificationId, data)
|
||||
val res = context.resources
|
||||
|
|
@ -29,7 +29,7 @@ class PartyInviteLocalNotification(context: Context, identifier: String?) :
|
|||
context,
|
||||
groupID.hashCode(),
|
||||
acceptInviteIntent,
|
||||
withImmutableFlag(PendingIntent.FLAG_UPDATE_CURRENT),
|
||||
withImmutableFlag(PendingIntent.FLAG_UPDATE_CURRENT)
|
||||
)
|
||||
notificationBuilder.addAction(0, context.getString(R.string.accept), pendingIntentAccept)
|
||||
|
||||
|
|
@ -42,7 +42,7 @@ class PartyInviteLocalNotification(context: Context, identifier: String?) :
|
|||
context,
|
||||
groupID.hashCode() + 1,
|
||||
rejectInviteIntent,
|
||||
withImmutableFlag(PendingIntent.FLAG_UPDATE_CURRENT),
|
||||
withImmutableFlag(PendingIntent.FLAG_UPDATE_CURRENT)
|
||||
)
|
||||
notificationBuilder.addAction(0, context.getString(R.string.reject), pendingIntentReject)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ import java.io.IOException
|
|||
class PushNotificationManager(
|
||||
var apiClient: ApiClient,
|
||||
private val sharedPreferences: SharedPreferences,
|
||||
private val context: Context,
|
||||
private val context: Context
|
||||
) {
|
||||
var refreshedToken: String = ""
|
||||
set(value) {
|
||||
|
|
@ -136,7 +136,7 @@ class PushNotificationManager(
|
|||
fun displayNotification(
|
||||
remoteMessage: RemoteMessage,
|
||||
context: Context,
|
||||
pushNotificationManager: PushNotificationManager? = null,
|
||||
pushNotificationManager: PushNotificationManager? = null
|
||||
) {
|
||||
val remoteMessageIdentifier = remoteMessage.data["identifier"]
|
||||
|
||||
|
|
@ -148,7 +148,7 @@ class PushNotificationManager(
|
|||
"receive notification",
|
||||
EventCategory.BEHAVIOUR,
|
||||
HitType.EVENT,
|
||||
additionalData,
|
||||
additionalData
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -156,7 +156,7 @@ class PushNotificationManager(
|
|||
val localNotification =
|
||||
notificationFactory.build(
|
||||
remoteMessageIdentifier,
|
||||
context,
|
||||
context
|
||||
)
|
||||
localNotification.setExtras(remoteMessage.data)
|
||||
val notification = remoteMessage.notification
|
||||
|
|
@ -164,13 +164,13 @@ class PushNotificationManager(
|
|||
localNotification.notifyLocally(
|
||||
notification.title ?: remoteMessage.data["title"],
|
||||
notification.body ?: remoteMessage.data["body"],
|
||||
remoteMessage.data,
|
||||
remoteMessage.data
|
||||
)
|
||||
} else {
|
||||
localNotification.notifyLocally(
|
||||
remoteMessage.data["title"],
|
||||
remoteMessage.data["body"],
|
||||
remoteMessage.data,
|
||||
remoteMessage.data
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ class QuestInviteLocalNotification(context: Context, identifier: String?) :
|
|||
|
||||
override fun setNotificationActions(
|
||||
notificationId: Int,
|
||||
data: Map<String, String>,
|
||||
data: Map<String, String>
|
||||
) {
|
||||
super.setNotificationActions(notificationId, data)
|
||||
val res = context.resources
|
||||
|
|
@ -37,7 +37,7 @@ class QuestInviteLocalNotification(context: Context, identifier: String?) :
|
|||
context,
|
||||
3001,
|
||||
acceptInviteIntent,
|
||||
flags,
|
||||
flags
|
||||
)
|
||||
notificationBuilder.addAction(0, "Accept", pendingIntentAccept)
|
||||
|
||||
|
|
@ -49,7 +49,7 @@ class QuestInviteLocalNotification(context: Context, identifier: String?) :
|
|||
context,
|
||||
2001,
|
||||
rejectInviteIntent,
|
||||
flags,
|
||||
flags
|
||||
)
|
||||
notificationBuilder.addAction(0, "Reject", pendingIntentReject)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ class ReceivedPrivateMessageLocalNotification(context: Context, identifier: Stri
|
|||
context.getString(
|
||||
R.string.inbox_messages_title,
|
||||
oldMessages.size,
|
||||
data["senderName"],
|
||||
data["senderName"]
|
||||
)
|
||||
} else {
|
||||
context.getString(R.string.inbox_messages_title_nosender, oldMessages.size)
|
||||
|
|
@ -60,8 +60,8 @@ class ReceivedPrivateMessageLocalNotification(context: Context, identifier: Stri
|
|||
notification.setContentTitle(
|
||||
context.getString(
|
||||
R.string.inbox_messages_title_single,
|
||||
data["senderName"],
|
||||
),
|
||||
data["senderName"]
|
||||
)
|
||||
)
|
||||
}
|
||||
return notification
|
||||
|
|
@ -79,7 +79,7 @@ class ReceivedPrivateMessageLocalNotification(context: Context, identifier: Stri
|
|||
|
||||
override fun setNotificationActions(
|
||||
notificationId: Int,
|
||||
data: Map<String, String>,
|
||||
data: Map<String, String>
|
||||
) {
|
||||
super.setNotificationActions(notificationId, data)
|
||||
val senderID = data["replyTo"] ?: return
|
||||
|
|
@ -100,14 +100,14 @@ class ReceivedPrivateMessageLocalNotification(context: Context, identifier: Stri
|
|||
context,
|
||||
senderID.hashCode(),
|
||||
intent,
|
||||
withMutableFlag(PendingIntent.FLAG_UPDATE_CURRENT),
|
||||
withMutableFlag(PendingIntent.FLAG_UPDATE_CURRENT)
|
||||
)
|
||||
|
||||
val action: NotificationCompat.Action =
|
||||
NotificationCompat.Action.Builder(
|
||||
R.drawable.ic_send_grey_600_24dp,
|
||||
context.getString(R.string.reply),
|
||||
replyPendingIntent,
|
||||
replyPendingIntent
|
||||
)
|
||||
.addRemoteInput(remoteInput)
|
||||
.build()
|
||||
|
|
|
|||
|
|
@ -8,27 +8,27 @@ import com.habitrpg.shared.habitica.models.responses.TaskScoringResult
|
|||
import javax.inject.Inject
|
||||
|
||||
class BuyRewardUseCase
|
||||
@Inject
|
||||
constructor(
|
||||
private val taskRepository: TaskRepository,
|
||||
private val soundManager: SoundManager,
|
||||
) : UseCase<BuyRewardUseCase.RequestValues, TaskScoringResult?>() {
|
||||
override suspend fun run(requestValues: RequestValues): TaskScoringResult? {
|
||||
val response =
|
||||
taskRepository.taskChecked(
|
||||
requestValues.user,
|
||||
requestValues.task,
|
||||
false,
|
||||
false,
|
||||
requestValues.notifyFunc,
|
||||
)
|
||||
soundManager.loadAndPlayAudio(SoundManager.SOUND_REWARD)
|
||||
return response
|
||||
}
|
||||
|
||||
class RequestValues(
|
||||
internal val user: User?,
|
||||
val task: Task,
|
||||
val notifyFunc: (TaskScoringResult) -> Unit,
|
||||
) : UseCase.RequestValues
|
||||
@Inject
|
||||
constructor(
|
||||
private val taskRepository: TaskRepository,
|
||||
private val soundManager: SoundManager
|
||||
) : UseCase<BuyRewardUseCase.RequestValues, TaskScoringResult?>() {
|
||||
override suspend fun run(requestValues: RequestValues): TaskScoringResult? {
|
||||
val response =
|
||||
taskRepository.taskChecked(
|
||||
requestValues.user,
|
||||
requestValues.task,
|
||||
false,
|
||||
false,
|
||||
requestValues.notifyFunc
|
||||
)
|
||||
soundManager.loadAndPlayAudio(SoundManager.SOUND_REWARD)
|
||||
return response
|
||||
}
|
||||
|
||||
class RequestValues(
|
||||
internal val user: User?,
|
||||
val task: Task,
|
||||
val notifyFunc: (TaskScoringResult) -> Unit
|
||||
) : UseCase.RequestValues
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,45 +8,45 @@ import com.habitrpg.android.habitica.ui.activities.ClassSelectionActivity
|
|||
import javax.inject.Inject
|
||||
|
||||
class CheckClassSelectionUseCase
|
||||
@Inject
|
||||
constructor() :
|
||||
@Inject
|
||||
constructor() :
|
||||
UseCase<CheckClassSelectionUseCase.RequestValues, Unit>() {
|
||||
override suspend fun run(requestValues: RequestValues) {
|
||||
val user = requestValues.user
|
||||
if (requestValues.currentClass == null) {
|
||||
if ((user?.stats?.lvl ?: 0) >= 9 &&
|
||||
user?.preferences?.disableClasses != true &&
|
||||
user?.flags?.classSelected != true
|
||||
) {
|
||||
displayClassSelectionActivity(false, null, requestValues.activity)
|
||||
}
|
||||
} else {
|
||||
displayClassSelectionActivity(
|
||||
requestValues.isClassSelected,
|
||||
requestValues.currentClass,
|
||||
requestValues.activity,
|
||||
)
|
||||
override suspend fun run(requestValues: RequestValues) {
|
||||
val user = requestValues.user
|
||||
if (requestValues.currentClass == null) {
|
||||
if ((user?.stats?.lvl ?: 0) >= 9 &&
|
||||
user?.preferences?.disableClasses != true &&
|
||||
user?.flags?.classSelected != true
|
||||
) {
|
||||
displayClassSelectionActivity(false, null, requestValues.activity)
|
||||
}
|
||||
} else {
|
||||
displayClassSelectionActivity(
|
||||
requestValues.isClassSelected,
|
||||
requestValues.currentClass,
|
||||
requestValues.activity
|
||||
)
|
||||
}
|
||||
|
||||
private fun displayClassSelectionActivity(
|
||||
isClassSelected: Boolean,
|
||||
currentClass: String?,
|
||||
activity: Activity,
|
||||
) {
|
||||
val bundle = Bundle()
|
||||
bundle.putBoolean("isClassSelected", isClassSelected)
|
||||
bundle.putString("currentClass", currentClass)
|
||||
|
||||
val intent = Intent(activity, ClassSelectionActivity::class.java)
|
||||
intent.putExtras(bundle)
|
||||
activity.startActivity(intent)
|
||||
}
|
||||
|
||||
class RequestValues(
|
||||
val user: User?,
|
||||
val isClassSelected: Boolean,
|
||||
val currentClass: String?,
|
||||
val activity: Activity,
|
||||
) : UseCase.RequestValues
|
||||
}
|
||||
|
||||
private fun displayClassSelectionActivity(
|
||||
isClassSelected: Boolean,
|
||||
currentClass: String?,
|
||||
activity: Activity
|
||||
) {
|
||||
val bundle = Bundle()
|
||||
bundle.putBoolean("isClassSelected", isClassSelected)
|
||||
bundle.putString("currentClass", currentClass)
|
||||
|
||||
val intent = Intent(activity, ClassSelectionActivity::class.java)
|
||||
intent.putExtras(bundle)
|
||||
activity.startActivity(intent)
|
||||
}
|
||||
|
||||
class RequestValues(
|
||||
val user: User?,
|
||||
val isClassSelected: Boolean,
|
||||
val currentClass: String?,
|
||||
val activity: Activity
|
||||
) : UseCase.RequestValues
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,44 +13,44 @@ import kotlinx.coroutines.launch
|
|||
import javax.inject.Inject
|
||||
|
||||
class DisplayItemDropUseCase
|
||||
@Inject
|
||||
constructor(private val soundManager: SoundManager) :
|
||||
@Inject
|
||||
constructor(private val soundManager: SoundManager) :
|
||||
UseCase<DisplayItemDropUseCase.RequestValues, Unit>() {
|
||||
override suspend fun run(requestValues: RequestValues) {
|
||||
val data = requestValues.data
|
||||
val snackbarText = StringBuilder(data?.drop?.dialog ?: "")
|
||||
|
||||
if ((data?.questItemsFound ?: 0) > 0 && requestValues.showQuestItems) {
|
||||
if (snackbarText.isNotEmpty()) {
|
||||
snackbarText.append('\n')
|
||||
}
|
||||
snackbarText.append(
|
||||
requestValues.context.getString(
|
||||
R.string.quest_items_found,
|
||||
data!!.questItemsFound,
|
||||
),
|
||||
)
|
||||
}
|
||||
override suspend fun run(requestValues: RequestValues) {
|
||||
val data = requestValues.data
|
||||
val snackbarText = StringBuilder(data?.drop?.dialog ?: "")
|
||||
|
||||
if ((data?.questItemsFound ?: 0) > 0 && requestValues.showQuestItems) {
|
||||
if (snackbarText.isNotEmpty()) {
|
||||
MainScope().launch(context = Dispatchers.Main) {
|
||||
delay(3000L)
|
||||
HabiticaSnackbar.showSnackbar(
|
||||
requestValues.snackbarTargetView,
|
||||
snackbarText,
|
||||
HabiticaSnackbar.SnackbarDisplayType.DROP,
|
||||
true,
|
||||
)
|
||||
soundManager.loadAndPlayAudio(SoundManager.SOUND_ITEM_DROP)
|
||||
}
|
||||
snackbarText.append('\n')
|
||||
}
|
||||
return
|
||||
snackbarText.append(
|
||||
requestValues.context.getString(
|
||||
R.string.quest_items_found,
|
||||
data!!.questItemsFound
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
class RequestValues(
|
||||
val data: TaskScoringResult?,
|
||||
val context: AppCompatActivity,
|
||||
val snackbarTargetView: ViewGroup,
|
||||
val showQuestItems: Boolean,
|
||||
) : UseCase.RequestValues
|
||||
if (snackbarText.isNotEmpty()) {
|
||||
MainScope().launch(context = Dispatchers.Main) {
|
||||
delay(3000L)
|
||||
HabiticaSnackbar.showSnackbar(
|
||||
requestValues.snackbarTargetView,
|
||||
snackbarText,
|
||||
HabiticaSnackbar.SnackbarDisplayType.DROP,
|
||||
true
|
||||
)
|
||||
soundManager.loadAndPlayAudio(SoundManager.SOUND_ITEM_DROP)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
class RequestValues(
|
||||
val data: TaskScoringResult?,
|
||||
val context: AppCompatActivity,
|
||||
val snackbarTargetView: ViewGroup,
|
||||
val showQuestItems: Boolean
|
||||
) : UseCase.RequestValues
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,64 +22,64 @@ import kotlinx.coroutines.MainScope
|
|||
import javax.inject.Inject
|
||||
|
||||
class FeedPetUseCase
|
||||
@Inject
|
||||
constructor(
|
||||
private val inventoryRepository: InventoryRepository,
|
||||
) : UseCase<FeedPetUseCase.RequestValues, FeedResponse?>() {
|
||||
override suspend fun run(requestValues: RequestValues): FeedResponse? {
|
||||
val feedResponse = inventoryRepository.feedPet(requestValues.pet, requestValues.food)
|
||||
(requestValues.context as? SnackbarActivity)?.showSnackbar(content = feedResponse?.message)
|
||||
if (feedResponse?.value == -1) {
|
||||
val mountWrapper = MountImageviewBinding.inflate(requestValues.context.layoutInflater)
|
||||
@Inject
|
||||
constructor(
|
||||
private val inventoryRepository: InventoryRepository
|
||||
) : UseCase<FeedPetUseCase.RequestValues, FeedResponse?>() {
|
||||
override suspend fun run(requestValues: RequestValues): FeedResponse? {
|
||||
val feedResponse = inventoryRepository.feedPet(requestValues.pet, requestValues.food)
|
||||
(requestValues.context as? SnackbarActivity)?.showSnackbar(content = feedResponse?.message)
|
||||
if (feedResponse?.value == -1) {
|
||||
val mountWrapper = MountImageviewBinding.inflate(requestValues.context.layoutInflater)
|
||||
|
||||
mountWrapper.mountImageview.setMount(requestValues.pet.key)
|
||||
val currentActivity =
|
||||
HabiticaBaseApplication.getInstance(requestValues.context)?.currentActivity?.get()
|
||||
val dialog = HabiticaAlertDialog(requestValues.context)
|
||||
if (currentActivity != null) {
|
||||
mountWrapper.backgroundView.setContent {
|
||||
HabiticaTheme {
|
||||
BackgroundScene(Modifier.clip(HabiticaTheme.shapes.large))
|
||||
}
|
||||
}
|
||||
dialog.window?.let {
|
||||
mountWrapper.root.setViewTreeSavedStateRegistryOwner(currentActivity)
|
||||
it.decorView.setViewTreeSavedStateRegistryOwner(currentActivity)
|
||||
mountWrapper.root.setViewTreeLifecycleOwner(currentActivity)
|
||||
it.decorView.setViewTreeLifecycleOwner(currentActivity)
|
||||
mountWrapper.mountImageview.setMount(requestValues.pet.key)
|
||||
val currentActivity =
|
||||
HabiticaBaseApplication.getInstance(requestValues.context)?.currentActivity?.get()
|
||||
val dialog = HabiticaAlertDialog(requestValues.context)
|
||||
if (currentActivity != null) {
|
||||
mountWrapper.backgroundView.setContent {
|
||||
HabiticaTheme {
|
||||
BackgroundScene(Modifier.clip(HabiticaTheme.shapes.large))
|
||||
}
|
||||
}
|
||||
dialog.setTitle(
|
||||
requestValues.context.getString(
|
||||
R.string.evolved_pet_title,
|
||||
requestValues.pet.text,
|
||||
),
|
||||
)
|
||||
dialog.isCelebratory = true
|
||||
dialog.setAdditionalContentView(mountWrapper.root)
|
||||
dialog.addButton(R.string.onwards, true)
|
||||
dialog.addButton(R.string.share, false) { hatchingDialog, _ ->
|
||||
val message =
|
||||
requestValues.context.getString(
|
||||
R.string.share_raised,
|
||||
requestValues.pet.text,
|
||||
)
|
||||
MainScope().launchCatching {
|
||||
ShareMountUseCase().callInteractor(
|
||||
ShareMountUseCase.RequestValues(
|
||||
requestValues.pet.key,
|
||||
message,
|
||||
requestValues.context,
|
||||
),
|
||||
)
|
||||
}
|
||||
hatchingDialog.dismiss()
|
||||
dialog.window?.let {
|
||||
mountWrapper.root.setViewTreeSavedStateRegistryOwner(currentActivity)
|
||||
it.decorView.setViewTreeSavedStateRegistryOwner(currentActivity)
|
||||
mountWrapper.root.setViewTreeLifecycleOwner(currentActivity)
|
||||
it.decorView.setViewTreeLifecycleOwner(currentActivity)
|
||||
}
|
||||
dialog.enqueue()
|
||||
}
|
||||
return feedResponse
|
||||
dialog.setTitle(
|
||||
requestValues.context.getString(
|
||||
R.string.evolved_pet_title,
|
||||
requestValues.pet.text
|
||||
)
|
||||
)
|
||||
dialog.isCelebratory = true
|
||||
dialog.setAdditionalContentView(mountWrapper.root)
|
||||
dialog.addButton(R.string.onwards, true)
|
||||
dialog.addButton(R.string.share, false) { hatchingDialog, _ ->
|
||||
val message =
|
||||
requestValues.context.getString(
|
||||
R.string.share_raised,
|
||||
requestValues.pet.text
|
||||
)
|
||||
MainScope().launchCatching {
|
||||
ShareMountUseCase().callInteractor(
|
||||
ShareMountUseCase.RequestValues(
|
||||
requestValues.pet.key,
|
||||
message,
|
||||
requestValues.context
|
||||
)
|
||||
)
|
||||
}
|
||||
hatchingDialog.dismiss()
|
||||
}
|
||||
dialog.enqueue()
|
||||
}
|
||||
|
||||
class RequestValues(val pet: Pet, val food: Food, val context: Context) :
|
||||
UseCase.RequestValues
|
||||
return feedResponse
|
||||
}
|
||||
|
||||
class RequestValues(val pet: Pet, val food: Food, val context: Context) :
|
||||
UseCase.RequestValues
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,71 +23,71 @@ import kotlinx.coroutines.MainScope
|
|||
import javax.inject.Inject
|
||||
|
||||
class HatchPetUseCase
|
||||
@Inject
|
||||
constructor(
|
||||
private val inventoryRepository: InventoryRepository,
|
||||
) : UseCase<HatchPetUseCase.RequestValues, Items?>() {
|
||||
override suspend fun run(requestValues: RequestValues): Items? {
|
||||
return inventoryRepository.hatchPet(requestValues.egg, requestValues.potion) {
|
||||
val petWrapper = PetImageviewBinding.inflate(requestValues.context.layoutInflater)
|
||||
val petKey = requestValues.egg.key + "-" + requestValues.potion.key
|
||||
petWrapper.petImageview.loadImage("stable_Pet-$petKey")
|
||||
val potionName = requestValues.potion.text
|
||||
val eggName = requestValues.egg.text
|
||||
val currentActivity =
|
||||
HabiticaBaseApplication.getInstance(requestValues.context)?.currentActivity?.get()
|
||||
val dialog = HabiticaAlertDialog(requestValues.context)
|
||||
if (currentActivity != null) {
|
||||
petWrapper.backgroundView.setContent {
|
||||
HabiticaTheme {
|
||||
BackgroundScene(Modifier.clip(HabiticaTheme.shapes.large))
|
||||
}
|
||||
}
|
||||
dialog.window?.let {
|
||||
petWrapper.root.setViewTreeSavedStateRegistryOwner(currentActivity)
|
||||
it.decorView.setViewTreeSavedStateRegistryOwner(currentActivity)
|
||||
petWrapper.root.setViewTreeLifecycleOwner(currentActivity)
|
||||
it.decorView.setViewTreeLifecycleOwner(currentActivity)
|
||||
@Inject
|
||||
constructor(
|
||||
private val inventoryRepository: InventoryRepository
|
||||
) : UseCase<HatchPetUseCase.RequestValues, Items?>() {
|
||||
override suspend fun run(requestValues: RequestValues): Items? {
|
||||
return inventoryRepository.hatchPet(requestValues.egg, requestValues.potion) {
|
||||
val petWrapper = PetImageviewBinding.inflate(requestValues.context.layoutInflater)
|
||||
val petKey = requestValues.egg.key + "-" + requestValues.potion.key
|
||||
petWrapper.petImageview.loadImage("stable_Pet-$petKey")
|
||||
val potionName = requestValues.potion.text
|
||||
val eggName = requestValues.egg.text
|
||||
val currentActivity =
|
||||
HabiticaBaseApplication.getInstance(requestValues.context)?.currentActivity?.get()
|
||||
val dialog = HabiticaAlertDialog(requestValues.context)
|
||||
if (currentActivity != null) {
|
||||
petWrapper.backgroundView.setContent {
|
||||
HabiticaTheme {
|
||||
BackgroundScene(Modifier.clip(HabiticaTheme.shapes.large))
|
||||
}
|
||||
}
|
||||
dialog.isCelebratory = true
|
||||
dialog.setTitle(
|
||||
requestValues.context.getString(
|
||||
R.string.hatched_pet_title,
|
||||
potionName,
|
||||
eggName,
|
||||
),
|
||||
)
|
||||
dialog.setAdditionalContentView(petWrapper.root)
|
||||
dialog.addButton(R.string.equip, true) { _, _ ->
|
||||
MainScope().launchCatching {
|
||||
inventoryRepository.equip(
|
||||
"pet",
|
||||
requestValues.egg.key + "-" + requestValues.potion.key,
|
||||
)
|
||||
}
|
||||
dialog.window?.let {
|
||||
petWrapper.root.setViewTreeSavedStateRegistryOwner(currentActivity)
|
||||
it.decorView.setViewTreeSavedStateRegistryOwner(currentActivity)
|
||||
petWrapper.root.setViewTreeLifecycleOwner(currentActivity)
|
||||
it.decorView.setViewTreeLifecycleOwner(currentActivity)
|
||||
}
|
||||
dialog.addButton(R.string.share, false) { hatchingDialog, _ ->
|
||||
MainScope().launchCatching {
|
||||
SharePetUseCase().callInteractor(
|
||||
SharePetUseCase.RequestValues(
|
||||
petKey,
|
||||
requestValues.context.getString(
|
||||
R.string.share_hatched,
|
||||
potionName,
|
||||
eggName,
|
||||
),
|
||||
requestValues.context,
|
||||
),
|
||||
)
|
||||
}
|
||||
hatchingDialog.dismiss()
|
||||
}
|
||||
dialog.setExtraCloseButtonVisibility(View.VISIBLE)
|
||||
dialog.enqueue()
|
||||
}
|
||||
dialog.isCelebratory = true
|
||||
dialog.setTitle(
|
||||
requestValues.context.getString(
|
||||
R.string.hatched_pet_title,
|
||||
potionName,
|
||||
eggName
|
||||
)
|
||||
)
|
||||
dialog.setAdditionalContentView(petWrapper.root)
|
||||
dialog.addButton(R.string.equip, true) { _, _ ->
|
||||
MainScope().launchCatching {
|
||||
inventoryRepository.equip(
|
||||
"pet",
|
||||
requestValues.egg.key + "-" + requestValues.potion.key
|
||||
)
|
||||
}
|
||||
}
|
||||
dialog.addButton(R.string.share, false) { hatchingDialog, _ ->
|
||||
MainScope().launchCatching {
|
||||
SharePetUseCase().callInteractor(
|
||||
SharePetUseCase.RequestValues(
|
||||
petKey,
|
||||
requestValues.context.getString(
|
||||
R.string.share_hatched,
|
||||
potionName,
|
||||
eggName
|
||||
),
|
||||
requestValues.context
|
||||
)
|
||||
)
|
||||
}
|
||||
hatchingDialog.dismiss()
|
||||
}
|
||||
dialog.setExtraCloseButtonVisibility(View.VISIBLE)
|
||||
dialog.enqueue()
|
||||
}
|
||||
|
||||
class RequestValues(val potion: HatchingPotion, val egg: Egg, val context: Context) :
|
||||
UseCase.RequestValues
|
||||
}
|
||||
|
||||
class RequestValues(val potion: HatchingPotion, val egg: Egg, val context: Context) :
|
||||
UseCase.RequestValues
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,21 +7,21 @@ import com.habitrpg.android.habitica.ui.activities.MainActivity
|
|||
import javax.inject.Inject
|
||||
|
||||
class InsufficientGemsUseCase
|
||||
@Inject
|
||||
constructor(
|
||||
private val purchaseHandler: PurchaseHandler,
|
||||
) : UseCase<InsufficientGemsUseCase.RequestValues, Unit>() {
|
||||
override suspend fun run(requestValues: RequestValues) {
|
||||
val activity = requestValues.activity as? MainActivity ?: return
|
||||
val gemSku =
|
||||
if (requestValues.gemPrice > 4) {
|
||||
PurchaseTypes.PURCHASE_21_GEMS
|
||||
} else {
|
||||
PurchaseTypes.PURCHASE_4_GEMS
|
||||
}
|
||||
val sku = purchaseHandler.getInAppPurchaseSKU(gemSku) ?: return
|
||||
purchaseHandler.purchase(activity, sku)
|
||||
}
|
||||
|
||||
class RequestValues(val gemPrice: Int, val activity: Activity) : UseCase.RequestValues
|
||||
@Inject
|
||||
constructor(
|
||||
private val purchaseHandler: PurchaseHandler
|
||||
) : UseCase<InsufficientGemsUseCase.RequestValues, Unit>() {
|
||||
override suspend fun run(requestValues: RequestValues) {
|
||||
val activity = requestValues.activity as? MainActivity ?: return
|
||||
val gemSku =
|
||||
if (requestValues.gemPrice > 4) {
|
||||
PurchaseTypes.PURCHASE_21_GEMS
|
||||
} else {
|
||||
PurchaseTypes.PURCHASE_4_GEMS
|
||||
}
|
||||
val sku = purchaseHandler.getInAppPurchaseSKU(gemSku) ?: return
|
||||
purchaseHandler.purchase(activity, sku)
|
||||
}
|
||||
|
||||
class RequestValues(val gemPrice: Int, val activity: Activity) : UseCase.RequestValues
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,116 +16,116 @@ import kotlinx.coroutines.MainScope
|
|||
import javax.inject.Inject
|
||||
|
||||
class LevelUpUseCase
|
||||
@Inject
|
||||
constructor(
|
||||
private val soundManager: SoundManager,
|
||||
private val checkClassSelectionUseCase: CheckClassSelectionUseCase,
|
||||
) : UseCase<LevelUpUseCase.RequestValues, Stats?>() {
|
||||
override suspend fun run(requestValues: RequestValues): Stats? {
|
||||
soundManager.loadAndPlayAudio(SoundManager.SOUND_LEVEL_UP)
|
||||
val suppressedModals = requestValues.user.preferences?.suppressModals
|
||||
@Inject
|
||||
constructor(
|
||||
private val soundManager: SoundManager,
|
||||
private val checkClassSelectionUseCase: CheckClassSelectionUseCase
|
||||
) : UseCase<LevelUpUseCase.RequestValues, Stats?>() {
|
||||
override suspend fun run(requestValues: RequestValues): Stats? {
|
||||
soundManager.loadAndPlayAudio(SoundManager.SOUND_LEVEL_UP)
|
||||
val suppressedModals = requestValues.user.preferences?.suppressModals
|
||||
|
||||
if (requestValues.newLevel == 10) {
|
||||
val binding = DialogLevelup10Binding.inflate(requestValues.activity.layoutInflater)
|
||||
binding.healerIconView.setImageBitmap(HabiticaIconsHelper.imageOfHealerLightBg())
|
||||
binding.mageIconView.setImageBitmap(HabiticaIconsHelper.imageOfMageLightBg())
|
||||
binding.rogueIconView.setImageBitmap(HabiticaIconsHelper.imageOfRogueLightBg())
|
||||
binding.warriorIconView.setImageBitmap(HabiticaIconsHelper.imageOfWarriorLightBg())
|
||||
if (requestValues.newLevel == 10) {
|
||||
val binding = DialogLevelup10Binding.inflate(requestValues.activity.layoutInflater)
|
||||
binding.healerIconView.setImageBitmap(HabiticaIconsHelper.imageOfHealerLightBg())
|
||||
binding.mageIconView.setImageBitmap(HabiticaIconsHelper.imageOfMageLightBg())
|
||||
binding.rogueIconView.setImageBitmap(HabiticaIconsHelper.imageOfRogueLightBg())
|
||||
binding.warriorIconView.setImageBitmap(HabiticaIconsHelper.imageOfWarriorLightBg())
|
||||
|
||||
val alert = HabiticaAlertDialog(requestValues.activity)
|
||||
alert.setTitle(
|
||||
requestValues.activity.getString(
|
||||
R.string.levelup_header,
|
||||
requestValues.newLevel,
|
||||
),
|
||||
val alert = HabiticaAlertDialog(requestValues.activity)
|
||||
alert.setTitle(
|
||||
requestValues.activity.getString(
|
||||
R.string.levelup_header,
|
||||
requestValues.newLevel
|
||||
)
|
||||
alert.setAdditionalContentView(binding.root)
|
||||
alert.addButton(R.string.select_class, true) { _, _ ->
|
||||
MainScope().launchCatching {
|
||||
showClassSelection(requestValues)
|
||||
}
|
||||
}
|
||||
alert.addButton(R.string.not_now, false)
|
||||
alert.isCelebratory = true
|
||||
|
||||
if (!requestValues.activity.isFinishing) {
|
||||
alert.enqueue()
|
||||
}
|
||||
} else {
|
||||
if (suppressedModals?.levelUp == true) {
|
||||
HabiticaSnackbar.showSnackbar(
|
||||
requestValues.snackbarTargetView,
|
||||
requestValues.activity.getString(
|
||||
R.string.levelup_header,
|
||||
requestValues.newLevel,
|
||||
),
|
||||
HabiticaSnackbar.SnackbarDisplayType.SUCCESS,
|
||||
true,
|
||||
)
|
||||
return requestValues.user.stats
|
||||
}
|
||||
val customView =
|
||||
requestValues.activity.layoutInflater.inflate(R.layout.dialog_levelup, null)
|
||||
if (customView != null) {
|
||||
val dialogAvatarView = customView.findViewById<AvatarView>(R.id.avatarView)
|
||||
dialogAvatarView.setAvatar(requestValues.user)
|
||||
}
|
||||
|
||||
val alert = HabiticaAlertDialog(requestValues.activity)
|
||||
alert.setTitle(
|
||||
requestValues.activity.getString(
|
||||
R.string.levelup_header,
|
||||
requestValues.newLevel,
|
||||
),
|
||||
)
|
||||
alert.setAdditionalContentView(customView)
|
||||
alert.addButton(R.string.onwards, true) { _, _ ->
|
||||
MainScope().launchCatching {
|
||||
showClassSelection(requestValues)
|
||||
}
|
||||
}
|
||||
alert.addButton(R.string.share, false) { _, _ ->
|
||||
MainScope().launchCatching {
|
||||
val usecase = ShareAvatarUseCase()
|
||||
usecase.callInteractor(
|
||||
ShareAvatarUseCase.RequestValues(
|
||||
requestValues.activity,
|
||||
requestValues.user,
|
||||
requestValues.activity.getString(
|
||||
R.string.share_levelup,
|
||||
requestValues.newLevel,
|
||||
),
|
||||
"levelup",
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
alert.isCelebratory = true
|
||||
|
||||
if (!requestValues.activity.isFinishing) {
|
||||
alert.enqueue()
|
||||
)
|
||||
alert.setAdditionalContentView(binding.root)
|
||||
alert.addButton(R.string.select_class, true) { _, _ ->
|
||||
MainScope().launchCatching {
|
||||
showClassSelection(requestValues)
|
||||
}
|
||||
}
|
||||
return requestValues.user.stats
|
||||
}
|
||||
alert.addButton(R.string.not_now, false)
|
||||
alert.isCelebratory = true
|
||||
|
||||
private suspend fun showClassSelection(requestValues: RequestValues) {
|
||||
checkClassSelectionUseCase.callInteractor(
|
||||
CheckClassSelectionUseCase.RequestValues(
|
||||
requestValues.user,
|
||||
true,
|
||||
null,
|
||||
requestValues.activity,
|
||||
),
|
||||
if (!requestValues.activity.isFinishing) {
|
||||
alert.enqueue()
|
||||
}
|
||||
} else {
|
||||
if (suppressedModals?.levelUp == true) {
|
||||
HabiticaSnackbar.showSnackbar(
|
||||
requestValues.snackbarTargetView,
|
||||
requestValues.activity.getString(
|
||||
R.string.levelup_header,
|
||||
requestValues.newLevel
|
||||
),
|
||||
HabiticaSnackbar.SnackbarDisplayType.SUCCESS,
|
||||
true
|
||||
)
|
||||
return requestValues.user.stats
|
||||
}
|
||||
val customView =
|
||||
requestValues.activity.layoutInflater.inflate(R.layout.dialog_levelup, null)
|
||||
if (customView != null) {
|
||||
val dialogAvatarView = customView.findViewById<AvatarView>(R.id.avatarView)
|
||||
dialogAvatarView.setAvatar(requestValues.user)
|
||||
}
|
||||
|
||||
val alert = HabiticaAlertDialog(requestValues.activity)
|
||||
alert.setTitle(
|
||||
requestValues.activity.getString(
|
||||
R.string.levelup_header,
|
||||
requestValues.newLevel
|
||||
)
|
||||
)
|
||||
}
|
||||
alert.setAdditionalContentView(customView)
|
||||
alert.addButton(R.string.onwards, true) { _, _ ->
|
||||
MainScope().launchCatching {
|
||||
showClassSelection(requestValues)
|
||||
}
|
||||
}
|
||||
alert.addButton(R.string.share, false) { _, _ ->
|
||||
MainScope().launchCatching {
|
||||
val usecase = ShareAvatarUseCase()
|
||||
usecase.callInteractor(
|
||||
ShareAvatarUseCase.RequestValues(
|
||||
requestValues.activity,
|
||||
requestValues.user,
|
||||
requestValues.activity.getString(
|
||||
R.string.share_levelup,
|
||||
requestValues.newLevel
|
||||
),
|
||||
"levelup"
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
alert.isCelebratory = true
|
||||
|
||||
class RequestValues(
|
||||
val user: User,
|
||||
val level: Int?,
|
||||
val activity: BaseActivity,
|
||||
val snackbarTargetView: ViewGroup,
|
||||
) : UseCase.RequestValues {
|
||||
val newLevel: Int = level ?: 0
|
||||
if (!requestValues.activity.isFinishing) {
|
||||
alert.enqueue()
|
||||
}
|
||||
}
|
||||
return requestValues.user.stats
|
||||
}
|
||||
|
||||
private suspend fun showClassSelection(requestValues: RequestValues) {
|
||||
checkClassSelectionUseCase.callInteractor(
|
||||
CheckClassSelectionUseCase.RequestValues(
|
||||
requestValues.user,
|
||||
true,
|
||||
null,
|
||||
requestValues.activity
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
class RequestValues(
|
||||
val user: User,
|
||||
val level: Int?,
|
||||
val activity: BaseActivity,
|
||||
val snackbarTargetView: ViewGroup
|
||||
) : UseCase.RequestValues {
|
||||
val newLevel: Int = level ?: 0
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,187 +24,187 @@ import javax.inject.Inject
|
|||
import kotlin.math.abs
|
||||
|
||||
class NotifyUserUseCase
|
||||
@Inject
|
||||
constructor(
|
||||
private val levelUpUseCase: LevelUpUseCase,
|
||||
private val userRepository: UserRepository,
|
||||
) : UseCase<NotifyUserUseCase.RequestValues, Stats?>() {
|
||||
override suspend fun run(requestValues: RequestValues): Stats? {
|
||||
if (requestValues.user == null) {
|
||||
return null
|
||||
}
|
||||
val pair =
|
||||
getNotificationAndAddStatsToUser(
|
||||
requestValues.context,
|
||||
requestValues.xp,
|
||||
requestValues.hp,
|
||||
requestValues.gold,
|
||||
requestValues.mp,
|
||||
requestValues.questDamage,
|
||||
@Inject
|
||||
constructor(
|
||||
private val levelUpUseCase: LevelUpUseCase,
|
||||
private val userRepository: UserRepository
|
||||
) : UseCase<NotifyUserUseCase.RequestValues, Stats?>() {
|
||||
override suspend fun run(requestValues: RequestValues): Stats? {
|
||||
if (requestValues.user == null) {
|
||||
return null
|
||||
}
|
||||
val pair =
|
||||
getNotificationAndAddStatsToUser(
|
||||
requestValues.context,
|
||||
requestValues.xp,
|
||||
requestValues.hp,
|
||||
requestValues.gold,
|
||||
requestValues.mp,
|
||||
requestValues.questDamage,
|
||||
requestValues.user
|
||||
)
|
||||
val view = pair.first
|
||||
val type = pair.second
|
||||
if (view != null && type != null) {
|
||||
HabiticaSnackbar.showSnackbar(requestValues.snackbarTargetView, null, null, view, type)
|
||||
}
|
||||
if (requestValues.hasLeveledUp == true) {
|
||||
levelUpUseCase.callInteractor(
|
||||
LevelUpUseCase.RequestValues(
|
||||
requestValues.user,
|
||||
requestValues.level,
|
||||
requestValues.context,
|
||||
requestValues.snackbarTargetView
|
||||
)
|
||||
val view = pair.first
|
||||
val type = pair.second
|
||||
if (view != null && type != null) {
|
||||
HabiticaSnackbar.showSnackbar(requestValues.snackbarTargetView, null, null, view, type)
|
||||
)
|
||||
userRepository.retrieveUser(true)
|
||||
}
|
||||
return requestValues.user.stats
|
||||
}
|
||||
|
||||
class RequestValues(
|
||||
val context: BaseActivity,
|
||||
val snackbarTargetView: ViewGroup,
|
||||
val user: User?,
|
||||
val xp: Double?,
|
||||
val hp: Double?,
|
||||
val gold: Double?,
|
||||
val mp: Double?,
|
||||
val questDamage: Double?,
|
||||
val hasLeveledUp: Boolean?,
|
||||
val level: Int?
|
||||
) : UseCase.RequestValues
|
||||
|
||||
companion object {
|
||||
val formatter =
|
||||
NumberFormat.getInstance().apply {
|
||||
this.minimumFractionDigits = 0
|
||||
this.maximumFractionDigits = 2
|
||||
}
|
||||
if (requestValues.hasLeveledUp == true) {
|
||||
levelUpUseCase.callInteractor(
|
||||
LevelUpUseCase.RequestValues(
|
||||
requestValues.user,
|
||||
requestValues.level,
|
||||
requestValues.context,
|
||||
requestValues.snackbarTargetView,
|
||||
),
|
||||
|
||||
fun getNotificationAndAddStatsToUser(
|
||||
context: Context,
|
||||
xp: Double?,
|
||||
hp: Double?,
|
||||
gold: Double?,
|
||||
mp: Double?,
|
||||
questDamage: Double?,
|
||||
user: User?
|
||||
): Pair<View, SnackbarDisplayType> {
|
||||
var displayType = SnackbarDisplayType.SUCCESS
|
||||
|
||||
val container = LinearLayout(context)
|
||||
container.orientation = LinearLayout.HORIZONTAL
|
||||
|
||||
if (xp != null && xp > 0) {
|
||||
container.addView(
|
||||
createTextView(
|
||||
context,
|
||||
xp,
|
||||
HabiticaIconsHelper.imageOfExperience()
|
||||
)
|
||||
)
|
||||
userRepository.retrieveUser(true)
|
||||
}
|
||||
return requestValues.user.stats
|
||||
if (hp != null && hp != 0.0) {
|
||||
if (hp < 0) {
|
||||
displayType = SnackbarDisplayType.FAILURE
|
||||
}
|
||||
container.addView(
|
||||
createTextView(
|
||||
context,
|
||||
hp,
|
||||
HabiticaIconsHelper.imageOfHeartDarkBg()
|
||||
)
|
||||
)
|
||||
}
|
||||
if (gold != null && gold != 0.0) {
|
||||
container.addView(createTextView(context, gold, HabiticaIconsHelper.imageOfGold()))
|
||||
if (gold < 0) {
|
||||
displayType = SnackbarDisplayType.FAILURE
|
||||
}
|
||||
}
|
||||
if (mp != null && mp > 0 && user?.hasClass == true) {
|
||||
container.addView(createTextView(context, mp, HabiticaIconsHelper.imageOfMagic()))
|
||||
}
|
||||
if (questDamage != null && questDamage > 0) {
|
||||
container.addView(
|
||||
createTextView(
|
||||
context,
|
||||
questDamage,
|
||||
HabiticaIconsHelper.imageOfDamage()
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
val childCount = container.childCount
|
||||
if (childCount == 0) {
|
||||
return Pair(null, displayType)
|
||||
}
|
||||
val padding = context.resources.getDimension(R.dimen.spacing_medium).toInt()
|
||||
(1 until childCount)
|
||||
.map { container.getChildAt(it) }
|
||||
.forEach { it.setPadding(padding, 0, 0, 0) }
|
||||
|
||||
return Pair(container, displayType)
|
||||
}
|
||||
|
||||
class RequestValues(
|
||||
val context: BaseActivity,
|
||||
val snackbarTargetView: ViewGroup,
|
||||
val user: User?,
|
||||
val xp: Double?,
|
||||
val hp: Double?,
|
||||
val gold: Double?,
|
||||
val mp: Double?,
|
||||
val questDamage: Double?,
|
||||
val hasLeveledUp: Boolean?,
|
||||
val level: Int?,
|
||||
) : UseCase.RequestValues
|
||||
|
||||
companion object {
|
||||
val formatter =
|
||||
NumberFormat.getInstance().apply {
|
||||
this.minimumFractionDigits = 0
|
||||
this.maximumFractionDigits = 2
|
||||
}
|
||||
|
||||
fun getNotificationAndAddStatsToUser(
|
||||
context: Context,
|
||||
xp: Double?,
|
||||
hp: Double?,
|
||||
gold: Double?,
|
||||
mp: Double?,
|
||||
questDamage: Double?,
|
||||
user: User?,
|
||||
): Pair<View, SnackbarDisplayType> {
|
||||
var displayType = SnackbarDisplayType.SUCCESS
|
||||
|
||||
val container = LinearLayout(context)
|
||||
container.orientation = LinearLayout.HORIZONTAL
|
||||
|
||||
if (xp != null && xp > 0) {
|
||||
container.addView(
|
||||
createTextView(
|
||||
context,
|
||||
xp,
|
||||
HabiticaIconsHelper.imageOfExperience(),
|
||||
),
|
||||
)
|
||||
}
|
||||
if (hp != null && hp != 0.0) {
|
||||
if (hp < 0) {
|
||||
displayType = SnackbarDisplayType.FAILURE
|
||||
}
|
||||
container.addView(
|
||||
createTextView(
|
||||
context,
|
||||
hp,
|
||||
HabiticaIconsHelper.imageOfHeartDarkBg(),
|
||||
),
|
||||
)
|
||||
}
|
||||
if (gold != null && gold != 0.0) {
|
||||
container.addView(createTextView(context, gold, HabiticaIconsHelper.imageOfGold()))
|
||||
if (gold < 0) {
|
||||
displayType = SnackbarDisplayType.FAILURE
|
||||
}
|
||||
}
|
||||
if (mp != null && mp > 0 && user?.hasClass == true) {
|
||||
container.addView(createTextView(context, mp, HabiticaIconsHelper.imageOfMagic()))
|
||||
}
|
||||
if (questDamage != null && questDamage > 0) {
|
||||
container.addView(
|
||||
createTextView(
|
||||
context,
|
||||
questDamage,
|
||||
HabiticaIconsHelper.imageOfDamage(),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
val childCount = container.childCount
|
||||
if (childCount == 0) {
|
||||
return Pair(null, displayType)
|
||||
}
|
||||
val padding = context.resources.getDimension(R.dimen.spacing_medium).toInt()
|
||||
(1 until childCount)
|
||||
.map { container.getChildAt(it) }
|
||||
.forEach { it.setPadding(padding, 0, 0, 0) }
|
||||
|
||||
return Pair(container, displayType)
|
||||
}
|
||||
|
||||
private fun createTextView(
|
||||
context: Context,
|
||||
value: Double,
|
||||
icon: Bitmap,
|
||||
): View {
|
||||
val textView = TextView(context)
|
||||
val iconDrawable = BitmapDrawable(context.resources, icon)
|
||||
textView.setCompoundDrawablesWithIntrinsicBounds(iconDrawable, null, null, null)
|
||||
val text: String =
|
||||
if (value > 0) {
|
||||
" + " + formatter.format(abs(value))
|
||||
} else {
|
||||
" - " + formatter.format(abs(value))
|
||||
}
|
||||
textView.text = text
|
||||
textView.gravity = Gravity.CENTER_VERTICAL
|
||||
textView.setTextColor(ContextCompat.getColor(context, R.color.white))
|
||||
return textView
|
||||
}
|
||||
|
||||
private fun formatValue(value: Double): String {
|
||||
return if (value >= 0) {
|
||||
private fun createTextView(
|
||||
context: Context,
|
||||
value: Double,
|
||||
icon: Bitmap
|
||||
): View {
|
||||
val textView = TextView(context)
|
||||
val iconDrawable = BitmapDrawable(context.resources, icon)
|
||||
textView.setCompoundDrawablesWithIntrinsicBounds(iconDrawable, null, null, null)
|
||||
val text: String =
|
||||
if (value > 0) {
|
||||
" + " + formatter.format(abs(value))
|
||||
} else {
|
||||
" - " + formatter.format(abs(value))
|
||||
}
|
||||
}
|
||||
textView.text = text
|
||||
textView.gravity = Gravity.CENTER_VERTICAL
|
||||
textView.setTextColor(ContextCompat.getColor(context, R.color.white))
|
||||
return textView
|
||||
}
|
||||
|
||||
fun getNotificationAndAddStatsToUserAsText(
|
||||
xp: Double?,
|
||||
hp: Double?,
|
||||
gold: Double?,
|
||||
mp: Double?,
|
||||
): Pair<SpannableStringBuilder, SnackbarDisplayType> {
|
||||
val builder = SpannableStringBuilder()
|
||||
var displayType = SnackbarDisplayType.NORMAL
|
||||
|
||||
if (xp != null && xp != 0.0) {
|
||||
builder.append(formatValue(xp)).append(" Exp")
|
||||
}
|
||||
if (hp != null && hp != 0.0) {
|
||||
if (hp < 0) {
|
||||
displayType = SnackbarDisplayType.FAILURE
|
||||
}
|
||||
builder.append(formatValue(hp)).append(" Health")
|
||||
}
|
||||
if (gold != null && gold != 0.0) {
|
||||
if (gold < 0) {
|
||||
displayType = SnackbarDisplayType.FAILURE
|
||||
}
|
||||
builder.append(formatValue(gold)).append(" Gold")
|
||||
}
|
||||
if (mp != null && mp != 0.0) {
|
||||
builder.append(formatValue(mp)).append(" Exp").append(" Mana")
|
||||
}
|
||||
|
||||
return Pair(builder, displayType)
|
||||
private fun formatValue(value: Double): String {
|
||||
return if (value >= 0) {
|
||||
" + " + formatter.format(abs(value))
|
||||
} else {
|
||||
" - " + formatter.format(abs(value))
|
||||
}
|
||||
}
|
||||
|
||||
fun getNotificationAndAddStatsToUserAsText(
|
||||
xp: Double?,
|
||||
hp: Double?,
|
||||
gold: Double?,
|
||||
mp: Double?
|
||||
): Pair<SpannableStringBuilder, SnackbarDisplayType> {
|
||||
val builder = SpannableStringBuilder()
|
||||
var displayType = SnackbarDisplayType.NORMAL
|
||||
|
||||
if (xp != null && xp != 0.0) {
|
||||
builder.append(formatValue(xp)).append(" Exp")
|
||||
}
|
||||
if (hp != null && hp != 0.0) {
|
||||
if (hp < 0) {
|
||||
displayType = SnackbarDisplayType.FAILURE
|
||||
}
|
||||
builder.append(formatValue(hp)).append(" Health")
|
||||
}
|
||||
if (gold != null && gold != 0.0) {
|
||||
if (gold < 0) {
|
||||
displayType = SnackbarDisplayType.FAILURE
|
||||
}
|
||||
builder.append(formatValue(gold)).append(" Gold")
|
||||
}
|
||||
if (mp != null && mp != 0.0) {
|
||||
builder.append(formatValue(mp)).append(" Exp").append(" Mana")
|
||||
}
|
||||
|
||||
return Pair(builder, displayType)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ class ScoreTaskLocallyInteractor {
|
|||
|
||||
private fun calculateDelta(
|
||||
task: Task,
|
||||
direction: TaskDirection,
|
||||
direction: TaskDirection
|
||||
): Double {
|
||||
val currentValue =
|
||||
when {
|
||||
|
|
@ -35,7 +35,7 @@ class ScoreTaskLocallyInteractor {
|
|||
nextDelta *= 1 + (
|
||||
task.checklist?.map { if (it.completed) 1 else 0 }?.reduce { _, _ -> 0 }
|
||||
?: 0
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -45,35 +45,35 @@ class ScoreTaskLocallyInteractor {
|
|||
private fun scoreHabit(
|
||||
user: User,
|
||||
task: Task,
|
||||
direction: TaskDirection,
|
||||
direction: TaskDirection
|
||||
) {
|
||||
}
|
||||
|
||||
private fun scoreDaily(
|
||||
user: User,
|
||||
task: Task,
|
||||
direction: TaskDirection,
|
||||
direction: TaskDirection
|
||||
) {
|
||||
}
|
||||
|
||||
private fun scoreToDo(
|
||||
user: User,
|
||||
task: Task,
|
||||
direction: TaskDirection,
|
||||
direction: TaskDirection
|
||||
) {
|
||||
}
|
||||
|
||||
private fun scoreReward(
|
||||
user: User,
|
||||
task: Task,
|
||||
direction: TaskDirection,
|
||||
direction: TaskDirection
|
||||
) {
|
||||
}
|
||||
|
||||
fun score(
|
||||
user: User,
|
||||
task: Task,
|
||||
direction: TaskDirection,
|
||||
direction: TaskDirection
|
||||
): TaskDirectionData? {
|
||||
return if (task.type == TaskType.HABIT || direction == TaskDirection.UP) {
|
||||
val stats = user.stats ?: return null
|
||||
|
|
@ -121,7 +121,7 @@ class ScoreTaskLocallyInteractor {
|
|||
delta: Double,
|
||||
stats: Stats,
|
||||
computedStats: Stats,
|
||||
task: Task,
|
||||
task: Task
|
||||
) {
|
||||
var conBonus = 1f - ((computedStats.constitution?.toFloat() ?: 0f) / 250f)
|
||||
if (conBonus < 0.1) {
|
||||
|
|
@ -137,13 +137,13 @@ class ScoreTaskLocallyInteractor {
|
|||
stats: Stats,
|
||||
computedStats: Stats,
|
||||
task: Task,
|
||||
direction: TaskDirection,
|
||||
direction: TaskDirection
|
||||
) {
|
||||
val intBonus = 1f + ((computedStats.intelligence?.toFloat() ?: 0f) * 0.025f)
|
||||
result.exp = (
|
||||
stats.exp
|
||||
?: 0.0
|
||||
) + (delta * intBonus * task.priority * 6).roundToLong().toDouble()
|
||||
) + (delta * intBonus * task.priority * 6).roundToLong().toDouble()
|
||||
|
||||
val perBonus = 1f + ((computedStats.per?.toFloat() ?: 0f) * 0.02f)
|
||||
val goldMod = delta * task.priority * perBonus
|
||||
|
|
|
|||
|
|
@ -8,32 +8,32 @@ import com.habitrpg.shared.habitica.models.Avatar
|
|||
import javax.inject.Inject
|
||||
|
||||
class ShareAvatarUseCase
|
||||
@Inject
|
||||
constructor() : UseCase<ShareAvatarUseCase.RequestValues, Unit>() {
|
||||
override suspend fun run(requestValues: RequestValues) {
|
||||
val avatarView =
|
||||
AvatarView(
|
||||
requestValues.activity,
|
||||
showBackground = true,
|
||||
showMount = true,
|
||||
showPet = true,
|
||||
)
|
||||
avatarView.setAvatar(requestValues.avatar)
|
||||
var sharedImage: Bitmap? = null
|
||||
avatarView.onAvatarImageReady { image ->
|
||||
sharedImage = image?.scale(image.width * 3, image.height * 3, false)
|
||||
requestValues.activity.shareContent(
|
||||
requestValues.identifier,
|
||||
requestValues.message,
|
||||
sharedImage,
|
||||
)
|
||||
}
|
||||
@Inject
|
||||
constructor() : UseCase<ShareAvatarUseCase.RequestValues, Unit>() {
|
||||
override suspend fun run(requestValues: RequestValues) {
|
||||
val avatarView =
|
||||
AvatarView(
|
||||
requestValues.activity,
|
||||
showBackground = true,
|
||||
showMount = true,
|
||||
showPet = true
|
||||
)
|
||||
avatarView.setAvatar(requestValues.avatar)
|
||||
var sharedImage: Bitmap? = null
|
||||
avatarView.onAvatarImageReady { image ->
|
||||
sharedImage = image?.scale(image.width * 3, image.height * 3, false)
|
||||
requestValues.activity.shareContent(
|
||||
requestValues.identifier,
|
||||
requestValues.message,
|
||||
sharedImage
|
||||
)
|
||||
}
|
||||
|
||||
class RequestValues(
|
||||
val activity: BaseActivity,
|
||||
val avatar: Avatar,
|
||||
val message: String?,
|
||||
val identifier: String,
|
||||
) : UseCase.RequestValues
|
||||
}
|
||||
|
||||
class RequestValues(
|
||||
val activity: BaseActivity,
|
||||
val avatar: Avatar,
|
||||
val message: String?,
|
||||
val identifier: String
|
||||
) : UseCase.RequestValues
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ class ShareMountUseCase : UseCase<ShareMountUseCase.RequestValues, Unit>() {
|
|||
Bitmap.createBitmap(
|
||||
width,
|
||||
height,
|
||||
Bitmap.Config.ARGB_8888,
|
||||
Bitmap.Config.ARGB_8888
|
||||
)
|
||||
val canvas = Canvas(sharedImage)
|
||||
var attempts = 0
|
||||
|
|
@ -65,9 +65,9 @@ class ShareMountUseCase : UseCase<ShareMountUseCase.RequestValues, Unit>() {
|
|||
mountWrapper.root.draw(canvas)
|
||||
(
|
||||
(requestValues.context as? BaseActivity) ?: HabiticaBaseApplication.getInstance(
|
||||
requestValues.context,
|
||||
requestValues.context
|
||||
)?.currentActivity?.get()
|
||||
)?.shareContent("pet", requestValues.message, sharedImage)
|
||||
)?.shareContent("pet", requestValues.message, sharedImage)
|
||||
containerView?.removeView(mountWrapper.root)
|
||||
}
|
||||
// trigger layout
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ class SharePetUseCase : UseCase<SharePetUseCase.RequestValues, Unit>() {
|
|||
Bitmap.createBitmap(
|
||||
width,
|
||||
height,
|
||||
Bitmap.Config.ARGB_8888,
|
||||
Bitmap.Config.ARGB_8888
|
||||
)
|
||||
val canvas = Canvas(sharedImage)
|
||||
var attempts = 0
|
||||
|
|
@ -63,9 +63,9 @@ class SharePetUseCase : UseCase<SharePetUseCase.RequestValues, Unit>() {
|
|||
petWrapper.root.draw(canvas)
|
||||
(
|
||||
(requestValues.context as? BaseActivity) ?: HabiticaBaseApplication.getInstance(
|
||||
requestValues.context,
|
||||
requestValues.context
|
||||
)?.currentActivity?.get()
|
||||
)?.shareContent("pet", requestValues.message, sharedImage)
|
||||
)?.shareContent("pet", requestValues.message, sharedImage)
|
||||
containerView?.removeView(petWrapper.root)
|
||||
}
|
||||
val m = FrameLayout.LayoutParams(width, height)
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ import kotlinx.coroutines.launch
|
|||
|
||||
class ShowNotificationInteractor(
|
||||
private val activity: Activity,
|
||||
private val lifecycleScope: LifecycleCoroutineScope,
|
||||
private val lifecycleScope: LifecycleCoroutineScope
|
||||
) {
|
||||
fun handleNotification(notification: Notification): Boolean {
|
||||
when (notification.type) {
|
||||
|
|
@ -41,7 +41,7 @@ class ShowNotificationInteractor(
|
|||
Notification.Type.ACHIEVEMENT_GUILD_JOINED.type -> showAchievementDialog(notification)
|
||||
Notification.Type.ACHIEVEMENT_CHALLENGE_JOINED.type ->
|
||||
showAchievementDialog(
|
||||
notification,
|
||||
notification
|
||||
)
|
||||
|
||||
Notification.Type.ACHIEVEMENT_INVITED_FRIEND.type -> showAchievementDialog(notification)
|
||||
|
|
@ -52,12 +52,12 @@ class ShowNotificationInteractor(
|
|||
Notification.Type.ACHIEVEMENT_JUST_ADD_WATER.type -> showAchievementDialog(notification)
|
||||
Notification.Type.ACHIEVEMENT_LOST_MASTERCLASSER.type ->
|
||||
showAchievementDialog(
|
||||
notification,
|
||||
notification
|
||||
)
|
||||
|
||||
Notification.Type.ACHIEVEMENT_MIND_OVER_MATTER.type ->
|
||||
showAchievementDialog(
|
||||
notification,
|
||||
notification
|
||||
)
|
||||
|
||||
Notification.Type.ACHIEVEMENT_DUST_DEVIL.type -> showAchievementDialog(notification)
|
||||
|
|
@ -65,12 +65,12 @@ class ShowNotificationInteractor(
|
|||
Notification.Type.ACHIEVEMENT_MONSTER_MAGUS.type -> showAchievementDialog(notification)
|
||||
Notification.Type.ACHIEVEMENT_UNDEAD_UNDERTAKER.type ->
|
||||
showAchievementDialog(
|
||||
notification,
|
||||
notification
|
||||
)
|
||||
|
||||
Notification.Type.ACHIEVEMENT_PRIMED_FOR_PAINTING.type ->
|
||||
showAchievementDialog(
|
||||
notification,
|
||||
notification
|
||||
)
|
||||
|
||||
Notification.Type.ACHIEVEMENT_PEARLY_PRO.type -> showAchievementDialog(notification)
|
||||
|
|
@ -79,18 +79,18 @@ class ShowNotificationInteractor(
|
|||
Notification.Type.ACHIEVEMENT_BUG_BONANZA.type -> showAchievementDialog(notification)
|
||||
Notification.Type.ACHIEVEMENT_BARE_NECESSITIES.type ->
|
||||
showAchievementDialog(
|
||||
notification,
|
||||
notification
|
||||
)
|
||||
|
||||
Notification.Type.ACHIEVEMENT_FRESHWATER_FRIENDS.type ->
|
||||
showAchievementDialog(
|
||||
notification,
|
||||
notification
|
||||
)
|
||||
|
||||
Notification.Type.ACHIEVEMENT_GOOD_AS_GOLD.type -> showAchievementDialog(notification)
|
||||
Notification.Type.ACHIEVEMENT_ALL_THAT_GLITTERS.type ->
|
||||
showAchievementDialog(
|
||||
notification,
|
||||
notification
|
||||
)
|
||||
|
||||
Notification.Type.ACHIEVEMENT_GOOD_AS_GOLD.type -> showAchievementDialog(notification)
|
||||
|
|
@ -102,7 +102,7 @@ class ShowNotificationInteractor(
|
|||
Notification.Type.ACHIEVEMENT_GENERIC.type -> showAchievementDialog(notification)
|
||||
Notification.Type.ACHIEVEMENT_ONBOARDING_COMPLETE.type ->
|
||||
showAchievementDialog(
|
||||
notification,
|
||||
notification
|
||||
)
|
||||
|
||||
Notification.Type.FIRST_DROP.type -> showFirstDropDialog(notification)
|
||||
|
|
@ -152,7 +152,7 @@ class ShowNotificationInteractor(
|
|||
(activity as? SnackbarActivity)?.showSnackbar(
|
||||
title = notificationData?.message,
|
||||
content = nextUnlockText,
|
||||
displayType = HabiticaSnackbar.SnackbarDisplayType.BLUE,
|
||||
displayType = HabiticaSnackbar.SnackbarDisplayType.BLUE
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package com.habitrpg.android.habitica.models
|
|||
data class CustomizationFilter(
|
||||
var onlyPurchased: Boolean = false,
|
||||
var ascending: Boolean = false,
|
||||
var months: MutableList<String> = mutableListOf(),
|
||||
var months: MutableList<String> = mutableListOf()
|
||||
) {
|
||||
val isFiltering: Boolean
|
||||
get() {
|
||||
|
|
@ -14,7 +14,7 @@ data class CustomizationFilter(
|
|||
if (other is CustomizationFilter) {
|
||||
return onlyPurchased == other.onlyPurchased && ascending == other.ascending && months.size == other.months.size &&
|
||||
months.containsAll(
|
||||
other.months,
|
||||
other.months
|
||||
)
|
||||
}
|
||||
return super.equals(other)
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ class SetupCustomization {
|
|||
fun createSize(
|
||||
key: String,
|
||||
drawableId: Int,
|
||||
text: String,
|
||||
text: String
|
||||
): SetupCustomization {
|
||||
val customization = SetupCustomization()
|
||||
customization.key = key
|
||||
|
|
@ -27,7 +27,7 @@ class SetupCustomization {
|
|||
|
||||
fun createShirt(
|
||||
key: String,
|
||||
drawableId: Int,
|
||||
drawableId: Int
|
||||
): SetupCustomization {
|
||||
val customization = SetupCustomization()
|
||||
customization.key = key
|
||||
|
|
@ -40,7 +40,7 @@ class SetupCustomization {
|
|||
|
||||
fun createSkin(
|
||||
key: String,
|
||||
colorId: Int?,
|
||||
colorId: Int?
|
||||
): SetupCustomization {
|
||||
val customization = SetupCustomization()
|
||||
customization.key = key
|
||||
|
|
@ -52,7 +52,7 @@ class SetupCustomization {
|
|||
|
||||
fun createHairColor(
|
||||
key: String,
|
||||
colorId: Int?,
|
||||
colorId: Int?
|
||||
): SetupCustomization {
|
||||
val customization = SetupCustomization()
|
||||
customization.key = key
|
||||
|
|
@ -65,7 +65,7 @@ class SetupCustomization {
|
|||
|
||||
fun createHairBangs(
|
||||
key: String,
|
||||
drawableId: Int?,
|
||||
drawableId: Int?
|
||||
): SetupCustomization {
|
||||
val customization = SetupCustomization()
|
||||
customization.key = key
|
||||
|
|
@ -78,7 +78,7 @@ class SetupCustomization {
|
|||
|
||||
fun createHairPonytail(
|
||||
key: String,
|
||||
drawableId: Int?,
|
||||
drawableId: Int?
|
||||
): SetupCustomization {
|
||||
val customization = SetupCustomization()
|
||||
customization.key = key
|
||||
|
|
@ -91,7 +91,7 @@ class SetupCustomization {
|
|||
|
||||
fun createGlasses(
|
||||
key: String,
|
||||
drawableId: Int?,
|
||||
drawableId: Int?
|
||||
): SetupCustomization {
|
||||
val customization = SetupCustomization()
|
||||
customization.key = key
|
||||
|
|
@ -104,7 +104,7 @@ class SetupCustomization {
|
|||
|
||||
fun createFlower(
|
||||
key: String,
|
||||
drawableId: Int?,
|
||||
drawableId: Int?
|
||||
): SetupCustomization {
|
||||
val customization = SetupCustomization()
|
||||
customization.key = key
|
||||
|
|
@ -117,7 +117,7 @@ class SetupCustomization {
|
|||
|
||||
fun createWheelchair(
|
||||
key: String,
|
||||
drawableId: Int?,
|
||||
drawableId: Int?
|
||||
): SetupCustomization {
|
||||
val customization = SetupCustomization()
|
||||
customization.key = key
|
||||
|
|
|
|||
|
|
@ -27,8 +27,8 @@ open class TutorialStep : RealmObject(), BaseMainObject {
|
|||
this.displayedOn == null || Date().time - (
|
||||
displayedOn?.time
|
||||
?: 0
|
||||
) > 86400000
|
||||
)
|
||||
) > 86400000
|
||||
)
|
||||
}
|
||||
override val realmClass: Class<out RealmModel>
|
||||
get() = TutorialStep::class.java
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ open class Customization : RealmObject(), BaseObject {
|
|||
|
||||
fun getIconName(
|
||||
userSize: String?,
|
||||
hairColor: String?,
|
||||
hairColor: String?
|
||||
): String? {
|
||||
if (this.type == "hair" && this.category == "color") {
|
||||
return "icon_color_hair_bangs_1_$identifier"
|
||||
|
|
@ -60,7 +60,7 @@ open class Customization : RealmObject(), BaseObject {
|
|||
|
||||
fun getImageName(
|
||||
userSize: String?,
|
||||
hairColor: String?,
|
||||
hairColor: String?
|
||||
): String? {
|
||||
if (!this.isValid) {
|
||||
return null
|
||||
|
|
@ -96,7 +96,7 @@ open class Customization : RealmObject(), BaseObject {
|
|||
path +
|
||||
this.customizationSet?.substring(
|
||||
5,
|
||||
7,
|
||||
7
|
||||
) + this.customizationSet?.substring(0, 4)
|
||||
} else {
|
||||
path + "." + this.customizationSet
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package com.habitrpg.android.habitica.models.inventory
|
|||
import io.realm.RealmObject
|
||||
import io.realm.annotations.PrimaryKey
|
||||
|
||||
open class EquipmentSet: RealmObject() {
|
||||
open class EquipmentSet : RealmObject() {
|
||||
@PrimaryKey
|
||||
var key: String = ""
|
||||
var text: String = ""
|
||||
|
|
|
|||
|
|
@ -54,14 +54,14 @@ class FallExtraGemsHabiticaPromotion(startDate: Date?, endDate: Date?) : Habitic
|
|||
view.setSubtitleImage(
|
||||
ContextCompat.getDrawable(
|
||||
context,
|
||||
R.drawable.fall_promo_menu_description,
|
||||
),
|
||||
R.drawable.fall_promo_menu_description
|
||||
)
|
||||
)
|
||||
view.setSubtitleText(null)
|
||||
|
||||
view.setDecoration(
|
||||
ContextCompat.getDrawable(context, R.drawable.fall_promo_menu_left),
|
||||
ContextCompat.getDrawable(context, R.drawable.fall_promo_menu_right),
|
||||
ContextCompat.getDrawable(context, R.drawable.fall_promo_menu_right)
|
||||
)
|
||||
|
||||
view.binding.button.backgroundTintList =
|
||||
|
|
@ -84,27 +84,27 @@ class FallExtraGemsHabiticaPromotion(startDate: Date?, endDate: Date?) : Habitic
|
|||
binding.promoBannerLeftImage.setImageDrawable(
|
||||
ContextCompat.getDrawable(
|
||||
context,
|
||||
R.drawable.fall_promo_banner_left,
|
||||
),
|
||||
R.drawable.fall_promo_banner_left
|
||||
)
|
||||
)
|
||||
binding.promoBannerRightImage.setImageDrawable(
|
||||
ContextCompat.getDrawable(
|
||||
context,
|
||||
R.drawable.fall_promo_banner_right,
|
||||
),
|
||||
R.drawable.fall_promo_banner_right
|
||||
)
|
||||
)
|
||||
binding.promoBannerTitleImage.setImageDrawable(
|
||||
ContextCompat.getDrawable(
|
||||
context,
|
||||
R.drawable.fall_promo_title,
|
||||
),
|
||||
R.drawable.fall_promo_title
|
||||
)
|
||||
)
|
||||
val formatter = SimpleDateFormat("MMM d", Locale.getDefault())
|
||||
binding.promoBannerDurationView.text =
|
||||
context.getString(
|
||||
R.string.x_to_y,
|
||||
formatter.format(startDate),
|
||||
formatter.format(endDate),
|
||||
formatter.format(endDate)
|
||||
)
|
||||
binding.promoBannerDurationView.setTextColor(Color.parseColor("#FEE2B6"))
|
||||
}
|
||||
|
|
@ -115,7 +115,7 @@ class FallExtraGemsHabiticaPromotion(startDate: Date?, endDate: Date?) : Habitic
|
|||
@SuppressLint("SetTextI18n")
|
||||
override fun configureGemView(
|
||||
binding: PurchaseGemViewBinding,
|
||||
regularAmount: Int,
|
||||
regularAmount: Int
|
||||
) {
|
||||
val context = binding.root.context
|
||||
binding.root.background = promoBackgroundDrawable(context)
|
||||
|
|
@ -156,20 +156,20 @@ class FallExtraGemsHabiticaPromotion(startDate: Date?, endDate: Date?) : Habitic
|
|||
fragment.binding?.promoBannerLeftImage?.setImageDrawable(
|
||||
ContextCompat.getDrawable(
|
||||
context,
|
||||
R.drawable.fall_promo_info_left,
|
||||
),
|
||||
R.drawable.fall_promo_info_left
|
||||
)
|
||||
)
|
||||
fragment.binding?.promoBannerRightImage?.setImageDrawable(
|
||||
ContextCompat.getDrawable(
|
||||
context,
|
||||
R.drawable.fall_promo_info_right,
|
||||
),
|
||||
R.drawable.fall_promo_info_right
|
||||
)
|
||||
)
|
||||
fragment.binding?.promoBannerTitleImage?.setImageDrawable(
|
||||
ContextCompat.getDrawable(
|
||||
context,
|
||||
R.drawable.fall_promo_title,
|
||||
),
|
||||
R.drawable.fall_promo_title
|
||||
)
|
||||
)
|
||||
fragment.binding?.promoBannerSubtitleView?.setText(R.string.limited_event)
|
||||
fragment.binding?.promoBannerDurationView?.setTextColor(Color.parseColor("#FEE2B6"))
|
||||
|
|
@ -178,13 +178,13 @@ class FallExtraGemsHabiticaPromotion(startDate: Date?, endDate: Date?) : Habitic
|
|||
context.getString(
|
||||
R.string.x_to_y,
|
||||
formatter.format(startDate),
|
||||
formatter.format(endDate),
|
||||
formatter.format(endDate)
|
||||
)
|
||||
fragment.binding?.promoBannerDurationView?.setTextColor(
|
||||
ContextCompat.getColor(
|
||||
context,
|
||||
R.color.white,
|
||||
),
|
||||
R.color.white
|
||||
)
|
||||
)
|
||||
fragment.binding?.promptText?.setText(R.string.fall_promo_info_prompt)
|
||||
fragment.binding?.promptText?.setTextColor(Color.parseColor("#F78E2F"))
|
||||
|
|
@ -197,7 +197,7 @@ class FallExtraGemsHabiticaPromotion(startDate: Date?, endDate: Date?) : Habitic
|
|||
context.getString(
|
||||
R.string.fall_promo_info_instructions,
|
||||
formatter.format(startDate),
|
||||
formatter.format(endDate),
|
||||
formatter.format(endDate)
|
||||
)
|
||||
val limitationsFormatter =
|
||||
SimpleDateFormat.getDateTimeInstance(SimpleDateFormat.LONG, SimpleDateFormat.LONG)
|
||||
|
|
@ -209,7 +209,7 @@ class FallExtraGemsHabiticaPromotion(startDate: Date?, endDate: Date?) : Habitic
|
|||
limitationsFormatter.format(startDate),
|
||||
utcTimeFormatter.format(startDate),
|
||||
limitationsFormatter.format(endDate),
|
||||
utcTimeFormatter.format(endDate),
|
||||
utcTimeFormatter.format(endDate)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ import com.habitrpg.common.habitica.helpers.MainNavigationController
|
|||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
import java.util.Locale
|
||||
import java.util.TimeZone
|
||||
|
||||
class GiftOneGetOneHabiticaPromotion(startDate: Date?, endDate: Date?) : HabiticaPromotion() {
|
||||
override val identifier: String
|
||||
|
|
@ -54,7 +53,7 @@ class GiftOneGetOneHabiticaPromotion(startDate: Date?, endDate: Date?) : Habitic
|
|||
|
||||
view.setDecoration(
|
||||
ContextCompat.getDrawable(context, R.drawable.g1g1_promo_menu_left),
|
||||
ContextCompat.getDrawable(context, R.drawable.g1g1_promo_menu_right),
|
||||
ContextCompat.getDrawable(context, R.drawable.g1g1_promo_menu_right)
|
||||
)
|
||||
|
||||
view.binding.button.backgroundTintList =
|
||||
|
|
@ -81,14 +80,14 @@ class GiftOneGetOneHabiticaPromotion(startDate: Date?, endDate: Date?) : Habitic
|
|||
binding.promoBannerLeftImage.setImageDrawable(
|
||||
ContextCompat.getDrawable(
|
||||
context,
|
||||
R.drawable.g1g1_promo_left,
|
||||
),
|
||||
R.drawable.g1g1_promo_left
|
||||
)
|
||||
)
|
||||
binding.promoBannerRightImage.setImageDrawable(
|
||||
ContextCompat.getDrawable(
|
||||
context,
|
||||
R.drawable.g1g1_promo_right,
|
||||
),
|
||||
R.drawable.g1g1_promo_right
|
||||
)
|
||||
)
|
||||
binding.promoBannerTitleImage.visibility = View.GONE
|
||||
binding.promoBannerDurationView.visibility = View.GONE
|
||||
|
|
@ -107,14 +106,14 @@ class GiftOneGetOneHabiticaPromotion(startDate: Date?, endDate: Date?) : Habitic
|
|||
binding.content.promoBannerLeftImage.setImageDrawable(
|
||||
ContextCompat.getDrawable(
|
||||
context,
|
||||
R.drawable.g1g1_promo_left,
|
||||
),
|
||||
R.drawable.g1g1_promo_left
|
||||
)
|
||||
)
|
||||
binding.content.promoBannerRightImage.setImageDrawable(
|
||||
ContextCompat.getDrawable(
|
||||
context,
|
||||
R.drawable.g1g1_promo_right,
|
||||
),
|
||||
R.drawable.g1g1_promo_right
|
||||
)
|
||||
)
|
||||
binding.content.promoBannerTitleImage.visibility = View.GONE
|
||||
binding.content.promoBannerDurationView.visibility = View.GONE
|
||||
|
|
@ -128,7 +127,7 @@ class GiftOneGetOneHabiticaPromotion(startDate: Date?, endDate: Date?) : Habitic
|
|||
|
||||
override fun configureGemView(
|
||||
binding: PurchaseGemViewBinding,
|
||||
regularAmount: Int,
|
||||
regularAmount: Int
|
||||
) {
|
||||
}
|
||||
|
||||
|
|
@ -138,14 +137,14 @@ class GiftOneGetOneHabiticaPromotion(startDate: Date?, endDate: Date?) : Habitic
|
|||
fragment.binding?.promoBannerLeftImage?.setImageDrawable(
|
||||
ContextCompat.getDrawable(
|
||||
context,
|
||||
R.drawable.g1g1_promo_left,
|
||||
),
|
||||
R.drawable.g1g1_promo_left
|
||||
)
|
||||
)
|
||||
fragment.binding?.promoBannerRightImage?.setImageDrawable(
|
||||
ContextCompat.getDrawable(
|
||||
context,
|
||||
R.drawable.g1g1_promo_right,
|
||||
),
|
||||
R.drawable.g1g1_promo_right
|
||||
)
|
||||
)
|
||||
fragment.binding?.promoBannerTitleImage?.visibility = View.GONE
|
||||
fragment.binding?.promoBannerTitleText?.visibility = View.VISIBLE
|
||||
|
|
@ -156,20 +155,20 @@ class GiftOneGetOneHabiticaPromotion(startDate: Date?, endDate: Date?) : Habitic
|
|||
context.getString(
|
||||
R.string.x_to_y,
|
||||
formatter.format(startDate),
|
||||
formatter.format(endDate),
|
||||
formatter.format(endDate)
|
||||
)
|
||||
fragment.binding?.promoBannerDurationView?.setTextColor(
|
||||
ContextCompat.getColor(
|
||||
context,
|
||||
R.color.white,
|
||||
),
|
||||
R.color.white
|
||||
)
|
||||
)
|
||||
fragment.binding?.promptText?.setText(R.string.g1g1_promo_info_prompt)
|
||||
fragment.binding?.promptText?.setTextColor(
|
||||
ContextCompat.getColor(
|
||||
context,
|
||||
R.color.text_teal,
|
||||
),
|
||||
R.color.text_teal
|
||||
)
|
||||
)
|
||||
fragment.binding?.promptButton?.background =
|
||||
ContextCompat.getDrawable(context, R.drawable.layout_rounded_bg_brand_400)
|
||||
|
|
@ -178,7 +177,7 @@ class GiftOneGetOneHabiticaPromotion(startDate: Date?, endDate: Date?) : Habitic
|
|||
fragment.binding?.promptButton?.setOnClickListener {
|
||||
fragment.context?.let { context ->
|
||||
SubscriptionFragment.showGiftSubscriptionDialog(
|
||||
context,
|
||||
context
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -191,7 +190,7 @@ class GiftOneGetOneHabiticaPromotion(startDate: Date?, endDate: Date?) : Habitic
|
|||
context.getString(
|
||||
R.string.g1g1_promo_info_limitations_noutc,
|
||||
limitationsFormatter.format(startDate),
|
||||
limitationsFormatter.format(endDate),
|
||||
limitationsFormatter.format(endDate)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ enum class PromoType {
|
|||
GEMS_AMOUNT,
|
||||
GEMS_PRICE,
|
||||
SUBSCRIPTION,
|
||||
SURVEY,
|
||||
SURVEY
|
||||
}
|
||||
|
||||
abstract class HabiticaPromotion {
|
||||
|
|
@ -50,7 +50,7 @@ abstract class HabiticaPromotion {
|
|||
|
||||
abstract fun configureGemView(
|
||||
binding: PurchaseGemViewBinding,
|
||||
regularAmount: Int,
|
||||
regularAmount: Int
|
||||
)
|
||||
|
||||
abstract fun configureInfoFragment(fragment: PromoInfoFragment)
|
||||
|
|
@ -59,19 +59,19 @@ abstract class HabiticaPromotion {
|
|||
fun getHabiticaPromotionFromKey(
|
||||
key: String,
|
||||
startDate: Date?,
|
||||
endDate: Date?,
|
||||
endDate: Date?
|
||||
): HabiticaPromotion? {
|
||||
return when (key) {
|
||||
"fall_extra_gems", "fall2020", "testFall2020" ->
|
||||
FallExtraGemsHabiticaPromotion(
|
||||
startDate,
|
||||
endDate,
|
||||
endDate
|
||||
)
|
||||
|
||||
"spooky_extra_gems", "fall2020SecondPromo", "spooky2020" ->
|
||||
SpookyExtraGemsHabiticaPromotion(
|
||||
startDate,
|
||||
endDate,
|
||||
endDate
|
||||
)
|
||||
|
||||
"g1g1" -> GiftOneGetOneHabiticaPromotion(startDate, endDate)
|
||||
|
|
|
|||
|
|
@ -55,14 +55,14 @@ class SpookyExtraGemsHabiticaPromotion(startDate: Date?, endDate: Date?) : Habit
|
|||
view.setSubtitleImage(
|
||||
ContextCompat.getDrawable(
|
||||
context,
|
||||
R.drawable.spooky_promo_menu_description,
|
||||
),
|
||||
R.drawable.spooky_promo_menu_description
|
||||
)
|
||||
)
|
||||
view.setSubtitleText(null)
|
||||
|
||||
view.setDecoration(
|
||||
ContextCompat.getDrawable(context, R.drawable.spooky_promo_menu_left),
|
||||
ContextCompat.getDrawable(context, R.drawable.spooky_promo_menu_right),
|
||||
ContextCompat.getDrawable(context, R.drawable.spooky_promo_menu_right)
|
||||
)
|
||||
|
||||
view.binding.button.backgroundTintList =
|
||||
|
|
@ -85,27 +85,27 @@ class SpookyExtraGemsHabiticaPromotion(startDate: Date?, endDate: Date?) : Habit
|
|||
binding.promoBannerLeftImage.setImageDrawable(
|
||||
ContextCompat.getDrawable(
|
||||
context,
|
||||
R.drawable.spooky_promo_banner_left,
|
||||
),
|
||||
R.drawable.spooky_promo_banner_left
|
||||
)
|
||||
)
|
||||
binding.promoBannerRightImage.setImageDrawable(
|
||||
ContextCompat.getDrawable(
|
||||
context,
|
||||
R.drawable.spooky_promo_banner_right,
|
||||
),
|
||||
R.drawable.spooky_promo_banner_right
|
||||
)
|
||||
)
|
||||
binding.promoBannerTitleImage.setImageDrawable(
|
||||
ContextCompat.getDrawable(
|
||||
context,
|
||||
R.drawable.spooky_promo_title,
|
||||
),
|
||||
R.drawable.spooky_promo_title
|
||||
)
|
||||
)
|
||||
val formatter = SimpleDateFormat("MMM d", Locale.getDefault())
|
||||
binding.promoBannerDurationView.text =
|
||||
context.getString(
|
||||
R.string.x_to_y,
|
||||
formatter.format(startDate),
|
||||
formatter.format(endDate),
|
||||
formatter.format(endDate)
|
||||
)
|
||||
binding.promoBannerDurationView.setTextColor(ContextCompat.getColor(context, R.color.white))
|
||||
}
|
||||
|
|
@ -116,7 +116,7 @@ class SpookyExtraGemsHabiticaPromotion(startDate: Date?, endDate: Date?) : Habit
|
|||
@SuppressLint("SetTextI18n")
|
||||
override fun configureGemView(
|
||||
binding: PurchaseGemViewBinding,
|
||||
regularAmount: Int,
|
||||
regularAmount: Int
|
||||
) {
|
||||
val context = binding.root.context
|
||||
binding.root.background = promoBackgroundDrawable(context)
|
||||
|
|
@ -157,47 +157,47 @@ class SpookyExtraGemsHabiticaPromotion(startDate: Date?, endDate: Date?) : Habit
|
|||
fragment.binding?.promoBannerLeftImage?.setImageDrawable(
|
||||
ContextCompat.getDrawable(
|
||||
context,
|
||||
R.drawable.spooky_promo_info_left,
|
||||
),
|
||||
R.drawable.spooky_promo_info_left
|
||||
)
|
||||
)
|
||||
fragment.binding?.promoBannerRightImage?.setImageDrawable(
|
||||
ContextCompat.getDrawable(
|
||||
context,
|
||||
R.drawable.spooky_promo_info_right,
|
||||
),
|
||||
R.drawable.spooky_promo_info_right
|
||||
)
|
||||
)
|
||||
fragment.binding?.promoBannerTitleImage?.setImageDrawable(
|
||||
ContextCompat.getDrawable(
|
||||
context,
|
||||
R.drawable.spooky_promo_title,
|
||||
),
|
||||
R.drawable.spooky_promo_title
|
||||
)
|
||||
)
|
||||
fragment.binding?.promoBannerSubtitleView?.setText(R.string.limited_event)
|
||||
fragment.binding?.promoBannerDurationView?.setTextColor(
|
||||
ContextCompat.getColor(
|
||||
context,
|
||||
R.color.white,
|
||||
),
|
||||
R.color.white
|
||||
)
|
||||
)
|
||||
val formatter = SimpleDateFormat("MMM d", Locale.getDefault())
|
||||
fragment.binding?.promoBannerDurationView?.text =
|
||||
context.getString(
|
||||
R.string.x_to_y,
|
||||
formatter.format(startDate),
|
||||
formatter.format(endDate),
|
||||
formatter.format(endDate)
|
||||
)
|
||||
fragment.binding?.promoBannerDurationView?.setTextColor(
|
||||
ContextCompat.getColor(
|
||||
context,
|
||||
R.color.white,
|
||||
),
|
||||
R.color.white
|
||||
)
|
||||
)
|
||||
fragment.binding?.promptText?.setText(R.string.spooky_promo_info_prompt)
|
||||
fragment.binding?.promptText?.setTextColor(
|
||||
ContextCompat.getColor(
|
||||
context,
|
||||
R.color.orange_50,
|
||||
),
|
||||
R.color.orange_50
|
||||
)
|
||||
)
|
||||
fragment.binding?.promptButton?.background = buttonDrawable(context)
|
||||
fragment.binding?.promptButton?.setText(R.string.view_gem_bundles)
|
||||
|
|
@ -208,7 +208,7 @@ class SpookyExtraGemsHabiticaPromotion(startDate: Date?, endDate: Date?) : Habit
|
|||
context.getString(
|
||||
R.string.spooky_promo_info_instructions,
|
||||
formatter.format(startDate),
|
||||
formatter.format(endDate),
|
||||
formatter.format(endDate)
|
||||
)
|
||||
val limitationsFormatter = SimpleDateFormat.getDateTimeInstance()
|
||||
val utcTimeFormatter = SimpleDateFormat.getTimeInstance(SimpleDateFormat.LONG)
|
||||
|
|
@ -219,7 +219,7 @@ class SpookyExtraGemsHabiticaPromotion(startDate: Date?, endDate: Date?) : Habit
|
|||
limitationsFormatter.format(startDate),
|
||||
utcTimeFormatter.format(startDate),
|
||||
limitationsFormatter.format(endDate),
|
||||
utcTimeFormatter.format(endDate),
|
||||
utcTimeFormatter.format(endDate)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ class Survey2021Promotion : HabiticaPromotion(), HabiticaWebPromotion {
|
|||
|
||||
view.setDecoration(
|
||||
ContextCompat.getDrawable(context, R.drawable.survey_art_left),
|
||||
ContextCompat.getDrawable(context, R.drawable.survey_art_right),
|
||||
ContextCompat.getDrawable(context, R.drawable.survey_art_right)
|
||||
)
|
||||
|
||||
view.binding.button.backgroundTintList =
|
||||
|
|
@ -67,7 +67,7 @@ class Survey2021Promotion : HabiticaPromotion(), HabiticaWebPromotion {
|
|||
override fun menuOnNavigation(context: Context) {
|
||||
MainNavigationController.navigate(
|
||||
R.id.promoWebFragment,
|
||||
PromoWebFragmentArgs.Builder(url ?: "").build().toBundle(),
|
||||
PromoWebFragmentArgs.Builder(url ?: "").build().toBundle()
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -79,7 +79,7 @@ class Survey2021Promotion : HabiticaPromotion(), HabiticaWebPromotion {
|
|||
|
||||
override fun configureGemView(
|
||||
binding: PurchaseGemViewBinding,
|
||||
regularAmount: Int,
|
||||
regularAmount: Int
|
||||
) {
|
||||
}
|
||||
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue