From 7194013e4f233b0f3f5ddec6b7a8be113a089a0d Mon Sep 17 00:00:00 2001 From: Joshua Kuestersteffen Date: Sun, 7 Jan 2024 13:42:47 -0600 Subject: [PATCH] chore: update dependencies (#209) --- app/build.gradle.kts | 39 +++--- .../slimlauncher/di/ActivityModule.kt | 2 + .../ui/dialogs/RenameAppDialog.kt | 7 +- .../ui/dialogs/RenameAppDisplayNameDialog.kt | 5 +- .../slimlauncher/ui/main/HomeFragment.kt | 111 +++++++++--------- .../slimlauncher/ui/options/AddAppFragment.kt | 19 +-- .../ui/options/CustomiseAppsFragment.kt | 22 ++-- .../CustomizeAppDrawerAppListFragment.kt | 16 ++- .../ui/options/CustomizeAppDrawerFragment.kt | 32 +++-- .../options/CustomizeQuickButtonsFragment.kt | 23 ++-- .../options/CustomizeSearchFieldFragment.kt | 60 +++++----- .../ui/options/OptionsFragment.kt | 43 ++++--- .../{layout => drawable}/imageview_border.xml | 0 .../customize_quick_buttons_fragment.xml | 6 +- build.gradle.kts | 11 +- gradle.properties | 3 + gradle/wrapper/gradle-wrapper.properties | 2 +- 17 files changed, 196 insertions(+), 205 deletions(-) rename app/src/main/res/{layout => drawable}/imageview_border.xml (100%) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index b72775cd..ff704e1e 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -3,17 +3,16 @@ import com.google.protobuf.gradle.* plugins { id("com.android.application") id("dagger.hilt.android.plugin") - id("com.google.protobuf") version "0.9.0" + id("com.google.devtools.ksp") + id("com.google.protobuf") kotlin("android") - kotlin("android.extensions") - kotlin("kapt") } android { compileSdk = 34 defaultConfig { applicationId = "com.jkuester.unlauncher" - minSdkVersion(21) + minSdk = 21 targetSdk = 34 versionName = "2.1.0-beta.1" versionCode = 19 @@ -29,7 +28,9 @@ android { // } // } } - + buildFeatures { + viewBinding = true + } buildTypes { named("release").configure { isMinifyEnabled = true @@ -74,38 +75,36 @@ android { } dependencies { - implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar")))) - // Kotlin Libraries - implementation("org.jetbrains.kotlin:kotlin-stdlib:1.7.22") + implementation("org.jetbrains.kotlin:kotlin-stdlib:1.9.22") // This needs to match ksp and kotlin-gradle-plugin // Support Libraries implementation("androidx.appcompat:appcompat:1.6.1") - implementation("androidx.recyclerview:recyclerview:1.3.0") + implementation("androidx.recyclerview:recyclerview:1.3.2") implementation("androidx.constraintlayout:constraintlayout:2.1.4") implementation("androidx.datastore:datastore:1.0.0") implementation("androidx.datastore:datastore-core:1.0.0") - implementation("com.google.protobuf:protobuf-javalite:3.23.3") + implementation("com.google.protobuf:protobuf-javalite:3.25.1") // Arch Components - implementation("androidx.core:core-ktx:1.9.0") - implementation("androidx.fragment:fragment-ktx:1.5.7") + implementation("androidx.core:core-ktx:1.12.0") + implementation("androidx.fragment:fragment-ktx:1.6.2") implementation("androidx.lifecycle:lifecycle-extensions:2.2.0") - implementation("androidx.navigation:navigation-fragment-ktx:2.5.3") - implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.5.1") - implementation("androidx.room:room-runtime:2.5.1") - kapt("androidx.room:room-compiler:2.5.1") + implementation("androidx.navigation:navigation-fragment-ktx:2.7.6") + implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.6.2") + implementation("androidx.room:room-runtime:2.6.1") + ksp("androidx.room:room-compiler:2.6.1") //3rd party libs implementation("com.intuit.sdp:sdp-android:1.0.6") implementation("com.intuit.ssp:ssp-android:1.0.6") - implementation("com.google.dagger:hilt-android:2.44.2") - kapt("androidx.hilt:hilt-compiler:1.0.0") - kapt("com.google.dagger:hilt-android-compiler:2.44") + implementation("com.google.dagger:hilt-android:2.50") + ksp("androidx.hilt:hilt-compiler:1.1.0") + ksp("com.google.dagger:hilt-android-compiler:2.50") } protobuf { protoc { - artifact = "com.google.protobuf:protoc:3.17.3" + artifact = "com.google.protobuf:protoc:3.25.1" } generateProtoTasks { all().forEach { task -> diff --git a/app/src/main/java/com/sduduzog/slimlauncher/di/ActivityModule.kt b/app/src/main/java/com/sduduzog/slimlauncher/di/ActivityModule.kt index bccba2fc..2c1bf478 100644 --- a/app/src/main/java/com/sduduzog/slimlauncher/di/ActivityModule.kt +++ b/app/src/main/java/com/sduduzog/slimlauncher/di/ActivityModule.kt @@ -1,5 +1,6 @@ package com.sduduzog.slimlauncher.di +import android.annotation.SuppressLint import android.app.Activity import androidx.core.app.ComponentActivity import androidx.lifecycle.LifecycleCoroutineScope @@ -14,6 +15,7 @@ import dagger.hilt.android.scopes.ActivityScoped @Module @InstallIn(ActivityComponent::class) class ActivityModule { + @SuppressLint("RestrictedApi") @Provides fun provideLifecycleCoroutineScope(activity: Activity): LifecycleCoroutineScope = (activity as ComponentActivity).lifecycleScope diff --git a/app/src/main/java/com/sduduzog/slimlauncher/ui/dialogs/RenameAppDialog.kt b/app/src/main/java/com/sduduzog/slimlauncher/ui/dialogs/RenameAppDialog.kt index 4e4f9399..b0ae9392 100644 --- a/app/src/main/java/com/sduduzog/slimlauncher/ui/dialogs/RenameAppDialog.kt +++ b/app/src/main/java/com/sduduzog/slimlauncher/ui/dialogs/RenameAppDialog.kt @@ -2,15 +2,14 @@ package com.sduduzog.slimlauncher.ui.dialogs import android.app.Dialog import android.os.Bundle -import android.view.LayoutInflater import android.widget.EditText import android.widget.Toast import androidx.appcompat.app.AlertDialog import androidx.fragment.app.DialogFragment import com.sduduzog.slimlauncher.R -import com.sduduzog.slimlauncher.models.HomeApp +import com.sduduzog.slimlauncher.databinding.RenameDialogEditTextBinding import com.sduduzog.slimlauncher.models.CustomiseAppsViewModel -import kotlinx.android.synthetic.main.customise_apps_fragment.* +import com.sduduzog.slimlauncher.models.HomeApp class RenameAppDialog : DialogFragment() { @@ -18,7 +17,7 @@ class RenameAppDialog : DialogFragment() { private lateinit var model: CustomiseAppsViewModel override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { - val view = layoutInflater.inflate(R.layout.rename_dialog_edit_text, customise_apps_fragment, false) + val view = RenameDialogEditTextBinding.inflate(layoutInflater).root val editText: EditText = view.findViewById(R.id.rename_editText) val appName: String = app.appNickname ?: app.appName editText.text.append(appName) diff --git a/app/src/main/java/com/sduduzog/slimlauncher/ui/dialogs/RenameAppDisplayNameDialog.kt b/app/src/main/java/com/sduduzog/slimlauncher/ui/dialogs/RenameAppDisplayNameDialog.kt index 7478d95f..4dd363fa 100644 --- a/app/src/main/java/com/sduduzog/slimlauncher/ui/dialogs/RenameAppDisplayNameDialog.kt +++ b/app/src/main/java/com/sduduzog/slimlauncher/ui/dialogs/RenameAppDisplayNameDialog.kt @@ -2,22 +2,21 @@ package com.sduduzog.slimlauncher.ui.dialogs import android.app.Dialog import android.os.Bundle -import android.view.LayoutInflater import android.widget.EditText import android.widget.Toast import androidx.appcompat.app.AlertDialog import androidx.fragment.app.DialogFragment import com.jkuester.unlauncher.datastore.UnlauncherApp import com.sduduzog.slimlauncher.R +import com.sduduzog.slimlauncher.databinding.RenameDialogEditTextBinding import com.sduduzog.slimlauncher.datasource.apps.UnlauncherAppsRepository -import kotlinx.android.synthetic.main.customise_apps_fragment.* class RenameAppDisplayNameDialog : DialogFragment() { private lateinit var app: UnlauncherApp private lateinit var unlauncherAppsRepo: UnlauncherAppsRepository override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { - val view = layoutInflater.inflate(R.layout.rename_dialog_edit_text, customise_apps_fragment, false) + val view = RenameDialogEditTextBinding.inflate(layoutInflater).root val editText: EditText = view.findViewById(R.id.rename_editText) val appName: String = app.displayName editText.text.append(appName) diff --git a/app/src/main/java/com/sduduzog/slimlauncher/ui/main/HomeFragment.kt b/app/src/main/java/com/sduduzog/slimlauncher/ui/main/HomeFragment.kt index 7a33e2fe..99f7a3ab 100644 --- a/app/src/main/java/com/sduduzog/slimlauncher/ui/main/HomeFragment.kt +++ b/app/src/main/java/com/sduduzog/slimlauncher/ui/main/HomeFragment.kt @@ -40,6 +40,9 @@ import com.jkuester.unlauncher.datastore.UnlauncherApp import com.sduduzog.slimlauncher.R import com.sduduzog.slimlauncher.adapters.AppDrawerAdapter import com.sduduzog.slimlauncher.adapters.HomeAdapter +import com.sduduzog.slimlauncher.databinding.HomeFragmentBottomBinding +import com.sduduzog.slimlauncher.databinding.HomeFragmentContentBinding +import com.sduduzog.slimlauncher.databinding.HomeFragmentDefaultBinding import com.sduduzog.slimlauncher.datasource.UnlauncherDataSource import com.sduduzog.slimlauncher.datasource.quickbuttonprefs.QuickButtonPreferencesRepository import com.sduduzog.slimlauncher.models.HomeApp @@ -49,18 +52,6 @@ import com.sduduzog.slimlauncher.utils.BaseFragment import com.sduduzog.slimlauncher.utils.OnLaunchAppListener import com.sduduzog.slimlauncher.utils.isSystemApp import dagger.hilt.android.AndroidEntryPoint -import kotlinx.android.synthetic.main.home_fragment_content.app_drawer_edit_text -import kotlinx.android.synthetic.main.home_fragment_content.app_drawer_fragment_list -import kotlinx.android.synthetic.main.home_fragment_content.home_fragment_analog_time -import kotlinx.android.synthetic.main.home_fragment_content.home_fragment_bin_time -import kotlinx.android.synthetic.main.home_fragment_content.home_fragment_call -import kotlinx.android.synthetic.main.home_fragment_content.home_fragment_camera -import kotlinx.android.synthetic.main.home_fragment_content.home_fragment_date -import kotlinx.android.synthetic.main.home_fragment_content.home_fragment_list -import kotlinx.android.synthetic.main.home_fragment_content.home_fragment_list_exp -import kotlinx.android.synthetic.main.home_fragment_content.home_fragment_options -import kotlinx.android.synthetic.main.home_fragment_content.home_fragment_time -import kotlinx.android.synthetic.main.home_fragment_default.home_fragment import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import java.text.SimpleDateFormat @@ -88,21 +79,19 @@ class HomeFragment : BaseFragment(), OnLaunchAppListener { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View { val coreRepository = unlauncherDataSource.corePreferencesRepo - val layout = when (coreRepository.get().searchBarPosition) { - SearchBarPosition.bottom -> R.layout.home_fragment_bottom - SearchBarPosition.UNRECOGNIZED, - SearchBarPosition.top -> R.layout.home_fragment_default - else -> R.layout.home_fragment_default - } - return inflater.inflate(layout, container, false) + return if(coreRepository.get().searchBarPosition == SearchBarPosition.bottom) + HomeFragmentBottomBinding.inflate(layoutInflater, container, false).root + else + HomeFragmentDefaultBinding.inflate(layoutInflater, container, false).root } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) val adapter1 = HomeAdapter(this, unlauncherDataSource) val adapter2 = HomeAdapter(this, unlauncherDataSource) - home_fragment_list.adapter = adapter1 - home_fragment_list_exp.adapter = adapter2 + val homeFragmentContent = HomeFragmentContentBinding.bind(view) + homeFragmentContent.homeFragmentList.adapter = adapter1 + homeFragmentContent.homeFragmentListExp.adapter = adapter2 val unlauncherAppsRepo = unlauncherDataSource.unlauncherAppsRepo @@ -130,16 +119,16 @@ class HomeFragment : BaseFragment(), OnLaunchAppListener { setEventListeners() - app_drawer_fragment_list.adapter = appDrawerAdapter + homeFragmentContent.appDrawerFragmentList.adapter = appDrawerAdapter unlauncherDataSource.corePreferencesRepo.liveData().observe(viewLifecycleOwner){ corePreferences -> - app_drawer_edit_text.visibility = if (corePreferences.showSearchBar) View.VISIBLE else View.GONE + homeFragmentContent.appDrawerEditText.visibility = if (corePreferences.showSearchBar) View.VISIBLE else View.GONE val clockType = corePreferences.clockType - home_fragment_time.visibility = if(clockType == ClockType.digital) View.VISIBLE else View.GONE - home_fragment_analog_time.visibility = if(clockType == ClockType.analog) View.VISIBLE else View.GONE - home_fragment_bin_time.visibility = if(clockType == ClockType.binary) View.VISIBLE else View.GONE - home_fragment_date.visibility = if(clockType != ClockType.none) View.VISIBLE else View.GONE + homeFragmentContent.homeFragmentTime.visibility = if(clockType == ClockType.digital) View.VISIBLE else View.GONE + homeFragmentContent.homeFragmentAnalogTime.visibility = if(clockType == ClockType.analog) View.VISIBLE else View.GONE + homeFragmentContent.homeFragmentBinTime.visibility = if(clockType == ClockType.binary) View.VISIBLE else View.GONE + homeFragmentContent.homeFragmentDate.visibility = if(clockType != ClockType.none) View.VISIBLE else View.GONE } } @@ -149,7 +138,7 @@ class HomeFragment : BaseFragment(), OnLaunchAppListener { activity?.registerReceiver(receiver, IntentFilter(Intent.ACTION_TIME_TICK)) } - override fun getFragmentView(): ViewGroup = home_fragment + override fun getFragmentView(): ViewGroup = HomeFragmentDefaultBinding.bind(requireView()).homeFragment override fun onResume() { super.onResume() @@ -161,9 +150,10 @@ class HomeFragment : BaseFragment(), OnLaunchAppListener { } // scroll back to the top if user returns to this fragment - val layoutManager = app_drawer_fragment_list.layoutManager as LinearLayoutManager + val appDrawerFragmentList = HomeFragmentContentBinding.bind(requireView()).appDrawerFragmentList + val layoutManager = appDrawerFragmentList.layoutManager as LinearLayoutManager if (layoutManager.findFirstCompletelyVisibleItemPosition() != 0) { - app_drawer_fragment_list.scrollToPosition(0) + appDrawerFragmentList.scrollToPosition(0) } } @@ -193,11 +183,12 @@ class HomeFragment : BaseFragment(), OnLaunchAppListener { // Do nothing, we've failed :( } } - home_fragment_time.setOnClickListener(launchShowAlarms) - home_fragment_analog_time.setOnClickListener(launchShowAlarms) - home_fragment_bin_time.setOnClickListener(launchShowAlarms) + val homeFragmentContent = HomeFragmentContentBinding.bind(requireView()) + homeFragmentContent.homeFragmentTime.setOnClickListener(launchShowAlarms) + homeFragmentContent.homeFragmentAnalogTime.setOnClickListener(launchShowAlarms) + homeFragmentContent.homeFragmentBinTime.setOnClickListener(launchShowAlarms) - home_fragment_date.setOnClickListener { + homeFragmentContent.homeFragmentDate.setOnClickListener { try { val builder = CalendarContract.CONTENT_URI.buildUpon().appendPath("time") val intent = Intent(Intent.ACTION_VIEW, builder.build()) @@ -211,9 +202,9 @@ class HomeFragment : BaseFragment(), OnLaunchAppListener { unlauncherDataSource.quickButtonPreferencesRepo.liveData() .observe(viewLifecycleOwner) { prefs -> val leftButtonIcon = QuickButtonPreferencesRepository.RES_BY_ICON.getValue(prefs.leftButton.iconId) - home_fragment_call.setImageResource(leftButtonIcon) + homeFragmentContent.homeFragmentCall.setImageResource(leftButtonIcon) if (leftButtonIcon != R.drawable.ic_empty) { - home_fragment_call.setOnClickListener { view -> + homeFragmentContent.homeFragmentCall.setOnClickListener { view -> try { val pm = context?.packageManager!! val intent = Intent(Intent.ACTION_DIAL) @@ -229,9 +220,9 @@ class HomeFragment : BaseFragment(), OnLaunchAppListener { } val centerButtonIcon = QuickButtonPreferencesRepository.RES_BY_ICON.getValue(prefs.centerButton.iconId) - home_fragment_options.setImageResource(centerButtonIcon) + homeFragmentContent.homeFragmentOptions.setImageResource(centerButtonIcon) if (centerButtonIcon != R.drawable.ic_empty) { - home_fragment_options.setOnClickListener( + homeFragmentContent.homeFragmentOptions.setOnClickListener( Navigation.createNavigateOnClickListener( R.id.action_homeFragment_to_optionsFragment ) @@ -239,9 +230,9 @@ class HomeFragment : BaseFragment(), OnLaunchAppListener { } val rightButtonIcon = QuickButtonPreferencesRepository.RES_BY_ICON.getValue(prefs.rightButton.iconId) - home_fragment_camera.setImageResource(rightButtonIcon) + homeFragmentContent.homeFragmentCamera.setImageResource(rightButtonIcon) if (rightButtonIcon != R.drawable.ic_empty) { - home_fragment_camera.setOnClickListener { + homeFragmentContent.homeFragmentCamera.setOnClickListener { try { val intent = Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA) launchActivity(it, intent) @@ -252,20 +243,21 @@ class HomeFragment : BaseFragment(), OnLaunchAppListener { } } - app_drawer_edit_text.addTextChangedListener(appDrawerAdapter.searchBoxListener) + homeFragmentContent.appDrawerEditText.addTextChangedListener(appDrawerAdapter.searchBoxListener) - app_drawer_edit_text.setOnEditorActionListener { _, actionId, _ -> + val homeFragment = HomeFragmentDefaultBinding.bind(requireView()).root + homeFragmentContent.appDrawerEditText.setOnEditorActionListener { _, actionId, _ -> if(actionId == EditorInfo.IME_ACTION_DONE && appDrawerAdapter.itemCount > 0) { val firstApp = appDrawerAdapter.getFirstApp() launchApp(firstApp.packageName, firstApp.className, firstApp.userSerial) - home_fragment.transitionToStart() + homeFragment.transitionToStart() true } else { false } } - home_fragment.setTransitionListener(object : TransitionListener { + homeFragment.setTransitionListener(object : TransitionListener { override fun onTransitionCompleted(motionLayout: MotionLayout?, currentId: Int) { val inputMethodManager = requireContext().getSystemService(Activity.INPUT_METHOD_SERVICE) as InputMethodManager @@ -281,10 +273,10 @@ class HomeFragment : BaseFragment(), OnLaunchAppListener { // Check for preferences to open the keyboard // only if the search field is shown if (preferences.showSearchBar && preferences.activateKeyboardInDrawer) { - app_drawer_edit_text.requestFocus() + homeFragmentContent.appDrawerEditText.requestFocus() // show the keyboard and set focus to the EditText when swiping down inputMethodManager.showSoftInput( - app_drawer_edit_text, + homeFragmentContent.appDrawerEditText, InputMethodManager.SHOW_IMPLICIT ) } @@ -308,10 +300,11 @@ class HomeFragment : BaseFragment(), OnLaunchAppListener { fun updateClock() { updateDate() + val homeFragmentContent = HomeFragmentContentBinding.bind(requireView()) when (unlauncherDataSource.corePreferencesRepo.get().clockType) { ClockType.digital -> updateClockDigital() - ClockType.analog -> home_fragment_analog_time.updateClock() - ClockType.binary -> home_fragment_bin_time.updateClock() + ClockType.analog -> homeFragmentContent.homeFragmentAnalogTime.updateClock() + ClockType.binary -> homeFragmentContent.homeFragmentBinTime.updateClock() else -> {} } } @@ -324,12 +317,14 @@ class HomeFragment : BaseFragment(), OnLaunchAppListener { 2 -> SimpleDateFormat("h:mm aa", Locale.getDefault()) else -> DateFormat.getTimeFormat(context) } - home_fragment_time.text = fWatchTime.format(Date()) + val homeFragmentContent = HomeFragmentContentBinding.bind(requireView()) + homeFragmentContent.homeFragmentTime.text = fWatchTime.format(Date()) } private fun updateDate() { val fWatchDate = SimpleDateFormat(getString(R.string.main_date_format), Locale.getDefault()) - home_fragment_date.text = fWatchDate.format(Date()) + val homeFragmentContent = HomeFragmentContentBinding.bind(requireView()) + homeFragmentContent.homeFragmentDate.text = fWatchDate.format(Date()) } override fun onLaunch(app: HomeApp, view: View) { @@ -337,12 +332,14 @@ class HomeFragment : BaseFragment(), OnLaunchAppListener { } override fun onBack(): Boolean { - home_fragment.transitionToStart() + val homeFragment = HomeFragmentDefaultBinding.bind(requireView()).root + homeFragment.transitionToStart() return true } override fun onHome() { - home_fragment.transitionToStart() + val homeFragment = HomeFragmentDefaultBinding.bind(requireView()).root + homeFragment.transitionToStart() } inner class ClockReceiver : BroadcastReceiver() { @@ -366,9 +363,10 @@ class HomeFragment : BaseFragment(), OnLaunchAppListener { } private fun resetAppDrawerEditText() { - app_drawer_edit_text.clearComposingText() - app_drawer_edit_text.setText("") - app_drawer_edit_text.clearFocus() + val homeFragmentContent = HomeFragmentContentBinding.bind(requireView()) + homeFragmentContent.appDrawerEditText.clearComposingText() + homeFragmentContent.appDrawerEditText.setText("") + homeFragmentContent.appDrawerEditText.clearFocus() } inner class AppDrawerListener { @@ -428,7 +426,8 @@ class HomeFragment : BaseFragment(), OnLaunchAppListener { fun onAppClicked(app: UnlauncherApp) { launchApp(app.packageName, app.className, app.userSerial) - home_fragment.transitionToStart() + val homeFragment = HomeFragmentDefaultBinding.bind(requireView()).root + homeFragment.transitionToStart() } } } diff --git a/app/src/main/java/com/sduduzog/slimlauncher/ui/options/AddAppFragment.kt b/app/src/main/java/com/sduduzog/slimlauncher/ui/options/AddAppFragment.kt index 34deda71..77784d15 100644 --- a/app/src/main/java/com/sduduzog/slimlauncher/ui/options/AddAppFragment.kt +++ b/app/src/main/java/com/sduduzog/slimlauncher/ui/options/AddAppFragment.kt @@ -11,16 +11,16 @@ import androidx.navigation.Navigation import com.sduduzog.slimlauncher.R import com.sduduzog.slimlauncher.adapters.AddAppAdapter import com.sduduzog.slimlauncher.data.model.App +import com.sduduzog.slimlauncher.databinding.AddAppFragmentBinding import com.sduduzog.slimlauncher.models.AddAppViewModel import com.sduduzog.slimlauncher.utils.BaseFragment import com.sduduzog.slimlauncher.utils.OnAppClickedListener import dagger.hilt.android.AndroidEntryPoint -import kotlinx.android.synthetic.main.add_app_fragment.* @AndroidEntryPoint class AddAppFragment : BaseFragment(), OnAppClickedListener { - override fun getFragmentView(): ViewGroup = add_app_fragment + override fun getFragmentView(): ViewGroup = AddAppFragmentBinding.bind(requireView()).addAppFragment private val viewModel: AddAppViewModel by viewModels() @@ -32,14 +32,15 @@ class AddAppFragment : BaseFragment(), OnAppClickedListener { super.onActivityCreated(savedInstanceState) val adapter = AddAppAdapter(this) - add_app_fragment_list.adapter = adapter + val addAppFragment = AddAppFragmentBinding.bind(requireView()) + addAppFragment.addAppFragmentList.adapter = adapter viewModel.apps.observe(viewLifecycleOwner, { it?.let { apps -> adapter.setItems(apps) - add_app_fragment_progress_bar.visibility = View.GONE + addAppFragment.addAppFragmentProgressBar.visibility = View.GONE } ?: run { - add_app_fragment_progress_bar.visibility = View.VISIBLE + addAppFragment.addAppFragmentProgressBar.visibility = View.VISIBLE } }) } @@ -48,12 +49,14 @@ class AddAppFragment : BaseFragment(), OnAppClickedListener { super.onResume() viewModel.setInstalledApps(getInstalledApps()) viewModel.filterApps("") - add_app_fragment_edit_text.addTextChangedListener(onTextChangeListener) + val addAppFragment = AddAppFragmentBinding.bind(requireView()) + addAppFragment.addAppFragmentEditText.addTextChangedListener(onTextChangeListener) } override fun onPause() { super.onPause() - add_app_fragment_edit_text?.removeTextChangedListener(onTextChangeListener) + val addAppFragment = AddAppFragmentBinding.bind(requireView()) + addAppFragment.addAppFragmentEditText.removeTextChangedListener(onTextChangeListener) } private val onTextChangeListener: TextWatcher = object : TextWatcher { @@ -73,6 +76,6 @@ class AddAppFragment : BaseFragment(), OnAppClickedListener { override fun onAppClicked(app: App) { viewModel.addAppToHomeScreen(app) - Navigation.findNavController(add_app_fragment).popBackStack() + Navigation.findNavController(AddAppFragmentBinding.bind(requireView()).addAppFragment).popBackStack() } } \ No newline at end of file diff --git a/app/src/main/java/com/sduduzog/slimlauncher/ui/options/CustomiseAppsFragment.kt b/app/src/main/java/com/sduduzog/slimlauncher/ui/options/CustomiseAppsFragment.kt index ec5ea47a..e8ed3bb2 100644 --- a/app/src/main/java/com/sduduzog/slimlauncher/ui/options/CustomiseAppsFragment.kt +++ b/app/src/main/java/com/sduduzog/slimlauncher/ui/options/CustomiseAppsFragment.kt @@ -12,6 +12,7 @@ import androidx.recyclerview.widget.ItemTouchHelper import androidx.recyclerview.widget.RecyclerView import com.sduduzog.slimlauncher.R import com.sduduzog.slimlauncher.adapters.CustomAppsAdapter +import com.sduduzog.slimlauncher.databinding.CustomiseAppsFragmentBinding import com.sduduzog.slimlauncher.models.CustomiseAppsViewModel import com.sduduzog.slimlauncher.models.HomeApp import com.sduduzog.slimlauncher.ui.dialogs.RemoveAllAppsDialog @@ -20,17 +21,12 @@ import com.sduduzog.slimlauncher.utils.BaseFragment import com.sduduzog.slimlauncher.utils.OnItemActionListener import com.sduduzog.slimlauncher.utils.OnShitDoneToAppsListener import dagger.hilt.android.AndroidEntryPoint -import kotlinx.android.synthetic.main.customise_apps_fragment.customise_apps_fragment -import kotlinx.android.synthetic.main.customise_apps_fragment.customise_apps_fragment_add -import kotlinx.android.synthetic.main.customise_apps_fragment.customise_apps_fragment_back -import kotlinx.android.synthetic.main.customise_apps_fragment.customise_apps_fragment_list -import kotlinx.android.synthetic.main.customise_apps_fragment.customise_apps_fragment_remove_all @AndroidEntryPoint class CustomiseAppsFragment : BaseFragment(), OnShitDoneToAppsListener { - override fun getFragmentView(): ViewGroup = customise_apps_fragment + override fun getFragmentView(): ViewGroup = CustomiseAppsFragmentBinding.bind(requireView()).customiseAppsFragment private val viewModel: CustomiseAppsViewModel by viewModels() @@ -40,7 +36,8 @@ class CustomiseAppsFragment : BaseFragment(), OnShitDoneToAppsListener { override fun onActivityCreated(savedInstanceState: Bundle?) { super.onActivityCreated(savedInstanceState) - customise_apps_fragment_back.setOnClickListener { + val customiseAppsFragment = CustomiseAppsFragmentBinding.bind(requireView()) + customiseAppsFragment.customiseAppsFragmentBack.setOnClickListener { requireActivity().onBackPressedDispatcher.onBackPressed() } } @@ -48,17 +45,18 @@ class CustomiseAppsFragment : BaseFragment(), OnShitDoneToAppsListener { super.onViewCreated(view, savedInstanceState) val adapter = CustomAppsAdapter(this) + val customiseAppsFragment = CustomiseAppsFragmentBinding.bind(view) viewModel.apps.observe(viewLifecycleOwner, { it?.let { apps -> adapter.setItems(apps) - customise_apps_fragment_add.visibility = if(apps.size < 6) View.VISIBLE else View.INVISIBLE + customiseAppsFragment.customiseAppsFragmentAdd.visibility = if(apps.size < 6) View.VISIBLE else View.INVISIBLE } ?: adapter.setItems(listOf()) }) - customise_apps_fragment_remove_all.setOnClickListener { + customiseAppsFragment.customiseAppsFragmentRemoveAll.setOnClickListener { RemoveAllAppsDialog.getInstance(viewModel.apps.value!!, viewModel).show(childFragmentManager, "REMOVE_APPS") } - customise_apps_fragment_list.adapter = adapter + customiseAppsFragment.customiseAppsFragmentList.adapter = adapter val listener: OnItemActionListener = adapter val simpleItemTouchCallback = object : ItemTouchHelper.Callback() { @@ -98,11 +96,11 @@ class CustomiseAppsFragment : BaseFragment(), OnShitDoneToAppsListener { val itemTouchHelper = ItemTouchHelper(simpleItemTouchCallback) - itemTouchHelper.attachToRecyclerView(customise_apps_fragment_list) + itemTouchHelper.attachToRecyclerView(customiseAppsFragment.customiseAppsFragmentList) adapter.setItemTouchHelper(itemTouchHelper) - customise_apps_fragment_add.setOnClickListener(Navigation.createNavigateOnClickListener(R.id.action_customiseAppsFragment_to_addAppFragment)) + customiseAppsFragment.customiseAppsFragmentAdd.setOnClickListener(Navigation.createNavigateOnClickListener(R.id.action_customiseAppsFragment_to_addAppFragment)) } private fun showPopupMenu(view: View): PopupMenu { diff --git a/app/src/main/java/com/sduduzog/slimlauncher/ui/options/CustomizeAppDrawerAppListFragment.kt b/app/src/main/java/com/sduduzog/slimlauncher/ui/options/CustomizeAppDrawerAppListFragment.kt index a1a76e81..e5829929 100644 --- a/app/src/main/java/com/sduduzog/slimlauncher/ui/options/CustomizeAppDrawerAppListFragment.kt +++ b/app/src/main/java/com/sduduzog/slimlauncher/ui/options/CustomizeAppDrawerAppListFragment.kt @@ -6,13 +6,10 @@ import android.view.View import android.view.ViewGroup import com.sduduzog.slimlauncher.R import com.sduduzog.slimlauncher.adapters.CustomizeAppDrawerAppsAdapter +import com.sduduzog.slimlauncher.databinding.CustomizeAppDrawerAppListFragmentBinding import com.sduduzog.slimlauncher.datasource.UnlauncherDataSource import com.sduduzog.slimlauncher.utils.BaseFragment import dagger.hilt.android.AndroidEntryPoint -import kotlinx.android.synthetic.main.customize_app_drawer_app_list_fragment.customize_app_drawer_fragment -import kotlinx.android.synthetic.main.customize_app_drawer_app_list_fragment.customize_app_drawer_fragment_app_list -import kotlinx.android.synthetic.main.customize_app_drawer_app_list_fragment.customize_app_drawer_fragment_app_progress_bar -import kotlinx.android.synthetic.main.customize_app_drawer_app_list_fragment.customize_app_drawer_fragment_back import javax.inject.Inject @AndroidEntryPoint @@ -20,7 +17,7 @@ class CustomizeAppDrawerAppListFragment : BaseFragment() { @Inject lateinit var unlauncherDataSource: UnlauncherDataSource - override fun getFragmentView(): ViewGroup = customize_app_drawer_fragment + override fun getFragmentView(): ViewGroup = CustomizeAppDrawerAppListFragmentBinding.bind(requireView()).customizeAppDrawerFragment override fun onCreateView( inflater: LayoutInflater, @@ -33,16 +30,17 @@ class CustomizeAppDrawerAppListFragment : BaseFragment() { override fun onActivityCreated(savedInstanceState: Bundle?) { super.onActivityCreated(savedInstanceState) val unlauncherAppsRepo = unlauncherDataSource.unlauncherAppsRepo - customize_app_drawer_fragment_app_list.adapter = + val customiseAppDrawerAppListFragment = CustomizeAppDrawerAppListFragmentBinding.bind(requireView()) + customiseAppDrawerAppListFragment.customizeAppDrawerFragmentAppList.adapter = CustomizeAppDrawerAppsAdapter(viewLifecycleOwner, unlauncherAppsRepo) unlauncherAppsRepo.liveData().observe(viewLifecycleOwner) { it?.let { - customize_app_drawer_fragment_app_progress_bar.visibility = View.GONE + customiseAppDrawerAppListFragment.customizeAppDrawerFragmentAppProgressBar.visibility = View.GONE } ?: run { - customize_app_drawer_fragment_app_progress_bar.visibility = View.VISIBLE + customiseAppDrawerAppListFragment.customizeAppDrawerFragmentAppProgressBar.visibility = View.VISIBLE } } - customize_app_drawer_fragment_back.setOnClickListener { + customiseAppDrawerAppListFragment.customizeAppDrawerFragmentBack.setOnClickListener { requireActivity().onBackPressedDispatcher.onBackPressed() } } diff --git a/app/src/main/java/com/sduduzog/slimlauncher/ui/options/CustomizeAppDrawerFragment.kt b/app/src/main/java/com/sduduzog/slimlauncher/ui/options/CustomizeAppDrawerFragment.kt index 16016382..be60778f 100644 --- a/app/src/main/java/com/sduduzog/slimlauncher/ui/options/CustomizeAppDrawerFragment.kt +++ b/app/src/main/java/com/sduduzog/slimlauncher/ui/options/CustomizeAppDrawerFragment.kt @@ -7,15 +7,11 @@ import android.view.ViewGroup import androidx.navigation.Navigation import com.jkuester.unlauncher.datastore.SearchBarPosition import com.sduduzog.slimlauncher.R +import com.sduduzog.slimlauncher.databinding.CustomizeAppDrawerFragmentBinding import com.sduduzog.slimlauncher.datasource.UnlauncherDataSource import com.sduduzog.slimlauncher.utils.BaseFragment import com.sduduzog.slimlauncher.utils.createTitleAndSubtitleText import dagger.hilt.android.AndroidEntryPoint -import kotlinx.android.synthetic.main.customize_app_drawer_fragment.customize_app_drawer_fragment -import kotlinx.android.synthetic.main.customize_app_drawer_fragment.customize_app_drawer_fragment_back -import kotlinx.android.synthetic.main.customize_app_drawer_fragment.customize_app_drawer_fragment_search_options -import kotlinx.android.synthetic.main.customize_app_drawer_fragment.customize_app_drawer_fragment_show_headings_switch -import kotlinx.android.synthetic.main.customize_app_drawer_fragment.customize_app_drawer_fragment_visible_apps import javax.inject.Inject @AndroidEntryPoint @@ -24,7 +20,7 @@ class CustomizeAppDrawerFragment : BaseFragment() { @Inject lateinit var unlauncherDataSource: UnlauncherDataSource - override fun getFragmentView(): ViewGroup = customize_app_drawer_fragment + override fun getFragmentView(): ViewGroup = CustomizeAppDrawerFragmentBinding.bind(requireView()).customizeAppDrawerFragment override fun onCreateView( inflater: LayoutInflater, @@ -34,20 +30,20 @@ class CustomizeAppDrawerFragment : BaseFragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - - customize_app_drawer_fragment_visible_apps + val customiseAppDrawerFragment = CustomizeAppDrawerFragmentBinding.bind(view) + customiseAppDrawerFragment.customizeAppDrawerFragmentVisibleApps .setOnClickListener(Navigation.createNavigateOnClickListener(R.id.action_customiseAppDrawerFragment_to_customiseAppDrawerAppListFragment)) - customize_app_drawer_fragment_back.setOnClickListener{ + customiseAppDrawerFragment.customizeAppDrawerFragmentBack.setOnClickListener{ requireActivity().onBackPressedDispatcher.onBackPressed() } - setupSearchFieldOptionsButton() - setupHeadingSwitch() + setupSearchFieldOptionsButton(customiseAppDrawerFragment) + setupHeadingSwitch(customiseAppDrawerFragment) } - private fun setupSearchFieldOptionsButton() { - customize_app_drawer_fragment_search_options.setOnClickListener( + private fun setupSearchFieldOptionsButton(customiseAppDrawerFragment: CustomizeAppDrawerFragmentBinding) { + customiseAppDrawerFragment.customizeAppDrawerFragmentSearchOptions.setOnClickListener( Navigation.createNavigateOnClickListener(R.id.action_customiseAppDrawerFragment_to_customizeSearchFieldFragment) ) val preferencesRepository = unlauncherDataSource.corePreferencesRepo @@ -72,20 +68,20 @@ class CustomizeAppDrawerFragment : BaseFragment() { getText(R.string.customize_app_drawer_fragment_search_field_options_subtitle_status_hidden) } - customize_app_drawer_fragment_search_options.text = + customiseAppDrawerFragment.customizeAppDrawerFragmentSearchOptions.text = createTitleAndSubtitleText(requireContext(), title, subtitle) } } - private fun setupHeadingSwitch() { + private fun setupHeadingSwitch(customiseAppDrawerFragment: CustomizeAppDrawerFragmentBinding) { val prefsRepo = unlauncherDataSource.corePreferencesRepo - customize_app_drawer_fragment_show_headings_switch.setOnCheckedChangeListener { _, checked -> + customiseAppDrawerFragment.customizeAppDrawerFragmentShowHeadingsSwitch.setOnCheckedChangeListener { _, checked -> prefsRepo.updateShowDrawerHeadings(checked) } prefsRepo.liveData().observe(viewLifecycleOwner) { - customize_app_drawer_fragment_show_headings_switch.isChecked = it.showDrawerHeadings + customiseAppDrawerFragment.customizeAppDrawerFragmentShowHeadingsSwitch.isChecked = it.showDrawerHeadings } - customize_app_drawer_fragment_show_headings_switch.text = + customiseAppDrawerFragment.customizeAppDrawerFragmentShowHeadingsSwitch.text = createTitleAndSubtitleText( requireContext(), R.string.customize_app_drawer_fragment_show_headings, R.string.customize_app_drawer_fragment_show_headings_subtitle diff --git a/app/src/main/java/com/sduduzog/slimlauncher/ui/options/CustomizeQuickButtonsFragment.kt b/app/src/main/java/com/sduduzog/slimlauncher/ui/options/CustomizeQuickButtonsFragment.kt index e493e065..e7c99f7a 100644 --- a/app/src/main/java/com/sduduzog/slimlauncher/ui/options/CustomizeQuickButtonsFragment.kt +++ b/app/src/main/java/com/sduduzog/slimlauncher/ui/options/CustomizeQuickButtonsFragment.kt @@ -5,16 +5,12 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import com.sduduzog.slimlauncher.R +import com.sduduzog.slimlauncher.databinding.CustomizeQuickButtonsFragmentBinding import com.sduduzog.slimlauncher.datasource.UnlauncherDataSource import com.sduduzog.slimlauncher.datasource.quickbuttonprefs.QuickButtonPreferencesRepository import com.sduduzog.slimlauncher.ui.dialogs.ChooseQuickButtonDialog import com.sduduzog.slimlauncher.utils.BaseFragment import dagger.hilt.android.AndroidEntryPoint -import kotlinx.android.synthetic.main.customize_quick_buttons_fragment.customize_quick_buttons_fragment -import kotlinx.android.synthetic.main.customize_quick_buttons_fragment.customize_quick_buttons_fragment_back -import kotlinx.android.synthetic.main.customize_quick_buttons_fragment.customize_quick_buttons_fragment_center -import kotlinx.android.synthetic.main.customize_quick_buttons_fragment.customize_quick_buttons_fragment_left -import kotlinx.android.synthetic.main.customize_quick_buttons_fragment.customize_quick_buttons_fragment_right import javax.inject.Inject @AndroidEntryPoint @@ -22,7 +18,7 @@ class CustomizeQuickButtonsFragment : BaseFragment() { @Inject lateinit var unlauncherDataSource: UnlauncherDataSource - override fun getFragmentView(): ViewGroup = customize_quick_buttons_fragment + override fun getFragmentView(): ViewGroup = CustomizeQuickButtonsFragmentBinding.bind(requireView()).customizeQuickButtonsFragment override fun onCreateView( inflater: LayoutInflater, @@ -34,31 +30,32 @@ class CustomizeQuickButtonsFragment : BaseFragment() { super.onViewCreated(view, savedInstanceState) val prefsRepo = unlauncherDataSource.quickButtonPreferencesRepo + val customizeQuickButtonsFragment = CustomizeQuickButtonsFragmentBinding.bind(view) prefsRepo.liveData().observe(viewLifecycleOwner) { prefs -> - customize_quick_buttons_fragment_left + customizeQuickButtonsFragment.customizeQuickButtonsFragmentLeft .setImageResource(QuickButtonPreferencesRepository.RES_BY_ICON.getValue(prefs.leftButton.iconId)) - customize_quick_buttons_fragment_center + customizeQuickButtonsFragment.customizeQuickButtonsFragmentCenter .setImageResource(QuickButtonPreferencesRepository.RES_BY_ICON.getValue(prefs.centerButton.iconId)) - customize_quick_buttons_fragment_right + customizeQuickButtonsFragment.customizeQuickButtonsFragmentRight .setImageResource(QuickButtonPreferencesRepository.RES_BY_ICON.getValue(prefs.rightButton.iconId)) } - customize_quick_buttons_fragment_back.setOnClickListener { + customizeQuickButtonsFragment.customizeQuickButtonsFragmentBack.setOnClickListener { requireActivity().onBackPressedDispatcher.onBackPressed() } - customize_quick_buttons_fragment_left.setOnClickListener { + customizeQuickButtonsFragment.customizeQuickButtonsFragmentLeft.setOnClickListener { ChooseQuickButtonDialog( prefsRepo, QuickButtonPreferencesRepository.IC_CALL ).showNow(childFragmentManager, "QUICK_BUTTON_CHOOSER") } - customize_quick_buttons_fragment_center.setOnClickListener { + customizeQuickButtonsFragment.customizeQuickButtonsFragmentCenter.setOnClickListener { ChooseQuickButtonDialog( prefsRepo, QuickButtonPreferencesRepository.IC_COG ).showNow(childFragmentManager, "QUICK_BUTTON_CHOOSER") } - customize_quick_buttons_fragment_right.setOnClickListener { + customizeQuickButtonsFragment.customizeQuickButtonsFragmentRight.setOnClickListener { ChooseQuickButtonDialog( prefsRepo, QuickButtonPreferencesRepository.IC_PHOTO_CAMERA diff --git a/app/src/main/java/com/sduduzog/slimlauncher/ui/options/CustomizeSearchFieldFragment.kt b/app/src/main/java/com/sduduzog/slimlauncher/ui/options/CustomizeSearchFieldFragment.kt index 0464097b..f0715c45 100644 --- a/app/src/main/java/com/sduduzog/slimlauncher/ui/options/CustomizeSearchFieldFragment.kt +++ b/app/src/main/java/com/sduduzog/slimlauncher/ui/options/CustomizeSearchFieldFragment.kt @@ -5,19 +5,12 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import com.sduduzog.slimlauncher.R +import com.sduduzog.slimlauncher.databinding.CustomizeAppDrawerFragmentSearchFieldOptionsBinding import com.sduduzog.slimlauncher.datasource.UnlauncherDataSource import com.sduduzog.slimlauncher.ui.dialogs.ChooseSearchBarPositionDialog import com.sduduzog.slimlauncher.utils.BaseFragment import com.sduduzog.slimlauncher.utils.createTitleAndSubtitleText 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 @AndroidEntryPoint @@ -26,7 +19,7 @@ class CustomizeSearchFieldFragment : BaseFragment() { @Inject lateinit var unlauncherDataSource: UnlauncherDataSource - override fun getFragmentView(): ViewGroup = customize_app_drawer_fragment_search_field_options + override fun getFragmentView(): ViewGroup = CustomizeAppDrawerFragmentSearchFieldOptionsBinding.bind(requireView()).customizeAppDrawerFragmentSearchFieldOptions override fun onCreateView( inflater: LayoutInflater, @@ -41,37 +34,38 @@ class CustomizeSearchFieldFragment : BaseFragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - customise_apps_fragment_back.setOnClickListener{ + val customizeAppDrawerFragmentSearchFieldOptions = CustomizeAppDrawerFragmentSearchFieldOptionsBinding.bind(view) + customizeAppDrawerFragmentSearchFieldOptions.customiseAppsFragmentBack.setOnClickListener{ requireActivity().onBackPressedDispatcher.onBackPressed() } - setupShowSearchBarSwitch() - setupSearchBarPositionOption() - setupKeyboardSwitch() - setupSearchAllAppsSwitch() + setupShowSearchBarSwitch(customizeAppDrawerFragmentSearchFieldOptions) + setupSearchBarPositionOption(customizeAppDrawerFragmentSearchFieldOptions) + setupKeyboardSwitch(customizeAppDrawerFragmentSearchFieldOptions) + setupSearchAllAppsSwitch(customizeAppDrawerFragmentSearchFieldOptions) } - private fun setupShowSearchBarSwitch() { + private fun setupShowSearchBarSwitch(customizeAppDrawerFragmentSearchFieldOptions: CustomizeAppDrawerFragmentSearchFieldOptionsBinding) { val prefsRepo = unlauncherDataSource.corePreferencesRepo - customize_app_drawer_fragment_show_search_field_switch.setOnCheckedChangeListener { _, checked -> + customizeAppDrawerFragmentSearchFieldOptions.customizeAppDrawerFragmentShowSearchFieldSwitch.setOnCheckedChangeListener { _, checked -> prefsRepo.updateShowSearchBar(checked) - enableSearchBarOptions(checked) + enableSearchBarOptions(customizeAppDrawerFragmentSearchFieldOptions, checked) } prefsRepo.liveData().observe(viewLifecycleOwner) { val checked = it.showSearchBar - customize_app_drawer_fragment_show_search_field_switch.isChecked = checked - enableSearchBarOptions(checked) + customizeAppDrawerFragmentSearchFieldOptions.customizeAppDrawerFragmentShowSearchFieldSwitch.isChecked = checked + enableSearchBarOptions(customizeAppDrawerFragmentSearchFieldOptions, checked) } } - private fun enableSearchBarOptions(enabled: Boolean) { - customize_app_drawer_fragment_search_field_position.isEnabled = enabled - customize_app_drawer_open_keyboard_switch.isEnabled = enabled + private fun enableSearchBarOptions(customizeAppDrawerFragmentSearchFieldOptions: CustomizeAppDrawerFragmentSearchFieldOptionsBinding, enabled: Boolean) { + customizeAppDrawerFragmentSearchFieldOptions.customizeAppDrawerFragmentSearchFieldPosition.isEnabled = enabled + customizeAppDrawerFragmentSearchFieldOptions.customizeAppDrawerOpenKeyboardSwitch.isEnabled = enabled } - private fun setupSearchBarPositionOption() { + private fun setupSearchBarPositionOption(customizeAppDrawerFragmentSearchFieldOptions: CustomizeAppDrawerFragmentSearchFieldOptionsBinding) { val prefRepo = unlauncherDataSource.corePreferencesRepo - customize_app_drawer_fragment_search_field_position.setOnClickListener { + customizeAppDrawerFragmentSearchFieldOptions.customizeAppDrawerFragmentSearchFieldPosition.setOnClickListener { val positionDialog = ChooseSearchBarPositionDialog.getSearchBarPositionChooser() positionDialog.showNow(childFragmentManager, "POSITION_CHOOSER") } @@ -79,35 +73,35 @@ class CustomizeSearchFieldFragment : BaseFragment() { val position = it.searchBarPosition.number val title = getText(R.string.customize_app_drawer_fragment_search_bar_position) val subtitle = resources.getTextArray(R.array.search_bar_position_array)[position] - customize_app_drawer_fragment_search_field_position.text = + customizeAppDrawerFragmentSearchFieldOptions.customizeAppDrawerFragmentSearchFieldPosition.text = createTitleAndSubtitleText(requireContext(), title, subtitle) } } - private fun setupKeyboardSwitch() { + private fun setupKeyboardSwitch(customizeAppDrawerFragmentSearchFieldOptions: CustomizeAppDrawerFragmentSearchFieldOptionsBinding) { val prefsRepo = unlauncherDataSource.corePreferencesRepo - customize_app_drawer_open_keyboard_switch.setOnCheckedChangeListener { _, checked -> + customizeAppDrawerFragmentSearchFieldOptions.customizeAppDrawerOpenKeyboardSwitch.setOnCheckedChangeListener { _, checked -> prefsRepo.updateActivateKeyboardInDrawer(checked) } prefsRepo.liveData().observe(viewLifecycleOwner) { - customize_app_drawer_open_keyboard_switch.isChecked = it.activateKeyboardInDrawer + customizeAppDrawerFragmentSearchFieldOptions.customizeAppDrawerOpenKeyboardSwitch.isChecked = it.activateKeyboardInDrawer } - customize_app_drawer_open_keyboard_switch.text = + customizeAppDrawerFragmentSearchFieldOptions.customizeAppDrawerOpenKeyboardSwitch.text = createTitleAndSubtitleText( requireContext(), R.string.customize_app_drawer_fragment_open_keyboard, R.string.customize_app_drawer_fragment_open_keyboard_subtitle ) } - private fun setupSearchAllAppsSwitch() { + private fun setupSearchAllAppsSwitch(customizeAppDrawerFragmentSearchFieldOptions: CustomizeAppDrawerFragmentSearchFieldOptionsBinding) { val prefsRepo = unlauncherDataSource.corePreferencesRepo - customize_app_drawer_search_all_switch.setOnCheckedChangeListener { _, checked -> + customizeAppDrawerFragmentSearchFieldOptions.customizeAppDrawerSearchAllSwitch.setOnCheckedChangeListener { _, checked -> prefsRepo.updateSearchAllAppsInDrawer(checked) } prefsRepo.liveData().observe(viewLifecycleOwner) { - customize_app_drawer_search_all_switch.isChecked = it.searchAllAppsInDrawer + customizeAppDrawerFragmentSearchFieldOptions.customizeAppDrawerSearchAllSwitch.isChecked = it.searchAllAppsInDrawer } - customize_app_drawer_search_all_switch.text = + customizeAppDrawerFragmentSearchFieldOptions.customizeAppDrawerSearchAllSwitch.text = createTitleAndSubtitleText( requireContext(), R.string.customize_app_drawer_fragment_search_all, R.string.customize_app_drawer_fragment_search_all_subtitle diff --git a/app/src/main/java/com/sduduzog/slimlauncher/ui/options/OptionsFragment.kt b/app/src/main/java/com/sduduzog/slimlauncher/ui/options/OptionsFragment.kt index 097bbdec..1e33e0b9 100644 --- a/app/src/main/java/com/sduduzog/slimlauncher/ui/options/OptionsFragment.kt +++ b/app/src/main/java/com/sduduzog/slimlauncher/ui/options/OptionsFragment.kt @@ -4,15 +4,13 @@ import android.content.Context.MODE_PRIVATE import android.content.Intent import android.os.Bundle import android.provider.Settings -import android.text.SpannableStringBuilder -import android.text.Spanned -import android.text.style.TextAppearanceSpan import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.core.content.edit import androidx.navigation.Navigation import com.sduduzog.slimlauncher.R +import com.sduduzog.slimlauncher.databinding.OptionsFragmentBinding import com.sduduzog.slimlauncher.datasource.UnlauncherDataSource import com.sduduzog.slimlauncher.ui.dialogs.ChangeThemeDialog import com.sduduzog.slimlauncher.ui.dialogs.ChooseAlignmentDialog @@ -22,7 +20,6 @@ import com.sduduzog.slimlauncher.utils.BaseFragment import com.sduduzog.slimlauncher.utils.createTitleAndSubtitleText import com.sduduzog.slimlauncher.utils.isActivityDefaultLauncher import dagger.hilt.android.AndroidEntryPoint -import kotlinx.android.synthetic.main.options_fragment.* import javax.inject.Inject @AndroidEntryPoint @@ -30,7 +27,7 @@ class OptionsFragment : BaseFragment() { @Inject lateinit var unlauncherDataSource: UnlauncherDataSource - override fun getFragmentView(): ViewGroup = options_fragment + override fun getFragmentView(): ViewGroup = OptionsFragmentBinding.bind(requireView()).optionsFragment override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { return inflater.inflate(R.layout.options_fragment, container, false) @@ -38,44 +35,45 @@ class OptionsFragment : BaseFragment() { override fun onActivityCreated(savedInstanceState: Bundle?) { super.onActivityCreated(savedInstanceState) - options_fragment_device_settings.setOnClickListener { + val optionsFragment = OptionsFragmentBinding.bind(requireView()) + optionsFragment.optionsFragmentDeviceSettings.setOnClickListener { val intent = Intent(Settings.ACTION_SETTINGS) launchActivity(it, intent) } - options_fragment_back.setOnClickListener{ + optionsFragment.optionsFragmentBack.setOnClickListener{ requireActivity().onBackPressedDispatcher.onBackPressed() } - options_fragment_device_settings.setOnLongClickListener { + optionsFragment.optionsFragmentDeviceSettings.setOnLongClickListener { val intent = Intent(Settings.ACTION_HOME_SETTINGS) launchActivity(it, intent) true } - options_fragment_change_theme.setOnClickListener { + optionsFragment.optionsFragmentChangeTheme.setOnClickListener { val changeThemeDialog = ChangeThemeDialog.getThemeChooser() changeThemeDialog.showNow(childFragmentManager, "THEME_CHOOSER") } - options_fragment_choose_time_format.setOnClickListener { + optionsFragment.optionsFragmentChooseTimeFormat.setOnClickListener { val chooseTimeFormatDialog = ChooseTimeFormatDialog.getInstance() chooseTimeFormatDialog.showNow(childFragmentManager, "TIME_FORMAT_CHOOSER") } - options_fragment_choose_clock_type.setOnClickListener { + optionsFragment.optionsFragmentChooseClockType.setOnClickListener { val chooseClockTypeDialog = ChooseClockTypeDialog.getInstance() chooseClockTypeDialog.showNow(childFragmentManager, "CLOCK_TYPE_CHOOSER") } - options_fragment_choose_alignment.setOnClickListener { + optionsFragment.optionsFragmentChooseAlignment.setOnClickListener { val chooseAlignmentDialog = ChooseAlignmentDialog.getInstance() chooseAlignmentDialog.showNow(childFragmentManager, "ALIGNMENT_CHOOSER") } - options_fragment_toggle_status_bar.setOnClickListener { + optionsFragment.optionsFragmentToggleStatusBar.setOnClickListener { val settings = requireContext().getSharedPreferences(getString(R.string.prefs_settings), MODE_PRIVATE) val isHidden = settings.getBoolean(getString(R.string.prefs_settings_key_toggle_status_bar), false) settings.edit { putBoolean(getString(R.string.prefs_settings_key_toggle_status_bar), !isHidden) } } - options_fragment_customise_apps.setOnClickListener(Navigation.createNavigateOnClickListener(R.id.action_optionsFragment_to_customiseAppsFragment)) - options_fragment_customize_quick_buttons.setOnClickListener(Navigation.createNavigateOnClickListener(R.id.action_optionsFragment_to_customiseQuickButtonsFragment)) - options_fragment_customize_app_drawer.setOnClickListener(Navigation.createNavigateOnClickListener(R.id.action_optionsFragment_to_customiseAppDrawerFragment)) + optionsFragment.optionsFragmentCustomiseApps.setOnClickListener(Navigation.createNavigateOnClickListener(R.id.action_optionsFragment_to_customiseAppsFragment)) + optionsFragment.optionsFragmentCustomizeQuickButtons.setOnClickListener(Navigation.createNavigateOnClickListener(R.id.action_optionsFragment_to_customiseQuickButtonsFragment)) + optionsFragment.optionsFragmentCustomizeAppDrawer.setOnClickListener(Navigation.createNavigateOnClickListener(R.id.action_optionsFragment_to_customiseAppDrawerFragment)) } override fun onStart() { @@ -88,14 +86,15 @@ class OptionsFragment : BaseFragment() { private fun setupAutomaticDeviceWallpaperSwitch() { val prefsRepo = unlauncherDataSource.corePreferencesRepo val appIsDefaultLauncher = isActivityDefaultLauncher(activity) - setupDeviceWallpaperSwitchText(appIsDefaultLauncher) - options_fragment_auto_device_theme_wallpaper.isEnabled = appIsDefaultLauncher + val optionsFragment = OptionsFragmentBinding.bind(requireView()) + setupDeviceWallpaperSwitchText(optionsFragment, appIsDefaultLauncher) + optionsFragment.optionsFragmentAutoDeviceThemeWallpaper.isEnabled = appIsDefaultLauncher prefsRepo.liveData().observe(viewLifecycleOwner) { // always uncheck once app isn't default launcher - options_fragment_auto_device_theme_wallpaper.isChecked = appIsDefaultLauncher && !it.keepDeviceWallpaper + optionsFragment.optionsFragmentAutoDeviceThemeWallpaper.isChecked = appIsDefaultLauncher && !it.keepDeviceWallpaper } - options_fragment_auto_device_theme_wallpaper.setOnCheckedChangeListener { _, checked -> + optionsFragment.optionsFragmentAutoDeviceThemeWallpaper.setOnCheckedChangeListener { _, checked -> prefsRepo.updateKeepDeviceWallpaper(!checked) } } @@ -103,13 +102,13 @@ class OptionsFragment : BaseFragment() { /** * Adds a hint text underneath the default text when app is not the default launcher. */ - private fun setupDeviceWallpaperSwitchText(appIsDefaultLauncher: Boolean) { + private fun setupDeviceWallpaperSwitchText(optionsFragment: OptionsFragmentBinding, appIsDefaultLauncher: Boolean) { val text = if (appIsDefaultLauncher) { getText(R.string.customize_app_drawer_fragment_auto_theme_wallpaper_text) } else { buildSwitchTextWithHint() } - options_fragment_auto_device_theme_wallpaper.text = text + optionsFragment.optionsFragmentAutoDeviceThemeWallpaper.text = text } private fun buildSwitchTextWithHint(): CharSequence { diff --git a/app/src/main/res/layout/imageview_border.xml b/app/src/main/res/drawable/imageview_border.xml similarity index 100% rename from app/src/main/res/layout/imageview_border.xml rename to app/src/main/res/drawable/imageview_border.xml diff --git a/app/src/main/res/layout/customize_quick_buttons_fragment.xml b/app/src/main/res/layout/customize_quick_buttons_fragment.xml index 9e91d0d6..f336f6d1 100644 --- a/app/src/main/res/layout/customize_quick_buttons_fragment.xml +++ b/app/src/main/res/layout/customize_quick_buttons_fragment.xml @@ -39,7 +39,7 @@ android:layout_marginStart="@dimen/margin_sides_small" android:layout_marginBottom="@dimen/margin_bottom_small" android:padding="@dimen/padding" - android:background="@layout/imageview_border" + android:background="@drawable/imageview_border" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintStart_toStartOf="parent" app:srcCompat="@drawable/ic_call" @@ -51,7 +51,7 @@ android:layout_marginBottom="@dimen/margin_bottom_small" android:alpha="1" android:padding="@dimen/padding" - android:background="@layout/imageview_border" + android:background="@drawable/imageview_border" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toStartOf="@+id/customize_quick_buttons_fragment_right" app:layout_constraintStart_toEndOf="@+id/customize_quick_buttons_fragment_left" @@ -64,7 +64,7 @@ android:layout_marginEnd="@dimen/margin_sides_small" android:layout_marginBottom="@dimen/margin_bottom_small" android:padding="@dimen/padding" - android:background="@layout/imageview_border" + android:background="@drawable/imageview_border" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:srcCompat="@drawable/ic_photo_camera" diff --git a/build.gradle.kts b/build.gradle.kts index 12e62311..c619aa37 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -6,9 +6,9 @@ buildscript { mavenCentral() } dependencies { - classpath("com.android.tools.build:gradle:7.4.2") - classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.22") - classpath("com.google.dagger:hilt-android-gradle-plugin:2.44.2") + classpath("com.android.tools.build:gradle:8.2.1") + classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.22") // This needs to match kotlin-stdlib + classpath("com.google.dagger:hilt-android-gradle-plugin:2.50") // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files @@ -25,3 +25,8 @@ allprojects { tasks.register("clean", Delete::class) { delete(rootProject.buildDir) } + +plugins { + id("com.google.devtools.ksp") version "1.9.22-1.0.16" apply false // This needs to match kotlin-stdlib + id("com.google.protobuf") version "0.9.4" apply false +} diff --git a/gradle.properties b/gradle.properties index c2dd310b..0053ed72 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,6 +9,9 @@ org.gradle.jvmargs=-Xmx6114m android.useAndroidX=true android.enableJetifier=true +android.defaults.buildfeatures.buildconfig=true +android.nonTransitiveRClass=false +android.nonFinalResIds=false # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index da1db5f0..15de9024 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists