diff --git a/JavaApp/src/main/java/net/kdt/pojavlaunch/authenticator/mojang/yggdrasil/YggdrasilAuthenticator.java b/JavaApp/src/main/java/net/kdt/pojavlaunch/authenticator/mojang/yggdrasil/YggdrasilAuthenticator.java index a238dd4f..ba7a1869 100644 --- a/JavaApp/src/main/java/net/kdt/pojavlaunch/authenticator/mojang/yggdrasil/YggdrasilAuthenticator.java +++ b/JavaApp/src/main/java/net/kdt/pojavlaunch/authenticator/mojang/yggdrasil/YggdrasilAuthenticator.java @@ -24,6 +24,7 @@ public class YggdrasilAuthenticator { HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestProperty("User-Agent", "Minecraft"); conn.setDoInput(true); + conn.setDoOutput(true); conn.setRequestMethod("POST"); conn.setRequestProperty("Content-Type", "application/json"); conn.connect(); diff --git a/JavaApp/src/main/java/net/kdt/pojavlaunch/uikit/AccountJNI.java b/JavaApp/src/main/java/net/kdt/pojavlaunch/uikit/AccountJNI.java index 41171e13..8fbb1559 100644 --- a/JavaApp/src/main/java/net/kdt/pojavlaunch/uikit/AccountJNI.java +++ b/JavaApp/src/main/java/net/kdt/pojavlaunch/uikit/AccountJNI.java @@ -21,7 +21,10 @@ public class AccountJNI { try { switch (type) { case TYPE_SELECTACC: - PojavProfile.updateTokens(username); + CURRENT_ACCOUNT = MinecraftAccount.load(username); + if (CURRENT_ACCOUNT.accessToken.length() > 5) { + PojavProfile.updateTokens(username); + } CURRENT_ACCOUNT = MinecraftAccount.load(username); break; diff --git a/Natives/LoginViewController.m b/Natives/LoginViewController.m index d2464517..f4c77013 100644 --- a/Natives/LoginViewController.m +++ b/Natives/LoginViewController.m @@ -11,7 +11,7 @@ #define TYPE_MOJANG 2 #define TYPE_OFFLINE 3 -void loginAccount(LoginViewController *controller, int type, char* username_c, char* password_c) { +void loginAccountInput(UINavigationController *controller, int type, char* username_c, char* password_c) { JNIEnv *env; (*runtimeJavaVMPtr)->AttachCurrentThread(runtimeJavaVMPtr, &env, NULL); @@ -30,7 +30,8 @@ void loginAccount(LoginViewController *controller, int type, char* username_c, c if (result == JNI_TRUE) { dispatch_async(dispatch_get_main_queue(), ^{ - [controller enterLauncher]; + LauncherViewController *vc = [[LauncherViewController alloc] init]; + [controller pushViewController:vc animated:YES]; }); } } @@ -144,7 +145,7 @@ void loginAccount(LoginViewController *controller, int type, char* username_c, c UITextField *passwordField = textFields[1]; const char *password = [passwordField.text UTF8String]; dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void){ - loginAccount(self, TYPE_MOJANG, username, password); + loginAccountInput(self.navigationController, TYPE_MOJANG, username, password); }); } else { if (usernameField.text.length < 3 || usernameField.text.length > 16) { @@ -152,7 +153,7 @@ void loginAccount(LoginViewController *controller, int type, char* username_c, c [self presentViewController:controller animated:YES completion:nil]; } else { dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void){ - loginAccount(self, TYPE_OFFLINE, username, ""); + loginAccountInput(self.navigationController, TYPE_OFFLINE, username, ""); }); } } @@ -166,7 +167,7 @@ void loginAccount(LoginViewController *controller, int type, char* username_c, c } - (void)loginMicrosoft { - [self enterLauncher]; + } - (void)loginOffline { @@ -178,11 +179,6 @@ void loginAccount(LoginViewController *controller, int type, char* username_c, c [self.navigationController pushViewController:vc animated:YES]; } -- (void)enterLauncher { - LauncherViewController *vc = [[LauncherViewController alloc] init]; - [self.navigationController pushViewController:vc animated:YES]; -} - @end @interface LoginListViewController () { @@ -251,8 +247,8 @@ NSMutableArray *accountList; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { - NSInteger rowNo = indexPath.row; - [self.navigationController popViewControllerAnimated:YES]; + NSString *str = [accountList objectAtIndex:indexPath.row]; + loginAccountInput(self.navigationController, TYPE_SELECTACC, [str UTF8String], ""); } - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { diff --git a/Natives/ios_uikit_bridge.m b/Natives/ios_uikit_bridge.m index 14d8056b..aad82ba1 100644 --- a/Natives/ios_uikit_bridge.m +++ b/Natives/ios_uikit_bridge.m @@ -27,19 +27,35 @@ dispatch_async(dispatch_get_main_queue(), ^{ UIAlertController* alert = [UIAlertController alertControllerWithTitle:@(title_c) message:@(message_c) preferredStyle:UIAlertControllerStyleAlert]; + NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init]; + style.alignment = NSTextAlignmentLeft; - UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault + NSMutableAttributedString *atrStr = [[NSMutableAttributedString alloc] initWithString:@(message_c) attributes:@{NSParagraphStyleAttributeName:style,NSFontAttributeName:[UIFont systemFontOfSize:13.0]}]; + + [alert setValue:atrStr forKey:@"attributedMessage"]; + + UIAlertAction* okAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) { + (*env)->ReleaseStringUTFChars(env, message, message_c); if (exitIfOk == JNI_TRUE) { exit(-1); } }]; - - [alert addAction:defaultAction]; + [alert addAction:okAction]; + + UIAlertAction* copyAction = [UIAlertAction actionWithTitle:@"Copy" style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) { + [[UIPasteboard generalPasteboard] setString:@(message_c)]; + (*env)->ReleaseStringUTFChars(env, message, message_c); + if (exitIfOk == JNI_TRUE) { + exit(-1); + } + }]; + [alert addAction:copyAction]; + [viewController presentViewController:alert animated:YES completion:nil]; (*env)->ReleaseStringUTFChars(env, title, title_c); - (*env)->ReleaseStringUTFChars(env, message, message_c); }); }