[merge] Merge branch 'dev-fun1'
This commit is contained in:
@@ -23,7 +23,7 @@ _🚀This is the client of the multimedia server Abyss, which can also be extend
|
|||||||
|
|
||||||
### High Priority
|
### High Priority
|
||||||
- [x] Fix tablet full-screen mode bug
|
- [x] Fix tablet full-screen mode bug
|
||||||
- [ ] Hide private key after user input
|
- [x] Hide private key after user input
|
||||||
- [ ] Replace Android robot icon with custom design
|
- [ ] Replace Android robot icon with custom design
|
||||||
- [ ] Configure server baseURL in client settings
|
- [ ] Configure server baseURL in client settings
|
||||||
- [ ] Implement proper access control for directory queries
|
- [ ] Implement proper access control for directory queries
|
||||||
|
|||||||
@@ -94,8 +94,7 @@ fun MeScreen(meScreenViewModel: MeScreenViewModel = viewModel())
|
|||||||
// Save Button
|
// Save Button
|
||||||
Button(
|
Button(
|
||||||
onClick = {
|
onClick = {
|
||||||
meScreenViewModel.updateAccount(username, privateKey);
|
meScreenViewModel.updateAccount(username, privateKey, context)
|
||||||
Toast.makeText(context, "Account updated", Toast.LENGTH_SHORT).show()
|
|
||||||
},
|
},
|
||||||
modifier = Modifier.fillMaxWidth()
|
modifier = Modifier.fillMaxWidth()
|
||||||
) {
|
) {
|
||||||
|
|||||||
@@ -70,11 +70,11 @@ class HomeScreenViewModel(application: Application) : AndroidViewModel(applicati
|
|||||||
u,
|
u,
|
||||||
p
|
p
|
||||||
)!!
|
)!!
|
||||||
|
|
||||||
|
Global.loggedIn = true
|
||||||
}catch(e: Exception)
|
}catch(e: Exception)
|
||||||
{
|
{
|
||||||
print(e.message)
|
print(e.message)
|
||||||
}finally {
|
|
||||||
Global.loggedIn = true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.acitelight.aether.viewModel
|
package com.acitelight.aether.viewModel
|
||||||
|
|
||||||
import android.app.Application
|
import android.app.Application
|
||||||
|
import android.content.Context
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
@@ -8,16 +9,19 @@ import androidx.datastore.preferences.core.edit
|
|||||||
import androidx.datastore.preferences.core.stringPreferencesKey
|
import androidx.datastore.preferences.core.stringPreferencesKey
|
||||||
import androidx.lifecycle.AndroidViewModel
|
import androidx.lifecycle.AndroidViewModel
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
|
import com.acitelight.aether.Global
|
||||||
import com.acitelight.aether.dataStore
|
import com.acitelight.aether.dataStore
|
||||||
import com.acitelight.aether.model.Video
|
import com.acitelight.aether.model.Video
|
||||||
|
import com.acitelight.aether.service.ApiClient
|
||||||
|
import com.acitelight.aether.service.AuthManager
|
||||||
|
import com.acitelight.aether.service.MediaManager
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
import kotlinx.coroutines.flow.first
|
import kotlinx.coroutines.flow.first
|
||||||
import kotlinx.coroutines.flow.map
|
import kotlinx.coroutines.flow.map
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
class MeScreenViewModel(application: Application) : AndroidViewModel(application)
|
class MeScreenViewModel(application: Application) : AndroidViewModel(application) {
|
||||||
{
|
|
||||||
private val dataStore = application.dataStore
|
private val dataStore = application.dataStore
|
||||||
private val USER_NAME_KEY = stringPreferencesKey("user_name")
|
private val USER_NAME_KEY = stringPreferencesKey("user_name")
|
||||||
private val PRIVATE_KEY = stringPreferencesKey("private_key")
|
private val PRIVATE_KEY = stringPreferencesKey("private_key")
|
||||||
@@ -36,17 +40,39 @@ class MeScreenViewModel(application: Application) : AndroidViewModel(application
|
|||||||
init {
|
init {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
username.value = userNameFlow.first()
|
username.value = userNameFlow.first()
|
||||||
privateKey.value = privateKeyFlow.first()
|
privateKey.value = if (privateKeyFlow.first() == "") "" else "******"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updateAccount(u: String, p: String)
|
fun updateAccount(u: String, p: String, context: Context) {
|
||||||
{
|
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
dataStore.edit { preferences ->
|
dataStore.edit { preferences ->
|
||||||
preferences[USER_NAME_KEY] = u
|
preferences[USER_NAME_KEY] = u
|
||||||
preferences[PRIVATE_KEY] = p
|
preferences[PRIVATE_KEY] = p
|
||||||
}
|
}
|
||||||
|
|
||||||
|
privateKey.value = "******"
|
||||||
|
|
||||||
|
Global.loggedIn = false
|
||||||
|
|
||||||
|
val u = userNameFlow.first()
|
||||||
|
val p = privateKeyFlow.first()
|
||||||
|
|
||||||
|
if (u == "" || p == "") return@launch
|
||||||
|
|
||||||
|
try {
|
||||||
|
MediaManager.token = AuthManager.fetchToken(
|
||||||
|
ApiClient.base,
|
||||||
|
u,
|
||||||
|
p
|
||||||
|
)!!
|
||||||
|
|
||||||
|
Global.loggedIn = true
|
||||||
|
Toast.makeText(context, "Account Updated", Toast.LENGTH_SHORT).show()
|
||||||
|
} catch (e: Exception) {
|
||||||
|
print(e.message)
|
||||||
|
Toast.makeText(context, "Invalid Account Information", Toast.LENGTH_SHORT).show()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user