Skip to content

Commit e7cb0e5

Browse files
committed
Initial commit
0 parents  commit e7cb0e5

36 files changed

+741
-0
lines changed

.gitignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/caches
5+
/.idea/libraries
6+
/.idea/modules.xml
7+
/.idea/workspace.xml
8+
/.idea/navEditor.xml
9+
/.idea/assetWizardSettings.xml
10+
.DS_Store
11+
/build
12+
/captures
13+
.externalNativeBuild
14+
.cxx
15+
local.properties

app/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

app/build.gradle

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
plugins {
2+
id 'com.android.application'
3+
id 'kotlin-android'
4+
}
5+
6+
android {
7+
compileSdk 30
8+
9+
defaultConfig {
10+
applicationId "me.kyuubiran.akinatorhelper"
11+
minSdk 21
12+
targetSdk 30
13+
versionCode 1
14+
versionName "1.0"
15+
}
16+
17+
buildTypes {
18+
release {
19+
minifyEnabled false
20+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
21+
}
22+
}
23+
compileOptions {
24+
sourceCompatibility JavaVersion.VERSION_1_8
25+
targetCompatibility JavaVersion.VERSION_1_8
26+
}
27+
kotlinOptions {
28+
jvmTarget = '1.8'
29+
}
30+
}
31+
32+
dependencies {
33+
34+
compileOnly 'de.robv.android.xposed:api:82'
35+
implementation 'com.github.kyuubiran:EzXHelper:0.3.8'
36+
}

app/proguard-rules.pro

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile

app/src/main/AndroidManifest.xml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="me.kyuubiran.akinatorhelper">
4+
5+
<application
6+
android:allowBackup="true"
7+
android:icon="@mipmap/ic_launcher"
8+
android:label="@string/app_name"
9+
android:roundIcon="@mipmap/ic_launcher_round"
10+
android:supportsRtl="true">
11+
<meta-data
12+
android:name="xposedmodule"
13+
android:value="true"/>
14+
<meta-data
15+
android:name="xposeddescription"
16+
android:value="Akinator 小助手" />
17+
<meta-data
18+
android:name="xposedminversion"
19+
android:value="54"/>
20+
<meta-data
21+
android:name="xposedscope"
22+
android:resource="@array/xposedscope"/>
23+
</application>
24+
25+
</manifest>

app/src/main/assets/xposed_init

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
me.kyuubiran.akinatorhelper.HookEntry
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package me.kyuubiran.akinatorhelper
2+
3+
import com.github.kyuubiran.ezxhelper.init.EzXHelperInit
4+
import de.robv.android.xposed.IXposedHookLoadPackage
5+
import de.robv.android.xposed.callbacks.XC_LoadPackage
6+
import me.kyuubiran.akinatorhelper.hooks.ConfigHook
7+
import me.kyuubiran.akinatorhelper.hooks.OnGameActivityCreateHook
8+
9+
class HookEntry : IXposedHookLoadPackage {
10+
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
11+
if (!lpparam.packageName.startsWith("com.digidust.elokence.akinator") || lpparam.packageName != lpparam.processName) return
12+
EzXHelperInit.initHandleLoadPackage(lpparam)
13+
EzXHelperInit.setLogTag("Akinator Helper")
14+
EzXHelperInit.setToastTag("Akinator Helper")
15+
init
16+
}
17+
18+
private val init: Unit by lazy {
19+
initHooks()
20+
}
21+
22+
private fun initHooks() {
23+
listOf(
24+
OnGameActivityCreateHook,
25+
ConfigHook
26+
).forEach {
27+
if (it.isInit) return
28+
it.init()
29+
it.isInit = true
30+
}
31+
}
32+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package me.kyuubiran.akinatorhelper.hooks
2+
3+
abstract class BaseHook {
4+
var isInit: Boolean = false
5+
6+
abstract fun init()
7+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package me.kyuubiran.akinatorhelper.hooks
2+
3+
import com.github.kyuubiran.ezxhelper.utils.getMethodsByCondition
4+
import com.github.kyuubiran.ezxhelper.utils.hookBefore
5+
6+
object ConfigHook : BaseHook() {
7+
override fun init() {
8+
getMethodsByCondition("com.digidust.elokence.akinator.factories.AkConfigFactory") {
9+
it.name == "isFreemium" || it.name == "isGameCountLimited" || it.name == "canShowAd"
10+
}.hookBefore { it.result = false }
11+
getMethodsByCondition("com.digidust.elokence.akinator.factories.AkConfigFactory") {
12+
it.name == "isPaid" || it.name == "isUnlocked"
13+
}.hookBefore { it.result = true }
14+
}
15+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package me.kyuubiran.akinatorhelper.hooks
2+
3+
import com.github.kyuubiran.ezxhelper.init.EzXHelperInit
4+
import com.github.kyuubiran.ezxhelper.utils.Log
5+
import com.github.kyuubiran.ezxhelper.utils.findMethodByCondition
6+
import com.github.kyuubiran.ezxhelper.utils.hookAfter
7+
import de.robv.android.xposed.XC_MethodHook
8+
9+
object OnGameActivityCreateHook : BaseHook() {
10+
private var hook: XC_MethodHook.Unhook? = null
11+
12+
override fun init() {
13+
hook = findMethodByCondition("com.digidust.elokence.akinator.activities.AkActivity") {
14+
it.name == "onCreate"
15+
}.hookAfter {
16+
hook?.unhook()
17+
EzXHelperInit.initAppContext()
18+
Log.toast("模块加载成功!")
19+
}
20+
}
21+
}

0 commit comments

Comments
 (0)