Ray Zhang 12 éve
szülő
commit
202e3401bc

+ 1 - 1
Apex Mobile/Apex Mobile/Apex Mobile-Info.plist

@@ -21,7 +21,7 @@
 	<key>CFBundleSignature</key>
 	<string>????</string>
 	<key>CFBundleVersion</key>
-	<string>140515</string>
+	<string>140517</string>
 	<key>LSRequiresIPhoneOS</key>
 	<true/>
 	<key>UIFileSharingEnabled</key>

+ 4 - 0
Apex Mobile/Apex Mobile/ApexMobileAppDelegate.m

@@ -86,6 +86,10 @@
     NSLog(@"userinfo:%@",userInfo);
     
     NSLog(@"收到推送消息:%@",[[userInfo objectForKey:@"aps"] objectForKey:@"alert"]);
+  
+    NSDictionary* objaps = [userInfo objectForKey:@"aps"];
+    [UIApplication sharedApplication].applicationIconBadgeNumber = [[objaps valueForKey:@"badge"] integerValue];
+    [[NSNotificationCenter defaultCenter] postNotificationName:@"new notification" object:nil];
 }
 
 - (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {

+ 1 - 0
Apex Mobile/Apex Mobile/ApexMobileNetwork.h

@@ -16,6 +16,7 @@
 #import "DetailContent.h"
 #import <MessageUI/MessageUI.h>
 #import <MessageUI/MFMailComposeViewController.h>
+#define TEST
 @interface ApexMobileNetwork : NSObject
 +(void)Logout ;
 +(int)Authorize : (NSString*) user password:(NSString*) password ;

+ 22 - 14
Apex Mobile/Apex Mobile/ApexMobileNetwork.m

@@ -61,7 +61,7 @@
             }
             jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
             result = [[jsobj valueForKey:@"result"] intValue];
-
+            
         }
         if(result!=AP_USER_AUTH)
         {
@@ -516,7 +516,7 @@
 
 +(void)post_without_return : (NSString*) url parameters:(NSMutableDictionary *) params //delegate:(id < NSURLConnectionDelegate >)delegate
 {
-
+    
     ApexMobileAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
     //分界线的标识符
     NSString *TWITTERFON_FORM_BOUNDARY = @"AaB03x";
@@ -650,10 +650,13 @@
     [params setValue:@"handset_search" forKey:@"action"];
     [params setValue:appDelegate.sessionid forKey:@"sessionid"];
     [params setValue:appDelegate.duid forKey:@"uuid"];
+    
+
+    
     [params setValue:[NSString stringWithFormat:@"%d",offset] forKey:@"offset"];
     [params setValue:[NSString stringWithFormat:@"%d",limit] forKey:@"limit"];
-//    [params setValue:@"20" forKey:@"limit"];
-
+    //    [params setValue:@"20" forKey:@"limit"];
+    
     NSData* json=[ApexMobileNetwork get_json:URL_PUSH parameters:params];
     if (json==nil)
     {
@@ -696,11 +699,11 @@
     [params setValue:@"Pull Message" forKey:@"module_name"];
     [params setValue:@"read_all" forKey:@"action_type"];
     [params setValue:@"handset_search" forKey:@"action"];
-//    [params setValue:appDelegate.sessionid forKey:@"sessionid"];
+    //    [params setValue:appDelegate.sessionid forKey:@"sessionid"];
     [params setValue:appDelegate.duid forKey:@"uuid"];
     [params setValue:before forKey:@"id"];
-
-
+    
+    
     NSData* json=[ApexMobileNetwork get_json:URL_PUSH parameters:params];
     if (json==nil)
     {
@@ -736,7 +739,7 @@
     
     ApexMobileAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
     
-//    NSString* sess
+    //    NSString* sess
     
     NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
     [params setValue:@"Pull Message" forKey:@"module_name"];
@@ -772,7 +775,7 @@
     if(result!= AP_MESSAGE_NEW)
         return nil;
     
-
+    
     return json;
     
 }
@@ -836,7 +839,7 @@
         if([area isEqualToString:@"null"])
             area=@"";
         
- 
+        
         if([company isEqual:[NSNull null]])
             company=@"";
         if(company==nil)
@@ -904,10 +907,10 @@
         sqlite3_bind_text(stmt, 2, [company UTF8String], -1, NULL);
         sqlite3_bind_text(stmt, 3, [city UTF8String], -1, NULL);
         sqlite3_bind_text(stmt, 4, [longitude UTF8String], -1, NULL);
-
+        
         sqlite3_bind_text(stmt, 5, [latitude UTF8String], -1, NULL);
-
-
+        
+        
         
         sqlite3_bind_text(stmt, 6, [address UTF8String], -1, NULL);
         sqlite3_bind_text(stmt, 7, [telephone UTF8String], -1, NULL);
@@ -916,7 +919,7 @@
         sqlite3_bind_text(stmt, 10, [email UTF8String], -1, NULL);
         if (sqlite3_step(stmt) != SQLITE_DONE)
         {
-
+            
             fprintf(stderr, "Error: insert search failed, error infomation: %s\nsql:%s\n", sqlite3_errmsg(db),sqlite3_sql(stmt));
         }
         sqlite3_reset(stmt);
@@ -1143,6 +1146,11 @@
     [params setValue:user forKey:@"user"];
     [params setValue:password forKey:@"password"];
     [params setValue:[NSString stringWithFormat:@"%ld",ver]  forKey:@"auth_ver"];
+#ifdef TEST
+    [params setValue:@"true" forKey:@"is_debug"];
+#else
+    [params setValue:@"false" forKey:@"is_debug"];
+#endif
     NSData* json=[ApexMobileNetwork get_json:URL_UPDATE_AUTH parameters:params];
     if(json==nil)
         return RESULT_NET_ERROR;

+ 4 - 3
Apex Mobile/Apex Mobile/Base.lproj/Main_iPhone.storyboard

@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="5056" systemVersion="13C1021" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" initialViewController="Lfr-X7-cX2">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="5056" systemVersion="13D65" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" initialViewController="Lfr-X7-cX2">
     <dependencies>
         <deployment defaultVersion="1792" identifier="iOS"/>
         <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3733"/>
@@ -722,6 +722,7 @@
                                 <rect key="frame" x="0.0" y="65" width="320" height="503"/>
                                 <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                 <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
+                                <color key="sectionIndexColor" red="0.90980398654937744" green="0.90980398654937744" blue="0.90980398654937744" alpha="1" colorSpace="deviceRGB"/>
                                 <prototypes>
                                     <tableViewCell contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="tableitemmsg" id="1nr-UE-sjD" customClass="MessageItem">
                                         <rect key="frame" x="0.0" y="22" width="320" height="44"/>
@@ -738,7 +739,7 @@
                                                     <nil key="highlightedColor"/>
                                                 </label>
                                                 <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="a" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="hpS-fx-8AH">
-                                                    <rect key="frame" x="133" y="20" width="167" height="21"/>
+                                                    <rect key="frame" x="70" y="20" width="230" height="21"/>
                                                     <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
                                                     <fontDescription key="fontDescription" type="system" pointSize="14"/>
                                                     <nil key="highlightedColor"/>
@@ -760,7 +761,7 @@
                         <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
                     </view>
                     <navigationItem key="navigationItem" id="pyf-tg-5tF">
-                        <barButtonItem key="rightBarButtonItem" systemItem="trash" id="7Pl-CC-Fek">
+                        <barButtonItem key="rightBarButtonItem" title="Mark all read" id="7Pl-CC-Fek">
                             <connections>
                                 <action selector="delAllMessage:" destination="qrn-VS-Yb7" id="Yk7-Vk-mM8"/>
                             </connections>

+ 24 - 1
Apex Mobile/Apex Mobile/FunctionSelectViewController.m

@@ -180,8 +180,10 @@
 {
     return UIInterfaceOrientationPortrait;
 }
+
 -(void)viewWillAppear:(BOOL)animated
 {
+    NSLog(@"App active");
     long i = [UIApplication sharedApplication].applicationIconBadgeNumber;
     if(i>0)
         self.messageButton.imageView.image = [UIImage imageNamed:@"ic_message_new"];
@@ -217,6 +219,7 @@
         [self performSegueWithIdentifier:@"LOGIN" sender:self];
     }
 }
+
 - (void)viewDidLoad
 {
     [super viewDidLoad];
@@ -233,6 +236,14 @@
     
     [self.radioHbol setImage:[UIImage imageNamed:@"unchecked_32.png"] forState:UIControlStateNormal];
     [self.radioHbol setImage:[UIImage imageNamed:@"checked_32.png"] forState:UIControlStateSelected];
+    
+    [[NSNotificationCenter defaultCenter] addObserver:self
+                                             selector:@selector(active)
+                                                 name:UIApplicationDidBecomeActiveNotification object:nil];
+    
+    [[NSNotificationCenter defaultCenter] addObserver:self
+                                             selector:@selector(active)
+                                                 name:@"new notification" object:nil];
 	// Do any additional setup after loading the view.
     
 //    NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
@@ -243,7 +254,19 @@
 //    }
     
 }
-
+-(void)dealloc
+{
+    [[NSNotificationCenter defaultCenter] removeObserver:self]; 
+}
+-(void) active
+{
+    NSLog(@"App active");
+    long i = [UIApplication sharedApplication].applicationIconBadgeNumber;
+    if(i>0)
+        self.messageButton.imageView.image = [UIImage imageNamed:@"ic_message_new"];
+    else
+        self.messageButton.imageView.image = [UIImage imageNamed:@"ic_message"];
+}
 - (void)didReceiveMemoryWarning
 {
     [super didReceiveMemoryWarning];

+ 2 - 0
Apex Mobile/Apex Mobile/MessageDetailViewController.h

@@ -18,4 +18,6 @@
 @property (strong,nonatomic) NSString* s_id;
 @property (strong,nonatomic) NSString* e_id;
 @property (strong,nonatomic) NSMutableArray * messageinfo;
+@property (strong,nonatomic) NSMutableArray * messagelist;
+@property long index;
 @end

+ 4 - 0
Apex Mobile/Apex Mobile/MessageDetailViewController.m

@@ -108,6 +108,10 @@
                 //                }
                 [self.tableview reloadData ];
                 [UIApplication sharedApplication].applicationIconBadgeNumber --;
+                NSMutableDictionary * item = self.messagelist[self.index];
+                [item setValue:@"t" forKey:@"is_read"];
+                
+//                [self.messagelist[self.index] setValue:@"0" forKey:@"is_read"];
             }
             else
             {

+ 38 - 15
Apex Mobile/Apex Mobile/MessageViewController.m

@@ -78,7 +78,7 @@
                 {
                     
                     NSDictionary* objmsg = [objrecords objectForKey:[NSString stringWithFormat:@"record%d",i]];
-                    [self.messageinfo addObject:objmsg];
+                    [self.messageinfo addObject:[NSMutableDictionary dictionaryWithDictionary:objmsg]];
                     
                 }
                 if(total<self.limit)
@@ -117,6 +117,7 @@
             else
             {
                 self.btnrefresh.enabled = true;
+                self.btnrefresh.hidden = false;
                 [self.btnrefresh setTitle:NSLocalizedString(@"refresh", nil) forState:UIControlStateNormal];
                 
             }
@@ -156,7 +157,7 @@
     
     self.btnrefresh = [UIButton buttonWithType:UIButtonTypeCustom];
     //    self.btnrefresh.titleLabel.text =@"Load more";
-    [self.btnrefresh setTitle:@"Load more" forState:UIControlStateNormal];
+    [self.btnrefresh setTitle:NSLocalizedString(@"load_more", nil) forState:UIControlStateNormal];
 //    [self.btnrefresh.titleLabel sizeToFit];
     self.btnrefresh.titleLabel.adjustsFontSizeToFitWidth = YES;
     self.btnrefresh.hidden = true;
@@ -168,7 +169,10 @@
     [self loadpage];
     // Do any additional setup after loading the view.
 }
-
+-(void)viewWillAppear:(BOOL)animated
+{
+    [self.tableview reloadData];
+}
 - (void)didReceiveMemoryWarning
 {
     [super didReceiveMemoryWarning];
@@ -205,21 +209,28 @@
         dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
             
             self.mum.hidden = false;
-            int result = [ApexMobileNetwork delAllMessage:_id];;
             
+            int result = [ApexMobileNetwork delAllMessage:_id];;
             
-            dispatch_async(dispatch_get_main_queue(), ^{
-                if(result==1)
-                {
-                    self.mum.hidden = true;
-                    [self.messageinfo removeAllObjects ];
-                [self.tableview reloadData];
-                    [UIApplication sharedApplication].applicationIconBadgeNumber = 0;
-                    
-                    [[UIApplication sharedApplication] cancelAllLocalNotifications];
-                    self.btnrefresh.hidden = true;
-                }
+            if(result==1)
+            {
+                [self.messageinfo removeAllObjects ];
+                self.offset = 0;
+                [UIApplication sharedApplication].applicationIconBadgeNumber = 0;
                 
+                [[UIApplication sharedApplication] cancelAllLocalNotifications];
+                [self loadpage];
+            }
+            dispatch_async(dispatch_get_main_queue(), ^{
+//                if(result==1)
+//                {
+////                    self.mum.hidden = true;
+////                    [self.messageinfo removeAllObjects ];
+////                [self.tableview reloadData];
+//
+////                    self.btnrefresh.hidden = true;
+//                }
+//                
                 NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
                 bool autologin =[defaults boolForKey:@"autologin"];
                 if(!autologin)
@@ -294,6 +305,15 @@
     MessageItem *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
     NSString* title =NSLocalizedString(@"new_message",nil);
     NSString* time =[self.messageinfo[indexPath.row] valueForKey:@"insert_time"];
+    bool bread = [[self.messageinfo[indexPath.row] valueForKey:@"is_read"] boolValue];
+    if(bread==false)
+    {
+        cell.backgroundColor = [UIColor colorWithRed:0.91 green:0.91 blue:0.91 alpha:1];
+    }
+    else
+    {
+        cell.backgroundColor = [UIColor whiteColor];
+    }
     cell.MessageLabel.text = title;
     cell.TimeLabel.text=time;
     [cell.MessageLabel sizeToFit];
@@ -333,6 +353,9 @@
     [params setValue:sid forKey:@"s_id"];
     [params setValue:eid forKey:@"e_id"];
     viewController.params = params;
+    viewController.messagelist = self.messageinfo;
+    viewController.index = indexPath.row;
+    
     [self.navigationController pushViewController:viewController animated:YES];
 
     //    SearchViewController *searchViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"SearchViewController"];

+ 3 - 0
Apex Mobile/Apex Mobile/zh-Hans.lproj/Main_iPhone.strings

@@ -229,3 +229,6 @@ usairedadt@united-us.net";
 
 /* Class = "IBUIButton"; normalTitle = "Login"; ObjectID = "xZv-Zy-g7q"; */
 "xZv-Zy-g7q.normalTitle" = "登录";
+
+/* Class = "IBUIBarButtonItem"; title = "Menu"; ObjectID = "7Pl-CC-Fek"; */
+"7Pl-CC-Fek.title" = "全部标记为已读";