Skip to content

Commit a1268d6

Browse files
Merge remote-tracking branch 'refs/remotes/origin/main'
2 parents 1ed8c51 + 35b9dc4 commit a1268d6

18 files changed

Lines changed: 143 additions & 78 deletions

.github/workflows/development.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@ jobs:
1818
include:
1919
- platform: 2
2020
platform_name: ios
21-
- platform: 7
22-
platform_name: iossimulator
23-
- platform: 8
24-
platform_name: tvossimulator
2521

2622
runs-on: J316sAP
2723
steps:

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ OUTPUTDIR := $(SOURCEDIR)/artifacts
99
WORKINGDIR := $(SOURCEDIR)/Natives/build
1010
DETECTPLAT := $(shell uname -s)
1111
DETECTARCH := $(shell uname -m)
12-
VERSION := 3.0
12+
VERSION := 1.0
1313
BRANCH := $(shell git branch --show-current)
1414
COMMIT := $(shell git log --oneline | sed '2,10000000d' | cut -b 1-7)
1515
PLATFORM ?= 2

Natives/AccountListViewController.m

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
9595
[self addActivityIndicatorTo:cell];
9696

9797
id callback = ^(id status, BOOL success) {
98-
[self callbackMicrosoftAuth:status success:success forCell:cell];
98+
dispatch_async(dispatch_get_main_queue(), ^(){
99+
[self callbackMicrosoftAuth:status success:success forCell:cell];
100+
});
99101
};
100102
[[BaseAuthenticator loadSavedName:self.accountList[indexPath.row][@"username"]] refreshTokenWithCallback:callback];
101103
}
@@ -210,14 +212,18 @@ - (void)actionLoginMicrosoft:(UITableViewCell *)sender {
210212

211213
NSDictionary *queryItems = [self parseQueryItems:callbackURL.absoluteString];
212214
if (queryItems[@"code"]) {
213-
self.modalInPresentation = YES;
214-
self.tableView.userInteractionEnabled = NO;
215-
[self addActivityIndicatorTo:sender];
215+
dispatch_async(dispatch_get_main_queue(), ^(){
216+
self.modalInPresentation = YES;
217+
self.tableView.userInteractionEnabled = NO;
218+
[self addActivityIndicatorTo:sender];
219+
});
216220
id callback = ^(id status, BOOL success) {
217221
if ([status isKindOfClass:NSString.class] && [status isEqualToString:@"DEMO"] && success) {
218222
showDialog(localize(@"login.warn.title.demomode", nil), localize(@"login.warn.message.demomode", nil));
219223
}
220-
[self callbackMicrosoftAuth:status success:success forCell:sender];
224+
dispatch_async(dispatch_get_main_queue(), ^(){
225+
[self callbackMicrosoftAuth:status success:success forCell:sender];
226+
});
221227
};
222228
[[[MicrosoftAuthenticator alloc] initWithInput:queryItems[@"code"]] loginWithCallback:callback];
223229
} else {

Natives/CustomControlsViewController.m

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ - (void)viewDidLoad
3737
[self setNeedsUpdateOfScreenEdgesDeferringSystemGestures];
3838
[self setNeedsUpdateOfHomeIndicatorAutoHidden];
3939

40-
CGRect screenBounds = [[UIScreen mainScreen] bounds];
4140
UIEdgeInsets insets = UIApplication.sharedApplication.windows.firstObject.safeAreaInsets;
4241

4342
UILabel *guideLabel = [[UILabel alloc] initWithFrame:self.view.frame];
@@ -48,7 +47,7 @@ - (void)viewDidLoad
4847
guideLabel.text = localize(@"custom_controls.hint", nil);
4948
[self.view addSubview:guideLabel];
5049

51-
self.ctrlView = [[ControlLayout alloc] initWithFrame:getSafeArea()];
50+
self.ctrlView = [[ControlLayout alloc] initWithFrame:getSafeArea(self.view.frame)];
5251
self.ctrlView.layer.borderColor = UIColor.labelColor.CGColor;
5352
[self.view addSubview:self.ctrlView];
5453

@@ -173,7 +172,7 @@ - (void)loadControlFile:(NSString *)file {
173172

174173
- (void)viewDidLayoutSubviews {
175174
if (self.navigationBar.hidden) {
176-
self.ctrlView.frame = getSafeArea();
175+
self.ctrlView.frame = getSafeArea(self.view.frame);
177176
}
178177

179178
// Update dynamic position for each view
@@ -193,7 +192,7 @@ - (void)changeSafeAreaSelection:(UISegmentedControl *)sender {
193192
self.ctrlView.frame = UIEdgeInsetsInsetRect(self.view.frame, getDefaultSafeArea());
194193
break;
195194
case 2:
196-
self.ctrlView.frame = getSafeArea();
195+
self.ctrlView.frame = getSafeArea(self.view.frame);
197196
break;
198197
}
199198
self.ctrlView.userInteractionEnabled = sender.selectedSegmentIndex == 2;
@@ -345,12 +344,12 @@ - (void)actionMenuSafeArea {
345344
}
346345

347346
- (void)actionMenuSafeAreaCancel {
348-
self.ctrlView.frame = getSafeArea();
347+
self.ctrlView.frame = getSafeArea(self.view.frame);
349348
[self actionMenuSafeArea];
350349
}
351350

352351
- (void)actionMenuSafeAreaDone {
353-
setSafeArea(self.ctrlView.frame);
352+
setSafeArea(self.view.frame.size, self.ctrlView.frame);
354353
[self actionMenuSafeArea];
355354
}
356355

Natives/Info.plist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
<key>CFBundlePackageType</key>
8383
<string>APPL</string>
8484
<key>CFBundleShortVersionString</key>
85-
<string>3.0</string>
85+
<string>1.0</string>
8686
<key>CFBundleSignature</key>
8787
<string>????</string>
8888
<key>CFBundleURLTypes</key>
@@ -97,7 +97,7 @@
9797
</dict>
9898
</array>
9999
<key>CFBundleVersion</key>
100-
<string>3.0</string>
100+
<string>1.0</string>
101101
<key>GCSupportsControllerUserInteraction</key>
102102
<true/>
103103
<key>UILaunchStoryboardName</key>

Natives/JavaLauncher.m

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,15 @@
2020

2121
extern char **environ;
2222

23+
BOOL validateVirtualMemorySpace(int size) {
24+
size <<= 20; // convert to MB
25+
void *map = mmap(0, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
26+
// check if process successfully maps and unmaps a contiguous range
27+
if(map == MAP_FAILED || munmap(map, size) != 0)
28+
return NO;
29+
return YES;
30+
}
31+
2332
void init_loadDefaultEnv() {
2433
/* Define default env */
2534

@@ -162,11 +171,16 @@ int launchJVM(NSString *username, id launchTarget, int width, int height, int mi
162171
int allocmem;
163172
if (getPrefBool(@"java.auto_ram")) {
164173
CGFloat autoRatio = getEntitlementValue(@"com.apple.private.memorystatus") ? 0.4 : 0.25;
165-
allocmem = roundf((NSProcessInfo.processInfo.physicalMemory / 1048576) * autoRatio);
174+
allocmem = roundf((NSProcessInfo.processInfo.physicalMemory >> 20) * autoRatio);
166175
} else {
167176
allocmem = getPrefInt(@"java.allocated_memory");
168177
}
169178
NSLog(@"[JavaLauncher] Max RAM allocation is set to %d MB", allocmem);
179+
if (!validateVirtualMemorySpace(allocmem)) {
180+
UIKit_returnToSplitView();
181+
showDialog(localize(@"Error", nil), @"Insufficient contiguous virtual memory space. Lower memory allocation and try again.");
182+
return 1;
183+
}
170184

171185
int margc = -1;
172186
const char *margv[1000];

Natives/LauncherPreferences.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ void resetWarnings();
1818
BOOL getEntitlementValue(NSString *key);
1919

2020
UIEdgeInsets getDefaultSafeArea();
21-
CGRect getSafeArea();
22-
void setSafeArea(CGRect safeArea);
21+
CGRect getSafeArea(CGRect screenBounds);
22+
void setSafeArea(CGSize screenSize, CGRect safeArea);
2323

2424
NSString* getSelectedJavaHome(NSString* defaultJRETag, int minVersion);
2525

Natives/LauncherPreferences.m

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,15 @@ void resetWarnings() {
5858

5959
#pragma mark Safe area
6060

61-
CGRect getSafeArea() {
62-
CGRect screenBounds = UIScreen.mainScreen.bounds;
61+
CGRect getSafeArea(CGRect screenBounds) {
6362
UIEdgeInsets safeArea = UIEdgeInsetsFromString(getPrefObject(@"control.control_safe_area"));
6463
if (screenBounds.size.width < screenBounds.size.height) {
6564
safeArea = UIEdgeInsetsMake(safeArea.right, safeArea.top, safeArea.left, safeArea.bottom);
6665
}
6766
return UIEdgeInsetsInsetRect(screenBounds, safeArea);
6867
}
6968

70-
void setSafeArea(CGRect frame) {
71-
CGSize screenSize = UIScreen.mainScreen.bounds.size;
69+
void setSafeArea(CGSize screenSize, CGRect frame) {
7270
UIEdgeInsets safeArea;
7371
// TODO: make safe area consistent across opposite orientations?
7472
if (screenSize.width < screenSize.height) {

Natives/LauncherPreferencesViewController.m

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,11 @@ - (void)viewDidLoad
211211
@"icon": @"speaker.zzz",
212212
@"type": self.typeSwitch
213213
},
214+
@{@"key": @"allow_microphone",
215+
@"hasDetail": @YES,
216+
@"icon": @"mic",
217+
@"type": self.typeSwitch
218+
},
214219
], @[
215220
// Control settings
216221
@{@"icon": @"gamecontroller"},
@@ -395,6 +400,12 @@ - (void)viewDidLoad
395400
if (self.navigationController == nil) {
396401
self.tableView.alpha = 0.9;
397402
}
403+
if (NSProcessInfo.processInfo.isMacCatalystApp) {
404+
UIButton *closeButton = [UIButton buttonWithType:UIButtonTypeClose];
405+
closeButton.frame = CGRectOffset(closeButton.frame, 10, 10);
406+
[closeButton addTarget:self action:@selector(actionClose) forControlEvents:UIControlEventTouchUpInside];
407+
[self.view addSubview:closeButton];
408+
}
398409
}
399410

400411
- (void)viewWillDisappear:(BOOL)animated {
@@ -404,6 +415,10 @@ - (void)viewWillDisappear:(BOOL)animated {
404415
}
405416
}
406417

418+
- (void)actionClose {
419+
[self dismissViewControllerAnimated:YES completion:nil];
420+
}
421+
407422
#pragma mark UITableView
408423

409424
- (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section {

Natives/LauncherProfilesViewController.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
#import "LauncherProfilesViewController.h"
88
//#import "NSFileManager+NRFileManager.h"
99
#import "PLProfiles.h"
10+
#pragma clang diagnostic push
11+
#pragma clang diagnostic ignored "-Wunguarded-availability-new"
1012
#import "UIKit+AFNetworking.h"
13+
#pragma clang diagnostic pop
1114
#import "UIKit+hook.h"
1215
#import "installer/FabricInstallViewController.h"
1316
#import "installer/ForgeInstallViewController.h"

0 commit comments

Comments
 (0)