Adaptive layout optimization method and device for folding screen

By identifying the folding device model and display mode, pre-calculate the layout, and using Map cache and component multiplexing technology, the interface layout adjustment problem of folding screen devices in different states is solved, achieving an efficient and smooth user experience.

CN120216080APending Publication Date: 2025-06-27INSPUR ZHUOSHU BIG DATA IND DEV CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510301379.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-14
Publication Date
2025-06-27

AI Technical Summary

Technical Problem

How to intelligently identify the device shape and automatically adjust the interface layout in the expanded and folded state of the folding screen device, ensure that users enjoy a smooth, consistent and efficient interactive experience in different usage scenarios.

Method used

Identify the folding device model through cold start, predict the user equipment display mode and pre-calculate the layout of each mode in memory, use the Map data structure to store the layout templates that have been parsed, and monitor the physical folding state of the device to achieve effective reuse of components.

Benefits of technology

It realizes accurate identification of folding device models and display modes, pre-packaged different folding style layouts, optimizes performance based on the Map cache mechanism, and monitors folding status to achieve component reuse, improving the system's application development efficiency, adaptability, performance and experience on folding devices.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120216080A_ABST
    Figure CN120216080A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of computers, and particularly provides an adaptive layout optimization method and device for a folding screen, and the method comprises the following steps: S1, recognizing the model of folding equipment through cold start; s2, predicting a user equipment display mode and pre-calculating and storing each mode layout in a memory; s3, storing the parsed layout template by using a Map data structure; and S4, monitoring the physical folding state of the equipment to realize effective multiplexing of the component. Compared with the prior art, the page response time can be effectively shortened, and the use experience of the user under the folding operation is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and specifically provides a method and device for optimizing the adaptive layout of a folding screen. Background Art

[0002] The emergence of the folding screen system marks another innovation in the form of mobile devices. To give full play to the advantages of folding screen devices and overcome the challenges they bring, system developers have introduced dynamic layout adjustment and component preloading strategies to optimize the user experience.

[0003] The dynamic layout adjustment technology is one of the keys to enhancing the user experience of the folding screen system. This technology can real-time monitor the folding state of the device and automatically adjust the interface layout accordingly, ensuring a comfortable and beautiful visual experience for users in different forms. The realization of this technology depends on the system's accurate perception and efficient response to the device's hardware state, as well as its flexible control ability over the application interface layout.

[0004] At the same time, the component preloading strategy is also an important means to improve the page response speed of the folding screen system. When the system starts or an application is installed, the preloading strategy will preload and cache key components and data, so that they can be quickly called when the user needs them, thus avoiding the cumbersome process of downloading data from the server again. This strategy not only significantly shortens the page loading time, but also improves the overall operating efficiency of the system.

[0005] Therefore, how to overcome the challenge of making the screen size and ratio change invisibly when the folding screen is in the unfolded and folded states, and ensure that users can enjoy a smooth, consistent and efficient interaction experience in different usage scenarios by intelligently identifying the device form and automatically adjusting the interface layout is an urgent problem to be solved by those skilled in the art. Summary of the Invention

[0006] The present invention aims at the above-mentioned deficiencies of the prior art and provides a folding screen adaptive layout optimization method with strong practicability.

[0007] The further technical task of the present invention is to provide a folding screen adaptive layout optimization device with reasonable design, safety and applicability.

[0008] The technical solution adopted by the present invention to solve its technical problems is as follows:

[0009] The folding screen adaptive layout optimization method has the following steps:

[0010] S1. Identify the folding device model during cold start;

[0011] S2. Predict the user device display mode and pre-calculate and store the layout of each mode in memory;

[0012] S3. Use the Map data structure to store the parsed layout templates that have been completed;

[0013] S4. Listen for the physical folding state of the device to achieve effective reuse of components.

[0014] Further, in step S1, when the user opens, switches, or returns to the application, the UIAbility instance in the application will transition between different states of its lifecycle. When the UIAbility instance is created, the system will trigger the onCreate() callback function. After the UIAbility instance is created and before entering the foreground Foreground, the system will create a WindowStage object. After the WindowStage is created, it will enter the onWindowStageCreate() callback function.

