diff --git a/.github/workflows/ci_pipeline.yml b/.github/workflows/ci_pipeline.yml new file mode 100644 index 0000000..0b84a1f --- /dev/null +++ b/.github/workflows/ci_pipeline.yml @@ -0,0 +1,34 @@ +name: cute-cat-gallery-ci-pipeline +on: + pull_request: + branches: [main] + push: + branches: [main] +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4.1.0 + - name: Setup Java JDK + uses: actions/setup-java@v3.13.0 + with: + java-version: '17' + distribution: 'adopt' + - name: Make gradlew executable + run: chmod +x ./gradlew + - name: Gradle Build Action + uses: gradle/gradle-build-action@v2.9.0 + with: + arguments: build + gradle-version: 7.6 + - name: Run Tests + uses: gradle/gradle-build-action@v2.9.0 + with: + arguments: test + gradle-version: 7.6 + - name: Upload a Build Artifact + uses: actions/upload-artifact@v3.1.3 + with: + name: CuteCatsGallery + path: app/build/outputs/apk/debug/app-debug.apk diff --git a/.gitignore b/.gitignore index fe9ad7b..276b709 100644 --- a/.gitignore +++ b/.gitignore @@ -334,4 +334,5 @@ $RECYCLE.BIN/ # Windows shortcuts *.lnk -# End of https://www.gitignore.io/api/java,linux,macos,windows,android,intellij,androidstudio \ No newline at end of file +# End of https://www.gitignore.io/api/java,linux,macos,windows,android,intellij,androidstudio +/.idea/ diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml deleted file mode 100644 index 7e340a7..0000000 --- a/.idea/kotlinc.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - \ No newline at end of file diff --git a/README.md b/README.md index e495984..a718d52 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,118 @@ -# Cute Cats Gallery + -Galeria de gatinhos fofos - -
- +[![Contributors][contributors-shield]][contributors-url] +[![Forks][forks-shield]][forks-url] +[![Stargazers][stars-shield]][stars-url] +[![Issues][issues-shield]][issues-url] +[![MIT License][license-shield]][license-url] +[![LinkedIn][linkedin-shield]][linkedin-url] + +
+
+ + Logo + + +

Cute Cats Gallery

+
+ +
+ Table of Contents +
    +
  1. + About The Project + +
  2. +
  3. + Getting Started + +
  4. +
  5. Usage
  6. +
  7. Roadmap
  8. +
  9. Contributing
  10. +
  11. License
  12. +
  13. Contact
  14. +
  15. Acknowledgments
  16. +
