- Deletion works and clear the corresponding keystore entries. - No more sync issues with the listing when creating/updating/deleting.main
parent
f9c341c35a
commit
11bea0e585
@ -1,41 +0,0 @@
|
||||
package dev.lowrespalmtree.comet
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.fragment.app.viewModels
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import androidx.preference.EditTextPreference
|
||||
import androidx.preference.PreferenceFragmentCompat
|
||||
import dev.lowrespalmtree.comet.Identities.Identity
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlin.coroutines.coroutineContext
|
||||
|
||||
class IdentityEditorFragment : PreferenceFragmentCompat() {
|
||||
private val vm: IdentityEditorViewModel by viewModels()
|
||||
private lateinit var namePref: EditTextPreference
|
||||
|
||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||
setPreferencesFromResource(R.xml.identity_preferences, rootKey)
|
||||
namePref = findPreference<EditTextPreference>("name")!!
|
||||
|
||||
// vm.identity.observe(viewLifecycleOwner) {
|
||||
// namePref.apply {
|
||||
// // TODO
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// arguments?.getLong("id")?.also { vm.loadIdentity(it) }
|
||||
}
|
||||
|
||||
class IdentityEditorViewModel : ViewModel() {
|
||||
val identity: MutableLiveData<Identity> by lazy { MutableLiveData<Identity>() }
|
||||
|
||||
fun loadIdentity(id: Long) {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
identity.postValue(Identities.get(id))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16sp" />
|
||||
|
||||
</LinearLayout>
|
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:id="@+id/item_edit" android:title="@string/edit" />
|
||||
<item android:id="@+id/item_delete" android:title="@string/delete" />
|
||||
</menu>
|
Loading…
Reference in new issue