Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import yuku.alkitab.base.util.Background;
import yuku.alkitab.base.util.DownloadMapper;
import yuku.alkitab.base.util.Foreground;
import yuku.alkitab.base.widget.Localized;
import yuku.alkitab.debug.R;
import yuku.alkitab.io.BibleReader;
import yuku.alkitab.io.OptionalGzipInputStream;
Expand Down Expand Up @@ -105,7 +106,7 @@ public static void onReceive(final int id) {
} catch (IOException e) {
AppLog.e(TAG, "I/O error when saving downloaded version", e);
Foreground.run(() -> context.startActivity(
AlertDialogActivity.createOkIntent(null, context.getString(R.string.version_download_saving_io_error))
AlertDialogActivity.createOkIntent(null, Localized.string(R.string.version_download_saving_io_error))
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
));
AppEvents.emitVersionListReload();
Expand All @@ -123,7 +124,7 @@ public static void onReceive(final int id) {
destFile.delete();

Foreground.run(() -> context.startActivity(
AlertDialogActivity.createOkIntent(null, context.getString(R.string.version_download_corrupted_file))
AlertDialogActivity.createOkIntent(null, Localized.string(R.string.version_download_corrupted_file))
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
));
AppEvents.emitVersionListReload();
Expand Down Expand Up @@ -151,7 +152,7 @@ public static void onReceive(final int id) {
MVersionDb.clearVersionImplCache();

Foreground.run(() -> {
Toast.makeText(App.context, TextUtils.expandTemplate(context.getText(R.string.version_download_complete), mvDb.longName), Toast.LENGTH_LONG).show();
Toast.makeText(App.context, TextUtils.expandTemplate(Localized.text(R.string.version_download_complete), mvDb.longName), Toast.LENGTH_LONG).show();
});

AppEvents.emitVersionListReload();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import yuku.alkitab.base.App;
import yuku.alkitab.base.connection.Connections;
import yuku.alkitab.base.util.AppLog;
import yuku.alkitab.base.widget.Localized;
import yuku.alkitab.debug.R;

public class DownloadService extends Service {
Expand Down Expand Up @@ -190,7 +191,7 @@ void changeState(State newState) {
boolean renameOk = entry.tempFile.renameTo(entry.completeFile);
if (!renameOk) {
AppLog.w(TAG, "Failed to rename file from " + entry.tempFile + " to " + entry.completeFile);
entry.errorMsg = getString(R.string.dl_failed_to_rename_temporary_file);
entry.errorMsg = Localized.string(R.string.dl_failed_to_rename_temporary_file);
changeState(State.failed);
return entry;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import yuku.alkitab.base.events.AppEvents;
import yuku.alkitab.base.storage.Prefkey;
import yuku.alkitab.base.util.AppLog;
import yuku.alkitab.base.widget.Localized;
import yuku.alkitab.debug.BuildConfig;
import yuku.alkitab.debug.R;

Expand Down Expand Up @@ -95,7 +96,7 @@ void handleCheckUpdate(final boolean auto) {
AppLog.e(TAG, "failed to download modify time", e);

if (!auto) {
toast(getString(R.string.version_config_updater_error_download_modify_time));
toast(Localized.string(R.string.version_config_updater_error_download_modify_time));
}

return;
Expand All @@ -108,14 +109,14 @@ void handleCheckUpdate(final boolean auto) {
AppLog.e(TAG, "failed to parse modify time file", e);

if (!auto) {
toast(getString(R.string.version_config_updater_error_modify_time_cannot_parse));
toast(Localized.string(R.string.version_config_updater_error_modify_time_cannot_parse));
}
return;
}

if (!modifyTimeObj.success) {
if (!auto) {
toast(getString(R.string.version_config_updater_error_modify_time_failed, modifyTimeObj.message));
toast(Localized.string(R.string.version_config_updater_error_modify_time_failed, modifyTimeObj.message));
}
return;
}
Expand All @@ -124,7 +125,7 @@ void handleCheckUpdate(final boolean auto) {
if (localModifyTime != 0 && localModifyTime >= modifyTimeObj.modifyTime) {
AppLog.d(TAG, "Update: no newer version available. Server modify time: " + new Date(modifyTimeObj.modifyTime * 1000L) + " Local modify time: " + new Date(localModifyTime * 1000L));
if (!auto) {
toast(getString(R.string.version_config_updater_no_newer_available));
toast(Localized.string(R.string.version_config_updater_no_newer_available));
}
return;
}
Expand All @@ -137,15 +138,15 @@ void handleCheckUpdate(final boolean auto) {
AppLog.e(TAG, "failed to download version list", e);

if (!auto) {
toast(getString(R.string.version_config_updater_error_download_list));
toast(Localized.string(R.string.version_config_updater_error_download_list));
}

return;
}

if (!VersionConfig.isValid(versionConfigBody)) {
if (!auto) {
toast(getString(R.string.version_config_updater_error_parsing_list));
toast(Localized.string(R.string.version_config_updater_error_parsing_list));
}

return;
Expand All @@ -154,13 +155,13 @@ void handleCheckUpdate(final boolean auto) {
final boolean updateSuccess = VersionConfig.useLatest(versionConfigBody, modifyTimeObj.modifyTime);
if (!updateSuccess) {
if (!auto) {
toast(getString(R.string.version_config_cannot_write_updated_list));
toast(Localized.string(R.string.version_config_cannot_write_updated_list));
}
return;
}

if (!auto) {
toast(getString(R.string.version_config_updater_updated));
toast(Localized.string(R.string.version_config_updater_updated));
}

Preferences.setInt(Prefkey.version_config_last_update_check, now);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import yuku.alkitab.base.App
import yuku.alkitab.base.ac.AlertDialogActivity
import yuku.alkitab.base.br.VersionDownloadCompleteReceiver
import yuku.alkitab.base.events.AppEvents
import yuku.alkitab.base.widget.Localized
import yuku.alkitab.debug.R

/**
Expand Down Expand Up @@ -201,13 +202,13 @@ class DownloadMapper private constructor() {
val msg: CharSequence = when (errorType) {
VersionDownloadWorker.ERROR_CONNECTION,
VersionDownloadWorker.ERROR_CANCELLED ->
TextUtils.expandTemplate(App.context.getString(R.string.version_download_network_error), row.title)
TextUtils.expandTemplate(Localized.string(R.string.version_download_network_error), row.title)

VersionDownloadWorker.ERROR_STORAGE ->
App.context.getString(R.string.version_download_saving_io_error)
Localized.string(R.string.version_download_saving_io_error)

else ->
TextUtils.expandTemplate(App.context.getString(R.string.version_download_server_error), row.title)
TextUtils.expandTemplate(Localized.string(R.string.version_download_server_error), row.title)
}

App.context.startActivity(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ private static Resources upToDateResources() {
}

AppLog.d(TAG, "Need to adjust resources for pref locale: " + prefLocale);
return currentResources = ConfigurationWrapper.wrap(App.context).getResources();
return currentResources = ConfigurationWrapper.localizedContext(App.context).getResources();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ class TextAppearancePanel(
@Composable
private fun FontRow() {
val escapeColor = colorResource(R.color.escape)
val options = buildFontOptions(uiFontEntries, escapeColor)
val options = buildFontOptions(uiFontEntries, escapeColor, stringResource(R.string.get_more_fonts))
val currentDisplay = displayNameForFont(uiFontName, uiFontEntries)
val currentFamily = fontFamilyForName(uiFontName, uiFontEntries)

Expand Down Expand Up @@ -660,15 +660,19 @@ class TextAppearancePanel(
val color: Color? = null,
)

private fun buildFontOptions(entries: List<FontManager.FontEntry>, escapeColor: Color): List<FontOption> {
private fun buildFontOptions(
entries: List<FontManager.FontEntry>,
escapeColor: Color,
getMoreFontsLabel: String,
): List<FontOption> {
val options = ArrayList<FontOption>(entries.size + 4)
options += FontOption("DEFAULT", "Roboto", FontFamily.SansSerif)
options += FontOption("SERIF", "Droid Serif", FontFamily.Serif)
options += FontOption("MONOSPACE", "Droid Mono", FontFamily.Monospace)
for (entry in entries) {
options += FontOption(entry.name, entry.name, familyForCustomFont(entry.name))
}
options += FontOption(null, App.context.getString(R.string.get_more_fonts), null, escapeColor)
options += FontOption(null, getMoreFontsLabel, null, escapeColor)
return options
}

Expand Down
1 change: 1 addition & 0 deletions Alkitab/src/main/res/values-in/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@
<string name="menuDisplay">Tampilan</string>
<string name="text_appearance_font">Jenis Huruf</string>
<string name="text_appearance_theme_custom">Lainnya&#8230;</string>
<string name="text_appearance_color_theme">Tema warna</string>
<string name="text_appearance_text_size">Ukuran teks</string>
<string name="text_appearance_text_size_for_version">Ukuran huruf untuk ^1</string>
<string name="text_appearance_line_spacing">Jarak antarbaris</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,34 @@ class ConfigurationWrapperLocalizedContextTest {

assertEquals("Loading Genesis 1", localized.getString(R.string.audio_log_loading, "Genesis 1"))
}

@Test
fun `appearance actions and color theme have Indonesian translations`() {
Preferences.setString(R.string.pref_language_key, "in")

val localized = ConfigurationWrapper.localizedContext(AfwApp.context)

assertEquals("Dapatkan huruf lainnya…", localized.getString(R.string.get_more_fonts))
assertEquals("Tema warna", localized.getString(R.string.text_appearance_color_theme))
}

@Test
fun `background strings follow language changes without changing application resources`() {
Preferences.setString(R.string.pref_language_key, "in")

assertEquals("Gagal mengecek daftar versi.", Localized.string(R.string.version_config_updater_error_download_modify_time))
assertEquals("Daftar versi tidak tersedia: offline", Localized.string(R.string.version_config_updater_error_modify_time_failed, "offline"))
assertEquals("^1 terunduh", Localized.text(R.string.version_download_complete).toString())
assertEquals("Download more fonts…", AfwApp.context.getString(R.string.get_more_fonts))

Preferences.setString(R.string.pref_language_key, "en")

assertEquals("Download more fonts…", Localized.string(R.string.get_more_fonts))

Preferences.setString(R.string.pref_language_key, "in")

assertEquals("Tema warna", Localized.string(R.string.text_appearance_color_theme))
assertEquals("Download more fonts…", AfwApp.context.getString(R.string.get_more_fonts))
}

}
Loading