Custom number keyboard to edit limit

The custom number keyboard is implemented to avoid any issue with external software keyboard. See Edit limit issue with Google Keyboard in App Gatekeeper.

custom number keyboard to edit limit on phone

On the bottom row of the number keyboard, we have left arrow, right arrow, backspace, and return keys. The arrow keys are for navigating between the hour and minute EditText. On navigating into EditText, the original numbers will be selected. (make it easier to replace)

The cursor is not shown in the EditText, but it can be assumed to be at the end. So, entered numbers appear appended to the right, and the backspace also deletes from the end.

The return key will end the editing and save the values.

The custom number keyboard is only shown when no hardware keyboard is available. Hardware keyboard should still work as before.

Implementation details

Refer to Maarten Pennings' Android development: Custom keyboard, it provides a detailed explanation. Thanks!

I use EditText.setKeyListener(null); with the custom number keyboard, which disables external software keyboard.
And, EditText.setKeyListener(DigitsKeyListener.getInstance()); if there is a hardware keyboard attached.

Activity.onConfigurationChanged can detect when a hardware keyboard is attached or detached. (AndroidManifest.xml android:configChanges="keyboard|keyboardHidden|navigation" specifies the Configuration types that will be handled by the activity) Any editing session is cancelled when there is a keyboard Configuration changed.

When editing the limit on a phone, the row containing the hour and minute EditText, is enlarged with the hour EditText positioning above the minute EditText. If the row is at the bottom (next to keyboard), then perhaps only the hour EditText is visible. The ListView is adjusted to fully display both hour and minute EditText.

Testing is done on Samsung Galaxy S3 and Nexus 7 and Transformer TF701.

Switching between soft input and usb keyboard works for Nexus 7, but in Samsung Galaxy S3, the system does not recognize the usb keyboard as hardware keyboard.

For Transformer TF701, you will need to enable/disable the hardware keyboard in the system "Choose input method" to inform Android.

App Gatekeeper (version 1.2.0) with the custom number keyboard is released.

Past release: App Gatekeeper updated to version 1.1


blog comments powered by Disqus