summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2017-09-12 00:13:40 +0200
committerandroid-build-merger <android-build-merger@google.com>2017-09-12 00:13:40 +0200
commit3644617e3d297a29d6cb4c3d56953206533f6fbc (patch)
tree20e787156857b7723e3f76cec6d43b479934c217
parentMerge "ui: Remove text_top_." am: 568644197f am: d96ce15139 (diff)
parentMerge "ui: Move locale and friends into ScreenRecoveryUI class." am: fc570c317b (diff)
downloadandroid_bootable_recovery-3644617e3d297a29d6cb4c3d56953206533f6fbc.tar
android_bootable_recovery-3644617e3d297a29d6cb4c3d56953206533f6fbc.tar.gz
android_bootable_recovery-3644617e3d297a29d6cb4c3d56953206533f6fbc.tar.bz2
android_bootable_recovery-3644617e3d297a29d6cb4c3d56953206533f6fbc.tar.lz
android_bootable_recovery-3644617e3d297a29d6cb4c3d56953206533f6fbc.tar.xz
android_bootable_recovery-3644617e3d297a29d6cb4c3d56953206533f6fbc.tar.zst
android_bootable_recovery-3644617e3d297a29d6cb4c3d56953206533f6fbc.zip
-rw-r--r--screen_ui.cpp31
-rw-r--r--screen_ui.h7
-rw-r--r--ui.cpp29
-rw-r--r--ui.h6
4 files changed, 38 insertions, 35 deletions
diff --git a/screen_ui.cpp b/screen_ui.cpp
index a366bb3ef..d65d656bd 100644
--- a/screen_ui.cpp
+++ b/screen_ui.cpp
@@ -14,6 +14,8 @@
* limitations under the License.
*/
+#include "screen_ui.h"
+
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
@@ -36,11 +38,10 @@
#include <android-base/properties.h>
#include <android-base/stringprintf.h>
#include <android-base/strings.h>
+#include <minui/minui.h>
#include "common.h"
#include "device.h"
-#include "minui/minui.h"
-#include "screen_ui.h"
#include "ui.h"
// Return the current time as a double (including fractions of a second).
@@ -79,6 +80,8 @@ ScreenRecoveryUI::ScreenRecoveryUI()
intro_done(false),
stage(-1),
max_stage(-1),
+ locale_(""),
+ rtl_locale_(false),
updateMutex(PTHREAD_MUTEX_INITIALIZER) {}
GRSurface* ScreenRecoveryUI::GetCurrentFrame() const {
@@ -496,6 +499,7 @@ bool ScreenRecoveryUI::InitTextParams() {
bool ScreenRecoveryUI::Init(const std::string& locale) {
RecoveryUI::Init(locale);
+
if (!InitTextParams()) {
return false;
}
@@ -510,6 +514,9 @@ bool ScreenRecoveryUI::Init(const std::string& locale) {
text_col_ = text_row_ = 0;
+ // Set up the locale info.
+ SetLocale(locale);
+
LoadBitmap("icon_error", &error_icon);
LoadBitmap("progress_empty", &progressBarEmpty);
@@ -833,3 +840,23 @@ void ScreenRecoveryUI::KeyLongPress(int) {
// will change color to indicate a successful long press.
Redraw();
}
+
+void ScreenRecoveryUI::SetLocale(const std::string& new_locale) {
+ locale_ = new_locale;
+ rtl_locale_ = false;
+
+ if (!new_locale.empty()) {
+ size_t underscore = new_locale.find('_');
+ // lang has the language prefix prior to '_', or full string if '_' doesn't exist.
+ std::string lang = new_locale.substr(0, underscore);
+
+ // A bit cheesy: keep an explicit list of supported RTL languages.
+ if (lang == "ar" || // Arabic
+ lang == "fa" || // Persian (Farsi)
+ lang == "he" || // Hebrew (new language code)
+ lang == "iw" || // Hebrew (old language code)
+ lang == "ur") { // Urdu
+ rtl_locale_ = true;
+ }
+ }
+}
diff --git a/screen_ui.h b/screen_ui.h
index 0d7b9e86e..eaac2a6e8 100644
--- a/screen_ui.h
+++ b/screen_ui.h
@@ -191,7 +191,14 @@ class ScreenRecoveryUI : public RecoveryUI {
int char_width_;
int char_height_;
+ // The locale that's used to show the rendered texts.
+ std::string locale_;
+ bool rtl_locale_;
+
pthread_mutex_t updateMutex;
+
+ private:
+ void SetLocale(const std::string&);
};
#endif // RECOVERY_UI_H
diff --git a/ui.cpp b/ui.cpp
index e80d7ed04..baf6d1080 100644
--- a/ui.cpp
+++ b/ui.cpp
@@ -50,9 +50,7 @@ static constexpr const char* BRIGHTNESS_FILE = "/sys/class/leds/lcd-backlight/br
static constexpr const char* MAX_BRIGHTNESS_FILE = "/sys/class/leds/lcd-backlight/max_brightness";
RecoveryUI::RecoveryUI()
- : locale_(""),
- rtl_locale_(false),
- brightness_normal_(50),
+ : brightness_normal_(50),
brightness_dimmed_(25),
touch_screen_allowed_(false),
kTouchLowThreshold(RECOVERY_UI_TOUCH_LOW_THRESHOLD),
@@ -132,10 +130,7 @@ bool RecoveryUI::InitScreensaver() {
return true;
}
-bool RecoveryUI::Init(const std::string& locale) {
- // Set up the locale info.
- SetLocale(locale);
-
+bool RecoveryUI::Init(const std::string& /* locale */) {
ev_init(std::bind(&RecoveryUI::OnInputEvent, this, std::placeholders::_1, std::placeholders::_2),
touch_screen_allowed_);
@@ -574,23 +569,3 @@ void RecoveryUI::SetEnableReboot(bool enabled) {
enable_reboot = enabled;
pthread_mutex_unlock(&key_queue_mutex);
}
-
-void RecoveryUI::SetLocale(const std::string& new_locale) {
- this->locale_ = new_locale;
- this->rtl_locale_ = false;
-
- if (!new_locale.empty()) {
- size_t underscore = new_locale.find('_');
- // lang has the language prefix prior to '_', or full string if '_' doesn't exist.
- std::string lang = new_locale.substr(0, underscore);
-
- // A bit cheesy: keep an explicit list of supported RTL languages.
- if (lang == "ar" || // Arabic
- lang == "fa" || // Persian (Farsi)
- lang == "he" || // Hebrew (new language code)
- lang == "iw" || // Hebrew (old language code)
- lang == "ur") { // Urdu
- rtl_locale_ = true;
- }
- }
-}
diff --git a/ui.h b/ui.h
index c6d6d6b52..4086023af 100644
--- a/ui.h
+++ b/ui.h
@@ -143,10 +143,6 @@ class RecoveryUI {
protected:
void EnqueueKey(int key_code);
- // The locale that's used to show the rendered texts.
- std::string locale_;
- bool rtl_locale_;
-
// The normal and dimmed brightness percentages (default: 50 and 25, which means 50% and 25% of
// the max_brightness). Because the absolute values may vary across devices. These two values can
// be configured via subclassing. Setting brightness_normal_ to 0 to disable screensaver.
@@ -184,8 +180,6 @@ class RecoveryUI {
static void* time_key_helper(void* cookie);
void time_key(int key_code, int count);
- void SetLocale(const std::string&);
-
bool InitScreensaver();
// Key event input queue