Skip to content

Commit f3f3e90

Browse files
committed
More clean up
1 parent 58ecf35 commit f3f3e90

File tree

6 files changed

+67
-63
lines changed

6 files changed

+67
-63
lines changed

android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/ConnectScreen.kt

+2-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import androidx.compose.material3.Text
2020
import androidx.compose.runtime.Composable
2121
import androidx.compose.runtime.LaunchedEffect
2222
import androidx.compose.runtime.collectAsState
23-
import androidx.compose.runtime.derivedStateOf
2423
import androidx.compose.runtime.getValue
2524
import androidx.compose.runtime.mutableFloatStateOf
2625
import androidx.compose.runtime.mutableLongStateOf
@@ -211,8 +210,8 @@ fun ConnectScreen(
211210
animationSpec = tween(SECURE_ZOOM_ANIMATION_MILLIS)
212211
)
213212

214-
val markers = uiState.tunnelRealState.toMarker(uiState.location)?.let { listOf(it) }
215-
?: emptyList()
213+
val markers =
214+
uiState.tunnelRealState.toMarker(uiState.location)?.let { listOf(it) } ?: emptyList()
216215

217216
AnimatedMap(
218217
modifier = Modifier.padding(top = it.calculateTopPadding()),

android/lib/map/src/main/kotlin/net/mullvad/mullvadvpn/lib/map/Map.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ internal fun Map(modifier: Modifier = Modifier, mapViewState: MapViewState) {
6262
view?.onResume()
6363
}
6464
Lifecycle.Event.ON_PAUSE -> {
65-
view?.onPause()
65+
view?.onPause()
6666
}
6767
else -> {}
6868
}

android/lib/map/src/main/kotlin/net/mullvad/mullvadvpn/lib/map/internal/Constants.kt

+6-6
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ internal const val MATRIX_SIZE = 16
66

77
// Constant what will talk the distance in LatLng multiply it to determine the animation duration,
88
// the result is then confined to the MIN_ANIMATION_MILLIS and MAX_ANIMATION_MILLIS
9-
const val DISTANCE_DURATION_SCALE_FACTOR = 20
10-
const val MIN_ANIMATION_MILLIS = 1300
11-
const val MAX_ANIMATION_MILLIS = 2500
9+
internal const val DISTANCE_DURATION_SCALE_FACTOR = 20
10+
internal const val MIN_ANIMATION_MILLIS = 1300
11+
internal const val MAX_ANIMATION_MILLIS = 2500
1212
// The cut off where we go from a short animation (camera pans) to a far animation (camera pans +
1313
// zoom out)
14-
const val SHORT_ANIMATION_CUTOFF_MILLIS = 1700
14+
internal const val SHORT_ANIMATION_CUTOFF_MILLIS = 1700
1515

1616
// Multiplier for the zoom out animation
17-
const val FAR_ANIMATION_MAX_ZOOM_MULTIPLIER = 1.30f
17+
internal const val FAR_ANIMATION_MAX_ZOOM_MULTIPLIER = 1.30f
1818
// When in the far animation we reach the MAX_ZOOM_MULTIPLIER, value is between 0 and 1
19-
const val MAX_MULTIPLIER_PEAK_TIMING = .35f
19+
internal const val MAX_MULTIPLIER_PEAK_TIMING = .35f

android/lib/map/src/main/kotlin/net/mullvad/mullvadvpn/lib/map/internal/MapGLSurfaceView.kt

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package net.mullvad.mullvadvpn.lib.map.internal
22

3-
import android.annotation.SuppressLint
43
import android.content.Context
54
import android.opengl.GLSurfaceView
65
import net.mullvad.mullvadvpn.lib.map.data.MapViewState

android/lib/map/src/main/kotlin/net/mullvad/mullvadvpn/lib/map/internal/shapes/Globe.kt

+28-23
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,7 @@ import net.mullvad.mullvadvpn.lib.map.internal.initArrayBuffer
1212
import net.mullvad.mullvadvpn.lib.map.internal.initIndexBuffer
1313
import net.mullvad.mullvadvpn.lib.map.internal.initShaderProgram
1414

