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_WIFI_ABILITY_SLICE_H 17 #define OHOS_SETTING_WIFI_ABILITY_SLICE_H 18 19 #include <cstddef> 20 #include <cstdio> 21 #include <cstring> 22 23 #include "ability_loader.h" 24 #include "common/task.h" 25 #include "components/ui_label.h" 26 #include "components/ui_label_button.h" 27 #include "components/ui_list.h" 28 #include "components/ui_scroll_view.h" 29 #include "components/ui_toggle_button.h" 30 #include "event_listener.h" 31 #include "gfx_utils/list.h" 32 #include "parameter.h" 33 #include "pthread.h" 34 #include "setting_utils.h" 35 #include "wpa_work.h" 36 37 namespace OHOS { 38 class TestBtnOnStateChangeListener : public OHOS::UICheckBox::OnChangeListener, public OHOS::UIView::OnClickListener { 39 public: ~TestBtnOnStateChangeListener()40 ~TestBtnOnStateChangeListener() {} TestBtnOnStateChangeListener(UIView* uiView)41 explicit TestBtnOnStateChangeListener(UIView* uiView) : myUiView(uiView) {} 42 43 bool OnChange(UICheckBox::UICheckBoxState state) override 44 { 45 return true; 46 } 47 bool OnClick(UIView& view, const ClickEvent& event) override 48 { 49 bool ret = myUiView->IsVisible(); 50 if (ret == false) { 51 myUiView->SetVisible(true); 52 } else { 53 myUiView->SetVisible(false); 54 } 55 myUiView->Invalidate(); 56 return true; 57 } 58 59 private: 60 UIView* myUiView; 61 }; 62 63 class SettingWifiAbilitySlice : public AbilitySlice, Task { 64 public: 65 SettingWifiAbilitySlice(); 66 virtual ~SettingWifiAbilitySlice(); 67 void AddWifi(void); 68 void Callback() override; 69 70 protected: 71 void OnStart(const Want& want) override; 72 void OnInactive() override; 73 void OnActive(const Want& want) override; 74 void OnBackground() override; 75 void OnStop() override; 76 77 private: 78 void MyThread(); 79 void SetWifiButtonListener(char* ssid); 80 void SetButtonListener(); 81 void SetHead(); 82 void SetToggleButton(); 83 void SetUseWifi(); 84 void SetScrollWifi(); 85 86 UIViewGroup* headView_; 87 UIViewGroup* toggleButtonView_; 88 UIScrollView* scrollView_; 89 RootView* rootView_; 90 TestBtnOnStateChangeListener* changeListener_; 91 EventListener* buttonBackListener_; 92 EventListener* buttonInputListener_; 93 int wpaCount_; 94 95 constexpr static int TOGGLE_X = 36; 96 constexpr static int TOGGLE_Y = 72; 97 98 constexpr static int USE_WIFI_FONT_X = 54; 99 constexpr static int USE_WIFI_FONT_Y = 187; 100 101 constexpr static int ADD_WIFI_X = 0; 102 constexpr static int SCROLL_WIFI_X = 36; 103 constexpr static int SCROLL_WIFI_Y = 242; 104 constexpr static int SCROLL_WIFI_WIDTH = 960; 105 constexpr static int SCROLL_WIFI_HEIGHT = 238; 106 }; 107 } // namespace OHOS 108 #endif 109