Fix compatibility problems with some browsers

Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
alperozturk 2024-05-21 11:52:24 +02:00 committed by Alper Öztürk
parent 4ecce019a4
commit 2082b625ec

View file

@ -143,6 +143,9 @@ import androidx.fragment.app.DialogFragment;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.LifecycleEventObserver;
import androidx.lifecycle.ProcessLifecycleOwner;
import de.cotech.hw.fido.WebViewFidoBridge;
import de.cotech.hw.fido.ui.FidoDialogOptions;
import de.cotech.hw.fido2.WebViewWebauthnBridge;
@ -360,10 +363,18 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
}
initServerPreFragment(savedInstanceState);
ProcessLifecycleOwner.get().getLifecycle().addObserver(lifecycleEventObserver);
// webViewUtil.checkWebViewVersion();
}
private final LifecycleEventObserver lifecycleEventObserver = ((lifecycleOwner, event) -> {
if (event == Lifecycle.Event.ON_START && token != null) {
Log_OC.d(TAG, "Start poolLogin");
poolLogin(clientFactory.createPlainClient());
}
});
private void deleteCookies() {
try {
CookieSyncManager.createInstance(this);
@ -403,7 +414,8 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
String loginUrl = login;
runOnUiThread(() -> {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(loginUrl));
loginFlowResultLauncher.launch(intent);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
});
token = jsonObject.getAsJsonObject("poll").get("token").getAsString();
@ -412,9 +424,6 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
thread.start();
}
private final ActivityResultLauncher<Intent> loginFlowResultLauncher = registerForActivityResult(
new ActivityResultContracts.StartActivityForResult(), result -> poolLogin(clientFactory.createPlainClient()));
private static String getWebLoginUserAgent() {
return Build.MANUFACTURER.substring(0, 1).toUpperCase(Locale.getDefault()) +
Build.MANUFACTURER.substring(1).toLowerCase(Locale.getDefault()) + " " + Build.MODEL + " (Android)";
@ -828,6 +837,8 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
mOperationsServiceBinder = null;
}
Log_OC.d(TAG, "AuthenticatorActivity onDestroy called");
super.onDestroy();
}
@ -1039,6 +1050,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
cancelButton.setOnClickListener(v -> {
loginFlowExecutorService.shutdown();
ProcessLifecycleOwner.get().getLifecycle().removeObserver(lifecycleEventObserver);
recreate();
});
}
@ -1638,7 +1650,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
private boolean isRedirectedToTheDefaultBrowser = false;
private void poolLogin(PlainClient client) {
loginFlowExecutorService.scheduleAtFixedRate(() -> {
loginFlowExecutorService.scheduleWithFixedDelay(() -> {
if (!isLoginProcessCompleted) {
performLoginFlowV2(client);
}
@ -1694,6 +1706,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
checkOcServer();
loginFlowExecutorService.shutdown();
ProcessLifecycleOwner.get().getLifecycle().removeObserver(lifecycleEventObserver);
}
/**