1
0

add windowBackground

add TranslucentActivity
This commit is contained in:
ketal 2024-06-28 14:27:51 +08:00
parent e7f3c5850b
commit 481ea9ff51
No known key found for this signature in database
GPG Key ID: 52E91FA93DA527DA
7 changed files with 136 additions and 20 deletions

View File

@ -36,6 +36,7 @@ android {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
buildConfigField "boolean", "ENABLE_LOG", "true"
signingConfig signingConfigs.debug
}
}
compileOptions {

View File

@ -2,17 +2,17 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:usesCleartextTraffic="true"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/Theme.GakumasLocalify"
android:usesCleartextTraffic="true"
tools:targetApi="31">
<meta-data
@ -43,14 +43,21 @@
</intent-filter>
</activity>
<activity
android:name=".TranslucentActivity"
android:exported="true"
android:theme="@style/Theme.GakumasLocalify.NoDisplay">
</activity>
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
</application>

View File

@ -347,7 +347,7 @@ class GakumasHookMain : IXposedHookLoadPackage, IXposedHookZygoteInit {
fun requestConfig(activity: Context) {
try {
val intent = Intent().apply {
setClassName("io.github.chinosk.gakumas.localify", "io.github.chinosk.gakumas.localify.MainActivity")
setClassName("io.github.chinosk.gakumas.localify", "io.github.chinosk.gakumas.localify.TranslucentActivity")
putExtra("gkmsData", "requestConfig")
flags = FLAG_ACTIVITY_NEW_TASK
}

View File

@ -187,18 +187,10 @@ class MainActivity : ComponentActivity(), ConfigUpdateListener {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = DataBindingUtil.setContentView<ActivityMainBinding>(this, R.layout.activity_main)
binding = DataBindingUtil.setContentView(this, R.layout.activity_main)
loadConfig()
binding.listener = this
val requestData = intent.getStringExtra("gkmsData")
if (requestData != null) {
if (requestData == "requestConfig") {
onClickStartGame()
finish()
}
}
factory = UserConfigViewModelFactory(binding.config!!)
viewModel = ViewModelProvider(this, factory)[UserConfigViewModel::class.java]

View File

@ -0,0 +1,91 @@
package io.github.chinosk.gakumas.localify
import android.content.Intent
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.core.content.FileProvider
import io.github.chinosk.gakumas.localify.GakumasHookMain.Companion.showToast
import io.github.chinosk.gakumas.localify.mainUtils.json
import io.github.chinosk.gakumas.localify.models.GakumasConfig
import io.github.chinosk.gakumas.localify.models.ProgramConfig
import io.github.chinosk.gakumas.localify.models.ProgramConfigSerializer
import kotlinx.serialization.SerializationException
import java.io.File
class TranslucentActivity : ComponentActivity() {
private lateinit var programConfig: ProgramConfig
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
loadConfig()
val requestData = intent.getStringExtra("gkmsData")
if (requestData != null) {
if (requestData == "requestConfig") {
onClickStartGame()
finish()
}
}
}
private fun loadConfig() {
val configStr = getConfigContent()
try {
json.decodeFromString<GakumasConfig>(configStr)
} catch (e: SerializationException) {
showToast("配置文件异常,已重置: $e")
GakumasConfig()
}
val programConfigStr = getProgramConfigContent()
programConfig = try {
json.decodeFromString<ProgramConfig>(programConfigStr)
}
catch (e: SerializationException) {
ProgramConfig()
}
}
private fun onClickStartGame() {
val intent = Intent().apply {
setClassName("com.bandainamcoent.idolmaster_gakuen", "com.google.firebase.MessagingUnityPlayerActivity")
putExtra("gkmsData", getConfigContent())
putExtra("localData", getProgramConfigContent(listOf("transRemoteZipUrl", "p")))
flags = Intent.FLAG_ACTIVITY_NEW_TASK
}
val updateFile = File(filesDir, "update_trans.zip")
if (updateFile.exists()) {
val dirUri = FileProvider.getUriForFile(this, "io.github.chinosk.gakumas.localify.fileprovider", File(updateFile.absolutePath))
intent.setDataAndType(dirUri, "resource/file")
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION)
}
startActivity(intent)
}
private fun getConfigContent(): String {
val configFile = File(filesDir, "gkms-config.json")
return if (configFile.exists()) {
configFile.readText()
}
else {
showToast("检测到第一次启动,初始化配置文件...")
"{}"
}
}
private fun getProgramConfigContent(excludes: List<String> = emptyList()): String {
if (excludes.isEmpty()) {
val configFile = File(filesDir, "localify-config.json")
return if (configFile.exists()) {
configFile.readText()
}
else {
"{}"
}
}
else {
return json.encodeToString(ProgramConfigSerializer(excludes), programConfig)
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 MiB

View File

@ -1,5 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.GakumasLocalify" parent="@style/Theme.MaterialComponents.Light.NoActionBar" />
<style name="Theme.GakumasLocalify" parent="@style/Theme.MaterialComponents.Light.NoActionBar" >
<item name="android:windowBackground">@drawable/splash</item>
</style>
</resources>
<style name="Theme.GakumasLocalify.NoDisplay" parent="@style/Theme.MaterialComponents.Light.NoActionBar" >
<item name="android:windowFrame">@null</item>
<!-- 设置是否可滑动 -->
<item name="android:windowIsFloating">true</item>
<!-- 设置是否透明 -->
<item name="android:windowIsTranslucent">true</item>
<!-- 无标题 -->
<item name="android:windowNoTitle">true</item>
<!-- 背景 -->
<item name="android:background">@null</item>
<!-- 窗口背景 -->
<item name="android:windowBackground">@android:color/transparent</item>
<!-- 是否变暗 -->
<item name="android:backgroundDimEnabled">false</item>
<!-- 点击空白部分activity不消失 -->
<item name="android:windowCloseOnTouchOutside">true</item>
<!-- 无标题 有的手机设置这行代码-->
<item name="windowNoTitle">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowAnimationStyle">@null</item>
<item name="android:windowDisablePreview">true</item>
<item name="android:windowNoDisplay">true</item>
</style>
</resources>