diff --git a/common/build.gradle b/common/build.gradle index 07e4653ee..2cd214fe1 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -189,4 +189,7 @@ dependencies { implementation 'com.github.tajchert:WaitingDots:0.6.1' //悬浮窗 api 'com.github.princekin-f:EasyFloat:2.0.4' + + +// api project(path: ':recognizer') } diff --git a/common/src/main/java/com/yunbao/common/manager/imrongcloud/RongcloudIMManager.java b/common/src/main/java/com/yunbao/common/manager/imrongcloud/RongcloudIMManager.java index d57e68412..3c5676c41 100644 --- a/common/src/main/java/com/yunbao/common/manager/imrongcloud/RongcloudIMManager.java +++ b/common/src/main/java/com/yunbao/common/manager/imrongcloud/RongcloudIMManager.java @@ -1,5 +1,7 @@ package com.yunbao.common.manager.imrongcloud; +import static com.yunbao.common.CommonAppContext.isReady; + import android.app.Application; import android.content.Context; import android.util.Log; @@ -17,8 +19,6 @@ import com.yunbao.common.manager.IMLoginManager; import org.greenrobot.eventbus.EventBus; -import java.util.ArrayList; - import io.rong.imkit.GlideKitImageEngine; import io.rong.imkit.IMCenter; import io.rong.imkit.RongIM; @@ -26,9 +26,7 @@ import io.rong.imkit.config.RongConfigCenter; import io.rong.imlib.RongIMClient; import io.rong.imlib.model.Conversation; import io.rong.imlib.model.Message; -import io.rong.imlib.model.MessageContent; - -import static com.yunbao.common.CommonAppContext.isReady; +import io.rong.recognizer.Recognizer; /** * 会话列表 @@ -38,13 +36,14 @@ public class RongcloudIMManager { //融云开发者平台注册app唯一识别符 // public static final String RONG_IM_KEY = "uwd1c0sxu1p71"; //测试环境 - public static String RONG_IM_KEY = "pvxdm17jpd3hr"; + public static String RONG_IM_KEY = "pvxdm17jpd3hr"; private static final String CLASSNAME = "RongcloudIMManager"; + static {//自动切换key - if(CommonAppConfig.HOST.contains("ceshi")){ + if (CommonAppConfig.HOST.contains("ceshi")) { RONG_IM_KEY = "pvxdm17jpd3hr"; //测试服key - }else{ + } else { RONG_IM_KEY = "uwd1c0sxu1p71"; //正式服key } } @@ -61,13 +60,13 @@ public class RongcloudIMManager { Log.e(CLASSNAME, "initRongIM:"); initPhotoGlide(); - + //初始化科大讯飞语音转文字 + Recognizer.setAppId("af2efca9"); } private static RongIMClient.OnReceiveMessageWrapperListener mListener; /** - * * 设置消息接受监听器 */ public static void addRongcloudIMOnReceiveMessageListener(RongIMClient.OnReceiveMessageWrapperListener listener) { diff --git a/common/src/main/res/layout/view_live_total.xml b/common/src/main/res/layout/view_live_total.xml index 5ffcfb799..2fc96c2c4 100644 --- a/common/src/main/res/layout/view_live_total.xml +++ b/common/src/main/res/layout/view_live_total.xml @@ -266,6 +266,27 @@ android:textColor="#FF9A9A9A" android:textSize="12sp" /> + + + + + + %s星挑战 恭喜 %s,完成了%s %s星 挑戰,快去一睹主播芳容吧! + 小窗播放設置 + 小窗播放 + APP內小窗播放 + 讓直播間內容在本APP主頁面中小窗播放 + APP全應用小窗播放 + 讓直播間內容在所有APP及頁面中小窗播放 diff --git a/live/src/main/AndroidManifest.xml b/live/src/main/AndroidManifest.xml index e04abfdfa..ebe6a3ed9 100644 --- a/live/src/main/AndroidManifest.xml +++ b/live/src/main/AndroidManifest.xml @@ -16,6 +16,7 @@ android:name=".activity.LiveAudienceActivity" android:screenOrientation="portrait" android:theme="@style/AppTheme" + android:launchMode="singleTask" android:windowSoftInputMode="adjustPan|stateAlwaysHidden" /> { + Bus.get().post(new LiveAudienceEvent() + .setType(LiveAudienceEvent.LiveAudienceType.FLOAT_SETTING)); + dismiss(); + } + ); } @Override diff --git a/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java b/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java index 55d09883e..6ba536c79 100644 --- a/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java +++ b/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java @@ -4,8 +4,8 @@ import com.yunbao.common.bean.ActiveModel; import com.yunbao.common.bean.AiAutomaticSpeechModel; import com.yunbao.common.bean.AnchorRecommendItemModel; import com.yunbao.common.bean.BaseModel; -import com.yunbao.common.bean.MsgModel; import com.yunbao.common.bean.LiveBean; +import com.yunbao.common.bean.MsgModel; import com.yunbao.live.bean.OpenParametersModel; public class LiveAudienceEvent extends BaseModel { @@ -148,7 +148,8 @@ public class LiveAudienceEvent extends BaseModel { START_MESSAGE(25, "星级消息"), AI_AUTOMATIC_SPEECH(26, "机器人助手"), STAR_CHALLENGE_UPGRADE_NOTIFY(27, "星级挑战成功"), - MESSAGE_BOTTOM(28, "聊天消息滚动到底部"); + MESSAGE_BOTTOM(28, "聊天消息滚动到底部"), + FLOAT_SETTING(29, "悬浮窗设置"); private int type; private String name; diff --git a/live/src/main/java/com/yunbao/live/views/LiveFloatView.java b/live/src/main/java/com/yunbao/live/views/LiveFloatView.java deleted file mode 100644 index 3f4117eaa..000000000 --- a/live/src/main/java/com/yunbao/live/views/LiveFloatView.java +++ /dev/null @@ -1,148 +0,0 @@ -package com.yunbao.live.views; - -import android.app.Activity; -import android.text.TextUtils; -import android.util.Log; -import android.view.Gravity; -import android.view.View; - -import com.lzf.easyfloat.EasyFloat; -import com.lzf.easyfloat.enums.ShowPattern; -import com.lzf.easyfloat.interfaces.FloatCallbacks; -import com.lzf.easyfloat.interfaces.OnInvokeView; -import com.tencent.live2.V2TXLivePlayer; -import com.tencent.live2.impl.V2TXLivePlayerImpl; -import com.tencent.rtmp.ui.TXCloudVideoView; -import com.yunbao.common.bean.LiveBean; -import com.yunbao.common.utils.RouteUtil; -import com.yunbao.common.views.weight.ViewClicksAntiShake; -import com.yunbao.live.R; - -import kotlin.Unit; -import kotlin.jvm.functions.Function0; -import kotlin.jvm.functions.Function1; - -/** - * 直播间悬浮窗管理 - */ -public class LiveFloatView implements Function1 { - - private static LiveFloatView instance; - private LiveOnInvokeView liveOnInvokeView = null; - private Activity mContext; - private String url; - private LiveBean mLiveBean; - private int mLiveType; - private int mLiveSDK; - private int mLiveTypeVal; - private FloatCallbacks.Builder builder; - private String TAG = "LiveFloatView"; - private V2TXLivePlayer mPlayer; - - public static LiveFloatView getInstance() { - if (instance == null) { - instance = new LiveFloatView(); - } - - return instance; - } - - public void builderFloat(Activity mContext, String url) { - liveOnInvokeView = new LiveOnInvokeView(); - this.mContext = mContext; - this.url = url; - EasyFloat.with(mContext) - .setTag(TAG) - .setLayout(R.layout.view_flaot_live, liveOnInvokeView) - .setShowPattern(ShowPattern.CURRENT_ACTIVITY) - .setGravity(Gravity.END | Gravity.CENTER_VERTICAL, 0, 200) - .registerCallback(this) - .show(); - } - - public void builderSystemFloat(Activity mContext, String url) { - liveOnInvokeView = new LiveOnInvokeView(); - this.mContext = mContext; - this.url = url; - EasyFloat.with(mContext) - .setTag(TAG) - .setLayout(R.layout.view_flaot_live, liveOnInvokeView) - .setShowPattern(ShowPattern.ALL_TIME) - .setGravity(Gravity.END | Gravity.CENTER_VERTICAL, 0, 200) - .registerCallback(this) - .show(); - } - - public LiveFloatView cacheLiveData(LiveBean mLiveBean, int mLiveType, int mLiveSDK, int mLiveTypeVal) { - this.mLiveBean = mLiveBean; - this.mLiveType = mLiveType; - this.mLiveSDK = mLiveSDK; - this.mLiveTypeVal = mLiveTypeVal; - return instance; - } - - @Override - public Unit invoke(FloatCallbacks.Builder builder) { - this.builder = builder; - builder.createResult((aBoolean, s, view) -> { - Log.e("LiveFloatView", "aBoolean:" + aBoolean + "---------------------s:" + s); - if (callback != null) { - callback.invoke(aBoolean); - } - builder.dismiss(() -> { - if (mPlayer != null && mPlayer.isPlaying() == 1) { - mPlayer.stopPlay(); - } - return null; - }); - builder.hide(view12 -> { - if (mPlayer != null && mPlayer.isPlaying() == 1) { - mPlayer.pauseAudio(); - mPlayer.pauseVideo(); - } - return null; - }); - - return null; - }); - return null; - } - - /** - * 悬浮窗布局管理 - */ - private class LiveOnInvokeView implements OnInvokeView { - - @Override - public void invoke(View view) { - TXCloudVideoView videoView = view.findViewById(R.id.video_view); - mPlayer = new V2TXLivePlayerImpl(mContext); - mPlayer.setRenderView(videoView); - mPlayer.startPlay(url); - ViewClicksAntiShake.clicksAntiShake(view.findViewById(R.id.btn_close), new ViewClicksAntiShake.ViewClicksCallBack() { - @Override - public void onViewClicks() { - mPlayer.stopPlay(); - EasyFloat.dismiss("LiveFloatView", true); - } - }); - ViewClicksAntiShake.clicksAntiShake(videoView, () -> { - mPlayer.stopPlay(); - RouteUtil.forwardLiveAudienceActivity(mLiveBean, mLiveType, mLiveSDK, mLiveTypeVal); - }); - } - } - - private LiveFloatViewCallback callback; - - public LiveFloatView setCallback(LiveFloatViewCallback callback) { - this.callback = callback; - return this; - } - - public interface LiveFloatViewCallback { - void invoke(Boolean aBoolean); - - } - -} diff --git a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java index ce308eed3..3cccdcb31 100644 --- a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java +++ b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java @@ -30,6 +30,7 @@ import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.blankj.utilcode.util.GsonUtils; import com.facebook.appevents.AppEventsLogger; +import com.lzf.easyfloat.EasyFloat; import com.lzf.easyfloat.permission.PermissionUtils; import com.tencent.imsdk.v2.V2TIMCallback; import com.tencent.imsdk.v2.V2TIMManager; @@ -57,6 +58,7 @@ import com.yunbao.common.utils.RouteUtil; import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.WordUtil; import com.yunbao.common.utils.formatBigNum; +import com.yunbao.common.views.weight.LiveFloatView; import com.yunbao.live.R; import com.yunbao.live.activity.LiveActivity; import com.yunbao.live.activity.LiveAudienceActivity; @@ -175,6 +177,13 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe private OpenParametersModel openParametersModel = null; //星级活动地址 private String activityUrl = ""; + //标记是调用正常退出还是手动切后台 + private boolean isQuitF = false; + + public PortraitLiveManager setQuitF(boolean quitF) { + isQuitF = quitF; + return this; + } public PortraitLiveManager(Activity context, Intent intent) { this.mContext = context; @@ -348,70 +357,23 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe mLiveRyLinkMicPkPresenter.release(); } if (isQuit) { - + isQuitF = true; if (PermissionUtils.checkPermission(mContext)) { LiveFloatView.getInstance() .cacheLiveData(mLiveBean, mLiveType, mLiveSDK, mLiveTypeVal) .builderSystemFloat(mContext, mLiveBean.getPull()); mContext.finish(); } else { - if (mContext instanceof LiveAudienceActivity) { - if (IMLoginManager.get(mContext).isFloat()) { - DialogUitl.showSimpleDialog(mContext, null, "您未打开悬浮窗权限,是否打开", false, new DialogUitl.SimpleCallback3() { - @Override - public void onConfirmClick(Dialog dialog) { - LiveFloatView.getInstance() - .setCallback(new LiveFloatView.LiveFloatViewCallback() { - @Override - public void invoke(Boolean aBoolean) { - if (aBoolean) { - mContext.finish(); - } else { - EventBus.getDefault() - .post(new LiveFloatEvent() - .setmLiveBean(mLiveBean) - .setmLiveSDK(mLiveSDK) - .setmLiveType(mLiveType) - .setmLiveTypeVal(mLiveTypeVal)); - mContext.finish(); - IMLoginManager.get(mContext).initFloat(true); - } - } - }) - .cacheLiveData(mLiveBean, mLiveType, mLiveSDK, mLiveTypeVal) - .builderSystemFloat(mContext, mLiveBean.getPull()); - - } - - @Override - public void onCancel() { - EventBus.getDefault() - .post(new LiveFloatEvent() - .setmLiveBean(mLiveBean) - .setmLiveSDK(mLiveSDK) - .setmLiveType(mLiveType) - .setmLiveTypeVal(mLiveTypeVal)); - mContext.finish(); - IMLoginManager.get(mContext).initFloat(false); - } - }); - } else { - EventBus.getDefault() - .post(new LiveFloatEvent() - .setmLiveBean(mLiveBean) - .setmLiveSDK(mLiveSDK) - .setmLiveType(mLiveType) - .setmLiveTypeVal(mLiveTypeVal)); - mContext.finish(); - } - + if (IMLoginManager.get(mContext).isFloat()) { + EventBus.getDefault() + .post(new LiveFloatEvent() + .setmLiveBean(mLiveBean) + .setmLiveSDK(mLiveSDK) + .setmLiveType(mLiveType) + .setmLiveTypeVal(mLiveTypeVal)); } -// PermissionUtils.requestPermission(mContext, new OnPermissionResult() { -// @Override -// public void permissionResult(boolean b) { -// ToastUtil.show("悬浮窗权限:"+b); -// } -// }); + + mContext.finish(); } } } @@ -430,12 +392,23 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe public void onResume() { // if (mLivePlayViewHolder != null) // mLivePlayViewHolder.onResume(); + //判断是否有直播悬浮窗,有直接关闭 + if (EasyFloat.isShow("LiveFloatView")) { + EasyFloat.dismiss("LiveFloatView", true); + } } @Override public void onPause() { // if (mLivePlayViewHolder != null) // mLivePlayViewHolder.onPause(); + if (mLiveBean != null && !isQuitF) { + LiveFloatView.getInstance() + .cacheLiveData(mLiveBean, mLiveType, mLiveSDK, mLiveTypeVal) + .builderSystemFloat(mContext, mLiveBean.getPull()); + mContext.finish(); + } + isQuitF = false; } @Override @@ -1033,7 +1006,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe @Override public void onHourRank(LiveChatBean bean, JSONObject ranks) { - if (mLiveRoomViewHolder != null) { + if (mLiveRoomViewHolder != null && !TextUtils.isEmpty(liveID)) { mLiveRoomViewHolder.setHourRankData(ranks.getInteger(liveID)); } } diff --git a/live/src/main/res/layout/view_flaot_live.xml b/live/src/main/res/layout/view_flaot_live.xml deleted file mode 100644 index e97d21e66..000000000 --- a/live/src/main/res/layout/view_flaot_live.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/main/src/main/java/com/yunbao/main/activity/MainActivity.java b/main/src/main/java/com/yunbao/main/activity/MainActivity.java index 8820d83af..8fce183c4 100644 --- a/main/src/main/java/com/yunbao/main/activity/MainActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/MainActivity.java @@ -91,7 +91,7 @@ import com.yunbao.live.http.LiveHttpUtil; import com.yunbao.live.presenter.LiveRoomCheckLivePresenter; import com.yunbao.live.utils.LiveStorge; import com.yunbao.live.views.ChatListViewHolder; -import com.yunbao.live.views.LiveFloatView; +import com.yunbao.common.views.weight.LiveFloatView; import com.yunbao.main.R; import com.yunbao.main.dialog.MainStartDialogFragment; import com.yunbao.main.dialog.ReturnUserDialog; diff --git a/main/src/main/java/com/yunbao/main/activity/PDLiveConversationListActivity.java b/main/src/main/java/com/yunbao/main/activity/PDLiveConversationListActivity.java index 1209c17a2..80efdcf6e 100644 --- a/main/src/main/java/com/yunbao/main/activity/PDLiveConversationListActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/PDLiveConversationListActivity.java @@ -36,9 +36,7 @@ import com.opensource.svgaplayer.SVGAVideoEntity; import com.yunbao.common.activity.AbsActivity; import com.yunbao.common.activity.WebViewActivity; import com.yunbao.common.bean.ImUserInfoModel; -import com.yunbao.common.bean.LiveBean; import com.yunbao.common.custom.TabButtonGroup; -import com.yunbao.common.event.LiveFloatEvent; import com.yunbao.common.event.MessageIMEvent; import com.yunbao.common.event.UpdateTablePointMe; import com.yunbao.common.glide.ImgLoader; @@ -50,18 +48,12 @@ import com.yunbao.common.manager.imrongcloud.MessageIMManager; import com.yunbao.common.utils.DeviceUtils; import com.yunbao.common.utils.DialogUitl; import com.yunbao.common.utils.ProcessResultUtil; -import com.yunbao.common.utils.RouteUtil; import com.yunbao.common.utils.SVGAViewUtils; import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.views.weight.ViewClicksAntiShake; -import com.yunbao.live.activity.LiveAudienceActivity; import com.yunbao.live.activity.SystemMessageActivity; import com.yunbao.live.bean.ImUserBean; -import com.yunbao.live.event.RecommendLiveRoomEvent; import com.yunbao.live.http.ImHttpUtil; -import com.yunbao.live.http.LiveHttpUtil; -import com.yunbao.live.presenter.LiveRoomCheckLivePresenter; -import com.yunbao.live.views.LiveFloatView; import com.yunbao.main.R; import com.yunbao.main.adapter.SystemMessageAdapter; import com.yunbao.main.dialog.MainStartDialogFragment; diff --git a/settings.gradle b/settings.gradle index 0685aa851..2cf55500d 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,2 +1,3 @@ -include ':app', ':video', ':common', ':main', ':baidu', ':live', ':lib_country_code' +include ':app', ':video', ':common', ':main', ':live', ':lib_country_code' //include ':FaceUnity' +//include ':recognizer'//融云语音转文字模块