Skip to content

Commit

Permalink
feat(#103): make hidden apps findable with search (#130)
Browse files Browse the repository at this point in the history
Co-authored-by: Joshua Kuestersteffen <[email protected]>
  • Loading branch information
JuanJakobo and jkuester authored Dec 26, 2023
1 parent a93a67a commit 4b25d7e
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,10 @@ class AppDrawerAdapter(

private fun updateFilteredApps(filterQuery: String = "") {
val showDrawerHeadings = corePreferencesRepo.get().showDrawerHeadings
val searchAllApps = corePreferencesRepo.get().searchAllAppsInDrawer && filterQuery != ""
val displayableApps = apps
.filter { app ->
app.displayInDrawer && regex.replace(app.displayName, "")
(app.displayInDrawer || searchAllApps) && regex.replace(app.displayName, "")
.contains(filterQuery, ignoreCase = true)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,12 @@ class CorePreferencesRepository(
}
}
}

fun updateSearchAllAppsInDrawer(searchAllAppsInDrawer: Boolean) {
lifecycleScope.launch {
corePreferencesStore.updateData {
it.toBuilder().setSearchAllAppsInDrawer(searchAllAppsInDrawer).build()
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import kotlinx.android.synthetic.main.customize_app_drawer_fragment_search_field
import kotlinx.android.synthetic.main.customize_app_drawer_fragment_search_field_options.customize_app_drawer_fragment_search_field_position
import kotlinx.android.synthetic.main.customize_app_drawer_fragment_search_field_options.customize_app_drawer_fragment_show_search_field_switch
import kotlinx.android.synthetic.main.customize_app_drawer_fragment_search_field_options.customize_app_drawer_open_keyboard_switch
import kotlinx.android.synthetic.main.customize_app_drawer_fragment_search_field_options.customize_app_drawer_search_all_switch

import javax.inject.Inject

Expand Down Expand Up @@ -42,6 +43,7 @@ class CustomizeSearchFieldFragment : BaseFragment() {
setupShowSearchBarSwitch()
setupSearchBarPositionOption()
setupKeyboardSwitch()
setupSearchAllAppsSwitch()
}

private fun setupShowSearchBarSwitch() {
Expand Down Expand Up @@ -91,4 +93,19 @@ class CustomizeSearchFieldFragment : BaseFragment() {
R.string.customize_app_drawer_fragment_open_keyboard_subtitle
)
}

private fun setupSearchAllAppsSwitch() {
val prefsRepo = unlauncherDataSource.corePreferencesRepo
customize_app_drawer_search_all_switch.setOnCheckedChangeListener { _, checked ->
prefsRepo.updateSearchAllAppsInDrawer(checked)
}
prefsRepo.liveData().observe(viewLifecycleOwner) {
customize_app_drawer_search_all_switch.isChecked = it.searchAllAppsInDrawer
}
customize_app_drawer_search_all_switch.text =
createTitleAndSubtitleText(
requireContext(), R.string.customize_app_drawer_fragment_search_all,
R.string.customize_app_drawer_fragment_search_all_subtitle
)
}
}
1 change: 1 addition & 0 deletions app/src/main/proto/core_preferences.proto
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ message CorePreferences {
optional bool show_search_bar = 3;
SearchBarPosition search_bar_position = 4;
bool show_drawer_headings = 5;
bool search_all_apps_in_drawer = 6;
}

enum SearchBarPosition {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,16 @@
android:textSize="@dimen/_20ssp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/customize_app_drawer_fragment_search_field_position" />

<androidx.appcompat.widget.SwitchCompat
android:id="@+id/customize_app_drawer_search_all_switch"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:layout_marginBottom="32dp"
android:text="@string/customize_app_drawer_fragment_search_all"
android:textAppearance="@style/TextAppearance.AppCompat"
android:textSize="@dimen/font_size_customize_options"
app:layout_constraintTop_toBottomOf="@id/customize_app_drawer_open_keyboard_switch"
app:layout_constraintStart_toStartOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>
1 change: 1 addition & 0 deletions app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
<item>Unten</item>
</string-array>
<string name="customize_app_drawer_fragment_open_keyboard">Tastatur anzeigen</string>
<string name="customize_app_drawer_fragment_search_all">Suche in allen Apps</string>
<string name="customize_app_drawer_fragment_visible_apps">Appsichtbarkeit einstellen</string>
<string name="customize_app_drawer_fragment_auto_theme_wallpaper_text">Themenhintergrund verwenden</string>
<string name="customize_app_drawer_fragment_auto_theme_wallpaper_subtext_no_default_launcher">Unlauncher muss die standard Start-App sein</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@
<string name="options_fragment_hide_status_bar">Hide Status Bar</string>
<string name="options_fragment_show_status_bar">Show Status Bar</string>
<string name="customize_app_drawer_fragment_open_keyboard">Open Keyboard</string>
<string name="customize_app_drawer_fragment_search_all">Search all apps</string>
<string name="customize_app_drawer_fragment_search_all_subtitle">Hidden apps can be found when searching</string>
<string name="customize_app_drawer_fragment_auto_theme_wallpaper_text">Set theme background as wallpaper</string>
<string name="customize_app_drawer_fragment_auto_theme_wallpaper_subtext_no_default_launcher">App needs to be default launcher</string>
<string name="customize_app_drawer_fragment_visible_apps">Visible Apps</string>
Expand Down

0 comments on commit 4b25d7e

Please sign in to comment.