Skip to content

Commit 7cc0144

Browse files
authored
Merge pull request #227 from Manuito83/develop
Merge develop for v3.3.0 - v2
2 parents 6fadc81 + f5d2ad5 commit 7cc0144

26 files changed

+870
-215
lines changed

android/app/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ if (flutterRoot == null) {
1313

1414
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
1515
if (flutterVersionCode == null) {
16-
flutterVersionCode = '380'
16+
flutterVersionCode = '382'
1717
}
1818

1919
def flutterVersionName = localProperties.getProperty('flutter.versionName')

cloud_functions/functions/src/retals.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ async function checkFaction(id: any, factionsList: any, db: any, refFactions: an
4545
if (ownFactionId === 0) return;
4646

4747
// DEBUG!
48-
//if (ownFactionId !== 6974) return;
48+
//if (ownFactionId !== 33241) return;
4949

5050
if (factionsList[id].timestamp === undefined) {
5151
promisesFaction.push(db.ref(`retals/factions/${ownFactionId}/api`).set(""));
@@ -389,10 +389,16 @@ async function checkFaction(id: any, factionsList: any, db: any, refFactions: an
389389
}
390390
}
391391

392+
// API FACTION PERMISSION DONOR
393+
// (this user chose to serve as a host, but not to be notified)
394+
if (subscribers[key].retalsNotificationDonor) {
395+
continue;
396+
}
397+
392398
// DEBUG!
393399
// DEBUG!
394400
// DEBUG!
395-
//if (subscribers[key].name !== "Manuito") return;
401+
//if (subscribers[key].name !== "Manuito") continue;
396402

397403
let title = notificationTitle;
398404
let body = notificationBody;

images/icons/midnightx_revive.png

737 Bytes
Loading

ios/Runner.xcodeproj/project.pbxproj

+4-4
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@
181181
97C146E61CF9000F007C117D /* Project object */ = {
182182
isa = PBXProject;
183183
attributes = {
184-
LastUpgradeCheck = 1430;
184+
LastUpgradeCheck = 1510;
185185
ORGANIZATIONNAME = "The Chromium Authors";
186186
TargetAttributes = {
187187
97C146ED1CF9000F007C117D = {
@@ -521,7 +521,7 @@
521521
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
522522
CODE_SIGN_IDENTITY = "Apple Development";
523523
CODE_SIGN_STYLE = Automatic;
524-
CURRENT_PROJECT_VERSION = 380;
524+
CURRENT_PROJECT_VERSION = 382;
525525
DEVELOPMENT_ASSET_PATHS = "";
526526
DEVELOPMENT_TEAM = 53KVJRJS99;
527527
ENABLE_BITCODE = NO;
@@ -665,7 +665,7 @@
665665
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
666666
CODE_SIGN_IDENTITY = "Apple Development";
667667
CODE_SIGN_STYLE = Automatic;
668-
CURRENT_PROJECT_VERSION = 380;
668+
CURRENT_PROJECT_VERSION = 382;
669669
DEVELOPMENT_ASSET_PATHS = "";
670670
DEVELOPMENT_TEAM = 53KVJRJS99;
671671
ENABLE_BITCODE = NO;
@@ -703,7 +703,7 @@
703703
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
704704
CODE_SIGN_IDENTITY = "Apple Development";
705705
CODE_SIGN_STYLE = Automatic;
706-
CURRENT_PROJECT_VERSION = 380;
706+
CURRENT_PROJECT_VERSION = 382;
707707
DEVELOPMENT_ASSET_PATHS = "";
708708
DEVELOPMENT_TEAM = 53KVJRJS99;
709709
ENABLE_BITCODE = NO;

ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1430"
3+
LastUpgradeVersion = "1510"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

lib/main.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ import 'package:workmanager/workmanager.dart';
5757

5858
// TODO (App release)
5959
const String appVersion = '3.3.0';
60-
const String androidCompilation = '380';
61-
const String iosCompilation = '380';
60+
const String androidCompilation = '382';
61+
const String iosCompilation = '382';
6262

6363
// TODO (App release)
6464
const bool pointFunctionsEmulatorToLocal = false;

lib/models/firebase_user_model.dart

+4-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class FirebaseUserModel extends OwnProfileExtended {
3232
List stockMarketShares = [];
3333
bool? factionAssistMessage = true;
3434
bool? retalsNotification = false;
35+
bool? retalsNotificationDonor = false;
3536

3637
FirebaseUserModel();
3738

@@ -79,6 +80,7 @@ class FirebaseUserModel extends OwnProfileExtended {
7980
"stockMarketShares": stockMarketShares,
8081
"factionAssistMessage": factionAssistMessage,
8182
"retalsNotification": retalsNotification,
83+
"retalsNotificationDonor": retalsNotificationDonor,
8284
};
8385
}
8486

@@ -116,6 +118,7 @@ class FirebaseUserModel extends OwnProfileExtended {
116118
..stockMarketNotification = data["stockMarketNotification"] ?? false
117119
..stockMarketShares = data["stockMarketShares"] ?? []
118120
..factionAssistMessage = data["factionAssistMessage"] ?? true
119-
..retalsNotification = data["retalsNotification"] ?? false;
121+
..retalsNotification = data["retalsNotification"] ?? false
122+
..retalsNotificationDonor = data["retalsNotificationDonor"] ?? false;
120123
}
121124
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// To parse this JSON data, do
2+
//
3+
// final midnightXReviveModel = midnightXReviveModelFromJson(jsonString);
4+
5+
// Dart imports:
6+
import 'dart:convert';
7+
8+
MidnightXReviveModel midnightXReviveModelFromJson(String str) => MidnightXReviveModel.fromJson(json.decode(str));
9+
10+
String midnightXReviveModelToJson(MidnightXReviveModel data) => json.encode(data.toJson());
11+
12+
class MidnightXReviveModel {
13+
String? vendor;
14+
int? tornId;
15+
String? username;
16+
String? source;
17+
String? type;
18+
19+
MidnightXReviveModel({
20+
this.vendor,
21+
this.tornId,
22+
this.username,
23+
this.source,
24+
this.type,
25+
});
26+
27+
factory MidnightXReviveModel.fromJson(Map<String, dynamic> json) => MidnightXReviveModel(
28+
vendor: json["vendor"],
29+
tornId: json["tornid"],
30+
username: json["username"],
31+
source: json["source"],
32+
type: json["type"],
33+
);
34+
35+
Map<String, dynamic> toJson() => {
36+
"vendor": vendor,
37+
"tornid": tornId,
38+
"username": username,
39+
"source": source,
40+
"type": type,
41+
};
42+
}

lib/models/userscript_model.dart

+11-4
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,12 @@ class UserScriptModel {
9090
}
9191

9292
factory UserScriptModel.fromMetaMap(Map<String, dynamic> metaMap,
93-
{String? url, UserScriptUpdateStatus updateStatus = UserScriptUpdateStatus.noRemote, bool? isExample, String? name, String? source, UserScriptTime? time}) {
93+
{String? url,
94+
UserScriptUpdateStatus updateStatus = UserScriptUpdateStatus.noRemote,
95+
bool? isExample,
96+
String? name,
97+
String? source,
98+
UserScriptTime? time}) {
9499
if (metaMap["name"] == null) {
95100
throw Exception("No script name found in userscript");
96101
}
@@ -146,7 +151,7 @@ class UserScriptModel {
146151
final List<String> version1List = version1.split(".");
147152
final List<String> version2List = version2.split(".");
148153
for (int i = 0; i < version1List.length; i++) {
149-
if (version2.length <= i || int.parse(version1List[i]) > int.parse(version2List[i])) {
154+
if (version2List.length <= i || int.parse(version1List[i]) > int.parse(version2List[i])) {
150155
return true;
151156
}
152157
}
@@ -200,8 +205,10 @@ class UserScriptModel {
200205
};
201206
}
202207

203-
shouldInject(String url, [UserScriptTime? time]) => enabled && (this.time == time || time == null) && matches
204-
.any((match) => (match == "*" || url.contains(match.replaceAll("*", ""))));
208+
shouldInject(String url, [UserScriptTime? time]) =>
209+
enabled &&
210+
(this.time == time || time == null) &&
211+
matches.any((match) => (match == "*" || url.contains(match.replaceAll("*", ""))));
205212

206213
void update({
207214
bool? enabled,

lib/pages/alerts.dart

+122-2
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ class AlertsSettingsState extends State<AlertsSettings> {
4949
ThemeProvider? _themeProvider;
5050
late WebViewProvider _webViewProvider;
5151

52+
final _scrollController = ScrollController();
53+
5254
@override
5355
void initState() {
5456
super.initState();
@@ -63,6 +65,12 @@ class AlertsSettingsState extends State<AlertsSettings> {
6365
routeName = "alerts";
6466
}
6567

68+
@override
69+
void dispose() {
70+
_scrollController.dispose();
71+
super.dispose();
72+
}
73+
6674
@override
6775
Widget build(BuildContext context) {
6876
_themeProvider = Provider.of<ThemeProvider>(context, listen: false);
@@ -86,6 +94,7 @@ class AlertsSettingsState extends State<AlertsSettings> {
8694
if (snapshot.data[0] is FirebaseUserModel) {
8795
_firebaseUserModel ??= snapshot.data[0] as FirebaseUserModel?;
8896
return SingleChildScrollView(
97+
controller: _scrollController,
8998
child: Column(
9099
children: [
91100
const Padding(
@@ -758,6 +767,13 @@ class AlertsSettingsState extends State<AlertsSettings> {
758767
_firebaseUserModel?.retalsNotification = enabled;
759768
});
760769
firestore.toggleRetaliationNotification(enabled);
770+
771+
// Makes sure to scroll down so that the new 2 options are visible
772+
_scrollController.animateTo(
773+
_scrollController.offset + 100,
774+
duration: const Duration(milliseconds: 200),
775+
curve: Curves.easeIn,
776+
);
761777
} else {
762778
String message = "";
763779
int seconds = 0;
@@ -817,7 +833,6 @@ class AlertsSettingsState extends State<AlertsSettings> {
817833
padding: const EdgeInsets.only(right: 10),
818834
child: GestureDetector(
819835
child: const Icon(Icons.info_outline_rounded),
820-
// Quick update
821836
onTap: () async {
822837
await showDialog(
823838
useRootNavigator: false,
@@ -843,6 +858,71 @@ class AlertsSettingsState extends State<AlertsSettings> {
843858
],
844859
),
845860
),
861+
if (_firebaseUserModel!.retalsNotification! && _factionApiAccess)
862+
Padding(
863+
padding: const EdgeInsets.fromLTRB(25, 0, 20, 0),
864+
child: Row(
865+
mainAxisAlignment: MainAxisAlignment.spaceBetween,
866+
children: <Widget>[
867+
Flexible(
868+
child: Row(
869+
children: [
870+
const Flexible(
871+
child: Padding(
872+
padding: EdgeInsets.only(left: 10, right: 5),
873+
child: Text(
874+
"Only as API permission donor",
875+
style: TextStyle(
876+
fontSize: 15,
877+
fontStyle: FontStyle.italic,
878+
),
879+
),
880+
),
881+
),
882+
Padding(
883+
padding: const EdgeInsets.only(right: 10),
884+
child: GestureDetector(
885+
child: const Icon(Icons.info_outline_rounded),
886+
onTap: () async {
887+
await showDialog(
888+
useRootNavigator: false,
889+
context: context,
890+
builder: (BuildContext context) {
891+
return _retalsDonorExplanation();
892+
},
893+
);
894+
},
895+
),
896+
),
897+
],
898+
),
899+
),
900+
Switch(
901+
value: _firebaseUserModel?.retalsNotificationDonor ?? false,
902+
onChanged: (enabled) {
903+
if (enabled) {
904+
BotToast.showText(
905+
text: "Please make sure that you understand the consequences of this setting "
906+
"by reading the information dialog.\n\n"
907+
"You will NOT receive relation alerts.",
908+
textStyle: const TextStyle(
909+
fontSize: 14,
910+
color: Colors.white,
911+
),
912+
contentColor: Colors.blue,
913+
duration: const Duration(seconds: 6),
914+
contentPadding: const EdgeInsets.all(10),
915+
);
916+
}
917+
setState(() {
918+
_firebaseUserModel?.retalsNotificationDonor = enabled;
919+
});
920+
firestore.toggleRetaliationDonor(enabled);
921+
},
922+
),
923+
],
924+
),
925+
),
846926
const SizedBox(height: 60),
847927
],
848928
),
@@ -950,7 +1030,7 @@ class AlertsSettingsState extends State<AlertsSettings> {
9501030
fontSize: 18,
9511031
),
9521032
),
953-
content: const SingleChildScrollView(
1033+
content: SingleChildScrollView(
9541034
child: Column(
9551035
children: [
9561036
Padding(
@@ -1190,6 +1270,46 @@ class AlertsSettingsState extends State<AlertsSettings> {
11901270
);
11911271
}
11921272

1273+
AlertDialog _retalsDonorExplanation() {
1274+
return AlertDialog(
1275+
title: const Text("Retaliation API Faction permissions donor"),
1276+
content: const Scrollbar(
1277+
thumbVisibility: true,
1278+
child: SingleChildScrollView(
1279+
child: Padding(
1280+
padding: EdgeInsets.only(right: 12),
1281+
child: Column(
1282+
crossAxisAlignment: CrossAxisAlignment.start,
1283+
children: [
1284+
Text(
1285+
"As explained in the Retalation Alerts information dialog, as a member of your faction with the "
1286+
"required Faction API access, your API key send retaliation notifications to faction members. "
1287+
"This will work as long as retalation alerts are active.\n\n"
1288+
"However, if you personally would prefer NOT to receive these notifications but continue to act "
1289+
"as a Faction API permission donor (so that the server can still notify other members), make "
1290+
"sure to activate this option.",
1291+
style: TextStyle(fontSize: 13),
1292+
),
1293+
SizedBox(height: 10),
1294+
],
1295+
),
1296+
),
1297+
),
1298+
),
1299+
actions: [
1300+
Padding(
1301+
padding: const EdgeInsets.only(right: 8),
1302+
child: TextButton(
1303+
child: const Text("Understood"),
1304+
onPressed: () {
1305+
Navigator.of(context).pop('exit');
1306+
},
1307+
),
1308+
),
1309+
],
1310+
);
1311+
}
1312+
11931313
Future _getFactionApiAccess() async {
11941314
// Assess whether we have permits
11951315
final attacksResult = await Get.find<ApiCallerController>().getFactionAttacks();

0 commit comments

Comments
 (0)