Data storage method and related device
By quickly saving and restoring the context of handwritten data on electronic devices, the problem of difficulty in recording sketches and handwritten notes in traditional input methods is solved, avoiding data loss and improving user experience.
Patent Information
- Application Number
- CN202410897214.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-04
- Publication Date
- 2024-11-08
- Estimated Expiration
- 2044-07-04
AI Technical Summary
Traditional text input methods are difficult to meet the needs of quickly recording sketches and handwritten notes on electronic devices, and it is easy to cause loss of handwritten data when the screen is refreshed, affecting the user experience.
By implementing data storage methods on electronic devices, quickly save and restore the context of handwritten data, avoid data loss, and use child threads to reload the context of writing handwriting after the main thread is destroyed to restore the handwritten canvas.
It effectively avoids the loss of handwritten data, improves the user experience, and ensures that the status of the note page can still be edited after the display mode changes.
Smart Images

Figure CN118916120A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of terminal technology, and in particular to a data storage method and related devices. Background Art
[0002] With the popularization of electronic devices and the advancement of technology, users have a growing demand for taking notes on electronic devices. However, traditional text input methods may not meet user needs in some scenarios, such as the need to quickly record sketches, handwritten notes, etc. Of course, users also hope that these handwritten notes can be easily saved, shared, and viewed.
[0003] In some implementations, data loss may occur in the user's handwritten notes, affecting the user experience. Summary of the invention
[0004] The embodiments of the present application provide a data storage method and related devices, which can save the context of handwriting in a canvas. Since the storage process of the context of handwriting in the canvas is fast, it is beneficial to quickly save handwritten data and avoid data loss.
[0005] In a first aspect, an embodiment of the present application proposes a data storage method, which is applied to an electronic device, and the method includes: at a first moment, displaying a first interface, the first interface includes a first canvas, the first canvas is used to receive a user's writing operation and present the writing handwriting, the first canvas is in a writable state, and the first interface is in a first display mode; at a second moment, receiving a first operation that triggers a change in the display mode; at a third moment, displaying a second interface, the second interface also includes the first canvas, the first canvas is still in a writable state, the writing handwriting in the first canvas is the same as that at the first moment, the second interface is displayed based on the first operation, the second interface is in a second display mode, and the second display mode is different from the first display mode; wherein, the second moment is after the first moment, the third moment is after the second moment, and between the second moment and the third moment, the first canvas in the first interface cannot be saved as a picture, and the first canvas in the second interface is obtained based on the context of the writing handwriting in the first canvas saved after the second moment.
[0006] Exemplarily, the first interface may be Figure 1 In the interface shown in , the first canvas can be Figure 1 In the handwriting area 101 in the first interface, the display mode of the first interface may be, for example, a light mode, or may also be called a day mode, etc.; the second interface may be Figure 8 In the interface shown in , the first canvas in the second interface can be Figure 8In the handwriting area 801, the display mode of the second interface can be, for example, a dark mode, or can also be called a night mode, which is not limited in the embodiments of the present application.
[0007] It should be understood that Figure 8 The handwriting area 801 in the Figure 1 The data saved in the handwriting area 101 is restored, so Figure 8 The handwriting area 801 in Figure 1 The handwriting area 101 in the image may be understood as the same canvas, or, Figure 8 The handwriting area 801 in the figure can be understood as being based on Figure 1 The data saved in the handwriting area 101 is recreated, and Figure 1 The same canvas as the handwriting area 101 in the present application is not limited to this.
[0008] In an embodiment of the present application, the first canvas in the second interface is obtained based on the context of the handwriting in the first canvas saved after the second moment. Since the storage process of the context of the handwriting in the first canvas is faster, it is beneficial to quickly save the handwriting data. The electronic device can restore based on the context of the handwriting in the first canvas during the process of displaying the second interface, which is beneficial to avoid data loss.
[0009] It should also be understood that in the related art, when it is necessary to store the data related to the first canvas, the implementation method is to store the view data of the first canvas as a picture, and each reporting point in the view data of the first canvas needs to be stored in a bitmap format. Since there is reporting point data without user handwriting in the view data of the first canvas, its storage process is slow. The context of the handwriting stored in the first canvas in the embodiment of the present application, on the one hand, only contains data with user handwriting, and on the other hand, does not require complex format conversion, and the speed is faster, so it is conducive to quickly saving user handwriting data and avoiding the loss of handwriting data.
[0010] The so-called reporting point can be understood as a unit in which the electronic device records the user's handwriting, which is used to limit an area on the canvas. It can be a unit of one pixel, a unit of multiple pixels, or a unit defined by other measurement units. The meaning of the "point position" mentioned in the above method 600 may be similar, and will not be explained again.
[0011] In combination with the first aspect, in certain implementations of the first aspect, the method further includes: at a fourth moment after the third moment, in response to a second operation on the second interface, displaying a third interface, the third interface including a first picture, the content presented by the first picture being the same as the writing handwriting in the first canvas of the second interface, the third interface being also in the second display mode, and the second operation being used to exit the writable state of the first canvas in the second interface.
[0012] For example, the second operation may be a user's Figure 8 In response to a click operation of the control 802 in the interface shown, the third interface displayed by the electronic device may be as follows: Fig. 9 As shown, the first picture can be Fig. 9 As shown in 901 in FIG. 8 , the content presented in 901 is the same as the handwriting in 801 , except that 901 is in the form of a picture and cannot be written. Figure 8 to Figure 9 , the display mode of the electronic device may not change.
[0013] In combination with the first aspect, in some implementations of the first aspect, the method further includes: at a fifth moment, displaying a fourth interface, the fourth interface including a second canvas, the second canvas being used to receive a user's writing operation and presenting writing handwriting, the second canvas being in a writable state, and the fourth interface being in a third display mode; at a sixth moment, receiving a third operation that triggers a change in display mode; at a seventh moment, displaying a fifth interface, the fifth interface including a second picture, the content presented by the second picture being the same as the writing handwriting in the second canvas, the fifth interface being displayed based on the third operation, the fifth interface being in a fourth display mode, and the fourth display mode being different from the third display mode; wherein the sixth moment is after the fifth moment, the seventh moment is after the sixth moment, and between the sixth moment and the seventh moment, the electronic device successfully saves the view data of the second canvas as the second picture after saving the context of the writing handwriting in the second canvas.
[0014] Exemplarily, the fourth interface may also be as follows Figure 1 The interface shown, the second canvas can also be Figure 1 The handwriting area 101 in the fifth interface can be as follows Fig. 9 In the interface shown, the second picture can be Fig. 9 901 in it.
[0015] In an embodiment of the present application, after saving the context of the writing handwriting in the second canvas, the electronic device also successfully saves the view data of the second canvas as a second picture. Since the view data of the second canvas has been successfully saved as the second picture, the picture data has good stability. When restoring the second canvas, the electronic device can also restore the second canvas in the form of the second picture. In this way, the restored fifth interface is not prone to garbled characters, which is conducive to giving users a better user experience.
[0016] In combination with the first aspect, in some implementations of the first aspect, the electronic device includes a first application, the first application supports a handwriting input function, and the receiving of the first operation that triggers a display mode change includes: a main thread receives the first operation that triggers a display mode change, and the main thread is a main thread in the first application used for interface display; the method also includes: the main thread starts a process of destroying the main thread based on the first operation and pulls up a child thread, the child thread is a child thread of the main thread, and the child thread is used to store data; the child thread obtains the context of the handwriting in the first canvas from the main thread and saves it; the displaying of the second interface includes: when the main thread is destroyed and then restarted, the restarted main thread loads the context of the handwriting in the first canvas, and displays the second interface using the context of the handwriting in the first canvas.
[0017] Optionally, the first application may be a note-taking application on the electronic device, or any other application that supports handwriting input, which is not limited in the present application.
[0018] It should be understood that the main thread can be the Activity of the note-taking application, which is a visual user interface responsible for creating a screen window and placing UI components for user interaction. The sub-thread is pulled up by the Activity main thread and is used to store relevant data in the Activity main thread, such as handwriting related data. The sub-thread 1 mentioned elsewhere in the embodiments of the present application may have a similar meaning to the sub-thread described here.
[0019] It should also be understood that when the main thread is destroyed, the child threads started by the main thread are also destroyed synchronously. For an introduction to the life cycle of the Activity main thread, see Figure 5 The corresponding description is given and will not be repeated here.
[0020] Furthermore, the "handwriting data", "handwriting handwriting", etc. described in the embodiments of the present application refer to the data collected by the electronic device when the user inputs handwriting, and the present application does not specifically limit the specific content of this data.
[0021] In the embodiment of the present application, when the main thread executes the destruction process, the sub-thread obtains and saves the context of the handwriting in the first canvas from the main thread. When the main thread is restarted after destruction, the context of the handwriting in the first canvas is loaded to restore the first canvas. This can help to save the relevant data of the first canvas in a timely manner, reduce the possibility of losing the handwriting in the first canvas, and improve the user experience.
[0022] In combination with the first aspect, in some implementations of the first aspect, during the destruction of the main thread, the method further includes: the child thread sets a mark bit, and sets the value of the mark bit to a first value, the first value being used to indicate that the canvas cannot be saved as a picture; the child thread obtains the size data of the first canvas from the main thread; the child thread saves a third picture with the same size as the first canvas based on the size data of the first canvas, and the third picture does not contain visual content; the restarted main thread loads the context of the handwriting in the first canvas, including: the restarted main thread loads the third picture and the context of the handwriting in the first canvas when determining that the value of the mark bit is the first value; the use of the context of the handwriting in the first canvas to display the second interface includes: the restarted main thread uses the third picture to determine the size of the first canvas, and loads the handwriting in the first canvas on a canvas with the same size as the third picture to display the second interface.
[0023] Exemplarily, the implementation process of this embodiment may be similar to the process in method 600, where sub-thread 1 executes S601 to S605 and then the Activity main thread executes S608 to S610. The specific process may refer to the description in method 600 and will not be repeated here.
[0024] Optionally, the third picture may be an empty picture as described in method 600, which may mean that the picture does not contain visual content, is completely transparent, or contains only some default colors (such as white, black or other pure colors, etc.), but this application does not specifically limit this. The third picture is invisible to the user and may serve as a placeholder in UI design.
[0025] In combination with the first aspect, in some implementations of the first aspect, the electronic device includes a first application, the first application supports a handwriting input function, and the receiving of a third operation that triggers a display mode change includes: a main thread receives the third operation that triggers a display mode change, the main thread is a main thread used for interface display in the first application, and the main thread is a main thread used for interface display in the first application; the method also includes: the main thread starts a process of destroying the main thread based on the third operation and pulls up a child thread, the child thread is a child thread of the main thread, and the child thread is used to store data; the child thread sets a mark bit and sets the value of the mark bit to a first value, the first value is used to indicate that the canvas cannot be saved as a picture; the child thread obtains view data of the second canvas from the main thread, the view data includes size data of the second canvas and the first color data of each dot in the second canvas; the child thread saves a fourth image of the same size as the second canvas based on the size data of the second canvas, and the fourth image does not contain visual content; the child thread obtains the context of the handwriting in the second canvas from the main thread and saves it; if the main thread has not been destroyed, the child thread saves the view data as the second image based on the size data of the second canvas and the color data of each dot in the second canvas included in the view data; the child thread modifies the value of the mark bit to a second value, and the second value is used to indicate that the canvas has been successfully saved as a picture; displaying the fourth interface includes: when the main thread is destroyed and restarted, the restarted main thread loads the second image to display the fourth interface when it is determined that the value of the mark bit is not the first value.
[0026] Exemplarily, the implementation process of this embodiment may be similar to the process in method 600, where sub-thread 1 executes S601 to S607 and then the Activity main thread executes S608 to S609 to S611. The specific process may refer to the description in method 600 and will not be repeated here.
[0027] Optionally, the fourth picture may have a similar meaning to the third picture mentioned above and will not be described in detail.
[0028] Optionally, the flag bit (which can be denoted as flag) can have a value of true, false, or a binary number such as 0 or 1, which is not limited in this application. For example, in an embodiment of this application, the first value can be true and the second value can be false.
[0029] It can be seen that when the sub-thread runs for a sufficient time, after saving the context of the writing handwriting in the second canvas, the sub-thread can further save the view data of the second canvas as the second picture. When the main thread is destroyed and then restarted, the restarted main thread can restore the second canvas in the form of the second picture. In this way, the fifth interface restored by the electronic device is not prone to garbled characters, which is conducive to giving users a better user experience.
[0030] Under such a saving order in the embodiment of the present application, at least the context of the handwriting in the second canvas can be saved. On the premise that the handwriting on the second canvas is not lost, the view data of the second canvas can be further saved as a second picture. This is beneficial to reducing the risk of data loss while maintaining data stability, which is beneficial to providing users with a better user experience.
[0031] Optionally, in this case, the restarted main thread may also use the context of the writing handwriting in the second canvas to restore the second canvas, so that the user can directly enter the writable state of the second canvas, simplifying the user operation.
[0032] In combination with the first aspect, in some implementations of the first aspect, the main thread is an interface activity Activity main thread.
[0033] In combination with the first aspect, in certain implementations of the first aspect, the context of the handwriting includes one or more of the following data for each reporting point in the handwriting: position data, color data, or pen type data.
[0034] In combination with the first aspect, in certain implementations of the first aspect, the context of the handwriting is saved in an ent file format.
[0035] In a second aspect, an embodiment of the present application provides a data storage device, which may be an electronic device, or a chip or chip system in an electronic device. The data storage device may include a display unit and a processing unit. When the data storage device is an electronic device, the display unit may be a display screen. The display unit is used to perform the display step so that the electronic device implements a data storage method described in the first aspect or any possible implementation of the first aspect. When the data storage device is an electronic device, the processing unit may be a processor. The data storage device may also include a storage unit, which may be a memory. The storage unit is used to store instructions, and the processing unit executes the instructions stored in the storage unit so that the electronic device implements a data storage method described in the first aspect or any possible implementation of the first aspect. When the data storage device is a chip or chip system in an electronic device, the processing unit may be a processor. The processing unit executes the instructions stored in the storage unit so that the electronic device implements a data storage method described in the first aspect or any possible implementation of the first aspect. The storage unit may be a storage unit in the chip (for example, a register, a cache, etc.), or a storage unit in the electronic device located outside the chip (for example, a read-only memory, a random access memory, etc.).
[0036] In a third aspect, an embodiment of the present application provides an electronic device, comprising one or more processors and a memory, wherein the memory is coupled to the one or more processors, the memory is used to store computer program code, the computer program code comprises computer instructions, and the one or more processors call the computer instructions so that the electronic device executes the method described in the first aspect or any possible implementation of the first aspect.
[0037] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, which includes a computer program or instructions. When the computer program or instructions are run on a computer, the computer executes the method described in the first aspect or any possible implementation of the first aspect.
[0038] In a fifth aspect, an embodiment of the present application provides a computer program product, which includes a computer program code. When the computer program code runs on a computer, the computer executes the method described in the first aspect or any possible implementation of the first aspect.
[0039] In a sixth aspect, the present application provides a chip or a chip system, which includes one or more processors and a communication interface, wherein the communication interface and the one or more processors are interconnected by lines, and the one or more processors are used to run computer programs or instructions to execute the method described in the first aspect or any possible implementation of the first aspect. The communication interface in the chip can be an input / output interface, a pin or a circuit, etc.
[0040] In a possible implementation, the chip or chip system described above in the present application further includes at least one memory, in which instructions are stored. The memory may be a storage unit inside the chip, such as a register, a cache, etc., or a storage unit of the chip (e.g., a read-only memory, a random access memory, etc.).
[0041] It should be understood that the second to sixth aspects of the present application correspond to the technical solutions of the first aspect of the present application, and the beneficial effects achieved by each aspect and the corresponding feasible implementation methods are similar and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] Figure 1 A schematic diagram of an electronic device interface provided in an embodiment of the present application;
[0043] Figure 2 A schematic diagram of another electronic device interface provided in an embodiment of the present application;
[0044] Figure 3 A schematic diagram of another electronic device interface provided in an embodiment of the present application;
[0045] Figure 4 A schematic block diagram of the software structure of an electronic device provided in an embodiment of the present application;
[0046] Figure 5 A schematic diagram of the life cycle of an Activity provided in an embodiment of the present application;
[0047] Figure 6 A schematic flow chart of a data storage method provided in an embodiment of the present application;
[0048] Figure 7 A schematic diagram of coordinates of location data provided in an embodiment of the present application;
[0049] Figure 8 A schematic diagram of an electronic device interface provided in an embodiment of the present application;
[0050] Fig. 9 A schematic diagram of another electronic device interface provided in an embodiment of the present application;
[0051] Fig.10 A schematic block diagram of the hardware structure of an electronic device provided in an embodiment of the present application;
[0052] Fig.11 A schematic block diagram of a chip structure provided in an embodiment of the present application. DETAILED DESCRIPTION
[0053] In order to clearly describe the technical solutions of the embodiments of the present application, some terms and technologies involved in the embodiments of the present application are briefly introduced below:
[0054] 1. Activity: Activity (usually translated as "activity" or "interface activity") is an application component. All operations in Activity are closely related to the user. It is a component responsible for interacting with the user. Activity provides a user interface that users can use to interact in order to complete a task. When a user opens an application, they are actually starting an Activity, which becomes the current focus and is displayed to the user for interaction.
[0055] For example, in the embodiment of the present application, the note application interface displayed by the electronic device seen by the user belongs to the Activity thread included in the note application process.
[0056] 2. Terminology
[0057] In the embodiments of the present application, words such as "first" and "second" are used to distinguish the same or similar items with substantially the same functions and effects. For example, the first chip and the second chip are only used to distinguish different chips, and their order is not limited. Those skilled in the art can understand that words such as "first" and "second" do not limit the quantity and execution order, and words such as "first" and "second" do not necessarily limit them to be different.
[0058] It should be noted that in the embodiments of the present application, words such as "exemplarily" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplarily" or "for example" in the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplarily" or "for example" is intended to present related concepts in a specific way.
[0059] In the embodiments of the present application, "at least one" refers to one or more, and "more than one" refers to two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone, where A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, or c can represent: a, b, c, ab, a--c, bc, or abc, where a, b, c can be single or multiple.
[0060] 3. Electronic equipment
[0061] The electronic device of the embodiment of the present application may include a handheld device with a handwriting function, a vehicle-mounted device, etc. For example, some electronic devices are: mobile phones, tablet computers, PDAs, laptop computers, mobile internet devices (MIDs), wearable devices, virtual reality (VR) devices, augmented reality (AR) devices, wireless terminals in industrial control, wireless terminals in self driving, wireless terminals in remote medical surgery, wireless terminals in smart grids, wireless terminals in transportation safety, wireless terminals in smart cities, wireless terminals in smart homes, cellular phones, cordless phones, session initiation protocol (SIP) phones, wireless local loop (WLL) stations, personal digital assistants (PDAs), handheld devices with wireless communication capabilities, computing devices or other processing devices connected to wireless modems, vehicle-mounted devices, wearable devices, electronic devices in 5G networks or future evolved public land mobile communication networks (public landmobile networks). The electronic devices in the network (PLMN) and the like are not limited to this in the embodiments of the present application.
[0062] As an example but not limitation, in the embodiments of the present application, the electronic device may also be a wearable device. Wearable devices may also be referred to as wearable smart devices, which are a general term for wearable devices that are intelligently designed and developed using wearable technology for daily wear, such as glasses, gloves, watches, clothing, and shoes. A wearable device is a portable device that is worn directly on the body or integrated into the user's clothes or accessories. Wearable devices are not only hardware devices, but also powerful functions achieved through software support, data interaction, and cloud interaction. Broadly speaking, wearable smart devices include full-featured, large-sized, and fully or partially independent of smartphones, such as smart watches or smart glasses, as well as devices that only focus on a certain type of application function and need to be used in conjunction with other devices such as smartphones, such as various types of smart bracelets and smart jewelry for vital sign monitoring.
[0063] In addition, in the embodiments of the present application, the electronic device may also be an electronic device in an Internet of Things (IoT) system. IoT is an important part of the future development of information technology. Its main technical feature is to connect objects to the network through communication technology, thereby realizing an intelligent network that interconnects people and machines and things.
[0064] The electronic device in the embodiments of the present application may also be referred to as: electronic device, user equipment (UE), mobile station (MS), mobile terminal (MT), access terminal, user unit, user station, mobile station, mobile station, remote station, remote terminal, mobile device, user terminal, terminal, wireless communication equipment, user agent or user device, etc.
[0065] With the popularization of electronic devices and the advancement of technology, users have a growing demand for taking notes on electronic devices. In some scenarios, traditional text input methods may not meet user needs in some scenarios, such as the need to quickly record sketches, handwritten notes, etc.
[0066] Some electronic devices can support the handwriting note function, but when there is handwritten text in the notes, when the electronic device flips the screen and needs to refresh the display interface view, the electronic device needs to update the view data of the electronic device before the change to the view after the change, which may cause the position of the handwritten text to be disordered, resulting in a bad user experience. Therefore, in some implementations, the electronic device converts the content of the user's handwriting area into a picture for storage. When the above-mentioned display interface view is refreshed, the position of the text in the handwriting area has been locked in the form of a picture, so as to avoid the position disorder of the handwritten text.
[0067] Figure 1 An exemplary embodiment of a note application interface of an electronic device is shown, such as Figure 1 As shown, the note records information related to the meeting theme "Content Quality and Security Assessment Meeting", including the content input by the user's handwriting in the user area 101 and the "Meeting Topic" 102 input in other areas using keyboard input, voice input or other methods. Figure 1 In the example, controls 103, 104, 105 and 106 may be controls displayed when the handwriting input is in progress. Optionally, 103 may be a back control, 104 may be a forward control, 105 may be a completion control, and 106 may include pen types, pen tip colors and a keypad call-out button supported by the electronic device. When the note is in the handwriting input state, area 101 may display the following: Figure 1 The dashed line boundary is shown, but this application is not limited to this.
[0068] In a possible implementation, after the user clicks to complete control 105, controls 103, 104, 105, and 106 can be displayed as follows: Figure 1 The interface shown is completely hidden or partially hidden, and the area 101 is converted from an editable canvas to a picture, and the boundary of the area 101 is a solid line boundary, for example Figure 2 As shown in , but the present application does not limit this, the area 101 may also have no boundaries. It is worth noting that Figure 2 The interface shown may also contain controls such as 201, 202 and 204, wherein the meanings of 201, 202 and 204 may be the same as Figure 1 The controls 103, 104 and 105 shown in the figure correspond to similar ones, but controls 103, 104 and 105 correspond to controlling the handwriting input actions, while controls 201, 202 and 204 correspond to controlling the input actions using other methods, or the input actions for the entire note page, including handwriting input and input actions using other methods. The user can end the editing operation of the entire note by clicking control 204. Figure 2 Also included is a control 203, which can be used to search for text or symbols in the note.
[0069] from Figure 1 The area 101 in the middle is the state of the editable handwriting canvas converted to Figure 2 As shown in Figure 1, the middle area 101 is already in the picture state, which may be due to the note exiting the handwriting input mode, for example, the user clicks Figure 1 After the control 105 shown in , the handwritten content can be converted into a picture and stored. However, the user may also be in the process of handwriting input, that is, when the handwritten content has not yet been converted into a picture (for example Figure 1In the case shown in the figure, the refresh of the display interface view is triggered. If there is a lot of handwritten data, the conversion process to a picture may take a long time. If this time exceeds the time required to refresh the view, the handwritten data may not be converted into a picture in time, resulting in the following situation: Figure 3 The data loss in the handwriting area 101 shown in FIG. 1 seriously affects the user experience.
[0070] In view of this, an embodiment of the present application provides a data storage method and related devices, which store the context of valid handwriting data when a display screen interface view needs to be refreshed. Since the process of storing the context of valid handwriting data is fast, the electronic device can restore the handwriting data based on the context of the handwriting data during the process of restoring the handwriting canvas, which helps to avoid data loss.
[0071] It should be understood that valid handwriting data refers to the handwriting on the handwriting canvas. Each handwriting of the user can be recorded through code, for example, through the Java list method. In some implementations, the record is temporary and is not written to the storage. In the embodiment of the present application, the record can be stored for the recovery of the handwriting canvas.
[0072] Optionally, the situations involved in the present application that can cause the display screen interface view to be refreshed may be: the display area size changes or the screen display mode changes, for example, the landscape mode changes to the portrait mode, or the portrait mode changes to the landscape mode, or the display screen of an electronic device with a folding function is folded or unfolded; or the screen brightness changes from light mode (day mode) to dark mode (night mode) or from dark mode to light mode, etc., and the present application does not limit this.
[0073] For the sake of ease of description, the above-mentioned situations that may cause the refresh of the display screen interface view are collectively referred to as changes in the display mode of the electronic device, and will not be explained repeatedly later.
[0074] In an embodiment of the present application, the electronic device includes a hardware layer and a software system running on the hardware layer. The hardware layer includes hardware such as a central processing unit (CPU), a memory management unit (MMU), and a memory (also called main memory). The software system may include any one or more computer operating systems that implement business processing through processes, such as Linux operating system, Unix operating system, Android operating system, iOS operating system, or Windows operating system.
[0075] The software system of the electronic device may adopt a layered architecture, an event-driven architecture, a micro-core architecture, a micro-service architecture, or a cloud architecture. The embodiment of the present application takes the Android system of the layered architecture as an example to exemplify the software structure of the electronic device.
[0076] Figure 4 It is a software structure block diagram of the electronic device according to an embodiment of the present application.
[0077] The layered architecture divides the software into several layers, each with clear roles and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers, from top to bottom: application layer, application framework layer, system layer, and kernel layer.
[0078] The application layer may include a series of application packages such as system applications and / or third-party applications. For example, the application package may include a note application and a system interface control center (systemUI). In the embodiment of the present application, the user can perform operations such as writing input by running the note application and creating notes.
[0079] The application framework layer provides application programming interface (API) and programming framework for the applications in the application layer. The application framework layer includes some predefined functions. Figure 4 As shown, the application framework layer may include an input management service (InputManagerService), a window management service (WindowManagerService), a resource manager (ResourceManager), an activity management service (ActivityManagerService), a view system (ViewSystem), a database interface, and a system file interface.
[0080] Among them, the input management service can be used to manage and process user input events; the window management service can be used to manage the display and layout of windows, and realize functions such as window creation, display, hiding, moving, and resizing; the resource manager can be used to provide various resources for applications, such as localized strings, icons, pictures, layout files, video files, etc.; the activity management service can be used to manage the life cycle of the application, such as starting, stopping, and destroying the activity in the application, as well as managing the process of the application; the view system can be used to build and manage the user interface (UI) of the application.
[0081] The database interface and system file interface are used to provide APIs for the upper layer to access the database and file system of the system layer respectively.
[0082] The system library may include multiple functional modules, such as input synthesis module (InputFlinger), layer synthesis module (SurfaceFlinger), graphics processing library (such as OpenGL), file system and database (such as SQLite).
[0083] Among them, the input synthesis module can be used to handle the processing and distribution of system input events; the surface synthesis module can be used to manage the display subsystem and provide fusion of 2D and 3D layers for multiple applications; the graphics processing library can be used to implement three-dimensional graphics drawing, image rendering, synthesis, and layer processing, etc.; both the file system and the database can be used to store data, but the storage method and access method of the two are different. In the embodiment of the present application, the original context of the valid handwriting data can be converted into an ent file and stored in the file system, and the text data formed by keyboard input and voice input and the bitmap data converted from the handwriting data can be stored in the database, but the present application is not limited to this.
[0084] The kernel layer is the layer between hardware and software. The kernel layer contains at least device input drivers, file drivers, and display drivers.
[0085] It should be understood that in some embodiments, the layers implementing the same function may be called by other names, or the layers that can implement the functions of multiple layers may be regarded as one layer, or the layers that can implement the functions of multiple layers may be divided into multiple layers. The embodiments of the present application are not limited to this.
[0086] The following is an illustrative description of the workflow of electronic device software and hardware in conjunction with the usage scenarios of the note-taking application.
[0087] For example, a user clicks on the area displayed by the note application icon on the screen of an electronic device to start the note application. The workflow of the electronic device software and hardware can be: the touch screen hardware of the electronic device responds to the click operation, generates a corresponding electrical signal (including the time of the click and the position on the screen), and transmits the electrical signal to the device input driver of the kernel layer. The device input driver processes the electrical signal into an event instruction recognizable by the operating system and transmits it to the input synthesis module of the system layer. The input synthesis module encapsulates the event read from the hardware and transmits it to the input management service of the application layer. The input management service distributes the click event to the note application. The note application notifies the operating system to start the application process. In the process of the operating system starting the application process, an Activity can be created through the activity management service until the Activity life cycle enters the running state. Then the Activity UI will be displayed on the screen, and the UI can be the note interface seen by the user. In the process of the Activity preparing the UI, the Activity interacts with the surface synthesis module through the window management service, receives the layers of the note application and the system, synthesizes multiple layers together through the accelerated rendering of the surface synthesis module and the graphics processing library, and outputs them to the display driver to display the UI on the display screen.
[0088] Furthermore, the user can click on the new note control on the note application interface to create a note, and after performing handwriting input or any other input operation, the user can obtain the following information: Figure 1 or Figure 2 The interface shown.
[0089] It should be understood that when the display mode of the electronic device described above changes, the Activity in the note application will be restarted. The following first introduces the life cycle of the Activity.
[0090] In some implementations, the life cycle of an Activity may include a creation phase, a running phase, a pause phase, a stop phase, and a destruction phase. Applying the above phases, the callback methods used in the life cycle of an Activity may be onCreate(), onResume(), onPause(), onStop(), and onDestroy(), respectively. The life cycle process may be as follows: Figure 5 shown.
[0091] Among them, the system can call onCreate() in the application creation stage. onCreate() is the first callback method in the entire life cycle and is used to perform initialization operations on the Activity, such as setting the layout and initializing variables. The running stage is one of the most important states in the Activity life cycle and is a stage that is visible and interactive to the user. After the application enters the running state, the system can call onResume() to interact with the user, update the UI, register listeners, and other operations. When the application loses focus (for example, when starting a new Activity or locking the screen), the Activity is in a paused state, that is, the Activity no longer interacts with the user. The system can call onPause() to save the current state of the Activity, such as stopping animation, saving data, and releasing no longer needed resources, such as canceling the registration of listeners. At this time, the application is still visible, but cannot interact with the user. When the application is completely invisible, the system can call onStop() to release resources, such as stopping playing music and closing database connections. When the application enters the destruction stage, the system calls onDestroy() to release all resources occupied by the Activity, such as deleting temporary files and clearing caches. onDestroy() is the last callback method in the entire life cycle of the Activity.
[0092] In one possible implementation, since the running phase of the Activity is a phase that is visible and interactive to the user, changes in the display mode of the electronic device may occur during this phase. When the display mode of the electronic device changes, the Activity main thread pulls up sub-thread 1 for storing handwriting data, and sub-thread 1 obtains the handwriting data from the temporary storage of the Activity main thread, and then converts the handwriting data into an image and stores it in the database, so that when the Activity life cycle ends and restarts to the running phase, the image can be obtained from the database again to be displayed in the user interface. The running process of sub-thread 1 and the Activity main thread can be as follows: Figure 5 As shown.
[0093] However, the researchers of this application found that if the child thread 1 cannot complete the process of converting the handwritten data into an image before the Activity main thread completes the destruction phase, the problem described in the preface of this article will occur. Figure 1 In the interface shown, after the display mode of the electronic device changes, it is updated to Figure 3 In the interface shown, handwritten data is lost.
[0094] Next, in view of the above technical problems, combined with Figures 6 to 8A data storage method 600 provided in an embodiment of the present application is described in detail. The method 600 can be applied to a software architecture such as Figure 4 The electronic device shown is not limited to this.
[0095] Taking the change of the display mode of an electronic device as an example, the display mode of the electronic device changes from a light mode to a dark mode, combined with Figure 4 , briefly describing this process. In some implementations, when a user clicks on a target control (a control that changes the display mode from light mode to dark mode, or from dark mode to light mode) of an electronic device system interface control center application, the touch screen hardware of the electronic device responds to the click operation, generates a corresponding electrical signal (including the time of the click and the position on the screen), and transmits the electrical signal to the device input driver of the kernel layer. The device input driver processes the electrical signal into an event instruction recognizable by the operating system and transmits it to the input synthesis module of the system layer. The input synthesis module encapsulates the event read from the hardware and transmits it to the input management service of the application layer. The input management service distributes the click event to the system interface control center application. The system interface control center application notifies the view system to adjust parameters such as screen brightness and color temperature, and restarts the activity of the note application. In this process, the window management service transmits the layer updated by the system interface control center and the layer of the activity to the surface synthesis module. The multiple layers are synthesized together through the accelerated rendering of the surface synthesis module and the graphics processing library, and output to the display driver to display the UI on the display screen.
[0096] When receiving a restart instruction from the system interface control center, the Activity main thread starts the child thread 1. Specifically, S601 to S607 in the method 600 can be executed by the child thread 1, and S608 to S611 are executed by the Activity main thread.
[0097] The method 600 may include the following steps:
[0098] S601. Sub-thread 1 obtains data 1 corresponding to a handwriting canvas view (view) from the temporary memory of the Activity main thread. Data 1 includes size information of the handwriting canvas and color information of each point on the handwriting canvas.
[0099] It should be understood that in the Activity layout file, the view used to input handwritten content can usually be a custom View class, which inherits from the standard view class (such as View, surface view (SurfaceView), canvas (Canvas) combined with View's onDraw method, etc.). The handwritten content input by the user on this view is converted into a data structure that can be drawn on the canvas Canvas. Data 1 includes the data structure on the Canvas, and this application does not limit this.
[0100] It should also be understood that the data structures on the Canvas are usually used internally by the program. They exist in a form suitable for graphics rendering (such as points, lines, surfaces, etc.) and are used for real-time rendering and drawing.
[0101] In one possible implementation, the handwriting canvas view can establish communication and interaction with the network view (webview) through a network bridge (webbridge), so that the handwriting canvas view in the form of Java code and the webview in the form of JavaScript code can be recognized by each other, so that the handwriting canvas can be recognized and displayed by electronic devices of various different systems.
[0102] S602. Child thread 1 sets flag bit 1 in the database, and sets the value of flag bit 1 to target value 1.
[0103] In the embodiment of the present application, the flag bit 1 is used to indicate whether the data 1 is successfully stored as a picture. Optionally, the target value 1 can be used to indicate that the data 1 cannot be stored as a picture, and the target value 1 can be true. The present application does not specifically limit the value of the flag bit.
[0104] It should be understood that the location, type and storage path of each data in the database are all in the "directory" of the database. The handwritten canvas should be stored in the image format accordingly. In the "directory", the above data 1 should be marked as a picture and associated with the universally unique identifier (UUID) of the picture. In the embodiment of the present application, the flag bit 1 set by thread 1 is associated with the UUID corresponding to data 1. In this way, when there are multiple pictures in the "directory", the UUID can be used to uniquely determine which picture is indicated by the flag bit 1.
[0105] It should also be understood that the "directory" is only a graphic description of the mapping relationship between the location, type and storage path of each data in the database, and the present application does not limit the specific name of this mapping relationship. In some implementations, this mapping relationship file can be an HTML format file.
[0106] S603. Sub-thread 1 stores an empty picture of the same size as the handwriting canvas in the database based on the size information of the handwriting canvas included in data 1.
[0107] In some implementations, the empty picture may be stored in a storage path that should be stored or set to be used to store pictures converted from data 1. In the embodiment of the present application, the attribute of the empty picture may be invisible to the user.
[0108] An empty picture can be understood as a picture that does not include valid color information, or it can be understood as each pixel in the picture contains the same color information.
[0109] S604, sub-thread 1 obtains data 2 from the temporary memory of the Activity, where data 2 is data related to the user's handwriting.
[0110] Optionally, Data 2 may include position data corresponding to each point in each stroke written by the user on the handwriting canvas, pen type data corresponding to each position data, color data corresponding to each position data, and a timestamp corresponding to each position data. A point may include one pixel or several pixels. This application does not specifically limit the specific information included in Data 2 and the meaning of the point.
[0111] For example, Figure 7 As shown, Figure 7 Taking the rectangular handwriting canvas shown as an example, a coordinate system can be established with the upper left vertex of the handwriting canvas area as the coordinate origin O, the upper boundary as the x-axis, and the left boundary as the y-axis. For each stroke written by the user in the handwriting canvas, the coordinates (x, y) of each point in each stroke are recorded under the coordinates shown in the figure. This coordinate information can be understood as the position data corresponding to each point in each stroke.
[0112] In some implementations, data 2 is a file temporarily stored by the Activity, and if these files are to be stored in a disk, they need to be converted into a file type that can be read and written by the disk. Exemplarily, data 2 is a Java list file.
[0113] S605. Sub-thread 1 converts data 2 into a file in ent format and stores it in the file system.
[0114] In the embodiment of the present application, since the empty picture does not need to record the color information of each point on the handwriting canvas, the time for thread 1 to store the empty picture is much shorter than the time for converting data 1 into a picture containing all its information. Data 2 is the context of the object class for recording handwriting saved by the Activity during the user's handwriting process. The process of converting the file into a file type that can be read and written on the disk is also faster. Therefore, thread 1 has a higher success rate in storing empty pictures and data 2, which is beneficial for the Activity main thread to provide valid data for the Activity's UI during the restart process, and is beneficial to reducing the possibility of loss of user handwriting data.
[0115] Optionally, sub-thread 1 may also execute S606 to S607.
[0116] S606. Sub-thread 1 converts data 1 into picture A including all information of data 1 and stores it in the database.
[0117] It should be understood that the image A may be data in bitmap format, and the bitmap format may be understood as a picture storage format. The data in bitmap format in S606 includes all information of data 1, such as the size information of the handwriting canvas mentioned above and the color information of each point on the handwriting canvas.
[0118] S607. Child thread 1 sets the value of flag bit 1 to target value 2.
[0119] Optionally, target value 2 may be used to indicate that data 1 has been successfully stored as picture A, and target value 2 may be false, but this application does not limit this.
[0120] Thread 1 and the Activity main thread run in parallel. If Thread 1 can complete S606 before the destruction phase (the phase of calling the onDestroy() method) in the life cycle of the Activity main thread is completed, it means that Data 1 has been successfully converted into Image A containing all the information of Data 1, which means that Data 1 can be restored in image format when the Activity main thread is restored. In this way, Thread 1 can continue to execute S606 to set the value of flag bit 1 to target value 2, to indicate that Data 1 will be restored to Image A containing all the information of Data 1 when the Activity main thread is restored.
[0121] When the Activity main thread is restarted to the running stage, the following S608 to S611 are executed.
[0122] S608. The Activity main thread loads data from the database.
[0123] S609. The Activity main thread determines whether the value of the flag bit 1 is the target value 1. If the value of the flag bit is the target value 1, execute S609; if the value of the flag bit is not the target value 1, execute S610.
[0124] It should be understood that if the value of flag bit 1 is the target value 1, it means that thread 1 has failed to execute or has failed to complete the above S606~S607, the destruction phase of the Activity main thread has been completed, and thread 1 has also been destroyed. Since the process of thread 1 executing the above S602~S605 is very fast, in this case, the valid information corresponding to data 1 can be stored in an ent format file; if the value of flag bit 1 is the target value 2, it means that thread 1 has executed the above S606~S607 before being destroyed, and data 1 has been converted into bitmap format data storage.
[0125] S610 , the Activity main thread loads an empty picture from the database, loads an ent file from the file system, and restores the ent file to an editable canvas with the same size as the empty picture.
[0126] It should be understood that the ent file includes the position data corresponding to all points of each handwritten stroke, the pen type data and color data corresponding to each position data. In some implementations, when the main thread of the Activity recovers the word data, a canvas of the same size as the empty image can be created first, and then the user's handwriting can be redrawn on the new canvas based on the position data corresponding to all points of each handwritten stroke, the pen type data and color data corresponding to each position data.
[0127] In a possible implementation, when the display mode is changed from a light mode to a dark mode, after the electronic device executes the above S610, the electronic device display screen may display the following: Figure 8 The interface shown. It can be seen that Figure 1 and Figure 8 The only difference is the background color. After the display mode of the electronic device changes, the handwriting canvas is still editable, and the user can write directly on the handwriting canvas. The method provided in the embodiment of the present application maintains the state of the note page to the greatest extent while ensuring that data is not lost, which is conducive to improving the user experience.
[0128] S611. The Activity main thread loads picture A containing all the information of data 1 from the database.
[0129] In a possible implementation, when the display mode is changed from a light mode to a dark mode, after the electronic device executes the above S611, the electronic device display screen may display the following: Fig. 9The interface shown. It can be seen that Figure 1 and Fig. 9 The difference is that Fig. 9 The handwriting canvas is converted to a picture, and there is no handwriting input tool in the interface. In this case, the user can still convert the picture into an editable canvas by clicking on the picture or performing any other specified operations, and continue handwriting input. This application does not limit this.
[0130] It is worth noting that no matter whether the main thread of the Activity executes S610 or S611, the empty picture stored in the above S603 may exist. In the embodiment of the present application, the attributes of the empty picture can be set to be invisible to the user. In this way, the empty picture can be used to mark the size of the handwriting canvas and the position of the handwriting canvas in the entire note interface, and will not affect the content displayed on the UI during the UI recovery process of the Activity, which is conducive to improving the user experience.
[0131] In a possible implementation, when the value of flag bit 1 is not the target value 1, the Activity main thread may also execute S610, which is not limited in this application.
[0132] The data storage method provided in the embodiment of the present application is described in detail below. The method is referred to as the first method in the following description. The first method can be applied to an electronic device, and its software structure can be as follows: Figure 4 As shown, the hardware structure can be as follows Fig.10 However, this application does not make any specific limitation to this.
[0133] The first method includes: at a first moment, displaying a first interface, the first interface includes a first canvas, the first canvas is used to receive a user's writing operation and present writing handwriting, the first canvas is in a writable state, and the first interface is in a first display mode; at a second moment, receiving a first operation that triggers a display mode change; at a third moment, displaying a second interface, the second interface also includes a first canvas, the first canvas is still in a writable state, the writing handwriting in the first canvas is the same as that at the first moment, the second interface is displayed based on the first operation, the second interface is in a second display mode, and the second display mode is different from the first display mode; wherein the second moment is after the first moment, the third moment is after the second moment, and between the second moment and the third moment, the first canvas in the first interface cannot be saved as a picture, and the first canvas in the second interface is obtained based on the context of the writing handwriting in the first canvas saved after the second moment.
[0134] It should be understood that a change in the display mode can cause the electronic device to refresh the display interface view. Exemplarily, a change in the display mode can refer to a change in the size of the display area or a change in the screen display mode, such as a change from landscape mode to portrait mode, or from portrait mode to landscape mode, or an electronic device with a folding screen whose display screen is folded or unfolded, or a change in screen brightness from light mode (day mode) to dark mode (night mode) or from dark mode to light mode, etc. This application does not limit this.
[0135] In some implementations, the electronic device includes a system interface control center, and the user can call out the system interface control center by sliding down from the upper right corner of the electronic device display screen. Optionally, the first operation can be any operation of the user on a button for switching display modes set by the system interface control center, such as clicking, double-clicking, sliding, etc.; the first operation can also be any operation that can cause a change in the display mode by interacting with a voice assistant included in the electronic device, which is not limited in the embodiments of the present application.
[0136] Exemplarily, the first interface may be Figure 1 In the interface shown in , the first canvas can be Figure 1 In the handwriting area 101 in the first interface, the display mode of the first interface may be, for example, a light mode, or may also be called a day mode, etc.; the second interface may be Figure 8 In the interface shown in , the first canvas in the second interface can be Figure 8 In the handwriting area 801, the display mode of the second interface can be, for example, a dark mode, or can also be called a night mode, which is not limited in the embodiments of the present application.
[0137] It should be understood that Figure 8 The handwriting area 801 in the Figure 1 The data saved in the handwriting area 101 is restored, so Figure 8 The handwriting area 801 in Figure 1 The handwriting area 101 in the image may be understood as the same canvas, or, Figure 8 The handwriting area 801 in the figure can be understood as being based on Figure 1 The data saved in the handwriting area 101 is recreated, and Figure 1 The same canvas as the handwriting area 101 in the present application is not limited to this.
[0138] In an embodiment of the present application, the first canvas in the second interface is obtained based on the context of the handwriting in the first canvas saved after the second moment. Since the storage process of the context of the handwriting in the first canvas is faster, it is beneficial to quickly save the handwriting data. The electronic device can restore based on the context of the handwriting in the first canvas during the process of displaying the second interface, which is beneficial to avoid data loss.
[0139] It should be understood that the “context of the handwriting in the first canvas” described here and the “context of the valid handwriting data” and “data 2” mentioned above can express similar meanings, and will not be explained again.
[0140] It should also be understood that in the related art, when it is necessary to store the data related to the first canvas, the implementation method is to store the view data of the first canvas as a picture, and each reporting point in the view data of the first canvas needs to be stored in a bitmap format. Since there is reporting point data without user handwriting in the view data of the first canvas, its storage process is slow. The context of the handwriting stored in the first canvas in the embodiment of the present application, on the one hand, only contains data with user handwriting, and on the other hand, does not require complex format conversion, and the speed is faster, so it is conducive to quickly saving user handwriting data and avoiding the loss of handwriting data.
[0141] The so-called reporting point can be understood as a unit in which the electronic device records the user's handwriting, which is used to limit an area on the canvas. It can be a unit of one pixel, a unit of multiple pixels, or a unit defined by other measurement units. The meaning of the "point position" mentioned in the above method 600 may be similar, and will not be explained again.
[0142] As an optional embodiment, the above-mentioned first method also includes: at a fourth moment after the third moment, in response to a second operation on the second interface, displaying a third interface, the third interface includes a first picture, the content presented by the first picture is the same as the writing handwriting in the first canvas of the second interface, the third interface is also in the second display mode, and the second operation is used to exit the writable state of the first canvas in the second interface.
[0143] For example, the second operation may be a user's Figure 8 In response to a click operation of the control 802 in the interface shown, the third interface displayed by the electronic device may be as follows: Fig. 9 As shown, the first picture can be Fig. 9 As shown in 901 in FIG. 8 , the content presented in 901 is the same as the handwriting in 801 , except that 901 is in the form of a picture and cannot be written. Figure 8 to Figure 9 , the display mode of the electronic device may not change.
[0144] As an optional embodiment, the above-mentioned first method also includes: at the fifth moment, displaying the fourth interface, the fourth interface includes a second canvas, the second canvas is used to receive the user's writing operation and present the writing handwriting, the second canvas is in a writable state, and the fourth interface is in the third display mode; at the sixth moment, receiving the third operation that triggers the display mode change; at the seventh moment, displaying the fifth interface, the fifth interface includes a second picture, the content presented in the second picture is the same as the writing handwriting in the second canvas, the fifth interface is displayed based on the third operation, the fifth interface is in the fourth display mode, and the fourth display mode is different from the third display mode; wherein, the sixth moment is after the fifth moment, the seventh moment is after the sixth moment, and between the sixth moment and the seventh moment, the electronic device successfully saves the view data of the second canvas as the second picture after saving the context of the writing handwriting in the second canvas.
[0145] Exemplarily, the fourth interface may also be as follows Figure 1 The interface shown, the second canvas can also be Figure 1 The handwriting area 101 in the fifth interface can be as follows Fig. 9 In the interface shown, the second picture can be Fig. 9 901 in it.
[0146] Optionally, the view data of the second canvas may be, for example, the data 1 described above, which is not limited in the present application.
[0147] In an embodiment of the present application, after saving the context of the writing handwriting in the second canvas, the electronic device also successfully saves the view data of the second canvas as a second picture. Since the view data of the second canvas has been successfully saved as the second picture, the picture data has good stability. When restoring the second canvas, the electronic device can also restore the second canvas in the form of the second picture. In this way, the restored fifth interface is not prone to garbled characters, which is conducive to giving users a better user experience.
[0148] As an optional embodiment, an electronic device includes a first application, the first application supports a handwriting input function, and receives a first operation that triggers a display mode change, including: a main thread receives the first operation that triggers a display mode change, the main thread is a main thread in the first application used for interface display; the method also includes: the main thread starts a process of destroying the main thread based on the first operation and pulls up a sub-thread, the sub-thread is a sub-thread of the main thread, and the sub-thread is used to store data; the sub-thread obtains the context of the handwriting in the first canvas from the main thread and saves it; and displays a second interface, including: when the main thread is destroyed and then restarted, the restarted main thread loads the context of the handwriting in the first canvas, and uses the context of the handwriting in the first canvas to display the second interface.
[0149] Optionally, the first application may be a note-taking application on the electronic device, or any other application that supports handwriting input, which is not limited in the present application.
[0150] It should be understood that the main thread can be the Activity of the note-taking application, which is a visual user interface responsible for creating a screen window and placing UI components for user interaction. The sub-thread is pulled up by the Activity main thread and is used to store relevant data in the Activity main thread, such as handwriting related data. The sub-thread 1 mentioned elsewhere in the embodiments of the present application may have a similar meaning to the sub-thread described here.
[0151] It should also be understood that when the main thread is destroyed, the child threads started by the main thread are also destroyed synchronously. For an introduction to the life cycle of the Activity main thread, see Figure 5 The corresponding description is given and will not be repeated here.
[0152] Furthermore, the "handwriting data", "handwriting handwriting", etc. described in the embodiments of the present application refer to the data collected by the electronic device when the user inputs handwriting, and the present application does not specifically limit the specific content of this data.
[0153] In the embodiment of the present application, when the main thread executes the destruction process, the sub-thread obtains and saves the context of the handwriting in the first canvas from the main thread. When the main thread is restarted after destruction, the context of the handwriting in the first canvas is loaded to restore the first canvas. This can help to save the relevant data of the first canvas in a timely manner, reduce the possibility of losing the handwriting in the first canvas, and improve the user experience.
[0154] As an optional embodiment, further, during the destruction of the main thread, the method also includes: the child thread sets a mark bit, and sets the value of the mark bit to a first value, the first value is used to indicate that the canvas cannot be saved as a picture; the child thread obtains the size data of the first canvas from the main thread; the child thread saves a third picture with the same size as the first canvas based on the size data of the first canvas, and the third picture does not contain visual content; the restarted main thread loads the context of the handwriting in the first canvas, including: the restarted main thread loads the third picture and the context of the handwriting in the first canvas when determining that the value of the mark bit is the first value; using the context of the handwriting in the first canvas to display the second interface, including: the restarted main thread uses the third picture to determine the size of the first canvas, and loads the handwriting in the first canvas on a canvas with the same size as the third picture to display the second interface.
[0155] Exemplarily, the implementation process of this embodiment may be similar to the process in method 600, where sub-thread 1 executes S601 to S605 and then the Activity main thread executes S608 to S610. The specific process may refer to the description in method 600 and will not be repeated here.
[0156] Optionally, the third picture may be an empty picture as described in method 600, which may mean that the picture does not contain visual content, is completely transparent, or contains only some default colors (such as white, black or other pure colors, etc.), but this application does not specifically limit this. The third picture is invisible to the user and may serve as a placeholder in UI design.
[0157] As an optional embodiment, the electronic device includes a first application, the first application supports a handwriting input function, and receives a third operation that triggers a display mode change, including: a main thread receives the third operation that triggers a display mode change, the main thread is the main thread used for interface display in the first application, and the main thread is the main thread used for interface display in the first application; the method also includes: the main thread starts a process of destroying the main thread based on the third operation and pulls up a child thread, the child thread is a child thread of the main thread, and the child thread is used to store data; the child thread sets a mark bit, and sets the value of the mark bit to a first value, the first value is used to indicate that the canvas cannot be saved as a picture; the child thread obtains view data of a second canvas from the main thread, the view data includes size data of the second canvas and each image in the second canvas The child thread obtains the color data of each reported point in the second canvas based on the size data of the second canvas, and saves a fourth picture with the same size as the second canvas based on the size data of the second canvas, and the fourth picture does not contain any visual content; the child thread obtains the context of the writing handwriting in the second canvas from the main thread and saves it; when the main thread has not been destroyed, the child thread saves the view data as the second picture based on the size data of the second canvas and the color data of each reported point in the second canvas included in the view data; the child thread modifies the value of the mark bit to the second value, and the second value is used to indicate that the canvas has been successfully saved as a picture; displaying the fourth interface, including: when the main thread is destroyed and then restarted, the restarted main thread loads the second picture to display the fourth interface when it is determined that the value of the mark bit is not the first value.
[0158] Exemplarily, the implementation process of this embodiment may be similar to the process in method 600, where sub-thread 1 executes S601 to S607 and then the Activity main thread executes S608 to S609 to S611. The specific process may refer to the description in method 600 and will not be repeated here.
[0159] Optionally, the fourth picture may have a similar meaning to the third picture mentioned above and will not be described in detail.
[0160] Optionally, the flag bit (which can be denoted as flag) can have a value of true, false, or a binary number such as 0 or 1, which is not limited in this application. For example, in an embodiment of the present application, the flag bit can be, for example, the flag bit 1 described above, the first value can be the target value 1 described above, and its value can be true, and the second value can be the target value 2 described above, and its value can be false.
[0161] It can be seen that when the sub-thread runs for a sufficient time, after saving the context of the writing handwriting in the second canvas, the sub-thread can further save the view data of the second canvas as the second picture. When the main thread is destroyed and then restarted, the restarted main thread can restore the second canvas in the form of the second picture. In this way, the fifth interface restored by the electronic device is not prone to garbled characters, which is conducive to giving users a better user experience.
[0162] Under such a saving order in the embodiment of the present application, at least the context of the handwriting in the second canvas can be saved. On the premise that the handwriting on the second canvas is not lost, the view data of the second canvas can be further saved as a second picture. This is beneficial to reducing the risk of data loss while maintaining data stability, which is beneficial to providing users with a better user experience.
[0163] Optionally, in this case, the restarted main thread may also use the context of the writing handwriting in the second canvas to restore the second canvas, so that the user can directly enter the writable state of the second canvas, simplifying the user operation.
[0164] Optionally, the main thread is the main thread of the interface activity Activity.
[0165] Optionally, the context of the handwriting includes one or more of the following data of each reported point in the handwriting: position data, color data or pen type data.
[0166] The location data may be coordinate data. For details, see Figure 7 The description given above will not be repeated here.
[0167] Optionally, the context of the handwriting is saved in an ent file format and can be saved in an electronic device file system, and the view data saved in an image bitmap format can be saved in an electronic device database, but this application does not limit this.
[0168] So far, the data storage method of the embodiment of the present application has been described above, and the device for executing the above method provided by the embodiment of the present application is described below. Those skilled in the art can understand that the method and the device can be combined and referenced with each other, and the relevant device provided by the embodiment of the present application can execute the steps in the above method.
[0169] Fig.10 FIG. 1 is a schematic diagram showing the hardware structure of an electronic device provided in an embodiment of the present application. Fig.10 As shown, the electronic device may include a processor 1010, a memory 1020, a display screen 1030, a sensor module 1040, a universal serial bus (USB) interface 1050, a charging management module 1060, a power management module 1061, a battery 1062, and the like.
[0170] The processor 1010 may include one or more processing units, for example, the processor 1010 may include a central processing unit (CPU), an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.
[0171] The memory 1020 can be used to store computer executable program codes, which include instructions, such as program codes corresponding to any of the above methods in the embodiments of the present application. The memory 1020 can also be used to store handwriting data involved in the embodiments of the present application.
[0172] The display screen 1030 is used to display images, videos, etc. The display screen 1030 includes a display panel. In some embodiments, the electronic device may include 1 or N display screens 1030, where N is a positive integer greater than 1. The electronic device implements the display function through a GPU, a display screen 1030, and an application processor. In some implementations, the display screen may communicate with a touch sensor to collect signals generated by a user's touch operation.
[0173] In some implementations, the sensor module may include a touch sensor, which may also be referred to as a "touch control device". The touch sensor may be disposed on the display screen 1030, and the touch sensor and the display screen may form a touch screen, also referred to as a "touch control screen". In an embodiment of the present application, the touch sensor may be used to detect a touch operation acting on or near it. The touch sensor may transmit the detected touch operation to an application processor to determine the type of touch event. A visual output related to the touch operation may be provided through the display screen. In other embodiments, the touch sensor may also be disposed on the surface of the electronic device, at a different location from the display screen 1030.
[0174] It should be noted that the module names involved in the embodiments of the present application can be defined as other names as long as the functions of each module can be achieved, and there is no specific restriction on the names of the modules.
[0175] The data storage method provided in the embodiment of the present application can be applied to an electronic device with a handwriting function. The software structure of the electronic device can be as follows: Figure 1 As shown in the figure, the hardware structure can be as follows Fig.10 As shown in , the specific form of the electronic device can refer to the above description and will not be repeated here.
[0176] Fig.11 The schematic diagram of the structure of a chip provided by the embodiment is exemplarily shown. The chip 1100 includes one or more (including two) processors 1101 , a communication line 1102 , a communication interface 1103 and a memory 1104 .
[0177] In some implementations, the memory 1104 stores the following elements: executable modules or data structures, or a subset thereof, or an extended set thereof.
[0178] The method described in the above embodiment of the present application can be applied to the processor 1101, or implemented by the processor 1101. The processor 1101 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by an integrated logic circuit of hardware or software instructions in the processor 1101. The above processor 1101 can be a general-purpose processor (for example, a microprocessor or a conventional processor), a digital signal processor (digital signal processing, DSP), an application specific integrated circuit (application specific integrated circuit, ASIC), a field-programmable gate array (field-programmable gate array, FPGA) or other programmable logic devices, discrete gates, transistor logic devices or discrete hardware components. The processor 1101 can implement or execute the methods, steps and logic block diagrams related to each processing disclosed in the embodiment of the present application.
[0179] The steps of the method disclosed in the embodiment of the present application can be directly embodied as being executed by a hardware decoding processor, or being executed by a combination of hardware and software modules in the decoding processor. Among them, the software module can be located in a mature storage medium in the field such as a random access memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable read only memory (EEPROM). The storage medium is located in the memory 1104, and the processor 1101 reads the information in the memory 1104 and completes the steps of the above method in combination with its hardware.
[0180] The processor 1101 , the memory 1104 , and the communication interface 1103 may communicate with each other via the communication line 1102 .
[0181] In the above embodiments, the instructions stored in the memory for execution by the processor may be implemented in the form of a computer program product, wherein the computer program product may be pre-written in the memory, or may be downloaded and installed in the memory in the form of software.
[0182] In the embodiment of the present application, the chip 1100 may also be a chip system, such as a system on chip (SOC), which is not limited in the present application.
[0183] An embodiment of the present application provides an electronic device, which includes: one or more processors and a memory; the memory is coupled to the one or more processors, the memory stores computer program code, and the computer program code includes computer instructions; the one or more processors call the computer instructions to enable the electronic device to execute the method in the above embodiment.
[0184] The embodiment of the present application provides a chip or a chip system. The chip or chip system is applied to an electronic device, and the chip or chip system includes one or more processors, and the one or more processors are used to call computer instructions to enable the electronic device to execute the method in the above embodiment. Its implementation principle and technical effect are similar to those of the above-mentioned related embodiments, and will not be repeated here.
[0185] The embodiment of the present application also provides a computer-readable storage medium. The computer-readable storage medium includes computer instructions. When the computer instructions are run on an electronic device, the electronic device executes the method in the above embodiment. The method described in the above embodiment can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. If implemented in software, the function can be stored as one or more instructions or codes on a computer-readable medium or transmitted on a computer-readable medium. Computer-readable media can include computer storage media and communication media, and can also include any medium that can transfer a computer program from one place to another. The storage medium can be any target medium that can be accessed by a computer.
[0186] In one possible implementation, a computer readable medium may include RAM, ROM, compact disc read-only memory (CD-ROM) or other optical disk storage, magnetic disk storage or other magnetic storage devices, or any other medium that is intended to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer. Moreover, any connection is appropriately referred to as a computer readable medium. For example, if the software is transmitted from a website, server or other remote source using a coaxial cable, fiber optic cable, twisted pair, digital subscriber line (DSL) or wireless technology (such as infrared, radio and microwave), the coaxial cable, fiber optic cable, twisted pair, DSL or wireless technology such as infrared, radio and microwave are included in the definition of medium. Disk and optical disk as used herein include optical disk, laser disk, optical disk, digital versatile disk (DVD), floppy disk and Blu-ray disk, where disks usually reproduce data magnetically, while optical disks reproduce data optically using lasers. Combinations of the above should also be included in the scope of computer readable media.
[0187] An embodiment of the present application provides a computer program product, which includes a computer program code. When the computer program code runs on an electronic device, the electronic device executes the method in the above embodiment.
[0188] The embodiments of the present application are described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processing unit of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable device to generate a machine, so that the instructions executed by the processing unit of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0189] The above specific implementation methods further illustrate the purpose, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above are only specific implementation methods of the present invention and are not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made on the basis of the technical solutions of the present invention should be included in the scope of protection of the present invention.
Claims
1. A data storage method, characterized in that: Applied to electronic equipment, the method comprises: At a first moment, a first interface is displayed, the first interface includes a first canvas, the first canvas is used to receive a writing operation of a user and present the writing handwriting, the first canvas is in a writable state, and the first interface is in a first display mode; At a second moment, a first operation that triggers a change in display mode is received; At a third moment, a second interface is displayed, the second interface also includes the first canvas, the first canvas is still in a writable state, the handwriting in the first canvas is the same as at the first moment, the second interface is displayed based on the first operation, the second interface is in a second display mode, and the second display mode is different from the first display mode; The second moment is after the first moment, the third moment is after the second moment, and between the second moment and the third moment, the first canvas in the first interface cannot be saved as a picture, and the first canvas in the second interface is obtained based on the context of the handwriting in the first canvas saved after the second moment.
2. The method according to claim 1, characterized in that The method further comprises: At a fourth moment after the third moment, in response to a second operation on the second interface, a third interface is displayed, the third interface including a first picture, the content presented by the first picture is the same as the writing handwriting in the first canvas of the second interface, the third interface is also in the second display mode, and the second operation is used to exit the writable state of the first canvas in the second interface.
3. The method according to claim 1 or 2, characterized in that: The method further comprises: At the fifth moment, a fourth interface is displayed, wherein the fourth interface includes a second canvas, wherein the second canvas is used to receive a writing operation of the user and present the writing handwriting, the second canvas is in a writable state, and the fourth interface is in the third display mode; At a sixth moment, a third operation triggering a display mode change is received; At the seventh moment, a fifth interface is displayed, the fifth interface includes a second picture, the content presented by the second picture is the same as the handwriting in the second canvas, the fifth interface is displayed based on the third operation, the fifth interface is in a fourth display mode, and the fourth display mode is different from the third display mode; Among them, the sixth moment is after the fifth moment, the seventh moment is after the sixth moment, and between the sixth moment and the seventh moment, the electronic device successfully saves the view data of the second canvas as the second picture after saving the context of the writing handwriting in the second canvas.
4. The method according to any one of claims 1 to 3, characterized in that The electronic device includes a first application, the first application supports a handwriting input function, and the receiving a first operation that triggers a display mode change includes: The main thread receives a first operation that triggers a display mode change, and the main thread is a main thread for interface display in the first application; The method further comprises: The main thread starts a process of destroying the main thread based on the first operation and starts a child thread, where the child thread is a child thread of the main thread and is used to store data; The child thread obtains and saves the context of the handwriting in the first canvas from the main thread; The displaying of the second interface includes: In the case where the main thread is destroyed and then restarted, the restarted main thread loads the context of the handwriting in the first canvas, and uses the context of the handwriting in the first canvas to display the second interface.
5. The method according to claim 4, characterized in that During the main thread destruction process, the method further includes: The child thread sets a flag bit, and sets the value of the flag bit to a first value, where the first value is used to indicate that the canvas cannot be saved as a picture; The child thread obtains the size data of the first canvas from the main thread; The child thread saves a third picture having the same size as the first canvas based on the size data of the first canvas, wherein the third picture does not contain any visual content; The restarted main thread loads the context of the handwriting in the first canvas, including: The restarted main thread loads the third picture and the context of the handwriting in the first canvas when determining that the value of the mark bit is the first value; The displaying of the second interface by using the context of the handwriting in the first canvas includes: The restarted main thread determines the size of the first canvas using the third picture, and loads the writing in the first canvas onto a canvas having the same size as the third picture to display the second interface.
6. The method according to claim 3, characterized in that The electronic device includes a first application, the first application supports a handwriting input function, and the receiving a third operation that triggers a display mode change includes: The main thread receives a third operation that triggers a display mode change, the main thread being the main thread used for interface display in the first application, and the main thread being the main thread used for interface display in the first application; The method further comprises: The main thread starts a process of destroying the main thread based on the third operation and starts a child thread, where the child thread is a child thread of the main thread and is used to store data; The child thread sets a flag bit, and sets the value of the flag bit to a first value, where the first value is used to indicate that the canvas cannot be saved as a picture; The child thread obtains the view data of the second canvas from the main thread, where the view data includes size data of the second canvas and color data of each point in the second canvas; The child thread saves a fourth picture having the same size as the second canvas based on the size data of the second canvas, wherein the fourth picture does not contain any visual content; The child thread obtains and saves the context of the handwriting in the second canvas from the main thread; In a case where the main thread has not been destroyed, the child thread saves the view data as the second picture based on the size data of the second canvas and the color data of each point in the second canvas included in the view data; The child thread modifies the value of the flag bit to a second value, where the second value is used to indicate that the canvas has been successfully saved as a picture; The displaying of the fourth interface includes: In the case where the main thread is destroyed and then restarted, the restarted main thread loads the second image to display the fourth interface when it is determined that the value of the flag bit is not the first value.
7. The method according to any one of claims 4 to 6, characterized in that The main thread is the main thread of the interface activity Activity.
8. The method according to any one of claims 1 to 7, characterized in that The context of the handwriting includes one or more of the following data for each reported point in the handwriting: position data, color data or pen type data.
9. The method according to any one of claims 1 to 8, characterized in that The context of the written handwriting is saved in the ent file format.
10. An electronic device, characterized in that: The electronic device comprises: one or more processors and a memory; The memory is coupled to the one or more processors, and the memory is used to store computer program codes, wherein the computer program codes include computer instructions, and the one or more processors call the computer instructions to enable the electronic device to perform the method as claimed in any one of claims 1 to 9.
11. A chip system, characterized in that: The chip system is applied to an electronic device, and the chip system includes one or more processors, and the one or more processors are used to call computer instructions so that the electronic device executes the method as described in any one of claims 1 to 9.
12. A computer-readable storage medium, characterized in that: The computer-readable storage medium comprises computer instructions, and when the computer instructions are executed on an electronic device, the electronic device is caused to perform the method as claimed in any one of claims 1 to 9.
13. A computer program product, characterized in that The computer program product comprises a computer program code, and when the computer program code is run on an electronic device, the electronic device is caused to perform the method according to any one of claims 1 to 9.
Citation Information
Patent Citations
Writing note data storage method and device, terminal and storage medium
CN108763320A
Note-taking generation method, electronic device, and computer storage medium
CN109085965A
Interactive writing display method and device and electronic equipment
CN112783595A
Display method of annotation box, electronic equipment and readable storage medium
CN116719459A
Tablet having user interface
US20130212535A1
