diff --git a/app/build.gradle b/app/build.gradle index 61c63fc..4a7616c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -11,8 +11,8 @@ android { applicationId "io.github.fplus" minSdk 24 targetSdk 33 - versionCode 128 - versionName "1.3.1" + versionCode 129 + versionName "1.3.2" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" vectorDrawables { diff --git a/app/src/main/assets/update.txt b/app/src/main/assets/update.txt index f183a19..b31f14f 100644 --- a/app/src/main/assets/update.txt +++ b/app/src/main/assets/update.txt @@ -1,3 +1,8 @@ +v1.3.2 +增加清爽模式菜单视频信息查询 +移除清爽模式菜单过滤统计选项 +修复文件下载不通知媒体库刷新的问题 + v1.3.1 增加横屏播放单独的状态栏沉浸逻辑 增加根据内容自动匹配下载文件的格式 (表情包无法发送微信问题) diff --git a/app/src/main/assets/version b/app/src/main/assets/version index 1259ac4..f2498d3 100644 --- a/app/src/main/assets/version +++ b/app/src/main/assets/version @@ -1 +1 @@ -1.3.1-128 \ No newline at end of file +1.3.2-129 \ No newline at end of file diff --git a/core/src/main/java/io/github/fplus/core/base/BaseHook.kt b/core/src/main/java/io/github/fplus/core/base/BaseHook.kt index 1a01497..375c7e8 100644 --- a/core/src/main/java/io/github/fplus/core/base/BaseHook.kt +++ b/core/src/main/java/io/github/fplus/core/base/BaseHook.kt @@ -14,7 +14,6 @@ import android.view.View import android.widget.FrameLayout import android.widget.ProgressBar import android.widget.TextView -import android.widget.Toast import androidx.annotation.DrawableRes import androidx.compose.runtime.Composable import androidx.core.view.isVisible @@ -53,7 +52,6 @@ abstract class BaseHook : HookEntity() { private var singleMainJob: MutableMap = mutableMapOf() private var singleIOJob: MutableMap = mutableMapOf() - private var toast: Toast? = null private var kDialog: KDialog? = null private fun launch(context: CoroutineContext, block: suspend CoroutineScope.() -> Unit): Job { diff --git a/core/src/main/java/io/github/fplus/core/hook/HLongPressLayout.kt b/core/src/main/java/io/github/fplus/core/hook/HLongPressLayout.kt index 6d10cc0..ea880b3 100644 --- a/core/src/main/java/io/github/fplus/core/hook/HLongPressLayout.kt +++ b/core/src/main/java/io/github/fplus/core/hook/HLongPressLayout.kt @@ -26,6 +26,8 @@ import io.github.fplus.core.base.BaseHook import io.github.fplus.core.config.ConfigV1 import io.github.fplus.core.helper.DexkitBuilder import io.github.fplus.core.hook.logic.DownloadLogic +import io.github.fplus.core.hook.logic.cityInfo +import io.github.fplus.core.hook.logic.createDate import io.github.fplus.core.ui.activity.FreedomSettingActivity import io.github.xpler.core.entity.OnAfter import io.github.xpler.core.hookBlockRunning @@ -171,9 +173,11 @@ class HLongPressLayout : BaseHook() { items.add(0, if (!config.neatModeState) "清爽模式" else "普通模式") } - if (config.isVideoFilter) { - items.add("过滤统计") - } + // if (config.isVideoFilter) { + // items.add("过滤统计") + // } + + items.add("视频信息") if (!config.isDisablePlugin) { items.add("模块设置") @@ -209,6 +213,18 @@ class HLongPressLayout : BaseHook() { ) } + "视频信息" -> { + singleLaunchMain("$item") { + val msg = "视频属地: ${aweme?.cityInfo()}\n发布时间: ${aweme?.createDate()}".trim() + showMessageDialog( + context = view.context, + title = "视频信息", + content = msg, + singleButton = true, + ) + } + } + "过滤统计" -> { val builder = StringBuilder() if (HVerticalViewPager.filterLiveCount > 0) { diff --git a/core/src/main/java/io/github/fplus/core/hook/HVerticalViewPager.kt b/core/src/main/java/io/github/fplus/core/hook/HVerticalViewPager.kt index 5e28d01..180b4b3 100644 --- a/core/src/main/java/io/github/fplus/core/hook/HVerticalViewPager.kt +++ b/core/src/main/java/io/github/fplus/core/hook/HVerticalViewPager.kt @@ -229,7 +229,7 @@ class HVerticalViewPager : BaseHook() { val mData = mModel?.fieldGet(name = "mData") if (mData?.javaClass?.name?.contains("FeedItemList") == true) { val items = mData.fieldGet(name = "items")?.asOrNull>() ?: emptyList() - if (items.size < 3) return@onBefore + if (items.size < 10) return@onBefore mData.fieldSet(name = "items", filterAwemeList(items)) // val array = items.map { it.sortString() }.toTypedArray() @@ -251,7 +251,7 @@ class HVerticalViewPager : BaseHook() { val mData = mModel?.fieldGet(name = "mData") if (mData?.javaClass?.name?.contains("FollowFeedList") == true) { val mItems = mData.fieldGet(name = "mItems")?.asOrNull>() ?: emptyList() - if (mItems.size < 3) return@onBefore + if (mItems.size < 10) return@onBefore mData.fieldSet("mItems", filterFollowFeedList(mItems)) // val array = mItems.map { it.aweme.sortString() }.toTypedArray() diff --git a/core/src/main/java/io/github/fplus/core/hook/logic/AwemeExt.kt b/core/src/main/java/io/github/fplus/core/hook/logic/AwemeExt.kt index b5e2a9f..a29df2f 100644 --- a/core/src/main/java/io/github/fplus/core/hook/logic/AwemeExt.kt +++ b/core/src/main/java/io/github/fplus/core/hook/logic/AwemeExt.kt @@ -1,7 +1,36 @@ package io.github.fplus.core.hook.logic +import com.freegang.extension.format +import com.freegang.extension.getStringOrDefault +import com.freegang.extension.parseJSON +import com.freegang.ktutils.net.KHttpUtils import com.ss.android.ugc.aweme.feed.model.Aweme import com.ss.ugc.aweme.ImageUrlStruct +import io.github.xpler.core.log.XplerLog +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.withContext +import java.util.Date + +fun Aweme.createDate(): String { + return Date(this.createTime * 1000).format() +} + +suspend fun Aweme.cityInfo(): String { + return withContext(Dispatchers.IO) { + runCatching { + val result = KHttpUtils.get("http://api.ip33.com/Area_Code/GetArea/?code=$city") + val areaJson = result.parseJSON() + val province = areaJson.getStringOrDefault("province") + val city = areaJson.getStringOrDefault("city") + val county = areaJson.getStringOrDefault("county") + + "$province $city $county".trim() + }.getOrElse { + XplerLog.e(it) + "获取失败" + } + } +} fun Aweme.getH265VideoUrlList(): List { val video = video ?: return emptyList() diff --git a/core/src/main/java/io/github/fplus/core/hook/logic/DownloadLogic.kt b/core/src/main/java/io/github/fplus/core/hook/logic/DownloadLogic.kt index 9269554..1094263 100644 --- a/core/src/main/java/io/github/fplus/core/hook/logic/DownloadLogic.kt +++ b/core/src/main/java/io/github/fplus/core/hook/logic/DownloadLogic.kt @@ -12,7 +12,6 @@ import com.freegang.extension.secureFilename import com.freegang.ktutils.app.IProgressNotification import com.freegang.ktutils.app.KNotifiUtils import com.freegang.ktutils.app.KToastUtils -import com.freegang.ktutils.log.KLogCat import com.freegang.ktutils.media.KMediaUtils import com.freegang.ktutils.net.KHttpUtils import com.freegang.ktutils.text.KTextUtils @@ -25,7 +24,6 @@ import io.github.xpler.core.log.XplerLog import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext import java.io.File -import java.io.FileOutputStream /// 下载(视频/图文/音乐)逻辑 class DownloadLogic( @@ -216,19 +214,16 @@ class DownloadLogic( val imageFiles = mutableListOf() var downloadCount = 0 // 下载计数器 structList.forEachIndexed { index, urlStruct -> - val downloadFile = - File(mImageParent.need(), mPureFileName.secureFilename("_${index + 1}.jpg")) - val finished = - download( - urlStruct.urlList.first(), - downloadFile, - it, - "$index/${aweme.images.size} %s%%" - ) - if (finished) { + val resultFile = downloadFile( + url = urlStruct.urlList.first(), + downloadFile = File(mImageParent.need(), mPureFileName.secureFilename("_${index + 1}.jpg")), + notify = it, + progressText = "$index/${aweme.images.size} %s%%", + ) + if (resultFile != null) { downloadCount += 1 - imageFiles.add(downloadFile) - KMediaUtils.notifyMediaUpdate(context, downloadFile.absolutePath) + imageFiles.add(resultFile) + KMediaUtils.notifyMediaUpdate(context, resultFile.absolutePath) } } @@ -288,18 +283,15 @@ class DownloadLogic( hook.singleLaunchIO(mPureFileName) { var downloadCount = 0 // 下载计数器 structList.forEachIndexed { index, urlStruct -> - val downloadFile = - File(mImageParent.need(), mPureFileName.secureFilename("_${index + 1}.jpg")) - val finished = - download( - urlStruct.urlList.first(), - downloadFile, - notify, - "$index/${aweme.images.size} %s%%" - ) - if (finished) { + val resultFile = downloadFile( + url = urlStruct.urlList.first(), + downloadFile = File(mImageParent.need(), mPureFileName.secureFilename("_${index + 1}.jpg")), + notify = notify, + progressText = "$index/${aweme.images.size} %s%%", + ) + if (resultFile != null) { downloadCount += 1 - KMediaUtils.notifyMediaUpdate(context, downloadFile.absolutePath) + KMediaUtils.notifyMediaUpdate(context, resultFile.absolutePath) } } @@ -360,19 +352,23 @@ class DownloadLogic( listener = { // 下载逻辑 hook.singleLaunchIO(pureFileName) { - val downloadFile = File(parentPath.need(), pureFileName) - val finished = download(urlList.first(), downloadFile, it, "下载中 %s%%") - if (finished) { + val resultFile = downloadFile( + url = urlList.first(), + downloadFile = File(parentPath.need(), pureFileName), + notify = it, + progressText = "下载中 %s%%", + ) + if (resultFile != null) { hook.refresh { val message = if (isWebDav) "下载成功, 正在上传WebDav!" else "下载成功!" it.setFinishedText(message) hook.showToast(context, message) - KMediaUtils.notifyMediaUpdate(context, downloadFile.absolutePath) + KMediaUtils.notifyMediaUpdate(context, resultFile.absolutePath) } // 上传WebDav if (isWebDav) { - val uploadStatus = uploadToWebDav(downloadFile) + val uploadStatus = uploadToWebDav(resultFile) hook.refresh { it.setFinishedText("上传WebDav${if (uploadStatus) "成功!" else "失败!"}") hook.showToast(context, "上传WebDav${if (uploadStatus) "成功!" else "失败!"}") @@ -403,20 +399,24 @@ class DownloadLogic( listener = { dialog, notify -> // 下载逻辑 hook.singleLaunchIO(pureFileName) { - val downloadFile = File(parentPath.need(), pureFileName) - val finished = download(urlList.first(), downloadFile, notify, "%s%%") - if (finished) { + val resultFile = downloadFile( + url = urlList.first(), + downloadFile = File(parentPath.need(), pureFileName), + notify = notify, + progressText = "%s%%", + ) + if (resultFile != null) { hook.refresh { dialog.dismiss() val message = if (isWebDav) "下载成功, 正在上传WebDav!" else "下载成功!" notify.setFinishedText(message) hook.showToast(context, message) - KMediaUtils.notifyMediaUpdate(context, downloadFile.absolutePath) + KMediaUtils.notifyMediaUpdate(context, resultFile.absolutePath) } // 上传WebDav if (isWebDav) { - val uploadStatus = uploadToWebDav(downloadFile) + val uploadStatus = uploadToWebDav(resultFile) hook.showToast(context, "上传WebDav${if (uploadStatus) "成功!" else "失败!"}") } } else { @@ -434,14 +434,17 @@ class DownloadLogic( /** * 下载至本地 */ - private suspend fun download( + private suspend fun downloadFile( url: String, downloadFile: File, notify: IProgressNotification, progressText: String, - ): Boolean { + ): File? { return withContext(Dispatchers.IO) { - KHttpUtils.download(url, downloadFile) { real, total, e -> + KHttpUtils.download( + sourceUrl = url, + file = downloadFile, + ) { real, total, e -> if (e != null) XplerLog.e(e) diff --git a/core/src/main/java/io/github/fplus/core/hook/logic/SaveAudioLogic.kt b/core/src/main/java/io/github/fplus/core/hook/logic/SaveAudioLogic.kt index f646ff1..30372b9 100644 --- a/core/src/main/java/io/github/fplus/core/hook/logic/SaveAudioLogic.kt +++ b/core/src/main/java/io/github/fplus/core/hook/logic/SaveAudioLogic.kt @@ -26,12 +26,13 @@ class SaveAudioLogic( // 构建保存文件名 hook.showToast(context, "保存语音, 请稍后..") - val file = File(parentPath, "${filename}.mp3") - - val result = KHttpUtils.download(url, file) - if (result) { + val resultFile = KHttpUtils.download( + sourceUrl = url, + file = File(parentPath, "${filename}.mp3"), + ) + if (resultFile != null) { hook.showToast(context, "保存成功!") - KMediaUtils.notifyMediaUpdate(context, file.absolutePath) + KMediaUtils.notifyMediaUpdate(context, resultFile.absolutePath) if (config.vibrate) hook.vibrate(context, 5L) } else { hook.showToast(context, "保存失败!") diff --git a/core/src/main/java/io/github/fplus/core/hook/logic/SaveCommentLogic.kt b/core/src/main/java/io/github/fplus/core/hook/logic/SaveCommentLogic.kt index 9019e4b..7a05997 100644 --- a/core/src/main/java/io/github/fplus/core/hook/logic/SaveCommentLogic.kt +++ b/core/src/main/java/io/github/fplus/core/hook/logic/SaveCommentLogic.kt @@ -39,7 +39,6 @@ class SaveCommentLogic( } }.onFailure { XplerLog.e(it) - hook.showToast(context, "基本信息获取失败") } } @@ -56,17 +55,20 @@ class SaveCommentLogic( // 保存评论区图片 private fun onSaveCommentImage(urlList: List) { - hook.singleLaunchIO("SaveCommentImage") { + val url = urlList.first() + hook.singleLaunchIO(url) { // 默认保存路径: `/外置存储器/Download/Freedom/picture/comment` val parentPath = ConfigV1.getFreedomDir(context).child("picture").child("comment").need() // 构建保存文件名 hook.showToast(context, "保存图片, 请稍后..") - val file = File(parentPath, "${System.currentTimeMillis() / 1000}.png") - val result = KHttpUtils.download(urlList.first(), file) - if (result) { + val resultFile = KHttpUtils.download( + sourceUrl = url, + file = File(parentPath, "${System.currentTimeMillis() / 1000}.png"), + ) + if (resultFile != null) { hook.showToast(context, "保存成功!") - KMediaUtils.notifyMediaUpdate(context, file.absolutePath) + KMediaUtils.notifyMediaUpdate(context, resultFile.absolutePath) if (config.vibrate) hook.vibrate(context, 5L) } else { hook.showToast(context, "保存失败!") @@ -76,17 +78,20 @@ class SaveCommentLogic( // 保存评论区视频 private fun onSaveCommentVideo(urlList: List) { - hook.singleLaunchIO("SaveCommentVideo") { + val url = urlList.first() + hook.singleLaunchIO(url) { // 默认保存路径: `/外置存储器/Download/Freedom/video/comment` val parentPath = ConfigV1.getFreedomDir(context).child("video").child("comment").need() // 构建保存文件名 hook.showToast(context, "保存视频, 请稍后..") - val file = File(parentPath, "${System.currentTimeMillis() / 1000}.mp4") - val result = KHttpUtils.download(urlList.first(), file) - if (result) { + val resultFile = KHttpUtils.download( + sourceUrl = urlList.first(), + file = File(parentPath, "${System.currentTimeMillis() / 1000}.mp4"), + ) + if (resultFile != null) { hook.showToast(context, "保存成功!") - KMediaUtils.notifyMediaUpdate(context, file.absolutePath) + KMediaUtils.notifyMediaUpdate(context, resultFile.absolutePath) if (config.vibrate) hook.vibrate(context, 5L) } else { hook.showToast(context, "保存失败!") diff --git a/core/src/main/java/io/github/fplus/core/hook/logic/SaveEmojiLogic.kt b/core/src/main/java/io/github/fplus/core/hook/logic/SaveEmojiLogic.kt index 24ceba0..0b65d83 100644 --- a/core/src/main/java/io/github/fplus/core/hook/logic/SaveEmojiLogic.kt +++ b/core/src/main/java/io/github/fplus/core/hook/logic/SaveEmojiLogic.kt @@ -3,14 +3,12 @@ package io.github.fplus.core.hook.logic import android.content.Context import com.freegang.extension.child import com.freegang.extension.need -import com.freegang.ktutils.log.KLogCat import com.freegang.ktutils.media.KMediaUtils import com.freegang.ktutils.net.KHttpUtils import io.github.fplus.core.base.BaseHook import io.github.fplus.core.config.ConfigV1 import io.github.xpler.core.log.XplerLog import java.io.File -import java.io.FileOutputStream // 保存表情逻辑 class SaveEmojiLogic( @@ -31,22 +29,24 @@ class SaveEmojiLogic( onSaveEmoji(urlList) }.onFailure { XplerLog.e(it) - hook.showToast(context, "表情内容获取失败") } } private fun onSaveEmoji(urlList: List) { - hook.singleLaunchIO("SaveEmoji") { + val url = urlList.first() + hook.singleLaunchIO(url) { // 默认保存路径: `/外置存储器/Download/Freedom/emoji` val parentPath = ConfigV1.getFreedomDir(context).child("emoji").need() // 构建保存文件名 hook.showToast(context, "保存表情, 请稍后..") - val file = File(parentPath, "${System.currentTimeMillis() / 1000}.webp") - val result = KHttpUtils.download(urlList.first(), file) - if (result) { + val resultFile = KHttpUtils.download( + sourceUrl = url, + file = File(parentPath, "${System.currentTimeMillis() / 1000}.webp"), + ) + if (resultFile != null) { hook.showToast(context, "保存成功!") - KMediaUtils.notifyMediaUpdate(context, file.absolutePath) + KMediaUtils.notifyMediaUpdate(context, resultFile.absolutePath) if (config.vibrate) hook.vibrate(context, 5L) } else { hook.showToast(context, "保存失败!") diff --git a/core/src/main/java/io/github/fplus/core/ui/viewmodel/FreedomSettingVM.kt b/core/src/main/java/io/github/fplus/core/ui/viewmodel/FreedomSettingVM.kt index 3139152..f01bcde 100644 --- a/core/src/main/java/io/github/fplus/core/ui/viewmodel/FreedomSettingVM.kt +++ b/core/src/main/java/io/github/fplus/core/ui/viewmodel/FreedomSettingVM.kt @@ -594,14 +594,14 @@ class FreedomSettingVM(application: Application) : AndroidViewModel(application) val versionName = version.substringBeforeLast("-") val versionCode = version.substringAfterLast("-") config.versionConfig = config.versionConfig.copy( - versionName, - versionCode.toLong(), - app.appVersionName, - app.appVersionCode, + versionName = versionName, + versionCode = versionCode.toLong(), + dyVersionName = app.appVersionName, + dyVersionCode = app.appVersionCode, ) } - val hasDexkitCache get() = !config.dexkitCache.isEmpty + val hasDexkitCache get() = !config.dexkitCache.isEmpty() // 清除类日志 fun clearDexkitCache() {