Added switching between 'Open Tabs' and 'On Other Devices' 54/47554/6
authorAlbert Malewski <a.malewski@samsung.com>
Fri, 4 Sep 2015 11:23:47 +0000 (13:23 +0200)
committerAlbert Malewski <a.malewski@samsung.com>
Mon, 7 Sep 2015 12:14:58 +0000 (14:14 +0200)
[Issue]     https://bugs.tizen.org/jira/browse/TT-149
[Problem]   "Opened Tabs" is not toggle with "On Other Devices" in Tab Manager.
[Cause]     Lack of implementation.
[Solution]  Added boolean onOtherDevicesSwitch variable, which allows to switch
            between 'Open Tabs' and 'On Other Devices' correctly. Changed type
            of onotherdevices_click and openedtabs_click from RECT to SWALLOW.
            Additionally, changed 'tab_gengird' to 'tab_gengrid'.
[Verify]    Launch browser > Open new tab > Tabs > On Other Devices > Obs
            Tabs should be hidden when 'On Other Devices' is clicked.

Change-Id: I18529df81e274dcbc658e8db7ef038b4080e907d

services/SimpleUI/SimpleUI.cpp
services/SimpleUI/SimpleUI.h
services/TabUI/TabUI.cpp
services/TabUI/TabUI.h
services/TabUI/edc/TabUI.edc

index de0e0d6c6f344a64fffe184b6d0f96650a762ff0..1b0e8d55af398e4457e41e3cd25107308698b477 100644 (file)
@@ -938,6 +938,7 @@ void SimpleUI::showTabUI()
     m_tabUI->tabClicked.connect(boost::bind(&SimpleUI::tabClicked, this,_1));
     m_tabUI->closeTabsClicked.connect(boost::bind(&SimpleUI::closeTabsClicked, this,_1));
     m_tabUI->newIncognitoTabClicked.connect(boost::bind(&SimpleUI::newTabClicked, this,_1));
+    m_tabUI->tabsCount.connect(boost::bind(&SimpleUI::tabsCount, this));
     m_tabUI->show(m_window.get());
     m_tabUI->addTabItems(m_webEngine->getTabContents());
 }
@@ -966,6 +967,11 @@ void SimpleUI::closeTabsClicked(const tizen_browser::basic_webengine::TabId& tab
     m_webEngine->closeTab(tabId);
 }
 
+int SimpleUI::tabsCount()
+{
+    return m_webEngine->tabsCount();
+}
+
 void SimpleUI::handleConfirmationRequest(basic_webengine::WebConfirmationPtr webConfirmation)
 {
     BROWSER_LOGD("%s", __func__);
index b8df3a1c1c735fb8afe628a85ee7c6fd417dd461..f8faab1c9545e0958896f27859bb70c9e5f0eebf 100644 (file)
@@ -270,6 +270,7 @@ private:
     void tabLimitPopupButtonClicked(PopupButtons button, std::shared_ptr< PopupData > /*popupData*/);
     void openLinkFromPopup(const std::string &);
     void disableHistoryButton(bool flag);
+    int tabsCount();
 
     void onNetworkError();
     void onNetworkConnected();
index cfb9e362ba8ecac75df2a47c5f5216e0e39076c0..e93f03e3735b8833c7b2083c04d6a4e77b607cd5 100644 (file)
@@ -51,6 +51,7 @@ TabUI::TabUI()
     elm_theme_extension_add(nullptr, m_edjFilePath.c_str());
     createTabItemClass();
     editMode = false;
+    onOtherDevicesSwitch = false;
 }
 
 TabUI::~TabUI()
@@ -100,7 +101,7 @@ Evas_Object* TabUI::createTabUILayout(Evas_Object* parent)
 
     //create gengrid containing tabs
     m_gengrid = elm_gengrid_add(tab_layout);
-    elm_object_part_content_set(tab_layout, "tab_gengird", m_gengrid);
+    elm_object_part_content_set(tab_layout, "tab_gengrid", m_gengrid);
 
     M_ASSERT(m_parent);
     elm_gengrid_align_set(m_gengrid, 0, 0);
@@ -155,7 +156,6 @@ Evas_Object* TabUI::createActionBar(Evas_Object* parent)
     return actionBarLayout;
 }
 