+
+ +## About The Project +
+
+ +### Built With + +* Kotlin +* Android Studio +* View Model +* Coroutines +* View Binding +* Koin +* Glide +* Retrofit +* Gson + +## Clone project + +```git clone https://github.dev/Louiixx-h/cute-cats-gallery-app``` + +## Contributing + +Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**. + +If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "improvement". +Don't forget to give the project a star! Thanks again! + +1. Fork the Project +2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`) +3. Commit your Changes (`git commit -m 'feat: Add some AmazingFeature'`) +4. Push to the Branch (`git push origin feature/AmazingFeature`) +5. Open a Pull Request + +## Contact + +Luis Henrique da Silva Moreira - [luis-henrique.dev](https://luis-henrique.dev/) - louix.sm@gmail.com + +Project Link: [https://github.dev/Louiixx-h/cute-cats-gallery-app](https://github.dev/Louiixx-h/cute-cats-gallery-app) + + + + +[contributors-shield]: https://img.shields.io/github/contributors/othneildrew/Best-README-Template.svg?style=for-the-badge +[contributors-url]: https://github.com/othneildrew/Best-README-Template/graphs/contributors +[forks-shield]: https://img.shields.io/github/forks/othneildrew/Best-README-Template.svg?style=for-the-badge +[forks-url]: https://github.com/othneildrew/Best-README-Template/network/members +[stars-shield]: https://img.shields.io/github/stars/othneildrew/Best-README-Template.svg?style=for-the-badge +[stars-url]: https://github.com/othneildrew/Best-README-Template/stargazers +[issues-shield]: https://img.shields.io/github/issues/othneildrew/Best-README-Template.svg?style=for-the-badge +[issues-url]: https://github.com/othneildrew/Best-README-Template/issues +[license-shield]: https://img.shields.io/github/license/othneildrew/Best-README-Template.svg?style=for-the-badge +[license-url]: https://github.com/othneildrew/Best-README-Template/blob/master/LICENSE.txt +[linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg?style=for-the-badge&logo=linkedin&colorB=555 +[linkedin-url]: https://linkedin.com/in/luishenr-m +[product-screenshot]: images/screenshot.png +[Next.js]: https://img.shields.io/badge/next.js-000000?style=for-the-badge&logo=nextdotjs&logoColor=white +[Next-url]: https://nextjs.org/ +[React.js]: https://img.shields.io/badge/React-20232A?style=for-the-badge&logo=react&logoColor=61DAFB +[React-url]: https://reactjs.org/ +[Vue.js]: https://img.shields.io/badge/Vue.js-35495E?style=for-the-badge&logo=vuedotjs&logoColor=4FC08D +[Vue-url]: https://vuejs.org/ +[Angular.io]: https://img.shields.io/badge/Angular-DD0031?style=for-the-badge&logo=angular&logoColor=white +[Angular-url]: https://angular.io/ +[Svelte.dev]: https://img.shields.io/badge/Svelte-4A4A55?style=for-the-badge&logo=svelte&logoColor=FF3E00 +[Svelte-url]: https://svelte.dev/ +[Laravel.com]: https://img.shields.io/badge/Laravel-FF2D20?style=for-the-badge&logo=laravel&logoColor=white +[Laravel-url]: https://laravel.com +[Bootstrap.com]: https://img.shields.io/badge/Bootstrap-563D7C?style=for-the-badge&logo=bootstrap&logoColor=white +[Bootstrap-url]: https://getbootstrap.com +[JQuery.com]: https://img.shields.io/badge/jQuery-0769AD?style=for-the-badge&logo=jquery&logoColor=white +[JQuery-url]: https://jquery.com + diff --git a/app/build.gradle b/app/build.gradle index 2cba4bc..f433448 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -4,7 +4,7 @@ plugins { } android { - compileSdk 31 + compileSdk 33 viewBinding { enabled = true @@ -13,7 +13,7 @@ android { defaultConfig { applicationId "com.luishenrique.cutecatsgallery" minSdk 21 - targetSdk 31 + targetSdkVersion 33 versionCode 1 versionName "1.0" @@ -27,12 +27,13 @@ android { } } compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 + sourceCompatibility JavaVersion.VERSION_17 + targetCompatibility JavaVersion.VERSION_17 } kotlinOptions { - jvmTarget = '1.8' + jvmTarget = '17' } + namespace 'com.luishenrique.cutecatsgallery' } dependencies { diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index d127b9f..e07327e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,10 +1,10 @@ - + + () { -// override fun onResourceReady( -// resource: Drawable, -// transition: Transition? -// ) { -// val bitmap: Bitmap = (resource as BitmapDrawable).bitmap -// Toast.makeText( -// context, -// "Salvando imagem...", -// Toast.LENGTH_SHORT -// ).show() -// saveImage(bitmap, dir, fileName) -// } -// override fun onLoadCleared(placeholder: Drawable?) {} -// override fun onLoadFailed(errorDrawable: Drawable?) {} -// }) + if (imageURL.isNullOrBlank() || !verifyPermissions()) return + val dirPath: String = run { + Environment.getExternalStorageDirectory().absolutePath + + "/" + context.getString(R.string.app_name_storage) + } + val dir = File(dirPath) + val fileName: String = imageURL.substring( + imageURL.lastIndexOf('/') + 1 + ) + + Glide.with(context) + .load(imageURL) + .into(object : CustomTarget() { + override fun onResourceReady( + resource: Drawable, + transition: Transition? + ) { + val bitmap: Bitmap = (resource as BitmapDrawable).bitmap + Toast.makeText( + context, + "Salvando imagem...", + Toast.LENGTH_SHORT + ).show() + saveImage(bitmap, dir, fileName) + } + override fun onLoadCleared(placeholder: Drawable?) {} + override fun onLoadFailed(errorDrawable: Drawable?) {} + }) } private fun saveImage(image: Bitmap, storageDir: File, imageFileName: String) { diff --git a/app/src/main/java/com/luishenrique/cutecatsgallery/ui/view/HomeActivity.kt b/app/src/main/kotlin/com/luishenrique/cutecatsgallery/ui/view/HomeActivity.kt similarity index 100% rename from app/src/main/java/com/luishenrique/cutecatsgallery/ui/view/HomeActivity.kt rename to app/src/main/kotlin/com/luishenrique/cutecatsgallery/ui/view/HomeActivity.kt diff --git a/app/src/main/java/com/luishenrique/cutecatsgallery/ui/viewmodel/HomeViewModel.kt b/app/src/main/kotlin/com/luishenrique/cutecatsgallery/ui/viewmodel/HomeViewModel.kt similarity index 100% rename from app/src/main/java/com/luishenrique/cutecatsgallery/ui/viewmodel/HomeViewModel.kt rename to app/src/main/kotlin/com/luishenrique/cutecatsgallery/ui/viewmodel/HomeViewModel.kt diff --git a/build.gradle b/build.gradle index d3d4e87..7582246 100644 --- a/build.gradle +++ b/build.gradle @@ -5,8 +5,9 @@ buildscript { mavenCentral() } dependencies { - classpath "com.android.tools.build:gradle:7.0.4" - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.30" + def gradle_version = "7.4.2" + classpath "com.android.tools.build:gradle:$gradle_version" + classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.21' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/domain/build.gradle b/domain/build.gradle index 02629ef..9b9a4b0 100644 --- a/domain/build.gradle +++ b/domain/build.gradle @@ -4,13 +4,11 @@ plugins { } android { - compileSdk 31 + compileSdk 33 defaultConfig { minSdk 21 - targetSdk 31 - versionCode 1 - versionName "1.0" + targetSdkVersion 33 testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" consumerProguardFiles "consumer-rules.pro" @@ -23,12 +21,13 @@ android { } } compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 + sourceCompatibility JavaVersion.VERSION_17 + targetCompatibility JavaVersion.VERSION_17 } kotlinOptions { - jvmTarget = '1.8' + jvmTarget = '17' } + namespace 'com.luishenrique.domain' } dependencies { diff --git a/domain/src/main/AndroidManifest.xml b/domain/src/main/AndroidManifest.xml index df895ba..a5918e6 100644 --- a/domain/src/main/AndroidManifest.xml +++ b/domain/src/main/AndroidManifest.xml @@ -1,5 +1,4 @@ - + \ No newline at end of file diff --git a/domain/src/main/java/com/luishenrique/domain/ApiService.kt b/domain/src/main/kotlin/com/luishenrique/domain/ApiService.kt similarity index 100% rename from domain/src/main/java/com/luishenrique/domain/ApiService.kt rename to domain/src/main/kotlin/com/luishenrique/domain/ApiService.kt diff --git a/domain/src/main/java/com/luishenrique/domain/di/AppModule.kt b/domain/src/main/kotlin/com/luishenrique/domain/di/AppModule.kt similarity index 100% rename from domain/src/main/java/com/luishenrique/domain/di/AppModule.kt rename to domain/src/main/kotlin/com/luishenrique/domain/di/AppModule.kt diff --git a/domain/src/main/java/com/luishenrique/domain/entity/Gallery.kt b/domain/src/main/kotlin/com/luishenrique/domain/entity/Gallery.kt similarity index 100% rename from domain/src/main/java/com/luishenrique/domain/entity/Gallery.kt rename to domain/src/main/kotlin/com/luishenrique/domain/entity/Gallery.kt diff --git a/domain/src/main/java/com/luishenrique/domain/handle/Result.kt b/domain/src/main/kotlin/com/luishenrique/domain/handle/Result.kt similarity index 100% rename from domain/src/main/java/com/luishenrique/domain/handle/Result.kt rename to domain/src/main/kotlin/com/luishenrique/domain/handle/Result.kt diff --git a/domain/src/main/java/com/luishenrique/domain/repository/GalleryRepository.kt b/domain/src/main/kotlin/com/luishenrique/domain/repository/GalleryRepository.kt similarity index 100% rename from domain/src/main/java/com/luishenrique/domain/repository/GalleryRepository.kt rename to domain/src/main/kotlin/com/luishenrique/domain/repository/GalleryRepository.kt diff --git a/domain/src/main/java/com/luishenrique/domain/repository/GalleryRepositoryImpl.kt b/domain/src/main/kotlin/com/luishenrique/domain/repository/GalleryRepositoryImpl.kt similarity index 100% rename from domain/src/main/java/com/luishenrique/domain/repository/GalleryRepositoryImpl.kt rename to domain/src/main/kotlin/com/luishenrique/domain/repository/GalleryRepositoryImpl.kt diff --git a/domain/src/main/java/com/luishenrique/domain/usecase/GalleryUseCase.kt b/domain/src/main/kotlin/com/luishenrique/domain/usecase/GalleryUseCase.kt similarity index 100% rename from domain/src/main/java/com/luishenrique/domain/usecase/GalleryUseCase.kt rename to domain/src/main/kotlin/com/luishenrique/domain/usecase/GalleryUseCase.kt diff --git a/domain/src/main/java/com/luishenrique/domain/usecase/GalleryUseCaseImpl.kt b/domain/src/main/kotlin/com/luishenrique/domain/usecase/GalleryUseCaseImpl.kt similarity index 100% rename from domain/src/main/java/com/luishenrique/domain/usecase/GalleryUseCaseImpl.kt rename to domain/src/main/kotlin/com/luishenrique/domain/usecase/GalleryUseCaseImpl.kt diff --git a/gradle.properties b/gradle.properties index 98bed16..8145fa7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -18,4 +18,7 @@ android.useAndroidX=true # Automatically convert third-party libraries to use AndroidX android.enableJetifier=true # Kotlin code style for this project: "official" or "obsolete": -kotlin.code.style=official \ No newline at end of file +kotlin.code.style=official +android.defaults.buildfeatures.buildconfig=true +android.nonTransitiveRClass=false +android.nonFinalResIds=false \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ffed3a2..f42e62f 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-7.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists