Beta 1 finished. Added implementation of checking if backup is selected, added several functions. All buttons work as tested

This commit is contained in:
Micah Gomez 2019-04-02 08:23:39 -06:00
parent d343e2b8ad
commit 7190d2aa3d
5 changed files with 454 additions and 76 deletions

View file

@ -2,7 +2,7 @@
"images" : [
{
"idiom" : "universal",
"filename" : "bgimage.jpg",
"filename" : "bgimage.png",
"scale" : "1x"
},
{

Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

View file

@ -18,12 +18,12 @@
<rect key="frame" x="0.0" y="0.0" width="375" height="812"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" alpha="0.5" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" image="bgimage" translatesAutoresizingMaskIntoConstraints="NO" id="Xdq-a9-Vkk">
<imageView clipsSubviews="YES" userInteractionEnabled="NO" alpha="0.84999999999999998" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" image="bgimage" translatesAutoresizingMaskIntoConstraints="NO" id="Xdq-a9-Vkk">
<rect key="frame" x="0.0" y="0.0" width="375" height="812"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
</imageView>
<pickerView contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="X4R-sr-2s9">
<rect key="frame" x="16" y="309" width="343" height="194"/>
<rect key="frame" x="16" y="221" width="343" height="287"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" white="1" alpha="0.25035761443661969" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<connections>
@ -32,7 +32,7 @@
</connections>
</pickerView>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="XMB-Cv-YLA">
<rect key="frame" x="16" y="670" width="167" height="50"/>
<rect key="frame" x="16" y="574" width="167" height="50"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" white="1" alpha="0.25035761439999998" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<fontDescription key="fontDescription" type="system" pointSize="31"/>
@ -42,7 +42,7 @@
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="WN9-tU-bOp">
<rect key="frame" x="192" y="670" width="167" height="50"/>
<rect key="frame" x="192" y="574" width="167" height="50"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" white="1" alpha="0.25035761439999998" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<fontDescription key="fontDescription" type="system" pointSize="31"/>
@ -52,9 +52,9 @@
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Z44-tn-4Km">
<rect key="frame" x="16" y="728" width="343" height="50"/>
<rect key="frame" x="16" y="690" width="343" height="50"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" white="1" alpha="0.25035761439999998" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<color key="backgroundColor" red="1" green="0.51075712174615018" blue="0.48122861101819614" alpha="0.25035761439999998" colorSpace="custom" customColorSpace="sRGB"/>
<fontDescription key="fontDescription" type="system" pointSize="31"/>
<state key="normal" title="Delete">
<color key="titleColor" red="1" green="0.084393614217168067" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
@ -64,7 +64,7 @@
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" adjustsImageWhenHighlighted="NO" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="FKY-5f-bN9">
<rect key="frame" x="16" y="612" width="343" height="50"/>
<rect key="frame" x="16" y="516" width="343" height="50"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" white="1" alpha="0.25035761439999998" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<fontDescription key="fontDescription" type="system" pointSize="31"/>
@ -73,26 +73,55 @@
<action selector="createBackup:" destination="BYZ-38-t0r" eventType="touchUpInside" id="HAA-of-GPp"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" adjustsImageWhenHighlighted="NO" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="lNN-hV-Kcy">
<rect key="frame" x="16" y="632" width="167" height="50"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" white="1" alpha="0.25035761439999998" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<fontDescription key="fontDescription" type="system" pointSize="31"/>
<state key="normal" title="Package"/>
<connections>
<action selector="packageBackup:" destination="BYZ-38-t0r" eventType="touchUpInside" id="BGU-Dg-Yyu"/>
</connections>
</button>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Selected Backup:" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="z1J-Te-u2O">
<rect key="frame" x="109" y="183" width="157" height="30"/>
<rect key="frame" x="108" y="145" width="157" height="30"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="20"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="gXr-H3-y6A">
<rect key="frame" x="16" y="221" width="343" height="30"/>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Scroll to Select a Backup" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="gXr-H3-y6A">
<rect key="frame" x="16" y="183" width="343" height="30"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="15"/>
<fontDescription key="fontDescription" type="system" pointSize="13"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="FlashBack" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="84C-7a-WER">
<rect key="frame" x="16" y="82" width="343" height="93"/>
<rect key="frame" x="16" y="44" width="343" height="93"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" name="Courier" family="Courier" pointSize="50"/>
<fontDescription key="fontDescription" name="Courier" family="Courier" pointSize="60"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" adjustsImageWhenHighlighted="NO" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="BHq-ds-6bc">
<rect key="frame" x="192" y="631" width="167" height="50"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" white="1" alpha="0.25035761439999998" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<fontDescription key="fontDescription" type="system" pointSize="31"/>
<state key="normal" title="Unpack"/>
<connections>
<action selector="unpackageBackup:" destination="BYZ-38-t0r" eventType="touchUpInside" id="ZaH-zv-Vd5"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" adjustsImageWhenHighlighted="NO" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="j3D-XF-u37">
<rect key="frame" x="103" y="748" width="167" height="42"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="25"/>
<state key="normal" title="Help"/>
<connections>
<action selector="helpMenu:" destination="BYZ-38-t0r" eventType="touchUpInside" id="Cqa-me-9od"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
@ -109,6 +138,6 @@
</scene>
</scenes>
<resources>
<image name="bgimage" width="1125" height="2436"/>
<image name="bgimage" width="1440" height="2960"/>
</resources>
</document>

View file

@ -19,6 +19,8 @@
NSArray *_backupFolderArray;
NSString *_backupDirectory;
NSMutableString *selectedBackupImageURL;
NSMutableString *selectedBackupURL;
NSString *backupNameSelected;
@implementation ViewController
@ -26,63 +28,105 @@ NSMutableString *selectedBackupImageURL;
- (IBAction)createBackup:(id)sender {
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Enter the Backup Name" message:@"" preferredStyle:UIAlertControllerStyleAlert];
[alertController addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
UIAlertController *createBackupAlert = [UIAlertController alertControllerWithTitle:@"Enter the Backup Name" message:@"Please do not use special symbols. Use only letters and numbers, no spaces." preferredStyle:UIAlertControllerStyleAlert];
[createBackupAlert addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
textField.placeholder = @"Backup Name";
textField.secureTextEntry = NO;
}];
UIAlertAction *confirmAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
NSLog(@"Backup name is :%@", [[alertController textFields][0] text]);
NSString *newBackupName=[[alertController textFields][0] text];
NSLog(@"Backup name is :%@", [[createBackupAlert textFields][0] text]);
NSString *newBackupName=[[createBackupAlert textFields][0] text];
if([[[alertController textFields][0] text] isEqual:@""]){
if([[[createBackupAlert textFields][0] text] isEqual:@""]){
NSLog(@"empty backup name!");
}
else{
NSLog(@"Backup name is good!");
/*NSString *content = @"Put this in a file please.";
NSData *fileContents = [content dataUsingEncoding:NSUTF8StringEncoding];
[[NSFileManager defaultManager] createFileAtPath:@"/Applications/test.txt"
contents:fileContents
attributes:nil];*/
NSData *fileContents = [content dataUsingEncoding:NSUTF8StringEncoding];
[[NSFileManager defaultManager] createFileAtPath:@"/Applications/test.txt"
contents:fileContents
attributes:nil];*/
NSLog(@"Running NSTask");
NSTask *task = [[NSTask alloc] init];
[task setLaunchPath:@"/usr/bin/bash"];
[task setArguments:@[ @"_FBCreate", newBackupName]];
[task launch];
NSTask *createTask = [[NSTask alloc] init];
[createTask setLaunchPath:@"/usr/bin/bash"];
[createTask setArguments:@[ @"FBCreate", newBackupName]];
[createTask launch];
[createTask waitUntilExit];
NSLog(@"Running NSTask failed, running posix_spawn");
UIAlertController * finishedCreateAlert= [UIAlertController
alertControllerWithTitle:@"Backup Creation Completed"
message:@"The backup will appear once you repoen the app."
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* ok = [UIAlertAction
actionWithTitle:@"OK"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
[finishedCreateAlert dismissViewControllerAnimated:YES completion:nil];
}];
[finishedCreateAlert addAction:ok];
[self presentViewController:finishedCreateAlert animated:YES completion:nil];
/*pid_t pid;
int status;
const char* args[] = {"killall", "backboardd", NULL, NULL};
posix_spawn(&pid, "/bin/bash", NULL, NULL, (char* const*)args, NULL);
waitpid(pid, &status, WEXITED);*/
int status;
const char* args[] = {"killall", "backboardd", NULL, NULL};
posix_spawn(&pid, "/bin/bash", NULL, NULL, (char* const*)args, NULL);
waitpid(pid, &status, WEXITED);*/
}
}];
[alertController addAction:confirmAction];
[createBackupAlert addAction:confirmAction];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
NSLog(@"Canelled");
}];
[alertController addAction:cancelAction];
[self presentViewController:alertController animated:YES completion:nil];
[createBackupAlert addAction:cancelAction];
[self presentViewController:createBackupAlert animated:YES completion:nil];
}
- (IBAction)restoreBackup:(id)sender {
UIAlertController * alert= [UIAlertController
alertControllerWithTitle:@"Restore Backup"
message:@"Your device will revert to the selected backup!"
preferredStyle:UIAlertControllerStyleAlert];
if (backupNameSelected == nil){
UIAlertController * selectBackupAlert= [UIAlertController
alertControllerWithTitle:@"Select a Backup!"
message:@"Scroll through the list then let it settle on an item to select the backup."
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* ok = [UIAlertAction
actionWithTitle:@"ok"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
[selectBackupAlert dismissViewControllerAnimated:YES completion:nil];
}];
[selectBackupAlert addAction:ok];
[self presentViewController:selectBackupAlert animated:YES completion:nil];
}
else{
UIAlertController * restoreBackupAlert= [UIAlertController
alertControllerWithTitle:@"Restore Backup"
message:@"Your device will revert to the selected backup! Please wait for your device to respring."
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* ok = [UIAlertAction
actionWithTitle:@"OK"
@ -90,9 +134,20 @@ NSMutableString *selectedBackupImageURL;
handler:^(UIAlertAction * action)
{
//RUN RESTORE SCRIPT
NSTask *restoreTask = [[NSTask alloc] init];
[restoreTask setLaunchPath:@"/usr/bin/bash"];
[restoreTask setArguments:@[ @"FBRestore", backupNameSelected]];
[restoreTask launch];
[alert dismissViewControllerAnimated:YES completion:nil];
UIAlertController * finishedRestoreAlert= [UIAlertController
alertControllerWithTitle:@"Restoring from backup"
message:@"Your device will respring when the process is completed."
preferredStyle:UIAlertControllerStyleAlert];
[self presentViewController:finishedRestoreAlert animated:YES completion:nil];
[restoreBackupAlert dismissViewControllerAnimated:YES completion:nil];
}];
UIAlertAction* cancel = [UIAlertAction
@ -100,23 +155,46 @@ NSMutableString *selectedBackupImageURL;
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
[alert dismissViewControllerAnimated:YES completion:nil];
[restoreBackupAlert dismissViewControllerAnimated:YES completion:nil];
}];
[alert addAction:cancel];
[alert addAction:ok];
[restoreBackupAlert addAction:cancel];
[restoreBackupAlert addAction:ok];
[self presentViewController:alert animated:YES completion:nil];
[self presentViewController:restoreBackupAlert animated:YES completion:nil];
}
}
- (IBAction)updateBackup:(id)sender {
UIAlertController * alert= [UIAlertController
alertControllerWithTitle:@"Update Backup"
message:@"The selected backup will be overwritten!"
preferredStyle:UIAlertControllerStyleAlert];
if (backupNameSelected == nil){
UIAlertController * selectBackupAlert= [UIAlertController
alertControllerWithTitle:@"Select a Backup!"
message:@"Scroll through the list then let it settle on an item to select the backup."
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* ok = [UIAlertAction
actionWithTitle:@"ok"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
[selectBackupAlert dismissViewControllerAnimated:YES completion:nil];
}];
[selectBackupAlert addAction:ok];
[self presentViewController:selectBackupAlert animated:YES completion:nil];
}
else{
UIAlertController * updateBackupAlert= [UIAlertController
alertControllerWithTitle:@"Update Backup"
message:@"The selected backup will be overwritten! Please wait until the completion pop-up appears"
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* ok = [UIAlertAction
actionWithTitle:@"OK"
@ -125,8 +203,20 @@ NSMutableString *selectedBackupImageURL;
{
[updateBackupAlert dismissViewControllerAnimated:YES completion:nil];
NSTask *deleteTask = [[NSTask alloc] init];
[deleteTask setLaunchPath:@"/usr/bin/bash"];
[deleteTask setArguments:@[ @"FBDelete", backupNameSelected]];
[deleteTask launch];
[deleteTask waitUntilExit];
NSTask *createTask = [[NSTask alloc] init];
[createTask setLaunchPath:@"/usr/bin/bash"];
[createTask setArguments:@[ @"FBCreate", backupNameSelected]];
[createTask launch];
[createTask waitUntilExit];
[alert dismissViewControllerAnimated:YES completion:nil];
}];
UIAlertAction* cancel = [UIAlertAction
@ -134,24 +224,276 @@ NSMutableString *selectedBackupImageURL;
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
[alert dismissViewControllerAnimated:YES completion:nil];
[updateBackupAlert dismissViewControllerAnimated:YES completion:nil];
}];
[alert addAction:cancel];
[alert addAction:ok];
[updateBackupAlert addAction:cancel];
[updateBackupAlert addAction:ok];
[self presentViewController:alert animated:YES completion:nil];
[self presentViewController:updateBackupAlert animated:YES completion:nil];
}
}
- (IBAction)packageBackup:(id)sender {
if (backupNameSelected == nil){
UIAlertController * selectBackupAlert= [UIAlertController
alertControllerWithTitle:@"Select a Backup!"
message:@"Scroll through the list then let it settle on an item to select the backup."
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* ok = [UIAlertAction
actionWithTitle:@"ok"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
[selectBackupAlert dismissViewControllerAnimated:YES completion:nil];
}];
[selectBackupAlert addAction:ok];
[self presentViewController:selectBackupAlert animated:YES completion:nil];
}
else{
UIAlertController * packageBackupAlert= [UIAlertController
alertControllerWithTitle:@"Package Backup"
message:@"This will package the selected backup."
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* ok = [UIAlertAction
actionWithTitle:@"OK"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
//RUN RESTORE SCRIPT
[packageBackupAlert dismissViewControllerAnimated:YES completion:nil];
NSTask *packageTask = [[NSTask alloc] init];
[packageTask setLaunchPath:@"/usr/bin/bash"];
[packageTask setArguments:@[ @"FBPackage", backupNameSelected]];
[packageTask launch];
[packageTask waitUntilExit];
UIAlertController * finishedPackageAlert= [UIAlertController
alertControllerWithTitle:@"Packaging Complete"
message:@"The package can be found in [/User/Documents/FlashBack/GeneratedPackages/]."
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* ok = [UIAlertAction
actionWithTitle:@"ok"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
[finishedPackageAlert dismissViewControllerAnimated:YES completion:nil];
}];
[finishedPackageAlert addAction:ok];
[self presentViewController:finishedPackageAlert animated:YES completion:nil];
}];
UIAlertAction* cancel = [UIAlertAction
actionWithTitle:@"Cancel"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
[packageBackupAlert dismissViewControllerAnimated:YES completion:nil];
}];
[packageBackupAlert addAction:cancel];
[packageBackupAlert addAction:ok];
[self presentViewController:packageBackupAlert animated:YES completion:nil];
}
}
- (IBAction)unpackageBackup:(id)sender {
if (backupNameSelected == nil){
UIAlertController * selectBackupAlert= [UIAlertController
alertControllerWithTitle:@"Select a Backup!"
message:@"Scroll through the list then let it settle on an item to select the backup."
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* ok = [UIAlertAction
actionWithTitle:@"ok"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
[selectBackupAlert dismissViewControllerAnimated:YES completion:nil];
}];
[selectBackupAlert addAction:ok];
[self presentViewController:selectBackupAlert animated:YES completion:nil];
}
else{
UIAlertController * unpackageBackupAlert= [UIAlertController
alertControllerWithTitle:@"Unpackage Imported Backups"
message:@"This will importall backups in [/User/Documents/FlashBack/Unpackage/]."
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* ok = [UIAlertAction
actionWithTitle:@"OK"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
//RUN RESTORE SCRIPT
NSTask *packageTask = [[NSTask alloc] init];
[packageTask setLaunchPath:@"/usr/bin/bash"];
[packageTask setArguments:@[ @"FBUnpackage"]];
[packageTask launch];
[packageTask waitUntilExit];
UIAlertController * finishedUnpackageAlert= [UIAlertController
alertControllerWithTitle:@"Import Complete"
message:@"Repoen the app to view imported backups."
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* ok = [UIAlertAction
actionWithTitle:@"ok"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
[finishedUnpackageAlert dismissViewControllerAnimated:YES completion:nil];
}];
[finishedUnpackageAlert addAction:ok];
[self presentViewController:finishedUnpackageAlert animated:YES completion:nil];
}];
UIAlertAction* cancel = [UIAlertAction
actionWithTitle:@"Cancel"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
[unpackageBackupAlert dismissViewControllerAnimated:YES completion:nil];
}];
[unpackageBackupAlert addAction:cancel];
[unpackageBackupAlert addAction:ok];
[self presentViewController:unpackageBackupAlert animated:YES completion:nil];
}
}
- (IBAction)helpMenu:(id)sender {
UIAlertController * tutorialAlert= [UIAlertController
alertControllerWithTitle:@"Help"
message:@"Create Backup: This will prompt you to enter a name for the backup which will be displayed in the box above.\n\nRestore: This will revert your settings, wallpaper, and Icon Layout to the selected setup.\n\nUpdate: This will overwrite the selected backup to cleanly update it.\n\nPackage:This will generate a package in ZIP format for you to share or back up for later.\n\nUnpackage: This will install the aforementioned ZIP packages to be used by FlashBack.\n\nDelete: This will delete the selected backup. These backups cannot be recovered!"
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* ok = [UIAlertAction
actionWithTitle:@"ok"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
[tutorialAlert dismissViewControllerAnimated:YES completion:nil];
UIAlertController * infoAlert= [UIAlertController
alertControllerWithTitle:@"Known issues"
message:@"Scrolling through the picker view with no backups will crash the app.\n\nChanges to the list of backups are not reflected until the app is relaunched.\n\nIf a backup is not properly selected, and a button is pressed, it may cause the app to crash."
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* okay = [UIAlertAction
actionWithTitle:@"ok"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
[infoAlert dismissViewControllerAnimated:YES completion:nil];
UIAlertController * contactAlert= [UIAlertController
alertControllerWithTitle:@"Contact Me"
message:@"You can contact my via Twitter or Email\n\n@micahpgomez\n\nmpg13@micahpgomez.dev\n\nhttps://www.micahpgomez.dev"
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* okey = [UIAlertAction
actionWithTitle:@"ok"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
[contactAlert dismissViewControllerAnimated:YES completion:nil];
}];
[contactAlert addAction:okey];
[self presentViewController:contactAlert animated:YES completion:nil];
}];
[infoAlert addAction:okay];
[self presentViewController:infoAlert animated:YES completion:nil];
}];
[tutorialAlert addAction:ok];
[self presentViewController:tutorialAlert animated:YES completion:nil];
}
- (IBAction)deleteBackup:(id)sender {
UIAlertController * alert= [UIAlertController
alertControllerWithTitle:@"Delete BAckup"
message:@"The selected backup will be deleted!"
preferredStyle:UIAlertControllerStyleAlert];
- (IBAction)deleteBackup:(id)sender {
if (backupNameSelected == nil){
UIAlertController * selectBackupAlert= [UIAlertController
alertControllerWithTitle:@"Select a Backup!"
message:@"Scroll through the list then let it settle on an item to select the backup."
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* ok = [UIAlertAction
actionWithTitle:@"ok"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
[selectBackupAlert dismissViewControllerAnimated:YES completion:nil];
}];
[selectBackupAlert addAction:ok];
[self presentViewController:selectBackupAlert animated:YES completion:nil];
}
UIAlertController * deleteBackupAlert= [UIAlertController
alertControllerWithTitle:@"Delete Backup"
message:@"The selected backup will be deleted!"
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* ok = [UIAlertAction
actionWithTitle:@"OK"
@ -159,24 +501,30 @@ NSMutableString *selectedBackupImageURL;
handler:^(UIAlertAction * action)
{
NSTask *deleteTask = [[NSTask alloc] init];
[deleteTask setLaunchPath:@"/usr/bin/bash"];
[deleteTask setArguments:@[ @"FBDelete", backupNameSelected]];
[deleteTask launch];
[deleteTask waitUntilExit];
[alert dismissViewControllerAnimated:YES completion:nil];
[deleteBackupAlert dismissViewControllerAnimated:YES completion:nil];
}];
UIAlertAction* cancel = [UIAlertAction
actionWithTitle:@"Cancel"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
[alert dismissViewControllerAnimated:YES completion:nil];
[deleteBackupAlert dismissViewControllerAnimated:YES completion:nil];
}];
[alert addAction:cancel];
[alert addAction:ok];
[deleteBackupAlert addAction:cancel];
[deleteBackupAlert addAction:ok];
[self presentViewController:deleteBackupAlert animated:YES completion:nil];
[self presentViewController:alert animated:YES completion:nil];
}
@ -185,9 +533,6 @@ NSMutableString *selectedBackupImageURL;
[super viewDidLoad];
// Do any additional setup after loading the view.
selectedBackupText.text=@"Select a Backup";
//selectedBackupImage.backgroundColor=[UIColor grayColor];
selectedBackupPickerView.delegate=self;
selectedBackupPickerView.dataSource=self;
@ -197,15 +542,20 @@ NSMutableString *selectedBackupImageURL;
-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component{
NSString *backupNameSelected = [_backupFolderArray objectAtIndex:row];
backupNameSelected = [_backupFolderArray objectAtIndex:row];
selectedBackupText.text=backupNameSelected;
selectedBackupImageURL = [NSMutableString stringWithString: @"/Library/FlashBack/Backups/"];
[selectedBackupImageURL appendString: backupNameSelected];
[selectedBackupImageURL appendString: @"/bgimage.png"];
selectedBackupURL = [NSMutableString stringWithString: @"/Library/FlashBack/Backups/"];
[selectedBackupURL appendString: backupNameSelected];
selectedBackupImageURL=selectedBackupURL;
[selectedBackupImageURL appendString: @"/SBFolder/LockBackgroundThumbnail.jpg"];
NSLog(@"%@", selectedBackupImageURL);
selectedBackupImage.image=[UIImage imageNamed:selectedBackupImageURL];
NSURL *url = [NSURL fileURLWithPath:selectedBackupImageURL];
NSData *data = [NSData dataWithContentsOfURL:url];
selectedBackupImage.image = [UIImage imageWithData:data];
NSLog(@"%@", backupNameSelected);
@ -226,6 +576,5 @@ NSMutableString *selectedBackupImageURL;
return _backupFolderArray[row];
}
@end