|
@@ -5,19 +5,12 @@ import android.view.LayoutInflater
|
|
|
import android.view.View
|
|
import android.view.View
|
|
|
import android.view.ViewGroup
|
|
import android.view.ViewGroup
|
|
|
import com.simplauncher.R
|
|
import com.simplauncher.R
|
|
|
|
|
+import com.simplauncher.databinding.CustomizeAppDrawerFragmentSearchFieldOptionsBinding
|
|
|
import com.simplauncher.datasource.UnlauncherDataSource
|
|
import com.simplauncher.datasource.UnlauncherDataSource
|
|
|
import com.simplauncher.ui.dialogs.ChooseSearchBarPositionDialog
|
|
import com.simplauncher.ui.dialogs.ChooseSearchBarPositionDialog
|
|
|
import com.simplauncher.utils.BaseFragment
|
|
import com.simplauncher.utils.BaseFragment
|
|
|
import com.simplauncher.utils.createTitleAndSubtitleText
|
|
import com.simplauncher.utils.createTitleAndSubtitleText
|
|
|
import dagger.hilt.android.AndroidEntryPoint
|
|
import dagger.hilt.android.AndroidEntryPoint
|
|
|
-import kotlinx.android.synthetic.main.customize_app_drawer_fragment_search_field_options.customise_apps_fragment_back
|
|
|
|
|
-import kotlinx.android.synthetic.main.customize_app_drawer_fragment_search_field_options.customize_app_drawer_fragment_search_field_options
|
|
|
|
|
-
|
|
|
|
|
-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
|
|
import javax.inject.Inject
|
|
|
|
|
|
|
|
@AndroidEntryPoint
|
|
@AndroidEntryPoint
|
|
@@ -26,22 +19,24 @@ class CustomizeSearchFieldFragment : BaseFragment() {
|
|
|
@Inject
|
|
@Inject
|
|
|
lateinit var unlauncherDataSource: UnlauncherDataSource
|
|
lateinit var unlauncherDataSource: UnlauncherDataSource
|
|
|
|
|
|
|
|
- override fun getFragmentView(): ViewGroup = customize_app_drawer_fragment_search_field_options
|
|
|
|
|
|
|
+ private var _binding: CustomizeAppDrawerFragmentSearchFieldOptionsBinding? = null
|
|
|
|
|
+ private val binding get() = _binding!!
|
|
|
|
|
+
|
|
|
|
|
+ override fun getFragmentView(): ViewGroup = binding.customizeAppDrawerFragmentSearchFieldOptions
|
|
|
|
|
|
|
|
override fun onCreateView(
|
|
override fun onCreateView(
|
|
|
inflater: LayoutInflater,
|
|
inflater: LayoutInflater,
|
|
|
container: ViewGroup?,
|
|
container: ViewGroup?,
|
|
|
savedInstanceState: Bundle?
|
|
savedInstanceState: Bundle?
|
|
|
- ): View? = inflater.inflate(
|
|
|
|
|
- R.layout.customize_app_drawer_fragment_search_field_options,
|
|
|
|
|
- container,
|
|
|
|
|
- false
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ ): View {
|
|
|
|
|
+ _binding = CustomizeAppDrawerFragmentSearchFieldOptionsBinding.inflate(inflater, container, false)
|
|
|
|
|
+ return binding.root
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
|
|
super.onViewCreated(view, savedInstanceState)
|
|
super.onViewCreated(view, savedInstanceState)
|
|
|
|
|
|
|
|
- customise_apps_fragment_back.setOnClickListener{
|
|
|
|
|
|
|
+ binding.customiseAppsFragmentBack.setOnClickListener {
|
|
|
requireActivity().onBackPressedDispatcher.onBackPressed()
|
|
requireActivity().onBackPressedDispatcher.onBackPressed()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -53,25 +48,25 @@ class CustomizeSearchFieldFragment : BaseFragment() {
|
|
|
|
|
|
|
|
private fun setupShowSearchBarSwitch() {
|
|
private fun setupShowSearchBarSwitch() {
|
|
|
val prefsRepo = unlauncherDataSource.corePreferencesRepo
|
|
val prefsRepo = unlauncherDataSource.corePreferencesRepo
|
|
|
- customize_app_drawer_fragment_show_search_field_switch.setOnCheckedChangeListener { _, checked ->
|
|
|
|
|
|
|
+ binding.customizeAppDrawerFragmentShowSearchFieldSwitch.setOnCheckedChangeListener { _, checked ->
|
|
|
prefsRepo.updateShowSearchBar(checked)
|
|
prefsRepo.updateShowSearchBar(checked)
|
|
|
enableSearchBarOptions(checked)
|
|
enableSearchBarOptions(checked)
|
|
|
}
|
|
}
|
|
|
prefsRepo.liveData().observe(viewLifecycleOwner) {
|
|
prefsRepo.liveData().observe(viewLifecycleOwner) {
|
|
|
val checked = it.showSearchBar
|
|
val checked = it.showSearchBar
|
|
|
- customize_app_drawer_fragment_show_search_field_switch.isChecked = checked
|
|
|
|
|
|
|
+ binding.customizeAppDrawerFragmentShowSearchFieldSwitch.isChecked = checked
|
|
|
enableSearchBarOptions(checked)
|
|
enableSearchBarOptions(checked)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private fun enableSearchBarOptions(enabled: Boolean) {
|
|
private fun enableSearchBarOptions(enabled: Boolean) {
|
|
|
- customize_app_drawer_fragment_search_field_position.isEnabled = enabled
|
|
|
|
|
- customize_app_drawer_open_keyboard_switch.isEnabled = enabled
|
|
|
|
|
|
|
+ binding.customizeAppDrawerFragmentSearchFieldPosition.isEnabled = enabled
|
|
|
|
|
+ binding.customizeAppDrawerOpenKeyboardSwitch.isEnabled = enabled
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private fun setupSearchBarPositionOption() {
|
|
private fun setupSearchBarPositionOption() {
|
|
|
val prefRepo = unlauncherDataSource.corePreferencesRepo
|
|
val prefRepo = unlauncherDataSource.corePreferencesRepo
|
|
|
- customize_app_drawer_fragment_search_field_position.setOnClickListener {
|
|
|
|
|
|
|
+ binding.customizeAppDrawerFragmentSearchFieldPosition.setOnClickListener {
|
|
|
val positionDialog = ChooseSearchBarPositionDialog.getSearchBarPositionChooser()
|
|
val positionDialog = ChooseSearchBarPositionDialog.getSearchBarPositionChooser()
|
|
|
positionDialog.showNow(childFragmentManager, "POSITION_CHOOSER")
|
|
positionDialog.showNow(childFragmentManager, "POSITION_CHOOSER")
|
|
|
}
|
|
}
|
|
@@ -79,20 +74,20 @@ class CustomizeSearchFieldFragment : BaseFragment() {
|
|
|
val position = it.searchBarPosition.number
|
|
val position = it.searchBarPosition.number
|
|
|
val title = getText(R.string.customize_app_drawer_fragment_search_bar_position)
|
|
val title = getText(R.string.customize_app_drawer_fragment_search_bar_position)
|
|
|
val subtitle = resources.getTextArray(R.array.search_bar_position_array)[position]
|
|
val subtitle = resources.getTextArray(R.array.search_bar_position_array)[position]
|
|
|
- customize_app_drawer_fragment_search_field_position.text =
|
|
|
|
|
|
|
+ binding.customizeAppDrawerFragmentSearchFieldPosition.text =
|
|
|
createTitleAndSubtitleText(requireContext(), title, subtitle)
|
|
createTitleAndSubtitleText(requireContext(), title, subtitle)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private fun setupKeyboardSwitch() {
|
|
private fun setupKeyboardSwitch() {
|
|
|
val prefsRepo = unlauncherDataSource.corePreferencesRepo
|
|
val prefsRepo = unlauncherDataSource.corePreferencesRepo
|
|
|
- customize_app_drawer_open_keyboard_switch.setOnCheckedChangeListener { _, checked ->
|
|
|
|
|
|
|
+ binding.customizeAppDrawerOpenKeyboardSwitch.setOnCheckedChangeListener { _, checked ->
|
|
|
prefsRepo.updateActivateKeyboardInDrawer(checked)
|
|
prefsRepo.updateActivateKeyboardInDrawer(checked)
|
|
|
}
|
|
}
|
|
|
prefsRepo.liveData().observe(viewLifecycleOwner) {
|
|
prefsRepo.liveData().observe(viewLifecycleOwner) {
|
|
|
- customize_app_drawer_open_keyboard_switch.isChecked = it.activateKeyboardInDrawer
|
|
|
|
|
|
|
+ binding.customizeAppDrawerOpenKeyboardSwitch.isChecked = it.activateKeyboardInDrawer
|
|
|
}
|
|
}
|
|
|
- customize_app_drawer_open_keyboard_switch.text =
|
|
|
|
|
|
|
+ binding.customizeAppDrawerOpenKeyboardSwitch.text =
|
|
|
createTitleAndSubtitleText(
|
|
createTitleAndSubtitleText(
|
|
|
requireContext(), R.string.customize_app_drawer_fragment_open_keyboard,
|
|
requireContext(), R.string.customize_app_drawer_fragment_open_keyboard,
|
|
|
R.string.customize_app_drawer_fragment_open_keyboard_subtitle
|
|
R.string.customize_app_drawer_fragment_open_keyboard_subtitle
|
|
@@ -101,16 +96,21 @@ class CustomizeSearchFieldFragment : BaseFragment() {
|
|
|
|
|
|
|
|
private fun setupSearchAllAppsSwitch() {
|
|
private fun setupSearchAllAppsSwitch() {
|
|
|
val prefsRepo = unlauncherDataSource.corePreferencesRepo
|
|
val prefsRepo = unlauncherDataSource.corePreferencesRepo
|
|
|
- customize_app_drawer_search_all_switch.setOnCheckedChangeListener { _, checked ->
|
|
|
|
|
|
|
+ binding.customizeAppDrawerSearchAllSwitch.setOnCheckedChangeListener { _, checked ->
|
|
|
prefsRepo.updateSearchAllAppsInDrawer(checked)
|
|
prefsRepo.updateSearchAllAppsInDrawer(checked)
|
|
|
}
|
|
}
|
|
|
prefsRepo.liveData().observe(viewLifecycleOwner) {
|
|
prefsRepo.liveData().observe(viewLifecycleOwner) {
|
|
|
- customize_app_drawer_search_all_switch.isChecked = it.searchAllAppsInDrawer
|
|
|
|
|
|
|
+ binding.customizeAppDrawerSearchAllSwitch.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
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ binding.customizeAppDrawerSearchAllSwitch.text =
|
|
|
|
|
+ createTitleAndSubtitleText(
|
|
|
|
|
+ requireContext(), R.string.customize_app_drawer_fragment_search_all,
|
|
|
|
|
+ R.string.customize_app_drawer_fragment_search_all_subtitle
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ override fun onDestroyView() {
|
|
|
|
|
+ _binding = null
|
|
|
|
|
+ super.onDestroyView()
|
|
|
}
|
|
}
|
|
|
-}
|
|
|
|
|
|
|
+}
|