Method, system and application for converting static layout into dynamic layout

By obtaining the element data set and translation dictionary of the static layout, the static layout is efficiently converted into a dynamic layout, which solves the problem of low efficiency of static layout conversion and realizes the rapid completion of the conversion from static layout to dynamic layout.

CN118569211APending Publication Date: 2024-08-30SHENZHEN WANSHENG CULTURE TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410751888.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-12
Publication Date
2024-08-30

AI Technical Summary

Technical Problem

In the existing technology, the efficiency of converting static layout into dynamic layout is low, especially when a large number of static layout files need to be transformed one by one, which is time-consuming and labor-intensive, and there is a lack of efficient automation methods.

Method used

By obtaining all the elements in the static layout to form a data set to be converted, establishing a translation dictionary, converting the static layout file into a static layout file tree, and using the translation dictionary to convert into a dynamic layout file tree, achieving efficient conversion from static layout to dynamic layout.

Benefits of technology

It achieves high efficiency in converting static layout into dynamic layout. It only takes one scan and conversion to complete the conversion of the entire project, which significantly improves the conversion efficiency and reduces the time and labor of manual conversion.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118569211A
    Figure CN118569211A
Patent Text Reader

Abstract

In order to overcome the defects in the prior art, the method, system and application for converting the static layout into the dynamic layout are provided, and the method comprises the steps that layout elements of any element in the static layout to be converted are obtained, and a data set to be converted is formed; forming a one-to-one correspondence relationship between the to-be-converted data set and layout elements of corresponding elements in the dynamic layout by using the translation dictionary; converting the static layout file into a static layout file forest formed by static layout file trees, so that any static layout file tree can be retrieved; and converting any static layout file tree into a dynamic layout file tree until the whole static layout file forest is converted. According to the method, all the static layouts to be converted can be obtained only through one-time scanning, then all the static layouts existing in the project can be converted into the dynamic layouts through one-time conversion, and the conversion efficiency is greatly improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of graphical user interfaces, and in particular to a method, system and application for converting a static layout into a dynamic layout. Background Art

[0002] A graphical user interface (GUI) is a computer operation user interface that is displayed graphically. A graphical user interface is a human-computer interface display format that allows users to use input devices such as a mouse to manipulate icons or menu options on the screen to select commands, call files, start programs, or perform other daily tasks. Compared with character interfaces that use keyboards or clicks on the screen to enter text or character commands to complete routine tasks, graphical user interfaces have many advantages. Graphical user interfaces are composed of windows, drop-down menus, dialog boxes, and their corresponding control mechanisms. They are standardized in various new applications, that is, the same operations are always completed in the same way. In a graphical user interface, users see and operate graphic objects, which have better interactivity.

[0003] The GUI interface can be implemented in the project. The traditional implementation method is to implement it through static layout, such as XML on the Android system. When rendering the layout, this implementation method needs to first load the layout file into the memory, then parse the static layout file, and then render the interface elements on the screen. Among them, loading the layout file into the memory and parsing the layout file are the most time-consuming, which may account for more than 90% of the entire process.

[0004] In order to optimize the performance of rendering layout, various systems have subsequently launched dynamic layout solutions. For example, on Android, layout can be implemented in a pure code manner through Kotlin DSL or Jetpack Compose.

[0005] However, for projects that have existed for a long time, there may already be a large number of static layouts. The modification of these static layout files is currently mainly done by manual conversion, and only files can be converted one by one, which is time-consuming, labor-intensive and very inefficient.

[0006] Based on this, an efficient method for converting static layout into dynamic layout needs to be developed urgently. Summary of the invention

[0007] The present application provides a method, system and application for converting a static layout into a dynamic layout, which can improve the efficiency of converting a static layout into a dynamic layout.

[0008] Specifically, the technical solution is as follows:

[0009] A method for converting a static layout into a dynamic layout, comprising:

[0010] Obtaining layout elements of all elements in the static layout to be converted to form a data set to be converted;

