Export values to plist through email #12

Closed
wants to merge 5 commits into
from

Projects

None yet

3 participants

@kcharwood
Contributor

Easy way to share. Let me know your thoughts!

@grp
Contributor
grp commented Mar 30, 2014

This is a great idea. I wonder if it would make sense to export all categories, rather than just one — maybe an action sheet that replaces the current "Reset" button with "Reset" and "Email" options?

@pruthvikar

It would be cool if you could share and import configs in one click. I'd love to implement this via URL schemes!

@kcharwood
Contributor

Sure I think that makes tons of sense.

How about a tool bar on the bottom of the main view controller, with the share in the bottom right?

I can take a stab at it today.

Kevin Harwood


Sent from my iPhone

On Mar 29, 2014, at 8:58 PM, Grant Paul notifications@github.com wrote:

This is a great idea. I wonder if it would make sense to export all categories, rather than just one — maybe an action sheet that replaces the current "Reset" button with "Reset" and "Email" options?


Reply to this email directly or view it on GitHub.

@kcharwood
Contributor

Sorry misread your comment. I thought you said replace reset, but you said replace it with an action sheet...

Still early in the morning.

Would you prefer the tool bar or the action sheet?

Kevin Harwood


Sent from my iPhone

On Mar 29, 2014, at 8:58 PM, Grant Paul notifications@github.com wrote:

This is a great idea. I wonder if it would make sense to export all categories, rather than just one — maybe an action sheet that replaces the current "Reset" button with "Reset" and "Email" options?


Reply to this email directly or view it on GitHub.

@kcharwood
Contributor

@grpaul added a toolbar and action to the main view controller, and removed it from the child.

Now exports everything.

@grp grp commented on an outdated diff Apr 9, 2014
FBTweak/_FBTweakCategoryViewController.m
@@ -33,14 +37,27 @@ - (void)viewDidLoad
{
[super viewDidLoad];
- _tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
+ CGFloat toolBarHeight = 44.0;
@grp
grp Apr 9, 2014 Contributor

Rather than hardcoding this, maybe call -sizeToFit on the UIToolbar to use the default height?

@grp grp commented on an outdated diff Apr 9, 2014
FBTweak/_FBTweakCategoryViewController.m
@@ -33,14 +37,27 @@ - (void)viewDidLoad
{
[super viewDidLoad];
- _tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
+ CGFloat toolBarHeight = 44.0;
+ _toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, CGRectGetHeight(self.view.bounds) - toolBarHeight, CGRectGetWidth(self.view.bounds), toolBarHeight)];
+ [_toolbar setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
+ [self.view addSubview:_toolbar];
+
+ CGRect tableViewFrame = self.view.bounds;
+ tableViewFrame.size.height -= CGRectGetHeight(_toolbar.bounds);
@grp
grp Apr 9, 2014 Contributor

Rather than resizing this shorter, for iOS 7 maybe it's best to include it in the contentInset?

@grp grp commented on an outdated diff Apr 9, 2014
FBTweak/_FBTweakCategoryViewController.m
@@ -98,4 +120,44 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
[_delegate tweakCategoryViewController:self selectedCategory:category];
}
+- (void)_exportTweaks
+{
+ MFMailComposeViewController *mailComposeViewController = [[MFMailComposeViewController alloc] init];
+ mailComposeViewController.mailComposeDelegate = self;
+
+
+ NSMutableDictionary *categoryDictionary = [NSMutableDictionary new];
+ [self.store.tweakCategories
@grp
grp Apr 9, 2014 Contributor

I wonder if creating this could be a method on the FBTweakStore? That way, other clients could easily build their own export UIs.

@grp grp commented on an outdated diff Apr 9, 2014
FBTweak/_FBTweakCategoryViewController.m
+ for (FBTweak *tweak in collection.tweaks) {
+ [tweakDictionary setValue:tweak.currentValue forKey:tweak.name];
+ }
+ [collectionDictionary setValue:tweakDictionary forKey:collection.name];
+ }
+ [categoryDictionary setValue:collectionDictionary forKey:category.name];
+ }];
+
+ NSString *version = [[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString*)kCFBundleVersionKey];
+ NSString *appName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"];
+
+ NSString *subject = [NSString stringWithFormat:@"%@ Tweaks",appName];
+ NSString *body = [NSString stringWithFormat:@"%@ \n%@", appName, version];
+ NSData *data = [NSKeyedArchiver archivedDataWithRootObject:categoryDictionary];
+
+ NSString *fileName = [NSString stringWithFormat:@"%@_tweaks.plist", appName];
@grp
grp Apr 9, 2014 Contributor

I like the filename here — can't get confused between apps (& versions).

@kcharwood
Contributor

I have most of this ready, although i noticed i have a problem with the dictionary export to a plist.

I'll let you know when its ready 🍻

@kcharwood
Contributor

This one is all ready to go!

@grp
Contributor
grp commented Apr 29, 2014

I converted it to NSCoding and landed it as 94dc87c. Thanks for the patch!

@grp grp closed this Apr 29, 2014
@kcharwood
Contributor

Good thinking. Looks good! 👍

When are you planning on releasing a new 1.1?

@grp
Contributor
grp commented May 2, 2014

I'm doing some testing this week to see if I can find any other bugs to fix, but after that I'll do a release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment