Skip to content

Commit

Permalink
Add toggle to clear persistent search states
Browse files Browse the repository at this point in the history
  • Loading branch information
Hamza417 committed May 31, 2024
1 parent adefda3 commit b52bee9
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 0 deletions.
9 changes: 9 additions & 0 deletions app/src/github/java/app/simple/inure/ui/panels/Debloat.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ import app.simple.inure.dialogs.miscellaneous.PackageStateResult.Companion.showP
import app.simple.inure.extensions.fragments.ScopedFragment
import app.simple.inure.models.Bloat
import app.simple.inure.preferences.DebloatPreferences
import app.simple.inure.preferences.DevelopmentPreferences
import app.simple.inure.ui.subpanels.DebloatChecklist
import app.simple.inure.ui.subpanels.DebloatSearch
import app.simple.inure.util.IntentHelper.asUri
import app.simple.inure.util.IntentHelper.openInBrowser
import app.simple.inure.util.NullSafety.isNotNull
import app.simple.inure.util.StringUtils.emptyString
import app.simple.inure.viewmodels.panels.DebloatViewModel

class Debloat : ScopedFragment() {
Expand All @@ -48,6 +50,7 @@ class Debloat : ScopedFragment() {
super.onViewCreated(view, savedInstanceState)
fullVersionCheck()
postponeEnterTransition()
clearSearchState()

if (debloatViewModel?.shouldShowLoader() == true) {
showLoader(manualOverride = true)
Expand Down Expand Up @@ -153,6 +156,12 @@ class Debloat : ScopedFragment() {
bottomRightCornerMenu?.updateBottomMenu(BottomMenuConstants.getDebloatMenu(adapterDebloat!!.isAnyItemSelected()))
}

private fun clearSearchState() {
if (DevelopmentPreferences.get(DevelopmentPreferences.CLEAR_SEARCH_STATE)) {
DebloatPreferences.setSearchKeyword(emptyString())
}
}

@SuppressLint("NotifyDataSetChanged")
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) {
super.onSharedPreferenceChanged(sharedPreferences, key)
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/assets/html/changelogs.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ <h1>Change Logs</h1>
<sub>(Current Version)</sub>
<h2>Build100.6.2</h2>

<h4>User Interface</h4>

<ul>
<li>Added toggle to clear persistent search states.
<br>
<small>Can be toggled in <b>Development Preferences</b>.</small>
</li>
</ul>

<h4>Bug Fixes</h4>

<ul>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ object DevelopmentPreferences {
const val usePeristyleInterface = "is_felicity_flow_interface_enabled"
const val useCorrespondingColorOnHighlight = "is_corresponding_color_on_highlight_enabled"
const val USE_BLUR_BETWEEN_PANELS = "is_blur_between_panels_enabled"
const val CLEAR_SEARCH_STATE = "clear_search_state"

val developmentPreferences: List<DevelopmentPreferencesModel> by lazy {
listOf(
Expand Down Expand Up @@ -198,6 +199,11 @@ object DevelopmentPreferences {
"Use blur effects while switching between panels in the app. It's available in" +
" Android 12+ only. Highly unstable, please use it with caution and on your own discretion.",
USE_BLUR_BETWEEN_PANELS,
DevelopmentPreferencesModel.TYPE_BOOLEAN),

DevelopmentPreferencesModel("Clear Search State",
"Clear various search states everytime app is launched.",
CLEAR_SEARCH_STATE,
DevelopmentPreferencesModel.TYPE_BOOLEAN)

// DevelopmentPreferencesModel("Enable Fancy Drag in Switch",
Expand Down
13 changes: 13 additions & 0 deletions app/src/main/java/app/simple/inure/ui/launcher/SplashScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,20 @@ import app.simple.inure.decorations.typeface.TypeFaceTextView
import app.simple.inure.decorations.views.LoaderImageView
import app.simple.inure.extensions.fragments.ScopedFragment
import app.simple.inure.preferences.AccessibilityPreferences
import app.simple.inure.preferences.ApkBrowserPreferences
import app.simple.inure.preferences.BehaviourPreferences
import app.simple.inure.preferences.ConfigurationPreferences
import app.simple.inure.preferences.DevelopmentPreferences
import app.simple.inure.preferences.MainPreferences
import app.simple.inure.preferences.MusicPreferences
import app.simple.inure.preferences.SearchPreferences
import app.simple.inure.preferences.SetupPreferences
import app.simple.inure.preferences.TrialPreferences
import app.simple.inure.services.DataLoaderService
import app.simple.inure.ui.panels.Home
import app.simple.inure.util.AppUtils
import app.simple.inure.util.ConditionUtils.invert
import app.simple.inure.util.StringUtils.emptyString
import app.simple.inure.util.ViewUtils.gone
import app.simple.inure.viewmodels.panels.ApkBrowserViewModel
import app.simple.inure.viewmodels.panels.AppsViewModel
Expand Down Expand Up @@ -97,6 +101,7 @@ class SplashScreen : ScopedFragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
startPostponedEnterTransition()
clearSearchStates()

intentFilter.addAction(DataLoaderService.APPS_LOADED)
intentFilter.addAction(DataLoaderService.UNINSTALLED_APPS_LOADED)
Expand Down Expand Up @@ -423,6 +428,14 @@ class SplashScreen : ScopedFragment() {
}
}

private fun clearSearchStates() {
if (DevelopmentPreferences.get(DevelopmentPreferences.CLEAR_SEARCH_STATE)) {
SearchPreferences.setLastSearchKeyword(emptyString())
ApkBrowserPreferences.setSearchKeyword(emptyString())
MusicPreferences.setSearchKeyword(emptyString())
}
}

override fun onResume() {
super.onResume()
LocalBroadcastManager.getInstance(requireContext()).registerReceiver(broadcastReceiver!!, intentFilter)
Expand Down

0 comments on commit b52bee9

Please sign in to comment.