Skip to content

Commit

Permalink
Option to filter tracker only Dex Classes
Browse files Browse the repository at this point in the history
  • Loading branch information
Hamza417 committed Dec 22, 2024
1 parent 21fdf12 commit 57c3703
Showing 1 changed file with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package app.simple.inure.viewmodels.viewers

import android.app.Application
import android.content.pm.PackageInfo
import android.util.Log
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.viewModelScope
import app.simple.inure.extensions.viewmodels.WrappedViewModel
Expand Down Expand Up @@ -63,7 +62,6 @@ class DexDataViewModel(application: Application, private val packageInfo: Packag
private fun getClassesOfPackage(packageName: String): ArrayList<String> {
val appContext = applicationContext().createPackageContext(packageName, 0)
val packageCodePath: String = appContext.packageCodePath
Log.d("DexDataViewModel", "Package code path: $packageCodePath")
val dexFile = DexFile(packageCodePath)
val enumeration = dexFile.entries()

Expand All @@ -78,20 +76,24 @@ class DexDataViewModel(application: Application, private val packageInfo: Packag
fun filterClasses(query: String) {
viewModelScope.launch(Dispatchers.Default) {
runCatching {
if (query.isEmpty()) {
val filteredClasses = ArrayList<DexClass>()

for (dexClass in backup) {
if (dexClass.className.lowercase().contains(query.lowercase(), true)) {
filteredClasses.add(dexClass)
}
if (query.isNotEmpty()) {
if (TRACKER.contains(query.lowercase())) {
dexData.postValue(ArrayList(backup.filter {
it.isTracker
}))
} else {
dexData.postValue(ArrayList(backup.filter {
it.className.lowercase().contains(query.lowercase(), true)
}))
}

dexData.postValue(filteredClasses)
} else {
dexData.postValue(backup)
}
}
}
}

companion object {
private val TRACKER = arrayOf("tracker", "trackers")
}
}

0 comments on commit 57c3703

Please sign in to comment.