1.删除视图ID为 VIEW_MAIN的文件slice
author罗正yun <1732036298@qq.com>
Sat, 20 Jan 2024 04:05:01 +0000 (12:05 +0800)
committer罗正yun <1732036298@qq.com>
Sat, 20 Jan 2024 04:05:01 +0000 (12:05 +0800)
code/sdk/application/wearable/nativeapp/CMakeLists.txt
code/sdk/application/wearable/nativeapp/nativelauncher/include/AppViewIDs.h
code/sdk/application/wearable/nativeapp/nativelauncher/include/NativeLauncher.h
code/sdk/application/wearable/nativeapp/nativelauncher/include/slices/main/MainPresenter.h [deleted file]
code/sdk/application/wearable/nativeapp/nativelauncher/include/slices/main/MainView.h [deleted file]
code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeLauncher.cpp
code/sdk/application/wearable/nativeapp/nativelauncher/src/slices/main/MainPresenter.cpp [deleted file]
code/sdk/application/wearable/nativeapp/nativelauncher/src/slices/main/MainView.cpp [deleted file]

index 794e7e8..ac1109e 100755 (executable)
@@ -5,7 +5,6 @@ set(UI_SAMPLE_ROOT ${ROOT_DIR}/middleware/services/gui/uikit/sample/uitest)
 
 set(PUBLIC_HEADER
     ${CMAKE_CURRENT_SOURCE_DIR}/nativelauncher/include
-    ${CMAKE_CURRENT_SOURCE_DIR}/nativelauncher/include/slices/main
 )
 
 set(PRIVATE_HEADER
@@ -77,8 +76,6 @@ 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
 
index 1af2dd9..4b74273 100755 (executable)
  * 基础应用的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,
@@ -45,14 +45,13 @@ typedef enum : uint16_t {
     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;
@@ -60,7 +59,8 @@ typedef enum : uint16_t {
 /*
  * Slice页面优先级,越小优先级越高
  */
-typedef enum : uint16_t {
+typedef enum : uint16_t
+{
     PRIO_0 = 0,
     PRIO_1,
     PRIO_2,
index 8870ce8..e5bc634 100755 (executable)
@@ -21,7 +21,6 @@ namespace OHOS
     public:
         static NativeLauncher &GetInstance(void);
         void InitNativeLauncher(void);
-        void InitMainSlice(void);
         void InitMainSampleSlice(void);
         void InitSettingSlice(void);
         void InitApplistSlice(void);
diff --git a/code/sdk/application/wearable/nativeapp/nativelauncher/include/slices/main/MainPresenter.h b/code/sdk/application/wearable/nativeapp/nativelauncher/include/slices/main/MainPresenter.h
deleted file mode 100755 (executable)
index 7e25bbd..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * 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
diff --git a/code/sdk/application/wearable/nativeapp/nativelauncher/include/slices/main/MainView.h b/code/sdk/application/wearable/nativeapp/nativelauncher/include/slices/main/MainView.h
deleted file mode 100755 (executable)
index 6a13cae..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * 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
index 3f47fce..d9e9e20 100755 (executable)
@@ -14,8 +14,6 @@
  */
 
 #include "NativeLauncher.h"
-#include "MainView.h"
-#include "MainPresenter.h"
 #include "SliceProxy.h"
 #include "AbilitySliceProxy.h"
 #include "wearable_log.h"
@@ -91,7 +89,6 @@ namespace OHOS
     };
 
     static const AppViewMapper SLICE_MAPPER[] = {
-        {VIEW_MAIN, &NativeLauncher::InitMainSlice},
         {VIEW_SETTING, &NativeLauncher::InitSettingSlice},
         {VIEW_APPLIST, &NativeLauncher::InitApplistSlice},
         {VIEW_MAIN_SAMPLE, &NativeLauncher::InitMainSampleSlice},
@@ -117,7 +114,6 @@ namespace OHOS
         {VIEW_UISAMPLE, &NativeLauncher::InitUISampleSlice}};
 
     static const ViewIdToString VIEW_MAPPER[] = {
-        {VIEW_MAIN, "main"},
         {VIEW_SETTING, "setting"},
         {VIEW_APPLIST, "applist"},
         {VIEW_MAIN_SAMPLE, "mainViewSample"},
@@ -179,15 +175,6 @@ namespace OHOS
         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");
diff --git a/code/sdk/application/wearable/nativeapp/nativelauncher/src/slices/main/MainPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativelauncher/src/slices/main/MainPresenter.cpp
deleted file mode 100755 (executable)
index dbfac37..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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
diff --git a/code/sdk/application/wearable/nativeapp/nativelauncher/src/slices/main/MainView.cpp b/code/sdk/application/wearable/nativeapp/nativelauncher/src/slices/main/MainView.cpp
deleted file mode 100755 (executable)
index f180f6e..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * 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