diff --git a/android/KMAPro/kMAPro/src/main/AndroidManifest.xml b/android/KMAPro/kMAPro/src/main/AndroidManifest.xml
index bf328d040d..d06bfc8422 100644
--- a/android/KMAPro/kMAPro/src/main/AndroidManifest.xml
+++ b/android/KMAPro/kMAPro/src/main/AndroidManifest.xml
@@ -294,6 +294,11 @@
android:parentActivityName=".SelectPackageActivity"
android:launchMode="singleTask"
android:theme="@style/AppTheme.Base" />
+
diff --git a/android/KMAPro/kMAPro/src/main/java/com/tavultesoft/kmapro/AdjustKeyboardHeightActivity.java b/android/KMAPro/kMAPro/src/main/java/com/tavultesoft/kmapro/AdjustKeyboardHeightActivity.java
new file mode 100644
index 0000000000..972165efdb
--- /dev/null
+++ b/android/KMAPro/kMAPro/src/main/java/com/tavultesoft/kmapro/AdjustKeyboardHeightActivity.java
@@ -0,0 +1,147 @@
+/**
+ * Copyright (C) SIL International. All rights reserved.
+ */
+package com.tavultesoft.kmapro;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.content.res.Configuration;
+import android.graphics.drawable.ColorDrawable;
+import android.os.Bundle;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Button;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import androidx.appcompat.app.ActionBar;
+import androidx.appcompat.widget.Toolbar;
+import androidx.core.content.ContextCompat;
+
+import com.tavultesoft.kmea.BaseActivity;
+import com.tavultesoft.kmea.KMManager;
+
+/**
+ * Settings menu for adjusting the keyboard height. The value for the current device orientation
+ * is saved in shared preferences.
+ */
+public class AdjustKeyboardHeightActivity extends BaseActivity {
+ private static final String TAG = "AdjustKbdHeight";
+ public static final String adjustKeyboardHeightKey = "AdjustKeyboardHeight";
+
+ private static Button resetButton = null;
+ private static ImageView sampleKeyboard = null;
+
+ // Keeps track of the adjusted keyboard height for saving
+ private static SharedPreferences.Editor editor = null;
+ private static int currentHeight = 0;
+ private static ViewGroup.LayoutParams layoutParams;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ final Context context = this;
+
+ setContentView(R.layout.activity_adjust_keyboard_height);
+
+ Toolbar toolbar = (Toolbar) findViewById(R.id.titlebar);
+ setSupportActionBar(toolbar);
+ ActionBar actionBar = getSupportActionBar();
+ if (actionBar != null) {
+ actionBar.setTitle(null);
+ actionBar.setDisplayUseLogoEnabled(false);
+ actionBar.setDisplayShowHomeEnabled(false);
+ actionBar.setDisplayShowTitleEnabled(false);
+ actionBar.setDisplayShowCustomEnabled(true);
+ actionBar.setBackgroundDrawable(new ColorDrawable(ContextCompat.getColor(this, R.color.keyman_blue)));
+ }
+
+ TextView adjustKeyboardHeightActivityTitle = (TextView) findViewById(R.id.bar_title);
+ adjustKeyboardHeightActivityTitle.setWidth((int) getResources().getDimension(R.dimen.package_label_width));
+
+ String titleStr = getString(R.string.adjust_keyboard_height);
+ adjustKeyboardHeightActivityTitle.setTextColor(ContextCompat.getColor(this, R.color.ms_white));
+ adjustKeyboardHeightActivityTitle.setText(titleStr);
+
+ SharedPreferences prefs = context.getSharedPreferences(context.getString(R.string.kma_prefs_name), Context.MODE_PRIVATE);
+ editor = prefs.edit();
+
+ sampleKeyboard = (ImageView) findViewById(R.id.sample_keyboard);
+ layoutParams = sampleKeyboard.getLayoutParams();
+ refreshSampleKeyboard(context, true);
+
+ resetButton = (Button) findViewById(R.id.reset_to_defaults);
+ resetButton.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View v) {
+ // Clear the keyboard height preferences to reset
+ editor.remove(KMManager.KMKey_KeyboardHeightPortrait);
+ editor.remove(KMManager.KMKey_KeyboardHeightLandscape);
+ editor.commit();
+
+ // Restore default height
+ refreshSampleKeyboard(context, true);
+ }
+ });
+
+ sampleKeyboard.setOnTouchListener(new View.OnTouchListener() {
+ @Override
+ public boolean onTouch(View view, MotionEvent event) {
+ int y = (int)event.getY();
+
+ switch(event.getAction()) {
+ case MotionEvent.ACTION_MOVE:
+ // Update currentHeight as the user drags (moves)
+ // Increasing the keyboard height is a negative y
+ currentHeight -= y;
+
+ refreshSampleKeyboard(context, false);
+ break;
+ case MotionEvent.ACTION_UP:
+ // Save the currentHeight when the user releases
+ int orientation = context.getResources().getConfiguration().orientation;
+ String keyboardHeightKey = (orientation == Configuration.ORIENTATION_LANDSCAPE) ?
+ KMManager.KMKey_KeyboardHeightLandscape : KMManager.KMKey_KeyboardHeightPortrait;
+ editor.putInt(keyboardHeightKey, currentHeight);
+ editor.commit();
+ break;
+ }
+ return true;
+ }
+ });
+ }
+
+ /**
+ * Refresh the layout for the sample keyboard
+ * @param context
+ * @param updateCurrentHeight - boolean if true, updates currentHeight
+ */
+ private void refreshSampleKeyboard(Context context, boolean updateCurrentHeight) {
+ if (updateCurrentHeight) {
+ currentHeight = KMManager.getKeyboardHeight(context);
+ }
+
+ layoutParams.height = currentHeight;
+ sampleKeyboard.setLayoutParams(layoutParams);
+ }
+
+ @Override
+ public void onConfigurationChanged(Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+
+ layoutParams = sampleKeyboard.getLayoutParams();
+
+ // When the user rotates the device, restore currentHeight
+ refreshSampleKeyboard(this,true);
+ }
+
+ @Override
+ public void onBackPressed() {
+ // Apply the adjusted height on exit
+ KMManager.setKeyboardHeight(this, currentHeight);
+
+ super.onBackPressed();
+ }
+
+}
\ No newline at end of file
diff --git a/android/KMAPro/kMAPro/src/main/java/com/tavultesoft/kmapro/KeymanSettingsFragment.java b/android/KMAPro/kMAPro/src/main/java/com/tavultesoft/kmapro/KeymanSettingsFragment.java
index 09a57a02e6..89e6cb29ed 100644
--- a/android/KMAPro/kMAPro/src/main/java/com/tavultesoft/kmapro/KeymanSettingsFragment.java
+++ b/android/KMAPro/kMAPro/src/main/java/com/tavultesoft/kmapro/KeymanSettingsFragment.java
@@ -27,7 +27,8 @@ public class KeymanSettingsFragment extends PreferenceFragmentCompat {
private static final String TAG = "SettingsFragment";
private static Context context;
- private Preference languagesPreference, installKeyboardOrDictionary, displayLanguagePreference;
+ private Preference languagesPreference, installKeyboardOrDictionary, displayLanguagePreference,
+ adjustKeyboardHeight;
private ListPreference spacebarTextPreference;
private CheckBoxPreference setSystemKeyboardPreference;
private CheckBoxPreference setDefaultKeyboardPreference;
@@ -62,6 +63,13 @@ public class KeymanSettingsFragment extends PreferenceFragmentCompat {
Intent displayLanguageIntent = new Intent(context, KeymanSettingsLocalizeActivity.class);
displayLanguagePreference.setIntent(displayLanguageIntent);
+ adjustKeyboardHeight = new Preference(context);
+ adjustKeyboardHeight.setKey(AdjustKeyboardHeightActivity.adjustKeyboardHeightKey);
+ adjustKeyboardHeight.setTitle(getString(R.string.adjust_keyboard_height));
+ adjustKeyboardHeight.setWidgetLayoutResource(R.layout.preference_height_icon_layout);
+ Intent adjustKeyboardHeightIntent = new Intent(context, AdjustKeyboardHeightActivity.class);
+ adjustKeyboardHeight.setIntent(adjustKeyboardHeightIntent);
+
/* Spacebar Caption Preference */
spacebarTextPreference = new ListPreference(context);
@@ -168,6 +176,7 @@ public class KeymanSettingsFragment extends PreferenceFragmentCompat {
screen.addPreference(languagesPreference);
screen.addPreference(installKeyboardOrDictionary);
screen.addPreference(displayLanguagePreference);
+ screen.addPreference(adjustKeyboardHeight);
screen.addPreference(spacebarTextPreference);
screen.addPreference(setSystemKeyboardPreference);
diff --git a/android/KMAPro/kMAPro/src/main/java/com/tavultesoft/kmapro/MainActivity.java b/android/KMAPro/kMAPro/src/main/java/com/tavultesoft/kmapro/MainActivity.java
index ba0a93744e..5fc6e1d0b7 100644
--- a/android/KMAPro/kMAPro/src/main/java/com/tavultesoft/kmapro/MainActivity.java
+++ b/android/KMAPro/kMAPro/src/main/java/com/tavultesoft/kmapro/MainActivity.java
@@ -260,6 +260,7 @@ public class MainActivity extends BaseActivity implements OnKeyboardEventListene
super.onResume();
KMManager.onResume();
KMManager.hideSystemKeyboard();
+ resizeTextView(textView.isKeyboardVisible());
KMManager.addKeyboardEventListener(this);
KMKeyboardDownloaderActivity.addKeyboardDownloadEventListener(this);
@@ -576,7 +577,7 @@ public class MainActivity extends BaseActivity implements OnKeyboardEventListene
}
}
- private void resizeTextView(boolean isKeyboardVisible) {
+ public void resizeTextView(boolean isKeyboardVisible) {
int bannerHeight = 0;
int keyboardHeight = 0;
if (isKeyboardVisible) {
diff --git a/android/KMAPro/kMAPro/src/main/res/drawable-hdpi/ic_height.png b/android/KMAPro/kMAPro/src/main/res/drawable-hdpi/ic_height.png
new file mode 100644
index 0000000000..a515e98f03
Binary files /dev/null and b/android/KMAPro/kMAPro/src/main/res/drawable-hdpi/ic_height.png differ
diff --git a/android/KMAPro/kMAPro/src/main/res/drawable-hdpi/ic_keyboard.png b/android/KMAPro/kMAPro/src/main/res/drawable-hdpi/ic_keyboard.png
new file mode 100644
index 0000000000..2468a51829
Binary files /dev/null and b/android/KMAPro/kMAPro/src/main/res/drawable-hdpi/ic_keyboard.png differ
diff --git a/android/KMAPro/kMAPro/src/main/res/drawable-mdpi/ic_height.png b/android/KMAPro/kMAPro/src/main/res/drawable-mdpi/ic_height.png
new file mode 100644
index 0000000000..a515e98f03
Binary files /dev/null and b/android/KMAPro/kMAPro/src/main/res/drawable-mdpi/ic_height.png differ
diff --git a/android/KMAPro/kMAPro/src/main/res/drawable-mdpi/ic_keyboard.png b/android/KMAPro/kMAPro/src/main/res/drawable-mdpi/ic_keyboard.png
new file mode 100644
index 0000000000..2468a51829
Binary files /dev/null and b/android/KMAPro/kMAPro/src/main/res/drawable-mdpi/ic_keyboard.png differ
diff --git a/android/KMAPro/kMAPro/src/main/res/drawable-xhdpi/ic_height.png b/android/KMAPro/kMAPro/src/main/res/drawable-xhdpi/ic_height.png
new file mode 100644
index 0000000000..9f5b593479
Binary files /dev/null and b/android/KMAPro/kMAPro/src/main/res/drawable-xhdpi/ic_height.png differ
diff --git a/android/KMAPro/kMAPro/src/main/res/drawable-xhdpi/ic_keyboard.png b/android/KMAPro/kMAPro/src/main/res/drawable-xhdpi/ic_keyboard.png
new file mode 100644
index 0000000000..d28e994a8f
Binary files /dev/null and b/android/KMAPro/kMAPro/src/main/res/drawable-xhdpi/ic_keyboard.png differ
diff --git a/android/KMAPro/kMAPro/src/main/res/drawable-xxhdpi/ic_height.png b/android/KMAPro/kMAPro/src/main/res/drawable-xxhdpi/ic_height.png
new file mode 100644
index 0000000000..94e006ef85
Binary files /dev/null and b/android/KMAPro/kMAPro/src/main/res/drawable-xxhdpi/ic_height.png differ
diff --git a/android/KMAPro/kMAPro/src/main/res/drawable-xxhdpi/ic_keyboard.png b/android/KMAPro/kMAPro/src/main/res/drawable-xxhdpi/ic_keyboard.png
new file mode 100644
index 0000000000..6d3f0e3dc8
Binary files /dev/null and b/android/KMAPro/kMAPro/src/main/res/drawable-xxhdpi/ic_keyboard.png differ
diff --git a/android/KMAPro/kMAPro/src/main/res/drawable-xxxhdpi/ic_height.png b/android/KMAPro/kMAPro/src/main/res/drawable-xxxhdpi/ic_height.png
new file mode 100644
index 0000000000..8ea3b1e396
Binary files /dev/null and b/android/KMAPro/kMAPro/src/main/res/drawable-xxxhdpi/ic_height.png differ
diff --git a/android/KMAPro/kMAPro/src/main/res/drawable-xxxhdpi/ic_keyboard.png b/android/KMAPro/kMAPro/src/main/res/drawable-xxxhdpi/ic_keyboard.png
new file mode 100644
index 0000000000..cfa9545e2f
Binary files /dev/null and b/android/KMAPro/kMAPro/src/main/res/drawable-xxxhdpi/ic_keyboard.png differ
diff --git a/android/KMAPro/kMAPro/src/main/res/drawable/dash_border.xml b/android/KMAPro/kMAPro/src/main/res/drawable/dash_border.xml
new file mode 100644
index 0000000000..1926ed58a3
--- /dev/null
+++ b/android/KMAPro/kMAPro/src/main/res/drawable/dash_border.xml
@@ -0,0 +1,11 @@
+
+
+
+ -
+
+
+
+
+
+
+
diff --git a/android/KMAPro/kMAPro/src/main/res/layout/activity_adjust_keyboard_height.xml b/android/KMAPro/kMAPro/src/main/res/layout/activity_adjust_keyboard_height.xml
new file mode 100644
index 0000000000..96b6d15746
--- /dev/null
+++ b/android/KMAPro/kMAPro/src/main/res/layout/activity_adjust_keyboard_height.xml
@@ -0,0 +1,59 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/android/KMAPro/kMAPro/src/main/res/layout/preference_height_icon_layout.xml b/android/KMAPro/kMAPro/src/main/res/layout/preference_height_icon_layout.xml
new file mode 100644
index 0000000000..be0e7ac155
--- /dev/null
+++ b/android/KMAPro/kMAPro/src/main/res/layout/preference_height_icon_layout.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/android/KMAPro/kMAPro/src/main/res/values/strings.xml b/android/KMAPro/kMAPro/src/main/res/values/strings.xml
index 7fd06ac652..8dda950bd0 100644
--- a/android/KMAPro/kMAPro/src/main/res/values/strings.xml
+++ b/android/KMAPro/kMAPro/src/main/res/values/strings.xml
@@ -104,6 +104,9 @@
Display language
+
+ Adjust keyboard height
+
Spacebar caption
@@ -177,6 +180,15 @@
All languages already installed
+
+ Drag the keyboard to resize the height
+
+
+ Rotate the device to adjust portrait and landscape
+
+
+ Reset to Defaults
+
Search or type URL
diff --git a/android/KMEA/app/src/main/java/com/tavultesoft/kmea/KMManager.java b/android/KMEA/app/src/main/java/com/tavultesoft/kmea/KMManager.java
index c659190a2b..af945493ac 100644
--- a/android/KMEA/app/src/main/java/com/tavultesoft/kmea/KMManager.java
+++ b/android/KMEA/app/src/main/java/com/tavultesoft/kmea/KMManager.java
@@ -230,6 +230,8 @@ public final class KMManager {
public static final String KMKey_FontFamily = "family";
public static final String KMKey_KeyboardModified = "lastModified";
public static final String KMKey_KeyboardRTL = "rtl";
+ public static final String KMKey_KeyboardHeightPortrait = "keyboardHeightPortrait";
+ public static final String KMKey_KeyboardHeightLandscape = "keyboardHeightLandscape";
public static final String KMKey_CustomHelpLink = "CustomHelpLink";
public static final String KMKey_KMPLink = "kmp";
@@ -1650,7 +1652,29 @@ public final class KMManager {
}
public static int getKeyboardHeight(Context context) {
- return (int) context.getResources().getDimension(R.dimen.keyboard_height);
+ int defaultHeight = (int) context.getResources().getDimension(R.dimen.keyboard_height);
+ SharedPreferences prefs = context.getSharedPreferences(context.getString(R.string.kma_prefs_name), Context.MODE_PRIVATE);
+ int orientation = context.getResources().getConfiguration().orientation;
+ if (orientation == Configuration.ORIENTATION_PORTRAIT) {
+ return prefs.getInt(KMManager.KMKey_KeyboardHeightPortrait, defaultHeight);
+ } else if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
+ return prefs.getInt(KMManager.KMKey_KeyboardHeightLandscape, defaultHeight);
+ }
+
+ return defaultHeight;
+ }
+
+ public static void setKeyboardHeight(Context context, int height) {
+ if (InAppKeyboard != null && InAppKeyboardLoaded) {
+ InAppKeyboard.loadJavascript(KMString.format("setOskHeight('%s')", height));
+ RelativeLayout.LayoutParams params = getKeyboardLayoutParams();
+ InAppKeyboard.setLayoutParams(params);
+ }
+ if (SystemKeyboard != null && SystemKeyboardLoaded) {
+ SystemKeyboard.loadJavascript(KMString.format("setOskHeight('%s')", height));
+ RelativeLayout.LayoutParams params = getKeyboardLayoutParams();
+ SystemKeyboard.setLayoutParams(params);
+ }
}
public static void setDebugMode(boolean value) {