// handle the user input events (mainly the touch events) inside the ui handler static void ui_handle_mouse_input(int* curPos) { pthread_mutex_lock(&key_queue_mutex); //In this case MENU_SELECT icon has maximum possible height. int menu_max_height = gr_get_height(gMenuIcon[MENU_SELECT]); struct { int x; int y; int xL; int xR; } MENU_ICON[] = { { gr_fb_width() - menu_max_height, 7*gr_fb_height()/8, 3*gr_fb_height()/4, 4*gr_fb_height()/4 }, { gr_fb_width() - menu_max_height, 5*gr_fb_height()/8, 2*gr_fb_height()/4, 3*gr_fb_height()/4 }, { gr_fb_width() - menu_max_height, 3*gr_fb_height()/8, 1*gr_fb_height()/4, 2*gr_fb_height()/4 }, { gr_fb_width() - menu_max_height, 1*gr_fb_height()/8, 0*gr_fb_height()/4, 1*gr_fb_height()/4 }, }; if (show_menu) { if (curPos[0] > 0) { int position = gr_fb_height() - curPos[1]; //ui_print("Pressure:%d\tX:%d\tY:%d\n",mousePos[0],mousePos[1],mousePos[2]); pthread_mutex_lock(&gUpdateMutex); if(position > MENU_ICON[MENU_BACK].xL && position < MENU_ICON[MENU_BACK].xR && selMenuIcon != MENU_BACK) { draw_icon_locked(gMenuIcon[selMenuIcon], MENU_ICON[selMenuIcon].x, MENU_ICON[selMenuIcon].y ); draw_icon_locked(gMenuIcon[MENU_BACK_M], MENU_ICON[MENU_BACK].x, MENU_ICON[MENU_BACK].y ); selMenuIcon = MENU_BACK; gr_flip(); } else if(position > MENU_ICON[MENU_DOWN].xL && position < MENU_ICON[MENU_DOWN].xR && selMenuIcon != MENU_DOWN) { draw_icon_locked(gMenuIcon[selMenuIcon], MENU_ICON[selMenuIcon].x, MENU_ICON[selMenuIcon].y ); draw_icon_locked(gMenuIcon[MENU_DOWN_M], MENU_ICON[MENU_DOWN].x, MENU_ICON[MENU_DOWN].y); selMenuIcon = MENU_DOWN; gr_flip(); } else if(position > MENU_ICON[MENU_UP].xL && position < MENU_ICON[MENU_UP].xR && selMenuIcon != MENU_UP) { draw_icon_locked(gMenuIcon[selMenuIcon], MENU_ICON[selMenuIcon].x, MENU_ICON[selMenuIcon].y ); draw_icon_locked(gMenuIcon[MENU_UP_M], MENU_ICON[MENU_UP].x, MENU_ICON[MENU_UP].y ); selMenuIcon = MENU_UP; gr_flip(); } else if(position > MENU_ICON[MENU_SELECT].xL && position < MENU_ICON[MENU_SELECT].xR && selMenuIcon != MENU_SELECT) { draw_icon_locked(gMenuIcon[selMenuIcon], MENU_ICON[selMenuIcon].x, MENU_ICON[selMenuIcon].y ); draw_icon_locked(gMenuIcon[MENU_SELECT_M], MENU_ICON[MENU_SELECT].x, MENU_ICON[MENU_SELECT].y ); selMenuIcon = MENU_SELECT; gr_flip(); } key_queue_len_back = key_queue_len; pthread_mutex_unlock(&gUpdateMutex); } } pthread_mutex_unlock(&key_queue_mutex); }
// Clear the screen and draw the currently selected background icon (if any). // Should only be called with updateMutex locked. void ScreenRecoveryUI::draw_background_locked(Icon icon) { pagesIdentical = false; gr_color(0, 0, 0, 255); gr_fill(0, 0, gr_fb_width(), gr_fb_height()); if (icon) { gr_surface surface = backgroundIcon[icon]; int iconWidth = gr_get_width(surface); int iconHeight = gr_get_height(surface); int iconX = (gr_fb_width() - iconWidth) / 2; int iconY = (gr_fb_height() - iconHeight) / 2; gr_blit(surface, 0, 0, iconWidth, iconHeight, iconX, iconY); if (icon == INSTALLING) { draw_install_overlay_locked(installingFrame); } } }
// Clear the screen and draw the currently selected background icon (if any). // Should only be called with gUpdateMutex locked. static void draw_background_locked(int icon) { gPagesIdentical = 0; gr_color(0, 0, 0, 255); gr_fill(0, 0, gr_fb_width(), gr_fb_height()); if (icon) { gr_surface surface = gBackgroundIcon[icon]; int iconWidth = gr_get_width(surface); int iconHeight = gr_get_height(surface); int iconX = (gr_fb_width() - iconWidth) / 2; int iconY = (gr_fb_height() - iconHeight) / 2; gr_blit(surface, 0, 0, iconWidth, iconHeight, iconX, iconY); if (icon == BACKGROUND_ICON_INSTALLING) { draw_install_overlay_locked(gInstallingFrame); } } }
static void draw(const char *resname) { GRSurface* surface; int w, h, x, y; if (res_create_display_surface(resname, &surface) < 0) { LOGE("failed to create surface for %s\n", resname); return; } w = gr_get_width(surface); h = gr_get_height(surface); x = (gr_fb_width() - w) / 2; y = (gr_fb_height() - h) / 2; gr_blit(surface, 0, 0, w, h, x, y); gr_flip(); res_free_surface(surface); }
GUIFileSelector::GUIFileSelector(xml_node<>* node) { xml_attribute<>* attr; xml_node<>* child; int header_separator_color_specified = 0, header_separator_height_specified = 0, header_text_color_specified = 0, header_background_color_specified = 0; mStart = mLineSpacing = startY = mFontHeight = mSeparatorH = scrollingY = scrollingSpeed = 0; mIconWidth = mIconHeight = mFolderIconHeight = mFileIconHeight = mFolderIconWidth = mFileIconWidth = mHeaderIconHeight = mHeaderIconWidth = 0; mHeaderSeparatorH = mLineHeight = mHeaderIsStatic = mHeaderH = actualLineHeight = 0; mFolderIcon = mFileIcon = mBackground = mFont = mHeaderIcon = NULL; mBackgroundX = mBackgroundY = mBackgroundW = mBackgroundH = 0; mShowFolders = mShowFiles = mShowNavFolders = 1; mUpdate = 0; touchDebounce = 6; mPathVar = "cwd"; ConvertStrToColor("black", &mBackgroundColor); ConvertStrToColor("black", &mHeaderBackgroundColor); ConvertStrToColor("black", &mSeparatorColor); ConvertStrToColor("black", &mHeaderSeparatorColor); ConvertStrToColor("white", &mFontColor); ConvertStrToColor("white", &mHeaderFontColor); // Load header text child = node->first_node("header"); if (child) { attr = child->first_attribute("icon"); if (attr) mHeaderIcon = PageManager::FindResource(attr->value()); attr = child->first_attribute("background"); if (attr) { std::string color = attr->value(); ConvertStrToColor(color, &mHeaderBackgroundColor); header_background_color_specified = -1; } attr = child->first_attribute("textcolor"); if (attr) { std::string color = attr->value(); ConvertStrToColor(color, &mHeaderFontColor); header_text_color_specified = -1; } attr = child->first_attribute("separatorcolor"); if (attr) { std::string color = attr->value(); ConvertStrToColor(color, &mHeaderSeparatorColor); header_separator_color_specified = -1; } attr = child->first_attribute("separatorheight"); if (attr) { string parsevalue = gui_parse_text(attr->value()); mHeaderSeparatorH = atoi(parsevalue.c_str()); header_separator_height_specified = -1; } } child = node->first_node("text"); if (child) mHeaderText = child->value(); // Simple way to check for static state mLastValue = gui_parse_text(mHeaderText); if (mLastValue != mHeaderText) mHeaderIsStatic = 0; else mHeaderIsStatic = -1; child = node->first_node("icon"); if (child) { attr = child->first_attribute("folder"); if (attr) mFolderIcon = PageManager::FindResource(attr->value()); attr = child->first_attribute("file"); if (attr) mFileIcon = PageManager::FindResource(attr->value()); } child = node->first_node("background"); if (child) { attr = child->first_attribute("resource"); if (attr) mBackground = PageManager::FindResource(attr->value()); attr = child->first_attribute("color"); if (attr) { std::string color = attr->value(); ConvertStrToColor(color, &mBackgroundColor); if (!header_background_color_specified) ConvertStrToColor(color, &mHeaderBackgroundColor); } } // Load the placement LoadPlacement(node->first_node("placement"), &mRenderX, &mRenderY, &mRenderW, &mRenderH); SetActionPos(mRenderX, mRenderY, mRenderW, mRenderH); // Load the font, and possibly override the color child = node->first_node("font"); if (child) { attr = child->first_attribute("resource"); if (attr) mFont = PageManager::FindResource(attr->value()); attr = child->first_attribute("color"); if (attr) { std::string color = attr->value(); ConvertStrToColor(color, &mFontColor); if (!header_text_color_specified) ConvertStrToColor(color, &mHeaderFontColor); } attr = child->first_attribute("spacing"); if (attr) { string parsevalue = gui_parse_text(attr->value()); mLineSpacing = atoi(parsevalue.c_str()); } } // Load the separator if it exists child = node->first_node("separator"); if (child) { attr = child->first_attribute("color"); if (attr) { std::string color = attr->value(); ConvertStrToColor(color, &mSeparatorColor); if (!header_separator_color_specified) ConvertStrToColor(color, &mHeaderSeparatorColor); } attr = child->first_attribute("height"); if (attr) { string parsevalue = gui_parse_text(attr->value()); mSeparatorH = atoi(parsevalue.c_str()); if (!header_separator_height_specified) mHeaderSeparatorH = mSeparatorH; } } child = node->first_node("filter"); if (child) { attr = child->first_attribute("extn"); if (attr) mExtn = attr->value(); attr = child->first_attribute("folders"); if (attr) mShowFolders = atoi(attr->value()); attr = child->first_attribute("files"); if (attr) mShowFiles = atoi(attr->value()); attr = child->first_attribute("nav"); if (attr) mShowNavFolders = atoi(attr->value()); } // Handle the path variable child = node->first_node("path"); if (child) { attr = child->first_attribute("name"); if (attr) mPathVar = attr->value(); attr = child->first_attribute("default"); if (attr) DataManager::SetValue(mPathVar, attr->value()); } // Handle the result variable child = node->first_node("data"); if (child) { attr = child->first_attribute("name"); if (attr) mVariable = attr->value(); attr = child->first_attribute("default"); if (attr) DataManager::SetValue(mVariable, attr->value()); } // Handle the sort variable child = node->first_node("sort"); if (child) { attr = child->first_attribute("name"); if (attr) mSortVariable = attr->value(); attr = child->first_attribute("default"); if (attr) DataManager::SetValue(mSortVariable, attr->value()); DataManager::GetValue(mSortVariable, mSortOrder); } // Handle the selection variable child = node->first_node("selection"); if (child) { attr = child->first_attribute("name"); if (attr) mSelection = attr->value(); else mSelection = "0"; } else mSelection = "0"; // Retrieve the line height gr_getFontDetails(mFont ? mFont->GetResource() : NULL, &mFontHeight, NULL); mLineHeight = mFontHeight; mHeaderH = mFontHeight; if (mFolderIcon && mFolderIcon->GetResource()) { mFolderIconWidth = gr_get_width(mFolderIcon->GetResource()); mFolderIconHeight = gr_get_height(mFolderIcon->GetResource()); if (mFolderIconHeight > (int)mLineHeight) mLineHeight = mFolderIconHeight; mIconWidth = mFolderIconWidth; } if (mFileIcon && mFileIcon->GetResource()) { mFileIconWidth = gr_get_width(mFileIcon->GetResource()); mFileIconHeight = gr_get_height(mFileIcon->GetResource()); if (mFileIconHeight > (int)mLineHeight) mLineHeight = mFileIconHeight; if (mFileIconWidth > mIconWidth) mIconWidth = mFileIconWidth; } if (mHeaderIcon && mHeaderIcon->GetResource()) { mHeaderIconWidth = gr_get_width(mHeaderIcon->GetResource()); mHeaderIconHeight = gr_get_height(mHeaderIcon->GetResource()); if (mHeaderIconHeight > mHeaderH) mHeaderH = mHeaderIconHeight; if (mHeaderIconWidth > mIconWidth) mIconWidth = mHeaderIconWidth; } mHeaderH += mLineSpacing + mHeaderSeparatorH; actualLineHeight = mLineHeight + mLineSpacing + mSeparatorH; if (mHeaderH < actualLineHeight) mHeaderH = actualLineHeight; if (actualLineHeight / 3 > 6) touchDebounce = actualLineHeight / 3; if (mBackground && mBackground->GetResource()) { mBackgroundW = gr_get_width(mBackground->GetResource()); mBackgroundH = gr_get_height(mBackground->GetResource()); } // Fetch the file/folder list std::string value; DataManager::GetValue(mPathVar, value); if (GetFileList(value) != 0 && (mShowNavFolders != 0 || mShowFiles != 0)) { GetFileList(DataManager::GetCurrentStoragePath()); DataManager::SetValue(mPathVar, DataManager::GetCurrentStoragePath()); } }
GUIKeyboard::GUIKeyboard(xml_node<>* node) : Conditional(node) { int layoutindex, rowindex, keyindex, Xindex, Yindex, keyHeight = 0, keyWidth = 0; rowY = colX = -1; highlightRenderCount = hasHighlight = 0; char resource[10], layout[8], row[5], key[6], longpress[7]; xml_attribute<>* attr; xml_node<>* child; xml_node<>* keylayout; xml_node<>* keyrow; for (layoutindex=0; layoutindex<MAX_KEYBOARD_LAYOUTS; layoutindex++) keyboardImg[layoutindex] = NULL; mRendered = false; currentLayout = 1; mAction = NULL; KeyboardHeight = KeyboardWidth = cursorLocation = 0; if (!node) return; // Load the action child = node->first_node("action"); if (child) { mAction = new GUIAction(node); } memset(&mHighlightColor, 0, sizeof(COLOR)); child = node->first_node("highlight"); if (child) { attr = child->first_attribute("color"); if (attr) { hasHighlight = 1; std::string color = attr->value(); ConvertStrToColor(color, &mHighlightColor); } } // Load the images for the different layouts child = node->first_node("layout"); if (child) { layoutindex = 1; strcpy(resource, "resource1"); attr = child->first_attribute(resource); while (attr && layoutindex < (MAX_KEYBOARD_LAYOUTS + 1)) { keyboardImg[layoutindex - 1] = PageManager::FindResource(attr->value()); layoutindex++; resource[8] = (char)(layoutindex + 48); attr = child->first_attribute(resource); } } // Check the first image to get height and width if (keyboardImg[0] && keyboardImg[0]->GetResource()) { KeyboardWidth = gr_get_width(keyboardImg[0]->GetResource()); KeyboardHeight = gr_get_height(keyboardImg[0]->GetResource()); } // Load all of the layout maps layoutindex = 1; strcpy(layout, "layout1"); keylayout = node->first_node(layout); while (keylayout) { if (layoutindex > MAX_KEYBOARD_LAYOUTS) { LOGERR("Too many layouts defined in keyboard.\n"); return; } child = keylayout->first_node("keysize"); if (child) { attr = child->first_attribute("height"); if (attr) keyHeight = atoi(attr->value()); else keyHeight = 0; attr = child->first_attribute("width"); if (attr) keyWidth = atoi(attr->value()); else keyWidth = 0; } rowindex = 1; Yindex = 0; strcpy(row, "row1"); keyrow = keylayout->first_node(row); while (keyrow) { if (rowindex > MAX_KEYBOARD_ROWS) { LOGERR("Too many rows defined in keyboard.\n"); return; } Yindex += keyHeight; row_heights[layoutindex - 1][rowindex - 1] = Yindex; keyindex = 1; Xindex = 0; strcpy(key, "key01"); attr = keyrow->first_attribute(key); while (attr) { string stratt; char keyinfo[255]; if (keyindex > MAX_KEYBOARD_KEYS) { LOGERR("Too many keys defined in a keyboard row.\n"); return; } stratt = attr->value(); if (strlen(stratt.c_str()) >= 255) { LOGERR("Key info on layout%i, row%i, key%dd is too long.\n", layoutindex, rowindex, keyindex); return; } strcpy(keyinfo, stratt.c_str()); if (strlen(keyinfo) == 0) { LOGERR("No key info on layout%i, row%i, key%dd.\n", layoutindex, rowindex, keyindex); return; } if (strlen(keyinfo) == 1) { // This is a single key, simple definition keyboard_keys[layoutindex - 1][rowindex - 1][keyindex - 1].key = keyinfo[0]; Xindex += keyWidth; keyboard_keys[layoutindex - 1][rowindex - 1][keyindex - 1].end_x = Xindex - 1; } else { // This key has extra data char* ptr; char* offset; char* keyitem; char foratoi[10]; ptr = keyinfo; offset = keyinfo; while (*ptr > 32 && *ptr != ':') ptr++; if (*ptr != 0) *ptr = 0; strcpy(foratoi, offset); Xindex += atoi(foratoi); keyboard_keys[layoutindex - 1][rowindex - 1][keyindex - 1].end_x = Xindex - 1; ptr++; if (*ptr == 0) { // This is an empty area keyboard_keys[layoutindex - 1][rowindex - 1][keyindex - 1].key = 0; } else if (strlen(ptr) == 1) { // This is the character that this key uses keyboard_keys[layoutindex - 1][rowindex - 1][keyindex - 1].key = *ptr; } else if (*ptr == 'c') { // This is an ASCII character code keyitem = ptr + 2; strcpy(foratoi, keyitem); keyboard_keys[layoutindex - 1][rowindex - 1][keyindex - 1].key = atoi(foratoi); } else if (*ptr == 'l') { // This is a different layout keyitem = ptr + 6; keyboard_keys[layoutindex - 1][rowindex - 1][keyindex - 1].key = KEYBOARD_LAYOUT; strcpy(foratoi, keyitem); keyboard_keys[layoutindex - 1][rowindex - 1][keyindex - 1].layout = atoi(foratoi); } else if (*ptr == 'a') { // This is an action keyboard_keys[layoutindex - 1][rowindex - 1][keyindex - 1].key = KEYBOARD_ACTION; } else LOGERR("Invalid key info on layout%i, row%i, key%02i.\n", layoutindex, rowindex, keyindex); } // PROCESS LONG PRESS INFO IF EXISTS sprintf(longpress, "long%02i", keyindex); attr = keyrow->first_attribute(longpress); if (attr) { stratt = attr->value(); if (strlen(stratt.c_str()) >= 255) { LOGERR("Key info on layout%i, row%i, key%dd is too long.\n", layoutindex, rowindex, keyindex); return; } strcpy(keyinfo, stratt.c_str()); if (strlen(keyinfo) == 0) { LOGERR("No long press info on layout%i, row%i, long%dd.\n", layoutindex, rowindex, keyindex); return; } if (strlen(keyinfo) == 1) { // This is a single key, simple definition keyboard_keys[layoutindex - 1][rowindex - 1][keyindex - 1].longpresskey = keyinfo[0]; } else { // This key has extra data char* ptr; char* offset; char* keyitem; char foratoi[10]; ptr = keyinfo; offset = keyinfo; while (*ptr > 32 && *ptr != ':') ptr++; if (*ptr != 0) *ptr = 0; strcpy(foratoi, offset); Xindex += atoi(foratoi); ptr++; if (*ptr == 0) { // This is an empty area keyboard_keys[layoutindex - 1][rowindex - 1][keyindex - 1].longpresskey = 0; } else if (strlen(ptr) == 1) { // This is the character that this key uses keyboard_keys[layoutindex - 1][rowindex - 1][keyindex - 1].longpresskey = *ptr; } else if (*ptr == 'c') { // This is an ASCII character code keyitem = ptr + 2; strcpy(foratoi, keyitem); keyboard_keys[layoutindex - 1][rowindex - 1][keyindex - 1].longpresskey = atoi(foratoi); } else if (*ptr == 'l') { // This is a different layout keyitem = ptr + 6; keyboard_keys[layoutindex - 1][rowindex - 1][keyindex - 1].longpresskey = KEYBOARD_LAYOUT; strcpy(foratoi, keyitem); keyboard_keys[layoutindex - 1][rowindex - 1][keyindex - 1].layout = atoi(foratoi); } else if (*ptr == 'a') { // This is an action keyboard_keys[layoutindex - 1][rowindex - 1][keyindex - 1].longpresskey = KEYBOARD_ACTION; } else LOGERR("Invalid long press key info on layout%i, row%i, long%02i.\n", layoutindex, rowindex, keyindex); } } keyindex++; sprintf(key, "key%02i", keyindex); attr = keyrow->first_attribute(key); } rowindex++; row[3] = (char)(rowindex + 48); keyrow = keylayout->first_node(row); } layoutindex++; layout[6] = (char)(layoutindex + 48); keylayout = node->first_node(layout); } int x, y, w, h; // Load the placement LoadPlacement(node->first_node("placement"), &x, &y, &w, &h); SetActionPos(x, y, KeyboardWidth, KeyboardHeight); SetRenderPos(x, y, w, h); return; }
// Redraw everything on the screen. Does not flip pages. // Should only be called with gUpdateMutex locked. void draw_screen_locked(void) { if (!ui_has_initialized) return; #ifdef BUILD_IN_LANDSCAPE //In this case MENU_SELECT icon has maximum possible height. int menu_max_height = gr_get_height(gMenuIcon[MENU_SELECT]); struct { int x; int y; } MENU_ICON[] = { { gr_fb_width() - menu_max_height, 7*gr_fb_height()/8 }, { gr_fb_width() - menu_max_height, 5*gr_fb_height()/8 }, { gr_fb_width() - menu_max_height, 3*gr_fb_height()/8 }, { gr_fb_width() - menu_max_height, 1*gr_fb_height()/8 }, #else //ToDo: Following structure should be global struct { int x; int y; int xL; int xR; } MENU_ICON[] = { { get_menu_icon_info(MENU_BACK,MENU_ICON_X), get_menu_icon_info(MENU_BACK,MENU_ICON_Y), get_menu_icon_info(MENU_BACK,MENU_ICON_XL), get_menu_icon_info(MENU_BACK,MENU_ICON_XR) }, { get_menu_icon_info(MENU_DOWN,MENU_ICON_X), get_menu_icon_info(MENU_DOWN,MENU_ICON_Y), get_menu_icon_info(MENU_DOWN,MENU_ICON_XL), get_menu_icon_info(MENU_DOWN,MENU_ICON_XR) }, { get_menu_icon_info(MENU_UP,MENU_ICON_X), get_menu_icon_info(MENU_UP,MENU_ICON_Y), get_menu_icon_info(MENU_UP,MENU_ICON_XL), get_menu_icon_info(MENU_UP,MENU_ICON_XR) }, { get_menu_icon_info(MENU_SELECT,MENU_ICON_X), get_menu_icon_info(MENU_SELECT,MENU_ICON_Y), get_menu_icon_info(MENU_SELECT,MENU_ICON_XL), get_menu_icon_info(MENU_SELECT,MENU_ICON_XR) }, #endif }; draw_background_locked(gCurrentIcon); draw_progress_locked(); if (show_text) { gr_color(0, 0, 0, 160); gr_fill(0, 0, gr_fb_width(), gr_fb_height()); int total_rows = gr_fb_height() / CHAR_HEIGHT+1; int i = 0; int j = 0; int row = 0; // current row that we are drawing on if (show_menu) { draw_icon_locked(gMenuIcon[MENU_BACK], MENU_ICON[MENU_BACK].x, MENU_ICON[MENU_BACK].y ); draw_icon_locked(gMenuIcon[MENU_DOWN], MENU_ICON[MENU_DOWN].x, MENU_ICON[MENU_DOWN].y); draw_icon_locked(gMenuIcon[MENU_UP], MENU_ICON[MENU_UP].x, MENU_ICON[MENU_UP].y ); draw_icon_locked(gMenuIcon[MENU_SELECT], MENU_ICON[MENU_SELECT].x, MENU_ICON[MENU_SELECT].y ); // Setup our text colors gr_color(UICOLOR0, UICOLOR1, UICOLOR2, 255); gr_color(UICOLOR0, UICOLOR1, UICOLOR2, 255); gr_fill(0, (menu_top + menu_sel - menu_show_start) * CHAR_HEIGHT, #ifdef BUILD_IN_LANDSCAPE gr_fb_width()-menu_max_height*2, (menu_top + menu_sel - menu_show_start + 1)*CHAR_HEIGHT+1); #else gr_fb_width(), (menu_top + menu_sel - menu_show_start + 1)*CHAR_HEIGHT+1); #endif gr_color(HEADER_TEXT_COLOR); for (i = 0; i < menu_top; ++i) { draw_text_line(i, menu[i], LEFT_ALIGN); row++; } if (menu_items - menu_show_start + menu_top >= MAX_ROWS) j = MAX_ROWS - menu_top; else j = menu_items - menu_show_start; gr_color(UICOLOR0, UICOLOR1, UICOLOR2, 255); for (i = menu_show_start + menu_top; i < (menu_show_start + menu_top + j); ++i) { if (i == menu_top + menu_sel) { gr_color(255, 255, 255, 255); draw_text_line(i - menu_show_start , menu[i], LEFT_ALIGN); gr_color(UICOLOR0, UICOLOR1, UICOLOR2, 255); } else { gr_color(UICOLOR0, UICOLOR1, UICOLOR2, 255); draw_text_line(i - menu_show_start, menu[i], LEFT_ALIGN); } row++; if (row >= max_menu_rows) break; } gr_fill(0, row*CHAR_HEIGHT+CHAR_HEIGHT/2-1, #ifdef BUILD_IN_LANDSCAPE gr_fb_width()-menu_max_height*2, row*CHAR_HEIGHT+CHAR_HEIGHT/2+1); #else gr_fb_width(), row*CHAR_HEIGHT+CHAR_HEIGHT/2+1); #endif } gr_color(NORMAL_TEXT_COLOR); for (; row < text_rows; ++row) { draw_text_line(row + 1, text[(row+text_top) % text_rows], LEFT_ALIGN); } } }
// Scale image function int res_scale_surface(gr_surface source, gr_surface* destination, float scale_w, float scale_h) { GGLContext *gl = NULL; GGLSurface* sc_mem_surface = NULL; *destination = NULL; GGLSurface *surface = (GGLSurface*)source; int w = gr_get_width(source), h = gr_get_height(source); int sx = 0, sy = 0, dx = 0, dy = 0; float dw = (float)w * scale_w; float dh = (float)h * scale_h; // Create a new surface that is the appropriate size sc_mem_surface = init_display_surface((int)dw, (int)dh); if (!sc_mem_surface) { printf("gr_scale_surface failed to init_display_surface\n"); return -1; } sc_mem_surface->format = surface->format; // Initialize the context gglInit(&gl); gl->colorBuffer(gl, sc_mem_surface); gl->activeTexture(gl, 0); // Enable or disable blending based on source surface format if (surface->format == GGL_PIXEL_FORMAT_RGBX_8888) { gl->disable(gl, GGL_BLEND); } else { gl->enable(gl, GGL_BLEND); gl->blendFunc(gl, GGL_ONE, GGL_ZERO); } // Bind our source surface to the context gl->bindTexture(gl, surface); // Deal with the scaling gl->texParameteri(gl, GGL_TEXTURE_2D, GGL_TEXTURE_MIN_FILTER, GGL_LINEAR); gl->texParameteri(gl, GGL_TEXTURE_2D, GGL_TEXTURE_MAG_FILTER, GGL_LINEAR); gl->texParameteri(gl, GGL_TEXTURE_2D, GGL_TEXTURE_WRAP_S, GGL_CLAMP); gl->texParameteri(gl, GGL_TEXTURE_2D, GGL_TEXTURE_WRAP_T, GGL_CLAMP); gl->texEnvi(gl, GGL_TEXTURE_ENV, GGL_TEXTURE_ENV_MODE, GGL_REPLACE); gl->texGeni(gl, GGL_S, GGL_TEXTURE_GEN_MODE, GGL_AUTOMATIC); gl->texGeni(gl, GGL_T, GGL_TEXTURE_GEN_MODE, GGL_AUTOMATIC); gl->enable(gl, GGL_TEXTURE_2D); int32_t grad[8]; memset(grad, 0, sizeof(grad)); // s, dsdx, dsdy, scale, t, dtdx, dtdy, tscale <- this is wrong! // This api uses block floating-point for S and T texture coordinates. // All values are given in 16.16, scaled by 'scale'. In other words, // set scale to 0, for 16.16 values. // s, dsdx, dsdy, t, dtdx, dtdy, sscale, tscale float dsdx = (float)w / dw; float dtdy = (float)h / dh; grad[0] = ((float)sx - (dsdx * dx)) * 65536; grad[1] = dsdx * 65536; grad[3] = ((float)sy - (dtdy * dy)) * 65536; grad[5] = dtdy * 65536; // printf("blit: w=%d h=%d dx=%d dy=%d dw=%f dh=%f dsdx=%f dtdy=%f s0=%x dsdx=%x t0=%x dtdy=%x\n", // w, h, dx, dy, dw, dh, dsdx, dtdy, grad[0], grad[1], grad[3], grad[5]); gl->texCoordGradScale8xv(gl, 0 /*tmu*/, grad); // draw / scale the source surface to our target context gl->recti(gl, dx, dy, dx + dw, dy + dh); gglUninit(gl); gl = NULL; // put the scaled surface in our destination *destination = (gr_surface*) sc_mem_surface; // free memory used in the source res_free_surface(source); source = NULL; return 0; }
GUIPartitionList::GUIPartitionList(xml_node<>* node) : GUIObject(node) { xml_attribute<>* attr; xml_node<>* child; int header_separator_color_specified = 0, header_separator_height_specified = 0, header_text_color_specified = 0, header_background_color_specified = 0; mStart = mLineSpacing = startY = mFontHeight = mSeparatorH = scrollingY = scrollingSpeed = 0; mIconWidth = mIconHeight = mSelectedIconHeight = mSelectedIconWidth = mUnselectedIconHeight = mUnselectedIconWidth = mHeaderIconHeight = mHeaderIconWidth = 0; mHeaderSeparatorH = mLineHeight = mHeaderIsStatic = mHeaderH = actualLineHeight = 0; mIconSelected = mIconUnselected = mBackground = mFont = mHeaderIcon = NULL; mBackgroundX = mBackgroundY = mBackgroundW = mBackgroundH = 0; mFastScrollW = mFastScrollLineW = mFastScrollRectW = mFastScrollRectH = 0; mFastScrollRectX = mFastScrollRectY = -1; mUpdate = 0; touchDebounce = 6; ConvertStrToColor("black", &mBackgroundColor); ConvertStrToColor("black", &mHeaderBackgroundColor); ConvertStrToColor("black", &mSeparatorColor); ConvertStrToColor("black", &mHeaderSeparatorColor); ConvertStrToColor("white", &mFontColor); ConvertStrToColor("white", &mHeaderFontColor); ConvertStrToColor("white", &mFastScrollLineColor); ConvertStrToColor("white", &mFastScrollRectColor); hasHighlightColor = false; hasFontHighlightColor = false; isHighlighted = false; updateList = false; startSelection = -1; // Load header text child = node->first_node("header"); if (child) { attr = child->first_attribute("icon"); if (attr) mHeaderIcon = PageManager::FindResource(attr->value()); attr = child->first_attribute("background"); if (attr) { std::string color = attr->value(); ConvertStrToColor(color, &mHeaderBackgroundColor); header_background_color_specified = -1; } attr = child->first_attribute("textcolor"); if (attr) { std::string color = attr->value(); ConvertStrToColor(color, &mHeaderFontColor); header_text_color_specified = -1; } attr = child->first_attribute("separatorcolor"); if (attr) { std::string color = attr->value(); ConvertStrToColor(color, &mHeaderSeparatorColor); header_separator_color_specified = -1; } attr = child->first_attribute("separatorheight"); if (attr) { string parsevalue = gui_parse_text(attr->value()); mHeaderSeparatorH = atoi(parsevalue.c_str()); header_separator_height_specified = -1; } } child = node->first_node("text"); if (child) mHeaderText = child->value(); memset(&mHighlightColor, 0, sizeof(COLOR)); child = node->first_node("highlight"); if (child) { attr = child->first_attribute("color"); if (attr) { hasHighlightColor = true; std::string color = attr->value(); ConvertStrToColor(color, &mHighlightColor); } } // Simple way to check for static state mLastValue = gui_parse_text(mHeaderText); if (mLastValue != mHeaderText) mHeaderIsStatic = 0; else mHeaderIsStatic = -1; child = node->first_node("icon"); if (child) { attr = child->first_attribute("selected"); if (attr) mIconSelected = PageManager::FindResource(attr->value()); attr = child->first_attribute("unselected"); if (attr) mIconUnselected = PageManager::FindResource(attr->value()); } child = node->first_node("background"); if (child) { attr = child->first_attribute("resource"); if (attr) mBackground = PageManager::FindResource(attr->value()); attr = child->first_attribute("color"); if (attr) { std::string color = attr->value(); ConvertStrToColor(color, &mBackgroundColor); if (!header_background_color_specified) ConvertStrToColor(color, &mHeaderBackgroundColor); } } // Load the placement LoadPlacement(node->first_node("placement"), &mRenderX, &mRenderY, &mRenderW, &mRenderH); SetActionPos(mRenderX, mRenderY, mRenderW, mRenderH); // Load the font, and possibly override the color child = node->first_node("font"); if (child) { attr = child->first_attribute("resource"); if (attr) mFont = PageManager::FindResource(attr->value()); attr = child->first_attribute("color"); if (attr) { std::string color = attr->value(); ConvertStrToColor(color, &mFontColor); if (!header_text_color_specified) ConvertStrToColor(color, &mHeaderFontColor); } attr = child->first_attribute("spacing"); if (attr) { string parsevalue = gui_parse_text(attr->value()); mLineSpacing = atoi(parsevalue.c_str()); } attr = child->first_attribute("highlightcolor"); memset(&mFontHighlightColor, 0, sizeof(COLOR)); if (attr) { std::string color = attr->value(); ConvertStrToColor(color, &mFontHighlightColor); hasFontHighlightColor = true; } } // Load the separator if it exists child = node->first_node("separator"); if (child) { attr = child->first_attribute("color"); if (attr) { std::string color = attr->value(); ConvertStrToColor(color, &mSeparatorColor); if (!header_separator_color_specified) ConvertStrToColor(color, &mHeaderSeparatorColor); } attr = child->first_attribute("height"); if (attr) { string parsevalue = gui_parse_text(attr->value()); mSeparatorH = atoi(parsevalue.c_str()); if (!header_separator_height_specified) mHeaderSeparatorH = mSeparatorH; } } // Handle the result variable child = node->first_node("data"); if (child) { attr = child->first_attribute("name"); if (attr) mVariable = attr->value(); attr = child->first_attribute("selectedlist"); if (attr) selectedList = attr->value(); } // Fast scroll colors child = node->first_node("fastscroll"); if (child) { attr = child->first_attribute("linecolor"); if(attr) ConvertStrToColor(attr->value(), &mFastScrollLineColor); attr = child->first_attribute("rectcolor"); if(attr) ConvertStrToColor(attr->value(), &mFastScrollRectColor); attr = child->first_attribute("w"); if (attr) { string parsevalue = gui_parse_text(attr->value()); mFastScrollW = atoi(parsevalue.c_str()); } attr = child->first_attribute("linew"); if (attr) { string parsevalue = gui_parse_text(attr->value()); mFastScrollLineW = atoi(parsevalue.c_str()); } attr = child->first_attribute("rectw"); if (attr) { string parsevalue = gui_parse_text(attr->value()); mFastScrollRectW = atoi(parsevalue.c_str()); } attr = child->first_attribute("recth"); if (attr) { string parsevalue = gui_parse_text(attr->value()); mFastScrollRectH = atoi(parsevalue.c_str()); } } // Retrieve the line height gr_getFontDetails(mFont ? mFont->GetResource() : NULL, &mFontHeight, NULL); mLineHeight = mFontHeight; mHeaderH = mFontHeight; if (mIconSelected && mIconSelected->GetResource()) { mSelectedIconWidth = gr_get_width(mIconSelected->GetResource()); mSelectedIconHeight = gr_get_height(mIconSelected->GetResource()); if (mSelectedIconHeight > (int)mLineHeight) mLineHeight = mSelectedIconHeight; mIconWidth = mSelectedIconWidth; } if (mIconUnselected && mIconUnselected->GetResource()) { mUnselectedIconWidth = gr_get_width(mIconUnselected->GetResource()); mUnselectedIconHeight = gr_get_height(mIconUnselected->GetResource()); if (mUnselectedIconHeight > (int)mLineHeight) mLineHeight = mUnselectedIconHeight; if (mUnselectedIconWidth > mIconWidth) mIconWidth = mUnselectedIconWidth; } if (mHeaderIcon && mHeaderIcon->GetResource()) { mHeaderIconWidth = gr_get_width(mHeaderIcon->GetResource()); mHeaderIconHeight = gr_get_height(mHeaderIcon->GetResource()); if (mHeaderIconHeight > mHeaderH) mHeaderH = mHeaderIconHeight; if (mHeaderIconWidth > mIconWidth) mIconWidth = mHeaderIconWidth; } mHeaderH += mLineSpacing + mHeaderSeparatorH; actualLineHeight = mLineHeight + mLineSpacing + mSeparatorH; if (mHeaderH < actualLineHeight) mHeaderH = actualLineHeight; if (actualLineHeight / 3 > 6) touchDebounce = actualLineHeight / 3; if (mBackground && mBackground->GetResource()) { mBackgroundW = gr_get_width(mBackground->GetResource()); mBackgroundH = gr_get_height(mBackground->GetResource()); } child = node->first_node("listtype"); if (child) { attr = child->first_attribute("name"); if (attr) { ListType = attr->value(); PartitionManager.Get_Partition_List(ListType, &mList); } else { mList.clear(); LOGERR("No partition listtype name specified for partitionlist GUI element\n"); return; } } else { mList.clear(); LOGERR("No partition listtype specified for partitionlist GUI element\n"); return; } }
int GetHeight() { return gr_get_height(this ? GetResource() : NULL); }
int GetHeight() { return gr_get_height(this ? mSurface : NULL); }
static void draw_check(){ gr_blit(keyboards,CHECK_X,CHECK_Y,gr_get_width(checkmark),gr_get_height(checkmark), CHECK_X, CHECK_Y); if(checked){ gr_blit(checkmark,0,0,gr_get_width(checkmark),gr_get_height(checkmark), CHECK_X, CHECK_Y ); } }
GUIListBox::GUIListBox(xml_node<>* node) : Conditional(node) { xml_attribute<>* attr; xml_node<>* child; int header_separator_color_specified = 0, header_separator_height_specified = 0, header_text_color_specified = 0, header_background_color_specified = 0; mStart = mLineSpacing = startY = mFontHeight = mSeparatorH = scrollingY = scrollingSpeed = 0; mIconWidth = mIconHeight = mSelectedIconHeight = mSelectedIconWidth = mUnselectedIconHeight = mUnselectedIconWidth = mHeaderIconHeight = mHeaderIconWidth = 0; mHeaderSeparatorH = mLineHeight = mHeaderIsStatic = mHeaderH = actualLineHeight = 0; mIconSelected = mIconUnselected = mBackground = mFont = mHeaderIcon = NULL; mBackgroundX = mBackgroundY = mBackgroundW = mBackgroundH = 0; mFastScrollW = mFastScrollLineW = mFastScrollRectW = mFastScrollRectH = 0; mFastScrollRectX = mFastScrollRectY = -1; mUpdate = 0; touchDebounce = 6; ConvertStrToColor("black", &mBackgroundColor); ConvertStrToColor("black", &mHeaderBackgroundColor); ConvertStrToColor("black", &mSeparatorColor); ConvertStrToColor("black", &mHeaderSeparatorColor); ConvertStrToColor("white", &mFontColor); ConvertStrToColor("white", &mHeaderFontColor); ConvertStrToColor("white", &mFastScrollLineColor); ConvertStrToColor("white", &mFastScrollRectColor); hasHighlightColor = false; hasFontHighlightColor = false; isHighlighted = false; startSelection = -1; // Load header text child = node->first_node("header"); if (child) { attr = child->first_attribute("icon"); if (attr) mHeaderIcon = PageManager::FindResource(attr->value()); attr = child->first_attribute("background"); if (attr) { std::string color = attr->value(); ConvertStrToColor(color, &mHeaderBackgroundColor); header_background_color_specified = -1; } attr = child->first_attribute("textcolor"); if (attr) { std::string color = attr->value(); ConvertStrToColor(color, &mHeaderFontColor); header_text_color_specified = -1; } attr = child->first_attribute("separatorcolor"); if (attr) { std::string color = attr->value(); ConvertStrToColor(color, &mHeaderSeparatorColor); header_separator_color_specified = -1; } attr = child->first_attribute("separatorheight"); if (attr) { string parsevalue = gui_parse_text(attr->value()); mHeaderSeparatorH = atoi(parsevalue.c_str()); header_separator_height_specified = -1; } } child = node->first_node("text"); if (child) mHeaderText = child->value(); memset(&mHighlightColor, 0, sizeof(COLOR)); child = node->first_node("highlight"); if (child) { attr = child->first_attribute("color"); if (attr) { hasHighlightColor = true; std::string color = attr->value(); ConvertStrToColor(color, &mHighlightColor); } } // Simple way to check for static state mLastValue = gui_parse_text(mHeaderText); if (mLastValue != mHeaderText) mHeaderIsStatic = 0; else mHeaderIsStatic = -1; child = node->first_node("icon"); if (child) { attr = child->first_attribute("selected"); if (attr) mIconSelected = PageManager::FindResource(attr->value()); attr = child->first_attribute("unselected"); if (attr) mIconUnselected = PageManager::FindResource(attr->value()); } child = node->first_node("background"); if (child) { attr = child->first_attribute("resource"); if (attr) mBackground = PageManager::FindResource(attr->value()); attr = child->first_attribute("color"); if (attr) { std::string color = attr->value(); ConvertStrToColor(color, &mBackgroundColor); if (!header_background_color_specified) ConvertStrToColor(color, &mHeaderBackgroundColor); } } // Load the placement LoadPlacement(node->first_node("placement"), &mRenderX, &mRenderY, &mRenderW, &mRenderH); SetActionPos(mRenderX, mRenderY, mRenderW, mRenderH); // Load the font, and possibly override the color child = node->first_node("font"); if (child) { attr = child->first_attribute("resource"); if (attr) mFont = PageManager::FindResource(attr->value()); attr = child->first_attribute("color"); if (attr) { std::string color = attr->value(); ConvertStrToColor(color, &mFontColor); if (!header_text_color_specified) ConvertStrToColor(color, &mHeaderFontColor); } attr = child->first_attribute("spacing"); if (attr) { string parsevalue = gui_parse_text(attr->value()); mLineSpacing = atoi(parsevalue.c_str()); } attr = child->first_attribute("highlightcolor"); memset(&mFontHighlightColor, 0, sizeof(COLOR)); if (attr) { std::string color = attr->value(); ConvertStrToColor(color, &mFontHighlightColor); hasFontHighlightColor = true; } } // Load the separator if it exists child = node->first_node("separator"); if (child) { attr = child->first_attribute("color"); if (attr) { std::string color = attr->value(); ConvertStrToColor(color, &mSeparatorColor); if (!header_separator_color_specified) ConvertStrToColor(color, &mHeaderSeparatorColor); } attr = child->first_attribute("height"); if (attr) { string parsevalue = gui_parse_text(attr->value()); mSeparatorH = atoi(parsevalue.c_str()); if (!header_separator_height_specified) mHeaderSeparatorH = mSeparatorH; } } // Handle the result variable child = node->first_node("data"); if (child) { attr = child->first_attribute("name"); if (attr) mVariable = attr->value(); attr = child->first_attribute("default"); if (attr) DataManager::SetValue(mVariable, attr->value()); } // Fast scroll colors child = node->first_node("fastscroll"); if (child) { attr = child->first_attribute("linecolor"); if(attr) ConvertStrToColor(attr->value(), &mFastScrollLineColor); attr = child->first_attribute("rectcolor"); if(attr) ConvertStrToColor(attr->value(), &mFastScrollRectColor); attr = child->first_attribute("w"); if (attr) { string parsevalue = gui_parse_text(attr->value()); mFastScrollW = atoi(parsevalue.c_str()); } attr = child->first_attribute("linew"); if (attr) { string parsevalue = gui_parse_text(attr->value()); mFastScrollLineW = atoi(parsevalue.c_str()); } attr = child->first_attribute("rectw"); if (attr) { string parsevalue = gui_parse_text(attr->value()); mFastScrollRectW = atoi(parsevalue.c_str()); } attr = child->first_attribute("recth"); if (attr) { string parsevalue = gui_parse_text(attr->value()); mFastScrollRectH = atoi(parsevalue.c_str()); } } // Retrieve the line height gr_getFontDetails(mFont ? mFont->GetResource() : NULL, &mFontHeight, NULL); mLineHeight = mFontHeight; mHeaderH = mFontHeight; if (mIconSelected && mIconSelected->GetResource()) { mSelectedIconWidth = gr_get_width(mIconSelected->GetResource()); mSelectedIconHeight = gr_get_height(mIconSelected->GetResource()); if (mSelectedIconHeight > (int)mLineHeight) mLineHeight = mSelectedIconHeight; mIconWidth = mSelectedIconWidth; } if (mIconUnselected && mIconUnselected->GetResource()) { mUnselectedIconWidth = gr_get_width(mIconUnselected->GetResource()); mUnselectedIconHeight = gr_get_height(mIconUnselected->GetResource()); if (mUnselectedIconHeight > (int)mLineHeight) mLineHeight = mUnselectedIconHeight; if (mUnselectedIconWidth > mIconWidth) mIconWidth = mUnselectedIconWidth; } if (mHeaderIcon && mHeaderIcon->GetResource()) { mHeaderIconWidth = gr_get_width(mHeaderIcon->GetResource()); mHeaderIconHeight = gr_get_height(mHeaderIcon->GetResource()); if (mHeaderIconHeight > mHeaderH) mHeaderH = mHeaderIconHeight; if (mHeaderIconWidth > mIconWidth) mIconWidth = mHeaderIconWidth; } mHeaderH += mLineSpacing + mHeaderSeparatorH; actualLineHeight = mLineHeight + mLineSpacing + mSeparatorH; if (mHeaderH < actualLineHeight) mHeaderH = actualLineHeight; if (actualLineHeight / 3 > 6) touchDebounce = actualLineHeight / 3; if (mBackground && mBackground->GetResource()) { mBackgroundW = gr_get_width(mBackground->GetResource()); mBackgroundH = gr_get_height(mBackground->GetResource()); } // Get the currently selected value for the list DataManager::GetValue(mVariable, currentValue); // Get the data for the list child = node->first_node("listitem"); while (child) { ListData data; attr = child->first_attribute("name"); if (!attr) return; data.displayName = attr->value(); data.variableValue = child->value(); if (child->value() == currentValue) { data.selected = 1; } else { data.selected = 0; } mList.push_back(data); child = child->next_sibling("listitem"); } // Load dynamic data child = node->first_node("items"); if (child) mItemsVar = child->value(); // Call this to get the selected item to be shown in the list on first render NotifyVarChange(mVariable, currentValue); if(!mItemsVar.empty()) NotifyVarChange(mItemsVar, DataManager::GetStrValue(mItemsVar)); }
int ScreenRecoveryUI::GetProgressBaseline() { return gr_fb_height() - PixelsFromDp(is_large_ ? 340 : 194) - gr_get_height(progressBarFill); }
int ScreenRecoveryUI::GetTextBaseline() { return GetProgressBaseline() - PixelsFromDp(32) - gr_get_height(installing_text); }
int ScreenRecoveryUI::GetAnimationBaseline() { return GetTextBaseline() - PixelsFromDp(68) - gr_get_height(loopFrames[0]); }
void ui_init(void) { ui_has_initialized = 1; gr_init(); ev_init(input_callback, NULL); text_col = text_row = 0; text_rows = gr_fb_height() / CHAR_HEIGHT; max_menu_rows = text_rows - MIN_LOG_ROWS; if (max_menu_rows > MENU_MAX_ROWS) max_menu_rows = MENU_MAX_ROWS; if (text_rows > MAX_ROWS) text_rows = MAX_ROWS; text_top = 1; text_cols = gr_fb_width() / CHAR_WIDTH; if (text_cols > MAX_COLS - 1) text_cols = MAX_COLS - 1; int i; for (i = 0; BITMAPS[i].name != NULL; ++i) { int result = res_create_surface(BITMAPS[i].name, BITMAPS[i].surface); if (result < 0) { LOGE("Missing bitmap %s\n(Code %d)\n", BITMAPS[i].name, result); } } gProgressBarIndeterminate = malloc(ui_parameters.indeterminate_frames * sizeof(gr_surface)); for (i = 0; i < ui_parameters.indeterminate_frames; ++i) { char filename[40]; // "indeterminate01.png", "indeterminate02.png", ... sprintf(filename, "indeterminate%02d", i+1); int result = res_create_surface(filename, gProgressBarIndeterminate+i); if (result < 0) { LOGE("Missing bitmap %s\n(Code %d)\n", filename, result); } } if (ui_parameters.installing_frames > 0) { gInstallationOverlay = malloc(ui_parameters.installing_frames * sizeof(gr_surface)); for (i = 0; i < ui_parameters.installing_frames; ++i) { char filename[40]; // "icon_installing_overlay01.png", // "icon_installing_overlay02.png", ... sprintf(filename, "icon_installing_overlay%02d", i+1); int result = res_create_surface(filename, gInstallationOverlay+i); if (result < 0) { LOGE("Missing bitmap %s\n(Code %d)\n", filename, result); } } // Adjust the offset to account for the positioning of the // base image on the screen. if (gBackgroundIcon[BACKGROUND_ICON_INSTALLING] != NULL) { gr_surface bg = gBackgroundIcon[BACKGROUND_ICON_INSTALLING]; ui_parameters.install_overlay_offset_x += (gr_fb_width() - gr_get_width(bg)) / 2; ui_parameters.install_overlay_offset_y += (gr_fb_height() - gr_get_height(bg)) / 2; } } else { gInstallationOverlay = NULL; } pthread_t t; pthread_create(&t, NULL, progress_thread, NULL); pthread_create(&t, NULL, input_thread, NULL); }
// Redraw everything on the screen. Does not flip pages. // Should only be called with gUpdateMutex locked. static void draw_screen_locked(void) { if (!ui_has_initialized) return; //In this case MENU_SELECT icon has maximum possible height. int menu_max_height = gr_get_height(gMenuIcon[MENU_SELECT]); struct { int x; int y; } MENU_ICON[] = { { gr_fb_width() - menu_max_height, 7*gr_fb_height()/8 }, { gr_fb_width() - menu_max_height, 5*gr_fb_height()/8 }, { gr_fb_width() - menu_max_height, 3*gr_fb_height()/8 }, { gr_fb_width() - menu_max_height, 1*gr_fb_height()/8 }, }; draw_background_locked(gCurrentIcon); draw_progress_locked(); if (show_text) { gr_color(0, 0, 0, 160); gr_fill(0, 0, gr_fb_width(), gr_fb_height()); int i = 0; int j = 0; int row = 0; // current row that we are drawing on if (show_menu) { draw_icon_locked(gMenuIcon[MENU_BACK], MENU_ICON[MENU_BACK].x, MENU_ICON[MENU_BACK].y ); draw_icon_locked(gMenuIcon[MENU_DOWN], MENU_ICON[MENU_DOWN].x, MENU_ICON[MENU_DOWN].y); draw_icon_locked(gMenuIcon[MENU_UP], MENU_ICON[MENU_UP].x, MENU_ICON[MENU_UP].y ); draw_icon_locked(gMenuIcon[MENU_SELECT], MENU_ICON[MENU_SELECT].x, MENU_ICON[MENU_SELECT].y ); gr_color(MENU_TEXT_COLOR); gr_fill(0, (menu_top + menu_sel - menu_show_start) * CHAR_HEIGHT, gr_fb_width()-menu_max_height*2, (menu_top + menu_sel - menu_show_start + 1)*CHAR_HEIGHT+1); gr_color(HEADER_TEXT_COLOR); for (i = 0; i < menu_top; ++i) { draw_text_line(i, menu[i]); row++; } if (menu_items - menu_show_start + menu_top >= MAX_ROWS) j = MAX_ROWS - menu_top; else j = menu_items - menu_show_start; gr_color(MENU_TEXT_COLOR); for (i = menu_show_start + menu_top; i < (menu_show_start + menu_top + j); ++i) { if (i == menu_top + menu_sel) { gr_color(255, 255, 255, 255); draw_text_line(i - menu_show_start , menu[i]); gr_color(MENU_TEXT_COLOR); } else { gr_color(MENU_TEXT_COLOR); draw_text_line(i - menu_show_start, menu[i]); } row++; } gr_fill(0, row*CHAR_HEIGHT+CHAR_HEIGHT/2-1, gr_fb_width()-menu_max_height*2, row*CHAR_HEIGHT+CHAR_HEIGHT/2+1); } gr_color(NORMAL_TEXT_COLOR); for (; row < text_rows; ++row) { draw_text_line(row, text[(row+text_top) % text_rows]); } } }
GUIInput::GUIInput(xml_node<>* node) : GUIObject(node) { xml_attribute<>* attr; xml_node<>* child; mInputText = NULL; mAction = NULL; mBackground = NULL; mCursor = NULL; mFont = NULL; mRendered = false; HasMask = false; DrawCursor = false; isLocalChange = true; HasAllowed = false; HasDisabled = false; skipChars = scrollingX = mFontHeight = mFontY = lastX = 0; mBackgroundX = mBackgroundY = mBackgroundW = mBackgroundH = MinLen = MaxLen = 0; mCursorLocation = -1; // -1 is always the end of the string CursorWidth = 3; ConvertStrToColor("black", &mBackgroundColor); ConvertStrToColor("white", &mCursorColor); if (!node) return; // Load text directly from the node mInputText = new GUIText(node); // Load action directly from the node mAction = new GUIAction(node); if (mInputText->Render() < 0) { delete mInputText; mInputText = NULL; } // Load the background child = node->first_node("background"); if (child) { attr = child->first_attribute("resource"); if (attr) mBackground = PageManager::FindResource(attr->value()); attr = child->first_attribute("color"); if (attr) { std::string color = attr->value(); ConvertStrToColor(color, &mBackgroundColor); } } if (mBackground && mBackground->GetResource()) { mBackgroundW = gr_get_width(mBackground->GetResource()); mBackgroundH = gr_get_height(mBackground->GetResource()); } // Load the cursor color child = node->first_node("cursor"); if (child) { attr = child->first_attribute("resource"); if (attr) mCursor = PageManager::FindResource(attr->value()); attr = child->first_attribute("color"); if (attr) { std::string color = attr->value(); ConvertStrToColor(color, &mCursorColor); } attr = child->first_attribute("hasfocus"); if (attr) { std::string color = attr->value(); SetInputFocus(atoi(color.c_str())); } attr = child->first_attribute("width"); if (attr) { std::string cwidth = gui_parse_text(attr->value()); CursorWidth = atoi(cwidth.c_str()); } } DrawCursor = HasInputFocus; // Load the font, and possibly override the color child = node->first_node("font"); if (child) { attr = child->first_attribute("resource"); if (attr) { mFont = PageManager::FindResource(attr->value()); mFontHeight = gr_getMaxFontHeight(mFont ? mFont->GetResource() : NULL); } } child = node->first_node("text"); if (child) mText = child->value(); mLastValue = gui_parse_text(mText); child = node->first_node("data"); if (child) { attr = child->first_attribute("name"); if (attr) mVariable = attr->value(); attr = child->first_attribute("default"); if (attr) DataManager::SetValue(mVariable, attr->value()); attr = child->first_attribute("mask"); if (attr) { mMask = attr->value(); HasMask = true; } attr = child->first_attribute("maskvariable"); if (attr) mMaskVariable = attr->value(); else mMaskVariable = mVariable; } // Load input restrictions child = node->first_node("restrict"); if (child) { attr = child->first_attribute("minlen"); if (attr) { std::string attrib = attr->value(); MinLen = atoi(attrib.c_str()); } attr = child->first_attribute("maxlen"); if (attr) { std::string attrib = attr->value(); MaxLen = atoi(attrib.c_str()); } attr = child->first_attribute("allow"); if (attr) { HasAllowed = true; AllowedList = attr->value(); } attr = child->first_attribute("disable"); if (attr) { HasDisabled = true; DisabledList = attr->value(); } } // Load the placement LoadPlacement(node->first_node("placement"), &mRenderX, &mRenderY, &mRenderW, &mRenderH); SetActionPos(mRenderX, mRenderY, mRenderW, mRenderH); if (mInputText && mFontHeight && mFontHeight < (unsigned)mRenderH) { mFontY = ((mRenderH - mFontHeight) / 2) + mRenderY; mInputText->SetRenderPos(mRenderX, mFontY); } else mFontY = mRenderY; if (mInputText) mInputText->SetMaxWidth(mRenderW); isLocalChange = false; HandleTextLocation(-3); }
// Redraw everything on the screen. Does not flip pages. // Should only be called with gUpdateMutex locked. static void draw_screen_locked(void) { if (!ui_has_initialized) return; draw_background_locked(gCurrentIcon); draw_progress_locked(); if (show_text) { // don't "disable" the background anymore with this... // gr_color(0, 0, 0, 160); // gr_fill(0, 0, gr_fb_width(), gr_fb_height()); gr_surface surface = gVirtualKeys; int total_rows = (gr_fb_height() / CHAR_HEIGHT) - (gr_get_height(surface) / CHAR_HEIGHT) - 1; int i = 0; int j = 0; int offset = 0; // offset of separating bar under menus int row = 0; // current row that we are drawing on if (show_menu) { gr_color(MENU_TEXT_COLOR); int batt_level = 0; batt_level = get_batt_stats(); if (batt_level < 21) { gr_color(255, 0, 0, 255); } char batt_text[40]; sprintf(batt_text, "[%d%%]", batt_level); draw_text_line(0, batt_text, RIGHT_ALIGN); gr_color(MENU_TEXT_COLOR); gr_fill(0, (menu_top + menu_sel - menu_show_start) * CHAR_HEIGHT, gr_fb_width(), (menu_top + menu_sel - menu_show_start + 1)*CHAR_HEIGHT+1); gr_color(HEADER_TEXT_COLOR); for (i = 0; i < menu_top; ++i) { draw_text_line(i, menu[i], LEFT_ALIGN); row++; } if (menu_items - menu_show_start + menu_top >= max_menu_rows) j = max_menu_rows - menu_top; else j = menu_items - menu_show_start; gr_color(MENU_TEXT_COLOR); for (i = menu_show_start + menu_top; i < (menu_show_start + menu_top + j); ++i) { if (i == menu_top + menu_sel) { gr_color(255, 255, 255, 255); draw_text_line(i - menu_show_start , menu[i], LEFT_ALIGN); gr_color(MENU_TEXT_COLOR); } else { gr_color(MENU_TEXT_COLOR); draw_text_line(i - menu_show_start, menu[i], LEFT_ALIGN); } row++; if (row >= max_menu_rows) break; } if (menu_items <= max_menu_rows) offset = 0; gr_fill(0, (row-offset)*CHAR_HEIGHT+CHAR_HEIGHT/2-1, gr_fb_width(), (row-offset)*CHAR_HEIGHT+CHAR_HEIGHT/2+1); } gr_color(NORMAL_TEXT_COLOR); int cur_row = text_row; int available_rows = total_rows - row - 1; int start_row = row + 1; if (available_rows < MAX_ROWS) cur_row = (cur_row + (MAX_ROWS - available_rows)) % MAX_ROWS; else start_row = total_rows - MAX_ROWS; int r; for (r = 0; r < (available_rows < MAX_ROWS ? available_rows : MAX_ROWS); r++) { draw_text_line(start_row + r, text[(cur_row + r) % MAX_ROWS], LEFT_ALIGN); } } draw_virtualkeys_locked(); //added to draw the virtual keys }
void ui_init(void) { ui_has_initialized = 1; gr_init(); ev_init(input_callback, NULL); #ifdef BOARD_TOUCH_RECOVERY touch_init(); #endif text_col = text_row = 0; text_rows = gr_fb_height() / CHAR_HEIGHT; max_menu_rows = text_rows - MIN_LOG_ROWS; #ifdef BOARD_TOUCH_RECOVERY max_menu_rows = get_max_menu_rows(max_menu_rows); #endif if (max_menu_rows > MENU_MAX_ROWS) max_menu_rows = MENU_MAX_ROWS; if (text_rows > MAX_ROWS) text_rows = MAX_ROWS; text_top = 1; text_cols = gr_fb_width() / CHAR_WIDTH; if (text_cols > MAX_COLS - 1) text_cols = MAX_COLS - 1; int i; for (i = 0; BITMAPS[i].name != NULL; ++i) { int result = res_create_surface(BITMAPS[i].name, BITMAPS[i].surface); if (result < 0) { LOGE("Missing bitmap %s\n(Code %d)\n", BITMAPS[i].name, result); } } gProgressBarIndeterminate = malloc(ui_parameters.indeterminate_frames * sizeof(gr_surface)); for (i = 0; i < ui_parameters.indeterminate_frames; ++i) { char filename[40]; // "indeterminate01.png", "indeterminate02.png", ... sprintf(filename, "indeterminate%02d", i+1); int result = res_create_surface(filename, gProgressBarIndeterminate+i); if (result < 0) { LOGE("Missing bitmap %s\n(Code %d)\n", filename, result); } } if (ui_parameters.installing_frames > 0) { gInstallationOverlay = malloc(ui_parameters.installing_frames * sizeof(gr_surface)); for (i = 0; i < ui_parameters.installing_frames; ++i) { char filename[40]; // "icon_installing_overlay01.png", // "icon_installing_overlay02.png", ... sprintf(filename, "icon_installing_overlay%02d", i+1); int result = res_create_surface(filename, gInstallationOverlay+i); if (result < 0) { LOGE("Missing bitmap %s\n(Code %d)\n", filename, result); } } // Adjust the offset to account for the positioning of the // base image on the screen. if (gBackgroundIcon[BACKGROUND_ICON_INSTALLING] != NULL) { gr_surface bg = gBackgroundIcon[BACKGROUND_ICON_INSTALLING]; ui_parameters.install_overlay_offset_x += (gr_fb_width() - gr_get_width(bg)) / 2; ui_parameters.install_overlay_offset_y += (gr_fb_height() - gr_get_height(bg)) / 2; } } else { gInstallationOverlay = NULL; } char enable_key_repeat[PROPERTY_VALUE_MAX]; property_get("ro.cwm.enable_key_repeat", enable_key_repeat, ""); if (!strcmp(enable_key_repeat, "true") || !strcmp(enable_key_repeat, "1")) { boardEnableKeyRepeat = 1; char key_list[PROPERTY_VALUE_MAX]; property_get("ro.cwm.repeatable_keys", key_list, ""); if (strlen(key_list) == 0) { boardRepeatableKeys[boardNumRepeatableKeys++] = KEY_UP; boardRepeatableKeys[boardNumRepeatableKeys++] = KEY_DOWN; boardRepeatableKeys[boardNumRepeatableKeys++] = KEY_VOLUMEUP; boardRepeatableKeys[boardNumRepeatableKeys++] = KEY_VOLUMEDOWN; } else { char *pch = strtok(key_list, ","); while (pch != NULL) { boardRepeatableKeys[boardNumRepeatableKeys++] = atoi(pch); pch = strtok(NULL, ","); } } } pthread_t t; pthread_create(&t, NULL, progress_thread, NULL); pthread_create(&t, NULL, input_thread, NULL); }
static int input_callback(int fd, short revents, void *data) { struct input_event ev; int ret; int fake_key = 0; gr_surface surface = gVirtualKeys; ret = ev_get_input(fd, revents, &ev); if (ret) return -1; #ifdef BOARD_TOUCH_RECOVERY if (touch_handle_input(fd, ev)) return 0; #endif if (ev.type == EV_SYN) { return 0; } else if (ev.type == EV_REL) { if (ev.code == REL_Y) { // accumulate the up or down motion reported by // the trackball. When it exceeds a threshold // (positive or negative), fake an up/down // key event. rel_sum += ev.value; if (rel_sum > 3) { fake_key = 1; ev.type = EV_KEY; ev.code = KEY_DOWN; ev.value = 1; rel_sum = 0; } else if (rel_sum < -3) { fake_key = 1; ev.type = EV_KEY; ev.code = KEY_UP; ev.value = 1; rel_sum = 0; } } } else { rel_sum = 0; } if (ev.type == 3 && ev.code == 48 && ev.value != 0) { if (in_touch == 0) { in_touch = 1; //starting to track touch... reset_gestures(); } } else if (ev.type == 3 && ev.code == 48 && ev.value == 0) { //finger lifted! lets run with this ev.type = EV_KEY; //touch panel support!!! int keywidth = gr_get_width(surface) / 4; int keyoffset = (gr_fb_width() - gr_get_width(surface)) / 2; if (touch_y > (gr_fb_height() - gr_get_height(surface)) && touch_x > 0) { //they lifted in the touch panel region if (touch_x < (keywidth + keyoffset)) { //down button ev.code = KEY_DOWN; reset_gestures(); } else if (touch_x < ((keywidth * 2) + keyoffset)) { //up button ev.code = KEY_UP; reset_gestures(); } else if (touch_x < ((keywidth * 3) + keyoffset)) { //back button ev.code = KEY_BACK; reset_gestures(); } else { //enter key ev.code = KEY_ENTER; reset_gestures(); } vibrate(VIBRATOR_TIME_MS); } if (slide_right == 1) { ev.code = KEY_ENTER; slide_right = 0; } else if (slide_left == 1) { ev.code = KEY_BACK; slide_left = 0; } ev.value = 1; in_touch = 0; reset_gestures(); } else if (ev.type == 3 && ev.code == 53) { old_x = touch_x; touch_x = ev.value; if (old_x != 0) diff_x += touch_x - old_x; if (touch_y < (gr_fb_height() - gr_get_height(surface))) { if (diff_x > (gr_fb_width() / 4)) { slide_right = 1; reset_gestures(); } else if(diff_x < ((gr_fb_width() / 4) * -1)) { slide_left = 1; reset_gestures(); } } else { input_buttons(); //reset_gestures(); } } else if (ev.type == 3 && ev.code == 54) { old_y = touch_y; touch_y = ev.value; if (old_y != 0) diff_y += touch_y - old_y; if (touch_y < (gr_fb_height() - gr_get_height(surface))) { if (diff_y > 25) { ev.code = KEY_DOWN; ev.type = EV_KEY; reset_gestures(); } else if (diff_y < -25) { ev.code = KEY_UP; ev.type = EV_KEY; reset_gestures(); } } else { input_buttons(); //reset_gestures(); } } if (ev.type != EV_KEY || ev.code > KEY_MAX) return 0; pthread_mutex_lock(&key_queue_mutex); if (!fake_key) { // our "fake" keys only report a key-down event (no // key-up), so don't record them in the key_pressed // table. key_pressed[ev.code] = ev.value; } const int queue_max = sizeof(key_queue) / sizeof(key_queue[0]); if (ev.value > 0 && key_queue_len < queue_max) { key_queue[key_queue_len++] = ev.code; if (boardEnableKeyRepeat) { struct timeval now; gettimeofday(&now, NULL); key_press_time[ev.code] = (now.tv_sec * 1000) + (now.tv_usec / 1000); key_last_repeat[ev.code] = 0; } pthread_cond_signal(&key_queue_cond); } pthread_mutex_unlock(&key_queue_mutex); if (ev.value > 0 && device_toggle_display(key_pressed, ev.code)) { pthread_mutex_lock(&gUpdateMutex); show_text = !show_text; if (show_text) show_text_ever = 1; update_screen_locked(); pthread_mutex_unlock(&gUpdateMutex); } if (ev.value > 0 && device_reboot_now(key_pressed, ev.code)) { android_reboot(ANDROID_RB_RESTART, 0, 0); } return 0; }
GUIConsole::GUIConsole(xml_node<>* node) { xml_attribute<>* attr; xml_node<>* child; mFont = NULL; mCurrentLine = -1; memset(&mForegroundColor, 255, sizeof(COLOR)); memset(&mBackgroundColor, 0, sizeof(COLOR)); mBackgroundColor.alpha = 255; memset(&mScrollColor, 0x08, sizeof(COLOR)); mScrollColor.alpha = 255; mLastCount = 0; mSlideout = 0; mSlideoutState = hidden; mRenderX = 0; mRenderY = 0; mRenderW = gr_fb_width(); mRenderH = gr_fb_height(); if (!node) { mSlideoutX = 0; mSlideoutY = 0; mSlideoutW = 0; mSlideoutH = 0; mConsoleX = 0; mConsoleY = 0; mConsoleW = gr_fb_width(); mConsoleH = gr_fb_height(); } else { child = node->first_node("font"); if (child) { attr = child->first_attribute("resource"); if (attr) mFont = PageManager::FindResource(attr->value()); } child = node->first_node("color"); if (child) { attr = child->first_attribute("foreground"); if (attr) { std::string color = attr->value(); ConvertStrToColor(color, &mForegroundColor); } attr = child->first_attribute("background"); if (attr) { std::string color = attr->value(); ConvertStrToColor(color, &mBackgroundColor); } attr = child->first_attribute("scroll"); if (attr) { std::string color = attr->value(); ConvertStrToColor(color, &mScrollColor); } } // Load the placement LoadPlacement(node->first_node("placement"), &mConsoleX, &mConsoleY, &mConsoleW, &mConsoleH); child = node->first_node("slideout"); if (child) { mSlideout = 1; LoadPlacement(child, &mSlideoutX, &mSlideoutY); attr = child->first_attribute("resource"); if (attr) mSlideoutImage = PageManager::FindResource(attr->value()); if (mSlideoutImage && mSlideoutImage->GetResource()) { mSlideoutW = gr_get_width(mSlideoutImage->GetResource()); mSlideoutH = gr_get_height(mSlideoutImage->GetResource()); } } } gr_getFontDetails(mFont ? mFont->GetResource() : NULL, &mFontHeight, NULL); //gr_getFontDetails(mFont, &mFontHeight, NULL); SetActionPos(mRenderX, mRenderY, mRenderW, mRenderH); SetRenderPos(mConsoleX, mConsoleY); return; }
GUIFileSelector::GUIFileSelector(xml_node<>* node) { xml_attribute<>* attr; xml_node<>* child; mStart = mLineSpacing = mIconWidth = mIconHeight = 0; mFolderIcon = mFileIcon = mBackground = mFont = NULL; mBackgroundX = mBackgroundY = mBackgroundW = mBackgroundH = 0; mShowFolders = mShowFiles = mShowNavFolders = 1; mUpdate = 0; mPathVar = "cwd"; ConvertStrToColor("black", &mBackgroundColor); ConvertStrToColor("white", &mFontColor); child = node->first_node("icon"); if (child) { attr = child->first_attribute("folder"); if (attr) mFolderIcon = PageManager::FindResource(attr->value()); attr = child->first_attribute("file"); if (attr) mFileIcon = PageManager::FindResource(attr->value()); } child = node->first_node("background"); if (child) { attr = child->first_attribute("resource"); if (attr) mBackground = PageManager::FindResource(attr->value()); attr = child->first_attribute("color"); if (attr) { std::string color = attr->value(); ConvertStrToColor(color, &mBackgroundColor); } } // Load the placement LoadPlacement(node->first_node("placement"), &mRenderX, &mRenderY, &mRenderW, &mRenderH); SetActionPos(mRenderX, mRenderY, mRenderW, mRenderH); // Load the font, and possibly override the color child = node->first_node("font"); if (child) { attr = child->first_attribute("resource"); if (attr) mFont = PageManager::FindResource(attr->value()); attr = child->first_attribute("color"); if (attr) { std::string color = attr->value(); ConvertStrToColor(color, &mFontColor); } attr = child->first_attribute("spacing"); if (attr) mLineSpacing = atoi(attr->value()); } child = node->first_node("filter"); if (child) { attr = child->first_attribute("extn"); if (attr) mExtn = attr->value(); attr = child->first_attribute("folders"); if (attr) mShowFolders = atoi(attr->value()); attr = child->first_attribute("files"); if (attr) mShowFiles = atoi(attr->value()); attr = child->first_attribute("nav"); if (attr) mShowNavFolders = atoi(attr->value()); } // Handle the path variable child = node->first_node("path"); if (child) { attr = child->first_attribute("name"); if (attr) mPathVar = attr->value(); attr = child->first_attribute("default"); if (attr) DataManager::SetValue(mPathVar, attr->value()); } // Handle the result variable child = node->first_node("data"); if (child) { attr = child->first_attribute("name"); if (attr) mVariable = attr->value(); attr = child->first_attribute("default"); if (attr) DataManager::SetValue(mVariable, attr->value()); } // Retrieve the line height gr_getFontDetails(mFont ? mFont->GetResource() : NULL, &mFontHeight, NULL); mLineHeight = mFontHeight; if (mFolderIcon && mFolderIcon->GetResource()) { if (gr_get_height(mFolderIcon->GetResource()) > mLineHeight) mLineHeight = gr_get_width(mFolderIcon->GetResource()); mIconWidth = gr_get_width(mFolderIcon->GetResource()); mIconHeight = gr_get_height(mFolderIcon->GetResource()); } if (mFileIcon && mFileIcon->GetResource()) { if (gr_get_height(mFileIcon->GetResource()) > mLineHeight) mLineHeight = gr_get_width(mFileIcon->GetResource()); mIconWidth = gr_get_width(mFileIcon->GetResource()); mIconHeight = gr_get_height(mFileIcon->GetResource()); } if (mBackground && mBackground->GetResource()) { mBackgroundW = gr_get_width(mBackground->GetResource()); mBackgroundH = gr_get_height(mBackground->GetResource()); } // Fetch the file/folder list std::string value; DataManager::GetValue(mPathVar, value); if (GetFileList(value) != 0 && (mShowNavFolders != 0 || mShowFiles != 0)) GetFileList("/sdcard"); }