From 19a943ab515f31a02204c37c5eef1ef468442561 Mon Sep 17 00:00:00 2001 From: Vinay Sachdeva Date: Wed, 29 May 2013 00:52:28 +0530 Subject: [PATCH] Fixed Nabi Issues & implementation of Article Reader Change-Id: I660e5216ffd99f5304836799515f2c602db38607 Signed-off-by: Vinay Sachdeva --- inc/IntArticleReaderForm.h | 6 +- inc/IntMainForm.h | 1 + inc/IntMultipleWindowForm.h | 2 + src/IntArticleReaderForm.cpp | 180 ++++++++++++++++++++++++++++++++++++++---- src/IntMainForm.cpp | 45 ++++++++++- src/IntMultipleWindowForm.cpp | 3 + 6 files changed, 215 insertions(+), 22 deletions(-) diff --git a/inc/IntArticleReaderForm.h b/inc/IntArticleReaderForm.h index 3f35175..a7f0238 100644 --- a/inc/IntArticleReaderForm.h +++ b/inc/IntArticleReaderForm.h @@ -109,6 +109,7 @@ class ArticleReaderForm void StartWordSearch(void); void RelayoutControls(void); + void FindNextWord(bool next); static const int IDA_MORE_BUTTON; static const int IDA_BACK_BUTTON; @@ -148,7 +149,10 @@ class ArticleReaderForm // Tizen::Base::String __currentSelectedStr; SharePopup* __pPopUp; - + Tizen::Base::String* __pReaderData; + Tizen::Base::String* __pShareUrl; + Tizen::Base::String* __pShareTitle; + bool __randomValue; }; #endif /* _INT_ARTICLE_READER_FORM_H_ */ diff --git a/inc/IntMainForm.h b/inc/IntMainForm.h index 8b41563..8c662ae 100644 --- a/inc/IntMainForm.h +++ b/inc/IntMainForm.h @@ -350,6 +350,7 @@ private: Tizen::Ui::Controls::Button* __pMultiWindowButton; // Tizen::Ui::Controls::Button* __pNewWindowButton; SharePopup* __pPopUp; + Tizen::Ui::Controls::Label* __pCheckLabel; AddressBarMode __prevAddressBarMode; Tizen::Ui::Controls::Button* __pReaderCloseBtn; Tizen::Base::String* __pReaderData; diff --git a/inc/IntMultipleWindowForm.h b/inc/IntMultipleWindowForm.h index 5546b45..220c482 100644 --- a/inc/IntMultipleWindowForm.h +++ b/inc/IntMultipleWindowForm.h @@ -39,6 +39,7 @@ class MultipleWindowForm , public Tizen::Ui::IOrientationEventListener , public Tizen::Ui::Scenes::ISceneEventListener + { public: /** @@ -154,6 +155,7 @@ private: // __pListDeleteImage Pointer to Bitmap contains list delete image Tizen::Graphics::Bitmap* __pListDeleteImage; ConfirmationPopup* __pConfirmationPopup; + Tizen::Graphics::Point __startPosition; }; diff --git a/src/IntArticleReaderForm.cpp b/src/IntArticleReaderForm.cpp index 657d02b..74c1b05 100644 --- a/src/IntArticleReaderForm.cpp +++ b/src/IntArticleReaderForm.cpp @@ -280,8 +280,8 @@ ArticleReaderForm::OnActionPerformed(const Control& source, int actionId) __pPopUp->Initialize(); ShareInfo* pShareInfo = new(std::nothrow) ShareInfo(); - pShareInfo->SetPageTitle(L"Google");//temporary only for testing - pShareInfo->SetPageUrl(L"http://www.google.com");//temporary only for testing + pShareInfo->SetPageTitle(*__pShareTitle); + pShareInfo->SetPageUrl(*__pShareUrl); pShareInfo->SetImageAttached(false); __pPopUp->RemoveAllShareInfo(); __pPopUp->AddShareInfo(pShareInfo); @@ -356,12 +356,12 @@ ArticleReaderForm::OnActionPerformed(const Control& source, int actionId) break; case IDA_COPY_TEXT_CLICKED: { - __pWebReader->ReleaseBlock(); + // Sets data to a clip board item ClipboardItem item; String resourcePath = App::GetInstance()->GetAppResourcePath(); item.Construct(CLIPBOARD_DATA_TYPE_TEXT, __pWebReader->GetTextFromBlock()); - + __pWebReader->ReleaseBlock(); // copying the item to clipboard Clipboard* pClipboard = Clipboard::GetInstance(); if (pClipboard != null) @@ -372,8 +372,10 @@ ArticleReaderForm::OnActionPerformed(const Control& source, int actionId) break; case IDA_FIND_TEXT_CLICKED: { + __randomValue = true; InitFindWordPanel(); - __pWebReader->SetBounds(0,__pFindWordControl->GetHeight(),GetClientAreaBounds().width,GetClientAreaBounds().height - __pFooterPanel->GetHeight() - __pFindWordControl->GetHeight()); + RelayoutControls(); +// __pWebReader->SetBounds(0,__pFindWordControl->GetHeight(),GetClientAreaBounds().width,GetClientAreaBounds().height - __pFooterPanel->GetHeight() - __pFindWordControl->GetHeight()); } break; case IDA_SHARE_TEXT_CLICKED: @@ -402,9 +404,9 @@ ArticleReaderForm::OnActionPerformed(const Control& source, int actionId) case IDA_FINDWORD_CANCEL_CLICKED: { -// __currentSearchStr = L""; -// __currentWordIndex = 0; -// __maxOccurrances = 0; +// currentSearchStr = L""; +// currentWordIndex = 0; +// maxOccurances = 0; __pFindWordEditField->SetText(L""); __pFindWordNext->SetEnabled(false); __pFindWordPrev->SetEnabled(false); @@ -418,19 +420,25 @@ ArticleReaderForm::OnActionPerformed(const Control& source, int actionId) break; case IDA_FINDWORD_CLEAR_CLICKED: { - + __pFindWordCountLabel->SetText(L"0/0"); + __pFindWordEditField->SetText(L""); + __pFindWordPrev->SetEnabled(false); + __pWebReader->SearchText(L"aaaaaabbbbbbccccccc"); + __pFindWordNext->SetEnabled(false); + __pFindWordControl->Invalidate(true); } break; case IDA_FINDWORD_NEXT_CLICKED: { - + FindNextWord(true); } break; case IDA_FINDWORD_PREV_CLICKED: { - + FindNextWord(false); } break; + break; default: break; } @@ -499,6 +507,67 @@ void ArticleReaderForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs) { AppLog("ArticleReaderForm::OnSceneActivatedN entered"); + int index = 0; + __pReaderData = static_cast(pArgs->GetAt(index++)); + __pShareUrl = static_cast(pArgs->GetAt(index++)); + __pShareTitle = static_cast(pArgs->GetAt(index++)); + AppLog("ArticleReaderForm::OnSceneActivatedN __pReaderData %ls",__pReaderData->GetPointer()); + + String loadData = L"\ + \ + \ + \ + \ + "); + AppLogDebug("data->GetLength %d",__pReaderData->GetLength()); + loadData.Append(*__pReaderData); + loadData.Append(L""); + + ByteBuffer buf ; + buf.Construct(loadData.GetLength()); + AppLogDebug("data->GetLength %d",loadData.GetLength()); + for (int z=0;zLoadData(L"",buf,L"text/html"); + AppLogDebug("LoadData result %s",GetErrorMessage(GetLastResult())); + } + else + { + AppLogDebug("cannot LoadData __pWebReader is null"); + } + + } void @@ -629,7 +698,6 @@ ArticleReaderForm::OnOrientationChanged(const Control& source, OrientationStatus void ArticleReaderForm::OnTextValueChanged (const Tizen::Ui::Control &source) { - if (__pFindWordEditField != null) { __pFindWordNext->SetEnabled(false); @@ -648,12 +716,12 @@ ArticleReaderForm::OnTextValueChanged (const Tizen::Ui::Control &source) __pFindWordPrev->SetEnabled(false); __pWebReader->SearchText(L"aaaaaaaabbbbbbbccccccc"); } - + __randomValue = true; // else // { -//// __currentSearchStr = L"aaaaaaaabbbbbbbccccccc"; +//// currentSearchStr = L"aaaaaaaabbbbbbbccccccc"; // StartWordSearch(); -//// __currentSearchStr = L""; +//// currentSearchStr = L""; // AppLogDebug("Enter something"); // } } @@ -715,6 +783,7 @@ ArticleReaderForm::InitFindWordPanel(void) { StartWordSearch(); } + __pFindWordEditField->Invalidate(false); return r; } @@ -835,11 +904,88 @@ ArticleReaderForm::RelayoutControls() if( __pFindWordControl && __pFindWordControl->GetShowState() == true) { __pFindWordControl->SetBounds(0,0, __pFindWordControl->GetWidth(), __pFindWordControl->GetHeight()); - __pWebReader->SetBounds(0,__pFindWordControl->GetHeight(),GetClientAreaBounds().width, GetClientAreaBounds().height - __pFooterPanel->GetHeight() - __pFindWordControl->GetHeight()); + if(__pFooterPanel && __pFooterPanel->GetShowState() == true && __pWebReader) + __pWebReader->SetBounds(0,__pFindWordControl->GetHeight(),GetClientAreaBounds().width, GetClientAreaBounds().height - __pFooterPanel->GetHeight() - __pFindWordControl->GetHeight()); + else if(__pWebReader) + __pWebReader->SetBounds(0,__pFindWordControl->GetHeight(),GetClientAreaBounds().width, GetClientAreaBounds().height - __pFindWordControl->GetHeight()); } else { - if(__pWebReader) + if(__pFooterPanel && __pFooterPanel->GetShowState() == true && __pWebReader) __pWebReader->SetBounds(0,0,GetClientAreaBounds().width, GetClientAreaBounds().height - __pFooterPanel->GetHeight()); + else if(__pWebReader) + __pWebReader->SetBounds(0,0,GetClientAreaBounds().width, GetClientAreaBounds().height); + + } +} + + +void +ArticleReaderForm::FindNextWord(bool next) +{ + String currentSearchStr = __pFindWordEditField->GetText(); + int currentWordIndex = 0; + String curWordIndexStr = L""; + int maxOccurances = 0; + String maxOccurancesStr = L""; + int index = -1; + String countStr = __pFindWordCountLabel->GetText(); + countStr.IndexOf(L"/",0,index); + countStr.SubString(0,index,curWordIndexStr); + countStr.SubString(index+1,maxOccurancesStr); + Integer::Parse(curWordIndexStr,currentWordIndex); + Integer::Parse(maxOccurancesStr,maxOccurances); + if (next == true) + { + if (__pWebReader->SearchText(currentSearchStr, true) == true) + { + if(currentWordIndex < maxOccurances) + { + currentWordIndex++; + } + if(__randomValue == true) + { + __randomValue = false; + __pWebReader->SearchText(currentSearchStr, true); + } + } + } + else + { + if (__pWebReader->SearchText(currentSearchStr, false) == true) + { + if(currentWordIndex > 1) + { + currentWordIndex--; + } + } } + + countStr.Clear(); + countStr.Append(currentWordIndex); + countStr.Append(L"/"); + countStr.Append(maxOccurances); + __pFindWordCountLabel->SetText(countStr); + // __pFindWordCountLabel->SetShowState(true); + __pFindWordCountLabel->Invalidate(false); + if (currentWordIndex >= maxOccurances) + { + __pFindWordNext->SetEnabled(false); + } + else + { + __pFindWordNext->SetEnabled(true); + } + if (currentWordIndex <= 1) + { + __pFindWordPrev->SetEnabled(false); + } + else + { + __pFindWordPrev->SetEnabled(true); + } + __pFindWordPrev->Invalidate(false); + __pFindWordNext->Invalidate(false); + __pFindWordCountLabel->Invalidate(false); + __pFindWordControl->Invalidate(true); } diff --git a/src/IntMainForm.cpp b/src/IntMainForm.cpp index 8412589..fc08487 100644 --- a/src/IntMainForm.cpp +++ b/src/IntMainForm.cpp @@ -71,6 +71,7 @@ static const wchar_t* IDS_TIZEN_SERVICE = L"tizen-service"; static const wchar_t* IDS_APPID = L"AppID"; static const wchar_t* IDB_TITLE_PROGRESS_BAR_BG = L"I01_title_progress_bar_bg.png"; static const wchar_t* IDB_TITLE_PROGRESS_BAR = L"I01_title_progress_bar.png"; +//static const wchar_t* IDB_ADDRESS_BAR_BACKGROUND = L"I01_toolbar_bg_02.9.png"; const int IDA_BACKBTN_CLICKED = 101; const int IDA_BOOKMARKBTN_CLICKED = 102; @@ -2788,7 +2789,8 @@ MainForm::OnLoadingCompleted(void) if (__pReaderData == null) { AppLog("MainScene::data is null Error :%s",GetErrorMessage(GetLastResult())); - return; + __pReaderData = new String(L"

