diff --git a/app/src/main/java/org/thoughtcrime/securesms/CountrySelectionFragment.java b/app/src/main/java/org/thoughtcrime/securesms/CountrySelectionFragment.java deleted file mode 100644 index 13551128b7..0000000000 --- a/app/src/main/java/org/thoughtcrime/securesms/CountrySelectionFragment.java +++ /dev/null @@ -1,101 +0,0 @@ -package org.thoughtcrime.securesms; - -import android.app.Activity; -import android.os.Bundle; -import androidx.annotation.NonNull; -import androidx.fragment.app.ListFragment; -import androidx.loader.app.LoaderManager; -import androidx.loader.content.Loader; -import android.text.Editable; -import android.text.TextWatcher; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.EditText; -import android.widget.ListView; -import android.widget.SimpleAdapter; - - -import org.thoughtcrime.securesms.database.loaders.CountryListLoader; - -import java.util.ArrayList; -import java.util.Map; - -public class CountrySelectionFragment extends ListFragment implements LoaderManager.LoaderCallbacks>> { - - private EditText countryFilter; - private CountrySelectedListener listener; - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) { - return inflater.inflate(R.layout.country_selection_fragment, container, false); - } - - @Override - public void onActivityCreated(Bundle bundle) { - super.onActivityCreated(bundle); - this.countryFilter = (EditText)getView().findViewById(R.id.country_search); - this.countryFilter.addTextChangedListener(new FilterWatcher()); - getLoaderManager().initLoader(0, null, this).forceLoad(); - } - - @Override - public void onAttach(Activity activity) { - super.onAttach(activity); - this.listener = (CountrySelectedListener)activity; - } - - @Override - public void onListItemClick(ListView listView, View view, int position, long id) { - Map item = (Map)this.getListAdapter().getItem(position); - if (this.listener != null) { - this.listener.countrySelected(item.get("country_name"), - Integer.parseInt(item.get("country_code").substring(1))); - } - } - - @Override - public @NonNull Loader>> onCreateLoader(int arg0, Bundle arg1) { - return new CountryListLoader(getActivity()); - } - - @Override - public void onLoadFinished(@NonNull Loader>> loader, - ArrayList> results) - { - String[] from = {"country_name", "country_code"}; - int[] to = {R.id.country_name, R.id.country_code}; - this.setListAdapter(new SimpleAdapter(getActivity(), results, R.layout.country_list_item, from, to)); - - if (this.countryFilter != null && this.countryFilter.getText().length() != 0) { - ((SimpleAdapter)getListAdapter()).getFilter().filter(this.countryFilter.getText().toString()); - } - } - - @Override - public void onLoaderReset(@NonNull Loader>> arg0) { - this.setListAdapter(null); - } - - public interface CountrySelectedListener { - public void countrySelected(String countryName, int countryCode); - } - - private class FilterWatcher implements TextWatcher { - - @Override - public void afterTextChanged(Editable s) { - if (getListAdapter() != null) { - ((SimpleAdapter)getListAdapter()).getFilter().filter(s.toString()); - } - } - - @Override - public void beforeTextChanged(CharSequence s, int start, int count, int after) { - } - - @Override - public void onTextChanged(CharSequence s, int start, int before, int count) { - } - } -} diff --git a/app/src/main/java/org/thoughtcrime/securesms/registration/fragments/CountryPickerFragment.java b/app/src/main/java/org/thoughtcrime/securesms/registration/fragments/CountryPickerFragment.java index 6aca33be39..42bb5e7cb5 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/registration/fragments/CountryPickerFragment.java +++ b/app/src/main/java/org/thoughtcrime/securesms/registration/fragments/CountryPickerFragment.java @@ -9,6 +9,7 @@ import android.view.ViewGroup; import android.widget.EditText; import android.widget.ListView; import android.widget.SimpleAdapter; +import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -67,6 +68,8 @@ public final class CountryPickerFragment extends ListFragment implements LoaderM public void onLoadFinished(@NonNull Loader>> loader, @NonNull ArrayList> results) { + ((TextView) getListView().getEmptyView()).setText( + R.string.country_selection_fragment__no_matching_countries); String[] from = { "country_name", "country_code" }; int[] to = { R.id.country_name, R.id.country_code }; diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 843dbe3e46..0ca575c2ee 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1396,6 +1396,7 @@ Loading countries… Search + No matching countries Scan the QR code displayed on the device to link