OssoABook.Button button_calendar;
Label label_driver;
OssoABook.Button button_phone;
+ OssoABook.Button button_sms;
Image image_smoke;
Label label;
button_route = new OssoABook.Button (SizeType.FINGER_HEIGHT);
button_route.style = OssoABook.ButtonStyle.LABEL;
- var table = new Table (2, 4, false);
+ var table = new Table (5, 2, false);
button_calendar = new OssoABook.Button (SizeType.FINGER_HEIGHT);
button_calendar.set_icon_name ("general_calendar");
button_phone.set_icon_visible (true);
button_phone.title = _("Phone");
+ button_sms = new OssoABook.Button (SizeType.FINGER_HEIGHT);
+ button_sms.set_icon_name ("general_sms");
+ button_sms.set_icon_visible (true);
+ button_sms.title = _("SMS");
+
image_smoke = new Image ();
label = new Label ("");
table.attach (button_calendar, 1, 2, 0, 1, AttachOptions.FILL | AttachOptions.EXPAND, AttachOptions.FILL, 0, 0);
table.attach (label_driver, 0, 1, 1, 2, AttachOptions.FILL | AttachOptions.EXPAND, AttachOptions.FILL, MARGIN_DEFAULT, 0);
table.attach (button_phone, 1, 2, 1, 2, AttachOptions.FILL | AttachOptions.EXPAND, AttachOptions.FILL, 0, 0);
- table.attach (image_smoke, 1, 2, 2, 3, AttachOptions.FILL | AttachOptions.EXPAND, AttachOptions.FILL, 0, 0);
- table.attach (label, 0, 2, 3, 4, AttachOptions.FILL | AttachOptions.EXPAND, AttachOptions.FILL, MARGIN_DEFAULT, 0);
+ table.attach (button_sms, 1, 2, 2, 3, AttachOptions.FILL | AttachOptions.EXPAND, AttachOptions.FILL, 0, 0);
+ table.attach (image_smoke, 1, 2, 3, 4, AttachOptions.FILL | AttachOptions.EXPAND, AttachOptions.FILL, 0, 0);
+ table.attach (label, 0, 2, 4, 5, AttachOptions.FILL | AttachOptions.EXPAND, AttachOptions.FILL, MARGIN_DEFAULT, 0);
vbox.pack_start (button_route, true, true, 0);
vbox.pack_start (table, true, true, 0);
add_contact.clicked.connect (on_add_contact_clicked);
goto_website.clicked.connect (on_goto_website_clicked);
button_phone.clicked.connect (on_button_phone_clicked);
+ button_sms.clicked.connect (on_button_sms_clicked);
}
private async void get_lift_details () {
label_driver.set_text (_("Driver: ") + lift.name);
if (lift.cell != null) {
button_phone.title = _("Cell");
- button_phone.value = E.normalize_phone_number (lift.cell);
+ string cell_number = E.normalize_phone_number (lift.cell);
+ button_phone.value = cell_number;
+ button_sms.value = cell_number;
} else if (lift.phone != null) {
button_phone.title = _("Phone");
- button_phone.value = E.normalize_phone_number (lift.phone);
+ string phone_number = E.normalize_phone_number (lift.phone);
+ button_phone.value = phone_number;
+ button_sms.value = phone_number;
}
string lift_text = _("Free places: %d\n").printf (lift.places);
}
}
+ void on_button_sms_clicked () {
+ var uri = "sms://";
+ if (lift.cell != null)
+ uri += E.normalize_phone_number (lift.cell);
+ else if (lift.phone != null)
+ uri += E.normalize_phone_number (lift.phone);
+ try {
+ var action = URIAction.get_default_action_by_uri (uri);
+ if (action != null) {
+ action.open (uri);
+ } else {
+
+ Banner.show_information (this, null, _("Couldn't open %s URI").printf (uri));
+ }
+ } catch (Error e) {
+ if (e is URIError) {
+ Banner.show_information (this, null, _("Error: %s").printf (e.message));
+ }
+ }
+ }
+
void on_add_contact_clicked () {
var contact = new OssoABook.Contact ();
var attr_fn = new E.VCardAttribute (null, E.EVC_FN);