JChatConstants.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. //
  2. // Common.h
  3. // JPush IM
  4. //
  5. // Created by Apple on 14/12/29.
  6. // Copyright (c) 2014年 Apple. All rights reserved.
  7. //
  8. #ifndef JPush_IM_Common_h
  9. #define JPush_IM_Common_h
  10. #import <CocoaLumberjack/CocoaLumberjack.h>
  11. #define TICK NSDate *startTime = [NSDate date]
  12. #define TOCK(action) DDLogDebug(@"%@ - TimeInSeconds - %f", action, -[startTime timeIntervalSinceNow])
  13. /*========================================屏幕适配============================================*/
  14. #define kIOSVersions [[[UIDevice currentDevice] systemVersion] floatValue] //获得iOS版本
  15. #define kUIWindow [[[UIApplication sharedApplication] delegate] window] //获得window
  16. #define kUnderStatusBarStartY (kIOSVersions>=7.0 ? 20 : 0) //7.0以上stautsbar不占位置,内容视图的起始位置要往下20
  17. #define kScreenSize [[UIScreen mainScreen] bounds].size //(e.g. 320,480)
  18. #define kScreenWidth [[UIScreen mainScreen] bounds].size.width //(e.g. 320)
  19. #define kScreenHeight (kIOSVersions>=7.0 ? [[UIScreen mainScreen] bounds].size.height + 64 : [[UIScreen mainScreen] bounds].size.height)
  20. #define kIOS7OffHeight (kIOSVersions>=7.0 ? 64 : 0)
  21. #define kApplicationSize [UIScreen mainScreen].bounds.size //(e.g. 320,460)
  22. #define kApplicationWidth [UIScreen mainScreen].bounds.size.width //(e.g. 320)
  23. #define kApplicationHeight [UIScreen mainScreen].bounds.size.height//不包含状态bar的高度(e.g. 460)
  24. #define kMoreHeight kScreenWidth/4 //227
  25. #define kStatusBarHeight 20
  26. #define kNavigationBarHeight 44
  27. #define kNavigationheightForIOS7 64
  28. #define kContentHeight (kApplicationHeight - kNavigationBarHeight)
  29. #define kTabBarHeight (tabBarSafeSpace + tabBarContentHeight)
  30. #define kTableRowTitleSize 14
  31. #define maxPopLength 170
  32. #define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
  33. #define UIColorFromRGBA(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:0.7]
  34. #define kNavigationBarColor UIColorFromRGB(0x3f80de)
  35. #define headDefaltWidth 46
  36. #define headDefaltHeight 46
  37. #define upLoadImgWidth 720
  38. #define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
  39. #define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
  40. #define IS_RETINA ([[UIScreen mainScreen] scale] >= 2.0)
  41. #define SCREEN_WIDTH ([[UIScreen mainScreen] bounds].size.width)
  42. #define SCREEN_HEIGHT ([[UIScreen mainScreen] bounds].size.height)
  43. #define SCREEN_MAX_LENGTH (MAX(SCREEN_WIDTH, SCREEN_HEIGHT))
  44. #define SCREEN_MIN_LENGTH (MIN(SCREEN_WIDTH, SCREEN_HEIGHT))
  45. #define IS_IPHONE_4_OR_LESS (IS_IPHONE && SCREEN_MAX_LENGTH < 568.0)
  46. #define IS_IPHONE_5 (IS_IPHONE && SCREEN_MAX_LENGTH == 568.0)
  47. #define IS_IPHONE_6 (IS_IPHONE && SCREEN_MAX_LENGTH == 667.0)
  48. #define IS_IPHONE_6P (IS_IPHONE && SCREEN_MAX_LENGTH == 736.0)
  49. #define kMessageChangeState @"messageChangeState"
  50. #define kCreatGroupState @"creatGroupState"
  51. #define kSkipToSingleChatViewState @"SkipToSingleChatViewState"
  52. #define kDeleteAllMessage @"deleteAllMessage"
  53. #define kConversationChange @"ConversationChange"
  54. #define JPIMLog(...) NSLog(@"%s %@", __PRETTY_FUNCTION__,[NSString stringWithFormat:__VA_ARGS__])
  55. #define LOG_PREFIX @"JChat"
  56. #define kWEAKSELF __weak __typeof(self)weakSelf = self;
  57. #define kSTRONGSELF __strong __typeof(weakSelf)strongSelf = weakSelf;
  58. /**
  59. DDLogError 错误:真的出错了,逻辑不正常
  60. DDLogWarn 警告:不是预期的情况,但也基本正常,不会导致逻辑问题
  61. DDLogInfo 信息:比较重要的信息,重要的方法入口
  62. DDLogDebug 调试:一般调试日志输出
  63. DDLogVerbose 过度:也用于调试,但输出时会过度,比如循环展示列表时输出其部分信息。
  64. 默认 DEBUG 模式时也不输出 Verbose 日志,有需要临时修改下面的定义打开这个日志信息。
  65. */
  66. #ifdef DEBUG
  67. static const DDLogLevel ddLogLevel = DDLogLevelDebug;
  68. #else
  69. static const DDLogLevel ddLogLevel = DDLogLevelInfo;
  70. #endif
  71. #define kuserName @"userName"
  72. #define klastLoginUserName @"lastUserName"
  73. #define kBADGE @"badge"
  74. #define kPassword @"password"
  75. #define kLogin_NotifiCation @"loginNotification"
  76. #define kFirstLogin @"firstLogin"
  77. #define kHaveLogin @"haveLogin"
  78. #define kimgKey @"imgKey"
  79. #define kmessageKey @"messageKey"
  80. #define kupdateUserInfo @"updateUserInfo"
  81. #define KNull @"(null)"
  82. #define KApnsNotification @"apnsNotification"
  83. #define kDBMigrateStartNotification @"DBMigrateStartNotification"
  84. #define kDBMigrateFinishNotification @"DBMigrateFinishNotification"
  85. #define JCHATMAINTHREAD(block) dispatch_async(dispatch_get_main_queue(), block)
  86. #endif
  87. typedef NS_ENUM(NSInteger, JCHATErrorCode) {
  88. JCHAT_ERROR_SERVER_ERROR = 898000,
  89. JCHAT_ERROR_REGISTER_EXIST = 898001,
  90. JCHAT_ERROR_USER_NOT_EXIST = 898002,
  91. JCHAT_ERROR_USER_PARAS_INVALID = 898003,
  92. JCHAT_ERROR_USER_WRONG_PASSWORD = 898004,
  93. JCHAT_ERROR_APPKEY_NOT_EXIST = 898009,
  94. JCHAT_ERROR_STATE_USER_NEVER_LOGIN = 800012,
  95. JCHAT_ERROR_STATE_USER_LOGOUT = 800013,
  96. JCHAT_ERROR_LOGIN_USERNAME_EMPTY = 801001,
  97. JCHAT_ERROR_LOGIN_PASSWORD_EMPTY = 801002,
  98. JCHAT_ERROR_LOGIN_NOT_REGISTERED = 801003,
  99. JCHAT_ERROR_LOGIN_PASSWORD_WRONG = 801004,
  100. JCHAT_ERROR_MSG_SERVER_ERROR = 803001,
  101. JCHAT_ERROR_MSG_TARGET_NOT_EXIST = 803003,
  102. JCHAT_ERROR_MSG_GROUP_NOT_EXIST = 803004,
  103. JCHAT_ERROR_MSG_USER_NOT_IN_GROUP = 803005,
  104. JCHAT_ERROR_GROUP_ADD_MEMBER_NOT_IN = 810003,
  105. JCHAT_ERROR_GROUP_ADD_MEMBER_NOT_REGISTERED = 810005,
  106. JCHAT_ERROR_GROUP_ADD_MEMBER_DUPLICATED = 810007,
  107. JCHAT_ERROR_GROUP_DEL_MEMBER_NOT_IN = 811003,
  108. };
  109. //ToolBar
  110. static NSInteger const st_toolBarTextSize = 17.0f;
  111. //Notification
  112. #define kAlertToSendImage @"AlertToSendImage"
  113. #define kDeleteMessage @"DeleteMessage"
  114. #define kRetractMsg @"RetractMesg"
  115. //Color
  116. #define kNavigationBarColor UIColorFromRGB(0x3f80de)
  117. #define kTabbarColor UIColorFromRGB(0x3e3e3e)
  118. #define kTextfieldPlaceholderColor UIColorFromRGB(0x555555)
  119. #define kTableviewCellClickColor UIColorFromRGB(0xdddddd)
  120. #define kTableviewSeperateLineColor UIColorFromRGB(0xcfcfcf)
  121. #define kSeparationLineColor UIColorFromRGB(0xd0d0d0)
  122. //NavigationBar
  123. #define kGoBackBtnImageOffset UIEdgeInsetsMake(0, 0, 0, 15)
  124. #define kNavigationLeftButtonRect CGRectMake(0, 0, 30, 30)
  125. //static const
  126. static NSString * const st_chatViewController = @"JCHATChatViewController";
  127. static NSString * const st_contactsViewController = @"JCHATContactsViewController";
  128. static NSString * const st_userInfoViewController = @"JCHATUserInfoViewController";
  129. static NSString * const st_chatViewControllerTittle = @"会话";
  130. static const NSInteger st_chatTabTag = 10;
  131. static NSString * const st_contactsTabTitle = @"通讯录";
  132. static NSInteger const st_contactsTabTag = 11;
  133. static NSString * const st_settingTabTitle = @"我";
  134. static NSInteger const st_settingTag = 12;
  135. static NSString * const st_receiveUnknowMessageDes = @"收到新消息类型无法解析的数据,请升级查看";
  136. static NSString * const st_receiveErrorMessageDes = @"接收消息错误";