From 98ca4095583c80a24e13fec64ca4859c3b759b0d Mon Sep 17 00:00:00 2001 From: Debanshu Datta Date: Fri, 3 Mar 2023 17:13:44 +0530 Subject: [PATCH] feat: Updating to Material3 and other edits --- .idea/deploymentTargetDropDown.xml | 4 +- .idea/inspectionProfiles/Project_Default.xml | 5 + README.md | 111 ++++++++++++------ app/build.gradle | 45 +++---- app/src/main/AndroidManifest.xml | 1 + .../common/MainActivity.kt | 3 +- .../common/components/AutosizeIcon.kt | 43 +++---- .../components/CustomBottomNavigation.kt | 36 +++--- .../features/feature_camera/CamaraScreen.kt | 2 + .../presentation/components/CamaraOpen.kt | 10 +- build.gradle | 9 +- gradle.properties | 2 +- gradle/wrapper/gradle-wrapper.properties | 2 +- 13 files changed, 154 insertions(+), 119 deletions(-) diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml index 20cb322..0b142a2 100644 --- a/.idea/deploymentTargetDropDown.xml +++ b/.idea/deploymentTargetDropDown.xml @@ -7,11 +7,11 @@ - + - + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml index 2842237..d235beb 100644 --- a/.idea/inspectionProfiles/Project_Default.xml +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -2,18 +2,23 @@ diff --git a/README.md b/README.md index ad92431..0ffea25 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ Snapchat Compose Clone👻

+**Facing with the camaraX for API 30 and above, looking into this issue** +

