9243C826153487640092B506 /* key-48.png in Resources */ = {isa = PBXBuildFile; fileRef = 9243C824153487640092B506 /* key-48.png */; };
9243C83115352EB20092B506 /* SinglePasswordDialog.m in Sources */ = {isa = PBXBuildFile; fileRef = 9243C83015352EB20092B506 /* SinglePasswordDialog.m */; };
9244E4D115397C300028FD10 /* FileItemTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 9244E4D015397C300028FD10 /* FileItemTest.m */; };
+ 9244E4DD1539B3250028FD10 /* MoveViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9244E4DC1539B3250028FD10 /* MoveViewController.m */; };
92DE332D151E277D00AD06EC /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 92DE332C151E277D00AD06EC /* UIKit.framework */; };
92DE332F151E277D00AD06EC /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 92DE332E151E277D00AD06EC /* Foundation.framework */; };
92DE3331151E277D00AD06EC /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 92DE3330151E277D00AD06EC /* CoreGraphics.framework */; };
9243C83015352EB20092B506 /* SinglePasswordDialog.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SinglePasswordDialog.m; sourceTree = "<group>"; };
9244E4CF15397C300028FD10 /* FileItemTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FileItemTest.h; sourceTree = "<group>"; };
9244E4D015397C300028FD10 /* FileItemTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FileItemTest.m; sourceTree = "<group>"; };
+ 9244E4DB1539B3250028FD10 /* MoveViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MoveViewController.h; sourceTree = "<group>"; };
+ 9244E4DC1539B3250028FD10 /* MoveViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MoveViewController.m; sourceTree = "<group>"; };
92DE3328151E277D00AD06EC /* Tombo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Tombo.app; sourceTree = BUILT_PRODUCTS_DIR; };
92DE332C151E277D00AD06EC /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
92DE332E151E277D00AD06EC /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
9243C7B41529D8610092B506 /* DetailViewController.m */,
922F592815295FAA009B1E32 /* EditViewController.h */,
922F592915295FAA009B1E32 /* EditViewController.m */,
+ 9244E4DB1539B3250028FD10 /* MoveViewController.h */,
+ 9244E4DC1539B3250028FD10 /* MoveViewController.m */,
92DE3333151E277D00AD06EC /* Supporting Files */,
92DE33841522998700AD06EC /* Storage.h */,
92DE33851522998700AD06EC /* Storage.m */,
9243C7ED1531ADA80092B506 /* CryptCore.m in Sources */,
9243C820153443B90092B506 /* PasswordManager.m in Sources */,
9243C83115352EB20092B506 /* SinglePasswordDialog.m in Sources */,
+ 9244E4DD1539B3250028FD10 /* MoveViewController.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
#import <UIKit/UIKit.h>
#import "FileItem.h"
+#import "MoveViewController.h"
@class MasterViewController;
@class Storage;
* Used on iPad only.
*/
-@interface DetailViewController : UIViewController
+@interface DetailViewController : UIViewController <MoveViewControllerDelegate>
@property (weak, nonatomic) FileItem *item;
@property (weak, nonatomic) Storage *storage;
*/
@protocol DetailViewControllerDelegate <NSObject>
-(void)detailViewFileItemChanged:(FileItem*)oldItem to:(FileItem *)newItem;
+-(void)detailViewFileItemRemoved:(FileItem *)item;
@end
\ No newline at end of file
[super viewDidLoad];
[self.navigationController setToolbarHidden:NO];
- NSString *btnTitle;
if (self.item != nil) {
- if (self.item.isCrypt) {
- btnTitle = @"Decrypt";
- } else {
- btnTitle = @"Encrypt";
- }
- UIBarButtonItem *cryptBtn = [[UIBarButtonItem alloc] initWithTitle:btnTitle
- style:UIBarButtonItemStyleBordered
- target:self
- action:@selector(crypt:)];
- [self setToolbarItems:[NSArray arrayWithObjects:cryptBtn, nil] animated:YES];
+ [self setupToolbar];
}
[self loadNote];
}
+- (void)setupToolbar {
+ NSString *btnTitle;
+ if (self.item.isCrypt) {
+ btnTitle = @"Decrypt";
+ } else {
+ btnTitle = @"Encrypt";
+ }
+ UIBarButtonItem *cryptBtn = [[UIBarButtonItem alloc] initWithTitle:btnTitle
+ style:UIBarButtonItemStyleBordered
+ target:self
+ action:@selector(crypt:)];
+ UIBarButtonItem *moveBtn = [[UIBarButtonItem alloc] initWithTitle:@"Move"
+ style:UIBarButtonItemStyleBordered
+ target:self
+ action:@selector(move:)];
+ [self setToolbarItems:[NSArray arrayWithObjects:cryptBtn, moveBtn, nil] animated:NO];
+
+}
+
- (void)viewDidUnload
{
[self setText:nil];
edit.detailItem = self.item;
edit.delegate = self.master;
+ } else if ([[segue identifier] isEqualToString:@"moveNote"]) {
+ MoveViewController *move = (MoveViewController*)[[[segue destinationViewController] viewControllers] objectAtIndex:0];
+ move.delegate = self;
+ move.folders = [self.storage listFolders];
}
}
}
}
+- (void)move:(id)sender {
+ [self performSegueWithIdentifier:@"moveNote" sender:self];
+}
+
- (void)loadNote {
if (!self.item) return;
// On iPhone and call by segue, self.text is nil because view is not loaded yet.
if (self.text) {
[self loadNote];
+ [self setupToolbar];
}
}
}
+
+#pragma mark - MoveViewControllerDelegate
+
+- (void)moveViewControllerCancel:(MoveViewController *)view {
+ [self dismissModalViewControllerAnimated:YES];
+}
+
+- (void)moveViewControllerSelect:(MoveViewController *)view path:(NSString *)path {
+ NSString *toPath = [self.storage moveFrom:self.item toPath:path];
+ [self.delegate detailViewFileItemRemoved:self.item];
+ self.item.path = toPath;
+ [self dismissModalViewControllerAnimated:YES];
+}
+
@end
storage = [Storage init];
}
+ // Init detailview for iPad.
+ self.detailViewController.storage = storage;
+ self.detailViewController.passwordManager = passwordManager;
+ self.detailViewController.delegate = self;
+
// Load initial items.
[self insertItems];
}
[self insertItem:newItem];
}
+-(void)detailViewFileItemRemoved:(FileItem *)item {
+ [self deleteItem:item];
+}
+
@end
--- /dev/null
+#import <UIKit/UIKit.h>
+
+@protocol MoveViewControllerDelegate;
+
+@interface MoveViewController : UITableViewController
+
+@property (weak,nonatomic) id <MoveViewControllerDelegate> delegate;
+@property (strong, nonatomic) NSArray *folders;
+
+- (IBAction)cancel:(id)sender;
+
+@end
+
+@protocol MoveViewControllerDelegate <NSObject>
+
+- (void)moveViewControllerCancel:(MoveViewController *)view;
+- (void)moveViewControllerSelect:(MoveViewController *)view path:(NSString *)path;
+@end
--- /dev/null
+#import "MoveViewController.h"
+
+@interface MoveViewController ()
+
+@end
+
+@implementation MoveViewController {
+ UIImage *imgFolder;
+}
+
+@synthesize delegate = _delegate;
+@synthesize folders = _folders;
+
+- (void)viewDidLoad
+{
+ [super viewDidLoad];
+
+ imgFolder = [UIImage imageNamed:@"Folder-32"];
+}
+
+- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
+{
+ return YES;
+}
+
+- (IBAction)cancel:(id)sender {
+ if (self.delegate) [self.delegate moveViewControllerCancel:self];
+}
+
+#pragma mark - Table view data source
+
+- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
+ return 1;
+}
+
+- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
+ return [self.folders count];
+}
+
+- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
+{
+ static NSString *CellIdentifier = @"Cell";
+ UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
+
+ NSString *folder = [self.folders objectAtIndex:indexPath.row];
+ cell.textLabel.text = folder;
+ cell.imageView.image = imgFolder;
+ return cell;
+}
+
+#pragma mark - Table view delegate
+
+- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
+{
+ NSString *path = [self.folders objectAtIndex:indexPath.row];
+ if (self.delegate) [self.delegate moveViewControllerSelect:self path:path];
+}
+
+@end
*/
-(BOOL)isTopDir;
+/*
+ * Enumerate top directory recursively and return array of NSString.
+ */
+- (NSArray *)listFolders;
+
-(FileItem*)newItem;
- (FileItem *)encrypt:(NSString *)key item:(FileItem*)item;
- (FileItem *)decrypt:(NSString *)key item:(FileItem*)item;
+- (void)moveFrom:(FileItem *)from to:(FileItem *)to;
+- (NSString *)moveFrom:(FileItem *)from toPath:(NSString *)to;
+
@end
return result;
}
+- (NSArray *)listFolders {
+ NSMutableArray *result = [NSMutableArray arrayWithCapacity:10];
+
+ [result addObject:@"/"];
+ [self listFoldersRec:result path:@"/"];
+ NSComparator compr = ^(id a, id b) {
+ NSString *strA = (NSString *)a;
+ NSString *strB = (NSString *)b;
+ return [strA compare:strB];
+ };
+ return [result sortedArrayUsingComparator:compr];
+}
+
+- (void)listFoldersRec:(NSMutableArray *)result path:(NSString *)path {
+ NSError *error = nil;
+ NSString *partPath = [documentRoot stringByAppendingString:path];
+ NSArray *files = [fileManager contentsOfDirectoryAtPath:partPath
+ error:&error];
+
+ for (NSString *f in files) {
+ BOOL bDir = NO;
+ NSString *p = [partPath stringByAppendingString:f];
+ [fileManager fileExistsAtPath:p isDirectory:&bDir];
+ if (!bDir) continue;
+ NSString *pFolder = [path stringByAppendingString:f];
+ [result addObject:pFolder];
+ [self listFoldersRec:result path:[pFolder stringByAppendingString:@"/"]];
+ }
+}
+
-(void)chdir:(NSString *)subdir {
NSString *newCurrent = [currentDirectory stringByAppendingPathComponent:subdir];
self.currentDirectory = [newCurrent stringByAppendingString:@"/"];
}
- (FileItem *)decrypt:(NSString *)key item:(FileItem*)item {
- // TODO: implement
NSData *encData = [NSData dataWithContentsOfFile:item.path];
NSError *error = nil;
NSData *plainData = [CryptCore decrypt:key data:encData error:&error];
return newItem;
}
+- (void)moveFrom:(FileItem *)from to:(FileItem *)to {
+ NSString *name = [from.path lastPathComponent];
+ NSMutableString *toPath = [[NSMutableString alloc]initWithCapacity:200];
+ [toPath appendString:to.path];
+ [toPath appendString:@"/"];
+ [toPath appendString:name];
+
+ NSError *error = nil;
+ [fileManager moveItemAtPath:from.path toPath:toPath error:&error];
+}
+
+- (NSString *)moveFrom:(FileItem *)from toPath:(NSString *)to {
+ NSString *name = [from.path lastPathComponent];
+ NSMutableString *toPath = [[NSMutableString alloc]initWithCapacity:200];
+ [toPath appendString:documentRoot];
+ [toPath appendString:to];
+ [toPath appendString:@"/"];
+ [toPath appendString:name];
+
+ NSError *error = nil;
+ [fileManager moveItemAtPath:from.path toPath:toPath error:&error];
+ return toPath;
+}
+
@end
</navigationItem>
<connections>
<outlet property="text" destination="I5K-hl-l4m" id="efg-OY-fpX"/>
+ <segue destination="d05-A3-3lh" kind="modal" identifier="moveNote" id="UNl-FX-1ZS"/>
</connections>
</viewController>
</objects>
<point key="canvasLocation" x="1025" y="-1397"/>
</scene>
+ <!--Move View Controller-->
+ <scene sceneID="VdD-0z-Oi9">
+ <objects>
+ <placeholder placeholderIdentifier="IBFirstResponder" id="Hr1-r9-0Qn" userLabel="First Responder" sceneMemberID="firstResponder"/>
+ <tableViewController id="kne-7K-i81" customClass="MoveViewController" sceneMemberID="viewController">
+ <tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" id="GrV-dc-OPL">
+ <rect key="frame" x="0.0" y="64" width="1024" height="704"/>
+ <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+ <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
+ <simulatedOrientationMetrics key="simulatedOrientationMetrics" orientation="landscapeRight"/>
+ <prototypes>
+ <tableViewCell contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="Cell" id="xuu-E4-adE">
+ <rect key="frame" x="0.0" y="22" width="768" height="44"/>
+ <autoresizingMask key="autoresizingMask"/>
+ <view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
+ <rect key="frame" x="0.0" y="0.0" width="768" height="43"/>
+ <autoresizingMask key="autoresizingMask"/>
+ <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
+ </view>
+ </tableViewCell>
+ </prototypes>
+ <connections>
+ <outlet property="dataSource" destination="kne-7K-i81" id="4nM-eP-aRT"/>
+ <outlet property="delegate" destination="kne-7K-i81" id="Glx-ob-e0s"/>
+ </connections>
+ </tableView>
+ <navigationItem key="navigationItem" id="9gq-dD-RPb">
+ <barButtonItem key="leftBarButtonItem" systemItem="cancel" id="Ogz-3k-B4z">
+ <connections>
+ <action selector="cancel:" destination="kne-7K-i81" id="JxE-Wk-dQR"/>
+ </connections>
+ </barButtonItem>
+ </navigationItem>
+ </tableViewController>
+ </objects>
+ <point key="canvasLocation" x="3287" y="-2199"/>
+ </scene>
<!--Split View Controller-->
<scene sceneID="18">
<objects>
</objects>
<point key="canvasLocation" x="2029" y="-494"/>
</scene>
+ <!--Navigation Controller-->
+ <scene sceneID="sop-gG-sUy">
+ <objects>
+ <placeholder placeholderIdentifier="IBFirstResponder" id="enT-QP-UTy" userLabel="First Responder" sceneMemberID="firstResponder"/>
+ <navigationController id="d05-A3-3lh" sceneMemberID="viewController">
+ <toolbarItems/>
+ <navigationBar key="navigationBar" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" id="Jwz-hL-bP9">
+ <rect key="frame" x="0.0" y="0.0" width="768" height="44"/>
+ <autoresizingMask key="autoresizingMask"/>
+ </navigationBar>
+ <nil name="viewControllers"/>
+ <connections>
+ <segue destination="kne-7K-i81" kind="relationship" relationship="rootViewController" id="Pot-UJ-tdT"/>
+ </connections>
+ </navigationController>
+ </objects>
+ <point key="canvasLocation" x="2211" y="-2191"/>
+ </scene>
</scenes>
<classes>
<class className="DetailViewController" superclassName="UIViewController">
<class className="MasterViewController" superclassName="UITableViewController">
<source key="sourceIdentifier" type="project" relativePath="./Classes/MasterViewController.h"/>
</class>
+ <class className="MoveViewController" superclassName="UITableViewController">
+ <source key="sourceIdentifier" type="project" relativePath="./Classes/MoveViewController.h"/>
+ <relationships>
+ <relationship kind="action" name="cancel:"/>
+ </relationships>
+ </class>
</classes>
<simulatedMetricsContainer key="defaultSimulatedMetrics">
<simulatedStatusBarMetrics key="statusBar" statusBarStyle="blackTranslucent"/>
<simulatedScreenMetrics key="destination"/>
</simulatedMetricsContainer>
<inferredMetricsTieBreakers>
- <segue reference="pK5-mO-z6F"/>
+ <segue reference="Kjf-1o-2Ik"/>
</inferredMetricsTieBreakers>
</document>
\ No newline at end of file
<outlet property="delegate" destination="12" id="15"/>
</connections>
</tableView>
- <navigationItem key="navigationItem" title="Master" id="36">
+ <navigationItem key="navigationItem" title="List" id="36">
<barButtonItem key="rightBarButtonItem" systemItem="add" id="agb-4g-a59">
<connections>
<segue destination="7bR-lH-lJ9" kind="modal" identifier="newNote" id="HlC-by-ur5"/>
</navigationItem>
<connections>
<outlet property="text" destination="crV-57-ylY" id="HD7-qX-vzI"/>
+ <segue destination="DVv-Iu-8Nq" kind="modal" identifier="moveNote" id="6ne-sM-16G"/>
</connections>
</viewController>
</objects>
</objects>
<point key="canvasLocation" x="2021" y="64"/>
</scene>
+ <!--Move View Controller - Choose folder-->
+ <scene sceneID="ysG-MP-3Qv">
+ <objects>
+ <placeholder placeholderIdentifier="IBFirstResponder" id="qw3-8U-E3I" userLabel="First Responder" sceneMemberID="firstResponder"/>
+ <tableViewController id="q5O-eT-KLN" customClass="MoveViewController" sceneMemberID="viewController">
+ <tableView key="view" opaque="NO" clipsSubviews="YES" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" id="VmW-Ud-l7o">
+ <rect key="frame" x="0.0" y="64" width="320" height="416"/>
+ <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+ <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
+ <prototypes>
+ <tableViewCell contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="Cell" id="ppG-Cp-Oqy">
+ <rect key="frame" x="0.0" y="22" width="320" height="44"/>
+ <autoresizingMask key="autoresizingMask"/>
+ <view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
+ <rect key="frame" x="0.0" y="0.0" width="320" height="43"/>
+ <autoresizingMask key="autoresizingMask"/>
+ <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
+ </view>
+ </tableViewCell>
+ </prototypes>
+ <connections>
+ <outlet property="dataSource" destination="q5O-eT-KLN" id="P2n-gA-Cze"/>
+ <outlet property="delegate" destination="q5O-eT-KLN" id="aDr-BS-3AP"/>
+ </connections>
+ </tableView>
+ <navigationItem key="navigationItem" title="Choose folder" id="4oC-95-7Hy">
+ <barButtonItem key="leftBarButtonItem" systemItem="cancel" id="rQF-JB-drS">
+ <connections>
+ <action selector="cancel:" destination="q5O-eT-KLN" id="SMm-ve-0ho"/>
+ </connections>
+ </barButtonItem>
+ </navigationItem>
+ </tableViewController>
+ </objects>
+ <point key="canvasLocation" x="2084" y="-535"/>
+ </scene>
<!--Navigation Controller-->
<scene sceneID="a6N-vh-sA4">
<objects>
</objects>
<point key="canvasLocation" x="1561" y="64"/>
</scene>
+ <!--Navigation Controller-->
+ <scene sceneID="N6v-4j-05b">
+ <objects>
+ <placeholder placeholderIdentifier="IBFirstResponder" id="vkq-xN-tWC" userLabel="First Responder" sceneMemberID="firstResponder"/>
+ <navigationController id="DVv-Iu-8Nq" sceneMemberID="viewController">
+ <toolbarItems/>
+ <navigationBar key="navigationBar" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" id="9hi-CP-Uox">
+ <rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
+ <autoresizingMask key="autoresizingMask"/>
+ </navigationBar>
+ <nil name="viewControllers"/>
+ <connections>
+ <segue destination="q5O-eT-KLN" kind="relationship" relationship="rootViewController" id="Evc-s3-ika"/>
+ </connections>
+ </navigationController>
+ </objects>
+ <point key="canvasLocation" x="1558" y="-535"/>
+ </scene>
</scenes>
<classes>
<class className="DetailViewController" superclassName="UIViewController">
<class className="MasterViewController" superclassName="UITableViewController">
<source key="sourceIdentifier" type="project" relativePath="./Classes/MasterViewController.h"/>
</class>
+ <class className="MoveViewController" superclassName="UITableViewController">
+ <source key="sourceIdentifier" type="project" relativePath="./Classes/MoveViewController.h"/>
+ <relationships>
+ <relationship kind="action" name="cancel:"/>
+ </relationships>
+ </class>
</classes>
<simulatedMetricsContainer key="defaultSimulatedMetrics">
<simulatedStatusBarMetrics key="statusBar"/>