Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import cc.microblock.TGStickerProvider.nomediaPath
import cc.microblock.TGStickerProvider.stickerDataPath
import cc.microblock.TGStickerProvider.syncFlagsPath
import cc.microblock.TGStickerProvider.tgseDataPath
import cc.microblock.TGStickerProvider.utils.CachePathHelper.getCachePath
import com.highcapable.yukihookapi.annotation.xposed.InjectYukiHookWithXposed
import com.highcapable.yukihookapi.hook.factory.configs
import com.highcapable.yukihookapi.hook.factory.encase
Expand Down Expand Up @@ -49,10 +50,7 @@ class HookEntry : IYukiHookXposedInit {
Thread {
Thread.sleep(1000);
val dataPath = "/data/data/${this.packageName}/";
val tgCachePath =
if(this.packageName == "xyz.nextalone.nagram") "/storage/emulated/0/Android/data/${this.packageName}/files/caches"
else "/storage/emulated/0/Android/data/${this.packageName}/cache"
;
val tgCachePath = getCachePath(this.appContext, this.packageName)

if (!File(tgseDataPath).exists()) {
File(tgseDataPath).mkdirs();
Expand Down Expand Up @@ -146,7 +144,6 @@ class HookEntry : IYukiHookXposedInit {
val localPath = "${sticker.dc_id}_${sticker.id}.webp";
val localPathLowQuality = "-${sticker.id}_1109.webp";
val stickerFile = File(tgCachePath, localPath);

val destFile = File(destDir, "${sticker.id}_high.webp");
val destFileLowQuality =
File(destDir, "${sticker.id}_low.webp");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package cc.microblock.TGStickerProvider.utils

import android.app.Application
import android.content.Context
import android.content.SharedPreferences
import java.io.File


object CachePathHelper {
@JvmStatic
fun getCachePath(context: Application?, packageName: String): String {
var defaultCachePath = "/storage/emulated/0/Android/data/${packageName}/cache"
if (context != null && isNekoX(packageName)) {
val nekoXCachePath = getNekoXCachePath(context)
if (nekoXCachePath != null) {
defaultCachePath = "$nekoXCachePath/caches"
}
}
return defaultCachePath
}

@JvmStatic
fun isNekoX(packageName: String): Boolean {
return File("/data/data/${packageName}/shared_prefs/nkmrcfg.xml").exists()
}

@JvmStatic
fun getNekoXCachePath(context: Context): String? {
val preferences: SharedPreferences =
context.getSharedPreferences(
"nkmrcfg",
Context.MODE_PRIVATE
)
return preferences.getString("cache_path", null)
}
}