diff --git a/app/src/main/java/com/shayu/phonelive/AppContext.java b/app/src/main/java/com/shayu/phonelive/AppContext.java index dd1ba1385..c864977e4 100644 --- a/app/src/main/java/com/shayu/phonelive/AppContext.java +++ b/app/src/main/java/com/shayu/phonelive/AppContext.java @@ -28,6 +28,7 @@ import com.fm.openinstall.OpenInstall; import com.google.firebase.FirebaseApp; import com.google.firebase.analytics.FirebaseAnalytics; import com.google.firebase.crashlytics.FirebaseCrashlytics; +import com.shayu.phonelive.utils.LogUtils; import com.tencent.imsdk.v2.V2TIMGroupMemberInfo; import com.tencent.imsdk.v2.V2TIMManager; import com.tencent.imsdk.v2.V2TIMSimpleMsgListener; @@ -137,6 +138,7 @@ public class AppContext extends CommonAppContext { CrashSaveBean.getInstance().setStartTime(System.currentTimeMillis()); registerError(); registerFirebaseCrash(); + LogUtils.start(this); sInstance = this; L.setDeBug(BuildConfig.DEBUG); AppEventsLogger.activateApp(this); diff --git a/app/src/main/java/com/shayu/phonelive/utils/LogUtils.java b/app/src/main/java/com/shayu/phonelive/utils/LogUtils.java new file mode 100644 index 000000000..58da15433 --- /dev/null +++ b/app/src/main/java/com/shayu/phonelive/utils/LogUtils.java @@ -0,0 +1,61 @@ +package com.shayu.phonelive.utils; + +import android.content.Context; + +import com.yunbao.common.utils.FileUtil; +import com.yunbao.common.utils.ToastUtil; + +import java.io.BufferedReader; +import java.io.File; +import java.io.InputStreamReader; +import java.net.URLEncoder; + +public class LogUtils { + public static void start(Context context) { + new Thread(new Runnable() { + @Override + public void run() { + try { + + String[] exec = new String[]{ + "logcat", + "-c" + }; + Runtime.getRuntime().exec(exec).waitFor(); + + exec = new String[]{ + "logcat", + "-v", + "-d", + "time" + }; + + Process process = Runtime.getRuntime().exec(exec); + StringBuilder builder = new StringBuilder(); + BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()), 1024); + String line; + File saveFile = new File(context.getDir("files", Context.MODE_PRIVATE).getAbsolutePath()); + while ((line = bufferedReader.readLine()) != null) { + builder.append(line).append("\n"); + if (builder.length() > 65500) { + FileUtil.saveAddStringToFile(saveFile, builder.toString(), "logcat.log"); + builder.setLength(0); + } + } + + exec = new String[]{ + "logcat", + "-c" + }; + Runtime.getRuntime().exec(exec).waitFor(); + bufferedReader.close(); + start(context); + } catch (Exception e) { + e.printStackTrace(); + ToastUtil.show(""); + } + } + }).start(); + + } +} diff --git a/common/src/main/java/com/yunbao/common/utils/FileUtil.java b/common/src/main/java/com/yunbao/common/utils/FileUtil.java index 6563406fc..481333a3a 100644 --- a/common/src/main/java/com/yunbao/common/utils/FileUtil.java +++ b/common/src/main/java/com/yunbao/common/utils/FileUtil.java @@ -33,6 +33,24 @@ public class FileUtil { } } } + /** + * 把字符串追加保存成文件 + */ + public static void saveAddStringToFile(File dir, String content, String fileName) { + PrintWriter writer = null; + try { + FileOutputStream os = new FileOutputStream(new File(dir, fileName)); + writer = new PrintWriter(os); + writer.append(content); + writer.flush(); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } finally { + if (writer != null) { + writer.close(); + } + } + } /** * 从文件读取字符串 diff --git a/config.gradle b/config.gradle index 70ee56319..8affa5db3 100644 --- a/config.gradle +++ b/config.gradle @@ -10,9 +10,9 @@ ext { manifestPlaceholders = [ //正式 -// serverHost : "https://napi.yaoulive.com", + serverHost : "https://napi.yaoulive.com", //測試 - serverHost : "https://ceshi.yaoulive.com", +// serverHost : "https://ceshi.yaoulive.com", //腾讯地图 txMapAppKey : "EOZBZ-ASLCU-4XPV3-BDCHZ-4E3Q7-H4BWB", @@ -25,7 +25,7 @@ ext { baiduAppSecretKey: "nEVSgmuGpU0pjPr6VleEGGAl0hzGW52S", // true表示谷歌支付 false - isGooglePlay : true, + isGooglePlay : false, //是否上报异常日志 isUploadLog : false ] diff --git a/live/src/main/java/com/yunbao/live/activity/LiveRyAnchorActivity.java b/live/src/main/java/com/yunbao/live/activity/LiveRyAnchorActivity.java index 54b17425b..c51d7a906 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveRyAnchorActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveRyAnchorActivity.java @@ -386,6 +386,9 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl * 主播展示离开直播间 */ private void leaveLive() { + if (PKing || isDRPK == 1) { + return; + } RCRTCRect rect = new RCRTCRect(0f, 0f, 1.0f); if (leave == 0) { leave = 1; @@ -1293,6 +1296,11 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl fragment4Audience.show(((LiveRyAnchorActivity) mContext).getSupportFragmentManager(), "LiveWishListDialogFragment4Audience"); } break; + case UN_LEAVELIVE: + if (leave == 1) { + leaveLive(); + } + break; } } } diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveLinkMicListDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/LiveLinkMicListDialogFragment.java index ae9d5d08e..faefa9ffb 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveLinkMicListDialogFragment.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveLinkMicListDialogFragment.java @@ -25,6 +25,7 @@ import com.yunbao.common.custom.CommonRefreshView; import com.yunbao.common.dialog.AbsDialogFragment; import com.yunbao.common.http.HttpCallback; import com.yunbao.common.interfaces.OnItemClickListener; +import com.yunbao.common.utils.Bus; import com.yunbao.common.utils.DpUtil; import com.yunbao.common.utils.ToastUtil; import com.yunbao.live.R; @@ -32,6 +33,7 @@ import com.yunbao.live.activity.LiveAnchorActivity; import com.yunbao.live.activity.LiveRyAnchorActivity; import com.yunbao.live.adapter.LivePkAdapter; import com.yunbao.live.bean.LivePkBean; +import com.yunbao.live.event.LiveAudienceEvent; import com.yunbao.live.http.LiveHttpConsts; import com.yunbao.live.http.LiveHttpUtil; @@ -345,7 +347,8 @@ public class LiveLinkMicListDialogFragment extends AbsDialogFragment implements Bundle bundle = getArguments(); if(bundle!=null){ - + Bus.get().post(new LiveAudienceEvent() + .setType(LiveAudienceEvent.LiveAudienceType.UN_LEAVELIVE)); if(bundle.getBoolean("isDRPK", false) == true) { // ToastUtil.show("多人"); 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 ae8558f29..7177d2ddd 100644 --- a/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java +++ b/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java @@ -173,7 +173,8 @@ public class LiveAudienceEvent extends BaseModel { VOICE_PRESS(30, "长按展示图片"), LUCKY_ANGEL(31, "幸运天使"), WE_CHEAT(32, "整蛊"), - WISH_LIST_UPDATE(33, "心愿单更新推送") + WISH_LIST_UPDATE(33, "心愿单更新推送"), + UN_LEAVELIVE(34, "取消暂时离开") ; private int type; diff --git a/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java b/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java index 44c00f5a0..35ba07be9 100644 --- a/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java +++ b/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java @@ -980,7 +980,7 @@ public class SocketRyClient { */ private static void processAnchorLinkMicPk(JSONObject map) { int action = map.getIntValue("action"); - Log.e("action", action + ""); + Log.i("Socket", "action = "+action+" json = "+map.toString()); switch (action) { case 1://收到对方主播PK回调 diff --git a/main/src/main/java/com/yunbao/main/activity/GoogleFragment.java b/main/src/main/java/com/yunbao/main/activity/GoogleFragment.java index 9dc2964b0..1bc82cd25 100644 --- a/main/src/main/java/com/yunbao/main/activity/GoogleFragment.java +++ b/main/src/main/java/com/yunbao/main/activity/GoogleFragment.java @@ -89,6 +89,10 @@ public class GoogleFragment extends Fragment { webSettings.setJavaScriptEnabled(true); // 是否开启JS支持 webSettings.setJavaScriptCanOpenWindowsAutomatically(true); // 是否允许JS打开新窗口 + webSettings.setLoadWithOverviewMode(true); // 缩放至屏幕大小 + webSettings.setSupportZoom(true); // 是否支持缩放 + webSettings.setBuiltInZoomControls(true); // 是否支持缩放变焦,前提是支持缩放 + rlWebview.addJavascriptInterface(new JsInteration(), "androidObject");