diff --git a/CHANGELOG.md b/CHANGELOG.md index 9321d3b..cb61a28 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG +## 1.1.0+6 +* Only copy multipaste link if multi box checked +* Add copy to clipboard shortcut in history view + ## 1.1.0+5 * Replace API key login with username and password login: a valid API key will automatically be created on login diff --git a/README.md b/README.md index 1ad84de..80cbedf 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ A mobile flutter app for [FileBin](https://github.com/Bluewind/filebin). +Available on the [Play Store](https://play.google.com/store/apps/details?id=de.varakh.fbmobile). + ## Getting Started This project is a starting point for a Flutter application. diff --git a/assets/i18n/en.json b/assets/i18n/en.json index 7ca5d32..21516a1 100644 --- a/assets/i18n/en.json +++ b/assets/i18n/en.json @@ -71,6 +71,11 @@ "link": "Link", "date": "Date", "open_link": "Open in browser", + "copy_link": { + "description": "Copy link", + "dismiss": "Dismiss", + "copied": "Copied link to clipboard." + }, "mimetype": "Mimetype", "delete": "Delete permanently", "multipaste_element": "Included as multipaste item", diff --git a/lib/core/viewmodels/upload_model.dart b/lib/core/viewmodels/upload_model.dart index ed5845f..f44891d 100644 --- a/lib/core/viewmodels/upload_model.dart +++ b/lib/core/viewmodels/upload_model.dart @@ -146,11 +146,11 @@ class UploadModel extends BaseModel { setState(ViewState.Idle); } - Future> upload() async { + Future> upload() async { setState(ViewState.Busy); setStateMessage(translate('upload.uploading_now')); - List uploadedPasteIds = []; + Map uploadedPasteIds = new Map(); try { List files; Map additionalFiles; @@ -165,11 +165,13 @@ class UploadModel extends BaseModel { } UploadedResponse response = await _fileService.upload(files, additionalFiles); - uploadedPasteIds.addAll(response.data.ids); + response.data.ids.forEach((element) { + uploadedPasteIds.putIfAbsent(element, () => false); + }); if (createMulti && response.data.ids.length > 1) { UploadedMultiResponse multiResponse = await _fileService.createMulti(response.data.ids); - uploadedPasteIds.add(multiResponse.data.urlId); + uploadedPasteIds.putIfAbsent(multiResponse.data.urlId, () => true); } clearCachedFiles(); diff --git a/lib/ui/views/history_view.dart b/lib/ui/views/history_view.dart index 52a11c3..b04fe89 100644 --- a/lib/ui/views/history_view.dart +++ b/lib/ui/views/history_view.dart @@ -1,3 +1,4 @@ +import 'package:clipboard/clipboard.dart'; import 'package:expandable/expandable.dart'; import 'package:flutter/material.dart'; import 'package:flutter_translate/flutter_translate.dart'; @@ -33,7 +34,7 @@ class HistoryView extends StatelessWidget { : (model.errorMessage == null ? Container( padding: EdgeInsets.all(0), - child: RefreshIndicator(onRefresh: () => model.getHistory(), child: _render(model, url))) + child: RefreshIndicator(onRefresh: () => model.getHistory(), child: _render(model, url, context))) : Container( padding: EdgeInsets.all(25), child: CenteredErrorRow( @@ -43,7 +44,7 @@ class HistoryView extends StatelessWidget { ); } - Widget _render(HistoryModel model, String url) { + Widget _render(HistoryModel model, String url, BuildContext context) { List cards = List(); if (model.pastes.length > 0) { @@ -63,6 +64,27 @@ class HistoryView extends StatelessWidget { trailing: openInBrowserButton, ); + var copyWidget = ListTile( + title: Text(translate('history.copy_link.description')), + trailing: IconButton( + icon: Icon(Icons.copy, color: Colors.blue, textDirection: TextDirection.ltr), + onPressed: () { + FlutterClipboard.copy(fullPasteUrl).then((value) { + final snackBar = SnackBar( + action: SnackBarAction( + label: translate('history.copy_link.dismiss'), + textColor: Colors.blue, + onPressed: () { + Scaffold.of(context).hideCurrentSnackBar(); + }, + ), + content: Text(translate('history.copy_link.copied')), + duration: Duration(seconds: 10), + ); + Scaffold.of(context).showSnackBar(snackBar); + }); + })); + var deleteWidget = ListTile( title: Text(translate('history.delete')), trailing: IconButton( @@ -105,6 +127,7 @@ class HistoryView extends StatelessWidget { widgets.add(dateWidget); widgets.add(linkWidget); + widgets.add(copyWidget); widgets.add(deleteWidget); var expandable = ExpandableTheme( diff --git a/lib/ui/views/upload_view.dart b/lib/ui/views/upload_view.dart index 0bcb07a..84d49be 100644 --- a/lib/ui/views/upload_view.dart +++ b/lib/ui/views/upload_view.dart @@ -103,12 +103,14 @@ class UploadView extends StatelessWidget { ), color: primaryAccentColor, onPressed: () async { - List items = await model.upload(); + Map items = await model.upload(); if (items != null) { var clipboardContent = ''; - items.forEach((element) { - clipboardContent += '$url/$element\n'; + items.forEach((id, isMulti) { + if (isMulti && model.createMulti || !isMulti && !model.createMulti) { + clipboardContent += '$url/$id\n'; + } }); FlutterClipboard.copy(clipboardContent).then((value) { diff --git a/pubspec.yaml b/pubspec.yaml index 7490299..ea9a0aa 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -11,7 +11,7 @@ description: A mobile client for FileBin. # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 1.1.0+5 +version: 1.2.0+6 environment: sdk: ">=2.7.0 <3.0.0"