diff --git a/FCL/src/main/java/com/tungsten/fcl/game/LauncherHelper.java b/FCL/src/main/java/com/tungsten/fcl/game/LauncherHelper.java index cc2e5d55..4d5e73c0 100644 --- a/FCL/src/main/java/com/tungsten/fcl/game/LauncherHelper.java +++ b/FCL/src/main/java/com/tungsten/fcl/game/LauncherHelper.java @@ -34,7 +34,6 @@ import com.tungsten.fcl.control.MenuType; import com.tungsten.fcl.setting.Profile; import com.tungsten.fcl.setting.VersionSetting; import com.tungsten.fcl.ui.TaskDialog; -import com.tungsten.fcl.ui.account.AccountListItem; import com.tungsten.fcl.util.TaskCancellationAction; import com.tungsten.fclauncher.utils.FCLPath; import com.tungsten.fclcore.auth.Account; @@ -311,7 +310,12 @@ public final class LauncherHelper { } catch (CredentialExpiredException e) { LOG.log(Level.INFO, "Credential has expired", e); - return Task.completed(AccountListItem.logIn(account)); + CompletableFuture> future = new CompletableFuture<>(); + Schedulers.androidUIThread().execute(() -> { + TipReLoginLoginDialog dialog = new TipReLoginLoginDialog(context, account, future); + dialog.show(); + }); + return Task.fromCompletableFuture(future).thenComposeAsync(task -> task); } catch (AuthenticationException e) { LOG.log(Level.WARNING, "Authentication failed, try skipping refresh", e); @@ -368,4 +372,41 @@ public final class LauncherHelper { } } + static class TipReLoginLoginDialog extends FCLDialog implements View.OnClickListener { + + private final Account account; + private final CompletableFuture> future; + + private FCLButton skip; + private FCLButton ok; + + public TipReLoginLoginDialog(@NonNull Context context, Account account, CompletableFuture> future) { + super(context); + this.account = account; + this.future = future; + setContentView(R.layout.dialog_tip_relogin); + setCancelable(false); + + skip = findViewById(R.id.skip); + ok = findViewById(R.id.ok); + skip.setOnClickListener(this); + ok.setOnClickListener(this); + } + + @Override + public void onClick(View view) { + if (view == skip) { + try { + future.complete(Task.completed(account.playOffline())); + } catch (AuthenticationException e2) { + future.completeExceptionally(e2); + } + } + if (view == ok) { + future.completeExceptionally(new CancellationException()); + } + dismiss(); + } + } + } diff --git a/FCL/src/main/res/layout/dialog_tip_relogin.xml b/FCL/src/main/res/layout/dialog_tip_relogin.xml new file mode 100644 index 00000000..093288b7 --- /dev/null +++ b/FCL/src/main/res/layout/dialog_tip_relogin.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/FCL/src/main/res/values-zh/strings.xml b/FCL/src/main/res/values-zh/strings.xml index 7adaf570..7c00e881 100644 --- a/FCL/src/main/res/values-zh/strings.xml +++ b/FCL/src/main/res/values-zh/strings.xml @@ -895,4 +895,5 @@ 显示全部 yyyy 年 MM 月 dd 日 HH:mm:ss 辅助瞄准区 + 凭据已过期,请删除账户重新登录。 \ No newline at end of file diff --git a/FCL/src/main/res/values/strings.xml b/FCL/src/main/res/values/strings.xml index 3fc2ec7c..c7a75cc6 100644 --- a/FCL/src/main/res/values/strings.xml +++ b/FCL/src/main/res/values/strings.xml @@ -57,6 +57,7 @@ External Account Microsoft Account Account refresh failed + Credential has expired, you must delete your account and re-login. There are no characters linked to this account. Unable to contact authentication servers, your Internet connection may be down. Unable to connect to the authentication server. Please check your network and make sure you entered the correct URL.