#define APP_CONTROL_MIME_CONTACT "application/vnd.tizen.contact"
-#define APP_CONTROL_SELECT_SINGLE "single"
+#define APP_CONTROL_SELECT_SINGLE "single"
#define APP_CONTROL_SELECT_MULTIPLE "multiple"
-#define APP_CONTROL_RESULT_ID "id"
-#define APP_CONTROL_RESULT_PHONE "phone"
-#define APP_CONTROL_RESULT_EMAIL "email"
-#define APP_CONTROL_RESULT_VCARD "vcf"
+#define APP_CONTROL_RESULT_ID "id"
+#define APP_CONTROL_RESULT_PHONE "phone"
+#define APP_CONTROL_RESULT_EMAIL "email"
+#define APP_CONTROL_RESULT_VCARD "vcf"
namespace App
{
std::string EXPORT_API getSingleExtraData(app_control_h appControl, const char *key);
/**
+ * @brief Get integer value from App Control array extra data.
+ * @param[in] appControl App Control handle
+ * @param[in] key Extra data array key
+ * @return Integer value.
+ */
+ int EXPORT_API getIntExtraData(app_control_h appControl, const char *key);
+
+ /**
* @brief Get vector of integer values from App Control array extra data.
* @param[in] appControl App Control handle
* @param[in] key Extra data array key
#define UI_WINDOW_H
#include "Ui/Control.h"
+#include <functional>
namespace Ui
{
class EXPORT_API Window : public Control
{
public:
+ /**
+ * @brief Called when "back" button was pressed and wasn't handled by any view.
+ * @return true to lower the window, otherwise false.
+ */
+ typedef std::function<bool()> BackCallback;
+
Window();
/**
Evas_Object *getBaseLayout() const;
/**
+ * @brief Set "back" button callback.
+ * @param[in] callback "back" button callback
+ */
+ void setBackCallback(BackCallback callback);
+
+ /**
+ * @brief Unset "back" button callback.
+ */
+ void unsetBackCallback();
+
+ /**
* @brief Attach main View to be displayed in the Window.
* @param[in] view Window main View
*/
Evas_Object *m_Conform;
Evas_Object *m_Layout;
View *m_MainView;
+ BackCallback m_OnBackPressed;
};
}
return result;
}
+int App::getIntExtraData(app_control_h appControl, const char *key)
+{
+ int result = 0;
+ char *resultStr = nullptr;
+
+ int err = app_control_get_extra_data(appControl, key, &resultStr);
+ RETVM_IF_ERR(err, result, "app_control_get_extra_data_array() failed.");
+
+ if (resultStr) {
+ result = atoi(resultStr);
+ free(resultStr);
+ }
+
+ return result;
+}
+
std::vector<int> App::getIntExtraDataArray(app_control_h appControl, const char *key)
{
std::vector<int> result;
return m_Layout;
}
+void Window::setBackCallback(BackCallback callback)
+{
+ m_OnBackPressed = std::move(callback);
+}
+
+void Window::unsetBackCallback()
+{
+ m_OnBackPressed = nullptr;
+}
+
void Window::attachView(View *view)
{
m_MainView = view;
void Window::onBackPressed(Evas_Object *obj, void *eventInfo)
{
if (!m_MainView || m_MainView->onBackPressed()) {
- elm_win_lower(getEvasObject());
+ if (!m_OnBackPressed || m_OnBackPressed()) {
+ elm_win_lower(getEvasObject());
+ }
}
}
enum Operation
{
- OPERATION_DEFAULT = 1 << 0,
- OPERATION_DIAL = 1 << 1,
- OPERATION_ADD = 1 << 2,
- OPERATION_EDIT = 1 << 3,
- OPERATION_VIEW = 1 << 4,
- OPERATION_PICK = 1 << 5
+ OperationDefault = 1 << 0,
+ OperationDial = 1 << 1,
+ OperationAdd = 1 << 2,
+ OperationEdit = 1 << 3,
+ OperationView = 1 << 4,
+ OperationPick = 1 << 5
};
class MainApp;
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef OPERATION_PICK_CONTROLLER_H
+#define OPERATION_PICK_CONTROLLER_H
+
+#include "OperationController.h"
+#include "Contacts/Common/SelectMode.h"
+
+#include <Evas.h>
+
+namespace Ui
+{
+ class Navigator;
+}
+
+class OperationPickController : public OperationController
+{
+public:
+ OperationPickController();
+ virtual ~OperationPickController();
+
+private:
+ virtual void onCreate() override;
+ virtual void onRequest(Operation operation, app_control_h request) override;
+ bool onSelected(Contacts::SelectResults results);
+
+ static Contacts::SelectMode getSelectMode(app_control_h request);
+ static Contacts::ResultType getResultType(app_control_h request);
+ static const char *getResultTypeString(Contacts::ResultType resultType);
+
+ Ui::Navigator *m_Navigator;
+ Contacts::SelectMode m_SelectMode;
+ Contacts::ResultType m_ResultType;
+};
+
+#endif /* _OPERATION_PICK_CONTROLLER_H_ */
#include "Utils/Logger.h"
#include "OperationDefaultController.h"
+#include "OperationPickController.h"
/* TODO:
#include "OperationEditController.h"
#include "OperationViewController.h"
-#include "OperationPickController.h"
*/
MainApp::MainApp()
m_Controller = nullptr;
switch (operation) {
- case OPERATION_DEFAULT:
- case OPERATION_DIAL:
+ case OperationDefault:
+ case OperationDial:
m_Controller = new OperationDefaultController();
break;
- case OPERATION_ADD:
- case OPERATION_EDIT:
+ case OperationAdd:
+ case OperationEdit:
/* TODO: m_Controller = new OperationEditController(); */
break;
- case OPERATION_VIEW:
+ case OperationView:
/* TODO: m_Controller = new OperationViewController(); */
break;
- case OPERATION_PICK:
- /* TODO: m_Controller = new OperationPickController(); */
+ case OperationPick:
+ m_Controller = new OperationPickController();
break;
}
Operation OperationController::getOperation(const char *operation)
{
if (!operation) {
- return OPERATION_DEFAULT;
+ return OperationDefault;
}
if (strcmp(operation, APP_CONTROL_OPERATION_DEFAULT) == 0) {
- return OPERATION_DEFAULT;
+ return OperationDefault;
}
if (strcmp(operation, APP_CONTROL_OPERATION_DIAL) == 0) {
- return OPERATION_DIAL;
+ return OperationDial;
}
if (strcmp(operation, APP_CONTROL_OPERATION_ADD) == 0) {
- return OPERATION_ADD;
+ return OperationAdd;
}
if (strcmp(operation, APP_CONTROL_OPERATION_EDIT) == 0) {
- return OPERATION_EDIT;
+ return OperationEdit;
}
if (strcmp(operation, APP_CONTROL_OPERATION_VIEW) == 0) {
- return OPERATION_VIEW;
+ return OperationView;
}
if (strcmp(operation, APP_CONTROL_OPERATION_PICK) == 0) {
- return OPERATION_PICK;
+ return OperationPick;
}
- return OPERATION_DEFAULT;
+ return OperationDefault;
}
MainApp *OperationController::getApplication() const
#define PREFERENCE_KEY_LAST_TAB "last_tab"
OperationDefaultController::OperationDefaultController()
- : OperationController(OPERATION_DEFAULT | OPERATION_DIAL),
+ : OperationController(OperationDefault | OperationDial),
m_Navigator(nullptr), m_Tabs{nullptr}
{
}
app_control_get_app_id(request, &appId);
TabId selectedTab = TabContacts;
- if (operation == OPERATION_DIAL) {
+ if (operation == OperationDial) {
auto dialer = static_cast<Phone::Dialer::DialerView *>(m_Tabs[TabDialer]);
dialer->setNumber(getPhoneNumber(request));
selectedTab = TabDialer;
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "OperationPickController.h"
+
+#include "MainApp.h"
+#include "Contacts/Common/Chooser.h"
+
+#include "App/AppControlRequest.h"
+#include "Ui/Navigator.h"
+#include "Ui/Window.h"
+
+#include <vector>
+
+#define ID_BUFFER_SIZE 16
+
+using namespace Contacts;
+using namespace Contacts::Common;
+using namespace std::placeholders;
+
+OperationPickController::OperationPickController()
+ : OperationController(OperationPick),
+ m_Navigator(nullptr),
+ m_SelectMode(SelectSingle), m_ResultType(ResultPerson)
+{
+}
+
+OperationPickController::~OperationPickController()
+{
+ getApplication()->getWindow()->unsetBackCallback();
+}
+
+void OperationPickController::onCreate()
+{
+ m_Navigator = getApplication()->getNavigator();
+ getApplication()->getWindow()->setBackCallback([] {
+ ui_app_exit();
+ return true;
+ });
+}
+
+void OperationPickController::onRequest(Operation operation, app_control_h request)
+{
+ m_SelectMode = getSelectMode(request);
+ m_ResultType = getResultType(request);
+
+ int limit = App::getIntExtraData(request, APP_CONTROL_DATA_TOTAL_COUNT);
+ Chooser *chooser = new Chooser(m_SelectMode, m_ResultType, limit);
+ chooser->setSelectCallback(std::bind(&OperationPickController::onSelected, this, _1));
+ m_Navigator->navigateTo(chooser);
+}
+
+bool OperationPickController::onSelected(SelectResults results)
+{
+ size_t count = results.count();
+ std::vector<char[ID_BUFFER_SIZE]> buffers(count);
+ std::vector<const char *> ids(count);
+
+ for (size_t i = 0; i < count; ++i) {
+ snprintf(buffers[i], sizeof(buffers[i]), "%d", results[i].itemId);
+ ids[i] = buffers[i];
+ }
+
+ app_control_h reply = nullptr;
+ app_control_create(&reply);
+
+ app_control_add_extra_data(reply, APP_CONTROL_DATA_TYPE, getResultTypeString(m_ResultType));
+ app_control_add_extra_data_array(reply, APP_CONTROL_DATA_SELECTED, ids.data(), ids.size());
+
+ app_control_reply_to_launch_request(reply, getRequest(), APP_CONTROL_RESULT_SUCCEEDED);
+ app_control_destroy(reply);
+
+ ui_app_exit();
+ return true;
+}
+
+SelectMode OperationPickController::getSelectMode(app_control_h request)
+{
+ char *selectMode = nullptr;
+ app_control_get_extra_data(request, APP_CONTROL_DATA_SELECTION_MODE, &selectMode);
+
+ if (selectMode) {
+ if (strcmp(selectMode, APP_CONTROL_SELECT_SINGLE) == 0) {
+ return SelectSingle;
+ } else if (strcmp(selectMode, APP_CONTROL_SELECT_MULTIPLE) == 0) {
+ return SelectMulti;
+ }
+
+ free(selectMode);
+ }
+
+ return SelectSingle;
+}
+
+ResultType OperationPickController::getResultType(app_control_h request)
+{
+ char *resultType = nullptr;
+ app_control_get_extra_data(request, APP_CONTROL_DATA_TYPE, &resultType);
+
+ if (resultType) {
+ if (strcmp(resultType, APP_CONTROL_RESULT_ID) == 0) {
+ return ResultPerson;
+ } else if (strcmp(resultType, APP_CONTROL_RESULT_PHONE) == 0) {
+ return ResultNumber;
+ } else if (strcmp(resultType, APP_CONTROL_RESULT_EMAIL) == 0) {
+ return ResultEmail;
+ }
+
+ free(resultType);
+ }
+
+ return ResultPerson;
+}
+
+const char *OperationPickController::getResultTypeString(ResultType resultType)
+{
+ switch (resultType) {
+ case ResultMyProfile:
+ case ResultPerson:
+ return APP_CONTROL_RESULT_ID;
+ case ResultNumber:
+ return APP_CONTROL_RESULT_PHONE;
+ case ResultEmail:
+ return APP_CONTROL_RESULT_EMAIL;
+ }
+
+ return APP_CONTROL_RESULT_ID;
+}
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<?xml version="1.0" encoding="UTF-8"?>
<manifest xmlns="http://tizen.org/ns/packages" api-version="2.4" package="org.tizen.contacts-2" version="1.0.0">
<profile name="mobile"/>
<ui-application appid="org.tizen.contacts-2" exec="contacts" hw-acceleration="on" multiple="false" nodisplay="false" taskmanage="true" type="capp">
<uri name="tel"/>
</app-control>
</ui-application>
+ <ui-application appid="org.tizen.contacts-2.app-control" exec="contacts" hw-acceleration="on" launch_mode="caller" multiple="true" nodisplay="true" taskmanage="false" type="capp">
+ <icon>org.tizen.contacts.png</icon>
+ <label>Contacts</label>
+ <label xml:lang="ar-ae">الأسماء</label>
+ <label xml:lang="az-az">Adlar</label>
+ <label xml:lang="bg-bg">Телефонен указател</label>
+ <label xml:lang="ca-es">Contactes</label>
+ <label xml:lang="cs-cz">Kontakty</label>
+ <label xml:lang="da-dk">Kontakter</label>
+ <label xml:lang="de-de">Kontakte</label>
+ <label xml:lang="el-gr">Επαφές</label>
+ <label xml:lang="en-gb">Contacts</label>
+ <label xml:lang="en-ph">Contacts</label>
+ <label xml:lang="en-us">Contacts 2</label>
+ <label xml:lang="es-es">Contactos</label>
+ <label xml:lang="es-mx">Contactos</label>
+ <label xml:lang="et-ee">Kontaktid</label>
+ <label xml:lang="eu-es">Kontaktuak</label>
+ <label xml:lang="fi-fi">Yhteystiedot</label>
+ <label xml:lang="fr-ca">Contacts</label>
+ <label xml:lang="fr-fr">Contacts</label>
+ <label xml:lang="ga-ie">Teagmhálaithe</label>
+ <label xml:lang="gl-es">Contactos</label>
+ <label xml:lang="hi-in">संपर्क</label>
+ <label xml:lang="hr-hr">Imenik</label>
+ <label xml:lang="hu-hu">Névjegyek</label>
+ <label xml:lang="hy-am">Կոնտակտներ</label>
+ <label xml:lang="is-is">Tengiliðir</label>
+ <label xml:lang="it-it">Rubrica</label>
+ <label xml:lang="ja-jp">電話帳</label>
+ <label xml:lang="ka-ge">კონტაქტები</label>
+ <label xml:lang="kk-kz">Контактілер</label>
+ <label xml:lang="ko-kr">연락처</label>
+ <label xml:lang="lt-lt">Adresatai</label>
+ <label xml:lang="lv-lv">Kontakti</label>
+ <label xml:lang="mk-mk">Именик</label>
+ <label xml:lang="nb-no">Kontakter</label>
+ <label xml:lang="nl-nl">Contacten</label>
+ <label xml:lang="pl-pl">Kontakty</label>
+ <label xml:lang="pt-br">Contatos</label>
+ <label xml:lang="pt-pt">Contactos</label>
+ <label xml:lang="ro-ro">Contacte</label>
+ <label xml:lang="ru-ru">Контакты</label>
+ <label xml:lang="sk-sk">Kontakty</label>
+ <label xml:lang="sl-si">Imenik</label>
+ <label xml:lang="sr-rs">Kontakti</label>
+ <label xml:lang="sv-se">Kontakter</label>
+ <label xml:lang="tr-tr">Rehber</label>
+ <label xml:lang="uk-ua">Контакти</label>
+ <label xml:lang="uz-uz">Kontaktlar</label>
+ <label xml:lang="zh-cn">联系人</label>
+ <label xml:lang="zh-hk">聯絡人</label>
+ <label xml:lang="zh-tw">聯絡人</label>
+ <app-control>
+ <operation name="http://tizen.org/appcontrol/operation/pick"/>
+ <mime name="application/vnd.tizen.contact"/>
+ </app-control>
+ </ui-application>
<privileges>
<privilege>http://tizen.org/privilege/appmanager.launch</privilege>
<privilege>http://tizen.org/privilege/call</privilege>
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<?xml version="1.0" encoding="UTF-8"?>
<manifest xmlns="http://tizen.org/ns/packages" api-version="2.4" package="@PACKAGE@" version="1.0.0">
<ui-application appid="@PACKAGE@" exec="@BIN_DIR@/contacts" hw-acceleration="use-GL" multiple="false" nodisplay="false" taskmanage="true" type="capp">
<icon>org.tizen.contacts.png</icon>
<uri name="tel" />
</app-control>
</ui-application>
+ <ui-application appid="@PACKAGE@.app-control" exec="@BIN_DIR@/contacts" hw-acceleration="use-GL" launch_mode="caller" multiple="true" nodisplay="true" taskmanage="false" type="capp">
+ <icon>org.tizen.contacts.png</icon>
+ <label>Contacts</label>
+ <label xml:lang="ar-ae">الأسماء</label>
+ <label xml:lang="az-az">Adlar</label>
+ <label xml:lang="bg-bg">Телефонен указател</label>
+ <label xml:lang="ca-es">Contactes</label>
+ <label xml:lang="cs-cz">Kontakty</label>
+ <label xml:lang="da-dk">Kontakter</label>
+ <label xml:lang="de-de">Kontakte</label>
+ <label xml:lang="el-gr">Επαφές</label>
+ <label xml:lang="en-gb">Contacts</label>
+ <label xml:lang="en-ph">Contacts</label>
+ <label xml:lang="en-us">Contacts</label>
+ <label xml:lang="es-es">Contactos</label>
+ <label xml:lang="es-mx">Contactos</label>
+ <label xml:lang="et-ee">Kontaktid</label>
+ <label xml:lang="eu-es">Kontaktuak</label>
+ <label xml:lang="fi-fi">Yhteystiedot</label>
+ <label xml:lang="fr-ca">Contacts</label>
+ <label xml:lang="fr-fr">Contacts</label>
+ <label xml:lang="ga-ie">Teagmhálaithe</label>
+ <label xml:lang="gl-es">Contactos</label>
+ <label xml:lang="hi-in">संपर्क</label>
+ <label xml:lang="hr-hr">Imenik</label>
+ <label xml:lang="hu-hu">Névjegyek</label>
+ <label xml:lang="hy-am">Կոնտակտներ</label>
+ <label xml:lang="is-is">Tengiliðir</label>
+ <label xml:lang="it-it">Rubrica</label>
+ <label xml:lang="ja-jp">電話帳</label>
+ <label xml:lang="ka-ge">კონტაქტები</label>
+ <label xml:lang="kk-kz">Контактілер</label>
+ <label xml:lang="ko-kr">연락처</label>
+ <label xml:lang="lt-lt">Adresatai</label>
+ <label xml:lang="lv-lv">Kontakti</label>
+ <label xml:lang="mk-mk">Именик</label>
+ <label xml:lang="nb-no">Kontakter</label>
+ <label xml:lang="nl-nl">Contacten</label>
+ <label xml:lang="pl-pl">Kontakty</label>
+ <label xml:lang="pt-br">Contatos</label>
+ <label xml:lang="pt-pt">Contactos</label>
+ <label xml:lang="ro-ro">Contacte</label>
+ <label xml:lang="ru-ru">Контакты</label>
+ <label xml:lang="sk-sk">Kontakty</label>
+ <label xml:lang="sl-si">Imenik</label>
+ <label xml:lang="sr-rs">Kontakti</label>
+ <label xml:lang="sv-se">Kontakter</label>
+ <label xml:lang="tr-tr">Rehber</label>
+ <label xml:lang="uk-ua">Контакти</label>
+ <label xml:lang="uz-uz">Kontaktlar</label>
+ <label xml:lang="zh-cn">联系人</label>
+ <label xml:lang="zh-hk">聯絡人</label>
+ <label xml:lang="zh-tw">聯絡人</label>
+ <app-control>
+ <operation name="http://tizen.org/appcontrol/operation/pick"/>
+ <mime name="application/vnd.tizen.contact"/>
+ </app-control>
+ </ui-application>
<privileges>
<privilege>http://tizen.org/privilege/appmanager.launch</privilege>
<privilege>http://tizen.org/privilege/call</privilege>