mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-04-14 11:46:32 +00:00
finish 4.4.2
This commit is contained in:
parent
bda5edf105
commit
d2c769eada
11 changed files with 219 additions and 44 deletions
|
|
@ -1,23 +1,30 @@
|
|||
<!-- A DrawerLayout is intended to be used as the top-level content view using match_parent for both width and height to consume the full space available. -->
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/drawer_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context="com.habitrpg.android.habitica.ui.activities.MainActivity"
|
||||
android:background="?attr/colorContentBackground"
|
||||
android:animateLayoutChanges="true">
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/root_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context="com.habitrpg.android.habitica.ui.activities.MainActivity"
|
||||
android:background="?attr/colorContentBackground"
|
||||
android:animateLayoutChanges="true">
|
||||
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/navigation_drawer"
|
||||
class="com.habitrpg.android.habitica.ui.fragments.NavigationDrawerFragment"
|
||||
android:layout_width="@dimen/drawer_width"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="start"
|
||||
tools:layout="@layout/drawer_main"/>
|
||||
android:id="@+id/navigation_drawer"
|
||||
class="com.habitrpg.android.habitica.ui.fragments.NavigationDrawerFragment"
|
||||
android:layout_width="@dimen/drawer_width"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="start"
|
||||
tools:layout="@layout/drawer_main" />
|
||||
|
||||
<View
|
||||
android:layout_width="1dp"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/colorWindowBackground"/>
|
||||
<include layout="@layout/activity_main_content" android:id="@+id/content" />
|
||||
</LinearLayout>
|
||||
android:layout_width="1dp"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/colorWindowBackground" />
|
||||
|
||||
<include
|
||||
layout="@layout/activity_main_content"
|
||||
android:id="@+id/content" />
|
||||
</LinearLayout>
|
||||
</FrameLayout>
|
||||
|
|
|
|||
|
|
@ -5,12 +5,6 @@
|
|||
android:layout_height="match_parent"
|
||||
tools:context=".ui.activities.MainActivity"
|
||||
android:id="@+id/overlayFrameLayout">
|
||||
<androidx.drawerlayout.widget.DrawerLayout
|
||||
android:id="@+id/drawer_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center">
|
||||
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
|
@ -43,5 +37,4 @@
|
|||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
</androidx.drawerlayout.widget.DrawerLayout>
|
||||
</FrameLayout>
|
||||
</FrameLayout>
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
<!-- A DrawerLayout is intended to be used as the top-level content view using match_parent for both width and height to consume the full space available. -->
|
||||
<FrameLayout
|
||||
android:id="@+id/root_layout"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<androidx.drawerlayout.widget.DrawerLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/drawer_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
|
@ -22,5 +24,5 @@
|
|||
android:layout_height="match_parent"
|
||||
android:layout_gravity="start"
|
||||
tools:layout="@layout/drawer_main"/>
|
||||
|
||||
</androidx.drawerlayout.widget.DrawerLayout>
|
||||
</FrameLayout>
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ class NoPartyFragmentFragment : BaseMainFragment<FragmentNoPartyBinding>() {
|
|||
refresh()
|
||||
|
||||
binding?.invitationsView?.acceptCall = {
|
||||
lifecycleScope.launch(ExceptionHandler.coroutine()) {
|
||||
lifecycleScope.launchCatching {
|
||||
socialRepository.joinGroup(it)
|
||||
userRepository.retrieveUser(false, true)
|
||||
parentFragmentManager.popBackStack()
|
||||
|
|
@ -152,7 +152,7 @@ class NoPartyFragmentFragment : BaseMainFragment<FragmentNoPartyBinding>() {
|
|||
if (it.resultCode == Activity.RESULT_OK) {
|
||||
val bundle = it.data?.extras
|
||||
if (bundle?.getString("groupType") == "party") {
|
||||
lifecycleScope.launch(ExceptionHandler.coroutine()) {
|
||||
lifecycleScope.launchCatching {
|
||||
val group =
|
||||
socialRepository.createGroup(
|
||||
bundle.getString("name"),
|
||||
|
|
@ -176,14 +176,12 @@ class NoPartyFragmentFragment : BaseMainFragment<FragmentNoPartyBinding>() {
|
|||
}
|
||||
|
||||
private fun refresh() {
|
||||
lifecycleScope.launch(ExceptionHandler.coroutine()) {
|
||||
lifecycleScope.launchCatching {
|
||||
val user = userRepository.retrieveUser(false, true)
|
||||
binding?.refreshLayout?.isRefreshing = false
|
||||
if (user?.hasParty == true) {
|
||||
lifecycleScope.launch(ExceptionHandler.coroutine()) {
|
||||
val group = socialRepository.retrieveGroup("party")
|
||||
socialRepository.retrievePartyMembers(group?.id ?: "", true)
|
||||
}
|
||||
val group = socialRepository.retrieveGroup("party")
|
||||
socialRepository.retrievePartyMembers(group?.id ?: "", true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,11 @@
|
|||
package com.habitrpg.shared.habitica
|
||||
|
||||
import android.os.Parcel
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
actual typealias HParcel = Parcel
|
||||
actual typealias HClassLoader = ClassLoader
|
||||
|
||||
actual fun <T : Any> getClassLoader(obj: KClass<T>?): HClassLoader? {
|
||||
return obj?.java?.classLoader
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,7 @@
|
|||
package com.habitrpg.shared.habitica
|
||||
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
actual fun <T : Any> getClassLoader(obj: KClass<T>?): HClassLoader? {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
package com.habitrpg.shared.habitica
|
||||
|
||||
import com.habitrpg.shared.habitica.models.responses.TaskDirectionDataDrop
|
||||
import com.habitrpg.shared.habitica.models.responses.TaskScoringResult
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
expect class Platform() {
|
||||
val platform: String
|
||||
|
|
@ -10,6 +12,10 @@ expect class Platform() {
|
|||
expect interface HParcelable {
|
||||
fun writeToParcel(dest: HParcel, flags: Int)
|
||||
fun describeContents(): Int
|
||||
interface Creator<T> {
|
||||
fun createFromParcel(source: HParcel): T
|
||||
fun newArray(size: Int): Array<T?>
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("EXPECT_ACTUAL_CLASSIFIERS_ARE_IN_BETA_WARNING")
|
||||
|
|
@ -19,6 +25,8 @@ expect interface HParcelable {
|
|||
@Retention(AnnotationRetention.BINARY)
|
||||
expect annotation class HParcelize()
|
||||
|
||||
expect abstract class HClassLoader
|
||||
|
||||
expect class HParcel {
|
||||
fun writeByte(byte: Byte)
|
||||
fun writeParcelable(drop: HParcelable?, flags: Int)
|
||||
|
|
@ -26,4 +34,12 @@ expect class HParcel {
|
|||
fun writeInt(level: Int)
|
||||
fun writeValue(questDamage: Any?)
|
||||
fun writeString(it: String?)
|
||||
fun readByte(): Byte
|
||||
fun <T: HParcelable> readParcelable(creator: HClassLoader?): T?
|
||||
fun readDouble(): Double
|
||||
fun readInt(): Int
|
||||
fun readValue(classLoader: HClassLoader?): Any?
|
||||
fun readString(): String?
|
||||
}
|
||||
|
||||
expect fun <T : Any> getClassLoader(obj: KClass<T>?): HClassLoader?
|
||||
|
|
|
|||
|
|
@ -31,4 +31,19 @@ data class TaskDirectionDataDrop(
|
|||
override fun describeContents(): Int {
|
||||
return 0
|
||||
}
|
||||
|
||||
companion object CREATOR : HParcelable.Creator<TaskDirectionDataDrop> {
|
||||
override fun createFromParcel(source: HParcel): TaskDirectionDataDrop {
|
||||
return TaskDirectionDataDrop(
|
||||
value = source.readInt(),
|
||||
key = source.readString(),
|
||||
type = source.readString(),
|
||||
dialog = source.readString()
|
||||
)
|
||||
}
|
||||
|
||||
override fun newArray(size: Int): Array<TaskDirectionDataDrop?> {
|
||||
return arrayOfNulls(size)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,9 @@ package com.habitrpg.shared.habitica.models.responses
|
|||
import com.habitrpg.shared.habitica.HParcel
|
||||
import com.habitrpg.shared.habitica.HParcelable
|
||||
import com.habitrpg.shared.habitica.HParcelize
|
||||
import com.habitrpg.shared.habitica.getClassLoader
|
||||
import com.habitrpg.shared.habitica.models.AvatarStats
|
||||
import kotlin.jvm.JvmField
|
||||
|
||||
data class TaskScoringResult(
|
||||
var hasDied: Boolean = false,
|
||||
|
|
@ -34,6 +36,19 @@ data class TaskScoringResult(
|
|||
data._tmp?.quest?.collection,
|
||||
)
|
||||
|
||||
constructor(source: HParcel) : this(
|
||||
hasDied = source.readByte() != 0.toByte(),
|
||||
drop = source.readParcelable(getClassLoader(TaskDirectionDataDrop.CREATOR::class)),
|
||||
experienceDelta = source.readDouble(),
|
||||
healthDelta = source.readDouble(),
|
||||
goldDelta = source.readDouble(),
|
||||
manaDelta = source.readDouble(),
|
||||
hasLeveledUp = source.readByte() != 0.toByte(),
|
||||
level = source.readInt(),
|
||||
questDamage = source.readValue(getClassLoader(Double::class)) as? Double,
|
||||
questItemsFound = source.readValue(getClassLoader(Int::class)) as? Int,
|
||||
)
|
||||
|
||||
override fun writeToParcel(dest: HParcel, flags: Int) {
|
||||
dest.writeByte(if (hasDied) 1.toByte() else 0.toByte())
|
||||
dest.writeParcelable(drop, flags)
|
||||
|
|
@ -50,4 +65,17 @@ data class TaskScoringResult(
|
|||
override fun describeContents(): Int {
|
||||
return 0
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmField
|
||||
final val CREATOR: HParcelable.Creator<TaskScoringResult> = object : HParcelable.Creator<TaskScoringResult> {
|
||||
override fun createFromParcel(source: HParcel): TaskScoringResult {
|
||||
return TaskScoringResult(source)
|
||||
}
|
||||
|
||||
override fun newArray(size: Int): Array<TaskScoringResult?> {
|
||||
return arrayOfNulls(size)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,47 @@
|
|||
package com.habitrpg.shared.habitica
|
||||
|
||||
actual class HParcel
|
||||
actual class HParcel {
|
||||
actual fun writeByte(byte: Byte) {
|
||||
}
|
||||
|
||||
actual fun writeParcelable(drop: HParcelable?, flags: Int) {
|
||||
}
|
||||
|
||||
actual fun writeDouble(experienceDelta: Double) {
|
||||
}
|
||||
|
||||
actual fun writeInt(level: Int) {
|
||||
}
|
||||
|
||||
actual fun writeValue(questDamage: Any?) {
|
||||
}
|
||||
|
||||
actual fun writeString(it: String?) {
|
||||
}
|
||||
|
||||
actual fun readByte(): Byte {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
actual fun <T : HParcelable> readParcelable(creator: HClassLoader?): T? {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
actual fun readDouble(): Double {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
actual fun readInt(): Int {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
actual fun readValue(classLoader: HClassLoader?): Any? {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
actual fun readString(): String? {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
}
|
||||
|
||||
actual abstract class HClassLoader
|
||||
|
|
|
|||
|
|
@ -1,9 +1,68 @@
|
|||
package com.habitrpg.shared.habitica
|
||||
|
||||
import com.habitrpg.shared.habitica.models.responses.TaskScoringResult
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
actual class Platform actual constructor() {
|
||||
actual val platform: String
|
||||
get() = "JS!"
|
||||
}
|
||||
|
||||
actual interface HParcelable
|
||||
actual class HParcel
|
||||
actual interface HParcelable {
|
||||
actual fun writeToParcel(dest: HParcel, flags: Int)
|
||||
actual fun describeContents(): Int
|
||||
actual interface Creator<T> {
|
||||
actual fun createFromParcel(source: HParcel): T
|
||||
actual fun newArray(size: Int): Array<TaskScoringResult?>
|
||||
}
|
||||
}
|
||||
|
||||
actual class HParcel {
|
||||
actual fun writeByte(byte: Byte) {
|
||||
}
|
||||
|
||||
actual fun writeParcelable(drop: HParcelable?, flags: Int) {
|
||||
}
|
||||
|
||||
actual fun writeDouble(experienceDelta: Double) {
|
||||
}
|
||||
|
||||
actual fun writeInt(level: Int) {
|
||||
}
|
||||
|
||||
actual fun writeValue(questDamage: Any?) {
|
||||
}
|
||||
|
||||
actual fun writeString(it: String?) {
|
||||
}
|
||||
|
||||
actual fun readByte(): Byte {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
actual fun <T : HParcelable> readParcelable(creator: HClassLoader?): T? {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
actual fun readDouble(): Double {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
actual fun readInt(): Int {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
actual fun readValue(classLoader: HClassLoader?): Any? {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
actual fun readString(): String? {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
}
|
||||
|
||||
actual abstract class HClassLoader
|
||||
|
||||
actual fun <T : Any> getClassLoader(obj: KClass<T>?): HClassLoader? {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue