Procházet zdrojové kódy

1.修改iOS Apex Mobile Detail,增加分享。

Pen Li před 8 roky
rodič
revize
cb70be5242
19 změnil soubory, kde provedl 245 přidání a 50 odebrání
  1. 3 1
      Apex Mobile/Apex Mobile/Base.lproj/Localizable.strings
  2. 68 11
      Apex Mobile/Apex Mobile/DetailTabBarController.m
  3. 55 36
      Apex Mobile/Apex Mobile/LPShareActivity.m
  4. 115 0
      Apex Mobile/Apex Mobile/NewImages.xcassets/ic_email.imageset/Contents.json
  5. binární
      Apex Mobile/Apex Mobile/NewImages.xcassets/ic_email.imageset/appicon_1024.png
  6. binární
      Apex Mobile/Apex Mobile/NewImages.xcassets/ic_email.imageset/appicon_120.png
  7. binární
      Apex Mobile/Apex Mobile/NewImages.xcassets/ic_email.imageset/appicon_152.png
  8. binární
      Apex Mobile/Apex Mobile/NewImages.xcassets/ic_email.imageset/appicon_167.png
  9. binární
      Apex Mobile/Apex Mobile/NewImages.xcassets/ic_email.imageset/appicon_180.png
  10. binární
      Apex Mobile/Apex Mobile/NewImages.xcassets/ic_email.imageset/appicon_20.png
  11. binární
      Apex Mobile/Apex Mobile/NewImages.xcassets/ic_email.imageset/appicon_29.png
  12. binární
      Apex Mobile/Apex Mobile/NewImages.xcassets/ic_email.imageset/appicon_40.png
  13. binární
      Apex Mobile/Apex Mobile/NewImages.xcassets/ic_email.imageset/appicon_58.png
  14. binární
      Apex Mobile/Apex Mobile/NewImages.xcassets/ic_email.imageset/appicon_60.png
  15. binární
      Apex Mobile/Apex Mobile/NewImages.xcassets/ic_email.imageset/appicon_76.png
  16. binární
      Apex Mobile/Apex Mobile/NewImages.xcassets/ic_email.imageset/appicon_80.png
  17. binární
      Apex Mobile/Apex Mobile/NewImages.xcassets/ic_email.imageset/appicon_87.png
  18. 1 1
      Apex Mobile/Apex Mobile/config.h
  19. 3 1
      Apex Mobile/Apex Mobile/zh-Hans.lproj/Localizable.strings

+ 3 - 1
Apex Mobile/Apex Mobile/Base.lproj/Localizable.strings

@@ -53,4 +53,6 @@
 "about_ver_key"="Version:";
 "about_support_key"="Support:";
 "about_support_value"="USAIRedAnt@united-us.net";
-"search"="Search Document";
+"search_document"="Search Document";
+"share_detail"="Share Detail";
+"save_detail"="Save Detail";

+ 68 - 11
Apex Mobile/Apex Mobile/DetailTabBarController.m

@@ -8,6 +8,7 @@
  
 #import "DetailTabBarController.h"
 #import "AMResultViewController.h"
+#import "LPShareActivity.h"
 
 @interface DetailTabBarController () <UITabBarControllerDelegate>
 
@@ -302,13 +303,15 @@
     [menuBtn addTarget:self action:@selector(menuClick:) forControlEvents:UIControlEventTouchUpInside];
     UIBarButtonItem *menuButton = [[UIBarButtonItem alloc] initWithCustomView:menuBtn];
     
-    DetailPageViewController *pageVC = (DetailPageViewController *)self.selectedViewController;
+//    DetailPageViewController *pageVC = (DetailPageViewController *)self.selectedViewController;
+//
+//    if([pageVC.function_name isEqualToString:@"Cargo Tracking"] || [pageVC.title isEqualToString:@"Tracing"]) {
+//        self.navigationItem.rightBarButtonItems = @[closeButton,fixBtn,menuButton];
+//    } else {
+//        self.navigationItem.rightBarButtonItems = @[closeButton,fixBtn,saveButton];
+//    }
     
-    if([pageVC.function_name isEqualToString:@"Cargo Tracking"] || [pageVC.title isEqualToString:@"Tracing"]) {
-        self.navigationItem.rightBarButtonItems = @[closeButton,fixBtn,menuButton];
-    } else {
-        self.navigationItem.rightBarButtonItems = @[closeButton,fixBtn,saveButton];
-    }
+    self.navigationItem.rightBarButtonItems = @[closeButton,fixBtn,menuButton];
 }
 
 - (void)searchDocument {
@@ -336,24 +339,78 @@
     }
 }
 
+- (void)shareDetail {
+    
+    DetailPageViewController *pageVC = (DetailPageViewController *)self.selectedViewController;
+    
+    NSString *to = [pageVC.content.originContent objectForKey:@"email"];
+    NSString *subject = [pageVC.content.originContent objectForKey:@"email_subject"];
+    NSString *content = [pageVC.content.originContent objectForKey:@"email_content"];
+    
+//    content = @"Test Body";
+    NSArray *activityItems = nil;
+    if (content) {
+        activityItems = @[content];
+    }
+    
+    LPShareActivity *share = [[LPShareActivity alloc] init];
+    share.to = [to componentsSeparatedByString:@","];
+    share.subject = subject;
+    share.body = content;
+
+    
+    // 服务类型控制器
+    UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:@[share]];
+    activityViewController.excludedActivityTypes = @[UIActivityTypeMail];
+    activityViewController.modalInPopover = true;
+    [self presentViewController:activityViewController animated:YES completion:nil];
+    
+    // 选中分享类型
+    [activityViewController setCompletionWithItemsHandler:^(NSString * __nullable activityType, BOOL completed, NSArray * __nullable returnedItems, NSError * __nullable activityError){
+        
+        // 显示选中的分享类型
+        NSLog(@"act type %@",activityType);
+        
+        if (completed) {
+            NSLog(@"ok");
+        }else {
+            NSLog(@"not ok");
+        }
+        
+    }];
+}
+
 - (void)menuClick:(id)sender {
     
-    UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleAlert];
+    UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
     
     __weak typeof(self) weakSelf = self;
-    UIAlertAction *saveAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"save", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+    UIAlertAction *saveAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"save_detail", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
         [weakSelf saveDetail:nil];
     }];
     
-    UIAlertAction *searchAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"search", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+    UIAlertAction *searchAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"search_document", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
         [weakSelf searchDocument];
     }];
-    UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"cancel", nil) style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
+    
+    UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"cancel", nil) style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
         
     }];
     
+    UIAlertAction *shareAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"share_detail", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+        [self shareDetail];
+    }];
+    
     [alertVC addAction:saveAction];
-    [alertVC addAction:searchAction];
+    [alertVC addAction:shareAction];
+    
+    DetailPageViewController *pageVC = (DetailPageViewController *)self.selectedViewController;
+    
+    if([pageVC.function_name isEqualToString:@"Cargo Tracking"] || [pageVC.title isEqualToString:@"Tracing"]) {
+        [alertVC addAction:searchAction];
+    } else {
+        
+    }
     [alertVC addAction:cancelAction];
     
     [self presentViewController:alertVC animated:YES completion:nil];

+ 55 - 36
Apex Mobile/Apex Mobile/LPShareActivity.m

@@ -38,7 +38,7 @@ NSString *const LPActivityType = @"com.emerys.www.share.activity";
  *  服务显示图标
  */
 - (UIImage *)activityImage {
-    return [UIImage imageNamed:@"AppIcon"];
+    return [UIImage imageNamed:@"ic_email"];
 }
 
 
