mirror of
https://github.com/go-vikunja/app
synced 2024-10-04 13:18:31 +00:00
added setting to disable update notifications
This commit is contained in:
parent
a536a0a973
commit
7da377121b
@ -124,8 +124,11 @@ class VikunjaGlobalState extends State<VikunjaGlobal> {
|
||||
platformChannelSpecificsReminders = notifs.NotificationDetails(
|
||||
android: androidSpecificsReminders, iOS: iOSSpecifics);
|
||||
notificationInitializer();
|
||||
versionChecker.postVersionCheckSnackbar();
|
||||
|
||||
settingsManager.getVersionNotifications().then((value) {
|
||||
if(value == "1") {
|
||||
versionChecker.postVersionCheckSnackbar();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void changeUser(User newUser, {String? token, String? base}) async {
|
||||
|
@ -6,52 +6,107 @@ import 'package:vikunja_app/models/list.dart';
|
||||
class SettingsPage extends StatefulWidget {
|
||||
@override
|
||||
State<StatefulWidget> createState() => SettingsPageState();
|
||||
|
||||
}
|
||||
|
||||
class SettingsPageState extends State<SettingsPage> {
|
||||
List<TaskList>? taskListList;
|
||||
int? defaultList;
|
||||
bool? ignoreCertificates;
|
||||
bool? getVersionNotifications;
|
||||
String? versionTag, newestVersionTag;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if(taskListList == null)
|
||||
VikunjaGlobal.of(context).listService.getAll().then((value) => setState(() => taskListList = value));
|
||||
if(defaultList == null)
|
||||
VikunjaGlobal.of(context).listService.getDefaultList().then((value) => setState(() => defaultList = value == null ? null : int.tryParse(value)));
|
||||
if(ignoreCertificates == null)
|
||||
VikunjaGlobal.of(context).settingsManager.getIgnoreCertificates().then((value) => setState(() => ignoreCertificates = value == "1" ? true:false));
|
||||
if(versionTag == null)
|
||||
VikunjaGlobal.of(context).versionChecker.getCurrentVersionTag().then((value) => setState(() => versionTag = value));
|
||||
if (taskListList == null)
|
||||
VikunjaGlobal.of(context)
|
||||
.listService
|
||||
.getAll()
|
||||
.then((value) => setState(() => taskListList = value));
|
||||
|
||||
if (defaultList == null)
|
||||
VikunjaGlobal.of(context).listService.getDefaultList().then((value) =>
|
||||
setState(
|
||||
() => defaultList = value == null ? null : int.tryParse(value)));
|
||||
|
||||
if (ignoreCertificates == null)
|
||||
VikunjaGlobal.of(context).settingsManager.getIgnoreCertificates().then(
|
||||
(value) =>
|
||||
setState(() => ignoreCertificates = value == "1" ? true : false));
|
||||
|
||||
if (getVersionNotifications == null)
|
||||
VikunjaGlobal.of(context).settingsManager.getVersionNotifications().then(
|
||||
(value) => setState(
|
||||
() => getVersionNotifications = value == "1" ? true : false));
|
||||
|
||||
if (versionTag == null)
|
||||
VikunjaGlobal.of(context)
|
||||
.versionChecker
|
||||
.getCurrentVersionTag()
|
||||
.then((value) => setState(() => versionTag = value));
|
||||
|
||||
return new Scaffold(
|
||||
appBar: AppBar(title: Text("Settings"),),
|
||||
appBar: AppBar(
|
||||
title: Text("Settings"),
|
||||
),
|
||||
body: Column(
|
||||
children: [
|
||||
taskListList != null ?
|
||||
ListTile(
|
||||
title: Text("Default List"),
|
||||
trailing: DropdownButton<int>(
|
||||
items: [DropdownMenuItem(child: Text("None"), value: null,), ...taskListList!.map((e) => DropdownMenuItem(child: Text(e.title), value: e.id)).toList()],
|
||||
value: defaultList,
|
||||
onChanged: (int? value){
|
||||
setState(() => defaultList = value);
|
||||
VikunjaGlobal.of(context).listService.setDefaultList(value);
|
||||
},
|
||||
),) : ListTile(title: Text("..."),),
|
||||
ignoreCertificates != null ?
|
||||
CheckboxListTile(title: Text("Ignore Certificates"), value: ignoreCertificates, onChanged: (value) {
|
||||
setState(() => ignoreCertificates = value);
|
||||
VikunjaGlobal.of(context).client.reload_ignore_certs(value);
|
||||
}) : ListTile(title: Text("...")),
|
||||
TextButton(onPressed: () => VikunjaGlobal.of(context).versionChecker.getLatestVersionTag().then((value) => newestVersionTag = value), child: Text("Check for latest version")),
|
||||
taskListList != null
|
||||
? ListTile(
|
||||
title: Text("Default List"),
|
||||
trailing: DropdownButton<int>(
|
||||
items: [
|
||||
DropdownMenuItem(
|
||||
child: Text("None"),
|
||||
value: null,
|
||||
),
|
||||
...taskListList!
|
||||
.map((e) => DropdownMenuItem(
|
||||
child: Text(e.title), value: e.id))
|
||||
.toList()
|
||||
],
|
||||
value: defaultList,
|
||||
onChanged: (int? value) {
|
||||
setState(() => defaultList = value);
|
||||
VikunjaGlobal.of(context)
|
||||
.listService
|
||||
.setDefaultList(value);
|
||||
},
|
||||
),
|
||||
)
|
||||
: ListTile(
|
||||
title: Text("..."),
|
||||
),
|
||||
ignoreCertificates != null
|
||||
? CheckboxListTile(
|
||||
title: Text("Ignore Certificates"),
|
||||
value: ignoreCertificates,
|
||||
onChanged: (value) {
|
||||
setState(() => ignoreCertificates = value);
|
||||
VikunjaGlobal.of(context).client.reload_ignore_certs(value);
|
||||
})
|
||||
: ListTile(title: Text("...")),
|
||||
getVersionNotifications != null
|
||||
? CheckboxListTile(
|
||||
title: Text("Get Version Notifications"),
|
||||
value: getVersionNotifications,
|
||||
onChanged: (value) {
|
||||
setState(() => getVersionNotifications = value);
|
||||
if(value != null)
|
||||
VikunjaGlobal.of(context).settingsManager.setVersionNotifications(value);
|
||||
})
|
||||
: ListTile(title: Text("...")),
|
||||
TextButton(
|
||||
onPressed: () => VikunjaGlobal.of(context)
|
||||
.versionChecker
|
||||
.getLatestVersionTag()
|
||||
.then((value) => newestVersionTag = value),
|
||||
child: Text("Check for latest version")),
|
||||
Text("Current version: ${versionTag ?? "loading"}"),
|
||||
Text(newestVersionTag != null ? "Newest version: $newestVersionTag" : "")
|
||||
Text(newestVersionTag != null
|
||||
? "Newest version: $newestVersionTag"
|
||||
: "")
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
import 'dart:async';
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||
import 'package:vikunja_app/api/response.dart';
|
||||
@ -13,29 +12,58 @@ import 'package:vikunja_app/models/bucket.dart';
|
||||
|
||||
import '../models/server.dart';
|
||||
|
||||
enum TaskServiceOptionSortBy {id, title, description, done, done_at, due_date, created_by_id, list_id, repeat_after, priority, start_date, end_date, hex_color, percent_done, uid, created, updated}
|
||||
enum TaskServiceOptionOrderBy {asc,desc}
|
||||
enum TaskServiceOptionFilterBy {done, due_date, reminder_dates}
|
||||
enum TaskServiceOptionFilterValue {enum_true,enum_false, enum_null}
|
||||
enum TaskServiceOptionFilterComparator {equals, greater, greater_equals, less, less_equals, like, enum_in}
|
||||
enum TaskServiceOptionFilterConcat {and, or}
|
||||
enum TaskServiceOptionSortBy {
|
||||
id,
|
||||
title,
|
||||
description,
|
||||
done,
|
||||
done_at,
|
||||
due_date,
|
||||
created_by_id,
|
||||
list_id,
|
||||
repeat_after,
|
||||
priority,
|
||||
start_date,
|
||||
end_date,
|
||||
hex_color,
|
||||
percent_done,
|
||||
uid,
|
||||
created,
|
||||
updated
|
||||
}
|
||||
|
||||
enum TaskServiceOptionOrderBy { asc, desc }
|
||||
|
||||
enum TaskServiceOptionFilterBy { done, due_date, reminder_dates }
|
||||
|
||||
enum TaskServiceOptionFilterValue { enum_true, enum_false, enum_null }
|
||||
|
||||
enum TaskServiceOptionFilterComparator {
|
||||
equals,
|
||||
greater,
|
||||
greater_equals,
|
||||
less,
|
||||
less_equals,
|
||||
like,
|
||||
enum_in
|
||||
}
|
||||
|
||||
enum TaskServiceOptionFilterConcat { and, or }
|
||||
|
||||
class TaskServiceOption<T> {
|
||||
String name;
|
||||
dynamic value;
|
||||
dynamic defValue;
|
||||
TaskServiceOption(
|
||||
this.name,
|
||||
this.value
|
||||
);
|
||||
|
||||
TaskServiceOption(this.name, this.value);
|
||||
|
||||
String handleValue(dynamic input) {
|
||||
if(input is String)
|
||||
return input;
|
||||
if (input is String) return input;
|
||||
return input.toString().split('.').last.replaceAll('enum_', '');
|
||||
}
|
||||
|
||||
dynamic getValue() {
|
||||
if(value is List)
|
||||
if (value is List)
|
||||
return value.map((elem) => handleValue(elem)).toList();
|
||||
else
|
||||
return handleValue(value);
|
||||
@ -46,14 +74,27 @@ class TaskServiceOptions {
|
||||
List<TaskServiceOption>? options;
|
||||
|
||||
TaskServiceOptions({this.options}) {
|
||||
if(this.options == null)
|
||||
if (this.options == null)
|
||||
options = [
|
||||
TaskServiceOption<TaskServiceOptionSortBy>("sort_by",[TaskServiceOptionSortBy.due_date, TaskServiceOptionSortBy.id]),
|
||||
TaskServiceOption<TaskServiceOptionOrderBy>("order_by", TaskServiceOptionOrderBy.asc),
|
||||
TaskServiceOption<TaskServiceOptionFilterBy>("filter_by", [TaskServiceOptionFilterBy.done, TaskServiceOptionFilterBy.due_date]),
|
||||
TaskServiceOption<TaskServiceOptionFilterValue>("filter_value", [TaskServiceOptionFilterValue.enum_false, '0001-01-02T00:00:00.000Z']),
|
||||
TaskServiceOption<TaskServiceOptionFilterComparator>("filter_comparator", [TaskServiceOptionFilterComparator.equals,TaskServiceOptionFilterComparator.greater]),
|
||||
TaskServiceOption<TaskServiceOptionFilterConcat>("filter_concat", TaskServiceOptionFilterConcat.and),
|
||||
TaskServiceOption<TaskServiceOptionSortBy>("sort_by",
|
||||
[TaskServiceOptionSortBy.due_date, TaskServiceOptionSortBy.id]),
|
||||
TaskServiceOption<TaskServiceOptionOrderBy>(
|
||||
"order_by", TaskServiceOptionOrderBy.asc),
|
||||
TaskServiceOption<TaskServiceOptionFilterBy>("filter_by", [
|
||||
TaskServiceOptionFilterBy.done,
|
||||
TaskServiceOptionFilterBy.due_date
|
||||
]),
|
||||
TaskServiceOption<TaskServiceOptionFilterValue>("filter_value", [
|
||||
TaskServiceOptionFilterValue.enum_false,
|
||||
'0001-01-02T00:00:00.000Z'
|
||||
]),
|
||||
TaskServiceOption<TaskServiceOptionFilterComparator>(
|
||||
"filter_comparator", [
|
||||
TaskServiceOptionFilterComparator.equals,
|
||||
TaskServiceOptionFilterComparator.greater
|
||||
]),
|
||||
TaskServiceOption<TaskServiceOptionFilterConcat>(
|
||||
"filter_concat", TaskServiceOptionFilterConcat.and),
|
||||
];
|
||||
}
|
||||
|
||||
@ -63,9 +104,8 @@ class TaskServiceOptions {
|
||||
|
||||
String getOptions() {
|
||||
String result = '';
|
||||
if(options == null)
|
||||
return '';
|
||||
for(TaskServiceOption option in options!) {
|
||||
if (options == null) return '';
|
||||
for (TaskServiceOption option in options!) {
|
||||
dynamic value = option.getValue();
|
||||
if (value is List) {
|
||||
for (dynamic valueEntry in value) {
|
||||
@ -76,41 +116,59 @@ class TaskServiceOptions {
|
||||
}
|
||||
}
|
||||
|
||||
if(result.startsWith('&'))
|
||||
result.substring(1);
|
||||
if (result.startsWith('&')) result.substring(1);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
abstract class NamespaceService {
|
||||
Future<List<Namespace>?> getAll();
|
||||
|
||||
Future<Namespace?> get(int namespaceId);
|
||||
|
||||
Future<Namespace?> create(Namespace ns);
|
||||
|
||||
Future<Namespace?> update(Namespace ns);
|
||||
|
||||
Future delete(int namespaceId);
|
||||
}
|
||||
|
||||
abstract class ListService {
|
||||
Future<List<TaskList>?> getAll();
|
||||
|
||||
Future<TaskList?> get(int listId);
|
||||
|
||||
Future<List<TaskList>?> getByNamespace(int namespaceId);
|
||||
|
||||
Future<TaskList?> create(int namespaceId, TaskList tl);
|
||||
|
||||
Future<TaskList?> update(TaskList tl);
|
||||
|
||||
Future delete(int listId);
|
||||
|
||||
Future<String?> getDisplayDoneTasks(int listId);
|
||||
|
||||
void setDisplayDoneTasks(int listId, String value);
|
||||
|
||||
Future<String?> getDefaultList();
|
||||
|
||||
void setDefaultList(int? listId);
|
||||
}
|
||||
|
||||
abstract class TaskService {
|
||||
Future<Task?> get(int taskId);
|
||||
|
||||
Future<Task?> update(Task task);
|
||||
|
||||
Future delete(int taskId);
|
||||
|
||||
Future<Task?> add(int listId, Task task);
|
||||
|
||||
Future<List<Task>?> getAll();
|
||||
|
||||
Future<Response?> getAllByList(int listId,
|
||||
[Map<String, List<String>> queryParameters]);
|
||||
|
||||
Future<List<Task>?> getByOptions(TaskServiceOptions options);
|
||||
|
||||
int get maxPages;
|
||||
@ -120,8 +178,11 @@ abstract class BucketService {
|
||||
// Not implemented in the Vikunja API
|
||||
// Future<Bucket> get(int listId, int bucketId);
|
||||
Future<Bucket?> update(Bucket bucket);
|
||||
|
||||
Future delete(int listId, int bucketId);
|
||||
|
||||
Future<Bucket?> add(int listId, Bucket bucket);
|
||||
|
||||
Future<Response?> getAllByList(int listId,
|
||||
[Map<String, List<String>> queryParameters]);
|
||||
|
||||
@ -129,22 +190,31 @@ abstract class BucketService {
|
||||
}
|
||||
|
||||
abstract class UserService {
|
||||
Future<UserTokenPair?> login(String username, String password, {bool rememberMe = false, String totp});
|
||||
Future<UserTokenPair?> login(String username, String password,
|
||||
{bool rememberMe = false, String totp});
|
||||
|
||||
Future<UserTokenPair?> register(String username, email, password);
|
||||
|
||||
Future<User?> getCurrentUser();
|
||||
}
|
||||
|
||||
abstract class LabelService {
|
||||
Future<List<Label>?> getAll({String query});
|
||||
|
||||
Future<Label?> get(int labelID);
|
||||
|
||||
Future<Label?> create(Label label);
|
||||
|
||||
Future<Label?> delete(Label label);
|
||||
|
||||
Future<Label?> update(Label label);
|
||||
}
|
||||
|
||||
abstract class LabelTaskService {
|
||||
Future<List<Label>?> getAll(LabelTask lt, {String query});
|
||||
|
||||
Future<Label?> create(LabelTask lt);
|
||||
|
||||
Future<Label?> delete(LabelTask lt);
|
||||
}
|
||||
|
||||
@ -159,22 +229,32 @@ abstract class ServerService {
|
||||
class SettingsManager {
|
||||
final FlutterSecureStorage _storage;
|
||||
|
||||
Map<String,String> defaults = {
|
||||
"ignore-certificates" : "0"
|
||||
Map<String, String> defaults = {
|
||||
"ignore-certificates": "0",
|
||||
"get-version-notifications": "1"
|
||||
};
|
||||
|
||||
SettingsManager(this._storage) {
|
||||
defaults.forEach((key, value) {
|
||||
_storage.containsKey(key: key).then((is_created) {
|
||||
if (!is_created)
|
||||
_storage.write(key: key, value: value);
|
||||
});});}
|
||||
if (!is_created) _storage.write(key: key, value: value);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Future<String?> getIgnoreCertificates() {
|
||||
return _storage.read(key: "ignore-certificates");
|
||||
}
|
||||
|
||||
Future<String?> getVersionNotifications() {
|
||||
return _storage.read(key: "get-version-notifications");
|
||||
}
|
||||
|
||||
void setIgnoreCertificates(bool value) {
|
||||
_storage.write(key: "ignore-certificates", value: value ? "1" : "0");
|
||||
}
|
||||
}
|
||||
|
||||
void setVersionNotifications(bool value) {
|
||||
_storage.write(key: "get-version-notifications", value: value ? "1" : "0");
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user