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());
}
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();
}
}
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);
}
Aggregations