Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add windowBackground #36

Merged
merged 4 commits into from
Jun 29, 2024
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
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,10 @@ jobs:
keyStorePassword: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }}
keyPassword: ${{ secrets.ANDROID_KEY_PASSWORD }}
buildToolsVersion: 33.0.0
continue-on-error: true

- uses: actions/upload-artifact@v4
with:
name: GakumasLocalify-Signed-apk
path: ${{steps.sign_app.outputs.signedFile}}
continue-on-error: true
4 changes: 1 addition & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -56,9 +57,6 @@ android {
version '3.22.1'
}
}
dataBinding {
enable true
}

packaging {
jniLibs {
Expand Down
23 changes: 15 additions & 8 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
package io.github.chinosk.gakumas.localify

import android.app.Activity
import android.content.Intent
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


interface IHasConfigItems {
var config: GakumasConfig
var programConfig: ProgramConfig

fun saveConfig() {} // do nothing
}

interface IConfigurableActivity<T : Activity> : IHasConfigItems


fun <T> T.getConfigContent(): String where T : Activity {
val configFile = File(filesDir, "gkms-config.json")
return if (configFile.exists()) {
configFile.readText()
} else {
showToast("检测到第一次启动,初始化配置文件...")
"{}"
}
}

fun <T> T.getProgramConfigContent(
excludes: List<String> = emptyList(),
origProgramConfig: ProgramConfig? = null
): String where T : Activity {
val configFile = File(filesDir, "localify-config.json")
if (excludes.isEmpty()) {
return if (configFile.exists()) {
configFile.readText()
} else {
"{}"
}
} else {
return if (origProgramConfig == null) {
if (configFile.exists()) {
val parsedConfig = json.decodeFromString<ProgramConfig>(configFile.readText())
json.encodeToString(ProgramConfigSerializer(excludes), parsedConfig)
} else {
"{}"
}
} else {
json.encodeToString(ProgramConfigSerializer(excludes), origProgramConfig)
}
}
}

fun <T> T.loadConfig() where T : Activity, T : IHasConfigItems {
val configStr = getConfigContent()
config = try {
json.decodeFromString<GakumasConfig>(configStr)
} catch (e: SerializationException) {
showToast("配置文件异常,已重置: $e")
GakumasConfig()
}
saveConfig()

val programConfigStr = getProgramConfigContent()
programConfig = try {
json.decodeFromString<ProgramConfig>(programConfigStr)
} catch (e: SerializationException) {
ProgramConfig()
}
}

fun <T> T.onClickStartGame() where T : Activity, T : IHasConfigItems {
val intent = Intent().apply {
setClassName(
"com.bandainamcoent.idolmaster_gakuen",
"com.google.firebase.MessagingUnityPlayerActivity"
)
putExtra("gkmsData", getConfigContent())
putExtra(
"localData",
getProgramConfigContent(listOf("transRemoteZipUrl", "p"), programConfig)
)
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)
}
Loading
Loading