Commit 2ad58dd7 authored by Evan W. Patton's avatar Evan W. Patton

Disable suggestions in TextView

This commit disables suggestions in the TextView, which appears to
crash the Companion on Android 7+ due to missing layouts.

Change-Id: I932f5aeaded2584e80f1e2e512e401000a7214ed
parent 9cba2394
......@@ -14,11 +14,13 @@ import com.google.appinventor.components.annotations.SimpleObject;
import com.google.appinventor.components.annotations.SimpleProperty;
import com.google.appinventor.components.common.ComponentConstants;
import com.google.appinventor.components.common.PropertyTypeConstants;
import com.google.appinventor.components.runtime.util.EclairUtil;
import com.google.appinventor.components.runtime.util.TextViewUtil;
import com.google.appinventor.components.runtime.util.ViewUtil;
//import com.google.appinventor.components.runtime.parameters.BooleanReferenceParameter;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.view.View;
import android.view.View.OnFocusChangeListener;
import android.widget.EditText;
......@@ -69,6 +71,14 @@ public abstract class TextBoxBase extends AndroidViewComponent
public TextBoxBase(ComponentContainer container, EditText textview) {
super(container);
view = textview;
// There appears to be an issue where, by default, Android 7+
// wants to provide suggestions in text boxes. However, we do not
// compile the necessary layouts for this to work correctly, which
// results in an application crash. This disables that feature
// until we include newer Android layouts.
if (Build.VERSION.SDK_INT >= 24 /* Nougat */ ) {
EclairUtil.disableSuggestions(textview);
}
// Listen to focus changes
view.setOnFocusChangeListener(this);
......
......@@ -12,6 +12,7 @@ import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.text.InputType;
import android.view.MotionEvent;
import android.view.View;
import android.webkit.GeolocationPermissions;
......@@ -19,6 +20,7 @@ import android.webkit.GeolocationPermissions.Callback;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.webkit.WebChromeClient;
import android.widget.EditText;
/**
* Helper methods for calling methods added in Eclair (2.0, API level 5)
......@@ -104,4 +106,16 @@ public class EclairUtil {
return form.getPackageManager().getInstallerPackageName(pname);
}
/**
* Disable suggestions on EditText widgets. This was added to
* support SDK levels where suggestions crashed apps without the
* appropriate Android Support library compiled into the app.
*
* @param textview EditText widget to have its suggestion feature
* disabled.
*/
public static void disableSuggestions(EditText textview) {
textview.setInputType(textview.getInputType() | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment