Android Default Text Selection Behavior for a WebView - android

I am expanding a previously written app. The main component of the app is a webview. In the previous iteration of the app we did not want to allow the users to select text. In the expansion we want to allow the users to be able to select text. I made the assumption that text selection is enabled by default on webviews and the developer who wrote the app disabled the ability for people to select text. In trying to enable this feature i commented out all the touch and click listeners that were attached to my webview one by one to see where they disabled text selection, but even with every touch listener commented out i still can't select text. My question is, was my original assumption correct? Is text selection enabled by default? Should i instead be looking for a way to enable text selection instead of not disabling it?
Thanks!

I found there was no text selection by default for Android 2.2 - 2.3, but it did enable copy/paste if long touch happened for Android 4.0+. Then I tried to disable this feature, but failed unfortunately. All answers right here (SO) didn't work too.

Related

Disable Copy/Paste/Share menu but keep text selectable

I already know about user-select: none css rule, but it doesn’t help me with my problem.
The thing is I have my own custom menu that appears when I long press or select text in my paragraphs, however the android default menu is displayed on top of my own and hinders the user experience.
I know there is a cordova plugin that already takes care of the issue in iOS but I couldn’t find one for android.
I want to remain able to select my text, with my own custom options on top of that but disable the default android menu. Please help.

Detect when the user enters/leaves "Swipe to type" mode in TextInput/EditText (Android)

This is an Android question.
Inside my <TextInput> (ReactNative (which renders an EditText in Android)) when the user types "#" and then they use Androids swipe mode to auto-complete a word, it adds a space between the "#" and the autocompleted word. So what I was doing was, onChange of the text, I replace the space between "#" and the word, however while the user is in swift mode, it is really messing things up. The space comes back and the swift autocomplete messes up to another word.
Is there a way in react-native to listen when the user accepts an autocompletion? I want to then check if the previous two chars are a # (hashtag and space) and if so, then replace it with just # (hashtag without space).
I was thinking the onCommitCompletion- https://developer.android.com/reference/android/widget/TextView.html#onCommitCompletion(android.view.inputmethod.CompletionInfo) - fires after a suggested word is accepted - is this true? If it is this would be perfect and I can submit a PR to react-native to accept this for Android.
Here is a video of what's happening: https://gfycat.com/AdmirableGrizzledIrishsetter
Low quality:
This is happening because you are typing a text via Swipe feature of your keyboard. The Swipe feature automatically adds an extra space before and after the String. There is no way to get rid of it, it's an integrated feature of(some) the keyboard. We have no control over it.
Don't worry, the end user is aware of it and all he has to do is type the whole text rather than using Swipe feature to input his text.
Try disabling AutoComplete inside your TextInput , perhaps like <TextInput autoCorrect={false}/>, I'm not sure.
Also, this isn't the problem with Android phones only, try installing GBoard in an Apple Device and you'll face the same problem.
I worked on a major keyboard for 2 years and I have no idea what you mean by "swift mode". But there is no such feature in the generic keyboard API. It may be a feature of some particular keyboard, but there'd be no way to programmatically turn it off.
What you're describing comes closest to sounding like autospacing. This is not a concept that Android has, it would be a concept of each individual keyboard. And since Android knows nothing about it, it can't turn it off (on many keyboards the user could, but that's it).
You might be able to override it (not turn it off, but force the spaces to disappear) if you were to do some work with either overridding the InputConnection or setting a text watcher in Java and altering the text to be inserted, but neither can be done at the react native level- you'd need to write a custom edit text and link that down to react native via a native component.
I think this would be onCommitCompletion - I'm not sure though I am not able to test yet. I think in this callback I would get the position, and see if there is a leading space, and if so then remove that leading space.

Android Open Context Menu Whenever i select any Text anywhere across the device

I am trying to work on one idea. whenever user selects any text anywhere in any application' on android device i want to show one option to user just like we get an option for copy.
Is it possible to change android's default behavior like this. When user selects any text i want to show one option just like "copy" and when user selects that option i want to perform some operation on that selected text.
Any idea how can i achieve this ?
Is it possible to change android's default behavior like this
Not from Android 1.0 through 5.1.
The M Developer Preview offers a means of doing this. Activities supporting the PROCESS_TEXT action will show up in the floating action mode that appears when users select text:
However, as this is not well-documented, it remains to be seen if this will make it into the final edition of Android M.

Numeric keyboard as default, but allow text

I'm currently developing an application targeted at android and desktop devices using apache cordova and HTML5.
In order to get the numeric keyboard to pop up I've used input type="number", which works fine.
However, the input field should also accept strings. The current functionality of type=number is that the ui seems to allow for strings to be entered, but the value property of the element is not changed if the input is invalid (e.g not numberic).
Is there a way of getting the numberic keyboard on mobile devices, while still being able to enter text?
My inital tries consisted of capturing the keydown event and manually setting the this.value property. I've tried this using jQuerys .val() and of course the more 'native' approach element.val += char. None of which work. UI is updated, but the change is not reflected in the model.
EDIT
For the next guy trying to achieve this.
1) The HTML solution.
As #LuudJacobs mentions in the comments below; There's currently no way to decide which keyboard is shown except for defining the type-attribute. Though some devices have a button to go back to alphabet keyboard, its not the case for every device. And can not be used reliably.
2) Writing a phonegap/cordova plugin.
It is possible to write a plugin to show and hide the keyboard at will. But, as far as I could find, there is currently no way of programmatically telling it to default to the symbols keyboard. Thus the functionality achieved is similar to using type=number and type=text in the HTML. Another problem with this approach is the diversity of keyboard for android devices, where even users themselves can install their custom keyboard. The functionality of the keyboard can are therefore unknown. What works on one device, may not work on the next.
3) JS/HTML/Canvas solution
Finally... A feasible solution. I suggest taking a look at this walkthrough as it shows an easy way to creating the keyboard using just html and js. Another option would be to use a canvas, and draw the keyboard yourself, but I would imagine that this is more error prone and harder to do.
As explained in the HTML5 spec you can not have anything but valid floats in a input type="number". So You can not. On a sidenote: how would users enter text when they'd only have a numeric keyboard?

Enabling my application to show up in the Android Global Search

I have an application that I have made searchable, and I want to include it in the Google Search bar by default, or give my users the option of enabling it from within my application. I have already exposed it by adding android:includeInGlobalSearch into my searchable.xml, but how would I enable it from my settings within the application?
I know I can also launch the Settings.ACTION_SEARCH_SETTINGS activity and have them select it, but how would I shift the focus/scroll to my application if it is below the initial fold?
AFAIK, you can't. The user has to enable it, you can't force them to. You can' control the focus scroll either, best you could do is experiment with different names and see how this affects sorting.

Categories

Resources