Automatic refresh history if something has been uploaded and add fastlane alpha and debug

This commit is contained in:
Varakh 2021-02-04 01:07:03 +01:00
parent 162137ee10
commit 1adf487782
11 changed files with 102 additions and 31 deletions

View file

@ -1,4 +1,7 @@
# CHANGELOG # CHANGELOG
## 1.0.0+2
* Automatic refresh history if something has been uploaded
## 1.0.0+1 ## 1.0.0+1
* Initial release * Initial release

View file

@ -1,11 +1,22 @@
default_platform(:android) default_platform(:android)
platform :android do platform :android do
desc "Build Debug"
lane :build_debug do
sh("#{ENV['PWD']}/fastlane/buildAndroidDebug.sh")
end
desc "Build" desc "Build"
lane :build do lane :build do
sh("#{ENV['PWD']}/fastlane/buildAndroid.sh") sh("#{ENV['PWD']}/fastlane/buildAndroid.sh")
end end
desc "Deploy a new version to the Google Play as Alpha"
lane :alpha do
build
upload_to_play_store(track: 'alpha', aab: '../build/app/outputs/bundle/release/app-release.aab')
end
desc "Deploy a new version to the Google Play as Beta" desc "Deploy a new version to the Google Play as Beta"
lane :beta do lane :beta do
build build

View file

@ -16,11 +16,21 @@ or alternatively using `brew install fastlane`
# Available Actions # Available Actions
## Android ## Android
### android build_debug
```
fastlane android build_debug
```
Build Debug
### android build ### android build
``` ```
fastlane android build fastlane android build
``` ```
Build Build
### android alpha
```
fastlane android alpha
```
Deploy a new version to the Google Play as Alpha
### android beta ### android beta
``` ```
fastlane android beta fastlane android beta

View file

@ -4,11 +4,13 @@ import 'package:flutter_translate/localization_provider.dart';
import 'package:flutter_translate/localized_app.dart'; import 'package:flutter_translate/localized_app.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'core/enums/refresh_event.dart';
import 'core/manager/dialog_manager.dart'; import 'core/manager/dialog_manager.dart';
import 'core/manager/lifecycle_manager.dart'; import 'core/manager/lifecycle_manager.dart';
import 'core/models/session.dart'; import 'core/models/session.dart';
import 'core/services/dialog_service.dart'; import 'core/services/dialog_service.dart';
import 'core/services/navigation_service.dart'; import 'core/services/navigation_service.dart';
import 'core/services/refresh_service.dart';
import 'core/services/session_service.dart'; import 'core/services/session_service.dart';
import 'locator.dart'; import 'locator.dart';
import 'ui/app_router.dart'; import 'ui/app_router.dart';
@ -22,6 +24,9 @@ class MyApp extends StatelessWidget {
return LocalizationProvider( return LocalizationProvider(
state: LocalizationProvider.of(context).state, state: LocalizationProvider.of(context).state,
child: StreamProvider<RefreshEvent>(
initialData: null,
create: (context) => locator<RefreshService>().refreshHistoryController.stream,
child: StreamProvider<Session>( child: StreamProvider<Session>(
initialData: Session.initial(), initialData: Session.initial(),
create: (context) => locator<SessionService>().sessionController.stream, create: (context) => locator<SessionService>().sessionController.stream,
@ -40,6 +45,6 @@ class MyApp extends StatelessWidget {
supportedLocales: localizationDelegate.supportedLocales, supportedLocales: localizationDelegate.supportedLocales,
locale: localizationDelegate.currentLocale, locale: localizationDelegate.currentLocale,
)), )),
)); )));
} }
} }

View file

@ -0,0 +1 @@
enum RefreshEvent { RefreshHistory }

View file

@ -0,0 +1,13 @@
import 'dart:async';
import '../enums/refresh_event.dart';
class RefreshService {
StreamController<RefreshEvent> refreshHistoryController = StreamController<RefreshEvent>();
void addEvent(RefreshEvent event) {
if (refreshHistoryController.hasListener) {
refreshHistoryController.add(event);
}
}
}

