2011-10-29 00:13:10 +02:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2011 The Android Open Source Project
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef RECOVERY_SCREEN_UI_H
|
|
|
|
#define RECOVERY_SCREEN_UI_H
|
|
|
|
|
|
|
|
#include <pthread.h>
|
2015-04-11 04:12:01 +02:00
|
|
|
#include <stdio.h>
|
2011-10-29 00:13:10 +02:00
|
|
|
|
|
|
|
#include "ui.h"
|
|
|
|
#include "minui/minui.h"
|
|
|
|
|
|
|
|
// Implementation of RecoveryUI appropriate for devices with a screen
|
|
|
|
// (shows an icon + a progress bar, text logging, menu, etc.)
|
|
|
|
class ScreenRecoveryUI : public RecoveryUI {
|
|
|
|
public:
|
|
|
|
ScreenRecoveryUI();
|
|
|
|
|
|
|
|
void Init();
|
2012-09-18 21:37:02 +02:00
|
|
|
void SetLocale(const char* locale);
|
2011-10-29 00:13:10 +02:00
|
|
|
|
|
|
|
// overall recovery state ("background image")
|
|
|
|
void SetBackground(Icon icon);
|
|
|
|
|
|
|
|
// progress indicator
|
|
|
|
void SetProgressType(ProgressType type);
|
|
|
|
void ShowProgress(float portion, float seconds);
|
|
|
|
void SetProgress(float fraction);
|
|
|
|
|
2013-11-25 22:53:25 +01:00
|
|
|
void SetStage(int current, int max);
|
|
|
|
|
2011-10-29 00:13:10 +02:00
|
|
|
// text log
|
|
|
|
void ShowText(bool visible);
|
|
|
|
bool IsTextVisible();
|
|
|
|
bool WasTextEverVisible();
|
|
|
|
|
|
|
|
// printing messages
|
2015-04-09 01:51:36 +02:00
|
|
|
void Print(const char* fmt, ...) __printflike(2, 3);
|
2015-04-09 05:06:50 +02:00
|
|
|
void ShowFile(const char* filename);
|
2011-10-29 00:13:10 +02:00
|
|
|
|
|
|
|
// menu display
|
|
|
|
void StartMenu(const char* const * headers, const char* const * items,
|
2015-04-09 01:51:36 +02:00
|
|
|
int initial_selection);
|
2011-10-29 00:13:10 +02:00
|
|
|
int SelectMenu(int sel);
|
|
|
|
void EndMenu();
|
|
|
|
|
2015-04-10 21:47:46 +02:00
|
|
|
void KeyLongPress(int);
|
|
|
|
|
2013-07-31 20:28:24 +02:00
|
|
|
void Redraw();
|
|
|
|
|
2015-04-13 23:36:02 +02:00
|
|
|
enum UIElement {
|
|
|
|
HEADER, MENU, MENU_SEL_BG, MENU_SEL_BG_ACTIVE, MENU_SEL_FG, LOG, TEXT_FILL, INFO
|
|
|
|
};
|
2015-04-10 21:47:46 +02:00
|
|
|
void SetColor(UIElement e);
|
2013-07-31 20:28:24 +02:00
|
|
|
|
2011-10-29 00:13:10 +02:00
|
|
|
private:
|
|
|
|
Icon currentIcon;
|
|
|
|
int installingFrame;
|
2014-03-17 20:10:02 +01:00
|
|
|
const char* locale;
|
2012-09-18 21:37:02 +02:00
|
|
|
bool rtl_locale;
|
2011-10-29 00:13:10 +02:00
|
|
|
|
|
|
|
pthread_mutex_t updateMutex;
|
2012-08-23 02:26:40 +02:00
|
|
|
gr_surface backgroundIcon[5];
|
|
|
|
gr_surface backgroundText[5];
|
2014-03-07 18:21:25 +01:00
|
|
|
gr_surface *installation;
|
2011-10-29 00:13:10 +02:00
|
|
|
gr_surface progressBarEmpty;
|
|
|
|
gr_surface progressBarFill;
|
2013-11-25 22:53:25 +01:00
|
|
|
gr_surface stageMarkerEmpty;
|
|
|
|
gr_surface stageMarkerFill;
|
2011-10-29 00:13:10 +02:00
|
|
|
|
|
|
|
ProgressType progressBarType;
|
|
|
|
|
|
|
|
float progressScopeStart, progressScopeSize, progress;
|
|
|
|
double progressScopeTime, progressScopeDuration;
|
|
|
|
|
2015-04-09 05:06:50 +02:00
|
|
|
// true when both graphics pages are the same (except for the progress bar).
|
2011-10-29 00:13:10 +02:00
|
|
|
bool pagesIdentical;
|
|
|
|
|
2015-04-09 05:06:50 +02:00
|
|
|
// Log text overlay, displayed when a magic key is pressed.
|
2015-04-08 21:42:50 +02:00
|
|
|
char** text;
|
|
|
|
size_t text_cols, text_rows;
|
|
|
|
size_t text_col, text_row, text_top;
|
2011-10-29 00:13:10 +02:00
|
|
|
bool show_text;
|
|
|
|
bool show_text_ever; // has show_text ever been true?
|
|
|
|
|
2015-04-08 21:42:50 +02:00
|
|
|
char** menu;
|
2015-04-13 23:36:02 +02:00
|
|
|
const char* const* menu_headers;
|
2011-10-29 00:13:10 +02:00
|
|
|
bool show_menu;
|
2015-04-13 23:36:02 +02:00
|
|
|
int menu_items, menu_sel;
|
2011-10-29 00:13:10 +02:00
|
|
|
|
2015-04-13 22:04:32 +02:00
|
|
|
pthread_t progress_thread_;
|
2011-11-01 19:00:20 +01:00
|
|
|
|
|
|
|
int animation_fps;
|
|
|
|
int installing_frames;
|
2014-03-07 18:21:25 +01:00
|
|
|
|
|
|
|
int iconX, iconY;
|
2011-10-29 00:13:10 +02:00
|
|
|
|
2013-11-25 22:53:25 +01:00
|
|
|
int stage, max_stage;
|
|
|
|
|
2011-10-29 00:13:10 +02:00
|
|
|
void draw_background_locked(Icon icon);
|
|
|
|
void draw_progress_locked();
|
|
|
|
void draw_screen_locked();
|
|
|
|
void update_screen_locked();
|
|
|
|
void update_progress_locked();
|
2015-04-13 22:04:32 +02:00
|
|
|
|
|
|
|
static void* ProgressThreadStartRoutine(void* data);
|
|
|
|
void ProgressThreadLoop();
|
2011-10-29 00:13:10 +02:00
|
|
|
|
2015-04-11 04:12:01 +02:00
|
|
|
void ShowFile(FILE*);
|
|
|
|
void PutChar(char);
|
|
|
|
void ClearText();
|
|
|
|
|
|
|
|
void DrawHorizontalRule(int* y);
|
2015-04-13 23:36:02 +02:00
|
|
|
void DrawTextLine(int* y, const char* line, bool bold);
|
|
|
|
void DrawTextLines(int* y, const char* const* lines);
|
2015-04-09 05:06:50 +02:00
|
|
|
|
2011-10-29 00:13:10 +02:00
|
|
|
void LoadBitmap(const char* filename, gr_surface* surface);
|
2014-03-07 18:21:25 +01:00
|
|
|
void LoadBitmapArray(const char* filename, int* frames, gr_surface** surface);
|
2012-08-23 02:26:40 +02:00
|
|
|
void LoadLocalizedBitmap(const char* filename, gr_surface* surface);
|
2011-10-29 00:13:10 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // RECOVERY_UI_H
|