-
 void TabUI::_close_clicked(void* data, Evas_Object*, void*)
 {
     BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
@@ -164,6 +164,7 @@ void TabUI::_close_clicked(void* data, Evas_Object*, void*)
         tabUI->closeTabUIClicked(std::string());
         tabUI->clearItems();
         tabUI->editMode = false;
+        tabUI->onOtherDevicesSwitch = false;
     }
 }
 
@@ -171,7 +172,7 @@ void TabUI::hide()
 {
     evas_object_hide(elm_layout_content_get(m_tab_layout, "action_bar"));
     evas_object_hide(elm_layout_content_get(m_tab_layout, "top_bar"));
-    evas_object_hide(elm_layout_content_get(m_tab_layout, "tab_gengird"));
+    evas_object_hide(elm_layout_content_get(m_tab_layout, "tab_gengrid"));
     evas_object_hide(m_tab_layout);
 }
 
@@ -188,14 +189,14 @@ Evas_Object* TabUI::createTopButtons(Evas_Object* parent)
     Evas_Object *button = elm_button_add(topLayout);
     elm_object_style_set(button, "tab_button");
     evas_object_smart_callback_add(button, "clicked", _openedtabs_clicked, this);
-    //TODO: "openedtabs_button" is not swallow, change it when implementing callbacks
-    elm_object_part_content_set(topLayout, "openedtabs_button", button);
+    evas_object_show(button);
+    elm_layout_content_set(topLayout, "openedtabs_click", button);
 
     button = elm_button_add(topLayout);
     elm_object_style_set(button, "tab_button");
-    //TODO: "onotherdevices_button" is not swallow, change it when implementing callbacks
     evas_object_smart_callback_add(button, "clicked", _onotherdevices_clicked, this);
-    elm_object_part_content_set(topLayout, "onotherdevices_button", button);
+    evas_object_show(button);
+    elm_layout_content_set(topLayout, "onotherdevices_click", button);
 
     return topLayout;
 }
@@ -208,17 +209,36 @@ void TabUI::_newtab_clicked(void * data, Evas_Object*, void*)
         tabUI->clearItems();
         tabUI->newTabClicked(std::string());
         tabUI->editMode = false;
+        tabUI->onOtherDevicesSwitch = false;
     }
 
 }
-void TabUI::_openedtabs_clicked(void*, Evas_Object*, void*)
+void TabUI::_openedtabs_clicked(void* data, Evas_Object*, void*)
 {
-        BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
+    BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
+    if (data) {
+        TabUI* tabUI = static_cast<TabUI*>(data);
+        if(tabUI->onOtherDevicesSwitch) {
+            tabUI->onOtherDevicesSwitch = false;
+            evas_object_show(tabUI->m_gengrid);
+            elm_layout_text_set(elm_layout_content_get(tabUI->m_tab_layout, "action_bar"), "closetabs_text", "Close Tabs");
+            tabUI->editMode = false;
+        }
+    }
 }
 
-void TabUI::_onotherdevices_clicked(void*, Evas_Object*, void*)
+void TabUI::_onotherdevices_clicked(void* data, Evas_Object*, void*)
 {
-        BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
+    BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
+    if (data) {
+        TabUI* tabUI = static_cast<TabUI*>(data);
+        if(!tabUI->onOtherDevicesSwitch) {
+            tabUI->onOtherDevicesSwitch = true;
+            evas_object_hide(tabUI->m_gengrid);
+            elm_layout_text_set(elm_layout_content_get(tabUI->m_tab_layout, "action_bar"), "closetabs_text", "Close Tabs");
+            tabUI->editMode = false;
+        }
+    }
 }
 
 void TabUI::_newincognitotab_clicked(void* data, Evas_Object*, void*)
@@ -229,6 +249,7 @@ void TabUI::_newincognitotab_clicked(void* data, Evas_Object*, void*)
         tabUI->clearItems();
         tabUI->newIncognitoTabClicked(std::string());
         tabUI->editMode = false;
+        tabUI->onOtherDevicesSwitch = false;
     }
 }
 