@@ -20,72 +22,107 @@ Jetpack Compose is Android’s modern toolkit for building native UI. It simplif ## Dependencies & References⚡ #### General Dependencies -* ***Compose-version: 1.1.1***
Jetpack Compose is Android’s modern toolkit for building native UI. It simplifies and accelerates UI development on Android. Quickly bring your app to life with less code, powerful tools, and intuitive Kotlin APIs. -* ***Gradle-version:7.1.2*** -* ***Kotlin-version:1.6.10*** + +* ***Compose-version: 1.4.0-beta02***
Jetpack Compose is Android’s modern toolkit for building native UI. It simplifies and accelerates UI development on Android. Quickly bring your app to life with less code, powerful tools, and intuitive Kotlin APIs. +* ***Gradle Version: 7.5*** +* ***Kotlin Version: 1.8.10*** + #### Navigation🚀 -* ***androidx.navigation:navigation-compose:2.5.0-alpha03***
The Navigation component provides support for Jetpack Compose applications. You can navigate between composables while taking advantage of the Navigation component’s infrastructure and features. -* Reference https://blog.mindorks.com/jetpack-compose-navigation + +* ***androidx.navigation:navigation-compose:2.5.3***
The Navigation component provides support for Jetpack Compose applications. You can navigate between composables while taking advantage of the Navigation component’s infrastructure and features. +* +Reference https://blog.mindorks.com/jetpack-compose-navigation + #### Camara📸 -camerax_version = "1.1.0-beta02" -* ***androidx.camera:camera-core,androidx.camera:camera-camera2,androidx.camera:camera-lifecycle, androidx.camera:camera-view*** -* Reference + +camerax_version = "1.2.1" + +* ***androidx.camera:camera-coreandroidx.camera:camera-camera2, androidx.camera:camera-lifecycle, androidx.camera:camera-view, androidx.camera:camera-lifecycle, androidx.camera:camera-video, androidx.camera:camera-extensions*** +* Reference - https://proandroiddev.com/compose-camerax-on-android-58578f37e6df - https://www.youtube.com/watch?v=gRMznojSHxE&t=321s + #### Google Map🗺 -* ***com.google.maps.android:android-maps-utils:2.2.3, com.google.android.libraries.maps:maps:3.1.0-beta, com.google.maps.android:maps-v3-ktx:2.2.0, androidx.fragment:fragment-ktx:1.4.0*** -* References + +* ***com.google.maps.android:maps-compose:2.1.0, com.google.android.gms:play-services-maps:18.1.0*** +* References - https://medium.com/geekculture/google-maps-in-jetpack-compose-android-ae7b1ad84e9 - https://johnoreilly.dev/posts/jetpack-compose-google-maps/ - https://www.youtube.com/watch?v=2tu-hNbyViU -#### Video Player📽 -* ***com.google.android.exoplayer:exoplayer:2.17.1***
ExoPlayer is an application level media player for Android. It provides an alternative to Android’s MediaPlayer API for playing audio and video both locally and over the Internet. ExoPlayer supports features not currently supported by Android’s MediaPlayer API, including DASH and SmoothStreaming adaptive playbacks. + +#### Video Player with Media 3📽 + +* ***androidx.media3:media3-exoplayer:1.0.0-rc01, androidx.media3:media3-ui:1.0.0-rc01***
We have several existing media APIs: Jetpack Media also known as MediaCompat, Jetpack Media2, and ExoPlayer. These libraries were developed with different goals, and have several areas of overlapping functionality. + +It can be challenging to decide which library to use for a given use case, and objects from +different libraries are often not compatible, requiring adapters or connecting code. Media3 removes +these challenges by providing a single set of libraries which work well together. + * References - - https://proandroiddev.com/using-exoplayer-in-lazycolumn-65c47e0ceed5 - - < a href="https://medium.com/compose-in-the-room/integrating-exoplayer-in-jetpack-compose-38fca2f76bb4"/>https://medium.com/compose-in-the-room/integrating-exoplayer-in-jetpack-compose-38fca2f76bb4 - - https://www.youtube.com/watch?v=Ve_bI_HJQy4 + - https://medium.com/backyard-programmers/media3-exoplayer-in-jetpack-compose-to-make-snapchat-spotlight-75e384e2ef56 + #### Coil🍥 -* io.coil-kt:coil-compose:1.4.0
Image loading for Android backed by Kotlin Coroutines. -* References + +* io.coil-kt:coil-compose:2.2.2
Image loading for + Android backed by Kotlin Coroutines. +* References - https://proandroiddev.com/loading-images-for-jetpack-compose-using-glide-coil-and-fresco-1211261a296e - https://medium.com/geekculture/jetpack-compose-image-loading-using-coil-647a8098c217 -#### Hiding Secret Key🔑 -* ***com.google.android.libraries.mapsplatform.secrets-gradle-plugin:2.0.1***
This Gradle plugin reads secrets from a properties file not checked into version control, such as local.properties, and expose those properties as variables in the Gradle-generated BuildConfig class and in the Android manifest file. -* References - - https://www.youtube.com/watch?v=X8lYNW_Or2o + #### Accompanist✨ -* com.google.accompanist:accompanist-permissions, com.google.accompanist:accompanist-pager:0.19.0
Accompanist is a group of libraries that aim to supplement Jetpack Compose with features that are commonly required by developers but not yet available. + +* com.google.accompanist:accompanist-permissions: + 0.23.1 , com.google.accompanist:accompanist-pager:0.25.1
Accompanist is a group of + libraries that aim to supplement Jetpack Compose with features that are commonly required by + developers but not yet available. * References - https://google.github.io/accompanist/ - https://medium.com/surfstudio/accompanist-the-first-chord-a-jetpack-compose-library-reviewed-9e007771db70 + #### Dokka and KDoc🚀 -* org.jetbrains.dokka:dokka-gradle-plugin:1.6.10
Dokka is a documentation engine for Kotlin, performing the same function as javadoc for Java. Just like Kotlin itself, Dokka fully supports mixed-language Java/Kotlin projects. It understands standard Javadoc comments in Java files and KDoc comments in Kotlin files, and can generate documentation in multiple formats including standard Javadoc, HTML and Markdown. + +* org.jetbrains.dokka:dokka-gradle-plugin:1.7.10
+ Dokka is a documentation engine for Kotlin, performing the same function as javadoc for Java. Just + like Kotlin itself, Dokka fully supports mixed-language Java/Kotlin projects. It understands + standard Javadoc comments in Java files and KDoc comments in Kotlin files, and can generate + documentation in multiple formats including standard Javadoc, HTML and Markdown. * References - https://medium.com/androiddevnotes/how-to-use-dokka-documentation-engine-for-android-gradle-to-generate-kdoc-or-javadoc-comments-2b5f177595ec - https://www.youtube.com/watch?v=GesMbOt5hIo #### Detekt🐱‍🏍 -* io.gitlab.arturbosch.detekt:1.18.0
Static code analysis for Kotlin + +* io.gitlab.arturbosch.detekt:detekt-gradle-plugin: + 1.18.1
Static code analysis for Kotlin * References - https://www.youtube.com/watch?v=o384NbCDB0U - + ## Clean architecture + ***I am still learning and understanding clean architecture so it might be perfectly correct***
-In Clean Architecture, instead of relying on Models, you'll communicate with Interactors from the Use Case layer. This layer contains the user interface related code, powered by Android Jetpack! -The outer circle represents the concrete mechanisms that are specific to the platform such as networking and database access. Moving inward, each circle is more abstract and higher-level. The center circle is the most abstract and contains business logic, which doesn’t rely on the platform or the framework you’re using.
+In Clean Architecture, instead of relying on Models, you'll communicate with Interactors from the +Use Case layer. This layer contains the user interface related code, powered by Android Jetpack! +The outer circle represents the concrete mechanisms that are specific to the platform such as +networking and database access. Moving inward, each circle is more abstract and higher-level. The +center circle is the most abstract and contains business logic, which doesn’t rely on the platform +or the framework you’re using.

