using namespace Tizen::Net::Nfc;
using namespace Tizen::Media;
-const int NfcPushUiForm::_DURATION_GROW_ = 667;
-const int NfcPushUiForm::_DURATION_OPACITY_ = 497;
-const int NfcPushUiForm::_DURATION_REPEAT_ = 516;
-const int NfcPushUiForm::_DURATION_OPACITY2_ = 431;
-
NfcPushUiForm::NfcPushUiForm(void)
: __reqId(-1)
, __pCapturedScreen(null)
, __pNfcManager(null)
, __pVisualElementBounds(null)
, __pVisualElementOpacity(null)
+ , __pVisualElementBackground(null)
+ , __pVisualElementGuideText(null)
+ , __pVisualElementAppInfo(null)
, __pVisualElement(null)
, __startRect()
, __endRect()
GetVisualElement()->AttachChild(*__pVisualElement);
////////////////////////////////////////////////////////////////////////////////
+ // Opacity background
+ ////////////////////////////////////////////////////////////////////////////////
+ Rectangle rect = GetClientAreaBounds();
+ __pVisualElementBackground = new (std::nothrow) VisualElement();
+ __pVisualElementBackground->Construct();
+ __pVisualElementBackground->SetName(L"Background");
+ __pVisualElementBackground->SetBounds(FloatRectangle(0, 0, __rect.width, __rect.height));
+ __pVisualElementBackground->SetShowState(true);
+ __pVisualElementBackground->SetImplicitAnimationEnabled(false);
+ __pVisualElement->AttachChild(*__pVisualElementBackground);
+
+ std::unique_ptr<Canvas> pCanvas(__pVisualElementBackground->GetCanvasN());
+ SysTryReturnResult(NID_NET_NFC, pCanvas != null, E_OUT_OF_MEMORY, "Failed to get canvas.");
+
+ if (__isCaptured == false)
+ {
+ // get canvas from form
+ r = CaptureScreen();
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "Failed to capture screen.");
+ __isCaptured = true;
+ }
+
+ __startOpacity = 0.0f;
+ __endOpacity = 1.0f;
+
+ // draw bitmap
+ pCanvas->SetBackgroundColor(Color(0x00000000));
+ pCanvas->Clear();
+ r = pCanvas->DrawBitmap(rect, *__pCapturedScreen);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "Failed to draw captured screen to canvas.");
+
+ // darkening
+ r = pCanvas->FillRectangle(Color(0xC0000000), rect);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "Failed to darken the captured screen.");
+
+ // set an opacity level
+ __pVisualElementBackground->SetOpacity(__startOpacity);
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // Opacity guide text
+ ////////////////////////////////////////////////////////////////////////////////
+ __pVisualElementGuideText = new (std::nothrow) VisualElement();
+ __pVisualElementGuideText->Construct();
+ __pVisualElementGuideText->SetName(L"GuideText");
+ __pVisualElementGuideText->SetBounds(FloatRectangle(_GUIDE_TEXT_COORDINATES_X_, _GUIDE_TEXT_COORDINATES_Y_,
+ _GUIDE_TEXT_WIDTH_, 100));
+ __pVisualElementGuideText->SetShowState(true);
+ __pVisualElementGuideText->SetImplicitAnimationEnabled(false);
+ __pVisualElement->AttachChild(*__pVisualElementGuideText);
+
+ pCanvas.reset(__pVisualElementGuideText->GetCanvasN());
+ SysTryReturnResult(NID_NET_NFC, pCanvas != null, E_OUT_OF_MEMORY, "Failed to get canvas.");
+
+ // draw guide text
+ pCanvas->SetBackgroundColor(Color(0x00000000));
+ pCanvas->Clear();
+ DrawGuideTextToCanvas(rect, pCanvas.get());
+ // set an opacity level
+ __pVisualElementGuideText->SetOpacity(__startOpacity);
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // Opacity app info
+ ////////////////////////////////////////////////////////////////////////////////
+ __pVisualElementAppInfo = new (std::nothrow) VisualElement();
+ __pVisualElementAppInfo->Construct();
+ __pVisualElementAppInfo->SetName(L"AppInfo");
+ __pVisualElementAppInfo->SetBounds(FloatRectangle(_APPINFO_TEXT_COORDINATES_X_, _APPINFO_TEXT_COORDINATES_Y_,
+ _APPINFO_TEXT_WIDTH_, 100));
+ __pVisualElementAppInfo->SetShowState(true);
+ __pVisualElementAppInfo->SetImplicitAnimationEnabled(false);
+ __pVisualElement->AttachChild(*__pVisualElementAppInfo);
+
+ pCanvas.reset(__pVisualElementAppInfo->GetCanvasN());
+ SysTryReturnResult(NID_NET_NFC, pCanvas != null, E_OUT_OF_MEMORY, "Failed to get canvas.");
+
+ // draw app info
+ pCanvas->SetBackgroundColor(Color(0x00000000));
+ pCanvas->Clear();
+ DrawAppInfoToCanvas(rect, pCanvas.get());
+ // set an opacity level
+ __pVisualElementAppInfo->SetOpacity(__startOpacity);
+
+ ////////////////////////////////////////////////////////////////////////////////
// bounds
////////////////////////////////////////////////////////////////////////////////
__pVisualElementBounds = new (std::nothrow) VisualElement();
__pVisualElementBounds->Construct();
__pVisualElementBounds->SetName(L"Grow");
- __pVisualElementBounds->SetBounds(FloatRectangle((__rect.width / 2.0f) - 121.0f, __rect.height - 794.0f, 242.0f, 242.0f));
+ __pVisualElementBounds->SetBounds(FloatRectangle(_CIRCLE_COORDINATES_X_, _CIRCLE_COORDINATES_Y_, _CIRCLE_WIDTH_, _CIRCLE_HEIGHT_));
__pVisualElementBounds->SetShowState(true);
__pVisualElementBounds->SetImplicitAnimationEnabled(false);
__pVisualElement->AttachChild(*__pVisualElementBounds);
__endRect = __pVisualElementBounds->GetBounds();
- __startRect = FloatRectangle(__endRect.x + 121.0f, __endRect.y + 121.0f, 0, 0);
+ __startRect = FloatRectangle(__endRect.x + (_CIRCLE_WIDTH_ / 2), __endRect.y + (_CIRCLE_HEIGHT_ / 2), 0, 0);
- std::unique_ptr<Canvas> pCanvas(__pVisualElementBounds->GetCanvasN());
+ pCanvas.reset(__pVisualElementBounds->GetCanvasN());
SysTryReturnResult(NID_NET_NFC, pCanvas != null, E_OUT_OF_MEMORY, "Failed to get canvas.");
std::unique_ptr<Bitmap> pBitmap;
SysTryReturnResult(NID_NET_NFC, pBitmap != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
// scale the bitmap
- r = pBitmap->Scale(Dimension(242, 242));
+ r = pBitmap->Scale(Dimension(_CIRCLE_WIDTH_, _CIRCLE_HEIGHT_));
SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "Failed to scale the bitmap.");
// draw the bitmap
__pVisualElementOpacity = new (std::nothrow) VisualElement();
__pVisualElementOpacity->Construct();
__pVisualElementOpacity->SetName(L"Opacity");
- __pVisualElementOpacity->SetBounds(FloatRectangle((__rect.width / 2) - 53, __rect.height - 726, 106, 106));
+ __pVisualElementOpacity->SetBounds(FloatRectangle(_ICON_COORDINATES_X_, _ICON_COORDINATES_Y_, _ICON_WIDTH_, _ICON_HEIGHT_));
__pVisualElementOpacity->SetShowState(true);
__pVisualElementOpacity->SetImplicitAnimationEnabled(false);
__pVisualElement->AttachChild(*__pVisualElementOpacity);
SysTryReturnResult(NID_NET_NFC, pBitmap != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
// scale the bitmap
- r = pBitmap->Scale(Dimension(106, 106));
+ r = pBitmap->Scale(Dimension(_ICON_WIDTH_, _ICON_HEIGHT_));
SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "Failed to scale the bitmap.");
- __startOpacity = 0.0f;
- __endOpacity = 1.0f;
-
// draw the bitmap
pCanvas->SetBackgroundColor(Color(0x00000000));
pCanvas->Clear();
SysLog(NID_NET_NFC, "start to play animation");
AnimationTransaction::Begin();
+ PlayOpacityAnimation(L"background_appear", _DURATION_OPACITY_BACKGROUND_);
+ PlayOpacityAnimation(L"guidetext_appear", _DURATION_OPACITY_BACKGROUND_);
+ PlayOpacityAnimation(L"appinfo_appear", _DURATION_OPACITY_BACKGROUND_);
PlayBoundsAnimation(L"grow", 1, _DURATION_GROW_);
- PlayOpacityAnimation(L"opacity", _DURATION_OPACITY_);
+ PlayOpacityAnimation(L"icon_appear", _DURATION_OPACITY_ICON_APPEAR_);
AnimationTransaction::Commit();
return r;
r = DrawBitmapToCanvas(rect);
SysTryCatch(NID_NET_NFC, r == E_SUCCESS, , r, "[%s] Failed to draw captured screen.", GetErrorMessage(r));
- // guide text
- r = DrawGuideTextToCanvas(rect);
- SysTryCatch(NID_NET_NFC, r == E_SUCCESS, , r, "[%s] Failed to draw guide text.", GetErrorMessage(r));
-
- // app info
- r = DrawAppInfoToCanvas(rect);
- SysTryCatch(NID_NET_NFC, r == E_SUCCESS, , r, "[%s] Failed to draw app info.", GetErrorMessage(r));
-
return r;
CATCH:
SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r,
"[%s] exception occurred. Failed to draw captured screen to canvas.", GetErrorMessage(r));
- // darkening
- r = pCanvas->FillRectangle(Color(0xC0000000), rect);
- SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r,
- "[%s] exception occurred. Failed to darken the captured screen.", GetErrorMessage(r));
-
return r;
}
result
-NfcPushUiForm::DrawAppInfoToCanvas(const Tizen::Graphics::Rectangle& rect)
+NfcPushUiForm::DrawAppInfoToCanvas(const Tizen::Graphics::Rectangle& rect, Tizen::Graphics::Canvas* pCanvas)
{
result r = E_SUCCESS;
const int textAreaWidth = rect.width;
pTextElement->SetTextColor(Color::GetColor(COLOR_ID_WHITE));
{
Font font;
- font.Construct(FONT_STYLE_BOLD, 42);
+ font.Construct(FONT_STYLE_PLAIN, _APPINFO_TEXT_HEIGHT_);
pTextElement->SetFont(font);
}
// Adds the TextElement and the bitmap to the EnrichedText
pEnrichedText->Add(*pTextElement);
- // canvas
- std::unique_ptr<Canvas> pCanvas(GetCanvasN());
- SysTryReturnResult(NID_NET_NFC, pCanvas != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
-
// Draws the EnrichedText at the specified Point
- pCanvas->DrawText(Point(0, rect.height - 510), *pEnrichedText);
+ pCanvas->DrawText(Point(__rect.x, __rect.y), *pEnrichedText);
return r;
}
result
-NfcPushUiForm::DrawGuideTextToCanvas(const Tizen::Graphics::Rectangle& rect)
+NfcPushUiForm::DrawGuideTextToCanvas(const Tizen::Graphics::Rectangle& rect, Tizen::Graphics::Canvas* pCanvas)
{
result r = E_SUCCESS;
const int textAreaWidth = rect.width;
pTextElement->SetTextColor(Color::GetColor(COLOR_ID_WHITE));
{
Font font;
- font.Construct(FONT_STYLE_BOLD, 42);
+ font.Construct(FONT_STYLE_PLAIN, _GUIDE_TEXT_HEIGHT_);
pTextElement->SetFont(font);
}
r = pEnrichedText->Add(*pTextElement);
SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "Failed to add text element to enriched text.");
- // canvas
- std::unique_ptr<Canvas> pCanvas(GetCanvasN());
- SysTryReturnResult(NID_NET_NFC, pCanvas != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
-
// Draws the EnrichedText at the specified Point
- r = pCanvas->DrawText(Point((rect.width - textAreaWidth) / 2, rect.height -1030), *pEnrichedText);
+ r = pCanvas->DrawText(Point(__rect.x, __rect.y), *pEnrichedText);
SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "Failed to draw text to canvas.");
return r;
pAnimation->SetRepeatCount(repeatCount);
pAnimation->SetAutoReverseEnabled(autoReverse);
pAnimation->SetVisualElementAnimationStatusEventListener(this);
- if (animationName == L"grow" || animationName == L"shrink")
+ if (animationName == L"grow")
{
pTimingFunction.reset(new (std::nothrow) EaseInOutTimingFunction());
+ pAnimation->SetDelay(_DELAY_GROW_);
pAnimation->SetTimingFunction(pTimingFunction.release());
+ __pVisualElementBounds->AddAnimation(animationName, *pAnimation);
+ }
+ else if (animationName == L"shrink")
+ {
+ pTimingFunction.reset(new (std::nothrow) EaseInOutTimingFunction());
+ pAnimation->SetTimingFunction(pTimingFunction.release());
+ __pVisualElementBounds->AddAnimation(animationName, *pAnimation);
+ }
+ else
+ {
+ __pVisualElementBounds->AddAnimation(animationName, *pAnimation);
}
-
- __pVisualElementBounds->AddAnimation(animationName, *pAnimation);
}
void
pAnimation->SetEndValue(Variant(__endOpacity));
pAnimation->SetDuration(duration);
pAnimation->SetVisualElementAnimationStatusEventListener(this);
- if (animationName == L"opacity")
+ if (animationName == L"background_appear")
+ {
+ __pVisualElementBackground->AddAnimation(animationName, *pAnimation);
+ }
+ else if (animationName == L"background_disappear")
+ {
+ pAnimation->SetDelay(_DELAY_BACKGROUND_DISAPPEAR_);
+ __pVisualElementBackground->AddAnimation(animationName, *pAnimation);
+ }
+ else if (animationName == L"guidetext_appear")
+ {
+ __pVisualElementGuideText->AddAnimation(animationName, *pAnimation);
+ }
+ else if (animationName == L"guidetext_disappear")
{
- pAnimation->SetDelay(247);
+ pAnimation->SetDelay(_DELAY_GUIDE_TEXT_DISAPPEAR_);
+ __pVisualElementGuideText->AddAnimation(animationName, *pAnimation);
+ }
+ else if (animationName == L"appinfo_appear")
+ {
+ __pVisualElementAppInfo->AddAnimation(animationName, *pAnimation);
+ }
+ else if (animationName == L"appinfo_disappear")
+ {
+ pAnimation->SetDelay(_DELAY_APPINFO_TEXT_DISAPPEAR_);
+ __pVisualElementAppInfo->AddAnimation(animationName, *pAnimation);
+ }
+ else if (animationName == L"icon_appear")
+ {
+ pAnimation->SetDelay(_DELAY_OPACITY_ICON_APPEAR_);
+ __pVisualElementOpacity->AddAnimation(animationName, *pAnimation);
+ }
+ else if (animationName == L"icon_disappear")
+ {
+ __pVisualElementOpacity->AddAnimation(animationName, *pAnimation);
}
- __pVisualElementOpacity->AddAnimation(animationName, *pAnimation);
}
void
{
if(completedNormally)
{
- if (keyName == L"opacity")
+ if (keyName == L"icon_appear")
{
float margin = (__endRect.width * 0.05f) / 2;
__startRect = __endRect;
// start second animation - repeat
PlayBoundsAnimation(L"repeat", 0, _DURATION_REPEAT_, true);
}
- else if (keyName == L"shrink")
+ else if (keyName == L"background_disappear")
{
// finish this app control with success
result r = E_SUCCESS;
- // remove the guide text and app description
- r = DrawBitmapToCanvas(rect);
- SysTryReturnVoidResult(NID_NET_NFC, r == E_SUCCESS, r, "[%s] Failed to remove guide text and app description.", GetErrorMessage(r));
-
FinishAppControl(__reqId, APP_CTRL_RESULT_SUCCEEDED);
}
}
// reset the circles size
__startRect = __endRect;
- __endRect = FloatRectangle(__startRect.x + 127.05f, __startRect.y + 127.05f, 0, 0);
+ __endRect = FloatRectangle(_CIRCLE_COORDINATES_X_ + (_CIRCLE_WIDTH_ / 2), _CIRCLE_COORDINATES_Y_ + (_CIRCLE_HEIGHT_ / 2), 0, 0);
// play animation
AnimationTransaction::Begin();
- PlayOpacityAnimation(L"opacity2", _DURATION_OPACITY2_);
- PlayBoundsAnimation(L"shrink", 1, 667, false);
+ PlayOpacityAnimation(L"icon_disappear", _DURATION_OPACITY_ICON_DISAPPEAR_);
+ PlayBoundsAnimation(L"shrink", 1, _DURATION_GROW_, false);
+ PlayOpacityAnimation(L"background_disappear", _DURATION_OPACITY_BACKGROUND_);
+ PlayOpacityAnimation(L"guidetext_disappear", _DURATION_OPACITY_BACKGROUND_);
+ PlayOpacityAnimation(L"appinfo_disappear", _DURATION_OPACITY_BACKGROUND_);
AnimationTransaction::Commit();
}