[0015] Further, in the onWindowStageCreate() callback function, use the display.isFoldable method to determine whether the current device is a foldable device. When the call result of this method indicates that the device is foldable, further call the display.getAllDisplays method to obtain all display objects through this synchronous call operation;

[0016] Subsequently, asynchronously call the display.getFoldDisplayMode method to obtain all display modes of these foldable devices. The return value of the API will be presented in the form of an enumeration of the display modes of the foldable devices. By parsing this enumeration value, it is known whether the device is in a double-fold, triple-fold, or half-fold style.

[0017] Further, in step S2, the half-fold, double-fold, and triple-fold styles are pre-encapsulated respectively. The steps are as follows:

[0018] (1) Window information acquisition and processing;

[0019] (2) Root layout creation and setting, constructing the infrastructure of the half-fold layout, and creating a rootLayout object of the DirectionalLayout type as the root container of the entire layout;

[0020] (3) Creation and configuration of the left and right split-screen layouts, creating two layout objects of the FlexLayout type, namely leftLayout and rightLayout;

[0021] (4) Add custom components, and call the createCustomComponent method to create custom components;

[0022] (5) The combined layout forms a complete semi-folded layout.

[0023] Furthermore, in step (1), first, the function calls the context.getWindow() method to obtain the window class object associated with the current UIAbility, denoted as windowClass.

[0024] Next, the windowClass.getWindowStage() method is used to further obtain the window stage object windowStage, and the object windowStage contains information about the current stage of the window.

[0025] Subsequently, the windowStage.getLayoutConfig() method is called to obtain the layout configuration information, which is stored in the layoutConfig variable. From layoutConfig, the two key layout parameters screenWidth and screenHeight are extracted, representing the designed width and height of the current device screen, and will be used as the basis for setting the subsequent layout dimensions.

[0026] In step (2), the width is set to the previously obtained screenWidth, the height is set to screenHeight, and at the same time, the layout direction of rootLayout is set to Horizontal, meaning that the elements in this layout will be arranged in sequence in the horizontal direction.

[0027] Furthermore, in step (3), for leftLayout, its width is set to screenWidth / 2, so that it occupies the left half of the screen, and the height is set to screenHeight to fill the entire vertical space of the screen.

[0028] The direction property of leftLayout is set to FlexDirection.Vertical, which indicates that the elements within the layout will be arranged in the vertical direction, and both the justifyContent and alignItems properties are assigned FlexAlign.Center, aiming to center-align the elements in leftLayout both horizontally and vertically.

[0029] For rightLayout, the same setting operations are performed so that it occupies the right half of the screen, ensuring that the left and right two parts of the layout are symmetrically distributed on the screen.

[0030] In step (4), the createCustomComponent method is called to create a custom component, passing context and the parameter "Left of Half Fold". The generated component is stored in the leftCustomComponent variable. Here, context provides relevant information about the application, and "Left of Half Fold" is the identifier of the component.

[0031] Subsequently, the leftCustomComponent component is added to leftLayout to integrate it into the left half layout.

[0032] For the right layout, the createCustomComponent method is also used, passing context and "Right of Half Fold" as parameters. The generated component is stored in the rightCustomComponent variable, and then it is added to rightLayout to incorporate it into the right half layout.

[0033] In step (5), through the two statements rootLayout.addComponent(leftLayout); and rootLayout.addComponent(rightLayout); the left and right split-screen layouts are added to the root layout rootLayout, thus forming a complete half-fold layout.

[0034] Finally, the statement return rootLayout; is used to return the generated root layout container.

[0035] Furthermore, in step S3, when a layout is needed, first check whether the corresponding layout already exists in the cache. If it exists, use it directly.

[0036] After preloading the custom layout through step S2, the custom layouts of all displays of the folding device are obtained. Then, a static asynchronous method getLayout is defined to receive a single parameter layoutId of type string, which is used to identify the required layout template and return a layout container of type layout.ComponentContainer. When listening to the screen folding state, first check whether layoutCache already stores the layout with the specified layoutId. Through the conditional judgment statement if(this.layoutCache.has(layoutId)), it will look for the corresponding key in the layoutCache Map.

[0037] If there is a corresponding layout, i.e., the has method returns true, it means that the required layout has been parsed and stored in the cache. At this time, a message will be output to the console, prompting the user "Layout with id${layoutId}found incache.", indicating that the layout has been found in the cache. Then, return this.layoutCache.get(layoutId); retrieve the layout from layoutCache and return it as the result;

[0038] If there is a corresponding layout, i.e., the has method returns true, it means that the required layout has been parsed and stored in the cache. At this time, a message will be output to the console, prompting the user "Layout with id${layoutId}found incache.", indicating that the layout has been found in the cache;

[0039] Then, return this.layoutCache.get(layoutId); retrieve the layout from layoutCache and return it as the result;

[0040] If there is no corresponding layout, i.e., the has method returns false, an unloaded message will be output to notify the user that the layout is not in the cache and needs to be parsed;

[0041] In an actual development scenario, the layout template is parsed according to step S2. The specific implementation will be completed according to the system's layout parsing service. When calling the parsing operation, the await keyword is used to wait for the parsing to complete;

[0042] After the parsing is completed, a parsed layout container will be obtained and stored in the container variable. Subsequently, call this.storeParsedLayout(layoutId,container); store the parsed layout in layoutCache for subsequent use.

[0043] Furthermore, in step S4, the display.on('foldStatusChange') method is used to start listening for changes in the folding status of the folding device. When the status of the folding device changes, the listening result returns one of the enumeration types,

[0044] Specific enumerations include: FOLD_STATUS_UNKNOWN indicates that the current folding status of the device is unknown, FOLD_STATUS_EXPANDED indicates that the current folding status of the device is fully expanded, FOLD_STATUS_FOLDED indicates that the current folding status of the device is folded, and FOLD_STATUS_HALF_FOLDED indicates that the current folding status of the device is half-folded. Half-folded refers to the state between fully expanded and folded;

[0045] According to the returned enumeration type, a custom folding status cache layout is generated by passing the corresponding layoutId parameter to the getLayout method in step S3, achieving the effect of listening and dynamic layout.

[0046] Furthermore, the component ArkTS is effectively reused. In ArkUI, when the page exits, the system will follow the default rules and first clarify the prerequisite that creating a NodeContainer requires a NodeItem;

[0047] Then, search for the NodeItem in the NodePool, and then enter the key judgment link, that is, judge whether there is a NodeItem of the corresponding type in the NodePool;

[0048] If it does not exist, a new NodeItem will be created and the build operation will be performed, and at the same time, the update method of the internal custom component will be bound to this NodeItem;

[0049] If it exists, take out a NodeItem from the NodePool and trigger the update operation;

[0050] In either case, after the reuse of the NodeItem is completed, the NodeContainer will be destroyed, and the NodeItem in the NodeContainer will be recycled into the cache pool, and the entire process ends here.

[0051] The folding screen adaptive layout optimization device includes: at least one memory and at least one processor;

[0052] The at least one memory is used to store machine-readable programs;

[0053] The at least one processor is used to call the machine-readable program and execute the folding screen adaptive layout optimization method.

[0054] Compared with the prior art, the folding screen adaptive layout optimization method and device of the present invention have the following prominent beneficial effects:

[0055] 1. Accurately identify the folding device model: When the user operates the application, the UIAbility instance state transitions. In a specific callback function, use the corresponding method to determine whether the device is foldable. If it is foldable, further obtain the display mode enumeration value, and based on this, clarify the device folding style, providing a basis for differential development optimization and enhancing the experience by adapting to the device.

[0056] 2. Pre-encapsulate layouts for different folding styles: Folding screen encapsulation idea: Obtain window information: Sequentially call methods to obtain the window class object, window stage object, and layout configuration information, and extract the screen width and height for subsequent layouts. Create the root layout: Create the root container and set the width, height, and direction. Create the split-screen layout: Create the left and right split-screen layouts, set the width, height, direction, and element alignment method to make them symmetrically distributed. Add custom components: Create and add custom components to the split-screen layout to enhance functionality. Combine layouts: Add the split-screen layout to the root layout and return the root layout. This process creates a layout for semi-foldable devices, and similarly, it can be used for other folding styles to improve development efficiency and adaptability.

