From: hcj <1224667075@qq.com> Date: Mon, 13 Oct 2025 02:58:35 +0000 (+0800) Subject: 解决左滑失效问题拨号盘 X-Git-Tag: V1.0.9_20251128_194606_LN~250^2~14 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=37888c70e8907b232e03999b9710af4226d8ae68;p=mirrors%2FFD230.git 解决左滑失效问题拨号盘 --- diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/src/PhoneCallView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/src/PhoneCallView.cpp index 798899a0f..e16416ea5 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/src/PhoneCallView.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/src/PhoneCallView.cpp @@ -60,9 +60,15 @@ namespace OHOS button->SetOnClickListener(buttonClick); UIView::OnLongPressListener*buttonlongpress=static_cast(PhoneCallPresenter::GetInstance()); button->SetOnLongPressListener(buttonlongpress); + UIView::OnDragListener *dragListener = static_cast(PhoneCallPresenter::GetInstance()); + button->SetOnDragListener(dragListener); - // Add to rootView - AddViewToRootContainer(button); + button->SetDraggable(true); + + // Add to container_child + if (container_child) { + container_child->Add(button); + } button->SetVisible(true); return button; @@ -78,6 +84,14 @@ namespace OHOS void PhoneCallView::Init() { + // 创建容器 + if (container_child == nullptr) { + container_child = new UIViewGroup(); + container_child->SetPosition(0, 0); + container_child->Resize(480, 480); // 设置容器大小 + container_child->SetDraggable(true); + } + // Add Label to App if (label_ == nullptr) { @@ -97,8 +111,10 @@ namespace OHOS label_->SetRollSpeed(0); label_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40); - // Add to rootView - AddViewToRootContainer(label_); + // Add to container_child + if (container_child) { + container_child->Add(label_); + } label_->SetVisible(true); ButtonInitParams buttonParams[] = { { BUTTON1, 68, 104, 104, 70, button1Path, button1Path}, @@ -118,7 +134,21 @@ namespace OHOS for(int i = 0;i<12;i++){ button_[i] = initButton(buttonParams[i]); } + + UIView::OnDragListener *dragListener = static_cast(PhoneCallPresenter::GetInstance()); + if (dragListener == nullptr) + { + return; + } + container_child->SetOnDragListener(dragListener); + + + + // 将容器添加到根视图 + AddViewToRootContainer(container_child); + container_child->SetVisible(true); } + static int8_t roll_falg=0;//0.1s一次变换 static void label_Timer_CallBack(int data) @@ -145,18 +175,6 @@ namespace OHOS if(call_roll_timer) { roll_falg=10; - // osTimerStop(call_roll_timer); - // osTimerDelete(call_roll_timer); - - // call_roll_timer = osTimerNew((osTimerFunc_t)label_Timer_CallBack, osTimerPeriodic, NULL, NULL); - // tick =100;// osMs2Tick(1000); - // retTimer = osTimerStart(call_roll_timer, tick); - // if (retTimer != osOK && call_roll_timer != NULL) { - // osTimerDelete(call_roll_timer); - // call_roll_timer = NULL; - // return ; - // } - } else { diff --git a/code/sdk/application/wearable/fd272/nativeapp/nativeui/phone/src/PhoneCallView.cpp b/code/sdk/application/wearable/fd272/nativeapp/nativeui/phone/src/PhoneCallView.cpp index 798899a0f..e16416ea5 100644 --- a/code/sdk/application/wearable/fd272/nativeapp/nativeui/phone/src/PhoneCallView.cpp +++ b/code/sdk/application/wearable/fd272/nativeapp/nativeui/phone/src/PhoneCallView.cpp @@ -60,9 +60,15 @@ namespace OHOS button->SetOnClickListener(buttonClick); UIView::OnLongPressListener*buttonlongpress=static_cast(PhoneCallPresenter::GetInstance()); button->SetOnLongPressListener(buttonlongpress); + UIView::OnDragListener *dragListener = static_cast(PhoneCallPresenter::GetInstance()); + button->SetOnDragListener(dragListener); - // Add to rootView - AddViewToRootContainer(button); + button->SetDraggable(true); + + // Add to container_child + if (container_child) { + container_child->Add(button); + } button->SetVisible(true); return button; @@ -78,6 +84,14 @@ namespace OHOS void PhoneCallView::Init() { + // 创建容器 + if (container_child == nullptr) { + container_child = new UIViewGroup(); + container_child->SetPosition(0, 0); + container_child->Resize(480, 480); // 设置容器大小 + container_child->SetDraggable(true); + } + // Add Label to App if (label_ == nullptr) { @@ -97,8 +111,10 @@ namespace OHOS label_->SetRollSpeed(0); label_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40); - // Add to rootView - AddViewToRootContainer(label_); + // Add to container_child + if (container_child) { + container_child->Add(label_); + } label_->SetVisible(true); ButtonInitParams buttonParams[] = { { BUTTON1, 68, 104, 104, 70, button1Path, button1Path}, @@ -118,7 +134,21 @@ namespace OHOS for(int i = 0;i<12;i++){ button_[i] = initButton(buttonParams[i]); } + + UIView::OnDragListener *dragListener = static_cast(PhoneCallPresenter::GetInstance()); + if (dragListener == nullptr) + { + return; + } + container_child->SetOnDragListener(dragListener); + + + + // 将容器添加到根视图 + AddViewToRootContainer(container_child); + container_child->SetVisible(true); } + static int8_t roll_falg=0;//0.1s一次变换 static void label_Timer_CallBack(int data) @@ -145,18 +175,6 @@ namespace OHOS if(call_roll_timer) { roll_falg=10; - // osTimerStop(call_roll_timer); - // osTimerDelete(call_roll_timer); - - // call_roll_timer = osTimerNew((osTimerFunc_t)label_Timer_CallBack, osTimerPeriodic, NULL, NULL); - // tick =100;// osMs2Tick(1000); - // retTimer = osTimerStart(call_roll_timer, tick); - // if (retTimer != osOK && call_roll_timer != NULL) { - // osTimerDelete(call_roll_timer); - // call_roll_timer = NULL; - // return ; - // } - } else { diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/phone/src/PhoneCallView.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/phone/src/PhoneCallView.cpp index 798899a0f..e16416ea5 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/phone/src/PhoneCallView.cpp +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/phone/src/PhoneCallView.cpp @@ -60,9 +60,15 @@ namespace OHOS button->SetOnClickListener(buttonClick); UIView::OnLongPressListener*buttonlongpress=static_cast(PhoneCallPresenter::GetInstance()); button->SetOnLongPressListener(buttonlongpress); + UIView::OnDragListener *dragListener = static_cast(PhoneCallPresenter::GetInstance()); + button->SetOnDragListener(dragListener); - // Add to rootView - AddViewToRootContainer(button); + button->SetDraggable(true); + + // Add to container_child + if (container_child) { + container_child->Add(button); + } button->SetVisible(true); return button; @@ -78,6 +84,14 @@ namespace OHOS void PhoneCallView::Init() { + // 创建容器 + if (container_child == nullptr) { + container_child = new UIViewGroup(); + container_child->SetPosition(0, 0); + container_child->Resize(480, 480); // 设置容器大小 + container_child->SetDraggable(true); + } + // Add Label to App if (label_ == nullptr) { @@ -97,8 +111,10 @@ namespace OHOS label_->SetRollSpeed(0); label_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40); - // Add to rootView - AddViewToRootContainer(label_); + // Add to container_child + if (container_child) { + container_child->Add(label_); + } label_->SetVisible(true); ButtonInitParams buttonParams[] = { { BUTTON1, 68, 104, 104, 70, button1Path, button1Path}, @@ -118,7 +134,21 @@ namespace OHOS for(int i = 0;i<12;i++){ button_[i] = initButton(buttonParams[i]); } + + UIView::OnDragListener *dragListener = static_cast(PhoneCallPresenter::GetInstance()); + if (dragListener == nullptr) + { + return; + } + container_child->SetOnDragListener(dragListener); + + + + // 将容器添加到根视图 + AddViewToRootContainer(container_child); + container_child->SetVisible(true); } + static int8_t roll_falg=0;//0.1s一次变换 static void label_Timer_CallBack(int data) @@ -145,18 +175,6 @@ namespace OHOS if(call_roll_timer) { roll_falg=10; - // osTimerStop(call_roll_timer); - // osTimerDelete(call_roll_timer); - - // call_roll_timer = osTimerNew((osTimerFunc_t)label_Timer_CallBack, osTimerPeriodic, NULL, NULL); - // tick =100;// osMs2Tick(1000); - // retTimer = osTimerStart(call_roll_timer, tick); - // if (retTimer != osOK && call_roll_timer != NULL) { - // osTimerDelete(call_roll_timer); - // call_roll_timer = NULL; - // return ; - // } - } else {