Close app drawer when opening another app

This commit is contained in:
Ensar Sarajčić 2023-07-26 16:54:33 +02:00
parent 2fefcf0cba
commit 5c7ad336ad
5 changed files with 23 additions and 21 deletions

View File

@ -195,16 +195,6 @@ class MainActivity : SimpleActivity(), FlingListener {
home_screen_grid.appWidgetHost.startListening()
}
override fun onTopResumedActivityChanged(isTopResumedActivity: Boolean) {
super.onTopResumedActivityChanged(isTopResumedActivity)
if (!isTopResumedActivity && config.alwaysNavigateToHomeScreen) {
Handler(mainLooper).postDelayed({
hideFragment(all_apps_fragment)
hideFragment(widgets_fragment)
}, 1000L)
}
}
override fun onResume() {
super.onResume()
updateStatusbarColor(Color.TRANSPARENT)
@ -493,6 +483,12 @@ class MainActivity : SimpleActivity(), FlingListener {
}
}
fun closeAppDrawer() {
if (isAllAppsFragmentExpanded()) {
hideFragment(all_apps_fragment)
}
}
private fun performItemClick(clickedGridItem: HomeScreenGridItem) {
if (clickedGridItem.type == ITEM_TYPE_ICON) {
launchApp(clickedGridItem.packageName, clickedGridItem.activityName)

View File

@ -38,7 +38,7 @@ class SettingsActivity : SimpleActivity() {
setupPurchaseThankYou()
setupCustomizeColors()
setupUseEnglish()
setupAlwaysNavigateToHomeScreen()
setupCloseAppDrawerOnOtherAppOpen()
setupDrawerColumnCount()
setupDrawerSearchBar()
setupHomeRowCount()
@ -47,7 +47,12 @@ class SettingsActivity : SimpleActivity() {
setupManageHiddenIcons()
updateTextColors(settings_holder)
arrayOf(settings_color_customization_section_label, settings_general_settings_label, settings_drawer_settings_label, settings_home_screen_label).forEach {
arrayOf(
settings_color_customization_section_label,
settings_general_settings_label,
settings_drawer_settings_label,
settings_home_screen_label
).forEach {
it.setTextColor(getProperPrimaryColor())
}
}
@ -93,11 +98,11 @@ class SettingsActivity : SimpleActivity() {
}
}
private fun setupAlwaysNavigateToHomeScreen() {
settings_navigate_to_home_grid_on_home.isChecked = config.alwaysNavigateToHomeScreen
settings_navigate_to_home_grid_on_home_holder.setOnClickListener {
settings_navigate_to_home_grid_on_home.toggle()
config.alwaysNavigateToHomeScreen = settings_navigate_to_home_grid_on_home.isChecked
private fun setupCloseAppDrawerOnOtherAppOpen() {
settings_close_app_drawer_on_other_app.isChecked = config.closeAppDrawer
settings_close_app_drawer_on_other_app_holder.setOnClickListener {
settings_close_app_drawer_on_other_app.toggle()
config.closeAppDrawer = settings_close_app_drawer_on_other_app.isChecked
}
}

View File

@ -120,6 +120,7 @@ class AllAppsFragment(context: Context, attributeSet: AttributeSet) : MyFragment
if (currAdapter == null) {
LaunchersAdapter(activity!!, launchers, this) {
activity?.launchApp((it as AppLauncher).packageName, it.activityName)
activity?.closeAppDrawer()
ignoreTouches = false
touchDownY = -1
}.apply {

View File

@ -29,7 +29,7 @@ class Config(context: Context) : BaseConfig(context) {
get() = prefs.getBoolean(SHOW_SEARCH_BAR, true)
set(showSearchBar) = prefs.edit().putBoolean(SHOW_SEARCH_BAR, showSearchBar).apply()
var alwaysNavigateToHomeScreen: Boolean
get() = prefs.getBoolean(ALWAYS_NAVIGATE_TO_HOME_SCREEN, true)
set(alwaysNavigateToHomeScreen) = prefs.edit().putBoolean(ALWAYS_NAVIGATE_TO_HOME_SCREEN, alwaysNavigateToHomeScreen).apply()
var closeAppDrawer: Boolean
get() = prefs.getBoolean(CLOSE_APP_DRAWER, true)
set(closeAppDrawer) = prefs.edit().putBoolean(CLOSE_APP_DRAWER, closeAppDrawer).apply()
}

View File

@ -9,7 +9,7 @@ const val HOME_ROW_COUNT = "home_row_count"
const val HOME_COLUMN_COUNT = "home_column_count"
const val DRAWER_COLUMN_COUNT = "drawer_column_count"
const val SHOW_SEARCH_BAR = "show_search_bar"
const val ALWAYS_NAVIGATE_TO_HOME_SCREEN = "always_navigate_to_home_screen"
const val CLOSE_APP_DRAWER = "close_app_drawer"
// default home screen grid size
const val ROW_COUNT = 6