| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ash/system/chromeos/network/tray_sms.h" | 5 #include "ash/system/chromeos/network/tray_sms.h" |
| 6 | 6 |
| 7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "ash/system/tray/fixed_sized_scroll_view.h" | 8 #include "ash/system/tray/fixed_sized_scroll_view.h" |
| 9 #include "ash/system/tray/system_tray.h" | 9 #include "ash/system/tray/system_tray.h" |
| 10 #include "ash/system/tray/system_tray_bubble.h" | 10 #include "ash/system/tray/system_tray_bubble.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 : TrayItemMore(owner, true) { | 60 : TrayItemMore(owner, true) { |
| 61 SetImage(ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | 61 SetImage(ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
| 62 IDR_AURA_UBER_TRAY_SMS)); | 62 IDR_AURA_UBER_TRAY_SMS)); |
| 63 Update(); | 63 Update(); |
| 64 } | 64 } |
| 65 | 65 |
| 66 ~SmsDefaultView() override {} | 66 ~SmsDefaultView() override {} |
| 67 | 67 |
| 68 void Update() { | 68 void Update() { |
| 69 int message_count = static_cast<TraySms*>(owner())->messages().GetSize(); | 69 int message_count = static_cast<TraySms*>(owner())->messages().GetSize(); |
| 70 base::string16 label = l10n_util::GetStringFUTF16( | 70 // TODO(jshin): Currently, a tabular format is used ("SMS Messages: |
| 71 IDS_ASH_STATUS_TRAY_SMS_MESSAGES, base::IntToString16(message_count)); | 71 // <count>"). Check with UX if '<count> SMS messages' with a proper plural |
| 72 // support is desired. |
| 73 base::string16 label = l10n_util::GetStringFUTF16Int( |
| 74 IDS_ASH_STATUS_TRAY_SMS_MESSAGES, message_count); |
| 72 SetLabel(label); | 75 SetLabel(label); |
| 73 SetAccessibleName(label); | 76 SetAccessibleName(label); |
| 74 } | 77 } |
| 75 | 78 |
| 76 private: | 79 private: |
| 77 DISALLOW_COPY_AND_ASSIGN(SmsDefaultView); | 80 DISALLOW_COPY_AND_ASSIGN(SmsDefaultView); |
| 78 }; | 81 }; |
| 79 | 82 |
| 80 // An entry (row) in SmsDetailedView or NotificationView. | 83 // An entry (row) in SmsDetailedView or NotificationView. |
| 81 class TraySms::SmsMessageView : public views::View, | 84 class TraySms::SmsMessageView : public views::View, |
| 82 public views::ButtonListener { | 85 public views::ButtonListener { |
| 83 public: | 86 public: |
| 84 enum ViewType { | 87 enum ViewType { |
| 85 VIEW_DETAILED, | 88 VIEW_DETAILED, |
| 86 VIEW_NOTIFICATION | 89 VIEW_NOTIFICATION |
| 87 }; | 90 }; |
| 88 | 91 |
| 89 SmsMessageView(TraySms* owner, | 92 SmsMessageView(TraySms* owner, |
| 90 ViewType view_type, | 93 ViewType view_type, |
| 91 size_t index, | 94 size_t index, |
| 92 const std::string& number, | 95 const std::string& number, |
| 93 const std::string& message) | 96 const std::string& message) |
| 94 : owner_(owner), | 97 : owner_(owner), |
| 95 index_(index) { | 98 index_(index) { |
| 99 // TODO(jshin): Convert ASCII digits in |number| (phone number) to native |
| 100 // digits if necessary. |number| can contain non-digit characters and may |
| 101 // have to be converted one-by-one or use libphonenumber's formating API. |
| 96 number_label_ = new views::Label( | 102 number_label_ = new views::Label( |
| 97 l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_SMS_NUMBER, | 103 l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_SMS_NUMBER, |
| 98 base::UTF8ToUTF16(number)), | 104 base::UTF8ToUTF16(number)), |
| 99 ui::ResourceBundle::GetSharedInstance().GetFontList( | 105 ui::ResourceBundle::GetSharedInstance().GetFontList( |
| 100 ui::ResourceBundle::BoldFont)); | 106 ui::ResourceBundle::BoldFont)); |
| 101 number_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 107 number_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 102 | 108 |
| 103 message_label_ = new views::Label(base::UTF8ToUTF16(message)); | 109 message_label_ = new views::Label(base::UTF8ToUTF16(message)); |
| 104 message_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 110 message_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 105 message_label_->SetMultiLine(true); | 111 message_label_->SetMultiLine(true); |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 std::string number, text; | 409 std::string number, text; |
| 404 if (GetLatestMessage(&index, &number, &text)) | 410 if (GetLatestMessage(&index, &number, &text)) |
| 405 notification_->Update(index, number, text); | 411 notification_->Update(index, number, text); |
| 406 } else if (notify) { | 412 } else if (notify) { |
| 407 ShowNotificationView(); | 413 ShowNotificationView(); |
| 408 } | 414 } |
| 409 } | 415 } |
| 410 } | 416 } |
| 411 | 417 |
| 412 } // namespace ash | 418 } // namespace ash |
| OLD | NEW |