@@ -237,11 +258,11 @@ void TabUI::_closetabs_clicked(void* data, Evas_Object* obj, void*)
     BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
     if (data) {
         TabUI* tabUI = static_cast<TabUI*>(data);
-        if (!tabUI->editMode) {
+        if (!tabUI->editMode && !tabUI->onOtherDevicesSwitch) {
             tabUI->editMode = true;
             BROWSER_LOGD("[%s:%d] --------> edit mode: %d ", __PRETTY_FUNCTION__, __LINE__, tabUI->editMode);
             elm_layout_text_set(elm_layout_content_get(tabUI->m_tab_layout, "action_bar"), "closetabs_text", "Close all");
-        } else {
+        } else if (tabUI->editMode && !tabUI->onOtherDevicesSwitch) {
             tabUI->closeAllTabs();
             elm_gengrid_realized_items_update(tabUI->m_gengrid);
         }
@@ -329,6 +350,10 @@ void TabUI::_thumbSelected(void *data, Evas_Object*, void*)
             Elm_Object_Item* it = elm_gengrid_selected_item_get(itemData->tabUI->m_gengrid);
             elm_object_item_del(it);
             elm_gengrid_realized_items_update(itemData->tabUI->m_gengrid);
+            int tabsNumber = *(itemData->tabUI->tabsCount());
+            BROWSER_LOGD("%s:%d %s, items: %d", __FILE__, __LINE__, __func__, tabsNumber);
+            if (!tabsNumber)
+                itemData->tabUI->hide();
         }
     }
 }
index b83f1187de58d1dceb9c927352142690b98da4f0..21cd5b24f62875844bbc4107359dd166979a9f59 100644 (file)
@@ -51,6 +51,7 @@ public:
     boost::signals2::signal<void (const std::string & )> openedTabsClicked;
     boost::signals2::signal<void (const std::string & )> onOtherDevicesClicked;
     boost::signals2::signal<void (const std::string & )> closeTabUIClicked;
+    boost::signals2::signal<int () > tabsCount;
 
 private:
     static char* _grid_text_get(void *data, Evas_Object *obj, const char *part);
@@ -80,6 +81,7 @@ private:
     Evas_Object *m_gengrid;
     Evas_Object *m_parent;
     bool editMode;
+    bool onOtherDevicesSwitch;
 
     Elm_Gengrid_Item_Class * m_item_class;
     std::map<std::string,Elm_Object_Item*> m_map_tab_views;
index 07f51923b30011e2c2b88059804947cdeaf438b8..faa4dac8642ebbff6b00ec9d31c2ae97f9adeab9 100644 (file)
@@ -256,7 +256,7 @@ group {
                     visible: 1;
                 }
            }
-          part { name: "tab_gengird";
+          part { name: "tab_gengrid";
                 type : SWALLOW;
                 scale: 1;
                 description {
@@ -1317,11 +1317,8 @@ group { name: "top_buttons_layout";
                     visible: 1;
                     align: 0 0;
                     fixed: 1 1;
-                    min: 348 65;
-                    max: 348 65;
-                    rel1 { relative: 0.0 0.0; to: "openedtabs_over";}
-                    rel2 { relative: 1.0 1.0; to: "openedtabs_over";}
-                    color_class: transparent;
+                    rel1 { relative: 0.0 0.0; to: "openedtabs_button";}
+                    rel2 { relative: 1.0 1.0; to: "openedtabs_button";}
                 }
             }
            part {
@@ -1400,7 +1397,7 @@ group { name: "top_buttons_layout";
             }
 
           part {
-                name: "onotherdevicess_click";
+                name: "onotherdevices_click";
                 scale:1;
                 type: SWALLOW;
                 description {
@@ -1408,11 +1405,8 @@ group { name: "top_buttons_layout";
                     visible: 1;
                     align: 0 0;
                     fixed: 1 1;
-                    min: 348 65;
-                    max: 348 65;
-                    rel1 { relative: 0.0 0.0; to: "onotherdevices_over";}
-                    rel2 { relative: 1.0 1.0; to: "onotherdevices_over";}
-                    color_class: transparent;
+                    rel1 { relative: 0.0 0.0; to: "onotherdevices_button";}
+                    rel2 { relative: 1.0 1.0; to: "onotherdevices_button";}
                 }
             }
         }