-
Notifications
You must be signed in to change notification settings - Fork 354
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
33 changed files
with
344 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 0 additions & 31 deletions
31
android/app/src/test/kotlin/net/mullvad/mullvadvpn/compose/map/data/LatLngTest.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
plugins { | ||
id(Dependencies.Plugin.kotlinAndroidId) | ||
id(Dependencies.Plugin.androidLibraryId) | ||
} | ||
|
||
android { | ||
namespace = "net.mullvad.mullvadvpn.lib.map" | ||
compileSdk = Versions.Android.compileSdkVersion | ||
|
||
defaultConfig { | ||
minSdk = Versions.Android.minSdkVersion | ||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
|
||
compileOptions { | ||
sourceCompatibility = JavaVersion.VERSION_17 | ||
targetCompatibility = JavaVersion.VERSION_17 | ||
} | ||
|
||
kotlinOptions { | ||
jvmTarget = Versions.jvmTarget | ||
} | ||
|
||
buildFeatures { compose = true } | ||
|
||
composeOptions { kotlinCompilerExtensionVersion = Versions.kotlinCompilerExtensionVersion } | ||
|
||
lint { | ||
lintConfig = file("${rootProject.projectDir}/config/lint.xml") | ||
abortOnError = true | ||
warningsAsErrors = true | ||
} | ||
} | ||
|
||
dependencies { | ||
|
||
//Model | ||
implementation(project(Dependencies.Mullvad.modelLib)) | ||
|
||
implementation(Dependencies.Compose.ui) | ||
implementation(Dependencies.Compose.foundation) | ||
|
||
implementation(Dependencies.AndroidX.lifecycleRuntimeKtx) | ||
} |
24 changes: 24 additions & 0 deletions
24
...id/lib/map/src/androidTest/java/net/mullvad/mullvadvpn/lib/map/ExampleInstrumentedTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package net.mullvad.mullvadvpn.lib.map | ||
|
||
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("net.mullvad.mullvadvpn.lib.map.test", appContext.packageName) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
android/lib/map/src/main/kotlin/net/mullvad/mullvadvpn/lib/map/RememberPrevious.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package net.mullvad.mullvadvpn.lib.map | ||
|
||
/* | ||
* Code snippet taken from: | ||
* https://stackoverflow.com/questions/67801939/get-previous-value-of-state-in-composable-jetpack-compose | ||
*/ | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.MutableState | ||
import androidx.compose.runtime.SideEffect | ||
import androidx.compose.runtime.remember | ||
|
||
// TODO this file was copied for now and should be removed/broken out to a new module | ||
@Composable | ||
fun <T> rememberPrevious( | ||
current: T, | ||
shouldUpdate: (prev: T?, curr: T) -> Boolean = { a: T?, b: T -> a != b }, | ||
): T? { | ||
val ref = rememberRef<T>() | ||
|
||
// launched after render, so the current render will have the old value anyway | ||
SideEffect { | ||
if (shouldUpdate(ref.value, current)) { | ||
ref.value = current | ||
} | ||
} | ||
|
||
return ref.value | ||
} | ||
|
||
@Composable | ||
private fun <T> rememberRef(): MutableState<T?> { | ||
// for some reason it always recreated the value with vararg keys, | ||
// leaving out the keys as a parameter for remember for now | ||
return remember { | ||
object : MutableState<T?> { | ||
override var value: T? = null | ||
|
||
override fun component1(): T? = value | ||
|
||
override fun component2(): (T?) -> Unit = { value = it } | ||
} | ||
} | ||
} |
4 changes: 3 additions & 1 deletion
4
...llvadvpn/compose/map/data/MapViewState.kt → ...d/mullvadvpn/lib/map/data/MapViewState.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
...vad/mullvadvpn/compose/map/data/Marker.kt → ...mullvad/mullvadvpn/lib/map/data/Marker.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 1 addition & 3 deletions
4
...lvadvpn/compose/map/internal/Constants.kt → .../mullvadvpn/lib/map/internal/Constants.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
package net.mullvad.mullvadvpn.compose.map.internal | ||
package net.mullvad.mullvadvpn.lib.map.internal | ||
|
||
const val VERTEX_COMPONENT_SIZE = 3 | ||
const val COLOR_COMPONENT_SIZE = 4 | ||
|
||
const val MATRIX_SIZE = 16 | ||
|
||
const val COMPLETE_ANGLE = 360f |
2 changes: 1 addition & 1 deletion
2
...llvadvpn/compose/map/internal/GLHelper.kt → ...d/mullvadvpn/lib/map/internal/GLHelper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ose/map/internal/IndexBufferWithLength.kt → ...lib/map/internal/IndexBufferWithLength.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
package net.mullvad.mullvadvpn.compose.map.internal | ||
package net.mullvad.mullvadvpn.lib.map.internal | ||
|
||
data class IndexBufferWithLength(val indexBuffer: Int, val length: Int) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
.../compose/map/internal/MapGLSurfaceView.kt → ...dvpn/lib/map/internal/MapGLSurfaceView.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 8 additions & 8 deletions
16
...dvpn/compose/map/internal/shapes/Globe.kt → ...llvadvpn/lib/map/internal/shapes/Globe.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.