Fix for surface_height=0 on some devices after keyboard shown
This commit is contained in:
parent
12b7b00710
commit
c4af642a71
@ -2,18 +2,4 @@ Android NDK: WARNING:/home/twaik/TermuxX11/app/src/main/jni/lorie/Android.mk:lor
|
|||||||
Android NDK: This is likely to result in incorrect builds. Try using LOCAL_STATIC_LIBRARIES
|
Android NDK: This is likely to result in incorrect builds. Try using LOCAL_STATIC_LIBRARIES
|
||||||
Android NDK: or LOCAL_SHARED_LIBRARIES instead to list the library dependencies of the
|
Android NDK: or LOCAL_SHARED_LIBRARIES instead to list the library dependencies of the
|
||||||
Android NDK: current module
|
Android NDK: current module
|
||||||
[arm64-v8a] Compile++ : lorie <= client.cpp
|
make: `/home/twaik/TermuxX11/app/build/intermediates/ndkBuild/debug/obj/local/arm64-v8a/liblorie.so' is up to date.
|
||||||
[arm64-v8a] Compile++ : lorie <= clipboard.cpp
|
|
||||||
[arm64-v8a] Compile++ : lorie <= compositor.cpp
|
|
||||||
[arm64-v8a] Compile++ : lorie <= egl-helper.cpp
|
|
||||||
[arm64-v8a] Compile++ : lorie <= message-queue.cpp
|
|
||||||
[arm64-v8a] Compile++ : lorie <= renderer.cpp
|
|
||||||
[arm64-v8a] Compile++ : lorie <= seat.cpp
|
|
||||||
[arm64-v8a] Compile++ : lorie <= surface.cpp
|
|
||||||
[arm64-v8a] Compile++ : lorie <= output.cpp
|
|
||||||
[arm64-v8a] Compile++ : lorie <= log.cpp
|
|
||||||
[arm64-v8a] Compile++ : lorie <= utils.cpp
|
|
||||||
[arm64-v8a] Compile++ : lorie <= wayland.cpp
|
|
||||||
[arm64-v8a] Compile++ : lorie <= android-app.cpp
|
|
||||||
[arm64-v8a] Compile : lorie <= utils.c
|
|
||||||
[arm64-v8a] SharedLibrary : liblorie.so
|
|
||||||
|
@ -2,50 +2,4 @@ Android NDK: WARNING:/home/twaik/TermuxX11/app/src/main/jni/lorie/Android.mk:lor
|
|||||||
Android NDK: This is likely to result in incorrect builds. Try using LOCAL_STATIC_LIBRARIES
|
Android NDK: This is likely to result in incorrect builds. Try using LOCAL_STATIC_LIBRARIES
|
||||||
Android NDK: or LOCAL_SHARED_LIBRARIES instead to list the library dependencies of the
|
Android NDK: or LOCAL_SHARED_LIBRARIES instead to list the library dependencies of the
|
||||||
Android NDK: current module
|
Android NDK: current module
|
||||||
[x86_64] Compile++ : lorie <= client.cpp
|
make: `/home/twaik/TermuxX11/app/build/intermediates/ndkBuild/debug/obj/local/x86_64/liblorie.so' is up to date.
|
||||||
[x86_64] Compile++ : lorie <= clipboard.cpp
|
|
||||||
[x86_64] Compile++ : lorie <= compositor.cpp
|
|
||||||
[x86_64] Compile++ : lorie <= egl-helper.cpp
|
|
||||||
[x86_64] Compile++ : lorie <= message-queue.cpp
|
|
||||||
[x86_64] Compile++ : lorie <= renderer.cpp
|
|
||||||
[x86_64] Compile++ : lorie <= seat.cpp
|
|
||||||
[x86_64] Compile++ : lorie <= surface.cpp
|
|
||||||
[x86_64] Compile++ : lorie <= output.cpp
|
|
||||||
[x86_64] Compile++ : lorie <= log.cpp
|
|
||||||
[x86_64] Compile++ : lorie <= utils.cpp
|
|
||||||
[x86_64] Compile++ : lorie <= wayland.cpp
|
|
||||||
[x86_64] Compile++ : lorie <= android-app.cpp
|
|
||||||
[x86_64] Compile : lorie <= utils.c
|
|
||||||
[x86_64] Compile : xkbcommon <= parser.c
|
|
||||||
[x86_64] Compile : xkbcommon <= paths.c
|
|
||||||
[x86_64] Compile : xkbcommon <= state.c
|
|
||||||
[x86_64] Compile : xkbcommon <= table.c
|
|
||||||
[x86_64] Compile : xkbcommon <= action.c
|
|
||||||
[x86_64] Compile : xkbcommon <= ast-build.c
|
|
||||||
[x86_64] Compile : xkbcommon <= compat.c
|
|
||||||
[x86_64] Compile : xkbcommon <= expr.c
|
|
||||||
[x86_64] Compile : xkbcommon <= include.c
|
|
||||||
[x86_64] Compile : xkbcommon <= keycodes.c
|
|
||||||
[x86_64] Compile : xkbcommon <= keymap.c
|
|
||||||
[x86_64] Compile : xkbcommon <= keymap-dump.c
|
|
||||||
[x86_64] Compile : xkbcommon <= keywords.c
|
|
||||||
[x86_64] Compile : xkbcommon <= parser.c
|
|
||||||
[x86_64] Compile : xkbcommon <= rules.c
|
|
||||||
[x86_64] Compile : xkbcommon <= scanner.c
|
|
||||||
[x86_64] Compile : xkbcommon <= symbols.c
|
|
||||||
[x86_64] Compile : xkbcommon <= types.c
|
|
||||||
[x86_64] Compile : xkbcommon <= vmod.c
|
|
||||||
[x86_64] Compile : xkbcommon <= xkbcomp.c
|
|
||||||
[x86_64] Compile : xkbcommon <= atom.c
|
|
||||||
[x86_64] Compile : xkbcommon <= context.c
|
|
||||||
[x86_64] Compile : xkbcommon <= context-priv.c
|
|
||||||
[x86_64] Compile : xkbcommon <= keysym.c
|
|
||||||
[x86_64] Compile : xkbcommon <= keysym-utf.c
|
|
||||||
[x86_64] Compile : xkbcommon <= keymap.c
|
|
||||||
[x86_64] Compile : xkbcommon <= keymap-priv.c
|
|
||||||
[x86_64] Compile : xkbcommon <= state.c
|
|
||||||
[x86_64] Compile : xkbcommon <= text.c
|
|
||||||
[x86_64] Compile : xkbcommon <= utf8.c
|
|
||||||
[x86_64] Compile : xkbcommon <= utils.c
|
|
||||||
[x86_64] SharedLibrary : libxkbcommon.so
|
|
||||||
[x86_64] SharedLibrary : liblorie.so
|
|
||||||
|
@ -133,6 +133,7 @@
|
|||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/transforms" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/transforms" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/validate_signing_config" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/validate_signing_config" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
|
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/reports" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
|
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
|
||||||
</content>
|
</content>
|
||||||
<orderEntry type="jdk" jdkName="Android API 28 Platform" jdkType="Android SDK" />
|
<orderEntry type="jdk" jdkName="Android API 28 Platform" jdkType="Android SDK" />
|
||||||
|
@ -31,7 +31,8 @@
|
|||||||
<activity android:name=".MainActivity"
|
<activity android:name=".MainActivity"
|
||||||
android:theme="@style/NoActionBar"
|
android:theme="@style/NoActionBar"
|
||||||
android:launchMode="singleInstance"
|
android:launchMode="singleInstance"
|
||||||
android:configChanges="fontScale|orientation|screenSize|keyboard|keyboardHidden|layoutDirection|locale|mcc|mnc|navigation|screenLayout|touchscreen|uiMode|smallestScreenSize|density">
|
android:configChanges="fontScale|orientation|screenSize|keyboard|keyboardHidden|layoutDirection|locale|mcc|mnc|navigation|screenLayout|touchscreen|uiMode|smallestScreenSize|density"
|
||||||
|
android:windowSoftInputMode="adjustPan">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|
||||||
|
@ -2,7 +2,9 @@ package com.termux.x11;
|
|||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
import android.support.v7.widget.AppCompatTextView;
|
import android.support.v7.widget.AppCompatTextView;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@ -10,6 +12,7 @@ import android.view.Gravity;
|
|||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.view.ViewTreeObserver;
|
||||||
import android.widget.HorizontalScrollView;
|
import android.widget.HorizontalScrollView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
|
|
||||||
@ -17,9 +20,10 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public class AdditionalKeyboardView extends HorizontalScrollView {
|
public class AdditionalKeyboardView extends HorizontalScrollView implements ViewTreeObserver.OnGlobalLayoutListener {
|
||||||
private final static int KEYCODE_BASE = KeyEvent.KEYCODE_REFRESH + 100;
|
private final static int KEYCODE_BASE = 300;
|
||||||
public final static int PREFERENCES_KEY = KEYCODE_BASE + 1;
|
public final static int PREFERENCES_KEY = KEYCODE_BASE + 1;
|
||||||
|
public final static int KEY_HEIGHT_DP = 35;
|
||||||
Context ctx;
|
Context ctx;
|
||||||
View targetView = null;
|
View targetView = null;
|
||||||
View.OnKeyListener targetListener = null;
|
View.OnKeyListener targetListener = null;
|
||||||
@ -39,15 +43,42 @@ public class AdditionalKeyboardView extends HorizontalScrollView {
|
|||||||
ctx = context;
|
ctx = context;
|
||||||
density = (int) context.getResources().getDisplayMetrics().density;
|
density = (int) context.getResources().getDisplayMetrics().density;
|
||||||
|
|
||||||
//setFillViewport(true);
|
getViewTreeObserver().addOnGlobalLayoutListener(this);
|
||||||
|
|
||||||
setBackgroundColor(0xFF000000);
|
setBackgroundColor(0xFF000000);
|
||||||
LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
|
LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT, KEY_HEIGHT_DP * density);
|
||||||
root = new LinearLayout(context);
|
root = new LinearLayout(context);
|
||||||
root.setLayoutParams(lp);
|
root.setLayoutParams(lp);
|
||||||
root.setOrientation(LinearLayout.HORIZONTAL);
|
root.setOrientation(LinearLayout.HORIZONTAL);
|
||||||
addView(root);
|
addView(root);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onGlobalLayout() {
|
||||||
|
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(ctx);
|
||||||
|
if (!preferences.getBoolean("showAdditionalKbd", true)) {
|
||||||
|
if (getVisibility() != View.GONE)
|
||||||
|
setVisibility(View.GONE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Rect r = new Rect();
|
||||||
|
getWindowVisibleDisplayFrame(r);
|
||||||
|
|
||||||
|
float mScreenDensity = getResources().getDisplayMetrics().density;
|
||||||
|
int MAGIC_NUMBER = 200;
|
||||||
|
|
||||||
|
int heightDiff = getRootView().getHeight() - (r.bottom - r.top);
|
||||||
|
float dp = heightDiff/ mScreenDensity;
|
||||||
|
int visibility = (dp > MAGIC_NUMBER)?View.VISIBLE:View.INVISIBLE;
|
||||||
|
|
||||||
|
if (getVisibility() == visibility) return;
|
||||||
|
|
||||||
|
if (visibility == View.VISIBLE)
|
||||||
|
setY(r.bottom - r.top - getHeight());
|
||||||
|
setVisibility(visibility);
|
||||||
|
}
|
||||||
|
|
||||||
public void reload(int[] keys, View TargetView, View.OnKeyListener TargetListener) {
|
public void reload(int[] keys, View TargetView, View.OnKeyListener TargetListener) {
|
||||||
targetView = TargetView;
|
targetView = TargetView;
|
||||||
targetListener = TargetListener;
|
targetListener = TargetListener;
|
||||||
|
@ -31,7 +31,7 @@ import android.view.SurfaceView;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
@SuppressWarnings("ConstantConditions")
|
@SuppressWarnings({"ConstantConditions", "SameParameterValue"})
|
||||||
@SuppressLint({"ClickableViewAccessibility", "StaticFieldLeak"})
|
@SuppressLint({"ClickableViewAccessibility", "StaticFieldLeak"})
|
||||||
public class LorieService extends Service {
|
public class LorieService extends Service {
|
||||||
|
|
||||||
@ -68,6 +68,7 @@ public class LorieService extends Service {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("BatteryLife")
|
||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
if (isServiceRunningInForeground(this, LorieService.class)) return;
|
if (isServiceRunningInForeground(this, LorieService.class)) return;
|
||||||
@ -155,12 +156,8 @@ public class LorieService extends Service {
|
|||||||
|
|
||||||
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(instance);
|
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(instance);
|
||||||
|
|
||||||
instance.mTP.setMode(
|
int mode = Integer.parseInt(preferences.getString("touchMode", "1"));
|
||||||
Integer.parseInt(
|
instance.mTP.setMode(mode);
|
||||||
preferences.getString("touchMode", "1")
|
|
||||||
)
|
|
||||||
);
|
|
||||||
act.showAdditionalKbd = preferences.getBoolean("showAdditionalKbd", true);
|
|
||||||
Log.e("LorieService", "Preferences changed");
|
Log.e("LorieService", "Preferences changed");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -233,6 +230,7 @@ public class LorieService extends Service {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("SameParameterValue")
|
||||||
private static class ServiceEventListener implements SurfaceHolder.Callback, View.OnTouchListener, View.OnKeyListener, View.OnHoverListener, View.OnGenericMotionListener, TouchParser.OnTouchParseListener {
|
private static class ServiceEventListener implements SurfaceHolder.Callback, View.OnTouchListener, View.OnKeyListener, View.OnHoverListener, View.OnGenericMotionListener, TouchParser.OnTouchParseListener {
|
||||||
LorieService svc;
|
LorieService svc;
|
||||||
|
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
package com.termux.x11;
|
package com.termux.x11;
|
||||||
|
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.inputmethodservice.InputMethodService;
|
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.provider.Settings;
|
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
@ -13,9 +11,8 @@ import android.view.SurfaceView;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.view.inputmethod.InputMethodManager;
|
|
||||||
|
|
||||||
public class MainActivity extends AppCompatActivity implements KeyboardUtils.SoftKeyboardToggleListener {
|
public class MainActivity extends AppCompatActivity {
|
||||||
|
|
||||||
private static int[] keys = {
|
private static int[] keys = {
|
||||||
KeyEvent.KEYCODE_ESCAPE,
|
KeyEvent.KEYCODE_ESCAPE,
|
||||||
@ -29,31 +26,24 @@ public class MainActivity extends AppCompatActivity implements KeyboardUtils.Sof
|
|||||||
};
|
};
|
||||||
|
|
||||||
AdditionalKeyboardView kbd;
|
AdditionalKeyboardView kbd;
|
||||||
boolean showAdditionalKbd = true;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
|
||||||
|
|
||||||
LorieService.setMainActivity(this);
|
LorieService.setMainActivity(this);
|
||||||
LorieService.start(LorieService.ACTION_START_FROM_ACTIVITY);
|
LorieService.start(LorieService.ACTION_START_FROM_ACTIVITY);
|
||||||
|
|
||||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||||
|
|
||||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||||
|
|
||||||
setContentView(R.layout.main_activity);
|
setContentView(R.layout.main_activity);
|
||||||
|
|
||||||
kbd = findViewById(R.id.additionalKbd);
|
kbd = findViewById(R.id.additionalKbd);
|
||||||
kbd.setVisibility(View.INVISIBLE);
|
|
||||||
KeyboardUtils.addKeyboardToggleListener(this, this);
|
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
||||||
getWindow().
|
getWindow().
|
||||||
getDecorView().
|
getDecorView().
|
||||||
setPointerIcon(PointerIcon.getSystemIcon(this, PointerIcon.TYPE_NULL));
|
setPointerIcon(PointerIcon.getSystemIcon(this, PointerIcon.TYPE_NULL));
|
||||||
getResources().getConfiguration();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onLorieServiceStart(LorieService instance) {
|
public void onLorieServiceStart(LorieService instance) {
|
||||||
@ -88,13 +78,6 @@ public class MainActivity extends AppCompatActivity implements KeyboardUtils.Sof
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onToggleSoftKeyboard(boolean isVisible) {
|
|
||||||
if (kbd != null && showAdditionalKbd)
|
|
||||||
kbd.setVisibility((isVisible)?View.VISIBLE:View.INVISIBLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBackPressed() {}
|
public void onBackPressed() {}
|
||||||
}
|
}
|
||||||
|
@ -7,21 +7,13 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
<RelativeLayout
|
<com.termux.x11.AdditionalKeyboardView
|
||||||
|
android:id="@+id/additionalKbd"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
<ScrollView
|
<!-- Without this view AdditionalKeyboard view sometimes dissapear -->
|
||||||
android:id="@+id/sv"
|
<View
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent" />
|
||||||
android:layout_below="@id/additionalKbd" />
|
|
||||||
|
|
||||||
<com.termux.x11.AdditionalKeyboardView
|
|
||||||
android:id="@+id/additionalKbd"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="35dp"
|
|
||||||
android:layout_alignParentBottom="true" />
|
|
||||||
|
|
||||||
</RelativeLayout>
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
Loading…
Reference in New Issue
Block a user