• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2020 Huawei Device Co., Ltd.
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 
16 #ifndef OHOS_APP_INFO_H
17 #define OHOS_APP_INFO_H
18 
19 #include <components/ui_label_button.h>
20 #include <components/ui_label.h>
21 #include <components/ui_view_group.h>
22 
23 #include "native_base.h"
24 #include "ui_config.h"
25 
26 namespace OHOS {
27 
28 class AppInfo;
29 using funcLongPress = bool (*)(AppInfo *app);
30 using funcClick  = bool (*)(AppInfo *app);
31 using UninstallApp = bool (*)(AppInfo *app);
32 using AddApp = bool (*)(AppInfo *app);
33 
34 struct MyPoint {
35     int16_t x; // the x coordinate of the point
36     int16_t y; // the y coordinate of the point
37 };
38 
39 class AppInfo {
40 public:
41     AppInfo();
42     virtual ~AppInfo();
43     void Release();
44     void ReSet();
45     void SetButton(UILabelButton *button);
46     void SetLable(UILabel *lable);
47     void SetListener(AppInfo *app);
48     void SetLocation(int16_t r, int16_t c);
49 
50     UILabelButton* button_ { nullptr };
51     UILabel* lable_ { nullptr };
52 
53     UIView::OnLongPressListener* appLpListener_ { nullptr };
54     UIView::OnClickListener* appClickListener_ { nullptr };
55 
56     funcClick funcclick_ { nullptr };
57     funcLongPress funclPress_ { nullptr };
58     MyPoint lableXY_ { 0 };
59     MyPoint lableHV_ { 0 };
60     MyPoint buttonXY_ { 0 };
61     MyPoint buttonHV_ { 0 };
62     MyPoint row_col_ { 0 };
63     char appName_[TMP_BUF_SIZE] = { 0 };
64     char abilityName_[TMP_BUF_SIZE] = { 0 };
65     char appIconDir_[TMP_BUF_SIZE] = { 0 };
66 };
67 
68 class AppClickListener : public UIView::OnClickListener {
69 public:
AppClickListener(funcClick func,AppInfo * app)70     AppClickListener(funcClick func, AppInfo* app) : funcClick_(func), appInfo_(app) {}
~AppClickListener()71     virtual ~AppClickListener() {}
OnClick(UIView & view,const ClickEvent & event)72     bool OnClick(UIView& view, const ClickEvent& event) override
73     {
74         funcClick_(appInfo_);
75         return true;
76     }
77 
78 private:
79     funcClick funcClick_ { nullptr };
80     AppInfo *appInfo_ { nullptr };
81 };
82 
83 class AppLongPressListener : public UIView::OnLongPressListener {
84 public:
AppLongPressListener(funcClick func,AppInfo * app)85     AppLongPressListener(funcClick func, AppInfo* app) : appInfo_(app), funcLongPress_(func) {}
~AppLongPressListener()86     virtual ~AppLongPressListener() {}
OnLongPress(UIView & view,const LongPressEvent & event)87     bool OnLongPress(UIView& view, const LongPressEvent& event) override
88     {
89         funcLongPress_(appInfo_);
90         return true;
91     }
92 
93 private:
94     AppInfo* appInfo_ { nullptr };
95     funcLongPress funcLongPress_ { nullptr };
96 };
97 } // namespace OHOS
98 #endif
99