Skip to content

Commit

Permalink
Merge pull request #297 from Manuito83/develop
Browse files Browse the repository at this point in the history
Merge for v3.6.2
  • Loading branch information
Manuito83 authored Dec 9, 2024
2 parents 70e6951 + dcb739a commit 793f710
Show file tree
Hide file tree
Showing 8 changed files with 108 additions and 49 deletions.
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ if (localPropertiesFile.exists()) {

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '465'
flutterVersionCode = '466'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '3.6.1'
flutterVersionName = '3.6.2'
}

def keystoreProperties = new Properties()
Expand Down
12 changes: 6 additions & 6 deletions ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 465;
CURRENT_PROJECT_VERSION = 466;
DEVELOPMENT_ASSET_PATHS = "";
DEVELOPMENT_TEAM = 53KVJRJS99;
ENABLE_BITCODE = NO;
Expand All @@ -567,7 +567,7 @@
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
);
MARKETING_VERSION = 3.6.1;
MARKETING_VERSION = 3.6.2;
PRODUCT_BUNDLE_IDENTIFIER = com.manuito.tornpda;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -698,7 +698,7 @@
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 465;
CURRENT_PROJECT_VERSION = 466;
DEVELOPMENT_ASSET_PATHS = "";
DEVELOPMENT_TEAM = 53KVJRJS99;
ENABLE_BITCODE = NO;
Expand All @@ -716,7 +716,7 @@
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
);
MARKETING_VERSION = 3.6.1;
MARKETING_VERSION = 3.6.2;
PRODUCT_BUNDLE_IDENTIFIER = com.manuito.tornpda;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -739,7 +739,7 @@
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 465;
CURRENT_PROJECT_VERSION = 466;
DEVELOPMENT_ASSET_PATHS = "";
DEVELOPMENT_TEAM = 53KVJRJS99;
ENABLE_BITCODE = NO;
Expand All @@ -757,7 +757,7 @@
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
);
MARKETING_VERSION = 3.6.1;
MARKETING_VERSION = 3.6.2;
PRODUCT_BUNDLE_IDENTIFIER = com.manuito.tornpda;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
6 changes: 3 additions & 3 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ import 'package:wakelock_plus/wakelock_plus.dart';
import 'package:workmanager/workmanager.dart';

// TODO (App release)
const String appVersion = '3.6.1';
const String androidCompilation = '465';
const String iosCompilation = '465';
const String appVersion = '3.6.2';
const String androidCompilation = '466';
const String iosCompilation = '466';

