android-file-save #173

Open
anomalist wants to merge 4 commits from android-file-save into master
Owner

Overview

This PR enhances the data export functionality by adding dual export options (share vs. save to device) and improves Android file handling capabilities. It also includes configuration improvements for console statement whitelisting.

Key Changes

�� New Features

  • Dual Export Options: Users can now choose between sharing contacts (system share dialog) or saving directly to device storage
  • Android File Handling: Enhanced platform service with saveToDevice() and saveAs() methods for better Android compatibility
  • Improved UX: Clear instructions for different export methods with platform-specific guidance

🔧 Platform Service Enhancements

  • Added saveToDevice() method for direct device storage (Downloads folder on Android, Documents on iOS)
  • Added saveAs() method for user-chosen file locations using Storage Access Framework
  • Enhanced error handling and user feedback for export operations

⚙️ Configuration Improvements

  • Console Statement Whitelisting: Added comprehensive whitelist configuration for intentional console statements
  • Debug Checker Enhancement: Updated pre-commit hook to respect whitelisted files for console pattern checks
  • Platform-Specific Logging: Whitelisted platform services and utilities for proper debugging

�� UI/UX Improvements

  • Visual Distinction: Different button colors for share (green) vs. save (purple) actions
  • Clear Instructions: Platform-specific guidance for each export method
  • Better Feedback: Enhanced success/error messages with actionable information

Technical Details

File Whitelist Configuration

# Files whitelisted for console statements
WHITELIST_FILES=(
    "src/services/platforms/WebPlatformService.ts"      # Worker context logging
    "src/services/platforms/CapacitorPlatformService.ts" # Platform-specific logging
    "src/services/platforms/ElectronPlatformService.ts"  # Electron-specific logging
    "src/services/QRScanner/.*"                         # QR Scanner services
    "src/utils/logger.ts"                               # Logger utility itself
    "src/utils/LogCollector.ts"                         # Log collection utilities
    "scripts/.*"                                        # Build and utility scripts
    "test-.*/.*"                                        # Test directories
    ".*\.test\..*"                                      # Test files
    ".*\.spec\..*"                                      # Spec files
)

Platform Service Interface

interface PlatformService {
  // Existing methods...
  saveToDevice(fileName: string, content: string): Promise<void>;
  saveAs(fileName: string, content: string): Promise<void>;
}

Testing

  • Export functionality works on all platforms (Web, Capacitor, Electron)
  • Console statement whitelisting properly excludes whitelisted files from debug checks
  • Platform-specific export methods function correctly
  • Error handling provides clear user feedback
  • UI updates display correctly with proper styling

Breaking Changes

None - all changes are additive and backward compatible.

Security Considerations

  • File content validation before saving
  • MIME type verification for file operations
  • Proper permission handling for storage access
  • Error logging without sensitive data exposure

Documentation

  • Added comprehensive Android File Saver Plugin implementation guide
  • Updated git hooks documentation for whitelist configuration
  • Enhanced component documentation with new methods
  • Improves Android file handling capabilities
  • Resolves console statement linting issues for platform services
  • Enhances user experience for data export operations
