Exemplo n.º 1
0
void
nandroid_menu()
{	
	// define constants for menu selection
#define ITEM_BACKUP_MENU         0
#define ITEM_RESTORE_MENU        1
#define ITEM_MENU_RBOOT 	     2
#define ITEM_MENU_BACK           3
	
	// build headers and items in menu
	char* nan_headers[] = { "Nandroid Menu",
							"Choose Backup or Restore:",
							NULL };
	
	char* nan_items[] = { "Backup Partitions",
						  "Restore Partitions",
						  "--> Reboot System",
						  "<-- Back To Main Menu",
						  NULL };
	
	char** headers = prepend_title(nan_headers);
	
	int chosen_item;
    inc_menu_loc(ITEM_MENU_BACK); // record back selection into array
	for (;;)
	{
         ui_set_background(BACKGROUND_ICON_NANDROID);
		chosen_item = get_menu_selection(headers, nan_items, 0, 0);
		switch (chosen_item)
		{
			case ITEM_BACKUP_MENU:
				nan_backup_menu(0);
				break;
			case ITEM_RESTORE_MENU:
                choose_backup_folder();
				break;
			case ITEM_MENU_RBOOT:
				tw_reboot();
                break;
			case ITEM_MENU_BACK:
				dec_menu_loc();
                ui_set_background(BACKGROUND_ICON_MAIN);
				return;
		}
	    if (go_home) { 		// if home was called
	        dec_menu_loc();
                ui_set_background(BACKGROUND_ICON_MAIN);
	        return;
	    }
	}
}
Exemplo n.º 2
0
int
sdcard_directory(const char* path) {
    ensure_path_mounted(SDCARD_ROOT);

    const char* MENU_HEADERS[] = { "Choose a package to install:",
                                   path,
                                   NULL };
    DIR* d;
    struct dirent* de;
    d = opendir(path);
    if (d == NULL) {
        LOGE("error opening %s: %s\n", path, strerror(errno));
        ensure_path_unmounted(SDCARD_ROOT);
        return 0;
    }

    char** headers = prepend_title(MENU_HEADERS);

    int s_size = 0;
    int s_alloc = 10;
    char** sele = malloc(s_alloc * sizeof(char*));
    int d_size = 0;
    int d_alloc = 10;
    char** dirs = malloc(d_alloc * sizeof(char*));
    int z_size = 0;
    int z_alloc = 10;
    char** zips = malloc(z_alloc * sizeof(char*));
    if (get_new_zip_dir == 1)
    {
    	sele[0] = strdup("[SELECT CURRENT FOLDER]");
    	s_size++;
    }
	sele[s_size] = strdup("../");
    inc_menu_loc(s_size);
	s_size++;
    
    while ((de = readdir(d)) != NULL) {
        int name_len = strlen(de->d_name);

        if (de->d_type == DT_DIR) {
            // skip "." and ".." entries
            if (name_len == 1 && de->d_name[0] == '.') continue;
            if (name_len == 2 && de->d_name[0] == '.' &&
                de->d_name[1] == '.') continue;

            if (d_size >= d_alloc) {
                d_alloc *= 2;
                dirs = realloc(dirs, d_alloc * sizeof(char*));
            }
            dirs[d_size] = malloc(name_len + 2);
            strcpy(dirs[d_size], de->d_name);
            dirs[d_size][name_len] = '/';
            dirs[d_size][name_len+1] = '\0';
            ++d_size;
        } else if (de->d_type == DT_REG &&
                   name_len >= 4 &&
                   strncasecmp(de->d_name + (name_len-4), ".zip", 4) == 0) {
            if (z_size >= z_alloc) {
                z_alloc *= 2;
                zips = realloc(zips, z_alloc * sizeof(char*));
            }
            zips[z_size++] = strdup(de->d_name);
        }
    }
    closedir(d);

    notError = 0;
    qsort(dirs, d_size, sizeof(char*), compare_string);
    qsort(zips, z_size, sizeof(char*), compare_string);
    
    // append dirs to the zips list
    if (d_size + z_size + 1 > z_alloc) {
        z_alloc = d_size + z_size + 1;
        zips = realloc(zips, z_alloc * sizeof(char*));
    }
    memcpy(zips + z_size, dirs, d_size * sizeof(char*));
    free(dirs);
    z_size += d_size;
    zips[z_size] = NULL;

    if (z_size + s_size + 1 > s_alloc) {
        s_alloc = z_size + s_size + 1;
        sele = realloc(sele, s_alloc * sizeof(char*));
    }
    memcpy(sele + s_size, zips, z_size * sizeof(char*));
    s_size += z_size;
    sele[s_size] = NULL;
    
    int result;
    int chosen_item = 0;
    do {
        chosen_item = get_menu_selection(headers, sele, 1, chosen_item);

        char* item = sele[chosen_item];
        int item_len = strlen(item);

        if (chosen_item == 0) {          // item 0 is always "../"
            // go up but continue browsing (if the caller is sdcard_directory)
        	if (get_new_zip_dir == 1)
        	{
        		strcpy(tw_zip_location_val,path);
                write_s_file();
                return 1;
        	} else {
            	dec_menu_loc();
                result = -1;
                break;
        	}
        } else if (chosen_item == 1 && get_new_zip_dir == 1) {
        	dec_menu_loc();
            result = -1;
            break;
        } else if (item[item_len-1] == '/') {
            // recurse down into a subdirectory
            char new_path[PATH_MAX];
            strlcpy(new_path, path, PATH_MAX);
            strlcat(new_path, "/", PATH_MAX);
            strlcat(new_path, item, PATH_MAX);
            new_path[strlen(new_path)-1] = '\0';  // truncate the trailing '/'
            result = sdcard_directory(new_path);
    	    if (go_home) { 
    	    	notError = 1;
    	        dec_menu_loc();
    	        if (get_new_zip_dir == 1)
    	        {
        	        return 1;
    	        } else {
        	        return 0;
    	        }
    	    }
            if (result >= 0) break;
        } else {
        	if (get_new_zip_dir != 1)
        	{
                // selected a zip file:  attempt to install it, and return
                // the status to the caller.
                char new_path[PATH_MAX];
                strlcpy(new_path, path, PATH_MAX);
                strlcat(new_path, "/", PATH_MAX);
                strlcat(new_path, item, PATH_MAX);

                ui_print("\n-- Install %s ...\n", path);
                set_sdcard_update_bootloader_message();
                char* copy = copy_sideloaded_package(new_path);
                ensure_path_unmounted(SDCARD_ROOT);
                if (copy) {
                    result = install_package(copy);
                    free(copy);
                } else {
                    result = INSTALL_ERROR;
                }
                break;
        	}
        }
    } while (true);
    
    free(zips);
    free(sele);
    free(headers);

    //ensure_path_unmounted(SDCARD_ROOT);
    return result;
}
void
nan_restore_menu(int pIdx)
{
	tw_total = 0;
	char* nan_r_headers[] = { "Nandroid Restore",
							  "Choose Restore Options:",
							  NULL	};
	
	char* nan_r_items[] = { "--> Restore Naowz!",
			 	 	 	 	nan_img_set(ITEM_NAN_SYSTEM,1),
			 	 	 	 	nan_img_set(ITEM_NAN_DATA,1),
			 	 	 	 	nan_img_set(ITEM_NAN_BOOT,1),
			 	 	 	 	nan_img_set(ITEM_NAN_RECOVERY,1),
			 	 	 	 	nan_img_set(ITEM_NAN_CACHE,1),
			 	 	 	 	nan_img_set(ITEM_NAN_WIMAX,1),
			 	 	 	 	nan_img_set(ITEM_NAN_ANDSEC,1),
			 	 	 	 	nan_img_set(ITEM_NAN_SDEXT,1),
							"<-- Back To Nandroid Menu",
							 NULL };

	char** headers = prepend_title(nan_r_headers);
	
    inc_menu_loc(ITEM_NAN_BACK);
	for (;;) {
		int chosen_item = get_menu_selection(headers, nan_r_items, 0, pIdx);
		pIdx = chosen_item; // remember last selection location
		switch (chosen_item)
		{
		case ITEM_NAN_BACKUP:
			if (tw_total > 0) {
				nandroid_rest_exe();
				dec_menu_loc();
				return;
			}
			break;
		case ITEM_NAN_SYSTEM:
			if (tw_nan_system_x == 0) {
				tw_nan_system_x = 1;
        		tw_total++;
			} else if (tw_nan_system_x == 1) {
				tw_nan_system_x = 0;
        		tw_total--;
			}
            break;
		case ITEM_NAN_DATA:
			if (tw_nan_data_x == 0) {
				tw_nan_data_x = 1;
        		tw_total++;
			} else if (tw_nan_data_x == 1) {
				tw_nan_data_x = 0;
        		tw_total--;
			}
			break;
		case ITEM_NAN_BOOT:
			if (tw_nan_boot_x == 0) {
				tw_nan_boot_x = 1;
        		tw_total++;
			} else if (tw_nan_boot_x == 1) {
				tw_nan_boot_x = 0;
        		tw_total--;
			}
			break;
		case ITEM_NAN_RECOVERY:
			if (tw_nan_recovery_x == 0) {
				tw_nan_recovery_x = 1;
        		tw_total++;
			} else if (tw_nan_recovery_x == 1) {
				tw_nan_recovery_x = 0;
        		tw_total--;
			}
			break;
		case ITEM_NAN_CACHE:
			if (tw_nan_cache_x == 0) {
				tw_nan_cache_x = 1;
        		tw_total++;
			} else if (tw_nan_cache_x == 1) {
				tw_nan_cache_x = 0;
        		tw_total--;
			}
			break;
		case ITEM_NAN_WIMAX:
			if (tw_nan_wimax_x == 0) {
				tw_nan_wimax_x = 1;
        		tw_total++;
			} else if (tw_nan_wimax_x == 1) {
				tw_nan_wimax_x = 0;
        		tw_total--;
			}
			break;
		case ITEM_NAN_ANDSEC:
			if (tw_nan_andsec_x == 0) {
				tw_nan_andsec_x = 1;
        		tw_total++;
			} else if (tw_nan_andsec_x == 1) {
				tw_nan_andsec_x = 0;
        		tw_total--;
			}
			break;
		case ITEM_NAN_SDEXT:
			if (tw_nan_sdext_x == 0) {
				tw_nan_sdext_x = 1;
        		tw_total++;
			} else if (tw_nan_sdext_x == 1) {
				tw_nan_sdext_x = 0;
        		tw_total--;
			}
			break;
		case ITEM_NAN_BACK - 1:
        	dec_menu_loc();
			return;
		}
	    if (go_home) { 
	        dec_menu_loc();
	        return;
	    }
	    break;
	}
	ui_end_menu();
    dec_menu_loc();
    nan_restore_menu(pIdx);
}
void
nan_backup_menu(int pIdx)
{
	tw_total = 0;
	char* nan_b_headers[] = { "Nandroid Backup",
							   "Choose Backup Options:",
							   NULL	};
	
	char* nan_b_items[] = { "--> Backup Naowz!",
							 nan_img_set(ITEM_NAN_SYSTEM,0),
							 nan_img_set(ITEM_NAN_DATA,0),
							 nan_img_set(ITEM_NAN_BOOT,0),
							 nan_img_set(ITEM_NAN_RECOVERY,0),
							 nan_img_set(ITEM_NAN_CACHE,0),
							 nan_img_set(ITEM_NAN_WIMAX,0),
							 nan_img_set(ITEM_NAN_ANDSEC,0),
							 nan_img_set(ITEM_NAN_SDEXT,0),
							 nan_compress(),
							 "<-- Back To Nandroid Menu",
							 NULL };

	char** headers = prepend_title(nan_b_headers);
	
    inc_menu_loc(ITEM_NAN_BACK);
	for (;;) {
		int chosen_item = get_menu_selection(headers, nan_b_items, 0, pIdx); // get key presses
		pIdx = chosen_item; // remember last selection location
		switch (chosen_item) {
			case ITEM_NAN_BACKUP:
				if (tw_total > 0) {
					nandroid_back_exe();
					dec_menu_loc();
					return;
				}
				break;
			case ITEM_NAN_SYSTEM:
            	if (DataManager_GetIntValue(TW_NANDROID_SYSTEM_VAR)) {
            		DataManager_SetIntValue(TW_NANDROID_SYSTEM_VAR, 0); // toggle's value
            		tw_total--; // keeps count of how many selected
            	} else {
            		DataManager_SetIntValue(TW_NANDROID_SYSTEM_VAR, 1);
            		tw_total++;
            	}
                break;
			case ITEM_NAN_DATA:
            	if (DataManager_GetIntValue(TW_NANDROID_DATA_VAR)) {
            		DataManager_SetIntValue(TW_NANDROID_DATA_VAR, 0);
            		tw_total--;
            	} else {
            		DataManager_SetIntValue(TW_NANDROID_DATA_VAR, 1);
            		tw_total++;
            	}
				break;
			case ITEM_NAN_BOOT:
            	if (DataManager_GetIntValue(TW_NANDROID_BOOT_VAR)) {
            		DataManager_SetIntValue(TW_NANDROID_BOOT_VAR, 0);
            		tw_total--;
            	} else {
            		DataManager_SetIntValue(TW_NANDROID_BOOT_VAR, 1);
            		tw_total++;
            	}
				break;
			case ITEM_NAN_RECOVERY:
            	if (DataManager_GetIntValue(TW_NANDROID_RECOVERY_VAR)) {
            		DataManager_SetIntValue(TW_NANDROID_RECOVERY_VAR, 0);
            		tw_total--;
            	} else {
            		DataManager_SetIntValue(TW_NANDROID_RECOVERY_VAR, 1);
            		tw_total++;
            	}
				break;
			case ITEM_NAN_CACHE:
            	if (DataManager_GetIntValue(TW_NANDROID_CACHE_VAR)) {
            		DataManager_SetIntValue(TW_NANDROID_CACHE_VAR, 0);
            		tw_total--;
            	} else {
            		DataManager_SetIntValue(TW_NANDROID_CACHE_VAR, 1);
            		tw_total++;
            	}
				break;
			case ITEM_NAN_WIMAX:
				if (tw_nan_wimax_x != -1) {
	            	if (DataManager_GetIntValue(TW_NANDROID_WIMAX_VAR)) {
	            		DataManager_SetIntValue(TW_NANDROID_WIMAX_VAR, 0);
	            		tw_total--;
	            	} else {
	            		DataManager_SetIntValue(TW_NANDROID_WIMAX_VAR, 1);
	            		tw_total++;
	            	}
				}
				break;
			case ITEM_NAN_ANDSEC:
				if (tw_nan_andsec_x != -1) {
	            	if (DataManager_GetIntValue(TW_NANDROID_ANDSEC_VAR)) {
	            		DataManager_SetIntValue(TW_NANDROID_ANDSEC_VAR, 0);
	            		tw_total--;
	            	} else {
	            		DataManager_SetIntValue(TW_NANDROID_ANDSEC_VAR, 1);
	            		tw_total++;
	            	}
				}
				break;
			case ITEM_NAN_SDEXT:
				if (tw_nan_sdext_x != -1) {
	            	if (DataManager_GetIntValue(TW_NANDROID_SDEXT_VAR)) {
	            		DataManager_SetIntValue(TW_NANDROID_SDEXT_VAR, 0);
	            		tw_total--;
	            	} else {
	            		DataManager_SetIntValue(TW_NANDROID_SDEXT_VAR, 1);
	            		tw_total++;
	           		}
				}
				break;
			case ITEM_NAN_COMPRESS:
            	DataManager_ToggleIntValue(TW_USE_COMPRESSION_VAR);
				break;
			case ITEM_NAN_BACK:
            	dec_menu_loc();
				return;
		}
	    if (go_home) { 
	        dec_menu_loc();
	        return;
	    }
		break;
	}
	ui_end_menu(); // end menu
    dec_menu_loc(); // decrease menu location
	nan_backup_menu(pIdx); // restart menu (to refresh it)
}
void choose_backup_folder() 
{
    ensure_path_mounted(SDCARD_ROOT);

	struct stat st;
    char tw_dir[255];
    sprintf(tw_dir, "%s/%s/", backup_folder, device_id);
    if (stat(backup_folder,&st) != 0) {
    	if (mkdir(backup_folder, 0777) != 0) {
    		LOGI("=> Can not create %s\n", backup_folder);
    	} else {
    		LOGI("=> Created folder %s\n", backup_folder);
    	}
    }
    if (stat(tw_dir,&st) != 0) {
    	if (mkdir(tw_dir, 0777) != 0) {
    		LOGI("=> Can not create %s\n", tw_dir);
    	} else {
    		LOGI("=> Created folder %s\n", tw_dir);
    	}
    }
    
    const char* MENU_HEADERS[] = { "Choose a Nandroid Folder:",
    							   tw_dir,
                                   NULL };
    
    char** headers = prepend_title(MENU_HEADERS);
    
    DIR* d;
    struct dirent* de;
    d = opendir(tw_dir);
    if (d == NULL) {
        LOGE("error opening %s: %s\n", tw_dir, strerror(errno));
        return;
    }

    int d_size = 0;
    int d_alloc = 10;
    char** dirs = malloc(d_alloc * sizeof(char*));
    int z_size = 1;
    int z_alloc = 10;
    char** zips = malloc(z_alloc * sizeof(char*));
    zips[0] = strdup("../");
    
    inc_menu_loc(0);
    while ((de = readdir(d)) != NULL) {
        int name_len = strlen(de->d_name);

        if (de->d_type == DT_DIR) {
            if (name_len == 1 && de->d_name[0] == '.') continue;
            if (name_len == 2 && de->d_name[0] == '.' &&
                de->d_name[1] == '.') continue;

            if (d_size >= d_alloc) {
                d_alloc *= 2;
                dirs = realloc(dirs, d_alloc * sizeof(char*));
            }
            dirs[d_size] = malloc(name_len + 2);
            strcpy(dirs[d_size], de->d_name);
            dirs[d_size][name_len] = '/';
            dirs[d_size][name_len+1] = '\0';
            ++d_size;
        }
    }
    closedir(d);

    qsort(dirs, d_size, sizeof(char*), compare_string);
    qsort(zips, z_size, sizeof(char*), compare_string);

    if (d_size + z_size + 1 > z_alloc) {
        z_alloc = d_size + z_size + 1;
        zips = realloc(zips, z_alloc * sizeof(char*));
    }
    memcpy(zips + z_size, dirs, d_size * sizeof(char*));
    free(dirs);
    z_size += d_size;
    zips[z_size] = NULL;

    int chosen_item = 0;
    for (;;) {
        chosen_item = get_menu_selection(headers, zips, 1, chosen_item);

        char* item = zips[chosen_item];
        int item_len = strlen(item);

        if (chosen_item == 0) {
            break;
        } else if (item[item_len-1] == '/') {
            strcpy(nan_dir, tw_dir);
            strcat(nan_dir, item);
            set_restore_files();
            nan_restore_menu(0);
            break;
        }
    }

    int i;
    for (i = 0; i < z_size; ++i) free(zips[i]);
    free(zips);

    dec_menu_loc();
}
Exemplo n.º 6
0
void
nan_backup_menu(int pIdx)
{
	tw_total = 0;
	char* nan_b_headers[] = { "Nandroid Backup",
							   "Choose Backup Options:",
							   NULL	};
	
	char* nan_b_items[] = { "--> Backup Naowz!",
							 nan_img_set(ITEM_NAN_SYSTEM,0),
							 nan_img_set(ITEM_NAN_DATA,0),
							 nan_img_set(ITEM_NAN_BOOT,0),
							 nan_img_set(ITEM_NAN_RECOVERY,0),
							 nan_img_set(ITEM_NAN_CACHE,0),
							 nan_img_set(ITEM_NAN_WIMAX,0),
							 nan_img_set(ITEM_NAN_ANDSEC,0),
							 nan_img_set(ITEM_NAN_SDEXT,0),
							 nan_compress(),
							 "<-- Back To Nandroid Menu",
							 NULL };

	char** headers = prepend_title(nan_b_headers);
	
    inc_menu_loc(ITEM_NAN_BACK);
	for (;;)
	{
		int chosen_item = get_menu_selection(headers, nan_b_items, 0, pIdx); // get key presses
		pIdx = chosen_item; // remember last selection location
		switch (chosen_item)
		{
			case ITEM_NAN_BACKUP:
				if (tw_total > 0) // only call backup if something was checked
				{
					nandroid_back_exe();
					dec_menu_loc();
					return;
				}
				break;
			case ITEM_NAN_SYSTEM:
            	if (is_true(tw_nan_system_val)) {
            		strcpy(tw_nan_system_val, "0"); // toggle's value
            		tw_total--;
            	} else {
            		strcpy(tw_nan_system_val, "1");
            		tw_total++;
            	}
                write_s_file();
                break;
			case ITEM_NAN_DATA:
            	if (is_true(tw_nan_data_val)) {
            		strcpy(tw_nan_data_val, "0");
            		tw_total--;
            	} else {
            		strcpy(tw_nan_data_val, "1");
            		tw_total++;
            	}
                write_s_file();
				break;
			case ITEM_NAN_BOOT:
            	if (is_true(tw_nan_boot_val)) {
            		strcpy(tw_nan_boot_val, "0");
            		tw_total--;
            	} else {
            		strcpy(tw_nan_boot_val, "1");
            		tw_total++;
            	}
                write_s_file();
				break;
			case ITEM_NAN_RECOVERY:
            	if (is_true(tw_nan_recovery_val)) {
            		strcpy(tw_nan_recovery_val, "0");
            		tw_total--;
            	} else {
            		strcpy(tw_nan_recovery_val, "1");
            		tw_total++;
            	}
                write_s_file();
				break;
			case ITEM_NAN_CACHE:
            	if (is_true(tw_nan_cache_val)) {
            		strcpy(tw_nan_cache_val, "0");
            		tw_total--;
            	} else {
            		strcpy(tw_nan_cache_val, "1");
            		tw_total++;
            	}
                write_s_file();
				break;
			case ITEM_NAN_WIMAX:
				if (tw_nan_wimax_x != -1)
				{
	            	if (is_true(tw_nan_wimax_val)) {
	            		strcpy(tw_nan_wimax_val, "0");
	            		tw_total--;
	            	} else {
	            		strcpy(tw_nan_wimax_val, "1");
	            		tw_total++;
	            	}
	                write_s_file();
				}
				break;
			case ITEM_NAN_ANDSEC:
				if (tw_nan_andsec_x != -1)
				{
	            	if (is_true(tw_nan_andsec_val)) {
	            		strcpy(tw_nan_andsec_val, "0");
	            		tw_total--;
	            	} else {
	            		strcpy(tw_nan_andsec_val, "1");
	            		tw_total++;
	            	}
	                write_s_file();
				}
				break;
			case ITEM_NAN_SDEXT:
				if (tw_nan_sdext_x != -1)
				{
	            	if (is_true(tw_nan_sdext_val)) {
	            		strcpy(tw_nan_sdext_val, "0");
	            		tw_total--;
	            	} else {
	            		strcpy(tw_nan_sdext_val, "1");
	            		tw_total++;
	           		}
	                write_s_file();
				}
				break;
			case ITEM_NAN_COMPRESS:
            	if (is_true(tw_use_compression_val)) {
            		strcpy(tw_use_compression_val, "0");
            	} else {
            		strcpy(tw_use_compression_val, "1");
           		}
                write_s_file();
				break;
			case ITEM_NAN_BACK:
            	dec_menu_loc();
				return;
		}
	    if (go_home) { 
	        dec_menu_loc();
	        return;
	    }
		break;
	}
	ui_end_menu(); // end menu
    dec_menu_loc();
	nan_backup_menu(pIdx); // restart menu (to refresh it)
}
Exemplo n.º 7
0
void twrp_themes_menu()
{
    static char* MENU_THEMES_HEADERS[] = { "twrp Theme Chooser",
    								   	   "Taste tEh Rainbow:",
                                           NULL };
    
	char* MENU_THEMES[] =       { 	"[REBOOT AND APPLY THEME]",
									checkTheme(TW_THEME),
									checkTheme(CM_THEME),
									checkTheme(RED_THEME),
									checkTheme(GOOGLE_THEME),
									checkTheme(JF_THEME),
									checkTheme(HTC_THEME),
									checkTheme(FABULOUS_THEME),
									checkTheme(PURPLE_SHIFT),
									checkTheme(GREYBALLER_THEME),
									checkTheme(TRIPPY_THEME),
									checkTheme(SHIFTY_BASTARD),
									"<-- Back To twrp Settings",
									NULL };

    char** headers = prepend_title(MENU_THEMES_HEADERS);
    
    inc_menu_loc(THEMES_BACK);
    for (;;)
    {
        int chosen_item = get_menu_selection(headers, MENU_THEMES, 0, 0);
        switch (chosen_item)
        {
            case THEME_REBOOT_RECOVERY:
            	ensure_path_unmounted("/sdcard");
                __reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, LINUX_REBOOT_CMD_RESTART2, "recovery");
                break;
            case TW_THEME:
            	strcpy(tw_color_theme_val,"0");
                break;
            case CM_THEME:
            	strcpy(tw_color_theme_val,"1");
                break;
            case RED_THEME:
            	strcpy(tw_color_theme_val,"2");
                break;
            case GOOGLE_THEME:
            	strcpy(tw_color_theme_val,"3");
                break;
            case JF_THEME:
            	strcpy(tw_color_theme_val,"4");
                break;
            case HTC_THEME:
            	strcpy(tw_color_theme_val,"5");
                break;
            case FABULOUS_THEME:
            	strcpy(tw_color_theme_val,"6");
                break;
	    case PURPLE_SHIFT:
		strcpy(tw_color_theme_val,"7");
                break;
	    case GREYBALLER_THEME:
		strcpy(tw_color_theme_val,"8");
                break;
	    case TRIPPY_THEME:
		strcpy(tw_color_theme_val,"9");
                break;
	    case SHIFTY_BASTARD:
		strcpy(tw_color_theme_val,"10");
                break;
            case THEMES_BACK:
            	dec_menu_loc();
            	return;
        }
        if (go_home) {
        	dec_menu_loc();
	        return;
	    }
        write_s_file();
        break;
    }
	ui_end_menu();
    dec_menu_loc();
    twrp_themes_menu();
}
Exemplo n.º 8
0
void twrp_themes_menu()
{
    const char* MENU_THEMES_HEADERS[] = {  "twrp Theme Chooser",
    								   	   "Taste tEh Rainbow:",
                                           NULL };
    
	char* MENU_THEMES[] =       { 	"[RESTART MENU AND APPLY THEME]",
									checkTheme(TW_THEME),
									checkTheme(CM_THEME),
									checkTheme(RED_THEME),
									checkTheme(GOOGLE_THEME),
									checkTheme(JF_THEME),
									checkTheme(HTC_THEME),
									checkTheme(FABULOUS_THEME),
									checkTheme(PURPLE_SHIFT),
									checkTheme(GREYBALLER_THEME),
									checkTheme(TRIPPY_THEME),
									checkTheme(SHIFTY_BASTARD),
									checkTheme(MYN_WARM),
									"<-- Back To twrp Settings",
									NULL };

    char** headers = prepend_title(MENU_THEMES_HEADERS);
    
    inc_menu_loc(THEMES_BACK);
    for (;;)
    {
        int chosen_item = get_menu_selection(headers, MENU_THEMES, 0, 0);
        switch (chosen_item)
        {
            case THEME_REBOOT_RECOVERY:
				set_theme(DataManager_GetStrValue(TW_COLOR_THEME_VAR));
				go_home = 1;
				go_restart = 1;
                break;
            case TW_THEME:
            	DataManager_SetIntValue(TW_COLOR_THEME_VAR, 0);
                break;
            case CM_THEME:
                DataManager_SetIntValue(TW_COLOR_THEME_VAR, 1);
                break;
            case RED_THEME:
                DataManager_SetIntValue(TW_COLOR_THEME_VAR, 2);
                break;
            case GOOGLE_THEME:
                DataManager_SetIntValue(TW_COLOR_THEME_VAR, 3);
                break;
            case JF_THEME:
                DataManager_SetIntValue(TW_COLOR_THEME_VAR, 4);
                break;
            case HTC_THEME:
                DataManager_SetIntValue(TW_COLOR_THEME_VAR, 5);
                break;
            case FABULOUS_THEME:
                DataManager_SetIntValue(TW_COLOR_THEME_VAR, 6);
                break;
			case PURPLE_SHIFT:
                DataManager_SetIntValue(TW_COLOR_THEME_VAR, 7);
                break;
			case GREYBALLER_THEME:
                DataManager_SetIntValue(TW_COLOR_THEME_VAR, 8);
                break;
			case TRIPPY_THEME:
                DataManager_SetIntValue(TW_COLOR_THEME_VAR, 9);
                break;
			case SHIFTY_BASTARD:
                DataManager_SetIntValue(TW_COLOR_THEME_VAR, 10);
                break;
			case MYN_WARM:
                DataManager_SetIntValue(TW_COLOR_THEME_VAR, 11);
                break;
            case THEMES_BACK:
            	dec_menu_loc();
            	return;
        }
        if (go_home) {
        	dec_menu_loc();
	        return;
	    }
        break;
    }
	ui_end_menu();
    dec_menu_loc();
    twrp_themes_menu();
}