-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
136 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
model/src/androidMain/aidl/dev/datlag/mimasu/core/update/IUpdateCheckCallback.aidl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package dev.datlag.mimasu.core.update; | ||
|
||
import dev.datlag.mimasu.core.update.IUpdateInfo; | ||
|
||
interface IUpdateCheckCallback { | ||
void onUpdateInfo(in IUpdateInfo updateInfo); | ||
} |
11 changes: 11 additions & 0 deletions
11
model/src/androidMain/aidl/dev/datlag/mimasu/core/update/IUpdateInfo.aidl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package dev.datlag.mimasu.core.update; | ||
|
||
interface IUpdateInfo { | ||
boolean available(); | ||
|
||
boolean required(); | ||
|
||
@nullable String playstore(); | ||
|
||
@nullable String directDownload(); | ||
} |
8 changes: 8 additions & 0 deletions
8
model/src/androidMain/aidl/dev/datlag/mimasu/core/update/IUpdateService.aidl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// IUpdateService.aidl | ||
package dev.datlag.mimasu.core.update; | ||
|
||
import dev.datlag.mimasu.core.update.IUpdateCheckCallback; | ||
|
||
interface IUpdateService { | ||
void hasUpdate(in IUpdateCheckCallback callback); | ||
} |
8 changes: 8 additions & 0 deletions
8
model/src/androidMain/kotlin/dev/datlag/burningseries/model/common/ExtendAny.android.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package dev.datlag.burningseries.model.common | ||
|
||
import kotlin.reflect.KClass | ||
|
||
actual val KClass<*>.name: String | ||
get() = this.qualifiedName?.ifBlank { null } | ||
?: this.simpleName?.ifBlank { null } | ||
?: this.java.canonicalName?.ifBlank { null } ?: this.java.name.ifBlank { null } ?: this.toString() |
55 changes: 55 additions & 0 deletions
55
model/src/androidMain/kotlin/dev/datlag/burningseries/model/common/MimasuUpdateService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package dev.datlag.burningseries.model.common | ||
|
||
import android.content.Intent | ||
import android.os.IBinder | ||
import androidx.lifecycle.LifecycleService | ||
import androidx.lifecycle.lifecycleScope | ||
import dev.datlag.mimasu.core.update.IUpdateCheckCallback | ||
import dev.datlag.mimasu.core.update.IUpdateInfo | ||
import dev.datlag.mimasu.core.update.IUpdateService | ||
import kotlinx.coroutines.CoroutineScope | ||
|
||
class MimasuUpdateService : LifecycleService() { | ||
|
||
override fun onBind(intent: Intent): IBinder { | ||
super.onBind(intent) | ||
|
||
return Binder(lifecycleScope) | ||
} | ||
|
||
data class UpdateInfo( | ||
val available: Boolean, | ||
val required: Boolean, | ||
val playStore: String? = null, | ||
val directDownload: String? = null | ||
) : IUpdateInfo.Stub() { | ||
override fun available(): Boolean { | ||
return available | ||
} | ||
|
||
override fun required(): Boolean { | ||
return required | ||
} | ||
|
||
override fun playstore(): String? { | ||
return playStore | ||
} | ||
|
||
override fun directDownload(): String? { | ||
return directDownload | ||
} | ||
} | ||
|
||
class Binder( | ||
val scope: CoroutineScope | ||
) : IUpdateService.Stub() { | ||
override fun hasUpdate(callback: IUpdateCheckCallback?) { | ||
callback?.onUpdateInfo( | ||
UpdateInfo( | ||
available = true, | ||
required = true | ||
) | ||
) | ||
} | ||
} | ||
} |