# parthdave93/accessibilityserviceexample architecture

> Architecture diagram of the GitHub repository parthdave93/accessibilityserviceexample, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-05-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/parthdave93/accessibilityserviceexample
- Repository: https://github.com/parthdave93/accessibilityserviceexample

## Overview

1. **Project type and purpose**  
   This is a single-module Android demo focused on **AccessibilityService** behavior. Its core purpose is to capture Android OS-level events outside the app’s own UI, especially text-entry/key-like events, and react to them in-app.

2. **Main runtime entry points**  
   The app has two main Android components:
   - **`MainActivity`** for the user-facing screen and setup/status handling.
   - **`MyAccessibilityService`** for receiving accessibility events from the system.  
   The service is declared in the manifest and bound with `BIND_ACCESSIBILITY_SERVICE`, which makes it a system-managed component rather than a normal app service.

3. **System event ingestion path**  
   The key data flow starts at the Android OS:
   - Android dispatches accessibility events to `MyAccessibilityService.onAccessibilityEvent()`.
   - The service inspects the event type and source package.
   - The README shows the app specifically reacting to `TYPE_VIEW_TEXT_CHANGED`, using the event text as the typed input signal.  
   This is the repository’s main architectural boundary: **system event stream in, app behavior out**.

4. **Accessibility configuration boundary**  
   The behavior of the service is controlled by `res/xml/accessibility_service_config.xml`.  
   That config declares which events the service can observe, whether it can retrieve window content, and whether it can request filter-key events. This is important because the app’s functionality depends on Android accessibility permissions and XML configuration, not just Java code.

5. **Service enablement and user setup**  
   The README includes logic for checking whether the accessibility service is enabled via `Settings.Secure`. That means the app likely has a setup/status flow in `MainActivity` that guides the user to enable the service in system settings before the event pipeline becomes active.

6. **Controller layer**  
   The `controllers` package suggests a thin coordination layer between the accessibility service and the UI/overlay behavior:
   - **`WindowPositionController`**: likely manages placement of a floating window or panel.
   - **`WindowTouchController`**: likely handles drag/touch interactions for that window.
   - **`SearchedItemController`**: likely manages filtered results or item selection after text changes.  
   This layer keeps the service from directly owning all UI and interaction logic.

7. **Overlay / floating UI**  
   The presence of `content_floatingview.xml` and controller classes strongly suggests the app renders a **floating in-app overlay** or custom panel that can be moved and updated while accessibility events arrive.  
   The overlay is likely the visible reaction surface for text changes or searched items, separate from the main activity screen.

8. **List presentation and actions**  
   The UI includes:
   - **`SearchItemsListAdapter`** for binding a list of items to a RecyclerView/ListView-like component.
   - **`ListItemAction`** as a callback interface for user actions on list rows.
   - **`InnerSounds`** as a model class for the list data.  
   This indicates a standard model-adapter-callback pattern for presenting and selecting items, probably tied to the “searched item” workflow.

9. **Network/data-fetch subsystem**  
   There are two network-related classes:
   - **`networktask/DownloadTask`**
   - **`utils/NetworkTask`**  
   These suggest the app can fetch external data or assets asynchronously. In the overall architecture, this is a secondary data source, separate from the accessibility event stream, likely used to populate or update the list/content shown in the overlay.

10. **Resource and packaging structure**  
    The app is organized like a typical Android app with:
    - layouts, drawables, colors, strings, styles
    - accessibility service XML config
    - screenshots for documentation  
    The repository is Android-only; there is no backend service or multi-module infrastructure visible in the tree.

11. **End-to-end data flow**  
    The most likely architecture diagram is:
    **Android system events → `MyAccessibilityService` → controllers (`SearchedItemController`, window controllers) → overlay/list UI (`SearchItemsListAdapter`, layouts) → optional network/download path**.  
    The main interaction loop is driven by accessibility events, not by polling or server callbacks.

12. **Important architectural boundaries to show**  
    If drawing the system, emphasize these boundaries:
    - **System vs app**: accessibility events originate outside the app.
    - **Service vs UI**: service receives events; activity/overlay presents them.
    - **Control vs presentation**: controllers manage behavior; adapter/layouts render data.
    - **Local event handling vs network retrieval**: event-driven updates are separate from optional async downloads.

