parent
							
								
									e7f3c5850b
								
							
						
					
					
						commit
						481ea9ff51
					
				| 
						 | 
					@ -36,6 +36,7 @@ android {
 | 
				
			||||||
            minifyEnabled false
 | 
					            minifyEnabled false
 | 
				
			||||||
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
 | 
					            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
 | 
				
			||||||
            buildConfigField "boolean", "ENABLE_LOG", "true"
 | 
					            buildConfigField "boolean", "ENABLE_LOG", "true"
 | 
				
			||||||
 | 
					            signingConfig signingConfigs.debug
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    compileOptions {
 | 
					    compileOptions {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2,17 +2,17 @@
 | 
				
			||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
 | 
					<manifest xmlns:android="http://schemas.android.com/apk/res/android"
 | 
				
			||||||
    xmlns:tools="http://schemas.android.com/tools">
 | 
					    xmlns:tools="http://schemas.android.com/tools">
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <uses-permission android:name="android.permission.INTERNET"/>
 | 
					    <uses-permission android:name="android.permission.INTERNET" />
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <application
 | 
					    <application
 | 
				
			||||||
        android:allowBackup="true"
 | 
					        android:allowBackup="true"
 | 
				
			||||||
        android:dataExtractionRules="@xml/data_extraction_rules"
 | 
					        android:dataExtractionRules="@xml/data_extraction_rules"
 | 
				
			||||||
        android:usesCleartextTraffic="true"
 | 
					 | 
				
			||||||
        android:fullBackupContent="@xml/backup_rules"
 | 
					        android:fullBackupContent="@xml/backup_rules"
 | 
				
			||||||
        android:icon="@mipmap/ic_launcher"
 | 
					        android:icon="@mipmap/ic_launcher"
 | 
				
			||||||
        android:label="@string/app_name"
 | 
					        android:label="@string/app_name"
 | 
				
			||||||
        android:supportsRtl="true"
 | 
					        android:supportsRtl="true"
 | 
				
			||||||
        android:theme="@style/Theme.GakumasLocalify"
 | 
					        android:theme="@style/Theme.GakumasLocalify"
 | 
				
			||||||
 | 
					        android:usesCleartextTraffic="true"
 | 
				
			||||||
        tools:targetApi="31">
 | 
					        tools:targetApi="31">
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        <meta-data
 | 
					        <meta-data
 | 
				
			||||||
| 
						 | 
					@ -43,6 +43,13 @@
 | 
				
			||||||
            </intent-filter>
 | 
					            </intent-filter>
 | 
				
			||||||
        </activity>
 | 
					        </activity>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        <activity
 | 
				
			||||||
 | 
					            android:name=".TranslucentActivity"
 | 
				
			||||||
 | 
					            android:exported="true"
 | 
				
			||||||
 | 
					            android:theme="@style/Theme.GakumasLocalify.NoDisplay">
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        </activity>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        <provider
 | 
					        <provider
 | 
				
			||||||
            android:name="androidx.core.content.FileProvider"
 | 
					            android:name="androidx.core.content.FileProvider"
 | 
				
			||||||
            android:authorities="${applicationId}.fileprovider"
 | 
					            android:authorities="${applicationId}.fileprovider"
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -347,7 +347,7 @@ class GakumasHookMain : IXposedHookLoadPackage, IXposedHookZygoteInit {
 | 
				
			||||||
    fun requestConfig(activity: Context) {
 | 
					    fun requestConfig(activity: Context) {
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
            val intent = Intent().apply {
 | 
					            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")
 | 
					                putExtra("gkmsData", "requestConfig")
 | 
				
			||||||
                flags = FLAG_ACTIVITY_NEW_TASK
 | 
					                flags = FLAG_ACTIVITY_NEW_TASK
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -187,18 +187,10 @@ class MainActivity : ComponentActivity(), ConfigUpdateListener {
 | 
				
			||||||
    override fun onCreate(savedInstanceState: Bundle?) {
 | 
					    override fun onCreate(savedInstanceState: Bundle?) {
 | 
				
			||||||
        super.onCreate(savedInstanceState)
 | 
					        super.onCreate(savedInstanceState)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        binding = DataBindingUtil.setContentView<ActivityMainBinding>(this, R.layout.activity_main)
 | 
					        binding = DataBindingUtil.setContentView(this, R.layout.activity_main)
 | 
				
			||||||
        loadConfig()
 | 
					        loadConfig()
 | 
				
			||||||
        binding.listener = this
 | 
					        binding.listener = this
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        val requestData = intent.getStringExtra("gkmsData")
 | 
					 | 
				
			||||||
        if (requestData != null) {
 | 
					 | 
				
			||||||
            if (requestData == "requestConfig") {
 | 
					 | 
				
			||||||
                onClickStartGame()
 | 
					 | 
				
			||||||
                finish()
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        factory = UserConfigViewModelFactory(binding.config!!)
 | 
					        factory = UserConfigViewModelFactory(binding.config!!)
 | 
				
			||||||
        viewModel = ViewModelProvider(this, factory)[UserConfigViewModel::class.java]
 | 
					        viewModel = ViewModelProvider(this, factory)[UserConfigViewModel::class.java]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -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  | 
| 
						 | 
					@ -1,5 +1,30 @@
 | 
				
			||||||
<?xml version="1.0" encoding="utf-8"?>
 | 
					<?xml version="1.0" encoding="utf-8"?>
 | 
				
			||||||
<resources>
 | 
					<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>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <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>
 | 
					</resources>
 | 
				
			||||||
		Loading…
	
		Reference in New Issue