Alignment, only fill out dropdown if there is only one other server
This commit is contained in:
parent
5f15be4bca
commit
7ed8287abe
2 changed files with 14 additions and 16 deletions
|
@ -108,22 +108,21 @@ class AddFragment : DialogFragment() {
|
|||
|
||||
// Fill autocomplete for base URL
|
||||
lifecycleScope.launch(Dispatchers.IO) {
|
||||
// Sort existing base URLs by most frequently used
|
||||
val appBaseUrl = getString(R.string.app_base_url)
|
||||
baseUrls = repository.getSubscriptions()
|
||||
.groupBy { it.baseUrl }
|
||||
.mapValues { it.value.size }
|
||||
.toList()
|
||||
.sortedBy { (_, size) -> size }
|
||||
.reversed()
|
||||
.map { (baseUrl, _) -> baseUrl }
|
||||
.map { it.key }
|
||||
.filterNot { it == appBaseUrl }
|
||||
.sorted()
|
||||
val adapter = ArrayAdapter(requireActivity(), R.layout.fragment_add_dialog_dropdown_item, baseUrls)
|
||||
requireActivity().runOnUiThread {
|
||||
baseUrlText.threshold = 1
|
||||
baseUrlText.setAdapter(adapter)
|
||||
if (baseUrls.isNotEmpty()) {
|
||||
if (baseUrls.count() == 1) {
|
||||
baseUrlLayout.setEndIconDrawable(R.drawable.ic_cancel_gray_24dp)
|
||||
baseUrlText.setText(baseUrls.first())
|
||||
} else {
|
||||
baseUrlLayout.setEndIconDrawable(R.drawable.ic_drop_down_gray_24dp)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
style="@style/Widget.MaterialComponents.TextInputLayout.FilledBox.Dense.ExposedDropdownMenu"
|
||||
android:id="@+id/add_dialog_base_url_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="40dp"
|
||||
android:layout_margin="0dp"
|
||||
android:background="@android:color/transparent"
|
||||
android:padding="0dp"
|
||||
|
@ -56,17 +56,16 @@
|
|||
android:id="@+id/add_dialog_base_url_text"
|
||||
android:hint="@string/app_base_url"
|
||||
android:maxLines="1"
|
||||
android:layout_marginTop="-2dp"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:visibility="visible"
|
||||
android:layout_marginTop="0dp"
|
||||
android:layout_marginBottom="0dp"
|
||||
android:inputType="textNoSuggestions"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:paddingStart="2dp"
|
||||
android:paddingEnd="2dp"
|
||||
android:paddingTop="10dp"
|
||||
android:paddingStart="0dp"
|
||||
android:paddingEnd="0dp"
|
||||
android:paddingTop="0dp"
|
||||
android:paddingBottom="0dp"
|
||||
android:layout_marginStart="2dp"
|
||||
android:layout_marginEnd="2dp"/>
|
||||
android:layout_marginStart="4dp"
|
||||
android:layout_marginEnd="4dp"/>
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<LinearLayout
|
||||
|
|
Loading…
Reference in a new issue