Skip to content

chore: Update Java target to 17 and improve DNS prefetch#29

Open
AgentKush wants to merge 25 commits intoYumemiProject:develfrom
AgentKush:feature/java-17-dns-update
Open

chore: Update Java target to 17 and improve DNS prefetch#29
AgentKush wants to merge 25 commits intoYumemiProject:develfrom
AgentKush:feature/java-17-dns-update

Conversation

@AgentKush
Copy link

  • Update Java compatibility from 11 to 17
  • Optimize DnsPrefetchManager to prefetch on-demand
  • Add more CDN domains for MangaKakalot and MangaSee sources

- Added Callback interface to ReaderMenuProvider for handling menu actions
- Implemented onOpenMangaInfo() in ReaderActivity to open manga details
- The info action now properly navigates to the manga details screen
…Model

- Replaced TODO comment with proper documentation explaining the early return logic
- The early return safely discards stale page position updates when content changes
- Replaced deprecated okhttp3.internal.platform.PlatformRegistry.applicationContext
- Now uses proper public API okhttp3.OkHttp.initialize() for OkHttp 5.x
- BasePageHolder: Implement onTrimMemory to properly handle memory pressure
  - TRIM_MEMORY_MODERATE or higher: recycle the image view
  - TRIM_MEMORY_BACKGROUND or higher: apply downsampling
- TypedListSpacingDecoration: Add vertical spacing for TIP list items
…wer state

- Replace hardcoded PREFETCH_LIMIT_DEFAULT with dynamic computation
- Adjust prefetch limit based on available RAM (2-10 pages)
- Reduce prefetch on metered networks (cellular) by 50%
- Reduce prefetch in power save mode by 50%
- Add PREFETCH_LIMIT_MINIMUM, PREFETCH_LIMIT_LOW, PREFETCH_LIMIT_HIGH constants
- Add isNetworkUnmetered() helper using NetworkCapabilities API
- Create ProxyWebViewUnsupportedException for better error handling
- Add localized string 'proxy_webview_not_supported' to strings.xml
- Update ProxyProvider to throw the new exception instead of generic IllegalArgumentException
- Add exception mapping in Throwable.kt for localized display message
- Import new exception in ExceptionResolver for future resolution support
- DetailsInteractor: Replace stale 'TODO: remove' with KDoc (class is in active use)
- AppRouter: Remove empty TODO from fragmentTag() extension
- ExternalMangaRepository: Clarify that external plugins don't support related manga
- Fragment.kt: Improve comment about container ancestor lookup behavior
- Preferences.kt: Fix MultiSelectListPreference.setDefaultValueCompat() to actually work
  (now checks if values is null/empty before setting, matching ListPreference behavior)
