Skip to content

Replace native Android AlertDialog with Flutter showDialog - #2

Draft
MeowTechOpenSource with Copilot wants to merge 4 commits into
mainfrom
copilot/use-flutter-for-message-display
Draft

Replace native Android AlertDialog with Flutter showDialog#2
MeowTechOpenSource with Copilot wants to merge 4 commits into
mainfrom
copilot/use-flutter-for-message-display

Conversation

Copilot AI commented Mar 20, 2026

Copy link
Copy Markdown
Contributor

The warning dialog was implemented in Java via a MethodChannel, coupling the UI to the Android native layer. This moves all dialog logic to Dart using Flutter's built-in showDialog, and ports all upstream localizations into a Flutter-native localization class.

Changes

  • lib/free_droid_warn.dart: Removed MethodChannel. showWarningOnUpgrade now accepts a BuildContext and renders a Flutter AlertDialog directly. Version tracking uses shared_preferences; URL launching uses url_launcher with canLaunchUrl guard. Dialog strings are resolved from the device locale via FreeDroidWarnLocalizations.of(context).
  • lib/src/free_droid_warn_localizations.dart: New file containing all translations ported from the upstream Android XML string resources. Supports Arabic, Czech, German, Greek, English, Spanish, French, Hindi, Hungarian, Indonesian, Italian, Japanese, Korean, Dutch, Polish, Portuguese, Russian, Slovak, Swedish, Turkish, Chinese Simplified, and Chinese Traditional. Falls back to English for unsupported languages. Chinese variants are resolved by scriptCode first (Hans/Hant), then by country code (TW, HK, MO → Traditional; all others → Simplified).
  • pubspec.yaml: Added shared_preferences: ^2.2.2 and url_launcher: ^6.2.0.
  • android/.../FreeDroidWarnPlugin.java: Reduced to a no-op FlutterPlugin stub — all dialog, SharedPreferences, and Activity logic removed.
  • example/lib/main.dart: Updated call sites to pass BuildContext as the new first parameter.

API change

// Before
FreeDroidWarn.showWarningOnUpgrade(buildVersion);

// After — BuildContext required for Flutter dialog
FreeDroidWarn.showWarningOnUpgrade(context, buildVersion);

Note: Existing users who dismissed the dialog under the old native implementation will see it once more after upgrading, because the Flutter shared_preferences key (flutter.versionCodeWarn) differs from the Android-native key (free_droid_warn / versionCodeWarn).


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Co-authored-by: MeowTechOpenSource <57005629+MeowTechOpenSource@users.noreply.github.com>
Copilot AI changed the title [WIP] Update message display to use Flutter instead of native library Replace native Android AlertDialog with Flutter showDialog Mar 20, 2026
@MeowTechOpenSource

Copy link
Copy Markdown
Member

@copilot Add back the localozations from upstream.

Co-authored-by: MeowTechOpenSource <57005629+MeowTechOpenSource@users.noreply.github.com>

Copilot AI commented Mar 20, 2026

Copy link
Copy Markdown
Contributor Author

@copilot Add back the localozations from upstream.

Done in commit 42dfaf5. Added lib/src/free_droid_warn_localizations.dart containing all 19 translations (ar, cs, de, el, es, fr, hi, hu, id, it, ja, ko, nl, pl, pt, ru, sk, sv, tr + en fallback) ported verbatim from the upstream Android XML string resources. showWarningOnUpgrade now calls FreeDroidWarnLocalizations.of(context) to pick the right strings for the device locale before showing the dialog, falling back to English for unsupported languages.

@MeowTechOpenSource

Copy link
Copy Markdown
Member

Add back zh different localozations by pulling from the upstream repo. @copilot

Copilot AI commented Mar 22, 2026

Copy link
Copy Markdown
Contributor Author

Add back zh different localozations by pulling from the upstream repo. @copilot

Done in commit 1e86ac6. Added zh-Hans (Simplified) and zh-Hant (Traditional) to FreeDroidWarnLocalizations, with strings pulled verbatim from the upstream woheller69/FreeDroidWarn repo. The locale is resolved by checking scriptCode first (Hans/Hant), then falling back to country code — TW, HK, and MO map to Traditional; all other zh locales (e.g. CN, SG) map to Simplified.

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