diff --git a/app/src/main/java/eu/faircode/email/AdapterMessage.java b/app/src/main/java/eu/faircode/email/AdapterMessage.java index 82a3041e8f..e1cb33cbe3 100644 --- a/app/src/main/java/eu/faircode/email/AdapterMessage.java +++ b/app/src/main/java/eu/faircode/email/AdapterMessage.java @@ -39,6 +39,7 @@ import android.content.Intent; import android.content.SharedPreferences; import android.content.pm.PackageManager; import android.content.res.ColorStateList; +import android.content.res.Resources; import android.database.Cursor; import android.graphics.Color; import android.graphics.Paint; @@ -6669,7 +6670,39 @@ public class AdapterMessage extends RecyclerView.Adapter languages = DeepL.getTargetLanguages(context); - ArrayAdapter adapter = new ArrayAdapter<>(context, android.R.layout.simple_spinner_item, android.R.id.text1, languages); + ArrayAdapter adapter = new ArrayAdapter(context, android.R.layout.simple_spinner_item, android.R.id.text1, languages) { + @NonNull + @Override + public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) { + return _getView(position, super.getView(position, convertView, parent)); + } + + @Override + public View getDropDownView(int position, @Nullable View convertView, @NonNull ViewGroup parent) { + return _getView(position, super.getDropDownView(position, convertView, parent)); + } + + private View _getView(int position, View view) { + DeepL.Language language = getItem(position); + if (language != null) { + TextView tv = view.findViewById(android.R.id.text1); + + Resources res = context.getResources(); + Drawable icon = res.getDrawable(language.icon); + int iconSize = res.getDimensionPixelSize(R.dimen.menu_item_icon_size); + icon.setBounds(0, 0, iconSize, iconSize); + ImageSpan imageSpan = new CenteredImageSpan(icon); + + SpannableStringBuilder ssb = new SpannableStringBuilder(language.name); + ssb.insert(0, "\uFFFC\u2002"); // object replacement character, en space + ssb.setSpan(imageSpan, 0, 1, 0); + + tv.setText(ssb); + } + + return view; + } + }; adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spLanguage.setAdapter(adapter); diff --git a/app/src/main/java/eu/faircode/email/DeepL.java b/app/src/main/java/eu/faircode/email/DeepL.java index 3a45e27518..ca003531be 100644 --- a/app/src/main/java/eu/faircode/email/DeepL.java +++ b/app/src/main/java/eu/faircode/email/DeepL.java @@ -121,7 +121,7 @@ public class DeepL { int freq1 = frequencies.get(l1.target); int freq2 = frequencies.get(l2.target); - if (freq1 == freq2) + if (freq1 == freq2 || !BuildConfig.DEBUG) return collator.compare(l1.name, l2.name); else return -Integer.compare(freq1, freq2); diff --git a/app/src/main/res/layout/dialog_translate.xml b/app/src/main/res/layout/dialog_translate.xml index 92e16ebf0c..dae779c963 100644 --- a/app/src/main/res/layout/dialog_translate.xml +++ b/app/src/main/res/layout/dialog_translate.xml @@ -16,7 +16,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:labelFor="@+id/etKeyword" - android:text="@string/title_translate" + android:text="@string/title_translate_tap" android:textAppearance="@style/TextAppearance.AppCompat.Large" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> @@ -30,19 +30,6 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/tvTitle" /> - - + app:layout_constraintTop_toBottomOf="@id/spLanguage" />