From 2561b6ddf97b8b07cbfab98c25761de2db083b4c Mon Sep 17 00:00:00 2001 From: "h.malik144@gmail.com" Date: Mon, 24 Jun 2024 18:30:31 +0100 Subject: [PATCH] - Removal of kotlin synthetics - Upgrade gradle to 8.0.0 - Change dependency versioning --- app/build.gradle | 137 ++++++++---------- .../atlas_weather/application/TestAppClass.kt | 1 - .../atlas_weather/ui/WorldItemFragment.kt | 5 +- .../ui/details/FurtherInfoFragment.kt | 19 ++- .../atlas_weather/ui/home/HomeFragment.kt | 16 +- .../ui/world/AddLocationFragment.kt | 9 +- .../atlas_weather/ui/world/WorldFragment.kt | 8 +- app/src/main/AndroidManifest.xml | 3 +- .../h_mal/atlas_weather/base/BaseActivity.kt | 1 + .../h_mal/atlas_weather/ui/MainActivity.kt | 4 +- .../h_mal/atlas_weather/utils/ViewUtils.kt | 65 +++++++++ .../atlas_weather/application/MonoApp.kt | 5 +- .../h_mal/monoWeather/ui/WorldItemFragment.kt | 15 +- .../ui/details/FurtherInfoFragment.kt | 22 +-- .../h_mal/monoWeather/ui/home/HomeFragment.kt | 13 +- .../ui/home/adapter/further/GridAdapter.kt | 10 +- .../WidgetLocationPermissionActivity.kt | 9 +- .../ui/world/AddLocationFragment.kt | 13 +- .../monoWeather/ui/world/WorldFragment.kt | 11 +- build.gradle | 19 +-- gradle.properties | 49 ++++++- gradle/wrapper/gradle-wrapper.properties | 2 +- 22 files changed, 270 insertions(+), 166 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 088fe52..99906a4 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,7 +1,6 @@ plugins { id 'com.android.application' id 'org.jetbrains.kotlin.android' - id 'kotlin-android-extensions' id 'kotlin-kapt' id 'androidx.navigation.safeargs' } @@ -13,14 +12,12 @@ def relKeyAlias = System.getenv("RELEASE_KEY_ALIAS") def keystorePath = System.getenv('PWD') + "/app/keystore.jks" def keystore = file(keystorePath).exists() ? file(keystorePath) : null android { - lintOptions { - abortOnError false - } + namespace 'com.appttude.h_mal.atlas_weather' + compileSdk 33 defaultConfig { applicationId "com.appttude.h_mal.atlas_weather" - compileSdk 33 - minSdkVersion 26 - targetSdkVersion 33 + minSdkVersion MIN_SDK_VERSION + targetSdkVersion TARGET_SDK_VERSION versionCode 5 versionName "3.0" testInstrumentationRunner "com.appttude.h_mal.atlas_weather.application.TestRunner" @@ -78,7 +75,7 @@ android { kotlinOptions { jvmTarget = "1.8" freeCompilerArgs += [ - '-Xjvm-default=enable' + '-Xjvm-default=all-compatibility' ] } @@ -91,7 +88,6 @@ android { } monoWeather { applicationId "com.appttude.h_mal.monoWeather" - versionCode 7 versionName "4.2.0" } @@ -108,105 +104,90 @@ android { } } } + lint { + abortOnError false + } } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation 'androidx.appcompat:appcompat:1.6.1' - implementation 'com.google.android.material:material:1.2.1' - implementation 'androidx.constraintlayout:constraintlayout:1.1.3' - implementation 'androidx.fragment:fragment:1.2.0' - implementation 'androidx.legacy:legacy-support-v4:1.0.0' - implementation 'com.nostra13.universalimageloader:universal-image-loader:1.9.5' + implementation "androidx.appcompat:appcompat:$MATERIAL_VERSION" + implementation "com.google.android.material:material:$MATERIAL_VERSION" + implementation "androidx.constraintlayout:constraintlayout:$CONSTR_LAYOUT_VERSION" + implementation "androidx.fragment:fragment:$FRAGMENT_VERSION" + implementation "androidx.legacy:legacy-support-v4:$LEGACY_SUPPORT_VERSION" implementation 'androidx.vectordrawable:vectordrawable:1.1.0' - implementation "com.google.android.gms:play-services-location:21.0.1" - implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation "com.google.android.gms:play-services-location:$GOOGLE_PLAY_SERVICE" + implementation "org.jetbrains.kotlin:kotlin-stdlib:$KOTLIN_VERSION" implementation 'androidx.cardview:cardview:1.0.0' - implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.2' - implementation 'androidx.preference:preference:1.2.1' - testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.1' + implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$KOTLINX_COROUTINES" + implementation "androidx.preference:preference:$PREFERENCES_VERSION" / * Unit testing * / - testImplementation 'junit:junit:4.13.2' - androidTestImplementation "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version" - testImplementation "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version" - implementation "org.jetbrains.kotlin:kotlin-test:$kotlin_version" + testImplementation "junit:junit:$JUNIT_VERSION" + testImplementation "org.jetbrains.kotlin:kotlin-test-junit:$KOTLIN_VERSION" + implementation "org.jetbrains.kotlin:kotlin-test:$KOTLIN_VERSION" + androidTestImplementation "junit:junit:$JUNIT_VERSION" + testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$KOTLINX_COROUTINES" + testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$KOTLINX_COROUTINES" / * Fragment Navigation * / - implementation 'androidx.navigation:navigation-fragment-ktx:2.3.2' - implementation 'androidx.navigation:navigation-ui-ktx:2.3.2' + implementation "androidx.navigation:navigation-fragment-ktx:$NAVIGATION_VERSION" + implementation "androidx.navigation:navigation-ui-ktx:$NAVIGATION_VERSION" / * android unit testing and espresso * / - androidTestImplementation 'androidx.test:rules:1.5.0' - androidTestImplementation "androidx.test:core:1.5.0" - - / * Android Espresso * / - def testJunitVersion = "1.1.5" - def testRunnerVersion = "1.5.2" - def espressoVersion = "3.5.1" - androidTestImplementation "androidx.test.ext:junit:$testJunitVersion" - androidTestImplementation "androidx.test.espresso:espresso-core:$espressoVersion" - androidTestImplementation "androidx.test.espresso.idling:idling-concurrent:$espressoVersion" - implementation "androidx.test.espresso:espresso-idling-resource:$espressoVersion" - androidTestImplementation "androidx.test:runner:$testRunnerVersion" - androidTestImplementation "androidx.test.espresso:espresso-contrib:$espressoVersion" - androidTestImplementation "androidx.test.espresso:espresso-intents:$espressoVersion" - androidTestImplementation "org.hamcrest:hamcrest:2.2" + androidTestImplementation "androidx.test:rules:$TEST_KTX_VERSION" + androidTestImplementation 'androidx.test:core:1.5.0' + androidTestImplementation 'androidx.test:monitor:1.6.1' + androidTestImplementation "androidx.test.ext:junit:$TEST_JUNIT_VERSION" + androidTestImplementation "org.jetbrains.kotlin:kotlin-test-junit:$KOTLIN_VERSION" + androidTestImplementation "androidx.test.espresso:espresso-core:$ESPRESSO_VERSION" + implementation "androidx.test.espresso:espresso-idling-resource:$ESPRESSO_VERSION" + androidTestImplementation "androidx.test:runner:$TEST_RUNNER_VERSION" + androidTestImplementation "androidx.test.espresso:espresso-contrib:$ESPRESSO_VERSION" + androidTestImplementation "androidx.test.espresso:espresso-intents:$ESPRESSO_VERSION" + androidTestImplementation "org.hamcrest:hamcrest:$HAMCREST_VERSION" + androidTestImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$KOTLINX_COROUTINES" + / * Universal Image loader */ + implementation 'com.nostra13.universalimageloader:universal-image-loader:1.9.5' / * mock websever for testing retrofit responses * / testImplementation "com.squareup.okhttp3:mockwebserver:4.6.0" testImplementation "com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0" - / * mockito and livedata testing * / - testImplementation 'org.mockito:mockito-inline:2.13.0' - implementation 'androidx.arch.core:core-testing:2.2.0' - + testImplementation "org.mockito:mockito-inline:$MOKITO_INLINE_VERSION" + testImplementation "androidx.arch.core:core-testing:$CORE_TEST_VERSION" + testImplementation 'org.mockito:mockito-core:2.19.0' + androidTestImplementation 'org.mockito:mockito-core:2.19.0' + androidTestImplementation "androidx.arch.core:core-testing:$CORE_TEST_VERSION" / * MockK * / - def mockk_ver = "1.10.5" - testImplementation "io.mockk:mockk:$mockk_ver" - androidTestImplementation "io.mockk:mockk-android:$mockk_ver" - + testImplementation "io.mockk:mockk:$MOCKK_VERSION" + androidTestImplementation "io.mockk:mockk-android:$MOCKK_VERSION" / * Retrofit * / def retrofit_ver = "2.9.0" implementation "com.squareup.retrofit2:retrofit:$retrofit_ver" implementation "com.squareup.retrofit2:converter-gson:$retrofit_ver" implementation "com.squareup.okhttp3:logging-interceptor:4.9.0" - / * Shared prefs * / - def prefs_ver = "1.2.0" - implementation "androidx.preference:preference-ktx:$prefs_ver" - - / *Kodein Dependency Injection * / - def kodein_version = "6.2.1" - implementation "org.kodein.di:kodein-di-generic-jvm:$kodein_version" - implementation "org.kodein.di:kodein-di-framework-android-x:$kodein_version" - + implementation "androidx.preference:preference-ktx:$PREFERENCES_VERSION" + / * Kodein Dependency Injection * / + implementation "org.kodein.di:kodein-di-generic-jvm:$KODEIN_VERSION" + implementation "org.kodein.di:kodein-di-framework-android-x:$KODEIN_VERSION" / * Room database * / - def room_version = "2.4.3" - implementation "androidx.room:room-runtime:$room_version" - kapt "androidx.room:room-compiler:$room_version" - implementation "androidx.room:room-ktx:$room_version" - + runtimeOnly "androidx.room:room-runtime:$ROOM_VERSION" + kapt "androidx.room:room-compiler:$ROOM_VERSION" + implementation "androidx.room:room-ktx:$ROOM_VERSION" / * Picasso * / implementation 'com.squareup.picasso:picasso:2.71828' - / * coroutine * / - def coroutine_version = "1.3.9" - implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutine_version" - + implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$KOTLINX_COROUTINES" / * tomtom search * / - def tomtom_version = "2.4771" - implementation "com.tomtom.online:sdk-search:$tomtom_version" - implementation "com.tomtom.online:sdk-maps:2.4807" - + implementation "com.tomtom.online:sdk-search:$TOMTOM_VERSION" + implementation "com.tomtom.online:sdk-maps:$TOMTOM_VERSION" / * coroutines support for firebase operations * / - def coroutines_google_ver = "1.6.4" - implementation "org.jetbrains.kotlinx:kotlinx-coroutines-play-services:$coroutines_google_ver" - + implementation "org.jetbrains.kotlinx:kotlinx-coroutines-play-services:$KOTLINX_COROUTINES" / * Picasso * / implementation 'com.squareup.picasso:picasso:2.71828' - / * screenshot library * / androidTestImplementation 'tools.fastlane:screengrab:2.1.1' / * Permissions dispatcher * / - def dispatcher_ver = "4.9.2" - implementation "com.github.permissions-dispatcher:permissionsdispatcher:${dispatcher_ver}" - kapt "com.github.permissions-dispatcher:permissionsdispatcher-processor:${dispatcher_ver}" + implementation "com.github.permissions-dispatcher:permissionsdispatcher:$PERMISSIONS_DISPATCHER" + kapt "com.github.permissions-dispatcher:permissionsdispatcher-processor:$PERMISSIONS_DISPATCHER" } diff --git a/app/src/androidTestMonoWeather/java/com/appttude/h_mal/atlas_weather/application/TestAppClass.kt b/app/src/androidTestMonoWeather/java/com/appttude/h_mal/atlas_weather/application/TestAppClass.kt index cdb697d..ef1122f 100644 --- a/app/src/androidTestMonoWeather/java/com/appttude/h_mal/atlas_weather/application/TestAppClass.kt +++ b/app/src/androidTestMonoWeather/java/com/appttude/h_mal/atlas_weather/application/TestAppClass.kt @@ -1,6 +1,5 @@ package com.appttude.h_mal.atlas_weather.application -import MonoApp import androidx.room.Room import androidx.test.espresso.IdlingRegistry import androidx.test.espresso.idling.CountingIdlingResource diff --git a/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/ui/WorldItemFragment.kt b/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/ui/WorldItemFragment.kt index 49a23f0..475bd6b 100644 --- a/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/ui/WorldItemFragment.kt +++ b/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/ui/WorldItemFragment.kt @@ -6,11 +6,12 @@ import android.view.View import android.view.ViewGroup import androidx.fragment.app.Fragment import androidx.recyclerview.widget.LinearLayoutManager +import androidx.recyclerview.widget.RecyclerView import com.appttude.h_mal.atlas_weather.R import com.appttude.h_mal.atlas_weather.model.forecast.WeatherDisplay import com.appttude.h_mal.atlas_weather.ui.home.adapter.WeatherRecyclerAdapter import com.appttude.h_mal.atlas_weather.utils.navigateTo -import kotlinx.android.synthetic.main.fragment_home.* + class WorldItemFragment : Fragment() { @@ -40,7 +41,7 @@ class WorldItemFragment : Fragment() { param1?.let { recyclerAdapter.addCurrent(it) } - forecast_listview.apply { + view.findViewById(R.id.forecast_listview).apply { layoutManager = LinearLayoutManager(context) adapter = recyclerAdapter } diff --git a/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/ui/details/FurtherInfoFragment.kt b/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/ui/details/FurtherInfoFragment.kt index 18e8370..0652bba 100644 --- a/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/ui/details/FurtherInfoFragment.kt +++ b/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/ui/details/FurtherInfoFragment.kt @@ -4,10 +4,11 @@ import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import android.widget.TextView import androidx.fragment.app.Fragment import com.appttude.h_mal.atlas_weather.R import com.appttude.h_mal.atlas_weather.model.forecast.Forecast -import kotlinx.android.synthetic.main.activity_further_info.* + private const val WEATHER = "param1" @@ -36,14 +37,12 @@ class FurtherInfoFragment : Fragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - maxtemp.text = param1?.mainTemp - averagetemp.text = param1?.averageTemp - minimumtemp.text = param1?.minorTemp - windtext.text = param1?.windText - preciptext.text = param1?.precipitation - humiditytext.text = param1?.humidity - uvtext.text = param1?.uvi - sunrisetext.text = param1?.sunrise - sunsettext.text = param1?.sunset + view.findViewById(R.id.maxtemp).text = param1?.mainTemp + view.findViewById(R.id.averagetemp).text = param1?.averageTemp + view.findViewById(R.id.minimumtemp).text = param1?.minorTemp + view.findViewById(R.id.windtext).text = param1?.windText + view.findViewById(R.id.preciptext).text = param1?.precipitation + view.findViewById(R.id.sunrisetext).text = param1?.sunrise + view.findViewById(R.id.sunsettext).text = param1?.sunset } } \ No newline at end of file diff --git a/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/ui/home/HomeFragment.kt b/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/ui/home/HomeFragment.kt index b46d0b3..0785554 100644 --- a/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/ui/home/HomeFragment.kt +++ b/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/ui/home/HomeFragment.kt @@ -12,6 +12,8 @@ import android.view.View import androidx.fragment.app.Fragment import androidx.navigation.Navigation.findNavController import androidx.navigation.ui.onNavDestinationSelected +import androidx.recyclerview.widget.RecyclerView +import androidx.swiperefreshlayout.widget.SwipeRefreshLayout import com.appttude.h_mal.atlas_weather.R import com.appttude.h_mal.atlas_weather.application.AtlasApp import com.appttude.h_mal.atlas_weather.base.BaseFragment @@ -22,7 +24,7 @@ import com.appttude.h_mal.atlas_weather.ui.home.adapter.WeatherRecyclerAdapter import com.appttude.h_mal.atlas_weather.utils.displayToast import com.appttude.h_mal.atlas_weather.utils.navigateTo import com.appttude.h_mal.atlas_weather.viewmodel.MainViewModel -import kotlinx.android.synthetic.main.fragment_home.* + import permissions.dispatcher.NeedsPermission import permissions.dispatcher.OnNeverAskAgain import permissions.dispatcher.OnPermissionDenied @@ -38,14 +40,15 @@ import permissions.dispatcher.RuntimePermissions @RuntimePermissions class HomeFragment : BaseFragment(R.layout.fragment_home) { - lateinit var recyclerAdapter: WeatherRecyclerAdapter + private lateinit var recyclerAdapter: WeatherRecyclerAdapter + private lateinit var swipeRefresh: SwipeRefreshLayout @SuppressLint("MissingPermission") override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) setHasOptionsMenu(true) - swipe_refresh.apply { + swipeRefresh = view.findViewById(R.id.swipe_refresh).apply { setOnRefreshListener { showLocationWithPermissionCheck() isRefreshing = true @@ -56,7 +59,7 @@ class HomeFragment : BaseFragment(R.layout.fragment_home) { navigateToFurtherDetails(it) }) - forecast_listview.adapter = recyclerAdapter + view.findViewById(R.id.forecast_listview).adapter = recyclerAdapter scheduleNotification() } @@ -69,7 +72,7 @@ class HomeFragment : BaseFragment(R.layout.fragment_home) { override fun onSuccess(data: Any?) { super.onSuccess(data) - swipe_refresh.isRefreshing = false + swipeRefresh.isRefreshing = false if (data is WeatherDisplay) { recyclerAdapter.addCurrent(data) @@ -78,7 +81,7 @@ class HomeFragment : BaseFragment(R.layout.fragment_home) { override fun onFailure(error: Any?) { super.onFailure(error) - swipe_refresh.isRefreshing = false + swipeRefresh.isRefreshing = false } private fun navigateToFurtherDetails(forecast: Forecast) { @@ -96,6 +99,7 @@ class HomeFragment : BaseFragment(R.layout.fragment_home) { return item.onNavDestinationSelected(navController) || super.onOptionsItemSelected(item) } + @Deprecated("Deprecated in Java") override fun onRequestPermissionsResult(requestCode: Int, permissions: Array, grantResults: IntArray) { super.onRequestPermissionsResult(requestCode, permissions, grantResults) // NOTE: delegate the permission handling to generated method diff --git a/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/ui/world/AddLocationFragment.kt b/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/ui/world/AddLocationFragment.kt index e9d72df..9d45c22 100644 --- a/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/ui/world/AddLocationFragment.kt +++ b/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/ui/world/AddLocationFragment.kt @@ -2,13 +2,13 @@ package com.appttude.h_mal.atlas_weather.ui.world import android.os.Bundle import android.view.View +import android.widget.Button +import android.widget.TextView import com.appttude.h_mal.atlas_weather.R import com.appttude.h_mal.atlas_weather.base.BaseFragment import com.appttude.h_mal.atlas_weather.utils.displayToast import com.appttude.h_mal.atlas_weather.utils.goBack import com.appttude.h_mal.atlas_weather.viewmodel.WorldViewModel -import kotlinx.android.synthetic.main.activity_add_forecast.location_name_tv -import kotlinx.android.synthetic.main.activity_add_forecast.submit class AddLocationFragment : BaseFragment(R.layout.activity_add_forecast) { @@ -16,8 +16,11 @@ class AddLocationFragment : BaseFragment(R.layout.activity_add_f override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) + val submit = view.findViewById