From 6f7e5b123a4668c79462fe65317a630fd102c136 Mon Sep 17 00:00:00 2001 From: zlzw <583819556@qq.com> Date: Wed, 10 Jul 2024 09:41:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8C=E6=AD=A5PD=EF=BC=9A=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../utils/net/StickerDownloadHelper.java | 2 +- app/build.gradle | 74 ++++---- .../java/com/shayu/phonelive/AppContext.java | 4 +- app/tmp/full-r8-config.txt | 72 ++++---- common/build.gradle | 2 + .../yunbao/common/activity/AbsActivity.java | 4 +- .../common/activity/WebViewActivity.java | 11 ++ .../java/com/yunbao/common/bean/QiniuLog.java | 16 ++ .../yunbao/common/http/CommonHttpUtil.java | 16 ++ .../com/yunbao/common/http/HttpCallback.java | 1 - .../common/http/HttpLoggingInterceptor.java | 18 +- .../com/yunbao/common/http/PDLiveApi.java | 5 + .../common/http/live/LiveNetManager.java | 28 ++- .../com/yunbao/common/upload/UploadBean.java | 1 + .../yunbao/common/upload/UploadQnImpl.java | 32 +++- .../main/java/com/yunbao/common/utils/L.java | 17 ++ .../java/com/yunbao/common/utils/LogUtil.java | 165 +++++++++--------- .../com/yunbao/common}/utils/LogUtils.java | 55 +++++- .../utils/MessageSayHiNotifyManager.java | 13 +- .../com/yunbao/common}/utils/ZipUtils.java | 49 ++++-- .../src/main/res/layout/activity_webview.xml | 3 +- config.gradle | 2 +- .../beautyapi/faceunity/agora/SWManager.java | 2 +- live/build.gradle | 2 +- .../yunbao/main/activity/MainActivity.java | 17 ++ .../main/activity/ZhuangBanActivity.java | 8 + .../yunbao/main/adapter/SettingAdapter.java | 2 +- 27 files changed, 428 insertions(+), 193 deletions(-) create mode 100644 common/src/main/java/com/yunbao/common/bean/QiniuLog.java rename {app/src/main/java/com/shayu/phonelive => common/src/main/java/com/yunbao/common}/utils/LogUtils.java (61%) rename {FaceUnity/src/main/java/com/yunbao/faceunity => common/src/main/java/com/yunbao/common}/utils/ZipUtils.java (86%) diff --git a/FaceUnity/src/main/java/com/yunbao/faceunity/utils/net/StickerDownloadHelper.java b/FaceUnity/src/main/java/com/yunbao/faceunity/utils/net/StickerDownloadHelper.java index 393cf0dc3..ec95d8f25 100644 --- a/FaceUnity/src/main/java/com/yunbao/faceunity/utils/net/StickerDownloadHelper.java +++ b/FaceUnity/src/main/java/com/yunbao/faceunity/utils/net/StickerDownloadHelper.java @@ -13,7 +13,7 @@ import com.google.gson.JsonObject; import com.yunbao.faceunity.entity.net.FineStickerEntity; import com.yunbao.faceunity.utils.FaceUnityData; import com.yunbao.faceunity.utils.FileUtils; -import com.yunbao.faceunity.utils.ZipUtils; +import com.yunbao.common.utils.ZipUtils; import java.io.File; import java.util.ArrayList; diff --git a/app/build.gradle b/app/build.gradle index 4325afa2e..fec68ed31 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -6,9 +6,6 @@ apply plugin: 'com.alibaba.arouter' apply from: "../package_config.gradle" android { namespace "com.pandoralive.shayu" - dexOptions { - jumboMode = true - } /* applicationVariants.all { variant -> variant.mergeAssetsProvider.configure { doLast { @@ -114,10 +111,11 @@ android { println "清空build文件夹"; for (final def project in rootProject.getAllprojects()) { def name = variant.name.replace('Debug', '').replace('Release', '').toLowerCase() - delete project.buildDir - delete 'app' + File.separator + name - println project.buildDir + //delete project.buildDir + delete project.rootDir.absolutePath+File.separator+"app"+File.separator+name + //println project.buildDir } + //delete project.rootDir.absolutePath + File.separator + "outputs" String variantName = variant.name.capitalize() def processManifestTask = project.tasks.getByName("process${variantName}Manifest") processManifestTask.doLast { pm -> @@ -183,29 +181,38 @@ android { } } } - variant.outputs.all { vt -> - println("输出文件名:${vt}") + variant.assemble.doLast { vt -> def channel = '' - def server='' - if (variant.name.startsWith('huawei')) { + def server = '' + if (variant.name.contains('huawei')) { channel = "华为" - } else if (variant.name.startsWith('samsung')) { + } else if (variant.name.contains('samsung')) { channel = "三星" - } else if (variant.name.startsWith('google')) { + } else if (variant.name.contains('google')) { channel = "谷歌" } else { channel = "链接" } - if(variant.name.contains('online')){ - server='正式服' - }else{ - server='测试服' + if (variant.name.contains('online')) { + server = '正式服' + } else { + server = '测试服' + } + def fileName = "[${new Date().format("yyyy-MM-dd HHmmss", TimeZone.getTimeZone("GMT+8"))}]潘多拉-${defaultConfig.versionName}-${defaultConfig.versionCode}-${channel}-${server}-${variant.buildType.name}.apk" + variant.outputs.forEach { fe -> + copy { + from fe.outputFile + into file("${project.rootDir}\\outputs\\apk\\") + rename { fn -> + fileName + } + } } - outputFileName = "[${new Date().format("yyyy-MM-dd HHmmss", TimeZone.getTimeZone("GMT+8"))}]潘多拉-${defaultConfig.versionName}-${channel}-${server}-${variant.buildType.name}.apk" } tasks.named("sign${variant.name.capitalize()}Bundle", com.android.build.gradle.internal.tasks.FinalizeBundleTask) { File file = finalBundleFile.asFile.get() def channel = '' + def server = '' if (variant.name.startsWith('huawei')) { channel = "华为" } else if (variant.name.startsWith('samsung')) { @@ -215,7 +222,13 @@ android { } else { channel = "链接" } - File finalFile = new File(file.parentFile, "[${new Date().format("yyyy-MM-dd HHmmss", TimeZone.getTimeZone("GMT+8"))}]潘多拉-${defaultConfig.versionName}-${channel}-${variant.buildType.name}.aab") + if (variant.name.contains('online')) { + server = '正式服' + } else { + server = '测试服' + } + def fileName = "[${new Date().format("yyyy-MM-dd HHmmss", TimeZone.getTimeZone("GMT+8"))}]潘多拉-${defaultConfig.versionName}-${defaultConfig.versionCode}-${channel}-${server}-${variant.buildType.name}.aab" + File finalFile = new File("${project.rootDir}\\outputs\\aab", fileName) finalBundleFile.set(finalFile) } project.afterEvaluate { project -> @@ -294,13 +307,16 @@ android { multiDexEnabled true ndk { // TODO: 谷歌商城需要兼容两个平台 - println("打包版本:${rootProject.ext.manifestPlaceholders.isGooglePlay}") - if (rootProject.ext.manifestPlaceholders.isGooglePlay == 0) { + Gradle gradle = getGradle() + String tskReqStr = gradle.getStartParameter().getTaskRequests().args.toString() + println("处理ndk 版本 = " + tskReqStr) + def isLink = tskReqStr.contains("Link") + if (isLink) { abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64" - println("链接包") + println("打包ndk 链接") } else { abiFilters "armeabi-v7a", "arm64-v8a" - println("谷歌包") + println("打包ndk其他") } } @@ -357,17 +373,3 @@ dependencies { } -// 链接包需要注释掉 否正无法更新 谷歌包需要打开 -/* -project.afterEvaluate { - android.applicationVariants.all { variant -> - variant.outputs.each { output -> - output.processResources.doFirst { pm-> - String manifestPath = output.processResources.manifestFile; - def manifestContent = file(manifestPath).getText() - manifestContent = manifestContent.replace('android.permission.REQUEST_INSTALL_PACKAGES', '') - file(manifestPath).write(manifestContent) - } - } - } -}*/ diff --git a/app/src/main/java/com/shayu/phonelive/AppContext.java b/app/src/main/java/com/shayu/phonelive/AppContext.java index 48eb61e90..2beb5a4b8 100644 --- a/app/src/main/java/com/shayu/phonelive/AppContext.java +++ b/app/src/main/java/com/shayu/phonelive/AppContext.java @@ -27,7 +27,7 @@ import com.facebook.appevents.AppEventsLogger; import com.fm.openinstall.OpenInstall; import com.google.gson.Gson; import com.pandoralive.shayu.R; -import com.shayu.phonelive.utils.LogUtils; +import com.yunbao.common.utils.LogUtils; import com.tencent.imsdk.v2.V2TIMGroupMemberInfo; import com.yunbao.common.http.Data; import com.tencent.imsdk.v2.V2TIMManager; @@ -60,6 +60,7 @@ import com.yunbao.common.utils.MessageChatNotifyManager; import com.yunbao.common.utils.MessageSayHiNotifyManager; import com.yunbao.common.utils.SoundUtils; import com.yunbao.common.utils.SpUtil; +import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.WordUtil; import com.yunbao.live.activity.LiveActivity; import com.yunbao.live.activity.SudRyGameActivity; @@ -153,6 +154,7 @@ public class AppContext extends CommonAppContext { } if (activity instanceof LoginActivity) { MessageSayHiNotifyManager.getInstance().stop(); + MessageSayHiNotifyManager.getInstance().clear(); return; } if (activity instanceof EntryActivity) { diff --git a/app/tmp/full-r8-config.txt b/app/tmp/full-r8-config.txt index 0f89f7fb3..d909c7e74 100644 --- a/app/tmp/full-r8-config.txt +++ b/app/tmp/full-r8-config.txt @@ -416,7 +416,7 @@ rx.internal.util.atomic.LinkedQueueNode* consumerNode; -ignorewarnings # End of content from C:\Users\58381\Documents\AndroidProject\pandorapan\app\proguard-rules.pro -# The proguard configuration file for the following section is C:\Users\58381\Documents\AndroidProject\pandorapan\app\build\intermediates\aapt_proguard_file\link_testRelease\processLink_testReleaseResources\aapt_rules.txt +# The proguard configuration file for the following section is C:\Users\58381\Documents\AndroidProject\pandorapan\app\build\intermediates\aapt_proguard_file\link_onlineRelease\processLink_onlineReleaseResources\aapt_rules.txt -keep class androidx.core.app.CoreComponentFactory { (); } -keep class androidx.core.content.FileProvider { (); } -keep class androidx.core.content.FileProvider4Utils { (); } @@ -1090,10 +1090,10 @@ rx.internal.util.atomic.LinkedQueueNode* consumerNode; -keepclassmembers class * { *** videoEditClick(android.view.View); } -# End of content from C:\Users\58381\Documents\AndroidProject\pandorapan\app\build\intermediates\aapt_proguard_file\link_testRelease\processLink_testReleaseResources\aapt_rules.txt -# The proguard configuration file for the following section is C:\Users\58381\Documents\AndroidProject\pandorapan\lib_faceunity\build\intermediates\consumer_proguard_dir\link_testRelease\exportLink_testReleaseConsumerProguardFiles\lib0\proguard.txt +# End of content from C:\Users\58381\Documents\AndroidProject\pandorapan\app\build\intermediates\aapt_proguard_file\link_onlineRelease\processLink_onlineReleaseResources\aapt_rules.txt +# The proguard configuration file for the following section is C:\Users\58381\Documents\AndroidProject\pandorapan\lib_faceunity\build\intermediates\consumer_proguard_dir\link_onlineRelease\exportLink_onlineReleaseConsumerProguardFiles\lib0\proguard.txt -# End of content from C:\Users\58381\Documents\AndroidProject\pandorapan\lib_faceunity\build\intermediates\consumer_proguard_dir\link_testRelease\exportLink_testReleaseConsumerProguardFiles\lib0\proguard.txt +# End of content from C:\Users\58381\Documents\AndroidProject\pandorapan\lib_faceunity\build\intermediates\consumer_proguard_dir\link_onlineRelease\exportLink_onlineReleaseConsumerProguardFiles\lib0\proguard.txt # The proguard configuration file for the following section is C:\gradle-6.1.1\caches\transforms-3\8d3e3177c15403546de73d87508067d6\transformed\jetified-XPopup-2.10.0\proguard.txt # Generated keep rule for Lifecycle observer adapter. -if class com.lxj.xpopup.core.BasePopupView { @@ -1153,9 +1153,9 @@ rx.internal.util.atomic.LinkedQueueNode* consumerNode; # End of content from C:\gradle-6.1.1\caches\transforms-3\a1df9a6aa192455030f7c9970b70e0e9\transformed\material-1.4.0\proguard.txt -# The proguard configuration file for the following section is C:\Users\58381\Documents\AndroidProject\pandorapan\lib_google\build\intermediates\consumer_proguard_dir\link_testRelease\exportLink_testReleaseConsumerProguardFiles\lib0\proguard.txt +# The proguard configuration file for the following section is C:\Users\58381\Documents\AndroidProject\pandorapan\lib_google\build\intermediates\consumer_proguard_dir\link_onlineRelease\exportLink_onlineReleaseConsumerProguardFiles\lib0\proguard.txt -# End of content from C:\Users\58381\Documents\AndroidProject\pandorapan\lib_google\build\intermediates\consumer_proguard_dir\link_testRelease\exportLink_testReleaseConsumerProguardFiles\lib0\proguard.txt +# End of content from C:\Users\58381\Documents\AndroidProject\pandorapan\lib_google\build\intermediates\consumer_proguard_dir\link_onlineRelease\exportLink_onlineReleaseConsumerProguardFiles\lib0\proguard.txt # The proguard configuration file for the following section is C:\gradle-6.1.1\caches\transforms-3\2929985d9627ba3bb45a0ebd18eaf9d3\transformed\jetified-linesdk-5.0.1\proguard.txt -keepattributes *Annotation* @@ -1506,36 +1506,6 @@ rx.internal.util.atomic.LinkedQueueNode* consumerNode; public boolean isLayoutSuppressed(); } # End of content from C:\gradle-6.1.1\caches\transforms-3\e9de7db2640f13ae2ab2a585dfd19337\transformed\recyclerview-1.2.1\proguard.txt -# The proguard configuration file for the following section is C:\gradle-6.1.1\caches\transforms-3\6905c56d188193f144e40adf093778f1\transformed\jetified-utilcode-1.30.0\proguard.txt -# Add project specific ProGuard rules here. -# By default, the flags in this file are appended to flags specified -# in G:\Android_IDE\ADT\sdk/tools/proguard/proguard-android.txt -# You can edit the include path and order by changing the proguardFiles -# directive in build.gradle. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# Add any project specific keep options here: - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} --dontwarn com.blankj.utilcode.** - --keepclassmembers class * { - @com.blankj.utilcode.util.BusUtils$Bus ; -} - --keep public class * extends com.blankj.utilcode.util.ApiUtils$BaseApi --keep,allowobfuscation @interface com.blankj.utilcode.util.ApiUtils$Api --keep @com.blankj.utilcode.util.ApiUtils$Api class * - --keepattributes *Annotation* -# End of content from C:\gradle-6.1.1\caches\transforms-3\6905c56d188193f144e40adf093778f1\transformed\jetified-utilcode-1.30.0\proguard.txt # The proguard configuration file for the following section is C:\gradle-6.1.1\caches\transforms-3\bb5ec4ef561b90312eb1ca52da1f144d\transformed\jetified-facebook-applinks-15.2.0\proguard.txt # Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. @@ -2049,6 +2019,36 @@ rx.internal.util.atomic.LinkedQueueNode* consumerNode; # The proguard configuration file for the following section is C:\gradle-6.1.1\caches\transforms-3\acd3bab55cb4f819050ef57ea2e25987\transformed\jetified-beautysdk-202202241203\proguard.txt # End of content from C:\gradle-6.1.1\caches\transforms-3\acd3bab55cb4f819050ef57ea2e25987\transformed\jetified-beautysdk-202202241203\proguard.txt +# The proguard configuration file for the following section is C:\gradle-6.1.1\caches\transforms-3\6905c56d188193f144e40adf093778f1\transformed\jetified-utilcode-1.30.0\proguard.txt +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in G:\Android_IDE\ADT\sdk/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} +-dontwarn com.blankj.utilcode.** + +-keepclassmembers class * { + @com.blankj.utilcode.util.BusUtils$Bus ; +} + +-keep public class * extends com.blankj.utilcode.util.ApiUtils$BaseApi +-keep,allowobfuscation @interface com.blankj.utilcode.util.ApiUtils$Api +-keep @com.blankj.utilcode.util.ApiUtils$Api class * + +-keepattributes *Annotation* +# End of content from C:\gradle-6.1.1\caches\transforms-3\6905c56d188193f144e40adf093778f1\transformed\jetified-utilcode-1.30.0\proguard.txt # The proguard configuration file for the following section is C:\gradle-6.1.1\caches\transforms-3\b75b75d929caf1295aec25af1cc611a0\transformed\jetified-crash-1.0.8\proguard.txt -keep class cn.rongcloud.xcrash.NativeHandler { native ; diff --git a/common/build.gradle b/common/build.gradle index ae8da9404..25d772264 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -258,4 +258,6 @@ dependencies { //声网SDK //api 'io.agora.rtc:agora-special-full:4.2.6.245' api 'com.xj.marqueeView:marqueeView:0.1.20' + + api rootProject.ext.dependencies["blank-utilcode"] } diff --git a/common/src/main/java/com/yunbao/common/activity/AbsActivity.java b/common/src/main/java/com/yunbao/common/activity/AbsActivity.java index d9bc9e968..f4ac8a40b 100644 --- a/common/src/main/java/com/yunbao/common/activity/AbsActivity.java +++ b/common/src/main/java/com/yunbao/common/activity/AbsActivity.java @@ -59,7 +59,6 @@ public abstract class AbsActivity extends AppCompatActivity { @Override protected void onCreate(@Nullable Bundle savedInstanceState) { - create(); Intent intent = getIntent(); if (intent != null) { isFullWindow = getIntent().getBooleanExtra("isFull", false); @@ -68,6 +67,7 @@ public abstract class AbsActivity extends AppCompatActivity { getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); } } + create(); super.onCreate(savedInstanceState); mTag = this.getClass().getSimpleName(); setStatusBar(); @@ -133,7 +133,7 @@ public abstract class AbsActivity extends AppCompatActivity { /** * 设置透明状态栏 */ - private void setStatusBar() { + public void setStatusBar() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Window window = getWindow(); diff --git a/common/src/main/java/com/yunbao/common/activity/WebViewActivity.java b/common/src/main/java/com/yunbao/common/activity/WebViewActivity.java index dc238840c..4a33c908c 100644 --- a/common/src/main/java/com/yunbao/common/activity/WebViewActivity.java +++ b/common/src/main/java/com/yunbao/common/activity/WebViewActivity.java @@ -5,6 +5,7 @@ import android.content.ClipData; import android.content.ClipboardManager; import android.content.Context; import android.content.Intent; +import android.graphics.Color; import android.net.Uri; import android.os.Build; import android.os.Handler; @@ -12,6 +13,7 @@ import android.provider.MediaStore; import android.text.TextUtils; import android.view.View; import android.view.ViewGroup; +import android.view.WindowManager; import android.webkit.ValueCallback; import android.webkit.WebChromeClient; import android.webkit.WebSettings; @@ -82,6 +84,15 @@ public class WebViewActivity extends AbsActivity { return R.layout.activity_webview; } + + + @Override + public void setStatusBar() { + getWindow().setStatusBarColor(Color.parseColor("#FFFFFF")); + getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); + getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR | View.SYSTEM_UI_FLAG_LAYOUT_STABLE); + } + @Override protected void main() { String url = getIntent().getStringExtra(Constants.URL); diff --git a/common/src/main/java/com/yunbao/common/bean/QiniuLog.java b/common/src/main/java/com/yunbao/common/bean/QiniuLog.java new file mode 100644 index 000000000..b861eda2e --- /dev/null +++ b/common/src/main/java/com/yunbao/common/bean/QiniuLog.java @@ -0,0 +1,16 @@ +package com.yunbao.common.bean; + +import com.alibaba.fastjson.annotation.JSONField; + +public class QiniuLog extends BaseModel{ + @JSONField(name = "log_type") + private int log_type; + + public int getLog_type() { + return log_type; + } + + public void setLog_type(int log_type) { + this.log_type = log_type; + } +} diff --git a/common/src/main/java/com/yunbao/common/http/CommonHttpUtil.java b/common/src/main/java/com/yunbao/common/http/CommonHttpUtil.java index 348558d19..8c30a1cb4 100644 --- a/common/src/main/java/com/yunbao/common/http/CommonHttpUtil.java +++ b/common/src/main/java/com/yunbao/common/http/CommonHttpUtil.java @@ -8,6 +8,7 @@ import android.util.Log; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; +import com.blankj.utilcode.util.DeviceUtils; import com.lzy.okgo.OkGo; import com.lzy.okgo.callback.Callback; import com.lzy.okgo.callback.StringCallback; @@ -29,6 +30,7 @@ import com.yunbao.common.utils.AppManager; import com.yunbao.common.utils.DialogUitl; import com.yunbao.common.utils.L; import com.yunbao.common.utils.SpUtil; +import com.yunbao.common.utils.StringUtil; import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.VersionUtil; import com.yunbao.common.utils.WordUtil; @@ -487,6 +489,20 @@ public class CommonHttpUtil { HttpClient.getInstance().get("User.getUserBaseinfo", CommonHttpConsts.GET_USER_BASEINFO) .params("touid", touid) .execute(callback); + } /** + * 上传文件 获取七牛云token的接口 + */ + public static void getUploadQiNiuTokenLog(HttpCallback callback,String fileName) { + String uid = CommonAppConfig.getInstance().getUid(); + if(StringUtil.isEmpty(uid)){ + uid="NotLogin_"+ DeviceUtils.getUniqueDeviceId(); + } + HttpClient.getInstance().get("Pdluserhome.getQiNiuToken3", "Pdluserhome.getQiNiuToken3") + .params("uid",uid) + .params("token", CommonAppConfig.getInstance().getToken()) + .params("file_name", fileName) + .params("ext", ".zip") + .execute(callback); } // // //埋点唯一性 diff --git a/common/src/main/java/com/yunbao/common/http/HttpCallback.java b/common/src/main/java/com/yunbao/common/http/HttpCallback.java index 42333451f..86b47ea60 100644 --- a/common/src/main/java/com/yunbao/common/http/HttpCallback.java +++ b/common/src/main/java/com/yunbao/common/http/HttpCallback.java @@ -36,7 +36,6 @@ public abstract class HttpCallback extends AbsCallback { public void onSuccess(Response response) { JsonBean bean = response.body(); String gson = new Gson().toJson(bean); - Log.e("onSuccess", gson); if (bean != null) { if (200 == bean.getRet()) { diff --git a/common/src/main/java/com/yunbao/common/http/HttpLoggingInterceptor.java b/common/src/main/java/com/yunbao/common/http/HttpLoggingInterceptor.java index 7df49adbe..74acc0e19 100644 --- a/common/src/main/java/com/yunbao/common/http/HttpLoggingInterceptor.java +++ b/common/src/main/java/com/yunbao/common/http/HttpLoggingInterceptor.java @@ -133,15 +133,18 @@ public class HttpLoggingInterceptor implements Interceptor { ResponseBody responseBody = clone.body(); boolean logBody = (printLevel == Level.BODY); boolean logHeaders = (printLevel == Level.BODY || printLevel == Level.HEADERS); - + StringBuilder sb=new StringBuilder(); try { - log("<-- " + clone.code() + ' ' + clone.message() + ' ' + clone.request().url() + " (" + tookMs + "ms)"); + sb.append("<-- ").append(clone.code()) + .append(' ').append(clone.message()) + .append(' ').append(clone.request().url()) + .append(" (").append(tookMs).append("ms)\n"); if (logHeaders) { Headers headers = clone.headers(); for (int i = 0, count = headers.size(); i < count; i++) { - log("\t" + headers.name(i) + ": " + headers.value(i)); + sb.append("\t").append(headers.name(i)).append(": ").append(headers.value(i)).append("\n"); } - log(" "); + sb.append("\n"); if (logBody && HttpHeaders.hasBody(clone)) { if (responseBody == null) return response; @@ -149,18 +152,19 @@ public class HttpLoggingInterceptor implements Interceptor { byte[] bytes = IOUtils.toByteArray(responseBody.byteStream()); MediaType contentType = responseBody.contentType(); String body = new String(bytes, getCharset(contentType)); - log("\tbody:" + body); + sb.append("\tbody:").append(body).append("\n"); responseBody = ResponseBody.create(responseBody.contentType(), bytes); return response.newBuilder().body(responseBody).build(); } else { - log("\tbody: maybe [binary body], omitted!"); + sb.append("\tbody: maybe [binary body], omitted!").append("\n"); } } } } catch (Exception e) { OkLogger.printStackTrace(e); } finally { - log("<-- END HTTP"); + sb.append("<-- END HTTP").append("\n"); + log(sb.toString()); } return response; } diff --git a/common/src/main/java/com/yunbao/common/http/PDLiveApi.java b/common/src/main/java/com/yunbao/common/http/PDLiveApi.java index 17ec489e4..c74051307 100644 --- a/common/src/main/java/com/yunbao/common/http/PDLiveApi.java +++ b/common/src/main/java/com/yunbao/common/http/PDLiveApi.java @@ -69,6 +69,7 @@ import com.yunbao.common.bean.PrankGiftBean; import com.yunbao.common.bean.PrankGiftResultBean; import com.yunbao.common.bean.PrankHttpTurntableBean; import com.yunbao.common.bean.PrankProgressBean; +import com.yunbao.common.bean.QiniuLog; import com.yunbao.common.bean.QuickGiftSendGiftModel; import com.yunbao.common.bean.RandomPkUserBean; import com.yunbao.common.bean.RankPkInfoBean; @@ -1405,4 +1406,8 @@ public interface PDLiveApi { @Query("anchor_id")String anchor_id, @Query("gift_id")String gift_id ); + @GET("/api/public/?service=Tx.androidQiniuLog") + Observable> getPrankList( + @Query("type")String type + ); } diff --git a/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java b/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java index 85e59ccb9..8baeff80d 100644 --- a/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java +++ b/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java @@ -71,6 +71,7 @@ import com.yunbao.common.bean.PrankGiftBean; import com.yunbao.common.bean.PrankGiftResultBean; import com.yunbao.common.bean.PrankHttpTurntableBean; import com.yunbao.common.bean.PrankProgressBean; +import com.yunbao.common.bean.QiniuLog; import com.yunbao.common.bean.QuickGiftSendGiftModel; import com.yunbao.common.bean.RandomPkUserBean; import com.yunbao.common.bean.RankPkInfoBean; @@ -3298,6 +3299,32 @@ public class LiveNetManager { } + /** + * 上报日志相关 + * @param type 1为查询,3为删除 + * @param callback + */ + public void getLogUpdateStatus(String type, HttpCallbackcallback) { + API.get().pdLiveApi(mContext) + .getPrankList(type) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(listResponseModel -> { + if (callback != null) { + callback.onSuccess(listResponseModel.getData().getInfo()); + } + }, new Consumer() { + @Override + public void accept(Throwable throwable) throws Exception { + throwable.printStackTrace(); + if (callback != null) { + callback.onError(mContext.getString(R.string.net_error)); + } + } + }).isDisposed(); + + } + public void getPdluserFriend(int p, HttpCallback> callback) { API.get().pdLiveApi(mContext) .getPdluserFriend(p) @@ -3551,7 +3578,6 @@ public class LiveNetManager { } - public void updateFile(File file, HttpCallback callback) { MultipartBody.Part uploadFile = createUploadFile(file); API.get().pdLiveApi(mContext) diff --git a/common/src/main/java/com/yunbao/common/upload/UploadBean.java b/common/src/main/java/com/yunbao/common/upload/UploadBean.java index 920f3a570..86dd42845 100644 --- a/common/src/main/java/com/yunbao/common/upload/UploadBean.java +++ b/common/src/main/java/com/yunbao/common/upload/UploadBean.java @@ -11,6 +11,7 @@ public class UploadBean { public static final int IMG = 0; public static final int VIDEO = 1; public static final int VOICE = 2; + public static final int LOG = 3; private File mOriginFile;//要被上传的源文件 private File mCompressFile;//压缩后的图片文件 private String mRemoteFileName;//上传成功后在云存储上的文件名字 diff --git a/common/src/main/java/com/yunbao/common/upload/UploadQnImpl.java b/common/src/main/java/com/yunbao/common/upload/UploadQnImpl.java index f1140759a..af19dc222 100644 --- a/common/src/main/java/com/yunbao/common/upload/UploadQnImpl.java +++ b/common/src/main/java/com/yunbao/common/upload/UploadQnImpl.java @@ -1,5 +1,7 @@ package com.yunbao.common.upload; +import static java.text.DateFormat.DEFAULT; + import android.content.Context; import android.text.TextUtils; @@ -11,6 +13,7 @@ import com.qiniu.android.storage.UpCompletionHandler; import com.qiniu.android.storage.UploadManager; import com.yunbao.common.http.CommonHttpUtil; import com.yunbao.common.http.HttpCallback; +import com.yunbao.common.manager.IMLoginManager; import com.yunbao.common.utils.L; import com.yunbao.common.utils.StringUtil; @@ -18,7 +21,10 @@ import org.json.JSONException; import org.json.JSONObject; import java.io.File; +import java.text.SimpleDateFormat; +import java.util.Date; import java.util.List; +import java.util.Locale; import top.zibin.luban.Luban; @@ -52,7 +58,9 @@ public class UploadQnImpl implements UploadStrategy { assert response != null; mList.get(mIndex).setRemoteAccessUrl(response.getString("key")); } catch (JSONException e) { - throw new RuntimeException(e); + // throw new RuntimeException(e); + L.e(e); + return; } if (mList == null || mList.size() == 0) { if (mUploadCallback != null) { @@ -72,6 +80,8 @@ public class UploadQnImpl implements UploadStrategy { compressedFile.delete(); } } + } else if (uploadBean.getType() == UploadBean.LOG) { + uploadBean.getOriginFile().delete(); } mIndex++; if (mIndex < mList.size()) { @@ -90,6 +100,10 @@ public class UploadQnImpl implements UploadStrategy { @Override public void upload(List list, boolean needCompress, UploadCallback callback, boolean isImg) { + upload(list, needCompress, callback, isImg, false); + } + + public void upload(List list, boolean needCompress, UploadCallback callback, boolean isImg, boolean isLog) { System.err.println("-------upload------>" + list.size()); if (callback == null) { return; @@ -127,7 +141,11 @@ public class UploadQnImpl implements UploadStrategy { } }; } - CommonHttpUtil.getUploadQiNiuTokenNew(mGetUploadTokenCallback, isImg); + if (isLog) { + CommonHttpUtil.getUploadQiNiuTokenLog(mGetUploadTokenCallback, list.get(0).getOriginFile().getName()); + } else { + CommonHttpUtil.getUploadQiNiuToken(mGetUploadTokenCallback, isImg); + } } @Override @@ -159,8 +177,16 @@ public class UploadQnImpl implements UploadStrategy { bean.setRemoteFileName(StringUtil.contact(StringUtil.generateFileName(), ".mp4")); } else if (bean.getType() == UploadBean.VOICE) { bean.setRemoteFileName(StringUtil.contact(StringUtil.generateFileName(), ".m4a")); + } else if (bean.getType() == UploadBean.LOG) { + bean.setRemoteFileName("logs/" + + IMLoginManager.get(mContext).getUserInfo().getId() + + "/" + + SimpleDateFormat.getDateInstance(DEFAULT, Locale.CHINA).format(new Date()) + + "/" + + bean.getOriginFile().getName() + ); } - System.err.println("-------mIndex >= bean.getType() == UploadBean.IMG------>" + bean); + System.err.println("-------mIndex >= bean.getType() == " + bean.getType() + "------>" + bean); upload(bean); /*if (bean.getType() == UploadBean.IMG && mNeedCompress) { System.err.println("-------UploadBean.IMG && mNeedCompress------>" + bean + "UploadBean.IMG:" + UploadBean.IMG + "__mNeedCompress" + mNeedCompress); diff --git a/common/src/main/java/com/yunbao/common/utils/L.java b/common/src/main/java/com/yunbao/common/utils/L.java index 7d4a2dc93..3cf47f2b8 100644 --- a/common/src/main/java/com/yunbao/common/utils/L.java +++ b/common/src/main/java/com/yunbao/common/utils/L.java @@ -2,6 +2,13 @@ package com.yunbao.common.utils; import android.util.Log; +import org.json.JSONException; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Locale; +import java.util.UUID; + /** * Created by cxf on 2017/8/3. */ @@ -24,13 +31,23 @@ public class L { } } + final static SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA); + public static void e(String tag, String s) { if (sDeBug) { Log.e(tag, s); + } else { + String uuid = UUID.randomUUID().toString(); + Log.e(tag, uuid); + LogUtils.addSafeLog(dateFormat.format(new Date()) + " [" + uuid + "|" + tag + "] " + s); } } public static void setDeBug(boolean deBug) { sDeBug = deBug; } + + public static void e(Exception e) { + Log.e("Exception", e.getMessage(), e); + } } diff --git a/common/src/main/java/com/yunbao/common/utils/LogUtil.java b/common/src/main/java/com/yunbao/common/utils/LogUtil.java index 7515ca027..604be0d3d 100644 --- a/common/src/main/java/com/yunbao/common/utils/LogUtil.java +++ b/common/src/main/java/com/yunbao/common/utils/LogUtil.java @@ -24,28 +24,25 @@ import com.lzy.okgo.request.PostRequest; import com.lzy.okserver.OkUpload; import com.lzy.okserver.upload.UploadListener; import com.lzy.okserver.upload.UploadTask; +import com.yunbao.common.BuildConfig; import com.yunbao.common.CommonAppConfig; -import com.yunbao.common.bean.IMLoginModel; -import com.yunbao.common.manager.IMLoginManager; +import com.yunbao.common.http.live.LiveNetManager; +import com.yunbao.common.upload.UploadBean; +import com.yunbao.common.upload.UploadCallback; +import com.yunbao.common.upload.UploadQnImpl; -import java.io.BufferedOutputStream; import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; import java.io.FileWriter; import java.io.IOException; -import java.nio.channels.Channels; -import java.nio.channels.FileChannel; -import java.nio.channels.WritableByteChannel; import java.nio.file.Files; import java.text.SimpleDateFormat; +import java.util.ArrayList; import java.util.Date; +import java.util.List; import java.util.Locale; import java.util.concurrent.TimeUnit; import java.util.regex.Matcher; import java.util.regex.Pattern; -import java.util.zip.ZipEntry; -import java.util.zip.ZipOutputStream; import okhttp3.Call; import okhttp3.Callback; @@ -149,91 +146,56 @@ public class LogUtil { public static void shareFile(Context context) { - try { - IMLoginModel bean = IMLoginManager.get(context).getUserInfo(); - boolean isAnchor = false; - if (bean != null) { - isAnchor = bean.anchorUserType(); - } - //有debug文件或主播才允许 - if (!new File(Environment.getExternalStorageDirectory().getAbsolutePath(), "pdlive.debug").exists() && !isAnchor) { - return; - } - } catch (Exception e) { - return; - } - /* if (PermissionChecker.checkCallingOrSelfPermission(context, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PERMISSION_GRANTED) { - ActivityCompat.requestPermissions((Activity) context, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 100); - return; - }*/ - String title = "[PDLIVE]" + CommonAppConfig.getInstance().getUid() + "_"; + String title = "[Pandorapan]" + CommonAppConfig.getInstance().getUid() + "_"; String today = title + SimpleDateFormat.getDateInstance(DEFAULT, Locale.CHINA).format(new Date()); - File dir = new File(context.getDir("files", Context.MODE_PRIVATE).getAbsolutePath() + File.separator); + File dir = new File("/data/data/" + context.getPackageName() + File.separator); File zip = new File(context.getDir("files", Context.MODE_PRIVATE).getAbsolutePath() + File.separator + today + ".zip"); - try { - ZipOutputStream zos = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(zip))); - FileInputStream fis = null; - WritableByteChannel writableByteChannel = Channels.newChannel(zos); - if (dir.listFiles() != null) { - for (File file : dir.listFiles()) { - if (file.getName().endsWith(".log")) { - ZipEntry entry = new ZipEntry(file.getName()); - zos.putNextEntry(entry); - fis = new FileInputStream(file); - FileChannel channel = fis.getChannel(); - channel.transferTo(0, file.length() - 1, writableByteChannel); - fis.close(); + List filters = getFiltersList(context.getPackageName()); + filters.add(context.getPackageName() + File.separator + "app_files" + File.separator + today + ".zip"); + List srcList = new ArrayList<>(); + srcList.add(dir.getAbsolutePath()); + srcList.add(context.getExternalFilesDir("").getAbsolutePath()); + LogUtils.endSafeLog(); + ZipUtils.zipFolder(srcList, zip.getAbsolutePath(), filters, new Runnable() { + @Override + public void run() { + if (BuildConfig.DEBUG) { + // return; } + UploadQnImpl mUploadStrategy = new UploadQnImpl(context); + List list = new ArrayList<>(); + list.add(new UploadBean(zip, UploadBean.LOG)); + mUploadStrategy.upload(list, false, new UploadCallback() { + @Override + public void onFinish(List list, boolean success) { + if (success) { + LiveNetManager.get(context).getLogUpdateStatus("3", null); + } + LogUtils.startSafeLog(context); + } + }, false, true); } - } - zos.close(); - writableByteChannel.close(); + }); } catch (Exception e) { e.printStackTrace(); } - if (zip.exists()) { - DialogUitl.showSimpleDialog(context, "上报日志", new DialogUitl.SimpleCallback() { - @Override - public void onConfirmClick(Dialog dialog, String content) { - new Thread(new Runnable() { - @Override - public void run() { - uploadLog(zip); - } - }).start(); - dialog.dismiss(); - ToastUtil.show("OK"); - Intent share = new Intent(Intent.ACTION_SEND); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { - Uri contentUri = FileProvider.getUriForFile(context, context.getPackageName() + ".fileprovider", zip); - share.putExtra(Intent.EXTRA_STREAM, contentUri); - share.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); - } else { - share.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(zip)); - } - share.setType("application/vnd.ms-excel"); - share.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - share.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); - context.startActivity(Intent.createChooser(share, "分享文件")); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && CommonAppConfig.IS_GOOGLE_PLAY == 0) { - if (!Environment.isExternalStorageManager()) { - Intent intent = new Intent(ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION); - context.startActivity(intent); - } - } - File out = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + zip.getName()); - try { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - Files.copy(zip.toPath(), out.toPath()); - } - } catch (Exception e) { - e.printStackTrace(); - } - } - }); + } - } + private static @NonNull List getFiltersList(String packageName) { + List filters = new ArrayList<>(); + filters.add(packageName + File.separator + "files" + File.separator + "gif"); + filters.add(packageName + File.separator + "app_textures"); + filters.add(packageName + File.separator + "app_webview"); + filters.add(packageName + File.separator + "code_cache"); + filters.add(packageName + File.separator + "databases"); + filters.add(packageName + File.separator + "cache" + File.separator + "https"); + filters.add(packageName + File.separator + "cache" + File.separator + "image"); + filters.add(packageName + File.separator + "cache" + File.separator + "jtechCache"); + filters.add(packageName + File.separator + "cache" + File.separator + "picasso-cache"); + filters.add(packageName + File.separator + "cache" + File.separator + "svga"); + filters.add(packageName + File.separator + "cache" + File.separator + "WebView"); + return filters; } private static String TAG = "Upload"; @@ -271,5 +233,36 @@ public class LogUtil { }); } + private static void openShareDialog(Context context, File zip) { + Intent share = new Intent(Intent.ACTION_SEND); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { + Uri contentUri = FileProvider.getUriForFile(context, context.getPackageName() + ".fileprovider", zip); + share.putExtra(Intent.EXTRA_STREAM, contentUri); + share.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); + } else { + share.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(zip)); + } + share.setType("application/vnd.ms-excel"); + share.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + share.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); + context.startActivity(Intent.createChooser(share, "分享文件")); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && CommonAppConfig.IS_GOOGLE_PLAY == 0) { + if (!Environment.isExternalStorageManager()) { + Intent intent = new Intent(ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION); + context.startActivity(intent); + } + } + File out = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + zip.getName()); + try { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + Files.copy(zip.toPath(), out.toPath()); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + + } diff --git a/app/src/main/java/com/shayu/phonelive/utils/LogUtils.java b/common/src/main/java/com/yunbao/common/utils/LogUtils.java similarity index 61% rename from app/src/main/java/com/shayu/phonelive/utils/LogUtils.java rename to common/src/main/java/com/yunbao/common/utils/LogUtils.java index b2dc80e1c..e474df6ad 100644 --- a/app/src/main/java/com/shayu/phonelive/utils/LogUtils.java +++ b/common/src/main/java/com/yunbao/common/utils/LogUtils.java @@ -1,4 +1,4 @@ -package com.shayu.phonelive.utils; +package com.yunbao.common.utils; import static java.text.DateFormat.DEFAULT; @@ -17,8 +17,11 @@ import java.util.Calendar; import java.util.Date; import java.util.Locale; import java.util.Objects; +import java.util.concurrent.LinkedBlockingQueue; public class LogUtils { + private static final LinkedBlockingQueue QUEUE = new LinkedBlockingQueue<>(); + /** * 采集所有日志 */ @@ -37,7 +40,7 @@ public class LogUtils { BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream())); String line; PrintWriter writer = null; - String title = "[PDLIVE]" + CommonAppConfig.getInstance().getUid() + "_"; + String title = "[Pandorapan]" + CommonAppConfig.getInstance().getUid() + "_"; String today = title + SimpleDateFormat.getDateInstance(DEFAULT, Locale.CHINA).format(new Date()); File dir = new File(context.getDir("files", Context.MODE_PRIVATE).getAbsolutePath() + File.separator); if (dir.listFiles() != null) { @@ -68,7 +71,55 @@ public class LogUtils { } } }).start(); + startSafeLog(context); + } + private static Thread safeThread; + private static boolean writerSafeLog = true; + + public static void startSafeLog(Context context) { + if (safeThread != null && safeThread.isAlive()) { + return; + } + safeThread = new Thread(new Runnable() { + @Override + public void run() { + try { + String title = CommonAppConfig.getInstance().getUid() + "_"; + String today = title + SimpleDateFormat.getDateInstance(DEFAULT, Locale.CHINA).format(new Date()); + File saveFile = new File(context.getDir("files", Context.MODE_PRIVATE).getAbsolutePath() + File.separator + today + ".safe"); + saveFile.createNewFile(); + FileOutputStream os = new FileOutputStream(saveFile, true); + PrintWriter writer = new PrintWriter(os); + while (writerSafeLog) { + if (!QUEUE.isEmpty()) { + writer.append(QUEUE.poll()).write("\n"); + writer.flush(); + } else { + Thread.sleep(1000); + } + } + while (!QUEUE.isEmpty()){ + writer.append(QUEUE.poll()).write("\n"); + writer.flush(); + } + writer.flush(); + writer.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + safeThread.setName("safeLog"); + safeThread.start(); + } + + public static void addSafeLog(String log) { + QUEUE.offer(log); + } + + public static void endSafeLog() { + writerSafeLog = false; } /** diff --git a/common/src/main/java/com/yunbao/common/utils/MessageSayHiNotifyManager.java b/common/src/main/java/com/yunbao/common/utils/MessageSayHiNotifyManager.java index cbc4c2918..0af1d7442 100644 --- a/common/src/main/java/com/yunbao/common/utils/MessageSayHiNotifyManager.java +++ b/common/src/main/java/com/yunbao/common/utils/MessageSayHiNotifyManager.java @@ -81,7 +81,7 @@ public class MessageSayHiNotifyManager { } data.setOldTime(hiBean.getNextTime()); hiBean = data; - if (data.getUser() == null || data.getStatus()==0) { + if (data.getUser() == null || data.getStatus() == 0) { timer.postDelayed(createTask(), data.getNextTime() * 1000L); return; } @@ -126,6 +126,11 @@ public class MessageSayHiNotifyManager { } } + public void clear() { + hiBean = null; + isInit = false; + } + public void stop() { Log.i(TAG, "stop: 停止定时器,当前Activity:" + AppManager.getInstance().getLastActivity() + "|" + hiBean); isStopShow = true; @@ -196,6 +201,12 @@ public class MessageSayHiNotifyManager { hiBean.setStatus(-2); return; } + if (hiBean.getUser().getId() == 0 || hiBean.getUser().getUser() == null) { + Log.i(TAG, "showDialog: 数据为空,不展示"); + isRun = false; + hiBean.setStatus(-2); + return; + } isShowDialog = true; Log.i(TAG, "showDialog: 打开本轮打招呼弹框 " + hiBean); lastActivity = AppManager.getInstance().getLastActivity().getClass().getSimpleName(); diff --git a/FaceUnity/src/main/java/com/yunbao/faceunity/utils/ZipUtils.java b/common/src/main/java/com/yunbao/common/utils/ZipUtils.java similarity index 86% rename from FaceUnity/src/main/java/com/yunbao/faceunity/utils/ZipUtils.java rename to common/src/main/java/com/yunbao/common/utils/ZipUtils.java index 22cbfa3af..8ccc839dc 100644 --- a/FaceUnity/src/main/java/com/yunbao/faceunity/utils/ZipUtils.java +++ b/common/src/main/java/com/yunbao/common/utils/ZipUtils.java @@ -1,10 +1,11 @@ -package com.yunbao.faceunity.utils; +package com.yunbao.common.utils; import android.util.Log; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; +import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.List; @@ -151,16 +152,36 @@ public class ZipUtils { * @param zipFileString 解压完成的Zip路径 * @throws Exception */ - public static void zipFolder(String srcFileString, String zipFileString) throws Exception { + public static void zipFolder(List srcFileString, String zipFileString, List filters, Runnable runnable) throws Exception { + if (filters == null) { + filters = new ArrayList<>(); + } + filters.add(new File(zipFileString).getAbsolutePath()); + final List tmp = new ArrayList<>(filters); //创建ZIP ZipOutputStream outZip = new ZipOutputStream(new FileOutputStream(zipFileString)); - //创建文件 - File file = new File(srcFileString); - //压缩 - zipFiles(file.getParent() + File.separator, file.getName(), outZip); - //完成和关闭 - outZip.finish(); - outZip.close(); + + new Thread(new Runnable() { + @Override + public void run() { + try { + for (String src : srcFileString) { + File file = new File(src); + //压缩 + zipFiles(file.getParent() + File.separator, file.getName(), outZip, tmp); + } + //创建文件 + //完成和关闭 + outZip.finish(); + outZip.close(); + runnable.run(); + } catch (Exception e) { + e.printStackTrace(); + } + } + }).start(); + + } /** @@ -171,9 +192,15 @@ public class ZipUtils { * @param zipOutputSteam * @throws Exception */ - private static void zipFiles(String folderString, String fileString, ZipOutputStream zipOutputSteam) throws Exception { + private static void zipFiles(String folderString, String fileString, ZipOutputStream zipOutputSteam, List filters) throws Exception { if (zipOutputSteam == null) return; + for (String filter : filters) { + if (fileString.startsWith(filter)) { + return; + } + } + System.out.println("压缩文件:" + folderString + "|" + fileString); File file = new File(folderString + fileString); if (file.isFile()) { ZipEntry zipEntry = new ZipEntry(fileString); @@ -196,7 +223,7 @@ public class ZipUtils { } //子文件和递归 for (int i = 0; i < fileList.length; i++) { - zipFiles(folderString, fileString + File.separator + fileList[i], zipOutputSteam); + zipFiles(folderString, fileString + File.separator + fileList[i], zipOutputSteam, filters); } } } diff --git a/common/src/main/res/layout/activity_webview.xml b/common/src/main/res/layout/activity_webview.xml index 44c9ef453..e22ab8281 100644 --- a/common/src/main/res/layout/activity_webview.xml +++ b/common/src/main/res/layout/activity_webview.xml @@ -17,8 +17,9 @@ android:layout_width="match_parent" android:layout_height="72dp" + android:background="@color/white" android:paddingTop="24dp" - android:background="@color/white"> + tools:visibility="gone"> () { + @Override + public void onSuccess(QiniuLog data) { + if(data.getLog_type()==1){ + LogUtil.shareFile(mContext); + } + } + @Override + public void onError(String error) { + } + }); + } } diff --git a/main/src/main/java/com/yunbao/main/activity/ZhuangBanActivity.java b/main/src/main/java/com/yunbao/main/activity/ZhuangBanActivity.java index 9b3bc4e02..60ef5880a 100644 --- a/main/src/main/java/com/yunbao/main/activity/ZhuangBanActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/ZhuangBanActivity.java @@ -5,6 +5,7 @@ import android.content.ClipData; import android.content.ClipboardManager; import android.content.Context; import android.content.Intent; +import android.graphics.Color; import android.net.Uri; import android.os.Build; import android.provider.MediaStore; @@ -12,6 +13,7 @@ import android.text.TextUtils; import android.util.Log; import android.view.View; import android.view.ViewGroup; +import android.view.WindowManager; import android.webkit.ValueCallback; import android.webkit.WebChromeClient; import android.webkit.WebResourceRequest; @@ -75,6 +77,12 @@ public class ZhuangBanActivity extends AbsActivity { private View v_spacing; private LinearLayout lt_title; + @Override + public void setStatusBar() { + getWindow().setStatusBarColor(Color.parseColor("#FFFFFF")); + getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); + getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR | View.SYSTEM_UI_FLAG_LAYOUT_STABLE); + } @Override protected int getLayoutId() { return R.layout.activity_zhuang_ban; diff --git a/main/src/main/java/com/yunbao/main/adapter/SettingAdapter.java b/main/src/main/java/com/yunbao/main/adapter/SettingAdapter.java index d14408af4..9341bcd8e 100644 --- a/main/src/main/java/com/yunbao/main/adapter/SettingAdapter.java +++ b/main/src/main/java/com/yunbao/main/adapter/SettingAdapter.java @@ -55,7 +55,7 @@ public class SettingAdapter extends RecyclerView.Adapter { int position = (int) tag; SettingBean bean = mList.get(position); if (bean.getId() == 19) { - LogUtil.shareFile(context); + } if (mOnItemClickListener != null) { mOnItemClickListener.onItemClick(bean, position);