Skip to content

Commit

Permalink
Merge pull request #121 from auth0/fix-cct-resume-issue
Browse files Browse the repository at this point in the history
Make CCT stay alive when activity is paused
  • Loading branch information
aaguiarz authored Oct 5, 2017
2 parents ed6b146 + 9dcd91a commit a669931
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ public void run() {
final Intent intent = new CustomTabsIntent.Builder(session.get())
.build()
.intent;
intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
intent.setData(uri);
try {
context.startActivity(intent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
* It can use an external browser by sending the {@link android.content.Intent#ACTION_VIEW} intent or also the {@link WebAuthActivity}.
* This behaviour is changed using {@link WebAuthProvider.Builder#useBrowser(boolean)}, and defaults to use browser.
*/
@SuppressWarnings("WeakerAccess")
public class WebAuthProvider {

private static final String TAG = WebAuthProvider.class.getName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
import java.util.ArrayList;
import java.util.List;

import static android.support.test.espresso.intent.matcher.IntentMatchers.hasFlag;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.Matchers.nullValue;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
Expand Down Expand Up @@ -162,7 +164,7 @@ public void shouldBindAndLaunchUri() throws Exception {
assertThat(intent.getAction(), is(Intent.ACTION_VIEW));
assertThat(intent.hasExtra(CustomTabsIntent.EXTRA_SESSION), is(true));
assertThat(intent.getData(), is(uri));
assertThat(intent.getFlags() & Intent.FLAG_ACTIVITY_NO_HISTORY, is(Intent.FLAG_ACTIVITY_NO_HISTORY));
assertThat(intent, not(hasFlag(Intent.FLAG_ACTIVITY_NO_HISTORY)));
}

@Test
Expand All @@ -174,7 +176,8 @@ public void shouldFailToBindButLaunchUri() throws Exception {
Intent intent = launchIntentCaptor.getValue();
assertThat(intent.getAction(), is(Intent.ACTION_VIEW));
assertThat(intent.getData(), is(uri));
assertThat(intent.getFlags() & Intent.FLAG_ACTIVITY_NO_HISTORY, is(Intent.FLAG_ACTIVITY_NO_HISTORY));
assertThat(intent.hasExtra(CustomTabsIntent.EXTRA_SESSION), is(true));
assertThat(intent, not(hasFlag(Intent.FLAG_ACTIVITY_NO_HISTORY)));
}

@Test
Expand All @@ -198,13 +201,13 @@ public void shouldLaunchUriWithFallbackIfCustomTabIntentFails() throws Exception
Intent customTabIntent = intents.get(0);
assertThat(customTabIntent.getAction(), is(Intent.ACTION_VIEW));
assertThat(customTabIntent.getData(), is(uri));
assertThat(customTabIntent.getFlags() & Intent.FLAG_ACTIVITY_NO_HISTORY, is(Intent.FLAG_ACTIVITY_NO_HISTORY));
assertThat(customTabIntent, not(hasFlag(Intent.FLAG_ACTIVITY_NO_HISTORY)));
assertThat(customTabIntent.hasExtra(CustomTabsIntent.EXTRA_SESSION), is(true));

Intent fallbackIntent = intents.get(1);
assertThat(fallbackIntent.getAction(), is(Intent.ACTION_VIEW));
assertThat(fallbackIntent.getData(), is(uri));
assertThat(fallbackIntent.getFlags() & Intent.FLAG_ACTIVITY_NO_HISTORY, is(Intent.FLAG_ACTIVITY_NO_HISTORY));
assertThat(fallbackIntent, hasFlag(Intent.FLAG_ACTIVITY_NO_HISTORY));
assertThat(fallbackIntent.hasExtra(CustomTabsIntent.EXTRA_SESSION), is(false));
}

Expand Down

0 comments on commit a669931

Please sign in to comment.