# canheo136/quicklook.plugin.apkviewer architecture

> Architecture diagram of the GitHub repository canheo136/quicklook.plugin.apkviewer, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/canheo136/quicklook.plugin.apkviewer
- Repository: https://github.com/canheo136/quicklook.plugin.apkviewer

## Overview

##### Project type and purpose
- The project includes:
- A “native‐style” QuickLook plugin entrypoint (`Plugin.cs`, `ViewerPane.xaml(.cs)`)
- A .NET wrapper library (`AAPTForNet/`) around the Android `aapt.exe` tool for parsing APKs
- A sample/debug host (`StartupDebuging/`)
- Packaging scripts (`Scripts/`)

##### File structure
- Top‐level solution & plugin project (`.sln`, `QuickLook.Plugin.ApkViewer.csproj`, `Plugin.cs`, `ViewerPane.*`)
- Submodule/library `AAPTForNet/`
- `AAPTForNet.csproj` – .NET Standard or .NET Framework project
- Core classes: `ApkParser`, `ApkExtractor`, `ResourceDetector`
- Filter pipeline: `/Filters/*.cs`
- Data models: `/Models/*.cs`
- Native tool: `/tool/aapt.exe`
- Packaging & utilities:
- PowerShell scripts: `pack-zip.ps1`, `update-version.ps1`
- Sample host debugger: `StartupDebuging/`

##### README
- Confirms it’s an Android‐APK preview plugin for QuickLook
- Installation and build steps reference building the project, packaging via script, and installing into QuickLook

a. Main components
- QuickLook Host (external)
- Plugin Loader / Extension Point
- ApkViewer Plugin Core
– Entry Point (`Plugin.cs`)
– UI Component (WPF UserControl: `ViewerPane.xaml(.cs)`)
- AAPTForNet Library
– ApkExtractor & ApkParser
– Filter Pipeline (ABIFilter, PermissionFilter, etc.)
– ResourceDetector
- External Native Tool: `aapt.exe`
- Packaging Scripts (build & pack steps)

b. Relationships & interactions
1. User selects `.apk` in QuickLook → Host invokes Plugin Loader
2. Plugin Entry Point in `Plugin.cs` receives a file handle
3. Plugin calls AAPTForNet → invokes `aapt.exe` via `ApkExtractor`
4. Raw text/xml output flows into `ApkParser` → populates `DumpModel` & `ApkInfo`
5. Data passes through each filter (`BaseFilter` → ABIFilter, PermissionFilter, etc.)
7. Final `ApkInfo` model handed to the WPF UI (`ViewerPane`)
8. UI renders preview in QuickLook window
9. Packaging scripts bundle everything into a `.qlplugin`

c. Architectural patterns & design principles
- Plugin architecture (dynamic extension)
- Pipeline pattern for parsing & filtering
- MVC/MVVM–style separation: Models in AAPTForNet, View in WPF, Controller logic in Plugin.cs
- Submodule/library separation (AAPTForNet as reusable component)

