gd: Update Screen Size Row
Updates the Screen Size detail row to utilize a primary FeatureTile and displays the correct icon and text that will match the compat mode view. The implementation of displaying the compat mode view and the UI polish for this FeatureTile will be implemented in a separate CL. Bug: b:303345567 Test: Ran unit tests and manual testing. Demo: b/303345567#comment2 Change-Id: I72cef007812412adb2ea0e1736bd9754dc9bc899 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4902897 Reviewed-by: Yury Khmel <khmel@chromium.org> Reviewed-by: Ahmed Fakhry <afakhry@chromium.org> Commit-Queue: Gina Domergue <gdomergue@google.com> Cr-Commit-Position: refs/heads/main@{#1215647}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
6410610d49
commit
ed3358a47c
ash
ash_strings.grd
ash_strings_grd
IDS_ARC_COMPAT_MODE_RESIZE_TOGGLE_MENU_PHONE.png.sha1IDS_ARC_COMPAT_MODE_RESIZE_TOGGLE_MENU_RESIZABLE.png.sha1IDS_ARC_COMPAT_MODE_RESIZE_TOGGLE_MENU_TABLET.png.sha1
components
arc
game_dashboard
public
resources
vector_icons
components
@ -7304,6 +7304,17 @@ To shut down the device, press and hold the power button on the device again.
|
||||
<message name="IDS_ASH_DEVICE_SETTINGS_LEARN_MORE_BUTTON" desc="Button shown for device settings notifications which opens an article with helpful information related to the notification.">
|
||||
Learn more
|
||||
</message>
|
||||
|
||||
<!-- Compat Mode Resize States-->
|
||||
<message name="IDS_ARC_COMPAT_MODE_RESIZE_TOGGLE_MENU_PHONE" desc="Item in a list of possible sizes for the app. Makes the app in a portrait, phone size.">
|
||||
Phone
|
||||
</message>
|
||||
<message name="IDS_ARC_COMPAT_MODE_RESIZE_TOGGLE_MENU_TABLET" desc="Item in a list of possible sizes for the app. Makes the app bigger and wider in a tablet size.">
|
||||
Tablet
|
||||
</message>
|
||||
<message name="IDS_ARC_COMPAT_MODE_RESIZE_TOGGLE_MENU_RESIZABLE" desc="Item in a list of possible sizes for the app. Makes the app resizable.">
|
||||
Resizable
|
||||
</message>
|
||||
</messages>
|
||||
</release>
|
||||
</grit>
|
||||
|
@ -4,63 +4,25 @@
|
||||
|
||||
#include "ash/components/arc/compat_mode/compat_mode_button_controller.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "ash/components/arc/compat_mode/arc_resize_lock_pref_delegate.h"
|
||||
#include "ash/components/arc/compat_mode/arc_window_property_util.h"
|
||||
#include "ash/components/arc/compat_mode/compat_mode_button.h"
|
||||
#include "ash/components/arc/compat_mode/resize_util.h"
|
||||
#include "ash/components/arc/vector_icons/vector_icons.h"
|
||||
#include "ash/frame/non_client_frame_view_ash.h"
|
||||
#include "ash/game_dashboard/game_dashboard_controller.h"
|
||||
#include "ash/public/cpp/app_types_util.h"
|
||||
#include "ash/public/cpp/arc_compat_mode_util.h"
|
||||
#include "ash/public/cpp/arc_resize_lock_type.h"
|
||||
#include "ash/public/cpp/window_properties.h"
|
||||
#include "ash/resources/vector_icons/vector_icons.h"
|
||||
#include "base/functional/bind.h"
|
||||
#include "base/functional/callback_forward.h"
|
||||
#include "chromeos/constants/chromeos_features.h"
|
||||
#include "chromeos/ui/frame/default_frame_header.h"
|
||||
#include "components/strings/grit/components_strings.h"
|
||||
#include "ui/base/l10n/l10n_util.h"
|
||||
#include "ui/gfx/vector_icon_types.h"
|
||||
#include "ui/views/vector_icons.h"
|
||||
|
||||
namespace arc {
|
||||
|
||||
namespace {
|
||||
|
||||
const gfx::VectorIcon& GetIcon(const ResizeCompatMode& mode) {
|
||||
switch (mode) {
|
||||
case ResizeCompatMode::kPhone:
|
||||
return chromeos::features::IsJellyEnabled()
|
||||
? ash::kSystemMenuPhoneIcon
|
||||
: ash::kSystemMenuPhoneLegacyIcon;
|
||||
case ResizeCompatMode::kTablet:
|
||||
return chromeos::features::IsJellyEnabled()
|
||||
? ash::kSystemMenuTabletIcon
|
||||
: ash::kSystemMenuTabletLegacyIcon;
|
||||
case ResizeCompatMode::kResizable:
|
||||
return kResizableIcon;
|
||||
}
|
||||
}
|
||||
|
||||
std::u16string GetText(const ResizeCompatMode& mode) {
|
||||
switch (mode) {
|
||||
case ResizeCompatMode::kPhone:
|
||||
return l10n_util::GetStringUTF16(
|
||||
IDS_ARC_COMPAT_MODE_RESIZE_TOGGLE_MENU_PHONE);
|
||||
case ResizeCompatMode::kTablet:
|
||||
return l10n_util::GetStringUTF16(
|
||||
IDS_ARC_COMPAT_MODE_RESIZE_TOGGLE_MENU_TABLET);
|
||||
case ResizeCompatMode::kResizable:
|
||||
return l10n_util::GetStringUTF16(
|
||||
IDS_ARC_COMPAT_MODE_RESIZE_TOGGLE_MENU_RESIZABLE);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
CompatModeButtonController::CompatModeButtonController() = default;
|
||||
CompatModeButtonController::~CompatModeButtonController() = default;
|
||||
|
||||
@ -102,12 +64,12 @@ void CompatModeButtonController::Update(
|
||||
frame_view->GetHeaderView()->UpdateCaptionButtons();
|
||||
}
|
||||
|
||||
const auto mode = PredictCurrentMode(window);
|
||||
const auto& icon = GetIcon(mode);
|
||||
const auto text = GetText(mode);
|
||||
const auto mode = ash::compat_mode_util::PredictCurrentMode(window);
|
||||
const auto text = ash::compat_mode_util::GetText(mode);
|
||||
|
||||
compat_mode_button->SetImage(views::CAPTION_BUTTON_ICON_CENTER,
|
||||
views::FrameCaptionButton::Animate::kNo, icon);
|
||||
views::FrameCaptionButton::Animate::kNo,
|
||||
ash::compat_mode_util::GetIcon(mode));
|
||||
compat_mode_button->SetText(text);
|
||||
compat_mode_button->SetAccessibleName(text);
|
||||
|
||||
|
@ -6,10 +6,11 @@
|
||||
|
||||
#include "ash/components/arc/compat_mode/overlay_dialog.h"
|
||||
#include "ash/components/arc/compat_mode/style/arc_color_provider.h"
|
||||
#include "ash/components/arc/vector_icons/vector_icons.h"
|
||||
#include "ash/public/cpp/arc_compat_mode_util.h"
|
||||
#include "ash/public/cpp/style/color_provider.h"
|
||||
#include "ash/public/cpp/window_properties.h"
|
||||
#include "ash/resources/vector_icons/vector_icons.h"
|
||||
#include "ash/strings/grit/ash_strings.h"
|
||||
#include "ash/style/typography.h"
|
||||
#include "base/check.h"
|
||||
#include "base/functional/bind.h"
|
||||
@ -304,7 +305,7 @@ std::unique_ptr<views::BubbleDialogDelegateView>
|
||||
ResizeToggleMenu::MakeBubbleDelegateView(
|
||||
views::Widget* parent,
|
||||
gfx::Rect anchor_rect,
|
||||
base::RepeatingCallback<void(ResizeCompatMode)> command_handler) {
|
||||
base::RepeatingCallback<void(ash::ResizeCompatMode)> command_handler) {
|
||||
const int kCornerRadius = chromeos::features::IsJellyEnabled() ? 12 : 16;
|
||||
|
||||
auto delegate_view =
|
||||
@ -364,24 +365,24 @@ ResizeToggleMenu::MakeBubbleDelegateView(
|
||||
provider->GetDistanceMetric(views::DISTANCE_RELATED_BUTTON_HORIZONTAL)));
|
||||
|
||||
const auto add_menu_button = [&container_view, &command_handler](
|
||||
ResizeCompatMode command_id,
|
||||
ash::ResizeCompatMode command_id,
|
||||
const gfx::VectorIcon& icon, int string_id) {
|
||||
return container_view->AddChildView(std::make_unique<MenuButtonView>(
|
||||
base::BindRepeating(command_handler, command_id), icon, string_id));
|
||||
};
|
||||
phone_button_ = add_menu_button(ResizeCompatMode::kPhone,
|
||||
phone_button_ = add_menu_button(ash::ResizeCompatMode::kPhone,
|
||||
chromeos::features::IsJellyEnabled()
|
||||
? ash::kSystemMenuPhoneIcon
|
||||
: ash::kSystemMenuPhoneLegacyIcon,
|
||||
IDS_ARC_COMPAT_MODE_RESIZE_TOGGLE_MENU_PHONE);
|
||||
tablet_button_ = add_menu_button(
|
||||
ResizeCompatMode::kTablet,
|
||||
ash::ResizeCompatMode::kTablet,
|
||||
chromeos::features::IsJellyEnabled() ? ash::kSystemMenuTabletIcon
|
||||
: ash::kSystemMenuTabletLegacyIcon,
|
||||
IDS_ARC_COMPAT_MODE_RESIZE_TOGGLE_MENU_TABLET);
|
||||
resizable_button_ =
|
||||
add_menu_button(ResizeCompatMode::kResizable, kResizableIcon,
|
||||
IDS_ARC_COMPAT_MODE_RESIZE_TOGGLE_MENU_RESIZABLE);
|
||||
resizable_button_ = add_menu_button(
|
||||
ash::ResizeCompatMode::kResizable, ash::kAppCompatResizableIcon,
|
||||
IDS_ARC_COMPAT_MODE_RESIZE_TOGGLE_MENU_RESIZABLE);
|
||||
|
||||
UpdateSelectedButton();
|
||||
|
||||
@ -403,21 +404,22 @@ void ResizeToggleMenu::UpdateSelectedButton() {
|
||||
if (!widget_)
|
||||
return;
|
||||
|
||||
const auto selected_mode = PredictCurrentMode(widget_);
|
||||
phone_button_->SetSelected(selected_mode == ResizeCompatMode::kPhone);
|
||||
tablet_button_->SetSelected(selected_mode == ResizeCompatMode::kTablet);
|
||||
resizable_button_->SetSelected(selected_mode == ResizeCompatMode::kResizable);
|
||||
const auto selected_mode = ash::compat_mode_util::PredictCurrentMode(widget_);
|
||||
phone_button_->SetSelected(selected_mode == ash::ResizeCompatMode::kPhone);
|
||||
tablet_button_->SetSelected(selected_mode == ash::ResizeCompatMode::kTablet);
|
||||
resizable_button_->SetSelected(selected_mode ==
|
||||
ash::ResizeCompatMode::kResizable);
|
||||
}
|
||||
|
||||
void ResizeToggleMenu::ApplyResizeCompatMode(ResizeCompatMode mode) {
|
||||
void ResizeToggleMenu::ApplyResizeCompatMode(ash::ResizeCompatMode mode) {
|
||||
switch (mode) {
|
||||
case ResizeCompatMode::kPhone:
|
||||
case ash::ResizeCompatMode::kPhone:
|
||||
ResizeLockToPhone(widget_, pref_delegate_);
|
||||
break;
|
||||
case ResizeCompatMode::kTablet:
|
||||
case ash::ResizeCompatMode::kTablet:
|
||||
ResizeLockToTablet(widget_, pref_delegate_);
|
||||
break;
|
||||
case ResizeCompatMode::kResizable:
|
||||
case ash::ResizeCompatMode::kResizable:
|
||||
EnableResizingWithConfirmationIfNeeded(widget_, pref_delegate_);
|
||||
break;
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ class ResizeToggleMenu : public views::WidgetObserver,
|
||||
|
||||
void UpdateSelectedButton();
|
||||
|
||||
void ApplyResizeCompatMode(ResizeCompatMode mode);
|
||||
void ApplyResizeCompatMode(ash::ResizeCompatMode mode);
|
||||
|
||||
gfx::Rect GetAnchorRect() const;
|
||||
|
||||
@ -98,7 +98,7 @@ class ResizeToggleMenu : public views::WidgetObserver,
|
||||
std::unique_ptr<views::BubbleDialogDelegateView> MakeBubbleDelegateView(
|
||||
views::Widget* parent,
|
||||
gfx::Rect anchor_rect,
|
||||
base::RepeatingCallback<void(ResizeCompatMode)> command_handler);
|
||||
base::RepeatingCallback<void(ash::ResizeCompatMode)> command_handler);
|
||||
|
||||
void CloseBubble();
|
||||
|
||||
|
@ -51,7 +51,7 @@ class ResizeToggleMenuTest : public CompatModeTestBase {
|
||||
on_bubble_widget_closing_callback_, widget_.get(), pref_delegate());
|
||||
}
|
||||
|
||||
bool IsCommandButtonDisabled(ResizeCompatMode command_id) {
|
||||
bool IsCommandButtonDisabled(ash::ResizeCompatMode command_id) {
|
||||
return GetButtonByCommandId(command_id)->GetState() ==
|
||||
views::Button::ButtonState::STATE_DISABLED;
|
||||
}
|
||||
@ -60,7 +60,7 @@ class ResizeToggleMenuTest : public CompatModeTestBase {
|
||||
return on_bubble_widget_closing_callback_called_;
|
||||
}
|
||||
|
||||
void ClickButton(ResizeCompatMode command_id) {
|
||||
void ClickButton(ash::ResizeCompatMode command_id) {
|
||||
const auto* button = GetButtonByCommandId(command_id);
|
||||
LeftClickOnView(widget_.get(), button);
|
||||
SyncResizeLockPropertyWithMojoState(widget());
|
||||
@ -72,13 +72,13 @@ class ResizeToggleMenuTest : public CompatModeTestBase {
|
||||
ResizeToggleMenu* resize_toggle_menu() { return resize_toggle_menu_.get(); }
|
||||
|
||||
private:
|
||||
views::Button* GetButtonByCommandId(ResizeCompatMode command_id) {
|
||||
views::Button* GetButtonByCommandId(ash::ResizeCompatMode command_id) {
|
||||
switch (command_id) {
|
||||
case ResizeCompatMode::kPhone:
|
||||
case ash::ResizeCompatMode::kPhone:
|
||||
return resize_toggle_menu_->phone_button_;
|
||||
case ResizeCompatMode::kTablet:
|
||||
case ash::ResizeCompatMode::kTablet:
|
||||
return resize_toggle_menu_->tablet_button_;
|
||||
case ResizeCompatMode::kResizable:
|
||||
case ash::ResizeCompatMode::kResizable:
|
||||
return resize_toggle_menu_->resizable_button_;
|
||||
}
|
||||
}
|
||||
@ -108,21 +108,21 @@ TEST_F(ResizeToggleMenuTest, TestResizePhone) {
|
||||
EXPECT_TRUE(IsMenuRunning());
|
||||
|
||||
// Test that resize command is properly handled.
|
||||
ClickButton(ResizeCompatMode::kPhone);
|
||||
ClickButton(ash::ResizeCompatMode::kPhone);
|
||||
EXPECT_LT(widget()->GetWindowBoundsInScreen().width(),
|
||||
widget()->GetWindowBoundsInScreen().height());
|
||||
|
||||
// Test that the selected item is changed dynamically after the resize.
|
||||
EXPECT_TRUE(IsCommandButtonDisabled(ResizeCompatMode::kPhone));
|
||||
EXPECT_FALSE(IsCommandButtonDisabled(ResizeCompatMode::kTablet));
|
||||
EXPECT_FALSE(IsCommandButtonDisabled(ResizeCompatMode::kResizable));
|
||||
EXPECT_TRUE(IsCommandButtonDisabled(ash::ResizeCompatMode::kPhone));
|
||||
EXPECT_FALSE(IsCommandButtonDisabled(ash::ResizeCompatMode::kTablet));
|
||||
EXPECT_FALSE(IsCommandButtonDisabled(ash::ResizeCompatMode::kResizable));
|
||||
|
||||
// Test that the item is selected after re-showing.
|
||||
ReshowMenu();
|
||||
EXPECT_TRUE(IsMenuRunning());
|
||||
EXPECT_TRUE(IsCommandButtonDisabled(ResizeCompatMode::kPhone));
|
||||
EXPECT_FALSE(IsCommandButtonDisabled(ResizeCompatMode::kTablet));
|
||||
EXPECT_FALSE(IsCommandButtonDisabled(ResizeCompatMode::kResizable));
|
||||
EXPECT_TRUE(IsCommandButtonDisabled(ash::ResizeCompatMode::kPhone));
|
||||
EXPECT_FALSE(IsCommandButtonDisabled(ash::ResizeCompatMode::kTablet));
|
||||
EXPECT_FALSE(IsCommandButtonDisabled(ash::ResizeCompatMode::kResizable));
|
||||
}
|
||||
|
||||
TEST_F(ResizeToggleMenuTest, TestResizeTablet) {
|
||||
@ -130,21 +130,21 @@ TEST_F(ResizeToggleMenuTest, TestResizeTablet) {
|
||||
EXPECT_TRUE(IsMenuRunning());
|
||||
|
||||
// Test that resize command is properly handled.
|
||||
ClickButton(ResizeCompatMode::kTablet);
|
||||
ClickButton(ash::ResizeCompatMode::kTablet);
|
||||
EXPECT_GT(widget()->GetWindowBoundsInScreen().width(),
|
||||
widget()->GetWindowBoundsInScreen().height());
|
||||
|
||||
// Test that the selected item is changed dynamically after the resize.
|
||||
EXPECT_FALSE(IsCommandButtonDisabled(ResizeCompatMode::kPhone));
|
||||
EXPECT_TRUE(IsCommandButtonDisabled(ResizeCompatMode::kTablet));
|
||||
EXPECT_FALSE(IsCommandButtonDisabled(ResizeCompatMode::kResizable));
|
||||
EXPECT_FALSE(IsCommandButtonDisabled(ash::ResizeCompatMode::kPhone));
|
||||
EXPECT_TRUE(IsCommandButtonDisabled(ash::ResizeCompatMode::kTablet));
|
||||
EXPECT_FALSE(IsCommandButtonDisabled(ash::ResizeCompatMode::kResizable));
|
||||
|
||||
// Test that the item is selected after re-showing.
|
||||
ReshowMenu();
|
||||
EXPECT_TRUE(IsMenuRunning());
|
||||
EXPECT_FALSE(IsCommandButtonDisabled(ResizeCompatMode::kPhone));
|
||||
EXPECT_TRUE(IsCommandButtonDisabled(ResizeCompatMode::kTablet));
|
||||
EXPECT_FALSE(IsCommandButtonDisabled(ResizeCompatMode::kResizable));
|
||||
EXPECT_FALSE(IsCommandButtonDisabled(ash::ResizeCompatMode::kPhone));
|
||||
EXPECT_TRUE(IsCommandButtonDisabled(ash::ResizeCompatMode::kTablet));
|
||||
EXPECT_FALSE(IsCommandButtonDisabled(ash::ResizeCompatMode::kResizable));
|
||||
}
|
||||
|
||||
TEST_F(ResizeToggleMenuTest, TestResizable) {
|
||||
@ -156,21 +156,21 @@ TEST_F(ResizeToggleMenuTest, TestResizable) {
|
||||
SyncResizeLockPropertyWithMojoState(widget());
|
||||
|
||||
// Test that resize command is properly handled.
|
||||
ClickButton(ResizeCompatMode::kResizable);
|
||||
ClickButton(ash::ResizeCompatMode::kResizable);
|
||||
EXPECT_EQ(pref_delegate()->GetResizeLockState(kTestAppId),
|
||||
mojom::ArcResizeLockState::OFF);
|
||||
|
||||
// Test that the selected item is changed dynamically.
|
||||
EXPECT_FALSE(IsCommandButtonDisabled(ResizeCompatMode::kPhone));
|
||||
EXPECT_FALSE(IsCommandButtonDisabled(ResizeCompatMode::kTablet));
|
||||
EXPECT_TRUE(IsCommandButtonDisabled(ResizeCompatMode::kResizable));
|
||||
EXPECT_FALSE(IsCommandButtonDisabled(ash::ResizeCompatMode::kPhone));
|
||||
EXPECT_FALSE(IsCommandButtonDisabled(ash::ResizeCompatMode::kTablet));
|
||||
EXPECT_TRUE(IsCommandButtonDisabled(ash::ResizeCompatMode::kResizable));
|
||||
|
||||
// Test that the item is selected after the resize.
|
||||
ReshowMenu();
|
||||
EXPECT_TRUE(IsMenuRunning());
|
||||
EXPECT_FALSE(IsCommandButtonDisabled(ResizeCompatMode::kPhone));
|
||||
EXPECT_FALSE(IsCommandButtonDisabled(ResizeCompatMode::kTablet));
|
||||
EXPECT_TRUE(IsCommandButtonDisabled(ResizeCompatMode::kResizable));
|
||||
EXPECT_FALSE(IsCommandButtonDisabled(ash::ResizeCompatMode::kPhone));
|
||||
EXPECT_FALSE(IsCommandButtonDisabled(ash::ResizeCompatMode::kTablet));
|
||||
EXPECT_TRUE(IsCommandButtonDisabled(ash::ResizeCompatMode::kResizable));
|
||||
}
|
||||
|
||||
// Test that the button state is dynamically changed even if no bounds change
|
||||
@ -179,27 +179,27 @@ TEST_F(ResizeToggleMenuTest, TestButtonStateChangeWithoutBoundsChange) {
|
||||
// Verify pre-conditions.
|
||||
EXPECT_TRUE(IsMenuRunning());
|
||||
|
||||
ClickButton(ResizeCompatMode::kPhone);
|
||||
EXPECT_TRUE(IsCommandButtonDisabled(ResizeCompatMode::kPhone));
|
||||
EXPECT_FALSE(IsCommandButtonDisabled(ResizeCompatMode::kTablet));
|
||||
EXPECT_FALSE(IsCommandButtonDisabled(ResizeCompatMode::kResizable));
|
||||
ClickButton(ash::ResizeCompatMode::kPhone);
|
||||
EXPECT_TRUE(IsCommandButtonDisabled(ash::ResizeCompatMode::kPhone));
|
||||
EXPECT_FALSE(IsCommandButtonDisabled(ash::ResizeCompatMode::kTablet));
|
||||
EXPECT_FALSE(IsCommandButtonDisabled(ash::ResizeCompatMode::kResizable));
|
||||
|
||||
ClickButton(ResizeCompatMode::kResizable);
|
||||
EXPECT_FALSE(IsCommandButtonDisabled(ResizeCompatMode::kPhone));
|
||||
EXPECT_FALSE(IsCommandButtonDisabled(ResizeCompatMode::kTablet));
|
||||
EXPECT_TRUE(IsCommandButtonDisabled(ResizeCompatMode::kResizable));
|
||||
ClickButton(ash::ResizeCompatMode::kResizable);
|
||||
EXPECT_FALSE(IsCommandButtonDisabled(ash::ResizeCompatMode::kPhone));
|
||||
EXPECT_FALSE(IsCommandButtonDisabled(ash::ResizeCompatMode::kTablet));
|
||||
EXPECT_TRUE(IsCommandButtonDisabled(ash::ResizeCompatMode::kResizable));
|
||||
|
||||
ClickButton(ResizeCompatMode::kPhone);
|
||||
EXPECT_TRUE(IsCommandButtonDisabled(ResizeCompatMode::kPhone));
|
||||
EXPECT_FALSE(IsCommandButtonDisabled(ResizeCompatMode::kTablet));
|
||||
EXPECT_FALSE(IsCommandButtonDisabled(ResizeCompatMode::kResizable));
|
||||
ClickButton(ash::ResizeCompatMode::kPhone);
|
||||
EXPECT_TRUE(IsCommandButtonDisabled(ash::ResizeCompatMode::kPhone));
|
||||
EXPECT_FALSE(IsCommandButtonDisabled(ash::ResizeCompatMode::kTablet));
|
||||
EXPECT_FALSE(IsCommandButtonDisabled(ash::ResizeCompatMode::kResizable));
|
||||
}
|
||||
|
||||
// Test that the menu is closed with delay when the button is clicked.
|
||||
TEST_F(ResizeToggleMenuTest, TestDelayedAutoClose) {
|
||||
EXPECT_TRUE(IsMenuRunning());
|
||||
|
||||
ClickButton(ResizeCompatMode::kPhone);
|
||||
ClickButton(ash::ResizeCompatMode::kPhone);
|
||||
EXPECT_TRUE(IsMenuRunning());
|
||||
task_environment()->FastForwardBy(base::Seconds(1));
|
||||
EXPECT_TRUE(IsMenuRunning());
|
||||
@ -211,11 +211,11 @@ TEST_F(ResizeToggleMenuTest, TestDelayedAutoClose) {
|
||||
TEST_F(ResizeToggleMenuTest, TestDelayedAutoCloseCancel) {
|
||||
EXPECT_TRUE(IsMenuRunning());
|
||||
|
||||
ClickButton(ResizeCompatMode::kPhone);
|
||||
ClickButton(ash::ResizeCompatMode::kPhone);
|
||||
EXPECT_TRUE(IsMenuRunning());
|
||||
task_environment()->FastForwardBy(base::Seconds(1));
|
||||
EXPECT_TRUE(IsMenuRunning());
|
||||
ClickButton(ResizeCompatMode::kTablet);
|
||||
ClickButton(ash::ResizeCompatMode::kTablet);
|
||||
EXPECT_TRUE(IsMenuRunning());
|
||||
task_environment()->FastForwardBy(base::Seconds(1));
|
||||
EXPECT_TRUE(IsMenuRunning());
|
||||
@ -227,7 +227,7 @@ TEST_F(ResizeToggleMenuTest, TestDelayedAutoCloseCancel) {
|
||||
TEST_F(ResizeToggleMenuTest, TestUserActionMetrics) {
|
||||
base::UserActionTester user_action_tester;
|
||||
|
||||
ClickButton(ResizeCompatMode::kPhone);
|
||||
ClickButton(ash::ResizeCompatMode::kPhone);
|
||||
EXPECT_EQ(1,
|
||||
user_action_tester.GetActionCount(GetResizeLockActionNameForTesting(
|
||||
ResizeLockActionType::ResizeToPhone)));
|
||||
@ -235,7 +235,7 @@ TEST_F(ResizeToggleMenuTest, TestUserActionMetrics) {
|
||||
user_action_tester.GetActionCount(GetResizeLockActionNameForTesting(
|
||||
ResizeLockActionType::TurnOnResizeLock)));
|
||||
|
||||
ClickButton(ResizeCompatMode::kTablet);
|
||||
ClickButton(ash::ResizeCompatMode::kTablet);
|
||||
EXPECT_EQ(1,
|
||||
user_action_tester.GetActionCount(GetResizeLockActionNameForTesting(
|
||||
ResizeLockActionType::ResizeToTablet)));
|
||||
@ -243,12 +243,12 @@ TEST_F(ResizeToggleMenuTest, TestUserActionMetrics) {
|
||||
user_action_tester.GetActionCount(GetResizeLockActionNameForTesting(
|
||||
ResizeLockActionType::TurnOnResizeLock)));
|
||||
|
||||
ClickButton(ResizeCompatMode::kResizable);
|
||||
ClickButton(ash::ResizeCompatMode::kResizable);
|
||||
EXPECT_EQ(1,
|
||||
user_action_tester.GetActionCount(GetResizeLockActionNameForTesting(
|
||||
ResizeLockActionType::TurnOffResizeLock)));
|
||||
|
||||
ClickButton(ResizeCompatMode::kPhone);
|
||||
ClickButton(ash::ResizeCompatMode::kPhone);
|
||||
EXPECT_EQ(2,
|
||||
user_action_tester.GetActionCount(GetResizeLockActionNameForTesting(
|
||||
ResizeLockActionType::ResizeToPhone)));
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "ash/components/arc/compat_mode/metrics.h"
|
||||
#include "ash/components/arc/compat_mode/resize_confirmation_dialog_view.h"
|
||||
#include "ash/constants/notifier_catalogs.h"
|
||||
#include "ash/public/cpp/arc_compat_mode_util.h"
|
||||
#include "ash/public/cpp/arc_resize_lock_type.h"
|
||||
#include "ash/public/cpp/system/toast_data.h"
|
||||
#include "ash/public/cpp/system/toast_manager.h"
|
||||
@ -184,28 +185,6 @@ void EnableResizingWithConfirmationIfNeeded(
|
||||
TurnOffResizeLockWithConfirmationIfNeeded(widget, pref_delegate);
|
||||
}
|
||||
|
||||
ResizeCompatMode PredictCurrentMode(const views::Widget* widget) {
|
||||
return PredictCurrentMode(widget->GetNativeWindow());
|
||||
}
|
||||
|
||||
ResizeCompatMode PredictCurrentMode(const aura::Window* window) {
|
||||
const auto resize_lock_type = window->GetProperty(ash::kArcResizeLockTypeKey);
|
||||
if (resize_lock_type == ash::ArcResizeLockType::NONE ||
|
||||
resize_lock_type == ash::ArcResizeLockType::RESIZE_ENABLED_TOGGLABLE) {
|
||||
return ResizeCompatMode::kResizable;
|
||||
}
|
||||
|
||||
const auto& bounds = window->bounds();
|
||||
// We don't use the exact size here to predict tablet or phone size because
|
||||
// the window size might be bigger than it due to the ARC app-side minimum
|
||||
// size constraints.
|
||||
if (bounds.width() <= bounds.height()) {
|
||||
return ResizeCompatMode::kPhone;
|
||||
}
|
||||
|
||||
return ResizeCompatMode::kTablet;
|
||||
}
|
||||
|
||||
bool ShouldShowSplashScreenDialog(ArcResizeLockPrefDelegate* pref_delegate) {
|
||||
int show_count = pref_delegate->GetShowSplashScreenDialogCount();
|
||||
if (show_count == 0)
|
||||
|
@ -5,26 +5,16 @@
|
||||
#ifndef ASH_COMPONENTS_ARC_COMPAT_MODE_RESIZE_UTIL_H_
|
||||
#define ASH_COMPONENTS_ARC_COMPAT_MODE_RESIZE_UTIL_H_
|
||||
|
||||
#include "third_party/abseil-cpp/absl/types/optional.h"
|
||||
#include "ash/public/cpp/arc_compat_mode_util.h"
|
||||
|
||||
namespace views {
|
||||
class Widget;
|
||||
} // namespace views
|
||||
|
||||
namespace aura {
|
||||
class Window;
|
||||
} // namespace aura
|
||||
|
||||
namespace arc {
|
||||
|
||||
class ArcResizeLockPrefDelegate;
|
||||
|
||||
enum class ResizeCompatMode {
|
||||
kPhone,
|
||||
kTablet,
|
||||
kResizable,
|
||||
};
|
||||
|
||||
void ResizeLockToPhone(views::Widget* widget,
|
||||
ArcResizeLockPrefDelegate* pref_delegate);
|
||||
|
||||
@ -35,9 +25,6 @@ void EnableResizingWithConfirmationIfNeeded(
|
||||
views::Widget* widget,
|
||||
ArcResizeLockPrefDelegate* pref_delegate);
|
||||
|
||||
ResizeCompatMode PredictCurrentMode(const views::Widget* widget);
|
||||
ResizeCompatMode PredictCurrentMode(const aura::Window* window);
|
||||
|
||||
bool ShouldShowSplashScreenDialog(ArcResizeLockPrefDelegate* pref_delegate);
|
||||
|
||||
int GetPortraitPhoneSizeWidth();
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <memory>
|
||||
|
||||
#include "ash/components/arc/compat_mode/test/compat_mode_test_base.h"
|
||||
#include "ash/public/cpp/arc_compat_mode_util.h"
|
||||
#include "ash/public/cpp/system/scoped_toast_pause.h"
|
||||
#include "ash/public/cpp/system/toast_data.h"
|
||||
#include "ash/public/cpp/system/toast_manager.h"
|
||||
@ -95,7 +96,8 @@ TEST_F(ResizeUtilTest, TestResizeLockToPhone) {
|
||||
EXPECT_FALSE(widget()->IsMaximized());
|
||||
EXPECT_LT(widget()->GetWindowBoundsInScreen().width(),
|
||||
widget()->GetWindowBoundsInScreen().height());
|
||||
EXPECT_EQ(PredictCurrentMode(widget()), ResizeCompatMode::kPhone);
|
||||
EXPECT_EQ(ash::compat_mode_util::PredictCurrentMode(widget()),
|
||||
ash::ResizeCompatMode::kPhone);
|
||||
}
|
||||
|
||||
// Test that resize tablet works properly in both needs-confirmation and no
|
||||
@ -115,7 +117,8 @@ TEST_F(ResizeUtilTest, TestResizeLockToTablet) {
|
||||
EXPECT_FALSE(widget()->IsMaximized());
|
||||
EXPECT_GT(widget()->GetWindowBoundsInScreen().width(),
|
||||
widget()->GetWindowBoundsInScreen().height());
|
||||
EXPECT_EQ(PredictCurrentMode(widget()), ResizeCompatMode::kTablet);
|
||||
EXPECT_EQ(ash::compat_mode_util::PredictCurrentMode(widget()),
|
||||
ash::ResizeCompatMode::kTablet);
|
||||
}
|
||||
|
||||
// Test that resize phone/tablet works properly on small displays.
|
||||
@ -164,7 +167,8 @@ TEST_F(ResizeUtilTest, TestEnableResizing) {
|
||||
SyncResizeLockPropertyWithMojoState(widget());
|
||||
EXPECT_EQ(pref_delegate()->GetResizeLockState(kTestAppId),
|
||||
mojom::ArcResizeLockState::OFF);
|
||||
EXPECT_EQ(PredictCurrentMode(widget()), ResizeCompatMode::kResizable);
|
||||
EXPECT_EQ(ash::compat_mode_util::PredictCurrentMode(widget()),
|
||||
ash::ResizeCompatMode::kResizable);
|
||||
EXPECT_TRUE(fake_toast_manager.called_cancel());
|
||||
EXPECT_TRUE(fake_toast_manager.called_show());
|
||||
|
||||
@ -192,7 +196,8 @@ TEST_F(ResizeUtilTest, TestPredictCurrentModeForUnresizable) {
|
||||
widget()->widget_delegate()->SetCanResize(false);
|
||||
ResizeLockToPhone(widget(), pref_delegate());
|
||||
SyncResizeLockPropertyWithMojoState(widget());
|
||||
EXPECT_EQ(PredictCurrentMode(widget()), ResizeCompatMode::kPhone);
|
||||
EXPECT_EQ(ash::compat_mode_util::PredictCurrentMode(widget()),
|
||||
ash::ResizeCompatMode::kPhone);
|
||||
}
|
||||
|
||||
} // namespace arc
|
||||
|
@ -13,7 +13,6 @@ aggregate_vector_icons("components_arc_vector_icons") {
|
||||
|
||||
sources = [
|
||||
"compat_mode_splashscreen.icon",
|
||||
"resizable.icon",
|
||||
"save.icon",
|
||||
]
|
||||
}
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "ash/game_dashboard/game_dashboard_utils.h"
|
||||
#include "ash/game_dashboard/game_dashboard_widget.h"
|
||||
#include "ash/public/cpp/app_types_util.h"
|
||||
#include "ash/public/cpp/arc_compat_mode_util.h"
|
||||
#include "ash/public/cpp/ash_view_ids.h"
|
||||
#include "ash/public/cpp/window_properties.h"
|
||||
#include "ash/resources/vector_icons/vector_icons.h"
|
||||
@ -466,6 +467,7 @@ void GameDashboardMainMenuView::AddFeatureDetailsRows() {
|
||||
views::BoxLayout::Orientation::kVertical,
|
||||
/*inside_border_insets=*/gfx::Insets(),
|
||||
/*between_child_spacing=*/2));
|
||||
// TODO(b/303351913): Update corners of detail rows to match UI specs.
|
||||
MaybeAddGameControlsDetailsRow(feature_details_container);
|
||||
MaybeAddScreenSizeSettingsRow(feature_details_container);
|
||||
}
|
||||
@ -569,22 +571,25 @@ void GameDashboardMainMenuView::MaybeAddGameControlsDetailsRow(
|
||||
|
||||
void GameDashboardMainMenuView::MaybeAddScreenSizeSettingsRow(
|
||||
views::View* container) {
|
||||
if (IsArcWindow(context_->game_window())) {
|
||||
auto* details = container->AddChildView(std::make_unique<FeatureDetailsRow>(
|
||||
base::BindRepeating(
|
||||
&GameDashboardMainMenuView::OnScreenSizeSettingsButtonPressed,
|
||||
base::Unretained(this)),
|
||||
RoundedContainer::Behavior::kBottomRounded,
|
||||
/*default_drill_in_arrow=*/true,
|
||||
/*icon=*/kGdScreenSizeSettingsIcon, /*title=*/
|
||||
l10n_util::GetStringUTF16(
|
||||
IDS_ASH_GAME_DASHBOARD_SCREEN_SIZE_SETTINGS_TITLE)));
|
||||
|
||||
details->SetID(VIEW_ID_GD_SCREEN_SIZE_TILE);
|
||||
// TODO(b/286455407): Update with final localized string.
|
||||
// TODO(b/286917169): Dynamically updating the sub-title.
|
||||
details->SetSubtitle(u"Landscape");
|
||||
aura::Window* game_window = context_->game_window();
|
||||
if (!IsArcWindow(game_window)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto resize_mode = compat_mode_util::PredictCurrentMode(game_window);
|
||||
auto* screen_size_row = container->AddChildView(CreateFeatureTile(
|
||||
base::BindRepeating(
|
||||
&GameDashboardMainMenuView::OnScreenSizeSettingsButtonPressed,
|
||||
base::Unretained(this)),
|
||||
/*is_togglable=*/false, FeatureTile::TileType::kPrimary,
|
||||
VIEW_ID_GD_SCREEN_SIZE_TILE,
|
||||
/*icon=*/compat_mode_util::GetIcon(resize_mode),
|
||||
l10n_util::GetStringUTF16(
|
||||
IDS_ASH_GAME_DASHBOARD_SCREEN_SIZE_SETTINGS_TITLE),
|
||||
/*sub_label=*/compat_mode_util::GetText(resize_mode)));
|
||||
// TODO(b/303351905): Investigate why drill in arrow isn't placed in correct
|
||||
// location.
|
||||
screen_size_row->CreateDecorativeDrillInArrow();
|
||||
}
|
||||
|
||||
void GameDashboardMainMenuView::AddUtilityClusterRow() {
|
||||
|
@ -64,6 +64,8 @@ component("cpp") {
|
||||
"app_types_util.h",
|
||||
"arc_app_id_provider.cc",
|
||||
"arc_app_id_provider.h",
|
||||
"arc_compat_mode_util.cc",
|
||||
"arc_compat_mode_util.h",
|
||||
"arc_game_controls_flag.h",
|
||||
"arc_resize_lock_type.h",
|
||||
"ash_constants.h",
|
||||
|
66
ash/public/cpp/arc_compat_mode_util.cc
Normal file
66
ash/public/cpp/arc_compat_mode_util.cc
Normal file
@ -0,0 +1,66 @@
|
||||
// Copyright 2023 The Chromium Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "ash/public/cpp/arc_compat_mode_util.h"
|
||||
|
||||
#include "ash/public/cpp/window_properties.h"
|
||||
#include "ash/resources/vector_icons/vector_icons.h"
|
||||
#include "ash/strings/grit/ash_strings.h"
|
||||
#include "chromeos/constants/chromeos_features.h"
|
||||
#include "ui/aura/client/aura_constants.h"
|
||||
#include "ui/base/l10n/l10n_util.h"
|
||||
#include "ui/views/widget/widget.h"
|
||||
|
||||
namespace ash::compat_mode_util {
|
||||
|
||||
ResizeCompatMode PredictCurrentMode(const views::Widget* widget) {
|
||||
return PredictCurrentMode(widget->GetNativeWindow());
|
||||
}
|
||||
|
||||
ResizeCompatMode PredictCurrentMode(const aura::Window* window) {
|
||||
const auto resize_lock_type = window->GetProperty(kArcResizeLockTypeKey);
|
||||
if (resize_lock_type == ArcResizeLockType::NONE ||
|
||||
resize_lock_type == ArcResizeLockType::RESIZE_ENABLED_TOGGLABLE) {
|
||||
return ResizeCompatMode::kResizable;
|
||||
}
|
||||
|
||||
const auto& bounds = window->bounds();
|
||||
// We don't use the exact size here to predict tablet or phone size because
|
||||
// the window size might be bigger than it due to the ARC app-side minimum
|
||||
// size constraints.
|
||||
if (bounds.width() <= bounds.height()) {
|
||||
return ResizeCompatMode::kPhone;
|
||||
}
|
||||
|
||||
return ResizeCompatMode::kTablet;
|
||||
}
|
||||
|
||||
const gfx::VectorIcon& GetIcon(ResizeCompatMode mode) {
|
||||
switch (mode) {
|
||||
case ResizeCompatMode::kPhone:
|
||||
return chromeos::features::IsJellyEnabled() ? kSystemMenuPhoneIcon
|
||||
: kSystemMenuPhoneLegacyIcon;
|
||||
case ResizeCompatMode::kTablet:
|
||||
return chromeos::features::IsJellyEnabled() ? kSystemMenuTabletIcon
|
||||
: kSystemMenuTabletLegacyIcon;
|
||||
case ResizeCompatMode::kResizable:
|
||||
return kAppCompatResizableIcon;
|
||||
}
|
||||
}
|
||||
|
||||
std::u16string GetText(ResizeCompatMode mode) {
|
||||
switch (mode) {
|
||||
case ResizeCompatMode::kPhone:
|
||||
return l10n_util::GetStringUTF16(
|
||||
IDS_ARC_COMPAT_MODE_RESIZE_TOGGLE_MENU_PHONE);
|
||||
case ResizeCompatMode::kTablet:
|
||||
return l10n_util::GetStringUTF16(
|
||||
IDS_ARC_COMPAT_MODE_RESIZE_TOGGLE_MENU_TABLET);
|
||||
case ResizeCompatMode::kResizable:
|
||||
return l10n_util::GetStringUTF16(
|
||||
IDS_ARC_COMPAT_MODE_RESIZE_TOGGLE_MENU_RESIZABLE);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace ash::compat_mode_util
|
47
ash/public/cpp/arc_compat_mode_util.h
Normal file
47
ash/public/cpp/arc_compat_mode_util.h
Normal file
@ -0,0 +1,47 @@
|
||||
// Copyright 2023 The Chromium Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef ASH_PUBLIC_CPP_ARC_COMPAT_MODE_UTIL_H_
|
||||
#define ASH_PUBLIC_CPP_ARC_COMPAT_MODE_UTIL_H_
|
||||
|
||||
#include "ash/public/cpp/ash_public_export.h"
|
||||
#include "ui/gfx/vector_icon_types.h"
|
||||
|
||||
namespace aura {
|
||||
class Window;
|
||||
} // namespace aura
|
||||
|
||||
namespace views {
|
||||
class Widget;
|
||||
} // namespace views
|
||||
|
||||
namespace ash {
|
||||
|
||||
enum class ResizeCompatMode {
|
||||
kPhone,
|
||||
kTablet,
|
||||
kResizable,
|
||||
};
|
||||
|
||||
namespace compat_mode_util {
|
||||
|
||||
ASH_PUBLIC_EXPORT ResizeCompatMode
|
||||
PredictCurrentMode(const views::Widget* widget);
|
||||
|
||||
ASH_PUBLIC_EXPORT ResizeCompatMode
|
||||
PredictCurrentMode(const aura::Window* window);
|
||||
|
||||
// Determines which icon should be associated with the given `ResizeCompatMode`
|
||||
// state.
|
||||
ASH_PUBLIC_EXPORT const gfx::VectorIcon& GetIcon(ResizeCompatMode mode);
|
||||
|
||||
// Determines what text should be displayed for the given `ResizeCompatMode`
|
||||
// state.
|
||||
ASH_PUBLIC_EXPORT std::u16string GetText(ResizeCompatMode mode);
|
||||
|
||||
} // namespace compat_mode_util
|
||||
|
||||
} // namespace ash
|
||||
|
||||
#endif // ASH_PUBLIC_CPP_ARC_COMPAT_MODE_UTIL_H_
|
@ -18,6 +18,7 @@ aggregate_vector_icons("ash_vector_icons") {
|
||||
"add_cellular_network.icon",
|
||||
"add_cellular_network_rtl.icon",
|
||||
"always_show_shelf.icon",
|
||||
"app_compat_resizable.icon",
|
||||
"auto_hide.icon",
|
||||
"autoclick.icon",
|
||||
"autoclick_close.icon",
|
||||
|
@ -39,15 +39,6 @@
|
||||
<message name="IDS_ASH_ARC_NEARBY_SHARE_LOW_DISK_SPACE_DIALOG_STORAGE_BUTTON" desc="Label for button to acknowledge Nearby Share failed due to low disk space and open the Storage management settings page.">
|
||||
Storage management
|
||||
</message>
|
||||
<message name="IDS_ARC_COMPAT_MODE_RESIZE_TOGGLE_MENU_PHONE" desc="Item in a list of possible sizes for the app. Makes the app in a portrait, phone size.">
|
||||
Phone
|
||||
</message>
|
||||
<message name="IDS_ARC_COMPAT_MODE_RESIZE_TOGGLE_MENU_TABLET" desc="Item in a list of possible sizes for the app. Makes the app bigger and wider in a tablet size.">
|
||||
Tablet
|
||||
</message>
|
||||
<message name="IDS_ARC_COMPAT_MODE_RESIZE_TOGGLE_MENU_RESIZABLE" desc="Item in a list of possible sizes for the app. Makes the app resizable.">
|
||||
Resizable
|
||||
</message>
|
||||
<message name="IDS_ARC_COMPAT_MODE_RESIZE_TOGGLE_MENU_RESIZE_SETTINGS" desc="Label for the button to allow the user to go to resize settings.">
|
||||
Settings
|
||||
</message>
|
||||
|
Reference in New Issue
Block a user