From 276657839e3ae2e3f263a6e46ce6c0c0dfa3dbaf Mon Sep 17 00:00:00 2001 From: Doug Zongker <dougz@google.com> Date: Thu, 30 Aug 2012 12:47:43 -0700 Subject: fix format of installing_text Was submitted in the wrong PNG format (color type 4 instead of 0). Change-Id: I8780c81eb92bdfc407b43948a92b37d93026325a --- res/images/installing_text.png | Bin 6785 -> 2747 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/res/images/installing_text.png b/res/images/installing_text.png index 0557350..42704b9 100644 Binary files a/res/images/installing_text.png and b/res/images/installing_text.png differ -- cgit v1.1 From ea6b2a7a85e1302b23ed0d9916e4b38015bc9a23 Mon Sep 17 00:00:00 2001 From: Doug Zongker <dougz@google.com> Date: Tue, 18 Sep 2012 12:37:02 -0700 Subject: localization for recovery messages Add images of text for all locales we support. Make the progress bar fill the correct way for RTL languages. (Flip the direction the spinner turns, too, just for good measure.) Bug: 7064142 Change-Id: I5dddb26e02ee5275c57c4dc4a03c6d68432ac7ba --- recovery.cpp | 3 ++- res/images/erasing_text.png | Bin 1492 -> 31490 bytes res/images/error_text.png | Bin 844 -> 17498 bytes res/images/installing_text.png | Bin 2747 -> 66587 bytes res/images/no_command_text.png | Bin 1868 -> 40633 bytes screen_ui.cpp | 52 ++++++++++++++++++++++++++++++++++++----- screen_ui.h | 2 ++ ui.h | 3 +++ 8 files changed, 53 insertions(+), 7 deletions(-) diff --git a/recovery.cpp b/recovery.cpp index 6ced420..3b58138 100644 --- a/recovery.cpp +++ b/recovery.cpp @@ -781,7 +781,7 @@ load_locale_from_cache() { if (fp != NULL) { fgets(buffer, sizeof(buffer), fp); int j = 0; - int i; + unsigned int i; for (i = 0; i < sizeof(buffer) && buffer[i]; ++i) { if (!isspace(buffer[i])) { buffer[j++] = buffer[i]; @@ -849,6 +849,7 @@ main(int argc, char **argv) { ui = device->GetUI(); ui->Init(); + ui->SetLocale(locale); ui->SetBackground(RecoveryUI::NONE); if (show_text) ui->ShowText(true); diff --git a/res/images/erasing_text.png b/res/images/erasing_text.png index 2cd2e38..8b9f265 100644 Binary files a/res/images/erasing_text.png and b/res/images/erasing_text.png differ diff --git a/res/images/error_text.png b/res/images/error_text.png index 91be5fe..b64b3d7 100644 Binary files a/res/images/error_text.png and b/res/images/error_text.png differ diff --git a/res/images/installing_text.png b/res/images/installing_text.png index 42704b9..9c16c77 100644 Binary files a/res/images/installing_text.png and b/res/images/installing_text.png differ diff --git a/res/images/no_command_text.png b/res/images/no_command_text.png index fbc2074..2241259 100644 Binary files a/res/images/no_command_text.png and b/res/images/no_command_text.png differ diff --git a/screen_ui.cpp b/screen_ui.cpp index 0b34375..64a5dcd 100644 --- a/screen_ui.cpp +++ b/screen_ui.cpp @@ -52,6 +52,7 @@ static double now() { ScreenRecoveryUI::ScreenRecoveryUI() : currentIcon(NONE), installingFrame(0), + rtl_locale(false), progressBarType(EMPTY), progressScopeStart(0), progressScopeSize(0), @@ -158,18 +159,35 @@ void ScreenRecoveryUI::draw_progress_locked() float p = progressScopeStart + progress * progressScopeSize; int pos = (int) (p * width); - if (pos > 0) { - gr_blit(progressBarFill, 0, 0, pos, height, dx, dy); - } - if (pos < width-1) { - gr_blit(progressBarEmpty, pos, 0, width-pos, height, dx+pos, dy); + if (rtl_locale) { + // Fill the progress bar from right to left. + if (pos > 0) { + gr_blit(progressBarFill, width-pos, 0, pos, height, dx+width-pos, dy); + } + if (pos < width-1) { + gr_blit(progressBarEmpty, 0, 0, width-pos, height, dx, dy); + } + } else { + // Fill the progress bar from left to right. + if (pos > 0) { + gr_blit(progressBarFill, 0, 0, pos, height, dx, dy); + } + if (pos < width-1) { + gr_blit(progressBarEmpty, pos, 0, width-pos, height, dx+pos, dy); + } } } if (progressBarType == INDETERMINATE) { static int frame = 0; gr_blit(progressBarIndeterminate[frame], 0, 0, width, height, dx, dy); - frame = (frame + 1) % indeterminate_frames; + // in RTL locales, we run the animation backwards, which + // makes the spinner spin the other way. + if (rtl_locale) { + frame = (frame + indeterminate_frames - 1) % indeterminate_frames; + } else { + frame = (frame + 1) % indeterminate_frames; + } } } } @@ -360,6 +378,28 @@ void ScreenRecoveryUI::Init() RecoveryUI::Init(); } +void ScreenRecoveryUI::SetLocale(const char* locale) { + if (locale) { + char* lang = strdup(locale); + for (char* p = lang; *p; ++p) { + if (*p == '_') { + *p = '\0'; + break; + } + } + + // A bit cheesy: keep an explicit list of supported languages + // that are RTL. + if (strcmp(lang, "ar") == 0 || // Arabic + strcmp(lang, "fa") == 0 || // Persian (Farsi) + strcmp(lang, "he") == 0 || // Hebrew (new language code) + strcmp(lang, "iw") == 0) { // Hebrew (old language code) + rtl_locale = true; + } + free(lang); + } +} + void ScreenRecoveryUI::SetBackground(Icon icon) { pthread_mutex_lock(&updateMutex); diff --git a/screen_ui.h b/screen_ui.h index 16ee741..8005172 100644 --- a/screen_ui.h +++ b/screen_ui.h @@ -29,6 +29,7 @@ class ScreenRecoveryUI : public RecoveryUI { ScreenRecoveryUI(); void Init(); + void SetLocale(const char* locale); // overall recovery state ("background image") void SetBackground(Icon icon); @@ -55,6 +56,7 @@ class ScreenRecoveryUI : public RecoveryUI { private: Icon currentIcon; int installingFrame; + bool rtl_locale; pthread_mutex_t updateMutex; gr_surface backgroundIcon[5]; diff --git a/ui.h b/ui.h index ccbb466..acb5766 100644 --- a/ui.h +++ b/ui.h @@ -30,6 +30,9 @@ class RecoveryUI { // Initialize the object; called before anything else. virtual void Init(); + // After calling Init(), you can tell the UI what locale it is operating in. + virtual void SetLocale(const char* locale) { } + // Set the overall recovery state ("background image"). enum Icon { NONE, INSTALLING_UPDATE, ERASING, NO_COMMAND, ERROR }; virtual void SetBackground(Icon icon) = 0; -- cgit v1.1 From cda00bba51c6adbf95e451fd8c6cad7a5390503a Mon Sep 17 00:00:00 2001 From: Doug Zongker <dougz@google.com> Date: Tue, 18 Sep 2012 14:52:18 -0700 Subject: tweak recovery text images Center and fix the extents for those locales that have multiple lines of text. Add Urdu as an RTL language. Bug: 7064142 Change-Id: I4c1aa1198be29cab01129dabf2c4a026b93719a6 --- res/images/erasing_text.png | Bin 31490 -> 31491 bytes res/images/error_text.png | Bin 17498 -> 17504 bytes res/images/installing_text.png | Bin 66587 -> 66592 bytes res/images/no_command_text.png | Bin 40633 -> 40632 bytes screen_ui.cpp | 3 ++- 5 files changed, 2 insertions(+), 1 deletion(-) diff --git a/res/images/erasing_text.png b/res/images/erasing_text.png index 8b9f265..441768a 100644 Binary files a/res/images/erasing_text.png and b/res/images/erasing_text.png differ diff --git a/res/images/error_text.png b/res/images/error_text.png index b64b3d7..4ac6391 100644 Binary files a/res/images/error_text.png and b/res/images/error_text.png differ diff --git a/res/images/installing_text.png b/res/images/installing_text.png index 9c16c77..e1ac819 100644 Binary files a/res/images/installing_text.png and b/res/images/installing_text.png differ diff --git a/res/images/no_command_text.png b/res/images/no_command_text.png index 2241259..a688f09 100644 Binary files a/res/images/no_command_text.png and b/res/images/no_command_text.png differ diff --git a/screen_ui.cpp b/screen_ui.cpp index 64a5dcd..ab7546d 100644 --- a/screen_ui.cpp +++ b/screen_ui.cpp @@ -393,7 +393,8 @@ void ScreenRecoveryUI::SetLocale(const char* locale) { if (strcmp(lang, "ar") == 0 || // Arabic strcmp(lang, "fa") == 0 || // Persian (Farsi) strcmp(lang, "he") == 0 || // Hebrew (new language code) - strcmp(lang, "iw") == 0) { // Hebrew (old language code) + strcmp(lang, "iw") == 0 || // Hebrew (old language code) + strcmp(lang, "ur") == 0) { // Urdu rtl_locale = true; } free(lang); -- cgit v1.1