Commit 7a035955e79088ff7c37e76ab3fe93073a147a76
1 parent
5111c4db95
Exists in
master
and in
1 other branch
Share LINE
Showing 3 changed files with 25 additions and 9 deletions Inline Diff
LifeLog/LifeLog/Info.plist
| 1 | <?xml version="1.0" encoding="UTF-8"?> | 1 | <?xml version="1.0" encoding="UTF-8"?> |
| 2 | <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | 2 | <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> |
| 3 | <plist version="1.0"> | 3 | <plist version="1.0"> |
| 4 | <dict> | 4 | <dict> |
| 5 | <key>CFBundleDevelopmentRegion</key> | 5 | <key>CFBundleDevelopmentRegion</key> |
| 6 | <string>en</string> | 6 | <string>en</string> |
| 7 | <key>CFBundleExecutable</key> | 7 | <key>CFBundleExecutable</key> |
| 8 | <string>$(EXECUTABLE_NAME)</string> | 8 | <string>$(EXECUTABLE_NAME)</string> |
| 9 | <key>CFBundleIdentifier</key> | 9 | <key>CFBundleIdentifier</key> |
| 10 | <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> | 10 | <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> |
| 11 | <key>CFBundleInfoDictionaryVersion</key> | 11 | <key>CFBundleInfoDictionaryVersion</key> |
| 12 | <string>6.0</string> | 12 | <string>6.0</string> |
| 13 | <key>CFBundleName</key> | 13 | <key>CFBundleName</key> |
| 14 | <string>$(PRODUCT_NAME)</string> | 14 | <string>$(PRODUCT_NAME)</string> |
| 15 | <key>CFBundlePackageType</key> | 15 | <key>CFBundlePackageType</key> |
| 16 | <string>APPL</string> | 16 | <string>APPL</string> |
| 17 | <key>CFBundleShortVersionString</key> | 17 | <key>CFBundleShortVersionString</key> |
| 18 | <string>1.0</string> | 18 | <string>1.0</string> |
| 19 | <key>CFBundleURLTypes</key> | ||
| 20 | <array> | ||
| 21 | <dict/> | ||
| 22 | </array> | ||
| 19 | <key>CFBundleVersion</key> | 23 | <key>CFBundleVersion</key> |
| 20 | <string>1</string> | 24 | <string>1</string> |
| 25 | <key>LSApplicationQueriesSchemes</key> | ||
| 26 | <array> | ||
| 27 | <string>line</string> | ||
| 28 | </array> | ||
| 21 | <key>LSRequiresIPhoneOS</key> | 29 | <key>LSRequiresIPhoneOS</key> |
| 22 | <true/> | 30 | <true/> |
| 31 | <key>NSAppTransportSecurity</key> | ||
| 32 | <dict> | ||
| 33 | <key>NSAllowsArbitraryLoads</key> | ||
| 34 | <true/> | ||
| 35 | </dict> | ||
| 36 | <key>NSCameraUsageDescription</key> | ||
| 37 | <string>to take photos and video</string> | ||
| 23 | <key>NSMotionUsageDescription</key> | 38 | <key>NSMotionUsageDescription</key> |
| 24 | <string>$(PRODUCT_NAME) motion use</string> | 39 | <string>$(PRODUCT_NAME) motion use</string> |
| 40 | <key>NSPhotoLibraryUsageDescription</key> | ||
| 41 | <string>to save photos and videos</string> | ||
| 25 | <key>UILaunchStoryboardName</key> | 42 | <key>UILaunchStoryboardName</key> |
| 26 | <string>LaunchScreen</string> | 43 | <string>LaunchScreen</string> |
| 27 | <key>UIRequiredDeviceCapabilities</key> | 44 | <key>UIRequiredDeviceCapabilities</key> |
| 28 | <array> | 45 | <array> |
| 29 | <string>armv7</string> | 46 | <string>armv7</string> |
| 30 | </array> | 47 | </array> |
| 31 | <key>UIStatusBarHidden</key> | 48 | <key>UIStatusBarHidden</key> |
| 32 | <true/> | 49 | <true/> |
| 33 | <key>UISupportedInterfaceOrientations</key> | 50 | <key>UISupportedInterfaceOrientations</key> |
| 34 | <array> | 51 | <array> |
| 35 | <string>UIInterfaceOrientationPortrait</string> | 52 | <string>UIInterfaceOrientationPortrait</string> |
| 36 | </array> | 53 | </array> |
| 37 | <key>UISupportedInterfaceOrientations~ipad</key> | 54 | <key>UISupportedInterfaceOrientations~ipad</key> |
| 38 | <array> | 55 | <array> |
| 39 | <string>UIInterfaceOrientationPortrait</string> | 56 | <string>UIInterfaceOrientationPortrait</string> |
| 40 | <string>UIInterfaceOrientationPortraitUpsideDown</string> | 57 | <string>UIInterfaceOrientationPortraitUpsideDown</string> |
| 41 | <string>UIInterfaceOrientationLandscapeLeft</string> | 58 | <string>UIInterfaceOrientationLandscapeLeft</string> |
| 42 | <string>UIInterfaceOrientationLandscapeRight</string> | 59 | <string>UIInterfaceOrientationLandscapeRight</string> |
| 43 | </array> | 60 | </array> |
| 44 | <key>UIViewControllerBasedStatusBarAppearance</key> | 61 | <key>UIViewControllerBasedStatusBarAppearance</key> |
| 45 | <false/> | 62 | <false/> |
| 46 | <key>NSAppTransportSecurity</key> | ||
| 47 | <dict> | ||
| 48 | <key>NSAllowsArbitraryLoads</key> |
LifeLog/LifeLog/Utilities.m
| 1 | // | 1 | // |
| 2 | // Utilities.m | 2 | // Utilities.m |
| 3 | // LifeLog | 3 | // LifeLog |
| 4 | // | 4 | // |
| 5 | // Created by Nguyen Van Phong on 7/29/17. | 5 | // Created by Nguyen Van Phong on 7/29/17. |
| 6 | // Copyright © 2017 PhongNV. All rights reserved. | 6 | // Copyright © 2017 PhongNV. All rights reserved. |
| 7 | // | 7 | // |
| 8 | 8 | ||
| 9 | #import <Social/Social.h> | 9 | #import <Social/Social.h> |
| 10 | #import <LineKit/Line.h> | ||
| 10 | 11 | ||
| 11 | #import "Utilities.h" | 12 | #import "Utilities.h" |
| 12 | 13 | ||
| 13 | @implementation Utilities | 14 | @implementation Utilities |
| 14 | + (NSString *)addCommaFromNumber:(NSInteger)number | 15 | + (NSString *)addCommaFromNumber:(NSInteger)number |
| 15 | { | 16 | { |
| 16 | NSNumberFormatter *fmt = [[NSNumberFormatter alloc] init]; | 17 | NSNumberFormatter *fmt = [[NSNumberFormatter alloc] init]; |
| 17 | [fmt setNumberStyle:NSNumberFormatterDecimalStyle]; | 18 | [fmt setNumberStyle:NSNumberFormatterDecimalStyle]; |
| 18 | [fmt setMaximumFractionDigits:0]; | 19 | [fmt setMaximumFractionDigits:0]; |
| 19 | NSString *result = [fmt stringFromNumber:@(number)]; | 20 | NSString *result = [fmt stringFromNumber:@(number)]; |
| 20 | return result; | 21 | return result; |
| 21 | } | 22 | } |
| 22 | 23 | ||
| 23 | + (UIColor *)convertHecToColor:(int) hex | 24 | + (UIColor *)convertHecToColor:(int) hex |
| 24 | { | 25 | { |
| 25 | return [UIColor colorWithRed:((float)((hex & 0xFF0000) >> 16))/255.0 \ | 26 | return [UIColor colorWithRed:((float)((hex & 0xFF0000) >> 16))/255.0 \ |
| 26 | green:((float)((hex & 0xFF00) >> 8))/255.0 \ | 27 | green:((float)((hex & 0xFF00) >> 8))/255.0 \ |
| 27 | blue:((float)(hex & 0xFF))/255.0 alpha:1.0]; | 28 | blue:((float)(hex & 0xFF))/255.0 alpha:1.0]; |
| 28 | } | 29 | } |
| 29 | 30 | ||
| 30 | + (void)showErrorMessage:(NSString *)message withViewController:(UIViewController *)vc | 31 | + (void)showErrorMessage:(NSString *)message withViewController:(UIViewController *)vc |
| 31 | { | 32 | { |
| 32 | if (message.length > 0) { | 33 | if (message.length > 0) { |
| 33 | UIAlertController * alert= [UIAlertController | 34 | UIAlertController * alert= [UIAlertController |
| 34 | alertControllerWithTitle:@"Error" | 35 | alertControllerWithTitle:@"Error" |
| 35 | message:message | 36 | message:message |
| 36 | preferredStyle:UIAlertControllerStyleAlert]; | 37 | preferredStyle:UIAlertControllerStyleAlert]; |
| 37 | 38 | ||
| 38 | UIAlertAction* ok = [UIAlertAction | 39 | UIAlertAction* ok = [UIAlertAction |
| 39 | actionWithTitle:@"OK" | 40 | actionWithTitle:@"OK" |
| 40 | style:UIAlertActionStyleDefault | 41 | style:UIAlertActionStyleDefault |
| 41 | handler:^(UIAlertAction * action) | 42 | handler:^(UIAlertAction * action) |
| 42 | { | 43 | { |
| 43 | [alert dismissViewControllerAnimated:YES completion:nil]; | 44 | [alert dismissViewControllerAnimated:YES completion:nil]; |
| 44 | 45 | ||
| 45 | }]; | 46 | }]; |
| 46 | 47 | ||
| 47 | [alert addAction:ok]; | 48 | [alert addAction:ok]; |
| 48 | 49 | ||
| 49 | [vc presentViewController:alert animated:YES completion:nil]; | 50 | [vc presentViewController:alert animated:YES completion:nil]; |
| 50 | } | 51 | } |
| 51 | } | 52 | } |
| 52 | 53 | ||
| 53 | + (void) shareFacebook : (NSString *) content withViewController:(UIViewController *)vc { | 54 | + (void) shareFacebook : (NSString *) content withViewController:(UIViewController *)vc { |
| 54 | if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) | 55 | if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) |
| 55 | { | 56 | { |
| 56 | SLComposeViewController *composeViewController = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook]; | 57 | SLComposeViewController *composeViewController = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook]; |
| 57 | 58 | ||
| 58 | [composeViewController setInitialText:content]; | 59 | [composeViewController setInitialText:content]; |
| 59 | [composeViewController setCompletionHandler:^(SLComposeViewControllerResult result) { | 60 | [composeViewController setCompletionHandler:^(SLComposeViewControllerResult result) { |
| 60 | 61 | ||
| 61 | switch (result) { | 62 | switch (result) { |
| 62 | case SLComposeViewControllerResultCancelled: | 63 | case SLComposeViewControllerResultCancelled: |
| 63 | NSLog(@"canceled"); | 64 | NSLog(@"canceled"); |
| 64 | break; | 65 | break; |
| 65 | case SLComposeViewControllerResultDone: | 66 | case SLComposeViewControllerResultDone: |
| 66 | NSLog(@"done"); | 67 | NSLog(@"done"); |
| 67 | break; | 68 | break; |
| 68 | default: | 69 | default: |
| 69 | break; | 70 | break; |
| 70 | } | 71 | } |
| 71 | }]; | 72 | }]; |
| 72 | [vc presentViewController:composeViewController animated:YES completion:nil]; | 73 | [vc presentViewController:composeViewController animated:YES completion:nil]; |
| 73 | } | 74 | } |
| 74 | else { | 75 | else { |
| 75 | [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"App-Prefs:root=FACEBOOK"]]; | 76 | [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"App-Prefs:root=FACEBOOK"]]; |
| 76 | } | 77 | } |
| 77 | } | 78 | } |
| 78 | 79 | ||
| 79 | + (void) shareTwitter : (NSString *) content withViewController:(UIViewController *)vc { | 80 | + (void) shareTwitter : (NSString *) content withViewController:(UIViewController *)vc { |
| 80 | if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter]) | 81 | if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter]) |
| 81 | { | 82 | { |
| 82 | SLComposeViewController *composeViewController = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter]; | 83 | SLComposeViewController *composeViewController = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter]; |
| 83 | 84 | ||
| 84 | [composeViewController setInitialText:content]; | 85 | [composeViewController setInitialText:content]; |
| 85 | [composeViewController setCompletionHandler:^(SLComposeViewControllerResult result) { | 86 | [composeViewController setCompletionHandler:^(SLComposeViewControllerResult result) { |
| 86 | 87 | ||
| 87 | switch (result) { | 88 | switch (result) { |
| 88 | case SLComposeViewControllerResultCancelled: | 89 | case SLComposeViewControllerResultCancelled: |
| 89 | NSLog(@"canceled"); | 90 | NSLog(@"canceled"); |
| 90 | break; | 91 | break; |
| 91 | case SLComposeViewControllerResultDone: | 92 | case SLComposeViewControllerResultDone: |
| 92 | NSLog(@"done"); | 93 | NSLog(@"done"); |
| 93 | break; | 94 | break; |
| 94 | default: | 95 | default: |
| 95 | break; | 96 | break; |
| 96 | } | 97 | } |
| 97 | }]; | 98 | }]; |
| 98 | [vc presentViewController:composeViewController animated:YES completion:nil]; | 99 | [vc presentViewController:composeViewController animated:YES completion:nil]; |
| 99 | } | 100 | } |
| 100 | else { | 101 | else { |
| 101 | [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"App-Prefs:root=TWITTER"]]; | 102 | [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"App-Prefs:root=TWITTER"]]; |
| 102 | } | 103 | } |
| 103 | } | 104 | } |
| 104 | 105 | ||
| 105 | + (void) shareLine : (NSString *) content withViewController:(UIViewController *)vc { | 106 | + (void) shareLine : (NSString *) content withViewController:(UIViewController *)vc { |
| 107 | if (![Line isLineInstalled]) { | ||
| 108 | [self showErrorMessage:@"Install Line app first" withViewController:vc]; | ||
| 109 | } | ||
| 110 | else { | ||
| 111 | [Line shareText:content]; | ||
| 112 | } | ||
| 106 | } | 113 | } |
| 107 | 114 | ||
| 108 | + (void) shareEmail : (NSString *) content withViewController:(UIViewController *)vc { | 115 | + (void) shareEmail : (NSString *) content withViewController:(UIViewController *)vc { |
| 109 | } | 116 | } |
| 110 | @end | 117 | @end |
| 111 | 118 |
LifeLog/Podfile
| 1 | platform :ios, '9.0' | 1 | platform :ios, '9.0' |
| 2 | use_frameworks! | 2 | use_frameworks! |
| 3 | 3 | ||
| 4 | target 'LifeLog' do | 4 | target 'LifeLog' do |
| 5 | pod 'CircleProgressBar' | 5 | pod 'CircleProgressBar' |
| 6 | pod 'MBProgressHUD', '~> 1.0.0' | 6 | pod 'MBProgressHUD', '~> 1.0.0' |
| 7 | pod 'Charts' | 7 | pod 'Charts' |
| 8 | pod 'LineKit' | ||
| 8 | end | 9 | end |
| 9 | 10 |