fix start failed when credential has expired
This commit is contained in:
parent
5ccbff594f
commit
3e72a2672b
|
@ -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<Task<AuthInfo>> 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<Task<AuthInfo>> future;
|
||||
|
||||
private FCLButton skip;
|
||||
private FCLButton ok;
|
||||
|
||||
public TipReLoginLoginDialog(@NonNull Context context, Account account, CompletableFuture<Task<AuthInfo>> 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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:padding="10dp"
|
||||
android:layout_width="400dp"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.tungsten.fcllibrary.component.view.FCLTextView
|
||||
android:id="@+id/title"
|
||||
android:text="@string/account_failed"
|
||||
android:singleLine="true"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"/>
|
||||
|
||||
<com.tungsten.fcllibrary.component.view.FCLTextView
|
||||
android:text="@string/account_failed_expired"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintTop_toBottomOf="@+id/title"
|
||||
app:layout_constraintBottom_toTopOf="@id/ok"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginBottom="10dp"/>
|
||||
|
||||
<com.tungsten.fcllibrary.component.view.FCLButton
|
||||
android:id="@+id/skip"
|
||||
android:text="@string/action_skip"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="10dp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"/>
|
||||
|
||||
<com.tungsten.fcllibrary.component.view.FCLButton
|
||||
android:id="@+id/ok"
|
||||
android:text="@string/dialog_positive"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -895,4 +895,5 @@
|
|||
<string name="world_show_all">显示全部</string>
|
||||
<string name="world_time">yyyy 年 MM 月 dd 日 HH:mm:ss</string>
|
||||
<string name="menu_settings_gamepad_aimzone">辅助瞄准区</string>
|
||||
<string name="account_failed_expired">凭据已过期,请删除账户重新登录。</string>
|
||||
</resources>
|
|
@ -57,6 +57,7 @@
|
|||
<string name="account_methods_authlib_injector">External Account</string>
|
||||
<string name="account_methods_microsoft">Microsoft Account</string>
|
||||
<string name="account_failed">Account refresh failed</string>
|
||||
<string name="account_failed_expired">Credential has expired, you must delete your account and re-login.</string>
|
||||
<string name="account_failed_no_character">There are no characters linked to this account.</string>
|
||||
<string name="account_failed_connect_authentication_server">Unable to contact authentication servers, your Internet connection may be down.</string>
|
||||
<string name="account_failed_connect_injector_server">Unable to connect to the authentication server. Please check your network and make sure you entered the correct URL.</string>
|
||||
|
|
Loading…
Reference in New Issue