Skip to content
This repository has been archived by the owner on Sep 15, 2024. It is now read-only.

Commit

Permalink
Migrate project codebase to Kotlin (#34)
Browse files Browse the repository at this point in the history
* Rename .java to .kt

* refactor: migrate util classes to kotlin

* chore: bump version

* fix: unable to open file

* refactor: add JvmField annotation to XposedContext

* Rename .java to .kt

* Migrate widgets to Kotlin

* Revert TbToast

* Rename .java to .kt

* Partially migrate DAO to Kotlin

* Rename .java to .kt

* Migrate Adp to Kotlin

* Revert "Revert TbToast"

This reverts commit 4e983d6.

* Add findRule function for Kotlin

* Convert property to getter functions

* Add helper hook functions

* Rename .java to .kt

* Migrate HistoryCache to Kotlin

* Rename .java to .kt

* Migrate Ripple to Kotlin

* Rename .java to .kt

* Migrate SaveImages to Kotlin

* Rename .java to .kt

* Migrate SelectClipboard to Kotlin

* Rename .java to .kt

* Migrate AgreeNum to Kotlin

* Rename .java to .kt

* Migrate AutoSign to Kotlin

* Change version name to alpha

* Rename .java to .kt

* Migrate FrsTab to Kotlin

* Add findClass helper function

* Rename .java to .kt

* Migrate MsgCenterTab to Kotlin

* Rename .java to .kt

* Migrate NotificationDetect to Kotlin

* Rename .java to .kt

* Migrate OpenSign to Kotlin

* Add installDebug task to gradle

* Add unhook to helper functions

* Rename .java to .kt

* Migrate OriginSrc to Kotlin

* Rename .java to .kt

* Migrate ContentFilter to Kotlin

* Rename .java to .kt

* Migrate FoldTopCardView to Kotlin

* Rename .java to .kt

* Migrate FollowFilter to Kotlin

* Rename .java to .kt

* Migrate FragmentTab to Kotlin

* Rename .java to .kt

* Migrate FrsPageFilter to Kotlin

* Rename .java to .kt

* Migrate PersonalizedFilter to Kotlin

* Rename .java to .kt

* Migrate PurgeEnter to Kotlin

* Rename .java to .kt

* Migrate PurgeMy to Kotlin

* Rename .java to .kt

* Migrate PurgeVideo to Kotlin

* Rename .java to .kt

* Migrate RedTip to Kotlin

* Rename .java to .kt

* Migrate RemoveUpdate to Kotlin

* Rename .java to .kt

* Migrate UserFilter to Kotlin

* Rename .java to .kt

* Migrate RegexFilter to Kotlin

* Convert property to getter functions in Switch

* Update page filter logic

* Rename .java to .kt

* Migrate Purge to Kotlin

* Rename .java to .kt

* Migrate Deobfuscation to Kotlin

* Rename .java to .kt

* Migrate TransitionAnimation to Kotlin

* Rename .java to .kt

* Migrate ForbidGesture to Kotlin

* Rename .java to .kt

* Migrate IHooker and Obfuscated to Kotlin

* Update AGP

* Rename .java to .kt

* Migrate TSPreferenceHelper to Kotlin

* Extract getDialogTheme to separate function

* Rename .java to .kt

* Migrate TSPreference to Kotlin

* Rename .java to .kt

* Migrate XposedInit to Kotlin

* Optimize imports

* Optimize variable naming

* Optimize imports

* Migrate build.gradle to Kotlin

* Update Purge rules

* Remove project wide build.gradle.kts

* Move isModuleBetaVersion to XposedContext

* Bump version

* Simplify matcher logic

* General style improvements

* Fix incorrect button color when skin changed

* Remove key file

* Improve style and null handling
  • Loading branch information
mkx173 authored May 5, 2024
1 parent 802ef21 commit 2916851
Show file tree
Hide file tree
Showing 105 changed files with 4,868 additions and 5,111 deletions.
88 changes: 0 additions & 88 deletions app/build.gradle

This file was deleted.

119 changes: 119 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
import java.io.ByteArrayOutputStream

plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
id("com.google.devtools.ksp")
}