d. Key technologies & frameworks
- .NET Framework / .NET Standard (C#)
- WPF / XAML for UI
- Native `aapt.exe` tool (Android SDK)
- PowerShell for build & packaging
- Git submodule for AAPTForNet

##### Detail
- Major class group (ApkExtractor, Filters, Models) as its own subcomponent.
- Exact sequence of operations from file selection to UI rendering.
- Packaging step into the final `.qlplugin` artifact.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External Host
    QuickLookHost["QuickLook Host (External)"]:::external

    %% Plugin Core Layer
    subgraph "Plugin Core" 
        direction TB
        PluginProj["QuickLook.Plugin.ApkViewer.csproj"]:::core
        PluginEntry["Plugin.cs (Entry Point)"]:::core
        ViewerUI["ViewerPane.xaml/.cs (WPF UI)"]:::core
    end

    %% Library Layer
    subgraph "AAPTForNet Library" 
        direction TB
        LibProj["AAPTForNet.csproj"]:::lib
        subgraph "Parsing & Extraction"
            direction TB
            ApkExtractor["ApkExtractor.cs"]:::lib
            ApkParser["ApkParser.cs"]:::lib
            ResourceDetector["ResourceDetector.cs"]:::lib
        end
        subgraph "Filter Pipeline"
            direction TB
            BaseFilter["BaseFilter.cs"]:::lib
            ABIFilter["ABIFilter.cs"]:::lib
            ApplicationFilter["ApplicationFilter.cs"]:::lib
            PackageFilter["PackageFilter.cs"]:::lib
            PermissionFilter["PermissionFilter.cs"]:::lib
            SDKFilter["SDKFilter.cs"]:::lib
            SupportScrFilter["SupportScrFilter.cs"]:::lib
        end
        subgraph "Data Models"
            direction TB
            ApkInfoModel["ApkInfo.cs"]:::lib
            DumpModel["DumpModel.cs"]:::lib
            IconModel["Icon.cs"]:::lib
            SDKInfoModel["SDKInfo.cs"]:::lib
            ConfigsModel["Configs.cs"]:::lib
        end
        AAPTTool["aapt.exe (Native Tool)"]:::external
    end

    %% Packaging Scripts
    subgraph "Build & Packaging Scripts"
        direction TB
        PackZip["pack-zip.ps1"]:::script
        UpdateVer["update-version.ps1"]:::script
    end

    %% Debug Host
    subgraph "Sample Debug Host"
        direction TB
        DebugProj["StartupDebuging.csproj"]:::external
        DebugProgram["Program.cs"]:::external
        DebugConfig["App.config"]:::external
        DebugReadme["apks/README.md"]:::external
    end

    %% Connections
    QuickLookHost -->|"invokes"| PluginEntry
    PluginEntry -->|"references"| PluginProj
    PluginEntry -->|"calls ApkExtractor"| ApkExtractor
    ApkExtractor -->|"launches"| AAPTTool
    AAPTTool -->|"returns dump xml/text"| ApkParser
    ApkParser -->|"outputs raw data"| BaseFilter
    BaseFilter --> ABIFilter
    ABIFilter --> ApplicationFilter
    ApplicationFilter --> PackageFilter
    PackageFilter --> PermissionFilter
    PermissionFilter --> SDKFilter
    SDKFilter --> SupportScrFilter
    SupportScrFilter -->|"filtered data"| ApkInfoModel
    ApkParser -->|"initial model"| DumpModel
    ApkParser -->|"initial model"| ConfigsModel
    ResourceDetector -->|"locates icons/resources"| IconModel
    ResourceDetector --> SDKInfoModel
    ApkInfoModel --> ViewerUI
    ViewerUI -->|"renders preview"| QuickLookHost
    PackZip -->|"packages into .qlplugin"| PackZip
    UpdateVer --> PackZip
    DebugProgram --> DebugProj
    DebugConfig --> DebugProj
    DebugReadme --> DebugProj

    %% Click Events
    click PluginEntry "https://github.com/canheo136/quicklook.plugin.apkviewer/blob/master/Plugin.cs"
    click ViewerUI "https://github.com/canheo136/quicklook.plugin.apkviewer/blob/master/ViewerPane.xaml"
    click ViewerUI "https://github.com/canheo136/quicklook.plugin.apkviewer/blob/master/ViewerPane.xaml.cs"
    click PluginProj "https://github.com/canheo136/quicklook.plugin.apkviewer/blob/master/QuickLook.Plugin.ApkViewer.csproj"
    click LibProj "https://github.com/canheo136/quicklook.plugin.apkviewer/blob/master/AAPTForNet/AAPTForNet.csproj"
    click ApkExtractor "https://github.com/canheo136/quicklook.plugin.apkviewer/blob/master/AAPTForNet/ApkExtractor.cs"
    click ApkParser "https://github.com/canheo136/quicklook.plugin.apkviewer/blob/master/AAPTForNet/ApkParser.cs"
    click ResourceDetector "https://github.com/canheo136/quicklook.plugin.apkviewer/blob/master/AAPTForNet/ResourceDetector.cs"
    click BaseFilter "https://github.com/canheo136/quicklook.plugin.apkviewer/blob/master/AAPTForNet/Filters/BaseFilter.cs"
    click ABIFilter "https://github.com/canheo136/quicklook.plugin.apkviewer/blob/master/AAPTForNet/Filters/ABIFilter.cs"
    click ApplicationFilter "https://github.com/canheo136/quicklook.plugin.apkviewer/blob/master/AAPTForNet/Filters/ApplicationFilter.cs"
    click PackageFilter "https://github.com/canheo136/quicklook.plugin.apkviewer/blob/master/AAPTForNet/Filters/PackageFilter.cs"
    click PermissionFilter "https://github.com/canheo136/quicklook.plugin.apkviewer/blob/master/AAPTForNet/Filters/PermissionFilter.cs"
    click SDKFilter "https://github.com/canheo136/quicklook.plugin.apkviewer/blob/master/AAPTForNet/Filters/SDKFilter.cs"
    click SupportScrFilter "https://github.com/canheo136/quicklook.plugin.apkviewer/blob/master/AAPTForNet/Filters/SupportScrFilter.cs"
    click ApkInfoModel "https://github.com/canheo136/quicklook.plugin.apkviewer/blob/master/AAPTForNet/Models/ApkInfo.cs"
    click DumpModel "https://github.com/canheo136/quicklook.plugin.apkviewer/blob/master/AAPTForNet/Models/DumpModel.cs"
    click IconModel "https://github.com/canheo136/quicklook.plugin.apkviewer/blob/master/AAPTForNet/Models/Icon.cs"
    click SDKInfoModel "https://github.com/canheo136/quicklook.plugin.apkviewer/blob/master/AAPTForNet/Models/SDKInfo.cs"
    click ConfigsModel "https://github.com/canheo136/quicklook.plugin.apkviewer/blob/master/AAPTForNet/Models/Configs.cs"
    click AAPTTool "https://github.com/canheo136/quicklook.plugin.apkviewer/blob/master/AAPTForNet/tool/aapt.exe"
    click DebugProj "https://github.com/canheo136/quicklook.plugin.apkviewer/blob/master/StartupDebuging/StartupDebuging.csproj"
    click DebugProgram "https://github.com/canheo136/quicklook.plugin.apkviewer/blob/master/StartupDebuging/Program.cs"
    click DebugConfig "https://github.com/canheo136/quicklook.plugin.apkviewer/blob/master/StartupDebuging/App.config"
    click DebugReadme "https://github.com/canheo136/quicklook.plugin.apkviewer/blob/master/StartupDebuging/apks/README.md"
    click PackZip "https://github.com/canheo136/quicklook.plugin.apkviewer/blob/master/Scripts/pack-zip.ps1"
    click UpdateVer "https://github.com/canheo136/quicklook.plugin.apkviewer/blob/master/Scripts/update-version.ps1"

    %% Styles
    classDef external fill:#cccccc,stroke:#333,stroke-width:1px
    classDef core fill:#00ccff,stroke:#030,stroke-width:1px
    classDef lib fill:#88cc88,stroke:#030,stroke-width:1px
    classDef script fill:#ffdd88,stroke:#333,stroke-width:1px
```
