mirror of
https://github.com/JGeek00/adguard-home-manager.git
synced 2025-06-05 06:10:17 +00:00
Merge branch 'beta'
This commit is contained in:
commit
e670ec26b3
18 changed files with 165 additions and 108 deletions
41
.github/workflows/release-beta.yaml
vendored
41
.github/workflows/release-beta.yaml
vendored
|
@ -4,9 +4,13 @@ on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
inputs:
|
||||||
version:
|
version:
|
||||||
description: "Version (beta)"
|
description: "Version"
|
||||||
required: true
|
required: true
|
||||||
default: "1.0.0-beta.1"
|
default: "1.0.0"
|
||||||
|
beta-number:
|
||||||
|
description: "Beta number"
|
||||||
|
required: true
|
||||||
|
default: "1"
|
||||||
number:
|
number:
|
||||||
description: "Build number"
|
description: "Build number"
|
||||||
required: true
|
required: true
|
||||||
|
@ -18,8 +22,11 @@ jobs:
|
||||||
env:
|
env:
|
||||||
ANDROID_AAB_RELEASE_PATH: build/app/outputs/bundle/release
|
ANDROID_AAB_RELEASE_PATH: build/app/outputs/bundle/release
|
||||||
ANDROID_APK_RELEASE_PATH: build/app/outputs/apk/release
|
ANDROID_APK_RELEASE_PATH: build/app/outputs/apk/release
|
||||||
|
VERSION_NAME: ${{ github.event.inputs.version }}-beta.${{ github.event.inputs.beta-number }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
ref: beta
|
||||||
- name: Decode android/app/keystore.jks
|
- name: Decode android/app/keystore.jks
|
||||||
run: echo "${{ secrets.KEYSTORE_JKS }}" | base64 --decode > android/app/keystore.jks
|
run: echo "${{ secrets.KEYSTORE_JKS }}" | base64 --decode > android/app/keystore.jks
|
||||||
- name: Decode android/key.properties
|
- name: Decode android/key.properties
|
||||||
|
@ -27,7 +34,7 @@ jobs:
|
||||||
- name: Decode .env
|
- name: Decode .env
|
||||||
run: echo "${{ secrets.ENV }}" | base64 --decode > .env
|
run: echo "${{ secrets.ENV }}" | base64 --decode > .env
|
||||||
- name: Update version in YAML
|
- name: Update version in YAML
|
||||||
run: sed -i 's/99.99.99+99/${{ github.event.inputs.version }}+${{ github.event.inputs.number }}/g' pubspec.yaml
|
run: sed -i 's/99.99.99+99/${{ env.VERSION_NAME }}+${{ github.event.inputs.number }}/g' pubspec.yaml
|
||||||
- name: Update KeyStore password in gradle properties
|
- name: Update KeyStore password in gradle properties
|
||||||
run: sed -i 's/#{KEYSTORE_PASS}#/${{ secrets.KEYSTORE_PASS }}/g' android/key.properties
|
run: sed -i 's/#{KEYSTORE_PASS}#/${{ secrets.KEYSTORE_PASS }}/g' android/key.properties
|
||||||
- name: Update KeyStore key password in gradle properties
|
- name: Update KeyStore key password in gradle properties
|
||||||
|
@ -44,26 +51,30 @@ jobs:
|
||||||
- run: flutter build apk --release
|
- run: flutter build apk --release
|
||||||
- run: flutter build appbundle --release
|
- run: flutter build appbundle --release
|
||||||
- name: Rename apk
|
- name: Rename apk
|
||||||
run: mv $ANDROID_APK_RELEASE_PATH/app-release.apk $ANDROID_APK_RELEASE_PATH/AdGuardHomeManager_${{ github.event.inputs.version }}_Android.apk
|
run: mv $ANDROID_APK_RELEASE_PATH/app-release.apk $ANDROID_APK_RELEASE_PATH/AdGuardHomeManager_${{ env.VERSION_NAME }}_Android.apk
|
||||||
- name: Rename aab
|
- name: Rename aab
|
||||||
run: mv $ANDROID_AAB_RELEASE_PATH/app-release.aab $ANDROID_AAB_RELEASE_PATH/AdGuardHomeManager_${{ github.event.inputs.version }}_Android.aab
|
run: mv $ANDROID_AAB_RELEASE_PATH/app-release.aab $ANDROID_AAB_RELEASE_PATH/AdGuardHomeManager_${{ env.VERSION_NAME }}_Android.aab
|
||||||
- name: Copy apk to project root
|
- name: Copy apk to project root
|
||||||
run: cp $ANDROID_APK_RELEASE_PATH/AdGuardHomeManager_${{ github.event.inputs.version }}_Android.apk AdGuardHomeManager_${{ github.event.inputs.version }}_Android.apk
|
run: cp $ANDROID_APK_RELEASE_PATH/AdGuardHomeManager_${{ env.VERSION_NAME }}_Android.apk AdGuardHomeManager_${{ env.VERSION_NAME }}_Android.apk
|
||||||
- name: Copy aab to project root
|
- name: Copy aab to project root
|
||||||
run: cp $ANDROID_AAB_RELEASE_PATH/AdGuardHomeManager_${{ github.event.inputs.version }}_Android.aab AdGuardHomeManager_${{ github.event.inputs.version }}_Android.aab
|
run: cp $ANDROID_AAB_RELEASE_PATH/AdGuardHomeManager_${{ env.VERSION_NAME }}_Android.aab AdGuardHomeManager_${{ env.VERSION_NAME }}_Android.aab
|
||||||
- name: Upload artifact
|
- name: Upload artifact
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: android
|
name: android
|
||||||
path: |
|
path: |
|
||||||
AdGuardHomeManager_${{ github.event.inputs.version }}_Android.aab
|
AdGuardHomeManager_${{ env.VERSION_NAME }}_Android.aab
|
||||||
AdGuardHomeManager_${{ github.event.inputs.version }}_Android.apk
|
AdGuardHomeManager_${{ env.VERSION_NAME }}_Android.apk
|
||||||
release-builds-github:
|
release-builds-github:
|
||||||
name: Release beta build to GitHub
|
name: Release beta build to GitHub
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [build-android]
|
needs: [build-android]
|
||||||
|
env:
|
||||||
|
VERSION_NAME: ${{ github.event.inputs.version }}-beta.${{ github.event.inputs.beta-number }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
ref: beta
|
||||||
- name: Create builds directory
|
- name: Create builds directory
|
||||||
run: mkdir releases
|
run: mkdir releases
|
||||||
- name: Download Android artifacts
|
- name: Download Android artifacts
|
||||||
|
@ -76,8 +87,8 @@ jobs:
|
||||||
with:
|
with:
|
||||||
artifacts: "releases/*"
|
artifacts: "releases/*"
|
||||||
token: ${{ secrets.GH_TOKEN }}
|
token: ${{ secrets.GH_TOKEN }}
|
||||||
tag: '${{ github.event.inputs.version }}_(${{ github.event.inputs.number }})'
|
tag: '${{ env.VERSION_NAME }}_(${{ github.event.inputs.number }})'
|
||||||
name: v${{ github.event.inputs.version }}
|
name: v${{ env.VERSION_NAME }}
|
||||||
draft: true
|
draft: true
|
||||||
prerelease: true
|
prerelease: true
|
||||||
commit: ${{ github.sha }}
|
commit: ${{ github.sha }}
|
||||||
|
@ -85,8 +96,12 @@ jobs:
|
||||||
name: Release Android beta build to the Google Play Store
|
name: Release Android beta build to the Google Play Store
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [build-android]
|
needs: [build-android]
|
||||||
|
env:
|
||||||
|
VERSION_NAME: ${{ github.event.inputs.version }}-beta.${{ github.event.inputs.beta-number }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
ref: beta
|
||||||
- name: Download Android artifacts
|
- name: Download Android artifacts
|
||||||
uses: actions/download-artifact@v3
|
uses: actions/download-artifact@v3
|
||||||
with:
|
with:
|
||||||
|
@ -96,7 +111,7 @@ jobs:
|
||||||
with:
|
with:
|
||||||
serviceAccountJsonPlainText: ${{ secrets.PLAYSTORE_ACCOUNT_KEY }}
|
serviceAccountJsonPlainText: ${{ secrets.PLAYSTORE_ACCOUNT_KEY }}
|
||||||
packageName: com.jgeek00.adguard_home_manager
|
packageName: com.jgeek00.adguard_home_manager
|
||||||
releaseFiles: AdGuardHomeManager_${{ github.event.inputs.version }}_Android.aab
|
releaseFiles: AdGuardHomeManager_${{ env.VERSION_NAME }}_Android.aab
|
||||||
track: beta
|
track: beta
|
||||||
status: draft
|
status: draft
|
||||||
releaseName: ${{ github.event.inputs.version }}
|
releaseName: ${{ env.VERSION_NAME }}
|
|
@ -39,7 +39,7 @@ bool compareVersions({
|
||||||
}
|
}
|
||||||
else { // stable
|
else { // stable
|
||||||
final current = currentVersion.replaceAll('v', '');
|
final current = currentVersion.replaceAll('v', '');
|
||||||
final newV = currentVersion.replaceAll('v', '');
|
final newV = newVersion.replaceAll('v', '');
|
||||||
|
|
||||||
final currentSplit = current.split('.').map((e) => int.parse(e)).toList();
|
final currentSplit = current.split('.').map((e) => int.parse(e)).toList();
|
||||||
final newSplit = newV.split('.').map((e) => int.parse(e)).toList();
|
final newSplit = newV.split('.').map((e) => int.parse(e)).toList();
|
||||||
|
@ -159,26 +159,34 @@ bool gitHubUpdateExists({
|
||||||
: gitHubReleases.firstWhere((release) => release.prerelease == false);
|
: gitHubReleases.firstWhere((release) => release.prerelease == false);
|
||||||
|
|
||||||
final versionNumberRegex = RegExp(r'\(\d+\)');
|
final versionNumberRegex = RegExp(r'\(\d+\)');
|
||||||
final releaseNumberExtracted = versionNumberRegex.allMatches(release.tagName).first.group(0);
|
final releaseNumberExtractedMatches = versionNumberRegex.allMatches(release.tagName);
|
||||||
|
|
||||||
if (releaseNumberExtracted != null) {
|
if (releaseNumberExtractedMatches.isNotEmpty) {
|
||||||
final releaseNumber = releaseNumberExtracted.replaceAll(RegExp(r'\(|\)'), '');
|
final releaseNumberExtracted = releaseNumberExtractedMatches.first.group(0);
|
||||||
try {
|
|
||||||
final newReleaseParsed = int.parse(releaseNumber);
|
if (releaseNumberExtracted != null) {
|
||||||
final currentReleaseParsed = int.parse(currentBuildNumber);
|
final releaseNumber = releaseNumberExtracted.replaceAll(RegExp(r'\(|\)'), '');
|
||||||
if (newReleaseParsed > currentReleaseParsed) {
|
try {
|
||||||
return true;
|
final newReleaseParsed = int.parse(releaseNumber);
|
||||||
}
|
final currentReleaseParsed = int.parse(currentBuildNumber);
|
||||||
else {
|
if (newReleaseParsed > currentReleaseParsed) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
Sentry.captureMessage("Invalid release number. Current release: $currentBuildNumber. New release: $releaseNumber");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} catch (e) {
|
}
|
||||||
Sentry.captureMessage("Invalid release number. Current release: $currentBuildNumber. New release: $releaseNumber");
|
else {
|
||||||
|
Sentry.captureMessage("Invalid release number. Tagname: ${release.tagName}");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Sentry.captureMessage("Invalid release number. Tagname: ${release.tagName}");
|
Sentry.captureMessage("No matches. ${release.tagName}");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,18 +3,21 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
|
|
||||||
|
import 'package:adguard_home_manager/config/globals.dart';
|
||||||
|
|
||||||
void copyToClipboard({
|
void copyToClipboard({
|
||||||
required BuildContext context,
|
|
||||||
required String value,
|
required String value,
|
||||||
required String successMessage
|
required String successMessage
|
||||||
}) async {
|
}) async {
|
||||||
await Clipboard.setData(
|
if (scaffoldMessengerKey.currentState != null) {
|
||||||
ClipboardData(text: value)
|
await Clipboard.setData(
|
||||||
);
|
ClipboardData(text: value)
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
);
|
||||||
SnackBar(
|
scaffoldMessengerKey.currentState!.showSnackBar(
|
||||||
content: Text(successMessage),
|
SnackBar(
|
||||||
backgroundColor: Colors.green,
|
content: Text(successMessage),
|
||||||
)
|
backgroundColor: Colors.green,
|
||||||
);
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -18,7 +18,6 @@ class UpdateAvailableData {
|
||||||
final bool? canAutoupdate;
|
final bool? canAutoupdate;
|
||||||
final bool disabled;
|
final bool disabled;
|
||||||
String? changelog;
|
String? changelog;
|
||||||
bool? updateAvailable;
|
|
||||||
|
|
||||||
UpdateAvailableData({
|
UpdateAvailableData({
|
||||||
required this.currentVersion,
|
required this.currentVersion,
|
||||||
|
@ -28,7 +27,6 @@ class UpdateAvailableData {
|
||||||
required this.canAutoupdate,
|
required this.canAutoupdate,
|
||||||
required this.disabled,
|
required this.disabled,
|
||||||
this.changelog,
|
this.changelog,
|
||||||
this.updateAvailable
|
|
||||||
});
|
});
|
||||||
|
|
||||||
factory UpdateAvailableData.fromJson(Map<String, dynamic> json) => UpdateAvailableData(
|
factory UpdateAvailableData.fromJson(Map<String, dynamic> json) => UpdateAvailableData(
|
||||||
|
@ -39,7 +37,15 @@ class UpdateAvailableData {
|
||||||
canAutoupdate: json["can_autoupdate"],
|
canAutoupdate: json["can_autoupdate"],
|
||||||
disabled: json["disabled"],
|
disabled: json["disabled"],
|
||||||
changelog: json["changelog"],
|
changelog: json["changelog"],
|
||||||
updateAvailable: json['update_available']
|
);
|
||||||
|
|
||||||
|
factory UpdateAvailableData.fromJsonUpdate(Map<String, dynamic> json) => UpdateAvailableData(
|
||||||
|
currentVersion: json["current_version"],
|
||||||
|
newVersion: json["new_version"],
|
||||||
|
announcement: json["announcement"],
|
||||||
|
announcementUrl: json["announcement_url"],
|
||||||
|
canAutoupdate: json["can_autoupdate"],
|
||||||
|
disabled: json["disabled"],
|
||||||
);
|
);
|
||||||
|
|
||||||
Map<String, dynamic> toJson() => {
|
Map<String, dynamic> toJson() => {
|
||||||
|
@ -50,6 +56,5 @@ class UpdateAvailableData {
|
||||||
"can_autoupdate": canAutoupdate,
|
"can_autoupdate": canAutoupdate,
|
||||||
"disabled": disabled,
|
"disabled": disabled,
|
||||||
"changelog": changelog,
|
"changelog": changelog,
|
||||||
"update_available": updateAvailable
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:sqflite/sqflite.dart';
|
import 'package:sqflite/sqflite.dart';
|
||||||
|
|
||||||
|
@ -6,7 +8,6 @@ import 'package:adguard_home_manager/models/update_available.dart';
|
||||||
import 'package:adguard_home_manager/services/http_requests.dart';
|
import 'package:adguard_home_manager/services/http_requests.dart';
|
||||||
import 'package:adguard_home_manager/functions/conversions.dart';
|
import 'package:adguard_home_manager/functions/conversions.dart';
|
||||||
import 'package:adguard_home_manager/services/db/queries.dart';
|
import 'package:adguard_home_manager/services/db/queries.dart';
|
||||||
import 'package:adguard_home_manager/functions/compare_versions.dart';
|
|
||||||
import 'package:adguard_home_manager/constants/enums.dart';
|
import 'package:adguard_home_manager/constants/enums.dart';
|
||||||
|
|
||||||
class ServersProvider with ChangeNotifier {
|
class ServersProvider with ChangeNotifier {
|
||||||
|
@ -16,6 +17,8 @@ class ServersProvider with ChangeNotifier {
|
||||||
Server? _selectedServer;
|
Server? _selectedServer;
|
||||||
ApiClient? _apiClient;
|
ApiClient? _apiClient;
|
||||||
|
|
||||||
|
bool _updatingServer = false;
|
||||||
|
|
||||||
final UpdateAvailable _updateAvailable = UpdateAvailable(
|
final UpdateAvailable _updateAvailable = UpdateAvailable(
|
||||||
loadStatus: LoadStatus.loading,
|
loadStatus: LoadStatus.loading,
|
||||||
data: null,
|
data: null,
|
||||||
|
@ -37,6 +40,10 @@ class ServersProvider with ChangeNotifier {
|
||||||
return _updateAvailable;
|
return _updateAvailable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool get updatingServer {
|
||||||
|
return _updatingServer;
|
||||||
|
}
|
||||||
|
|
||||||
void setDbInstance(Database db) {
|
void setDbInstance(Database db) {
|
||||||
_dbInstance = db;
|
_dbInstance = db;
|
||||||
}
|
}
|
||||||
|
@ -68,6 +75,11 @@ class ServersProvider with ChangeNotifier {
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setUpdatingServer(bool status) {
|
||||||
|
_updatingServer = status;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
Future<dynamic> createServer(Server server) async {
|
Future<dynamic> createServer(Server server) async {
|
||||||
final saved = await saveServerQuery(_dbInstance!, server);
|
final saved = await saveServerQuery(_dbInstance!, server);
|
||||||
if (saved == null) {
|
if (saved == null) {
|
||||||
|
@ -155,7 +167,9 @@ class ServersProvider with ChangeNotifier {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void checkServerUpdatesAvailable(Server server) async {
|
void checkServerUpdatesAvailable({
|
||||||
|
required Server server,
|
||||||
|
}) async {
|
||||||
setUpdateAvailableLoadStatus(LoadStatus.loading, true);
|
setUpdateAvailableLoadStatus(LoadStatus.loading, true);
|
||||||
final result = await _apiClient!.checkServerUpdates();
|
final result = await _apiClient!.checkServerUpdates();
|
||||||
if (result['result'] == 'success') {
|
if (result['result'] == 'success') {
|
||||||
|
@ -164,12 +178,6 @@ class ServersProvider with ChangeNotifier {
|
||||||
if (gitHubResult['result'] == 'success') {
|
if (gitHubResult['result'] == 'success') {
|
||||||
data.changelog = gitHubResult['body'];
|
data.changelog = gitHubResult['body'];
|
||||||
}
|
}
|
||||||
data.updateAvailable = data.newVersion != null
|
|
||||||
? compareVersions(
|
|
||||||
currentVersion: data.currentVersion,
|
|
||||||
newVersion: data.newVersion!,
|
|
||||||
)
|
|
||||||
: false;
|
|
||||||
setUpdateAvailableData(data);
|
setUpdateAvailableData(data);
|
||||||
setUpdateAvailableLoadStatus(LoadStatus.loaded, true);
|
setUpdateAvailableLoadStatus(LoadStatus.loaded, true);
|
||||||
}
|
}
|
||||||
|
@ -178,18 +186,12 @@ class ServersProvider with ChangeNotifier {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void clearUpdateAvailable(Server server, String newCurrentVersion) {
|
|
||||||
if (_updateAvailable.data != null) {
|
|
||||||
_updateAvailable.data!.updateAvailable = null;
|
|
||||||
_updateAvailable.data!.currentVersion = newCurrentVersion;
|
|
||||||
notifyListeners();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future initializateServer(Server server) async {
|
Future initializateServer(Server server) async {
|
||||||
final serverStatus = await _apiClient!.getServerStatus();
|
final serverStatus = await _apiClient!.getServerStatus();
|
||||||
if (serverStatus['result'] == 'success') {
|
if (serverStatus['result'] == 'success') {
|
||||||
checkServerUpdatesAvailable(server); // Do not await
|
checkServerUpdatesAvailable( // Do not await
|
||||||
|
server: server,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,4 +231,39 @@ class ServersProvider with ChangeNotifier {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void recheckPeriodServerUpdated() {
|
||||||
|
if (_selectedServer != null) {
|
||||||
|
setUpdatingServer(true);
|
||||||
|
Server server = _selectedServer!;
|
||||||
|
Timer.periodic(
|
||||||
|
const Duration(seconds: 2),
|
||||||
|
(timer) async {
|
||||||
|
if (_selectedServer != null && _selectedServer == server) {
|
||||||
|
final result = await _apiClient!.checkServerUpdates();
|
||||||
|
if (result['result'] == 'success') {
|
||||||
|
UpdateAvailableData data = UpdateAvailableData.fromJsonUpdate(result['data']);
|
||||||
|
if (data.currentVersion == data.newVersion) {
|
||||||
|
final gitHubResult = await _apiClient!.getUpdateChangelog(releaseTag: data.newVersion ?? data.currentVersion);
|
||||||
|
if (gitHubResult['result'] == 'success') {
|
||||||
|
data.changelog = gitHubResult['body'];
|
||||||
|
}
|
||||||
|
setUpdateAvailableData(data);
|
||||||
|
timer.cancel();
|
||||||
|
setUpdatingServer(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
timer.cancel();
|
||||||
|
setUpdatingServer(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
timer.cancel();
|
||||||
|
setUpdatingServer(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -290,10 +290,12 @@ class StatusProvider with ChangeNotifier {
|
||||||
required String domain,
|
required String domain,
|
||||||
required String newStatus
|
required String newStatus
|
||||||
}) async {
|
}) async {
|
||||||
|
if (_serverStatus == null) return false;
|
||||||
|
|
||||||
final rules = await _serversProvider!.apiClient!.getFilteringRules();
|
final rules = await _serversProvider!.apiClient!.getFilteringRules();
|
||||||
|
|
||||||
if (rules['result'] == 'success') {
|
if (rules['result'] == 'success') {
|
||||||
FilteringStatus oldStatus = serverStatus!.filteringStatus;
|
FilteringStatus oldStatus = _serverStatus!.filteringStatus;
|
||||||
|
|
||||||
List<String> newRules = rules['data'].userRules.where((d) => !d.contains(domain)).toList();
|
List<String> newRules = rules['data'].userRules.where((d) => !d.contains(domain)).toList();
|
||||||
if (newStatus == 'block') {
|
if (newStatus == 'block') {
|
||||||
|
@ -302,7 +304,7 @@ class StatusProvider with ChangeNotifier {
|
||||||
else if (newStatus == 'unblock') {
|
else if (newStatus == 'unblock') {
|
||||||
newRules.add("@@||$domain^");
|
newRules.add("@@||$domain^");
|
||||||
}
|
}
|
||||||
FilteringStatus newObj = serverStatus!.filteringStatus;
|
FilteringStatus newObj = _serverStatus!.filteringStatus;
|
||||||
newObj.userRules = newRules;
|
newObj.userRules = newRules;
|
||||||
_filteringStatus = newObj;
|
_filteringStatus = newObj;
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,6 @@ class ActiveClientTile extends StatelessWidget {
|
||||||
icon: Icons.copy_rounded,
|
icon: Icons.copy_rounded,
|
||||||
action: () {
|
action: () {
|
||||||
copyToClipboard(
|
copyToClipboard(
|
||||||
context: context,
|
|
||||||
value: client.name != ''
|
value: client.name != ''
|
||||||
? client.name!
|
? client.name!
|
||||||
: client.ip,
|
: client.ip,
|
||||||
|
@ -58,7 +57,6 @@ class ActiveClientTile extends StatelessWidget {
|
||||||
icon: Icons.copy_rounded,
|
icon: Icons.copy_rounded,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
copyToClipboard(
|
copyToClipboard(
|
||||||
context: context,
|
|
||||||
value: client.name != ''
|
value: client.name != ''
|
||||||
? client.name!
|
? client.name!
|
||||||
: client.ip,
|
: client.ip,
|
||||||
|
@ -137,7 +135,6 @@ class ActiveClientTile extends StatelessWidget {
|
||||||
icon: Icons.copy_rounded,
|
icon: Icons.copy_rounded,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
copyToClipboard(
|
copyToClipboard(
|
||||||
context: context,
|
|
||||||
value: client.name != ''
|
value: client.name != ''
|
||||||
? client.name!
|
? client.name!
|
||||||
: client.ip,
|
: client.ip,
|
||||||
|
|
|
@ -55,7 +55,6 @@ class AddedClientTile extends StatelessWidget {
|
||||||
icon: Icons.copy_rounded,
|
icon: Icons.copy_rounded,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
copyToClipboard(
|
copyToClipboard(
|
||||||
context: context,
|
|
||||||
value: client.ids.toString().replaceAll(RegExp(r'^\[|\]$'), ''),
|
value: client.ids.toString().replaceAll(RegExp(r'^\[|\]$'), ''),
|
||||||
successMessage: AppLocalizations.of(context)!.copiedClipboard,
|
successMessage: AppLocalizations.of(context)!.copiedClipboard,
|
||||||
);
|
);
|
||||||
|
@ -189,7 +188,6 @@ class AddedClientTile extends StatelessWidget {
|
||||||
icon: Icons.copy_rounded,
|
icon: Icons.copy_rounded,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
copyToClipboard(
|
copyToClipboard(
|
||||||
context: context,
|
|
||||||
value: client.ids.toString().replaceAll(RegExp(r'^\[|\]$'), ''),
|
value: client.ids.toString().replaceAll(RegExp(r'^\[|\]$'), ''),
|
||||||
successMessage: AppLocalizations.of(context)!.copiedClipboard,
|
successMessage: AppLocalizations.of(context)!.copiedClipboard,
|
||||||
);
|
);
|
||||||
|
|
|
@ -249,7 +249,6 @@ class FiltersTripleColumn extends StatelessWidget {
|
||||||
icon: Icons.copy_rounded,
|
icon: Icons.copy_rounded,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
copyToClipboard(
|
copyToClipboard(
|
||||||
context: context,
|
|
||||||
value: filteringProvider.filtering!.userRules[index],
|
value: filteringProvider.filtering!.userRules[index],
|
||||||
successMessage: AppLocalizations.of(context)!.copiedClipboard,
|
successMessage: AppLocalizations.of(context)!.copiedClipboard,
|
||||||
);
|
);
|
||||||
|
@ -266,7 +265,6 @@ class FiltersTripleColumn extends StatelessWidget {
|
||||||
title: AppLocalizations.of(context)!.copyClipboard,
|
title: AppLocalizations.of(context)!.copyClipboard,
|
||||||
icon: Icons.copy_rounded,
|
icon: Icons.copy_rounded,
|
||||||
action: () => copyToClipboard(
|
action: () => copyToClipboard(
|
||||||
context: context,
|
|
||||||
value: filteringProvider.filtering!.userRules[index],
|
value: filteringProvider.filtering!.userRules[index],
|
||||||
successMessage: AppLocalizations.of(context)!.copiedClipboard,
|
successMessage: AppLocalizations.of(context)!.copiedClipboard,
|
||||||
)
|
)
|
||||||
|
|
|
@ -87,7 +87,6 @@ class ListOptionsMenu extends StatelessWidget {
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.pop(context); // Closes the context menu
|
Navigator.pop(context); // Closes the context menu
|
||||||
copyToClipboard(
|
copyToClipboard(
|
||||||
context: context,
|
|
||||||
value: list.url,
|
value: list.url,
|
||||||
successMessage: AppLocalizations.of(context)!.listUrlCopied
|
successMessage: AppLocalizations.of(context)!.listUrlCopied
|
||||||
);
|
);
|
||||||
|
@ -114,7 +113,6 @@ class ListOptionsMenu extends StatelessWidget {
|
||||||
title: AppLocalizations.of(context)!.copyListUrl,
|
title: AppLocalizations.of(context)!.copyListUrl,
|
||||||
icon: Icons.copy_rounded,
|
icon: Icons.copy_rounded,
|
||||||
action: () => copyToClipboard(
|
action: () => copyToClipboard(
|
||||||
context: context,
|
|
||||||
value: list.url,
|
value: list.url,
|
||||||
successMessage: AppLocalizations.of(context)!.listUrlCopied
|
successMessage: AppLocalizations.of(context)!.listUrlCopied
|
||||||
)
|
)
|
||||||
|
|
|
@ -25,7 +25,6 @@ class AppLogs extends StatelessWidget {
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: appConfigProvider.logs.isNotEmpty
|
onPressed: appConfigProvider.logs.isNotEmpty
|
||||||
? () => copyToClipboard(
|
? () => copyToClipboard(
|
||||||
context: context,
|
|
||||||
value: jsonEncode(appConfigProvider.logs.map((log) => log.toMap()).toList()),
|
value: jsonEncode(appConfigProvider.logs.map((log) => log.toMap()).toList()),
|
||||||
successMessage: AppLocalizations.of(context)!.logsCopiedClipboard
|
successMessage: AppLocalizations.of(context)!.logsCopiedClipboard
|
||||||
)
|
)
|
||||||
|
|
|
@ -48,12 +48,12 @@ class _ServerInformationWidgetState extends State<ServerInformationWidget> {
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
if (result['result'] == 'success') {
|
if (result['result'] == 'success') {
|
||||||
setState(() {
|
setState(() {
|
||||||
serverInfo.loadStatus = LoadStatus.loaded;
|
|
||||||
serverInfo.data = result['data'];
|
serverInfo.data = result['data'];
|
||||||
|
serverInfo.loadStatus = LoadStatus.loaded;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
setState(() => serverInfo.loadStatus = LoadStatus.loaded);
|
setState(() => serverInfo.loadStatus = LoadStatus.error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -188,8 +188,7 @@ class SettingsWidget extends StatelessWidget {
|
||||||
title: AppLocalizations.of(context)!.updates,
|
title: AppLocalizations.of(context)!.updates,
|
||||||
subtitle: AppLocalizations.of(context)!.updatesDescription,
|
subtitle: AppLocalizations.of(context)!.updatesDescription,
|
||||||
trailing: serversProvider.updateAvailable.data != null &&
|
trailing: serversProvider.updateAvailable.data != null &&
|
||||||
serversProvider.updateAvailable.data!.updateAvailable != null &&
|
serversProvider.updateAvailable.data!.canAutoupdate == true
|
||||||
serversProvider.updateAvailable.data!.updateAvailable == true
|
|
||||||
? Container(
|
? Container(
|
||||||
width: 10,
|
width: 10,
|
||||||
height: 10,
|
height: 10,
|
||||||
|
|
|
@ -40,7 +40,7 @@ class UpdateScreen extends StatelessWidget {
|
||||||
processModal.close();
|
processModal.close();
|
||||||
|
|
||||||
if (result['result'] == 'success') {
|
if (result['result'] == 'success') {
|
||||||
serversProvider.clearUpdateAvailable(serversProvider.selectedServer!, serversProvider.updateAvailable.data!.newVersion!);
|
serversProvider.recheckPeriodServerUpdated();
|
||||||
showSnacbkar(
|
showSnacbkar(
|
||||||
appConfigProvider: appConfigProvider,
|
appConfigProvider: appConfigProvider,
|
||||||
label: AppLocalizations.of(context)!.requestStartUpdateSuccessful,
|
label: AppLocalizations.of(context)!.requestStartUpdateSuccessful,
|
||||||
|
@ -79,7 +79,9 @@ class UpdateScreen extends StatelessWidget {
|
||||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||||
),
|
),
|
||||||
tooltip: AppLocalizations.of(context)!.checkUpdates,
|
tooltip: AppLocalizations.of(context)!.checkUpdates,
|
||||||
onPressed: () => serversProvider.checkServerUpdatesAvailable(serversProvider.selectedServer!)
|
onPressed: () => serversProvider.checkServerUpdatesAvailable(
|
||||||
|
server: serversProvider.selectedServer!,
|
||||||
|
)
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
@ -97,11 +99,9 @@ class UpdateScreen extends StatelessWidget {
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
: Icon(
|
: Icon(
|
||||||
serversProvider.updateAvailable.data!.updateAvailable != null
|
serversProvider.updateAvailable.data!.canAutoupdate == true
|
||||||
? serversProvider.updateAvailable.data!.updateAvailable == true
|
? Icons.system_update_rounded
|
||||||
? Icons.system_update_rounded
|
: Icons.system_security_update_good_rounded,
|
||||||
: Icons.system_security_update_good_rounded
|
|
||||||
: Icons.system_security_update_warning_rounded,
|
|
||||||
size: 40,
|
size: 40,
|
||||||
color: Theme.of(context).colorScheme.primary,
|
color: Theme.of(context).colorScheme.primary,
|
||||||
),
|
),
|
||||||
|
@ -109,11 +109,9 @@ class UpdateScreen extends StatelessWidget {
|
||||||
Text(
|
Text(
|
||||||
serversProvider.updateAvailable.loadStatus == LoadStatus.loading
|
serversProvider.updateAvailable.loadStatus == LoadStatus.loading
|
||||||
? AppLocalizations.of(context)!.checkingUpdates
|
? AppLocalizations.of(context)!.checkingUpdates
|
||||||
: serversProvider.updateAvailable.data!.updateAvailable != null
|
: serversProvider.updateAvailable.data!.canAutoupdate == true
|
||||||
? serversProvider.updateAvailable.data!.updateAvailable == true
|
? AppLocalizations.of(context)!.updateAvailable
|
||||||
? AppLocalizations.of(context)!.updateAvailable
|
: AppLocalizations.of(context)!.serverUpdated,
|
||||||
: AppLocalizations.of(context)!.serverUpdated
|
|
||||||
: AppLocalizations.of(context)!.unknownStatus,
|
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: 24,
|
fontSize: 24,
|
||||||
fontWeight: FontWeight.w400
|
fontWeight: FontWeight.w400
|
||||||
|
@ -127,7 +125,7 @@ class UpdateScreen extends StatelessWidget {
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
serversProvider.updateAvailable.data!.updateAvailable != null && serversProvider.updateAvailable.data!.updateAvailable == true
|
serversProvider.updateAvailable.data!.canAutoupdate == true
|
||||||
? AppLocalizations.of(context)!.newVersion
|
? AppLocalizations.of(context)!.newVersion
|
||||||
: AppLocalizations.of(context)!.currentVersion,
|
: AppLocalizations.of(context)!.currentVersion,
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
|
@ -136,11 +134,9 @@ class UpdateScreen extends StatelessWidget {
|
||||||
),
|
),
|
||||||
const SizedBox(height: 4),
|
const SizedBox(height: 4),
|
||||||
Text(
|
Text(
|
||||||
serversProvider.updateAvailable.data!.updateAvailable != null
|
serversProvider.updateAvailable.data!.canAutoupdate == true
|
||||||
? serversProvider.updateAvailable.data!.updateAvailable == true
|
? serversProvider.updateAvailable.data!.newVersion ?? 'N/A'
|
||||||
? serversProvider.updateAvailable.data!.newVersion ?? 'N/A'
|
: serversProvider.updateAvailable.data!.currentVersion,
|
||||||
: serversProvider.updateAvailable.data!.currentVersion
|
|
||||||
: "N/A",
|
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
fontWeight: FontWeight.w700,
|
fontWeight: FontWeight.w700,
|
||||||
|
@ -153,11 +149,13 @@ class UpdateScreen extends StatelessWidget {
|
||||||
FilledButton.icon(
|
FilledButton.icon(
|
||||||
icon: const Icon(Icons.download_rounded),
|
icon: const Icon(Icons.download_rounded),
|
||||||
label: Text(AppLocalizations.of(context)!.updateNow),
|
label: Text(AppLocalizations.of(context)!.updateNow),
|
||||||
onPressed: serversProvider.updateAvailable.data!.updateAvailable != null && serversProvider.updateAvailable.data!.updateAvailable == true
|
onPressed: serversProvider.updatingServer == true
|
||||||
? serversProvider.updateAvailable.data!.canAutoupdate != null && serversProvider.updateAvailable.data!.canAutoupdate == true
|
? null
|
||||||
? () => update()
|
: serversProvider.updateAvailable.data!.canAutoupdate == true
|
||||||
: () => showAutoUpdateUnavailableModal()
|
? serversProvider.updateAvailable.data!.canAutoupdate != null && serversProvider.updateAvailable.data!.canAutoupdate == true
|
||||||
: null
|
? () => update()
|
||||||
|
: () => showAutoUpdateUnavailableModal()
|
||||||
|
: null
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
@ -174,7 +172,7 @@ class UpdateScreen extends StatelessWidget {
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||||
child: Text(
|
child: Text(
|
||||||
"Changelog ${serversProvider.updateAvailable.data!.updateAvailable == true
|
"Changelog ${serversProvider.updateAvailable.data!.canAutoupdate == true
|
||||||
? serversProvider.updateAvailable.data!.newVersion
|
? serversProvider.updateAvailable.data!.newVersion
|
||||||
: serversProvider.updateAvailable.data!.currentVersion}",
|
: serversProvider.updateAvailable.data!.currentVersion}",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
|
|
|
@ -2007,21 +2007,18 @@ class ApiClient {
|
||||||
final result = await Future.wait([
|
final result = await Future.wait([
|
||||||
apiRequest(
|
apiRequest(
|
||||||
urlPath: '/version.json',
|
urlPath: '/version.json',
|
||||||
method: 'get',
|
method: 'post',
|
||||||
server: server,
|
server: server,
|
||||||
type: 'check_server_updates',
|
type: 'check_server_updates',
|
||||||
body: json.encode({
|
body: {
|
||||||
"recheck_now": true
|
"recheck_now": true
|
||||||
})
|
}
|
||||||
),
|
),
|
||||||
apiRequest(
|
apiRequest(
|
||||||
urlPath: '/status',
|
urlPath: '/status',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
server: server,
|
server: server,
|
||||||
type: 'check_server_updates',
|
type: 'check_server_updates',
|
||||||
body: json.encode({
|
|
||||||
"recheck_now": true
|
|
||||||
})
|
|
||||||
),
|
),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
|
@ -66,8 +66,7 @@ class BottomNavBar extends StatelessWidget {
|
||||||
if (
|
if (
|
||||||
screen.name == 'settings' &&
|
screen.name == 'settings' &&
|
||||||
serversProvider.updateAvailable.data != null &&
|
serversProvider.updateAvailable.data != null &&
|
||||||
serversProvider.updateAvailable.data!.updateAvailable != null &&
|
serversProvider.updateAvailable.data!.canAutoupdate == true
|
||||||
serversProvider.updateAvailable.data!.updateAvailable == true
|
|
||||||
) Positioned(
|
) Positioned(
|
||||||
bottom: 0,
|
bottom: 0,
|
||||||
right: -12,
|
right: -12,
|
||||||
|
|
|
@ -145,7 +145,9 @@ class _ServersListItemState extends State<ServersListItem> with SingleTickerProv
|
||||||
statusProvider.setServerStatusData(
|
statusProvider.setServerStatusData(
|
||||||
data: serverStatus['data']
|
data: serverStatus['data']
|
||||||
);
|
);
|
||||||
serversProvider.checkServerUpdatesAvailable(server);
|
serversProvider.checkServerUpdatesAvailable(
|
||||||
|
server: server,
|
||||||
|
);
|
||||||
statusProvider.setServerStatusLoad(LoadStatus.loaded);
|
statusProvider.setServerStatusLoad(LoadStatus.loaded);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -112,7 +112,9 @@ class _ServersTileItemState extends State<ServersTileItem> with SingleTickerProv
|
||||||
statusProvider.setServerStatusData(
|
statusProvider.setServerStatusData(
|
||||||
data: serverStatus['data']
|
data: serverStatus['data']
|
||||||
);
|
);
|
||||||
serversProvider.checkServerUpdatesAvailable(server);
|
serversProvider.checkServerUpdatesAvailable(
|
||||||
|
server: server,
|
||||||
|
);
|
||||||
statusProvider.setServerStatusLoad(LoadStatus.loaded);
|
statusProvider.setServerStatusLoad(LoadStatus.loaded);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue