mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-11-23 20:49:26 +01:00
feat: Bring back config.json
This commit is contained in:
parent
30efe4b68a
commit
b6a0d372a1
@ -45,6 +45,10 @@ build_windows:
|
||||
- cd ..; git clone https://github.com/flutter/flutter.git -b dev; $env:path += ";C:\GitLab-Runner\builds\ChristianPauly\flutter\bin"; cd fluffychat-flutter
|
||||
- flutter doctor
|
||||
- flutter config --enable-windows-desktop
|
||||
- "$package_override = \"`r`ndependency_overrides:`r`n intl: 0.17.0-nullsafety.2\""
|
||||
- "[System.IO.File]::AppendAllText(\"$CI_PROJECT_DIR/pubspec.yaml\", $package_override, [System.Text.Encoding]::UTF8)"
|
||||
- flutter clean
|
||||
- flutter pub get
|
||||
- flutter build windows
|
||||
needs: []
|
||||
artifacts:
|
||||
@ -87,7 +91,7 @@ build_android_appbundle:
|
||||
resource_group: playstore_release
|
||||
only:
|
||||
- main
|
||||
|
||||
|
||||
upload_to_fdroid_repo:
|
||||
stage: release
|
||||
before_script:
|
||||
|
@ -77,6 +77,11 @@ flutter pub get
|
||||
flutter build web --release --verbose
|
||||
```
|
||||
|
||||
* Optionally configure by serving a `config.json` at the same path as fluffychat.
|
||||
An example can be found at `config.sample.json`. None of these
|
||||
values have to exist, the ones stated here are the default ones. If you e.g. only want
|
||||
to change the default homeserver, then only modify the `default_homeserver` key.
|
||||
|
||||
### Desktop (Linux, Windows, macOS)
|
||||
|
||||
* Enable Desktop support in Flutter: https://flutter.dev/desktop
|
||||
|
10
config.sample.json
Normal file
10
config.sample.json
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"application_name": "FluffyChat",
|
||||
"application_welcome_message": null,
|
||||
"default_homeserver": "matrix.org",
|
||||
"jitsi_instance": "https://meet.jit.si/",
|
||||
"privacy_url": "https://fluffychat.im/en/privacy.html",
|
||||
"render_html": false,
|
||||
"hide_redacted_events": false,
|
||||
"hide_unknown_events": false
|
||||
}
|
@ -1,11 +1,15 @@
|
||||
abstract class AppConfig {
|
||||
static const String applicationName = 'FluffyChat';
|
||||
static const String applicationWelcomeMessage = null;
|
||||
static const String defaultHomeserver = 'matrix.org';
|
||||
static String _applicationName = 'FluffyChat';
|
||||
static String get applicationName => _applicationName;
|
||||
static String _applicationWelcomeMessage;
|
||||
static String get applicationWelcomeMessage => _applicationWelcomeMessage;
|
||||
static String _defaultHomeserver = 'matrix.org';
|
||||
static String get defaultHomeserver => _defaultHomeserver;
|
||||
static String jitsiInstance = 'https://meet.jit.si/';
|
||||
static const bool allowOtherHomeservers = true;
|
||||
static const bool enableRegistration = true;
|
||||
static const String privacyUrl = 'https://fluffychat.im/en/privacy.html';
|
||||
static String _privacyUrl = 'https://fluffychat.im/en/privacy.html';
|
||||
static String get privacyUrl => _privacyUrl;
|
||||
static const String sourceCodeUrl =
|
||||
'https://gitlab.com/ChristianPauly/fluffychat-flutter';
|
||||
static const String supportUrl =
|
||||
@ -26,4 +30,31 @@ abstract class AppConfig {
|
||||
static const String pushNotificationsAppId = 'chat.fluffy.fluffychat';
|
||||
static const String pushNotificationsGatewayUrl = 'https://janian.de:7023/';
|
||||
static const String pushNotificationsPusherFormat = 'event_id_only';
|
||||
|
||||
static void loadFromJson(Map<String, dynamic> json) {
|
||||
if (json['application_name'] is String) {
|
||||
_applicationName = json['application_name'];
|
||||
}
|
||||
if (json['application_welcome_message'] is String) {
|
||||
_applicationWelcomeMessage = json['application_welcome_message'];
|
||||
}
|
||||
if (json['default_homeserver'] is String) {
|
||||
_defaultHomeserver = json['default_homeserver'];
|
||||
}
|
||||
if (json['jitsi_instance'] is String) {
|
||||
jitsiInstance = json['jitsi_instance'];
|
||||
}
|
||||
if (json['privacy_url'] is String) {
|
||||
_privacyUrl = json['privacy_url'];
|
||||
}
|
||||
if (json['render_html'] is bool) {
|
||||
renderHtml = json['render_html'];
|
||||
}
|
||||
if (json['hide_redacted_events'] is bool) {
|
||||
hideRedactedEvents = json['hide_redacted_events'];
|
||||
}
|
||||
if (json['hide_unknown_events'] is bool) {
|
||||
hideUnknownEvents = json['hide_unknown_events'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:adaptive_dialog/adaptive_dialog.dart';
|
||||
import 'package:famedlysdk/encryption.dart';
|
||||
@ -16,6 +17,8 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:universal_html/prefer_universal/html.dart' as html;
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
/*import 'package:fluffychat/views/chat.dart';
|
||||
import 'package:fluffychat/app_config.dart';
|
||||
import 'package:dbus/dbus.dart';
|
||||
@ -275,6 +278,33 @@ class MatrixState extends State<Matrix> {
|
||||
void initState() {
|
||||
super.initState();
|
||||
initMatrix();
|
||||
initConfig().then((_) => initSettings());
|
||||
}
|
||||
|
||||
Future<void> initConfig() async {
|
||||
if (PlatformInfos.isMobile) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
var configJsonString = '';
|
||||
if (PlatformInfos.isWeb) {
|
||||
configJsonString =
|
||||
utf8.decode((await http.get('config.json')).bodyBytes);
|
||||
} else if (PlatformInfos.isBetaDesktop) {
|
||||
final appDocDir = await getApplicationSupportDirectory();
|
||||
configJsonString =
|
||||
await File('${appDocDir.path}/config.json').readAsString();
|
||||
} else {
|
||||
final appDocDir = await getApplicationDocumentsDirectory();
|
||||
configJsonString =
|
||||
await File('${appDocDir.path}/config.json').readAsString();
|
||||
}
|
||||
final configJson = json.decode(configJsonString);
|
||||
AppConfig.loadFromJson(configJson);
|
||||
} catch (error) {
|
||||
debugPrint(
|
||||
'[ConfigLoader] Failed to load config.json: ' + error.toString());
|
||||
}
|
||||
}
|
||||
|
||||
void initMatrix() {
|
||||
@ -369,7 +399,6 @@ class MatrixState extends State<Matrix> {
|
||||
.listen(_showLocalNotification);
|
||||
});
|
||||
}
|
||||
initSettings();
|
||||
}
|
||||
|
||||
void initSettings() {
|
||||
|
@ -2,6 +2,7 @@
|
||||
flutter channel dev
|
||||
flutter upgrade
|
||||
flutter config --enable-linux-desktop
|
||||
echo "dependency_overrides:\n intl: 0.17.0-nullsafety.2" >> pubspec.yaml
|
||||
flutter clean
|
||||
flutter pub get
|
||||
flutter build linux --release -v
|
||||
|
@ -1,6 +1,6 @@
|
||||
#!/bin/sh -ve
|
||||
flutter channel beta
|
||||
flutter upgrade
|
||||
#flutter channel beta
|
||||
#flutter upgrade
|
||||
flutter config --enable-web
|
||||
flutter clean
|
||||
flutter pub get
|
||||
|
Loading…
Reference in New Issue
Block a user