Skip to content

Commit f4c448e

Browse files
author
sds100
committed
Merge branch 'develop' into main
2 parents 1a4c67e + 7752976 commit f4c448e

92 files changed

Lines changed: 3743 additions & 293 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ captures/
4949
.idea/modules.xml
5050
# Comment next line if keeping position of elements in Navigation Editor is relevant for you
5151
.idea/navEditor.xml
52+
.idea/androidTestResultsUserPreferences.xml
53+
.idea/misc.xml
54+
.idea/inspectionProfiles
55+
.idea/deploymentTargetDropDown.xml
5256

5357
# Keystore files
5458
# Uncomment the following lines if you do not want to check your keystore files in.

.idea/misc.xml

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
## [1.0.0](https://github.com/mapcode-foundation/mapcode-android-app/releases/tag/v1.0.0)
2+
3+
#### 21 July 2022
4+
5+
Initial release! 🎉

app/build.gradle

Lines changed: 61 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
plugins {
22
id 'com.android.application'
33
id 'org.jetbrains.kotlin.android'
4+
id 'kotlin-kapt'
5+
id 'dagger.hilt.android.plugin'
6+
id 'com.google.android.libraries.mapsplatform.secrets-gradle-plugin'
47
}
58

69
android {
@@ -10,9 +13,10 @@ android {
1013
defaultConfig {
1114
applicationId "com.mapcode"
1215
minSdk 21
16+
//noinspection OldTargetApi wait for sources to be released before upgrading
1317
targetSdk 32
1418
versionCode 1
15-
versionName "1.0"
19+
versionName "1.0.0"
1620

1721
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1822
vectorDrawables {
@@ -22,16 +26,26 @@ android {
2226

2327
buildTypes {
2428
release {
25-
minifyEnabled false
29+
minifyEnabled true
2630
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
2731
}
32+
benchmark {
33+
initWith buildTypes.release
34+
signingConfig signingConfigs.debug
35+
matchingFallbacks = ['release']
36+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-benchmark-rules.pro'
37+
debuggable false
38+
}
2839
}
2940
compileOptions {
3041
sourceCompatibility JavaVersion.VERSION_1_8
3142
targetCompatibility JavaVersion.VERSION_1_8
3243
}
3344
kotlinOptions {
3445
jvmTarget = '1.8'
46+
freeCompilerArgs += [
47+
"-Xopt-in=kotlin.RequiresOptIn"
48+
]
3549
}
3650
buildFeatures {
3751
compose true
@@ -47,17 +61,56 @@ android {
4761
}
4862

4963
dependencies {
50-
implementation 'com.mapcode:mapcode:2.4.14'
51-
implementation 'androidx.core:core-ktx:1.7.0'
52-
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.4.1'
53-
implementation 'androidx.activity:activity-compose:1.4.0'
64+
//google
65+
implementation 'com.google.maps.android:maps-compose:2.2.0'
66+
implementation 'com.google.android.gms:play-services-maps:18.0.2'
67+
implementation "com.google.dagger:hilt-android:2.42"
68+
implementation 'androidx.hilt:hilt-navigation-compose:1.0.0'
69+
implementation 'com.google.android.gms:play-services-location:20.0.0'
70+
kapt "com.google.dagger:hilt-compiler:2.42"
71+
implementation "com.google.android.material:material:1.6.1"
72+
73+
//android
74+
implementation 'androidx.core:core-ktx:1.8.0'
75+
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0"
76+
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.5.0'
77+
implementation 'androidx.activity:activity-compose:1.5.0'
78+
//noinspection GradleDependency
5479
implementation "androidx.compose.ui:ui:$compose_ui_version"
5580
implementation "androidx.compose.ui:ui-tooling-preview:$compose_ui_version"
5681
implementation 'androidx.compose.material:material:1.1.1'
82+
implementation "androidx.navigation:navigation-compose:2.5.0"
83+
implementation "androidx.compose.foundation:foundation:1.3.0-alpha01"
84+
implementation 'com.google.accompanist:accompanist-permissions:0.24.10-beta'
85+
implementation "com.google.accompanist:accompanist-systemuicontroller:0.17.0"
86+
implementation "com.google.accompanist:accompanist-insets:0.23.1"
87+
implementation "androidx.datastore:datastore-preferences:1.0.0"
88+
implementation "androidx.core:core-splashscreen:1.0.0-rc01"
89+
implementation "androidx.compose.material3:material3-window-size-class:1.0.0-alpha14"
90+
91+
//other
92+
implementation 'com.jakewharton.timber:timber:5.0.1'
93+
//noinspection GradleDependency. Issue with R8 on Android 8.0 or lower
94+
implementation 'com.mapcode:mapcode:2.4.14'
95+
96+
//debug
97+
debugImplementation "androidx.compose.ui:ui-tooling:$compose_ui_version"
98+
99+
//testing
57100
testImplementation 'junit:junit:4.13.2'
101+
testImplementation 'com.willowtreeapps.assertk:assertk-jvm:0.25'
102+
testImplementation 'org.mockito.kotlin:mockito-kotlin:4.0.0'
103+
testImplementation 'org.mockito:mockito-core:4.6.1'
104+
testImplementation 'org.mockito:mockito-inline:4.6.1'
105+
testImplementation "androidx.arch.core:core-testing:2.1.0"
106+
testImplementation "androidx.test:core-ktx:1.4.0"
107+
testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.2'
108+
testImplementation "androidx.compose.ui:ui-test-manifest:$compose_ui_version"
109+
110+
androidTestImplementation 'com.willowtreeapps.assertk:assertk-jvm:0.25'
58111
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
59112
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
60113
androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_ui_version"
61-
debugImplementation "androidx.compose.ui:ui-tooling:$compose_ui_version"
62-
debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_ui_version"
114+
androidTestImplementation 'org.mockito.kotlin:mockito-kotlin:4.0.0'
115+
androidTestImplementation 'org.mockito:mockito-android:4.6.1'
63116
}

app/src/androidTest/java/com/mapcode/ExampleInstrumentedTest.kt

Lines changed: 0 additions & 24 deletions
This file was deleted.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.mapcode
2+
3+
/**
4+
* Created by sds100 on 02/06/2022.
5+
*/
6+
data class FakeLocation(
7+
val latitude: Double,
8+
val longitude: Double,
9+
val addresses: List<String>,
10+
val mapcodes: List<Mapcode>
11+
)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.mapcode
2+
3+
import androidx.datastore.preferences.core.Preferences
4+
import com.mapcode.data.PreferenceRepository
5+
import kotlinx.coroutines.flow.Flow
6+
import kotlinx.coroutines.flow.MutableStateFlow
7+
import kotlinx.coroutines.flow.map
8+
9+
/**
10+
* Created by sds100 on 26/04/2021.
11+
*/
12+
class FakePreferenceRepository : PreferenceRepository {
13+
private val preferences: MutableStateFlow<Map<Preferences.Key<*>, Any?>> = MutableStateFlow(emptyMap())
14+
15+
@Suppress("UNCHECKED_CAST")
16+
override fun <T> get(key: Preferences.Key<T>): Flow<T?> {
17+
return preferences.map { it[key] as T? }
18+
}
19+
20+
override fun <T> set(key: Preferences.Key<T>, value: T?) {
21+
preferences.value = preferences.value.toMutableMap().apply {
22+
this[key] = value
23+
}
24+
}
25+
}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
package com.mapcode
2+
3+
import com.mapcode.map.ShowMapcodeUseCase
4+
import com.mapcode.util.Location
5+
import com.mapcode.util.NoAddressException
6+
import com.mapcode.util.UnknownAddressException
7+
import java.io.IOException
8+
import kotlin.Result.Companion.failure
9+
import kotlin.Result.Companion.success
10+
11+
/**
12+
* Created by sds100 on 02/06/2022.
13+
*/
14+
class FakeShowMapcodeUseCase : ShowMapcodeUseCase {
15+
var clipboard: String? = null
16+
var hasInternetConnection: Boolean = true
17+
var currentLocation: Location? = null
18+
var isMapsAppInstalled: Boolean = true
19+
20+
var sharedText: String? = null
21+
private set
22+
23+
val knownLocations: MutableList<FakeLocation> = mutableListOf()
24+
25+
override fun getMapcodes(lat: Double, long: Double): List<Mapcode> {
26+
return knownLocations
27+
.find { it.latitude == lat && it.longitude == long }
28+
?.mapcodes ?: emptyList()
29+
}
30+
31+
override fun decodeMapcode(mapcode: String): Result<Location> {
32+
val matchingLocation = knownLocations.find { location ->
33+
location.mapcodes.any { it.codeWithTerritory == mapcode }
34+
}
35+
36+
if (matchingLocation == null) {
37+
return failure(UnknownMapcodeException(""))
38+
} else {
39+
return success(Location(matchingLocation.latitude, matchingLocation.longitude))
40+
}
41+
}
42+
43+
override fun copyToClipboard(text: String) {
44+
clipboard = text
45+
}
46+
47+
override suspend fun geocode(address: String): Result<Location> {
48+
if (!hasInternetConnection) {
49+
return failure(IOException())
50+
}
51+
52+
val fakeLocation = knownLocations.find { it.addresses.contains(address) }
53+
54+
if (fakeLocation == null) {
55+
return failure(UnknownAddressException())
56+
} else {
57+
return success(Location(fakeLocation.latitude, fakeLocation.longitude))
58+
}
59+
}
60+
61+
override suspend fun reverseGeocode(lat: Double, long: Double): Result<String> {
62+
if (!hasInternetConnection) {
63+
return failure(IOException())
64+
}
65+
66+
val fakeLocation = knownLocations.find { it.latitude == lat && it.longitude == long }
67+
68+
if (fakeLocation == null || fakeLocation.addresses.isEmpty()) {
69+
return failure(NoAddressException())
70+
} else {
71+
return success(fakeLocation.addresses.first())
72+
}
73+
}
74+
75+
override suspend fun getLastLocation(): Location? {
76+
return currentLocation
77+
}
78+
79+
override fun launchDirectionsToLocation(location: Location, zoom: Float): Boolean {
80+
return isMapsAppInstalled
81+
}
82+
83+
override fun shareText(text: String, description: String) {
84+
sharedText = text
85+
}
86+
}

0 commit comments

Comments
 (0)