// TODO (App release)
// Note: if using Windows and calling HTTP functions, we need to change the URL in [firebase_functions.dart]
Expand Down
5 changes: 3 additions & 2 deletions lib/utils/changelog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,12 @@ class ChangeLogState extends State<ChangeLog> {
void _createItems() {
final itemList = <ChangeLogItem>[];

// v3.6.1 - Build 465 - 06/11/2024
// v3.6.2 - Build 466 - 07/11/2024
itemList.add(
ChangeLogItem()
..version = 'Torn PDA v3.6.1'
..version = 'Torn PDA v3.6.2'
..date = '8 DEC 2024'
..infoString = 'Hotfix: resolved an issue affecting the reordering of tabs'
..features = [
"Added channel info to chat notifications",
"Fixed notifications for own chat messages",
Expand Down
30 changes: 18 additions & 12 deletions lib/utils/stats_calculator.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:developer';

class StatsCalculator {
static final statsLevelTriggers = [2, 6, 11, 26, 31, 50, 71, 100];
static final statsCrimesTriggers = [100, 5000, 10000, 20000, 30000, 50000];
Expand Down Expand Up @@ -48,19 +50,23 @@ class StatsCalculator {
required int? networth,
required String? rank,
}) {
final levelIndex = statsLevelTriggers.lastIndexWhere((x) => x <= level!) + 1;
final crimeIndex = statsCrimesTriggers.lastIndexWhere((x) => x <= criminalRecordTotal!) + 1;
final networthIndex = statsNetworthTriggers.lastIndexWhere((x) => x <= networth!) + 1;
var rankIndex = 0;
statsRanksTriggers.forEach((tornRank, index) {
if (rank!.contains(tornRank)) {
rankIndex = index;
}
});
try {
final levelIndex = statsLevelTriggers.lastIndexWhere((x) => x <= level!) + 1;
final crimeIndex = statsCrimesTriggers.lastIndexWhere((x) => x <= criminalRecordTotal!) + 1;
final networthIndex = statsNetworthTriggers.lastIndexWhere((x) => x <= networth!) + 1;
var rankIndex = 0;
statsRanksTriggers.forEach((tornRank, index) {
if (rank!.contains(tornRank)) {
rankIndex = index;
}
});

final finalIndex = rankIndex - levelIndex - crimeIndex - networthIndex - 1;
if (finalIndex >= 0 && finalIndex <= 6) {
return statsResults[finalIndex];
final finalIndex = rankIndex - levelIndex - crimeIndex - networthIndex - 1;
if (finalIndex >= 0 && finalIndex <= 6) {
return statsResults[finalIndex];
}
} catch (e) {
log(e.toString());
}
return "unk";
}
Expand Down
44 changes: 44 additions & 0 deletions lib/utils/webview/webview_utils.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
import 'package:html/parser.dart';

class WebViewUtils {
/// Checks for a specific element by [selector] in the HTML from [webViewController]
/// It will attempt to find the element(s) up to [maxSeconds] total, checking every [intervalSeconds]
///
/// If [returnElements] is true, it returns a tuple-like result:
/// {
/// 'document': dom.Document,
/// 'elements': List<dom.Element>
/// }
///
/// Otherwise, it only returns the [dom.Document]
///
/// If the element is never found, returns null
static Future<Map<String, dynamic>?> waitForElement({
required InAppWebViewController webViewController,
required String selector,
int maxSeconds = 6,
int intervalSeconds = 1,
bool returnElements = false,
}) async {
final int attempts = (maxSeconds / intervalSeconds).ceil();

for (int attempt = 0; attempt < attempts; attempt++) {
await Future.delayed(Duration(seconds: intervalSeconds));

final html = await webViewController.getHtml();
final document = parse(html);
final elements = document.querySelectorAll(selector);

if (elements.isNotEmpty) {
if (returnElements) {
return {'document': document, 'elements': elements};
} else {
return {'document': document};
}
}
}

return null;
}
}
2 changes: 1 addition & 1 deletion lib/widgets/webviews/circular_menu/circular_menu_tabs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class CircularMenuTabsState extends State<CircularMenuTabs> with SingleTickerPro
if (!mounted) return;
_onTabTapped(context);
},
child: ReorderableDragStartListener(
child: ReorderableDelayedDragStartListener(
index: widget.tabIndex,
child: Container(
alignment: Alignment.center,
Expand Down
54 changes: 31 additions & 23 deletions lib/widgets/webviews/webview_full.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ import 'package:torn_pda/torn-pda-native/auth/native_user_provider.dart';
import 'package:torn_pda/utils/html_parser.dart' as pda_parser;
import 'package:torn_pda/utils/js_snippets.dart';
import 'package:torn_pda/utils/shared_prefs.dart';
import 'package:torn_pda/utils/webview/webview_utils.dart';
import 'package:torn_pda/widgets/bounties/bounties_widget.dart';
import 'package:torn_pda/widgets/chaining/chain_widget.dart';
import 'package:torn_pda/widgets/city/city_widget.dart';
Expand Down Expand Up @@ -2838,7 +2839,9 @@ class WebViewFullState extends State<WebViewFull> with WidgetsBindingObserver {
_cityTriggered = false;
_profileTriggered = false;
_attackTriggered = false;
} else if (_currentUrl.contains("torn.com/profiles.php?XID=") && _profileTriggered) {
} else if ((_currentUrl.contains("torn.com/profiles.php?XID=") ||
_currentUrl.contains("torn.com/profiles.php?NID=")) &&
_profileTriggered) {
_crimesTriggered = false;
_gymTriggered = false;
_vaultTriggered = false;
Expand Down Expand Up @@ -4007,7 +4010,7 @@ class WebViewFullState extends State<WebViewFull> with WidgetsBindingObserver {
}

// ASSESS PROFILES
Future _assessProfileAttack({dom.Document? document, String pageTitle = ""}) async {
Future _assessProfileAttack({required dom.Document document, String pageTitle = ""}) async {
if (mounted) {
if (!_currentUrl.contains('loader.php?sid=attack&user2ID=') &&
!_currentUrl.contains('loader2.php?sid=getInAttack&user2ID=') &&
Expand Down Expand Up @@ -4046,29 +4049,34 @@ class WebViewFullState extends State<WebViewFull> with WidgetsBindingObserver {
// When the URL is constructed with name instead of ID (e.g.: when the heart icon is pressed),
// we capture the ID from the profile element, ensuring that it's besides the correct name

final RegExp regId = RegExp(r"php\?NID=([^&]+)");
final matches = regId.allMatches(_currentUrl);
final String username = matches.elementAt(0).group(1)!;
final result = await WebViewUtils.waitForElement(
webViewController: webViewController!,
selector: 'a.profile-image-wrapper[href*="XID="]',
maxSeconds: 6,
intervalSeconds: 1,
returnElements: true,
);

final dom.Element userInfoValue = document!.querySelector('div.user-info-value')!;
final String textContent = userInfoValue.querySelector('span.bold')!.text.trim();
final RegExp regUsername = RegExp('($username' r')\s*\[([0-9]+)\]');
final match = regUsername.firstMatch(textContent);
if (match != null) {
setState(() {
_profileAttackWidget = ProfileAttackCheckWidget(
key: UniqueKey(),
profileId: int.parse(match.group(2)!),
apiKey: _userProvider?.basic?.userApiKey ?? "",
profileCheckType: ProfileCheckType.profile,
themeProvider: _themeProvider,
);
});
}
} else {
userId = 0;
if (result == null) throw ("No html tag found");

document = result['document'] as dom.Document;
final elements = result['elements'] as List<dom.Element>;
final anchor = elements.first;
final match = RegExp(r"XID=([^&]+)").firstMatch(anchor.attributes['href']!)!;
userId = int.parse(match.group(1)!);

setState(() {
_profileAttackWidget = ProfileAttackCheckWidget(
key: UniqueKey(),
profileId: userId,
apiKey: _userProvider?.basic?.userApiKey ?? "",
profileCheckType: ProfileCheckType.profile,
themeProvider: _themeProvider,
);
});
}
} catch (e) {
} catch (e, trace) {
log("Issue locating NID user ID: $e, $trace", name: "Profile Check");
userId = 0;
}
} else if (_currentUrl.contains('loader.php?sid=attack&user2ID=') ||
Expand Down

0 comments on commit 793f710

Please sign in to comment.