There were 2 issues combined into one: (#3643)

1. The languages were shown with the characters of the given language (i.e. Mandarin was displayed with Chinese characters).
2. The languages were not sorted
How I fixed them:
1. I changed the list that was called from AppLanguageLookUpTable from localized to cannonical.
2. I imported List and Collections and I sorted said list in lexicographical order.
This commit is contained in:
Raj Bapat 2020-04-26 00:23:00 -07:00 committed by GitHub
parent 1fea1bbf49
commit 95372f33b5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -16,6 +16,10 @@ import android.widget.LinearLayout;
import android.widget.Spinner;
import android.widget.TextView;
import androidx.annotation.NonNull;
import java.lang.ref.SoftReference;
import java.util.Collections;
import java.util.List;
import org.wikipedia.util.StringUtil;
import butterknife.BindView;
@ -136,14 +140,15 @@ public class AboutActivity extends NavigationBaseActivity {
@OnClick(R.id.about_translate)
public void launchTranslate(View view) {
@NonNull List<String> sortedLocalizedNamesRef = CommonsApplication.getInstance().getLanguageLookUpTable().getCanonicalNames();
Collections.sort(sortedLocalizedNamesRef);
final ArrayAdapter<String> languageAdapter = new ArrayAdapter<>(AboutActivity.this,
android.R.layout.simple_spinner_dropdown_item, CommonsApplication.getInstance().getLanguageLookUpTable().getLocalizedNames());
android.R.layout.simple_spinner_dropdown_item, sortedLocalizedNamesRef);
final Spinner spinner = new Spinner(AboutActivity.this);
spinner.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT));
spinner.setAdapter(languageAdapter);
spinner.setGravity(17);
spinner.setPadding(50,0,0,0);
AlertDialog.Builder builder = new AlertDialog.Builder(AboutActivity.this);
builder.setView(spinner);
builder.setTitle(R.string.about_translate_title)