Fixed Nabi Issues
[apps/osp/Internet.git] / src / IntMainForm.cpp
index aeb00b2..049663c 100644 (file)
@@ -212,7 +212,7 @@ MainForm::MainForm(void)
        __pStopBtn = null;
        __pClearBtn = null;
        __pReaderBtn = null;
-       __isWebKeypadOpened = false;
+       __isKeypadOpened = false;
        __fontSize = 44;
        __pNotification = null;
 }
@@ -754,6 +754,7 @@ MainForm::InitOptionMenu()
 
        if (__pOptionMenu != null)
        {
+               __pOptionMenu->SetFocusable(true);
                __pOptionMenu->Invalidate(true);
                return r;
        }
@@ -762,6 +763,7 @@ MainForm::InitOptionMenu()
        r = __pOptionMenu->Construct();
        TryCatch(!IsFailed(r),,"Contextmenu creation failed with%s",GetErrorMessage(r));
 
+       __pOptionMenu->SetFocusable(true);
        isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
 
 
@@ -850,8 +852,8 @@ MainForm::InitImageLinkContextMenu(Tizen::Graphics::Point p)
        r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
        TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
 
-       r = __pImageMenu->AddItem("Open in new window"/*CommonUtil::GetString(L"IDS_BR_OPT_COPY_IMAGE")*/,IDA_HYPERLINK_OPEN_CLICKED);
-       r = __pImageMenu->AddItem("Copy link URL"/*CommonUtil::GetString(L"IDS_DLNA_BODY_SHARE_IMAGE_ABB")*/,IDA_HYPERLINK_COPY_LINK_CLICKED);
+       r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_BODY_OPEN_IN_NEW_WINDOW"),IDA_HYPERLINK_OPEN_CLICKED);
+       r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_COPY_LINK_URL"),IDA_HYPERLINK_COPY_LINK_CLICKED);
        //r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_HYPERLINK_SAVE_IMAGE_CLICKED);
        r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_HYPERLINK_SHARE_IMAGE_CLICKED);
 
@@ -1136,6 +1138,12 @@ MainForm::InitFindWordPanel(void)
        __pFindWordEditFieldRightToLeft->AddKeypadEventListener(*this);
        __pFindWordEditFieldRightToLeft->SetOverlayKeypadCommandButtonVisible(false);
        __pFindWordEditFieldRightToLeft->SetColor(EDIT_STATUS_HIGHLIGHTED, Color(0x00, 0x00, 0x00, 0x00));
+
+       if(__pAddressbar)
+               __pAddressbar->SetShowState(false);
+
+       if(__isKeypadOpened == false)
+               __pFooterPanel->SetShowState(true);
        return r;
 }
 
@@ -1205,7 +1213,7 @@ MainForm::CreateItem (int index, int itemWidth)
        if ( pListIconImage != NULL)
        {
                listImageRect.SetBounds(screenBounds.x + 16, screenBounds.y + 28  + (__fontSize - 44)/2 , 72, 72);
-               pagetTitleRect.SetBounds(listImageRect.x + 72 + 16,10, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 60  + (__fontSize - 44));
+               pagetTitleRect.SetBounds(listImageRect.x + 72 + 16,10, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 72  + (__fontSize - 44));
                pageURLRect.SetBounds(pagetTitleRect.x, pagetTitleRect.y + pagetTitleRect.height, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 48);
 
 
@@ -1287,6 +1295,7 @@ MainForm::GetItemCount (void)
 void
 MainForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state)
 {
+       AppLog("MainForm::OnListViewContextItemStateChanged called");
        if(__pMostVisitedSites != null)
        {
                History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
@@ -2031,7 +2040,7 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
                __pFindWordCountLabel->SetText(L"0/0");
                __pWebViewer->SearchText(L"aaaabbbbcccc",true);
                AppLog("akjshdasd 1");
-               if(__isWebKeypadOpened == false)
+               if(__isKeypadOpened == false)
                        __pFooterPanel->SetShowState(true);
                ShowFindWordPanel(false);
        }
@@ -2453,6 +2462,7 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
                {
                        String idElement = __pHitElementResult->GetAttributeValue(L"id");
                        String nameElement = __pHitElementResult->GetAttributeValue(L"name");
+                       String tagElement  = __pHitElementResult->GetTagName();
                        AppLog("MainForm::IDA_PASTE_TEXT_CLICKED id is %ls",idElement.GetPointer());
 
                        String script;
@@ -2476,6 +2486,16 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
                                script.Append(*pString);
                                script.Append("\");");
                        }
+                       else//adding for twitter post page
+                       {
+                               script = L"function insertAtCursor(myField, myValue) {  if (document.selection) {   document.getElementsByTagName(myField)[0].focus();   sel = document.selection.createRange();   sel.text = myValue;  }   else if (myField.selectionStart || myField.selectionStart == '0'){   var startPos = myField.selectionStart;   var endPos = myField.selectionEnd;   myField.value = myField.value.substring(0, startPos)+ myValue + myField.value.substring(endPos, myField.value.length);   } else {    document.getElementsByTagName(myField)[0].value += myValue;   }  } ";
+                               script.Append("insertAtCursor(document.getElementsByTagName('");
+                               script.Append(tagElement);
+                               script.Append("')[0],");
+                               script.Append("\"");
+                               script.Append(*pString);
+                               script.Append("\");");
+                       }
                        AppLog("MainForm::OnTouchLongPressed script is %ls",script.GetPointer());
                        String* pStr = __pWebViewer->EvaluateJavascriptN(script);
                        delete pStr;
@@ -2884,6 +2904,7 @@ MainForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
                delete pBitmap;
        }
 
