set(PUBLIC_HEADER
${CMAKE_CURRENT_SOURCE_DIR}/nativelauncher/include
- ${CMAKE_CURRENT_SOURCE_DIR}/nativelauncher/include/slices/main
)
set(PRIVATE_HEADER
set(SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/nativelauncher/src/NativeLauncher.cpp
- ${CMAKE_CURRENT_SOURCE_DIR}/nativelauncher/src/slices/main/MainPresenter.cpp
- ${CMAKE_CURRENT_SOURCE_DIR}/nativelauncher/src/slices/main/MainView.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nativeui/main/src/MainViewSample.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nativeui/main/src/MainPresenterSample.cpp
* 基础应用的view id,与MVP的V一一对应
* 枚举命名要求:参考View名字,名字尽量简短
*/
-typedef enum : uint16_t {
- VIEW_INVALID = 0,
- VIEW_MAIN = 1,
- VIEW_SETTING = 2,
- VIEW_APPLIST = 3,
- VIEW_SETTING_FIRST = 4,
- VIEW_MAIN_SAMPLE = 5,
- VIEW_MAIN_ALARM = 6,
- VIEW_MAIN_ACTIVITY = 7,
+typedef enum : uint16_t
+{
+ VIEW_INVALID = 0, // 无效视图
+ VIEW_MAIN_SAMPLE = 1, // 主界面
+ VIEW_SETTING, // 设置
+ VIEW_APPLIST, // App应用
+ VIEW_MAIN_ALARM, // 闹钟
+ VIEW_SETTING_FIRST,
+ VIEW_MAIN_ACTIVITY,
VIEW_ALARM_POP_UP,
VIEW_CALLER_SAMPLE,
VIEW_MAEKPHONE_SAMPLE,
VIEW_INDOORWALK,
VIEW_REBOOT,
VIEW_UISAMPLE,
- VIEW_DIAL,//切换表盘
-
+ VIEW_DIAL, // 切换表盘
VIEW_WEATHER, // 天气
VIEW_WEATHER_REPORT, // 气象报告
VIEW_FUTURE_WEATHER, // 未来天气
VIEW_GET_WEATHER_DATA_ERROR, // 获取天气数据失败
-
- VIEW_MAX_INTER_APP, // 在此之前添加native应用ID.
+ /* -------------------------------------------------------------------------- */
+ VIEW_MAX_INTER_APP, // 在此之前添加native应用ID.
VIEW_EXTERN_APP = 0xFFFE, // 三方应用
VIEW_INVALIDE_APP = 0xFFFF,
} AppViewId;
/*
* Slice页面优先级,越小优先级越高
*/
-typedef enum : uint16_t {
+typedef enum : uint16_t
+{
PRIO_0 = 0,
PRIO_1,
PRIO_2,
public:
static NativeLauncher &GetInstance(void);
void InitNativeLauncher(void);
- void InitMainSlice(void);
void InitMainSampleSlice(void);
void InitSettingSlice(void);
void InitApplistSlice(void);
+++ /dev/null
-/*
- * Copyright (c) 2020-2021 CompanyNameMagicTag.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef MAIN_PRESENTER_H
-#define MAIN_PRESENTER_H
-
-#include "Presenter.h"
-
-namespace OHOS {
-class MainView;
-class MainPresenter : public Presenter<MainView> {
-public:
- MainPresenter();
- virtual ~MainPresenter();
-
- void OnStart() override;
- void OnPause() override;
- void OnResume() override;
- void OnStop() override;
-};
-}
-
-#endif // MAIN_PRESENTER_H
+++ /dev/null
-/*
- * Copyright (c) 2020-2021 CompanyNameMagicTag.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef MAIN_VIEW_H
-#define MAIN_VIEW_H
-
-#include <string>
-
-#include "View.h"
-#include "window/window.h"
-#include "components/ui_label.h"
-#include "components/root_view.h"
-#include "components/ui_view_group.h"
-#include "components/ui_image_view.h"
-#include "components/ui_button.h"
-#include "components/ui_label_button.h"
-
-#include "BaseView.h"
-#include "ChangeSliceListener.h"
-
-namespace OHOS {
-#define LA_HORIZONTAL_RESOLUTION 400 // watch width
-#define LA_VERTICAL_RESOLUTION 400 // watch height
-#define NORMAL_BUTTON_WIDTH 100 // normal button width
-#define NORMAL_BUTTON_HEIGHT 50 // normal button height
-#define UN_OPACITY 255 // UN_OPACITY
-#define FONT_COMMON 20 // 20px
-
-class MainPresenter;
-class MainView : public View<MainPresenter> {
-public:
- MainView();
- virtual ~MainView();
-
- void OnStart() override;
- void OnSetUpView() override;
- void OnTearDownView() override;
- void OnStop() override;
-};
-} // namespace OHOS
-#endif // MAIN_VIEW_H
\ No newline at end of file
*/
#include "NativeLauncher.h"
-#include "MainView.h"
-#include "MainPresenter.h"
#include "SliceProxy.h"
#include "AbilitySliceProxy.h"
#include "wearable_log.h"
};
static const AppViewMapper SLICE_MAPPER[] = {
- {VIEW_MAIN, &NativeLauncher::InitMainSlice},
{VIEW_SETTING, &NativeLauncher::InitSettingSlice},
{VIEW_APPLIST, &NativeLauncher::InitApplistSlice},
{VIEW_MAIN_SAMPLE, &NativeLauncher::InitMainSampleSlice},
{VIEW_UISAMPLE, &NativeLauncher::InitUISampleSlice}};
static const ViewIdToString VIEW_MAPPER[] = {
- {VIEW_MAIN, "main"},
{VIEW_SETTING, "setting"},
{VIEW_APPLIST, "applist"},
{VIEW_MAIN_SAMPLE, "mainViewSample"},
return;
}
- void NativeLauncher::InitMainSlice(void)
- {
- SliceProxy *mainSlice = new AbilitySliceProxy<MainView, MainPresenter>;
- if (mainSlice != nullptr)
- {
- NativeAbility::GetInstance().AddSliceProxy(VIEW_MAIN, mainSlice);
- }
- }
-
void NativeLauncher::InitMainSampleSlice(void)
{
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitMainSampleSlice");
+++ /dev/null
-/*
- * Copyright (c) 2020-2021 CompanyNameMagicTag.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "MainPresenter.h"
-#include "MainView.h"
-
-namespace OHOS {
-
-MainPresenter::MainPresenter() {}
-
-MainPresenter::~MainPresenter() {}
-
-void MainPresenter::OnStart()
-{
- Presenter<MainView>::OnStart();
-}
-
-void MainPresenter::OnPause(void)
-{
-}
-
-void MainPresenter::OnResume(void)
-{
-}
-
-void MainPresenter::OnStop(void)
-{
-}
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright (c) 2020-2021 CompanyNameMagicTag.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "MainView.h"
-#include "AppViewIDs.h"
-
-#include "wearable_log.h"
-
-namespace OHOS {
-MainView::MainView(){}
-
-MainView::~MainView(){}
-
-void MainView::OnStart()
-{
- WEARABLE_LOGI(WEARABLE_LOG_MODULE_LAUNCHER_FWK, "MainView::OnStart");
- View<MainPresenter>::OnStart();
-
- BaseView::RootView(Color::Black().full);
-
- UILabel *goSettings = new UILabel();
- goSettings->SetText("Settings");
- goSettings->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_COMMON);
- goSettings->SetPosition(35, LA_VERTICAL_RESOLUTION);
- goSettings->Resize(NORMAL_BUTTON_WIDTH, NORMAL_BUTTON_HEIGHT);
- goSettings->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
- goSettings->SetStyle(STYLE_TEXT_OPA, OPA_OPAQUE);
- goSettings->SetStyle(STYLE_TEXT_COLOR, Color::Black().full);
- goSettings->SetStyle(STYLE_BACKGROUND_COLOR, Color::Green().full);
- goSettings->SetStyle(STYLE_BACKGROUND_OPA, UN_OPACITY);
- goSettings->SetStyle(STYLE_BORDER_RADIUS, 4);
- goSettings->SetTouchable(true);
- goSettings->SetOnTouchListener(new ChangeSliceListener(VIEW_MAIN));
-
- UILabel *goAppList = new UILabel();
- goAppList->SetText("App List");
- goAppList->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_COMMON);
- goAppList->SetPosition(165, LA_VERTICAL_RESOLUTION);
- goAppList->Resize(NORMAL_BUTTON_WIDTH, NORMAL_BUTTON_HEIGHT);
- goAppList->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
- goAppList->SetStyle(STYLE_TEXT_OPA, OPA_OPAQUE);
- goAppList->SetStyle(STYLE_TEXT_COLOR, Color::Black().full);
- goAppList->SetStyle(STYLE_BACKGROUND_COLOR, Color::Green().full);
- goAppList->SetStyle(STYLE_BACKGROUND_OPA, UN_OPACITY);
- goAppList->SetStyle(STYLE_BORDER_RADIUS, 4);
- goAppList->SetTouchable(true);
- goAppList->SetOnTouchListener(new ChangeSliceListener(VIEW_MAIN));
-
- RootView::GetInstance()->Add(goSettings);
- RootView::GetInstance()->Add(goAppList);
-}
-
-void MainView::OnSetUpView()
-{
- WEARABLE_LOGI(WEARABLE_LOG_MODULE_LAUNCHER_FWK, "MainView::OnSetUpView");
- View<MainPresenter>::OnSetUpView();
-
- UIViewGroup *group = new UIViewGroup();
- group->SetPosition(0, 0, LA_HORIZONTAL_RESOLUTION, LA_VERTICAL_RESOLUTION);
- group->SetStyle(STYLE_BACKGROUND_OPA, UN_OPACITY);
- group->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full);
-
- RootView::GetInstance()->Add(group);
- Draw();
-}
-
-void MainView::OnTearDownView()
-{
- WEARABLE_LOGI(WEARABLE_LOG_MODULE_LAUNCHER_FWK, "MainView::OnTearDownView");
- View<MainPresenter>::OnTearDownView();
- return;
-}
-
-void MainView::OnStop()
-{
- WEARABLE_LOGI(WEARABLE_LOG_MODULE_LAUNCHER_FWK, "MainView::OnStop");
- View<MainPresenter>::OnStop();
-
- if (container_ != nullptr) {
- container_->RemoveAll();
- delete container_;
- container_ = nullptr;
- }
-
- RootView::GetInstance()->ClearOnKeyActListener();
- RootView::GetInstance()->RemoveAll();
- return;
-}
-}
\ No newline at end of file