Accessibility Service not logging events when TextView visibility toggles to invisible - android

I have a simple app with a text view and a button. When I click on the button, the text view visibility toggles. I also have an accessibility service to capture all accessibility events. The service logs an accessibility event of type window_content_changed when the text view appears, but doesn't log anything when the text view disappears. Can someone help me understand why this is happening and how to fix it?
My accessibility_service_config is also very broad:
<accessibility-service xmlns:android="http://schemas.android.com/apk/res/android"
android:accessibilityFeedbackType="feedbackAllMask"
android:accessibilityFlags="flagDefault|flagReportViewIds|flagIncludeNotImportantViews|flagRequestFilterKeyEvents|flagRetrieveInteractiveWindows|flagRequestAccessibilityButton|flagEnableAccessibilityVolume|flagRequestTouchExplorationMode|flagRequestMultiFingerGestures"
android:accessibilityEventTypes="typeAllMask"
android:canPerformGestures="true"
android:canRetrieveWindowContent="true"
android:description="#string/accessibility_service_description"
/>

Related

Scrollable layout when keyboard pops up, but without focus change

I have a UX problem with my layout. I want that is possible that the user can scroll over the compleat layout without a focus change when the keyboard popes up.
This is what the Layout looks like when the activity starts
This is what happens when the user clicks to the Big Text EditText
This is what I want the layout to look like, the positions should stand in the same way as before, but it should be possible to scroll to the bottom with the keyboard open
The rootView of my layout is
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
I also try to add android:windowSoftInputMode="adjustResize" and android:windowSoftInputMode="adjustPan" the the activity in the Manifest.xml but it does not solve my problem.

want to retrive every visible and clickable view on the screen from another app,including itemviews of recyclerView using accessibility service

My question is I want to retrive every visible and clickable view on the screen with their position,including itemviews of recyclerView using accessibility service and their positions on screen.
I have configured accessibilityService as below.
<?xml version="1.0" encoding="utf-8"?>
<accessibility-service
xmlns:android="http://schemas.android.com/apk/res/android"
android:accessibilityEventTypes="typeWindowContentChanged|
typeWindowStatChanged"
android:accessibilityFeedbackType="feedbackAllMask"
android:accessibilityFlags="flagDefault"
android:canPerformGestures="true"
android:canRetrieveWindowContent="true"
android:notificationTimeout="100"
/>
but I am not getting every visible view on screen.Is there any other way to get all view visible on screen??
Do note my comment on missing the code that you're utilizing to actually look at the node hierarchy. That being said, if you truly want to see ALL views, you're xml configuration is missing a flag.
I recommend replacing this line:
android:accessibilityFlags="flagDefault"
With the following:
android:accessibilityFlags="flagDefault|flagIncludeNotImportantViews"

Adding CheckBox to ListView row view makes the row not clickable

I am trying to create a ListView similar to the Gmail app, where each row has a CheckBox on the left to facilitate multiple selection and actions via the contextual action bar, while at the same time, allow clicking each row to transition to another activity.
Originally, before adding the CheckBox the rows would indicate their selection with a light blue background color from the Holo theme I'm using and call onListItemClick in my ListFragment when clicked and onItemLongClick in my OnItemLongClickListener when long clicked.
When I add the CheckBox to my layout .xml file for the row view, the background no longer changes color and I no longer receive click or long click events. If I add android:longClickable="true" to the top ViewGroup in my view .xml then I start getting long click events again. But android:clickable="true" does not get me click events. And neither allows the background blue selection indication to return. Only the CheckBox itself provides visual touch indication with a blue background when touched.
What do I need to do to get the normal visual selection indication as well as click events on the ListView rows with the CheckBox in the view?
Here's the relevant portion of my view .xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:longClickable="true"
android:orientation="horizontal" >
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:paddingBottom="5dp"
android:paddingRight="12dp"
android:paddingTop="5dp" >
...
</LinearLayout>
</LinearLayout>
I wrote a blog post on this subject awhile back that you may find helpful. The problem is, in fact, that adding focusable elements (like CheckBox or Button) disables the ability to click the overall list item and their focusability has to be disabled. You should not add any clickable flags to the main layout either.
While adding checkbox in CAB please make it focusable="false", this will solved the problem of only one time called onItemCheckedStateChanged.

How to disable any event on a View in Android?

My question is simple: How to disable any event on a View in Android? (including removing its focussability, like I just want it to be there visually but be inexistant on everything else)
And does it work on a whole view tree? (like if I disable events on the root, all the events will be disabled for its children?).
Now, before you say anything I have tried all the following:
setEnabled
setFocusable
setSelected
setClickable
setActivated
And none of these methods appear to work, seriously.
I have tried them directly on a WebView, as well as on the parent layout on everything but I am still able to interact with it.
Any idea?
Thanks!
EDIT#1
The solution that consists in adding a view on top of the view that needs to be disabled doesn't work. Actually, it's still possible to click on the inner view, I have tried with a simple example:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#ff0000">
<Button
android:id="#+id/button"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Click Me!"
/>
</LinearLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#00000000"
/>
</FrameLayout>
Here it's still possible to click on the button.
EDIT#2
The reason why I want to do this is related to the following question that I asked weeks ago.
What I have is a ListViewacting as a navigation bar which is underneath a View that holds the content of my app. The problem with this implementation is that when I try to scroll through the ListView when there is a focusable view in the layer on top of it, well the ListView doesn't scroll and instead it's the top view that takes focus (That's the case when there is a
Webview or an EditText etc.).
So yes as mentioned in one of the answers, I can disable any click events on a WebView by overriding setOnTouchListener but the view remains focussed and I think this is the reason why I am still having the same issue with my navigation bar.
Simply put a view on top of your view. You can toggle it on off by setting view.visibility = gone/visible.
<FrameLayout>
<WebView/>
<FrameLayout This view will be on top/>
</FrameLayout>
Edit: Just stumpled upon this link: https://stackoverflow.com/a/3856199/969325
Basically disables all touch event for the webview. Tryed that?
Edit 2 reedit: Try to set the visibility to gone for the the top view below your listview.

Is it possible to add a button to a scroll view?

I have a simple ScrollView in a layout that displays an About Box in a dialog format. So it just pops up on the phone screen in a dialog. The only way for the user to close the box is to click the back button (it is an intent).
Do I have a way of adding a close button to the box or could I have the user hit the box on the screen with their finger and close it?
Here is my xml:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:screenOrientation="portrait"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dip" >
<TextView
android:id="#+id/about_box"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/about_text" />
</ScrollView>
The only way for the user to close the box is to click the back button
That's what any Android user would want to do. Anyway, if you want to provide the "close with button" functionality just keep in mind this: ScrollView cannot contain more than one item, so you will have to wrap both TextView and Button inside a LinearLayout or something.
But, my suggestion is that you should build an AlertDialog, which can be automatically configured with an "OK" button which will close the dialog.

Categories

Resources