-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #144 from ronickg/main
Various UI improvements and a bug fix.
- Loading branch information
Showing
78 changed files
with
2,371 additions
and
248 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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 @@ | ||
/.vs | ||
.DS_Store | ||
.Thumbs.db | ||
*.sublime* | ||
.idea/ | ||
debug.log | ||
package-lock.json | ||
.vscode/settings.json | ||
yarn.lock | ||
|
||
/.tauri | ||
/target | ||
Cargo.lock | ||
node_modules/ | ||
|
||
# dist-js | ||
# dist |
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] | ||
name = "tauri-plugin-safe-area-insets" | ||
version = "0.1.0" | ||
authors = [ "Ronald <[email protected]>" ] | ||
description = "" | ||
edition = "2021" | ||
rust-version = "1.77.2" | ||
exclude = ["/examples", "/webview-dist", "/webview-src", "/node_modules"] | ||
links = "tauri-plugin-safe-area-insets" | ||
|
||
[dependencies] | ||
tauri = { version = "2.1.0" } | ||
serde = "1.0" | ||
thiserror = "2" | ||
|
||
[build-dependencies] | ||
tauri-plugin = { version = "2.0.2", features = ["build"] } |
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 @@ | ||
# Tauri Plugin safe-area-insets |
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,2 @@ | ||
/build | ||
/.tauri |
44 changes: 44 additions & 0 deletions
44
plugins/tauri-plugin-safe-area-insets/android/build.gradle.kts
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("com.android.library") | ||
id("org.jetbrains.kotlin.android") | ||
} | ||
|
||
android { | ||
namespace = "com.plugin.safeareainsets" | ||
compileSdk = 34 | ||
|
||
defaultConfig { | ||
minSdk = 21 | ||
|
||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" | ||
consumerProguardFiles("consumer-rules.pro") | ||
} | ||
|
||
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" | ||
} | ||
} | ||
|
||
dependencies { | ||
|
||
implementation("androidx.core:core-ktx:1.9.0") | ||
implementation("androidx.appcompat:appcompat:1.6.0") | ||
implementation("com.google.android.material:material:1.7.0") | ||
testImplementation("junit:junit:4.13.2") | ||
androidTestImplementation("androidx.test.ext:junit:1.1.5") | ||
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1") | ||
implementation(project(":tauri-android")) | ||
} |
21 changes: 21 additions & 0 deletions
21
plugins/tauri-plugin-safe-area-insets/android/proguard-rules.pro
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,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 |
31 changes: 31 additions & 0 deletions
31
plugins/tauri-plugin-safe-area-insets/android/settings.gradle
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,31 @@ | ||
pluginManagement { | ||
repositories { | ||
mavenCentral() | ||
gradlePluginPortal() | ||
google() | ||
} | ||
resolutionStrategy { | ||
eachPlugin { | ||
switch (requested.id.id) { | ||
case "com.android.library": | ||
useVersion("8.0.2") | ||
break | ||
case "org.jetbrains.kotlin.android": | ||
useVersion("1.8.20") | ||
break | ||
} | ||
} | ||
} | ||
} | ||
|
||
dependencyResolutionManagement { | ||
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) | ||
repositories { | ||
mavenCentral() | ||
google() | ||
|
||
} | ||
} | ||
|
||
include ':tauri-android' | ||
project(':tauri-android').projectDir = new File('./.tauri/tauri-api') |
24 changes: 24 additions & 0 deletions
24
...ins/tauri-plugin-safe-area-insets/android/src/androidTest/java/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 com.plugin.safeareainsets | ||
|
||
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.plugin.safeareainsets", appContext.packageName) | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
plugins/tauri-plugin-safe-area-insets/android/src/main/AndroidManifest.xml
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,3 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
</manifest> |
10 changes: 10 additions & 0 deletions
10
plugins/tauri-plugin-safe-area-insets/android/src/main/java/Example.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,10 @@ | ||
package com.plugin.safeareainsets | ||
|
||
import android.util.Log | ||
|
||
class Example { | ||
fun pong(value: String): String { | ||
Log.i("Pong", value) | ||
return value | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
plugins/tauri-plugin-safe-area-insets/android/src/main/java/InsetPlugin.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,33 @@ | ||
package com.plugin.safeareainsets | ||
|
||
import android.app.Activity | ||
import android.view.View | ||
import androidx.core.view.ViewCompat | ||
import androidx.core.view.WindowInsetsCompat | ||
import app.tauri.annotation.Command | ||
import app.tauri.annotation.TauriPlugin | ||
import app.tauri.plugin.JSObject | ||
import app.tauri.plugin.Plugin | ||
import app.tauri.plugin.Invoke | ||
|
||
@TauriPlugin | ||
class InsetPlugin(private val activity: Activity): Plugin(activity) { | ||
private fun toDIPFromPixel(pixels: Float): Float { | ||
val density = activity.resources.displayMetrics.density | ||
return pixels / density | ||
} | ||
|
||
@Command | ||
fun getInsets(invoke: Invoke) { | ||
val rootView = activity.window.decorView | ||
ViewCompat.getRootWindowInsets(rootView)?.let { windowInsets -> | ||
val systemBars = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars()) | ||
val result = JSObject() | ||
result.put("top", toDIPFromPixel(systemBars.top.toFloat()).toDouble()) | ||
result.put("bottom", toDIPFromPixel(systemBars.bottom.toFloat()).toDouble()) | ||
result.put("left", toDIPFromPixel(systemBars.left.toFloat()).toDouble()) | ||
result.put("right", toDIPFromPixel(systemBars.right.toFloat()).toDouble()) | ||
invoke.resolve(result) | ||
} ?: invoke.reject("Failed to get window insets") | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
plugins/tauri-plugin-safe-area-insets/android/src/test/java/ExampleUnitTest.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.plugin.safeareainsets | ||
|
||
import org.junit.Test | ||
|
||
import org.junit.Assert.* | ||
|
||
/** | ||
* Example local unit test, which will execute on the development machine (host). | ||
* | ||
* See [testing documentation](http://d.android.com/tools/testing). | ||
*/ | ||
class ExampleUnitTest { | ||
@Test | ||
fun addition_isCorrect() { | ||
assertEquals(4, 2 + 2) | ||
} | ||
} |
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,8 @@ | ||
const COMMANDS: &[&str] = &["get_insets"]; | ||
|
||
fn main() { | ||
tauri_plugin::Builder::new(COMMANDS) | ||
.android_path("android") | ||
.ios_path("ios") | ||
.build(); | ||
} |
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,9 @@ | ||
'use strict'; | ||
|
||
var core = require('@tauri-apps/api/core'); | ||
|
||
async function getInsets() { | ||
return await core.invoke("plugin:window-insets|get_insets"); | ||
} | ||
|
||
exports.getInsets = getInsets; |
Oops, something went wrong.