Commit 4d265fc5 authored by Jeffrey Cohen's avatar Jeffrey Cohen Committed by Commit Bot

[ShareButtonInToolbar] Minimum width driven via finch config.

Add a requirement for devices to have a min width, and use finch param.

Bug: 1036023
Change-Id: I75e15afc4ddd646f6d3f8577dae792160d13f215
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2088635
Commit-Queue: Jeffrey Cohen <jeffreycohen@chromium.org>
Reviewed-by: default avatarJeffrey Cohen <jeffreycohen@chromium.org>
Reviewed-by: default avatarHenrique Nakashima <hnakashima@chromium.org>
Reviewed-by: default avatarTheresa  <twellington@chromium.org>
Reviewed-by: default avatarDavid Trainor <dtrainor@chromium.org>
Cr-Commit-Position: refs/heads/master@{#751751}
parent 5c4646ad
...@@ -57,7 +57,6 @@ public class ChromeCachedFlags { ...@@ -57,7 +57,6 @@ public class ChromeCachedFlags {
ChromeFeatureList.PAINT_PREVIEW_DEMO, ChromeFeatureList.PAINT_PREVIEW_DEMO,
ChromeFeatureList.PRIORITIZE_BOOTSTRAP_TASKS, ChromeFeatureList.PRIORITIZE_BOOTSTRAP_TASKS,
ChromeFeatureList.INSTANT_START, ChromeFeatureList.INSTANT_START,
ChromeFeatureList.SHARE_BUTTON_IN_TOP_TOOLBAR,
ChromeFeatureList.START_SURFACE_ANDROID, ChromeFeatureList.START_SURFACE_ANDROID,
ChromeFeatureList.SWAP_PIXEL_FORMAT_TO_FIX_CONVERT_FROM_TRANSLUCENT, ChromeFeatureList.SWAP_PIXEL_FORMAT_TO_FIX_CONVERT_FROM_TRANSLUCENT,
ChromeFeatureList.TAB_GROUPS_CONTINUATION_ANDROID, ChromeFeatureList.TAB_GROUPS_CONTINUATION_ANDROID,
......
...@@ -14,7 +14,6 @@ import org.chromium.base.metrics.RecordUserAction; ...@@ -14,7 +14,6 @@ import org.chromium.base.metrics.RecordUserAction;
import org.chromium.base.supplier.ObservableSupplier; import org.chromium.base.supplier.ObservableSupplier;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.ActivityTabProvider; import org.chromium.chrome.browser.ActivityTabProvider;
import org.chromium.chrome.browser.flags.CachedFeatureFlags;
import org.chromium.chrome.browser.flags.ChromeFeatureList; import org.chromium.chrome.browser.flags.ChromeFeatureList;
import org.chromium.chrome.browser.tab.Tab; import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.toolbar.ButtonData; import org.chromium.chrome.browser.toolbar.ButtonData;
...@@ -26,6 +25,11 @@ import org.chromium.chrome.browser.toolbar.bottom.BottomToolbarVariationManager; ...@@ -26,6 +25,11 @@ import org.chromium.chrome.browser.toolbar.bottom.BottomToolbarVariationManager;
* whether NTP is shown). * whether NTP is shown).
*/ */
public class ShareButtonController implements ButtonDataProvider { public class ShareButtonController implements ButtonDataProvider {
/**
* Default minimum width to show share button.
*/
private static final int MIN_WIDTH = 360;
// Context is used for fetching resources and launching preferences page. // Context is used for fetching resources and launching preferences page.
private final Context mContext; private final Context mContext;
...@@ -41,6 +45,8 @@ public class ShareButtonController implements ButtonDataProvider { ...@@ -41,6 +45,8 @@ public class ShareButtonController implements ButtonDataProvider {
private final ObservableSupplier<Boolean> mBottomToolbarVisibilitySupplier; private final ObservableSupplier<Boolean> mBottomToolbarVisibilitySupplier;
private OnClickListener mOnClickListener; private OnClickListener mOnClickListener;
private Integer mMinimumWidthDp;
/** /**
* Creates ShareButtonController object. * Creates ShareButtonController object.
* @param context The Context for retrieving resources, etc. * @param context The Context for retrieving resources, etc.
...@@ -99,11 +105,26 @@ public class ShareButtonController implements ButtonDataProvider { ...@@ -99,11 +105,26 @@ public class ShareButtonController implements ButtonDataProvider {
} }
private void updateButtonState(Tab tab) { private void updateButtonState(Tab tab) {
// TODO(crbug.com/1036023) add width constraints. if (tab == null || tab.getWebContents() == null
if (!CachedFeatureFlags.isEnabled(ChromeFeatureList.SHARE_BUTTON_IN_TOP_TOOLBAR) || !ChromeFeatureList.isEnabled(ChromeFeatureList.SHARE_BUTTON_IN_TOP_TOOLBAR)) {
|| (mBottomToolbarVisibilitySupplier.get() mButtonData.canShow = false;
&& BottomToolbarVariationManager.isShareButtonOnBottom()) return;
|| mShareDelegateSupplier.get() == null) { }
if (mMinimumWidthDp == null) {
mMinimumWidthDp = ChromeFeatureList.getFieldTrialParamByFeatureAsInt(
ChromeFeatureList.SHARE_BUTTON_IN_TOP_TOOLBAR, "minimum_width", MIN_WIDTH);
}
float deviceWidthPX = mContext.getResources().getDisplayMetrics().widthPixels;
int deviceWidth =
(int) (deviceWidthPX / (mContext.getResources().getDisplayMetrics().density));
boolean isDeviceWideEnough = deviceWidth > mMinimumWidthDp;
if ((mBottomToolbarVisibilitySupplier.get()
&& BottomToolbarVariationManager.isShareButtonOnBottom())
|| mShareDelegateSupplier.get() == null || !isDeviceWideEnough) {
mButtonData.canShow = false; mButtonData.canShow = false;
return; return;
} }
......
...@@ -65,7 +65,6 @@ public class CachedFeatureFlags { ...@@ -65,7 +65,6 @@ public class CachedFeatureFlags {
put(ChromeFeatureList.TAB_GROUPS_ANDROID, false); put(ChromeFeatureList.TAB_GROUPS_ANDROID, false);
put(ChromeFeatureList.TAB_GROUPS_CONTINUATION_ANDROID, false); put(ChromeFeatureList.TAB_GROUPS_CONTINUATION_ANDROID, false);
put(ChromeFeatureList.DUET_TABSTRIP_INTEGRATION_ANDROID, false); put(ChromeFeatureList.DUET_TABSTRIP_INTEGRATION_ANDROID, false);
put(ChromeFeatureList.SHARE_BUTTON_IN_TOP_TOOLBAR, false);
put(ChromeFeatureList.CLOSE_TAB_SUGGESTIONS, false); put(ChromeFeatureList.CLOSE_TAB_SUGGESTIONS, false);
put(ChromeFeatureList.INSTANT_START, false); put(ChromeFeatureList.INSTANT_START, false);
put(ChromeFeatureList.TAB_GROUPS_CONTINUATION_ANDROID, false); put(ChromeFeatureList.TAB_GROUPS_CONTINUATION_ANDROID, 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