File tree Expand file tree Collapse file tree 2 files changed +26
-6
lines changed
android/app/src/main/java/com/foxdebug/acode Expand file tree Collapse file tree 2 files changed +26
-6
lines changed Original file line number Diff line number Diff line change 11package com.foxdebug.acode
22
33import android.content.Context
4+ import android.os.Build
45import android.os.Bundle
6+ import androidx.core.view.ViewCompat
7+ import androidx.core.view.WindowInsetsCompat
58import androidx.lifecycle.lifecycleScope
69import com.foxdebug.acode.plugins.NativeLayer
710import com.getcapacitor.BridgeActivity
@@ -30,6 +33,23 @@ class MainActivity : BridgeActivity() {
3033
3134 super .onCreate(savedInstanceState)
3235 activityRef = WeakReference (this )
36+
37+ // only apply insets for android 13+
38+ if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .TIRAMISU ) {
39+ ViewCompat .setOnApplyWindowInsetsListener(window.decorView) { v, insets ->
40+ val systemBarsInsets = insets.getInsets(WindowInsetsCompat .Type .systemBars())
41+ val imeInsets = insets.getInsets(WindowInsetsCompat .Type .ime())
42+ val isImeVisible = insets.isVisible(WindowInsetsCompat .Type .ime())
43+
44+ v.setPadding(
45+ systemBarsInsets.left,
46+ systemBarsInsets.top,
47+ systemBarsInsets.right,
48+ if (isImeVisible) imeInsets.bottom else systemBarsInsets.bottom
49+ )
50+ insets
51+ }
52+ }
3353 }
3454
3555 override fun onDestroy () {
Original file line number Diff line number Diff line change @@ -27,12 +27,12 @@ class NativeLayer : Plugin() {
2727 * Upon clicking "OK", the dialog will resolve the call.
2828 */
2929 @PluginMethod
30- fun showDialog (call : PluginCall ) = with (call){
31- autoRejectOnError(onFailure = {}){
32- existsNot(" title" ){
30+ fun showDialog (call : PluginCall ) = with (call) {
31+ autoRejectOnError(onFailure = {}) {
32+ existsNot(" title" ) {
3333 return @with
3434 }
35- existsNot(" message" ){
35+ existsNot(" message" ) {
3636 return @with
3737 }
3838
@@ -48,7 +48,7 @@ class NativeLayer : Plugin() {
4848 AlertDialog .Builder (context).apply {
4949 setTitle(title)
5050 setMessage(message)
51- setPositiveButton(" OK" ,null )
51+ setPositiveButton(" OK" , null )
5252 show()
5353 }
5454 call.resolve()
@@ -84,7 +84,7 @@ class NativeLayer : Plugin() {
8484 */
8585 @PluginMethod
8686 fun launchIntent (call : PluginCall ) {
87- call.autoRejectOnError(onFailure = {}){
87+ call.autoRejectOnError(onFailure = {}) {
8888 val constructorNumber = call.getInt(" constructor_number" ) ? : run {
8989 call.reject(" Missing 'constructor_number'" )
9090 return
You can’t perform that action at this time.
0 commit comments