Resource configuration method and device, electronic equipment and readable storage medium
Obtaining adapted resources by generating resource identifiers solves the problem of cumbersome resource settings for different electronic devices, improves application development efficiency and ensures interface adaptation.
Patent Information
- Application Number
- CN202411553034.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-01
- Publication Date
- 2025-01-24
AI Technical Summary
When developing applications, different resource codes need to be set for multiple resources of different electronic devices, resulting in cumbersome code settings and reducing application development efficiency.
By obtaining the default resource identifier in the application and the information of the electronic device, the resource identifier is generated, thereby obtaining the adapted resource in the resource library, and directly configuring the resource for the application to avoid setting multiple resource codes.
The application development process is simplified, the development efficiency is improved, and the application interface is adapted to the electronic device without modifying the logic of the original code.
Smart Images

Figure CN119356759A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the technical field of electronic equipment, and specifically relates to a resource configuration method, device, electronic equipment and readable storage medium. Background Art
[0002] With the development of electronic devices, the brands, models, operating systems, resolutions, screen types, screen sizes, screen densities, split-screen states, etc. of different electronic devices may be different. Therefore, in the process of developing an application, the resources of the application are usually differentiated from dimensions such as screen density, screen resolution, system version, and screen orientation so that the resources of the application can adapt to different electronic devices.
[0003] In the related art, when using the resources of the same application on two different models with the same screen density, screen resolution, system version and screen orientation, different resources can be adapted to the two models respectively by setting different resource codes.
[0004] However, if there are multiple different resources when these two models use the resources of the same application, then different resource codes need to be set for each of the multiple resources to adapt different resources for the two models. This makes the code setting process cumbersome and reduces the efficiency of application development. Summary of the invention
[0005] The purpose of the embodiments of the present application is to provide a resource configuration method, device, electronic device and readable storage medium, which can improve application development efficiency.
[0006] In a first aspect, an embodiment of the present application provides a resource configuration method, the method comprising:
[0007] Obtain a default resource identifier of a first category of resources in a first application and at least one information of an electronic device, wherein each of the at least one information represents the electronic device from one dimension; generate a first resource identifier based on the default resource identifier and the at least one information; based on the first resource identifier, obtain a first resource indicated by the first resource identifier in a first resource library corresponding to the first category of resources, and configure the first resource for the first application, wherein the first resource library includes multiple resources corresponding to the first category of resources and a resource identifier for each resource.
[0008] In a second aspect, an embodiment of the present application provides a resource configuration device, which includes an acquisition module and an execution module. The acquisition module is used to obtain a default resource identifier of a first category of resources in a first application and at least one information of an electronic device, each of the at least one information representing the electronic device from one dimension. The execution module is used to generate a first resource identifier based on the default resource identifier and the at least one information. The acquisition module is also used to obtain, based on the first resource identifier, a first resource indicated by the first resource identifier in a first resource library corresponding to the first category of resources, and configure the first resource for the first application, the first resource library including multiple resources corresponding to the first category of resources and a resource identifier of each resource.
[0009] In a third aspect, an embodiment of the present application provides an electronic device, which includes a processor and a memory, wherein the memory stores programs or instructions that can be run on the processor, and when the program or instructions are executed by the processor, the steps of the resource configuration method described in the first aspect are implemented.
[0010] In a fourth aspect, an embodiment of the present application provides a readable storage medium, on which a program or instruction is stored, and when the program or instruction is executed by a processor, the steps of the resource configuration method described in the first aspect are implemented.
[0011] In a fifth aspect, an embodiment of the present application provides a chip, comprising a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run a program or instruction to implement the resource configuration method as described in the first aspect.
[0012] In a sixth aspect, an embodiment of the present application provides a computer program product, which is stored in a storage medium and is executed by at least one processor to implement the resource configuration method as described in the first aspect.
[0013] In an embodiment of the present application, a default resource identifier of a first type of resource in a first application and at least one information of an electronic device are obtained, each of the at least one information characterizes the electronic device from one dimension; a first resource identifier is generated according to the default resource identifier and at least one information; based on the first resource identifier, a first resource indicated by the first resource identifier is obtained in a first resource library corresponding to the first type of resource, and the first resource is configured for the first application, the first resource library includes multiple resources corresponding to the first type of resource and a resource identifier of each resource. That is to say, when the electronic device runs the first application, the first resource identifier of the resource of the first application required by the electronic device is generated according to the default resource identifier and the information characterizing the electronic device from different dimensions. The first resource identifier can not only indicate the resource but also characterize the electronic device, which is related to the characteristics of the electronic device. Then, the resource indicated by the first resource identifier is obtained from the first resource library corresponding to the first type of resource. Then, the resource is adapted to the electronic device. After configuring the resource for the first application, the first application loads and displays the application interface on the electronic device based on the resource. Then, the application interface is also adapted to the electronic device. In this way, by combining the information of the electronic device based on the default resource identifier, the resources of the first application adapted to the electronic device can be obtained. There is no need to set different resource codes for each resource, that is, there is no need to modify the original code logic, which simplifies the application development process and improves application development efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0014] Figure 1 This is one of the flowcharts of the resource configuration method provided in the embodiment of the present application;
[0015] Figure 2 This is the second flow chart of the resource configuration method provided in the embodiment of the present application;
[0016] Figure 3 This is the third flow chart of the resource configuration method provided in the embodiment of the present application;
[0017] Figure 4 This is the fourth flowchart of the resource configuration method provided in the embodiment of the present application;
[0018] Figure 5 This is the fifth flow chart of the resource configuration method provided in the embodiment of the present application;
[0019] Figure 6 This is the sixth flowchart of the resource configuration method provided in the embodiment of the present application;
[0020] Figure 7 is a schematic diagram of a visual design diagram provided in an embodiment of the present application;
[0021] Figure 8is a schematic diagram of a background image provided by an embodiment of the present application;
[0022] Fig. 9 is a schematic diagram of the structure of a resource configuration device provided in an embodiment of the present application;
[0023] Fig.10 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application;
[0024] Fig.11 It is a schematic diagram of the hardware structure of the electronic device provided in the embodiment of the present application. DETAILED DESCRIPTION
[0025] The following will be combined with the drawings in the embodiments of the present application to clearly describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments in the present application belong to the scope of protection of this application.
[0026] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.
[0027] The terms "at least one (item)", "at least one of" and the like in the specification and claims of the present application refer to any one, any two or a combination of more than two of the objects included therein. For example, at least one (item) of a, b, and c can be represented by: "a", "b", "c", "a and b", "a and c", "b and c" and "a, b and c", where a, b, and c can be single or multiple. Similarly, "at least two (items)" refers to two or more, and its meaning is similar to that of "at least one (item)".
[0028] The resource configuration method, device, electronic device and readable storage medium provided in the embodiments of the present application are described in detail below with reference to the accompanying drawings through specific embodiments and their application scenarios.
[0029] The resource configuration method provided in the embodiment of the present application can be applied to the scenario of running applications on an electronic device.
[0030] Electronic devices on the market have different screen resolutions, different screen sizes, different operating system versions, different models such as mobile phones, folding screens, watches, car computers, etc., different screens such as large folding (Fold), small folding (Flip), etc. In order to achieve better display effects, user interface (UI) designers will require different effects to be presented on electronic devices with different dimensions of information. Therefore, when these electronic devices run the same application, they need to obtain different resources of the application.
[0031] To this end, an embodiment of the present application provides a resource configuration method, in which an electronic device obtains a default resource identifier of a first type of resource in a first application and at least one information of the electronic device; then generates a first resource identifier based on the default resource identifier and at least one information; then based on the first resource identifier, obtains the first resource indicated by the first resource identifier in the first resource library corresponding to the first type of resource, and configures the first resource for the first application. That is to say, when the electronic device runs the first application, this scheme generates a first resource identifier of the resource of the first application required by the electronic device based on the default resource identifier and information representing the electronic device from different dimensions. The first resource identifier can not only indicate the resource but also represent the electronic device, which is related to the characteristics of the electronic device. Then, the resource indicated by the first resource identifier is obtained from the first resource library corresponding to the first type of resource. The resource is adapted to the electronic device. After configuring the resource for the first application, the first application loads and displays the application interface on the electronic device based on the resource. The application interface is also adapted to the electronic device. In this way, by combining the information of the electronic device with the default resource identifier, it is possible to obtain resources that are compatible with the electronic device for any application. There is no need to set different resource codes for each resource, that is, there is no need to set a large number of resource codes, which simplifies the application development process and improves application development efficiency.
[0032] The execution subject of the resource configuration method provided in the embodiment of the present application may be a resource configuration device. Exemplarily, the resource configuration device may be an electronic device, or a functional component or functional entity in the electronic device. The resource configuration method provided in the embodiment of the present application will be exemplarily described below by taking the execution subject as an electronic device as an example.
[0033] Figure 1 is a flow chart of the resource configuration method provided in the embodiment of the present application, such as Figure 1 As shown, the resource configuration method provided in the embodiment of the present application may include the following steps 101 to 103.
[0034] Step 101: An electronic device obtains a default resource identifier of a first type of resource in a first application and at least one information of the electronic device.
[0035] In the embodiment of the present application, the first application may be any application or software (Application, APP) that can be installed and used in the electronic device. For example, the first application may be social software, video software, music software, etc.
[0036] In the embodiment of the present application, the first type of resources may be any form of resources related to the first application. The first type of resources may include any of the following: application running code files, application resource values, application resource files, and application original files.
[0037] Optionally, in an embodiment of the present application, the running code file of the above-mentioned application can be a code file executed when the application is running, and can be written by a developer.
[0038] Optionally, in an embodiment of the present application, the resource value of the above-mentioned application can be various forms of resource values used by the application stored in the values folder, and the various forms include but are not limited to dimensions (dimens), colors (colors), strings (strings), themes (themes) and styles (styles).
[0039] Exemplarily, the various forms of resource values mentioned above usually exist in the form of XML files, and the various forms of resource values mentioned above may include but are not limited to strings (strings.xml), color values (colors.xml), dimension values (dimens.xml), styles (styles.xml), array constants (arrays.xml), integer constants (integers.xml) and Boolean constants (bools.xml).
[0040] Optionally, in an embodiment of the present application, the resource files of the above-mentioned application are various resource files required by the application stored in the res folder, and the resource files may include but are not limited to layout files (layout), image files (drawable), animation files (anim), menu files (menu), resource values (values) and startup icons (mipmap).
[0041] Optionally, in the embodiment of the present application, the original files of the above application are original files required by the application stored in the assets folder. The original files may include but are not limited to Hyper Text Markup Language (HTML), Cascading Style Sheets (CSS), JavaScript files, audio and video files, and database files.
[0042] In the embodiment of the present application, the above-mentioned default resource identifier can be any identifier that can uniquely indicate the first type of resource, such as a resource name, a resource number, etc. Moreover, the default resource identifier can be represented in any form such as letters, numbers, symbols, and text.
[0043] For example, assuming that the first type of resource is an image file (drawable), the default resource identifier may be the name of the image file app_drawable. Assuming that the first type of resource is a color (colors), the default resource identifier may be app_colors. Assuming that the first type of resource is a background image (background), and the background image may be an image in a format such as png, jpg, or webp, the default resource identifier may be the name of the background image app_background.
[0044] Optionally, in an embodiment of the present application, in the above step 101, "the electronic device obtains the default resource identifier of the first category of resources in the first application" can be specifically implemented by the following steps 1011 and 1012.
[0045] Step 1011: The electronic device obtains a default resource identifier of a first format for a first category of resources.
[0046] Optionally, in an embodiment of the present application, the default resource identifier in the first format may be a digital identifier (Identity, ID), and the digital identifier may be a binary digital ID, a decimal digital ID, an octal digital ID, or a hexadecimal digital ID, etc. For example, the default resource identifier in the first format may be a hexadecimal digital ID "EE093F".
[0047] Step 1012: The electronic device converts the default resource identifier in the first format into a default resource identifier in the second format.
[0048] Optionally, in an embodiment of the present application, the default resource identifier in the second format may be a resource name expressed in words.
[0049] For example, the default resource identifier in the second format may be the resource name app_color.
[0050] Optionally, in an embodiment of the present application, during the process of developing an application, when setting the resources of the application in the form of an XML layout file, the default resource identifier in the second format, such as the resource name, is written during the development code, and there is a corresponding relationship between the resource and the resource name, but when the code is compiled into an application, all the default resource identifiers in the second format are converted to the default resource identifiers in the first format, such as a digital ID. Therefore, when the electronic device runs the first application and needs to use the first type of resource, the default resource identifier in the first format of the first type of resource can be obtained first, and then the default resource identifier in the first format is converted to the default resource identifier in the second format according to the preset mapping relationship between the first format and the second format.
[0051] In this way, when the first type of resources are needed, although the electronic device obtains the default resource identifier in the first format, it can convert it into the default resource identifier in the second format so that the required resources can be obtained according to the default resource identifier in the second format, thereby improving the efficiency of obtaining resources.
[0052] In the embodiment of the present application, each of the at least one information characterizes the electronic device from one dimension, that is, each of the at least one information characterizes the characteristics of the electronic device in different dimensions. It can be understood that if the number of the at least one information is at least two, the at least two information characterizes the electronic device from different dimensions.
[0053] Optionally, in an embodiment of the present application, each of the at least one information mentioned above may include any one of the following: model information, system version information, split-screen status information, brand information, model series information, horizontal and vertical screen status information, small window status information, and machine information.
[0054] Optionally, in an embodiment of the present application, the above-mentioned model information can be used to indicate the model of the electronic device, and the model information can include a tablet computer (portable Android device, Pad) model, a small folding (Flip) model, a large folding (Fold) model, and the like.
[0055] Optionally, in an embodiment of the present application, the above-mentioned system version information can be used to indicate the version of the operating system (OS) of the electronic device, and the system version information can include OS6.0 system, OS5.0 system, OS4.0 system, etc.
[0056] Optionally, in an embodiment of the present application, the above-mentioned split-screen status information can be used to indicate the split-screen status of the electronic device, and the split-screen status information may include split screen, left-right split screen, top-bottom split screen, and the like.
[0057] Optionally, in an embodiment of the present application, the above brand information may be used to indicate the brand of the electronic device, and the brand information may include brand V, brand O, brand M, and the like.
[0058] Optionally, in an embodiment of the present application, the above-mentioned model series information can be used to indicate the model of the electronic device or the version of the model to which it belongs. The model series information can include series such as O series, S series, Y series, and versions of each series (such as O8, O9), etc.
[0059] Optionally, in an embodiment of the present application, the above-mentioned horizontal and vertical screen status information can be used to indicate whether the application is displayed in horizontal or vertical screen, and the horizontal screen status information can include horizontal screen or vertical screen.
[0060] Optionally, in an embodiment of the present application, the above-mentioned small window status information can be used to indicate that the application is displayed in the form of a small window in the electronic device, and the small window status information may include a small window or a floating window.
[0061] Optionally, in an embodiment of the present application, the above-mentioned machine information can be used to indicate the model of the electronic device, and the machine information can include PD2178 machine, PD2307 machine, and so on.
[0062] For example, assuming that the first application is running on an electronic device of an S series Flip model PD2333 machine OS6.0 system, the at least one information obtained about the electronic device may include model series information "S series", model information "Flip model", machine information "PD2333 machine" and system version information "OS6.0 system".
[0063] It should be noted that the above is only an exemplary description of at least one information. With the development of electronic technology, the above at least one information may also include information of other dimensions of the electronic device, which can be determined according to actual needs, and the embodiments of the present application do not limit this.
[0064] Step 102: The electronic device generates a first resource identifier according to a default resource identifier and at least one information.
[0065] Optionally, in the embodiment of the present application, combined with Figure 1 ,like Figure 2 As shown, the above step 102 can be specifically implemented through the following step 1021.
[0066] Step 1021: The electronic device combines at least one information with a default resource identifier to generate a first resource identifier.
[0067] Optionally, in an embodiment of the present application, the electronic device may splice at least one information before or after a default resource identifier, that is, splice each of the at least one information before the default resource identifier, or splice each of the at least one information after the default resource identifier.
[0068] Next, taking the default resource identifier app_background as an example, the process of generating a first resource identifier by splicing any information of the electronic device after the default resource identifier is explained.
[0069] Exemplarily, when information of an electronic device includes model information, if the model information is a Pad model, app_background is concatenated with Pad to generate a first resource identifier app_background_pad; if the model information is a Fold model, app_background is concatenated with Fold to generate a first resource identifier app_background_fold.
[0070] When one piece of information of the electronic device includes system version information, if the system version information is OS4.0 system, app_background and os4_0 are concatenated to generate the first resource identifier app_background_os4_0; if the system version information is OS5.0 system, app_background and os5_0 are concatenated to generate the first resource identifier app_background_os5_0.
[0071] In the case that one piece of information of the electronic device includes split-screen status information, if the allocated status information is split-screen, app_background is concatenated with split to generate a first resource identifier app_background_split.
[0072] In the case that one piece of information of the electronic device includes brand information, if the brand information is v, app_background is concatenated with v to generate a first resource identifier app_background_v; if the brand information is O, app_background is concatenated with O to generate a first resource identifier app_background_o.
[0073] When information of an electronic device includes model series information, if the model series information is O series, app_background is concatenated with O to generate a first resource identifier app_background_o; if the model series information is S series, app_background is concatenated with S to generate a first resource identifier app_background_s.
[0074] Optionally, in the embodiment of the present application, combined with Figure 2 ,like Figure 3 As shown, the above step 1021 can be specifically implemented through the following steps 10211.
[0075] Step 10211: The electronic device sequentially concatenates each information in the at least one information with the default resource identifier according to the priority of each information to generate a first resource identifier.
[0076] It should be noted that the higher the priority of a piece of information, the greater the probability that different electronic devices with the same piece of information will use different resources when running the same application. It can be understood that when developing an application, in most cases, different resources need to be configured for the same application based on the information. In addition, the priority of each of the above information can be set according to actual business needs or developer experience.
[0077] Optionally, in an embodiment of the present application, when the number of at least one information is one, the electronic device may directly splice the one information before or after the default resource identifier to generate a first resource identifier.
[0078] Optionally, in an embodiment of the present application, when the number of at least one information is multiple (including two or more), the electronic device can sort the multiple information in order of priority from high to low, and then sequentially splice the multiple information with the default resource identifier, and the information adjacent to the default resource identifier after splicing is the information with the highest or lowest priority.
[0079] Exemplarily, assume that at least one information of the electronic device includes split, OS6.0 system, Fold model, S series and PD2307 machine, the default resource identifier is app_background, and the priority of at least one information of the electronic device is split screen status information> system version information> machine information> model information> model series information. The electronic device can sort the above five information in order of priority from high to low, and the sorting result is split, OS6.0 system, PD2307 machine, Fold model, S series, and then splice the above five information to the default resource identifier in sequence according to the sorting result to obtain the first resource identifier app_background_split_os6_0_PD2307_fold_s. Alternatively, the electronic device can sort the above five information in order of priority from low to high, and the sorting result is S series, Fold model, PD2307 machine, OS6.0 system, split, and then splice the above five information into the default resource identifier in sequence according to the sorting result to obtain the first resource identifier app_background_s_fold_PD2307_os6_0_split.
[0080] In an embodiment of the present application, after the electronic device concatenates at least one information with a default resource identifier, the first resource identifier obtained can represent the characteristics of the electronic device in different dimensions, and the resources obtained based on the first resource identifier can be adapted to the electronic device.
[0081] Furthermore, in order to provide a richer experience, different resources used by the application when running in different time periods can be set when developing the application. When the electronic device runs the application, the resources adapted to the electronic device can be obtained according to the time period information.
[0082] Optionally, in an embodiment of the present application, before the above step 102, the resource configuration method provided in the embodiment of the present application may further include the following step 100, and the above step 102 may be specifically implemented by the following step 1022.
[0083] Step 100: The electronic device obtains information about the current time period.
[0084] Step 1022: The electronic device generates a first resource identifier according to the default resource identifier, at least one information and time period information.
[0085] Optionally, in an embodiment of the present application, the electronic device may concatenate at least one information and the time period information with a default resource identifier to generate a first resource identifier.
[0086] In an example of the present application, the electronic device may first splice at least one information and the time period information into an information group, and then splice the information group before or after the default resource identifier.
[0087] Exemplarily, the electronic device may splice the time period information after the last information in the at least one information to obtain an information group. Alternatively, the electronic device may splice the time period information before the first information in the at least one information to obtain an information group. Alternatively, the electronic device may set a priority for the time period information, and splice the time period information with the at least one information in a descending order or a descending order according to the priority of the time period information and the priority of each information in the at least one information to obtain a group of information.
[0088] In another example of the present application, the electronic device can splice each information in the at least one information before the default resource identifier, and splice the time period information after the default resource identifier to generate a first resource identifier. Alternatively, the electronic device can splice each information in the at least one information after the default resource identifier, and splice the time period information before the default resource identifier to generate a first resource identifier.
[0089] It should be noted that the specific implementation of the electronic device splicing at least one information and time period information with the default resource identifier can be found in the relevant description of the above steps 1021 and 1022, and the embodiments of the present application will not be repeated here.
[0090] In an embodiment of the present application, when the electronic device acquires resources used to run the first application, it not only combines at least one information of the electronic device, but also combines the time period information, so that the resources acquired by the electronic device are not only adapted to the electronic device, but also to the actual environment, thereby improving the flexibility and accuracy of resource acquisition.
[0091] Step 103: Based on the first resource identifier, the electronic device obtains a first resource indicated by the first resource identifier from a first resource library corresponding to the first type of resources, and configures the first resource for the first application.
[0092] It should be noted that whether there are differences in the resources obtained when running the first application on different electronic devices is determined based on the user effect, the resources provided by the UI designer, and the convenience of development. It does not necessarily mean that the resources are different on different electronic devices. The first category of resources may be the same, and other categories of resources may be different. Therefore, the electronic device can search for resources from the first resource library corresponding to the first category of resources based on the first resource identifier obtained after splicing.
[0093] For example, assuming that the default resource identifier before splicing is app_background, and the first resource identifier obtained after splicing is app_background_s, and these two resources are different background images, the electronic device searches for resources according to app_background_s.
[0094] In the embodiment of the present application, the first resource library includes multiple resources corresponding to the first type of resources and resource identifiers of each resource. The multiple resources corresponding to the first type of resources may be different resources set by developers for different electronic devices according to information of the electronic devices in different dimensions during application development.
[0095] Optionally, in an embodiment of the present application, in the above-mentioned first resource library, multiple sub-resource libraries can also be divided according to information such as screen resolution, screen density, screen size, etc. that are not included in the above-mentioned at least one information, and the electronic device can obtain the first resource from the corresponding sub-resource library based on the first resource identifier and other information of the electronic device except at least one information. That is to say, in the case of determining that the first resource exists, the electronic device can call the native resource matching logic to obtain the first resource from the first resource library. For example, assuming that the screen resolution of the electronic device is xhdpi, the first resource can be obtained from the sub-resource library corresponding to xhdpi in the first resource library. In this way, the resource configuration method provided in the embodiment of the present application does not modify the native resource matching logic, but adds a new resource matching logic to some resources on the native resource matching logic, that is, splicing the default resource identifier and at least one information to obtain the first resource identifier, and then obtaining the logic of the first resource according to the first resource identifier, which will not affect the original code logic, nor will it affect the already developed business.
[0096] Exemplarily, taking the first resource identifier app_background_o9 as an example, the electronic device can first determine the second resource identifier that is the same as the first resource identifier in the first resource library. If in the first resource library, the sub-resource library corresponding to the screen resolution xhdpi includes the second resource identifier, and the sub-resource library corresponding to the screen resolution xxhdpi also includes the second resource identifier, assuming that the screen resolution of the electronic device is xhdpi, the electronic device can obtain the resource indicated by the second resource identifier from the sub-resource library corresponding to the screen resolution xxhdpi, and use the resource as the first resource.
[0097] In some embodiments of the present application, after the electronic device obtains the first resource, the first resource can be configured for the first application, that is, the first application can generate and display an application interface based on the first resource, and the displayed application interface is adapted to the electronic device.
[0098] Optionally, in an embodiment of the present application, the first resource may include at least one of the following: an application running code file, an application resource value, an application resource file, and an application original file.
[0099] It should be noted that the first resource is of the same type as the first category of resources, such as background images, but the first category of resources refers to background images, which may include multiple different background images, and the first resource can be understood as one of the multiple different background images. In addition, the relevant explanations of the running code files of the above-mentioned application, the resource values of the application, the resource files of the application, and the original files of the application can all be found in the relevant description of step 101 in the above-mentioned embodiment, and the embodiments of this application will not be repeated here.
[0100] Optionally, in the embodiment of the present application, combined with Figure 1 ,like Figure 4 As shown, the above step 103 can be specifically implemented through the following steps 1031 and 1032.
[0101] Step 1031: Based on the first resource identifier, the electronic device searches for a resource identifier identical to the first resource identifier in a first resource library.
[0102] Step 1032: If a second resource identifier that is identical to the first resource identifier is found, the electronic device determines the resource indicated by the second resource identifier as the first resource, and configures the first resource for the first application.
[0103] Optionally, in an embodiment of the present application, the first resource library includes multiple resources and a resource identifier of each resource, and the electronic device can search the first resource library for a resource identifier that is identical to the first resource identifier. If there is a resource identifier that is identical to the first resource identifier, the resource identifier is called the second resource identifier, and then the resource indicated by the second resource identifier is obtained, and the obtained resource is determined as the above-mentioned first resource.
[0104] Exemplarily, assuming that the resource that the electronic device needs to obtain is a background image, the first resource identifier is app_background_s_psd, and there is a second resource identifier that is identical to the first resource identifier in the background image library (the above-mentioned first resource library), then the background image indicated by the second resource identifier is determined as the background image (the above-mentioned first resource) that the first application needs to obtain and display.
[0105] Optionally, in the embodiment of the present application, combined with Figure 1 ,like Figure 4 As shown, after the above step 1031, the resource configuration method provided in the embodiment of the present application may further include the following steps 1033 and 1034.
[0106] Step 1033: If a resource identifier identical to the first resource identifier is not found, the electronic device deletes M pieces of information from at least one piece of information spliced in the first resource identifier to obtain a third resource identifier.
[0107] In the embodiment of the present application, M is an integer greater than 0, and the M values can be set according to actual business needs or based on experience.
[0108] Optionally, in an embodiment of the present application, if there is no resource identifier identical to the first resource identifier in the first resource library, it means that all electronic devices use the same resources under certain dimensions in the first resource identifier, and the developer has not set specific resources for the first resource identifier. Then, the electronic device can delete the information of some dimensions spliced in the first resource identifier to obtain a third resource identifier.
[0109] Optionally, in the embodiment of the present application, combined with Figure 4 ,like Figure 5 As shown, in the above step 1033, "the electronic device deletes M pieces of information among the at least one piece of information spliced in the first resource identifier" can be specifically implemented through the following step 10331.
[0110] Step 10331: The electronic device deletes M pieces of information from the at least one piece of information spliced in the first resource identifier according to the priority of each piece of information in the at least one piece of information.
[0111] Optionally, in an embodiment of the present application, the electronic device may delete M pieces of information from at least one piece of information spliced in the first resource identifier according to the priority of each piece of information and in order of priority from low to high.
[0112] Exemplarily, the electronic device may delete one piece of spliced information in the first resource identifier at one time, or the electronic device may delete two or more pieces of information in the first resource identifier at one time. The specific amount may be determined based on actual business needs, and the embodiments of the present application do not limit this.
[0113] For example, assuming that the first resource identifier is app_background_split_os6_0_PD2307_fold_s, and the priority of the five information spliced in the first resource identifier is split screen status information>system version information>machine information>model information>model series information, then the electronic device can delete the model series information s in the first resource identifier to obtain the third resource identifier app_background_split_os6_0_PD2307_fold. Alternatively, the electronic device can also delete the model series information s and the model information fold in the first resource identifier to obtain the third resource identifier app_background_split_os6_0_PD2307.
[0114] Step 1034: The electronic device determines the resource indicated by the third resource identifier in the first resource library as the first resource, and configures the first resource for the first application.
[0115] Optionally, in an embodiment of the present application, the electronic device may search for a resource identifier that is identical to the third resource identifier in the first resource library. If a fourth resource identifier that is identical to the third resource identifier is found, the resource indicated by the fourth resource identifier is determined as the first resource; if a resource identifier that is identical to the third resource identifier is not found, the electronic device continues to delete M pieces of information from at least one piece of information spliced in the third resource identifier, and then determines the first resource from the first resource library based on the modified resource identifier until the first resource is acquired.
[0116] For example, taking the default resource identifier as app_background, assuming that the UI designer requires the same resources in split-screen state and non-split-screen state (that is, using the same background image) to achieve the desired visual effect, the resources are the same in Fold model electronic devices and ordinary electronic devices (that is, using the same background image), and the resources are different only in electronic devices of different model series (that is, using different background images). Then, in the application development stage, the developer can set the default resource identifier to app_background, and the resource identifier of the resources used by the S series electronic devices is app_background_s. Assuming that the above-mentioned electronic device uses an S series folding screen, the above-mentioned first resource identifier is app_background_s_fold. Because the Fold model electronic device has the same resources as other models of electronic devices, and there is no resource indicated by the built-in resource identifier app_background_s_fold during the development process, the electronic device cannot find the same resource identifier as the first resource identifier. The electronic device then deletes the spliced model information fold in the first resource identifier to obtain the third resource identifier app_background_s. The development stage just happens to set the correspondence between the resource identifier app_background_s and the resources in the split-screen state designed by the UI designer. Therefore, the electronic device can obtain the resource corresponding to app_background_s as the above-mentioned first resource.
[0117] In an embodiment of the present application, if the electronic device fails to find a resource identifier that is identical to the first resource identifier, it can delete the information of some dimensions spliced in the first resource identifier, and then continue to search for the first resource based on the third resource identifier obtained after deleting the information of some dimensions. In this way, resources that meet the specific conditions of the electronic device in each dimension can be found, that is, resources that are adapted to the electronic device can be found, thereby improving the accuracy of resource acquisition.
[0118] It should be noted that the above embodiment describes the implementation process of the electronic device acquiring resources when the first application is running on the electronic device, which belongs to the application running stage. Next, the implementation process of the application development stage is described.
[0119] Optionally, in an embodiment of the present application, developers can choose whether to use the automatic resource matching function according to the business situation of the application during the process of developing the application. For example, whether to use the automatic resource matching function is determined based on whether different resources need to be used in different models, different split-screen states, different brands, different machines, and other scenarios. If the automatic resource matching function is used, the developer customizes the resource identifier of the resource designed by the UI designer according to business needs, and stores the resource identifier in the resource library of the corresponding resource; if the automatic resource matching function is not used, the native resource matching logic is directly called.
[0120] Exemplarily, the above-mentioned native resource matching logic includes: developers can create different resource folders according to different screen densities (dpi), different minimum screen widths (sw), different screen widths (w), different screen heights (h), different Android versions, and different screen states, and the resource names under different resource folders are the same, and the resource names under the same resource folder are different. During the application development process, when setting resources in the form of an xml layout file, the resource identifier (such as the resource name) in the second format is written during the development coding, but when the code is compiled into an application, all resource identifiers in the second format are converted into corresponding resource identifiers in the first format (such as hexadecimal digital IDs). When the application is running on an electronic device, the electronic device will automatically load the resources under the corresponding resource folder according to the hexadecimal digital ID and the status of the electronic device, screen information, Android version, etc.
[0121] It should be noted that the above-mentioned resource automatic matching function is the logic of the resource configuration method provided in the embodiment of the present application, that is, the electronic device can splice at least one information of the electronic device into the default resource identifier to obtain the first resource identifier, and search for the corresponding resource according to the first resource identifier. In addition, the resource automatic matching function is an optimization function for the native resource matching logic, and the native resource matching logic is not modified. Therefore, this function has no effect on the original code logic. Developers can use the resource automatic matching function only for part of the development code according to the business development status, which has no effect on the already developed business.
[0122] Optionally, in an embodiment of the present application, Table 1 shows the resource names of resources set by developers in the process of developing an application and a description of the resources corresponding to each resource name.
[0123] Table 1
[0124]
[0125]
[0126] The resource configuration method provided in the embodiment of the present application adds logic for adapting resources for electronic devices according to information of any dimension of the electronic device on the basis of the native resource matching logic without modifying the original code logic. It can realize fast resource matching for different brands, different model series, different models, different system versions, different split-screen states and other dimensions, and the resource matching logic supports customization, and can even support resource matching in different time periods, thereby optimizing the resource matching logic, reducing the complexity of application development, and improving application development efficiency.
[0127] Next, the resource configuration method provided in the embodiment of the present application is illustrated by taking detailed scenarios when running applications on different electronic devices:
[0128] In one example, if an APP is run on an electronic device with an S series Flip model PD2333 machine OS6.0 system, and a background image is required, the electronic device can first obtain the default resource identifier "app_background" of the background image, as well as the model series information "S series", model information "Flip model", machine information "PD2333 machine" and system version information "OS6.0 system", and then splice each piece of information with the default resource identifier in turn according to the priority of each piece of information, to obtain the first resource identifier app_background_s_flip_pd2333_os6_0, and obtain the background image based on the first resource identifier. Since the S series Flip model PD2333 machine OS6.0 system resources are not set during the application development process, the electronic device will remove the information of some dimensions spliced in the first resource identifier according to the priority of each piece of information before obtaining the background image.
[0129] For example, the resource acquisition process is as follows:
[0130] First, search for the background image based on the first resource identifier app_background_s_flip_pd2333_os6_0. If there is no corresponding background image, remove the system version information os6_0 in the first resource identifier to obtain the resource identifier app_background_s_flip_pd2333. Then, search for the background image based on the resource identifier app_background_s_flip_pd2333. If there is no corresponding background image, continue to remove the machine information pd2333 in the resource identifier app_background_s_flip_pd2333 to obtain the resource identifier app_background_s_flip. Then search for the background image based on the resource identifier app_background_s_flip. If there is a corresponding background image, obtain the background image.
[0131] In another example, if an APP is run on an electronic device with an X series Flip model PD2344 machine OS6.0 system, when a background image needs to be obtained, the electronic device can first obtain the default resource identifier "app_background" of the background image, as well as the model series information "X series", the model information "Flip model", the machine information "PD2344 machine" and the system version information "OS6.0 system", and then splice each piece of information with the default resource identifier in sequence according to the priority of each piece of information to obtain the first resource identifier app_background_x_flip_pd2344_os6_0, and obtain the background image based on the first resource identifier. Since the X series Flip model PD2344 machine OS6.0 system resources are not set during the application development process, the electronic device will remove the information of some dimensions spliced in the first resource identifier according to the priority of each piece of information before obtaining the background image.
[0132] For example, the resource acquisition process is as follows:
[0133] First, search for the background image based on the first resource identifier app_background_x_flip_pd2344_os6_0. If there is no corresponding background image, remove the system version information os6_0 in the first resource identifier to obtain the resource identifier app_background_x_flip_pd2344. Then search for the background image based on the resource identifier app_background_x_flip_pd2344. If there is no corresponding background image, continue to remove the machine information pd2344 in the resource identifier app_background_x_flip_pd2344 to obtain the resource identifier app_background_x_flip_pd2344. kground_x_flip, and then search for the background image based on the resource identifier app_background_x_flip. If there is no corresponding background image, remove the model series information flip in the resource identifier app_background_x_flip to obtain the resource identifier app_background_x, and then search for the background image based on the resource identifier app_background_x. If there is no corresponding background image, remove the model information x in the resource identifier app_background_x to obtain the resource identifier app_background. If there is a corresponding background image, obtain the background image.
[0134] Figure 6 It is a flow chart of the resource configuration method provided in an embodiment of the present application. The method may include the following steps 601 to 609.
[0135] Step 601: When the electronic device needs to obtain a background image in an application, the electronic device obtains a default resource name of the background image, model series information of the electronic device, and brand information of the electronic device.
[0136] It should be noted that the above-mentioned background image may be the first type of resource in the above-mentioned embodiment, and the above-mentioned default resource name may be the default resource identifier in the above-mentioned embodiment.
[0137] Step 602: The electronic device concatenates the model series information, the brand information, and the default resource name according to the priority of the model series information and the priority of the brand information to generate a first resource name.
[0138] It should be noted that the above-mentioned first resource name may be the first resource identifier in the above-mentioned embodiment.
[0139] Step 603 : The electronic device searches the background gallery to see whether there is a resource name identical to the first resource name. If so, execute step 604 ; if not, execute step 605 .
[0140] Step 604: The electronic device determines the background image indicated by the second resource name that is the same as the first resource name as the target background image adapted by the electronic device.
[0141] It should be noted that the target background image may be the first resource in the above embodiment.
[0142] Step 605: The electronic device removes the brand information concatenated in the first resource name to obtain a third resource name.
[0143] Step 606 : The electronic device searches the background gallery to see whether there is a resource name identical to the third resource name. If so, execute step 607 ; if not, execute step 608 .
[0144] Step 607: The electronic device determines the background image indicated by the fourth resource name that is the same as the third resource name as the target background image adapted by the electronic device.
[0145] Step 608: The electronic device removes the model series information concatenated in the third resource name to obtain a fifth resource name.
[0146] Step 609: The electronic device finds a resource name identical to the fifth resource name in the background image library, and determines the background image indicated by the found resource name as the target background image adapted by the electronic device.
[0147] It should be noted that the above steps 601 to 609 illustrate the resource configuration method by taking at least one information of an electronic device including model series information and brand information, and first removing the spliced brand information and then removing the spliced model series information as an example, and do not constitute a limitation of the present application.
[0148] It should be noted that the specific implementation process of the above steps 601 to 609 can refer to the relevant description of the above embodiment. To avoid repetition, this embodiment will not be repeated here.
[0149] Next, take the example of getting the background image when running the APP on the O8 and O9 models, combined with Figures 7 and 8 , the resource configuration method provided in the embodiment of the present application is illustrated by way of example:
[0150] Assume that an Android developer wants to develop an APP for O8 and O9 models. The UI designer designs the corresponding visual design drawings. And this APP needs to display different information when displayed on these two different series of electronic devices. Then the UI designer designs two visual design drawings, such as Figure 7 As shown in the figure, one is the application design of the O8 model, and the other is the application design of the O9 model. Taking the page background in these two visual design drawings as an example, the UI designer provides background images for the two models, such as Figure 8 As shown, one is the background image of the O8 model, and the other is the background image of the O9 model. From the development perspective, both the O8 and O9 models have a screen density of xxhdpi, a screen resolution of 1080*1920, are Android 10 machines, and the APP is in portrait mode. Therefore, the native resource adaptation logic of Android (i.e., adapting resources according to screen density, screen resolution, Android version, and screen orientation) cannot meet the requirements. Therefore, the electronic device can implement resource adaptation according to the resource configuration method provided in the embodiment of the present application.
[0151] For example, taking the default resource name of the background image as app_background and the information of the electronic device as model series information O9, during the application development process, the developer customizes the resource name app_background_o9 and places the resource name in the resource library.
[0152] For example, the above-mentioned background image is one of the image files in the res folder of the above-mentioned APP. The resource library of the APP includes a res folder, and the res folder includes subfolders such as anim, drawable, drawable-v24, drawable-xxhdpi, layout, mipmap-anydpi, mipmap-hdpi and mipmap-xhdpi. The drawable-xxhdpi subfolder includes app_background_o9 and app_background.
[0153] When the application runs on an electronic device, the electronic device can obtain the background image by referring to the following code. The logic of the following code is the same as the logic of the resource configuration method provided in the embodiment of the present application.
[0154] The code example is as follows:
[0155] "<?xml version="1.0" encoding="utf-8"?>
[0156] <Relativelayout xmlns:android=“http: / / schemas.android”
[0157] android:id="@+id / app_bg"
[0158] android:layout_width="match_parent"
[0159] android:layout_height="match_parent"
[0160] android:background="@drawable / app_background">".
[0161] Exemplarily, the running process of the above code on the electronic device is as follows:
[0162] On O8 series electronic devices, the default resource name of the background image is app_background, which is automatically concatenated with the model name _o8 to obtain the concatenated resource name app_background_o8. The electronic device uses the concatenated resource name app_background_o8 to obtain the corresponding background image. Since, during the application development process, a background image indicated by a resource name identical to the concatenated resource name app_background_o8 is not placed in the resource library, that is, the electronic device does not find the resource name identical to the concatenated resource name app_background_o8, and thus the background image acquisition fails. Then, the electronic device can automatically remove the suffix _o8 from the concatenated resource name app_background_o8 to obtain the resource name app_background. Since, during the application development process, a background image indicated by a resource name identical to the resource name app_background_o9 is placed in the resource library, the electronic device can find the resource name identical to the resource name app_background, and then the electronic device can obtain the background image indicated by the found resource name, and display the obtained background image on the APP page.
[0163] On O9 series electronic devices, the default resource name of the background image is app_background, which is automatically spliced with the model name_o9 to obtain the spliced resource name app_background_o9. The electronic device uses the spliced resource name app_background_o9 to obtain the corresponding background image. Since a background image indicated by the same resource name as the spliced resource name app_background_o9 is placed in the resource library during application development, the electronic device can find the same resource name as the resource name app_background_o9, and then the electronic device can obtain the background image indicated by the found resource name and display the obtained background image on the APP page.
[0164] It should be noted that if the APP needs to be adapted to the O10 series of electronic devices in the future, it only needs to add another app_background_o10.png to the resource library. In this way, when the adaptation situation is more complex and there are more scenarios, compared with the related technology that requires more resource codes to be generated, the resource configuration method provided in the embodiment of the present application does not need to write so much resource code, and the improvement of application development efficiency is more obvious.
[0165] It should be noted that the above-mentioned method embodiments, or various possible implementation methods in each method embodiment, can be executed separately, or any two or more can be executed in combination with each other. The specific implementation method can be determined according to actual usage requirements, and the embodiments of the present application do not impose any restrictions on this.
[0166] The resource configuration method provided in the embodiment of the present application can be executed by a resource configuration device. In the embodiment of the present application, the resource configuration device provided in the embodiment of the present application is described by taking the resource configuration method executed by the resource configuration device as an example.
[0167] Fig. 9 It is a structural diagram of a resource configuration device provided in an embodiment of the present application. The resource configuration device may include: an acquisition module 1101 and an execution module 1102.
[0168] The acquisition module 1101 is used to acquire a default resource identifier of a first type of resource in a first application and at least one information of an electronic device, wherein each information in the at least one information represents the electronic device from one dimension.
[0169] The execution module 1102 is used to generate a first resource identifier according to a default resource identifier and at least one information.
[0170] The above-mentioned acquisition module 1101 is also used to obtain the first resource indicated by the first resource identifier in the first resource library corresponding to the first category of resources based on the first resource identifier, and configure the first resource for the first application. The first resource library includes multiple resources corresponding to the first category of resources and the resource identifier of each resource.
[0171] Optionally, in an embodiment of the present application, the above-mentioned execution module 1102 is specifically used to splice at least one information with a default resource identifier to generate a first resource identifier.
[0172] Optionally, in an embodiment of the present application, the above-mentioned execution module 1102 is specifically used to splice each information with the default resource identifier in sequence according to the priority of each information in the at least one information to generate a first resource identifier.
[0173] Optionally, in an embodiment of the present application, the acquisition module 1101 is further used to acquire the current time period information before generating the first resource identifier according to the default resource identifier and at least one information. The execution module 1102 is specifically used to generate the first resource identifier according to the default resource identifier, at least one information and the time period information.
[0174] Optionally, in an embodiment of the present application, the above-mentioned acquisition module 1101 is specifically used to search for a resource identifier identical to the first resource identifier in the first resource library based on the first resource identifier; and if a second resource identifier identical to the first resource identifier is found, the resource indicated by the second resource identifier is determined as the first resource.
[0175] Optionally, in the embodiment of the present application, the resource configuration device further includes a deletion module and a determination module;
[0176] The above-mentioned deletion module is used to delete M pieces of information in at least one piece of information spliced in the first resource identifier if the resource identifier identical to the first resource identifier is not found, so as to obtain a third resource identifier, where M is an integer greater than 0.
[0177] The above-mentioned determination module is used to determine the resource indicated by the third resource identifier in the first resource library as the first resource.
[0178] Optionally, in an embodiment of the present application, the above-mentioned deletion module is specifically used to delete M pieces of information in the at least one information spliced in the first resource identifier according to the priority of each piece of information in the at least one information.
[0179] Optionally, in the embodiment of the present application, each of the at least one information includes any of the following:
[0180] Model information, system version information, split-screen status information, brand information, model series information, horizontal and vertical screen status information, small window status information, and machine information.
[0181] Optionally, in an embodiment of the present application, the first resource includes at least one of the following: an application running code file, an application resource value, an application resource file, and an application original file.
[0182] Optionally, in an embodiment of the present application, the acquisition module 1101 is specifically used to acquire a default resource identifier of a first format for a first category of resources.
[0183] The execution module 1102 is further configured to convert the default resource identifier in the first format into the default resource identifier in the second format.
[0184] The resource configuration device provided in the embodiment of the present application generates a first resource identifier of the resource of the first application required by the resource configuration device according to the default resource identifier and information representing the electronic device from different dimensions when running the first application. The first resource identifier can not only indicate the resource but also represent the resource configuration device, which is related to the characteristics of the resource configuration device. Then, the resource indicated by the first resource identifier is obtained from the first resource library corresponding to the first type of resource. The resource is adapted to the resource configuration device. After configuring the resource for the first application, the first application loads and displays the application interface on the electronic device based on the resource. The application interface is also adapted to the electronic device. In this way, by combining the information of the resource configuration device on the basis of the default resource identifier, the resources of the first application adapted to the resource configuration device can be obtained. There is no need to set different resource codes for each resource, that is, there is no need to set a large number of resource codes, which simplifies the application development process and improves the application development efficiency.
[0185] The resource configuration device in the embodiment of the present application can be an electronic device, or a component in the electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal, or it can be other devices other than a terminal. For example, the electronic device can be a mobile phone, a tablet computer, a laptop computer, a PDA, a vehicle-mounted electronic device, a mobile Internet device, an augmented reality / virtual reality device, a robot, a wearable device, a super mobile personal computer, a netbook or a personal digital assistant, etc., and can also be a server, a network attached storage (Network Attached Storage, NAS), a personal computer (personal computer, PC), a television (television, TV), a teller machine or a self-service machine, etc., which is not specifically limited in the embodiment of the present application.
[0186] The resource configuration device in the embodiment of the present application may be a device having an operating system. The operating system may be an Android operating system, an iOS operating system, or other possible operating systems, which are not specifically limited in the embodiment of the present application.
[0187] The resource configuration device provided in the embodiment of the present application can implement each process implemented by each embodiment of the above-mentioned resource configuration method. To avoid repetition, it will not be described here.
[0188] Alternatively, if Fig.10 As shown, an embodiment of the present application also provides an electronic device 900, including a processor 901 and a memory 902, wherein the memory 902 stores programs or instructions that can be executed on the processor 901, and when the program or instructions are executed by the processor 901, the various steps of the above-mentioned resource configuration method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, they are not described here.
[0189] It should be noted that the electronic devices in the embodiments of the present application include the mobile electronic devices and non-mobile electronic devices mentioned above.
[0190] Fig.11 It is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application.
[0191] The electronic device 1000 includes but is not limited to: a radio frequency unit 1001, a network module 1002, an audio output unit 1003, an input unit 1004, a sensor 1005, a display unit 1006, a user input unit 1007, an interface unit 1008, a memory 1009, and a processor 1010 and other components.
[0192] Those skilled in the art will appreciate that the electronic device 1000 may also include a power source (such as a battery) for supplying power to each component, and the power source may be logically connected to the processor 1010 through a power management system, thereby implementing functions such as managing charging, discharging, and power consumption management through the power management system. Fig.11 The electronic device structure shown in the figure does not constitute a limitation on the electronic device. The electronic device may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently, which will not be described in detail here.
[0193] The processor 1010 is used to obtain a default resource identifier of a first type of resource in a first application and at least one information of an electronic device, wherein each information in the at least one information represents the electronic device from one dimension.
[0194] The processor 1010 is further configured to generate a first resource identifier according to a default resource identifier and at least one information.
[0195] The above-mentioned processor 1010 is also used to obtain the first resource indicated by the first resource identifier in the first resource library corresponding to the first category of resources based on the first resource identifier, and configure the first resource for the first application. The first resource library includes multiple resources corresponding to the first category of resources and the resource identifier of each resource.
[0196] Optionally, in an embodiment of the present application, the processor 1010 is specifically configured to concatenate at least one information with a default resource identifier to generate a first resource identifier.
[0197] Optionally, in an embodiment of the present application, the processor 1010 is specifically configured to sequentially concatenate each information with a default resource identifier according to a priority of each information in at least one information to generate a first resource identifier.
[0198] Optionally, in the embodiment of the present application, the processor 1010 is further configured to obtain the current time period information before generating the first resource identifier according to the default resource identifier and at least one information. The execution module is specifically configured to generate the first resource identifier according to the default resource identifier, at least one information and the time period information.
[0199] Optionally, in an embodiment of the present application, the above-mentioned processor 1010 is specifically used to search for a resource identifier identical to the first resource identifier in the first resource library based on the first resource identifier; and if a second resource identifier identical to the first resource identifier is found, the resource indicated by the second resource identifier is determined as the first resource.
[0200] Optionally, in an embodiment of the present application, the above-mentioned processor 1010 is also used to delete M pieces of information from at least one piece of information spliced in the first resource identifier if a resource identifier identical to the first resource identifier is not found, to obtain a third resource identifier, where M is an integer greater than 0; and determine the resource indicated by the third resource identifier in the first resource library as the first resource.
[0201] Optionally, in an embodiment of the present application, the processor 1010 is specifically configured to delete M pieces of information from the at least one piece of information spliced in the first resource identifier according to the priority of each piece of information in the at least one piece of information.
[0202] Optionally, in an embodiment of the present application, each of the at least one information mentioned above may include any one of the following: model information, system version information, split-screen status information, brand information, model series information, horizontal and vertical screen status information, small window status information, and machine information.
[0203] Optionally, in an embodiment of the present application, the first resource may include at least one of the following: an application running code file, an application resource value, an application resource file, and an application original file.
[0204] Optionally, in an embodiment of the present application, the processor 1010 is specifically configured to obtain a default resource identifier in a first format for a first category of resources; and convert the default resource identifier in the first format into a default resource identifier in a second format.
[0205] The electronic device provided in the embodiment of the present application, when running the first application, generates a first resource identifier of the resources of the first application required by the resource configuration device according to the default resource identifier and information characterizing the electronic device from different dimensions. The first resource identifier can not only indicate the resource but also characterize the electronic device, which is related to the characteristics of the electronic device. Then, the resource indicated by the first resource identifier is obtained from the first resource library corresponding to the first type of resource. The resource is adapted to the electronic device. After configuring the resource for the first application, the first application loads and displays the application interface on the electronic device based on the resource. The application interface is also adapted to the electronic device. In this way, by combining the information of the electronic device on the basis of the default resource identifier, the resources of the first application adapted to the electronic device can be obtained. There is no need to set different resource codes for each resource, that is, there is no need to set a large number of resource codes, which simplifies the application development process and improves the efficiency of application development.
[0206] It should be understood that in the embodiment of the present application, the input unit 1004 may include a graphics processor (Graphics Processing Unit, GPU) 10041 and a microphone 10042, and the graphics processor 10041 processes the image data of the static picture or video obtained by the image capture device (such as a camera) in the video capture mode or the image capture mode. The display unit 1006 may include a display panel 10061, and the display panel 10061 may be configured in the form of a liquid crystal display, an organic light emitting diode, etc. The user input unit 1007 includes a touch panel 10071 and at least one of other input devices 10072. The touch panel 10071 is also called a touch screen. The touch panel 10071 may include two parts: a touch detection device and a touch controller. Other input devices 10072 may include, but are not limited to, a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, and a joystick, which will not be repeated here.
[0207] The memory 1009 can be used to store software programs and various data. The memory 1009 may mainly include a first storage area for storing programs or instructions and a second storage area for storing data, wherein the first storage area may store an operating system, an application program or instructions required for at least one function (such as a sound playback function, an image playback function, etc.), etc. In addition, the memory 1009 may include a volatile memory or a non-volatile memory, or the memory 1009 may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), a static random access memory (SRAM), a dynamic random access memory (DRAM), a synchronous dynamic random access memory (SDRAM), a double data rate synchronous dynamic random access memory (DDRSDRAM), an enhanced synchronous dynamic random access memory (ESDRAM), a synchronous link dynamic random access memory (SLDRAM) and a direct memory bus random access memory (DRRAM). The memory 109 in the embodiment of the present application includes but is not limited to these and any other suitable types of memory.
[0208] The processor 1010 may include one or more processing units; optionally, the processor 1010 integrates an application processor and a modem processor, wherein the application processor mainly processes operations related to an operating system, a user interface, and application programs, and the modem processor mainly processes wireless communication signals, such as a baseband processor. It is understandable that the modem processor may not be integrated into the processor 1010.
[0209] An embodiment of the present application also provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, the various processes of the above-mentioned resource configuration method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0210] The processor is the processor in the electronic device described in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a computer read-only memory ROM, a random access memory RAM, a magnetic disk or an optical disk.
[0211] An embodiment of the present application further provides a chip, which includes a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run programs or instructions to implement the various processes of the above-mentioned resource configuration method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0212] It should be understood that the chip mentioned in the embodiments of the present application can also be called a system-level chip, a system chip, a chip system or a system-on-chip chip, etc.
[0213] An embodiment of the present application provides a computer program product, which is stored in a storage medium. The program product is executed by at least one processor to implement the various processes of the resource configuration method embodiment described above, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0214] It should be noted that, in this article, the terms "comprise", "include" or any other variant thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise one..." do not exclude the presence of other identical elements in the process, method, article or device including the element. In addition, it should be pointed out that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in reverse order according to the functions involved, for example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.
[0215] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a computer software product, which is stored in a storage medium (such as ROM / RAM, a disk, or an optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present application.
[0216] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.
Claims
1. A resource configuration method, characterized in that: The method comprises: Acquire a default resource identifier of a first type of resource in a first application and at least one information of an electronic device, wherein each information in the at least one information represents the electronic device from one dimension; Generate a first resource identifier according to the default resource identifier and the at least one information; Based on the first resource identifier, in a first resource library corresponding to the first category of resources, obtain the first resource indicated by the first resource identifier, and configure the first resource for the first application. The first resource library includes multiple resources corresponding to the first category of resources and a resource identifier for each resource.
2. The method according to claim 1, characterized in that: The step of generating a first resource identifier according to the default resource identifier and the at least one information includes: The at least one information is concatenated with the default resource identifier to generate the first resource identifier.
3. The method according to claim 2, characterized in that The step of combining the at least one information with the default resource identifier to generate the first resource identifier includes: According to the priority of each information in the at least one information, each information is sequentially concatenated with the default resource identifier to generate the first resource identifier.
4. The method according to any one of claims 1 to 3, characterized in that Before generating the first resource identifier according to the default resource identifier and the at least one information, the method further includes: Get the current time period information; The step of generating a first resource identifier according to the default resource identifier and the at least one information includes: The first resource identifier is generated according to the default resource identifier, the at least one information and the time period information.
5. The method according to claim 2, characterized in that: The acquiring, based on the first resource identifier, in a first resource library corresponding to the first type of resources, the first resource indicated by the first resource identifier includes: Based on the first resource identifier, searching the first resource library for a resource identifier identical to the first resource identifier; If a second resource identifier that is the same as the first resource identifier is found, the resource indicated by the second resource identifier is determined as the first resource.
6. The method according to claim 5, characterized in that The method further comprises: If a resource identifier identical to the first resource identifier is not found, M pieces of information in the at least one piece of information spliced in the first resource identifier are deleted to obtain a third resource identifier, where M is an integer greater than 0; The resource indicated by the third resource identifier in the first resource library is determined as the first resource.
7. The method according to claim 6, characterized in that The deleting M pieces of information in the at least one piece of information spliced in the first resource identifier includes: According to the priority of each information in the at least one information, M information in the at least one information spliced in the first resource identifier is deleted.
8. The method according to claim 1, characterized in that The obtaining of the default resource identifier of the first type of resource in the first application includes: Obtaining a default resource identifier of a first format for the first type of resource; The default resource identifier in the first format is converted into a default resource identifier in a second format.
9. A resource allocation device, characterized in that: The device comprises an acquisition module and an execution module; The acquisition module is used to acquire a default resource identifier of a first type of resource in a first application and at least one information of an electronic device, wherein each information of the at least one information represents the electronic device from one dimension; The execution module is used to generate a first resource identifier according to the default resource identifier and the at least one information; The acquisition module is also used to acquire the first resource indicated by the first resource identifier in a first resource library corresponding to the first category of resources based on the first resource identifier, and configure the first resource for the first application. The first resource library includes multiple resources corresponding to the first category of resources and the resource identifier of each resource.
10. The device according to claim 9, characterized in that The execution module is specifically used for: The at least one information is concatenated with the default resource identifier to generate the first resource identifier.
11. An electronic device, characterized in that: The method comprises a processor and a memory, wherein the memory stores programs or instructions that can be run on the processor, and when the programs or instructions are executed by the processor, the steps of the resource configuration method according to any one of claims 1 to 8 are implemented.
12. A readable storage medium, characterized in that: The readable storage medium stores a program or instruction, and when the program or instruction is executed by a processor, the steps of the resource configuration method according to any one of claims 1 to 8 are implemented.