use of org.chromium.chrome.browser.ChromeTabbedActivity2 in project AndroidChromium by JackyAndroid.
the class ExternalNavigationDelegateImpl method maybeSetWindowId.
@Override
public void maybeSetWindowId(Intent intent) {
Context context = getAvailableContext();
if (!(context instanceof ChromeTabbedActivity2))
return;
intent.putExtra(IntentHandler.EXTRA_WINDOW_ID, 2);
}
use of org.chromium.chrome.browser.ChromeTabbedActivity2 in project AndroidChromium by JackyAndroid.
the class MultiWindowUtils method getTabbedActivityForIntent.
/**
* Determines the correct ChromeTabbedActivity class to use for an incoming intent.
* @param intent The incoming intent that is starting ChromeTabbedActivity.
* @param context The current Context, used to retrieve the ActivityManager system service.
* @return The ChromeTabbedActivity to use for the incoming intent.
*/
public Class<? extends ChromeTabbedActivity> getTabbedActivityForIntent(Intent intent, Context context) {
// ChromeTabbedActivity2 isn't running.
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.M || (mTabbedActivity2TaskRunning != null && !mTabbedActivity2TaskRunning)) {
return ChromeTabbedActivity.class;
}
// 2. If the intent has a window id set, use that.
if (intent.hasExtra(IntentHandler.EXTRA_WINDOW_ID)) {
int windowId = IntentUtils.safeGetIntExtra(intent, IntentHandler.EXTRA_WINDOW_ID, 0);
if (windowId == 1)
return ChromeTabbedActivity.class;
if (windowId == 2)
return ChromeTabbedActivity2.class;
}
// 3. If only one ChromeTabbedActivity is currently in Android recents, use it.
boolean tabbed2TaskRunning = isActivityTaskInRecents(ChromeTabbedActivity2.class.getName(), context);
// Exit early if ChromeTabbedActivity2 isn't running.
if (!tabbed2TaskRunning) {
mTabbedActivity2TaskRunning = false;
return ChromeTabbedActivity.class;
}
boolean tabbedTaskRunning = isActivityTaskInRecents(ChromeTabbedActivity.class.getName(), context);
if (!tabbedTaskRunning) {
return ChromeTabbedActivity2.class;
}
// 4. If only one of the ChromeTabbedActivity's is currently visible use it.
// e.g. ChromeTabbedActivity is docked to the top of the screen and another app is docked
// to the bottom.
// Find the activities.
Activity tabbedActivity = null;
Activity tabbedActivity2 = null;
for (WeakReference<Activity> reference : ApplicationStatus.getRunningActivities()) {
Activity activity = reference.get();
if (activity == null)
continue;
if (activity.getClass().equals(ChromeTabbedActivity.class)) {
tabbedActivity = activity;
} else if (activity.getClass().equals(ChromeTabbedActivity2.class)) {
tabbedActivity2 = activity;
}
}
// Determine if only one is visible.
boolean tabbedActivityVisible = isActivityVisible(tabbedActivity);
boolean tabbedActivity2Visible = isActivityVisible(tabbedActivity2);
if (tabbedActivityVisible ^ tabbedActivity2Visible) {
if (tabbedActivityVisible)
return ChromeTabbedActivity.class;
return ChromeTabbedActivity2.class;
}
// 5. Use the ChromeTabbedActivity that was resumed most recently if it's still running.
if (mLastResumedTabbedActivity != null) {
ChromeTabbedActivity lastResumedActivity = mLastResumedTabbedActivity.get();
if (lastResumedActivity != null) {
Class<?> lastResumedClassName = lastResumedActivity.getClass();
if (tabbedTaskRunning && lastResumedClassName.equals(ChromeTabbedActivity.class)) {
return ChromeTabbedActivity.class;
}
if (tabbed2TaskRunning && lastResumedClassName.equals(ChromeTabbedActivity2.class)) {
return ChromeTabbedActivity2.class;
}
}
}
// 6. Default to regular ChromeTabbedActivity.
return ChromeTabbedActivity.class;
}
Aggregations