],
"debug.onTaskErrors": "debugAnyway",
"files.associations": {
- "pinctrl_porting.h": "c"
+ "pinctrl_porting.h": "c",
+ "complex": "cpp",
+ "*.inc": "cpp"
}
}
\ No newline at end of file
// Add to rootView
container_->Add(image1_);
- //image1_->SetVisible(true);
+ // image1_->SetVisible(true);
InitDateTime();
// Add to rootView
container_->Add(label2_);
- //label2_->SetVisible(true);
+ // label2_->SetVisible(true);
SetCoverable(true);
}
viewiInitStatus = true;
}
}
-
+
void DialUserView::InitDateTime(void)
{
// Add Label to App
// Add to rootView
container_->Add(label1_);
- //label1_->SetVisible(true);
+ // label1_->SetVisible(true);
}
}
\ No newline at end of file
class PhoneCallPresenter : public Presenter<PhoneCallView>,
public UIView::OnClickListener,
public UIView::OnDragListener
+
{
public:
PhoneCallPresenter();
void OnTearDownView() override;
void OnStop() override;
void Invalidate();
+ void ReLabel();
void Init();
void DeInit();
class PhoneCallupPresenter : public Presenter<PhoneCallupView>,
public UIView::OnClickListener,
- public UIView::OnDragListener
+ public UIView::OnDragListener,
+ public UIView::OnLongPressListener
{
public:
PhoneCallupPresenter();
// 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承;
bool OnClick(UIView &view, const ClickEvent &event) override;
bool OnDrag(UIView &view, const DragEvent &event) override;
+ bool OnLongPress(UIView &view, const LongPressEvent &event);
};
} // namespace OHOS
UIImageView *image1_ = nullptr;
UIToggleButton *toggleButton2_ = nullptr;
UIButton *button1_ = nullptr;
+ UIButton *button2_ = nullptr;
PhoneAnimatorCallback *callBack_ = nullptr;
Animator *animator_ = nullptr;
};
bool PhoneCallPresenter::OnDrag(UIView &view, const DragEvent &event)
{
-
- if (event.GetDragDirection() == DragEvent::DIRECTION_RIGHT_TO_LEFT)
+ if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT &&
+ (event.GetDeltaX() > 20) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY()))))
{
- printf("draglistene is ok!\n");
NativeAbility::GetInstance().ChangeSlice(VIEW_PHONE);
}
- if (event.GetDragDirection() == DragEvent::DIRECTION_BOTTOM_TO_TOP)
+ if ((event.GetDragDirection() == DragEvent::DIRECTION_BOTTOM_TO_TOP) &&
+ (event.GetStartPoint().y > 300))
{
NativeAbility::GetInstance().ChangeSlice(VIEW_PHONECALLING);
}
printf("**************************\n");
printf("per phoneNumber: %s\n", phoneNumber.c_str());
-
- PhoneCallView::GetInstance()->Init();
+ PhoneCallView::GetInstance()->ReLabel();
- //view.Invalidate();
- // RootView::GetInstance()->Invalidate();
+ // view.Invalidate();
+ // RootView::GetInstance()->Invalidate();
printf("now phoneNumber: %s\n", phoneNumber.c_str());
printf("**************************\n");
label_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
label_->SetRollSpeed(0);
label_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40);
-
+
// Add to rootView
container_->Add(label_);
label_->SetVisible(true);
initButton(params);
}
}
+ void PhoneCallView::ReLabel()
+ {
+ label_->SetText(PhoneCallPresenter::GetInstance()->phoneNumber.c_str());
+ }
void PhoneCallView::DeInit()
{
printf("DeInit is ok !\n");
if (container_ != nullptr)
{
container_->RemoveAll();
- delete container_;
- container_ = nullptr;
}
if (button1_ != nullptr)
{
delete buttondel_;
buttondel_ = nullptr;
}
+ delete container_;
+ container_ = nullptr;
}
UIView *PhoneCallView::GetView()
{
{
NativeAbility::GetInstance().ChangeSlice(VIEW_PHONE);
}
+ if (strcmp(view.GetViewId(), "button2") == 0)
+ {
+ NativeAbility::GetInstance().ChangeSlice(VIEW_SYSTEM_VOLUME);
+ }
+
+ return true;
+ }
+ bool PhoneCallupPresenter::OnLongPress(UIView &view, const LongPressEvent &event)
+ {
+ // 1.长按button1
+ // 2.退出 button1NativeAbility::GetInstance().ChangeSlice(VIEW_SAVEELE);
+ // 3.返回 true 以消耗点击事件
+ if (strcmp(view.GetViewId(), "toggleButton2") == 0)
+ {
+ NativeAbility::GetInstance().ChangeSlice(VIEW_SYSTEM_VOLUME);
+ }
return true;
}
}
\ No newline at end of file
container_->Add(image1_);
image1_->SetVisible(true);
- // Add ToggleButton to App
- if (toggleButton2_ == nullptr)
+ // Add Button to App
+ if (button2_ == nullptr)
{
- toggleButton2_ = new UIToggleButton();
+ button2_ = new UIButton();
}
- toggleButton2_->SetPosition(369, 207); // widget's left position and top position
- toggleButton2_->Resize(52, 52); // widget's width and height
- toggleButton2_->SetViewId("toggleButton2"); // Set style
- toggleButton2_->SetStyle(STYLE_BACKGROUND_OPA, 0x00);
+ button2_->SetPosition(369, 207); // widget's left position and top position
+ button2_->Resize(52, 52); // widget's width and height
+ button2_->SetViewId("button2"); // Set style
+ button2_->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff);
+ button2_->SetStyle(STYLE_BACKGROUND_OPA, 0x00);
// Set additional property
#ifdef _WIN32
- char *toggleButton2selectedImg = "c:/Users/caiking/project/image_converter_tool/output/Phone/voice.bin";
-#else
- char *toggleButton2selectedImg = "/user/res/Phone/voice.bin";
-#endif
-#ifdef _WIN32
- char *toggleButton2unSelectedImg = "c:/Users/caiking/project/image_converter_tool/output/Phone/voice-no.bin";
+ char *button2defaultImgSrc = "c:/Users/caiking/project/image_converter_tool/output/Phone/voice.bin";
#else
- char *toggleButton2unSelectedImg = "/user/res/Phone/voice-no.bin";
+ char *button2defaultImgSrc = "/user/res/Phone/voice.bin";
#endif
- toggleButton2_->SetImages(toggleButton2selectedImg, toggleButton2unSelectedImg);
+ char *button2triggeredImgSrc = nullptr;
+ button2_->SetImageSrc(button2defaultImgSrc, button2triggeredImgSrc);
+ button2_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff000000, UIButton::PRESSED);
+ button2_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);
+ // Add the CallBack about events
+ UIView::OnClickListener *button2Click = static_cast<UIView::OnClickListener *>(PhoneCallupPresenter::GetInstance());
+ button2_->SetOnClickListener(button2Click);
// Add to rootView
- container_->Add(toggleButton2_);
- toggleButton2_->SetVisible(true);
+ container_->Add(button2_);
+ button2_->SetVisible(true);
// Add Button to App
if (button1_ == nullptr)
bool PhoneDirPresenter::OnDrag(UIView &view, const DragEvent &event)
{
- if (event.GetDragDirection() == DragEvent::DIRECTION_RIGHT_TO_LEFT)
+ if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT &&
+ (event.GetDeltaX() > 20) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY()))))
{
- printf("draglistene is ok!\n");
NativeAbility::GetInstance().ChangeSlice(VIEW_PHONE);
}
- UNUSED(view);
- return true;
+ UNUSED(view);
+ return true;
}
bool PhoneDirPresenter::OnClick(UIView &view, const ClickEvent &event)
bool PhonePresenter::OnDrag(UIView &view, const DragEvent &event)
{
- if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT)
+ if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT &&
+ (event.GetDeltaX() > 20) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY()))))
{
NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST);
}
// {
// NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST);
// }
- UNUSED(view);
- return true;
+ UNUSED(view);
+ return true;
}
bool SaveElePresenter::OnClick(UIView &view, const ClickEvent &event)
// if (strcmp(view.GetViewId(), 控件ID) == 0)
if (strcmp(view.GetViewId(), "button1") == 0)
{
- NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN_SAMPLE);
+ // NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN_SAMPLE);
+ uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId();
+ NativeAbility::GetInstance().ChangeSlice(preSlice);
}
if (strcmp(view.GetViewId(), "button2") == 0)
{
uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId();
NativeAbility::GetInstance().ChangeSlice(preSlice);
}
- // if(strcmp(view.GetViewId(), BRIGHTNESS_CONTROL_SLIDER))
- // {
-
- // }
return true;
}
#define WEARABLE_LOG_H
#ifdef __cplusplus
#if __cplusplus
-extern "C" {
+extern "C"
+{
#endif
#endif
#include "debug_print.h"
#endif
-/**
- * @brief Enumerates logging module types.
- *
- * The module type must be globally unique. A maximum of 64 module types can be defined.
- *
- * @since 1.0
- * @version 1.0
- */
-typedef enum {
- /** applications */
- WEARABLE_LOG_MODULE_APP = 0,
- /** Launcher Framework */
- WEARABLE_LOG_MODULE_LAUNCHER_FWK,
- /** Main Service */
- WEARABLE_LOG_MODULE_MAIN_SERVICE,
- /** Broadcast Service */
- WEARABLE_LOG_MODULE_BROADCASE_SERVICE,
- /** Atomic Ability Framework */
- WEARABLE_LOG_MODULE_AAFWK,
- /** smart voice */
- WEARABLE_LOG_MODULE_SMART_VOICE,
- /* UI SERVICE */
- WEARABLE_LOG_MODULE_UI_SERVICE,
+ /**
+ * @brief Enumerates logging module types.
+ *
+ * The module type must be globally unique. A maximum of 64 module types can be defined.
+ *
+ * @since 1.0
+ * @version 1.0
+ */
+ typedef enum
+ {
+ /** applications */
+ WEARABLE_LOG_MODULE_APP = 0,
+ /** Launcher Framework */
+ WEARABLE_LOG_MODULE_LAUNCHER_FWK,
+ /** Main Service */
+ WEARABLE_LOG_MODULE_MAIN_SERVICE,
+ /** Broadcast Service */
+ WEARABLE_LOG_MODULE_BROADCASE_SERVICE,
+ /** Atomic Ability Framework */
+ WEARABLE_LOG_MODULE_AAFWK,
+ /** smart voice */
+ WEARABLE_LOG_MODULE_SMART_VOICE,
+ /* UI SERVICE */
+ WEARABLE_LOG_MODULE_UI_SERVICE,
- WEARABLE_LOG_MODULE_MAX
-} WearableLogModuleType;
+ WEARABLE_LOG_MODULE_MAX
+ } WearableLogModuleType;
#ifdef USE_DIAG_LOG
#define WEARABLE_LOGE(mod, fmt, arg...) uapi_diag_error_log(0, fmt, ##arg)