|
1 | 1 | package fr.free.nrw.commons; |
2 | 2 |
|
3 | 3 | import android.annotation.SuppressLint; |
| 4 | +import android.app.AlertDialog; |
| 5 | +import android.content.DialogInterface; |
4 | 6 | import android.content.Intent; |
5 | 7 | import android.net.Uri; |
6 | 8 | import android.os.Bundle; |
|
10 | 12 | import android.support.customtabs.CustomTabsIntent; |
11 | 13 | import android.support.v4.content.ContextCompat; |
12 | 14 | import android.view.View; |
| 15 | +import android.widget.ArrayAdapter; |
| 16 | +import android.widget.LinearLayout; |
| 17 | +import android.widget.Spinner; |
13 | 18 | import android.widget.TextView; |
14 | 19 | import android.widget.Toast; |
15 | 20 |
|
@@ -102,6 +107,37 @@ public void launchPrivacyPolicy(View view) { |
102 | 107 | public void launchFrequentlyAskedQuesions(View view) { |
103 | 108 | Utils.handleWebUrl(this,Uri.parse("https://github.com/commons-app/apps-android-commons/wiki/Frequently-Asked-Questions\\")); |
104 | 109 | } |
105 | | - |
| 110 | + |
| 111 | + @OnClick(R.id.about_translate) |
| 112 | + public void launchTranslate(View view) { |
| 113 | + final ArrayAdapter<String> languageAdapter = new ArrayAdapter<String>(AboutActivity.this, |
| 114 | + android.R.layout.simple_spinner_item, language); |
| 115 | + final Spinner spinner = new Spinner(AboutActivity.this); |
| 116 | + spinner.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); |
| 117 | + spinner.setAdapter(languageAdapter); |
| 118 | + spinner.setGravity(17); |
| 119 | + |
| 120 | + AlertDialog.Builder builder = new AlertDialog.Builder(AboutActivity.this); |
| 121 | + builder.setView(spinner); |
| 122 | + builder.setTitle(R.string.about_translate_title) |
| 123 | + .setMessage(R.string.about_translate_message) |
| 124 | + .setPositiveButton(R.string.about_translate_proceed, new DialogInterface.OnClickListener() { |
| 125 | + @Override |
| 126 | + public void onClick(DialogInterface dialog, int which) { |
| 127 | + String languageSelected = spinner.getSelectedItem().toString(); |
| 128 | + TokensTranslations tokensTranslations = new TokensTranslations(); |
| 129 | + String token = tokensTranslations.getTranslationToken(languageSelected); |
| 130 | + Utils.handleWebUrl(AboutActivity.this,Uri.parse("https://translatewiki.net/w/i.php?title=Special:Translate&language="+token+"&group=commons-android-strings&filter=%21translated&action=translate ?")); |
| 131 | + } |
| 132 | + }); |
| 133 | + builder.setNegativeButton(R.string.about_translate_cancel, new DialogInterface.OnClickListener() { |
| 134 | + @Override |
| 135 | + public void onClick(DialogInterface dialog, int which) { |
| 136 | + finish(); |
| 137 | + } |
| 138 | + }); |
| 139 | + builder.create().show(); |
| 140 | + |
| 141 | + } |
106 | 142 |
|
107 | 143 | } |
0 commit comments