[0057] 3. Optimize performance based on the Map cache mechanism: After preloading, use Map to cache the parsed layout templates. Define a method that receives a parameter to identify the layout. When listening, first check the cache. If there is a match, use it directly; otherwise, parse and store it to avoid repeated parsing, improve the response speed and performance, and solve the performance overhead problem.

[0058] 4. Listen to the folding state to achieve component reuse and improve performance: Listen to the device folding state and generate a cached layout according to the returned enumeration to achieve a dynamic effect. The folding application interface needs to be updated frequently. The component reuse strategy can avoid repeated creation and destruction of views. Manage the reusable NodeItem according to the principle to improve resource utilization and performance, meet the update requirements, and enhance the experience.

[0059] In summary, the present invention innovates in many aspects, improving the application development efficiency, adaptability, performance, and experience of the system on folding devices, and having significant beneficial effects and practical values. BRIEF DESCRIPTION OF THE DRAWINGS

[0060] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the following drawings are some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0061] Attached Figure 1 is a flowchart of an adaptive layout optimization method for a folding screen;

[0062] Attached Figure 2 is a flowchart of component reuse in an adaptive layout optimization method for a folding screen. Detailed implementation manners

[0063] To enable those skilled in the art of this technology to better understand the solution of the present invention, the present invention will be further described in detail below in conjunction with specific implementation manners. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.

[0064] The following gives a best embodiment:

[0065] As Figure 1 shown, in the folding screen adaptive layout optimization method of this embodiment, the specific model of the folding device is identified and authenticated, and the switching requirements of the user device in the display mode are pre-perceived. Based on this prediction, the system pre-computes and stores the layout schemes corresponding to each display mode. To improve efficiency, a caching mechanism is used to store the parsed layout templates. At the same time, the system continuously monitors the physical folding state of the device so that the interface layout can be adjusted immediately and dynamically when the device form changes. In addition, by using the component reuse technology, the interface response time is effectively reduced, and the user experience is improved.

[0066] The specific steps are as follows:

[0067] S1. Identify the folding device model during cold start;

[0068] When the user opens, switches, or returns to a HarmonyOS application, the UIAbility instance in the application will transition between different states in its life cycle. When the UIAbility instance is created, the system will trigger the onCreate() callback function. After the UIAbility instance is created and before entering the foreground, the system will create a WindowStage object. After the WindowStage is created, it will enter the onWindowStageCreate() callback function.

[0069] In this callback function, the display.isFoldable method is used to determine whether the current device is a foldable device. When the call result of this method indicates that the device is foldable, we will further call the display.getAllDisplays method to obtain all display objects through this synchronous call operation. Subsequently, we will asynchronously call the display.getFoldDisplayMode method to obtain all display modes of these foldable devices. The return value of this API will be presented in the form of an enumeration of the display modes of the foldable device. By parsing this enumeration value, we can clearly know whether the device is in a double-fold, triple-fold, or half-fold style. Such an operation process can help us accurately identify the folding style of the foldable device during development, providing an important basis for subsequent differential development and optimization for different folding styles.

[0070] S2. Predict the display mode of the user device and pre-calculate and store the layouts of each mode in memory;

[0071] Based on the folding styles of HarmonyOS devices on the market, pre-packaging has been carried out for the half-fold, double-fold, and triple-fold styles respectively. In this embodiment, when packaging the half-fold screen, the following steps are involved:

[0072] (1) Window information acquisition and processing;

[0073] First, the function calls the context.getWindow() method. This operation aims to obtain the window class object associated with the current UIAbility, denoted as windowClass.

[0074] Next, the windowClass.getWindowStage() method is used to further obtain the window stage object windowStage, which contains information about the current stage of the window.