@@ -111,47 +111,66 @@ NSString *const LPActivityType = @"com.emerys.www.share.activity";
  *  点击自定义服务之后的操作
  */
 - (void)performActivity {
-    
-    MFMailComposeViewController *mailComposer = [MFMailComposeViewController new];
-    
-    [mailComposer setToRecipients:self.to];
-    [mailComposer setSubject:self.subject];
-    [mailComposer setMessageBody:[NSString stringWithFormat:@"<html><p>%@</p></html>",self.body] isHTML:YES];
-    
-    if (self.filePath.length) {
-        NSData *data = [NSData dataWithContentsOfFile:self.filePath];
-        NSString *fileName = [[self.filePath stringByDeletingPathExtension] lastPathComponent];
-        [mailComposer addAttachmentData:data mimeType:@"application/pdf" fileName:fileName];
-    }
-    
-    mailComposer.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
-    
-    mailComposer.modalPresentationStyle = UIModalPresentationFormSheet;
-    
-    AppDelegate *delagate =(AppDelegate *) [[UIApplication sharedApplication]delegate];
-    
-    mailComposer.mailComposeDelegate = [[(UINavigationController *)delagate.window.rootViewController viewControllers] lastObject]; // Set the delegate
-    
-    
-    [(UIViewController *)[[(UINavigationController *)delagate.window.rootViewController viewControllers] lastObject] presentViewController:mailComposer animated:YES completion:nil];
-
-//    NSLog(@"选中了自定义服务");
 //
-//    MFMailComposeViewController *mailComposeViewController = [[MFMailComposeViewController alloc] init];
+//    MFMailComposeViewController *mailComposer = [MFMailComposeViewController new];
 //
-//    [mailComposeViewController setToRecipients:self.to];
-//    [mailComposeViewController setSubject:self.subject];
-//    [mailComposeViewController setMessageBody:[NSString stringWithFormat:@"<html><p>%@</p></html>",self.body] isHTML:YES];
+//    [mailComposer setToRecipients:self.to];
+//    [mailComposer setSubject:self.subject];
+//    [mailComposer setMessageBody:[NSString stringWithFormat:@"<html><p>%@</p></html>",self.body] isHTML:YES];
 //
 //    if (self.filePath.length) {
 //        NSData *data = [NSData dataWithContentsOfFile:self.filePath];
 //        NSString *fileName = [[self.filePath stringByDeletingPathExtension] lastPathComponent];
-//        [mailComposeViewController addAttachmentData:data mimeType:@"application/pdf" fileName:fileName];
+//        [mailComposer addAttachmentData:data mimeType:@"application/pdf" fileName:fileName];
 //    }
-    [self activityDidFinish:YES];
-////    return mailComposeViewController;
-//        if (_handle) {
-//            _handle(mailComposeViewController);
-//        }
+//
+//    mailComposer.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
+//
+//    mailComposer.modalPresentationStyle = UIModalPresentationFormSheet;
+//
+//    AppDelegate *delagate =(AppDelegate *) [[UIApplication sharedApplication]delegate];
+//
+//    mailComposer.mailComposeDelegate = [[(UINavigationController *)delagate.window.rootViewController viewControllers] lastObject]; // Set the delegate
+//
+//
+//    [(UIViewController *)[[(UINavigationController *)delagate.window.rootViewController viewControllers] lastObject] presentViewController:mailComposer animated:YES completion:nil];
+//
+////    NSLog(@"选中了自定义服务");
+////
+////    MFMailComposeViewController *mailComposeViewController = [[MFMailComposeViewController alloc] init];
+////
+////    [mailComposeViewController setToRecipients:self.to];
+////    [mailComposeViewController setSubject:self.subject];
+////    [mailComposeViewController setMessageBody:[NSString stringWithFormat:@"<html><p>%@</p></html>",self.body] isHTML:YES];
+////
+////    if (self.filePath.length) {
+////        NSData *data = [NSData dataWithContentsOfFile:self.filePath];
+////        NSString *fileName = [[self.filePath stringByDeletingPathExtension] lastPathComponent];
+////        [mailComposeViewController addAttachmentData:data mimeType:@"application/pdf" fileName:fileName];
+////    }
+//    [self activityDidFinish:YES];
+//////    return mailComposeViewController;
+////        if (_handle) {
+////            _handle(mailComposeViewController);
+////        }
+}
+
+- (void)setTo:(NSArray *)to {
+    _to = to;
+}
+
+- (void)setSubject:(NSString *)subject {
+    if (subject == nil) {
+        subject = @"";
+    }
+    _subject = subject;
 }
+
+- (void)setBody:(NSString *)body {
+    if (body == nil) {
+        body = @"";
+    }
+    _body = body;
+}
+
 @end

+ 115 - 0
Apex Mobile/Apex Mobile/NewImages.xcassets/ic_email.imageset/Contents.json

