X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2FIntSharePopup.cpp;h=fa5844d3ee914717ce724ab798b337afb3f60a69;hb=c17908e6da1de70b54e4b83f5e6b0d7b57071f89;hp=e530bf9f180a0e25adc04e28d58af61e3aeec907;hpb=d4ce02d269060420a6ab388143a3dec32862345a;p=apps%2Fosp%2FInternet.git diff --git a/src/IntSharePopup.cpp b/src/IntSharePopup.cpp index e530bf9..fa5844d 100644 --- a/src/IntSharePopup.cpp +++ b/src/IntSharePopup.cpp @@ -33,11 +33,13 @@ using namespace Tizen::App; using namespace Tizen::Io; using namespace Tizen::Base; using namespace Tizen::Base::Collection; +using namespace Tizen::Base::Runtime; using namespace Tizen::Graphics; using namespace Tizen::Ui; using namespace Tizen::Ui::Controls; using namespace Tizen::Ui::Scenes; + const int SharePopup::IDA_CANCEL_BUTTON = 101; const int SharePopup::ID_FORMAT_MESSAGE_STRING = 500; const int SharePopup::ID_FORMAT_EMAIL_STRING = 501; @@ -51,7 +53,6 @@ ShareInfo:: ShareInfo(void) ShareInfo:: ~ShareInfo(void) { - } void @@ -108,12 +109,45 @@ ShareInfo::GetImagePath(void) SharePopup::SharePopup(void) :__pList(null),__pShareList(null) { - + __appControlOngoing = false; + __pTimer = null; } SharePopup::~SharePopup(void) { + ShareInfo* pShareInfo = null; + result r = E_FAILURE; + + if (__pShareList != null) + { + pShareInfo = dynamic_cast(__pShareList->GetAt(0)); + } + + String attachVal; + bool imageAttachment = false; + if (pShareInfo != null) + { + imageAttachment = pShareInfo->GetImageAttached(); + if (imageAttachment) + { + attachVal = pShareInfo->GetImagePath(); + AppLog("SharePopup:: imagePath is %S",attachVal.GetPointer()); + r = File::Remove(attachVal); + if(r == E_SUCCESS) + { + AppLog("removed success"); + } + else + { + AppLog("removed failure"); + } + } + __pShareList->RemoveAll(true); + } + if(__pAppControlList) + __pAppControlList->RemoveAll(true); + delete __pAppControlList; } bool @@ -135,6 +169,7 @@ SharePopup::Initialize(void) __pList->SetItemProvider(*this); __pList->AddListViewItemEventListener(*this); +// __pList->SetTextOfEmptyList(L"No Sharing Options");//hardcoded string pCancelButton = static_cast< Button* >(GetControl(L"IDC_BUTTON1", true)); if (pCancelButton) @@ -143,6 +178,9 @@ SharePopup::Initialize(void) pCancelButton->SetActionId(IDA_CANCEL_BUTTON); } + __pTimer = new(std::nothrow) Timer(); + __pTimer->Construct(*this); + SetPropagatedKeyEventListener(this); return true; } @@ -154,6 +192,13 @@ SharePopup::OnTerminating(void) } void +SharePopup::OnTimerExpired(Timer& timer) +{ + Popup::SetShowState(false); + Popup::Show(); +} + +void SharePopup::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) { switch(actionId) @@ -183,25 +228,59 @@ SharePopup::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, { case 0: { - - // share via message - StartMessageAppControl(); - Popup::SetShowState(false); - Popup::Show(); + if(__appControlOngoing == false) + { + __appControlOngoing = true; + // share via message + StartMessageAppControl(); + if(__pTimer == null) + { + __pTimer = new(std::nothrow) Timer(); + __pTimer->Construct(*this); + } + __pTimer->Start(2500); + } } break; case 1: { + if(__appControlOngoing == false) + { + __appControlOngoing = true; + // share via email + StartEmailAppControl(); + if(__pTimer == null) + { + __pTimer = new(std::nothrow) Timer(); + __pTimer->Construct(*this); + } + __pTimer->Start(2500); + } - // share via email - StartEmailAppControl(); - Popup::SetShowState(false); - Popup::Show(); } break; default: + if(__appControlOngoing == false) + { + __appControlOngoing = true; + //share via third party app + StartAppControl(index); + if(__pTimer == null) + { + __pTimer = new(std::nothrow) Timer(); + __pTimer->Construct(*this); + } + __pTimer->Start(2500); + } break; } + Frame* pCurrentFrame = null; + pCurrentFrame = Application::GetInstance()->GetAppFrame()->GetFrame(); + + if (pCurrentFrame != null) + { + pCurrentFrame->SetEnabled(false); + } } void @@ -219,14 +298,15 @@ SharePopup::OnListViewItemLongPressed(Tizen::Ui::Controls::ListView& listView, i Tizen::Ui::Controls::ListItemBase* SharePopup::CreateItem(int index, int itemWidth) { + AppLog("SharePopup::CreateItem index %d",index); result r = E_FAILURE; ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL; int textSize = 35; int elementHeight = 50; - int listItemWidth = 80; + int listItemHeight = 75; CustomItem* pItem = new(std::nothrow) CustomItem(); - r = pItem->Construct(Dimension(GetClientAreaBounds().width, listItemWidth), style); + r = pItem->Construct(Dimension(GetClientAreaBounds().width, listItemHeight), style); if (IsFailed(r)) { AppLogDebug("Create Item Failed with error %s", GetErrorMessage(r)); @@ -234,23 +314,32 @@ SharePopup::CreateItem(int index, int itemWidth) return null; } + + switch(index) { case 0: { AppLogDebug("SharePopUp CreateItem 0"); // IDS_SHARE_VIA_MESSAGE - pItem->AddElement(Rectangle(45,0, GetClientAreaBounds().width, listItemWidth), ID_FORMAT_MESSAGE_STRING, CommonUtil::GetString(L"IDS_BR_OPT_SHARE_VIA_MESSAGES"), true); + pItem->AddElement(Rectangle(45,0, GetClientAreaBounds().width, listItemHeight), ID_FORMAT_MESSAGE_STRING, CommonUtil::GetString(L"IDS_BR_OPT_MESSAGES"), true); } break; case 1: { AppLogDebug("SharePopUp CreateItem 1"); // IDS_SHARE_VIA_EMAIL - pItem->AddElement(Rectangle(45, 0, GetClientAreaBounds().width, listItemWidth), ID_FORMAT_EMAIL_STRING, CommonUtil::GetString(L"IDS_BR_OPT_SHARE_VIA_EMAIL"), true); + pItem->AddElement(Rectangle(45, 0, GetClientAreaBounds().width, listItemHeight), ID_FORMAT_EMAIL_STRING, CommonUtil::GetString(L"IDS_BR_OPT_SENDURLVIA_EMAIL"), true); } break; default: + if(__pAppControlList) + { + AppControl * pControl = dynamic_cast(__pAppControlList->GetAt(index -2)); + AppLog("SharePopup::CreateItem appcontrol count %d",__pAppControlList->GetCount()); + if(pControl) + pItem->AddElement(Rectangle(45,0, GetClientAreaBounds().width, listItemHeight), ID_FORMAT_MESSAGE_STRING+index, pControl->GetAppName(), true); + } break; } return pItem; @@ -265,7 +354,30 @@ SharePopup::DeleteItem(int index, Tizen::Ui::Controls::ListItemBase* pItem, int int SharePopup::GetItemCount(void) { - return 2; + String* pStrId = new String(L"http://tizen.org/appcontrol/operation/share_text"); + __pAppControlList = AppManager::FindAppControlsN(pStrId,null,null,null); + if(__pAppControlList == null) + { + return 2; + } + int count = __pAppControlList->GetCount(); + AppLog("SharePopup::GetItemCount appcontrol count %d",count); + int removeCount = 0; + for(int pos = 0; pos < count; pos++) + { + AppControl * pControl = dynamic_cast(__pAppControlList->GetAt(pos)); + if(pControl->GetAppName().Equals(L"Messages",false) == true || pControl->GetAppName().Equals(L"Email",false) == true ) + { + __pAppControlList->RemoveAt(pos,true); + pos--; + count --; + removeCount++; + } + } + + AppLog("removeCount %d",removeCount); + return count+removeCount; + } result @@ -285,6 +397,83 @@ void SharePopup::RemoveAllShareInfo() __pShareList->RemoveAll(); } + + + +void +SharePopup::StartAppControl(int index) +{ + HashMap extraData; + ShareInfo* pShareInfo = null; + result r = E_FAILURE; + bool imageAttachment = false; + + extraData.Construct(); + + if (__pShareList != null) + { + pShareInfo = dynamic_cast(__pShareList->GetAt(0)); + if (pShareInfo != null) + { + String testURL = pShareInfo->GetPageURL(); + AppLogDebug("getpageURL getpageURL is %ls", testURL.GetPointer()); + } + } + + String textVal; + + if (pShareInfo != null) + { + textVal.Append(pShareInfo->GetPageTitle()); + textVal.Append(L" <"); + AppLog("share info url is %ls",pShareInfo->GetPageURL().GetPointer()); + textVal.Append(pShareInfo->GetPageURL().GetPointer()); + textVal.Append(L">"); + } + + + String textKey = L"http://tizen.org/appcontrol/data/text"; + + //String attachKey = L"attachments"; + String attachKey = L"http://tizen.org/appcontrol/data/path"; + String attachVal; + if (pShareInfo != null) + { + imageAttachment = pShareInfo->GetImageAttached(); + if (imageAttachment) + { + attachVal = pShareInfo->GetImagePath(); + AppLog("SharePopup::StartEmailAppControl imagePath is %S",attachVal.GetPointer()); + } + else + { + attachVal = L""; + } + } + + ArrayList* pDataList = null; + pDataList = new (std::nothrow) ArrayList(); + pDataList->Construct(); + pDataList->Add(&attachVal); + + + extraData.Add(&textKey, &textVal); + + if(attachVal.GetLength() > 0) + { + extraData.Add(&attachKey, pDataList); + } + + AppControl * pControl = dynamic_cast(__pAppControlList->GetAt(index - 2)); + if (pControl) + { + r = pControl->Start(null, null, &extraData, this); +// delete pControl; + } + + delete pDataList; +} + void SharePopup::StartEmailAppControl(void) { @@ -326,6 +515,9 @@ SharePopup::StartEmailAppControl(void) String ccVal = L""; String bccKey = L"http://tizen.org/appcontrol/data/bcc"; String bccVal = L""; + String resultKey = L"http://tizen.org/appcontrol/data/return_result"; + String resultVal = "true"; + //String attachKey = L"attachments"; String attachKey = L"http://tizen.org/appcontrol/data/path"; @@ -354,6 +546,7 @@ SharePopup::StartEmailAppControl(void) extraData.Add(&toKey, &toVal); extraData.Add(&ccKey, &ccVal); extraData.Add(&bccKey, &bccVal); + extraData.Add(&resultKey, &resultVal); if(attachVal.GetLength() > 0) { extraData.Add(&attachKey, pDataList); @@ -366,12 +559,7 @@ SharePopup::StartEmailAppControl(void) delete pAc; } - if (pShareInfo != null) - { - delete pShareInfo; - } delete pDataList; - } void @@ -390,6 +578,8 @@ SharePopup::StartMessageAppControl(void) String textVal; String attachKey = L"http://tizen.org/appcontrol/data/path"; String attachVal; + String resultKey = L"http://tizen.org/appcontrol/data/return_result"; + String resultVal = "true"; ArrayList* pDataList = null; if (__pShareList != null) @@ -449,7 +639,7 @@ SharePopup::StartMessageAppControl(void) // type is SMS , attach the text extraData.Add(&textKey, &textVal); } - + extraData.Add(&resultKey, &resultVal); AppControl* pAc = AppManager::FindAppControlN(L"tizen.messages", L"http://tizen.org/appcontrol/operation/compose"); if (pAc) { @@ -457,10 +647,6 @@ SharePopup::StartMessageAppControl(void) delete pAc; } - if (pShareInfo != null) - { - delete pShareInfo; - } if(pDataList) { delete pDataList; @@ -471,26 +657,75 @@ void SharePopup::OnAppControlCompleted(const Tizen::Base::String& providerId, const Tizen::Base::String& operationId, const Tizen::Base::Collection::IList* pResultList) { AppLog("InternetApp::OnForeground called"); - Frame* pCurrentFrame = null; - pCurrentFrame = Application::GetInstance()->GetAppFrame()->GetFrame(); - if (pCurrentFrame != null) - { - pCurrentFrame->SetEnabled(true); - pCurrentFrame->Invalidate(true); - } } void SharePopup::OnAppControlCompleteResponseReceived(const Tizen::App::AppId& appId, const Tizen::Base::String& operationId, Tizen::App::AppCtrlResult appControlResult, const Tizen::Base::Collection::IMap* pExtraData) { AppLog("SharePopup::OnAppControlCompleteResponseReceived"); + + ShareInfo* pShareInfo = null; + result r = E_FAILURE; + if(__pTimer) + { + __pTimer->Cancel(); + delete __pTimer; + __pTimer = null; + } + if (__pShareList != null) + { + pShareInfo = dynamic_cast(__pShareList->GetAt(0)); + } + + String attachVal; + bool imageAttachment = false; + if (pShareInfo != null) + { + imageAttachment = pShareInfo->GetImageAttached(); + if (imageAttachment) + { + attachVal = pShareInfo->GetImagePath(); + AppLog("SharePopup:: imagePath is %S",attachVal.GetPointer()); + r = File::Remove(attachVal); + if(r == E_SUCCESS) + { + AppLog("removed success"); + } + else + { + AppLog("removed failure"); + } + } + __pShareList->RemoveAll(true); + } + Popup::SetShowState(false); + Popup::Show(); Frame* pCurrentFrame = null; - pCurrentFrame = Application::GetInstance()->GetAppFrame()->GetFrame(); + pCurrentFrame = Application::GetInstance()->GetAppFrame()->GetFrame(); if (pCurrentFrame != null) { pCurrentFrame->SetEnabled(true); - pCurrentFrame->Invalidate(true); } + __appControlOngoing = false; +} +bool +SharePopup::OnKeyReleased (Control &source, const KeyEventInfo &keyEventInfo) +{ + AppLog("ConfirmationPopup::OnKeyReleased %d",keyEventInfo.GetKeyCode()); + if(keyEventInfo.GetKeyCode() == KEY_BACK || keyEventInfo.GetKeyCode() == KEY_ESC) + { + if(GetShowState() == true) + { + if(__pTimer) + { + __pTimer->Cancel(); + delete __pTimer; + __pTimer = null; + } + SetShowState(false); + } + } + return false; }