From c633e299d895f305850edd62fb306268c4c7454f Mon Sep 17 00:00:00 2001 From: Dmytro Turskyi Date: Mon, 22 May 2023 19:17:31 -0400 Subject: [PATCH] 2.0.8(21) (#22) * changed home background * add datastore to save if user signed in * add ExpandableSearchBar.kt to TravellersActivity.kt * fix fab on travellers activity * Fix uploading photo to firestore and set sdk_version = 32 * update CI/CD * update CI/CD * update gradle and README.md * update gradle and dependencies * remove deprecated on back pressed and replaced with a new approach * remove deprecated on back pressed and replaced with a new approach * replaced deprecated getParcelable and getPackageInfo methods * upgraded koin and okhttp version * upgraded firebase_bom_version * Fix updating the the number of visited countries * upgrade koin version * add org.gradle.unsafe.configuration-cache-problems=warn * increment version to 2.0.8(21) * increment java version to 17 in ci/cd * Update dependencies --- .github/workflows/android_ci.yml | 4 +- README.md | 29 +++++++------- build.gradle | 9 +++-- data/build.gradle | 9 +++-- .../local/entities/CountryEntity.kt | 4 +- di/build.gradle | 2 + .../io/github/turskyi/domain/models/Result.kt | 17 -------- gradle.properties | 39 ++++++++++--------- gradle/wrapper/gradle-wrapper.properties | 2 +- presentation/build.gradle | 35 ++++++++++------- presentation/src/main/AndroidManifest.xml | 6 ++- .../travellingpro/common/di/KoinModules.kt | 4 +- .../view/adapter/AllCountriesAdapter.kt | 2 +- .../adapter/CountriesPositionalDataSource.kt | 6 +-- .../view/adapter/EmptyListObserver.kt | 2 +- .../FilteredCountriesPositionalDataSource.kt | 4 +- .../view/ui/AllCountriesActivity.kt | 8 ++-- .../AllCountriesActivityViewModel.kt | 6 +-- .../flags/view/adapter/FlagsAdapter.kt | 7 ++-- .../flags/view/fragments/FlagFragment.kt | 4 +- .../view/fragments/FriendFlagsFragment.kt | 7 ++-- .../home/view/ui/AddCityDialogFragment.kt | 1 + .../features/home/view/ui/HomeActivity.kt | 20 ++++++++-- .../traveller/view/TravellerActivity.kt | 3 +- .../travellers/view/TravellersActivity.kt | 2 +- .../utils/extensions/ActivityExtensions.kt | 2 - .../utils/extensions/BundleExtensions.kt | 1 + .../utils/extensions/IntentExtension.kt | 10 +++++ .../utils/extensions/LiveDataExtension.kt | 4 +- .../utils/extensions/ViewExtensions.kt | 11 +++++- .../widgets/ExpandableSearchBar.kt | 1 + .../res/layout/activity_all_countries.xml | 2 +- 32 files changed, 150 insertions(+), 113 deletions(-) delete mode 100644 domain/src/main/java/io/github/turskyi/domain/models/Result.kt rename presentation/src/main/java/io/github/turskyi/travellingpro/features/{allcountries => countries}/view/adapter/AllCountriesAdapter.kt (98%) rename presentation/src/main/java/io/github/turskyi/travellingpro/features/{allcountries => countries}/view/adapter/CountriesPositionalDataSource.kt (96%) rename presentation/src/main/java/io/github/turskyi/travellingpro/features/{allcountries => countries}/view/adapter/EmptyListObserver.kt (90%) rename presentation/src/main/java/io/github/turskyi/travellingpro/features/{allcountries => countries}/view/adapter/FilteredCountriesPositionalDataSource.kt (95%) rename presentation/src/main/java/io/github/turskyi/travellingpro/features/{allcountries => countries}/view/ui/AllCountriesActivity.kt (95%) rename presentation/src/main/java/io/github/turskyi/travellingpro/features/{allcountries => countries}/viewmodel/AllCountriesActivityViewModel.kt (93%) create mode 100644 presentation/src/main/java/io/github/turskyi/travellingpro/utils/extensions/IntentExtension.kt diff --git a/.github/workflows/android_ci.yml b/.github/workflows/android_ci.yml index f6afec7..6421efe 100644 --- a/.github/workflows/android_ci.yml +++ b/.github/workflows/android_ci.yml @@ -16,7 +16,7 @@ jobs: - name: Set up JDK environment(JDK 11) uses: actions/setup-java@v1.4.3 with: - java-version: 11 + java-version: 17 - name: Generate Release APK run: ./gradlew assembleRelease @@ -27,5 +27,5 @@ jobs: appId: ${{secrets.FIREBASE_ANDROID_APPID}} token: ${{secrets.FIREBASE_TOKEN}} groups: testers - releaseNotes: "App Build" + releaseNotes: "Travelling Pro App Build" file: presentation/build/outputs/apk/release/presentation-release.apk diff --git a/README.md b/README.md index 7f1950a..240ad9b 100644 --- a/README.md +++ b/README.md @@ -26,9 +26,7 @@ after every push to the **dev** branch, [Visual Studio App Center](https://docs.microsoft.com/en-us/appcenter/) is used to deliver new release app bundle to **Google Play** after every push to **master** branch; -• Architectural pattern: [MVVM](https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93viewmodel) -and -[Clean Architecture](https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html); +• Architectural pattern: [MVVM](https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93viewmodel); • Architecture Components: [Paging](https://developer.android.com/topic/libraries/architecture/paging), @@ -62,14 +60,19 @@ and • Api: https://restcountries.com/#api-endpoints-v2-all; +• **Code Readability:** code is easily readable such that a fellow programmer can understand the +purpose of the app, all variables, methods, and resource IDs are descriptively named such that +another developer reading the code can easily understand their function, no unnecessary blank lines, +no unused variables or methods, no commented out code. + • Screenshots: - - - - - - - - - - + + + + + + + + + + diff --git a/build.gradle b/build.gradle index 1458f31..360f96e 100644 --- a/build.gradle +++ b/build.gradle @@ -5,12 +5,13 @@ buildscript { ext { // sdk versions compile_sdk_version = 33 + skd_preview = "UpsideDownCake" build_tools_version = "30.0.3" min_sdk_version = 21 target_sdk_version = 33 // last version is here [https://play.google.com/console/u/0/developers/6867856033872987263/app/4972072127034375090/releases/overview] - version_code = 20 - version_name = "2.0.7" + version_code = 21 + version_name = "2.0.8" } repositories { google() @@ -18,8 +19,8 @@ buildscript { maven { url "https://jitpack.io" } } dependencies { - classpath 'com.android.tools.build:gradle:7.3.1' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + classpath 'com.android.tools.build:gradle:8.0.1' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.21" // Google Services plugin (used with firebase) classpath "com.google.gms:google-services:$google_services_version" // Crashlytics Gradle plugin diff --git a/data/build.gradle b/data/build.gradle index 2e7579a..85b87e9 100644 --- a/data/build.gradle +++ b/data/build.gradle @@ -2,6 +2,7 @@ plugins { id 'com.android.library' id 'kotlin-android' + id 'org.jetbrains.kotlin.android' } android { @@ -16,7 +17,6 @@ android { defaultConfig { minSdkVersion rootProject.min_sdk_version targetSdkVersion rootProject.target_sdk_version - buildConfigField "String", "HOST_URL", "\"${rootProject.HOST_URL}\"" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" @@ -34,11 +34,11 @@ android { //noinspection GroovyAssignabilityCheck //noinspection GroovyMissingReturnStatement compileOptions { - sourceCompatibility JavaVersion.VERSION_11 - targetCompatibility JavaVersion.VERSION_11 + sourceCompatibility JavaVersion.VERSION_17 + targetCompatibility JavaVersion.VERSION_17 } kotlinOptions { - jvmTarget = '11' + jvmTarget = '17' } namespace 'io.github.turskyi.data' } @@ -65,6 +65,7 @@ dependencies { // Preferences DataStore (SharedPreferences like APIs) implementation("androidx.datastore:datastore-preferences:1.0.0") + implementation 'androidx.core:core-ktx:1.10.1' // test testImplementation "junit:junit:$junit_version" diff --git a/data/src/main/java/io/github/turskyi/data/datasources/local/entities/CountryEntity.kt b/data/src/main/java/io/github/turskyi/data/datasources/local/entities/CountryEntity.kt index 4d54ce6..dce0cd3 100644 --- a/data/src/main/java/io/github/turskyi/data/datasources/local/entities/CountryEntity.kt +++ b/data/src/main/java/io/github/turskyi/data/datasources/local/entities/CountryEntity.kt @@ -8,10 +8,10 @@ data class CountryEntity( val shortName: String, val name: String, val flag: String, - // parameter to use on the "all countries" page, to show if the country was already visited + /** parameter to use on the "all countries" page, to show if the country was already visited*/ @field:JvmField val isVisited: Boolean, -){ +) { // required empty constructor for firestore serialization constructor() : this(0, "", "", "", false) } diff --git a/di/build.gradle b/di/build.gradle index 888ec61..41de11d 100644 --- a/di/build.gradle +++ b/di/build.gradle @@ -2,6 +2,7 @@ plugins { id 'com.android.library' id 'kotlin-android' + id 'org.jetbrains.kotlin.android' } android { @@ -49,6 +50,7 @@ dependencies { // Koin core features api "io.insert-koin:koin-core:$koin_core_version" + implementation 'androidx.core:core-ktx:1.10.1' // test testImplementation "junit:junit:$junit_version" diff --git a/domain/src/main/java/io/github/turskyi/domain/models/Result.kt b/domain/src/main/java/io/github/turskyi/domain/models/Result.kt deleted file mode 100644 index c2db3e3..0000000 --- a/domain/src/main/java/io/github/turskyi/domain/models/Result.kt +++ /dev/null @@ -1,17 +0,0 @@ -package io.github.turskyi.domain.models - -@Suppress("unused") -sealed class Result { - - data class Success(val data: T? = null, val responseCode: Int? = null) : - Result() - - data class Error(val exception: Exception) : Result() - - override fun toString(): String { - return when (this) { - is Success<*> -> "Success[data=$data]" - is Error -> "Error[exception=$exception]" - } - } -} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 5ad1402..408ef0f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -20,30 +20,30 @@ android.enableJetifier=true # Kotlin code style for this project: "official" or "obsolete": kotlin.code.style=official # global dependency versions -activity_version=1.6.1 -appcompat_version=1.5.1 -multidexVersion=2.0.1 -koin_android_version=3.3.2 -koin_core_version=3.3.2 +activity_version=1.7.1 +appcompat_version=1.6.1 coroutines_version=1.4.0 -kotlin_version=1.7.20 -retrofit_version=2.9.0 -paging_version=2.1.2 -material_version=1.7.0 -fragment_version=1.5.5 -okhttp_version=4.10.0 -junit_version=4.13.2 -ext_junit_version=1.1.4 -espresso_version=3.5.0 -gson_version=2.10 -jwt_version=4.2.1 +ext_junit_version=1.1.5 +espresso_version=3.5.1 +fragment_version=1.5.7 # The latest Firebase BoM version contains the latest versions of each Firebase Android library. firebase_bom_version=31.1.1 firebase_ui_auth_version=8.0.2 -play_services_basement_version=17.6.0 firebase_crashlytics_gradle_version=2.7.0 firebase_perf_version=1.4.1 +gson_version=2.10.1 google_services_version=4.3.8 +junit_version=4.13.2 +jwt_version=4.4.0 +koin_android_version=3.4.0 +koin_core_version=3.4.0 +kotlin_version=1.7.20 +multidexVersion=2.0.1 +material_version=1.9.0 +okhttp_version=4.10.0 +paging_version=2.1.2 +play_services_basement_version=17.6.0 +retrofit_version=2.9.0 # envirement variables env.HOST_URL=https://restcountries.com/ env.SIGNING_KEY_DEBUG_PATH=../keystore/travelling_debug.keystore @@ -56,4 +56,7 @@ env.SIGNING_KEY_RELEASE_KEY=travelling_release env.SIGNING_KEY_RELEASE_KEY_PASSWORD=travelling #configuration-cache org.gradle.unsafe.configuration-cache=true -org.gradle.unsafe.configuration-cache-problems=warn \ No newline at end of file +org.gradle.unsafe.configuration-cache-problems=warn +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 f1fdc56..5dc1839 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-all.zip diff --git a/presentation/build.gradle b/presentation/build.gradle index 8786ee9..8d26593 100644 --- a/presentation/build.gradle +++ b/presentation/build.gradle @@ -8,6 +8,7 @@ plugins { id 'com.google.firebase.crashlytics' id 'com.google.firebase.firebase-perf' id 'kotlin-parcelize' + id 'org.jetbrains.kotlin.android' } android { @@ -28,7 +29,7 @@ android { testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" // to ensure that the translations of Firebase library are relevant to the application - resConfigs 'en' + resourceConfigurations += ['en'] } //noinspection GroovyAssignabilityCheck signingConfigs { @@ -74,11 +75,11 @@ android { //noinspection GroovyAssignabilityCheck //noinspection GroovyMissingReturnStatement compileOptions { - sourceCompatibility JavaVersion.VERSION_11 - targetCompatibility JavaVersion.VERSION_11 + sourceCompatibility JavaVersion.VERSION_17 + targetCompatibility JavaVersion.VERSION_17 } kotlinOptions { - jvmTarget = '11' + jvmTarget = '17' } namespace 'io.github.turskyi.travellingpro' } @@ -89,6 +90,8 @@ dependencies { implementation project(":domain") implementation project(":di") + implementation(platform("org.jetbrains.kotlin:kotlin-bom:1.8.21")) + // design components implementation "com.google.android.material:material:$material_version" @@ -97,11 +100,11 @@ dependencies { // android implementation "androidx.appcompat:appcompat:$appcompat_version" - implementation 'androidx.core:core-ktx:1.9.0' + implementation 'androidx.core:core-ktx:1.10.1' // firebase - implementation 'com.google.firebase:firebase-crashlytics:18.3.2' - implementation('com.google.firebase:firebase-analytics:21.2.0') { + implementation 'com.google.firebase:firebase-crashlytics:18.3.7' + implementation('com.google.firebase:firebase-analytics:21.2.2') { // remove advertising dependency exclude module: "play-services-ads-identifier" exclude module: "play-services-measurement" @@ -110,18 +113,20 @@ dependencies { // To show authentication page with pre-implemented authentication implementation "com.firebaseui:firebase-ui-auth:$firebase_ui_auth_version" // performance tracing - implementation 'com.google.firebase:firebase-perf:20.3.0' + implementation 'com.google.firebase:firebase-perf:20.3.2' // to send notifications across devices from firebase console - implementation 'com.google.firebase:firebase-messaging:23.1.1' - implementation 'com.google.android.gms:play-services-cast-framework:21.2.0' + implementation 'com.google.firebase:firebase-messaging:23.1.2' + implementation 'com.google.android.gms:play-services-cast-framework:21.3.0' + implementation 'androidx.core:core-ktx:1.10.1' + implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1' // Glide (Image caching and management) - def glideVersion = "4.14.2" + def glideVersion = "4.15.1" kapt "com.github.bumptech.glide:compiler:$glideVersion" implementation "com.github.bumptech.glide:glide:$glideVersion" // ViewModel and LiveData - def lifecycle_version = "2.5.1" + def lifecycle_version = "2.6.1" implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version" implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version" implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycle_version" @@ -134,7 +139,7 @@ dependencies { implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:3.0.7' // Recyclerview - implementation 'androidx.recyclerview:recyclerview:1.2.1' + implementation 'androidx.recyclerview:recyclerview:1.3.0' // CardView implementation 'androidx.cardview:cardview:1.0.0' @@ -152,14 +157,14 @@ dependencies { implementation "com.google.android.gms:play-services-location:21.0.1" // Facebook SDK - def facebookVersion = "15.2.0" + def facebookVersion = "16.0.1" implementation "com.facebook.android:facebook-android-sdk:$facebookVersion" implementation "com.facebook.android:facebook-share:$facebookVersion" implementation "com.facebook.android:facebook-applinks:$facebookVersion" implementation "com.facebook.android:facebook-login:$facebookVersion" // used for animation - def lottieVersion = "5.2.0" + def lottieVersion = "6.0.0" implementation "com.airbnb.android:lottie:$lottieVersion" // Koin for Android diff --git a/presentation/src/main/AndroidManifest.xml b/presentation/src/main/AndroidManifest.xml index 99306d1..69f9f5d 100644 --- a/presentation/src/main/AndroidManifest.xml +++ b/presentation/src/main/AndroidManifest.xml @@ -21,7 +21,9 @@ - + @@ -56,7 +58,7 @@ diff --git a/presentation/src/main/java/io/github/turskyi/travellingpro/common/di/KoinModules.kt b/presentation/src/main/java/io/github/turskyi/travellingpro/common/di/KoinModules.kt index 035a5c8..f92f36b 100644 --- a/presentation/src/main/java/io/github/turskyi/travellingpro/common/di/KoinModules.kt +++ b/presentation/src/main/java/io/github/turskyi/travellingpro/common/di/KoinModules.kt @@ -3,8 +3,8 @@ package io.github.turskyi.travellingpro.common.di import io.github.turskyi.domain.interactors.CountriesInteractor import io.github.turskyi.domain.interactors.PreferenceInteractor import io.github.turskyi.domain.interactors.TravellersInteractor -import io.github.turskyi.travellingpro.features.allcountries.view.adapter.AllCountriesAdapter -import io.github.turskyi.travellingpro.features.allcountries.viewmodel.AllCountriesActivityViewModel +import io.github.turskyi.travellingpro.features.countries.view.adapter.AllCountriesAdapter +import io.github.turskyi.travellingpro.features.countries.viewmodel.AllCountriesActivityViewModel import io.github.turskyi.travellingpro.features.flags.viewmodel.FlagsFragmentViewModel import io.github.turskyi.travellingpro.features.flags.viewmodel.FriendFlagsFragmentViewModel import io.github.turskyi.travellingpro.features.home.view.HomeAdapter diff --git a/presentation/src/main/java/io/github/turskyi/travellingpro/features/allcountries/view/adapter/AllCountriesAdapter.kt b/presentation/src/main/java/io/github/turskyi/travellingpro/features/countries/view/adapter/AllCountriesAdapter.kt similarity index 98% rename from presentation/src/main/java/io/github/turskyi/travellingpro/features/allcountries/view/adapter/AllCountriesAdapter.kt rename to presentation/src/main/java/io/github/turskyi/travellingpro/features/countries/view/adapter/AllCountriesAdapter.kt index 6a27117..ad5aa6b 100644 --- a/presentation/src/main/java/io/github/turskyi/travellingpro/features/allcountries/view/adapter/AllCountriesAdapter.kt +++ b/presentation/src/main/java/io/github/turskyi/travellingpro/features/countries/view/adapter/AllCountriesAdapter.kt @@ -1,4 +1,4 @@ -package io.github.turskyi.travellingpro.features.allcountries.view.adapter +package io.github.turskyi.travellingpro.features.countries.view.adapter import android.graphics.Color import android.graphics.Paint diff --git a/presentation/src/main/java/io/github/turskyi/travellingpro/features/allcountries/view/adapter/CountriesPositionalDataSource.kt b/presentation/src/main/java/io/github/turskyi/travellingpro/features/countries/view/adapter/CountriesPositionalDataSource.kt similarity index 96% rename from presentation/src/main/java/io/github/turskyi/travellingpro/features/allcountries/view/adapter/CountriesPositionalDataSource.kt rename to presentation/src/main/java/io/github/turskyi/travellingpro/features/countries/view/adapter/CountriesPositionalDataSource.kt index 4f8d272..c606d34 100644 --- a/presentation/src/main/java/io/github/turskyi/travellingpro/features/allcountries/view/adapter/CountriesPositionalDataSource.kt +++ b/presentation/src/main/java/io/github/turskyi/travellingpro/features/countries/view/adapter/CountriesPositionalDataSource.kt @@ -1,14 +1,14 @@ -package io.github.turskyi.travellingpro.features.allcountries.view.adapter +package io.github.turskyi.travellingpro.features.countries.view.adapter import android.view.View.GONE import androidx.lifecycle.MutableLiveData import androidx.paging.PositionalDataSource import io.github.turskyi.domain.interactors.CountriesInteractor -import io.github.turskyi.travellingpro.utils.extensions.mapModelListToCountryList import io.github.turskyi.travellingpro.entities.Country +import io.github.turskyi.travellingpro.utils.extensions.mapModelListToCountryList import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.launch -import java.util.* +import java.util.Timer import kotlin.concurrent.schedule internal class CountriesPositionalDataSource( diff --git a/presentation/src/main/java/io/github/turskyi/travellingpro/features/allcountries/view/adapter/EmptyListObserver.kt b/presentation/src/main/java/io/github/turskyi/travellingpro/features/countries/view/adapter/EmptyListObserver.kt similarity index 90% rename from presentation/src/main/java/io/github/turskyi/travellingpro/features/allcountries/view/adapter/EmptyListObserver.kt rename to presentation/src/main/java/io/github/turskyi/travellingpro/features/countries/view/adapter/EmptyListObserver.kt index 1d661b1..0905a20 100644 --- a/presentation/src/main/java/io/github/turskyi/travellingpro/features/allcountries/view/adapter/EmptyListObserver.kt +++ b/presentation/src/main/java/io/github/turskyi/travellingpro/features/countries/view/adapter/EmptyListObserver.kt @@ -1,4 +1,4 @@ -package io.github.turskyi.travellingpro.features.allcountries.view.adapter +package io.github.turskyi.travellingpro.features.countries.view.adapter import android.view.View import androidx.recyclerview.widget.RecyclerView diff --git a/presentation/src/main/java/io/github/turskyi/travellingpro/features/allcountries/view/adapter/FilteredCountriesPositionalDataSource.kt b/presentation/src/main/java/io/github/turskyi/travellingpro/features/countries/view/adapter/FilteredCountriesPositionalDataSource.kt similarity index 95% rename from presentation/src/main/java/io/github/turskyi/travellingpro/features/allcountries/view/adapter/FilteredCountriesPositionalDataSource.kt rename to presentation/src/main/java/io/github/turskyi/travellingpro/features/countries/view/adapter/FilteredCountriesPositionalDataSource.kt index d49b323..62a358d 100644 --- a/presentation/src/main/java/io/github/turskyi/travellingpro/features/allcountries/view/adapter/FilteredCountriesPositionalDataSource.kt +++ b/presentation/src/main/java/io/github/turskyi/travellingpro/features/countries/view/adapter/FilteredCountriesPositionalDataSource.kt @@ -1,9 +1,9 @@ -package io.github.turskyi.travellingpro.features.allcountries.view.adapter +package io.github.turskyi.travellingpro.features.countries.view.adapter import androidx.paging.PositionalDataSource import io.github.turskyi.domain.interactors.CountriesInteractor -import io.github.turskyi.travellingpro.utils.extensions.mapModelListToCountryList import io.github.turskyi.travellingpro.entities.Country +import io.github.turskyi.travellingpro.utils.extensions.mapModelListToCountryList import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.launch diff --git a/presentation/src/main/java/io/github/turskyi/travellingpro/features/allcountries/view/ui/AllCountriesActivity.kt b/presentation/src/main/java/io/github/turskyi/travellingpro/features/countries/view/ui/AllCountriesActivity.kt similarity index 95% rename from presentation/src/main/java/io/github/turskyi/travellingpro/features/allcountries/view/ui/AllCountriesActivity.kt rename to presentation/src/main/java/io/github/turskyi/travellingpro/features/countries/view/ui/AllCountriesActivity.kt index e1a0539..281bc15 100644 --- a/presentation/src/main/java/io/github/turskyi/travellingpro/features/allcountries/view/ui/AllCountriesActivity.kt +++ b/presentation/src/main/java/io/github/turskyi/travellingpro/features/countries/view/ui/AllCountriesActivity.kt @@ -1,4 +1,4 @@ -package io.github.turskyi.travellingpro.features.allcountries.view.ui +package io.github.turskyi.travellingpro.features.countries.view.ui import android.animation.ValueAnimator import android.content.Intent @@ -17,9 +17,9 @@ import androidx.recyclerview.widget.RecyclerView import io.github.turskyi.travellingpro.R import io.github.turskyi.travellingpro.databinding.ActivityAllCountriesBinding import io.github.turskyi.travellingpro.entities.Country -import io.github.turskyi.travellingpro.features.allcountries.view.adapter.AllCountriesAdapter -import io.github.turskyi.travellingpro.features.allcountries.view.adapter.EmptyListObserver -import io.github.turskyi.travellingpro.features.allcountries.viewmodel.AllCountriesActivityViewModel +import io.github.turskyi.travellingpro.features.countries.view.adapter.AllCountriesAdapter +import io.github.turskyi.travellingpro.features.countries.view.adapter.EmptyListObserver +import io.github.turskyi.travellingpro.features.countries.viewmodel.AllCountriesActivityViewModel import io.github.turskyi.travellingpro.utils.Event import io.github.turskyi.travellingpro.utils.extensions.hideKeyboard import io.github.turskyi.travellingpro.utils.extensions.openInfoDialog diff --git a/presentation/src/main/java/io/github/turskyi/travellingpro/features/allcountries/viewmodel/AllCountriesActivityViewModel.kt b/presentation/src/main/java/io/github/turskyi/travellingpro/features/countries/viewmodel/AllCountriesActivityViewModel.kt similarity index 93% rename from presentation/src/main/java/io/github/turskyi/travellingpro/features/allcountries/viewmodel/AllCountriesActivityViewModel.kt rename to presentation/src/main/java/io/github/turskyi/travellingpro/features/countries/viewmodel/AllCountriesActivityViewModel.kt index ebb804f..0bab0bd 100644 --- a/presentation/src/main/java/io/github/turskyi/travellingpro/features/allcountries/viewmodel/AllCountriesActivityViewModel.kt +++ b/presentation/src/main/java/io/github/turskyi/travellingpro/features/countries/viewmodel/AllCountriesActivityViewModel.kt @@ -1,4 +1,4 @@ -package io.github.turskyi.travellingpro.features.allcountries.viewmodel +package io.github.turskyi.travellingpro.features.countries.viewmodel import android.view.View.GONE import android.view.View.VISIBLE @@ -9,8 +9,8 @@ import androidx.lifecycle.viewModelScope import androidx.paging.PagedList import io.github.turskyi.domain.interactors.CountriesInteractor import io.github.turskyi.travellingpro.entities.Country -import io.github.turskyi.travellingpro.features.allcountries.view.adapter.CountriesPositionalDataSource -import io.github.turskyi.travellingpro.features.allcountries.view.adapter.FilteredCountriesPositionalDataSource +import io.github.turskyi.travellingpro.features.countries.view.adapter.CountriesPositionalDataSource +import io.github.turskyi.travellingpro.features.countries.view.adapter.FilteredCountriesPositionalDataSource import io.github.turskyi.travellingpro.utils.Event import io.github.turskyi.travellingpro.utils.MainThreadExecutor import io.github.turskyi.travellingpro.utils.extensions.mapToModel diff --git a/presentation/src/main/java/io/github/turskyi/travellingpro/features/flags/view/adapter/FlagsAdapter.kt b/presentation/src/main/java/io/github/turskyi/travellingpro/features/flags/view/adapter/FlagsAdapter.kt index 780a38f..9f3a037 100644 --- a/presentation/src/main/java/io/github/turskyi/travellingpro/features/flags/view/adapter/FlagsAdapter.kt +++ b/presentation/src/main/java/io/github/turskyi/travellingpro/features/flags/view/adapter/FlagsAdapter.kt @@ -10,11 +10,12 @@ import androidx.lifecycle.LifecycleOwner import androidx.recyclerview.widget.RecyclerView import androidx.viewpager2.adapter.FragmentStateAdapter import io.github.turskyi.travellingpro.entities.Traveller -import io.github.turskyi.travellingpro.features.flags.view.callbacks.FlagsActivityView import io.github.turskyi.travellingpro.features.flags.view.FlagsActivity.Companion.EXTRA_POSITION import io.github.turskyi.travellingpro.features.flags.view.FlagsActivity.Companion.EXTRA_USER +import io.github.turskyi.travellingpro.features.flags.view.callbacks.FlagsActivityView import io.github.turskyi.travellingpro.features.flags.view.fragments.FlagFragment import io.github.turskyi.travellingpro.features.flags.view.fragments.FriendFlagsFragment +import io.github.turskyi.travellingpro.utils.extensions.parcelable import io.github.turskyi.travellingpro.utils.extensions.showReportDialog import io.github.turskyi.travellingpro.utils.extensions.toastLong @@ -43,11 +44,11 @@ class FlagsAdapter(private val activity: AppCompatActivity) : override fun getItemCount(): Int = flagsActivityViewListener?.getItemCount() ?: 0 override fun createFragment(position: Int): Fragment { - return if (activity.intent.extras != null && activity.intent.extras!!.getParcelable( + return if (activity.intent.extras != null && activity.intent.extras!!.parcelable( EXTRA_USER ) != null ) { - val traveller: Traveller = activity.intent.extras!!.getParcelable(EXTRA_USER)!! + val traveller: Traveller = activity.intent.extras!!.parcelable(EXTRA_USER)!! FriendFlagsFragment().apply { arguments = bundleOf( EXTRA_POSITION to position, diff --git a/presentation/src/main/java/io/github/turskyi/travellingpro/features/flags/view/fragments/FlagFragment.kt b/presentation/src/main/java/io/github/turskyi/travellingpro/features/flags/view/fragments/FlagFragment.kt index a78acd7..f4e0ad4 100644 --- a/presentation/src/main/java/io/github/turskyi/travellingpro/features/flags/view/fragments/FlagFragment.kt +++ b/presentation/src/main/java/io/github/turskyi/travellingpro/features/flags/view/fragments/FlagFragment.kt @@ -104,7 +104,7 @@ class FlagFragment : BaseFlagFragment() { val fileOutputStream: FileOutputStream = file.outputStream() fileOutputStream.use { inputStream.copyTo(it) } val visitedCountriesObserverForLocalPhotos: Observer> = - Observer> { visitedCountries: List -> + Observer { visitedCountries: List -> viewModel.updateSelfie( shortName = visitedCountries[position].shortName, filePath = file.absolutePath, @@ -151,7 +151,7 @@ class FlagFragment : BaseFlagFragment() { } } val visitedCountriesObserver: Observer> = - Observer> { countries: List -> + Observer { countries: List -> val position: Int = this.requireArguments().getInt(EXTRA_POSITION) if (mChangeFlagListener != null) { mChangeFlagListener!!.onChangeToolbarTitle(countries[position].title) diff --git a/presentation/src/main/java/io/github/turskyi/travellingpro/features/flags/view/fragments/FriendFlagsFragment.kt b/presentation/src/main/java/io/github/turskyi/travellingpro/features/flags/view/fragments/FriendFlagsFragment.kt index 21aacfe..b91d0e1 100644 --- a/presentation/src/main/java/io/github/turskyi/travellingpro/features/flags/view/fragments/FriendFlagsFragment.kt +++ b/presentation/src/main/java/io/github/turskyi/travellingpro/features/flags/view/fragments/FriendFlagsFragment.kt @@ -9,6 +9,7 @@ import io.github.turskyi.travellingpro.entities.VisitedCountry import io.github.turskyi.travellingpro.features.flags.view.FlagsActivity.Companion.EXTRA_POSITION import io.github.turskyi.travellingpro.features.flags.view.FlagsActivity.Companion.EXTRA_USER import io.github.turskyi.travellingpro.features.flags.viewmodel.FriendFlagsFragmentViewModel +import io.github.turskyi.travellingpro.utils.extensions.parcelable import io.github.turskyi.travellingpro.utils.extensions.toast import io.github.turskyi.travellingpro.utils.extensions.toastLong import org.koin.android.ext.android.inject @@ -20,9 +21,9 @@ class FriendFlagsFragment : BaseFlagFragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) if (this.arguments != null && this.requireArguments() - .getParcelable(EXTRA_USER) != null + .parcelable(EXTRA_USER) != null ) { - val traveller: Traveller = this.requireArguments().getParcelable(EXTRA_USER)!! + val traveller: Traveller = this.requireArguments().parcelable(EXTRA_USER)!! viewModel.setVisitedCountries(traveller.id) } else { toast(R.string.msg_not_found) @@ -45,7 +46,7 @@ class FriendFlagsFragment : BaseFlagFragment() { flagsActivityViewListener?.setLoaderVisibility(currentVisibility) } val visitedCountriesObserver: Observer> = - Observer> { countries -> + Observer { countries: List -> val position: Int = this.requireArguments().getInt(EXTRA_POSITION) if (mChangeFlagListener != null) { mChangeFlagListener!!.onChangeToolbarTitle(countries[position].title) diff --git a/presentation/src/main/java/io/github/turskyi/travellingpro/features/home/view/ui/AddCityDialogFragment.kt b/presentation/src/main/java/io/github/turskyi/travellingpro/features/home/view/ui/AddCityDialogFragment.kt index 9ad52db..e80da0a 100644 --- a/presentation/src/main/java/io/github/turskyi/travellingpro/features/home/view/ui/AddCityDialogFragment.kt +++ b/presentation/src/main/java/io/github/turskyi/travellingpro/features/home/view/ui/AddCityDialogFragment.kt @@ -33,6 +33,7 @@ import org.koin.android.ext.android.inject import java.io.IOException import java.util.* +@Suppress("unused") class AddCityDialogFragment : DialogFragment() { companion object { diff --git a/presentation/src/main/java/io/github/turskyi/travellingpro/features/home/view/ui/HomeActivity.kt b/presentation/src/main/java/io/github/turskyi/travellingpro/features/home/view/ui/HomeActivity.kt index 8840627..66da75f 100644 --- a/presentation/src/main/java/io/github/turskyi/travellingpro/features/home/view/ui/HomeActivity.kt +++ b/presentation/src/main/java/io/github/turskyi/travellingpro/features/home/view/ui/HomeActivity.kt @@ -11,7 +11,11 @@ import android.os.Handler import android.os.Looper import android.os.SystemClock import android.provider.Settings.ACTION_WIRELESS_SETTINGS -import android.view.* +import android.view.Gravity +import android.view.Menu +import android.view.MenuInflater +import android.view.MenuItem +import android.view.View import android.window.OnBackInvokedDispatcher import androidx.activity.result.ActivityResult import androidx.activity.result.ActivityResultLauncher @@ -33,7 +37,7 @@ import io.github.turskyi.travellingpro.entities.City import io.github.turskyi.travellingpro.entities.Country import io.github.turskyi.travellingpro.entities.VisitedCountry import io.github.turskyi.travellingpro.entities.VisitedCountryNode -import io.github.turskyi.travellingpro.features.allcountries.view.ui.AllCountriesActivity +import io.github.turskyi.travellingpro.features.countries.view.ui.AllCountriesActivity import io.github.turskyi.travellingpro.features.flags.view.FlagsActivity import io.github.turskyi.travellingpro.features.flags.view.FlagsActivity.Companion.EXTRA_ITEM_COUNT import io.github.turskyi.travellingpro.features.flags.view.FlagsActivity.Companion.EXTRA_POSITION @@ -43,7 +47,17 @@ import io.github.turskyi.travellingpro.features.home.viewmodels.HomeActivityView import io.github.turskyi.travellingpro.features.travellers.view.TravellersActivity import io.github.turskyi.travellingpro.utils.Event import io.github.turskyi.travellingpro.utils.decoration.SectionAverageGapItemDecoration -import io.github.turskyi.travellingpro.utils.extensions.* +import io.github.turskyi.travellingpro.utils.extensions.action +import io.github.turskyi.travellingpro.utils.extensions.getScreenWidth +import io.github.turskyi.travellingpro.utils.extensions.isOnline +import io.github.turskyi.travellingpro.utils.extensions.mapVisitedCountryNodeToCountry +import io.github.turskyi.travellingpro.utils.extensions.openActivity +import io.github.turskyi.travellingpro.utils.extensions.openActivityWithArgs +import io.github.turskyi.travellingpro.utils.extensions.openInfoDialog +import io.github.turskyi.travellingpro.utils.extensions.showSnackBar +import io.github.turskyi.travellingpro.utils.extensions.showSnackWithAction +import io.github.turskyi.travellingpro.utils.extensions.toast +import io.github.turskyi.travellingpro.utils.extensions.toastLong import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.first import kotlinx.coroutines.launch diff --git a/presentation/src/main/java/io/github/turskyi/travellingpro/features/traveller/view/TravellerActivity.kt b/presentation/src/main/java/io/github/turskyi/travellingpro/features/traveller/view/TravellerActivity.kt index 0b58903..96de970 100644 --- a/presentation/src/main/java/io/github/turskyi/travellingpro/features/traveller/view/TravellerActivity.kt +++ b/presentation/src/main/java/io/github/turskyi/travellingpro/features/traveller/view/TravellerActivity.kt @@ -20,6 +20,7 @@ import io.github.turskyi.travellingpro.features.travellers.view.TravellersActivi import io.github.turskyi.travellingpro.utils.decoration.SectionAverageGapItemDecoration import io.github.turskyi.travellingpro.utils.extensions.getScreenWidth import io.github.turskyi.travellingpro.utils.extensions.openActivityWithArgs +import io.github.turskyi.travellingpro.utils.extensions.parcelable import io.github.turskyi.travellingpro.utils.extensions.toast import io.github.turskyi.travellingpro.utils.extensions.toastLong import io.github.turskyi.travellingpro.widgets.CirclePieChart @@ -33,7 +34,7 @@ class TravellerActivity : AppCompatActivity(), TravellerActivityView { private var traveller: Traveller? = null override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - traveller = intent.getParcelableExtra(EXTRA_TRAVELLER) + traveller = intent.parcelable(EXTRA_TRAVELLER) if (traveller != null) { initView() initObservers() diff --git a/presentation/src/main/java/io/github/turskyi/travellingpro/features/travellers/view/TravellersActivity.kt b/presentation/src/main/java/io/github/turskyi/travellingpro/features/travellers/view/TravellersActivity.kt index 329df9f..aa9244e 100644 --- a/presentation/src/main/java/io/github/turskyi/travellingpro/features/travellers/view/TravellersActivity.kt +++ b/presentation/src/main/java/io/github/turskyi/travellingpro/features/travellers/view/TravellersActivity.kt @@ -13,7 +13,7 @@ import androidx.recyclerview.widget.RecyclerView import io.github.turskyi.travellingpro.R import io.github.turskyi.travellingpro.databinding.ActivityTravellersBinding import io.github.turskyi.travellingpro.entities.Traveller -import io.github.turskyi.travellingpro.features.allcountries.view.adapter.EmptyListObserver +import io.github.turskyi.travellingpro.features.countries.view.adapter.EmptyListObserver import io.github.turskyi.travellingpro.features.traveller.view.TravellerActivity import io.github.turskyi.travellingpro.features.travellers.TravellersActivityViewModel import io.github.turskyi.travellingpro.features.travellers.view.adapter.TravellersAdapter diff --git a/presentation/src/main/java/io/github/turskyi/travellingpro/utils/extensions/ActivityExtensions.kt b/presentation/src/main/java/io/github/turskyi/travellingpro/utils/extensions/ActivityExtensions.kt index e5237fe..d78a154 100644 --- a/presentation/src/main/java/io/github/turskyi/travellingpro/utils/extensions/ActivityExtensions.kt +++ b/presentation/src/main/java/io/github/turskyi/travellingpro/utils/extensions/ActivityExtensions.kt @@ -1,5 +1,3 @@ -@file:Suppress("unused") - package io.github.turskyi.travellingpro.utils.extensions import android.app.Activity diff --git a/presentation/src/main/java/io/github/turskyi/travellingpro/utils/extensions/BundleExtensions.kt b/presentation/src/main/java/io/github/turskyi/travellingpro/utils/extensions/BundleExtensions.kt index 441b8e0..058c2b3 100644 --- a/presentation/src/main/java/io/github/turskyi/travellingpro/utils/extensions/BundleExtensions.kt +++ b/presentation/src/main/java/io/github/turskyi/travellingpro/utils/extensions/BundleExtensions.kt @@ -4,6 +4,7 @@ import android.os.Build.VERSION.SDK_INT import android.os.Bundle import android.os.Parcelable +@Suppress("SameParameterValue", "SameParameterValue", "SameParameterValue") inline fun Bundle.parcelable(key: String): T? = when { SDK_INT >= 33 -> getParcelable(key, T::class.java) else -> @Suppress("DEPRECATION") getParcelable(key) as? T diff --git a/presentation/src/main/java/io/github/turskyi/travellingpro/utils/extensions/IntentExtension.kt b/presentation/src/main/java/io/github/turskyi/travellingpro/utils/extensions/IntentExtension.kt new file mode 100644 index 0000000..5aa5463 --- /dev/null +++ b/presentation/src/main/java/io/github/turskyi/travellingpro/utils/extensions/IntentExtension.kt @@ -0,0 +1,10 @@ +package io.github.turskyi.travellingpro.utils.extensions + +import android.content.Intent +import android.os.Build.VERSION.SDK_INT +import android.os.Parcelable + +inline fun Intent.parcelable(key: String): T? = when { + SDK_INT >= 33 -> getParcelableExtra(key, T::class.java) + else -> @Suppress("DEPRECATION") getParcelableExtra(key) as? T +} \ No newline at end of file diff --git a/presentation/src/main/java/io/github/turskyi/travellingpro/utils/extensions/LiveDataExtension.kt b/presentation/src/main/java/io/github/turskyi/travellingpro/utils/extensions/LiveDataExtension.kt index ee629cd..ff65c1a 100644 --- a/presentation/src/main/java/io/github/turskyi/travellingpro/utils/extensions/LiveDataExtension.kt +++ b/presentation/src/main/java/io/github/turskyi/travellingpro/utils/extensions/LiveDataExtension.kt @@ -6,8 +6,8 @@ import androidx.lifecycle.Observer fun LiveData.observeOnce(lifecycleOwner: LifecycleOwner, observer: Observer) { observe(lifecycleOwner, object : Observer { - override fun onChanged(t: T?) { - observer.onChanged(t) + override fun onChanged(value: T) { + observer.onChanged(value) removeObserver(this) } }) diff --git a/presentation/src/main/java/io/github/turskyi/travellingpro/utils/extensions/ViewExtensions.kt b/presentation/src/main/java/io/github/turskyi/travellingpro/utils/extensions/ViewExtensions.kt index f017af3..62bbfc0 100644 --- a/presentation/src/main/java/io/github/turskyi/travellingpro/utils/extensions/ViewExtensions.kt +++ b/presentation/src/main/java/io/github/turskyi/travellingpro/utils/extensions/ViewExtensions.kt @@ -8,6 +8,7 @@ import android.graphics.Bitmap import android.graphics.Canvas import android.graphics.Color import android.net.Uri +import android.os.Build import android.view.View import android.widget.TextView import android.widget.Toast @@ -106,7 +107,15 @@ fun View.shareImageViaChooser() { ) val resInfoList: List = - context.packageManager.queryIntentActivities(chooser, PackageManager.MATCH_DEFAULT_ONLY) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + context.packageManager.queryIntentActivities( + chooser, + PackageManager.ResolveInfoFlags.of(PackageManager.MATCH_DEFAULT_ONLY.toLong()), + ) + } else { + @Suppress("DEPRECATION") + context.packageManager.queryIntentActivities(chooser, PackageManager.MATCH_DEFAULT_ONLY) + } for (resolveInfo in resInfoList) { val packageName = resolveInfo.activityInfo.packageName diff --git a/presentation/src/main/java/io/github/turskyi/travellingpro/widgets/ExpandableSearchBar.kt b/presentation/src/main/java/io/github/turskyi/travellingpro/widgets/ExpandableSearchBar.kt index 43d07a9..025ae26 100644 --- a/presentation/src/main/java/io/github/turskyi/travellingpro/widgets/ExpandableSearchBar.kt +++ b/presentation/src/main/java/io/github/turskyi/travellingpro/widgets/ExpandableSearchBar.kt @@ -433,6 +433,7 @@ class ExpandableSearchBar(context: Context, attrs: AttributeSet) : ConstraintLay * * @param buttonCode [.BUTTON_NAVIGATION], [.BUTTON_SPEECH] or [.BUTTON_BACK] will be passed */ + @Suppress("EmptyMethod") fun onButtonClicked(buttonCode: Int) } } diff --git a/presentation/src/main/res/layout/activity_all_countries.xml b/presentation/src/main/res/layout/activity_all_countries.xml index e95cf83..b79923b 100644 --- a/presentation/src/main/res/layout/activity_all_countries.xml +++ b/presentation/src/main/res/layout/activity_all_countries.xml @@ -3,7 +3,7 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tool="http://schemas.android.com/tools" style="@style/CoordinatorLayoutStyle" - tool:context=".features.allcountries.view.ui.AllCountriesActivity" + tool:context=".features.countries.view.ui.AllCountriesActivity" tool:keep="@layout/activity_all_countries">