[0011] Establishing a translation dictionary, and using the translation dictionary to establish a one-to-one correspondence between the data set to be converted and the layout elements of the corresponding elements in the dynamic layout;

[0012] Converting a static layout file into a static layout file forest consisting of static layout file trees, so that any static layout file tree can be retrieved;

[0013] Any of the static layout file trees is converted into a dynamic layout file tree until the entire static layout file forest is converted.

[0014] The static layout file tree includes:

[0015] The root of the static layout file tree is any layout element in the static layout.

[0016] The step of converting the static layout file into a static layout file forest consisting of static layout file trees so that any static layout file tree can be retrieved includes:

[0017] Take any layout file in the static layout file as a static layout file tree, extending from the root node through the branch node to the leaf node; and take any layout element in the layout file as the root node of the static layout file tree;

[0018] The layout element corresponding to the root node is used as a retrieval feature value, so that when performing a scanning retrieval, the corresponding static layout file tree can be obtained through the retrieval feature value, and then the entire static layout file forest can be obtained.

[0019] Get the layout elements of any element in the static layout to be converted, including:

[0020] In any UI drawing framework, include at least one static layout;

[0021] The layout elements involved in the static layout are screened to obtain the attributes and attribute values ​​of any layout element to form the data set to be converted.

[0022] The converting any of the static layout file trees into a dynamic layout file tree comprises:

[0023] Taking any layout file in the static layout file as a static layout file tree, and taking any layout element in the layout file as a root node of the static layout file tree;

[0024] Using the root node, traverse the static layout file tree to obtain data to be converted from any node in the static layout file tree;

[0025] The data to be converted corresponding to the node is converted into dynamic code attributes through a translation dictionary, thereby completing the process of converting the static layout file tree into a dynamic layout file tree.

[0026] A system for converting a static layout into a dynamic layout based on the method described above, comprising:

[0027] A storage module, used for storing a translation dictionary when a static layout to be converted is converted into a dynamic layout;

[0028] A collection module, used for collecting layout elements in the static layout to be converted;

[0029] A conversion module, which interacts with the acquisition module for data conversion of a static layout file into a static layout file forest consisting of static layout file trees, and enables any static layout file tree to be retrieved;

[0030] A processing module, which performs data interaction with the conversion module and the storage module, and is used to obtain the static layout file forest and convert any static layout file tree in the entire static layout file forest into a dynamic layout file tree;

[0031] The output module performs data interaction with the processing module and is used to display the converted dynamic layout.

[0032] The processing module comprises:

[0033] A first processing unit, performing data transmission with the conversion module, for acquiring the static layout file forest;

[0034] a second processing unit, which performs data transmission with the storage module, and is used to obtain the translation dictionary;

[0035] The third processing unit performs data transmission with the first processing unit and the second processing unit, and is used to obtain the static layout file forest, and convert any static layout file tree in the entire static layout file forest into a dynamic layout file tree according to the translation dictionary.

[0036] An application of the method as described above, comprising:

[0037] In the Android system, all layout elements in the static layout to be converted are read to form a data set to be converted;

[0038] When converting a static layout file into a static layout file forest consisting of a static layout file tree, any layout element in the static layout to be converted is used as a root node; and when scanning, the layout element as the root node is used as a feature value to obtain data to be converted of any node in the static layout file tree;

[0039] Using the root node, traverse the static layout file tree to obtain data to be converted from any node in the static layout file tree;

[0040] The data to be converted corresponding to the node is converted into dynamic code attributes through a translation dictionary, thereby completing the process of converting the static layout file tree into a dynamic layout file tree.

[0041] An electronic device for converting a static layout into a dynamic layout, comprising:

[0042] Storage medium for storing computer programs;

[0043] The processing unit exchanges data with the storage medium, and is used to execute the computer program through the processing unit to perform the steps of the method for converting the static layout into the dynamic layout as described above when converting the static layout into the dynamic layout.

[0044] A computer readable storage medium:

