wip: Migrate to Trixnity
This commit is contained in:
@@ -16,22 +16,6 @@ import ru.risdeveau.pixeldragon.util.getRoomStore
|
||||
import splitties.experimental.ExperimentalSplittiesApi
|
||||
import splitties.init.appCtx
|
||||
|
||||
//data class Me (val userId: String, val deviceId: String)
|
||||
//data class UserProfile (val displayName: String, val avatarUrl: String, val other: JSONObject)
|
||||
//
|
||||
///**
|
||||
// * This func is to validate the token
|
||||
// */
|
||||
//suspend fun getMe(): Me? {
|
||||
// val r = webClient.get("$baseUrl/account/whoami") { bearerAuth(token) }
|
||||
// if (r.status != HttpStatusCode.OK) {
|
||||
// Log.e("getMe", r.bodyAsText())
|
||||
// return null
|
||||
// }
|
||||
//
|
||||
// val json = JSONObject(r.bodyAsText())
|
||||
// return Me(json.getString("user_id"), json.getString("device_id"))
|
||||
//}
|
||||
|
||||
@OptIn(ExperimentalSplittiesApi::class)
|
||||
suspend fun login(server: String, login: String, pass: String): Boolean {
|
||||
@@ -55,19 +39,4 @@ suspend fun login(server: String, login: String, pass: String): Boolean {
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
//suspend fun getAccountData(user: String, state: String): JSONObject? {
|
||||
// val r = webClient.get("$baseUrl/user/$user/account_data/$state") { bearerAuth(token) }
|
||||
// if (r.status != HttpStatusCode.OK) return null
|
||||
// return JSONObject(r.bodyAsText())
|
||||
//}
|
||||
//
|
||||
//suspend fun getUserProfile(userId: String): UserProfile? {
|
||||
// val r = webClient.get("$baseUrl/profile/$userId") { bearerAuth(token) }
|
||||
// if (r.status != HttpStatusCode.OK) return null
|
||||
// val json = JSONObject(r.bodyAsText())
|
||||
// val name = json.optString("displayname", ""); json.remove("displayname")
|
||||
// val avatar = json.optString("avatar_url", ""); json.remove("avatar_url")
|
||||
// return UserProfile(name, avatar, json)
|
||||
//}
|
||||
}
|
||||
@@ -12,12 +12,12 @@ import androidx.activity.compose.setContent
|
||||
import androidx.activity.enableEdgeToEdge
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material3.CenterAlignedTopAppBar
|
||||
import androidx.compose.material3.CircularProgressIndicator
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TopAppBar
|
||||
import androidx.compose.material3.TopAppBarDefaults.topAppBarColors
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
@@ -35,6 +35,8 @@ import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import net.folivo.trixnity.client.MatrixClient
|
||||
import net.folivo.trixnity.client.fromStore
|
||||
import net.folivo.trixnity.clientserverapi.client.SyncState
|
||||
import ru.risdeveau.pixeldragon.R
|
||||
import ru.risdeveau.pixeldragon.client
|
||||
import ru.risdeveau.pixeldragon.ui.layout.RoomList
|
||||
import ru.risdeveau.pixeldragon.ui.theme.PixelDragonTheme
|
||||
@@ -42,6 +44,7 @@ import ru.risdeveau.pixeldragon.util.getMediaStore
|
||||
import ru.risdeveau.pixeldragon.util.getRoomStore
|
||||
import splitties.activities.start
|
||||
import splitties.init.appCtx
|
||||
import splitties.resources.str
|
||||
|
||||
|
||||
class MainActivity : ComponentActivity() {
|
||||
@@ -49,11 +52,11 @@ class MainActivity : ComponentActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
|
||||
enableEdgeToEdge()
|
||||
setContent {
|
||||
PixelDragonTheme {
|
||||
var isClientReady by remember { mutableStateOf(false) }
|
||||
val syncState by remember { mutableStateOf(SyncState.STOPPED) }
|
||||
|
||||
if (!isClientReady) {
|
||||
CircularProgressIndicator()
|
||||
@@ -61,13 +64,20 @@ class MainActivity : ComponentActivity() {
|
||||
Scaffold(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
topBar = {
|
||||
TopAppBar(
|
||||
CenterAlignedTopAppBar(
|
||||
colors = topAppBarColors(
|
||||
containerColor = MaterialTheme.colorScheme.primaryContainer,
|
||||
titleContentColor = MaterialTheme.colorScheme.primary,
|
||||
),
|
||||
title = {
|
||||
Text("Top app bar")
|
||||
when (syncState) {
|
||||
SyncState.STARTED -> Text("Syncing...")
|
||||
SyncState.INITIAL_SYNC -> Text("Initial sync...")
|
||||
SyncState.STOPPED,
|
||||
SyncState.RUNNING -> Text(str(R.string.app_name))
|
||||
SyncState.TIMEOUT -> Text("No network connection")
|
||||
SyncState.ERROR -> Text("Error syncing")
|
||||
}
|
||||
}
|
||||
)
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user