UI style replacement method and device, equipment and storage medium
By receiving voice skinning instructions and reflection technology from voice assistant, the control object is determined, which solves the problem of cumbersome UI style replacement process in the prior art, and achieves fast and efficient UI style replacement.
Patent Information
- Application Number
- CN202411447145.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-16
- Publication Date
- 2025-02-14
- Estimated Expiration
- 2044-10-16
AI Technical Summary
When changing the UI style of the voice assistant, the source code needs to be remodified, compiled and released, resulting in a long process, cumbersome steps and inefficient modification.
By receiving voice peeling instructions triggered by the voice assistant, the control object is determined using reflection technology, and the style replacement data is determined in multiple UI style packages according to the style package identification, and the style data of the target control object is replaced.
It realizes that UI styles can be replaced without re-modifying the source code, compiling and publishing, which significantly improves the efficiency of UI style modification.
Smart Images

Figure CN119440699A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a UI style changing method, device, equipment and storage medium. Background Art
[0002] In order to make it more convenient for drivers to control the vehicle, a voice assistant can be installed on the vehicle so that the driver can perform certain operations in the vehicle through voice. When writing the source code of the voice assistant, in order to make the voice assistant look more beautiful, the technicians will set the UI (User Interface) style (such as background color, picture, font color, etc.) in the source code to obtain the source code of the voice assistant. After that, the source code is compiled to obtain the APK file of the voice assistant, and then the APK file is published to the server for the driver to download and install.
[0003] The above solution sets the UI style in the source code. If the UI style needs to be modified, the source code needs to be modified again, and then the modified source code needs to be compiled and released. The whole process is time-consuming and cumbersome, resulting in low efficiency in modifying the UI style. Summary of the invention
[0004] The present application provides a UI style changing method, apparatus, device and storage medium, which can improve the efficiency of UI style modification.
[0005] In a first aspect, the present application provides a method for changing a UI style, the method comprising:
[0006] Receiving a voice skin-changing instruction triggered by a voice assistant, wherein the voice skin-changing instruction includes a style package identifier of a UI style package to be used;
[0007] Determine at least one control object based on the reflection technology and all controls in the voice assistant;
[0008] According to each control object, determine the target control object whose corresponding style can be replaced;
[0009] Determining style replacement data of the target control object in multiple UI style packages according to the target control object and the style package identifier;
[0010] The style data of the target control object is replaced using the style replacement data of the target control object.
[0011] Optionally, determining at least one control object according to the reflection technology and all controls in the voice assistant includes:
[0012] Among all controls in the voice assistant, determine at least one UI control for building a user interface;
[0013] Use reflection technology to reflect at least one UI control to obtain a control object corresponding to each UI control.
[0014] Optionally, determining, according to each control object, a target control object whose corresponding style can be replaced includes:
[0015] Get the properties of each control object;
[0016] In at least one control object, detecting whether there is a control object whose attribute is the target attribute;
[0017] When a control object having the attribute of the target attribute is detected, the control object is determined as a target control object whose corresponding skin can be replaced.
[0018] Optionally, determining the style replacement data of the target control object in multiple UI style packages according to the target control object and the style package identifier includes:
[0019] Determine, according to the style package identifier, a UI style package to be used from among multiple UI style packages;
[0020] According to the target control object, the style replacement data of the target control object is determined in the UI style package to be used.
[0021] Optionally, determining, according to the target control object, in a UI style package to be used, style replacement data of the target control object includes:
[0022] According to the target control object, in the APK file of the voice assistant, determine the target control identifier of the target control object;
[0023] According to the target control identifier, searching for a property value corresponding to the target control identifier in the UI style package to be used;
[0024] The attribute value corresponding to the target control identifier is determined as the style replacement data of the target control object.
[0025] Optionally, the UI style package further includes a property and a type corresponding to the control identifier. Before searching for a property value corresponding to the target control identifier in the UI style package to be used according to the target control identifier, the method further includes:
[0026] According to the target control object, in the APK file of the voice assistant, determine the target attribute and target type corresponding to the target control object;
[0027] According to the target control identifier, determining a reference attribute and a reference type corresponding to the target control identifier in a UI style package to be used;
[0028] Detecting whether the target attribute is consistent with the reference attribute, and whether the target type is consistent with the reference type;
[0029] When the two are consistent, the property value corresponding to the target control identifier is searched in the UI style package to be used according to the target control identifier.
[0030] Optionally, using the style replacement data of the target control object to replace the style data of the target control object includes:
[0031] According to the target control object, in the APK file of the voice assistant, determine the target control identifier of the target control object;
[0032] According to the target control identifier, determine the style data corresponding to the target control identifier in the APK file of the voice assistant;
[0033] The style data corresponding to the target control identifier is replaced using the style replacement data of the target control object.
[0034] In a second aspect, the present application provides a UI style changing device, the device comprising:
[0035] A receiving unit, configured to receive a voice skin-changing instruction triggered by a voice assistant, wherein the voice skin-changing instruction includes a style package identifier of a UI style package to be used;
[0036] A first determining unit, configured to determine at least one control object according to the reflection technology and all controls in the voice assistant;
[0037] A second determining unit is used to determine, according to each control object, a target control object whose corresponding style can be replaced;
[0038] A third determining unit, configured to determine, according to the target control object and the style package identifier, style replacement data of the target control object in a plurality of UI style packages;
[0039] A replacement unit is used to replace the style data of the target control object by using the style replacement data of the target control object.
[0040] Optionally, the first determining unit is configured to:
[0041] Among all controls in the voice assistant, determine at least one UI control for building a user interface;
[0042] Use reflection technology to reflect at least one UI control to obtain a control object corresponding to each UI control.
[0043] Optionally, the second determining unit is configured to:
[0044] Get the properties of each control object;
[0045] In at least one control object, detecting whether there is a control object whose attribute is the target attribute;
[0046] When a control object having the attribute of the target attribute is detected, the control object is determined as a target control object whose corresponding skin can be replaced.
[0047] Optionally, the third determining unit is used to:
[0048] Determine, according to the style package identifier, a UI style package to be used from among multiple UI style packages;
[0049] According to the target control object, the style replacement data of the target control object is determined in the UI style package to be used.
[0050] Optionally, the third determining unit is used to:
[0051] According to the target control object, in the APK file of the voice assistant, determine the target control identifier of the target control object;
[0052] According to the target control identifier, searching for a property value corresponding to the target control identifier in the UI style package to be used;
[0053] The attribute value corresponding to the target control identifier is determined as the style replacement data of the target control object.
[0054] Optionally, the UI style package further includes properties and types corresponding to the control identifier, and the device further includes a detection unit, wherein the detection unit is used to:
[0055] According to the target control object, in the APK file of the voice assistant, determine the target attribute and target type corresponding to the target control object;
[0056] According to the target control identifier, determining a reference attribute and a reference type corresponding to the target control identifier in a UI style package to be used;
[0057] Detecting whether the target attribute is consistent with the reference attribute, and whether the target type is consistent with the reference type;
[0058] When the two are consistent, the property value corresponding to the target control identifier is searched in the UI style package to be used according to the target control identifier.
[0059] Optionally, the replacement unit is used to:
[0060] According to the target control object, in the APK file of the voice assistant, determine the target control identifier of the target control object;
[0061] According to the target control identifier, determine the style data corresponding to the target control identifier in the APK file of the voice assistant;
[0062] The style data corresponding to the target control identifier is replaced using the style replacement data of the target control object.
[0063] In a third aspect, the present application provides a UI style changing device, comprising: at least one communication interface; at least one bus connected to the at least one communication interface; at least one processor connected to the at least one bus; at least one memory connected to the at least one bus, wherein the processor is configured to:
[0064] Receiving a voice skin-changing instruction triggered by a voice assistant, wherein the voice skin-changing instruction includes a style package identifier of a UI style package to be used;
[0065] Determine at least one control object based on the reflection technology and all controls in the voice assistant;
[0066] According to each control object, determine the target control object whose corresponding style can be replaced;
[0067] Determining style replacement data of the target control object in multiple UI style packages according to the target control object and the style package identifier;
[0068] The style data of the target control object is replaced using the style replacement data of the target control object.
[0069] In a fourth aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, and the computer program implements the above-mentioned UI style changing method when executed by a processor.
[0070] The above technical solution provided by the embodiment of the present application has the following advantages compared with the prior art:
[0071] In an embodiment of the present application, when a voice skin-changing instruction triggered by a voice assistant is received, at least one control object is determined based on the reflection technology and all controls in the voice assistant, and based on each control object, a target control object whose corresponding style can be replaced is determined, and based on the target control object and the style package identifier, the style replacement data of the target control object is determined in multiple UI style packages, and the style replacement data of the target control object is used to replace the style data of the target control object, wherein the voice skin-changing instruction includes the style package identifier of the UI style package to be used. It can be seen that the present application can replace the style of the control that needs to be replaced when receiving the voice skin-changing instruction, without re-executing the source code modification, compilation, and publishing processes, avoiding these cumbersome processes, and improving the efficiency of modifying the UI style. BRIEF DESCRIPTION OF THE DRAWINGS
[0072] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.
[0073] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0074] One or more embodiments are exemplarily described by pictures in the corresponding drawings, and these exemplified descriptions do not constitute limitations on the embodiments. Elements with the same reference numerals in the drawings represent similar elements, and unless otherwise stated, the figures in the drawings do not constitute proportional limitations.
[0075] Figure 1 A flowchart of a UI style changing method provided in an embodiment of the present application;
[0076] Figure 2 A flowchart of a method for determining a target control object provided in an embodiment of the present application;
[0077] Figure 3 A schematic diagram of a flow chart of a method for determining style replacement data provided in an embodiment of the present application;
[0078] Figure 4 A flowchart of another method for determining style replacement data provided in an embodiment of the present application;
[0079] Figure 5 A flowchart of a data detection method provided in an embodiment of the present application;
[0080] Figure 6A flowchart of a data replacement method provided in an embodiment of the present application;
[0081] Figure 7 A flowchart of a control object determination method provided in an embodiment of the present application;
[0082] Figure 8 A schematic diagram of a process flow of a UI style changing device provided in an embodiment of the present application;
[0083] Fig. 9 A schematic diagram of a UI style changing device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0084] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0085] The disclosure below provides many different embodiments or examples to implement different structures of the present invention. In order to simplify the disclosure of the present invention, the parts and settings of specific examples are described below. Of course, they are only examples, and the purpose is not to limit the present invention. In addition, the present invention can repeat reference numbers and / or letters in different examples. This repetition is for the purpose of simplification and clarity, and does not itself indicate the relationship between the various embodiments and / or settings discussed.
[0086] In order to make it more convenient for the driver to control the vehicle, a voice assistant can be installed on the vehicle so that the driver can implement certain operations in the vehicle through voice. When writing the source code of the voice assistant, in order to make the voice assistant look more beautiful, the technician will set the UI style (such as background color, picture, font color, etc.) in the source code to obtain the source code of the voice assistant. After that, the source code is compiled to obtain the APK file of the voice assistant, and then the APK file is published to the server for the driver to download and install. The above scheme sets the UI style in the source code. If the UI style needs to be modified, the source code needs to be modified again, and then the modified source code is compiled and published. The whole process is time-consuming and cumbersome, resulting in inefficient modification of the UI style.
[0087] Therefore, in order to solve the above problems, the embodiment of the present application provides a UI style replacement method, which can improve the modification efficiency of the UI style. Figure 1 As shown, the specific steps include:
[0088] Step 101, receiving a voice skin-changing instruction triggered by a voice assistant.
[0089] The voice assistant is an application installed on the vehicle and is used to execute voice commands input by the driver. The voice skinning command includes a style package identifier of the UI style package to be used. The UI style package includes the UI style data to be used. The style package identifier is used to uniquely indicate the UI style package. The identifier can be a unique name set by a technician for the UI style package, or other data, which is not limited here.
[0090] In this step, a voice assistant is installed on the vehicle. When the driver needs to operate based on the voice assistant, the driver can wake up the voice assistant through a preset voice command. After the driver wakes up the voice assistant, the driver can change the skin of the voice assistant. Specifically, the driver can control the voice assistant through skin change voice commands to display at least one icon, each icon corresponding to a style package identifier. When the voice assistant receives a voice trigger operation for an icon, the voice assistant obtains the style package identifier corresponding to the icon, and generates a voice skin change instruction based on the style package identifier.
[0091] Before executing this step, technicians are required to create UI style packages and upload various UI style packages through the upload page. The specific process is to use Android Studio IDE to create an application project containing the required resource files. After that, the control properties in the layout file of the voice assistant and the resource files related to the UI style can be analyzed to produce a UI style file that meets the requirements. For example, the attribute name, attribute value corresponding type and other data in the UI style file are the same as the attribute name, attribute value corresponding type and other data included in the voice assistant.
[0092] After obtaining a UI style file that meets the requirements, the UI style file can be packaged to obtain a UI style package in APK format. Based on the same method, various UI style packages are obtained. In order to facilitate the identification of these UI style packages, technicians can set different names for the UI style packages based on experience. Afterwards, the produced UI style package is uploaded to the server through the resource upload page, so that the voice assistant client can download the required UI style package through the server. At the same time, technicians can also upload the package name, poster, and MD5 value of each UI style package to the server system. Among them, the poster is made by the technician according to the UI style corresponding to the UI style package, and the MD5 value is obtained by processing the UI style package using the message digest algorithm.
[0093] Afterwards, the client of the voice assistant can obtain relevant information of various UI style packages through the HTTPS interface, such as the package name of the UI style package, the download address of the UI style package, the corresponding poster download address and the MD5 value of the UI style package. After the client of the voice assistant obtains the poster download addresses corresponding to various UI style packages, the posters of these UI style packages can be downloaded and displayed according to these poster download addresses, so that the driver can understand the UI style corresponding to each UI style package according to these posters, so as to select the UI style package that best meets the needs. After that, the download address of the UI style package that best meets the needs can be obtained, and the UI style package can be downloaded to obtain the UI style package that best meets the needs. The download address includes the package name of the UI style package, so as to find the UI style package to be downloaded by the package name. In order to ensure the integrity of the data in the UI style package, the MD5 value of the UI style package can also be used to verify the data in the UI style package. If the verification passes, it means that the data in the UI style package is complete and the UI style package can be used. If the verification fails, it means that the data in the UI style package is incomplete and the UI style package cannot be used. In the case where the UI style package cannot be used, the UI style package can be downloaded again based on the download address of the UI style package.
[0094] Step 102: Determine at least one control object based on the reflection technology and all controls in the voice assistant.
[0095] In this step, since the Android interface uses the LayoutInflater tool class to recursively parse the controls declared in the XML layout file to create control objects, then add them to the top-level ViewGroup control, and then perform subsequent measurement, layout, and drawing, and finally display them on the screen, the voice assistant can use reflection technology to obtain the control object of each control, and then obtain the control-related data of each control object in the APK file of the voice assistant through each control object, that is, the control-related data of each control. Specifically, the voice assistant determines the XML layout file in the APK file, and recursively parses the controls declared in the XML layout file through the LayoutInflater tool class, creates control objects, and obtains the control object of each control.
[0096] Furthermore, since this application only changes the UI style of the UI control, the voice assistant can find the UI control among all the controls of the voice assistant, and use reflection technology to reflect these UI controls to obtain the control objects of these UI controls.
[0097] Among them, UI controls are used to build user interfaces and are unit components related to interface operations, such as computer input boxes, buttons, etc. The APK file involved above is a file used when the voice assistant is running. The file includes an XML layout file, which stores data related to the layout of the voice assistant, such as the control identifier of each UI control, the properties of the control, the property values, the type of the property values, and other data. Among them, the properties of the control indicate the elements in the control, for example, the properties can be text color textColor, background background, etc. The property value can be the storage path, color value, etc. of the corresponding element. The type of the property value, for example, the type can be picture, link, etc., which is used to indicate whether the property value is a picture or a link, etc.
[0098] Step 103: According to each control object, determine the target control object whose corresponding style can be changed.
[0099] The target control is a control whose corresponding style can be changed, and the control object of the control is determined as the target control object.
[0100] In this step, the voice assistant can determine whether the style of the control object can be changed through the properties of the control object. Specifically, when the property of the control object is a target property, the voice assistant determines that the style of the control can be changed and determines the control as a target control. When the property of the control is not a target property, the voice assistant determines that the style of the control cannot be changed and cannot determine the control as a target control.
[0101] Furthermore, the voice assistant can find the properties of the control object in the XML layout file through the control object. Afterwards, for each control object, the voice assistant detects whether the property of the control object is the target property. When it is detected that the property of the control object is the target property, the control object is determined as the target control object. When the voice assistant has detected all control objects, the voice assistant obtains all target control objects in the voice assistant.
[0102] Step 104: determining style replacement data of the target control object in multiple UI style packages according to the target control object and the style package identifier.
[0103] The UI style package includes style replacement data of multiple controls, so that these style replacement data can be used for replacement.
[0104] In this step, the voice assistant can find and load the UI style package to be used according to the style package identifier in the voice skin-changing instruction and the correspondence between the UI style package and the style package identifier, and then find the style replacement data of the target control object in the UI style package according to the target control object.
[0105] When the UI style package to be used needs to be loaded into the memory, the voice assistant creates a Resources class object through reflection. The Resources class is provided by Android and is specifically used to manage various application resources. In order to enable the Resources class object to load the UI style package, the voice assistant can obtain the addAssetPath function in the AssetManager through reflection, and use this function to set the path of the skin package as the resource management path of Resources, and then the Resources class object can load the UI style package to be used through this path.
[0106] Step 105: Use the style replacement data of the target control object to replace the style data of the target control object.
[0107] The style data is data related to the target control style in the APK file.
[0108] In this step, the voice assistant can search for the style data of the target control object in the XML layout file through the target control object, and replace the style data with the style replacement data of the target control object. When the style data of all target control objects are replaced with the style replacement data, the skin of the voice assistant can be updated.
[0109] In an embodiment of the present application, when a voice skin-changing instruction triggered by a voice assistant is received, at least one control object is determined based on the reflection technology and all controls in the voice assistant, and based on each control object, a target control object whose corresponding style can be replaced is determined, and based on the target control object and the style package identifier, the style replacement data of the target control object is determined in multiple UI style packages, and the style replacement data of the target control object is used to replace the style data of the target control object, wherein the voice skin-changing instruction includes the style package identifier of the UI style package to be used. It can be seen that the present application can replace the style of the control that needs to be replaced when receiving the voice skin-changing instruction, without re-executing the source code modification, compilation, and publishing processes, avoiding these cumbersome processes, and improving the efficiency of modifying the UI style.
[0110] In the embodiment of the present application, when step 103 needs to be executed, the voice assistant can find the properties of each control object in the XML layout file of the voice assistant through each control object, and then determine whether the style of each control object can be changed through the properties of each control object. Therefore, the embodiment of the present application provides a method for determining a target control object, such as Figure 2 As shown, the specific steps include:
[0111] Step 201, obtaining the properties of each control object.
[0112] In this step, for each control object, the voice assistant can search for the properties of the control object in the XML layout file of the voice assistant based on the control object.
[0113] Step 202: Detect whether there is a control object whose attribute is a target attribute in at least one control object.
[0114] In this step, for each control object, the voice assistant can detect whether the attribute of the control object is the target attribute. When the attribute of the control object is the target attribute, it is determined that there is a control object whose attribute is the target attribute. When the attribute of the control object is not the target attribute, it is determined that there is no control object whose attribute is the target attribute.
[0115] Step 203: When a control object with a target attribute is detected, the control object is determined as a target control object whose corresponding skin can be replaced.
[0116] In this step, when a control object with a target attribute is detected, the voice assistant determines the control object as a target control object whose corresponding skin can be replaced. Based on this, the voice assistant finds all target control objects among these control objects.
[0117] In the embodiment of the present application, in addition to storing each UI style package, the voice assistant also stores the style package identifier of each UI style package. In this way, the voice assistant can determine the UI style package to be used according to the style package identifier in the voice skinning instruction, and then determine the style replacement data of the target control object in the UI style package. Therefore, the embodiment of the present application provides a method for determining style replacement data, such as Figure 3 As shown, specifically including:
[0118] Step 301: Determine a UI style package to be used from among multiple UI style packages according to a style package identifier.
[0119] In this step, since the voice assistant stores each UI style package and the style package identifier of each UI style package point, the voice assistant can determine the UI style package to be used according to the style package identifier in the voice skin-changing instruction.
[0120] Step 302: According to the target control object, determine the style replacement data of the target control object in the UI style package to be used.
[0121] The UI style package to be used includes style replacement data of multiple controls.
[0122] In this step, when the UI style of a certain control needs to be changed, the voice assistant can determine the style replacement data of the control object in the UI style package to be used according to the target control object.
[0123] The present application embodiment provides another method for determining style replacement data, which is a further limitation of step 302. Figure 4 As shown, specifically including:
[0124] Step 401, according to the target control object, determine the target control identifier of the target control object in the APK file of the voice assistant.
[0125] The control identifier is a unique identifier indicating the control, for example, the control identifier is a control ID.
[0126] In this step, the UI style package includes multiple control identifiers and style replacement data corresponding to each control identifier. Therefore, if the voice assistant needs to determine the style replacement data of the target control object, the voice assistant needs to first determine the target control identifier of the target control object. The XML layout file of the voice assistant stores the control identifier of each control, so that the voice assistant can determine the target control identifier of the target control object in the APK file of the voice assistant through the target control object.
[0127] Step 402: According to the target control identifier, search for a property value corresponding to the target control identifier in the UI style package to be used.
[0128] In this step, since the UI style package includes multiple control identifiers and style replacement data corresponding to each control identifier, the voice assistant searches the UI style package to be used according to the target control identifier and finds the property value corresponding to the target control identifier.
[0129] Step 403: determine the property value corresponding to the target control identifier as the style replacement data of the target control object.
[0130] In this step, the voice assistant determines the property value corresponding to the target control as the style replacement data of the target control object.
[0131] Furthermore, if the attribute value corresponding to a certain control in the UI style package does not match the attribute and type corresponding to the XML layout file, it means that the attribute value corresponding to the control in the UI style package is incorrect and cannot be replaced based on the attribute value. If the attribute value corresponding to a certain control in the UI style package matches the attribute and type corresponding to the APK file, it means that the attribute value corresponding to the control in the UI style package is correct and can be replaced based on the attribute value. Therefore, the embodiment of the present application provides a data detection method, which method is as follows: Figure 5As shown, the specific steps include:
[0132] Step 501, according to the target control object, determine the target attribute and target type corresponding to the target control object in the APK file of the voice assistant.
[0133] Among them, the target property is the property corresponding to the target control object, and the target type is the type corresponding to the target control object.
[0134] In this step, the voice assistant determines the XML layout file in the APK file of the voice assistant, and searches the XML layout file for the target attribute and target type corresponding to the target control object according to the target control object.
[0135] Step 502: According to the target control identifier, determine the reference property and reference type corresponding to the target control identifier in the UI style package to be used.
[0136] In this step, the voice assistant searches the UI style package to be used according to the target control identifier to find the reference attribute and reference type corresponding to the target control identifier.
[0137] Step 503: Check whether the target attribute is consistent with the reference attribute, and whether the target type is consistent with the reference type.
[0138] In this step, the voice assistant may compare the target attribute with the reference attribute to detect whether the target attribute is consistent with the reference attribute, and compare the target type with the reference type to detect whether the target type is consistent with the reference type.
[0139] Step 504: when the two are consistent, search for the property value corresponding to the target control identifier in the UI style package to be used according to the target control identifier.
[0140] In this step, when the two are consistent, it means that the property value of the target control identifier is correct. The voice assistant can search for the property value corresponding to the target control identifier in the UI style package to be used according to the target control identifier.
[0141] After determining the style replacement data of the target control object, the embodiment of the present application also needs to determine the style data of the target control object, and then replace the style data according to the style replacement data of the target control object. Therefore, the embodiment of the present application provides a data replacement method, the method is as follows Figure 6 As shown, the specific steps include:
[0142] Step 601, according to the target control object, determine the target control identifier of the target control object in the APK file of the voice assistant.
[0143] In this step, the voice assistant determines the XML layout file in the APK file, and then searches for the target control identifier of the target control object in the XML layout file according to the target control object.
[0144] Step 602: Determine the style data corresponding to the target control identifier in the APK file of the voice assistant according to the target control identifier.
[0145] The style data may be an attribute value, and the APK file includes at least one control identifier and an attribute value corresponding to each control identifier.
[0146] In this step, after determining the target control identifier, the voice assistant can determine the style data corresponding to the target control identifier in the APK file based on the target control identifier.
[0147] Step 603: Use the style replacement data of the target control object to replace the style data corresponding to the target control identifier.
[0148] In this step, after the voice assistant determines the style data corresponding to the target control identifier in the APK file, it uses the style replacement data of the target control object to replace its style data.
[0149] In the embodiment of the present application, when step 102 needs to be executed, the voice assistant can also first find the UI control among all the controls in the voice assistant, and use the control object of the UI control as the at least one control object obtained. Therefore, the embodiment of the present application provides a control object determination method, specifically as follows Figure 7 As shown, the specific steps include:
[0150] Step 701, among all controls of the voice assistant, determine at least one UI control for constructing a user interface.
[0151] In this step, the technician can label the UI controls in the voice assistant, and then determine whether the control is a UI control by whether the control has a label. Alternatively, the voice assistant can store the identifier of each UI control, so that at least one UI control used to build a user interface can be determined from the identifiers of all controls based on the identifier. Alternatively, this step can also use other methods to determine the UI control, which is not limited here.
[0152] Step 702: Use reflection technology to reflect at least one UI control to obtain a control object corresponding to each UI control.
[0153] In the embodiment of the present application, a UI style changing device is also provided, which corresponds to the method embodiment, specifically as follows: Figure 8 As shown, including:
[0154] The receiving unit 801 is used to receive a voice skin-changing instruction triggered by a voice assistant, wherein the voice skin-changing instruction includes a style package identifier of a UI style package to be used;
[0155] A first determining unit 802 is used to determine at least one control object according to the reflection technology and all controls in the voice assistant;
[0156] The second determining unit 803 is used to determine, according to each control object, a target control object whose corresponding style can be replaced;
[0157] A third determining unit 804 is configured to determine the style replacement data of the target control object in multiple UI style packages according to the target control object and the style package identifier;
[0158] The replacing unit 805 is configured to replace the style data of the target control object by using the style replacement data of the target control object.
[0159] Optionally, the first determining unit 802 is configured to:
[0160] Among all controls in the voice assistant, determine at least one UI control for building a user interface;
[0161] Use reflection technology to reflect at least one UI control to obtain a control object corresponding to each UI control.
[0162] Optionally, the second determining unit 803 is configured to:
[0163] Get the properties of each control object;
[0164] In at least one control object, detecting whether there is a control object whose attribute is the target attribute;
[0165] When a control object having the attribute of the target attribute is detected, the control object is determined as a target control object whose corresponding skin can be replaced.
[0166] Optionally, the third determining unit 804 is configured to:
[0167] Determine, according to the style package identifier, a UI style package to be used from among multiple UI style packages;
[0168] According to the target control object, the style replacement data of the target control object is determined in the UI style package to be used.
[0169] Optionally, the third determining unit 804 is configured to:
[0170] According to the target control object, in the APK file of the voice assistant, determine the target control identifier of the target control object;
[0171] According to the target control identifier, searching for a property value corresponding to the target control identifier in the UI style package to be used;
[0172] The attribute value corresponding to the target control identifier is determined as the style replacement data of the target control object.
[0173] Optionally, the UI style package further includes properties and types corresponding to the control identifier, and the device further includes a detection unit 806, wherein the detection unit 806 is configured to:
[0174] According to the target control object, in the APK file of the voice assistant, determine the target attribute and target type corresponding to the target control object;
[0175] According to the target control identifier, determining a reference attribute and a reference type corresponding to the target control identifier in a UI style package to be used;
[0176] Detecting whether the target attribute is consistent with the reference attribute, and whether the target type is consistent with the reference type;
[0177] When the two are consistent, the property value corresponding to the target control identifier is searched in the UI style package to be used according to the target control identifier.
[0178] Optionally, the replacing unit 805 is used to:
[0179] According to the target control object, in the APK file of the voice assistant, determine the target control identifier of the target control object;
[0180] According to the target control identifier, determine the style data corresponding to the target control identifier in the APK file of the voice assistant;
[0181] The style data corresponding to the target control identifier is replaced using the style replacement data of the target control object.
[0182] like Figure 8 As shown, the embodiment of the present application provides a UI style changing device, including a processor 801, a communication interface 802, a memory 803 and a communication bus 804, wherein the processor 801, the communication interface 802, and the memory 803 communicate with each other through the communication bus 804.
[0183] Memory 803, used for storing computer programs;
[0184] In one embodiment of the present application, the processor 801 is used to implement the UI style changing method provided by any one of the aforementioned method embodiments when executing the program stored in the memory 803, including:
[0185] Receiving a voice skin-changing instruction triggered by a voice assistant, wherein the voice skin-changing instruction includes a style package identifier of a UI style package to be used;
[0186] Determine at least one control object based on the reflection technology and all controls in the voice assistant;
[0187] According to each control object, determine the target control object whose corresponding style can be replaced;
[0188] Determining style replacement data of the target control object in multiple UI style packages according to the target control object and the style package identifier;
[0189] The style data of the target control object is replaced using the style replacement data of the target control object.
[0190] An embodiment of the present application further provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the steps of the UI style changing method provided in any of the aforementioned method embodiments are implemented.
[0191] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0192] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a general hardware platform, and of course, by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the relevant technology can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0193] It should be understood that the terms used herein are only for the purpose of describing specific example embodiments and are not intended to be limiting. Unless the context clearly indicates otherwise, the singular forms "one", "an" and "said" as used herein may also be meant to include plural forms. The terms "include", "comprise", "contain", and "have" are inclusive, and therefore specify the existence of stated features, steps, operations, elements and / or parts, but do not exclude the existence or addition of one or more other features, steps, operations, elements, parts, and / or combinations thereof. The method steps, processes, and operations described herein are not interpreted as necessarily requiring them to be performed in the specific order described or illustrated, unless the execution order is clearly indicated. It should also be understood that additional or alternative steps may be used.
[0194] The foregoing is merely a specific embodiment of the present invention, which enables those skilled in the art to understand or implement the present invention. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features claimed herein.
Claims
1. A UI style changing method, characterized in that: The method comprises: Receiving a voice skin-changing instruction triggered by a voice assistant, wherein the voice skin-changing instruction includes a style package identifier of a UI style package to be used; Determine at least one control object based on the reflection technology and all controls in the voice assistant; According to each control object, determine the target control object whose corresponding style can be replaced; Determining style replacement data of the target control object in multiple UI style packages according to the target control object and the style package identifier; The style data of the target control object is replaced using the style replacement data of the target control object.
2. The method according to claim 1, characterized in that: The determining at least one control object according to the reflection technology and all controls in the voice assistant includes: Among all controls in the voice assistant, determine at least one UI control for building a user interface; Use reflection technology to reflect at least one UI control to obtain a control object corresponding to each UI control.
3. The method according to claim 1, characterized in that: The step of determining, according to each control object, a target control object whose corresponding style can be replaced includes: Get the properties of each control object; In at least one control object, detecting whether there is a control object whose attribute is the target attribute; When a control object having the attribute of the target attribute is detected, the control object is determined as a target control object whose corresponding skin can be replaced.
4. The method according to claim 1, characterized in that: The step of determining the style replacement data of the target control object in a plurality of UI style packages according to the target control object and the style package identifier includes: Determine, according to the style package identifier, a UI style package to be used from among multiple UI style packages; According to the target control object, the style replacement data of the target control object is determined in the UI style package to be used.
5. The method according to claim 4, characterized in that: The step of determining, according to the target control object, in a UI style package to be used, style replacement data of the target control object comprises: According to the target control object, in the APK file of the voice assistant, determine the target control identifier of the target control object; According to the target control identifier, searching for a property value corresponding to the target control identifier in the UI style package to be used; The attribute value corresponding to the target control identifier is determined as the style replacement data of the target control object.
6. The method according to claim 5, characterized in that: The UI style package also includes properties and types corresponding to the control identifier. Before searching for the property value corresponding to the target control identifier in the UI style package to be used according to the target control identifier, the method further includes: According to the target control object, in the APK file of the voice assistant, determine the target attribute and target type corresponding to the target control object; According to the target control identifier, determining a reference attribute and a reference type corresponding to the target control identifier in a UI style package to be used; Detecting whether the target attribute is consistent with the reference attribute, and whether the target type is consistent with the reference type; When the two are consistent, the property value corresponding to the target control identifier is searched in the UI style package to be used according to the target control identifier.
7. The method according to claim 1, characterized in that: The using the style replacement data of the target control object to replace the style data of the target control object includes: According to the target control object, in the APK file of the voice assistant, determine the target control identifier of the target control object; According to the target control identifier, determine the style data corresponding to the target control identifier in the APK file of the voice assistant; The style data corresponding to the target control identifier is replaced using the style replacement data of the target control object.
8. A UI style changing device, characterized in that: The device comprises: A receiving unit, configured to receive a voice skin-changing instruction triggered by a voice assistant, wherein the voice skin-changing instruction includes a style package identifier of a UI style package to be used; A first determining unit, configured to determine at least one control object according to the reflection technology and all controls in the voice assistant; A second determining unit is used to determine, according to each control object, a target control object whose corresponding style can be replaced; A third determining unit, configured to determine, according to the target control object and the style package identifier, style replacement data of the target control object in a plurality of UI style packages; A replacement unit is used to replace the style data of the target control object by using the style replacement data of the target control object.
9. A UI style changing device, characterized in that: include: at least one communication interface; at least one bus connected to the at least one communication interface; at least one processor connected to the at least one bus; at least one memory connected to the at least one bus, wherein the processor is configured to: Receiving a voice skin-changing instruction triggered by a voice assistant, wherein the voice skin-changing instruction includes a style package identifier of a UI style package to be used; Determine at least one control object based on the reflection technology and all controls in the voice assistant; According to each control object, determine the target control object whose corresponding style can be replaced; Determining style replacement data of the target control object in multiple UI style packages according to the target control object and the style package identifier; The style data of the target control object is replaced using the style replacement data of the target control object.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the UI style changing method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Skin replacement method and device, electronic equipment and readable storage medium
CN111061414A
Skin changing method and device
CN112015497A
Theme color switching method and device for hybrid development APP, equipment and medium
CN115495188A
Interface changing method and device, electronic equipment and storage medium
CN116501416A
UI service package generation and registration method and apparatus, and UI service loading method and apparatus
US20230110520A1