styles: fix some issues and rename things around

This commit is contained in:
dece 2022-02-04 19:08:08 +01:00
parent 02ba3a1401
commit b6d855fdeb
8 changed files with 16 additions and 14 deletions

View file

@ -35,7 +35,7 @@ class IdentitiesAdapter(private val listener: Listener) :
listener.onIdentityClick(item) listener.onIdentityClick(item)
} }
holder.binding.container.setOnLongClickListener { holder.binding.container.setOnLongClickListener {
listener.onIdentityLongClick(item, holder.itemView); listener.onIdentityLongClick(item, holder.itemView)
true true
} }
} }

View file

@ -20,7 +20,7 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import java.util.* import java.util.*
class IdentitiesFragment : Fragment(), IdentitiesAdapter.Listener, IdentityDialog.Listener { class IdentitiesFragment : Fragment(), IdentitiesAdapter.Listener, IdentityEditDialog.Listener {
private val vm: IdentitiesViewModel by viewModels() private val vm: IdentitiesViewModel by viewModels()
private lateinit var binding: FragmentIdentitiesBinding private lateinit var binding: FragmentIdentitiesBinding
private lateinit var adapter: IdentitiesAdapter private lateinit var adapter: IdentitiesAdapter
@ -41,7 +41,7 @@ class IdentitiesFragment : Fragment(), IdentitiesAdapter.Listener, IdentityDialo
adapter = IdentitiesAdapter(this) adapter = IdentitiesAdapter(this)
binding.list.adapter = adapter binding.list.adapter = adapter
binding.floatingActionButton.setOnClickListener { openNewIdentityEditor() } binding.floatingActionButton.setOnClickListener { openIdentityWizard() }
vm.identities.observe(viewLifecycleOwner) { adapter.setIdentities(it) } vm.identities.observe(viewLifecycleOwner) { adapter.setIdentities(it) }
@ -49,7 +49,7 @@ class IdentitiesFragment : Fragment(), IdentitiesAdapter.Listener, IdentityDialo
} }
override fun onIdentityClick(identity: Identity) { override fun onIdentityClick(identity: Identity) {
IdentityDialog(requireContext(), identity, this).show() IdentityEditDialog(requireContext(), identity, this).show()
} }
override fun onIdentityLongClick(identity: Identity, view: View) { override fun onIdentityLongClick(identity: Identity, view: View) {
@ -59,7 +59,7 @@ class IdentitiesFragment : Fragment(), IdentitiesAdapter.Listener, IdentityDialo
setOnMenuItemClickListener { item -> setOnMenuItemClickListener { item ->
when (item.itemId) { when (item.itemId) {
R.id.item_edit -> { R.id.item_edit -> {
IdentityDialog( IdentityEditDialog(
requireContext(), requireContext(),
identity, identity,
this@IdentitiesFragment this@IdentitiesFragment

View file

@ -5,7 +5,7 @@ import android.content.Context
import android.view.LayoutInflater import android.view.LayoutInflater
import dev.lowrespalmtree.comet.databinding.DialogIdentityBinding import dev.lowrespalmtree.comet.databinding.DialogIdentityBinding
class IdentityDialog( class IdentityEditDialog(
private val context: Context, private val context: Context,
private val identity: Identities.Identity, private val identity: Identities.Identity,
private val listener: Listener private val listener: Listener

View file

@ -5,19 +5,15 @@ import android.content.ActivityNotFoundException
import android.content.Intent import android.content.Intent
import android.net.Uri import android.net.Uri
import android.os.Bundle import android.os.Bundle
import android.text.InputType
import android.util.Log import android.util.Log
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.view.inputmethod.EditorInfo import android.view.inputmethod.EditorInfo
import android.view.inputmethod.InputMethodManager import android.view.inputmethod.InputMethodManager
import android.widget.EditText
import android.widget.FrameLayout
import android.widget.TextView import android.widget.TextView
import androidx.activity.addCallback import androidx.activity.addCallback
import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AlertDialog
import androidx.core.view.setMargins
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.fragment.app.viewModels import androidx.fragment.app.viewModels
import androidx.preference.PreferenceManager import androidx.preference.PreferenceManager

View file

@ -28,6 +28,7 @@ fun confirm(context: Context, @StringRes prompt: Int, onOk: () -> Unit) {
.setTitle(R.string.confirm) .setTitle(R.string.confirm)
.setView(binding.root) .setView(binding.root)
.setPositiveButton(android.R.string.ok) { _, _ -> onOk() } .setPositiveButton(android.R.string.ok) { _, _ -> onOk() }
.setNegativeButton(android.R.string.cancel) { dialog, _ -> dialog.dismiss() }
.create() .create()
.show() .show()
} }

View file

@ -8,6 +8,6 @@
android:id="@+id/text_view" android:id="@+id/text_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="16sp" /> style="@style/CometText" />
</LinearLayout> </LinearLayout>

View file

@ -10,7 +10,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/identity_name" android:text="@string/identity_name"
android:textAppearance="@style/TextAppearance.AppCompat.Medium" /> style="@style/CometLabel" />
<EditText <EditText
android:id="@+id/labelInput" android:id="@+id/labelInput"
@ -28,7 +28,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/identity_usages" android:text="@string/identity_usages"
android:textAppearance="@style/TextAppearance.AppCompat.Medium" /> style="@style/CometLabel" />
<EditText <EditText
android:id="@+id/urlInput" android:id="@+id/urlInput"
@ -46,7 +46,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/identity_alias_title" android:text="@string/identity_alias_title"
android:textAppearance="@style/TextAppearance.AppCompat.Medium" /> style="@style/CometLabel" />
<TextView <TextView
android:id="@+id/aliasText" android:id="@+id/aliasText"

View file

@ -14,4 +14,9 @@
<item name="android:textIsSelectable">false</item> <item name="android:textIsSelectable">false</item>
<item name="android:background">?attr/selectableItemBackground</item> <item name="android:background">?attr/selectableItemBackground</item>
</style> </style>
<style name="CometLabel">
<item name="android:textSize">16sp</item>
<item name="android:textColor">@color/main_accent</item>
<item name="android:paddingTop">2dp</item>
</style>
</resources> </resources>