1 /*
2 * Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15 #include "launcher.h"
16 #include "log.h"
17
18 #define X_AXIS 25
19 #define Y_AXIS 75
20 #define POS_WIDTH 400
21 #define POS_HEIGHT 300
22
23 namespace OHOS {
InitUI()24 void Launcher::InitUI()
25 {
26 rootView_ = RootView::GetInstance();
27 rootView_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
28 HILOG_DEBUG(HILOG_MODULE_APP, "rootView %d-%d", rootView_->GetWidth(), rootView_->GetHeight());
29
30 gifImageView_ = new UIImageView();
31 gifImageView_->SetPosition(X_AXIS, Y_AXIS, POS_WIDTH, POS_HEIGHT);
32 const char *launcherGifPath = "/data/img/launcher.gif";
33 gifImageView_->SetSrc(launcherGifPath);
34 rootView_->Add(gifImageView_);
35 rootView_->Invalidate();
36 }
37
DeleteUI()38 void Launcher::DeleteUI()
39 {
40 HILOG_DEBUG(HILOG_MODULE_APP, "%s", __func__);
41 if (gifImageView_ != nullptr) {
42 delete gifImageView_;
43 gifImageView_ = nullptr;
44 }
45 }
46
~Launcher()47 Launcher::~Launcher()
48 {
49 DeleteUI();
50 }
51
OnStart(const Want & want)52 void Launcher::OnStart(const Want &want)
53 {
54 HILOG_DEBUG(HILOG_MODULE_APP, "%s", __func__);
55 }
56
OnInactive()57 void Launcher::OnInactive()
58 {
59 HILOG_DEBUG(HILOG_MODULE_APP, "%s", __func__);
60 }
61
OnActive(const Want & want)62 void Launcher::OnActive(const Want &want)
63 {
64 HILOG_DEBUG(HILOG_MODULE_APP, "%s", __func__);
65 InitUI();
66 }
67
OnBackground()68 void Launcher::OnBackground()
69 {
70 HILOG_DEBUG(HILOG_MODULE_APP, "%s", __func__);
71 DeleteUI();
72 }
73
OnStop()74 void Launcher::OnStop()
75 {
76 HILOG_DEBUG(HILOG_MODULE_APP, "%s", __func__);
77 DeleteUI();
78 }
79 } // namespace OHOS
80
81 extern "C" int InstallNativeAbility(const AbilityInfo *abilityInfo, const OHOS::SliteAbility *ability);
InstallLauncher()82 extern "C" void InstallLauncher()
83 {
84 OHOS::Launcher *launcher = OHOS::Launcher::GetInstance();
85 InstallNativeAbility(NULL, launcher);
86 }
87