* @Author: luozheng 1732036298@qq.com
* @Date: 2024-04-10 11:58:32
* @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-04-10 16:26:47
+ * @LastEditTime: 2024-06-07 18:54:26
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/dnotdisturb/include/DnotDisturbPresenter.h
*/
bool OnDrag(UIView &view, const DragEvent &event) override;
bool OnDragEnd(UIView &view, const DragEvent &event) override;
bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件
+ bool X_DRAG_FLAG{false};
};
}
* @Author: luozheng 1732036298@qq.com
* @Date: 2024-04-10 11:58:15
* @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-05-10 15:42:00
+ * @LastEditTime: 2024-06-07 18:46:54
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/dnotdisturb/include/DnotDisturbView.h
*/
#ifndef DNOTDISTURB_VIEW_H
void DnotDisturbViewInit(void);
void ClearAll(void);
UIScrollView *scrollView = nullptr;
- UILabelExt *showTimeLabel{nullptr}; // 显示系统时间的标签
+ UILabelExt *showTitleLabel{nullptr};
UIImageView *background{nullptr};
UIImageView *DnotDisturbImage{nullptr};
UILabel *AttentionLabel{nullptr};
* @Author: luozheng 1732036298@qq.com
* @Date: 2024-04-10 11:58:37
* @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-04-25 16:39:57
+ * @LastEditTime: 2024-06-07 18:54:14
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/dnotdisturb/src/DnotDisturbPresenter.cpp
*/
#include "AppViewIDs.h"
#include "NativeAbility.h"
+#include "UiConfig.h"
#include "dnotdisturb/include/DnotDisturbView.h"
#include "dnotdisturb/include/DnotDisturbPresenter.h"
#include "dnotdisturb/include/DnotDisturbModel.h"
bool DnotDisturbPresenter::OnDrag(UIView &view, const DragEvent &event)
{
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "DnotDisturbPresenter::OnDrag");
UNUSED(view);
- UNUSED(event);
+ if ((event.GetDeltaX() > X_DRAG_OFFSET) && (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) // 拖动过程中判断是否是水平滑动
+ {
+ DnotDisturbPresenter::X_DRAG_FLAG = true;
+ }
return true;
}
bool DnotDisturbPresenter::OnDragEnd(UIView &view, const DragEvent &event)
{
- UNUSED(view);
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "DnotDisturbPresenter::OnDragEnd");
UNUSED(event);
+ if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && DnotDisturbPresenter::X_DRAG_FLAG)
+ {
+ NativeAbility::GetInstance().Back(TransitionType::TRANSITION_BACK_TO_HEXAGONS);
+ DnotDisturbPresenter::X_DRAG_FLAG = false;
+ }
return true;
}
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DnotDisturbView::GetInstance fail!!");
return false;
}
- if (&view == p_DnotDisturbView->GetButtonOn())//开启勿扰模式
+ if (&view == p_DnotDisturbView->GetButtonOn()) // 开启勿扰模式
{
DnotDisturbModel::GetInstance().SetDoNotDisturbModeEnabled(true);
- NativeAbility::GetInstance().Back();
+ NativeAbility::GetInstance().Back(TransitionType::TRANSITION_BACK_TO_HEXAGONS);
}
else if (&view == p_DnotDisturbView->GetButtonOff())
{
- NativeAbility::GetInstance().Back();
+ // NativeAbility::GetInstance().Back(TransitionType::TRANSITION_BACK_TO_HEXAGONS);
}
+ NativeAbility::GetInstance().Back(TransitionType::TRANSITION_BACK_TO_HEXAGONS);
return true;
}
// 如果是power键就返回上一级
if (keyID == static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 0 && uapi_get_screen_state() == 0)
{
- NativeAbility::GetInstance().Back();
+ NativeAbility::GetInstance().Back(TransitionType::TRANSITION_BACK_TO_HEXAGONS);
}
return true;
}
void DnotDisturbPresenter::Notify()
{
- DnotDisturbView::GetInstance()->UpdataTime();
+ // DnotDisturbView::GetInstance()->UpdataTime();
}
}
\ No newline at end of file
* @Author: luozheng 1732036298@qq.com
* @Date: 2024-04-10 11:58:21
* @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-05-10 15:43:25
+ * @LastEditTime: 2024-06-07 18:51:22
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/dnotdisturb/src/DnotDisturbView.cpp
*/
#include "dnotdisturb/include/DnotDisturbView.h"
{
scrollView->RemoveAll();
- if (showTimeLabel != nullptr)
+ if (showTitleLabel != nullptr)
{
- delete showTimeLabel;
- showTimeLabel = nullptr;
+ delete showTitleLabel;
+ showTitleLabel = nullptr;
}
if (background != nullptr)
}
scrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
scrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
+ scrollView->SetTouchable(true);
+ scrollView->SetDraggable(true);
+ UIView::OnDragListener *dragListener = static_cast<UIView::OnDragListener *>(DnotDisturbPresenter::GetInstance());
+ if (dragListener == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DnotDisturbView::dragListener new fail!!");
+ return;
+ }
+ scrollView->SetOnDragListener(dragListener);
/* -------------------------------------------------------------------------- */
- showTimeLabel = new UILabelExt();
- if (showTimeLabel == nullptr)
+ showTitleLabel = new UILabelExt();
+ if (showTitleLabel == nullptr)
{
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DnotDisturbView::showTimeLabel new fail!!");
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DnotDisturbView::showTitleLabel new fail!!");
return;
}
- showTimeLabel->SetPosition(83, 52, 300, 46);
- showTimeLabel->SetStyle(STYLE_TEXT_FONT, 40);
- showTimeLabel->SetStyle(STYLE_LINE_HEIGHT, 46);
- showTimeLabel->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE);
- showTimeLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
- showTimeLabel->SetRollSpeed(40);
- showTimeLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40);
+ showTitleLabel->SetPosition(83, 52, 300, 35);
+ showTitleLabel->SetStyle(STYLE_TEXT_FONT, 30);
+ showTitleLabel->SetStyle(STYLE_LINE_HEIGHT, 35);
+ showTitleLabel->SetTextId(STR_DO_NOT_DISTURB);
+ showTitleLabel->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE);
+ showTitleLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+ showTitleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
/* -------------------------------------------------------------------------- */
background = new UIImageView();
if (background == nullptr)
AttentionLabel->SetPosition(33, 228, 400, 70);
AttentionLabel->SetStyle(STYLE_TEXT_FONT, 30);
AttentionLabel->SetStyle(STYLE_LINE_HEIGHT, 35);
- //AttentionLabel->SetText("开启勿扰模式,手表将不会发出震动与铃声,是否开启");
+ // AttentionLabel->SetText("开启勿扰模式,手表将不会发出震动与铃声,是否开启");
SetLabelId(AttentionLabel, STR_DO_NOT_DISTURB_MODE);
AttentionLabel->SetLineBreakMode(UILabelExt::LINE_BREAK_WRAP);
AttentionLabel->SetTextColor(Color::GetColorFromRGBA(0x99, 0x99, 0x99, 0xff));
/*更新当前时间*/
void DnotDisturbView::UpdataTime()
{
+#if 0
// 获取当前时间
struct tm pTM;
time_t seconds;
// 将时间和日期转换为字符串
std::string stringtime = (hour < 10 ? "0" : "") + std::to_string(hour) + ":" + (minute < 10 ? "0" : "") + std::to_string(minute);
- showTimeLabel->SetText(stringtime.c_str());
+ showTitleLabel->SetText(stringtime.c_str());
+#endif
}
UILabelButtonExt *DnotDisturbView::GetButtonOn(void)
void DnotDisturbView::OnSetUpView()
{
View<DnotDisturbPresenter>::OnSetUpView();
- scrollView->Add(showTimeLabel);
+ scrollView->Add(showTitleLabel);
scrollView->Add(background);
scrollView->Add(DnotDisturbImage);
scrollView->Add(AttentionLabel);
scrollView->Add(ButtonOn);
scrollView->Add(ButtonOff);
RootView::GetInstance()->Add(scrollView);
+ container_ = scrollView;
Draw();
}
* @Author: luozheng 1732036298@qq.com
* @Date: 2024-03-27 10:47:24
* @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-05-10 16:22:33
+ * @LastEditTime: 2024-06-07 18:18:38
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/findphone/include/FindPhonePresenter.h
*/
class FindPhoneView;
class FindPhonePresenter : public Presenter<FindPhoneView>,
public UIView::OnClickListener,
- public RootView::OnKeyActListener
+ public RootView::OnKeyActListener,
+ public UIView::OnDragListener
{
public:
FindPhonePresenter();
private:
bool OnClick(UIView &view, const ClickEvent &event) override;
+ bool OnDrag(UIView &view, const DragEvent &event) override;
+ bool OnDragEnd(UIView &view, const DragEvent &event) override;
bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件
+ bool X_DRAG_FLAG{false};
};
}
#endif
* @Author: luozheng 1732036298@qq.com
* @Date: 2024-03-27 10:47:40
* @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-05-10 16:29:37
+ * @LastEditTime: 2024-06-07 18:21:37
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/findphone/src/FindPhonePresenter.cpp
*/
#include "AppViewIDs.h"
+#include "UiConfig.h"
#include "components/ui_label_ext.h"
#include "language/font/ui_resource_string.h"
#include "NativeAbility.h"
bool FindPhonePresenter::OnClick(UIView &view, const ClickEvent &event)
{
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "FindPhonePresenter::OnClick");
UNUSED(event);
if (strcmp(view.GetViewId(), FINDPHONE_LABELBUTTON) == 0)
{
{
senfindphoneSend(FINDPHONE_STOP);
}
- NativeAbility::GetInstance().Back();
+ NativeAbility::GetInstance().Back(TransitionType::TRANSITION_BACK_TO_HEXAGONS);
+ }
+ return true;
+ }
+
+ bool FindPhonePresenter::OnDrag(UIView &view, const DragEvent &event)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "FindPhonePresenter::OnDrag");
+ UNUSED(view);
+ if ((event.GetDeltaX() > X_DRAG_OFFSET) && (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) // 拖动过程中判断是否是水平滑动
+ {
+ FindPhonePresenter::X_DRAG_FLAG = true;
+ }
+ return true;
+ }
+
+ bool FindPhonePresenter::OnDragEnd(UIView &view, const DragEvent &event)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "FindPhonePresenter::OnDragEnd");
+ UNUSED(event);
+ if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && FindPhonePresenter::X_DRAG_FLAG)
+ {
+ NativeAbility::GetInstance().Back(TransitionType::TRANSITION_BACK_TO_HEXAGONS);
+ FindPhonePresenter::X_DRAG_FLAG = false;
}
return true;
}
{
senfindphoneSend(FINDPHONE_STOP);
}
- NativeAbility::GetInstance().Back();
+ NativeAbility::GetInstance().Back(TransitionType::TRANSITION_BACK_TO_HEXAGONS);
}
return true;
}
* @Author: luozheng 1732036298@qq.com
* @Date: 2024-03-27 10:47:46
* @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-05-10 16:36:28
+ * @LastEditTime: 2024-06-07 18:33:39
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/findphone/src/FindPhoneView.cpp
*/
#include "findphone/include/FindPhoneView.h"
{
FindPhoneViewInit_BlueToothDisConnected();
}
+
+ FindPhoneGroupView->SetTouchable(true);
+ FindPhoneGroupView->SetDraggable(true);
+ UIView::OnDragListener *dragListener = static_cast<UIView::OnDragListener *>(FindPhonePresenter::GetInstance());
+ FindPhoneGroupView->SetOnDragListener(dragListener);
+
// 增加按键监听
RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::FindPhonePresenter::GetInstance();
RootView::GetInstance()->SetOnKeyActListener(keyactListener);
{
View<FindPhonePresenter>::OnSetUpView();
RootView::GetInstance()->Add(FindPhoneGroupView);
+ container_ = FindPhoneGroupView;
Draw();
}