CSS Element Hiding (## rules):
- Add cssSelectors list to RulesList for storing element hiding rules
- Parse '##selector' rules and store CSS selectors
- Add elementHidingSelectors property for accessing selectors
- Add getElementHidingScript() to AdBlock for generating injectable JS
- Script creates <style> tag to hide matched elements with display:none

Domain Modifiers (domain= option):
- Parse 'domain=example.com|~exclude.com' modifier syntax
- Support both include (domain=x.com) and exclude (~x.com) domains
- Apply domain restrictions in Rule.WithModifiers.invoke()
- Extract baseDomain once for efficiency

Removes 4 TODO comments from adblock implementation.
- Refactor shareFile() to detect files vs directories
- Add shareSingleFile() for individual file sharing with proper MIME types
- Add shareDirectory() to share all files in a directory as multiple streams
- Support CBZ, CBR, ZIP file types with appropriate MIME types
- Filter hidden files when sharing directory contents
- Add new MIME type constants: TYPE_CBR, TYPE_ZIP, TYPE_OCTET_STREAM

This allows sharing local manga stored as directories (containing images)
in addition to the existing CBZ file support.
ReadButtonDelegate - Missing chapter handling:
- Add 'Select chapter' action to Snackbar when chapter is missing
- Change Snackbar duration to LENGTH_LONG for better visibility
- User can now quickly navigate to chapter list to pick another chapter
- Add 'select_chapter' string resource

CaptchaHandler - Clarify request retry:
- Replace ambiguous 'TODO check if ok' with explanatory comment
- Document that re-enqueuing request after captcha resolution is correct

DownloadNotificationFactory - Document cache behavior:
- Add comment explaining covers HashMap is bounded by active downloads
- Cache is simple and appropriate for notification icon use case

Removes 3 TODO comments with meaningful improvements.
- Updated from commit hash e205a8706e to tagged release 1.2
- Includes latest parser fixes and new source support from YakaTeam fork
- Tagged releases provide better stability than commit hashes
- Added KEY_JS_TIMEOUT setting with default of 4000ms (range: 2000-30000ms)
- Inject AppSettings into MangaLoaderContextImpl
- Use dynamic jsTimeoutMs property instead of hardcoded 4 seconds
- Helps with complex CloudFlare challenges that need more time to resolve
- Removed unused TimeUnit import
- Added BitmapCompressFormat enum with PNG, JPEG, WEBP, WEBP_LOSSLESS options
- Added overloaded compressTo() with format and quality parameters
- Maintains backward compatibility with original compressTo() method
- Handles API level differences for WebP formats gracefully
- Quality parameter (0-100) for lossy formats, ignored for lossless
- Better compression choices: JPEG for photos, WebP for modern efficiency
- Persist failed mirror sources to SharedPreferences across app restarts
- Add 24-hour TTL for blacklist entries (auto-expire and retry)
- Add clearBlacklist() method to manually reset all failed sources
- Add removeFromBlacklist() for individual source removal
- Add blacklistedSources property to query current blacklist state
- Load blacklist on init, cleanup expired entries before each check
- Handle unknown/removed sources gracefully during storage load
- Added @singleton annotation for proper DI lifecycle
ExternalPluginContentSource:
- Added getRelatedManga() method to query related manga from plugins
- Uses content URI: content://{authority}/manga/related/{url}
- Gracefully returns empty list if plugin doesn't support this feature
- Added COLUMN_RELATED_MANGA constant for capability detection

MangaSourceCapabilities:
- Added isRelatedMangaSupported flag (default: false for compatibility)
- Read from capabilities cursor during plugin initialization

ExternalMangaRepository:
- Updated getRelatedMangaImpl() to use plugin's related manga feature
- Checks capability before making content provider query
- Maintains backward compatibility with plugins that don't support it
- Configurable max retries (default: 3 attempts)
- Exponential backoff with jitter to prevent thundering herd
- Respects Retry-After header when present, caps at maxDelayMs
- Calculated delay formula: min(maxDelay, initialDelay * 2^retryCount) ± 25% jitter
- Default delays: 1s initial, 30s max, 2x multiplier
- Debug logging for retry attempts
- Fixed parseRetryAfter to handle HTTP date format properly
- Only throws TooManyRequestExceptions after all retries exhausted
ProxyBlacklistManager (new):
- Singleton class managing persistent host blacklist
- SharedPreferences storage with timestamps for TTL
- 6-hour expiration for blacklist entries
- Thread-safe with synchronized access
- Methods: isBlacklisted(), addToBlacklist(), removeFromBlacklist(), clearBlacklist()

BaseImageProxyInterceptor:
- Now accepts optional ProxyBlacklistManager parameter
- Removed in-memory ArraySet blacklist
- Delegates to manager for blacklist operations
- Backward compatible with null manager

WsrvNlProxyInterceptor / ZeroMsProxyInterceptor:
- Updated constructors to accept blacklist manager

RealImageProxyInterceptor:
- Injects ProxyBlacklistManager via Hilt
- Passes manager to child interceptors on creation
AppSettings:
- Added KEY_CACHE_DETAILS_TTL (default: 5 min, range: 1-60)
- Added KEY_CACHE_PAGES_TTL (default: 10 min, range: 1-120)
- Added KEY_CACHE_RELATED_TTL (default: 10 min, range: 1-120)
- Added getter properties with coerceIn bounds validation

MemoryContentCache:
- Now injects AppSettings for TTL configuration
- Uses configurable TTL values instead of hardcoded
- Added KDoc explaining settings and restart requirement
- Reformatted cache initialization for clarity

Note: Changes to cache TTL settings require app restart to take effect.
AppSettings:
- Added KEY_TRACKER_PARALLELISM setting (default: 6, range: 1-12)
- Added DEFAULT_TRACKER_PARALLELISM constant

CheckNewChaptersUseCase:
- Added checkBatch() method returning Flow<MangaUpdates>
- Parallel execution with configurable semaphore
- Maintains per-manga mutex locking for thread safety
- Added DEFAULT_PARALLELISM and MAX_PARALLELISM constants

TrackWorker:
- Now uses checkBatch() from CheckNewChaptersUseCase
- Reads parallelism from settings.trackerParallelism
- Removed redundant channelFlow/semaphore implementation
- Removed MAX_PARALLELISM constant (now in use case)
- Cleaned up unused imports
- Add NetworkQuality enum for quality levels (OFFLINE/POOR/MODERATE/GOOD/EXCELLENT)
- Add NetworkQualityMonitor for real-time network assessment
  - Monitors WiFi/cellular/ethernet connections
  - Tracks bandwidth via download samples
  - Measures latency periodically
  - Detects cellular network types (2G/3G/4G/5G)
- Add AdaptiveNetworkSettings for dynamic configuration
  - Adaptive timeouts based on network quality
  - Concurrent download limits
  - Preload page counts
  - Image quality reduction settings
  - Retry counts and delays
- Add BandwidthTrackingInterceptor for OkHttp
  - Tracks download speeds automatically
  - Reports to NetworkQualityMonitor for assessment
- Update NetworkState with transport type helpers
  - isWifi(), isCellular(), getTransportType()
- Integrate BandwidthTrackingInterceptor into MangaHttpClient

Features:
- Real-time network quality assessment
- Automatic bandwidth estimation from downloads
- Adaptive timeouts (10s-30s connect, 30s-90s read)
- Dynamic concurrent download limits (0-6)
- Preload page count adaptation (0-5)
- Observable network quality state
- Add DnsPrefetcher class implementing OkHttp Dns interface
  - Caches DNS results with 5-minute TTL
  - Proactive refresh before entries expire
  - Common CDN domains pre-configured
  - Observable cache statistics
- Add DnsPrefetchManager for manga source integration
  - Auto-prefetch domains for enabled sources
  - Prefetch when sources become enabled
  - Source-specific CDN domain support
- Integrate with existing DoH infrastructure
  - DnsPrefetcher wraps DoHManager as delegate
  - Seamless integration with existing DNS-over-HTTPS
- Initialize on app startup via BaseApp

Features:
- DNS cache with configurable TTL (5 min default)
- Background refresh 1 minute before expiry
- Prefetch for enabled manga source domains
- Common CDN domains (jsdelivr, cloudflare, googleapis)
- Source-specific CDN domains (MangaDex, Webtoon)
- Cache statistics for debugging
- Network-aware (skip when offline)
- Add ResumableDownloader for HTTP Range request support
  - Detects server support via Accept-Ranges header
  - Resumes partial downloads from last byte position
  - Falls back to full download if resume not supported
  - Validates Content-Range responses

- Add DownloadStateTracker for persistent download state
  - Tracks chapter download progress (completed pages)
  - Stores partial file information for resume
  - Automatically cleans up data older than 7 days
  - Thread-safe with mutex protection

- Integrate with DownloadWorker
  - Use resumable downloader for HTTP page downloads
  - Track partial files on download failure
  - Resume from partial files on retry
  - Clean up tracking after successful download
- Update Java compatibility from 11 to 17
- Optimize DnsPrefetchManager to prefetch on-demand
- Add more CDN domains for MangaKakalot and MangaSee sources
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant