# wuapnjie/stickerview architecture

> Architecture diagram of the GitHub repository wuapnjie/stickerview, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/wuapnjie/stickerview
- Repository: https://github.com/wuapnjie/stickerview

## Overview

##### Main Components
- Sticker Library Module (“sticker” folder): This is the heart of the project and contains all the core functionality related to sticker manipulation. Key classes include StickerView (which extends FrameLayout), various sticker types (e.g., TextSticker, DrawableSticker), event handler classes (like FlipHorizontallyEvent, DeleteIconEvent, etc.) and sticker utility classes.
- Sample Application Module (“app” folder): This module demonstrates the usage of the StickerView component. It includes the AndroidManifest.xml, MainActivity, instrumented tests, and unit tests to illustrate integration with the StickerView library.
- Common/Utility Components: Under the sticker module and the sample app, you see resource files (layouts, drawables, values) and utility classes (e.g., FileUtil in the “app” module) that support the UI and functionality.

##### Relationships and Interactions
- The sample app (app module) uses the StickerView from the sticker module by embedding it in the layout (as shown in the example in the README) and interacting with it programmatically via methods like addSticker(), removeSticker(), etc.
- There is a clear dependency relationship where the app module “consumes” the sticker module library.

##### Architectural Patterns and Design Principles
- Modularization: The project is split into at least two modules – a demonstration app and a dedicated sticker library. This separation encourages code reusability and testability.

##### Technologies, Frameworks, and Libraries
- Android SDK – the entire project is structured as an Android application/library.
- Gradle – for build configuration (build.gradle files are evident in both modules).
- Android testing frameworks – there are instrumented tests and unit tests organized in the app module.
- Standard Android resource directories (for layouts, drawables, and values) which specify support for different screen densities.