fun String.runCommand(currentWorkingDir: File = file("./")): String {
val byteOut = ByteArrayOutputStream()
project.exec {
workingDir = currentWorkingDir
commandLine = this@runCommand.split("\\s".toRegex())
standardOutput = byteOut
}
return String(byteOut.toByteArray()).trim()
}

val gitCommitCount = "git rev-list --count HEAD".runCommand().toInt()
val latestTag = "git describe --abbrev=0 --tags".runCommand()
val commitCountSinceLatestTag = ("git rev-list --count $latestTag..HEAD").runCommand()
val sdk = 34

android {
compileSdk = sdk
buildToolsVersion = "34.0.0"
ndkVersion = "26.0.10792818"

defaultConfig {
applicationId = "gm.tieba.tabswitch"
minSdk = 28
targetSdk = sdk
versionCode = gitCommitCount
versionName = "3.0.0-beta"
if (versionName!!.contains("alpha") || versionName!!.contains("beta")) {
versionNameSuffix = ".$commitCountSinceLatestTag"
}
buildConfigField("String", "TARGET_VERSION", "\"12.60.1.1\"")
buildConfigField("String", "MIN_VERSION", "\"12.53.1.0\"")

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
externalNativeBuild {
cmake {
abiFilters("arm64-v8a")
arguments("-DANDROID_STL=none")
}
}
}
applicationVariants.all {
outputs
.map { it as com.android.build.gradle.internal.api.ApkVariantOutputImpl }
.all { output ->
output.outputFileName = "TS_${defaultConfig.versionName}${defaultConfig.versionNameSuffix ?: ""}_${name}.apk"
false
}
}
buildTypes {
release {
isMinifyEnabled = true
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
externalNativeBuild {
cmake {
path("src/main/cpp/CMakeLists.txt")
}
}
packaging {
resources.excludes.addAll(listOf("/META-INF/**", "/kotlin/**", "/okhttp3/**"))
jniLibs.excludes.addAll(listOf("**/liblog.so", "/lib/x86/**", "/lib/x86_64/**"))
}
buildFeatures {
prefab = true
buildConfig = true
}
lint {
checkDependencies = true
}
namespace = "gm.tieba.tabswitch"
}

dependencies {
compileOnly("de.robv.android.xposed:api:82")
api("androidx.annotation:annotation:1.7.1")

val roomVersion = "2.6.1"
implementation("androidx.room:room-runtime:$roomVersion")
annotationProcessor("androidx.room:room-compiler:$roomVersion")
implementation("androidx.room:room-ktx:$roomVersion")
ksp("androidx.room:room-compiler:$roomVersion")

implementation("io.reactivex.rxjava3:rxjava:3.1.8")
implementation("org.luckypray:dexkit:2.0.1")
implementation("com.squareup.okhttp3:okhttp:4.12.0")
implementation("dev.rikka.ndk.thirdparty:cxx:1.2.0")
}

val adbExecutable: String = androidComponents.sdkComponents.adb.get().asFile.absolutePath

tasks.register("restartTieba") {
doLast {
exec {
commandLine(adbExecutable, "shell", "am", "force-stop", "com.baidu.tieba")
}
exec {
commandLine(adbExecutable, "shell", "am", "start", "$(pm resolve-activity --components com.baidu.tieba)")
}
}
}

afterEvaluate {
tasks.named("installDebug").configure {
finalizedBy(tasks.named("restartTieba"))
}
}
1 change: 0 additions & 1 deletion app/gm.jks.base64.txt

This file was deleted.

1 change: 0 additions & 1 deletion app/src/main/java/gm/tieba/tabswitch/Constants.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package gm.tieba.tabswitch

object Constants {
@JvmStatic
val strings = mapOf(
"EULA" to "如果您对本协议的任何条款表示异议,您可以选择不使用本模块;使用本模块则意味着您已完全理解和同意遵守本协议。\n\n" +
" ①本模块开源免费,所有版本均为自动构建,可确保构建版本与源代码一致。对本模块的任何异议都必须以源代码为依据。\n" +
Expand Down
60 changes: 0 additions & 60 deletions app/src/main/java/gm/tieba/tabswitch/XposedContext.java

This file was deleted.

Loading

0 comments on commit 2916851

Please sign in to comment.