-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat/android/google-play
- Loading branch information
Showing
60 changed files
with
1,257 additions
and
377 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
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 |
---|---|---|
|
@@ -12,5 +12,5 @@ plugins { | |
|
||
allprojects { | ||
group = "com.stadiamaps.ferrostar" | ||
version = "0.10.1" | ||
version = "0.11.0" | ||
} |
10 changes: 0 additions & 10 deletions
10
.../src/main/java/com/stadiamaps/ferrostar/composeui/runtime/KeepScreenOnDisposableEffect.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
53 changes: 53 additions & 0 deletions
53
.../composeui/src/main/java/com/stadiamaps/ferrostar/composeui/runtime/WindowInsetSupport.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,53 @@ | ||
package com.stadiamaps.ferrostar.composeui.runtime | ||
|
||
import androidx.compose.foundation.layout.PaddingValues | ||
import androidx.compose.foundation.layout.WindowInsets | ||
import androidx.compose.foundation.layout.asPaddingValues | ||
import androidx.compose.foundation.layout.calculateEndPadding | ||
import androidx.compose.foundation.layout.calculateStartPadding | ||
import androidx.compose.foundation.layout.safeDrawing | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.platform.LocalConfiguration | ||
import androidx.compose.ui.unit.Dp | ||
import androidx.compose.ui.unit.LayoutDirection | ||
import androidx.compose.ui.unit.dp | ||
|
||
@Composable | ||
fun paddingForGridView(horizontal: Dp = 16.dp, vertical: Dp = 16.dp): PaddingValues { | ||
val rawLayoutDirection = LocalConfiguration.current.layoutDirection | ||
val layoutDirection: LayoutDirection = LayoutDirection.entries[rawLayoutDirection] | ||
val safeDrawingPadding = WindowInsets.safeDrawing.asPaddingValues() | ||
|
||
val topPadding = | ||
if (safeDrawingPadding.calculateTopPadding() > vertical) { | ||
0.dp | ||
} else { | ||
vertical | ||
} | ||
|
||
val bottomPadding = | ||
if (safeDrawingPadding.calculateBottomPadding() > vertical) { | ||
0.dp | ||
} else { | ||
vertical | ||
} | ||
|
||
val systemStartPadding = safeDrawingPadding.calculateStartPadding(layoutDirection) | ||
val startPadding = | ||
if (systemStartPadding > horizontal) { | ||
systemStartPadding | ||
} else { | ||
horizontal | ||
} | ||
|
||
val systemEndPadding = safeDrawingPadding.calculateEndPadding(layoutDirection) | ||
val endPadding = | ||
if (systemEndPadding > horizontal) { | ||
systemEndPadding | ||
} else { | ||
horizontal | ||
} | ||
|
||
return PaddingValues( | ||
top = topPadding, start = startPadding, end = endPadding, bottom = bottomPadding) | ||
} |
17 changes: 17 additions & 0 deletions
17
android/composeui/src/main/java/com/stadiamaps/ferrostar/composeui/runtime/WindowSupport.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,17 @@ | ||
package com.stadiamaps.ferrostar.composeui.runtime | ||
|
||
import android.app.Activity | ||
import android.view.Window | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.platform.LocalContext | ||
|
||
/** | ||
* Get the Window for the current scene (Activity). | ||
* | ||
* @return The Window for the current scene, or null if the current context is not an Activity. | ||
*/ | ||
@Composable | ||
internal fun window(): Window? { | ||
val context = LocalContext.current | ||
return (context as? Activity)?.window ?: return null | ||
} |
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
21 changes: 21 additions & 0 deletions
21
android/core/src/main/java/com/stadiamaps/ferrostar/core/Extensions.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,6 +1,27 @@ | ||
package com.stadiamaps.ferrostar.core | ||
|
||
import okhttp3.Request | ||
import okhttp3.RequestBody.Companion.toRequestBody | ||
import uniffi.ferrostar.Route | ||
import uniffi.ferrostar.RouteRequest | ||
import uniffi.ferrostar.getRoutePolyline | ||
|
||
@Throws fun Route.getPolyline(precision: UInt): String = getRoutePolyline(this, precision) | ||
|
||
@Throws | ||
fun RouteRequest.toOkhttp3Request(): Request { | ||
val headers: Map<String, String> | ||
return when (this) { | ||
is RouteRequest.HttpPost -> { | ||
headers = this.headers | ||
Request.Builder().url(url).post(body.toRequestBody()) | ||
} | ||
|
||
is RouteRequest.HttpGet -> { | ||
headers = this.headers | ||
Request.Builder().url(url).get() | ||
} | ||
} | ||
.apply { headers.map { (name, value) -> header(name, value) } } | ||
.build() | ||
} |
Oops, something went wrong.