Skip to content

Commit

Permalink
Merge pull request #18 from jpush/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
KenChoi1992 authored Oct 30, 2017
2 parents 6897f90 + f91925a commit cbf24c8
Show file tree
Hide file tree
Showing 26 changed files with 528 additions and 83 deletions.
Binary file removed android/libs/jmessage-android_v2.2.1.jar
Binary file not shown.
Binary file added android/libs/jmessage-android_v2.3.0.jar
Binary file not shown.
18 changes: 18 additions & 0 deletions android/src/io/jchat/android/JMessageModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,24 @@ public void gotResult(int status, String desc) {
});
}

@ReactMethod
public void updateMyAvatar(ReadableMap map, final Callback success, final Callback fail) {
try {
String path = map.getString("imgPath");
File file = new File(path);
if (file.exists() && file.isFile()) {
JMessageClient.updateUserAvatar(file, new BasicCallback() {
@Override
public void gotResult(int status, String desc) {
mJMessageUtils.handleCallback(status, desc, success, fail);
}
});
}
} catch (Exception e) {
e.printStackTrace();
}
}

@ReactMethod
public void updateMyInfo(ReadableMap map, final Callback success, final Callback fail) {
UserInfo myInfo = JMessageClient.getMyInfo();
Expand Down
5 changes: 3 additions & 2 deletions example/android/app/app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/check-manifest" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes-jar" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaPrecompile" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
Expand All @@ -96,10 +95,12 @@
<orderEntry type="jdk" jdkName="Android API 25 Platform (1)" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="okio-1.9.0" level="project" />
<orderEntry type="library" name="chatinput-0.4.7" level="project" />
<orderEntry type="library" name="imagepipeline-base-1.0.1" level="project" />
<orderEntry type="library" name="chatinput-0.4.9" level="project" />
<orderEntry type="library" name="XhsEmoticonsKeyboard-2.0.4" level="project" />
<orderEntry type="library" name="textlayoutbuilder-1.0.0" level="project" />
<orderEntry type="library" name="gson-2.8.0" level="project" />
<orderEntry type="library" name="AndroidEmoji-1.0.0" level="project" />
<orderEntry type="library" name="jsr305-3.0.0" level="project" />
<orderEntry type="library" name="transition-25.3.1" level="project" />
<orderEntry type="library" name="design-25.3.1" level="project" />
Expand Down
1 change: 1 addition & 0 deletions example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@ allprojects {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
maven { url "https://jitpack.io" }
}
}
43 changes: 37 additions & 6 deletions example/app/routes/Chat/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@ export default class Chat extends Component {
constructor(props) {
super(props);
this.state = {
inputViewLayout: {width:window.width, height:100,},
inputViewLayout: {width:window.width, height:86,},
menuContainerHeight: 1000,
isDismissMenuContainer: false,
shouldExpandMenuContainer: false,
};

this.updateLayout = this.updateLayout.bind(this);
Expand Down Expand Up @@ -189,7 +190,10 @@ export default class Chat extends Component {
componentWillUnmount() {
JMessage.removeReceiveMessageListener(this.receiveMessageCallBack)
AuroraIController.removeMessageListDidLoadListener(this.messageListDidLoadCallback)
UIManager.dispatchViewManagerCommand(findNodeHandle(this.refs["MessageList"]), 1, null)
if (Platform.OS === 'android') {
UIManager.dispatchViewManagerCommand(findNodeHandle(this.refs["MessageList"]), 1, null)
}

}

updateLayout(layout) {
Expand All @@ -208,12 +212,29 @@ export default class Chat extends Component {
width: Dimensions.get('window').width,
height: 100
},
shouldExpandMenuContainer: false,
});
}

onTouchEditText() {
onTouchEditText = () => {
console.log("scroll to bottom")
AuroraIController.scrollToBottom(true);
if (this.state.shouldExpandMenuContainer) {
this.setState({inputViewLayout: {width:window.width, height:420,}})
}

}

onFullScreen = () => {
this.setState({
inputViewLayout: {width: window.width, height:window.height}
})
}

onRecoverScreen = () => {
this.setState({
inputViewLayout: {width: window.width, height: 480}
})
}

onMsgClick = (message) => {
Expand Down Expand Up @@ -358,15 +379,23 @@ export default class Chat extends Component {
}

onSwitchToMicrophoneMode = () => {
this.updateLayout({width:window.width, height:420,})
this.updateLayout({width:window.width, height:338,})
}

onSwitchToGalleryMode = () => {
this.updateLayout({width:window.width, height:420,})
this.updateLayout({width:window.width, height:338,})
}

onSwitchToCameraMode = () => {
this.updateLayout({width:window.width, height:420,})
if (Platform.OS == "android") {
this.updateLayout({width:window.width, height: 338})
this.setState({
shouldExpandMenuContainer: true
})
} else {
this.updateLayout({width:window.width, height:338,})
}

}

onShowKeyboard = (keyboard_height) => {
Expand Down Expand Up @@ -413,6 +442,8 @@ export default class Chat extends Component {
onSwitchToCameraMode={this.onSwitchToCameraMode}
onShowKeyboard={this.onShowKeyboard}
onTouchEditText={this.onTouchEditText}
onFullScreen={this.onFullScreen}
onRecoverScreen={this.onRecoverScreen}
/>
</View>
);
Expand Down
1 change: 1 addition & 0 deletions example/app/routes/Home/ConversationList/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ export default class ConversationList extends React.Component {
this.props.navigation.setParams({
createConversation: this._onCreateConversation
});

}
componentWillMount() {
this.reloadConversationList()
Expand Down
12 changes: 12 additions & 0 deletions example/ios/JMessageDemo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,17 @@
name = Products;
sourceTree = "<group>";
};
6291C0931F99C22600C85F64 /* Recovered References */ = {
isa = PBXGroup;
children = (
E53DEE966F3C4EF59620DD03 /* libRNSVG.a */,
B68903A680EE48DAA80CB4A8 /* libRCTJMessageModule.a */,
B3D3338066F545108CE6489C /* libAuroraIMUI.a */,
2C597C5BCCDA4718A237069C /* libRCTJCoreModule.a */,
);
name = "Recovered References";
sourceTree = "<group>";
};
62D683711F43E8890083CDF6 /* Products */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -666,6 +677,7 @@
00E356EF1AD99517003FC87E /* JMessageDemoTests */,
83CBBA001A601CBA00E9B192 /* Products */,
621730111F4DAA24001ADED4 /* Frameworks */,
6291C0931F99C22600C85F64 /* Recovered References */,
);
indentWidth = 2;
sourceTree = "<group>";
Expand Down
2 changes: 2 additions & 0 deletions ios/RCTJMessageModule.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@
"$(inherited)",
"$(PROJECT_DIR)/RCTJMessageModule",
);
HEADER_SEARCH_PATHS = "$(SRCROOT)/../../react-native/React/**";
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
Expand All @@ -253,6 +254,7 @@
"$(inherited)",
"$(PROJECT_DIR)/RCTJMessageModule",
);
HEADER_SEARCH_PATHS = "$(SRCROOT)/../../react-native/React/**";
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
Expand Down
16 changes: 8 additions & 8 deletions ios/RCTJMessageModule/JMessage.framework/Headers/JMSGConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,10 @@ typedef NS_ENUM(NSInteger, JMSGEventNotificationType) {

/// 事件类型: 消息撤回
kJMSGEventNotificationMessageRetract = 55,
/// 事件类型: 消息透传
kJMSGEventNotificationMessageTransparent = 58,
/// 事件类型: 消息回执变更
kJMSGEventNotificationMessageReceiptStatusChange = 68,

// 消息事件
/// 事件类型: 群组被创建
Expand Down Expand Up @@ -314,6 +318,8 @@ typedef NS_ENUM(NSInteger, JMSGSDKErrorCode) {
kJMSGErrorSDKMediaHashCodeIllegal = 864006,
/// 媒体HASH校验失败
kJMSGErrorSDKMediaHashVerifyFailed = 864007,
/// 这条消息不支持转发
kJMSGErrorSDKMessageNotSupportForward = 864008,

// ------------------------ Message (865xxx)

Expand Down Expand Up @@ -413,6 +419,8 @@ typedef NS_ENUM(NSUInteger, JMSGTcpErrorCode) {
kJMSGErrorTcpUserNotRegistered = 801003,
/// 用户密码错误
kJMSGErrorTcpUserPasswordError = 801004,
/// 多通道同时登录错误,登录失败
kJMSGErrorTcpLoginMultiChannelError = 801007,
/// 目标用户不存在
kJMSGErrorTcpTargetUserNotExist = 803003,
/// 目标群组不存在
Expand Down Expand Up @@ -455,14 +463,6 @@ static NSString *const KEY_REGION = @"region"; //区域
static NSString *const KEY_SIGNATURE = @"signature";//签名
static NSString *const KEY_ADDRESS = @"address"; //地址
static NSString *const KEY_STAR = @"star";
static NSString *const KEY_UID = @"uid";
static NSString *const KEY_NO_DISTURB = @"no_disturb";
static NSString *const KEY_BLACKLIST = @"blicklist";
static NSString *const KEY_NOTE_NAME = @"memo_name";//note_name
static NSString *const KEY_NOTE_TEXT = @"memo_others";//note_text
static NSString *const KEY_SHIELD_GROUP = @"shield_group";
static NSString *const KEY_USER_MTIME = @"mtime";
static NSString *const KEY_USER_CTIME = @"ctime";



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
@class JMSGAbstractContent;
@class JMSGImageContent;
@class JMSGOptionalContent;
@class JMSGMediaAbstractContent;


/*!
Expand Down Expand Up @@ -218,6 +219,7 @@ JMSG_ASSUME_NONNULL_BEGIN
@property(nonatomic, strong, readonly) NSString *targetAppKey;



///----------------------------------------------------
/// @name Message Operations 消息相关操作
///----------------------------------------------------
Expand Down Expand Up @@ -311,16 +313,24 @@ JMSG_ASSUME_NONNULL_BEGIN
*/
- (JMSGMessage * JMSG_NULLABLE)createMessageWithContent:(JMSGAbstractContent *)content;


/*!
* @abstract 创建消息对象(图片,异步)
*
* @param content 准备好的图片内容
* 注意:此方法已过期,请使用 createMessageAsyncWithMediaContent: 方法
*/
- (void)createMessageAsyncWithImageContent:(JMSGImageContent *)content
completionHandler:(JMSGCompletionHandler JMSG_NULLABLE)handler __attribute__((deprecated("first deprecated in JMessage 3.3.0 - Use -createMessageAsyncWithMediaContent:")));
/*!
* @abstract 创建消息对象(多媒体消息,异步)
*
* @param content 准备好的多媒体内容,如:图片、语音、文件等
* @param handler 结果回调. 正常返回时 resultObject 类型为 JMSGMessage.
*
* @discussion 对于图片消息,因为 SDK 要做缩图有一定的性能损耗,图片文件很大时存储落地也会较慢。
* @discussion 注意:对于多媒体消息,因为 SDK 要做缩图有一定的性能损耗,图片文件很大时存储落地也会较慢。
* 所以创建图片消息,建议使用这个异步接口。
*/
- (void)createMessageAsyncWithImageContent:(JMSGImageContent *)content
- (void)createMessageAsyncWithMediaContent:(JMSGMediaAbstractContent *)content
completionHandler:(JMSGCompletionHandler JMSG_NULLABLE)handler;

/*!
Expand All @@ -333,12 +343,12 @@ JMSG_ASSUME_NONNULL_BEGIN
- (void)sendMessage:(JMSGMessage *)message;

/*!
* @abstract 发送消息(附带可选功能,如:控制离线消息存储、自定义通知栏内容等
* @abstract 发送消息(附带可选功能,如:控制离线消息存储、自定义通知栏内容、消息已读回执等
*
* @param message 通过消息创建类接口,创建好的消息对象
* @param optionalContent 可选功能,具体请查看 JMSGOptionalContent 类
*
* @discussion 可选功能里可以设置离线消息存储、自定义通知栏内容等,具体请查看 JMSGOptionalContent 类。
* @discussion 可选功能里可以设置离线消息存储、自定义通知栏内容、消息已读回执等,具体请查看 JMSGOptionalContent 类。
*
*/
- (void)sendMessage:(JMSGMessage *)message optionalContent:(JMSGOptionalContent *)optionalContent;
Expand Down Expand Up @@ -421,7 +431,23 @@ JMSG_ASSUME_NONNULL_BEGIN
- (void)retractMessage:(JMSGMessage *)message completionHandler:(JMSGCompletionHandler)handler;

/*!
* @abstract 异步获取会话头像(仅限单聊)
* @abstract 消息透传
*
* @param transparentText 用户自定义透传内容,仅限 NSString 类型
* @param handler 回调,error=nil 表示成功
*
* @discussion 注意:
*
* 1. 消息透传功能,消息不会进入到后台的离线存储中去,仅当对方用户当前在线时才会成功送达,可以快速响应,方便开发者拓展自定义行为;
*
* 2. 可用来快速实现一些在线场景下的辅助功能 :输入状态提示、位置信息提示、开发者自定义等。
*
*/
- (void)sendTransparentMessage:(NSString *JMSG_NONNULL)transparentText
completionHandler:(JMSGCompletionHandler JMSG_NULLABLE)handler;

/*!
* @abstract 异步获取会话头像
*
* @param handler 结果回调。回调参数:
*
Expand All @@ -443,7 +469,7 @@ JMSG_ASSUME_NONNULL_BEGIN
*
* @return 返回本地路,返回值只有在下载完成之后才有意义
*/
- (NSString *)avatarLocalPath;
- (NSString *JMSG_NULLABLE)avatarLocalPath;

///----------------------------------------------------
/// @name Conversation State Maintenance 会话状态维护
Expand All @@ -463,6 +489,34 @@ JMSG_ASSUME_NONNULL_BEGIN
*/
- (NSString *)latestMessageContentText;

/*!
* @abstract 获取会话所有扩展字段
*
* @return 返回所有值,NSDictionary 类型
*
* @discussion 与 [- (void)setExtraValue:forKey:] 配套使用,可用于对会话属性的扩展
*/
- (NSDictionary *JMSG_NULLABLE)getConversationExtras;

/*!
* @abstract 获取单个扩展字段
*
* @return 返回 key 对应值,NSString 类型
*
* @discussion 与 [- (void)setExtraValue:forKey:] 配套使用,可用于对会话属性的扩展
*/
- (NSString *JMSG_NULLABLE)getExtraValueForKey:(NSString *JMSG_NONNULL)key;

/*!
* @abstract 增加或更新扩展字段,可扩展会话属性,比如:会话置顶、标识特殊会话等
*
* @param value 新增键值对的值. String 类型.
* @param key 新增键值对的键
*
* @discussion 如果 value = nil,则删除 extras 中 key 对应的值
*/
- (void)setExtraValue:(NSString *JMSG_NULLABLE)value forKey:(NSString *JMSG_NONNULL)key;

/*!
* @abstract 判断消息是否属于这个 Conversation
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@
- (void)onUnreadChanged:(NSUInteger)newCount;

/*!
* @abstract 同步离线消息通知
* @abstract 同步离线消息、离线事件通知
*
* @param conversation 同步离线消息的会话
* @param offlineMessages 离线消息数组
* @param offlineMessages 离线消息、离线事件数组
*
* @discussion 注意:
*
Expand All @@ -53,11 +53,12 @@
*
* 3.1.0 版本之后: SDK 会以会话为单位,不管该会话有多少离线消息,SDK同步完成后每个会话只上抛一次.
*
* 注意一个会话只会上抛一个会话,这样会大大减轻上层在收到消息事件需要刷新 UI 的应用场景下,UI 刷新的压力.
* 3.2.1 版本之后: SDK 会以会话为单位,不管该会话有多少离线事件,SDK同步完成后每个会话只上抛一次
*
* 注意:一个会话最多触发两次这个代理,即:离线消息和离线事件各一次,这样会大大减轻上层在收到消息刷新 UI 的压力.
*
* 上层通过此代理方法监听离线消息同步的会话,详见官方文档.
*
* @since 3.1.0
*/
@optional
- (void)onSyncOfflineMessageConversation:(JMSGConversation *)conversation
Expand Down
Loading

0 comments on commit cbf24c8

Please sign in to comment.