summaryrefslogtreecommitdiff
path: root/ios
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2012-08-08 17:30:18 +0200
committerTor Andersson <tor.andersson@artifex.com>2012-08-08 17:50:33 +0200
commitfbb151fac52da10c3d9bbdfddae98c8ed3affd9d (patch)
tree849e42a255543d0faf11166312861e4dda29d08e /ios
parent511ea75a53db6e72334438bcda2ce774c7d72d1e (diff)
downloadmupdf-fbb151fac52da10c3d9bbdfddae98c8ed3affd9d.tar.xz
Add delete button to iOS library view.
Diffstat (limited to 'ios')
-rw-r--r--ios/MuPDF.xcodeproj/project.pbxproj8
-rw-r--r--ios/main.m60
-rw-r--r--ios/x_alt_blue.pngbin0 -> 344 bytes
-rw-r--r--ios/x_alt_blue@2x.pngbin0 -> 534 bytes
4 files changed, 64 insertions, 4 deletions
diff --git a/ios/MuPDF.xcodeproj/project.pbxproj b/ios/MuPDF.xcodeproj/project.pbxproj
index 1c047a36..f7b1f956 100644
--- a/ios/MuPDF.xcodeproj/project.pbxproj
+++ b/ios/MuPDF.xcodeproj/project.pbxproj
@@ -14,6 +14,8 @@
968F2EA014539C880085264E /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 968F2E9F14539C880085264E /* CoreGraphics.framework */; };
968F2EB014539CDA0085264E /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 968F2E9014539BEB0085264E /* main.m */; };
96A4739B147C1C3A003D757D /* libLibraries.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 968461E214642DB00012AE09 /* libLibraries.a */; };
+ 96B6AF8315D16A7E00EAAF7B /* x_alt_blue.png in Resources */ = {isa = PBXBuildFile; fileRef = 96B6AF8115D16A7E00EAAF7B /* x_alt_blue.png */; };
+ 96B6AF8415D16A7E00EAAF7B /* x_alt_blue@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 96B6AF8215D16A7E00EAAF7B /* x_alt_blue@2x.png */; };
96BD2B38145AC485001CEBC3 /* Icon-72.png in Resources */ = {isa = PBXBuildFile; fileRef = 96BD2B35145AC485001CEBC3 /* Icon-72.png */; };
96BD2B39145AC485001CEBC3 /* Icon.png in Resources */ = {isa = PBXBuildFile; fileRef = 96BD2B36145AC485001CEBC3 /* Icon.png */; };
96F2341514603FBA004A8A22 /* Icon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 96F2341414603FBA004A8A22 /* Icon@2x.png */; };
@@ -41,6 +43,8 @@
968F2E9B14539C880085264E /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = Library/Frameworks/UIKit.framework; sourceTree = DEVELOPER_DIR; };
968F2E9D14539C880085264E /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Library/Frameworks/Foundation.framework; sourceTree = DEVELOPER_DIR; };
968F2E9F14539C880085264E /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = Library/Frameworks/CoreGraphics.framework; sourceTree = DEVELOPER_DIR; };
+ 96B6AF8115D16A7E00EAAF7B /* x_alt_blue.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = x_alt_blue.png; sourceTree = "<group>"; };
+ 96B6AF8215D16A7E00EAAF7B /* x_alt_blue@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "x_alt_blue@2x.png"; sourceTree = "<group>"; };
96BD2B35145AC485001CEBC3 /* Icon-72.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-72.png"; sourceTree = "<group>"; };
96BD2B36145AC485001CEBC3 /* Icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Icon.png; sourceTree = "<group>"; };
96F2341414603FBA004A8A22 /* Icon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon@2x.png"; sourceTree = "<group>"; };
@@ -68,6 +72,8 @@
96BD2B36145AC485001CEBC3 /* Icon.png */,
96F2341414603FBA004A8A22 /* Icon@2x.png */,
96BD2B35145AC485001CEBC3 /* Icon-72.png */,
+ 96B6AF8115D16A7E00EAAF7B /* x_alt_blue.png */,
+ 96B6AF8215D16A7E00EAAF7B /* x_alt_blue@2x.png */,
968F2E8F14539BEB0085264E /* Info.plist */,
968F2E8E14539BEB0085264E /* build_libs.sh */,
9644E99E146ACEC000E5B70A /* document.c */,
@@ -176,6 +182,8 @@
96BD2B39145AC485001CEBC3 /* Icon.png in Resources */,
96F2341514603FBA004A8A22 /* Icon@2x.png in Resources */,
9668C8D91476A30200D7BA52 /* About.xps in Resources */,
+ 96B6AF8315D16A7E00EAAF7B /* x_alt_blue.png in Resources */,
+ 96B6AF8415D16A7E00EAAF7B /* x_alt_blue@2x.png in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
diff --git a/ios/main.m b/ios/main.m
index f24e2bdd..6f2c3b9c 100644
--- a/ios/main.m
+++ b/ios/main.m
@@ -20,7 +20,7 @@ static dispatch_queue_t queue;
static float screenScale = 1;
static fz_context *ctx = NULL;
-@interface MuLibraryController : UITableViewController
+@interface MuLibraryController : UITableViewController <UIActionSheetDelegate>
{
NSArray *files;
NSTimer *timer;
@@ -335,6 +335,42 @@ static UIImage *renderTile(struct document *doc, int number, CGSize screenSize,
return [files count] + 1;
}
+- (void) actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
+{
+ if (buttonIndex == [actionSheet destructiveButtonIndex])
+ {
+ char filename[PATH_MAX];
+ int row = [actionSheet tag];
+
+ dispatch_sync(queue, ^{});
+
+ strcpy(filename, [NSHomeDirectory() UTF8String]);
+ strcat(filename, "/Documents/");
+ strcat(filename, [[files objectAtIndex: row - 1] UTF8String]);
+
+ printf("delete document '%s'\n", filename);
+
+ unlink(filename);
+
+ [self reload];
+ }
+}
+
+- (void) onTapDelete: (UIControl*)sender
+{
+ int row = [sender tag];
+ NSString *title = [NSString stringWithFormat: @"Delete %@?", [files objectAtIndex: row - 1]];
+ UIActionSheet *sheet = [[UIActionSheet alloc]
+ initWithTitle: title
+ delegate: self
+ cancelButtonTitle: @"Cancel"
+ destructiveButtonTitle: @"Delete"
+ otherButtonTitles: nil];
+ [sheet setTag: row];
+ [sheet showInView: [self tableView]];
+ [sheet release];
+}
+
- (UITableViewCell*) tableView: (UITableView*)tableView cellForRowAtIndexPath: (NSIndexPath*)indexPath
{
static NSString *cellid = @"MuCellIdent";
@@ -345,11 +381,25 @@ static UIImage *renderTile(struct document *doc, int number, CGSize screenSize,
if (row == 0) {
[[cell textLabel] setText: @"About MuPDF"];
[[cell textLabel] setFont: [UIFont systemFontOfSize: 20]];
-// [[cell textLabel] setFont: [UIFont italicSystemFontOfSize: 20]];
} else {
[[cell textLabel] setText: [files objectAtIndex: row - 1]];
[[cell textLabel] setFont: [UIFont systemFontOfSize: 20]];
}
+
+ if (row > 0)
+ {
+ UIButton *deleteButton = [UIButton buttonWithType:UIButtonTypeCustom];
+ [deleteButton setImage: [UIImage imageNamed: @"x_alt_blue.png"] forState: UIControlStateNormal];
+ [deleteButton setFrame: CGRectMake(0, 0, 35, 35)];
+ [deleteButton addTarget: self action: @selector(onTapDelete:) forControlEvents: UIControlEventTouchUpInside];
+ [deleteButton setTag: row];
+ [cell setAccessoryView: deleteButton];
+ }
+ else
+ {
+ [cell setAccessoryView: nil];
+ }
+
return cell;
}
@@ -485,11 +535,13 @@ static UIImage *renderTile(struct document *doc, int number, CGSize screenSize,
static NSString *cellid = @"MuCellIdent";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier: cellid];
if (!cell)
+ {
cell = [[[UITableViewCell alloc] initWithStyle: UITableViewCellStyleValue1 reuseIdentifier: cellid] autorelease];
+ [[cell textLabel] setFont: [UIFont systemFontOfSize: 16]];
+ [[cell detailTextLabel] setFont: [UIFont systemFontOfSize: 16]];
+ }
NSString *title = [titles objectAtIndex: [indexPath row]];
NSString *page = [pages objectAtIndex: [indexPath row]];
- [[cell textLabel] setFont: [UIFont systemFontOfSize: 16]];
- [[cell detailTextLabel] setFont: [UIFont systemFontOfSize: 16]];
[[cell textLabel] setText: title];
[[cell detailTextLabel] setText: [NSString stringWithFormat: @"%d", [page intValue]+1]];
return cell;
diff --git a/ios/x_alt_blue.png b/ios/x_alt_blue.png
new file mode 100644
index 00000000..0ca9a6cc
--- /dev/null
+++ b/ios/x_alt_blue.png
Binary files differ
diff --git a/ios/x_alt_blue@2x.png b/ios/x_alt_blue@2x.png
new file mode 100644
index 00000000..1cb67549
--- /dev/null
+++ b/ios/x_alt_blue@2x.png
Binary files differ