+       RelayoutControls(false);
        AppLog("ABC: OnSceneActivatedN started exit");
 
 }
@@ -3080,6 +3101,7 @@ void
 MainForm::OnKeypadOpened(Tizen::Ui::Control& source)
 {
        AppLog("XYZ::MainForm::OnKeypadOpened");
+       __isKeypadOpened = true;
        __pFooterPanel->SetShowState(false);
 
 }
@@ -3088,6 +3110,7 @@ void
 MainForm::OnKeypadClosed(Tizen::Ui::Control& source)
 {
        AppLog("XYZ::MainForm::OnKeypadClosed");
+       __isKeypadOpened = false;
        __pFooterPanel->SetShowState(true);
        RelayoutControls(true);
 }
@@ -3406,6 +3429,7 @@ MainForm::LoadUrl(String& url)
 void
 MainForm::OnFocusGained(const Tizen::Ui::Control& source)
 {
+       AppLog("MainForm::OnFocusGained");
        if(__pFooterPanel)
        {
                __pFooterPanel->SetShowState(false);
@@ -3422,7 +3446,7 @@ MainForm::OnFocusGained(const Tizen::Ui::Control& source)
 void
 MainForm::OnFocusLost(const Tizen::Ui::Control& source)
 {
-
+       AppLog("MainForm::OnFocusLost called");
 }
 
 void
@@ -4129,6 +4153,7 @@ MainForm::RelayoutControls(bool showAddressbar,bool relayoutFooter)
                else
                {
                        __pWebViewer->SetBounds(0, __webControlPosition.y, GetClientAreaBounds().width, __webControlHeight + 12);
+                       AppLog("xyz:: MainForm::RelayoutControls called __webControlHeight %d",__webControlHeight);
                        __pWebViewer->Invalidate(false);
                }
        }
@@ -4408,7 +4433,7 @@ void
 MainForm::OnWebKeypadWillOpen(Tizen::Web::Controls::Web& source)
 {
        AppLog("xyz::MainForm::OnWebKeypadWillOpen");
-       __isWebKeypadOpened = true;
+       __isKeypadOpened = true;
        __pFooterPanel->SetShowState(false);
        //      OnAddressBarKeypadOpened(*__pAddressbar);
 }
@@ -4416,7 +4441,7 @@ MainForm::OnWebKeypadWillOpen(Tizen::Web::Controls::Web& source)
 void
 MainForm::OnWebKeypadOpened(Tizen::Web::Controls::Web& source)
 {
-       __isWebKeypadOpened = true;
+       __isKeypadOpened = true;
        AppLog("xyz::MainForm::OnWebKeypadOpened");
 
        if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
@@ -4464,7 +4489,7 @@ MainForm::OnWebKeypadClosed(Tizen::Web::Controls::Web& source)
        __pFooterPanel->SetShowState(true);
 //     OnAddressBarKeypadClosed(*__pAddressbar);
        RelayoutControls(false);
-       __isWebKeypadOpened = false;
+       __isKeypadOpened = false;
 }
 
 void
@@ -4568,7 +4593,7 @@ void MainForm::OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen:
 
                __isLongPressedDone = true;
                result r =__pWebViewer->SetBlockSelectionPosition(currentPosition);
-               if (((tagName.CompareTo(L"INPUT") == 0)  || tagName.CompareTo(L"TEXTAREA") == 0) && innerHtml.GetLength() == 0 /*&& __isWebKeypadOpened == true*/ && __currentSelectedStr.CompareTo(L"") == 0 && r == E_INVALID_ARG)
+               if (((tagName.CompareTo(L"INPUT") == 0)  || tagName.CompareTo(L"TEXTAREA") == 0) && innerHtml.GetLength() == 0  && type.CompareTo(L"submit") !=0/*&& __isWebKeypadOpened == true*/ && __currentSelectedStr.CompareTo(L"") == 0 && r == E_INVALID_ARG)
                {
                        AppLog("MainForm::OnWebPageBlockSelected show paste option");
 
@@ -4595,7 +4620,7 @@ MainForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphic
        {
                __pAddressbar->SetShowState(false);
        }
-       if(__pFooterPanel && __isWebKeypadOpened == false)
+       if(__pFooterPanel && __isKeypadOpened == false)
        {
                __pFooterPanel->SetShowState(true);
        }
@@ -4650,13 +4675,14 @@ MainForm::OnTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEven
                __pWebViewer->SearchText(L"aaaabbbbcccc",true);
                __pFindWordControl->SetShowState(false);
        }
+       AppLog("__pAddressbar->GetShowState() %d",__pAddressbar->GetShowState());
        if(__pAddressbar->GetShowState() == false)
        {
                __pAddressbar->SetAddressbarURLFocus();
                __pFooterPanel->SetShowState(false);
        }
 
-       return true;
+       return false;
 }
 
 bool
@@ -4705,6 +4731,20 @@ MainForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::Ori
 
 //     if(__pFindWordControl != null)
 //             ShowFindWordPanel(__pFindWordControl->GetShowState(), false);
+
+       if(__pOptionMenu && __pOptionMenu->GetShowState() == true)
+       {
+               if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
+               {
+                       AppLog(" Orientation landscape");
+                       __pOptionMenu->SetMaxVisibleItemsCount(5);
+               }
+               else
+               {
+                       AppLog(" Orientation potrait");
+                       __pOptionMenu->SetMaxVisibleItemsCount(6);
+               }
+       }
        if(__pNotification && __pNotification->GetShowState() == true)
        {
                __pNotification->SetShowState(false);
@@ -5088,7 +5128,7 @@ MainForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics
        {
                __pAddressbar->SetShowState(false);
        }
-       if(__pFooterPanel && __isWebKeypadOpened == false)
+       if(__pFooterPanel && __isKeypadOpened == false)
        {
                __pFooterPanel->SetShowState(true);
        }
@@ -5133,6 +5173,9 @@ MainForm::OnTextValueChanged (const Tizen::Ui::Control &source)
                else
                {
                        __pFindWordCountLabel->SetShowState(false);
+                       __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),84,__pFindWordCountLabel->GetHeight());
+                       __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());
+
                }
                __pFindWordNext->SetEnabled(false);
                __pFindWordPrev->SetEnabled(false);
@@ -5618,6 +5661,10 @@ MainForm::OnUserEventReceivedN (RequestId requestId, Tizen::Base::Collection::IL
                {
                        __pWebViewer->Pause();
                }
+               if(__pImageMenu)
+               {
+                       __pImageMenu->SetShowState(false);
+               }
                if(__pAddressbar != null)
                {
                        __pAddressbar->SendUserEvent(BACK_GROUND_APP_EVENT,NULL);
@@ -5746,7 +5793,8 @@ MainForm::OnFormMenuRequested (Tizen::Ui::Controls::Form &source)
                delete pBitmap;
        }
        AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
-       __pOptionMenu->SetShowState(true);
+       result r = __pOptionMenu->SetShowState(true);
+       AppLog("ajsghd %s",GetErrorMessage(r));
        __pOptionMenu->Invalidate(true);
        __pOptionMenu->Show();