mirror of
https://github.com/jahruz67/Bible-Daily.git
synced 2026-08-08 18:14:05 +00:00
feat: add multilingual support for UI text in ExtrasActivity, MainActivity, SettingsActivity, and UpdateManager
This commit is contained in:
@@ -23,6 +23,8 @@ public class ExtrasActivity extends Activity {
|
|||||||
private static final int COLOR_ACCENT = Color.rgb(0, 107, 90);
|
private static final int COLOR_ACCENT = Color.rgb(0, 107, 90);
|
||||||
private static final int COLOR_WARM = Color.rgb(217, 75, 61);
|
private static final int COLOR_WARM = Color.rgb(217, 75, 61);
|
||||||
|
|
||||||
|
private boolean isEnglish;
|
||||||
|
|
||||||
private static final String VENI_CREATOR_PRAYER =
|
private static final String VENI_CREATOR_PRAYER =
|
||||||
"Ven, Esp\u00edritu Creador,\n"
|
"Ven, Esp\u00edritu Creador,\n"
|
||||||
+ "visita las almas de tus fieles\n"
|
+ "visita las almas de tus fieles\n"
|
||||||
@@ -135,6 +137,8 @@ public class ExtrasActivity extends Activity {
|
|||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
isEnglish = UpdateManager.isEnglish(this);
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||||
getWindow().setStatusBarColor(COLOR_BACKGROUND);
|
getWindow().setStatusBarColor(COLOR_BACKGROUND);
|
||||||
getWindow().setNavigationBarColor(COLOR_BACKGROUND);
|
getWindow().setNavigationBarColor(COLOR_BACKGROUND);
|
||||||
@@ -143,6 +147,16 @@ public class ExtrasActivity extends Activity {
|
|||||||
setContentView(createScreen());
|
setContentView(createScreen());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
boolean currentLanguage = UpdateManager.isEnglish(this);
|
||||||
|
if (currentLanguage != isEnglish) {
|
||||||
|
isEnglish = currentLanguage;
|
||||||
|
recreate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBackPressed() {
|
public void onBackPressed() {
|
||||||
if (detailContainer != null && detailContainer.getVisibility() == View.VISIBLE) {
|
if (detailContainer != null && detailContainer.getVisibility() == View.VISIBLE) {
|
||||||
@@ -170,7 +184,7 @@ public class ExtrasActivity extends Activity {
|
|||||||
|
|
||||||
content.addView(createTopBar());
|
content.addView(createTopBar());
|
||||||
|
|
||||||
titleText = textView("Extras", 34, COLOR_INK, Typeface.BOLD);
|
titleText = textView(isEnglish ? "Extras" : "Extras", 34, COLOR_INK, Typeface.BOLD);
|
||||||
titleText.setIncludeFontPadding(false);
|
titleText.setIncludeFontPadding(false);
|
||||||
LinearLayout.LayoutParams titleParams = new LinearLayout.LayoutParams(
|
LinearLayout.LayoutParams titleParams = new LinearLayout.LayoutParams(
|
||||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||||
@@ -221,14 +235,14 @@ public class ExtrasActivity extends Activity {
|
|||||||
topBar.setOrientation(LinearLayout.HORIZONTAL);
|
topBar.setOrientation(LinearLayout.HORIZONTAL);
|
||||||
topBar.setGravity(Gravity.CENTER_VERTICAL);
|
topBar.setGravity(Gravity.CENTER_VERTICAL);
|
||||||
|
|
||||||
TextView label = textView("ORACIONES", 12, COLOR_ACCENT, Typeface.BOLD);
|
TextView label = textView(isEnglish ? "PRAYERS" : "ORACIONES", 12, COLOR_ACCENT, Typeface.BOLD);
|
||||||
topBar.addView(label, new LinearLayout.LayoutParams(
|
topBar.addView(label, new LinearLayout.LayoutParams(
|
||||||
0,
|
0,
|
||||||
ViewGroup.LayoutParams.WRAP_CONTENT,
|
ViewGroup.LayoutParams.WRAP_CONTENT,
|
||||||
1f
|
1f
|
||||||
));
|
));
|
||||||
|
|
||||||
TextView settings = textView("Ajustes", 15, COLOR_ACCENT, Typeface.BOLD);
|
TextView settings = textView(isEnglish ? "Settings" : "Ajustes", 15, COLOR_ACCENT, Typeface.BOLD);
|
||||||
settings.setGravity(Gravity.CENTER);
|
settings.setGravity(Gravity.CENTER);
|
||||||
settings.setPadding(dp(14), 0, dp(14), 0);
|
settings.setPadding(dp(14), 0, dp(14), 0);
|
||||||
settings.setBackground(roundedRect(Color.WHITE, dp(8), Color.rgb(219, 226, 222), dp(1)));
|
settings.setBackground(roundedRect(Color.WHITE, dp(8), Color.rgb(219, 226, 222), dp(1)));
|
||||||
@@ -240,7 +254,7 @@ public class ExtrasActivity extends Activity {
|
|||||||
settingsParams.setMargins(0, 0, dp(8), 0);
|
settingsParams.setMargins(0, 0, dp(8), 0);
|
||||||
topBar.addView(settings, settingsParams);
|
topBar.addView(settings, settingsParams);
|
||||||
|
|
||||||
TextView home = textView("Inicio", 15, COLOR_ACCENT, Typeface.BOLD);
|
TextView home = textView(isEnglish ? "Home" : "Inicio", 15, COLOR_ACCENT, Typeface.BOLD);
|
||||||
home.setGravity(Gravity.CENTER);
|
home.setGravity(Gravity.CENTER);
|
||||||
home.setPadding(dp(14), 0, dp(14), 0);
|
home.setPadding(dp(14), 0, dp(14), 0);
|
||||||
home.setBackground(roundedRect(Color.WHITE, dp(8), Color.rgb(219, 226, 222), dp(1)));
|
home.setBackground(roundedRect(Color.WHITE, dp(8), Color.rgb(219, 226, 222), dp(1)));
|
||||||
@@ -316,7 +330,7 @@ public class ExtrasActivity extends Activity {
|
|||||||
prayerParams.setMargins(0, dp(16), 0, dp(18));
|
prayerParams.setMargins(0, dp(16), 0, dp(18));
|
||||||
detailContainer.addView(prayer, prayerParams);
|
detailContainer.addView(prayer, prayerParams);
|
||||||
|
|
||||||
TextView backToList = textView("Volver a extras", 15, COLOR_ACCENT, Typeface.BOLD);
|
TextView backToList = textView(isEnglish ? "Back to extras" : "Volver a extras", 15, COLOR_ACCENT, Typeface.BOLD);
|
||||||
backToList.setGravity(Gravity.CENTER);
|
backToList.setGravity(Gravity.CENTER);
|
||||||
backToList.setPadding(dp(14), 0, dp(14), 0);
|
backToList.setPadding(dp(14), 0, dp(14), 0);
|
||||||
backToList.setBackground(roundedRect(Color.WHITE, dp(8), Color.rgb(219, 226, 222), dp(1)));
|
backToList.setBackground(roundedRect(Color.WHITE, dp(8), Color.rgb(219, 226, 222), dp(1)));
|
||||||
@@ -337,7 +351,7 @@ public class ExtrasActivity extends Activity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void showPrayerList() {
|
private void showPrayerList() {
|
||||||
titleText.setText("Extras");
|
titleText.setText(isEnglish ? "Extras" : "Extras");
|
||||||
detailContainer.setVisibility(View.GONE);
|
detailContainer.setVisibility(View.GONE);
|
||||||
listContainer.setVisibility(View.VISIBLE);
|
listContainer.setVisibility(View.VISIBLE);
|
||||||
scrollToTop();
|
scrollToTop();
|
||||||
|
|||||||
@@ -195,7 +195,7 @@ public class MainActivity extends Activity {
|
|||||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
ViewGroup.LayoutParams.WRAP_CONTENT
|
||||||
));
|
));
|
||||||
|
|
||||||
sourceText = textView("Fuente: Vatican News", 13, COLOR_MUTED, Typeface.NORMAL);
|
sourceText = textView(isEnglish ? "Source: Vatican News" : "Fuente: Vatican News", 13, COLOR_MUTED, Typeface.NORMAL);
|
||||||
LinearLayout.LayoutParams sourceParams = new LinearLayout.LayoutParams(
|
LinearLayout.LayoutParams sourceParams = new LinearLayout.LayoutParams(
|
||||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
ViewGroup.LayoutParams.WRAP_CONTENT
|
||||||
@@ -319,7 +319,7 @@ public class MainActivity extends Activity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private View createExtrasButton() {
|
private View createExtrasButton() {
|
||||||
TextView button = textView("Extras", 15, Color.WHITE, Typeface.BOLD);
|
TextView button = textView(isEnglish ? "Extras" : "Extras", 15, Color.WHITE, Typeface.BOLD);
|
||||||
button.setGravity(Gravity.CENTER);
|
button.setGravity(Gravity.CENTER);
|
||||||
button.setPadding(dp(16), 0, dp(16), 0);
|
button.setPadding(dp(16), 0, dp(16), 0);
|
||||||
button.setBackground(roundedRect(COLOR_ACCENT, dp(8), Color.TRANSPARENT, 0));
|
button.setBackground(roundedRect(COLOR_ACCENT, dp(8), Color.TRANSPARENT, 0));
|
||||||
@@ -409,9 +409,9 @@ public class MainActivity extends Activity {
|
|||||||
);
|
);
|
||||||
quickParams.setMargins(0, dp(10), 0, dp(6));
|
quickParams.setMargins(0, dp(10), 0, dp(6));
|
||||||
|
|
||||||
quickRow.addView(smallCalendarButton("- Año", view -> changeVisibleYear(-1)));
|
quickRow.addView(smallCalendarButton(isEnglish ? "- Year" : "- Año", view -> changeVisibleYear(-1)));
|
||||||
quickRow.addView(smallCalendarButton("Hoy", view -> selectDate(Calendar.getInstance())));
|
quickRow.addView(smallCalendarButton(isEnglish ? "Today" : "Hoy", view -> selectDate(Calendar.getInstance())));
|
||||||
quickRow.addView(smallCalendarButton("+ Año", view -> changeVisibleYear(1)));
|
quickRow.addView(smallCalendarButton(isEnglish ? "+ Year" : "+ Año", view -> changeVisibleYear(1)));
|
||||||
panel.addView(quickRow, quickParams);
|
panel.addView(quickRow, quickParams);
|
||||||
|
|
||||||
LinearLayout weekdays = new LinearLayout(this);
|
LinearLayout weekdays = new LinearLayout(this);
|
||||||
@@ -445,7 +445,7 @@ public class MainActivity extends Activity {
|
|||||||
button.setGravity(Gravity.CENTER);
|
button.setGravity(Gravity.CENTER);
|
||||||
button.setBackground(roundedRect(Color.rgb(229, 244, 240), dp(8), Color.TRANSPARENT, 0));
|
button.setBackground(roundedRect(Color.rgb(229, 244, 240), dp(8), Color.TRANSPARENT, 0));
|
||||||
button.setOnClickListener(listener);
|
button.setOnClickListener(listener);
|
||||||
button.setContentDescription(text.equals("<") ? "Mes anterior" : "Mes siguiente");
|
button.setContentDescription(text.equals("<") ? (isEnglish ? "Previous month" : "Mes anterior") : (isEnglish ? "Next month" : "Mes siguiente"));
|
||||||
return button;
|
return button;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -997,7 +997,7 @@ public class MainActivity extends Activity {
|
|||||||
progressParams.setMargins(0, 0, dp(12), 0);
|
progressParams.setMargins(0, 0, dp(12), 0);
|
||||||
row.addView(progressBar, progressParams);
|
row.addView(progressBar, progressParams);
|
||||||
|
|
||||||
statusText = textView("Cargando la Palabra de hoy...", 16, COLOR_INK, Typeface.NORMAL);
|
statusText = textView(isEnglish ? "Loading today's Word..." : "Cargando la Palabra de hoy...", 16, COLOR_INK, Typeface.NORMAL);
|
||||||
statusText.setLineSpacing(0, 1.16f);
|
statusText.setLineSpacing(0, 1.16f);
|
||||||
row.addView(statusText, new LinearLayout.LayoutParams(
|
row.addView(statusText, new LinearLayout.LayoutParams(
|
||||||
0,
|
0,
|
||||||
@@ -1007,7 +1007,7 @@ public class MainActivity extends Activity {
|
|||||||
statusBlock.addView(row);
|
statusBlock.addView(row);
|
||||||
|
|
||||||
retryButton = new Button(this);
|
retryButton = new Button(this);
|
||||||
retryButton.setText("Reintentar");
|
retryButton.setText(isEnglish ? "Retry" : "Reintentar");
|
||||||
retryButton.setTextColor(Color.WHITE);
|
retryButton.setTextColor(Color.WHITE);
|
||||||
retryButton.setTextSize(14);
|
retryButton.setTextSize(14);
|
||||||
retryButton.setAllCaps(false);
|
retryButton.setAllCaps(false);
|
||||||
@@ -1043,7 +1043,7 @@ public class MainActivity extends Activity {
|
|||||||
LinearLayout labelRow = new LinearLayout(this);
|
LinearLayout labelRow = new LinearLayout(this);
|
||||||
labelRow.setGravity(Gravity.CENTER_VERTICAL);
|
labelRow.setGravity(Gravity.CENTER_VERTICAL);
|
||||||
|
|
||||||
TextView label = textView("Tamaño de letra", 15, COLOR_INK, Typeface.BOLD);
|
TextView label = textView(isEnglish ? "Font size" : "Tamaño de letra", 15, COLOR_INK, Typeface.BOLD);
|
||||||
labelRow.addView(label, new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 1f));
|
labelRow.addView(label, new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 1f));
|
||||||
|
|
||||||
fontValueText = textView(Math.round(readingFontSp) + " sp", 14, COLOR_MUTED, Typeface.BOLD);
|
fontValueText = textView(Math.round(readingFontSp) + " sp", 14, COLOR_MUTED, Typeface.BOLD);
|
||||||
@@ -1954,7 +1954,7 @@ public class MainActivity extends Activity {
|
|||||||
DailySection papalWords = DailySection.reflection(cleanSectionText(papalText));
|
DailySection papalWords = DailySection.reflection(cleanSectionText(papalText));
|
||||||
|
|
||||||
if (gospel.body.isEmpty() && firstReading.body.isEmpty() && papalWords.body.isEmpty()) {
|
if (gospel.body.isEmpty() && firstReading.body.isEmpty() && papalWords.body.isEmpty()) {
|
||||||
throw new IOException("No encontré las secciones esperadas en la página.");
|
throw new IOException(isEnglish ? "Could not find the expected sections on the page." : "No encontré las secciones esperadas en la página.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return new DailyReading(
|
return new DailyReading(
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ public class SettingsActivity extends Activity {
|
|||||||
private TextView voiceSubtitleText;
|
private TextView voiceSubtitleText;
|
||||||
private TextView voiceButton;
|
private TextView voiceButton;
|
||||||
private UpdateManager.UpdateInfo latestInfo;
|
private UpdateManager.UpdateInfo latestInfo;
|
||||||
|
private boolean isEnglish;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@@ -46,6 +47,7 @@ public class SettingsActivity extends Activity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
executor = Executors.newSingleThreadExecutor();
|
executor = Executors.newSingleThreadExecutor();
|
||||||
|
isEnglish = UpdateManager.isEnglish(this);
|
||||||
setContentView(createScreen());
|
setContentView(createScreen());
|
||||||
updateInstalledVersionText();
|
updateInstalledVersionText();
|
||||||
}
|
}
|
||||||
@@ -89,7 +91,7 @@ public class SettingsActivity extends Activity {
|
|||||||
content.addView(createVoiceCard());
|
content.addView(createVoiceCard());
|
||||||
content.addView(createVersionCard());
|
content.addView(createVersionCard());
|
||||||
|
|
||||||
checkButton = actionButton("Check now", COLOR_ACCENT, Color.WHITE);
|
checkButton = actionButton(isEnglish ? "Check now" : "Comprobar", COLOR_ACCENT, Color.WHITE);
|
||||||
checkButton.setOnClickListener(view -> checkForUpdate());
|
checkButton.setOnClickListener(view -> checkForUpdate());
|
||||||
LinearLayout.LayoutParams checkParams = new LinearLayout.LayoutParams(
|
LinearLayout.LayoutParams checkParams = new LinearLayout.LayoutParams(
|
||||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||||
@@ -142,7 +144,7 @@ public class SettingsActivity extends Activity {
|
|||||||
1f
|
1f
|
||||||
));
|
));
|
||||||
|
|
||||||
TextView back = textView("Extras", 15, COLOR_ACCENT, Typeface.BOLD);
|
TextView back = textView(isEnglish ? "Extras" : "Extras", 15, COLOR_ACCENT, Typeface.BOLD);
|
||||||
back.setGravity(Gravity.CENTER);
|
back.setGravity(Gravity.CENTER);
|
||||||
back.setPadding(dp(14), 0, dp(14), 0);
|
back.setPadding(dp(14), 0, dp(14), 0);
|
||||||
back.setBackground(roundedRect(Color.WHITE, dp(8), Color.rgb(219, 226, 222), dp(1)));
|
back.setBackground(roundedRect(Color.WHITE, dp(8), Color.rgb(219, 226, 222), dp(1)));
|
||||||
@@ -181,11 +183,11 @@ public class SettingsActivity extends Activity {
|
|||||||
1f
|
1f
|
||||||
));
|
));
|
||||||
|
|
||||||
TextView langToggle = actionButton(UpdateManager.isEnglish(this) ? "English" : "Spanish", COLOR_ACCENT, Color.WHITE);
|
TextView langToggle = actionButton(UpdateManager.isEnglish(this) ? "English" : "Español", COLOR_ACCENT, Color.WHITE);
|
||||||
langToggle.setOnClickListener(view -> {
|
langToggle.setOnClickListener(view -> {
|
||||||
boolean current = UpdateManager.isEnglish(this);
|
boolean current = UpdateManager.isEnglish(this);
|
||||||
UpdateManager.setEnglish(this, !current);
|
UpdateManager.setEnglish(this, !current);
|
||||||
langToggle.setText(!current ? "English" : "Spanish");
|
langToggle.setText(!current ? "English" : "Español");
|
||||||
updateVoiceCard();
|
updateVoiceCard();
|
||||||
});
|
});
|
||||||
card.addView(langToggle, new LinearLayout.LayoutParams(dp(100), dp(40)));
|
card.addView(langToggle, new LinearLayout.LayoutParams(dp(100), dp(40)));
|
||||||
@@ -336,17 +338,18 @@ public class SettingsActivity extends Activity {
|
|||||||
String voiceId = UpdateManager.getTtsVoice(this, english);
|
String voiceId = UpdateManager.getTtsVoice(this, english);
|
||||||
voiceSubtitleText.setText(english
|
voiceSubtitleText.setText(english
|
||||||
? "English voices are shown while English is selected"
|
? "English voices are shown while English is selected"
|
||||||
: "Spanish voices are shown while Spanish is selected");
|
: "Las voces en español se muestran mientras el español esté seleccionado");
|
||||||
voiceButton.setText(UpdateManager.getTtsVoiceLabel(english, voiceId));
|
voiceButton.setText(UpdateManager.getTtsVoiceLabel(english, voiceId));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateInstalledVersionText() {
|
private void updateInstalledVersionText() {
|
||||||
try {
|
try {
|
||||||
installedVersionText.setText("Installed: "
|
installedVersionText.setText(
|
||||||
|
(isEnglish ? "Installed: " : "Instalada: ")
|
||||||
+ UpdateManager.getInstalledVersionName(this)
|
+ UpdateManager.getInstalledVersionName(this)
|
||||||
+ " (" + UpdateManager.getInstalledVersionCode(this) + ")");
|
+ " (" + UpdateManager.getInstalledVersionCode(this) + ")");
|
||||||
} catch (Exception error) {
|
} catch (Exception error) {
|
||||||
installedVersionText.setText("Installed version unavailable.");
|
installedVersionText.setText(isEnglish ? "Installed version unavailable." : "Versión instalada no disponible.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -205,11 +205,12 @@ final class UpdateManager {
|
|||||||
? String.valueOf(info.latestVersionCode)
|
? String.valueOf(info.latestVersionCode)
|
||||||
: info.latestVersionName + " (" + info.latestVersionCode + ")";
|
: info.latestVersionName + " (" + info.latestVersionCode + ")";
|
||||||
|
|
||||||
|
boolean english = isEnglish(activity);
|
||||||
new AlertDialog.Builder(activity)
|
new AlertDialog.Builder(activity)
|
||||||
.setTitle("Update available")
|
.setTitle(english ? "Update available" : "Actualización disponible")
|
||||||
.setMessage("Version " + version + " is ready to download.")
|
.setMessage((english ? "Version " : "Versión ") + version + (english ? " is ready to download." : " está lista para descargar."))
|
||||||
.setPositiveButton("Download", (dialog, which) -> openDownload(activity, info.apkUrl))
|
.setPositiveButton(english ? "Download" : "Descargar", (dialog, which) -> openDownload(activity, info.apkUrl))
|
||||||
.setNegativeButton("Later", null)
|
.setNegativeButton(english ? "Later" : "Después", null)
|
||||||
.show();
|
.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user