mirror of
https://github.com/CTCaer/RetroArch.git
synced 2025-02-14 00:05:24 +00:00
(iOS) Cleanups to UI
This commit is contained in:
parent
4c3d0fea3b
commit
f0817c7864
@ -13,15 +13,11 @@
|
|||||||
* If not, see <http://www.gnu.org/licenses/>.
|
* If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <dirent.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
|
|
||||||
#include "../../file_extract.h"
|
#include "../../file_extract.h"
|
||||||
|
|
||||||
#import "../common/RetroArch_Apple.h"
|
#import "../common/RetroArch_Apple.h"
|
||||||
#import "views.h"
|
#import "views.h"
|
||||||
|
|
||||||
#include <file/config_file.h>
|
|
||||||
#include "../../content.h"
|
#include "../../content.h"
|
||||||
#include "../../general.h"
|
#include "../../general.h"
|
||||||
#include <file/dir_list.h>
|
#include <file/dir_list.h>
|
||||||
@ -109,16 +105,26 @@ static void file_action(enum file_action action, NSString* source, NSString* tar
|
|||||||
+ (RADirectoryItem*)directoryItemFromPath:(NSString*)path
|
+ (RADirectoryItem*)directoryItemFromPath:(NSString*)path
|
||||||
{
|
{
|
||||||
RADirectoryItem* item = [RADirectoryItem new];
|
RADirectoryItem* item = [RADirectoryItem new];
|
||||||
|
|
||||||
|
if (!item)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
item.path = path;
|
item.path = path;
|
||||||
item.isDirectory = path_is_directory(path.UTF8String);
|
item.isDirectory = path_is_directory(path.UTF8String);
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (RADirectoryItem*)directoryItemFromElement:(struct string_list_elem*)element
|
+ (RADirectoryItem*)directoryItemFromElement:(struct string_list_elem*)element
|
||||||
{
|
{
|
||||||
RADirectoryItem* item = [RADirectoryItem new];
|
RADirectoryItem* item = [RADirectoryItem new];
|
||||||
|
|
||||||
|
if (!item)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
item.path = BOXSTRING(element->data);
|
item.path = BOXSTRING(element->data);
|
||||||
item.isDirectory = (element->attr.i == RARCH_DIRECTORY);
|
item.isDirectory = (element->attr.i == RARCH_DIRECTORY);
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,10 +132,9 @@ static void file_action(enum file_action action, NSString* source, NSString* tar
|
|||||||
{
|
{
|
||||||
static NSString* const cell_id = @"path_item";
|
static NSString* const cell_id = @"path_item";
|
||||||
static NSString* const icon_types[2] = { @"ic_file", @"ic_dir" };
|
static NSString* const icon_types[2] = { @"ic_file", @"ic_dir" };
|
||||||
|
|
||||||
uint32_t type_id = self.isDirectory ? 1 : 0;
|
uint32_t type_id = self.isDirectory ? 1 : 0;
|
||||||
|
|
||||||
UITableViewCell* result = [tableView dequeueReusableCellWithIdentifier:cell_id];
|
UITableViewCell* result = [tableView dequeueReusableCellWithIdentifier:cell_id];
|
||||||
|
|
||||||
if (!result)
|
if (!result)
|
||||||
result = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cell_id];
|
result = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cell_id];
|
||||||
|
|
||||||
@ -227,17 +232,18 @@ static void file_action(enum file_action action, NSString* source, NSString* tar
|
|||||||
self.path = path;
|
self.path = path;
|
||||||
self.title = self.path.lastPathComponent;
|
self.title = self.path.lastPathComponent;
|
||||||
|
|
||||||
// Need one array per section
|
/* Need one array per section. */
|
||||||
self.sections = [NSMutableArray array];
|
self.sections = [NSMutableArray array];
|
||||||
|
|
||||||
for (NSString* i in [self sectionIndexTitlesForTableView:self.tableView])
|
for (NSString* i in [self sectionIndexTitlesForTableView:self.tableView])
|
||||||
[self.sections addObject:[NSMutableArray arrayWithObject:i]];
|
[self.sections addObject:[NSMutableArray arrayWithObject:i]];
|
||||||
|
|
||||||
// List contents
|
/* List contents */
|
||||||
struct string_list *contents = dir_list_new(self.path.UTF8String, g_settings.menu.navigation.browser.filter.supported_extensions_enable ? self.extensions.UTF8String : NULL, true);
|
struct string_list *contents = dir_list_new(self.path.UTF8String, g_settings.menu.navigation.browser.filter.supported_extensions_enable ? self.extensions.UTF8String : NULL, true);
|
||||||
|
|
||||||
if (contents)
|
if (contents)
|
||||||
{
|
{
|
||||||
|
ssize_t i;
|
||||||
RADirectoryList __weak* weakSelf = self;
|
RADirectoryList __weak* weakSelf = self;
|
||||||
|
|
||||||
if (self.allowBlank)
|
if (self.allowBlank)
|
||||||
@ -249,7 +255,7 @@ static void file_action(enum file_action action, NSString* source, NSString* tar
|
|||||||
|
|
||||||
dir_list_sort(contents, true);
|
dir_list_sort(contents, true);
|
||||||
|
|
||||||
for (size_t i = 0; i < contents->size; i ++)
|
for (i = 0; i < contents->size; i ++)
|
||||||
{
|
{
|
||||||
const char* basename = path_basename(contents->elems[i].data);
|
const char* basename = path_basename(contents->elems[i].data);
|
||||||
|
|
||||||
@ -316,13 +322,15 @@ static void file_action(enum file_action action, NSString* source, NSString* tar
|
|||||||
|
|
||||||
if (idx_path)
|
if (idx_path)
|
||||||
{
|
{
|
||||||
|
bool is_zip;
|
||||||
|
UIActionSheet *menu;
|
||||||
|
NSString *button4_name = (IOS_IS_VERSION_7_OR_HIGHER()) ? @"AirDrop" : @"Delete";
|
||||||
|
NSString *button5_name = (IOS_IS_VERSION_7_OR_HIGHER()) ? @"Delete" : nil;
|
||||||
|
|
||||||
self.selectedItem = [self itemForIndexPath:idx_path];
|
self.selectedItem = [self itemForIndexPath:idx_path];
|
||||||
bool is_zip = [[self.selectedItem.path pathExtension] isEqualToString:@"zip"];
|
is_zip = !(strcmp(self.selectedItem.path.pathExtension.UTF8String, "zip"));
|
||||||
|
|
||||||
NSString* button4_name = (IOS_IS_VERSION_7_OR_HIGHER()) ? @"AirDrop" : @"Delete";
|
menu = [[UIActionSheet alloc] initWithTitle:self.selectedItem.path.lastPathComponent delegate:self
|
||||||
NSString* button5_name = (IOS_IS_VERSION_7_OR_HIGHER()) ? @"Delete" : nil;
|
|
||||||
|
|
||||||
UIActionSheet* menu = [[UIActionSheet alloc] initWithTitle:self.selectedItem.path.lastPathComponent delegate:self
|
|
||||||
cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil
|
cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil
|
||||||
otherButtonTitles:is_zip ? @"Unzip" : @"Zip", @"Move", @"Rename", button4_name, button5_name, nil];
|
otherButtonTitles:is_zip ? @"Unzip" : @"Zip", @"Move", @"Rename", button4_name, button5_name, nil];
|
||||||
[menu showFromToolbar:self.navigationController.toolbar];
|
[menu showFromToolbar:self.navigationController.toolbar];
|
||||||
@ -331,13 +339,13 @@ static void file_action(enum file_action action, NSString* source, NSString* tar
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called by the action sheet created in (void)fileAction:
|
/* Called by the action sheet created in (void)fileAction: */
|
||||||
- (void)actionSheet:(UIActionSheet*)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
|
- (void)actionSheet:(UIActionSheet*)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
|
||||||
{
|
{
|
||||||
NSString* target = self.selectedItem.path;
|
NSString* target = self.selectedItem.path;
|
||||||
NSString* action = [actionSheet buttonTitleAtIndex:buttonIndex];
|
NSString* action = [actionSheet buttonTitleAtIndex:buttonIndex];
|
||||||
|
|
||||||
if ([action isEqualToString:@"Unzip"])
|
if (!strcmp(action.UTF8String, "Unzip"))
|
||||||
{
|
{
|
||||||
UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:@"Enter target directory" message:@"" delegate:self
|
UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:@"Enter target directory" message:@"" delegate:self
|
||||||
cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil];
|
cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil];
|
||||||
@ -346,19 +354,18 @@ static void file_action(enum file_action action, NSString* source, NSString* tar
|
|||||||
[alertView textFieldAtIndex:0].text = [[target lastPathComponent] stringByDeletingPathExtension];
|
[alertView textFieldAtIndex:0].text = [[target lastPathComponent] stringByDeletingPathExtension];
|
||||||
[alertView show];
|
[alertView show];
|
||||||
}
|
}
|
||||||
else if ([action isEqualToString:@"Move"])
|
else if (!strcmp(action.UTF8String, "Move"))
|
||||||
[self.navigationController pushViewController:[[RAFoldersList alloc] initWithFilePath:target] animated:YES];
|
[self.navigationController pushViewController:[[RAFoldersList alloc] initWithFilePath:target] animated:YES];
|
||||||
else if ([action isEqualToString:@"Rename"])
|
else if (!strcmp(action.UTF8String, "Rename"))
|
||||||
{
|
{
|
||||||
UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:@"Enter new name" message:@"" delegate:self
|
UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:@"Enter new name" message:@"" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil];
|
||||||
cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil];
|
|
||||||
alertView.alertViewStyle = UIAlertViewStylePlainTextInput;
|
alertView.alertViewStyle = UIAlertViewStylePlainTextInput;
|
||||||
alertView.tag = FA_MOVE;
|
alertView.tag = FA_MOVE;
|
||||||
[alertView textFieldAtIndex:0].text = target.lastPathComponent;
|
[alertView textFieldAtIndex:0].text = target.lastPathComponent;
|
||||||
[alertView show];
|
[alertView show];
|
||||||
}
|
}
|
||||||
#ifdef __IPHONE_7_0
|
#ifdef __IPHONE_7_0
|
||||||
else if ([action isEqualToString:@"AirDrop"] && IOS_IS_VERSION_7_OR_HIGHER())
|
else if (!strcmp(action.UTF8String, "AirDrop") && IOS_IS_VERSION_7_OR_HIGHER())
|
||||||
{
|
{
|
||||||
// TODO: Zip if not already zipped
|
// TODO: Zip if not already zipped
|
||||||
|
|
||||||
@ -369,14 +376,13 @@ static void file_action(enum file_action action, NSString* source, NSString* tar
|
|||||||
[self presentViewController:avc animated:YES completion:nil];
|
[self presentViewController:avc animated:YES completion:nil];
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
else if ([action isEqualToString:@"Delete"])
|
else if (!strcmp(action.UTF8String, "Delete"))
|
||||||
{
|
{
|
||||||
UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:@"Really delete?" message:@"" delegate:self
|
UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:@"Really delete?" message:@"" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil];
|
||||||
cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil];
|
|
||||||
alertView.tag = FA_DELETE;
|
alertView.tag = FA_DELETE;
|
||||||
[alertView show];
|
[alertView show];
|
||||||
}
|
}
|
||||||
else if (![action isEqualToString:@"Cancel"])// Zip
|
else if (!strcmp(action.UTF8String, "Cancel")) /* Zip */
|
||||||
apple_display_alert("Action not supported.", "Action Failed");
|
apple_display_alert("Action not supported.", "Action Failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -374,6 +374,7 @@ static void RunActionSheet(const char* title, const struct string_list* items, U
|
|||||||
static NSString* const cell_id = @"boolean_setting";
|
static NSString* const cell_id = @"boolean_setting";
|
||||||
|
|
||||||
UITableViewCell* result = (UITableViewCell*)[tableView dequeueReusableCellWithIdentifier:cell_id];
|
UITableViewCell* result = (UITableViewCell*)[tableView dequeueReusableCellWithIdentifier:cell_id];
|
||||||
|
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
result = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cell_id];
|
result = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cell_id];
|
||||||
@ -392,12 +393,10 @@ static void RunActionSheet(const char* title, const struct string_list* items, U
|
|||||||
|
|
||||||
- (void)handleBooleanSwitch:(UISwitch*)swt
|
- (void)handleBooleanSwitch:(UISwitch*)swt
|
||||||
{
|
{
|
||||||
if (self.setting) {
|
if (self.setting)
|
||||||
*self.setting->value.boolean = swt.on ? true : false;
|
*self.setting->value.boolean = swt.on ? true : false;
|
||||||
}
|
if (self.action)
|
||||||
if (self.action) {
|
|
||||||
self.action();
|
self.action();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)wasSelectedOnTableView:(UITableView*)tableView ofController:(UIViewController*)controller
|
- (void)wasSelectedOnTableView:(UITableView*)tableView ofController:(UIViewController*)controller
|
||||||
@ -425,12 +424,15 @@ static void RunActionSheet(const char* title, const struct string_list* items, U
|
|||||||
^(RADirectoryList* list, RADirectoryItem* item)
|
^(RADirectoryList* list, RADirectoryItem* item)
|
||||||
{
|
{
|
||||||
const char *newval = NULL;
|
const char *newval = NULL;
|
||||||
if (item) {
|
if (item)
|
||||||
|
{
|
||||||
if (list.forDirectory && !item.isDirectory)
|
if (list.forDirectory && !item.isDirectory)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
newval = [item.path UTF8String];
|
newval = [item.path UTF8String];
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
if (!list.allowBlank)
|
if (!list.allowBlank)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user