Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add custom menu API #453

Merged
merged 16 commits into from
Sep 11, 2018
Prev Previous commit
Next Next commit
Update sample
  • Loading branch information
JoshLipan committed Sep 10, 2018
commit 65683f880bbc3294036d255229ffa13cce362150
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
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.util.Log;
import android.view.View;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

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.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;
Expand Down Expand Up @@ -81,6 +87,34 @@ public void initModule() {
// set show display name or not
// mMsgList.setShowReceiverDisplayName(true);
// mMsgList.setShowSenderDisplayName(false);


// add Custom Menu View
mChatInput.getMenuManager().addCustomMenu("MY_CUSTOM",R.layout.menu_text,R.layout.menu_text_feature);

// Custom menu order
mChatInput.getMenuManager().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());
mChatInput.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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"/>


Expand Down
12 changes: 12 additions & 0 deletions Android/sample/exampleui/src/main/res/layout/menu_text.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<cn.jiguang.imui.chatinput.menu.view.MenuItem xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:gravity="center"
android:layout_height="match_parent">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TEXT"/>

</cn.jiguang.imui.chatinput.menu.view.MenuItem>
14 changes: 14 additions & 0 deletions Android/sample/exampleui/src/main/res/layout/menu_text_feature.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<cn.jiguang.imui.chatinput.menu.view.MenuFeature xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:gravity="center"
android:layout_height="match_parent">

<TextView
android:id="@+id/menu_text_feature_tv"
android:layout_width="wrap_content"
android:textSize="50dp"
android:layout_height="wrap_content"
android:text="TEXT"/>

</cn.jiguang.imui.chatinput.menu.view.MenuFeature>