[0045] The computer readable storage medium stores a computer program;

[0046] When the computer program is running, the steps of the method for converting a static layout into a dynamic layout as described above are executed.

[0047] This application has at least the following beneficial effects:

[0048] The method for converting a static layout into a dynamic layout described in the present application first obtains the layout elements of any element in the static layout to be converted to form a data set to be converted; then, a translation dictionary is established, and the data set to be converted is formed into a one-to-one correspondence with the layout elements of the corresponding elements in the dynamic layout using the translation dictionary; then, the static layout file is converted into a static layout file forest composed of static layout file trees, so that any static layout file tree can be retrieved; finally, any of the static layout file trees is converted into a dynamic layout file tree until the entire static layout file forest is converted. The method for converting a static layout into a dynamic layout described in the present application can obtain all static layouts to be converted through only one scan, and then all existing static layouts in the project can be converted into dynamic layouts through one conversion, which greatly improves the conversion efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0049] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0050] Figure 1 A flowchart of the method for converting a static layout into a dynamic layout described in the present application;

[0051] Figure 2 A flowchart for retrieving any static layout file tree in the method for converting a static layout into a dynamic layout described in this application;

[0052] Figure 3 A flowchart of converting any of the static layout file trees into a dynamic layout file tree in the method described in this application;

[0053] Figure 4 A block diagram of a system for converting a static layout into a dynamic layout as described in the present application;

[0054] Figure 5 for Figure 3 Block diagram of the processing module in the figure;

[0055] Figure 6 A flowchart of the application described in this application;

[0056] exist Figure 3-4 middle:

[0057] 100. Storage module; 200. Acquisition module; 300. Conversion module; 400. Processing module; 500. Output module; 401. First processing unit; 402. Second processing unit; 403. Third processing unit. DETAILED DESCRIPTION

[0058] Those skilled in the art will appreciate that the modules in the device in the implementation scenario can be distributed in the device in the implementation scenario according to the implementation scenario description, or can be changed accordingly and located in one or more devices different from the implementation scenario. The modules in the above implementation scenario can be combined into one module, or can be further split into multiple sub-modules.

[0059] In order to explain the present application in detail, the following embodiments are provided, and the technical solution of the present application will be explained in detail in conjunction with the accompanying drawings.

[0060] Specific embodiment 1:

[0061] This application provides an embodiment:

[0062] like Figure 1 A method for converting a static layout into a dynamic layout, comprising: obtaining the layout elements of any element in the static layout to be converted to form a data set to be converted; establishing a translation dictionary, and using the translation dictionary to form a one-to-one correspondence between the data set to be converted and the layout elements of the corresponding elements in the dynamic layout; converting the static layout file into a static layout file forest composed of static layout file trees, so that any static layout file tree can be retrieved; converting any of the static layout file trees into a dynamic layout file tree until the entire static layout file forest is converted; wherein the static layout file tree comprises: the root of the static layout file tree is any layout element in the static layout; the layout element can be the width, height, etc. of the element, as well as the specific values ​​of the width and height.

[0063] Specifically, when obtaining the layout elements of any element in the static layout to be converted, it includes: within a UI drawing framework, including at least one static layout; screening the layout elements involved in the static layout, obtaining the attributes and attribute values ​​of any layout element, and forming the data set to be converted.

[0064] like Figure 2 When converting the static layout file into a static layout file forest composed of static layout file trees, any static layout file tree can be retrieved or scanned, including: taking any layout file in the static layout file as a static layout file tree, extending from the root node through the branch node to the leaf node; and taking any layout element in the layout file as the root node of the static layout file tree; taking the layout element corresponding to the root node as a retrieval feature value, so that when scanning and retrieving, the corresponding static layout file tree can be obtained through the retrieval feature value, and then the entire static layout file forest is obtained.

