### Usage of Preference Interface Source: https://github.com/mihonapp/mihon/blob/main/_autodocs/api-reference/domain-models.md Example demonstrating how to obtain and use a Preference instance for string values. This shows getting a preference, retrieving its value, setting a new value, and subscribing to its changes. ```kotlin val myPref: Preference = preferenceStore.getString("my_key", "default") val value = myPref.get() myPref.set("new_value") val updates: Flow = myPref.changes() ``` -------------------------------- ### Example CatalogueSource Implementation Source: https://github.com/mihonapp/mihon/blob/main/_autodocs/api-reference/source-api.md An example implementation of the `CatalogueSource` interface, demonstrating how to define source properties and implement suspend methods for fetching manga. ```kotlin class MySource : CatalogueSource { override val id: Long = 1234567890 override val name: String = "MyMangaSite" override val lang: String = "en" override val supportsLatest: Boolean = true override suspend fun getPopularManga(page: Int): MangasPage { // Fetch and parse popular manga val response = client.newCall(popularMangaRequest(page)).execute() return popularMangaParse(response) } override suspend fun getSearchManga( page: Int, query: String, filters: FilterList ): MangasPage { // Implement search with filter support } override suspend fun getPageList(chapter: SChapter): List { // Fetch and return pages for chapter } } ``` -------------------------------- ### Example ConfigurableMangaSource Source: https://github.com/mihonapp/mihon/blob/main/_autodocs/api-reference/source-api.md An example implementation of a `ConfigurableSource` that adds a checkbox preference for image quality. The `getSourcePreferences()` method is used to retrieve and store the preference value. ```kotlin class ConfigurableMangaSource : HttpSource(), ConfigurableSource { override fun setupPreferenceScreen(screen: PreferenceScreen) { screen.addPreference(CheckBoxPreference(context).apply { key = "use_high_quality" title = "Use High Quality Images" defaultValue = false }) } private fun useHighQuality(): Boolean { return getSourcePreferences().getBoolean("use_high_quality", false) } } ``` -------------------------------- ### Example Filter List Implementation Source: https://github.com/mihonapp/mihon/blob/main/_autodocs/api-reference/source-api.md Demonstrates how to implement and return a FilterList, including various filter types like Header, Select, Sort, CheckBox, Separator, and TriState. This example shows the practical usage of the Filter classes. ```kotlin override fun getFilterList() = FilterList( Filter.Header("Search Filters"), GenreFilter(), SortFilter(), Filter.Separator(), Filter.CheckBox("NSFW", false), StatusFilter() ) class GenreFilter : Filter.Select( "Genre", arrayOf("All", "Action", "Comedy", "Drama") ) class SortFilter : Filter.Sort( "Sort By", arrayOf("Newest", "Popular", "Alphabetical"), ) class StatusFilter : Filter.TriState("Ongoing") ``` -------------------------------- ### GenreFilter Example Source: https://github.com/mihonapp/mihon/blob/main/_autodocs/types.md Example implementation of a Select filter for choosing a genre from a list of strings. ```kotlin class GenreFilter : Filter.Select( "Genre", arrayOf("All", "Action", "Comedy", "Drama"), state = 0 ) ``` -------------------------------- ### Manage Network Preferences Source: https://github.com/mihonapp/mihon/blob/main/_autodocs/configuration.md Example of how to configure network-related preferences such as verbose logging, DoH provider, and user agent. ```kotlin class MyNetworkConfig( private val networkPrefs: NetworkPreferences ) { fun enableVerboseLogging() { networkPrefs.verboseLogging.set(true) } fun setDoHProvider(providerId: Int) { networkPrefs.dohProvider.set(providerId) } fun updateUserAgent(userAgent: String) { networkPrefs.defaultUserAgent.set(userAgent) } fun observeUserAgent(): Flow { return networkPrefs.defaultUserAgent.changes() } } ``` -------------------------------- ### Get Next Chapters Flow Source: https://github.com/mihonapp/mihon/blob/main/_autodocs/api-reference/interactors.md Provides recommended chapters to read next. Use to get a list of suggested chapters. ```kotlin class GetNextChapters( private val historyRepository: HistoryRepository, ) { fun subscribe(limit: Int = 5): Flow> } ``` -------------------------------- ### StartOffset Constructors Source: https://github.com/mihonapp/mihon/blob/main/app/src/main/baselineProfiles/baseline-prof.txt Constructors for creating a StartOffset, which defines when an animation should start. ```APIDOC ## StartOffset Constructors ### Description Represents the starting offset for an animation. ### Methods - `constructor-impl$default(int, int, int, DefaultConstructorMarker)` - `constructor-impl(int, int)`: Creates a StartOffset with specified delay and type. - `constructor-impl(long)`: Creates a StartOffset from a long value. ``` -------------------------------- ### SortFilter Example Source: https://github.com/mihonapp/mihon/blob/main/_autodocs/types.md Example implementation of a Sort filter for selecting a sort order from a predefined list of strings. ```kotlin class SortFilter : Filter.Sort( "Sort By", arrayOf("Date", "Title", "Views"), state = Filter.Sort.Selection(0, true) ) ``` -------------------------------- ### Manage Security Preferences Source: https://github.com/mihonapp/mihon/blob/main/_autodocs/configuration.md Example of how to interact with security preferences like biometric lock and auto-lock timeout. ```kotlin class MySecuritySettings( private val securityPrefs: SecurityPreferences ) { fun enableBiometricLock() { securityPrefs.useAuthenticator.set(true) } fun setLockTimeout(minutes: Int) { securityPrefs.lockAppAfter.set(minutes) } fun observeSecureMode(): Flow { return securityPrefs.secureScreen.changes() } } ``` -------------------------------- ### Preference Usage Example Source: https://github.com/mihonapp/mihon/blob/main/_autodocs/configuration.md Demonstrates the common pattern for accessing, reading, updating, and reacting to changes in preferences using the Preference interface. ```kotlin // Access preference val myPref: Preference = preferenceStore.getString("my_key", "default") // Read value val value = myPref.get() // Update value myPref.set("new_value") // React to changes myPref.changes().collect { println("Value changed to: $it") } // Reset to default myPref.delete() ``` -------------------------------- ### Example HttpSource Implementation Source: https://github.com/mihonapp/mihon/blob/main/_autodocs/api-reference/source-api.md A concrete implementation of HttpSource for a manga website. Demonstrates overriding headersBuilder and implementing methods for fetching popular manga and page lists. ```kotlin class MangaSourceImpl : HttpSource() { override val baseUrl = "https://mangasite.example.com" override val lang = "en" override val name = "MangaSite" override val supportsLatest = true override fun headersBuilder(): Headers.Builder = super.headersBuilder().apply { add("Accept-Language", "en-US") } override suspend fun getPopularManga(page: Int): MangasPage { val response = client.newCall( GET("$baseUrl/popular?page=$page", headers) ).execute() return response.use { resp -> if (!resp.isSuccessful) throw HttpException(resp.code) MangasPage( mangas = parsePopularMangas(resp.body.string()), hasNextPage = true ) } } override suspend fun getPageList(chapter: SChapter): List { val response = client.newCall(GET(baseUrl + chapter.url, headers)).execute() return response.use { if (!it.isSuccessful) throw HttpException(it.code) parsePages(it.body.string()) } } } ``` -------------------------------- ### Get Extension Stores Flow Source: https://github.com/mihonapp/mihon/blob/main/_autodocs/api-reference/interactors.md Retrieves available extension repositories. Use to get a list of extension sources or subscribe to updates. ```kotlin class GetExtensionStores( private val repository: ExtensionStoreRepository, ) { suspend fun get(): List fun subscribe(): Flow> } ``` ```kotlin val getStores: GetExtensionStores = Injekt.get() // Get once val stores = getStores.get() stores.forEach { store -> println("Store: ${store.name}") } // Subscribe to changes getStores.subscribe().collect { stores -> println("${stores.size} stores available") } ``` -------------------------------- ### Dependency Injection with Injekt Source: https://github.com/mihonapp/mihon/blob/main/_autodocs/INDEX.md Examples of using Injekt for lazy injection in sources and direct retrieval in ViewModels/Services. ```kotlin // In sources protected val network: NetworkHelper by injectLazy() // In ViewModels/Services private val getChapters: GetChaptersByMangaId = Injekt.get() private val manga: Manga = Injekt.get() ``` -------------------------------- ### Dependency Injection with Injekt Source: https://github.com/mihonapp/mihon/blob/main/_autodocs/configuration.md Shows how to retrieve dependencies using the Injekt DI framework. Includes examples for direct retrieval and lazy injection within HttpSource. ```kotlin // Getting dependencies val networkHelper: NetworkHelper = Injekt.get() val securityPrefs: SecurityPreferences = Injekt.get() // In HttpSource (lazy injection) protected val network: NetworkHelper by injectLazy() ``` -------------------------------- ### GetExtensionStores Source: https://github.com/mihonapp/mihon/blob/main/_autodocs/api-reference/interactors.md Get available extension repositories. Provides both a one-time fetch and a subscription to changes. ```APIDOC ## GetExtensionStores ### Description Get available extension repositories. ### Methods #### `get(): List` Fetches the list of available extension stores once. #### `subscribe(): Flow>` Subscribes to a flow that emits the list of available extension stores whenever it changes. ### Returns * `List` (for `get()`) * `Flow>` (for `subscribe()`) ``` -------------------------------- ### Handling OkHttp IOExceptions Source: https://github.com/mihonapp/mihon/blob/main/_autodocs/errors.md This example demonstrates how to catch and differentiate various network-related IOExceptions thrown by OkHttp, such as timeouts, DNS failures, and general network errors. It's crucial for robust network request handling. ```kotlin try { val response = client.newCall(request).execute() } catch (e: IOException) { when { e is SocketTimeoutException -> println("Connection timeout") e is UnknownHostException -> println("DNS failure") e.message?.contains("cancelled") == true -> println("Request cancelled") else -> println("Network error: ${e.message}") } } ``` -------------------------------- ### StartOffsetType Companion Methods Source: https://github.com/mihonapp/mihon/blob/main/app/src/main/baselineProfiles/baseline-prof.txt Companion object methods for StartOffsetType, providing access to animation start offset types. ```APIDOC ## StartOffsetType Companion Methods ### Description Companion object for `StartOffsetType` which defines types of animation start offsets. ### Methods - `()` - `access$getDelay$cp()`: Accessor for the delay constant. - `constructor-impl(int)`: Constructor for StartOffsetType. - `StartOffsetType$Companion()`: Default constructor for the companion object. - `StartOffsetType$Companion(DefaultConstructorMarker)`: Constructor with marker. - `getDelay-Eo1U57Q()`: Gets the delay value. ``` -------------------------------- ### GetNextChapters Source: https://github.com/mihonapp/mihon/blob/main/_autodocs/api-reference/interactors.md Get recommended chapters to read next. Returns a Flow of Chapter. ```APIDOC ## GetNextChapters ### Description Get recommended chapters to read next. ### Method Signature `fun subscribe(limit: Int = 5): Flow>` ### Parameters * `limit` (Int, Optional) - The maximum number of chapters to recommend. Defaults to 5. ### Returns * `Flow>` - A flow emitting a list of recommended chapters. ``` -------------------------------- ### Handle NoChaptersException Source: https://github.com/mihonapp/mihon/blob/main/_autodocs/errors.md Example of throwing and catching NoChaptersException when no chapters are found for a manga. This can be used to inform the user that no chapters are available. ```kotlin try { val chapters = chapterRepository.getChapterByMangaId(mangaId) if (chapters.isEmpty()) { throw NoChaptersException("Manga $mangaId has no chapters") } } catch (e: NoChaptersException) { // Show "no chapters available" UI } ``` -------------------------------- ### SourceRepository Source: https://github.com/mihonapp/mihon/blob/main/_autodocs/api-reference/repositories.md Manages the collection of available sources, including online and installer sources, with options to filter and retrieve specific sources. ```APIDOC ## SourceRepository Manages the collection of available sources. ### Methods **getSources(): Flow>** - **Returns:** All available sources **getOnlineSources(): Flow>** - **Returns:** Online (HTTP) sources only **getSourcesWithFavoriteCount(): Flow>** - **Returns:** Sources with library count aggregation **getSource(sourceId: Long): Source?** - **Parameters:** `sourceId` (Long) - source ID - **Returns:** Source or null if not loaded **getSourcesWithIds(sourceIds: List): List** - **Parameters:** `sourceIds` (List) - filter by IDs - **Returns:** Loaded sources **getRemoteSources(ids: List): List** - **Parameters:** `ids` (List) - extension source IDs - **Returns:** Sources from extensions **getSourcesFromInstaller(): List** - **Returns:** Sources from installer source ``` -------------------------------- ### WindowInsetsCompat$Impl34 Source: https://github.com/mihonapp/mihon/blob/main/app/src/main/baselineProfiles/baseline-prof.txt Implementation for WindowInsetsCompat for Android API level 34, offering methods to get insets and check visibility. ```APIDOC ## getInsets ### Description Retrieves the insets for a given type. ### Method `getInsets(int type)` ### Parameters #### Path Parameters - **type** (int) - The type of insets to retrieve. ``` ```APIDOC ## getInsetsIgnoringVisibility ### Description Retrieves the insets for a given type, ignoring visibility. ### Method `getInsetsIgnoringVisibility(int type)` ### Parameters #### Path Parameters - **type** (int) - The type of insets to retrieve. ``` ```APIDOC ## initDisplayShape ### Description Initializes the display shape for a given view. ### Method `initDisplayShape(View view)` ### Parameters #### Path Parameters - **view** (View) - The view to initialize the display shape for. ``` ```APIDOC ## isVisible ### Description Checks if a given inset type is visible. ### Method `isVisible(int type)` ### Parameters #### Path Parameters - **type** (int) - The type of inset to check. ``` -------------------------------- ### Get History Flow Source: https://github.com/mihonapp/mihon/blob/main/_autodocs/api-reference/interactors.md Queries reading history. Use this to subscribe to changes in reading history. ```kotlin class GetHistory( private val historyRepository: HistoryRepository, ) { fun subscribe(query: String = ""): Flow> } ``` ```kotlin val getHistory: GetHistory = Injekt.get() getHistory.subscribe().collect { history -> history.forEach { entry -> println("${entry.manga.title} - last read: ${entry.history.readAt}") } } ``` -------------------------------- ### Handle HttpException in Network Calls Source: https://github.com/mihonapp/mihon/blob/main/_autodocs/errors.md Example of throwing HttpException when an unsuccessful HTTP response is encountered. This is typically used within network request execution. ```kotlin override suspend fun getPopularManga(page: Int): MangasPage { val response = client.newCall(request).execute() if (!response.isSuccessful) { throw HttpException(response.code) } return parse(response) } ``` -------------------------------- ### Get Group Anchor Operation Source: https://github.com/mihonapp/mihon/blob/main/app/src/main/baselineProfiles/startup-prof.txt Retrieves the group anchor for the InsertNodeFixup operation. ```java HSPLandroidx/compose/runtime/composer/gapbuffer/changelist/Operation$InsertNodeFixup;->getGroupAnchor(Landroidx/compose/runtime/composer/gapbuffer/changelist/OperationArgContainer;Landroidx/compose/runtime/composer/gapbuffer/SlotWriter;)Landroidx/compose/runtime/composer/gapbuffer/GapAnchor; ``` -------------------------------- ### Template for Custom Interactor Source: https://github.com/mihonapp/mihon/blob/main/_autodocs/api-reference/interactors.md Provides a template for creating custom interactors, including examples of read-only, one-time, and mutation operations. Demonstrates using Flow for reactive data and suspend functions for asynchronous tasks. ```kotlin class MyCustomInteractor( private val repository: MyRepository, private val otherDependency: SomeService, ) { // Read-only operation returning Flow fun subscribe(param: String): Flow { return repository.getAllAsFlow() .map { list -> list.filter { it.name.contains(param) } } } // One-time operation with suspend suspend fun execute(id: Long): MyType { return repository.getById(id) } // Mutation operation suspend operator fun invoke(input: MyInput) { val result = otherDependency.process(input) repository.save(result) } } ``` -------------------------------- ### Configure OkHttp Client with Defaults Source: https://github.com/mihonapp/mihon/blob/main/_autodocs/configuration.md Set up an OkHttpClient with default configurations including timeouts, cache, and essential interceptors like UserAgentInterceptor and UncaughtExceptionInterceptor. ```kotlin val client = OkHttpClient.Builder() .cookieJar(cookieJar) .connectTimeout(30, TimeUnit.SECONDS) .readTimeout(30, TimeUnit.SECONDS) .callTimeout(2, TimeUnit.MINUTES) .cache( Cache( directory = context.cacheDir + "/network_cache", maxSize = 5 * 1024 * 1024 // 5 MiB ) ) .addInterceptor(UncaughtExceptionInterceptor()) .addInterceptor(UserAgentInterceptor(::defaultUserAgentProvider)) .build() ``` -------------------------------- ### Adding a Custom Extension Store Source: https://github.com/mihonapp/mihon/blob/main/_autodocs/configuration.md Demonstrates how to create and upsert a custom extension store using the ExtensionStore model and the extension store repository. ```kotlin val customStore = ExtensionStore( indexUrl = "https://myextensions.example.com", name = "My Extension Store", badgeLabel = "Custom", signingKey = "...", // Base64-encoded public key contact = ExtensionStore.Contact( website = "https://example.com", discord = "https://discord.gg/example" ), isLegacy = false, extensionListUrl = null ) // Upsert via repository extensionStoreRepository.upsert(customStore) ``` -------------------------------- ### Get Last Read Manga Flow Source: https://github.com/mihonapp/mihon/blob/main/_autodocs/api-reference/interactors.md Retrieves the most recently read manga entries. Use to get a paginated list of recently read manga. ```kotlin class GetLastReadManga( private val historyRepository: HistoryRepository, ) { fun subscribe(limit: Int, offset: Int): Flow> } ``` -------------------------------- ### GetLastReadManga Source: https://github.com/mihonapp/mihon/blob/main/_autodocs/api-reference/interactors.md Get the most recently read manga. Returns a Flow of HistoryWithRelations. ```APIDOC ## GetLastReadManga ### Description Get most recently read manga. ### Method Signature `fun subscribe(limit: Int, offset: Int): Flow>` ### Parameters * `limit` (Int) - The maximum number of results to return. * `offset` (Int) - The number of results to skip. ### Returns * `Flow>` - A flow emitting a list of the most recently read manga. ``` -------------------------------- ### SoftwareKeyboardControllerCompat Methods Source: https://github.com/mihonapp/mihon/blob/main/app/src/main/baselineProfiles/baseline-prof.txt Compat methods for controlling the software keyboard. ```APIDOC ## SoftwareKeyboardControllerCompat Methods ### Description Provides backward-compatible methods for controlling the software keyboard attached to a View. ### Methods - `(View)` ``` -------------------------------- ### Get Track by ID Source: https://github.com/mihonapp/mihon/blob/main/_autodocs/api-reference/repositories.md Retrieves a specific tracker entry by its unique ID. ```APIDOC ## getTrackById(id: Long): Track? ### Description Retrieves a single track entry by its unique identifier. ### Parameters #### Path Parameters - **id** (Long) - Required - The ID of the track to retrieve. ### Returns - **Track?** - The Track object if found, otherwise null. ``` -------------------------------- ### Project File Structure Source: https://github.com/mihonapp/mihon/blob/main/_autodocs/SUMMARY.md Illustrates the organization of the project's documentation files and directories. ```plaintext /workspace/home/output/ ├── README.md # Start here ├── INDEX.md # Navigation guide ├── SUMMARY.md # This file │ ├── api-reference/ # API documentation │ ├── source-api.md # Source interfaces │ ├── domain-models.md # Entity definitions │ ├── repositories.md # Data access │ ├── interactors.md # Business logic │ └── archive.md # Archive utilities │ ├── types.md # Type definitions ├── configuration.md # Preferences & config └── errors.md # Exception handling ``` -------------------------------- ### ContextCompat.Api28Impl Source: https://github.com/mihonapp/mihon/blob/main/app/src/main/baselineProfiles/baseline-prof.txt Provides API 28 implementations for ContextCompat methods. ```APIDOC ## ContextCompat.Api28Impl ### Description Provides API 28 implementations for ContextCompat methods. (No specific methods documented in the source for this class.) ``` -------------------------------- ### Get Tracks by Manga ID Source: https://github.com/mihonapp/mihon/blob/main/_autodocs/api-reference/repositories.md Retrieves all associated tracker entries for a given manga ID. ```APIDOC ## getTracksByMangaId(mangaId: Long): List ### Description Retrieves all trackers associated with a specific manga. ### Parameters #### Path Parameters - **mangaId** (Long) - Required - The ID of the manga to query tracks for. ### Returns - **List** - A list of Track objects associated with the manga. ``` -------------------------------- ### AddExtensionStore Source: https://github.com/mihonapp/mihon/blob/main/_autodocs/api-reference/interactors.md Register an extension store. ```APIDOC ## AddExtensionStore ### Description Register extension store. ### Method Signature `suspend operator fun invoke(store: ExtensionStore)` ### Parameters * `store` (ExtensionStore) - The ExtensionStore object to register. ``` -------------------------------- ### ContextCompat Source: https://github.com/mihonapp/mihon/blob/main/app/src/main/baselineProfiles/baseline-prof.txt Utility class for accessing resources and system services. ```APIDOC ## ContextCompat ### Description Utility class for accessing resources and system services. ### Methods - **getDrawable**(context: Context, id: Int): Drawable - **getMainExecutor**(context: Context): Executor - **registerReceiver**(context: Context, receiver: BroadcastReceiver, filter: IntentFilter, flags: Int): Intent - **registerReceiver**(context: Context, receiver: BroadcastReceiver, filter: IntentFilter, permission: String, handler: Handler, flags: Int): Intent ``` -------------------------------- ### ConfigurationKt Utility Methods Source: https://github.com/mihonapp/mihon/blob/main/app/src/main/baselineProfiles/baseline-prof.txt Utility methods for creating default executors and tracers within the ConfigurationKt class. ```APIDOC ## ConfigurationKt Utilities ### Description Provides static methods for creating default components used in WorkManager configuration. ### Methods - `access$createDefaultExecutor(Z)`: Internal access method for creating a default executor. - `access$createDefaultTracer()`: Internal access method for creating a default tracer. - `createDefaultExecutor(Z)`: Creates a default `Executor`. - `createDefaultTracer()`: Creates a default `Tracer`. ``` -------------------------------- ### Get Tracks by Tracker ID Source: https://github.com/mihonapp/mihon/blob/main/_autodocs/api-reference/repositories.md Retrieves all tracker entries associated with a specific external tracker service. ```APIDOC ## getTracksByTrackerId(trackerId: Long): List ### Description Retrieves all track entries associated with a specific tracker service. ### Parameters #### Path Parameters - **trackerId** (Long) - Required - The ID of the tracker service to query. ### Returns - **List** - A list of Track objects associated with the tracker service. ``` -------------------------------- ### Create Archive Source: https://github.com/mihonapp/mihon/blob/main/_autodocs/api-reference/archive.md Creates a new ZIP archive file. Takes a map where keys are entry paths and values are their content as byte arrays. ```kotlin fun createArchive( outputFile: File, filesToAdd: Map // path -> content ) { ZipWriter(FileOutputStream(outputFile)).use { writer -> filesToAdd.forEach { (path, content) -> writer.writeEntry(ZipEntry(path), content) } } } ``` -------------------------------- ### Get Tracks by Manga ID (Flow) Source: https://github.com/mihonapp/mihon/blob/main/_autodocs/api-reference/repositories.md Provides a reactive stream of tracker entries for a given manga ID. ```APIDOC ## getTracksByMangaIdAsFlow(mangaId: Long): Flow> ### Description Returns a reactive stream of all trackers associated with a specific manga. ### Parameters #### Path Parameters - **mangaId** (Long) - Required - The ID of the manga to observe tracks for. ### Returns - **Flow>** - A Flow emitting lists of Track objects. ``` -------------------------------- ### Implement ConfigurableSource Preferences Source: https://github.com/mihonapp/mihon/blob/main/_autodocs/configuration.md Use SharedPreferences to store source-specific configurations like image quality settings. This allows users to customize source behavior through a preference screen. ```kotlin class MyConfigurableSource : HttpSource(), ConfigurableSource { override fun setupPreferenceScreen(screen: PreferenceScreen) { screen.addPreference(CheckBoxPreference(context).apply { key = "use_high_quality" title = "Use High Quality Images" summary = "Download high quality images when available" defaultValue = true }) screen.addPreference(ListPreference(context).apply { key = "image_quality" title = "Image Quality" entries = arrayOf("Low", "Medium", "High") entryValues = arrayOf("0", "1", "2") defaultValue = "2" }) } private fun getHighQuality(): Boolean { return getSourcePreferences().getBoolean("use_high_quality", true) } private fun getImageQuality(): String { return getSourcePreferences().getString("image_quality", "2") ?: "2" } override suspend fun getImageUrl(page: Page): String { val quality = getImageQuality() // Use quality setting in URL construction return when (quality) { "0" -> page.url + "?size=small" "1" -> page.url + "?size=medium" else -> page.url + "?size=large" } } } ``` -------------------------------- ### Dependency Injection for Custom Interactor Source: https://github.com/mihonapp/mihon/blob/main/_autodocs/api-reference/interactors.md Illustrates how to set up dependency injection for a custom interactor and how to use it within a ViewModel. This ensures proper instantiation and access to dependencies. ```kotlin // In DI module/setup single { MyCustomInteractor( repository = get(), otherDependency = get(), ) } // Usage in ViewModel class MyViewModel( private val myInteractor: MyCustomInteractor, ) { val data = myInteractor.subscribe("filter") } ``` -------------------------------- ### ViewCompat Static Methods Source: https://github.com/mihonapp/mihon/blob/main/app/src/main/baselineProfiles/baseline-prof.txt Static utility methods for interacting with Views in a backward-compatible manner. ```APIDOC ## ViewCompat Static Methods ### Description Utility methods for performing View operations that are compatible across different Android versions. ### Methods - `()` - `getRootWindowInsets(View)` - `onApplyWindowInsets(View, WindowInsetsCompat)` - `postOnAnimation(View, Runnable)` - `setAccessibilityDelegate(View, AccessibilityDelegateCompat)` - `setImportantForAccessibilityIfNeeded(View)` - `setOnApplyWindowInsetsListener(View, OnApplyWindowInsetsListener)` - `setWindowInsetsAnimationCallback(View, WindowInsetsAnimationCompat.Callback)` ``` -------------------------------- ### MenuHostHelper Methods Source: https://github.com/mihonapp/mihon/blob/main/app/src/main/baselineProfiles/baseline-prof.txt Helper class for managing MenuHost, allowing addition of MenuProviders. ```APIDOC ## MenuHostHelper Methods ### Description Helper methods for managing menu providers associated with a MenuHost. ### Methods - `(Runnable)` - `addMenuProvider(MenuProvider)` ``` -------------------------------- ### Preference Source: https://github.com/mihonapp/mihon/blob/main/_autodocs/api-reference/domain-models.md Generic preference interface for storing key-value data with reactive updates. It allows getting, setting, deleting, and observing changes to preference values. ```APIDOC ## Preference ### Description Generic preference interface for storing key-value data with reactive updates. ### Methods - `key(): String` - Returns the unique key for the preference. - `get(): T` - Retrieves the current value of the preference. - `set(value: T)` - Sets a new value for the preference. - `isSet(): Boolean` - Checks if the preference has been set (i.e., not using the default value). - `delete()` - Deletes the preference. - `defaultValue(): T` - Returns the default value of the preference. - `changes(): Flow` - Returns a Flow that emits new values when the preference changes. - `stateIn(scope: CoroutineScope): StateFlow` - Converts the changes Flow into a StateFlow. ### Companion Methods - `isPrivate(key: String): Boolean` - Checks if a preference key is private. - `privateKey(key: String): String` - Returns the private key for a given key. - `isAppState(key: String): Boolean` - Checks if a preference key is an app state key. - `appStateKey(key: String): String` - Returns the app state key for a given key. ### Usage Example ```kotlin val myPref: Preference = preferenceStore.getString("my_key", "default") val value = myPref.get() myPref.set("new_value") val updates: Flow = myPref.changes() ``` ### Key Prefixes - `__PRIVATE_` — User preferences not exported in backups - `__APP_STATE_` — Internal state, not exported anywhere ``` -------------------------------- ### Preference Interface Definition Source: https://github.com/mihonapp/mihon/blob/main/_autodocs/configuration.md Defines the generic Preference interface for managing configuration values, including methods for getting, setting, deleting, and observing changes. ```kotlin interface Preference { fun key(): String // Storage key fun get(): T // Current value fun set(value: T) // Update value fun isSet(): Boolean // Whether explicitly set fun delete() // Reset to default fun defaultValue(): T // Get default fun changes(): Flow // Reactive updates fun stateIn(scope: CoroutineScope): StateFlow // StateFlow } ``` -------------------------------- ### Implement Fallback on HTTP 404 Error for Page Fetching Source: https://github.com/mihonapp/mihon/blob/main/_autodocs/errors.md Attempts to fetch pages from a primary source and falls back to an alternative mirror if a 404 HTTP error is encountered. Other HTTP errors are re-thrown. ```kotlin override suspend fun getPageList(chapter: SChapter): List { return try { fetchPagesFromPrimary(chapter) } catch (e: HttpException) { if (e.code == 404) { // Try alternative endpoint fetchPagesFromMirror(chapter) } else { throw e } } } ``` -------------------------------- ### AccessibilityNodeInfoCompat$Api30Impl Source: https://github.com/mihonapp/mihon/blob/main/app/src/main/baselineProfiles/baseline-prof.txt Implementation details for API level 30. ```APIDOC ## AccessibilityNodeInfoCompat$Api30Impl ### Description Provides API-specific implementations for Android 11 (API 30). ### Methods - **setStateDescription(AccessibilityNodeInfo info, CharSequence stateDescription)**: Sets the state description for an AccessibilityNodeInfo on API 30. ``` -------------------------------- ### Get InputStream for Archive Entry Source: https://github.com/mihonapp/mihon/blob/main/_autodocs/api-reference/archive.md Retrieve an InputStream for a specific entry within an archive. The caller is responsible for closing the returned InputStream. Returns null if the entry is not found. ```kotlin val manifest = ArchiveReader(pfd).getInputStream("META-INF/manifest.xml") manifest?.bufferedReader()?.use { reader -> val content = reader.readText() parseManifest(content) } ``` -------------------------------- ### Extension Sealed Class Hierarchy Source: https://github.com/mihonapp/mihon/blob/main/_autodocs/types.md Defines a sealed class hierarchy for representing different types of extensions: Installed, Available, and Untrusted. Includes common properties and specific details for each type. ```kotlin sealed class Extension { abstract val name: String abstract val pkgName: String abstract val versionName: String abstract val versionCode: Long abstract val libVersion: Double abstract val lang: String? abstract val isNsfw: Boolean data class Installed( override val name: String, override val pkgName: String, override val versionName: String, override val versionCode: Long, override val libVersion: Double, override val lang: String, override val isNsfw: Boolean, val pkgFactory: String?, val sources: List, val icon: Drawable?, val hasUpdate: Boolean = false, val isObsolete: Boolean = false, val isShared: Boolean, val store: ExtensionStore? = null, ) : Extension() data class Available( override val name: String, override val pkgName: String, override val versionName: String, override val versionCode: Long, override val libVersion: Double, override val lang: String, override val isNsfw: Boolean, val sources: List, val apkUrl: String, val iconUrl: String, val store: ExtensionStore, ) : Extension() { data class Source( val id: Long, val lang: String, val name: String, val baseUrl: String, ) { fun toStubSource(): StubSource } } data class Untrusted( override val name: String, override val pkgName: String, override val versionName: String, override val versionCode: Long, override val libVersion: Double, val signatureHash: String, override val lang: String? = null, override val isNsfw: Boolean = false, ) : Extension() } ``` -------------------------------- ### Catch and Handle HttpException Source: https://github.com/mihonapp/mihon/blob/main/_autodocs/errors.md Demonstrates how to catch HttpException and handle different HTTP error codes using a 'when' statement. This is useful for providing specific user feedback or retry logic. ```kotlin try { val mangas = source.getPopularManga(1) } catch (e: HttpException) { when (e.code) { 404 -> println("Not found") 429 -> println("Rate limited") 500 -> println("Server error") else -> println("HTTP error: ${e.code}") } } ``` -------------------------------- ### DisplayCutoutCompat Methods Source: https://github.com/mihonapp/mihon/blob/main/app/src/main/baselineProfiles/baseline-prof.txt Provides access to display cutout information, such as bounding rectangles, cutout path, and waterfall insets. ```APIDOC ## DisplayCutoutCompat Methods ### Description Methods for retrieving information about the display cutout, including its geometry and insets. ### Methods - `getBoundingRects()` - `getCutoutPath()` - `getWaterfallInsets()` - `wrap(DisplayCutout)` ``` -------------------------------- ### Operation: EnsureRootGroupStarted Source: https://github.com/mihonapp/mihon/blob/main/app/src/main/baselineProfiles/startup-prof.txt Manages the EnsureRootGroupStarted operation, covering its static initialization, constructor, and execution. ```java Landroidx/compose/runtime/composer/gapbuffer/changelist/Operation$EnsureRootGroupStarted; ``` ```java HSPLandroidx/compose/runtime/composer/gapbuffer/changelist/Operation$EnsureRootGroupStarted;->()V ``` ```java HSPLandroidx/compose/runtime/composer/gapbuffer/changelist/Operation$EnsureRootGroupStarted;->()V ``` ```java HSPLandroidx/compose/runtime/composer/gapbuffer/changelist/Operation$EnsureRootGroupStarted;->execute(Landroidx/compose/runtime/composer/gapbuffer/changelist/OperationArgContainer;Landroidx/compose/runtime/Applier;Landroidx/compose/runtime/composer/gapbuffer/SlotWriter;Landroidx/compose/runtime/composer/RememberManager;Landroidx/compose/runtime/composer/gapbuffer/changelist/OperationErrorContext;)V ``` -------------------------------- ### NotificationChannelCompat.Builder Source: https://github.com/mihonapp/mihon/blob/main/app/src/main/baselineProfiles/baseline-prof.txt Builder class for creating NotificationChannelCompat instances. ```APIDOC ## NotificationChannelCompat.Builder ### Description Builder class for creating NotificationChannelCompat instances. ### Methods - ****(id: String, importance: Int): NotificationChannelCompat.Builder - **build**(): NotificationChannelCompat - **setGroup**(groupId: String): NotificationChannelCompat.Builder - **setName**(name: CharSequence): NotificationChannelCompat.Builder - **setShowBadge**(showBadge: Boolean): NotificationChannelCompat.Builder - **setSound**(uri: Uri, audioAttributes: AudioAttributes): NotificationChannelCompat.Builder ``` -------------------------------- ### LibraryManga Data Class Source: https://github.com/mihonapp/mihon/blob/main/_autodocs/api-reference/domain-models.md Represents manga within the library, including associated metadata like category IDs, read/unread counts, latest upload time, total chapter count, and whether the user has started reading it. Used for displaying library content. ```kotlin data class LibraryManga( val manga: Manga, val categories: List, val unreadCount: Long, val readCount: Long, val latestUploadTime: Long, val chapterCount: Long, val hasStarted: Boolean, ) ``` -------------------------------- ### SManga Data Model Source: https://github.com/mihonapp/mihon/blob/main/_autodocs/api-reference/source-api.md Represents source manga metadata. It includes properties like URL, title, thumbnail, artist, author, status, description, genre, update strategy, initialization status, and a memo field for internal use. It also provides methods for getting genres and creating copies. ```APIDOC ## SManga Source manga metadata interface. ### Properties | Property | Type | Description | |----------|------|-------------| | url | String | Relative URL path on source's website (without domain). | | title | String | Manga title. | | thumbnail_url | String? | URL to cover image. | | artist | String? | Artist name(s). | | author | String? | Author name(s). | | status | Int | Status code: UNKNOWN, ONGOING, COMPLETED, LICENSED, PUBLISHING_FINISHED, CANCELLED, ON_HIATUS | | description | String? | Long-form description/synopsis. | | genre | String? | Comma-separated genres. | | update_strategy | UpdateStrategy | How often to fetch updates (ALWAYS_UPDATE, etc.) | | initialized | Boolean | Whether metadata has been fully fetched and set. | | memo | JsonObject | Extra metadata for internal/source-specific purposes. Not visible to users. | ### Methods **getGenres(): List?** - **Returns:** Parsed list of genre strings, or null if not set - **Parsing:** Splits on ", ", trims, removes blanks, deduplicates **copy(): SManga** - **Returns:** Deep copy with all properties cloned **create(): SManga** (companion) - **Returns:** New `SMangaImpl` instance ### Status Constants - `UNKNOWN = 0` — Unknown status - `ONGOING = 1` — Series is ongoing - `COMPLETED = 2` — Series is complete - `LICENSED = 3` — Series is licensed - `PUBLISHING_FINISHED = 4` — Publishing has finished - `CANCELLED = 5` — Series was cancelled - `ON_HIATUS = 6` — Series is on hiatus ``` -------------------------------- ### ConfigurableSource Interface Source: https://github.com/mihonapp/mihon/blob/main/_autodocs/api-reference/source-api.md Marker interface for sources that provide preference/configuration screens. Implement this to allow users to configure source-specific settings. ```kotlin interface ConfigurableSource : Source { fun getSourcePreferences(): SharedPreferences fun setupPreferenceScreen(screen: PreferenceScreen) } ``` -------------------------------- ### Add Extension Store Source: https://github.com/mihonapp/mihon/blob/main/_autodocs/api-reference/interactors.md Registers a new extension store. Use to add a new source for extensions. ```kotlin class AddExtensionStore( private val repository: ExtensionStoreRepository, ) { suspend operator fun invoke(store: ExtensionStore) } ``` -------------------------------- ### WindowInsetsCompat$Impl30 Source: https://github.com/mihonapp/mihon/blob/main/app/src/main/baselineProfiles/baseline-prof.txt Implementation for WindowInsetsCompat for Android API level 30, including methods for initializing display shape. ```APIDOC ## copyRootViewBounds ### Description Copies the root view bounds. ### Method `copyRootViewBounds(View view)` ### Parameters #### Path Parameters - **view** (View) - The view to copy bounds from. ``` -------------------------------- ### WindowInsetsCompat$Type Source: https://github.com/mihonapp/mihon/blob/main/app/src/main/baselineProfiles/baseline-prof.txt Defines constants for different types of window insets. ```APIDOC ## captionBar ### Description Returns the type code for the caption bar insets. ### Method `captionBar()` ### Returns `int` - The type code for caption bar insets. ``` ```APIDOC ## displayCutout ### Description Returns the type code for display cutout insets. ### Method `displayCutout()` ### Returns `int` - The type code for display cutout insets. ``` ```APIDOC ## ime ### Description Returns the type code for input method editor (IME) insets. ### Method `ime()` ### Returns `int` - The type code for IME insets. ``` ```APIDOC ## indexOf ### Description Returns the index of a given inset type. ### Method `indexOf(int type)` ### Parameters #### Path Parameters - **type** (int) - The inset type to find the index of. ### Returns `int` - The index of the inset type. ``` ```APIDOC ## mandatorySystemGestures ### Description Returns the type code for mandatory system gestures insets. ### Method `mandatorySystemGestures()` ### Returns `int` - The type code for mandatory system gestures insets. ``` ```APIDOC ## navigationBars ### Description Returns the type code for navigation bar insets. ### Method `navigationBars()` ### Returns `int` - The type code for navigation bar insets. ``` ```APIDOC ## statusBars ### Description Returns the type code for status bar insets. ### Method `statusBars()` ### Returns `int` - The type code for status bar insets. ``` ```APIDOC ## systemBars ### Description Returns the type code for system bar insets (status bars and navigation bars). ### Method `systemBars()` ### Returns `int` - The type code for system bar insets. ``` ```APIDOC ## systemGestures ### Description Returns the type code for system gestures insets. ### Method `systemGestures()` ### Returns `int` - The type code for system gestures insets. ``` ```APIDOC ## tappableElement ### Description Returns the type code for tappable element insets. ### Method `tappableElement()` ### Returns `int` - The type code for tappable element insets. ``` -------------------------------- ### AccessibilityNodeInfoCompat Methods Source: https://github.com/mihonapp/mihon/blob/main/app/src/main/baselineProfiles/baseline-prof.txt This section details the public methods available on the AccessibilityNodeInfoCompat class for managing accessibility information. ```APIDOC ## AccessibilityNodeInfoCompat Methods ### Description Provides methods to interact with and modify accessibility node information. ### Methods - **isClickable()**: Checks if the node is clickable. - **isFocusable()**: Checks if the node is focusable. - **isFocused()**: Checks if the node currently has focus. - **obtain()**: Creates a new AccessibilityNodeInfoCompat instance. - **setAccessibilityDataSensitive(boolean sensitive)**: Sets whether accessibility data is sensitive. - **setAccessibilityFocused(boolean focused)**: Sets the accessibility focus state. - **setAvailableExtraData(List data)**: Sets available extra data for accessibility. - **setBoundsInScreen(Rect bounds)**: Sets the bounding rectangle of the node within the screen. - **setCheckable(boolean checkable)**: Sets whether the node is checkable. - **setClassName(CharSequence className)**: Sets the class name of the node. - **setClickable(boolean clickable)**: Sets whether the node is clickable. - **setCollectionInfo(Object collectionInfo)**: Sets collection information for the node. - **setCollectionItemInfo(Object collectionItemInfo)**: Sets collection item information for the node. - **setContentDescription(CharSequence contentDescription)**: Sets the content description for the node. - **setDrawingOrder(int order)**: Sets the drawing order for the node. - **setEditable(boolean editable)**: Sets whether the node is editable. - **setEnabled(boolean enabled)**: Sets whether the node is enabled. - **setFocusable(boolean focusable)**: Sets whether the node is focusable. - **setFocused(boolean focused)**: Sets the focus state of the node. - **setImportantForAccessibility(boolean important)**: Sets whether the node is important for accessibility. - **setLongClickable(boolean longClickable)**: Sets whether the node is long clickable. - **setMaxTextLength(int maxLength)**: Sets the maximum text length for the node. - **setMovementGranularities(int granularities)**: Sets the movement granularities for the node. - **setPackageName(CharSequence packageName)**: Sets the package name associated with the node. - **setPaneTitle(CharSequence paneTitle)**: Sets the pane title for the node. - **setParent(View parent)**: Sets the parent view of the node. - **setParent(View parent, int virtualDescendantId)**: Sets the parent view and virtual descendant ID. - **setPassword(boolean password)**: Sets whether the node represents a password. - **setRoleDescription(CharSequence roleDescription)**: Sets the role description for the node. - **setScreenReaderFocusable(boolean focusable)**: Sets whether the node is focusable by screen readers. - **setScrollable(boolean scrollable)**: Sets whether the node is scrollable. - **setSelected(boolean selected)**: Sets whether the node is selected. - **setSource(View source, int virtualDescendantId)**: Sets the source view and virtual descendant ID. - **setStateDescription(CharSequence stateDescription)**: Sets the state description for the node. - **setText(CharSequence text)**: Sets the text content of the node. - **setTextSelection(int start, int end)**: Sets the text selection range. - **setVisibleToUser(boolean visible)**: Sets whether the node is visible to the user. - **unwrap()**: Unwraps the AccessibilityNodeInfoCompat to its underlying AccessibilityNodeInfo. - **wrap(AccessibilityNodeInfo info)**: Wraps an AccessibilityNodeInfo into an AccessibilityNodeInfoCompat. ``` -------------------------------- ### NotificationChannelCompat.Api26Impl Source: https://github.com/mihonapp/mihon/blob/main/app/src/main/baselineProfiles/baseline-prof.txt Provides API 26 implementations for NotificationChannelCompat methods. ```APIDOC ## NotificationChannelCompat.Api26Impl ### Description Provides API 26 implementations for NotificationChannelCompat methods. ### Methods - **setGroup**(channel: NotificationChannel, groupId: String) - **setLightColor**(channel: NotificationChannel, arg1: Int) - **setShowBadge**(channel: NotificationChannel, arg1: Boolean) - **setSound**(channel: NotificationChannel, uri: Uri, audioAttributes: AudioAttributes) - **setVibrationPattern**(channel: NotificationChannel, pattern: [J]) ``` -------------------------------- ### Operation: PostInsertNodeFixup Source: https://github.com/mihonapp/mihon/blob/main/app/src/main/baselineProfiles/startup-prof.txt Details the PostInsertNodeFixup operation, including its static initialization, constructor, and execution. ```java Landroidx/compose/runtime/composer/gapbuffer/changelist/Operation$PostInsertNodeFixup; ``` ```java HSPLandroidx/compose/runtime/composer/gapbuffer/changelist/Operation$PostInsertNodeFixup;->()V ``` ```java HSPLandroidx/compose/runtime/composer/gapbuffer/changelist/Operation$PostInsertNodeFixup;->()V ``` -------------------------------- ### create Source: https://github.com/mihonapp/mihon/blob/main/_autodocs/api-reference/repositories.md Creates a new category with a given name and order. ```APIDOC ## create(name: String, order: Long) ### Description Creates a new category with the specified name and display order. ### Method `suspend fun create(name: String, order: Long): Long` ### Parameters #### Path Parameters - **name** (String) - Required - The name for the new category. - **order** (Long) - Required - The display order for the new category. ### Returns - `Long`: The ID of the newly created category. ``` -------------------------------- ### NetworkPreferences Class Source: https://github.com/mihonapp/mihon/blob/main/_autodocs/api-reference/domain-models.md Handles network-related configurations, including verbose logging for HTTP headers, DNS-over-HTTPS (DoH) provider selection, and the default User-Agent string. It allows for customization of network behavior. ```kotlin class NetworkPreferences( preferenceStore: PreferenceStore, verboseLoggingDefault: Boolean = false, ) { val verboseLogging: Preference // Log HTTP headers val dohProvider: Preference // DNS-over-HTTPS provider val defaultUserAgent: Preference // HTTP User-Agent header } ```