@SuppressLint("CommitPrefEdits") private EasePreferenceManager(){ mSharedPreferences = EaseUI.getInstance().getContext().getSharedPreferences("EM_SP_AT_MESSAGE", Context.MODE_PRIVATE); editor = mSharedPreferences.edit(); } private static EasePreferenceManager instance;
@SuppressLint("CommitPrefEdits") private EasePreferenceManager(){ mSharedPreferences = EaseUI.getInstance().getContext().getSharedPreferences("EM_SP_AT_MESSAGE", Context.MODE_PRIVATE); editor = mSharedPreferences.edit(); } private static EasePreferenceManager instance;
public boolean containsAtAll(String content){ String atAll = "@" + EaseUI.getInstance().getContext().getString(R.string.all_members); if(content.contains(atAll)){ return true; } return false; }
public boolean containsAtAll(String content){ String atAll = "@" + EaseUI.getInstance().getContext().getString(R.string.all_members); if(content.contains(atAll)){ return true; } return false; }
/** * init helper * * @param context * application context */ public void init(Context context) { EMOptions options = initChatOptions(); if (EaseUI.getInstance().init(context, options)) { appContext = context; EMClient.getInstance().setDebugMode(BuildConfig.DEBUG); easeUI = EaseUI.getInstance(); PreferenceManager.init(context); } }
@Override protected void onResume() { super.onResume(); // cancel the notification EaseUI.getInstance().getNotifier().reset(); }
@Override protected void onResume() { super.onResume(); // cancel the notification EaseUI.getInstance().getNotifier().reset(); }
@Override public void onSetUpView() { String emojiconId = message.getStringAttribute(EaseConstant.MESSAGE_ATTR_EXPRESSION_ID, null); EaseEmojicon emojicon = null; if(EaseUI.getInstance().getEmojiconInfoProvider() != null){ emojicon = EaseUI.getInstance().getEmojiconInfoProvider().getEmojiconInfo(emojiconId); } if(emojicon != null){ if(emojicon.getBigIcon() != 0){ Glide.with(activity).load(emojicon.getBigIcon()).placeholder(R.drawable.ease_default_expression).into(imageView); }else if(emojicon.getBigIconPath() != null){ Glide.with(activity).load(emojicon.getBigIconPath()).placeholder(R.drawable.ease_default_expression).into(imageView); }else{ imageView.setImageResource(R.drawable.ease_default_expression); } } } }
private void setSpeaker() { boolean speakerOn = EaseUI.getInstance().getSettingsProvider().isSpeakerOpened(); if (speakerOn) { audioManager.setMode(AudioManager.MODE_NORMAL); audioManager.setSpeakerphoneOn(true); mediaPlayer.setAudioStreamType(AudioManager.STREAM_RING); } else { audioManager.setSpeakerphoneOn(false);// 关闭扬声器 // 把声音设定成Earpiece(听筒)出来,设定为正在通话中 audioManager.setMode(AudioManager.MODE_IN_CALL); mediaPlayer.setAudioStreamType(AudioManager.STREAM_VOICE_CALL); } } }
public synchronized void onNewMesg(List<EMMessage> messages) { if(EaseCommonUtils.isSilentMessage(messages.get(messages.size()-1))){ return; } EaseSettingsProvider settingsProvider = EaseUI.getInstance().getSettingsProvider(); if(!settingsProvider.isMsgNotifyAllowed(null)){ return; } // check if app running background if (!EasyUtils.isAppRunningForeground(appContext)) { EMLog.d(TAG, "app is running in backgroud"); sendNotification(messages, false); } else { sendNotification(messages, true); } vibrateAndPlayTone(messages.get(messages.size()-1)); }
public synchronized void onNewMesg(List<EMMessage> messages) { if(EaseCommonUtils.isSilentMessage(messages.get(messages.size()-1))){ return; } EaseSettingsProvider settingsProvider = EaseUI.getInstance().getSettingsProvider(); if(!settingsProvider.isMsgNotifyAllowed(null)){ return; } // check if app running background if (!EasyUtils.isAppRunningForeground(appContext)) { EMLog.d(TAG, "app is running in backgroud"); sendNotification(messages, false); } else { sendNotification(messages, true); } vibrateAndPlayTone(messages.get(messages.size()-1)); }
@Override public void onMessageReceived(List<EMMessage> messages) { for (EMMessage message : messages) { String username = null; // group message if (message.getChatType() == ChatType.GroupChat || message.getChatType() == ChatType.ChatRoom) { username = message.getTo(); } else { // single chat message username = message.getFrom(); } // if the message is for current conversation if (username.equals(toChatUsername) || message.getTo().equals(toChatUsername) || message.conversationId().equals(toChatUsername)) { messageList.refreshSelectLast(); EaseUI.getInstance().getNotifier().vibrateAndPlayTone(message); conversation.markMessageAsRead(message.getMsgId()); } else { EaseUI.getInstance().getNotifier().onNewMsg(message); } } }
@Override public void onMessageReceived(List<EMMessage> messages) { for (EMMessage message : messages) { String username = null; // group message if (message.getChatType() == ChatType.GroupChat || message.getChatType() == ChatType.ChatRoom) { username = message.getTo(); } else { // single chat message username = message.getFrom(); } // if the message is for current conversation if (username.equals(toChatUsername) || message.getTo().equals(toChatUsername) || message.conversationId().equals(toChatUsername)) { messageList.refreshSelectLast(); EaseUI.getInstance().getNotifier().vibrateAndPlayTone(message); conversation.markMessageAsRead(message.getMsgId()); } else { EaseUI.getInstance().getNotifier().onNewMsg(message); } } }
@Override public void onStop() { super.onStop(); // unregister this event listener when this activity enters the // background EMClient.getInstance().chatManager().removeMessageListener(this); // remove activity from foreground activity list EaseUI.getInstance().popActivity(getActivity()); }
@Override public void onStop() { super.onStop(); // unregister this event listener when this activity enters the // background EMClient.getInstance().chatManager().removeMessageListener(this); // remove activity from foreground activity list EaseUI.getInstance().popActivity(getActivity()); }
@Override public void onResume() { super.onResume(); if(isMessageListInited) messageList.refresh(); EaseUI.getInstance().pushActivity(getActivity()); // register the event listener when enter the foreground EMClient.getInstance().chatManager().addMessageListener(this); if(chatType == EaseConstant.CHATTYPE_GROUP){ EaseAtMessageHelper.get().removeAtMeGroup(toChatUsername); } }
@Override public void onResume() { super.onResume(); if(isMessageListInited) messageList.refresh(); EaseUI.getInstance().pushActivity(getActivity()); // register the event listener when enter the foreground EMClient.getInstance().chatManager().addMessageListener(this); if(chatType == EaseConstant.CHATTYPE_GROUP){ EaseAtMessageHelper.get().removeAtMeGroup(toChatUsername); } }
/** * handle the new message * this function can be override * * @param message */ public synchronized void onNewMsg(EMMessage message) { if(EaseCommonUtils.isSilentMessage(message)){ return; } EaseSettingsProvider settingsProvider = EaseUI.getInstance().getSettingsProvider(); if(!settingsProvider.isMsgNotifyAllowed(message)){ return; } // check if app running background if (!EasyUtils.isAppRunningForeground(appContext)) { EMLog.d(TAG, "app is running in backgroud"); sendNotification(message, false); } else { sendNotification(message, true); } vibrateAndPlayTone(message); }
/** * handle the new message * this function can be override * * @param message */ public synchronized void onNewMsg(EMMessage message) { if(EaseCommonUtils.isSilentMessage(message)){ return; } EaseSettingsProvider settingsProvider = EaseUI.getInstance().getSettingsProvider(); if(!settingsProvider.isMsgNotifyAllowed(message)){ return; } // check if app running background if (!EasyUtils.isAppRunningForeground(appContext)) { EMLog.d(TAG, "app is running in backgroud"); sendNotification(message, false); } else { sendNotification(message, true); } vibrateAndPlayTone(message); }
EaseUI.getInstance().init(getApplicationContext(),options);