From f7beaf62d159e548bb9f17f87e1a22ee810aa61f Mon Sep 17 00:00:00 2001 From: Avneet Singh Date: Sat, 6 Jul 2024 06:48:48 +0530 Subject: [PATCH] refactor: location module --- app/build.gradle.kts | 5 ++-- .../mobile/ui/location/LocationsFragment.kt | 6 ++--- .../main/res/layout/fragment_locations.xml | 6 ----- feature/location/.gitignore | 1 + feature/location/build.gradle.kts | 17 +++++++++++++ feature/location/consumer-rules.pro | 0 feature/location/proguard-rules.pro | 21 ++++++++++++++++ .../location/ExampleInstrumentedTest.kt | 24 +++++++++++++++++++ feature/location/src/main/AndroidManifest.xml | 4 ++++ .../feature}/location/LocationScreen.kt | 4 +--- .../location/src/main/res/values/strings.xml | 7 ++++++ .../feature/location/ExampleUnitTest.kt | 17 +++++++++++++ gradle/libs.versions.toml | 2 ++ settings.gradle.kts | 1 + 14 files changed, 99 insertions(+), 16 deletions(-) create mode 100644 feature/location/.gitignore create mode 100644 feature/location/build.gradle.kts create mode 100644 feature/location/consumer-rules.pro create mode 100644 feature/location/proguard-rules.pro create mode 100644 feature/location/src/androidTest/java/org/mifos/mobile/feature/location/ExampleInstrumentedTest.kt create mode 100644 feature/location/src/main/AndroidManifest.xml rename {app/src/main/java/org/mifos/mobile/ui => feature/location/src/main/java/org/mifos/mobile/feature}/location/LocationScreen.kt (95%) create mode 100644 feature/location/src/main/res/values/strings.xml create mode 100644 feature/location/src/test/java/org/mifos/mobile/feature/location/ExampleUnitTest.kt diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 3eaeafeca..f35f7bf0a 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -91,6 +91,7 @@ dependencies { implementation(projects.feature.thirdPartyTransfer) implementation(projects.feature.help) implementation(projects.feature.notification) + implementation(projects.feature.location) implementation("androidx.legacy:legacy-support-v4:1.0.0") @@ -99,7 +100,7 @@ dependencies { implementation(libs.androidx.appcompat) implementation(libs.material) implementation(libs.androidx.preference) - implementation(libs.play.services.maps) + // DBFlow implementation(libs.dbflow) @@ -197,8 +198,6 @@ dependencies { debugApi(libs.androidx.compose.ui.tooling) api(libs.androidx.hilt.navigation.compose) - // google maps - implementation ("com.google.maps.android:maps-compose:4.4.1") //image cropper implementation("com.github.CanHub:Android-Image-Cropper:4.0.0") diff --git a/app/src/main/java/org/mifos/mobile/ui/location/LocationsFragment.kt b/app/src/main/java/org/mifos/mobile/ui/location/LocationsFragment.kt index e0edb381b..cbcf460f7 100644 --- a/app/src/main/java/org/mifos/mobile/ui/location/LocationsFragment.kt +++ b/app/src/main/java/org/mifos/mobile/ui/location/LocationsFragment.kt @@ -6,7 +6,7 @@ import android.view.View import android.view.ViewGroup import androidx.fragment.app.Fragment import org.mifos.mobile.core.ui.component.mifosComposeView -import org.mifos.mobile.core.ui.theme.MifosMobileTheme +import org.mifos.mobile.feature.location.LocationsScreen class LocationsFragment : Fragment() { @@ -16,9 +16,7 @@ class LocationsFragment : Fragment() { savedInstanceState: Bundle? ): View { return mifosComposeView(requireContext()) { - MifosMobileTheme { - LocationsScreen() - } + LocationsScreen() } } diff --git a/app/src/main/res/layout/fragment_locations.xml b/app/src/main/res/layout/fragment_locations.xml index bf596d584..efca737f0 100644 --- a/app/src/main/res/layout/fragment_locations.xml +++ b/app/src/main/res/layout/fragment_locations.xml @@ -21,11 +21,5 @@ android:layout_height="wrap_content" android:text="@string/mifos_location" /> - diff --git a/feature/location/.gitignore b/feature/location/.gitignore new file mode 100644 index 000000000..42afabfd2 --- /dev/null +++ b/feature/location/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/feature/location/build.gradle.kts b/feature/location/build.gradle.kts new file mode 100644 index 000000000..8414ba686 --- /dev/null +++ b/feature/location/build.gradle.kts @@ -0,0 +1,17 @@ +plugins { + alias(libs.plugins.mifos.android.feature) + alias(libs.plugins.mifos.android.library.compose) +} + +android { + namespace = "org.mifos.mobile.feature.location" +} + +dependencies { + // google maps + implementation(libs.google.map.compose) + + testImplementation(libs.junit) + androidTestImplementation(libs.androidx.test.ext.junit) + androidTestImplementation(libs.espresso.core) +} \ No newline at end of file diff --git a/feature/location/consumer-rules.pro b/feature/location/consumer-rules.pro new file mode 100644 index 000000000..e69de29bb diff --git a/feature/location/proguard-rules.pro b/feature/location/proguard-rules.pro new file mode 100644 index 000000000..481bb4348 --- /dev/null +++ b/feature/location/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/feature/location/src/androidTest/java/org/mifos/mobile/feature/location/ExampleInstrumentedTest.kt b/feature/location/src/androidTest/java/org/mifos/mobile/feature/location/ExampleInstrumentedTest.kt new file mode 100644 index 000000000..690bff5f4 --- /dev/null +++ b/feature/location/src/androidTest/java/org/mifos/mobile/feature/location/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package org.mifos.mobile.feature.location + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("org.mifos.mobile.feature.location.test", appContext.packageName) + } +} \ No newline at end of file diff --git a/feature/location/src/main/AndroidManifest.xml b/feature/location/src/main/AndroidManifest.xml new file mode 100644 index 000000000..a5918e68a --- /dev/null +++ b/feature/location/src/main/AndroidManifest.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/app/src/main/java/org/mifos/mobile/ui/location/LocationScreen.kt b/feature/location/src/main/java/org/mifos/mobile/feature/location/LocationScreen.kt similarity index 95% rename from app/src/main/java/org/mifos/mobile/ui/location/LocationScreen.kt rename to feature/location/src/main/java/org/mifos/mobile/feature/location/LocationScreen.kt index 4b2a4c02d..f29ab9933 100644 --- a/app/src/main/java/org/mifos/mobile/ui/location/LocationScreen.kt +++ b/feature/location/src/main/java/org/mifos/mobile/feature/location/LocationScreen.kt @@ -1,4 +1,4 @@ -package org.mifos.mobile.ui.location +package org.mifos.mobile.feature.location import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Spacer @@ -14,7 +14,6 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.compose.ui.viewinterop.AndroidView -import com.google.android.gms.maps.GoogleMap import com.google.android.gms.maps.MapView import com.google.android.gms.maps.model.CameraPosition import com.google.android.gms.maps.model.LatLng @@ -22,7 +21,6 @@ import com.google.maps.android.compose.GoogleMap import com.google.maps.android.compose.Marker import com.google.maps.android.compose.MarkerState import com.google.maps.android.compose.rememberCameraPositionState -import org.mifos.mobile.R import org.mifos.mobile.core.ui.theme.MifosMobileTheme import kotlin.coroutines.coroutineContext diff --git a/feature/location/src/main/res/values/strings.xml b/feature/location/src/main/res/values/strings.xml new file mode 100644 index 000000000..7843e450c --- /dev/null +++ b/feature/location/src/main/res/values/strings.xml @@ -0,0 +1,7 @@ + + + Mifos Initiative + Mifos Initiative , Seattle , Washington 98121 + Seattle + Home to large tech industry + \ No newline at end of file diff --git a/feature/location/src/test/java/org/mifos/mobile/feature/location/ExampleUnitTest.kt b/feature/location/src/test/java/org/mifos/mobile/feature/location/ExampleUnitTest.kt new file mode 100644 index 000000000..a3c7ee53d --- /dev/null +++ b/feature/location/src/test/java/org/mifos/mobile/feature/location/ExampleUnitTest.kt @@ -0,0 +1,17 @@ +package org.mifos.mobile.feature.location + +import org.junit.Test + +import org.junit.Assert.* + +/** + * Example local unit test, which will execute on the development machine (host). + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +class ExampleUnitTest { + @Test + fun addition_isCorrect() { + assertEquals(4, 2 + 2) + } +} \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 5384d6fd2..4487b0fb1 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -52,6 +52,7 @@ playServicesCodeScanner = "16.1.0" googleAppCodeScanner = "17.2.0" cameraxVersion = "1.3.1" compose-material = "1.6.8" +googleMaps = "4.4.1" [libraries] androidx-activity-ktx = { module = "androidx.activity:activity-ktx", version.ref = "activityVersion" } @@ -112,6 +113,7 @@ androidx-camera-camera2 = { group = "androidx.camera", name = "camera-camera2", androidx-camera-lifecycle = { group = "androidx.camera", name = "camera-lifecycle", version.ref = "cameraxVersion"} androidx-camera-view = { group = "androidx.camera", name = "camera-view", version.ref = "cameraxVersion"} androidx-camera-core = { group = "androidx.camera", name = "camera-core", version.ref = "cameraxVersion" } +google-map-compose = { group = "com.google.maps.android", name = "maps-compose", version.ref = "googleMaps" } # Dependencies of the included build-logic android-gradlePlugin = { group = "com.android.tools.build", name = "gradle", version.ref = "androidGradlePlugin" } diff --git a/settings.gradle.kts b/settings.gradle.kts index 0859dc53d..f1007af30 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -42,3 +42,4 @@ include(":feature:client_charge") include(":feature:third-party-transfer") include(":feature:help") include(":feature:notification") +include(":feature:location")