Keep search interface open - android

Is there a way to keep the search (widget or dialog) open even if the user clicks on the screen? I've seen many Google apps doing this (Keep, GMail, Youtube...) but not so many apps from external developers...
I have my search edit text visible on the ActionBar but as soon as I tap somewhere else on the screen, it is dismissed. I only want it dismissed if the user clicks on the action bar icon or presses the back key.
Is it possible? Thanks in advance!

Intercept the touch event on the container view.
Check if the SearchView is expanded.
If it is do nothing
Other idea, is cutting the SearchView being collapsed whenever the container sends touch event signals down to the view tree if it is already expanded. Or make sure it does not collapse when the SearchView looses the focus. Make sure you properly collapsed, when back key is pressed.
These are just ideas.
Hope it helps.

Related

Clicking on soft home button in navigation bar also triggers underlying click listener for a view

Some newer Android devices have removed the hard Home Button and replaced it with a soft pop up navigation bar at the bottom of the screen that appears when the user swipes up. I've found that the Home Button can also be accessed by hard pressing (not just long clicking, kind of like iOS force touch) the area where the Home Button would appear if navigation bar is visible. This action triggers an onClick event within the current application before navigating to the device home screen. How can I prevent the onClick event within the application?
You can see in the image below how the navigation bar Home Button overlays the app button. Thanks for any help, I feel like i'm missing something really obvious.

Android ListPopupWindow Detecting Click outside of list

I'm using ListPopupWindow which I find very suitable for the purpose with one exception. I want to be able to detect when the user does other than select an item from the list or presses the back button. Currently what is happening is that when an item is clicked outside of the ListPopupWindow list I cannot determine what was clicked and the ListPopupWindow is dismissed. Ideally what I would prefer is for the user to only be able to select an item from the list or press the back button, however I cannot achieve that. I've searched for an answer and experimented for hours but I cannot achieve what is required. As far as I can determine, setting modal to either true or false appears to make no difference. I can obviously detect what is selected from the list, however whether the user presses the back button or clicks outside of the list appear to both dismiss the ListPopupWindow and I cannot determine the action that caused it other than an item was not selected. How can I either detect or prevent other than the user selecting an item from the list or pressing the back button?
As far as I can determine, this can be solved using
android.support.v7.widget.ListPopupWindow;
and
setForceIgnoreOutsideTouch(true)

Announce QuickAction window dismissal with TalkBack

I have a custom QuickAction menu in my app. I have added contentDescription "Open Menu" for the ImageView which opens the menu. So my TalkBack(form the Accessibility settings) announces the same. The popup menu has setOutsideTouchable(true) to dismiss it when touched outside. When TalkBack is On user has to double tap to dismiss it but Android does not announce any such message. Ideally, it should announce "Double tap to dismiss ...". How can I achieve this ? Also, I would like to announce when the menu is dismissed. I have tried sending AccessibilityEvent inside:QuickAction.setOnDismissListener(new myQuickAction.OnDismissListener() {
#Override
public void onDismiss() {
// tried sending event here
} Added reference image to explain in detail. On clicking button blue popup is the QuickAction popup. Now I want to announce "Dismiss Menu" when user tap anywhere(black dot) on white region. White region is actually my LinearLayout containing header, footer etc.(that are not shown in the image). I have tried adding the contentDescription, importantForAccessibility for the layout but to no avail.
I would add either a little "X" box, or if you don't want to mess up your UI, make your layout container focusable, and add the content-description "Double Tap to Dismiss". (Note: The double tap is a talkback gesture, don't add this, just replicating from your question.)
EDIT: Essentially, what I'm recommending, is instead of adding an "X" button to the view, allow the layout view to act as an "X" button itself. By adding a contentDescription to the layout, you are making it focusable, even though typical users wouldn't interact with this view, nothing is keeping TalkBack users from doing so. Thus you do not change your layout visually, but still have the accessibility benefit of a separate close button, even though technically speaking this is not necessary, as users should understand how to close modals without it.
I don't believe announcing that it has been dismissed is necessary. Shifting focus back to the element that was focused before you opened the modal is the typical approach. Have this happen after your double tap, and TalkBack users will know the menu was dismissed, because they are back in the main view, on the element that opened the modal.
Sidenote: Ensure your QuickAction behaves as a modal!

How to detect loss of accessibility focus with on-screen navigation buttons?

I'm looking at the Support4Demos from the Android SDK and I'm not sure if this is working as intended. Specifically, I'm referring to accessibility focus when using the Widget > Explore by Touch Helper demo. If I tap on one of the blue regions to give it accessibility focus then tap on the on-screen home button focus will switch to the home button. But if I tap on the same blue region as before nothing happens (but if I tap on the other blue region focus transfers from the home button). I'm testing this on a Kindle with on-screen navigation buttons.
Am I correct in assuming that focus should transfer back to the blue region? If so, what is the proper way to handle this? Presumably there would be a way to know that the user tapped on something outside of the app and in response to this I could clear state in the ExploreByTouchHelper but I'm not sure how I would go about that.

Open SearchView without gaining focus

I have seen a lot of posts to perform the contrary but here is what I want to achieve. After the user has performed a search through the SearchView, I would like it to stay open but without it being focused or the keyboard being visible.
If it is unclear, just have a look at how search behaves on the Play Store app.
I have tried to give focus to an other View on the screen, to call clearFocus() or setFocusable(false) on the SearchView but nothing works.
Any ideas ?
Thanks
OK. I finally nailed it.
Best way to do it is to override onStartActvityForResult and to manually close the keyboard. This way, you can handle yourself the search and nothing comes to disturb the SearchView which remains in the required state.

Categories

Resources