Add inset detection and passthrough
This commit is contained in:
parent
ea302c23c4
commit
eb3afb0057
5 changed files with 22 additions and 5 deletions
|
@ -7,7 +7,7 @@ android {
|
||||||
applicationId "org.mapcomplete"
|
applicationId "org.mapcomplete"
|
||||||
minSdkVersion rootProject.ext.minSdkVersion
|
minSdkVersion rootProject.ext.minSdkVersion
|
||||||
targetSdkVersion rootProject.ext.targetSdkVersion
|
targetSdkVersion rootProject.ext.targetSdkVersion
|
||||||
versionCode 5
|
versionCode 9
|
||||||
versionName "debug"
|
versionName "debug"
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
aaptOptions {
|
aaptOptions {
|
||||||
|
@ -53,6 +53,8 @@ repositories {
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||||
|
implementation 'androidx.core:core:1.16.0'
|
||||||
|
implementation 'androidx.core:core-ktx:1.16.0'
|
||||||
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
|
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
|
||||||
implementation "androidx.coordinatorlayout:coordinatorlayout:$androidxCoordinatorLayoutVersion"
|
implementation "androidx.coordinatorlayout:coordinatorlayout:$androidxCoordinatorLayoutVersion"
|
||||||
implementation "androidx.core:core-splashscreen:$coreSplashScreenVersion"
|
implementation "androidx.core:core-splashscreen:$coreSplashScreenVersion"
|
||||||
|
|
|
@ -32,7 +32,7 @@ public class Databridge extends Plugin {
|
||||||
}
|
}
|
||||||
JSObject ret = new JSObject();
|
JSObject ret = new JSObject();
|
||||||
ret.put("value", answer);
|
ret.put("value", answer);
|
||||||
Log.i("databridge", "Resolving call");
|
Log.i("databridge", "Resolving call for "+call+" with "+answer);
|
||||||
call.resolve(ret);
|
call.resolve(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,14 +3,18 @@ package org.mapcomplete;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.provider.ContactsContract;
|
import android.provider.ContactsContract;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.view.Window;
|
||||||
|
import android.view.WindowInsets;
|
||||||
import android.window.OnBackInvokedDispatcher;
|
import android.window.OnBackInvokedDispatcher;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.core.app.ActivityCompat;
|
import androidx.core.app.ActivityCompat;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
|
import androidx.core.view.WindowCompat;
|
||||||
|
|
||||||
import com.getcapacitor.BridgeActivity;
|
import com.getcapacitor.BridgeActivity;
|
||||||
import com.getcapacitor.JSObject;
|
import com.getcapacitor.JSObject;
|
||||||
|
@ -63,7 +67,17 @@ public class MainActivity extends BridgeActivity {
|
||||||
});
|
});
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
WindowCompat.setDecorFitsSystemWindows(getWindow(), false);
|
||||||
|
Databridge.addResponder("insets", (responder) -> {
|
||||||
|
var view = getWindow().getDecorView();
|
||||||
|
var insets = view.getRootWindowInsets();
|
||||||
|
var topInsetPxSize= insets.getInsetsIgnoringVisibility(WindowInsets.Type.statusBars()).top;
|
||||||
|
var bottomInsetPxSize= insets.getInsetsIgnoringVisibility(WindowInsets.Type.navigationBars()).bottom;
|
||||||
|
|
||||||
|
var json = "{ \"top\": "+topInsetPxSize+", \"bottom\":"+bottomInsetPxSize+"}";
|
||||||
|
Log.i("insets","Inset sizes are:"+topInsetPxSize+" bottom:"+ bottomInsetPxSize);
|
||||||
|
Databridge.sendAnswerTo(responder, json);
|
||||||
|
});
|
||||||
|
|
||||||
getOnBackInvokedDispatcher().registerOnBackInvokedCallback(OnBackInvokedDispatcher.PRIORITY_OVERLAY,
|
getOnBackInvokedDispatcher().registerOnBackInvokedCallback(OnBackInvokedDispatcher.PRIORITY_OVERLAY,
|
||||||
() -> {
|
() -> {
|
||||||
|
@ -75,6 +89,7 @@ public class MainActivity extends BridgeActivity {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private boolean hasGeolocationPermission() {
|
private boolean hasGeolocationPermission() {
|
||||||
return ContextCompat.checkSelfPermission(
|
return ContextCompat.checkSelfPermission(
|
||||||
getApplicationContext(),
|
getApplicationContext(),
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
ext {
|
ext {
|
||||||
androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.7.0'
|
androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.7.0'
|
||||||
cordovaAndroidVersion = project.hasProperty('cordovaAndroidVersion') ? rootProject.ext.cordovaAndroidVersion : '10.1.1'
|
cordovaAndroidVersion = project.hasProperty('cordovaAndroidVersion') ? rootProject.ext.cordovaAndroidVersion : '10.1.1'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,4 +56,4 @@ apply from: "cordova.variables.gradle"
|
||||||
|
|
||||||
for (def func : cdvPluginPostBuildExtras) {
|
for (def func : cdvPluginPostBuildExtras) {
|
||||||
func()
|
func()
|
||||||
}
|
}
|
|
@ -1,3 +1,3 @@
|
||||||
// DO NOT EDIT THIS FILE! IT IS GENERATED EACH TIME "capacitor update" IS RUN
|
// DO NOT EDIT THIS FILE! IT IS GENERATED EACH TIME "capacitor update" IS RUN
|
||||||
include ':capacitor-android'
|
include ':capacitor-android'
|
||||||
project(':capacitor-android').projectDir = new File('../node_modules/@capacitor/android/capacitor')
|
project(':capacitor-android').projectDir = new File('@capacitor/android/capacitor')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue