• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 #ifndef OHOS_RESOURCE_MANAGER_RESCONFIG_H
16 #define OHOS_RESOURCE_MANAGER_RESCONFIG_H
17 
18 #ifdef SUPPORT_GRAPHICS
19 #include <unicode/locid.h>
20 #endif
21 #include <vector>
22 #include "res_common.h"
23 #include "rstate.h"
24 #ifdef SUPPORT_GRAPHICS
25 using icu::Locale;
26 #endif
27 namespace OHOS {
28 namespace Global {
29 namespace Resource {
30 class ResConfig {
31 public:
32     virtual RState SetLocaleInfo(const char *language, const char *script, const char *region) = 0;
33 
34 #ifdef SUPPORT_GRAPHICS
35     virtual RState SetLocaleInfo(Locale &localeInfo) = 0;
36 #endif
37 
38     virtual void SetDeviceType(DeviceType deviceType) = 0;
39 
40     virtual void SetDirection(Direction direction) = 0;
41 
42     virtual void SetScreenDensity(float screenDensity) = 0;
43 
44     virtual void SetColorMode(ColorMode colorMode) = 0;
45 
46     virtual void SetMcc(uint32_t mcc) = 0;
47 
48     virtual void SetMnc(uint32_t mnc) = 0;
49 
50     virtual void SetThemeId(uint32_t themeId) = 0;
51 
52     virtual void SetThemeIcon(bool isIcon) = 0;
53 
54 #ifdef SUPPORT_GRAPHICS
55     virtual const Locale *GetLocaleInfo() const = 0;
56 #endif
57 
58     virtual Direction GetDirection() const = 0;
59 
60     virtual float GetScreenDensity() const = 0;
61 
62     virtual DeviceType GetDeviceType() const = 0;
63 
64     virtual ColorMode GetColorMode() const = 0;
65 
66     virtual uint32_t GetMcc() const = 0;
67 
68     virtual uint32_t GetMnc() const = 0;
69 
70     virtual uint32_t GetThemeId() const = 0;
71 
72     virtual bool GetThemeIcon() const = 0;
73 
74     virtual bool Copy(ResConfig &other, bool isRead = false) = 0;
75 
76     virtual void SetInputDevice(InputDevice inputDevice) = 0;
77 
78     virtual InputDevice GetInputDevice() const = 0;
79 
80     virtual ScreenDensity ConvertDensity(float density) = 0;
81 
~ResConfig()82     virtual ~ResConfig() {}
83 
84 #ifdef SUPPORT_GRAPHICS
85     virtual const Locale *GetPreferredLocaleInfo() const = 0;
86 
87     virtual RState SetPreferredLocaleInfo(Locale &preferredLocaleInfo) = 0;
88 #endif
89 
90     virtual void SetScreenDensityDpi(ScreenDensity screenDensityDpi) = 0;
91 
92     virtual RState SetLocaleInfo(const char *localeStr) = 0;
93 
94     virtual ScreenDensity GetScreenDensityDpi() const = 0;
95 
96     virtual void SetAppColorMode(bool isAppColorMode) = 0;
97 
98     virtual bool GetAppColorMode() const = 0;
99 
100     virtual bool GetAppDarkRes() const = 0;
101 };
102 
103 EXPORT_FUNC ResConfig *CreateResConfig();
104 
105 EXPORT_FUNC ResConfig *CreateDefaultResConfig();
106 
107 #ifdef SUPPORT_GRAPHICS
108 EXPORT_FUNC const Locale *GetSysDefault();
109 
110 EXPORT_FUNC void UpdateSysDefault(const Locale &localeInfo, bool needNotify);
111 
112 EXPORT_FUNC Locale *BuildFromString(const char *str, char sep, RState &rState);
113 
114 EXPORT_FUNC Locale *BuildFromParts(const char *language, const char *script, const char *region, RState &rState);
115 #endif
116 
117 void FindAndSort(const std::string localeStr, std::vector<std::string> &candidateLocale,
118     std::vector<std::string> &outValue);
119 } // namespace Resource
120 } // namespace Global
121 } // namespace OHOS
122 #endif