Skip to content

Commit

Permalink
First release
Browse files Browse the repository at this point in the history
  • Loading branch information
ipad_kid committed Apr 10, 2018
1 parent eb2b53a commit 5a6798c
Show file tree
Hide file tree
Showing 21 changed files with 119 additions and 100 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
com.ipadkid.carReader_*
10 changes: 10 additions & 0 deletions carReader.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
974DA0001F766E5B003CF5AE /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 974D9FFF1F766E5B003CF5AE /* main.m */; };
974DA00B1F768C3D003CF5AE /* CRViewerViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 974DA00A1F768C3D003CF5AE /* CRViewerViewController.m */; };
977D52E21F8C226600B2E3A8 /* CRImageViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 977D52E11F8C226600B2E3A8 /* CRImageViewCell.m */; };
9793FD22207C596C001030D2 /* ent.plist in Resources */ = {isa = PBXBuildFile; fileRef = 9793FD20207C596B001030D2 /* ent.plist */; };
9793FD23207C596C001030D2 /* control in Resources */ = {isa = PBXBuildFile; fileRef = 9793FD21207C596C001030D2 /* control */; };
97E3938B204B8ED5008EA2F5 /* CRFileSystemViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 97E3938A204B8ED5008EA2F5 /* CRFileSystemViewController.m */; };
/* End PBXBuildFile section */

