|
15 | 15 | */ |
16 | 16 | package org.gnucash.android.ui.util.widget; |
17 | 17 |
|
18 | | -import android.app.Activity; |
19 | 18 | import android.content.Context; |
20 | 19 | import android.content.res.TypedArray; |
21 | 20 | import android.inputmethodservice.KeyboardView; |
| 21 | +import android.os.Build; |
22 | 22 | import android.support.annotation.Nullable; |
23 | 23 | import android.support.annotation.XmlRes; |
24 | 24 | import android.support.v7.widget.AppCompatEditText; |
|
29 | 29 | import android.util.Log; |
30 | 30 | import android.view.MotionEvent; |
31 | 31 | import android.view.View; |
32 | | -import android.view.inputmethod.InputMethodManager; |
33 | 32 |
|
34 | 33 | import com.crashlytics.android.Crashlytics; |
35 | 34 |
|
36 | 35 | import net.objecthunter.exp4j.Expression; |
37 | 36 | import net.objecthunter.exp4j.ExpressionBuilder; |
38 | 37 |
|
39 | 38 | import org.gnucash.android.R; |
40 | | -import org.gnucash.android.app.GnuCashApplication; |
41 | 39 | import org.gnucash.android.model.Commodity; |
42 | 40 | import org.gnucash.android.ui.common.FormActivity; |
43 | 41 | import org.gnucash.android.util.AmountParser; |
@@ -148,18 +146,12 @@ public void onClick(View v) { |
148 | 146 | // Disable spell check (hex strings look like words to Android) |
149 | 147 | setInputType(getInputType() | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS); |
150 | 148 |
|
151 | | - // FIXME: for some reason, this prevents the text selection from working |
152 | | - setOnLongClickListener(new View.OnLongClickListener() { |
153 | | - @Override |
154 | | - public boolean onLongClick(View v) { |
155 | | - if (v != null && !isInEditMode()) |
156 | | - ((InputMethodManager) GnuCashApplication.getAppContext() |
157 | | - .getSystemService(Activity.INPUT_METHOD_SERVICE)) |
158 | | - .hideSoftInputFromWindow(v.getWindowToken(), 0); |
159 | | - |
160 | | - return false; |
161 | | - } |
162 | | - }); |
| 149 | + // Disable system keyboard appearing on long-press, but for some reason, this prevents the text selection from working. |
| 150 | + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { |
| 151 | + setShowSoftInputOnFocus(false); |
| 152 | + } else { |
| 153 | + setRawInputType(InputType.TYPE_CLASS_NUMBER); |
| 154 | + } |
163 | 155 |
|
164 | 156 | // Although this handler doesn't make sense, if removed, the standard keyboard |
165 | 157 | // shows up in addition to the calculator one when the EditText gets a touch event. |
|
0 commit comments