Commit 2fa22cff authored by juncai's avatar juncai Committed by Commit bot

Centering turn on Bluetooth message on the chooser

Currently the message "Turn on Bluetooth to allow pairing" is aligned
left on the chooser. This CL moves it to the center of the chooser.

I uploaded some screenshots on the issue page.

BUG=664240

Review-Url: https://codereview.chromium.org/2627483003
Cr-Commit-Position: refs/heads/master@{#443015}
parent a80bb6a6
...@@ -22,23 +22,25 @@ ...@@ -22,23 +22,25 @@
android:paddingEnd="16dp" android:paddingEnd="16dp"
android:textSize="16sp" /> android:textSize="16sp" />
<!-- The "no item found" message. -->
<org.chromium.ui.widget.TextViewWithClickableSpans
android:id="@+id/not_found_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:textSize="16sp"
android:visibility="gone" />
<!-- A layout containing a spinning progress bar that gets replaced with a <!-- A layout containing a spinning progress bar that gets replaced with a
list of items. --> list of items. -->
<FrameLayout <FrameLayout
android:id="@+id/container" android:id="@+id/container"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="100dp" > android:layout_height="100dp" >
<!-- The "no item found" message. -->
<org.chromium.ui.widget.TextViewWithClickableSpans
android:id="@+id/not_found_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="8dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:textSize="16sp"
android:visibility="gone" />
<ProgressBar <ProgressBar
android:id="@+id/progress" android:id="@+id/progress"
android:layout_width="24dp" android:layout_width="24dp"
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#import "chrome/browser/ui/cocoa/device_chooser_content_view_cocoa.h" #import "chrome/browser/ui/cocoa/device_chooser_content_view_cocoa.h"
#include <algorithm> #include <algorithm>
#include <cmath>
#include "base/macros.h" #include "base/macros.h"
#include "base/strings/sys_string_conversions.h" #include "base/strings/sys_string_conversions.h"
...@@ -60,9 +61,6 @@ const CGFloat kSeparatorHeight = 1.0f; ...@@ -60,9 +61,6 @@ const CGFloat kSeparatorHeight = 1.0f;
const CGFloat kTableRowViewHorizontalPadding = 5.0f; const CGFloat kTableRowViewHorizontalPadding = 5.0f;
const CGFloat kTableRowViewVerticalPadding = 1.0f; const CGFloat kTableRowViewVerticalPadding = 1.0f;
// Distance between the adapter off help link and the scroll view boundaries.
const CGFloat kAdapterOffHelpLinkPadding = 5.0f;
// The lookup table for signal strength level image. // The lookup table for signal strength level image.
const int kSignalStrengthLevelImageIds[5] = {IDR_SIGNAL_0_BAR, IDR_SIGNAL_1_BAR, const int kSignalStrengthLevelImageIds[5] = {IDR_SIGNAL_0_BAR, IDR_SIGNAL_1_BAR,
IDR_SIGNAL_2_BAR, IDR_SIGNAL_3_BAR, IDR_SIGNAL_2_BAR, IDR_SIGNAL_3_BAR,
...@@ -434,6 +432,7 @@ void ChooserContentViewController::UpdateTableView() { ...@@ -434,6 +432,7 @@ void ChooserContentViewController::UpdateTableView() {
// Adapter turned off message. // Adapter turned off message.
adapterOffMessage_ = CreateLabel(l10n_util::GetNSStringF( adapterOffMessage_ = CreateLabel(l10n_util::GetNSStringF(
IDS_BLUETOOTH_DEVICE_CHOOSER_TURN_ADAPTER_OFF, base::string16())); IDS_BLUETOOTH_DEVICE_CHOOSER_TURN_ADAPTER_OFF, base::string16()));
CGFloat adapterOffMessageWidth = NSWidth([adapterOffMessage_ frame]);
// Connect button. // Connect button.
connectButton_ = [self createConnectButton]; connectButton_ = [self createConnectButton];
...@@ -528,10 +527,13 @@ void ChooserContentViewController::UpdateTableView() { ...@@ -528,10 +527,13 @@ void ChooserContentViewController::UpdateTableView() {
[self addSubview:titleView_]; [self addSubview:titleView_];
// Adapter turned off help button. // Adapter turned off help button.
CGFloat adapterOffHelpButtonOriginX = kMarginX + kAdapterOffHelpLinkPadding; CGFloat adapterOffHelpButtonOriginX = std::floor(
CGFloat adapterOffHelpButtonOriginY = titleOriginY - kVerticalPadding - scrollViewOriginX +
adapterOffHelpButtonHeight - (scrollViewWidth - adapterOffHelpButtonWidth - adapterOffMessageWidth) /
kAdapterOffHelpLinkPadding; 2);
CGFloat adapterOffHelpButtonOriginY =
std::floor(scrollViewOriginY +
(scrollViewHeight - adapterOffHelpButtonHeight) / 2);
[adapterOffHelpButton_ [adapterOffHelpButton_
setFrameOrigin:NSMakePoint(adapterOffHelpButtonOriginX, setFrameOrigin:NSMakePoint(adapterOffHelpButtonOriginX,
adapterOffHelpButtonOriginY)]; adapterOffHelpButtonOriginY)];
......
...@@ -106,8 +106,13 @@ void DeviceChooserContentView::Layout() { ...@@ -106,8 +106,13 @@ void DeviceChooserContentView::Layout() {
throbber_->SetBounds((rect.width() - kThrobberDiameter) / 2, throbber_->SetBounds((rect.width() - kThrobberDiameter) / 2,
(rect.height() - kThrobberDiameter) / 2, (rect.height() - kThrobberDiameter) / 2,
kThrobberDiameter, kThrobberDiameter); kThrobberDiameter, kThrobberDiameter);
// Set the adapter off message in the center of the chooser.
// The adapter off message will only be shown when the adapter is off,
// and in that case, the system won't be able to scan for devices, so
// the throbber won't be shown at the same time.
turn_adapter_off_help_->SetPosition( turn_adapter_off_help_->SetPosition(
gfx::Point(kAdapterOffHelpLinkPadding, kAdapterOffHelpLinkPadding)); gfx::Point((rect.width() - turn_adapter_off_help_->width()) / 2,
(rect.height() - turn_adapter_off_help_->height()) / 2));
turn_adapter_off_help_->SizeToFit(rect.width() - turn_adapter_off_help_->SizeToFit(rect.width() -
2 * kAdapterOffHelpLinkPadding); 2 * kAdapterOffHelpLinkPadding);
views::View::Layout(); views::View::Layout();
......
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