[0075] Subsequently, the windowStage.getLayoutConfig() method is called to obtain the layout configuration information, which is stored in the layoutConfig variable. From layoutConfig, two key layout parameters, screenWidth and screenHeight, are extracted. They represent the designed width and height of the current device screen and will be used as the basis for setting the subsequent layout dimensions.

[0076] (2) Root layout creation and setting;

[0077] Build the infrastructure of the half-fold layout and create a rootLayout object of the DirectionalLayout type as the root container of the entire layout.

[0078] To ensure that the rootLayout can cover the entire screen area, set its width to the previously obtained screenWidth and its height to screenHeight. At the same time, set the layout direction of the rootLayout to Horizontal, which means that the elements in this layout will be arranged in sequence horizontally.

[0079] (3) Creation and configuration of the split-screen layout on the left and right;

[0080] To simulate the display areas on the left and right of a semi-folded device, create two layout objects of the FlexLayout type, namely leftLayout and rightLayout.

[0081] For leftLayout, set its width to screenWidth / 2 so that it occupies the left half of the screen, and set its height to screenHeight to fill the entire vertical space of the screen.

[0082] The direction property of leftLayout is set to FlexDirection.Vertical, which indicates that the elements within this layout will be arranged vertically. The justifyContent and alignItems properties are both assigned the value FlexAlign.Center. The purpose is to center-align the elements in leftLayout both horizontally and vertically to achieve a more aesthetic and reasonable layout effect. For rightLayout, perform the same setting operations so that it occupies the right half of the screen, ensuring that the left and right layout parts are symmetrically distributed on the screen, providing a visually balanced display effect for users.

[0083] (4) Adding custom components;

[0084] First, call the createCustomComponent method to create a custom component. By passing the context and the parameter "Left of Half Fold", the generated component is stored in the leftCustomComponent variable. Among them, the context provides relevant information about the application, and "Left of Half Fold" is the identifier of this component. Subsequently, add the leftCustomComponent component to the leftLayout to integrate it into the left half layout.

[0085] For the right layout, the createCustomComponent method is also used, passing context and "Right ofHalf Fold" as parameters. The generated component is stored in the rightCustomComponent variable and then added to the rightLayout, thus incorporating it into the right half layout.

[0086] Such an operation aims to add custom components to the left and right layout parts, enhancing the personalization and functionality of the layout.

[0087] (5) Composite layout;

[0088] In the present invention, through the two statements rootLayout.addComponent(leftLayout); and rootLayout.addComponent(rightLayout); the left and right split-screen layouts are added to the root layout rootLayout, thereby forming a complete half-fold layout.

[0089] Finally, the return rootLayout; statement is used to return the generated root layout container, which encompasses the left and right split-screen layouts and their respective custom components.

[0090] First, window information is obtained by means of relevant methods, which will provide the necessary basis for the subsequent creation of the layout. Subsequently, the root layout is created, which forms the basis of the overall architecture. After that, left and right split-screen layouts are created respectively to adapt to the half-fold state. Then, custom components are added to the left and right split-screen layouts to add personalized elements. Finally, the left and right split-screen layouts are combined into the root layout to form a complete half-fold layout and returned as the final result for use.

[0091] This process includes a series of operations from basic information acquisition to final layout construction, aiming to create a complete and customizable interface layout solution for half-fold devices.

[0092] S3. Use the Map data structure to store the parsed layout templates;

[0093] To reduce the response time after preloading on HarmonyOS foldable screens and optimize the performance of layout processing, a Map-based caching mechanism is adopted to store the parsed layout templates. This mechanism aims to solve the performance overhead problem caused by repeated parsing of layout templates. By storing the parsed layout templates in the Map, when a layout is needed, first check whether the corresponding layout already exists in the cache. If it exists, it is directly used, avoiding repeated parsing, thereby improving the response speed and performance of the application.

[0094] After preloading the custom layout through step S2, the custom layout of all displays of the folding device is obtained. Then, a static asynchronous method getLayout is defined to receive a single parameter layoutId of type string, which is used to identify the required layout template (semi-folded, double-folded, triple-folded, etc.), and return a layout container of type layout.ComponentContainer. Listen for the screen folding state. First, it will check whether the layoutCache has stored the layout with the specified layoutId.

[0095] Through the conditional judgment statement if(this.layoutCache.has(layoutId)), it will look for the corresponding key in the layoutCache Map.

[0096] If the corresponding layout exists, that is, the has method returns true, it means that the required layout has been parsed and stored in the cache. At this time, a message will be output to the console to prompt the user Layout with id${layoutId}found incache., indicating that the layout has been found in the cache. Then, return this.layoutCache.get(layoutId); to retrieve the layout from the layoutCache and return it as the result.

[0097] If the corresponding layout does not exist, that is, the has method returns false, an unloaded message will be output to notify the user that the layout is not in the cache and needs to be parsed. In an actual development scenario, the layout template is parsed according to S102, and the specific implementation will be completed according to the system's layout parsing service. When calling the parsing operation, the await keyword is used because the layout parsing may be an asynchronous operation and needs to wait for the parsing to complete.

[0098] After the parsing is completed, a parsed layout container will be obtained and stored in the container variable. Subsequently, call this.storeParsedLayout(layoutId,container); to store the parsed layout in the layoutCache for subsequent use.

[0099] S4. Listen for the physical folding state of the device to achieve effective reuse of components;

[0100] Start listening for changes in the folding state of the folding device through the display.on('foldStatusChange') method. When the state of the folding device changes, the listening result returns one of the enumeration types. The specific enumerations include:

[0101] FOLD_STATUS_UNKNOWN (Indicates that the current folding state of the device is unknown), FOLD_STATUS_EXPANDED (Indicates that the current folding state of the device is fully expanded), FOLD_STATUS_FOLDED (Indicates that the current folding state of the device is folded), FOLD_STATUS_HALF_FOLDED (Indicates that the current folding state of the device is half-folded. Half-folded refers to the state between fully expanded and folded).

[0102] According to the returned enumeration type, a custom folding state cache layout is generated by passing the corresponding layoutId parameter to the getLayout method in step S3, achieving the effect of listening and dynamic layout.

[0103] To meet the requirement of frequent layout updates in folding applications, such as dynamically adjusting the view structure and style according to the user's folding operation or data change, if the method of repeatedly creating and destroying views is adopted, it will cause frequent layout calculations, which will have an adverse impact on the frame rate. In this case, using the component reuse strategy can effectively avoid unnecessary view creation operations and layout calculations, thus improving the performance.

[0104] As Figure 2 shown, the principle of ArkTS component reuse is as follows:

[0105] In ArkUI, when the page exits, the system follows the default rules. First, it clarifies the prerequisite that creating a NodeContainer requires a NodeItem. Then, it searches for the NodeItem in the NodePool, and then enters the key judgment link, that is, to judge whether there is a NodeItem of the corresponding type in the NodePool. If not, a new NodeItem will be created and the build operation will be performed, and at the same time, the update method of the internal custom component will be bound to this NodeItem; if it exists, a NodeItem will be taken out from the NodePool and the update operation will be triggered.

[0106] In either case, after the reuse of the NodeItem is completed, the NodeContainer will be destroyed, and the NodeItem in the NodeContainer will be recycled into the cache pool, and the whole process ends here.

[0107] This process aims to improve resource utilization and system performance through the effective management and reuse of NodeItem, ensuring that resources can be reasonably allocated and efficiently utilized in the creation of NodeContainer and related operations, and realizing the optimized operation of the system.

[0108] Based on the above method, the folding screen adaptive layout optimization device in this embodiment includes: at least one memory and at least one processor;

[0109] The at least one memory is used to store machine-readable programs;

[0110] The at least one processor is used to call the machine-readable program and execute the folding screen adaptive layout optimization method.

[0111] The above specific embodiments are only specific cases of the present invention. The patent protection scope of the present invention includes but is not limited to the above specific embodiments. Any technical solution that conforms to the technical solutions described in the above specific embodiments of the present invention and any appropriate changes or substitutions made by those of ordinary skill in the art shall fall within the patent protection scope of the present invention.