[0065] like Figure 3 , the conversion of any of the static layout file trees into a dynamic layout file tree includes: taking any layout file in the static layout file as a static layout file tree, and taking any layout element in the layout file as the root node of the static layout file tree; using the root node, traversing the static layout file tree, and obtaining the data to be converted of any node in the static layout file tree; converting the data to be converted corresponding to the node into dynamic code attributes through a translation dictionary, thereby completing the process of converting the static layout file tree into a dynamic layout file tree. The translation dictionary described in this embodiment includes: a one-to-one correspondence between the layout elements in the static layout file and the layout elements in the dynamic layout file; the correspondence is a rule artificially specified according to needs.

[0066] It can be seen that the method described in this embodiment first forms a static file forest with all static files in the form of a static file tree; and when forming the static file tree, the root node is used as the retrieval feature value; at the same time, the layout element is used as the root node, and when scanning the static file forest with the root node, the corresponding file tree can be obtained according to the root node; and then the static file tree is converted into a dynamic file tree by using a converter; thus, the entire static file forest is converted into a dynamic file forest. The converter can be self-constructed by Java, and its purpose is to convert any static file tree into a corresponding dynamic file tree.

[0067] Specific embodiment II:

[0068] This application also provides an embodiment:

[0069] like Figure 4 A system for converting a static layout into a dynamic layout based on the method described above comprises: a storage module 100, a collection module 200, a conversion module 300, a processing module 400 and an output module 500; wherein the storage module 100, such as any storage unit RAM, is used to store a translation dictionary when the static layout to be converted is converted into a dynamic layout; the collection module 200 is used to collect layout elements in the static layout to be converted; the conversion module 300 interacts with the collection module 200 for data conversion of a static layout file into a static layout file forest composed of static layout file trees, and enables any static layout file tree to be retrieved; the processing module 400 interacts with the conversion module 300 and the storage module 100 for data acquisition of the static layout file forest, and converts any static layout file tree in the entire static layout file forest into a dynamic layout file tree; the output module 500 interacts with the processing module 400 for data display of the converted dynamic layout.

[0070] Specifically, the processing module 400 includes: a first processing unit 401, a second processing unit 402 and a third processing unit 403; Figure 5 The first processing unit 401 performs data transmission with the conversion module 300 to obtain the static layout file forest; the second processing unit 402 performs data transmission with the storage module 100 to obtain the translation dictionary; the third processing unit 403 performs data transmission with the first processing unit 401 and the second processing unit 402 to obtain the static layout file forest, and converts any static layout file tree in the entire static layout file forest into a dynamic layout file tree according to the translation dictionary.

[0071] Specific embodiment III:

[0072] The present application also provides a specific embodiment:

[0073] like Figure 6 , an application of the method described in a specific embodiment I in an Android system specifically includes:

[0074] In an Android system, FrameLayout or ConstraintLayout is used as a layout element to form a data set to be converted; when a static layout file is converted into a static layout file forest consisting of a static layout file tree, FrameLayout or ConstraintLayout is used as a root node; and when scanning, FrameLayout or ConstraintLayout is used as a feature value to obtain the data to be converted of any node in the static layout file tree; using the root node, traversing the static layout file tree, and obtaining the data to be converted of any node in the static layout file tree; converting the data to be converted corresponding to the node into dynamic code attributes through a translation dictionary, thereby completing the process of converting the static layout file tree into a dynamic layout file tree.

[0075] Specifically, the steps of this embodiment are as follows:

[0076] The first step is to obtain the elements of static layout:

[0077] Static layout elements mainly include: FrameLayout, ConstraintLayout, etc. on Android; attributes of layout elements, such as the width and height of the above elements, and the values ​​of the above layout element attributes. In a set of UI drawing frameworks, there may be several layouts, that is, more layout elements and attributes of layout elements, as well as possible value types of each attribute. Therefore, in this embodiment, it is necessary to establish a complete translation dictionary between each layout element and / or attribute and / or attribute value from static layout to dynamic layout, and establish a one-to-one correspondence.

[0078] The second step is to process the static files and obtain the static layout file forest:

