diff --git a/app/src/main/java/io/heckel/ntfy/ui/AddFragment.kt b/app/src/main/java/io/heckel/ntfy/ui/AddFragment.kt index baf4114..0472144 100644 --- a/app/src/main/java/io/heckel/ntfy/ui/AddFragment.kt +++ b/app/src/main/java/io/heckel/ntfy/ui/AddFragment.kt @@ -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) } } } diff --git a/app/src/main/res/layout/fragment_add_dialog.xml b/app/src/main/res/layout/fragment_add_dialog.xml index dcaa7a9..c3436d1 100644 --- a/app/src/main/res/layout/fragment_add_dialog.xml +++ b/app/src/main/res/layout/fragment_add_dialog.xml @@ -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"/>