Skip to content

Add 'Export rules' and 'Import rules' feature #3

@yogesh-7

Description

@yogesh-7

📦 Import / Export Rules

Users who reinstall the app or switch devices currently lose all their per-app rules. Add the ability to export and import the rule set as a JSON file.

Requirements

Export

  • Button in SettingsScreen.kt: Export rules
  • Serialize all AppRule entries from Room into JSON
  • Save via ACTION_CREATE_DOCUMENT system picker
  • Format suggestion:
    {
      "version": 1,
      "exportedAt": "2026-04-15T10:00:00Z",
      "rules": [
        { "packageName": "com.example", "wifiAllowed": true, "mobileAllowed": false }
      ]
    }

Import

  • Button: Import rules
  • Open file via ACTION_OPEN_DOCUMENT
  • Validate JSON schema
  • Confirm dialog: "This will overwrite your current rules. Continue?"
  • Upsert rules into Room
  • Trigger VPN tunnel rebuild

Edge Cases

  • Invalid JSON → show error toast
  • Missing packages (app uninstalled) → skip silently or log
  • Schema version mismatch → show friendly error

Hints

  • Use kotlinx.serialization (add as dependency)
  • Access repository via SettingsViewModel
  • File IO with ActivityResultContracts.CreateDocument / OpenDocument

Medium difficulty — great for someone wanting to touch persistence, UI, and Android file APIs!

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthacktoberfestGood for Hacktoberfest contributorshelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions