Improved user experience when working with the gallery and inpaint, adding support for Forge/Reforge, Hires. Fix, ADetailer, and Fal AI. by crim50n · Pull Request #614 · ShiftHackZ/Stable-Diffusion-Android

added 18 commits

December 29, 2025 21:31
- Add tests for FalAiEndpointRepositoryImpl, FalAiGenerationRepositoryImpl, ForgeModulesRepositoryImpl
- Add tests for TestFalAiApiKeyUseCaseImpl, GetForgeModulesUseCaseImpl, GetGalleryPagedIdsUseCaseImpl
- Add tests for FalAiGenerationUseCaseImpl, ConnectToFalAiUseCaseImpl
- Fix existing tests: add mediaFileManager, falAiApiKey, mediaPath/inputMediaPath mocks
- Add mock files for FalAi and ForgeModule entities
- GetStableDiffusionModelsUseCaseImpl: only fetch when A1111 is active
- FetchAndGetSwarmUiModelsUseCaseImpl: only fetch when SwarmUI is active
- FetchAndGetHuggingFaceModelsUseCaseImpl: only fetch when HuggingFace is active
- FetchAndGetStabilityAiEnginesUseCaseImpl: only fetch when StabilityAI is active

This prevents unnecessary network requests to servers that are not currently
configured as the active generation source.
Add model name field to generation results and display it in the
gallery detail view. This allows users to see which model was used
for each generated image.

Changes:
- Add modelName field to AiGenerationResult entity
- Add MODEL_NAME column to GenerationResultEntity (DB migration v9)
- Display model name in GalleryDetailScreen when available
- Update test mocks
Add new LOCAL_QUALCOMM_QNN server source that enables on-device
Stable Diffusion generation using Qualcomm QNN SDK with NPU (HTP)
acceleration. Supports Snapdragon 8 Gen 1 and newer chipsets.

Features:
- NPU-accelerated inference using Qualcomm HTP backend
- GPU fallback with OpenCL support (MNN backend)
- Built-in models from HuggingFace (xororz/sd-qnn)
- Custom model support with folder scanning
- Multiple resolution presets (512x512, 768x768, etc.)
- Configurable scheduler (DPM, Euler)
- Real-time diffusion process visualization
- Img2Img support with denoising

Technical changes:
- Add feature/qnn module with LocalDream-based implementation
- Add DeviceChipsetDetector for Snapdragon detection
- Add QNN preferences (model, runtime, scheduler, etc.)
- Add QnnForm for server setup configuration
- Add QnnRuntimeSelectionComponent for runtime switching
- Add model scanning for custom QNN models
- Update generation usecases to support QNN backend
- Add prepare_qnn_libs.sh script for library setup

Note: QNN libraries must be extracted separately using the
prepare_qnn_libs.sh script (not included in repository).
- Add fal.ai as supported backend with FLUX models
- Document local diffusion options (ONNX, MediaPipe, QNN)
- Add QNN setup instructions for Snapdragon devices
- Update feature list with ADetailer, Hires.Fix, Forge modules
- Document gallery improvements and file-based storage
Update test mocks and fixtures to support QNN repository and use cases:
- Add QnnGenerationRepository mocks to generation use case tests
- Add GetForgeModulesUseCase to generation viewmodel tests
- Add QNN preferences to configuration tests
- Fix mapper tests for model name field
- Add missing parameters to presentation viewmodel tests
- Rename log tag [SDAI] -> [PDAI]
- Rename log file sdaiv1.log -> pdaiv1.log
- Update custom model path SDAI -> PDAI
- Rename SdaiWorkerFactory -> PdaiWorkerFactory
- Update test stubs naming
- Add CHANGES.md with 0.7.0 release notes
- Add gradle-versions-plugin for dependency updates checking
- Add version-catalog-update-plugin for automated updates
- Update stable dependencies to latest versions:
  - compileSdk: 35 -> 36 (required by new AndroidX libs)
  - Compose BOM: 2025.03.01 -> 2025.12.01
  - AndroidX core-ktx: 1.15.0 -> 1.17.0
  - AndroidX lifecycle: 2.8.7 -> 2.10.0
  - AndroidX navigation: 2.8.9 -> 2.9.6
  - AndroidX work: 2.10.0 -> 2.11.0
  - Koin: 4.0.4 -> 4.1.1
  - Retrofit: 2.11.0 -> 3.0.0
  - ONNX: 1.21.0 -> 1.23.2
  - Material: 1.12.0 -> 1.13.0
  - And other library updates
- Pin critical versions (paging, agp, kotlin, ksp) to prevent breaking changes
- Keep minSdk=24 for Android 7.0+ compatibility

