Skip to content

Commit ab03207

Browse files
author
chimnayajith
committed
feat: add download button to lightbox to bottom app bar
1 parent 28b3536 commit ab03207

16 files changed

+373
-1
lines changed

android/app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
https://developer.android.com/build/manage-manifests#inspect_the_merged_manifest_and_find_conflicts -->
55
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
66
<uses-permission android:name="android.permission.INTERNET"/>
7+
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
78
<application
89
android:label="Zulip beta"
910
android:name="${applicationName}"
Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,39 @@
11
package com.zulip.flutter
22

3+
import android.media.MediaScannerConnection
4+
import android.net.Uri
35
import io.flutter.embedding.android.FlutterActivity
6+
import io.flutter.embedding.engine.FlutterEngine
7+
import io.flutter.plugin.common.MethodChannel
48

5-
class MainActivity: FlutterActivity() {
9+
class MainActivity : FlutterActivity() {
10+
private val CHANNEL = "gallery_saver"
11+
12+
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
13+
super.configureFlutterEngine(flutterEngine)
14+
15+
MethodChannel(flutterEngine.dartExecutor.binaryMessenger, CHANNEL).setMethodCallHandler { call, result ->
16+
if (call.method == "scanFile") {
17+
val filePath = call.argument<String>("path")
18+
if (filePath != null) {
19+
scanFile(filePath)
20+
result.success("MediaScanner invoked for $filePath")
21+
} else {
22+
result.error("INVALID_ARGUMENT", "File path is null", null)
23+
}
24+
} else {
25+
result.notImplemented()
26+
}
27+
}
28+
}
29+
30+
private fun scanFile(filePath: String) {
31+
MediaScannerConnection.scanFile(
32+
applicationContext,
33+
arrayOf(filePath),
34+
null
35+
) { _, _ ->
36+
// Intentionally left empty
37+
}
38+
}
639
}

