Search in sources :

Example 21 with SafeIntent

use of mozilla.components.utils.SafeIntent in project focus-android by mozilla-mobile.

the class SessionManagerTest method testShareIntentViaNewIntent.

@Test
public void testShareIntentViaNewIntent() {
    final SessionManager sessionManager = SessionManager.getInstance();
    final Intent unsafeIntent = new Intent(Intent.ACTION_SEND);
    unsafeIntent.putExtra(Intent.EXTRA_TEXT, TEST_URL);
    sessionManager.handleNewIntent(RuntimeEnvironment.application, new SafeIntent(unsafeIntent));
    final List<Session> sessions = sessionManager.getSessions().getValue();
    assertNotNull(sessions);
    assertEquals(1, sessions.size());
    final Session session = sessions.get(0);
    assertFalse(session.isSearch());
    assertEquals(TEST_URL, session.getUrl().getValue());
    assertFalse(session.isCustomTab());
    assertNull(session.getCustomTabConfig());
    assertTrue(sessionManager.hasSession());
}
Also used : SafeIntent(mozilla.components.utils.SafeIntent) CustomTabsIntent(android.support.customtabs.CustomTabsIntent) Intent(android.content.Intent) SafeIntent(mozilla.components.utils.SafeIntent) Test(org.junit.Test)

Example 22 with SafeIntent

use of mozilla.components.utils.SafeIntent in project focus-android by mozilla-mobile.

the class MainActivity method onNewIntent.

@Override
protected void onNewIntent(Intent unsafeIntent) {
    final SafeIntent intent = new SafeIntent(unsafeIntent);
    sessionManager.handleNewIntent(this, intent);
    final String action = intent.getAction();
    if (ACTION_OPEN.equals(action)) {
        TelemetryWrapper.openNotificationActionEvent();
    }
    if (ACTION_ERASE.equals(action)) {
        processEraseAction(intent);
    }
    if (intent.isLauncherIntent()) {
        TelemetryWrapper.resumeFromIconEvent();
    }
}
Also used : SafeIntent(mozilla.components.utils.SafeIntent)

Example 23 with SafeIntent

use of mozilla.components.utils.SafeIntent in project focus-android by mozilla-mobile.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (Settings.getInstance(this).shouldUseSecureMode()) {
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
    }
    getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
    setContentView(R.layout.activity_main);
    final SafeIntent intent = new SafeIntent(getIntent());
    if (intent.isLauncherIntent()) {
        TelemetryWrapper.openFromIconEvent();
    }
    sessionManager.handleIntent(this, intent, savedInstanceState);
    registerSessionObserver();
    WebViewProvider.preload(this);
}
Also used : SafeIntent(mozilla.components.utils.SafeIntent)

Aggregations

SafeIntent (mozilla.components.utils.SafeIntent)23 CustomTabsIntent (android.support.customtabs.CustomTabsIntent)20 Test (org.junit.Test)19 Intent (android.content.Intent)10 Bitmap (android.graphics.Bitmap)5 PendingIntent (android.app.PendingIntent)3 Bundle (android.os.Bundle)3 CustomTabConfig (org.mozilla.focus.customtabs.CustomTabConfig)2 Parcel (android.os.Parcel)1 RequiresApi (android.support.annotation.RequiresApi)1 Field (java.lang.reflect.Field)1