@crim50n

@crim50n

@crim50n

…om models scan

- QNN Hires.Fix only for square resolutions (512→768/1024, 768→1024)
- Add save selected images to device gallery + dialog copy
- Add low-importance progress notification channel to avoid heads-up popups
- Remove donate button from settings
- Update localization (en/ru/uk/tr/zh) and release notes
- Improve custom local model scanning/selection + prompt persistence
- Update release workflow to prepare QNN libs
Add unit tests for previously untested classes:
- Domain: connectivity, downloadable, gallery, report, settings, swarmmodel use cases
- Data: FalAi endpoints, report data sources and repositories, MediaPipe repository
- Presentation: InputHistory and OnBoarding view models
- Fix EngineSelectionViewModelTest to include new MediaPipe use case dependency

@crim50n

- Fix DownloadableModelLocalDataSourceTest: CustomOnnx models should have
  downloaded=false (implementation returns false for custom models)
- Replace deprecated createTempDir() with kotlin.io.path.createTempDirectory()
  in ScanCustomModelsUseCaseImplTest

@crim50n

…st and ServerSetupScreenTest

- MediaStoreGatewayFactoryTest: Replace unreliable Java reflection SDK mocking with MockK static function mocking for shouldUseNewMediaStore()
- ServerSetupScreenTest: Fix button text assertions (Setup -> Start) and state management for custom model toggle
…tities

- Add new database migrations (v11, v12)
- Add IdWithBlurHash entity for blurhash support
- Add ThumbnailInfo entity for thumbnail data
- Update GenerationResultDao with new queries
- Update GenerationResultEntity with new fields
- Update GenerationResultContract
- Add ThumbnailData entity
- Add DeleteAllUnlikedUseCase for bulk delete
- Add GetGalleryItemsRawUseCase
- Add GetThumbnailInfoUseCase
- Add HideItemsUseCase
- Add LikeItemsUseCase
- Add ToggleLikeUseCase
- Update DomainModule with new use cases
- Update AiGenerationResult entity
- Update Grid entity
- Update GetGalleryPagedIdsUseCase
- Update GenerationResultRepository
- Update MediaStoreGateway
- Update GenerationResultDataSource
- Update BackgroundWorkObserver
…port

- Add ThumbnailGenerator for efficient thumbnail creation
- Add blurhash module for image placeholders
- Add cache module for image caching
- Add ImageProcessingModule DI
- Add Base64ImageUtils
- Update CoreGenerationRepository
- Add MediaStoreGateway implementations
- Update GenerationResultLocalDataSource
- Update AiGenerationResultMappers
- Update PreferenceManagerImpl
- Update FalAiGenerationRemoteDataSource
- Update GenerationResultRepositoryImpl with tests
- Update all generation repository implementations
… transitions

- Add GalleryItemStateEvent
- Add SharedTransitionProvider for navigation
- Add gallery editor components
- Add gallery list selection support
- Add scaffold widgets
- Add new UI components
- Update GalleryScreen with multi-selection
- Update GalleryDetailScreen with enhanced features
- Update GalleryViewModel with batch operations
- Update navigation graphs and routers
- Update FalAiGenerationScreen
- Update ImageToImageScreen and TextToImageScreen
- Update SettingsScreen
- Update HomeNavigationScreen and DrawerScreen
- Update ZoomableImage widget
- Update BackgroundWorkWidget
- Add/update ViewModel tests
- Add notification drawable v35
- Update notification icon
- Add new localization strings
- Update HeaderInterceptor
- Update FalAiResponses
- Update libs.versions.toml
- Remove ic_sd_flat.xml
- Update BackgroundWorkObserverImpl
- Update CoreGenerationWorker
…ures in multiple languages

@crim50n

@crim50n

Gallery:
- Add unlike/unhide toggle logic for bulk selection
- If all selected items are liked/hidden, action reverses state
- Add unlikeByIds/unhideByIds to DAO and repository layers

Onboarding/UI:
- Fix CollapsibleScaffold background color (use background instead of surface)
- Fix bottom padding in txt2img and settings for onboarding demo mode

Img2Img:
- Show inpaint mask overlay on source image with 50% opacity

Release Notes:
- Update v0.7.1 notes with toggle behavior and UI fixes
- Add blurHashEncoder mock to generation repository tests
- Add unlikeItemsUseCase/unhideItemsUseCase to GalleryViewModelTest
- Fix toggleLike test to return toggled result on second queryById
- Add missing liked/blurHash fields to GenerationResultEntityMocks

@crim50n

@crim50n