Android, How to select editor segment of TimePicker? - android

As you know time picker has three segments, two buttons on top and bottom of view and an editor in between.
By tap and holding editor, we can select its contents. The problem that I have is I want to select content of editor just by taping (not tap and hold). Is it possible?

Try something like this in layout file
<TimePicker
android:id="#+id/activity_main_timepicker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="14dip"
android:layout_marginRight="16dip"
android:focusable="true"
android:focusableInTouchMode="true" />
Unlike most other controls, EditTexts are focusable while the system is in 'touch mode'.
The first click event focuses the control, while the second click event actually fires the
OnClickListener. If you disable touch-mode focus with the android:focusableInTouchMode View
attribute, the OnClickListener should fire as expected.

Related

Navigate between headings with swipe while using talkback

Android 9 has introduced accessibilityHeading tag, which can be used by talkback to announce the Headings.
https://developer.android.com/about/versions/pie/android-9.0#a11y
Look for Heading-based navigation
In my app I have multiple Textviews in my activity with some Headings
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:accessibilityHeading="true"
android:text="Accessibility Heading 1"
android:textColor="#000000"
android:textSize="18sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:text="Message"
android:textColor="#000000" />
But when I run the app, headings are treated as normal textviews only and no special treatment is given by Talkback.
I can swipe left to navigate through all elements.
There is option to swipe up to change mode for talkback announcements. e.g Default, Links, Controls, Headings etc.
When chosen Headings, I expect talkback to announce only headings and to jump from one heading to another but it stays at the same place even after Swipe Left or Swipe Right gesture.
Set both accessibilityHeading and focusableInTouchMode to true. Then, after setting the navigation mode to Headers (you can do this via the up down gesture), swiping up or down navigates you though the headers. Swiping right and left will still allow you to navigate through single items.
I just tried, it work here as expected.
Talkback properly announces textviews as headings and in heading mode I can navigate to them as well.
Please ensure that you are using the latest version of Talkback.
This is quite an old question so may be you may have got the solution since then
I was having the same issue.
In my particular situation it was fixed when I set focusable and focusableInTouchMode to false in the parent view, and true in the TextView.

Two fragments stacked ontop of each other using transactional ADD - how to prevent edit text gaining focus on bottom fragment?

Try stacking two fragments with editTexts on top of each other using an Add Transaction. after that when you press the keyboard imeOption key next button the bottom fragment's edit text can gain focus. this is a security concern. user can type things into the bottom fragments edit text (blindly). I tried the following code:
android:filterTouchesWhenObscured="true"
but it has not helped at least on api 27.
my edit text itself looks like this, nothing special:
<EditText
android:id="#+id/et"
android:layout_width="195dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:imeOptions="actionNone"
android:layout_marginBottom="10dp"
android:hint="#string/enter_name"
android:filterTouchesWhenObscured="true"
android:inputType="textNoSuggestions"
android:textColorHint="#959595"
android:textSize="11sp" />
the issue is very similar to android tap jacking
i tried even doing this:
android:nextFocusDown="#+id/et_two" thinking it would bypass and go directly to the edittext i want. but instead the bottom edit text still gains focus.
the issue solution was surprising. recyclerview was stealing focus. see this SO incident:
adding android:descendantFocusability="blocksDescendants" to the recyclerview stopped the issue.

Unfocusable element, focusable on touch

