diff --git a/build.gradle.kts b/build.gradle.kts index b550560..83e77a6 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -6,12 +6,12 @@ buildscript { dependencies { classpath(libs.android.gradle.plugin) classpath(libs.kotlin.gradle.plugin) - classpath(libs.androidx.navigation.safeArgsGradlePlugin) } } plugins { alias(libs.plugins.detekt) + alias(libs.plugins.navigation.safeargs.kotlin).apply(false) } allprojects { diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts deleted file mode 100644 index cc364ff..0000000 --- a/buildSrc/build.gradle.kts +++ /dev/null @@ -1,13 +0,0 @@ -plugins { - `kotlin-dsl` -} - -repositories { - google() - mavenCentral() -} - -dependencies { - implementation(buildSrcLibs.android.gradle.plugin) - implementation(buildSrcLibs.kotlin.gradle.plugin) -} diff --git a/convention-plugin-android-library/build.gradle.kts b/convention-plugin-android-library/build.gradle.kts new file mode 100644 index 0000000..ea9a0b9 --- /dev/null +++ b/convention-plugin-android-library/build.gradle.kts @@ -0,0 +1,13 @@ +plugins { + `kotlin-dsl` +} + +repositories { + google() + mavenCentral() +} + +dependencies { + implementation(libs.android.gradle.plugin) + implementation(libs.kotlin.gradle.plugin) +} diff --git a/buildSrc/settings.gradle.kts b/convention-plugin-android-library/settings.gradle.kts similarity index 79% rename from buildSrc/settings.gradle.kts rename to convention-plugin-android-library/settings.gradle.kts index d312e67..b5a0fab 100644 --- a/buildSrc/settings.gradle.kts +++ b/convention-plugin-android-library/settings.gradle.kts @@ -1,6 +1,6 @@ dependencyResolutionManagement { versionCatalogs { - create("buildSrcLibs") { + create("libs") { from(files("../gradle/libs.versions.toml")) } } diff --git a/buildSrc/src/main/java/androidApplicationConvention.gradle.kts b/convention-plugin-android-library/src/main/java/androidApplicationConvention.gradle.kts similarity index 100% rename from buildSrc/src/main/java/androidApplicationConvention.gradle.kts rename to convention-plugin-android-library/src/main/java/androidApplicationConvention.gradle.kts diff --git a/buildSrc/src/main/java/androidLibraryConvention.gradle.kts b/convention-plugin-android-library/src/main/java/androidLibraryConvention.gradle.kts similarity index 100% rename from buildSrc/src/main/java/androidLibraryConvention.gradle.kts rename to convention-plugin-android-library/src/main/java/androidLibraryConvention.gradle.kts diff --git a/dialog-fragment/build.gradle.kts b/dialog-fragment/build.gradle.kts index cbecec7..002f618 100644 --- a/dialog-fragment/build.gradle.kts +++ b/dialog-fragment/build.gradle.kts @@ -1,5 +1,5 @@ plugins { - androidApplicationConvention + id("androidApplicationConvention") } android { diff --git a/dialog-fragment/src/main/AndroidManifest.xml b/dialog-fragment/src/main/AndroidManifest.xml index a6221b0..14a0087 100644 --- a/dialog-fragment/src/main/AndroidManifest.xml +++ b/dialog-fragment/src/main/AndroidManifest.xml @@ -1,14 +1,10 @@ - + + android:theme="@style/Theme.MaterialComponents.Light.DarkActionBar"> binding.fragmentWithIdDialogButton.setOnClickListener { AppDialogFragment.Builder( diff --git a/dialog-fragment/src/main/java/siarhei/luskanau/example/dialogfragment/FragmentWithTag.kt b/dialog-fragment/src/main/java/siarhei/luskanau/example/dialogfragment/FragmentWithTag.kt index ced07a6..79d984e 100644 --- a/dialog-fragment/src/main/java/siarhei/luskanau/example/dialogfragment/FragmentWithTag.kt +++ b/dialog-fragment/src/main/java/siarhei/luskanau/example/dialogfragment/FragmentWithTag.kt @@ -16,7 +16,7 @@ class FragmentWithTag : inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? - ): View? = FragmentWithTagBinding.inflate(inflater, container, false) + ): View = FragmentWithTagBinding.inflate(inflater, container, false) .also { binding -> binding.fragmentWithTagDialogButton.setOnClickListener { AppDialogFragment.Builder( diff --git a/fileprovider-camera/app/build.gradle.kts b/fileprovider-camera/app/build.gradle.kts index 8f3775a..45c38cc 100644 --- a/fileprovider-camera/app/build.gradle.kts +++ b/fileprovider-camera/app/build.gradle.kts @@ -1,5 +1,5 @@ plugins { - androidApplicationConvention + id("androidApplicationConvention") } android { @@ -8,7 +8,6 @@ android { applicationId = "siarhei.luskanau.example.camera.app" versionCode = 1 versionName = "1.0" - vectorDrawables.useSupportLibrary = true } buildTypes { @@ -35,7 +34,6 @@ android { dependencies { implementation(project(":fileprovider-camera:camera")) - implementation(libs.android.material) implementation(libs.androidx.activity.ktx) implementation(libs.androidx.fragment.ktx) diff --git a/fileprovider-camera/app/src/main/AndroidManifest.xml b/fileprovider-camera/app/src/main/AndroidManifest.xml index de76d08..3f28b78 100644 --- a/fileprovider-camera/app/src/main/AndroidManifest.xml +++ b/fileprovider-camera/app/src/main/AndroidManifest.xml @@ -1,19 +1,14 @@ - + + android:theme="@style/Theme.MaterialComponents.Light.DarkActionBar"> + android:exported="true"> diff --git a/fileprovider-camera/camera/build.gradle.kts b/fileprovider-camera/camera/build.gradle.kts index 993bc68..f607c59 100644 --- a/fileprovider-camera/camera/build.gradle.kts +++ b/fileprovider-camera/camera/build.gradle.kts @@ -1,5 +1,5 @@ plugins { - androidLibraryConvention + id("androidLibraryConvention") } android { diff --git a/fonts/build.gradle.kts b/fonts/build.gradle.kts index 1331d88..62b0701 100644 --- a/fonts/build.gradle.kts +++ b/fonts/build.gradle.kts @@ -1,5 +1,5 @@ plugins { - androidApplicationConvention + id("androidApplicationConvention") } android { diff --git a/fonts/src/main/AndroidManifest.xml b/fonts/src/main/AndroidManifest.xml index c7b8be9..062bfb0 100644 --- a/fonts/src/main/AndroidManifest.xml +++ b/fonts/src/main/AndroidManifest.xml @@ -1,12 +1,10 @@ - + + android:theme="@style/Theme.MaterialComponents.Light.DarkActionBar"> - setContentView(binding.root) - } - } -} +class AppActivity : AppCompatActivity(R.layout.activity_app) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 806040c..c7b1be6 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -23,7 +23,6 @@ androidx-activity-ktx = { module = "androidx.activity:activity-ktx", version.ref androidx-core = { module = "androidx.core:core", version.ref = "androidx-core" } androidx-fragment-ktx = { module = "androidx.fragment:fragment-ktx", version.ref = "androidx-fragment" } androidx-navigation-fragment-ktx = { module = "androidx.navigation:navigation-fragment-ktx", version.ref = "androidx-navigation" } -androidx-navigation-safeArgsGradlePlugin = { module = "androidx.navigation:navigation-safe-args-gradle-plugin", version.ref = "androidx-navigation" } androidx-navigation-ui-ktx = { module = "androidx.navigation:navigation-ui-ktx", version.ref = "androidx-navigation" } androidx-work-runtime-ktx = { module = "androidx.work:work-runtime-ktx", version.ref = "androidx-work" } kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" } @@ -32,3 +31,4 @@ timber = { module = "com.jakewharton.timber:timber", version.ref = "timber" } [plugins] detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" } +navigation-safeargs-kotlin = { id = "androidx.navigation.safeargs.kotlin", version.ref = "androidx-navigation" } diff --git a/navigation/build.gradle.kts b/navigation/build.gradle.kts index 3acfb15..0800bbe 100644 --- a/navigation/build.gradle.kts +++ b/navigation/build.gradle.kts @@ -1,6 +1,6 @@ plugins { - androidApplicationConvention - id("androidx.navigation.safeargs.kotlin") + id("androidApplicationConvention") + alias(libs.plugins.navigation.safeargs.kotlin) } android { diff --git a/navigation/src/main/AndroidManifest.xml b/navigation/src/main/AndroidManifest.xml index c0f757e..337d72c 100644 --- a/navigation/src/main/AndroidManifest.xml +++ b/navigation/src/main/AndroidManifest.xml @@ -1,12 +1,10 @@ - + + android:theme="@style/AppTheme"> - + + android:theme="@style/Theme.MaterialComponents.Light.NoActionBar"> - setContentView(binding.root) - } + val binding = ActivityAppBinding.inflate(LayoutInflater.from(this)) + .also { binding -> setContentView(binding.root) } navController = Navigation.findNavController(this, R.id.navHostFragment) appBarConfiguration = AppBarConfiguration(navController.graph, binding.drawerLayout) diff --git a/workmanager/src/main/java/siarhei/luskanau/example/workmanager/BaseBeginCancelWorkFragment.kt b/workmanager/src/main/java/siarhei/luskanau/example/workmanager/BaseBeginCancelWorkFragment.kt index 694bd55..f4245b7 100644 --- a/workmanager/src/main/java/siarhei/luskanau/example/workmanager/BaseBeginCancelWorkFragment.kt +++ b/workmanager/src/main/java/siarhei/luskanau/example/workmanager/BaseBeginCancelWorkFragment.kt @@ -13,7 +13,7 @@ abstract class BaseBeginCancelWorkFragment : Fragment() { inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? - ): View? { + ): View { val binding = FragmentBeginCancelWorkBinding.inflate(inflater, container, false) binding.beginWorkButton.setOnClickListener { onBeginButtonPressed() } diff --git a/workmanager/src/main/java/siarhei/luskanau/example/workmanager/monitor/WorkManagerMonitorFragment.kt b/workmanager/src/main/java/siarhei/luskanau/example/workmanager/monitor/WorkManagerMonitorFragment.kt index e1e5589..42ba040 100644 --- a/workmanager/src/main/java/siarhei/luskanau/example/workmanager/monitor/WorkManagerMonitorFragment.kt +++ b/workmanager/src/main/java/siarhei/luskanau/example/workmanager/monitor/WorkManagerMonitorFragment.kt @@ -6,9 +6,12 @@ import android.view.View import android.view.ViewGroup import android.widget.LinearLayout.VERTICAL import androidx.fragment.app.Fragment -import androidx.lifecycle.Observer +import androidx.lifecycle.Lifecycle import androidx.lifecycle.ViewModelProvider +import androidx.lifecycle.lifecycleScope +import androidx.lifecycle.repeatOnLifecycle import androidx.recyclerview.widget.DividerItemDecoration +import kotlinx.coroutines.launch import siarhei.luskanau.example.workmanager.databinding.FragmentWorkManagerMonitorBinding class WorkManagerMonitorFragment : Fragment() { @@ -16,7 +19,7 @@ class WorkManagerMonitorFragment : Fragment() { inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? - ): View? { + ): View { val binding = FragmentWorkManagerMonitorBinding.inflate(inflater, container, false) val adapter = WorkInfoAdapter() @@ -30,9 +33,14 @@ class WorkManagerMonitorFragment : Fragment() { ) val workManagerMonitorViewModel = - ViewModelProvider(this).get(WorkManagerMonitorViewModel::class.java) - workManagerMonitorViewModel.getWorkStatusListLiveData(requireContext()) - .observe(viewLifecycleOwner, Observer { adapter.submitList(it) }) + ViewModelProvider(this)[WorkManagerMonitorViewModel::class.java] + lifecycleScope.launch { + viewLifecycleOwner.repeatOnLifecycle(Lifecycle.State.RESUMED) { + workManagerMonitorViewModel.getWorkStatusListFlow(binding.root.context).collect { + adapter.submitList(it) + } + } + } return binding.root } diff --git a/workmanager/src/main/java/siarhei/luskanau/example/workmanager/monitor/WorkManagerMonitorViewModel.kt b/workmanager/src/main/java/siarhei/luskanau/example/workmanager/monitor/WorkManagerMonitorViewModel.kt index fd6b537..c2f4647 100644 --- a/workmanager/src/main/java/siarhei/luskanau/example/workmanager/monitor/WorkManagerMonitorViewModel.kt +++ b/workmanager/src/main/java/siarhei/luskanau/example/workmanager/monitor/WorkManagerMonitorViewModel.kt @@ -1,12 +1,12 @@ package siarhei.luskanau.example.workmanager.monitor import android.content.Context -import androidx.lifecycle.LiveData import androidx.lifecycle.ViewModel import androidx.work.WorkInfo import androidx.work.WorkManager +import kotlinx.coroutines.flow.Flow class WorkManagerMonitorViewModel : ViewModel() { - fun getWorkStatusListLiveData(context: Context): LiveData> = - WorkManager.getInstance(context).getWorkInfosByTagLiveData(WorkManagerConstants.TAG_ALL) + fun getWorkStatusListFlow(context: Context): Flow> = + WorkManager.getInstance(context).getWorkInfosByTagFlow(WorkManagerConstants.TAG_ALL) }