@@ -0,0 +1,115 @@
+{
+  "images" : [
+    {
+      "idiom" : "iphone",
+      "scale" : "1x"
+    },
+    {
+      "idiom" : "iphone",
+      "filename" : "appicon_120.png",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "iphone",
+      "filename" : "appicon_120.png",
+      "scale" : "3x"
+    },
+    {
+      "idiom" : "ipad",
+      "filename" : "appicon_20.png",
+      "scale" : "1x"
+    },
+    {
+      "idiom" : "ipad",
+      "filename" : "appicon_152.png",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "ios-marketing",
+      "filename" : "appicon_1024.png",
+      "scale" : "1x"
+    },
+    {
+      "idiom" : "iphone",
+      "filename" : "appicon_40.png",
+      "unassigned" : true,
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "iphone",
+      "filename" : "appicon_58.png",
+      "unassigned" : true,
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "iphone",
+      "filename" : "appicon_80.png",
+      "unassigned" : true,
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "iphone",
+      "filename" : "appicon_60.png",
+      "unassigned" : true,
+      "scale" : "3x"
+    },
+    {
+      "idiom" : "iphone",
+      "filename" : "appicon_87.png",
+      "unassigned" : true,
+      "scale" : "3x"
+    },
+    {
+      "idiom" : "iphone",
+      "filename" : "appicon_180.png",
+      "unassigned" : true,
+      "scale" : "3x"
+    },
+    {
+      "idiom" : "ipad",
+      "filename" : "appicon_29.png",
+      "unassigned" : true,
+      "scale" : "1x"
+    },
+    {
+      "idiom" : "ipad",
+      "filename" : "appicon_40.png",
+      "unassigned" : true,
+      "scale" : "1x"
+    },
+    {
+      "idiom" : "ipad",
+      "filename" : "appicon_76.png",
+      "unassigned" : true,
+      "scale" : "1x"
+    },
+    {
+      "idiom" : "ipad",
+      "filename" : "appicon_40.png",
+      "unassigned" : true,
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "ipad",
+      "filename" : "appicon_58.png",
+      "unassigned" : true,
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "ipad",
+      "filename" : "appicon_80.png",
+      "unassigned" : true,
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "ipad",
+      "filename" : "appicon_167.png",
+      "unassigned" : true,
+      "scale" : "2x"
+    }
+  ],
+  "info" : {
+    "version" : 1,
+    "author" : "xcode"
+  }
+}

binární
Apex Mobile/Apex Mobile/NewImages.xcassets/ic_email.imageset/appicon_1024.png


binární
Apex Mobile/Apex Mobile/NewImages.xcassets/ic_email.imageset/appicon_120.png


binární
Apex Mobile/Apex Mobile/NewImages.xcassets/ic_email.imageset/appicon_152.png


binární
Apex Mobile/Apex Mobile/NewImages.xcassets/ic_email.imageset/appicon_167.png


binární
Apex Mobile/Apex Mobile/NewImages.xcassets/ic_email.imageset/appicon_180.png


binární
Apex Mobile/Apex Mobile/NewImages.xcassets/ic_email.imageset/appicon_20.png


binární
Apex Mobile/Apex Mobile/NewImages.xcassets/ic_email.imageset/appicon_29.png


binární
Apex Mobile/Apex Mobile/NewImages.xcassets/ic_email.imageset/appicon_40.png


binární
Apex Mobile/Apex Mobile/NewImages.xcassets/ic_email.imageset/appicon_58.png


binární
Apex Mobile/Apex Mobile/NewImages.xcassets/ic_email.imageset/appicon_60.png


binární
Apex Mobile/Apex Mobile/NewImages.xcassets/ic_email.imageset/appicon_76.png


binární
Apex Mobile/Apex Mobile/NewImages.xcassets/ic_email.imageset/appicon_80.png


binární
Apex Mobile/Apex Mobile/NewImages.xcassets/ic_email.imageset/appicon_87.png


+ 1 - 1
Apex Mobile/Apex Mobile/config.h

@@ -12,7 +12,7 @@
 
 # ifdef DEBUG
 
-#define test_server
+//#define test_server
 
 # endif
 

+ 3 - 1
Apex Mobile/Apex Mobile/zh-Hans.lproj/Localizable.strings

@@ -52,4 +52,6 @@
 "about_ver_key"="版本:";
 "about_support_key"="技术支持:";
 "about_support_value"="USAIRedAnt@united-us.net";
-"search"="搜索文档";
+"search_document"="搜索文档";
+"share_detail"="分享详情";
+"save_detail"="保存详情";