I have an editText that I want to fill in automatically with info from other controls in the form, and at the same time allow to change its contents, discouraging the user from doing so though.
So I set this control to not focusable so when you press actionNext it moves on to the next control. However if you click the edit text, I want to allow the user to change its contents.
This is what I did:
mNameEditText.setFocusable(false);
mNameEditText.setFocusableInTouchMode(false);
mNameEditText.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
mNameEditText.setFocusableInTouchMode(true);
mNameEditText.requestFocusFromTouch();
mNameEditText.setFocusable(true);
}
});
However this behaves very weirdly, the result is that when you click, you can edit, but suddenly the next control (an AutoCompleteTextView) is not focusable anymore! Actually it looks like the focus remains on the edit text and goes to the autocompletetextview at the same time, like so:
How can I fix this?
Make a sub class of your text edit view
Use it in your view
Set its enabled property to false
Overwrite the touch handlers within your subclass: when the text edit view is touched, enable the view now and focus it. When the focus is lost, disable the text edit view again. Do all that in the subclass.
Style the text edit view properly so that the user has the impression that it's editable
If you want the automatic focus change to skip some views, you can use a combination of the nextFocus* attributes.
Something like :
<EditText
android:id="#+id/txt1"
android:imeOptions="actionNext"
android:nextFocusForward="#+id/txt3"
android:nextFocusDown="#+id/txt3"
... />
<!-- skipped view -->
<EditText
android:id="#+id/txt2"
android:imeOptions="actionNext"
... />
<EditText
android:id="#+id/txt3"
android:imeOptions="actionNext"
android:nextFocusUp="#id/txt1"
... />
nextFocusForward is the one used for actionNext. I believe the other attributes are mostly useful in non touch mode (e.g. with a hardware keyboard)

Isn't windowsoftinputmode = adjustResize supposed to move ALL the activity window to make room for the keyboard?

I'm working on a chat feature for an app an stumbled across the following issue.
I have an activity with android:windowsotinputmode = "stateHidden|adjustResize" (when the activity starts, the keyboard doesn't pop automatically up but waits until the user taps on the editText to type his message and after, the whole activity screen should slide up and make room for the soft keyboard).
However...
I noticed that the activity only slides up until the keyboard is right below the editText, covering the 'random view' at the bottom of the activity.
Is there a way to override this and make the screen move up completely and make visible the whole activity?
[EDIT] I should also mention that setting any paddingBottom/marginBottom to the editText gets ignored as well as the view.
You could go through this link and the code,could help you:
http://android-developers.blogspot.in/2009/04/updating-applications-for-on-screen.html
<EditText android:id="#+id/edtInput"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:inputType="textShortMessage|textAutoCorrect|textCapSentences|textMultiLine"
android:imeOptions="actionSend|flagNoEnterAction"
android:maxLines="4"
android:maxLength="2000"
android:hint="#string/compose_hint"/>

Why doesn't nextFocusDown work with TalkBack navigation?

I have four TextViews, and I'm trying to control the order that they get focus when a user navigates using TalkBack and touch gestures.
TextView android:text="foo" android:clickable="false" android:focusable="true" android:focusableInTouchMode="true" android:id="#+id/id_foo" android:nextFocusDown="#+id/id_baz"/>
TextView android:text="bar" android:clickable="false" android:focusable="true" android:focusableInTouchMode="true" android:id="#+id/id_bar" android:nextFocusDown="#+id/id_qux"/>
TextView android:text="baz" android:clickable="false" android:focusable="true" android:focusableInTouchMode="true" android:id="#id/id_baz" android:nextFocusDown="#id/id_bar"/>
TextView android:text="qux" android:clickable="false" android:focusable="true" android:focusableInTouchMode="true" android:id="#id/id_qux" android:nextFocusDown="#id/id_foo"/>
When a user turns on TalkBack, touches "foo", and then swipes down to navigate between the TextViews, I want the order to go foo->baz->bar->qux. But, the order I try to set up using nextFocusDown seems to have no effect, and instead focus order always just follows the positions of the TextViews on the screen. I've tried every possible combination of clickable, focusable, and focusableInTouchMode. I've tried calling setNextFocusDownId on the views in code. I've tried setting android:imeOptions="actionNext" on the TextViews. Nothing seems to work. What am I missing?
Try to use View.setAccessibilityTraversalAfter(int) and View.setAccessibilityTraversalBefore(int) to configure TalkBack navigation. Please note that TalkBack has only two directions:
forward (swipe to the right or down)
back (swipe to the left or up).
Example:
findView(R.id.bar).setAccessibilityTraversalBefore(R.id.quix);
NextFocusDown doesn't refer to TalkBack gestures. It refers to track-ball and keyboard arrow key navigation. TalkBack exploration gestures are limited to swiping down/right for next focus, and swiping up/left for previous focus. And of course, drag to explore.

Categories

Resources