Commit b954708e authored by Thomas's avatar Thomas
Browse files

Fix issue #1238 - Improve language picker when filtered with some languages

parent 0fcd1c6d
Loading
Loading
Loading
Loading
+29 −17
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.Manifest;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
@@ -1915,7 +1916,6 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
                        i++;
                    }
                } else {

                    List<Languages.Language> languages = Languages.get(context);
                    if (languages != null) {
                        codesArr = new String[languages.size()];
@@ -1936,8 +1936,9 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
                AlertDialog.Builder builder = new MaterialAlertDialogBuilder(context);
                builder.setTitle(context.getString(R.string.message_language));

                builder.setSingleChoiceItems(languagesArr, selection, null);
                String[] finalCodesArr = codesArr;
                if (storedLanguages == null || storedLanguages.isEmpty()) {
                    builder.setSingleChoiceItems(languagesArr, selection, null);
                    builder.setPositiveButton(R.string.validate, (dialog, which) -> {
                        int selectedPosition = ((AlertDialog) dialog).getListView().getCheckedItemPosition();
                        editor.putString(context.getString(R.string.SET_COMPOSE_LANGUAGE) + account.user_id + account.instance, finalCodesArr[selectedPosition]);
@@ -1953,6 +1954,16 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
                        notifyItemChanged(holder.getLayoutPosition());
                        dialog.dismiss();
                    });
                } else {
                    builder.setSingleChoiceItems(languagesArr, selection, (dialog, which) -> {
                        int selectedPosition = ((AlertDialog) dialog).getListView().getCheckedItemPosition();
                        editor.putString(context.getString(R.string.SET_COMPOSE_LANGUAGE) + account.user_id + account.instance, finalCodesArr[selectedPosition]);
                        editor.apply();
                        statusDraft.language = finalCodesArr[selectedPosition];
                        notifyItemChanged(holder.getLayoutPosition());
                        dialog.dismiss();
                    });
                }
                builder.create().show();
            });
        }
@@ -1988,6 +1999,7 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
        composePollBinding.option1.textLayout.setHint(context.getString(R.string.poll_choice_s, 1));
        composePollBinding.option2.text.setFilters(fArray);
        composePollBinding.option2.textLayout.setHint(context.getString(R.string.poll_choice_s, 2));
        composePollBinding.option2.textLayout.setHint(context.getString(R.string.poll_choice_s, 2));
        composePollBinding.option1.buttonRemove.setVisibility(View.GONE);
        composePollBinding.option2.buttonRemove.setVisibility(View.GONE);
        int finalMax_entry = max_entry;