• 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 #ifdef SUPPORT_GRAPHICS
51     virtual const Locale *GetLocaleInfo() const = 0;
52 #endif
53 
54     virtual Direction GetDirection() const = 0;
55 
56     virtual float GetScreenDensity() const = 0;
57 
58     virtual DeviceType GetDeviceType() const = 0;
59 
60     virtual ColorMode GetColorMode() const = 0;
61 
62     virtual uint32_t GetMcc() const = 0;
63 
64     virtual uint32_t GetMnc() const = 0;
65 
66     virtual bool Copy(ResConfig &other) = 0;
67 
68     virtual void SetInputDevice(InputDevice inputDevice) = 0;
69 
70     virtual InputDevice GetInputDevice() const = 0;
71 
72     virtual ScreenDensity ConvertDensity(float density) = 0;
73 
~ResConfig()74     virtual ~ResConfig() {}
75 };
76 
77 EXPORT_FUNC ResConfig *CreateResConfig();
78 
79 #ifdef SUPPORT_GRAPHICS
80 EXPORT_FUNC const Locale *GetSysDefault();
81 
82 EXPORT_FUNC void UpdateSysDefault(const Locale &localeInfo, bool needNotify);
83 
84 EXPORT_FUNC Locale *BuildFromString(const char *str, char sep, RState &rState);
85 
86 EXPORT_FUNC Locale *BuildFromParts(const char *language, const char *script, const char *region, RState &rState);
87 #endif
88 
89 void FindAndSort(const std::string localeStr, std::vector<std::string> &candidateLocale,
90     std::vector<std::string> &outValue);
91 } // namespace Resource
92 } // namespace Global
93 } // namespace OHOS
94 #endif