summaryrefslogtreecommitdiffstats
path: root/screen_ui.cpp
diff options
context:
space:
mode:
authorDamien Bargiacchi <drb@google.com>2016-08-25 03:28:43 +0200
committerDamien Bargiacchi <drb@google.com>2016-09-07 11:26:50 +0200
commit5e7cfb9af64d5f6bf616d9b6fa40bd0ae82e781a (patch)
treeab6853be5f37627748b1456eec59caf1ed5a2271 /screen_ui.cpp
parentMerge "Support use of custom fonts in miniui" into cw-f-dev (diff)
downloadandroid_bootable_recovery-5e7cfb9af64d5f6bf616d9b6fa40bd0ae82e781a.tar
android_bootable_recovery-5e7cfb9af64d5f6bf616d9b6fa40bd0ae82e781a.tar.gz
android_bootable_recovery-5e7cfb9af64d5f6bf616d9b6fa40bd0ae82e781a.tar.bz2
android_bootable_recovery-5e7cfb9af64d5f6bf616d9b6fa40bd0ae82e781a.tar.lz
android_bootable_recovery-5e7cfb9af64d5f6bf616d9b6fa40bd0ae82e781a.tar.xz
android_bootable_recovery-5e7cfb9af64d5f6bf616d9b6fa40bd0ae82e781a.tar.zst
android_bootable_recovery-5e7cfb9af64d5f6bf616d9b6fa40bd0ae82e781a.zip
Diffstat (limited to 'screen_ui.cpp')
-rw-r--r--screen_ui.cpp52
1 files changed, 32 insertions, 20 deletions
diff --git a/screen_ui.cpp b/screen_ui.cpp
index c2b532657..f884797d3 100644
--- a/screen_ui.cpp
+++ b/screen_ui.cpp
@@ -53,8 +53,6 @@ static double now() {
ScreenRecoveryUI::ScreenRecoveryUI() :
currentIcon(NONE),
locale(nullptr),
- intro_done(false),
- current_frame(0),
progressBarType(EMPTY),
progressScopeStart(0),
progressScopeSize(0),
@@ -75,6 +73,8 @@ ScreenRecoveryUI::ScreenRecoveryUI() :
file_viewer_text_(nullptr),
intro_frames(0),
loop_frames(0),
+ current_frame(0),
+ intro_done(false),
animation_fps(30), // TODO: there's currently no way to infer this.
stage(-1),
max_stage(-1),
@@ -447,9 +447,18 @@ void ScreenRecoveryUI::SetSystemUpdateText(bool security_update) {
Redraw();
}
-void ScreenRecoveryUI::Init() {
+void ScreenRecoveryUI::InitTextParams() {
gr_init();
+ gr_font_size(gr_sys_font(), &char_width_, &char_height_);
+ text_rows_ = gr_fb_height() / char_height_;
+ text_cols_ = gr_fb_width() / char_width_;
+}
+
+void ScreenRecoveryUI::Init() {
+ RecoveryUI::Init();
+ InitTextParams();
+
density_ = static_cast<float>(property_get_int32("ro.sf.lcd_density", 160)) / 160.f;
// Are we portrait or landscape?
@@ -457,10 +466,6 @@ void ScreenRecoveryUI::Init() {
// Are we the large variant of our base layout?
if (gr_fb_height() > PixelsFromDp(800)) ++layout_;
- gr_font_size(gr_sys_font(), &char_width_, &char_height_);
- text_rows_ = gr_fb_height() / char_height_;
- text_cols_ = gr_fb_width() / char_width_;
-
text_ = Alloc2d(text_rows_, text_cols_ + 1);
file_viewer_text_ = Alloc2d(text_rows_, text_cols_ + 1);
menu_ = Alloc2d(text_rows_, text_cols_ + 1);
@@ -487,37 +492,44 @@ void ScreenRecoveryUI::Init() {
LoadAnimation();
pthread_create(&progress_thread_, nullptr, ProgressThreadStartRoutine, this);
-
- RecoveryUI::Init();
}
void ScreenRecoveryUI::LoadAnimation() {
- // How many frames of intro and loop do we have?
std::unique_ptr<DIR, decltype(&closedir)> dir(opendir("/res/images"), closedir);
dirent* de;
+ std::vector<std::string> intro_frame_names;
+ std::vector<std::string> loop_frame_names;
+
while ((de = readdir(dir.get())) != nullptr) {
- int value;
- if (sscanf(de->d_name, "intro%d", &value) == 1 && intro_frames < (value + 1)) {
- intro_frames = value + 1;
- } else if (sscanf(de->d_name, "loop%d", &value) == 1 && loop_frames < (value + 1)) {
- loop_frames = value + 1;
+ int value, num_chars;
+ if (sscanf(de->d_name, "intro%d%n.png", &value, &num_chars) == 1) {
+ intro_frame_names.emplace_back(de->d_name, num_chars);
+ } else if (sscanf(de->d_name, "loop%d%n.png", &value, &num_chars) == 1) {
+ loop_frame_names.emplace_back(de->d_name, num_chars);
}
}
+ intro_frames = intro_frame_names.size();
+ loop_frames = loop_frame_names.size();
+
+ LOGD("Recovery animation intro_frames: %d, loop_frames: %d\n", intro_frames, loop_frames);
+
// It's okay to not have an intro.
if (intro_frames == 0) intro_done = true;
// But you must have an animation.
if (loop_frames == 0) abort();
+ std::sort(intro_frame_names.begin(), intro_frame_names.end());
+ std::sort(loop_frame_names.begin(), loop_frame_names.end());
+
introFrames = new GRSurface*[intro_frames];
- for (int i = 0; i < intro_frames; ++i) {
- // TODO: remember the names above, so we don't have to hard-code the number of 0s.
- LoadBitmap(android::base::StringPrintf("intro%05d", i).c_str(), &introFrames[i]);
+ for (size_t i = 0; i < intro_frames; i++) {
+ LoadBitmap(intro_frame_names.at(i).c_str(), &introFrames[i]);
}
loopFrames = new GRSurface*[loop_frames];
- for (int i = 0; i < loop_frames; ++i) {
- LoadBitmap(android::base::StringPrintf("loop%05d", i).c_str(), &loopFrames[i]);
+ for (size_t i = 0; i < loop_frames; i++) {
+ LoadBitmap(loop_frame_names.at(i).c_str(), &loopFrames[i]);
}
}