Build99.1.0

- Debloat rev08
    - Added loader in header
This commit is contained in:
Hamza417
2024-01-28 10:04:02 +05:30
parent ff4e6a18e5
commit 19b9da4114
6 changed files with 49 additions and 20 deletions

View File

@ -2,9 +2,9 @@ name: Copy UAD File
on:
workflow_dispatch: # Allow manual triggering
push:
paths:
- 'resources/assets/uad_lists.json'
## Run the file every day at 00:00 UTC
schedule:
- cron: "0 0 * * *"
jobs:
copy_file:

View File

@ -11,6 +11,7 @@ import app.simple.inure.decorations.ripple.DynamicRippleConstraintLayout
import app.simple.inure.decorations.toggles.CheckBox
import app.simple.inure.decorations.typeface.TypeFaceTextView
import app.simple.inure.decorations.views.AppIconImageView
import app.simple.inure.decorations.views.CustomProgressBar
import app.simple.inure.enums.Removal
import app.simple.inure.glide.util.ImageLoader.loadAppIcon
import app.simple.inure.models.Bloat
@ -24,6 +25,7 @@ import app.simple.inure.util.StringUtils.appendFlag
class AdapterDebloat(private val bloats: ArrayList<Bloat>) : RecyclerView.Adapter<VerticalListViewHolder>() {
private var adapterDebloatCallback: AdapterDebloatCallback? = null
private var isLoading = false
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): VerticalListViewHolder {
return when (viewType) {
@ -65,6 +67,12 @@ class AdapterDebloat(private val bloats: ArrayList<Bloat>) : RecyclerView.Adapte
}
}
is Header -> {
if (isLoading) {
holder.loader.visibility = View.VISIBLE
} else {
holder.loader.visibility = View.GONE
}
holder.total.text = holder.total.context.getString(R.string.total_apps, bloats.size.toString())
holder.uadSubtitle.setOnClickListener {
UAD_REPO_LINK.asUri().openInBrowser(holder.uadSubtitle.context)
@ -131,6 +139,7 @@ class AdapterDebloat(private val bloats: ArrayList<Bloat>) : RecyclerView.Adapte
val uadSubtitle: TypeFaceTextView = itemView.findViewById(R.id.uad_subtitle)
val category: TypeFaceTextView = itemView.findViewById(R.id.adapter_header_category)
val sorting: TypeFaceTextView = itemView.findViewById(R.id.adapter_header_sorting)
val loader: CustomProgressBar = itemView.findViewById(R.id.loader)
}
fun setAdapterDebloatCallback(adapterDebloatCallback: AdapterDebloatCallback) {
@ -147,6 +156,11 @@ class AdapterDebloat(private val bloats: ArrayList<Bloat>) : RecyclerView.Adapte
return false
}
fun setLoading(isLoading: Boolean) {
this.isLoading = isLoading
notifyItemChanged(0)
}
private fun TypeFaceTextView.setBloatFlags(bloat: Bloat) {
text = buildString {
// State

View File

@ -21,7 +21,8 @@ import app.simple.inure.viewmodels.panels.DebloatViewModel
class Debloat : ScopedFragment() {
private lateinit var recyclerView: CustomVerticalRecyclerView
private lateinit var debloatViewModel: DebloatViewModel
private var debloatViewModel: DebloatViewModel? = null
private var adapterDebloat: AdapterDebloat? = null
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val view = inflater.inflate(R.layout.fragment_debloat, container, false)
@ -37,12 +38,12 @@ class Debloat : ScopedFragment() {
fullVersionCheck()
postponeEnterTransition()
debloatViewModel.getBloatList().observe(viewLifecycleOwner) {
val adapterDebloat = AdapterDebloat(it)
debloatViewModel?.getBloatList()?.observe(viewLifecycleOwner) {
adapterDebloat = AdapterDebloat(it)
adapterDebloat.setAdapterDebloatCallback(object : AdapterDebloat.Companion.AdapterDebloatCallback {
adapterDebloat!!.setAdapterDebloatCallback(object : AdapterDebloat.Companion.AdapterDebloatCallback {
override fun onBloatSelected(bloat: Bloat) {
bottomRightCornerMenu?.updateBottomMenu(BottomMenuConstants.getDebloatMenu(adapterDebloat.isAnyItemSelected()))
bottomRightCornerMenu?.updateBottomMenu(BottomMenuConstants.getDebloatMenu(adapterDebloat!!.isAnyItemSelected()))
}
override fun onBloatLongPressed(bloat: Bloat) {
@ -56,13 +57,14 @@ class Debloat : ScopedFragment() {
startPostponedEnterTransition()
}
bottomRightCornerMenu?.initBottomMenuWithRecyclerView(BottomMenuConstants.getDebloatMenu(adapterDebloat.isAnyItemSelected()), recyclerView) { id, _ ->
bottomRightCornerMenu?.initBottomMenuWithRecyclerView(
BottomMenuConstants.getDebloatMenu(adapterDebloat!!.isAnyItemSelected()), recyclerView) { id, _ ->
when (id) {
R.drawable.ic_delete -> {
// TODO - Delete
}
R.drawable.ic_refresh -> {
debloatViewModel.refreshBloatList()
debloatViewModel?.refreshBloatList()
}
R.drawable.ic_filter -> {
childFragmentManager.showDebloatFilter()
@ -87,7 +89,8 @@ class Debloat : ScopedFragment() {
DebloatPreferences.sort,
DebloatPreferences.state,
DebloatPreferences.sortingStyle -> {
debloatViewModel.refreshBloatList()
adapterDebloat?.setLoading(true)
debloatViewModel?.refreshBloatList()
}
}
}

View File

@ -37,11 +37,13 @@ class DebloatViewModel(application: Application) : PackageUtilsViewModel(applica
val apps = getInstalledApps() + getUninstalledApps()
var bloats = ArrayList<Bloat>()
uadList.forEach { (id, bloat) ->
apps.forEach { app ->
if (app.packageName == id) {
bloat.packageInfo = app
bloats.add(bloat)
uadList.parallelStream().forEach { bloat ->
synchronized(bloats) {
apps.forEach { app ->
if (app.packageName == bloat.id) {
bloat.packageInfo = app
bloats.add(bloat)
}
}
}
}
@ -91,7 +93,7 @@ class DebloatViewModel(application: Application) : PackageUtilsViewModel(applica
* "removal": "Recommended"
* },
*/
private fun getUADList(): HashMap<String, Bloat> {
private fun getUADList(): ArrayList<Bloat> {
val bufferedReader = BufferedReader(InputStreamReader(DebloatViewModel::class.java.getResourceAsStream(UAD_FILE_NAME)))
val stringBuilder = StringBuilder()
var line: String?
@ -102,7 +104,7 @@ class DebloatViewModel(application: Application) : PackageUtilsViewModel(applica
val json = stringBuilder.toString()
val jsonArray = org.json.JSONArray(json)
val bloats = hashMapOf<String, Bloat>()
val bloats = arrayListOf<Bloat>()
for (i in 0 until jsonArray.length()) {
val jsonObject = jsonArray.getJSONObject(i)
@ -135,7 +137,7 @@ class DebloatViewModel(application: Application) : PackageUtilsViewModel(applica
bloat.labels.add(labels.getString(j))
}
bloats[id] = bloat
bloats.add(bloat)
}
return bloats

View File

@ -61,6 +61,16 @@
</LinearLayout>
<app.simple.inure.decorations.views.CustomProgressBar
android:id="@+id/loader"
style="?android:attr/progressBarStyleSmall"
android:layout_width="@dimen/button_size"
android:layout_height="@dimen/button_size"
android:layout_gravity="center_vertical"
android:indeterminateTint="?attr/colorAppAccent"
android:padding="10dp"
android:visibility="invisible" />
</LinearLayout>
<LinearLayout

View File

@ -8,7 +8,7 @@ buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:8.2.2'
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.0'
classpath 'com.autonomousapps:dependency-analysis-gradle-plugin:1.28.0'
classpath 'com.autonomousapps:dependency-analysis-gradle-plugin:1.18.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files