• 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_SETTING_DISPLAY_ABILITY_SLICE_H
17 #define OHOS_SETTING_DISPLAY_ABILITY_SLICE_H
18 
19 #include <cstddef>
20 #include <cstdio>
21 #include <cstring>
22 #include <iproxy_client.h>
23 #include <power_screen_saver.h>
24 
25 #include "ability_loader.h"
26 #include "components/ui_label.h"
27 #include "components/ui_label_button.h"
28 #include "components/ui_list.h"
29 #include "components/ui_scroll_view.h"
30 #include "components/ui_toggle_button.h"
31 #include "event_listener.h"
32 #include "gfx_utils/list.h"
33 #include "parameter.h"
34 #include "samgr_lite.h"
35 #include "setting_utils.h"
36 
37 namespace OHOS {
38 class DisBtnOnStateChangeListener : public OHOS::UICheckBox::OnChangeListener, public OHOS::UIView::OnClickListener {
39 public:
~DisBtnOnStateChangeListener()40     ~DisBtnOnStateChangeListener() {}
DisBtnOnStateChangeListener(UIToggleButton * togglebutton)41     explicit DisBtnOnStateChangeListener(UIToggleButton* togglebutton) : myTogglebutton(togglebutton) {}
42 
OnChange(UICheckBox::UICheckBoxState state)43     bool OnChange(UICheckBox::UICheckBoxState state) override
44     {
45         return true;
46     }
OnClick(UIView & view,const ClickEvent & event)47     bool OnClick(UIView& view, const ClickEvent& event) override
48     {
49         bool status = myTogglebutton->GetState();
50         SetScreenSaverState(status ? TRUE : FALSE);
51 
52         return true;
53     }
54 private:
55     UIToggleButton* myTogglebutton;
56 };
57 
58 class SettingDisplayAbilitySlice : public AbilitySlice {
59 public:
SettingDisplayAbilitySlice()60     SettingDisplayAbilitySlice()
61         : headView_(nullptr), toggleButtonView_(nullptr), rootView_(nullptr),
62           buttonBackListener_(nullptr), changeListener_(nullptr) {}
63 
64     virtual ~SettingDisplayAbilitySlice();
65 protected:
66     void OnStart(const Want& want) override;
67     void OnInactive() override;
68     void OnActive(const Want& want) override;
69     void OnBackground() override;
70     void OnStop() override;
71 
72 private:
73     void SetButtonListener();
74     void SetHead();
75     void SetToggleButton();
76 
77     UIViewGroup* headView_;
78     UIViewGroup* toggleButtonView_;
79     RootView* rootView_;
80     EventListener* buttonBackListener_;
81     DisBtnOnStateChangeListener* changeListener_;
82     constexpr static int TOGGLE_X = 36;
83     constexpr static int TOGGLE_Y = 72;
84 
85     constexpr static int USE_WIFI_FONT_X = 54;
86     constexpr static int USE_WIFI_FONT_Y = 187;
87 
88     constexpr static int ADD_WIFI_X = 0;
89     constexpr static int SCROLL_WIFI_X = 36;
90     constexpr static int SCROLL_WIFI_Y = 242;
91     constexpr static int SCROLL_WIFI_WIDTH = 960;
92     constexpr static int SCROLL_WIFI_HEIGHT = 238;
93 };
94 } // namespace OHOS
95 #endif
96