Commit 16920f1d authored by twellington's avatar twellington Committed by Commit bot

Introduce MultiWindowUtils#isLegacyMultiWindow()

MultiWindowUtils#isLecacyMultiWindow() will check for old multi-window
mode (e.g. Samsung's multi-window mode), and #isMultiWindow() will check
for Android N multi-window.

BUG=570741

Review URL: https://codereview.chromium.org/1633763003

Cr-Commit-Position: refs/heads/master@{#371631}
parent 45a4b5a7
...@@ -208,7 +208,8 @@ public class ChromeApplication extends ContentApplication { ...@@ -208,7 +208,8 @@ public class ChromeApplication extends ContentApplication {
} }
// For multiwindow mode we do not track keyboard visibility. // For multiwindow mode we do not track keyboard visibility.
return activity != null && MultiWindowUtils.getInstance().isMultiWindow(activity); return activity != null
&& MultiWindowUtils.getInstance().isLegacyMultiWindow(activity);
} }
}); });
......
...@@ -129,7 +129,8 @@ public class CompositorView ...@@ -129,7 +129,8 @@ public class CompositorView
mPreviousWindowTop = windowTop; mPreviousWindowTop = windowTop;
Activity activity = mWindowAndroid != null ? mWindowAndroid.getActivity().get() : null; Activity activity = mWindowAndroid != null ? mWindowAndroid.getActivity().get() : null;
boolean isMultiWindow = MultiWindowUtils.getInstance().isMultiWindow(activity); boolean isMultiWindow = MultiWindowUtils.getInstance().isLegacyMultiWindow(activity)
|| MultiWindowUtils.getInstance().isMultiWindow(activity);
// If the measured width is the same as the allowed width (i.e. the orientation has // If the measured width is the same as the allowed width (i.e. the orientation has
// not changed) and multi-window mode is off, use the largest measured height seen thus // not changed) and multi-window mode is off, use the largest measured height seen thus
......
...@@ -41,13 +41,23 @@ public class MultiWindowUtils { ...@@ -41,13 +41,23 @@ public class MultiWindowUtils {
/** /**
* @param activity The {@link Activity} to check. * @param activity The {@link Activity} to check.
* @return Whether or not {@code activity} is currently in multi-window mode. * @return Whether or not {@code activity} is currently in Android N+ multi-window mode.
*/ */
public boolean isMultiWindow(Activity activity) { public boolean isMultiWindow(Activity activity) {
// This logic is overridden in a subclass. // This logic is overridden in a subclass.
return false; return false;
} }
/**
* @param activity The {@link Activity} to check.
* @return Whether or not {@code activity} is currently in legacy pre-N multi-window mode
* (e.g. Samsung's multi-window mode).
*/
public boolean isLegacyMultiWindow(Activity activity) {
// This logic is overridden in a subclass.
return false;
}
/** /**
* @param activity The {@link Activity} to check. * @param activity The {@link Activity} to check.
* @return Whether or not {@code activity} should run in multi-instance mode. * @return Whether or not {@code activity} should run in multi-instance mode.
...@@ -55,7 +65,7 @@ public class MultiWindowUtils { ...@@ -55,7 +65,7 @@ public class MultiWindowUtils {
public boolean shouldRunInMultiInstanceMode(ChromeLauncherActivity activity) { public boolean shouldRunInMultiInstanceMode(ChromeLauncherActivity activity) {
return Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP return Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP
&& TextUtils.equals(activity.getIntent().getAction(), Intent.ACTION_MAIN) && TextUtils.equals(activity.getIntent().getAction(), Intent.ACTION_MAIN)
&& isMultiWindow(activity) && isLegacyMultiWindow(activity)
&& activity.isChromeBrowserActivityRunning(); && activity.isChromeBrowserActivityRunning();
} }
...@@ -64,7 +74,7 @@ public class MultiWindowUtils { ...@@ -64,7 +74,7 @@ public class MultiWindowUtils {
*/ */
@TargetApi(Build.VERSION_CODES.LOLLIPOP) @TargetApi(Build.VERSION_CODES.LOLLIPOP)
public void makeMultiInstanceIntent(Activity activity, Intent intent) { public void makeMultiInstanceIntent(Activity activity, Intent intent) {
if (activity instanceof ChromeLauncherActivity && isMultiWindow(activity)) { if (activity instanceof ChromeLauncherActivity && isLegacyMultiWindow(activity)) {
if (TextUtils.equals(ChromeTabbedActivity.class.getName(), if (TextUtils.equals(ChromeTabbedActivity.class.getName(),
intent.getComponent().getClassName())) { intent.getComponent().getClassName())) {
intent.setClassName(activity, MultiInstanceChromeTabbedActivity.class.getName()); intent.setClassName(activity, MultiInstanceChromeTabbedActivity.class.getName());
......
...@@ -52,7 +52,7 @@ public class DataReductionPromoScreen extends Dialog implements View.OnClickList ...@@ -52,7 +52,7 @@ public class DataReductionPromoScreen extends Dialog implements View.OnClickList
if (getDisplayedDataReductionPromo(parentActivity)) return; if (getDisplayedDataReductionPromo(parentActivity)) return;
// Showing the promo dialog in multiwindow mode is broken on Galaxy Note devices: // Showing the promo dialog in multiwindow mode is broken on Galaxy Note devices:
// http://crbug.com/354696. If we're in multiwindow mode, save the dialog for later. // http://crbug.com/354696. If we're in multiwindow mode, save the dialog for later.
if (MultiWindowUtils.getInstance().isMultiWindow(parentActivity)) return; if (MultiWindowUtils.getInstance().isLegacyMultiWindow(parentActivity)) return;
DataReductionPromoScreen promoScreen = new DataReductionPromoScreen(parentActivity); DataReductionPromoScreen promoScreen = new DataReductionPromoScreen(parentActivity);
promoScreen.setOnDismissListener(promoScreen); promoScreen.setOnDismissListener(promoScreen);
......
...@@ -48,7 +48,7 @@ public class SigninPromoScreen ...@@ -48,7 +48,7 @@ public class SigninPromoScreen
// navigate to and view a URL on startup), the instance is part of the field trial, // navigate to and view a URL on startup), the instance is part of the field trial,
// and the promo has been marked to display. // and the promo has been marked to display.
ChromePreferenceManager preferenceManager = ChromePreferenceManager.getInstance(activity); ChromePreferenceManager preferenceManager = ChromePreferenceManager.getInstance(activity);
if (MultiWindowUtils.getInstance().isMultiWindow(activity)) return false; if (MultiWindowUtils.getInstance().isLegacyMultiWindow(activity)) return false;
if (!preferenceManager.getShowSigninPromo()) return false; if (!preferenceManager.getShowSigninPromo()) return false;
preferenceManager.setShowSigninPromo(false); preferenceManager.setShowSigninPromo(false);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment