Temporarily have 2 text fields in Keyman app

for testing that in-app keyboard resets when changing text area.

Do **not** merge this commit
This commit is contained in:
darcywong00 2017-09-08 11:58:52 +07:00
parent 8e8a9c1b26
commit a18bb2a2fd
3 changed files with 48 additions and 14 deletions

View file

@ -62,11 +62,12 @@ import android.widget.Toast;
public class MainActivity extends Activity implements OnKeyboardEventListener, OnKeyboardDownloadEventListener {
private KMTextView textView;
private KMTextView textView, textView2;
private final int minTextSize = 16;
private final int maxTextSize = 72;
private int textSize = minTextSize;
private static final String userTextKey = "UserText";
private static final String userTextKey2 = "UserText";
private static final String userTextSizeKey = "UserTextSize";
protected static final String dontShowGetStartedKey = "DontShowGetStarted";
protected static final String didCheckUserDataKey = "DidCheckUserData";
@ -86,11 +87,15 @@ public class MainActivity extends Activity implements OnKeyboardEventListener, O
KMManager.initialize(getApplicationContext(), KeyboardType.KEYBOARD_TYPE_INAPP);
setContentView(R.layout.activity_main);
textView = (KMTextView) findViewById(R.id.kmTextView);
textView2 = (KMTextView) findViewById(R.id.kmTextView2);
SharedPreferences prefs = getSharedPreferences(getString(R.string.kma_prefs_name), Context.MODE_PRIVATE);
textView.setText(prefs.getString(userTextKey, ""));
textView2.setText(prefs.getString(userTextKey2, ""));
textSize = prefs.getInt(userTextSizeKey, minTextSize);
textView.setTextSize((float) textSize);
textView2.setTextSize((float) textSize);
textView.setSelection(textView.getText().length());
textView2.setSelection(textView2.getText().length());
boolean didCheckUserData = prefs.getBoolean(MainActivity.didCheckUserDataKey, false);
if (!didCheckUserData && (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)) {
@ -193,6 +198,7 @@ public class MainActivity extends Activity implements OnKeyboardEventListener, O
SharedPreferences prefs = getSharedPreferences(getString(R.string.kma_prefs_name), Context.MODE_PRIVATE);
SharedPreferences.Editor editor = prefs.edit();
editor.putString(userTextKey, textView.getText().toString());
editor.putString(userTextKey2, textView2.getText().toString());
editor.putInt(userTextSizeKey, textSize);
editor.commit();
}
@ -264,6 +270,7 @@ public class MainActivity extends Activity implements OnKeyboardEventListener, O
@Override
public void onKeyboardChanged(String newKeyboard) {
textView.setTypeface(KMManager.getKeyboardTextFontTypeface(this));
textView2.setTypeface(KMManager.getKeyboardTextFontTypeface(this));
}
@Override
@ -294,7 +301,7 @@ public class MainActivity extends Activity implements OnKeyboardEventListener, O
Point size = new Point(0, 0);
getWindowManager().getDefaultDisplay().getSize(size);
int screenHeight = size.y;
textView.setHeight(screenHeight - statusBarHeight - actionBarHeight - keyboardHeight);
//textView.setHeight(screenHeight - statusBarHeight - actionBarHeight - keyboardHeight);
}
private void showInfo() {

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/keyman_blue" />
<corners android:radius="0dp" />
<padding android:left="10dp" android:top="10dp" android:right="10dp" android:bottom="10dp" />
<stroke android:color="#858585" android:width="0dp" />
</shape>

View file

@ -6,19 +6,39 @@
android:background="@color/yellow_background"
tools:context=".MainActivity" >
<com.tavultesoft.kmea.KMTextView
android:id="@+id/kmTextView"
android:background="@drawable/textview_bg"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:ems="10"
android:inputType="textMultiLine"
android:hint="@string/textview_hint"
android:gravity="top"
android:scrollbars="vertical" >
android:layout_height="match_parent"
android:weightSum="3"
android:orientation="vertical">
<com.tavultesoft.kmea.KMTextView
android:id="@+id/kmTextView"
android:background="@drawable/textview_bg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_alignParentTop="true"
android:ems="10"
android:inputType="textMultiLine"
android:hint="@string/textview_hint"
android:gravity="top"
android:scrollbars="vertical" >
<requestFocus />
</com.tavultesoft.kmea.KMTextView>
<requestFocus />
</com.tavultesoft.kmea.KMTextView>
<com.tavultesoft.kmea.KMTextView
android:id="@+id/kmTextView2"
android:background="@drawable/textview2_bg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_alignParentTop="true"
android:ems="10"
android:inputType="textMultiLine"
android:hint="this is temporary..."
android:gravity="top"
android:scrollbars="vertical" >
</com.tavultesoft.kmea.KMTextView>
</LinearLayout>
</RelativeLayout>