-Refer here for more details and description: - - https://www.raywenderlich.com/3595916-clean-architecture-tutorial-for-android-getting-started - - https://medium.com/android-dev-hacks/detailed-guide-on-android-clean-architecture-9eab262a9011 - - https://medium.com/swlh/clean-architecture-in-android-a-beginner-approach-be0ce00d806b - +Refer here for more details and description: + +- https://www.raywenderlich.com/3595916-clean-architecture-tutorial-for-android-getting-started +- https://medium.com/android-dev-hacks/detailed-guide-on-android-clean-architecture-9eab262a9011 +- https://medium.com/swlh/clean-architecture-in-android-a-beginner-approach-be0ce00d806b + ## Want to Contribute ? Awesome! If you want to contribute to this project, you're always welcome! -Have any questions, doubts or want to present your opinions, views? You're always welcome. You can mail me at debanshudatta123@gmail.com or make an issue. -Looking for contributors! Don't be shy. 😁 Feel free to open issues/pull requests to help me improve this project. +Have any questions, doubts or want to present your opinions, views? You're always welcome. You can +mail me at debanshudatta123@gmail.com or make an issue. +Looking for contributors! Don't be shy. 😁 Feel free to open issues/pull requests to help me improve +this project. -- When reporting a new Issue, make sure to attach Screenshots, Videos or GIFs of the problem you are reporting. +- When reporting a new Issue, make sure to attach Screenshots, Videos or GIFs of the problem you are + reporting. - When submitting a new PR, make sure tests are all green. Write new tests if necessary. ## Contributors @@ -94,7 +131,3 @@ Looking for contributors! Don't be shy. 😁 Feel free to open issues/pull reque ## License The Snapchat name, artwork, trademark are all property of Snap Inc. This project is provided for educational purposes only. It is not affiliated with and has not been approved by Snap Inc. - - - - diff --git a/app/build.gradle b/app/build.gradle index 8873667..879d9d9 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -15,7 +15,7 @@ android { minSdk 23 targetSdk 33 versionCode 1 - versionName "1.0" + versionName "2.0" manifestPlaceholders=[GMP_KEY: "Google Maps", googleMapApiKey: ""] testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" @@ -41,7 +41,7 @@ android { compose true } composeOptions { - kotlinCompilerExtensionVersion '1.3.0' + kotlinCompilerExtensionVersion '1.4.3' } packagingOptions { resources { @@ -65,38 +65,40 @@ tasks.dokkaHtml.configure { dependencies { - implementation 'androidx.core:core-ktx:1.8.0' - implementation 'androidx.appcompat:appcompat:1.5.0' - implementation "androidx.compose.material3:material3:1.0.0-alpha16" + implementation 'androidx.core:core-ktx:1.9.0' + implementation 'androidx.appcompat:appcompat:1.6.1' + implementation "androidx.compose.material3:material3:1.1.0-alpha07" implementation "androidx.compose.ui:ui:$compose_version" implementation "androidx.compose.ui:ui-tooling-preview:$compose_version" implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.5.1' - implementation 'androidx.activity:activity-compose:1.5.1' + implementation 'androidx.activity:activity-compose:1.6.1' debugImplementation "androidx.compose.ui:ui-tooling:$compose_version" implementation "androidx.compose.material:material-icons-extended:$compose_version" //Navigation - implementation "androidx.navigation:navigation-compose:2.5.1" + implementation "androidx.navigation:navigation-compose:2.5.3" // Camara - def camerax_version = "1.2.0-alpha04" - implementation "androidx.camera:camera-core:$camerax_version" - implementation "androidx.camera:camera-camera2:$camerax_version" - implementation "androidx.camera:camera-lifecycle:$camerax_version" - implementation "androidx.camera:camera-view:$camerax_version" + def camerax_version = "1.2.1" + implementation "androidx.camera:camera-core:${camerax_version}" + implementation "androidx.camera:camera-camera2:${camerax_version}" + implementation "androidx.camera:camera-lifecycle:${camerax_version}" + implementation "androidx.camera:camera-video:${camerax_version}" + implementation "androidx.camera:camera-view:${camerax_version}" + implementation "androidx.camera:camera-extensions:${camerax_version}" // Coroutines - implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.2' - implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.2' - implementation "org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.6.2" + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4' + implementation "org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.6.4" // Coroutine Lifecycle Scopes implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1" implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.5.1" // Coroutines - implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.2' - implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.2' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4' // Coroutine Lifecycle Scopes implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1" @@ -110,9 +112,12 @@ dependencies { implementation "com.google.maps.android:maps-compose:2.1.0" implementation "com.google.android.gms:play-services-maps:18.1.0" - implementation 'androidx.media3:media3-exoplayer:1.0.0-beta02' - implementation "androidx.media3:media3-ui:1.0.0-beta02" - implementation "io.coil-kt:coil-compose:2.1.0" + //Media3 + implementation 'androidx.media3:media3-exoplayer:1.0.0-rc01' + implementation "androidx.media3:media3-ui:1.0.0-rc01" + + //Coil + implementation "io.coil-kt:coil-compose:2.2.2" //Image Picker implementation 'com.himanshoe:pluck:1.0.0-RC1' diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index a0724ef..0364472 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -5,6 +5,7 @@ + val selected = item.route == backStackEntry.value?.destination?.route @@ -48,7 +50,7 @@ fun CustomBottomNavigation( modifier = modifier .fillMaxSize() .weight(1f) - .padding(0.dp) + .padding(top = 15.dp) .clickable { onItemClick(item) }, contentAlignment = Center ) { @@ -56,7 +58,7 @@ fun CustomBottomNavigation( if (item.onSelectedBatchVisible) { AutoSizeIcon( size = 1.dp, - tint = if (selected) item.onSelectedColor else null, + tint = if (selected) item.onSelectedColor else Color.White, icon = item.icon, factor = 15f, badgeColor = item.onSelectedColor, @@ -65,28 +67,22 @@ fun CustomBottomNavigation( isBadge = true, ) } else { - if (selected && item.name == "Camara") { - CustomCamaraOnSelectItem( - item.onSelectedColor, - configuration, - item.name - ) - } else { - AutoSizeIcon( - size = 1.dp, - icon = item.icon, - factor = 15f, - badgeColor = item.onSelectedColor, - configuration = configuration, - contentDescription = item.name, - ) - } + AutoSizeIcon( + size = 1.dp, + tint = if (selected) item.onSelectedColor else Color.White, + icon = item.icon, + factor = 15f, + badgeColor = item.onSelectedColor, + configuration = configuration, + contentDescription = item.name, + ) } - if (selected && item.name != "Camara") { + if (selected) { Icon( modifier = Modifier.height(15.dp), imageVector = Icons.Default.ArrowDropUp, - contentDescription = item.name + contentDescription = item.name, + tint = item.onSelectedColor ) } else { Spacer(modifier = Modifier.height(15.dp)) diff --git a/app/src/main/java/com/debanshu777/snapchatUIComposeClone/features/feature_camera/CamaraScreen.kt b/app/src/main/java/com/debanshu777/snapchatUIComposeClone/features/feature_camera/CamaraScreen.kt index 14d61ce..f535014 100644 --- a/app/src/main/java/com/debanshu777/snapchatUIComposeClone/features/feature_camera/CamaraScreen.kt +++ b/app/src/main/java/com/debanshu777/snapchatUIComposeClone/features/feature_camera/CamaraScreen.kt @@ -3,6 +3,7 @@ package com.debanshu777.snapchatUIComposeClone.features.feature_camera import androidx.compose.animation.ExperimentalAnimationApi import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.padding import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.Surface import androidx.compose.runtime.Composable @@ -27,6 +28,7 @@ fun CamaraScreen() { val lifecycleOwner = LocalLifecycleOwner.current Surface( modifier = Modifier + .padding(bottom = 20.dp) .clip(RoundedCornerShape(bottomEnd = 10.dp, bottomStart = 10.dp)), ) { Column( diff --git a/app/src/main/java/com/debanshu777/snapchatUIComposeClone/features/feature_camera/presentation/components/CamaraOpen.kt b/app/src/main/java/com/debanshu777/snapchatUIComposeClone/features/feature_camera/presentation/components/CamaraOpen.kt index 09ab45f..438d2da 100644 --- a/app/src/main/java/com/debanshu777/snapchatUIComposeClone/features/feature_camera/presentation/components/CamaraOpen.kt +++ b/app/src/main/java/com/debanshu777/snapchatUIComposeClone/features/feature_camera/presentation/components/CamaraOpen.kt @@ -71,7 +71,9 @@ fun SimpleCameraPreview( var flashEnabled by remember { mutableStateOf(false) } var flashRes by remember { mutableStateOf(Icons.Default.FlashOff) } val executor = ContextCompat.getMainExecutor(context) - var cameraSelector: CameraSelector? + var cameraSelector: CameraSelector = CameraSelector.Builder() + .requireLensFacing(CameraSelector.LENS_FACING_BACK) + .build() val cameraProvider = cameraProviderFuture.get() Box { @@ -84,10 +86,6 @@ fun SimpleCameraPreview( .setTargetRotation(previewView.display.rotation) .build() - val cameraSelector = CameraSelector.Builder() - .requireLensFacing(CameraSelector.LENS_FACING_BACK) - .build() - cameraProvider.unbindAll() cameraProvider.bindToLifecycle( lifecycleOwner, @@ -163,7 +161,7 @@ fun SimpleCameraPreview( cameraProvider.unbindAll() cameraProvider.bindToLifecycle( lifecycleOwner, - cameraSelector as CameraSelector, + cameraSelector, imageCapture, preview ) diff --git a/build.gradle b/build.gradle index c149172..36efdaa 100644 --- a/build.gradle +++ b/build.gradle @@ -1,17 +1,18 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { ext { - compose_version = '1.3.0-alpha03' + compose_version = '1.4.0-beta02' } repositories { google() mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:7.2.2' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10" + classpath 'com.android.tools.build:gradle:7.4.2' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.10" + classpath "com.google.dagger:hilt-android-gradle-plugin:2.41" classpath "com.google.android.libraries.mapsplatform.secrets-gradle-plugin:secrets-gradle-plugin:2.0.1" - classpath "org.jetbrains.dokka:dokka-gradle-plugin:1.6.21" + classpath "org.jetbrains.dokka:dokka-gradle-plugin:1.7.10" classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.18.1" // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/gradle.properties b/gradle.properties index 2c0ede2..4d568b5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,7 @@ # http://www.gradle.org/docs/current/userguide/build_environment.html # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. -org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 -XX:+UseParallelGC +org.gradle.jvmargs=-Xmx4608m -Dfile.encoding=UTF-8 -XX:+UseParallelGC # 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 2c07189..375ae5d 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Fri Oct 08 01:41:01 IST 2021 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME