improve auto layout adjustements

hauntED
yova 3 months ago
parent 3b0b00d89c
commit b9ffe73652

@ -25,17 +25,20 @@
<activity <activity
android:name=".MetadataActivity" android:name=".MetadataActivity"
android:exported="false" android:exported="false"
android:label="Metadata"/> android:label="Metadata"
android:windowSoftInputMode="adjustResize"/>
<activity <activity
android:name=".LoginActivity" android:name=".LoginActivity"
android:exported="false" android:exported="false"
android:label="ghost CMS login" /> android:label="ghost CMS login"
android:windowSoftInputMode="adjustResize"/>
<activity <activity
android:name=".MainActivity" android:name=".MainActivity"
android:exported="true" android:exported="true"
android:label="@string/app_name" android:label="@string/app_name"
android:theme="@style/Theme.MDEditor" android:theme="@style/Theme.MDEditor"
android:launchMode="singleInstance"> android:launchMode="singleInstance"
android:windowSoftInputMode="adjustResize">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />

@ -38,7 +38,6 @@ import okhttp3.ResponseBody.Companion.toResponseBody
import org.json.JSONObject import org.json.JSONObject
import retrofit2.Response import retrofit2.Response
import java.io.BufferedReader import java.io.BufferedReader
import java.io.File
import java.io.FileOutputStream import java.io.FileOutputStream
import java.io.IOException import java.io.IOException
import java.io.InputStreamReader import java.io.InputStreamReader
@ -109,6 +108,7 @@ class MainActivity : AppCompatActivity() {
} }
] ]
}); });
easyMDE.codemirror.getScrollerElement().style.minHeight="100px";
""" """
companion object { companion object {
@ -162,6 +162,11 @@ class MainActivity : AppCompatActivity() {
} }
} }
} }
webView.viewTreeObserver.addOnGlobalLayoutListener {
webView.evaluateJavascript("easyMDE.codemirror.getScrollerElement().style.height=String(window.innerHeight-120) +\"px\"", {
Log.d(javaClass.simpleName, "js window innerheight set to: $it")
})
}
webView.loadUrl("file:///android_res/raw/index.html") webView.loadUrl("file:///android_res/raw/index.html")
val jsi = object { val jsi = object {
@ -269,7 +274,6 @@ class MainActivity : AppCompatActivity() {
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
if (!readOnResume) { if (!readOnResume) {
readOnResume = true readOnResume = true
autosaveTimer = fixedRateTimer("timer",true,0,5000){ autosaveTimer = fixedRateTimer("timer",true,0,5000){

@ -7,6 +7,8 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:padding="5dp" android:padding="5dp"
android:layout_alignParentBottom="true"
android:fitsSystemWindows="true"
tools:context="LoginActivity"> tools:context="LoginActivity">
<EditText <EditText

@ -5,7 +5,8 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
> android:layout_alignParentBottom="true"
android:fitsSystemWindows="true">
<WebView <WebView
android:id="@+id/mde_webview" android:id="@+id/mde_webview"

@ -5,6 +5,8 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:padding="5dp" android:padding="5dp"
android:layout_alignParentBottom="true"
android:fitsSystemWindows="true"
tools:context="MetadataActivity"> tools:context="MetadataActivity">
<TextView <TextView

@ -40,11 +40,6 @@ function pasteText() {
windowHeight = window.innerHeight windowHeight = window.innerHeight
function toggleBar() { function toggleBar() {
if (Android.isFullscreen()) {
easyMDE.codemirror.getScrollerElement().style.height=String(windowHeight-40)+"px"
} else {
easyMDE.codemirror.getScrollerElement().style.height=String(windowHeight-120)+"px"
}
Android.toggleBar() Android.toggleBar()
easyMDE.codemirror.focus() easyMDE.codemirror.focus()
} }

Loading…
Cancel
Save