[0079] There may be a large number of static layout files in the project code to be processed. In this embodiment, each layout file presents a tree structure, extending from the root node through the branch node to the leaf node, that is, a static layout file tree. All these layout file "trees" constitute a layout file forest.

[0080] However, there may be other description files similar to layout files in the project. For example, in the Android system, in addition to the layout XML file, there are also configuration XML files for various attributes. You need to retrieve the entire layout "forest" from all these static description files. In this step, you can use the characteristics of the layout file: its root node must be a layout element, such as FrameLayout, ConstraintLayout, etc. mentioned in the first step, and only the layout description file meets this feature. Therefore, in the process of scanning the attribute description file, you can retrieve each layout file tree through this unique feature value, and then retrieve the "forest" composed of the entire static layout file tree.

[0081] The third step is to convert the static layout file into a dynamic layout file:

[0082] For each tree in the static layout file forest, the converter converts it into a "tree" of dynamic code layout, that is, a dynamic layout file tree. For each specific static layout file tree, traverse from the root node. This process can adopt any of the pre-order / post-order / in-order / layer order, as long as every node is visited and translated into dynamic code attributes through static attributes. For each specific node, all attributes of the node must be traversed, and each static attribute / attribute value must be translated into an attribute / attribute value represented by the dynamic code.

[0083] In the fourth step, the process is repeated for each tree until the entire static layout file forest is converted. Through the above steps, it can be seen that the method described in this application can obtain all static layouts to be converted by only one scan, and then through another conversion, all static layouts in the project can be converted into dynamic layouts. The original work that required several people for one month can be completed by automated execution in just a few hours using the method described in this embodiment, which greatly improves the conversion efficiency.

[0084] This application also provides an embodiment:

[0085] An electronic device for converting a static layout into a dynamic layout, comprising: a storage medium and a processing unit; wherein the storage medium is used to store a computer program; the processing unit exchanges data with the storage medium, and is used to execute the computer program through the processing unit when converting the static layout into a dynamic layout, and perform the steps of the method for converting the static layout into a dynamic layout as described in specific embodiment I.

[0086] This application also provides an embodiment:

[0087] A computer-readable storage medium: the computer-readable storage medium stores a computer program;

[0088] When the computer program is running, it executes the steps of the method for converting a static layout into a dynamic layout as described in Specific Embodiment 1.

[0089] In the present application, a readable storage medium may be any tangible medium that contains or stores a program, as long as it can be recognized by an Android platform or a computer; the program may be used by or in combination with an instruction execution system, device, or device. In the present invention, a readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A readable signal medium may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by or in combination with an instruction execution system, device, or device. The program code contained on the readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.

[0090] The present invention provides an embodiment, including a program product, which includes a program carried on an Android platform readable medium, the program including a program for executing Figure 1-3 The program code of the method shown in any of the flowcharts described in the present invention. The program can be downloaded and installed from the Internet. When the program is executed by the CPU, the functions defined in the system of the present invention are executed; the CPU described here can be any controller chip that supports the Android platform or the PC end.

[0091] The above serial numbers of the present invention are only for description and do not represent the advantages or disadvantages of the implementation scenarios.

[0092] The above disclosures are only several specific implementation scenarios of the present application, but the present application is not limited thereto, and any changes that can be thought of by a person skilled in the art should fall within the protection scope of the present application. The above application numbers are only for description and do not represent the advantages and disadvantages of the implementation scenarios.

Claims

1. A method for converting a static layout into a dynamic layout, characterized in that: include: Obtaining layout elements of all elements in the static layout to be converted to form a data set to be converted; The data set to be converted is used to establish a one-to-one correspondence with the layout elements of the corresponding elements in the dynamic layout by using an existing translation dictionary; Converting a static layout file into a static layout file forest consisting of static layout file trees, so that any static layout file tree can be retrieved; Any of the static layout file trees is converted into a dynamic layout file tree until the entire static layout file forest is converted.

