diff --git a/Android/chatinput/README.md b/Android/chatinput/README.md
index 0dffc077..7892a5ae 100644
--- a/Android/chatinput/README.md
+++ b/Android/chatinput/README.md
@@ -12,7 +12,7 @@
- Gradle
```groovy
-compile 'cn.jiguang.imui:chatinput:0.8.3'
+compile 'cn.jiguang.imui:chatinput:0.9.0'
```
- Maven
@@ -20,7 +20,7 @@ compile 'cn.jiguang.imui:chatinput:0.8.3'
cn.jiguang.imui
chatinput
- 0.8.3
+ 0.9.0
pom
```
@@ -42,7 +42,7 @@ compile 'cn.jiguang.imui:chatinput:0.8.3'
```groovy
dependencies {
- compile 'com.github.jpush:imui:0.7.6'
+ compile 'com.github.jpush:imui:0.9.0'
}
```
@@ -265,3 +265,101 @@ mChatInput.setCameraControllerListener(new CameraControllerListener() {
mChatInput.setCameraCaptureFile(path, fileName);
```
+## MenuManager(从0.9.0版本开始支持)
+菜单功能管理类,用于添加自定义菜单,自由设置菜单项的位置,包括输入框的左边/右边/下边位置。
+
+### 获取MenuManager
+
+`MenuManager menuManager = mChatInput.getMenuManager();`
+
+
+### 添加自定义菜单
+
+1. 添加菜单项布局,根节点为MenuItem(继承自LinearLayout)
+```xml
+
+
+ ...
+
+
+```
+
+2. 添加对应菜单功能布局,根节点为MenuFeature(继承自LinearLayout)
+```xml
+
+
+ ...
+
+
+```
+3. 通过MenuManager添加自定义菜单,
+```java
+//第一种:添加view方式,tag唯一
+//menuFeature 传 null 即表示此菜单项不需要对应功能
+addCustomMenu(String tag, MenuItem menuItem, MenuFeature menuFeature)
+
+//第二种:添加布局资源,tag唯一
+//menuFeatureResource 传 -1 即表示此菜单项不需要对应功能
+addCustomMenu(String tag, int menuItemResource, int menuFeatureResource)
+```
+4. 设置自定义菜单事件监听,CustomMenuEventListener
+```java
+menuManager.setCustomMenuClickListener(new CustomMenuEventListener() {
+ @Override
+ public boolean onMenuItemClick(String tag, MenuItem menuItem) {
+ //Menu feature will not be shown if return false;
+ return true;
+ }
+
+ @Override
+ public void onMenuFeatureVisibilityChanged(int visibility, String tag, MenuFeature menuFeature) {
+ if(visibility == View.VISIBLE){
+ // Menu feature is visible.
+ }else {
+ // Menu feature is gone.
+ }
+ }
+ });
+```
+### 设置菜单项的位置
+`setMenu(Menu menu)`
+
+#### Menu
+通过传入菜单项的tag来控制布局,默认可使用的布局tag有:
+```Java
+Menu.TAG_VOICE
+Menu.TAG_EMOJI
+Menu.TAG_GALLERY
+Menu.TAG_CAMERA
+Menu.TAG_SEND
+```
+设置位置,tag不能重复:
+
+```java
+Menu.newBuilder().
+ customize(boolean customize).//是否自定义位置
+ setLeft(String ... tag).//输入框左侧菜单项
+ setRight(String ... tag).//输入框右侧菜单项
+ setBottom(String ... tag).//输入框下侧菜单项
+ build()
+```
+#### 示例
+```java
+menuManager.setMenu(Menu.newBuilder().
+ customize(true).
+ setRight(Menu.TAG_SEND).
+ setBottom(Menu.TAG_VOICE,Menu.TAG_EMOJI,Menu.TAG_GALLERY,Menu.TAG_CAMERA).
+ build());
+```
+
+
+
+
+
+
+
+
diff --git a/Android/chatinput/README_EN.md b/Android/chatinput/README_EN.md
index 1224942e..bb16199e 100644
--- a/Android/chatinput/README_EN.md
+++ b/Android/chatinput/README_EN.md
@@ -273,5 +273,98 @@ Since 0.4.5, take picture will return default path.
mChatInput.setCameraCaptureFile(path, fileName);
```
+## MenuManager(Support since 0.9.0)
+
+Menu management class, used to add a custom menu, freely set the position of the menu item, including the left/right/lower position of the chatinput.
+
+### Get MenuManager
+
+`MenuManager menuManager = mChatInput.getMenuManager();`
+
+
+### Add custom menu
+
+1. Add custom menu item layout,the root node has to be MenuItem(Extends LinearLayout)
+```xml
+
+
+ ...
+
+
+```
+
+2. Add custom menu feature layout,the root node has to be MenuFeature(Extends LinearLayout)
+```xml
+
+
+ ...
+
+
+```
+3. Add custom menu by MenuManager
+```java
+//First:add view mode, tag must be unique
+//If set menuFeature as null means that this menu item does not require a corresponding function.
+addCustomMenu(String tag, MenuItem menuItem, MenuFeature menuFeature)
+
+//Second: add layout resources, tag must be unique
+//If set menuFeatureResource as -1 means that this menu item does not require a corresponding function.
+addCustomMenu(String tag, int menuItemResource, int menuFeatureResource)
+```
+4. CustomMenuEventListener
+```java
+menuManager.setCustomMenuClickListener(new CustomMenuEventListener() {
+ @Override
+ public boolean onMenuItemClick(String tag, MenuItem menuItem) {
+ //Menu feature will not be shown if return false;
+ return true;
+ }
+
+ @Override
+ public void onMenuFeatureVisibilityChanged(int visibility, String tag, MenuFeature menuFeature) {
+ if(visibility == View.VISIBLE){
+ // Menu feature is visible.
+ }else {
+ // Menu feature is gone.
+ }
+ }
+ });
+```
+### Set the position of the menu item
+`setMenu(Menu menu)`
+
+#### Menu
+
+The position is controlled by passing in the tag of the menu item. The default layout tags are:
+
+```Java
+Menu.TAG_VOICE
+Menu.TAG_EMOJI
+Menu.TAG_GALLERY
+Menu.TAG_CAMERA
+Menu.TAG_SEND
+```
+Set position,tag cannot be repeated:
+
+```java
+Menu.newBuilder().
+ customize(boolean customize).// Whether to customize the position
+ setLeft(String ... tag).// Set left menu items
+ setRight(String ... tag).// Set right menu items
+ setBottom(String ... tag).//Set bottom menu items
+ build()
+```
+#### Sample
+```java
+menuManager.setMenu(Menu.newBuilder().
+ customize(true).
+ setRight(Menu.TAG_SEND).
+ setBottom(Menu.TAG_VOICE,Menu.TAG_EMOJI,Menu.TAG_GALLERY,Menu.TAG_CAMERA).
+ build());
+```
diff --git a/Android/chatinput/build.gradle b/Android/chatinput/build.gradle
index 8cf28efe..d9e71ddc 100644
--- a/Android/chatinput/build.gradle
+++ b/Android/chatinput/build.gradle
@@ -3,7 +3,7 @@ apply plugin: 'com.android.library'
ext {
PUBLISH_GROUP_ID = 'cn.jiguang.imui'
PUBLISH_ARTIFACT_ID = 'chatinput'
- PUBLISH_VERSION = '0.8.3'
+ PUBLISH_VERSION = '0.9.0'
}
android {
diff --git a/Android/chatinput/src/main/java/cn/jiguang/imui/chatinput/ChatInputStyle.java b/Android/chatinput/src/main/java/cn/jiguang/imui/chatinput/ChatInputStyle.java
index 1588edb0..b330cc9e 100644
--- a/Android/chatinput/src/main/java/cn/jiguang/imui/chatinput/ChatInputStyle.java
+++ b/Android/chatinput/src/main/java/cn/jiguang/imui/chatinput/ChatInputStyle.java
@@ -16,6 +16,8 @@ public class ChatInputStyle extends Style {
private int inputMarginLeft;
private int inputMarginRight;
+ private int inputMarginBottom;
+ private int inputMarginTop;
private int inputMaxLines;
private String inputText;
@@ -57,6 +59,10 @@ public static ChatInputStyle parse(Context context, AttributeSet attrs) {
style.getDimension(R.dimen.aurora_margin_input_left));
style.inputMarginRight = typedArray.getDimensionPixelSize(R.styleable.ChatInputView_inputMarginRight,
style.getDimension(R.dimen.aurora_margin_input_right));
+ style.inputMarginBottom = typedArray.getDimensionPixelSize(R.styleable.ChatInputView_inputMarginBottom,
+ style.getDimension(R.dimen.aurora_margin_input_bottom));
+ style.inputMarginTop = typedArray.getDimensionPixelSize(R.styleable.ChatInputView_inputMarginTop,
+ style.getDimension(R.dimen.aurora_margin_input_top));
style.inputMaxLines = typedArray.getInt(R.styleable.ChatInputView_inputMaxLines, DEFAULT_MAX_LINES);
style.inputHint = typedArray.getString(R.styleable.ChatInputView_inputHint);
style.inputText = typedArray.getString(R.styleable.ChatInputView_inputText);
@@ -116,6 +122,14 @@ public int getInputMarginRight() {
return this.inputMarginRight;
}
+ public int getInputMarginTop() {
+ return this.inputMarginTop;
+ }
+
+ public int getInputMarginBottom() {
+ return this.inputMarginBottom;
+ }
+
public int getInputMaxLines() {
return this.inputMaxLines;
}
diff --git a/Android/chatinput/src/main/java/cn/jiguang/imui/chatinput/ChatInputView.java b/Android/chatinput/src/main/java/cn/jiguang/imui/chatinput/ChatInputView.java
index fc619d39..2d97d8bb 100644
--- a/Android/chatinput/src/main/java/cn/jiguang/imui/chatinput/ChatInputView.java
+++ b/Android/chatinput/src/main/java/cn/jiguang/imui/chatinput/ChatInputView.java
@@ -7,7 +7,6 @@
import android.app.Activity;
import android.content.Context;
import android.content.pm.PackageManager;
-import android.content.res.Resources;
import android.graphics.Rect;
import android.graphics.SurfaceTexture;
import android.graphics.drawable.Drawable;
@@ -29,7 +28,6 @@
import android.util.TypedValue;
import android.view.Display;
import android.view.Gravity;
-import android.view.MotionEvent;
import android.view.Surface;
import android.view.TextureView;
import android.view.View;
@@ -70,9 +68,11 @@
import cn.jiguang.imui.chatinput.listener.CameraEventListener;
import cn.jiguang.imui.chatinput.listener.OnCameraCallbackListener;
import cn.jiguang.imui.chatinput.listener.OnClickEditTextListener;
+import cn.jiguang.imui.chatinput.listener.CustomMenuEventListener;
import cn.jiguang.imui.chatinput.listener.OnFileSelectedListener;
import cn.jiguang.imui.chatinput.listener.OnMenuClickListener;
import cn.jiguang.imui.chatinput.listener.RecordVoiceListener;
+import cn.jiguang.imui.chatinput.menu.MenuManager;
import cn.jiguang.imui.chatinput.model.FileItem;
import cn.jiguang.imui.chatinput.model.VideoItem;
import cn.jiguang.imui.chatinput.photo.SelectPhotoView;
@@ -178,6 +178,9 @@ public class ChatInputView extends LinearLayout
private View mPhotoBtnContainer;
private View mEmojiBtnContainer;
+
+ private MenuManager mMenuManager;
+
public ChatInputView(Context context) {
super(context);
init(context);
@@ -197,6 +200,12 @@ private void init(Context context) {
mContext = context;
inflate(context, R.layout.view_chatinput, this);
+ mChatInputContainer = (LinearLayout) findViewById(R.id.aurora_ll_input_container);
+ mMenuItemContainer = (LinearLayout) findViewById(R.id.aurora_ll_menuitem_container);
+ mMenuContainer = (FrameLayout) findViewById(R.id.aurora_fl_menu_container);
+
+ mMenuManager = new MenuManager(this,mChatInputContainer,mMenuItemContainer,mMenuContainer);
+
// menu buttons
mChatInput = (EmoticonsEditText) findViewById(R.id.aurora_et_chat_input);
mVoiceBtn = (ImageButton) findViewById(R.id.aurora_menuitem_ib_voice);
@@ -218,9 +227,8 @@ private void init(Context context) {
mSendCountTv = (TextView) findViewById(R.id.aurora_menuitem_tv_send_count);
mInputMarginLeft = (Space) findViewById(R.id.aurora_input_margin_left);
mInputMarginRight = (Space) findViewById(R.id.aurora_input_margin_right);
- mChatInputContainer = (LinearLayout) findViewById(R.id.aurora_ll_input_container);
- mMenuItemContainer = (LinearLayout) findViewById(R.id.aurora_ll_menuitem_container);
- mMenuContainer = (FrameLayout) findViewById(R.id.aurora_fl_menu_container);
+
+
mRecordVoiceRl = (RelativeLayout) findViewById(R.id.aurora_rl_recordvoice_container);
mPreviewPlayLl = (LinearLayout) findViewById(R.id.aurora_ll_recordvoice_preview_container);
mPreviewPlayBtn = (ProgressButton) findViewById(R.id.aurora_pb_recordvoice_play_audio);
@@ -292,6 +300,7 @@ public void onBackKeyClick() {
// return false;
// }
// });
+
}
EmoticonClickListener emoticonClickListener = new EmoticonClickListener() {
@@ -330,7 +339,6 @@ public void onEmoticonClick(Object o, int actionType, boolean isDelBtn) {
private void init(Context context, AttributeSet attrs) {
init(context);
mStyle = ChatInputStyle.parse(context, attrs);
-
mChatInput.setMaxLines(mStyle.getInputMaxLines());
mChatInput.setHint(mStyle.getInputHint());
mChatInput.setText(mStyle.getInputText());
@@ -340,6 +348,7 @@ private void init(Context context, AttributeSet attrs) {
mChatInput.setBackgroundResource(mStyle.getInputEditTextBg());
mChatInput.setPadding(mStyle.getInputPaddingLeft(), mStyle.getInputPaddingTop(), mStyle.getInputPaddingRight(),
mStyle.getInputPaddingBottom());
+
mInputMarginLeft.getLayoutParams().width = mStyle.getInputMarginLeft();
mInputMarginRight.getLayoutParams().width = mStyle.getInputMarginRight();
mVoiceBtn.setImageResource(mStyle.getVoiceBtnIcon());
@@ -353,6 +362,10 @@ private void init(Context context, AttributeSet attrs) {
mSendCountTv.setBackground(mStyle.getSendCountBg());
mSelectAlbumIb.setVisibility(mStyle.getShowSelectAlbum() ? VISIBLE : INVISIBLE);
+ LinearLayout.LayoutParams lp =(LayoutParams) mChatInputContainer.getLayoutParams();
+ lp.setMargins(0,mStyle.getInputMarginTop(),0,mStyle.getInputMarginBottom());
+ mChatInputContainer.setLayoutParams(lp);
+
mMediaPlayer.setAudioStreamType(AudioManager.STREAM_RING);
mMediaPlayer.setOnErrorListener(new MediaPlayer.OnErrorListener() {
@Override
@@ -378,6 +391,11 @@ public void setMenuClickListener(OnMenuClickListener listener) {
mListener = listener;
}
+ public void setCustomMenuClickListener(CustomMenuEventListener listener){
+ mMenuManager.setCustomMenuClickListener(listener);
+ }
+
+
public void setRecordVoiceListener(RecordVoiceListener listener) {
this.mRecordVoiceBtn.setRecordVoiceListener(listener);
this.mRecordVoiceListener = listener;
@@ -446,6 +464,7 @@ public void onClick(View view) {
}
} else {
+ mMenuManager.hideCustomMenu();
mChatInput.clearFocus();
if (view.getId() == R.id.aurora_ll_menuitem_voice_container) {
if (mListener != null && mListener.switchToMicrophoneMode()) {
@@ -965,6 +984,7 @@ public void run() {
}
public void dismissMenuLayout() {
+ mMenuManager.hideCustomMenu();
mMenuContainer.setVisibility(GONE);
if (mCameraSupport != null) {
mCameraSupport.release();
@@ -1039,6 +1059,14 @@ public void showEmojiLayout() {
mEmojiRl.setVisibility(VISIBLE);
}
+ public void hideDefaultMenuLayout(){
+ mRecordVoiceRl.setVisibility(GONE);
+ mSelectPhotoView.setVisibility(GONE);
+ mCameraFl.setVisibility(GONE);
+ mEmojiRl.setVisibility(GONE);
+ }
+
+
public void dismissEmojiLayout() {
mEmojiRl.setVisibility(GONE);
}
@@ -1457,4 +1485,9 @@ public ImageButton getRecordVideoBtn() {
return this.mRecordVideoBtn;
}
+ public MenuManager getMenuManager(){
+ return this.mMenuManager;
+ }
+
+
}
diff --git a/Android/chatinput/src/main/java/cn/jiguang/imui/chatinput/listener/CustomMenuEventListener.java b/Android/chatinput/src/main/java/cn/jiguang/imui/chatinput/listener/CustomMenuEventListener.java
new file mode 100644
index 00000000..ae94f5b6
--- /dev/null
+++ b/Android/chatinput/src/main/java/cn/jiguang/imui/chatinput/listener/CustomMenuEventListener.java
@@ -0,0 +1,21 @@
+package cn.jiguang.imui.chatinput.listener;
+
+
+import android.view.View;
+
+import java.util.List;
+
+import cn.jiguang.imui.chatinput.menu.view.MenuFeature;
+import cn.jiguang.imui.chatinput.menu.view.MenuItem;
+import cn.jiguang.imui.chatinput.model.FileItem;
+
+/**
+ * Custom Menu' callbacks
+ */
+public interface CustomMenuEventListener {
+
+ boolean onMenuItemClick(String tag, MenuItem menuItem);
+
+ void onMenuFeatureVisibilityChanged(int visibility,String tag,MenuFeature menuFeature);
+
+}
\ No newline at end of file
diff --git a/Android/chatinput/src/main/java/cn/jiguang/imui/chatinput/menu/Menu.java b/Android/chatinput/src/main/java/cn/jiguang/imui/chatinput/menu/Menu.java
new file mode 100644
index 00000000..ae6195a9
--- /dev/null
+++ b/Android/chatinput/src/main/java/cn/jiguang/imui/chatinput/menu/Menu.java
@@ -0,0 +1,76 @@
+package cn.jiguang.imui.chatinput.menu;
+
+
+public class Menu {
+
+ public static final String TAG_VOICE = "voice";
+ public static final String TAG_GALLERY = "gallery";
+ public static final String TAG_CAMERA = "camera";
+ public static final String TAG_EMOJI = "emoji";
+ public static final String TAG_SEND = "send";
+
+ private final boolean customize;
+ private final String[] left;
+ private final String[] right;
+ private final String[] bottom;
+
+ private Menu(Builder builder) {
+ this.customize = builder.customize;
+ this.left = builder.left;
+ this.right = builder.right;
+ this.bottom = builder.bottom;
+ }
+
+ public boolean isCustomize() {
+ return customize;
+ }
+
+ public String[] getLeft() {
+ return left;
+ }
+
+ public String[] getRight() {
+ return right;
+ }
+
+ public String[] getBottom() {
+ return bottom;
+ }
+
+ public static Builder newBuilder(){
+ return new Builder();
+ }
+
+ public static class Builder{
+ private boolean customize;
+ private String[] left;
+ private String[] right;
+ private String[] bottom;
+
+ public Builder customize(boolean customize){
+ this.customize = customize;
+ return this;
+ }
+
+
+ public Builder setLeft(String ... tags){
+ this.left =tags;
+ return this;
+ }
+
+ public Builder setRight(String ... tags){
+ this.right =tags;
+ return this;
+ }
+
+ public Builder setBottom(String ... tags){
+ this.bottom =tags;
+ return this;
+ }
+
+ public Menu build(){
+ return new Menu(this);
+ }
+
+ }
+}
diff --git a/Android/chatinput/src/main/java/cn/jiguang/imui/chatinput/menu/MenuManager.java b/Android/chatinput/src/main/java/cn/jiguang/imui/chatinput/menu/MenuManager.java
new file mode 100644
index 00000000..89c466cf
--- /dev/null
+++ b/Android/chatinput/src/main/java/cn/jiguang/imui/chatinput/menu/MenuManager.java
@@ -0,0 +1,186 @@
+package cn.jiguang.imui.chatinput.menu;
+
+import android.content.Context;
+import android.util.Log;
+import android.view.View;
+import android.widget.FrameLayout;
+import android.widget.LinearLayout;
+
+import cn.jiguang.imui.chatinput.ChatInputView;
+import cn.jiguang.imui.chatinput.emoji.EmoticonsKeyboardUtils;
+import cn.jiguang.imui.chatinput.listener.CustomMenuEventListener;
+import cn.jiguang.imui.chatinput.menu.collection.MenuCollection;
+import cn.jiguang.imui.chatinput.menu.collection.MenuFeatureCollection;
+import cn.jiguang.imui.chatinput.menu.collection.MenuItemCollection;
+import cn.jiguang.imui.chatinput.menu.view.MenuFeature;
+import cn.jiguang.imui.chatinput.menu.view.MenuItem;
+import cn.jiguang.imui.chatinput.utils.SimpleCommonUtils;
+
+import static android.view.View.GONE;
+import static android.view.View.VISIBLE;
+
+
+public class MenuManager {
+ public static final String TAG = SimpleCommonUtils.formatTag(MenuManager.class.getSimpleName());
+
+ private ChatInputView mChatInputView;
+ private LinearLayout mChatInputContainer;
+ private LinearLayout mMenuItemContainer;
+ private FrameLayout mMenuContainer;
+ private Context mContext;
+ private MenuItemCollection mMenuItemCollection;
+ private MenuFeatureCollection mMenuFeatureCollection;
+ private CustomMenuEventListener mCustomMenuEventListener;
+
+ public MenuManager(ChatInputView chatInputView, LinearLayout chatInputContainer, LinearLayout menuItemContainer, FrameLayout menuContainer) {
+ mChatInputView = chatInputView;
+ mContext = chatInputView.getContext();
+ mChatInputContainer = chatInputContainer;
+ mMenuItemContainer = menuItemContainer;
+ mMenuContainer = menuContainer;
+ initCollection();
+
+ initDefaultMenu();
+ }
+
+ private void initCollection() {
+ mMenuItemCollection = new MenuItemCollection(mContext);
+
+ mMenuItemCollection.setMenuCollectionChangedListener(new MenuCollection.MenuCollectionChangedListener() {
+ @Override
+ public void addMenu(String menuTag, View menu) {
+ menu.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ mChatInputView.getInputView().clearFocus();
+ String tag = (String) v.getTag();
+ if (mCustomMenuEventListener != null && mCustomMenuEventListener.onMenuItemClick(tag, (MenuItem) v)) {
+ showMenuFeatureByTag(tag);
+ }
+ }
+ });
+ }
+ });
+
+ mMenuFeatureCollection = new MenuFeatureCollection(mContext);
+ mMenuFeatureCollection.setMenuCollectionChangedListener(new MenuCollection.MenuCollectionChangedListener() {
+ @Override
+ public void addMenu(String menuTag, View menu) {
+ menu.setVisibility(View.GONE);
+ mMenuContainer.addView(menu);
+ }
+ });
+
+ }
+
+
+ private void showMenuFeatureByTag(String tag) {
+
+
+ View menuFeature = mMenuFeatureCollection.get(tag);
+ if (menuFeature == null) {
+ Log.i(TAG, "Can't find MenuFeature to show by tag:" + tag);
+ return;
+ }
+
+ if (menuFeature.getVisibility() == VISIBLE && mMenuContainer.getVisibility() == VISIBLE) {
+ mChatInputView.dismissMenuLayout();
+ return;
+ }
+
+ if (mChatInputView.isKeyboardVisible()) {
+ mChatInputView.setPendingShowMenu(true);
+ EmoticonsKeyboardUtils.closeSoftKeyboard(mChatInputView.getInputView());
+
+ } else {
+ mChatInputView.showMenuLayout();
+
+ }
+
+ mChatInputView.hideDefaultMenuLayout();
+ hideCustomMenu();
+ menuFeature.setVisibility(VISIBLE);
+ if (mCustomMenuEventListener != null)
+ mCustomMenuEventListener.onMenuFeatureVisibilityChanged(VISIBLE, tag, (MenuFeature) menuFeature);
+ lastMenuFeature = menuFeature;
+
+ }
+
+ private View lastMenuFeature;
+
+ public void hideCustomMenu() {
+ if (lastMenuFeature != null && lastMenuFeature.getVisibility() != GONE) {
+ lastMenuFeature.setVisibility(View.GONE);
+ if (mCustomMenuEventListener != null)
+ mCustomMenuEventListener.onMenuFeatureVisibilityChanged(GONE, (String) lastMenuFeature.getTag(), (MenuFeature) lastMenuFeature);
+ }
+
+ }
+
+
+ private void initDefaultMenu() {
+ addBottomByTag(Menu.TAG_VOICE,
+ Menu.TAG_GALLERY,
+ Menu.TAG_CAMERA,
+ Menu.TAG_EMOJI,
+ Menu.TAG_SEND);
+ }
+
+ public void setMenu(Menu menu) {
+ if (menu.isCustomize()) {
+ mMenuItemContainer.removeAllViews();
+ addViews(mChatInputContainer, 1, menu.getLeft());
+ addViews(mChatInputContainer, mChatInputContainer.getChildCount() - 1, menu.getRight());
+ addBottomByTag(menu.getBottom());
+ }
+ }
+
+ private void addBottomByTag(String... tags) {
+ if (tags == null || tags.length == 0) {
+ mMenuItemContainer.setVisibility(View.GONE);
+ }
+ addViews(mMenuItemContainer, -1, tags);
+ }
+
+
+ private void addViews(LinearLayout parent, int index, String... tags) {
+ if (parent == null || tags == null)
+ return;
+ for (String tag : tags) {
+ View child = mMenuItemCollection.get(tag);
+ if (child == null) {
+ Log.e(TAG, "Can't find view by tag " + tag + ".");
+ continue;
+ }
+
+ parent.addView(child, index);
+ }
+ }
+
+ public MenuItemCollection getMenuItemCollection() {
+ return mMenuItemCollection;
+ }
+
+ public MenuFeatureCollection getMenuFeatureCollection() {
+ return mMenuFeatureCollection;
+ }
+
+ public void addCustomMenu(String tag, MenuItem menuItem, MenuFeature menuFeature) {
+
+ mMenuItemCollection.addCustomMenuItem(tag, menuItem);
+ mMenuFeatureCollection.addMenuFeature(tag, menuFeature);
+ }
+
+ public void addCustomMenu(String tag, int menuItemResource, int menuFeatureResource) {
+
+ mMenuItemCollection.addCustomMenuItem(tag, menuItemResource);
+ mMenuFeatureCollection.addMenuFeature(tag, menuFeatureResource);
+ }
+
+
+ public void setCustomMenuClickListener(CustomMenuEventListener listener) {
+ this.mCustomMenuEventListener = listener;
+ }
+
+
+}
diff --git a/Android/chatinput/src/main/java/cn/jiguang/imui/chatinput/menu/collection/MenuCollection.java b/Android/chatinput/src/main/java/cn/jiguang/imui/chatinput/menu/collection/MenuCollection.java
new file mode 100644
index 00000000..bf6bc60b
--- /dev/null
+++ b/Android/chatinput/src/main/java/cn/jiguang/imui/chatinput/menu/collection/MenuCollection.java
@@ -0,0 +1,57 @@
+package cn.jiguang.imui.chatinput.menu.collection;
+
+import android.content.Context;
+import android.text.TextUtils;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+
+import java.util.HashMap;
+
+import cn.jiguang.imui.chatinput.utils.SimpleCommonUtils;
+
+
+public class MenuCollection extends HashMap {
+
+ public static final String TAG = SimpleCommonUtils.formatTag(MenuCollection.class.getSimpleName());
+ protected Context mContext;
+ protected LayoutInflater mInflater;
+
+
+ public MenuCollection(Context context) {
+ mContext = context;
+ mInflater = LayoutInflater.from(mContext);
+ }
+
+
+ protected void addMenu(String menuTag, View menu) {
+ if(TextUtils.isEmpty(menuTag)){
+ Log.e(TAG, "Collection custom menu failed,tag is empty.");
+ return;
+ }
+
+ if (containsKey(menuTag)) {
+ Log.e(TAG, "Collection custom menu failed,Tag " + menuTag + " has been used already!");
+ return;
+ }
+ menu.setTag(menuTag);
+ if (mMenuCollectionChangedListener != null) {
+ mMenuCollectionChangedListener.addMenu(menuTag, menu);
+ }
+
+ this.put(menuTag, menu);
+
+ }
+
+ private MenuCollectionChangedListener mMenuCollectionChangedListener;
+
+ public void setMenuCollectionChangedListener(MenuCollectionChangedListener menuCollectionChangedListener) {
+ this.mMenuCollectionChangedListener = menuCollectionChangedListener;
+ }
+
+ public interface MenuCollectionChangedListener {
+ void addMenu(String menuTag, View menu);
+ }
+
+
+}
diff --git a/Android/chatinput/src/main/java/cn/jiguang/imui/chatinput/menu/collection/MenuFeatureCollection.java b/Android/chatinput/src/main/java/cn/jiguang/imui/chatinput/menu/collection/MenuFeatureCollection.java
new file mode 100644
index 00000000..282e0ada
--- /dev/null
+++ b/Android/chatinput/src/main/java/cn/jiguang/imui/chatinput/menu/collection/MenuFeatureCollection.java
@@ -0,0 +1,41 @@
+package cn.jiguang.imui.chatinput.menu.collection;
+
+import android.content.Context;
+import android.util.Log;
+import android.view.View;
+
+import cn.jiguang.imui.chatinput.menu.view.MenuFeature;
+
+
+public class MenuFeatureCollection extends MenuCollection{
+
+
+
+ public MenuFeatureCollection(Context context){
+ super(context);
+ }
+
+ public void addMenuFeature(String tag,int resource){
+ if(resource == -1){
+ Log.i(TAG,"Menu feature with tag"+tag+" will not be added.");
+ return;
+ }
+ View view = mInflater.inflate(resource, null);
+ addMenuFeature(tag,view);
+ }
+
+ public void addMenuFeature(String tag,View menuFeature){
+ if(menuFeature == null){
+ Log.i(TAG,"Menu feature with tag"+tag+" will not be added.");
+ return;
+ }
+
+ if(menuFeature instanceof MenuFeature){
+ menuFeature.setVisibility(View.GONE);
+ addMenu(tag,menuFeature);
+ }else {
+ Log.e(TAG,"Collection menu feature failed exception!");
+ }
+ }
+
+}
diff --git a/Android/chatinput/src/main/java/cn/jiguang/imui/chatinput/menu/collection/MenuItemCollection.java b/Android/chatinput/src/main/java/cn/jiguang/imui/chatinput/menu/collection/MenuItemCollection.java
new file mode 100644
index 00000000..4524f0b3
--- /dev/null
+++ b/Android/chatinput/src/main/java/cn/jiguang/imui/chatinput/menu/collection/MenuItemCollection.java
@@ -0,0 +1,55 @@
+package cn.jiguang.imui.chatinput.menu.collection;
+
+import android.content.Context;
+import android.util.Log;
+import android.view.View;
+
+
+import cn.jiguang.imui.chatinput.R;
+import cn.jiguang.imui.chatinput.menu.Menu;
+import cn.jiguang.imui.chatinput.menu.view.MenuItem;
+import cn.jiguang.imui.chatinput.utils.ViewUtil;
+
+
+public class MenuItemCollection extends MenuCollection {
+
+
+ public MenuItemCollection(Context context) {
+ super(context);
+ initDefaultMenu();
+ }
+
+ private void initDefaultMenu() {
+ this.put(Menu.TAG_VOICE, inflaterMenu(R.layout.menu_item_voice));
+ this.put(Menu.TAG_GALLERY, inflaterMenu(R.layout.menu_item_photo));
+ this.put(Menu.TAG_CAMERA, inflaterMenu(R.layout.menu_item_camera));
+ this.put(Menu.TAG_EMOJI, inflaterMenu(R.layout.menu_item_emoji));
+ this.put(Menu.TAG_SEND, inflaterMenu(R.layout.menu_item_send));
+
+ }
+
+ private View inflaterMenu(int resource) {
+ View view = mInflater.inflate(resource, null);
+ view = ViewUtil.formatViewWeight(view, 1);
+ return view;
+
+ }
+
+ public void addCustomMenuItem(String tag, int resource) {
+ View view = mInflater.inflate(resource, null);
+ addCustomMenuItem(tag, view);
+ }
+
+
+ public void addCustomMenuItem(String tag, View menu) {
+ if (menu instanceof MenuItem) {
+ menu.setClickable(true);
+ menu = ViewUtil.formatViewWeight(menu, 1);
+ addMenu(tag, menu);
+ } else {
+ Log.e(TAG, "Collection menu item failed !");
+ }
+ }
+
+
+}
diff --git a/Android/chatinput/src/main/java/cn/jiguang/imui/chatinput/menu/view/MenuFeature.java b/Android/chatinput/src/main/java/cn/jiguang/imui/chatinput/menu/view/MenuFeature.java
new file mode 100644
index 00000000..f6b26715
--- /dev/null
+++ b/Android/chatinput/src/main/java/cn/jiguang/imui/chatinput/menu/view/MenuFeature.java
@@ -0,0 +1,21 @@
+package cn.jiguang.imui.chatinput.menu.view;
+
+import android.content.Context;
+import android.support.annotation.Nullable;
+import android.util.AttributeSet;
+import android.widget.LinearLayout;
+
+
+public class MenuFeature extends LinearLayout {
+ public MenuFeature(Context context) {
+ super(context);
+ }
+
+ public MenuFeature(Context context, @Nullable AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ public MenuFeature(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
+ super(context, attrs, defStyleAttr);
+ }
+}
diff --git a/Android/chatinput/src/main/java/cn/jiguang/imui/chatinput/menu/view/MenuItem.java b/Android/chatinput/src/main/java/cn/jiguang/imui/chatinput/menu/view/MenuItem.java
new file mode 100644
index 00000000..daf731cb
--- /dev/null
+++ b/Android/chatinput/src/main/java/cn/jiguang/imui/chatinput/menu/view/MenuItem.java
@@ -0,0 +1,22 @@
+package cn.jiguang.imui.chatinput.menu.view;
+
+import android.content.Context;
+import android.support.annotation.Nullable;
+import android.util.AttributeSet;
+import android.widget.LinearLayout;
+
+
+public class MenuItem extends LinearLayout {
+ public MenuItem(Context context) {
+ super(context);
+ }
+
+ public MenuItem(Context context, @Nullable AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ public MenuItem(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
+ super(context, attrs, defStyleAttr);
+ }
+
+}
diff --git a/Android/chatinput/src/main/java/cn/jiguang/imui/chatinput/utils/SimpleCommonUtils.java b/Android/chatinput/src/main/java/cn/jiguang/imui/chatinput/utils/SimpleCommonUtils.java
index 7f5f3a5e..9539b937 100644
--- a/Android/chatinput/src/main/java/cn/jiguang/imui/chatinput/utils/SimpleCommonUtils.java
+++ b/Android/chatinput/src/main/java/cn/jiguang/imui/chatinput/utils/SimpleCommonUtils.java
@@ -224,4 +224,8 @@ public static void delClick(EditText editText) {
//
// tv_content.setText(spannable);
// }
+ public static String formatTag(String tag){
+ return "IMUI-"+tag;
+ }
+
}
diff --git a/Android/chatinput/src/main/java/cn/jiguang/imui/chatinput/utils/ViewUtil.java b/Android/chatinput/src/main/java/cn/jiguang/imui/chatinput/utils/ViewUtil.java
index 1a998cde..999b92e6 100644
--- a/Android/chatinput/src/main/java/cn/jiguang/imui/chatinput/utils/ViewUtil.java
+++ b/Android/chatinput/src/main/java/cn/jiguang/imui/chatinput/utils/ViewUtil.java
@@ -1,6 +1,8 @@
package cn.jiguang.imui.chatinput.utils;
import android.content.res.Resources;
+import android.view.View;
+import android.widget.LinearLayout;
public final class ViewUtil {
@@ -15,5 +17,13 @@ public static int dpToPx(int dp) {
return Math.round(dp * density);
}
+ public static View formatViewWeight(View view,float weight) {
+ if(view != null){
+ LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(0,LinearLayout.LayoutParams.MATCH_PARENT,weight);
+ view.setLayoutParams(lp);
+ }
+ return view;
+ }
+
}
diff --git a/Android/chatinput/src/main/res/layout/layout_chatinput_menu.xml b/Android/chatinput/src/main/res/layout/layout_chatinput_menu.xml
index aafc0963..9f31245c 100644
--- a/Android/chatinput/src/main/res/layout/layout_chatinput_menu.xml
+++ b/Android/chatinput/src/main/res/layout/layout_chatinput_menu.xml
@@ -6,135 +6,135 @@
android:baselineAligned="false"
android:orientation="horizontal">
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Android/chatinput/src/main/res/layout/menu_item_camera.xml b/Android/chatinput/src/main/res/layout/menu_item_camera.xml
new file mode 100644
index 00000000..4f46278f
--- /dev/null
+++ b/Android/chatinput/src/main/res/layout/menu_item_camera.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/Android/chatinput/src/main/res/layout/menu_item_emoji.xml b/Android/chatinput/src/main/res/layout/menu_item_emoji.xml
new file mode 100644
index 00000000..6a46af09
--- /dev/null
+++ b/Android/chatinput/src/main/res/layout/menu_item_emoji.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/Android/chatinput/src/main/res/layout/menu_item_photo.xml b/Android/chatinput/src/main/res/layout/menu_item_photo.xml
new file mode 100644
index 00000000..17fb0e84
--- /dev/null
+++ b/Android/chatinput/src/main/res/layout/menu_item_photo.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
diff --git a/Android/chatinput/src/main/res/layout/menu_item_send.xml b/Android/chatinput/src/main/res/layout/menu_item_send.xml
new file mode 100644
index 00000000..cfe6eab8
--- /dev/null
+++ b/Android/chatinput/src/main/res/layout/menu_item_send.xml
@@ -0,0 +1,42 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Android/chatinput/src/main/res/layout/menu_item_voice.xml b/Android/chatinput/src/main/res/layout/menu_item_voice.xml
new file mode 100644
index 00000000..ae819e54
--- /dev/null
+++ b/Android/chatinput/src/main/res/layout/menu_item_voice.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/Android/chatinput/src/main/res/layout/view_chatinput.xml b/Android/chatinput/src/main/res/layout/view_chatinput.xml
index 5add0011..8858e651 100644
--- a/Android/chatinput/src/main/res/layout/view_chatinput.xml
+++ b/Android/chatinput/src/main/res/layout/view_chatinput.xml
@@ -13,14 +13,14 @@
diff --git a/Android/chatinput/src/main/res/values/attrs.xml b/Android/chatinput/src/main/res/values/attrs.xml
index ef68dcb0..00ec976e 100644
--- a/Android/chatinput/src/main/res/values/attrs.xml
+++ b/Android/chatinput/src/main/res/values/attrs.xml
@@ -6,6 +6,8 @@
+
+
diff --git a/Android/chatinput/src/main/res/values/dimens.xml b/Android/chatinput/src/main/res/values/dimens.xml
index 36272c36..2aebe953 100644
--- a/Android/chatinput/src/main/res/values/dimens.xml
+++ b/Android/chatinput/src/main/res/values/dimens.xml
@@ -8,6 +8,8 @@
20dp
20dp
+ 8dp
+ 0dp
17sp
diff --git a/Android/sample/exampleui/src/main/java/imui/jiguang/cn/imuisample/views/ChatView.java b/Android/sample/exampleui/src/main/java/imui/jiguang/cn/imuisample/views/ChatView.java
index 5f078c53..b1ed5da1 100644
--- a/Android/sample/exampleui/src/main/java/imui/jiguang/cn/imuisample/views/ChatView.java
+++ b/Android/sample/exampleui/src/main/java/imui/jiguang/cn/imuisample/views/ChatView.java
@@ -1,9 +1,9 @@
package imui.jiguang.cn.imuisample.views;
import android.content.Context;
-import android.graphics.Color;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
+import android.view.View;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
@@ -12,8 +12,13 @@
import cn.jiguang.imui.chatinput.ChatInputView;
import cn.jiguang.imui.chatinput.listener.OnCameraCallbackListener;
import cn.jiguang.imui.chatinput.listener.OnClickEditTextListener;
+import cn.jiguang.imui.chatinput.listener.CustomMenuEventListener;
import cn.jiguang.imui.chatinput.listener.OnMenuClickListener;
import cn.jiguang.imui.chatinput.listener.RecordVoiceListener;
+import cn.jiguang.imui.chatinput.menu.Menu;
+import cn.jiguang.imui.chatinput.menu.MenuManager;
+import cn.jiguang.imui.chatinput.menu.view.MenuFeature;
+import cn.jiguang.imui.chatinput.menu.view.MenuItem;
import cn.jiguang.imui.chatinput.record.RecordVoiceButton;
import cn.jiguang.imui.messages.MessageList;
import cn.jiguang.imui.messages.MsgListAdapter;
@@ -81,6 +86,35 @@ public void initModule() {
// set show display name or not
// mMsgList.setShowReceiverDisplayName(true);
// mMsgList.setShowSenderDisplayName(false);
+
+
+ // add Custom Menu View
+ MenuManager menuManager = mChatInput.getMenuManager();
+ menuManager.addCustomMenu("MY_CUSTOM",R.layout.menu_text_item,R.layout.menu_text_feature);
+
+ // Custom menu order
+ menuManager.setMenu(Menu.newBuilder().
+ customize(true).
+ setRight(Menu.TAG_SEND).
+ setBottom(Menu.TAG_VOICE,Menu.TAG_EMOJI,Menu.TAG_GALLERY,Menu.TAG_CAMERA,"MY_CUSTOM").
+ build());
+ menuManager.setCustomMenuClickListener(new CustomMenuEventListener() {
+ @Override
+ public boolean onMenuItemClick(String tag, MenuItem menuItem) {
+ //Menu feature will not be show shown if return false;
+ return true;
+ }
+
+ @Override
+ public void onMenuFeatureVisibilityChanged(int visibility, String tag, MenuFeature menuFeature) {
+ if(visibility == View.VISIBLE){
+ // Menu feature is visible.
+ }else {
+ // Menu feature is gone.
+ }
+ }
+ });
+
}
public PullToRefreshLayout getPtrLayout() {
diff --git a/Android/sample/exampleui/src/main/res/layout/activity_chat.xml b/Android/sample/exampleui/src/main/res/layout/activity_chat.xml
index 051e83af..bd1654af 100644
--- a/Android/sample/exampleui/src/main/res/layout/activity_chat.xml
+++ b/Android/sample/exampleui/src/main/res/layout/activity_chat.xml
@@ -64,6 +64,8 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
+ app:inputMarginLeft="3dp"
+ app:inputMarginRight="3dp"
app:showSelectAlbum="true"/>
diff --git a/Android/sample/exampleui/src/main/res/layout/menu_text_feature.xml b/Android/sample/exampleui/src/main/res/layout/menu_text_feature.xml
new file mode 100644
index 00000000..3a1079b3
--- /dev/null
+++ b/Android/sample/exampleui/src/main/res/layout/menu_text_feature.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Android/sample/exampleui/src/main/res/layout/menu_text_item.xml b/Android/sample/exampleui/src/main/res/layout/menu_text_item.xml
new file mode 100644
index 00000000..35fac49a
--- /dev/null
+++ b/Android/sample/exampleui/src/main/res/layout/menu_text_item.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ReactNative/android/build.gradle b/ReactNative/android/build.gradle
index e97a3ef2..9d891a27 100644
--- a/ReactNative/android/build.gradle
+++ b/ReactNative/android/build.gradle
@@ -28,7 +28,7 @@ dependencies {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'cn.jiguang.imui:messagelist:0.7.4'
- compile 'cn.jiguang.imui:chatinput:0.8.3'
+ compile 'cn.jiguang.imui:chatinput:0.9.0'
compile 'pub.devrel:easypermissions:1.0.1'
compile 'org.greenrobot:eventbus:3.0.0'
implementation 'com.android.support:appcompat-v7:27.1.0'
diff --git a/ReactNative/android/src/main/java/cn/jiguang/imui/messagelist/viewmanager/ReactChatInputManager.java b/ReactNative/android/src/main/java/cn/jiguang/imui/messagelist/viewmanager/ReactChatInputManager.java
index ad77a98b..d3074f25 100644
--- a/ReactNative/android/src/main/java/cn/jiguang/imui/messagelist/viewmanager/ReactChatInputManager.java
+++ b/ReactNative/android/src/main/java/cn/jiguang/imui/messagelist/viewmanager/ReactChatInputManager.java
@@ -56,6 +56,7 @@
import cn.jiguang.imui.chatinput.listener.OnCameraCallbackListener;
import cn.jiguang.imui.chatinput.listener.OnMenuClickListener;
import cn.jiguang.imui.chatinput.listener.RecordVoiceListener;
+import cn.jiguang.imui.chatinput.menu.Menu;
import cn.jiguang.imui.chatinput.model.FileItem;
import cn.jiguang.imui.chatinput.model.VideoItem;
import cn.jiguang.imui.messagelist.AuroraIMUIModule;
@@ -64,7 +65,6 @@
import cn.jiguang.imui.messagelist.event.OnTouchMsgListEvent;
import cn.jiguang.imui.messagelist.event.ScrollEvent;
import cn.jiguang.imui.messagelist.event.StopPlayVoiceEvent;
-import pub.devrel.easypermissions.AfterPermissionGranted;
import pub.devrel.easypermissions.AppSettingsDialog;
import pub.devrel.easypermissions.EasyPermissions;
@@ -405,7 +405,7 @@ public void run() {
@Override
public void onTakePictureCompleted(String photoPath) {
- if(mLastPhotoPath.equals(photoPath)){
+ if (mLastPhotoPath.equals(photoPath)) {
return;
}
mLastPhotoPath = photoPath;
@@ -554,6 +554,7 @@ public void onPageScrollStateChanged(int state) {
}
});
+
return mChatInput;
}
@@ -682,10 +683,10 @@ public void showSelectAlbumBtn(ChatInputView chatInputView, boolean flag) {
@ReactProp(name = "showRecordVideoBtn")
public void showRecordVideoBtn(ChatInputView chatInputView, boolean flag) {
- if(flag){
+ if (flag) {
chatInputView.getRecordVideoBtn().setVisibility(View.VISIBLE);
chatInputView.getRecordVideoBtn().setTag("VISIBLE");
- }else{
+ } else {
chatInputView.getRecordVideoBtn().setVisibility(View.GONE);
chatInputView.getRecordVideoBtn().setTag("GONE");
}
@@ -742,6 +743,45 @@ public void hidePhotoButton(ChatInputView chatInputView, boolean hide) {
chatInputView.getPhotoBtnContainer().setVisibility(hide ? View.GONE : View.VISIBLE);
}
+ @ReactProp(name = "customLayoutItems")
+ public void setCustomItems(ChatInputView chatInputView, ReadableMap map) {
+
+ ReadableArray left = map.hasKey("left") ? map.getArray("left") : null;
+ ReadableArray right = map.hasKey("right") ? map.getArray("right") : null;
+ ReadableArray bottom = map.hasKey("bottom") ? map.getArray("bottom") : null;
+ String[] bottomTags = new String[0];
+ if (bottom != null) {
+ bottomTags = new String[bottom.size()];
+ for (int i = 0; i < bottom.size(); i++) {
+ bottomTags[i] = bottom.getString(i);
+ }
+ }
+
+ String[] leftTags = new String[0];
+ if (left != null) {
+ leftTags = new String[left.size()];
+ for (int i = 0; i < left.size(); i++) {
+ leftTags[i] = left.getString(i);
+ }
+ }
+
+ String[] rightTags = new String[0];
+ if (right != null) {
+ rightTags = new String[right.size()];
+ for (int i = 0; i < right.size(); i++) {
+ rightTags[i] = right.getString(i);
+ }
+ }
+ mChatInput.getMenuManager()
+ .setMenu(Menu.newBuilder()
+ .customize(true)
+ .setLeft(leftTags)
+ .setRight(rightTags)
+ .setBottom(bottomTags)
+ .build());
+
+ }
+
@Override
public Map getExportedCustomDirectEventTypeConstants() {
return MapBuilder.builder()
diff --git a/ReactNative/chatinput.android.js b/ReactNative/chatinput.android.js
index 8f5a34e5..0958eef5 100644
--- a/ReactNative/chatinput.android.js
+++ b/ReactNative/chatinput.android.js
@@ -267,6 +267,7 @@ ChatInput.propTypes = {
hideVoiceButton: PropTypes.bool,
hideEmojiButton: PropTypes.bool,
hidePhotoButton: PropTypes.bool,
+ customLayoutItems: PropTypes.object,
...ViewPropTypes
};
diff --git a/ReactNative/docs/APIs.md b/ReactNative/docs/APIs.md
index 71f55b04..0683d60a 100644
--- a/ReactNative/docs/APIs.md
+++ b/ReactNative/docs/APIs.md
@@ -82,10 +82,6 @@ Refer to iOS,Android example
- [chatInputBackgroupColor](#chatInputbackgroupcolor)
- [showSelectAlbumBtn](#showselectalbumbtnandroid-only)
- [showRecordVideoBtn](#showRecordVideoBtnandroid-only)
- - [hideCameraButton](#hideCameraButtonandroid-only)
- - [hideVoiceButton](#hideVoiceButtonandroid-only)
- - [hideEmojiButton](#hideEmojiButtonandroid-only)
- - [hidePhotoButton](#hidePhotoButtonandroid-only)
- [inputPadding](#inputPadding)
- [inputTextColor](#inputTextColor)
- [inputTextSize](#inputTextSize)
@@ -578,7 +574,7 @@ Example: ```isAllowPullToRefresh={ture}```。
***
-#### customLayoutItems(iOS Only)
+#### customLayoutItems
**PropTypes.string:**
@@ -628,43 +624,6 @@ Set the visibility of the record video button.
Example: ```showRecordVideoBtn={true}```
-------
-
-#### hideCameraButton(Android Only)
-**PropTypes.bool:**
-
-Set the visibility of the camera button.
-
-Example: ```hideCameraButton={true}```
-
-
-------
-
-#### hideVoiceButton(Android Only)
-**PropTypes.bool:**
-
-Set the visibility of the voice button.
-
-Example: ```hideVoiceButton={true}```
-
-------
-
-#### hideEmojiButton(Android Only)
-**PropTypes.bool:**
-
-Set the visibility of the Emoji button.
-
-Example: ```hideEmojiButton={true}```
-
-------
-
-#### hidePhotoButton(Android Only)
-**PropTypes.bool:**
-
-Set the visibility of the photo button.
-
-Example: ```hidePhotoButton={true}```
-
------
### inputPadding
diff --git a/ReactNative/docs/APIs_zh.md b/ReactNative/docs/APIs_zh.md
index 0f926e24..6e73ddc2 100644
--- a/ReactNative/docs/APIs_zh.md
+++ b/ReactNative/docs/APIs_zh.md
@@ -81,10 +81,6 @@ const AuroraIMUIController = IMUI.AuroraIMUIController; // the IMUI controller,
- [chatInputBackgroupColor](#chatInputbackgroupcolor)
- [showSelectAlbumBtn](#showselectalbumbtnandroid-only)
- [showRecordVideoBtn](#showRecordVideoBtnandroid-only)
- - [hideCameraButton](#hideCameraButtonandroid-only)
- - [hideVoiceButton](#hideVoiceButtonandroid-only)
- - [hideEmojiButton](#hideEmojiButtonandroid-only)
- - [hidePhotoButton](#hidePhotoButtonandroid-only)
- [inputPadding](#inputPadding)
- [inputTextColor](#inputTextColor)
- [inputTextSize](#inputTextSize)
@@ -577,7 +573,7 @@ Example: `messageTextLineHeight={5}`
### Props customizable style
------
-#### customLayoutItems(iOS Only)
+#### customLayoutItems
**PropTypes.string:**
@@ -627,43 +623,6 @@ Example: ```showSelectAlbumBtn={true}```
Example: ```showRecordVideoBtn={true}```
-
-------
-
-#### hideCameraButton(Android Only)
-**PropTypes.bool:**
-
-设置菜单栏相机按钮可见性。
-
-Example: ```hideCameraButton={true}```
-
-------
-
-#### hideVoiceButton(Android Only)
-**PropTypes.bool:**
-
-设置菜单栏录音按钮可见性。
-
-Example: ```hideVoiceButton={true}```
-
-------
-
-#### hideEmojiButton(Android Only)
-**PropTypes.bool:**
-
-设置菜单栏Emoji表情按钮可见性。
-
-Example: ```hideEmojiButton={true}```
-
-------
-
-#### hidePhotoButton(Android Only)
-**PropTypes.bool:**
-
-设置菜单栏相册按钮可见性。
-
-Example: ```hidePhotoButton={true}```
-
------
### inputPadding
diff --git a/ReactNative/sample/App.js b/ReactNative/sample/App.js
index 5c72fd28..2c8f5be4 100644
--- a/ReactNative/sample/App.js
+++ b/ReactNative/sample/App.js
@@ -549,7 +549,6 @@ export default class TestRNIMUI extends Component {
inputPadding={{ left: 30, top: 10, right: 10, bottom: 10 }}
galleryScale={0.6}//default = 0.5
compressionQuality={0.6}
- hideCameraButton={false}
customLayoutItems={{
left: [],
right: [],
diff --git a/package.json b/package.json
index 2b003489..e1ce69a9 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "aurora-imui-react-native",
- "version": "0.10.12",
+ "version": "0.11.0",
"description": "aurora imui plugin for react native application",
"main": "index.js",