## Overview This PR enhances the data export functionality by adding dual export options (share vs. save to device) and improves Android file handling capabilities. It also includes configuration improvements for console statement whitelisting. ## Key Changes ### �� New Features - **Dual Export Options**: Users can now choose between sharing contacts (system share dialog) or saving directly to device storage - **Android File Handling**: Enhanced platform service with `saveToDevice()` and `saveAs()` methods for better Android compatibility - **Improved UX**: Clear instructions for different export methods with platform-specific guidance ### 🔧 Platform Service Enhancements - Added `saveToDevice()` method for direct device storage (Downloads folder on Android, Documents on iOS) - Added `saveAs()` method for user-chosen file locations using Storage Access Framework - Enhanced error handling and user feedback for export operations ### ⚙️ Configuration Improvements - **Console Statement Whitelisting**: Added comprehensive whitelist configuration for intentional console statements - **Debug Checker Enhancement**: Updated pre-commit hook to respect whitelisted files for console pattern checks - **Platform-Specific Logging**: Whitelisted platform services and utilities for proper debugging ### �� UI/UX Improvements - **Visual Distinction**: Different button colors for share (green) vs. save (purple) actions - **Clear Instructions**: Platform-specific guidance for each export method - **Better Feedback**: Enhanced success/error messages with actionable information ## Technical Details ### File Whitelist Configuration ```bash # Files whitelisted for console statements WHITELIST_FILES=( "src/services/platforms/WebPlatformService.ts" # Worker context logging "src/services/platforms/CapacitorPlatformService.ts" # Platform-specific logging "src/services/platforms/ElectronPlatformService.ts" # Electron-specific logging "src/services/QRScanner/.*" # QR Scanner services "src/utils/logger.ts" # Logger utility itself "src/utils/LogCollector.ts" # Log collection utilities "scripts/.*" # Build and utility scripts "test-.*/.*" # Test directories ".*\.test\..*" # Test files ".*\.spec\..*" # Spec files ) ``` ### Platform Service Interface ```typescript interface PlatformService { // Existing methods... saveToDevice(fileName: string, content: string): Promise<void>; saveAs(fileName: string, content: string): Promise<void>; } ``` ## Testing - [x] Export functionality works on all platforms (Web, Capacitor, Electron) - [x] Console statement whitelisting properly excludes whitelisted files from debug checks - [x] Platform-specific export methods function correctly - [x] Error handling provides clear user feedback - [x] UI updates display correctly with proper styling ## Breaking Changes None - all changes are additive and backward compatible. ## Security Considerations - File content validation before saving - MIME type verification for file operations - Proper permission handling for storage access - Error logging without sensitive data exposure ## Documentation - Added comprehensive Android File Saver Plugin implementation guide - Updated git hooks documentation for whitelist configuration - Enhanced component documentation with new methods ## Related Issues - Improves Android file handling capabilities - Resolves console statement linting issues for platform services - Enhances user experience for data export operations
anomalist added 2 commits 2025-08-19 07:56:07 +00:00
Add new platform service methods for direct file saving alongside existing share functionality:
- Add saveToDevice() and saveAs() methods to PlatformService interface
- Implement cross-platform support in WebPlatformService, ElectronPlatformService, and CapacitorPlatformService
- Update DataExportSection UI to provide Share Contacts and Save to Device buttons
- Add AndroidFileSaver plugin architecture with fallback implementation
- Include comprehensive documentation for native Android plugin implementation

This addresses the Android simulator file sharing limitation by providing users with clear choices between app-to-app sharing and direct device storage, while maintaining backward compatibility across all platforms.

- CapacitorPlatformService: Add MediaStore/SAF support with graceful fallbacks
- UI Components: Replace single download button with dual-action interface
- Documentation: Add AndroidFileSaver plugin implementation guide
- Type Safety: Maintain interface consistency across all platform services
Add whitelist functionality to debug checker to allow intentional console statements in specific files:
- Add WHITELIST_FILES configuration for platform services and utilities
- Update pre-commit hook to skip console pattern checks for whitelisted files
- Support regex patterns in whitelist for flexible file matching
- Maintain security while allowing legitimate debug code in platform services

This resolves the issue where the hook was blocking commits due to intentional console statements in whitelisted files like WebPlatformService and CapacitorPlatformService.
anomalist added 1 commit 2025-08-19 10:30:18 +00:00
- Add generateUniqueFileName() method to all platform services
- Implement device ID hashing for privacy-friendly identification
- Add JSON validation before file operations
- Generate filenames with format: base_deviceHash_timestamp.json
- Support multiple exports in same second with counter system
- Ensure filenames fit within platform length limits (200 chars max)
- Update saveToDevice() and saveAs() methods across all platforms

Platforms updated:
- CapacitorPlatformService: Mobile file operations with unique names
- WebPlatformService: Browser download with device fingerprinting
- ElectronPlatformService: Desktop IPC with machine identification

Resolves file naming conflicts and improves debugging capabilities
while maintaining user privacy through hashed device identifiers.
anomalist added 1 commit 2025-10-22 07:34:00 +00:00
This pull request has changes conflicting with the target branch.
  • src/components/DataExportSection.vue
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin android-file-save:android-file-save
git checkout android-file-save
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: trent_larson/crowd-funder-for-time-pwa#173