• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 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_APPLICATION_CONFIGURATION_MANAGER_H
17 #define OHOS_APPLICATION_CONFIGURATION_MANAGER_H
18 
19 #include <cstdint>
20 #include <string>
21 #include <vector>
22 #include <map>
23 #include "context.h"
24 #include "resource_manager.h"
25 
26 namespace OHOS {
27 namespace AbilityRuntime {
28 enum class SetLevel : uint8_t {
29     // system level, only color mode have SA level
30     System,
31     SA,
32     // application level
33     Application,
34     SetLevelCount,
35 };
36 
37 class ApplicationConfigurationManager {
38     ApplicationConfigurationManager() = default;
39     ~ApplicationConfigurationManager() = default;
40 public:
41     static ApplicationConfigurationManager& GetInstance();
42     void SetLanguageSetLevel(SetLevel languageSetLevel);
43     void SetfontSetLevel(SetLevel fontSetLevel);
44     SetLevel GetLanguageSetLevel() const;
45     SetLevel GetFontSetLevel() const;
46     std::string SetColorModeSetLevel(SetLevel colorModeSetLevel, const std::string &value);
47     SetLevel GetColorModeSetLevel() const;
48     std::string GetColorMode();
49     bool ColorModeHasSetByApplication() const;
50     void AddIgnoreContext(std::shared_ptr<Context> context,
51         std::shared_ptr<Global::Resource::ResourceManager> resourceManager);
52     void DeleteIgnoreContext(std::shared_ptr<Context> context);
53     std::vector<std::shared_ptr<Context>> GetIgnoreContext();
54     std::vector<std::shared_ptr<Global::Resource::ResourceManager>> GetIgnoreResource();
55     static std::string GetUpdatedLocale(const std::string& systemLocale, const std::string& systemLanguage);
56 
57 private:
58     SetLevel languageSetLevel_ = SetLevel::System;
59     SetLevel colorModeSetLevel_ = SetLevel::System;
60     SetLevel fontSetLevel_ = SetLevel::System;
61     std::vector<std::string> colorModeVal_ =
62         std::vector<std::string>(static_cast<uint8_t>(SetLevel::SetLevelCount));
63     std::map<std::shared_ptr<Context>, std::shared_ptr<Global::Resource::ResourceManager>> ignoreContext_;
64 };
65 } // namespace AbilityRuntime
66 } // namespace OHOS
67 #endif