birch: Update context menu to toggle weather temperature units
UX/UXW wants the menu item to go back and forth between two labels: * Show temperature in Celsius * Show temperature in Fahrenheit Bug: none Change-Id: Id6a96702b6cebafa8f0fed9a49d465e0e21af9ef Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5787618 Reviewed-by: Matthew Mourgos <mmourgos@chromium.org> Commit-Queue: James Cook <jamescook@chromium.org> Cr-Commit-Position: refs/heads/main@{#1342037}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
176488545b
commit
8e97ac32d4
@ -8674,8 +8674,11 @@ To shut down the device, press and hold the power button on the device again.
|
||||
<message name="IDS_ASH_BIRCH_CUSTOMIZE_SUGGESTIONS" desc="Context menu item that opens the submenu to customize suggestions in informed restore/overview UI">
|
||||
Customize suggestions
|
||||
</message>
|
||||
<message name="IDS_ASH_BIRCH_TOGGLE_TEMPERATURE_UNITS" desc="Context menu item that toggles temperature units (F vs. C) for the weather suggestion in informed restore/overview UI">
|
||||
Toggle temperature units (F vs. C)
|
||||
<message name="IDS_ASH_BIRCH_SHOW_TEMPERATURE_IN_CELSIUS" desc="Context menu item that sets the temperature units to Celsius for the weather suggestion in informed restore/overview UI">
|
||||
Show temperature in Celsius
|
||||
</message>
|
||||
<message name="IDS_ASH_BIRCH_SHOW_TEMPERATURE_IN_FAHRENHEIT" desc="Context menu item that sets the temperature units to Fahrenheit for the weather suggestion in informed restore/overview UI">
|
||||
Show temperature in Fahrenheit
|
||||
</message>
|
||||
<message name="IDS_ASH_BIRCH_SEND_FEEDBACK" desc="Context menu item that sends feedback about suggestions in informed restore/overview UI">
|
||||
Send feedback
|
||||
|
@ -0,0 +1 @@
|
||||
ca8f6a4e3909d39d94c2cf4c2c5420d78d44d011
|
@ -0,0 +1 @@
|
||||
57855c42761d0fb7aed68de0a61ebd4d8e863220
|
@ -1 +0,0 @@
|
||||
b618b2c6ed3ba0e26caa64d465f519bae9a2b39b
|
@ -4,14 +4,26 @@
|
||||
|
||||
#include "ash/wm/overview/birch/birch_chip_context_menu_model.h"
|
||||
|
||||
#include "ash/constants/ash_pref_names.h"
|
||||
#include "ash/resources/vector_icons/vector_icons.h"
|
||||
#include "ash/session/session_controller_impl.h"
|
||||
#include "ash/shell.h"
|
||||
#include "ash/strings/grit/ash_strings.h"
|
||||
#include "ash/wm/overview/overview_utils.h"
|
||||
#include "components/prefs/pref_service.h"
|
||||
#include "ui/base/l10n/l10n_util.h"
|
||||
#include "ui/base/models/menu_separator_types.h"
|
||||
#include "ui/views/controls/menu/menu_types.h"
|
||||
|
||||
namespace ash {
|
||||
namespace {
|
||||
|
||||
// Returns the pref service to use for Birch bar prefs.
|
||||
PrefService* GetPrefService() {
|
||||
return Shell::Get()->session_controller()->GetPrimaryUserPrefService();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
BirchChipContextMenuModel::BirchChipContextMenuModel(
|
||||
ui::SimpleMenuModel::Delegate* delegate,
|
||||
@ -73,8 +85,11 @@ BirchChipContextMenuModel::BirchChipContextMenuModel(
|
||||
l10n_util::GetStringUTF16(IDS_ASH_BIRCH_CUSTOMIZE_SUGGESTIONS),
|
||||
sub_menu_model_.get(), CreateIconForMenuItem(kPencilIcon));
|
||||
if (chip_type == BirchSuggestionType::kWeather) {
|
||||
bool is_celsius = GetPrefService()->GetBoolean(prefs::kBirchUseCelsius);
|
||||
AddItem(base::to_underlying(CommandId::kToggleTemperatureUnits),
|
||||
l10n_util::GetStringUTF16(IDS_ASH_BIRCH_TOGGLE_TEMPERATURE_UNITS));
|
||||
l10n_util::GetStringUTF16(
|
||||
is_celsius ? IDS_ASH_BIRCH_SHOW_TEMPERATURE_IN_FAHRENHEIT
|
||||
: IDS_ASH_BIRCH_SHOW_TEMPERATURE_IN_CELSIUS));
|
||||
}
|
||||
AddSeparator(ui::MenuSeparatorType::NORMAL_SEPARATOR);
|
||||
AddItemWithIcon(base::to_underlying(CommandId::kFeedback),
|
||||
|
Reference in New Issue
Block a user