diff --git a/Cargo.toml b/Cargo.toml index 0bd1b69..43842e0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,6 +14,7 @@ exclude = [ "wasm_examples/many_points", "wasm_examples/lambert", "wasm_examples/with_egui", + "android_examples/raster_tiles/rust", ] [workspace.package] diff --git a/README.md b/README.md index 6a60e99..035f954 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,17 @@ it can be used on any platform that `wgpu` supports: Still, the backend is not integral part of the Galileo design, so we will probably try other promising backends (like [vello](https://github.com/linebender/vello)). +![Android](https://maximkaaa.github.io/galileo/android.png) + +## FFI + +At this point, you can develop an application using Galileo only in Rust. But there is +a POC example of how we envision future development on other platforms: [wasm_examples/raster_tiles]. +When all main features of Galileo are more or less stable (or when a need arises) we +will add FFI bindings to other languages using `wasm-bindgen` and `uniffi`. This will +allow you to create your applications in `JS`, `Kotlin`, `Swift` or `Python` using +common API. + ## Features Galileo is an active WIP, here is the list of the features that are already present: @@ -91,10 +102,12 @@ them all done at the same time. So here's our current plan and priorities: # Running examples -Rust examples of using Galileo are located at [`galileo/examples`]. Refer to the [readme](galileo/examples/README.md) +Rust examples of using Galileo are located at [`galileo/examples`](galileo/examples). Refer to the [readme](galileo/examples/README.md) for the list, description and run instructions. -There are also examples of running Galileo in a web-browser located at [`web_examples`] folder. These are +## Web + +There are also examples of running Galileo in a web-browser located at [`wasm_examples`](wasm_examples) folder. These are excluded from the workspace (because Cargo does not like cross-platform workspaces). To run those you will need to [install wasm-pack](https://rustwasm.github.io/wasm-pack/installer/): @@ -105,6 +118,10 @@ wasm-pack build wasm_examples/countries --target no-modules --release After that open `index.html` in your browser (must be served from `localhost`, use your favourite developer server). +## Android + +Check out [this example](android_examples/raster_tiles/README.md) to run Galileo on Android. + ## Cross-compile from Linux to Windows Install the target: @@ -127,14 +144,18 @@ cargo build --target x86_64-px-windows-gnu # Sponsoring +There is still a lot of work to be done to make Galileo feature-full, production ready and useful for many. And we +would love to work on this full-time to bring this to you as soon as possible. So we are looking for sponsors +to make it possible. + +Sponsor funds will help support maintainer's dedicated work and eventually fund freelance contributors. + If you think this library can be useful to you or someone you love, consider supporting its development. Sponsoring comes with additional advantages: -* Increase development speed. All funds will be spent on development. +* Increase development speed. * Make your needs our priority. * See your logo on the project's page. -Please, contact the maintainer of the project with any questions related to sponsoring. - # License You can use this library without any worries as it is licensed under either of diff --git a/android_examples/raster_tiles/.gitignore b/android_examples/raster_tiles/.gitignore new file mode 100644 index 0000000..c3b0a98 --- /dev/null +++ b/android_examples/raster_tiles/.gitignore @@ -0,0 +1,16 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties +/app/src/main/jniLibs \ No newline at end of file diff --git a/android_examples/raster_tiles/README.md b/android_examples/raster_tiles/README.md new file mode 100644 index 0000000..f1e6a3c --- /dev/null +++ b/android_examples/raster_tiles/README.md @@ -0,0 +1,25 @@ +This example app demonstrates how to run Galileo map as a Rust app on Android. + +To run the example install Android Studio with NDK. + +Then to build the rust part: + +```shell +# Install Cargo NDK +cargo install cargo-ndk + +# Install android targets +rustup target add \ + aarch64-linux-android \ + armv7-linux-androideabi \ + x86_64-linux-android \ + i686-linux-android + +# Export NDK location. The location and version number on your system may differ from the bellow +export ANDROID_NDK_HOME=~/Android/Sdk/ndk/26.1.10909125/ + +# Build the app +cargo ndk -t arm64-v8a -t armeabi-v7a -t x86 -t x86_64 -o ../app/src/main/jniLibs/ build +``` + +After that you can run the application from the Android Studio. \ No newline at end of file diff --git a/android_examples/raster_tiles/app/.gitignore b/android_examples/raster_tiles/app/.gitignore new file mode 100644 index 0000000..42afabf --- /dev/null +++ b/android_examples/raster_tiles/app/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/android_examples/raster_tiles/app/build.gradle.kts b/android_examples/raster_tiles/app/build.gradle.kts new file mode 100644 index 0000000..c22f0e6 --- /dev/null +++ b/android_examples/raster_tiles/app/build.gradle.kts @@ -0,0 +1,70 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + namespace = "com.example.rastertilesandroid" + compileSdk = 34 + ndkVersion = "26.1.10909125" + + defaultConfig { + applicationId = "com.example.rastertilesandroid" + minSdk = 24 + targetSdk = 34 + versionCode = 1 + versionName = "1.0" + + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + vectorDrawables { + useSupportLibrary = true + } + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro" + ) + } + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } + kotlinOptions { + jvmTarget = "1.8" + } + buildFeatures { + compose = true + } + composeOptions { + kotlinCompilerExtensionVersion = "1.5.1" + } + packaging { + resources { + excludes += "/META-INF/{AL2.0,LGPL2.1}" + } + } +} + +dependencies { + + implementation("androidx.core:core-ktx:1.12.0") + implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.7.0") + implementation("androidx.activity:activity-compose:1.8.2") + implementation(platform("androidx.compose:compose-bom:2023.08.00")) + implementation("androidx.compose.ui:ui") + implementation("androidx.compose.ui:ui-graphics") + implementation("androidx.compose.ui:ui-tooling-preview") + implementation("androidx.compose.material3:material3") + testImplementation("junit:junit:4.13.2") + androidTestImplementation("androidx.test.ext:junit:1.1.5") + androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1") + androidTestImplementation(platform("androidx.compose:compose-bom:2023.08.00")) + androidTestImplementation("androidx.compose.ui:ui-test-junit4") + debugImplementation("androidx.compose.ui:ui-tooling") + debugImplementation("androidx.compose.ui:ui-test-manifest") +} \ No newline at end of file diff --git a/android_examples/raster_tiles/app/proguard-rules.pro b/android_examples/raster_tiles/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /dev/null +++ b/android_examples/raster_tiles/app/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/android_examples/raster_tiles/app/src/androidTest/java/com/example/rastertilesandroid/ExampleInstrumentedTest.kt b/android_examples/raster_tiles/app/src/androidTest/java/com/example/rastertilesandroid/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..5e690b7 --- /dev/null +++ b/android_examples/raster_tiles/app/src/androidTest/java/com/example/rastertilesandroid/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.example.rastertilesandroid + +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("com.example.rastertilesandroid", appContext.packageName) + } +} \ No newline at end of file diff --git a/android_examples/raster_tiles/app/src/main/AndroidManifest.xml b/android_examples/raster_tiles/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..74efb4d --- /dev/null +++ b/android_examples/raster_tiles/app/src/main/AndroidManifest.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/android_examples/raster_tiles/app/src/main/res/drawable/ic_launcher_background.xml b/android_examples/raster_tiles/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/android_examples/raster_tiles/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/android_examples/raster_tiles/app/src/main/res/drawable/ic_launcher_foreground.xml b/android_examples/raster_tiles/app/src/main/res/drawable/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/android_examples/raster_tiles/app/src/main/res/drawable/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/android_examples/raster_tiles/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/android_examples/raster_tiles/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..6f3b755 --- /dev/null +++ b/android_examples/raster_tiles/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/android_examples/raster_tiles/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/android_examples/raster_tiles/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..6f3b755 --- /dev/null +++ b/android_examples/raster_tiles/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/android_examples/raster_tiles/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/android_examples/raster_tiles/app/src/main/res/mipmap-hdpi/ic_launcher.webp new file mode 100644 index 0000000..c209e78 Binary files /dev/null and b/android_examples/raster_tiles/app/src/main/res/mipmap-hdpi/ic_launcher.webp differ diff --git a/android_examples/raster_tiles/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/android_examples/raster_tiles/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp new file mode 100644 index 0000000..b2dfe3d Binary files /dev/null and b/android_examples/raster_tiles/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp differ diff --git a/android_examples/raster_tiles/app/src/main/res/mipmap-mdpi/ic_launcher.webp b/android_examples/raster_tiles/app/src/main/res/mipmap-mdpi/ic_launcher.webp new file mode 100644 index 0000000..4f0f1d6 Binary files /dev/null and b/android_examples/raster_tiles/app/src/main/res/mipmap-mdpi/ic_launcher.webp differ diff --git a/android_examples/raster_tiles/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/android_examples/raster_tiles/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp new file mode 100644 index 0000000..62b611d Binary files /dev/null and b/android_examples/raster_tiles/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp differ diff --git a/android_examples/raster_tiles/app/src/main/res/mipmap-xhdpi/ic_launcher.webp b/android_examples/raster_tiles/app/src/main/res/mipmap-xhdpi/ic_launcher.webp new file mode 100644 index 0000000..948a307 Binary files /dev/null and b/android_examples/raster_tiles/app/src/main/res/mipmap-xhdpi/ic_launcher.webp differ diff --git a/android_examples/raster_tiles/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/android_examples/raster_tiles/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..1b9a695 Binary files /dev/null and b/android_examples/raster_tiles/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp differ diff --git a/android_examples/raster_tiles/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/android_examples/raster_tiles/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp new file mode 100644 index 0000000..28d4b77 Binary files /dev/null and b/android_examples/raster_tiles/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp differ diff --git a/android_examples/raster_tiles/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/android_examples/raster_tiles/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..9287f50 Binary files /dev/null and b/android_examples/raster_tiles/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp differ diff --git a/android_examples/raster_tiles/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/android_examples/raster_tiles/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp new file mode 100644 index 0000000..aa7d642 Binary files /dev/null and b/android_examples/raster_tiles/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp differ diff --git a/android_examples/raster_tiles/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/android_examples/raster_tiles/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..9126ae3 Binary files /dev/null and b/android_examples/raster_tiles/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp differ diff --git a/android_examples/raster_tiles/app/src/main/res/values/colors.xml b/android_examples/raster_tiles/app/src/main/res/values/colors.xml new file mode 100644 index 0000000..f8c6127 --- /dev/null +++ b/android_examples/raster_tiles/app/src/main/res/values/colors.xml @@ -0,0 +1,10 @@ + + + #FFBB86FC + #FF6200EE + #FF3700B3 + #FF03DAC5 + #FF018786 + #FF000000 + #FFFFFFFF + \ No newline at end of file diff --git a/android_examples/raster_tiles/app/src/main/res/values/strings.xml b/android_examples/raster_tiles/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..9240c02 --- /dev/null +++ b/android_examples/raster_tiles/app/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + RasterTilesAndroid + \ No newline at end of file diff --git a/android_examples/raster_tiles/app/src/main/res/values/themes.xml b/android_examples/raster_tiles/app/src/main/res/values/themes.xml new file mode 100644 index 0000000..f3fb376 --- /dev/null +++ b/android_examples/raster_tiles/app/src/main/res/values/themes.xml @@ -0,0 +1,5 @@ + + + +