Expand Down Expand Up @@ -50,6 +52,9 @@
9779FC31200997B400B2F0C8 /* readMe.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = readMe.md; sourceTree = "<group>"; };
977D52E11F8C226600B2E3A8 /* CRImageViewCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CRImageViewCell.m; sourceTree = "<group>"; };
977D52E31F8C227000B2E3A8 /* CRImageViewCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CRImageViewCell.h; sourceTree = "<group>"; };
9793FD1E207C5216001030D2 /* make.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = make.sh; sourceTree = "<group>"; };
9793FD20207C596B001030D2 /* ent.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = ent.plist; sourceTree = "<group>"; };
9793FD21207C596C001030D2 /* control */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = control; sourceTree = "<group>"; };
97E39389204B8ECB008EA2F5 /* CRFileSystemViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CRFileSystemViewController.h; sourceTree = "<group>"; };
97E3938A204B8ED5008EA2F5 /* CRFileSystemViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CRFileSystemViewController.m; sourceTree = "<group>"; };
/* End PBXFileReference section */
Expand All @@ -69,6 +74,9 @@
isa = PBXGroup;
children = (
9779FC31200997B400B2F0C8 /* readMe.md */,
9793FD1E207C5216001030D2 /* make.sh */,
9793FD21207C596C001030D2 /* control */,
9793FD20207C596B001030D2 /* ent.plist */,
974D9FEF1F766E5B003CF5AE /* carReader */,
974D9FEE1F766E5B003CF5AE /* Products */,
);
Expand Down Expand Up @@ -175,6 +183,8 @@
files = (
974D9FFD1F766E5B003CF5AE /* LaunchScreen.storyboard in Resources */,
974D9FFA1F766E5B003CF5AE /* Assets.xcassets in Resources */,
9793FD22207C596C001030D2 /* ent.plist in Resources */,
9793FD23207C596C001030D2 /* control in Resources */,
974D9FF81F766E5B003CF5AE /* Main.storyboard in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
9 changes: 5 additions & 4 deletions carReader/Assets.xcassets/AppIcon.appiconset/Contents.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@
"scale" : "1x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"idiom" : "iphone",
"filename" : "[email protected]",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"idiom" : "iphone",
"filename" : "[email protected]",
"scale" : "3x"
},
{
Expand Down Expand Up @@ -65,9 +67,8 @@
"scale" : "1x"
},
{
"size" : "20x20",
"idiom" : "ipad",
"filename" : "Icon-App-20x20@2x.png",
"size" : "20x20",
"scale" : "2x"
},
{
Expand Down
Binary file not shown.
Binary file modified carReader/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified carReader/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified carReader/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified carReader/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified carReader/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified carReader/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified carReader/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified carReader/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 1 addition & 2 deletions carReader/CRFileSystemViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

@interface CRFileSystemViewController : UITableViewController

@property (nullable, nonatomic) NSArray<NSString *> *validFiles;
@property (nonatomic) NSString *currentPath;

@end

100 changes: 40 additions & 60 deletions carReader/CRFileSystemViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,85 +10,65 @@
#import "Private.h"
#import "CRViewerViewController.h"

#define kCellIdentifier @"Cell"

@implementation CRFileSystemViewController {
UIAlertController *infoAlert;
NSArray *_filesAtCurrentPath;
}

- (void)viewDidLoad {
[super viewDidLoad];

[self.tableView registerClass:UITableViewCell.class forCellReuseIdentifier:@"Cell"];
self.navigationItem.title = @"Select File";
}

- (void)dismissInfoAlert {
if (infoAlert) {
CGRect newBounds = infoAlert.view.bounds;
newBounds.origin.y = self.view.bounds.size.height;
[UIView animateWithDuration:0.15 animations:^{
infoAlert.view.bounds = newBounds;
} completion:^(BOOL finished) {
[infoAlert dismissViewControllerAnimated:NO completion:nil];
infoAlert = NULL;
}];
if (!_currentPath) {
_currentPath = @"/";
}

_filesAtCurrentPath = [NSFileManager.defaultManager contentsOfDirectoryAtPath:_currentPath error:NULL];

self.navigationItem.title = _currentPath.lastPathComponent;

[self.tableView registerClass:UITableViewCell.class forCellReuseIdentifier:kCellIdentifier];
}

- (void)longTouch:(UILongPressGestureRecognizer *)touch {
if (touch.state == UIGestureRecognizerStateBegan) {
UITableViewCell *cell = (UITableViewCell *)touch.view;
NSString *text = cell.textLabel.text;

infoAlert = [UIAlertController alertControllerWithTitle:@"" message:text preferredStyle:UIAlertControllerStyleAlert];
infoAlert.view.hidden = YES;
[self presentViewController:infoAlert animated:NO completion:^{
UITapGestureRecognizer *dismissRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismissInfoAlert)];
UIView *infoAlertView = infoAlert.view;
[infoAlertView.superview.subviews.firstObject addGestureRecognizer:dismissRecognizer];

CGRect originalBounds = infoAlertView.bounds;
CGRect tmpBounds = originalBounds;
tmpBounds.origin.y = -self.view.frame.size.height;
infoAlertView.bounds = tmpBounds;
infoAlertView.hidden = NO;

[UIView animateWithDuration:0.15 animations:^{
infoAlertView.bounds = originalBounds;
}];
}];
}

if (touch.state == UIGestureRecognizerStateEnded) {
[self dismissInfoAlert];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return _filesAtCurrentPath.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
[cell addGestureRecognizer:[[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longTouch:)]];
cell.textLabel.text = _validFiles[indexPath.row];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
NSString *dirObject = _filesAtCurrentPath[indexPath.row];
NSString *fullPath = [_currentPath stringByAppendingPathComponent:dirObject];

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellIdentifier forIndexPath:indexPath];
cell.textLabel.text = dirObject;

BOOL isDir;
[NSFileManager.defaultManager fileExistsAtPath:fullPath isDirectory:&isDir];
cell.accessoryType = isDir ? UITableViewCellAccessoryDisclosureIndicator : UITableViewCellAccessoryNone;
cell.userInteractionEnabled = cell.textLabel.enabled = (isDir || [dirObject.pathExtension isEqualToString:@"car"]);

return cell;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return _validFiles.count;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:NSBundle.mainBundle];
CRViewerViewController *newViewController = [storyboard instantiateViewControllerWithIdentifier:@"Viewer"];
UIUserInterfaceIdiom deviceIdiom = UIDevice.currentDevice.userInterfaceIdiom;
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
NSString *fullPath = [_currentPath stringByAppendingPathComponent:cell.textLabel.text];

NSString *assetPath = _validFiles[indexPath.row];
newViewController.assets = [[_UIAssetManager alloc] initWithURL:[NSURL fileURLWithPath:assetPath isDirectory:NO] idiom:deviceIdiom error:NULL];
[self.navigationController pushViewController:newViewController animated:YES];
BOOL isDir;
[NSFileManager.defaultManager fileExistsAtPath:fullPath isDirectory:&isDir];
if (isDir) {
typeof(self) newViewController = self.class.new;
newViewController.currentPath = fullPath;
[self.navigationController pushViewController:newViewController animated:YES];
} else {
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:NSBundle.mainBundle];
CRViewerViewController *newViewController = [storyboard instantiateViewControllerWithIdentifier:@"Viewer"];
NSURL *integrityPath = [NSURL fileURLWithPath:fullPath isDirectory:NO];
UIUserInterfaceIdiom deviceIdiom = UIDevice.currentDevice.userInterfaceIdiom;
newViewController.assets = [[_UIAssetManager alloc] initWithURL:integrityPath idiom:deviceIdiom error:NULL];
[self.navigationController pushViewController:newViewController animated:YES];
}

[tableView deselectRowAtIndexPath:indexPath animated:YES];
}

- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskAll;
}

@end
37 changes: 6 additions & 31 deletions carReader/CRViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,35 +29,6 @@ - (IBAction)goButton {
[self.navigationController pushViewController:newViewController animated:YES];
}

- (void)recursiveDump:(NSString *)dir list:(NSMutableArray<NSString *> *)list {
NSFileManager *fileManager = NSFileManager.defaultManager;
for (NSString *file in [fileManager contentsOfDirectoryAtPath:dir error:NULL]) {
NSString *path = [dir stringByAppendingPathComponent:file];
BOOL isDir;
if ([fileManager fileExistsAtPath:path isDirectory:&isDir]) {
if (isDir) {
[self recursiveDump:path list:list];
} else if ([path.pathExtension isEqualToString:@"car"]) {
[list addObject:path];
}
}
}
}

- (void)dumpFS {
UIAlertController *loadAlert = [UIAlertController alertControllerWithTitle:@"Loading" message:@"Finding all files with .car extension" preferredStyle:1];
[self presentViewController:loadAlert animated:YES completion:^{
NSMutableArray<NSString *> *list = NSMutableArray.new;
[self recursiveDump:@"/" list:list];

CRFileSystemViewController *filePicker = CRFileSystemViewController.new;
filePicker.validFiles = list;
[loadAlert dismissViewControllerAnimated:YES completion:^{
[self.navigationController pushViewController:filePicker animated:YES];
}];
}];
}

- (void)pasteButton {
NSString *pasteboard = UIPasteboard.generalPasteboard.string;
if (pasteboard.absolutePath) {
Expand Down Expand Up @@ -114,6 +85,10 @@ - (void)pickFrameworkHit {
}];
}

- (void)popFileSystemBrowser {
[self.navigationController pushViewController:[CRFileSystemViewController new] animated:YES];
}

- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskAll;
}
Expand All @@ -132,7 +107,7 @@ - (nonnull UITableViewCell *)tableView:(nonnull UITableView *)tableView cellForR
titleText = @"Pick Framework";
break;
case 3:
titleText = @"All Files";
titleText = @"Browse Files";
break;
}

Expand Down Expand Up @@ -162,7 +137,7 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
[self pickFrameworkHit];
break;
case 3:
[self dumpFS];
[self popFileSystemBrowser];
break;
}
}
Expand Down
9 changes: 9 additions & 0 deletions control
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Package: com.ipadkid.carReader
Name: carReader
Architecture: iphoneos-arm
Description: View the contents of .car files
Homepage: https://github.com/ipadkid358/carReader
Maintainer: ipad_kid <[email protected]>
Author: ipad_kid <[email protected]>
Section: Utilities
Version: 0.0.1
8 changes: 8 additions & 0 deletions ent.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>platform-application</key>
<true/>
</dict>
</plist>
39 changes: 39 additions & 0 deletions make.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash

xcodebuild clean build CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY="" -sdk "$(xcrun --sdk iphoneos --show-sdk-path)" -arch arm64 -arch armv7 || {
exit 1
}

cd build || {
echo "Failed to change to build directory"
exit 1
}

test "$1" = "ipa" && {
kPayloadDir="Payload"
kIPAName="com.ipadkid.carReader_0.0.1.ipa"

mkdir "$kPayloadDir"
mv Release-iphoneos/carReader.app "$kPayloadDir"
zip -r "$kIPAName" "$kPayloadDir"
mv "$kIPAName" ..
echo "Created IPA at "$kIPAName""
}

test "$1" = "deb" && {
kPayloadDir="Payload"
kDebName="com.ipadkid.carReader_0.0.1_iphoneos-arm.deb"

mkdir -p "$kPayloadDir"/DEBIAN
mkdir "$kPayloadDir"/Applications

mv Release-iphoneos/carReader.app "$kPayloadDir"/Applications
cp ../control "$kPayloadDir"/DEBIAN
ldid -S../ent.plist -Icom.ipadkid.carReader "$kPayloadDir"/Applications/carReader.app/carReader
dpkg-deb -Zlzma -b "$kPayloadDir" "$kDebName"
mv "$kDebName" ..
echo "Created deb at "$kDebName""
}

cd ..
rm -r build
3 changes: 0 additions & 3 deletions readMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,3 @@ CUIStructuredThemeStore *themeStore = catalog._themeStore;

NSArray<NSString *> *allImageNames = themeStore.allImageNames;
```

### TODOs:
- Fix filesystem dump to skip symlinks

0 comments on commit 5a6798c

Please sign in to comment.