From 20fa1a92cc53950a030281453e46015ecaec29bb Mon Sep 17 00:00:00 2001 From: Bill Yi Date: Tue, 15 Aug 2017 20:14:00 -0700 Subject: Import translations. DO NOT MERGE Auto-generated-cl: translation import Exempt-From-Owner-Approval: translation import Bug: 64712476 Change-Id: I7e9049129d9a886cac53a1f6438d9c733fb3d3d8 --- tools/recovery_l10n/res/values-en-rCA/strings.xml | 9 +++++++++ tools/recovery_l10n/res/values-mr/strings.xml | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 tools/recovery_l10n/res/values-en-rCA/strings.xml diff --git a/tools/recovery_l10n/res/values-en-rCA/strings.xml b/tools/recovery_l10n/res/values-en-rCA/strings.xml new file mode 100644 index 000000000..dc75c2374 --- /dev/null +++ b/tools/recovery_l10n/res/values-en-rCA/strings.xml @@ -0,0 +1,9 @@ + + + "Installing system update" + "Erasing" + "No command" + "Error!" + "Installing security update" + diff --git a/tools/recovery_l10n/res/values-mr/strings.xml b/tools/recovery_l10n/res/values-mr/strings.xml index 8cf86f773..017a515c0 100644 --- a/tools/recovery_l10n/res/values-mr/strings.xml +++ b/tools/recovery_l10n/res/values-mr/strings.xml @@ -1,9 +1,9 @@ - "सिस्टम अद्यतन स्थापित करीत आहे" + "सिस्टम अपडेट इंस्टॉल करत आहे" "मिटवत आहे" "कोणताही आदेश नाही" "त्रुटी!" - "सुरक्षा अद्यतन स्थापित करीत आहे" + "सुरक्षा अपडेट इंस्टॉल करत आहे" -- cgit v1.2.3 From ee6fefd2f203a7df2164b3262fa54e62f61e6ad2 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Sun, 13 Aug 2017 23:48:55 -0700 Subject: screen_ui: Word-wrap menu headers. This CL adds ScreenRecoveryUI::DrawWrappedTextLines() to better handle long menu header texts. It does a word wrap at spaces, if available. This avoids fixed-length menu headers being truncated on small screens. Bug: 64293520 Test: On bullhead, boot into recovery with --prompt_and_wipe_data, and check the prompt texts. Change-Id: Ia22746583516dd230567a267584aca558429395e (cherry picked from commit 2bbc6d642d1fbfb007905d95b629fe5f833b2a1b) --- recovery.cpp | 9 +++++---- screen_ui.cpp | 30 +++++++++++++++++++++++++++++- screen_ui.h | 3 +++ 3 files changed, 37 insertions(+), 5 deletions(-) diff --git a/recovery.cpp b/recovery.cpp index 8f08c53f4..07bd7b9d4 100644 --- a/recovery.cpp +++ b/recovery.cpp @@ -758,12 +758,13 @@ static bool wipe_data(Device* device) { } static bool prompt_and_wipe_data(Device* device) { + // Use a single string and let ScreenRecoveryUI handles the wrapping. const char* const headers[] = { - "Can't load Android system. Your data may be corrupt.", - "If you continue to get this message, you may need to", - "perform a factory data reset and erase all user data", + "Can't load Android system. Your data may be corrupt. " + "If you continue to get this message, you may need to " + "perform a factory data reset and erase all user data " "stored on this device.", - NULL + nullptr }; const char* const items[] = { "Try again", diff --git a/screen_ui.cpp b/screen_ui.cpp index 8f792f162..e056512bd 100644 --- a/screen_ui.cpp +++ b/screen_ui.cpp @@ -278,6 +278,34 @@ int ScreenRecoveryUI::DrawTextLines(int x, int y, const char* const* lines) cons return offset; } +int ScreenRecoveryUI::DrawWrappedTextLines(int x, int y, const char* const* lines) const { + int offset = 0; + for (size_t i = 0; lines != nullptr && lines[i] != nullptr; ++i) { + // The line will be wrapped if it exceeds text_cols_. + std::string line(lines[i]); + size_t next_start = 0; + while (next_start < line.size()) { + std::string sub = line.substr(next_start, text_cols_ + 1); + if (sub.size() <= text_cols_) { + next_start += sub.size(); + } else { + // Line too long and must be wrapped to text_cols_ columns. + size_t last_space = sub.find_last_of(" \t\n"); + if (last_space == std::string::npos) { + // No space found, just draw as much as we can + sub.resize(text_cols_); + next_start += text_cols_; + } else { + sub.resize(last_space); + next_start += last_space + 1; + } + } + offset += DrawTextLine(x, y + offset, sub.c_str(), false); + } + } + return offset; +} + static const char* REGULAR_HELP[] = { "Use volume up/down and power.", NULL @@ -316,7 +344,7 @@ void ScreenRecoveryUI::draw_screen_locked() { y += DrawTextLines(x, y, HasThreeButtons() ? REGULAR_HELP : LONG_PRESS_HELP); SetColor(HEADER); - y += DrawTextLines(x, y, menu_headers_); + y += DrawWrappedTextLines(x, y, menu_headers_); SetColor(MENU); y += DrawHorizontalRule(y) + 4; diff --git a/screen_ui.h b/screen_ui.h index 8402fac00..df7cc25b3 100644 --- a/screen_ui.h +++ b/screen_ui.h @@ -187,6 +187,9 @@ class ScreenRecoveryUI : public RecoveryUI { virtual int DrawTextLine(int x, int y, const char* line, bool bold) const; // Draws multiple text lines. Returns the offset it should be moving along Y-axis. int DrawTextLines(int x, int y, const char* const* lines) const; + // Similar to DrawTextLines() to draw multiple text lines, but additionally wraps long lines. + // Returns the offset it should be moving along Y-axis. + int DrawWrappedTextLines(int x, int y, const char* const* lines) const; }; #endif // RECOVERY_UI_H -- cgit v1.2.3 From 2cf6fe2ced4c117d132afd2c6e40fe0d937d0fca Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Wed, 16 Aug 2017 13:25:55 -0700 Subject: screen_ui: Fix a case that may truncate the last char. ScreenRecoveryUI::DrawWrappedTextLines() should be called with kMarginWidth only. Because it's using a line limit of text_cols_, which is unaware of kMenuIdent. Bug: 64293520 Test: No missing char with long header text. Change-Id: Ib4d08de2c56473a483ff9964eb6cec31f8a74c9a (cherry picked from commit 13aa4a902ba2fa304fc9fe826f797a4e0e2182b7) --- screen_ui.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/screen_ui.cpp b/screen_ui.cpp index e056512bd..a02550199 100644 --- a/screen_ui.cpp +++ b/screen_ui.cpp @@ -344,7 +344,8 @@ void ScreenRecoveryUI::draw_screen_locked() { y += DrawTextLines(x, y, HasThreeButtons() ? REGULAR_HELP : LONG_PRESS_HELP); SetColor(HEADER); - y += DrawWrappedTextLines(x, y, menu_headers_); + // Ignore kMenuIndent, which is not taken into account by text_cols_. + y += DrawWrappedTextLines(kMarginWidth, y, menu_headers_); SetColor(MENU); y += DrawHorizontalRule(y) + 4; -- cgit v1.2.3