Main entry points: [`app/src/main/java/com/accessibilityexample/Service/MyAccessibilityService.java`](https://github.com/parthdave93/accessibilityserviceexample/blob/master/app/src/main/java/com/accessibilityexample/Service/MyAccessibilityService.java) (Accessibility Service), [`app/src/main/java/com/accessibilityexample/ui/adapters/SearchItemsListAdapter.java`](https://github.com/parthdave93/accessibilityserviceexample/blob/master/app/src/main/java/com/accessibilityexample/ui/adapters/SearchItemsListAdapter.java) (List Adapter), [`app/src/main/java/com/accessibilityexample/controllers/SearchedItemController.java`](https://github.com/parthdave93/accessibilityserviceexample/blob/master/app/src/main/java/com/accessibilityexample/controllers/SearchedItemController.java) (Search Controller), [`app/src/main/res/layout/content_floatingview.xml`](https://github.com/parthdave93/accessibilityserviceexample/blob/master/app/src/main/res/layout/content_floatingview.xml) (Floating View)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_grp_system["System boundary"]
  node_node_accessibility_service["Accessibility Service"]
  node_node_service_config["Service Config<br/>accessibility xml"]
end

subgraph group_grp_runtime["Runtime logic"]
  node_node_settings_check["Enable Check<br/>system settings<br/>[README.md]"]
  node_node_search_controller["Search Controller"]
  node_node_window_position["Window Position<br/>controller"]
  node_node_window_touch["Window Touch<br/>controller"]
end

subgraph group_grp_ui["UI layer"]
  node_node_main_activity["Main Activity<br/>[MainActivity.java]"]
  node_node_overlay_view["Floating View<br/>overlay layout"]
  node_node_list_adapter["List Adapter"]
  node_node_list_action{{"Item Action<br/>callback"}}
  node_node_activity_layout["Main Layout<br/>[activity_main.xml]"]
  node_node_item_layout["Item Layout<br/>[item_soundview.xml]"]
end

subgraph group_grp_data["Data & network"]
  node_node_item_model["Sound Item<br/>model<br/>[InnerSounds.java]"]
  node_node_download_task["Download Task<br/>async task<br/>[DownloadTask.java]"]
  node_node_network_task["Network Task<br/>network helper<br/>[NetworkTask.java]"]
  node_node_constants["Constants<br/>[Constants.java]"]
end

subgraph group_grp_resources["Resources"]
end

node_node_service_config -->|"configures"| node_node_accessibility_service
node_node_main_activity -->|"checks"| node_node_settings_check
node_node_main_activity -->|"renders"| node_node_activity_layout
node_node_accessibility_service -->|"routes events"| node_node_search_controller
node_node_accessibility_service -->|"updates"| node_node_window_position
node_node_accessibility_service -->|"coordinates"| node_node_window_touch
node_node_search_controller -->|"drives"| node_node_overlay_view
node_node_window_position -->|"positions"| node_node_overlay_view
node_node_window_touch -->|"handles"| node_node_overlay_view
node_node_search_controller -->|"binds"| node_node_list_adapter
node_node_list_adapter -->|"inflates"| node_node_item_layout
node_node_list_adapter -->|"displays"| node_node_item_model
node_node_list_adapter -->|"emits actions"| node_node_list_action
node_node_download_task -->|"uses"| node_node_network_task
node_node_network_task -.->|"fetches"| node_node_item_model
node_node_constants -.->|"supports"| node_node_search_controller

click node_node_main_activity "https://github.com/parthdave93/accessibilityserviceexample/blob/master/app/src/main/java/com/accessibilityexample/ui/activity/MainActivity.java"
click node_node_accessibility_service "https://github.com/parthdave93/accessibilityserviceexample/blob/master/app/src/main/java/com/accessibilityexample/Service/MyAccessibilityService.java"
click node_node_service_config "https://github.com/parthdave93/accessibilityserviceexample/blob/master/app/src/main/res/xml/accessibility_service_config.xml"
click node_node_settings_check "https://github.com/parthdave93/accessibilityserviceexample/blob/master/README.md"
click node_node_search_controller "https://github.com/parthdave93/accessibilityserviceexample/blob/master/app/src/main/java/com/accessibilityexample/controllers/SearchedItemController.java"
click node_node_window_position "https://github.com/parthdave93/accessibilityserviceexample/blob/master/app/src/main/java/com/accessibilityexample/controllers/WindowPositionController.java"
click node_node_window_touch "https://github.com/parthdave93/accessibilityserviceexample/blob/master/app/src/main/java/com/accessibilityexample/controllers/WindowTouchController.java"
click node_node_overlay_view "https://github.com/parthdave93/accessibilityserviceexample/blob/master/app/src/main/res/layout/content_floatingview.xml"
click node_node_list_adapter "https://github.com/parthdave93/accessibilityserviceexample/blob/master/app/src/main/java/com/accessibilityexample/ui/adapters/SearchItemsListAdapter.java"
click node_node_list_action "https://github.com/parthdave93/accessibilityserviceexample/blob/master/app/src/main/java/com/accessibilityexample/interfaces/ListItemAction.java"
click node_node_item_model "https://github.com/parthdave93/accessibilityserviceexample/blob/master/app/src/main/java/com/accessibilityexample/models/InnerSounds.java"
click node_node_download_task "https://github.com/parthdave93/accessibilityserviceexample/blob/master/app/src/main/java/com/accessibilityexample/networktask/DownloadTask.java"
click node_node_network_task "https://github.com/parthdave93/accessibilityserviceexample/blob/master/app/src/main/java/com/accessibilityexample/utils/NetworkTask.java"
click node_node_constants "https://github.com/parthdave93/accessibilityserviceexample/blob/master/app/src/main/java/com/accessibilityexample/utils/Constants.java"
click node_node_activity_layout "https://github.com/parthdave93/accessibilityserviceexample/blob/master/app/src/main/res/layout/activity_main.xml"
click node_node_item_layout "https://github.com/parthdave93/accessibilityserviceexample/blob/master/app/src/main/res/layout/item_soundview.xml"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_node_accessibility_service,node_node_service_config toneBlue
class node_node_settings_check,node_node_search_controller,node_node_window_position,node_node_window_touch toneAmber
class node_node_main_activity,node_node_overlay_view,node_node_list_adapter,node_node_list_action,node_node_activity_layout,node_node_item_layout toneMint
class node_node_item_model,node_node_download_task,node_node_network_task,node_node_constants toneRose
```

## Components

### System boundary

Android-managed accessibility entry points and configuration

- [Accessibility Service](https://github.com/parthdave93/accessibilityserviceexample/blob/master/app/src/main/java/com/accessibilityexample/Service/MyAccessibilityService.java): service · Receives system accessibility events and reacts to them · `app/src/main/java/com/accessibilityexample/Service/MyAccessibilityService.java`
- [Service Config](https://github.com/parthdave93/accessibilityserviceexample/blob/master/app/src/main/res/xml/accessibility_service_config.xml): accessibility xml · Declares observed event types and service capabilities · `app/src/main/res/xml/accessibility_service_config.xml`

### Runtime logic

App coordination, controllers, and service handling

- [Enable Check](https://github.com/parthdave93/accessibilityserviceexample/blob/master/README.md): system settings · Service-enabled detection via secure settings · `README.md`
- [Search Controller](https://github.com/parthdave93/accessibilityserviceexample/blob/master/app/src/main/java/com/accessibilityexample/controllers/SearchedItemController.java): controller · Coordinates searched-item updates from incoming events · `app/src/main/java/com/accessibilityexample/controllers/SearchedItemController.java`
- [Window Position](https://github.com/parthdave93/accessibilityserviceexample/blob/master/app/src/main/java/com/accessibilityexample/controllers/WindowPositionController.java): controller · Controls overlay placement and movement · `app/src/main/java/com/accessibilityexample/controllers/WindowPositionController.java`
- [Window Touch](https://github.com/parthdave93/accessibilityserviceexample/blob/master/app/src/main/java/com/accessibilityexample/controllers/WindowTouchController.java): controller · Handles drag and touch interactions for the floating view · `app/src/main/java/com/accessibilityexample/controllers/WindowTouchController.java`

### UI layer

Activity, overlay presentation, and list rendering

- [Main Activity](https://github.com/parthdave93/accessibilityserviceexample/blob/master/app/src/main/java/com/accessibilityexample/ui/activity/MainActivity.java): activity · User-facing entry screen and service setup/status flow · `app/src/main/java/com/accessibilityexample/ui/activity/MainActivity.java`
- [Floating View](https://github.com/parthdave93/accessibilityserviceexample/blob/master/app/src/main/res/layout/content_floatingview.xml): overlay layout · Custom floating panel shown above the main screen · `app/src/main/res/layout/content_floatingview.xml`
- [List Adapter](https://github.com/parthdave93/accessibilityserviceexample/blob/master/app/src/main/java/com/accessibilityexample/ui/adapters/SearchItemsListAdapter.java): adapter · Binds search items into the list UI · `app/src/main/java/com/accessibilityexample/ui/adapters/SearchItemsListAdapter.java`
- [Item Action](https://github.com/parthdave93/accessibilityserviceexample/blob/master/app/src/main/java/com/accessibilityexample/interfaces/ListItemAction.java): callback · Row action contract used by the list UI · `app/src/main/java/com/accessibilityexample/interfaces/ListItemAction.java`
- [Main Layout](https://github.com/parthdave93/accessibilityserviceexample/blob/master/app/src/main/res/layout/activity_main.xml): layout · Primary activity screen layout · `app/src/main/res/layout/activity_main.xml`
- [Item Layout](https://github.com/parthdave93/accessibilityserviceexample/blob/master/app/src/main/res/layout/item_soundview.xml): layout · Row template for list items · `app/src/main/res/layout/item_soundview.xml`

### Data & network

Models and asynchronous fetch helpers

- [Sound Item](https://github.com/parthdave93/accessibilityserviceexample/blob/master/app/src/main/java/com/accessibilityexample/models/InnerSounds.java): model · List item data model · `app/src/main/java/com/accessibilityexample/models/InnerSounds.java`
- [Download Task](https://github.com/parthdave93/accessibilityserviceexample/blob/master/app/src/main/java/com/accessibilityexample/networktask/DownloadTask.java): async task · Background downloader for external data or assets · `app/src/main/java/com/accessibilityexample/networktask/DownloadTask.java`
- [Network Task](https://github.com/parthdave93/accessibilityserviceexample/blob/master/app/src/main/java/com/accessibilityexample/utils/NetworkTask.java): network helper · General-purpose async network access utility · `app/src/main/java/com/accessibilityexample/utils/NetworkTask.java`
- [Constants](https://github.com/parthdave93/accessibilityserviceexample/blob/master/app/src/main/java/com/accessibilityexample/utils/Constants.java): utility · Shared app-wide constants · `app/src/main/java/com/accessibilityexample/utils/Constants.java`

## Connections

- Service Config → Accessibility Service: configures · Declares what the service can observe and do
- Main Activity → Enable Check: checks · Verifies whether accessibility service is enabled
- Main Activity → Main Layout: renders · Uses the main activity screen layout
- Accessibility Service → Search Controller: routes events · Forwards typed-input accessibility signals into app logic
- Accessibility Service → Window Position: updates · Can adjust floating window placement in response to events
- Accessibility Service → Window Touch: coordinates · Keeps overlay interaction behavior separate from event ingestion
- Search Controller → Floating View: drives · Feeds updates into the floating UI surface
- Window Position → Floating View: positions · Controls where the overlay appears on screen
- Window Touch → Floating View: handles · Manages user dragging and touch on the floating view
- Search Controller → List Adapter: binds · Supplies search results to the list presenter
- List Adapter → Item Layout: inflates · Uses row layout for each list entry
- List Adapter → Sound Item: displays · Renders the underlying data model
- List Adapter → Item Action: emits actions · Delegates row interactions back to the host
- Download Task → Network Task: uses · Shares asynchronous network behavior
- Network Task → Sound Item: fetches · Can populate model data from external source
- Constants → Search Controller: supports · Provides shared values used in control flow
