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 #include <vector> 19 #include "locale_info.h" 20 #include "res_common.h" 21 #include "rstate.h" 22 23 using OHOS::I18N::LocaleInfo; 24 namespace OHOS { 25 namespace Global { 26 namespace Resource { 27 class ResConfig { 28 public: 29 virtual RState SetLocaleInfo(const char *language, const char *script, const char *region) = 0; 30 31 virtual RState SetLocaleInfo(LocaleInfo &localeInfo) = 0; 32 33 virtual void SetDeviceType(DeviceType deviceType) = 0; 34 35 virtual void SetDirection(Direction direction) = 0; 36 37 virtual void SetScreenDensity(ScreenDensity screenDensity) = 0; 38 39 virtual const LocaleInfo *GetLocaleInfo() const = 0; 40 41 virtual Direction GetDirection() const = 0; 42 43 virtual ScreenDensity GetScreenDensity() const = 0; 44 45 virtual DeviceType GetDeviceType() const = 0; 46 47 virtual bool Copy(ResConfig &other) = 0; 48 ~ResConfig()49 virtual ~ResConfig() {} 50 }; 51 52 ResConfig *CreateResConfig(); 53 54 const LocaleInfo *GetSysDefault(); 55 56 void UpdateSysDefault(const LocaleInfo &localeInfo, bool needNotify); 57 58 LocaleInfo *BuildFromString(const char *str, char sep, RState &rState); 59 60 LocaleInfo *BuildFromParts(const char *language, const char *script, const char *region, RState &rState); 61 62 void FindAndSort(const std::string localeStr, std::vector<std::string> &candidateLocale, 63 std::vector<std::string> &outValue); 64 } // namespace Resource 65 } // namespace Global 66 } // namespace OHOS 67 #endif