Skip to content

Commit 6301f77

Browse files
authored
Bring app to foreground after authentication (#85)
* Add onLoginSuccess implementation to CustomTabURLOpener This will bring the app's main activity to foreground after successful authentication * Check isOpened is set to true on 'onLoginSuccess' callback * Update submodule reference and URL to forked repo Once the forked repo's PR is approved, it will be changed back to the original URL * Update submodule reference and URL back to main
1 parent 4ff2356 commit 6301f77

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

app/src/main/java/io/netbird/client/CustomTabURLOpener.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import io.netbird.gomobile.android.URLOpener;
1515

1616
public class CustomTabURLOpener implements URLOpener {
17+
private static final String TAG = "CustomTabURLOpener";
1718
private final AppCompatActivity context;
1819
private final ActivityResultLauncher<Intent> customTabLauncher;
1920

@@ -42,6 +43,18 @@ public boolean isOpened() {
4243
}
4344

4445

46+
@Override
47+
public void onLoginSuccess() {
48+
Log.d(TAG, "onLoginSuccess fired.");
49+
50+
if (isOpened) {
51+
Intent i = new Intent(this.context, MainActivity.class);
52+
i.setAction(Intent.ACTION_MAIN);
53+
i.addCategory(Intent.CATEGORY_LAUNCHER);
54+
this.context.startActivity(i);
55+
}
56+
}
57+
4558
@Override
4659
public void open(String url) {
4760
isOpened = true;
@@ -51,7 +64,7 @@ public void open(String url) {
5164
intent.setData(Uri.parse(url));
5265
customTabLauncher.launch(intent);
5366
} catch (Exception e) {
54-
Log.e("CustomTabURLOpener", "Failed to launch CustomTab: " + e.getMessage());
67+
Log.e(TAG, "Failed to launch CustomTab: " + e.getMessage());
5568
if (context instanceof OnCustomTabResult) {
5669
((OnCustomTabResult) context).onClosed();
5770
}

0 commit comments

Comments
 (0)