2. The method for converting a static layout into a dynamic layout according to claim 1, characterized in that: The static layout file tree includes: The root node of the static layout file tree is any layout element in the static layout.

3. The method for converting a static layout into a dynamic layout according to claim 1, characterized in that: The step of converting the static layout file into a static layout file forest consisting of static layout file trees so that any static layout file tree can be retrieved includes: Take any layout file in the static layout file as a static layout file tree, extending from the root node through the branch node to the leaf node; and take any layout element in the layout file as the root node of the static layout file tree; The layout element corresponding to the root node is used as a retrieval feature value, so that when performing a scanning retrieval, the corresponding static layout file tree can be obtained through the retrieval feature value, and then the entire static layout file forest can be obtained.

4. The method for converting a static layout into a dynamic layout according to claim 1, characterized in that: Get the layout elements of any element in the static layout to be converted, including: In any UI drawing framework, include at least one static layout; The layout elements included in the static layout are screened to obtain the attributes and attribute values ​​of any layout element to form the data set to be converted.

5. The method for converting a static layout into a dynamic layout according to claim 1, characterized in that: The converting any of the static layout file trees into a dynamic layout file tree comprises: Taking any layout file in the static layout file as a static layout file tree, and taking any layout element in the layout file as a root node of the static layout file tree; Using the root node, traverse the static layout file tree to obtain data to be converted from any node in the static layout file tree; The data to be converted corresponding to the node is converted into dynamic code attributes through a translation dictionary, thereby completing the process of converting the static layout file tree into a dynamic layout file tree.

6. A system for converting a static layout into a dynamic layout based on the method according to any one of claims 1 to 5, characterized in that: include: A storage module, used for storing a translation dictionary when a static layout to be converted is converted into a dynamic layout; A collection module, used for collecting layout elements in the static layout to be converted; A conversion module, which interacts with the acquisition module for data conversion of a static layout file into a static layout file forest consisting of static layout file trees, and enables any static layout file tree to be retrieved; A processing module, which performs data interaction with the conversion module and the storage module, and is used to obtain the static layout file forest and convert any static layout file tree in the entire static layout file forest into a dynamic layout file tree; The output module performs data interaction with the processing module and is used to display the converted dynamic layout.

7. The system for converting a static layout into a dynamic layout according to claim 6, characterized in that: The processing module comprises: A first processing unit, performing data transmission with the conversion module, for acquiring the static layout file forest; a second processing unit, which performs data transmission with the storage module, and is used to obtain the translation dictionary; a third processing unit, which performs data transmission with the first processing unit and the second processing unit, and is used to obtain the static layout file forest, and convert any static layout file tree in the entire static layout file forest into a dynamic layout file tree according to the translation dictionary; The third processing unit performs data interaction with the output module to display the converted dynamic layout.

8. An application of the method according to any one of claims 1 to 5, characterized in that: include: In the Android system, all layout elements in the static layout to be converted are read to form a data set to be converted; When converting a static layout file into a static layout file forest consisting of a static layout file tree, any layout element in the static layout to be converted is used as a root node; and when scanning, the layout element as the root node is used as a feature value to obtain data to be converted of any node in the static layout file tree; Using the root node, traverse the static layout file tree to obtain data to be converted from any node in the static layout file tree; The data to be converted corresponding to the node is converted into dynamic code attributes through a translation dictionary, thereby completing the process of converting the static layout file tree into a dynamic layout file tree.

9. An electronic device for converting a static layout into a dynamic layout, characterized in that: include: Storage medium for storing computer programs; A processing unit exchanges data with the storage medium, and is used to execute the computer program through the processing unit when converting the static layout into the dynamic layout, and perform the steps of the method for converting the static layout into the dynamic layout as described in any one of claims 1 to 5.

10. A computer-readable storage medium, characterized in that: The computer readable storage medium stores a computer program; When the computer program is run, the computer program executes the steps of the method for converting a static layout into a dynamic layout as claimed in any one of claims 1 to 5.