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
This commit is contained in:
Doug Zongker 2012-09-18 12:37:02 -07:00
parent 52eeea4fa5
commit 5fa8c23911
8 changed files with 53 additions and 7 deletions

View file

@ -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);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 844 B

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 40 KiB

View file

@ -52,6 +52,7 @@ static double now() {
ScreenRecoveryUI::ScreenRecoveryUI() :
currentIcon(NONE),
installingFrame(0),
rtl_locale(false),
progressBarType(EMPTY),
progressScopeStart(0),
progressScopeSize(0),
@ -158,6 +159,16 @@ void ScreenRecoveryUI::draw_progress_locked()
float p = progressScopeStart + progress * progressScopeSize;
int pos = (int) (p * width);
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);
}
@ -165,13 +176,20 @@ void ScreenRecoveryUI::draw_progress_locked()
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);
// 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;
}
}
}
}
void ScreenRecoveryUI::draw_text_line(int row, const char* t) {
@ -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);

View file

@ -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];

3
ui.h
View file

@ -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;