[0112] Although the embodiments of the present invention have been shown and described, for those of ordinary skill in the art, it can be understood that various changes, modifications, substitutions, and variations can be made to these embodiments without departing from the principles and spirit of the present invention. The scope of the present invention is defined by the appended claims and their equivalents.

Claims

1. A folding screen adaptive layout optimization method, characterized in that: The steps are as follows: S1, cold start identification of folding device model; S2, predicting the display mode of the user's device and pre-calculating and storing the layout of each mode in memory; S3. Use the Map data structure to store the parsed layout template; S4. Monitor the physical folding state of the device to achieve effective reuse of components.

2. The folding screen adaptive layout optimization method according to claim 1, characterized in that: In step S1, when the user opens, switches or returns to the application, the UIAbility instance in the application will transition between different states of its life cycle. When the UIAbility instance is created, the system will trigger the onCreate() callback function. After the UIAbility instance is created, before entering the foreground, the system will create a WindowStage object. After the WindowStage is created, it will enter the onWindowStageCreate() callback function.

3. The folding screen adaptive layout optimization method according to claim 2, characterized in that: In the onWindowStageCreate() callback function, the display.isFoldable method is used to determine whether the current device is a foldable device. When the result of calling this method indicates that the device is foldable, the display.getAllDisplays method is further called to obtain all display objects through this synchronous call operation; Subsequently, the display.getFoldDisplayMode method is called asynchronously to obtain all display modes of these foldable devices. The return value of the API will be presented in the form of an enumeration of display modes for foldable devices. By parsing the enumeration value, it can be known whether the device is a double-fold, triple-fold, or half-fold style.

4. The folding screen adaptive layout optimization method according to claim 3, characterized in that: In step S2, the half-fold, double-fold, and triple-fold styles are pre-packaged, respectively, as follows: (1) Window information acquisition and processing; (2) Create and set the root layout, build the basic architecture of the semi-folded layout, and create a rootLayout object of the DirectionalLayout type as the root container of the entire layout; (3) Create and configure the left and right split-screen layout. Create two layout objects of the FlexLayout type, namely leftLayout and rightLayout; (4) Add custom components and call the createCustomComponent method to create custom components; (5) The combined layout constitutes a complete semi-folded layout.

5. The folding screen adaptive layout optimization method according to claim 4, characterized in that: In step (1), first, the function calls the context.getWindow() method to obtain the window class object associated with the current UIAbility, denoted as windowClass; Next, the windowClass.getWindowStage() method is used to further obtain the window stage object windowStage, wherein the object windowStage contains information about the current stage of the window; Then, call the windowStage.getLayoutConfig() method to obtain the layout configuration information and store it in the layoutConfig variable. From the layoutConfig, extract the two key layout parameters of screenWidth and screenHeight, which represent the design width and height of the current device screen and will serve as the basis for subsequent layout size settings. In step (2), the width is set to the previously obtained screenWidth, the height is set to screenHeight, and at the same time, the layout direction of rootLayout is set to Horizontal, which means that the elements in the layout will be arranged in sequence in the horizontal direction.

6. The folding screen adaptive layout optimization method according to claim 5, characterized in that: In step (3), for leftLayout, set its width to screenWidth / 2 so that it occupies the left half of the screen, and set its height to screenHeight to fill the entire vertical space of the screen; The direction property of leftLayout is set to FlexDirection.Vertical, which means that the elements in the layout will be arranged vertically. The justifyContent and alignItems properties are both assigned the value of FlexAlign.Center, which aims to center the elements in leftLayout horizontally and vertically. For rightLayout, perform the same setting operation to make it occupy the right half of the screen, ensuring that the left and right parts of the layout are symmetrically distributed on the screen; In step (4), the createCustomComponent method is called to create a custom component, passing the context and "Left of Half Fold" parameters. The generated component is stored in the leftCustomComponent variable, where the context provides relevant information about the application and "Left of Half Fold" is the identifier of the component. Then, add the leftCustomComponent component to the leftLayout to integrate it into the left half of the layout; For the right layout, use the createCustomComponent method again, passing context and "Right ofHalf Fold" as parameters, store the generated component in the rightCustomComponent variable, and then add it to rightLayout to include it in the right half layout; In step (5), the left and right split screen layouts are added to the root layout rootLayout through the two statements rootLayout.addComponent(leftLayout); and rootLayout.addComponent(rightLayout);, thereby forming a complete half-folded layout; Finally, use the return rootLayout; statement to return the generated root layout container.