15-
class Globe(resources: Resources) {
16-
private val vertexShaderCode =
17-
"""
18-
attribute vec3 aVertexPosition;
19-
uniform vec4 uColor;
20-
uniform mat4 uModelViewMatrix;
21-
uniform mat4 uProjectionMatrix;
22-
varying lowp vec4 vColor;
23-
void main(void) {
24-
gl_Position = uProjectionMatrix * uModelViewMatrix * vec4(aVertexPosition, 1.0);
25-
vColor = uColor;
26-
}
27-
"""
28-
.trimIndent()
29-
30-
private val fragmentShaderCode =
31-
"""
32-
varying lowp vec4 vColor;
33-
void main(void) {
34-
gl_FragColor = vColor;
35-
}
36-
"""
37-
.trimIndent()
15+
internal class Globe(resources: Resources) {
3816

3917
private val shaderProgram: Int
4018

@@ -172,5 +150,32 @@ class Globe(resources: Resources) {
172150

173151
companion object {
174152
private const val LAND_OCEAN_SCALE_FACTOR = 0.999f
153+
154+
// Vertex, and fragment shader code is taken from Mullvad Desktop 3dmap.ts
155+
private val vertexShaderCode =
156+
"""
157+
attribute vec3 aVertexPosition;
158+
159+
uniform vec4 uColor;
160+
uniform mat4 uModelViewMatrix;
161+
uniform mat4 uProjectionMatrix;
162+
163+
varying lowp vec4 vColor;
164+
165+
void main(void) {
166+
gl_Position = uProjectionMatrix * uModelViewMatrix * vec4(aVertexPosition, 1.0);
167+
vColor = uColor;
168+
}
169+
"""
170+
.trimIndent()
171+
private val fragmentShaderCode =
172+
"""
173+
varying lowp vec4 vColor;
174+
175+
void main(void) {
176+
gl_FragColor = vColor;
177+
}
178+
"""
179+
.trimIndent()
175180
}
176181
}

android/lib/map/src/main/kotlin/net/mullvad/mullvadvpn/lib/map/internal/shapes/LocationMarker.kt

+30-29
Original file line numberDiff line numberDiff line change
@@ -16,33 +16,6 @@ import net.mullvad.mullvadvpn.model.LatLong
1616

1717
internal class LocationMarker(val colors: LocationMarkerColors) {
1818

19-
private val vertexShaderCode =
20-
"""
21-
attribute vec3 aVertexPosition;
22-
attribute vec4 aVertexColor;
23-
24-
uniform mat4 uModelViewMatrix;
25-
uniform mat4 uProjectionMatrix;
26-
27-
varying lowp vec4 vColor;
28-
29-
void main(void) {
30-
gl_Position = uProjectionMatrix * uModelViewMatrix * vec4(aVertexPosition, 1.0);
31-
vColor = aVertexColor;
32-
}
33-
"""
34-
.trimIndent()
35-
36-
private val fragmentShaderCode =
37-
"""
38-
varying lowp vec4 vColor;
39-
40-
void main(void) {
41-
gl_FragColor = vColor;
42-
}
43-
"""
44-
.trimIndent()
45-
4619
private val rings =
4720
listOf(
4821
circleFanVertices(
@@ -79,9 +52,9 @@ internal class LocationMarker(val colors: LocationMarkerColors) {
7952
private val attribLocations: AttribLocations
8053
private val uniformLocation: UniformLocation
8154

82-
data class AttribLocations(val vertexPosition: Int, val vertexColor: Int)
55+
private data class AttribLocations(val vertexPosition: Int, val vertexColor: Int)
8356

84-
data class UniformLocation(val projectionMatrix: Int, val modelViewMatrix: Int)
57+
private data class UniformLocation(val projectionMatrix: Int, val modelViewMatrix: Int)
8558

8659
private val positionBuffer: Int
8760
private val colorBuffer: Int
@@ -213,6 +186,34 @@ internal class LocationMarker(val colors: LocationMarkerColors) {
213186

214187
companion object {
215188
private const val MARKER_TRANSLATE_Z_FACTOR = 1.0001f
189+
190+
// Vertex, and fragment shader code is taken from Mullvad Desktop 3dmap.ts
191+
private val vertexShaderCode =
192+
"""
193+
attribute vec3 aVertexPosition;
194+
attribute vec4 aVertexColor;
195+
196+
uniform mat4 uModelViewMatrix;
197+
uniform mat4 uProjectionMatrix;
198+
199+
varying lowp vec4 vColor;
200+
201+
void main(void) {
202+
gl_Position = uProjectionMatrix * uModelViewMatrix * vec4(aVertexPosition, 1.0);
203+
vColor = aVertexColor;
204+
}
205+
"""
206+
.trimIndent()
207+
208+
private val fragmentShaderCode =
209+
"""
210+
varying lowp vec4 vColor;
211+
212+
void main(void) {
213+
gl_FragColor = vColor;
214+
}
215+
"""
216+
.trimIndent()
216217
}
217218
}
218219

0 commit comments

Comments
 (0)