Skip to content

Conversation

@optiix
Copy link
Contributor

@optiix optiix commented Nov 5, 2025

WebDrop Feature - LAN-based Playlist Upload

• Adds a new "WebDrop" option to the Playlist Management data source dropdown

• Allows users to upload M3U playlists through a web browser instead of typing on TV remote

• Embedded web server runs on port 8080 and displays the device's local IP address (e.g., http://192.168.1.x:8080)

• Three upload methods supported: File upload (drag-and-drop or browse), URL import, and Xtream codes input

• Maximum file size: 400MB for M3U/M3U8 files

• Real-time server status indicator showing running/stopped/error states with color-coded UI

• One-tap URL copying to clipboard for easy sharing

• Responsive Material3 web interface that works on any device with a browser (phone, tablet, laptop)

• Automatic emulator detection for development testing (shows localhost + supports adb port forwarding)

• Reuses existing M3U and Xtream parsers - no duplication of parsing logic

• Built with Ktor 3.3.1 CIO engine (pure Kotlin, Android-compatible)

• Full multi-language support across 11 locales

• Follows Material3 design system matching existing app themes

• Start/Stop server controls directly in the app settings

• Server automatically binds to all network interfaces (0.0.0.0) for LAN accessibility

optiix and others added 6 commits November 4, 2025 20:56
Added complete Swedish translation with 203 strings across 11 XML files:
- ui.xml (20 strings) - Main UI navigation
- feat_stream.xml (21 strings) - Video player controls
- feat_playlist.xml (13 strings) - Playlist management
- feat_setting.xml (106 strings) - Settings
- feat_foryou.xml (14 strings) - Home screen
- feat_playlist_configuration.xml (9 strings)
- data.xml (9 strings) - Notifications
- app.xml (7 strings) - App-level resources
- feat_favourite.xml (2 strings)
- feat_console.xml (1 string)
- feat_about.xml (1 string)

Technical terms (M3U, EPG, IPTV, DLNA) preserved.
All format placeholders and markdown formatting maintained.
Implements a new "WebDrop" data source that allows users to upload M3U playlists
through a web browser on their local network, eliminating the need to type on TV remotes.

Features:
- Embedded Ktor CIO web server running on port 8080
- Responsive Material3 web UI with drag-and-drop support
- Three upload methods: file upload (400MB max), URL import, Xtream codes
- Real-time server status display with URL copy functionality
- Automatic emulator detection (shows localhost for testing)
- Full integration with existing M3U and Xtream parsers
- Material3 Compose UI following existing design patterns
- Multi-language support (11 locales)

Technical implementation:
- Repository pattern with WebServerRepository interface
- StateFlow-based reactive state management
- Ktor 3.3.1 CIO engine (Android-compatible, pure Kotlin)
- ADB port forwarding support for emulator testing
- CORS and content negotiation middleware
- Integration with PlaylistRepository.m3uOrThrow() and xtreamOrThrow()

Also removes broken French translations containing invalid unicode escape sequences.
This commit adds two major security and convenience features:

## USB Encryption Feature
- Encrypt entire database using USB stick as physical key
- Military-grade AES-256-GCM encryption with PBKDF2 key derivation
- Supports both TV and smartphone apps
- Lock screen when USB is removed
- USB device monitoring and management
- Warning dialogs for encryption enable/disable
- Multi-language support for all USB encryption strings

Files:
- USBKeyRepository: Core USB device detection and encryption management
- DatabaseMigrationHelper: Handles SQLCipher database encryption
- SecuritySection (TV): Material3 TV-optimized UI
- SecurityFragment (smartphone): Material Design UI
- USBLockScreen: Full-screen lock when USB removed
- USB permissions in AndroidManifest

## WebDrop Feature Integration
- Server-side file upload handling (already implemented)
- UI integration for WebDrop in settings
- Multi-language support

Dependencies:
- SQLCipher for Android 4.6.1
- USB Host API support

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
…h enterprise-level improvements

This commit introduces two major features along with critical bug fixes for production stability:

## 1. WebDrop Feature - Embedded Web Server for Playlist Management
- Implemented Ktor-based embedded web server for remote playlist uploads
- Web interface accessible at http://[device-ip]:8080 for easy file uploads
- Three import methods supported:
  * File upload (M3U/M3U8 files up to 400MB)
  * URL import (remote M3U playlist URLs)
  * Xtream Codes API import (username/password authentication)
- Enhanced upload.html with modern responsive UI
- Real-time playlist status endpoint at /status
- Automatic playlist parsing and channel import on upload

## 2. PIN-Based Database Encryption with SQLCipher
- Full Room database encryption using SQLCipher 4.5.x
- 6-digit PIN authentication system with unlock screen
- Secure key derivation using Android Keystore (AES-256-GCM)
- PBKDF2 with SHA-256 for PIN-to-key conversion (100,000 iterations)
- UnlockManager for app-wide authentication state management
- PIN unlock screen blocks app access until authentication succeeds
- Encryption status dashboard showing health metrics
- Database migration support for upgrading unencrypted to encrypted DBs
- USB key storage for encryption keys

## 3. Enterprise-Level Network Timeout Fixes
- Fixed SocketTimeoutException for large M3U playlist downloads
- Configured OkHttp timeouts for slow M3U servers:
  * connectTimeout: 30 seconds (slow networks)
  * readTimeout: 90 seconds (critical for slow servers)
  * writeTimeout: 30 seconds (sufficient for GET requests)
  * callTimeout: 5 minutes (total max time for large downloads)
- Comprehensive error handling with proper HTTP status codes (408, 503, 500)
- Detailed error logging with timing metrics for debugging
- Streaming-aware timeout configuration (readTimeout resets per data chunk)

## 4. Android TV Compatibility Fixes
- Fixed ActivityNotFoundException crash on TV startup
- Wrapped MANAGE_ALL_FILES_ACCESS_PERMISSION request in try-catch
- TV devices skip this permission gracefully (not supported on Android TV)
- App can still access cache/data directories without this permission

## 5. File Upload Path Fix
- Fixed WebServerRepositoryImpl.kt file path handling
- Changed from absolute path to proper file:// URI scheme
- Ensures uploaded files are correctly recognized by playlist parser

## 6. Enhanced Logging and Debugging
- Added comprehensive logging to M3UParserImpl for stream debugging
- Enhanced PlaylistRepositoryImpl logging for input stream tracking
- OkHttp interceptor logs request/response timing and payload sizes
- Timber-based structured logging with component-specific tags

## Files Changed:
- app/tv/MainActivity.kt: Added PIN unlock authentication gate
- data/api/ApiModule.kt: Enterprise-level timeout configuration
- data/database/DatabaseModule.kt: SQLCipher integration
- data/repository/webserver/WebServerRepositoryImpl.kt: File URI fix
- business/setting/UnlockManager.kt: Authentication state manager
- data/security/PINKeyManager.kt: Secure key management with Android Keystore
- app/tv/screens/security/PINUnlockScreen.kt: 6-digit PIN input UI
- app/tv/screens/security/EncryptionStatusDashboard.kt: Health monitoring UI
- data/repository/usbkey/USBKeyRepositoryImpl.kt: USB key storage
@oxyroid
Copy link
Owner

oxyroid commented Nov 7, 2025

Sorry I have closed this PR because AI coding is not allowed in the project.

@optiix
Copy link
Contributor Author

optiix commented Nov 7, 2025

AI-assisted coding is really just the next evolution of programming tools, like how C++ or C# abstracted things before. In the end, all code still compiles down to the same machine instructions (Machine code) anyway. Same thing, faster dev. :)

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.

2 participants