Chinese PM Li Keqiang vows to open up markets to India

Chinese PM Li Keqiang vows to open up markets to India

"); +// return; } AppLogDebug("evaluateJavascript result %s , __pReaderData %ls",GetErrorMessage(GetLastResult()),__pReaderData->GetPointer()); if (__pReaderData->CompareTo(L"undefined") != 0 && __pReaderData->CompareTo(L"") != 0) @@ -3497,7 +3499,7 @@ MainForm::RelayoutControls(bool showAddressbar,bool relayoutFooter) } if (__pWebViewer != null && __pWebViewer->GetShowState() == true) { - __pWebViewer->SetBounds(0, __webControlPosition.y, GetClientAreaBounds().width, __webControlHeight); + __pWebViewer->SetBounds(0, __webControlPosition.y, GetClientAreaBounds().width, __webControlHeight + 12); __pWebViewer->Invalidate(false); } if(__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null) @@ -3685,6 +3687,7 @@ MainForm::FindNextWord(bool next) __pFindWordCountLabel->Invalidate(false); __pFindWordControl->Invalidate(true); } + void MainForm::OnWebKeypadWillOpen(Tizen::Web::Controls::Web& source) { @@ -3951,8 +3954,9 @@ MainForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::Ori __pFooterLabel->SetBackgroundBitmap(*pBitmap); delete pBitmap; } - } + + } if (__pFindWordBgLabel != null) { Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight()); @@ -4608,7 +4612,40 @@ MainForm::UpdateProgressBitmap(void) void MainForm::ReaderClicked() { - SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_ARTICLE_READER, SCENE_TRANSITION_ANIMATION_TYPE_NONE)); + result r = E_SUCCESS; + ArrayList* pArgList = new(std::nothrow) ArrayList(); + if (pArgList != null) + { + r = pArgList->Construct(); + if (IsFailed(r)) + { + delete pArgList; + return; + } + + r = pArgList->Add(*new(std::nothrow) String(*__pReaderData)); + if (IsFailed(r)) + { + delete pArgList; + return; + } + + r = pArgList->Add(*new(std::nothrow) String(__pWebViewer->GetUrl())); + if (IsFailed(r)) + { + delete pArgList; + return; + } + + r = pArgList->Add(*new(std::nothrow) String(__pWindowInfo->pageTitle)); + if (IsFailed(r)) + { + delete pArgList; + return; + } + } + + SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_ARTICLE_READER, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList); return; diff --git a/src/IntMultipleWindowForm.cpp b/src/IntMultipleWindowForm.cpp index 920365c..d27c8d7 100644 --- a/src/IntMultipleWindowForm.cpp +++ b/src/IntMultipleWindowForm.cpp @@ -46,6 +46,8 @@ MultipleWindowForm::MultipleWindowForm(void) , __pListDeleteImage(null) ,__pConfirmationPopup(null) { + __startPosition.x = -1; + __startPosition.y = -1; } MultipleWindowForm::~MultipleWindowForm(void) @@ -121,6 +123,7 @@ MultipleWindowForm::OnInitializing(void) { __pList->SetItemProvider(*this); __pList->AddListViewItemEventListener(*this); + } AddOrientationEventListener(*this); -- 2.7.4