View file

@ -1,3 +1,4 @@
import 'dart:async';
import 'dart:io'; import 'dart:io';
import 'package:flutter_translate/flutter_translate.dart'; import 'package:flutter_translate/flutter_translate.dart';
@ -6,6 +7,7 @@ import 'package:logger/logger.dart';
import '../../locator.dart'; import '../../locator.dart';
import '../datamodels/dialog_response.dart'; import '../datamodels/dialog_response.dart';
import '../enums/error_code.dart'; import '../enums/error_code.dart';
import '../enums/refresh_event.dart';
import '../enums/viewstate.dart'; import '../enums/viewstate.dart';
import '../error/rest_service_exception.dart'; import '../error/rest_service_exception.dart';
import '../error/service_exception.dart'; import '../error/service_exception.dart';
@ -15,18 +17,30 @@ import '../models/uploaded_paste.dart';
import '../services/dialog_service.dart'; import '../services/dialog_service.dart';
import '../services/file_service.dart'; import '../services/file_service.dart';
import '../services/link_service.dart'; import '../services/link_service.dart';
import '../services/refresh_service.dart';
import '../util/logger.dart'; import '../util/logger.dart';
import 'base_model.dart'; import 'base_model.dart';
class HistoryModel extends BaseModel { class HistoryModel extends BaseModel {
final Logger _logger = getLogger(); final Logger _logger = getLogger();
final FileService _fileService = locator<FileService>(); final FileService _fileService = locator<FileService>();
final RefreshService _refreshService = locator<RefreshService>();
final LinkService _linkService = locator<LinkService>(); final LinkService _linkService = locator<LinkService>();
final DialogService _dialogService = locator<DialogService>(); final DialogService _dialogService = locator<DialogService>();
String errorMessage; StreamSubscription _refreshTriggerSubscription;
List<UploadedPaste> pastes = []; List<UploadedPaste> pastes = [];
String errorMessage;
void init() {
this._refreshTriggerSubscription = _refreshService.refreshHistoryController.stream.listen((event) {
if (event == RefreshEvent.RefreshHistory) {
_logger.d('History needs a refresh');
getHistory();
}
});
}
Future getHistory() async { Future getHistory() async {
setState(ViewState.Busy); setState(ViewState.Busy);
@ -64,7 +78,6 @@ class HistoryModel extends BaseModel {
} }
pastes.sort((a, b) => a.date.compareTo(b.date)); pastes.sort((a, b) => a.date.compareTo(b.date));
errorMessage = null; errorMessage = null;
} catch (e) { } catch (e) {
if (e is RestServiceException) { if (e is RestServiceException) {
@ -148,4 +161,10 @@ class HistoryModel extends BaseModel {
void openLink(String link) { void openLink(String link) {
_linkService.open(link); _linkService.open(link);
} }
@override
void dispose() {
_refreshTriggerSubscription.cancel();
super.dispose();
}
} }

View file

@ -11,6 +11,7 @@ import 'package:receive_sharing_intent/receive_sharing_intent.dart';
import '../../locator.dart'; import '../../locator.dart';
import '../enums/error_code.dart'; import '../enums/error_code.dart';
import '../enums/refresh_event.dart';
import '../enums/viewstate.dart'; import '../enums/viewstate.dart';
import '../error/rest_service_exception.dart'; import '../error/rest_service_exception.dart';
import '../error/service_exception.dart'; import '../error/service_exception.dart';
@ -19,6 +20,7 @@ import '../models/rest/uploaded_multi_response.dart';
import '../models/rest/uploaded_response.dart'; import '../models/rest/uploaded_response.dart';
import '../services/file_service.dart'; import '../services/file_service.dart';
import '../services/link_service.dart'; import '../services/link_service.dart';
import '../services/refresh_service.dart';
import '../util/logger.dart'; import '../util/logger.dart';
import 'base_model.dart'; import 'base_model.dart';
@ -26,6 +28,7 @@ class UploadModel extends BaseModel {
final Logger _logger = getLogger(); final Logger _logger = getLogger();
final FileService _fileService = locator<FileService>(); final FileService _fileService = locator<FileService>();
final LinkService _linkService = locator<LinkService>(); final LinkService _linkService = locator<LinkService>();
final RefreshService _refreshService = locator<RefreshService>();
TextEditingController _pasteTextController = TextEditingController(); TextEditingController _pasteTextController = TextEditingController();
StreamSubscription _intentDataStreamSubscription; StreamSubscription _intentDataStreamSubscription;
@ -171,6 +174,7 @@ class UploadModel extends BaseModel {
clearCachedFiles(); clearCachedFiles();
_pasteTextController.clear(); _pasteTextController.clear();
_refreshService.addEvent(RefreshEvent.RefreshHistory);
errorMessage = null; errorMessage = null;
return uploadedPasteIds; return uploadedPasteIds;
} catch (e) { } catch (e) {

View file

@ -7,6 +7,7 @@ import 'core/services/file_service.dart';
import 'core/services/link_service.dart'; import 'core/services/link_service.dart';
import 'core/services/navigation_service.dart'; import 'core/services/navigation_service.dart';
import 'core/services/permission_service.dart'; import 'core/services/permission_service.dart';
import 'core/services/refresh_service.dart';
import 'core/services/session_service.dart'; import 'core/services/session_service.dart';
import 'core/services/storage_service.dart'; import 'core/services/storage_service.dart';
import 'core/viewmodels/about_model.dart'; import 'core/viewmodels/about_model.dart';
@ -35,6 +36,7 @@ void setupLocator() {
locator.registerLazySingleton(() => FileService()); locator.registerLazySingleton(() => FileService());
locator.registerLazySingleton(() => LinkService()); locator.registerLazySingleton(() => LinkService());
locator.registerLazySingleton(() => PermissionService()); locator.registerLazySingleton(() => PermissionService());
locator.registerLazySingleton(() => RefreshService());
/// view models /// view models
locator.registerFactory(() => StartUpViewModel()); locator.registerFactory(() => StartUpViewModel());

View file

@ -21,7 +21,10 @@ class HistoryView extends StatelessWidget {
var url = Provider.of<Session>(context).url; var url = Provider.of<Session>(context).url;
return BaseView<HistoryModel>( return BaseView<HistoryModel>(
onModelReady: (model) => model.getHistory(), onModelReady: (model) {
model.init();
return model.getHistory();
},
builder: (context, model, child) => Scaffold( builder: (context, model, child) => Scaffold(
appBar: MyAppBar(title: Text(translate('titles.history'))), appBar: MyAppBar(title: Text(translate('titles.history'))),
backgroundColor: backgroundColor, backgroundColor: backgroundColor,
@ -40,14 +43,6 @@ class HistoryView extends StatelessWidget {
); );
} }
Widget _renderOpenInBrowser(HistoryModel model, String url) {
return IconButton(
icon: Icon(Icons.open_in_new, color: Colors.blue, textDirection: TextDirection.ltr),
onPressed: () {
return model.openLink(url);
});
}
Widget _render(HistoryModel model, String url) { Widget _render(HistoryModel model, String url) {
List<Widget> cards = List<Widget>(); List<Widget> cards = List<Widget>();
@ -163,4 +158,12 @@ class HistoryView extends StatelessWidget {
physics: AlwaysScrollableScrollPhysics(), physics: AlwaysScrollableScrollPhysics(),
); );
} }
Widget _renderOpenInBrowser(HistoryModel model, String url) {
return IconButton(
icon: Icon(Icons.open_in_new, color: Colors.blue, textDirection: TextDirection.ltr),
onPressed: () {
return model.openLink(url);
});
}
} }

View file

@ -11,7 +11,7 @@ description: A mobile client for FileBin.
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at # Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1 version: 1.0.0+2
environment: environment:
sdk: ">=2.7.0 <3.0.0" sdk: ">=2.7.0 <3.0.0"