This commit overwrites the version 1 database schema. Yeah as long as Comet is not out of alpha, I'm not dealing with this horrendous migration process.main
parent
020f48149b
commit
1f2be8cdee
@ -0,0 +1,38 @@
|
||||
package dev.lowrespalmtree.comet
|
||||
|
||||
import androidx.room.*
|
||||
|
||||
object Identities {
|
||||
@Entity
|
||||
data class Identity(
|
||||
/** ID. */
|
||||
@PrimaryKey(autoGenerate = true) val id: Int,
|
||||
/** Key to retrieve certificate from the keystore. */
|
||||
val key: String,
|
||||
/** Label for this identity. */
|
||||
val name: String?,
|
||||
)
|
||||
|
||||
@Entity
|
||||
data class IdentityUsage(
|
||||
/** ID. */
|
||||
@PrimaryKey(autoGenerate = true) val id: Int,
|
||||
/** URL path where an identity can be used. */
|
||||
val uri: String,
|
||||
/** ID of the Identity to use. */
|
||||
val identityId: Int
|
||||
)
|
||||
|
||||
@Dao
|
||||
interface IdentityDao {
|
||||
@Insert
|
||||
suspend fun insert(vararg entries: Identity)
|
||||
|
||||
@Query("SELECT * FROM IdentityUsage WHERE :identityId = identityId")
|
||||
fun getUsagesFor(identityId: Int): List<IdentityUsage>
|
||||
}
|
||||
|
||||
suspend fun insert(key: String, name: String? = null) {
|
||||
Database.INSTANCE.identityDao().insert(Identity(0, key, name))
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package dev.lowrespalmtree.comet
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.fragment.app.Fragment
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import dev.lowrespalmtree.comet.databinding.FragmentIdentitiesBinding
|
||||
|
||||
class IdentitiesFragment : Fragment() {
|
||||
private lateinit var binding: FragmentIdentitiesBinding
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
binding = FragmentIdentitiesBinding.inflate(layoutInflater)
|
||||
return binding.root
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package dev.lowrespalmtree.comet
|
||||
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import dev.lowrespalmtree.comet.databinding.FragmentIdentityBinding
|
||||
|
||||
class IdentityAdapter : RecyclerView.Adapter<HistoryItemAdapter.ViewHolder>() {
|
||||
private var identities = listOf<Unit>()
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): HistoryItemAdapter.ViewHolder {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: HistoryItemAdapter.ViewHolder, position: Int) {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
inner class ViewHolder(val binding: FragmentIdentityBinding) : RecyclerView.ViewHolder(binding.root)
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/list"
|
||||
android:name="dev.lowrespalmtree.comet.IdentitiesFragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:context=".IdentitiesFragment"
|
||||
tools:listitem="@layout/fragment_identity">
|
||||
|
||||
</androidx.recyclerview.widget.RecyclerView>
|
||||
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/floatingActionButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="@+id/list" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.cardview.widget.CardView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/card"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:layout_margin="4dp"
|
||||
app:cardCornerRadius="4dp"
|
||||
app:cardElevation="4dp"
|
||||
android:foreground="?android:selectableItemBackground">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</androidx.cardview.widget.CardView>
|
Loading…
Reference in new issue