assets/l10n/app_en.arb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,22 @@
395395
"@lightboxCopyLinkTooltip": {
396396
"description": "Tooltip in lightbox for the copy link action."
397397
},
398+
"lightboxDownloadImageTooltip": "Download image",
399+
"@lightboxDownloadImageTooltip": {
400+
"description": "Tooltip in lightbox for the download image action."
401+
},
402+
"lightboxDownloadImageSuccess": "Image downloaded successfully!",
403+
"@lightboxDownloadImageSuccess": {
404+
"description": "Message shown when the image downloads successfully."
405+
},
406+
"lightboxDownloadImageFailed": "Failed to download the image.",
407+
"@lightboxDownloadImageFailed": {
408+
"description": "Message shown when the image download fails."
409+
},
410+
"lightboxDownloadImageError": "An error occurred while downloading the image.",
411+
"@lightboxDownloadImageError": {
412+
"description": "Message shown when an unexpected error occurs during image download."
413+
},
398414
"loginPageTitle": "Log in",
399415
"@loginPageTitle": {
400416
"description": "Title for login page."

lib/generated/l10n/zulip_localizations.dart

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,30 @@ abstract class ZulipLocalizations {
631631
/// **'Copy link'**
632632
String get lightboxCopyLinkTooltip;
633633

634+
/// Tooltip in lightbox for the download image action.
635+
///
636+
/// In en, this message translates to:
637+
/// **'Download image'**
638+
String get lightboxDownloadImageTooltip;
639+
640+
/// Message shown when the image downloads successfully.
641+
///
642+
/// In en, this message translates to:
643+
/// **'Image downloaded successfully!'**
644+
String get lightboxDownloadImageSuccess;
645+
646+
/// Message shown when the image download fails.
647+
///
648+
/// In en, this message translates to:
649+
/// **'Failed to download the image.'**
650+
String get lightboxDownloadImageFailed;
651+
652+
/// Message shown when an unexpected error occurs during image download.
653+
///
654+
/// In en, this message translates to:
655+
/// **'An error occurred while downloading the image.'**
656+
String get lightboxDownloadImageError;
657+
634658
/// Title for login page.
635659
///
636660
/// In en, this message translates to:

lib/generated/l10n/zulip_localizations_ar.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,18 @@ class ZulipLocalizationsAr extends ZulipLocalizations {
310310
@override
311311
String get lightboxCopyLinkTooltip => 'Copy link';
312312

313+
@override
314+
String get lightboxDownloadImageTooltip => 'Download image';
315+
316+
@override
317+
String get lightboxDownloadImageSuccess => 'Image downloaded successfully!';
318+
319+
@override
320+
String get lightboxDownloadImageFailed => 'Failed to download the image.';
321+
322+
@override
323+
String get lightboxDownloadImageError => 'An error occurred while downloading the image.';
324+
313325
@override
314326
String get loginPageTitle => 'Log in';
315327

lib/generated/l10n/zulip_localizations_en.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,18 @@ class ZulipLocalizationsEn extends ZulipLocalizations {
310310
@override
311311
String get lightboxCopyLinkTooltip => 'Copy link';
312312

313+
@override
314+
String get lightboxDownloadImageTooltip => 'Download image';
315+
316+
@override
317+
String get lightboxDownloadImageSuccess => 'Image downloaded successfully!';
318+
319+
@override
320+
String get lightboxDownloadImageFailed => 'Failed to download the image.';
321+
322+
@override
323+
String get lightboxDownloadImageError => 'An error occurred while downloading the image.';
324+
313325
@override
314326
String get loginPageTitle => 'Log in';
315327

lib/generated/l10n/zulip_localizations_fr.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,18 @@ class ZulipLocalizationsFr extends ZulipLocalizations {
310310
@override
311311
String get lightboxCopyLinkTooltip => 'Copy link';
312312

313+
@override
314+
String get lightboxDownloadImageTooltip => 'Download image';
315+
316+
@override
317+
String get lightboxDownloadImageSuccess => 'Image downloaded successfully!';
318+
319+
@override
320+
String get lightboxDownloadImageFailed => 'Failed to download the image.';
321+
322+
@override
323+
String get lightboxDownloadImageError => 'An error occurred while downloading the image.';
324+
313325
@override
314326
String get loginPageTitle => 'Log in';
315327

lib/generated/l10n/zulip_localizations_ja.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,18 @@ class ZulipLocalizationsJa extends ZulipLocalizations {
310310
@override
311311
String get lightboxCopyLinkTooltip => 'Copy link';
312312

313+
@override
314+
String get lightboxDownloadImageTooltip => 'Download image';
315+
316+
@override
317+
String get lightboxDownloadImageSuccess => 'Image downloaded successfully!';
318+
319+
@override
320+
String get lightboxDownloadImageFailed => 'Failed to download the image.';
321+
322+
@override
323+
String get lightboxDownloadImageError => 'An error occurred while downloading the image.';
324+
313325
@override
314326
String get loginPageTitle => 'Log in';
315327

lib/generated/l10n/zulip_localizations_pl.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,18 @@ class ZulipLocalizationsPl extends ZulipLocalizations {
310310
@override
311311
String get lightboxCopyLinkTooltip => 'Skopiuj odnośnik';
312312

313+
@override
314+
String get lightboxDownloadImageTooltip => 'Download image';
315+
316+
@override
317+
String get lightboxDownloadImageSuccess => 'Image downloaded successfully!';
318+
319+
@override
320+
String get lightboxDownloadImageFailed => 'Failed to download the image.';
321+
322+
@override
323+
String get lightboxDownloadImageError => 'An error occurred while downloading the image.';
324+
313325
@override
314326
String get loginPageTitle => 'Zaloguj';
315327

lib/generated/l10n/zulip_localizations_ru.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,18 @@ class ZulipLocalizationsRu extends ZulipLocalizations {
310310
@override
311311
String get lightboxCopyLinkTooltip => 'Copy link';
312312

313+
@override
314+
String get lightboxDownloadImageTooltip => 'Download image';
315+
316+
@override
317+
String get lightboxDownloadImageSuccess => 'Image downloaded successfully!';
318+
319+
@override
320+
String get lightboxDownloadImageFailed => 'Failed to download the image.';
321+
322+
@override
323+
String get lightboxDownloadImageError => 'An error occurred while downloading the image.';
324+
313325
@override
314326
String get loginPageTitle => 'Log in';
315327

0 commit comments

Comments
 (0)