Remove non-functional end icon of country selector

This commit is contained in:
ByteHamster 2022-12-11 16:18:49 +01:00
parent 4513711981
commit ac4409bcf4
2 changed files with 14 additions and 7 deletions

View File

@ -1,6 +1,5 @@
package de.danoeh.antennapod.fragment;
import android.app.AlertDialog;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
@ -21,11 +20,11 @@ import androidx.appcompat.widget.Toolbar;
import androidx.fragment.app.Fragment;
import com.google.android.material.appbar.MaterialToolbar;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.textfield.MaterialAutoCompleteTextView;
import com.google.android.material.textfield.TextInputLayout;
import de.danoeh.antennapod.core.BuildConfig;
import org.apache.commons.lang3.StringUtils;
import org.greenrobot.eventbus.EventBus;
import java.util.ArrayList;
@ -222,7 +221,7 @@ public class DiscoveryFragment extends Fragment implements Toolbar.OnMenuItemCli
LayoutInflater inflater = getLayoutInflater();
View selectCountryDialogView = inflater.inflate(R.layout.select_country_dialog, null);
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(getContext());
builder.setView(selectCountryDialogView);
List<String> countryCodeArray = new ArrayList<>(Arrays.asList(Locale.getISOCountries()));
@ -245,11 +244,16 @@ public class DiscoveryFragment extends Fragment implements Toolbar.OnMenuItemCli
editText.setAdapter(dataAdapter);
editText.setText(countryCodeNames.get(countryCode));
editText.setOnClickListener(view -> {
if (StringUtils.isEmpty(editText.getText().toString())) {
return;
if (editText.getText().length() != 0) {
editText.setText("");
editText.postDelayed(editText::showDropDown, 100);
}
});
editText.setOnFocusChangeListener((v, hasFocus) -> {
if (hasFocus) {
editText.setText("");
editText.postDelayed(editText::showDropDown, 100);
}
editText.getText().clear();
editText.postDelayed(editText::showDropDown, 100);
});
builder.setPositiveButton(android.R.string.ok, (dialogInterface, i) -> {
@ -267,6 +271,7 @@ public class DiscoveryFragment extends Fragment implements Toolbar.OnMenuItemCli
EventBus.getDefault().post(new DiscoveryDefaultUpdateEvent());
loadToplist(countryCode);
});
builder.setNegativeButton(R.string.cancel_label, null);
builder.show();
return true;
}

View File

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
@ -11,6 +12,7 @@
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:hint="@string/country"
app:endIconMode="none"
style="@style/Widget.MaterialComponents.TextInputLayout.FilledBox.ExposedDropdownMenu">
<AutoCompleteTextView