Skip to content

Commit

Permalink
Refactor searchable fragments
Browse files Browse the repository at this point in the history
Signed-off-by: DrDisagree <[email protected]>
  • Loading branch information
Mahmud0808 committed Sep 5, 2024
1 parent 8c08138 commit ebbda01
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 26 deletions.
44 changes: 19 additions & 25 deletions app/src/main/java/com/drdisagree/iconify/common/Resources.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.drdisagree.iconify.common

import android.os.Build
import android.os.Environment
import com.drdisagree.iconify.BuildConfig
import com.drdisagree.iconify.Iconify.Companion.appContext
Expand Down Expand Up @@ -106,7 +107,19 @@ object Resources {

val searchConfiguration = SearchConfiguration()

private val commonFragments = arrayOf(
val searchableFragments = arrayOf(
SearchPreferenceItem(
R.xml.home,
R.string.navbar_home,
Home(),
!Preferences.isXposedOnlyMode
),
SearchPreferenceItem(
R.xml.tweaks,
R.string.navbar_tweaks,
Tweaks(),
!Preferences.isXposedOnlyMode
),
SearchPreferenceItem(
R.xml.xposed,
R.string.navbar_xposed,
Expand Down Expand Up @@ -152,15 +165,11 @@ object Resources {
R.string.activity_title_volume_panel,
VolumePanel()
),
SearchPreferenceItem(
R.xml.xposed_volume_panel,
R.string.activity_title_volume_panel,
VolumePanel()
),
SearchPreferenceItem(
R.xml.xposed_op_qs_header,
R.string.activity_title_op_qs_header,
OpQsHeader()
OpQsHeader(),
Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE
),
SearchPreferenceItem(
R.xml.xposed_header_clock,
Expand Down Expand Up @@ -192,22 +201,7 @@ object Resources {
R.string.activity_title_xposed_others,
Others()
)
)

val searchableFragments = if (Preferences.isXposedOnlyMode) {
commonFragments
} else {
arrayOf(
SearchPreferenceItem(
R.xml.home,
R.string.navbar_home,
Home()
),
SearchPreferenceItem(
R.xml.tweaks,
R.string.navbar_tweaks,
Tweaks()
)
) + commonFragments
}.distinctBy { it.fragment::class.java }
).filter { it.shouldAdd }
.distinctBy { it.fragment::class.java }
.toTypedArray()
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ import com.drdisagree.iconify.ui.base.ControlledPreferenceFragmentCompat
class SearchPreferenceItem(
@field:XmlRes val xml: Int,
@field:StringRes val title: Int,
val fragment: ControlledPreferenceFragmentCompat
val fragment: ControlledPreferenceFragmentCompat,
val shouldAdd: Boolean = true
)

0 comments on commit ebbda01

Please sign in to comment.