summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2017-08-17 10:10:27 +0200
committerandroid-build-team Robot <android-build-team-robot@google.com>2017-08-17 10:10:27 +0200
commite5fc72dcd7779cc3ba456e5f162198c36a4ecec3 (patch)
tree07a11cdcf6d620125a7b6a89d663426823d5d377
parentrelease-request-8c6f0e6c-413f-4241-b3dc-c159fdcc7655-for-git_pi-release-4273687 snap-temp-L51400000093075386 (diff)
parentImport translations. DO NOT MERGE am: 20fa1a92cc -s ours (diff)
downloadandroid_bootable_recovery-e5fc72dcd7779cc3ba456e5f162198c36a4ecec3.tar
android_bootable_recovery-e5fc72dcd7779cc3ba456e5f162198c36a4ecec3.tar.gz
android_bootable_recovery-e5fc72dcd7779cc3ba456e5f162198c36a4ecec3.tar.bz2
android_bootable_recovery-e5fc72dcd7779cc3ba456e5f162198c36a4ecec3.tar.lz
android_bootable_recovery-e5fc72dcd7779cc3ba456e5f162198c36a4ecec3.tar.xz
android_bootable_recovery-e5fc72dcd7779cc3ba456e5f162198c36a4ecec3.tar.zst
android_bootable_recovery-e5fc72dcd7779cc3ba456e5f162198c36a4ecec3.zip
-rw-r--r--recovery.cpp9
-rw-r--r--screen_ui.cpp30
-rw-r--r--screen_ui.h3
3 files changed, 37 insertions, 5 deletions
diff --git a/recovery.cpp b/recovery.cpp
index 9abb9341c..6f62ff17c 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