7. The folding screen adaptive layout optimization method according to claim 6, characterized in that: In step S3, when a layout needs to be used, first check whether the corresponding layout already exists in the cache, and if so, use it directly; After preloading the custom layout in step S2, the custom layout of all displays of the folding device is obtained. Then, the getLayout static asynchronous method is defined to receive a single parameter layoutId of the string type, which is used to identify the required layout template, and return a layout container of the layout.ComponentContainer type. It monitors the screen folding state and first checks whether the layoutCache has stored the layout with the specified layoutId. Through the conditional judgment statement if (this.layoutCache.has(layoutId)), it will search for the corresponding key in the layoutCache Map. If the corresponding layout exists, that is, the has method returns true, it means that the required layout has been parsed and stored in the cache. At this time, a message will be output to the console, prompting the user that Layout with id${layoutId}found incache., indicating that the layout has been found in the cache. Then, through return this.layoutCache.get(layoutId);, the layout is retrieved from layoutCache and returned as the result; If the corresponding layout exists, that is, the has method returns true, it means that the required layout has been parsed and stored in the cache. At this time, a message will be output in the console to prompt the user Layout with id${layoutId}found incache., indicating that the layout has been found in the cache; Then, return this.layoutCache.get(layoutId); to retrieve the layout from layoutCache and return it as the result; If there is no corresponding layout, that is, the has method returns false, the unloaded information will be output to inform the user that the layout is not in the cache and needs to be parsed; In the actual development scenario, the layout template is parsed according to step S2. The specific implementation will be completed according to the system's layout parsing service. When calling the parsing operation, the await keyword is used to wait for the parsing to be completed. When the parsing is completed, a parsed layout container will be obtained and stored in the container variable. Then, this.storeParsedLayout(layoutId,container) is called; the parsed layout is stored in layoutCache for subsequent use.

8. The folding screen adaptive layout optimization method according to claim 7, characterized in that: In step S4, the display.on('foldStatusChange') method is used to enable monitoring of changes in the folding status of the folding device. When the status of the folding device changes, the monitoring result returns one of the enumeration types. The specific enumerations include: FOLD_STATUS_UNKNOWN indicates that the current folding state of the device is unknown, FOLD_STATUS_EXPANDED indicates that the current folding state of the device is fully expanded, FOLD_STATUS_FOLDED indicates that the current folding state of the device is folded, FOLD_STATUS_HALF_FOLDED indicates that the current folding state of the device is half folded, and half folding refers to the state between fully expanded and folded; According to the returned enumeration type, the corresponding layoutId parameter is passed to the getLayout method through step S3 to generate a custom folded state cache layout, so as to achieve monitoring and dynamic layout effects.

9. The folding screen adaptive layout optimization method according to claim 8, characterized in that: The component ArkTS is effectively reused. In ArkUI, when the page is exited, the system follows the default rules. First, it is clear that creating a NodeContainer requires a NodeItem. Next, search for NodeItem in NodePool, and then enter the key judgment link, that is, to determine whether there is a NodeItem of the corresponding type in NodePool; If it does not exist, a new NodeItem is created and built, and the update method of the internal custom component is bound to the NodeItem; If it exists, take a NodeItem from the NodePool and trigger the update operation; In either case, after the reuse of NodeItem is completed, NodeContainer will be destroyed, and the NodeItem in NodeContainer will be recycled into the cache pool, and the whole process ends.

10. A folding screen adaptive layout optimization device, characterized in that: include: at least one memory and at least one processor; The at least one memory is used to store a machine-readable program; The at least one processor is configured to call the machine-readable program to execute the method according to any one of claims 1 to 9.