##### Detail Orientation
- It’s essential to be as detailed as possible, ensuring that every logical unit is represented. Do not hesitate to separate components (even if they might logically group together) to make dependencies and interactions obvious.
- User interacts with the UI in the sample app (e.g., touches a sticker on the StickerView) → StickerView processes the event → delegated to the appropriate event handler (like HelloIconEvent) → updates the UI accordingly.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global Actor
    U["User"]:::actor

    %% Sticker Library Module
    subgraph "Sticker Library Module (Core)"
        S_StickerView["StickerView Component"]:::library
        S_TextSticker["TextSticker"]:::library
        S_DrawableSticker["DrawableSticker"]:::library
    end

    subgraph "Sticker Library Module (Icon Event Handlers)"
        S_DeleteIcon["DeleteIconEvent"]:::library
        S_FlipHoriz["FlipHorizontallyEvent"]:::library
        S_FlipVert["FlipVerticallyEvent"]:::library
        S_FlipBoth["FlipBothDirectionsEvent"]:::library
        S_ZoomIcon["ZoomIconEvent"]:::library
    end

    subgraph "Sticker Library Module (Utilities & Resources)"
        S_Utils["StickerUtils"]:::library
        S_Attrs["Attributes (attrs.xml)"]:::resource
        S_Strings["Strings (strings.xml)"]:::resource
    end

    %% Sample Application Module
    subgraph "Sample Application Module (Main)"
        A_MainActivity["MainActivity"]:::sampleApp
        A_Manifest["AndroidManifest"]:::sampleApp
        A_Layout["Activity Layout (activity_main.xml)"]:::resource
        A_Menu["Menu (menu_save.xml)"]:::resource
        A_FileUtil["FileUtil"]:::sampleApp
    end

    subgraph "Sample Application Module (Tests)"
        A_InstTest["Instrumented Test"]:::test
        A_UnitTest["Unit Test"]:::test
    end

    %% Relationships and Flow
    U -->|"interacts"| A_MainActivity
    A_MainActivity -->|"instantiates"| S_StickerView

    S_StickerView -->|"renders_text"| S_TextSticker
    S_StickerView -->|"renders_drawable"| S_DrawableSticker

    S_StickerView -->|"handles_delete"| S_DeleteIcon
    S_StickerView -->|"handles_flipHoriz"| S_FlipHoriz
    S_StickerView -->|"handles_flipVert"| S_FlipVert
    S_StickerView -->|"handles_flipBoth"| S_FlipBoth
    S_StickerView -->|"handles_zoom"| S_ZoomIcon

    A_MainActivity -->|"loads_layout"| A_Layout
    A_MainActivity -->|"utilizes"| A_FileUtil

    A_InstTest -->|"tests_UIIntegration"| A_MainActivity
    A_UnitTest -->|"tests_functionality"| A_FileUtil

    %% Styles
    classDef library fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef sampleApp fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef resource fill:#FFB347,stroke:#000,stroke-width:2px;
    classDef test fill:#FFA07A,stroke:#000,stroke-width:2px;
    classDef actor fill:#F5F5DC,stroke:#000,stroke-width:2px;

    %% Click Events for Sticker Library Module
    click S_StickerView "https://github.com/wuapnjie/stickerview/blob/master/sticker/src/main/java/com/xiaopo/flying/sticker/StickerView.java"
    click S_TextSticker "https://github.com/wuapnjie/stickerview/blob/master/sticker/src/main/java/com/xiaopo/flying/sticker/TextSticker.java"
    click S_DrawableSticker "https://github.com/wuapnjie/stickerview/blob/master/sticker/src/main/java/com/xiaopo/flying/sticker/DrawableSticker.java"
    click S_DeleteIcon "https://github.com/wuapnjie/stickerview/blob/master/sticker/src/main/java/com/xiaopo/flying/sticker/DeleteIconEvent.java"
    click S_FlipHoriz "https://github.com/wuapnjie/stickerview/blob/master/sticker/src/main/java/com/xiaopo/flying/sticker/FlipHorizontallyEvent.java"
    click S_FlipVert "https://github.com/wuapnjie/stickerview/blob/master/sticker/src/main/java/com/xiaopo/flying/sticker/FlipVerticallyEvent.java"
    click S_FlipBoth "https://github.com/wuapnjie/stickerview/blob/master/sticker/src/main/java/com/xiaopo/flying/sticker/FlipBothDirectionsEvent.java"
    click S_ZoomIcon "https://github.com/wuapnjie/stickerview/blob/master/sticker/src/main/java/com/xiaopo/flying/sticker/ZoomIconEvent.java"
    click S_Utils "https://github.com/wuapnjie/stickerview/blob/master/sticker/src/main/java/com/xiaopo/flying/sticker/StickerUtils.java"
    click S_Attrs "https://github.com/wuapnjie/stickerview/blob/master/sticker/src/main/res/values/attrs.xml"
    click S_Strings "https://github.com/wuapnjie/stickerview/blob/master/sticker/src/main/res/values/strings.xml"

    %% Click Events for Sample Application Module
    click A_MainActivity "https://github.com/wuapnjie/stickerview/blob/master/app/src/main/java/com/xiaopo/flying/stickerview/MainActivity.java"
    click A_Manifest "https://github.com/wuapnjie/stickerview/blob/master/app/src/main/AndroidManifest.xml"
    click A_Layout "https://github.com/wuapnjie/stickerview/blob/master/app/src/main/res/layout/activity_main.xml"
    click A_Menu "https://github.com/wuapnjie/stickerview/blob/master/app/src/main/res/menu/menu_save.xml"
    click A_FileUtil "https://github.com/wuapnjie/stickerview/blob/master/app/src/main/java/com/xiaopo/flying/stickerview/util/FileUtil.java"
    click A_InstTest "https://github.com/wuapnjie/stickerview/blob/master/app/src/androidTest/java/com/xiaopo/flying/stickerview/ExampleInstrumentedTest.java"
    click A_UnitTest "https://github.com/wuapnjie/stickerview/blob/master/app/src/test/java/com/xiaopo/flying/stickerview/ExampleUnitTest.java"
```
