Skip to content

feat: use androidx.browser for AuthenticatorActivity#16766

Open
mykh-hailo wants to merge 2 commits intonextcloud:masterfrom
mykh-hailo:feat/authenticator-browser
Open

feat: use androidx.browser for AuthenticatorActivity#16766
mykh-hailo wants to merge 2 commits intonextcloud:masterfrom
mykh-hailo:feat/authenticator-browser

Conversation

@mykh-hailo
Copy link
Copy Markdown
Contributor

@mykh-hailo mykh-hailo commented Mar 28, 2026

Summary

Use Chrome Custom Tabs (CustomTabsIntent) for login flow v2 instead of opening the default browser with ACTION_VIEW and FLAG_ACTIVITY_NEW_TASK. Users stay in the Nextcloud app task while authentication still runs in their default browser engine, and closing the tab returns them to the in-progress login screen without manually switching apps.

Closes: #15984

Changes

  • AuthenticatorActivity: Open the v2 login URL via CustomTabsIntent (toolbar tinted with R.color.primary, system color scheme, title shown, share disabled for a cleaner UI). Fallback to ACTION_VIEW without FLAG_ACTIVITY_NEW_TASK if Custom Tabs cannot be used.
  • Dependencies: Add androidx.browser:browser (version catalog + app module).
  • Manifest: Declare a intent for CustomTabsService so a Custom Tabs provider can be resolved on API 30+.

@alperozturk96 alperozturk96 force-pushed the feat/authenticator-browser branch from 2eac820 to c965a88 Compare March 30, 2026 07:42
@mykh-hailo
Copy link
Copy Markdown
Contributor Author

@alperozturk96 I'd appreciate it if you provide me any feedback on this PR.

@alperozturk96 alperozturk96 force-pushed the feat/authenticator-browser branch from c965a88 to 58a12a8 Compare March 31, 2026 06:34
Copy link
Copy Markdown
Collaborator

@alperozturk96 alperozturk96 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello

Thank you for the PR. This is definitely an improvement.

When I checked the API, I noticed a better alternative: AuthTabIntent.

Can we use this?

Additionally, I noticed that the user still needs to open the app switcher and go back to the app. I couldn’t find a way to eliminate this.

Also, please be aware that it must behave exactly the same as master for the following scenarios:

  • User enters the URL to log in for the first time
  • User enters the same URL to log in again with different user name
  • User enters a different URL to log in for the first time

@mykh-hailo
Copy link
Copy Markdown
Contributor Author

@alperozturk96 I read through the code and looks like it cannot perfectly solved only on android.
My suggestion is to open deep link from the nextcloud server to handle authentication success.
Can you share your opinion about it please?

@mykh-hailo
Copy link
Copy Markdown
Contributor Author

@alperozturk96 I read through the code and looks like it cannot perfectly solved only on android. My suggestion is to open deep link from the nextcloud server to handle authentication success. Can you share your opinion about it please?

@alperozturk96 I'd appreciate it if you share any opinion about this.

@alperozturk96
Copy link
Copy Markdown
Collaborator

alperozturk96 commented Apr 7, 2026

@alperozturk96 I read through the code and looks like it cannot perfectly solved only on android. My suggestion is to open deep link from the nextcloud server to handle authentication success. Can you share your opinion about it please?

For now, we can proceed with using AuthTabIntent within this PR, and address deep-link handling in a separate issue later. This approach should help avoid blocking the entire PR.

Please let me know if this works for you. Thank you.

Signed-off-by: mykh-hailo <kristianderonta0205@gmail.com>
@mykh-hailo mykh-hailo force-pushed the feat/authenticator-browser branch 2 times, most recently from 11e56f1 to 176198e Compare April 7, 2026 12:28
@mykh-hailo
Copy link
Copy Markdown
Contributor Author

@alperozturk96 I replaced the CustomTabsIntent with AuthTabIntent.
Could you check my update again please?
Thank you.

Copy link
Copy Markdown
Collaborator

@alperozturk96 alperozturk96 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey

Thanks for the update.

<package android:name="org.fairscan.app" />

<intent>
<action android:name="android.support.customtabs.action.CustomTabsService" />
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we need this? I removed this and still worked.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed it. Can you check again please?

@alperozturk96
Copy link
Copy Markdown
Collaborator

@tobiasKaminsky I tested this PR and it seems to behave the same as the master branch.

When a user enters the URL to log in for the first time, they are prompted to enter a username and password. However, if the user visits the same URL again to log in with a different account, the previously logged-in account is shown, and only the “Grant Access” option is available.

To log in with a different account, the user must clear the browser’s history (or session data). After doing so, they can log in with another account. This behavior is the same as in the master branch.

Signed-off-by: mykh-hailo <kristianderonta0205@gmail.com>
@mykh-hailo mykh-hailo force-pushed the feat/authenticator-browser branch from 176198e to dd5451a Compare April 7, 2026 13:40
@mykh-hailo mykh-hailo requested a review from alperozturk96 April 7, 2026 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use androidx.browser for AuthenticatorActivity

2 participants