A method for translating the interface of an application and related devices
By introducing the first software module and the second software module in the electronic device, directly interacting in the translated interface, the problem of users in the prior art need to switch back and forth between the original text and the translated interface is solved, and the human-computer interaction efficiency and user experience are improved.
Patent Information
- Application Number
- CN202010990248.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-09-18
- Publication Date
- 2025-07-18
- Estimated Expiration
- 2040-09-18
AI Technical Summary
In the prior art, when translating the application interface, users need to switch back and forth between the original text interface and the translation interface, resulting in inefficient human-computer interaction.
By introducing the first software module and the second software module in the electronic device, the interactive operation is performed directly in the translated interface, and the original text interface is drawn using the first layout file and the translation interface is displayed after translation, avoiding additional interface switching.
It simplifies user operations and improves human-computer interaction efficiency. Users can directly perform the same interaction as the original text interface in the translation interface, improving the user experience.
Smart Images

Figure CN114201978B_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present application relate to the technical field of terminal devices, and in particular, to a method for translating the interface of an application program and related devices. Background Art
[0002] With the development of technological globalization, in order to provide services to users who speak different languages, the application programs installed in electronic devices need to provide interfaces of application programs in different languages. In the prior art, the electronic device first takes a screenshot of the original text in the original interface of the application program, recognizes the original text in the screenshot through OCR (Optical Character Recognition) technology, then translates the original text and obtains the translated text, and finally displays the translated text through a floating layer or a new window covering the original interface. It can be understood that the translated text is displayed through an additional translated interface covering the original interface. When translating the interface of an application program using the above method, when a user needs to perform an interactive operation with a control in the translated interface of the application program, for example, click a button on the page, the user needs to switch from the translated interface back to the original interface for the interactive operation. When the user needs to view the translated text, the user needs to switch from the original interface to the corresponding translated interface again. The user operation steps are cumbersome and the human-computer interaction efficiency is low. Summary of the Invention
[0003] Embodiments of the present application provide a method for translating the interface of an application program. After translating the interface of the application program according to this method, interactive operations can be directly performed in the interface where the translation result is displayed, thereby simplifying the user operation, improving the human-computer interaction efficiency, and enhancing the user experience.
[0004] A method for translating an interface of an application provided in a first aspect of an embodiment of the present application includes: a first software module in an electronic device obtains a first layout file from a first application, where the first layout file is used to draw a first interface of the first application, and the first layout file includes first text content; the first software module draws the first interface according to the first layout file; the electronic device displays the first interface, where the first text content is displayed in the first interface; the electronic device detects a first operation; in response to the first operation, the first software module sends the first text content to a second software module in the electronic device for translation, the first software module obtains second text content from the second software module, and the first software module draws a second interface of the first application according to the first layout file and the second text content, where the second text content is obtained after translating the first text content; in response to the first operation, the electronic device displays the second interface, where the second text content is displayed in the second interface; the electronic device detects a second operation in a first area of the second interface, where the first area is located near the second text content; in response to the second operation, the electronic device displays a third interface of the first application, where the third interface is associated with the first text content.
[0005] According to the above embodiments, the first text content included in the first layout file obtained by the electronic device from the first application is the original text in the original language. Then, the electronic device can obtain the translation based on the original text, without the first application providing additional language packs to offer application program interfaces in different languages, reducing the development difficulty for application developers. Further, the second interface for displaying the translation (second text content) is drawn by the electronic device (specifically, the first software module in the system of the electronic device for drawing interfaces) according to the first layout file and the second text content. Compared with the first interface, the second interface mainly updates and draws the first text content in the first interface and displays it as the second text content (it can be understood that the electronic device updates the text content to be drawn obtained during the drawing stage through the first software module for drawing the interface of the first application. The information obtained by the electronic device from the first application in the two different stages of drawing the original text interface and the translated text interface is the same, and only the information related to the original text interface is obtained, without the need for the first application to make changes). Other information included in the second interface (such as information for interacting with the user) can be substantially the same as the other information included in the first interface. The second interface can be understood as an interface belonging to the first application, rather than an additional floating layer or new window covering the original application interface, because the second interface includes the information for interacting with the user included in the first interface, and the user can directly perform interactive operations with the elements in the second interface (translated text interface). Specifically, when the user performs a second operation in the first area of the second interface, the first area is near the second text content; in response to the second operation, the electronic device can display the third interface of the first application, where the third interface is associated with the first text content. It can be understood that the third interface displayed after the user performs an interactive operation on the interface element associated with the translation in the second interface is the same as the interface displayed after the user performs an interactive operation on the corresponding interface element associated with the original text in the first interface. Thus, this method enables the user to directly perform the same interactive operations in the translated text interface as in the original text interface, without having to switch back and forth between the original text interface and the translated text interface for interactive operations, thereby simplifying the user operation, improving the human-computer interaction efficiency, and enhancing the user experience.
[0006] Furthermore, the method provided in this embodiment can be implemented by the first software module and the second software module in the operating system of the electronic device to obtain a translated interface according to the original interface of an application program, and enable the user to directly perform interactive operations on the translated interface. This method provides an improved system-level solution for interface translation, which can be applied to any application program installed in the electronic device, realizing the cross-application interface translation function. It is not necessary for each application developer to additionally provide different language packs to provide users with application interfaces in different languages, reducing the development difficulty of application developers.
[0007] In a possible implementation manner of the first aspect of the embodiment of the present application, the first interface includes a first text control, the first layout file includes first information, the first information includes the first text content, and the first information is used to draw the first text control; the first software module in the electronic device draws the first interface according to the first layout file, including: the first software module in the electronic device draws the first text control according to the first information; the electronic device displays the first interface, where displaying the first text content in the first interface includes: the electronic device displays the first text control, where the first text content is displayed in the first text control; the first software module draws the second interface according to the first layout file and the second text content, including: the first software module draws a second text control according to the first information and the second text content; the electronic device displays the second interface, where displaying the second text content in the second interface includes: the electronic device displays the second text control, where the second text content is displayed in the second text control; the first area is located near the second text content, including: the first area is located near the second text control; the third interface is associated with the first text content, including: the third interface is associated with the first text control.
[0008] According to the above embodiments, the electronic device improves the drawing process of the text control, translates the text to be translated during the drawing process, and replaces the original text with the translation result, so that the translation result is displayed on the original interface of the first control. At the same time, the layout file of the application program is not changed, improving the applicability of the translation function.
[0009] In a possible implementation manner of the first aspect of the embodiments of the present application, the association between the third interface and the first text control includes: the third interface is the interface linked by the first text control; or, the third interface is the interface linked by the picture control associated with the first text control, and the picture control is located in the first area. In this implementation manner, considering that the link available for interaction with the user (such as when the user clicks within the operable area of a certain control on the first interface, they can enter the interface linked by the control) may be set in the first text control, or may be set in the picture control associated with the first text control (such as the first text control is used to prompt the function of the picture control), the first area may be the operable area corresponding to the first text control or the operable area corresponding to the picture control associated with the first text control, which can improve the diversity of user operations and the compatibility of the electronic device with user operations.
[0010] In a possible implementation manner of the first aspect of the embodiments of the present application, the first layout file is an Extensible Markup Language (XML) file, and the XML file includes the first information.
[0011] In a possible implementation manner of the first aspect of the embodiments of the present application, the first text control and the second text control are any one of the following: a text view (TextView) control, a list view (ListView) control. The TextView control is a type of text control, and its name can also be taken as other names as long as the functions are the same. For example, it can be called a text box control, etc.
[0012] In a possible implementation manner of the first aspect of the embodiments of the present application, the first software module and the second software module belong to the application framework layer of the electronic device. The first software module and the second software module may be software modules in the operating system of the electronic device. Specifically, they may belong to the application framework layer of the operating system of the electronic device. The operating system of the electronic device may be, for example, the Android operating system.
[0013] In a possible implementation manner of the first aspect of the embodiments of the present application, the first software module sends the first text content to the second software module in the electronic device for translation, and the first software module obtains the second text content from the second software module, including: the first software module sends the first text content to the second software module; the second software module translates the first text content to obtain the second text content; the second software module sends the second text content to the first software module.
[0014] In a possible implementation manner of the first aspect of the embodiments of the present application, the first text content is in a first language, and the second text content is in a second language; a storage module is provided in the second software module; the second software module translates the first text content to obtain the second text content, including: determining, according to the identifier of the first application and the second language, that a first storage unit is stored in the storage module, the first storage unit corresponding to the identifier of the first application and the second language, and the second text content corresponding to the first text content being stored in the first storage unit; and obtaining the second text content corresponding to the first text content from the first storage unit. In this embodiment, when the second text content that has been previously translated is stored in the electronic device, the electronic device can directly obtain the second text content without repeating the translation of the first text content, improving the efficiency of the electronic device in obtaining the translated text and reducing the power consumption of the electronic device.
[0015] In a possible implementation manner of the first aspect of the embodiments of the present application, the first text content is in a first language, and the second text content is in a second language; a storage module and a translation engine are provided in the second software module; the second software module translates the first text content to obtain the second text content, including: judging, according to the identifier of the first application and the second language, whether a first storage unit is stored in the storage module, the first storage unit corresponding to the identifier of the first application and the second language; when the first storage unit is not stored in the storage module, creating the first storage unit in the storage module; translating the first text content through the translation engine to obtain the second text content corresponding to the first text content; and saving the first text content and the corresponding second text content in the newly created first storage unit.
[0016] According to the above embodiments, the electronic device can store the translation result in the translation cache according to the application identifier and the target language (the language corresponding to the translated text to be translated), so that the translated text can be directly obtained in the subsequent translation stage without translation again, avoiding the long translation time caused by calling the server side for translation every time in the prior art, resulting in a stuck display of the translation page, reducing the translation processing time, accelerating the display speed of the translated text interface, and improving the operation efficiency of the system.
[0017] In a possible implementation manner of the first aspect of the embodiment of the present application, the first layout file further includes a first parameter and a second parameter of the first text control, the first parameter includes a format parameter of the first text content, and the second parameter includes an appearance parameter corresponding to the first text control; before the electronic device displays the second interface, the method further includes: the first software module obtains a third parameter according to at least one of the first parameter and the second parameter, and the third parameter includes a format parameter of the second text content; the first software module draws the second text control according to the second parameter and the third parameter.
[0018] According to the above embodiments, by adjusting the format parameters of the text content, the font deformation or confusion in the text control is avoided, the interface display effect of the application program is optimized, and the operation experience of the application program is improved.
[0019] In a possible implementation manner of the first aspect of the embodiment of the present application, the format parameter of the first text content or the format parameter of the second text content includes one or more of the following parameters: font parameter, font size parameter, character spacing parameter, line spacing parameter, number of characters per line parameter, and number of lines parameter.
[0020] In a possible implementation manner of the first aspect of the embodiment of the present application, the first layout file further includes a fourth parameter, and the fourth parameter is used to indicate whether the first text control contains security information; before the first software module sends the first text content to the second software module, the method further includes: the first software module confirms that the first text control does not contain security information according to the fourth parameter.
[0021] According to the above embodiments, the text control including security information is identified through the fourth parameter, and for the control including security information, the translation process is not executed to achieve the purpose of protecting the user information security.
[0022] In a possible implementation of the first aspect of the embodiments of the present application, the first interface includes a first picture control, the first layout file further includes third information, the third information includes a path corresponding to the first picture, the first picture includes third text content, and the third information is used to draw the first picture control; the first software module in the electronic device draws the first interface according to the first layout file, including: the first software module in the electronic device obtains the first picture according to the third information and draws the first picture control; the electronic device displays the first interface, including: the electronic device displays the first picture control, wherein the first picture is displayed in the first picture control, and the third text content is displayed in the first picture; in response to the first operation, the method further includes: the first software module obtains the third text content from the first picture through an OCR method, the first software module sends the third text content to the second software module for translation, the first software module obtains fourth text content from the second software module, the fourth text content is obtained after translating the third text content, the first software module replaces the third text content in the first picture with the fourth text content to obtain a second picture including the fourth text content, and the first software module draws the second picture control according to the first layout file and the second picture; the electronic device displays the second interface, including: the electronic device displays the second picture control, wherein the second picture is displayed in the second picture control, and the fourth text content is displayed in the second picture.
[0023] In a possible implementation of the first aspect of the embodiments of the present application, the first interface includes a first web control, and the first layout file includes fifth information of the first web control. The method further includes: a first software module in the electronic device obtains a first URL (Uniform Resource Locator) corresponding to the first web control from the first application according to the fifth information, and obtains a first HTML (HyperText Markup Language) file corresponding to the first URL according to the first URL. The first HTML file includes fifth text content, and the first HTML file is used to draw the first web control; the first software module draws the first interface according to the first layout file, including: the first software module obtains a first Document Object Model (DOM) tree corresponding to the first HTML file from the first HTML file, and obtains the fifth text content from the first DOM tree, and draws the first web control according to the fifth text content; the electronic device displays the first interface, including: the electronic device displays the first web control, where the fifth text content is displayed in the first web control; in response to the first operation, the method further includes: the first software module sends the fifth text content to the second software module for translation, the first software module obtains sixth text content from the second software module, the sixth text content is obtained after translating the fifth text content, the first software module replaces the first text content in the first DOM tree with the second text content to obtain a second DOM tree including the second text content, and the first software module draws a second web control according to the first layout file and the second DOM tree; the electronic device displays the second interface, including: the electronic device displays the second web control, where the sixth text content is displayed in the second web control.
[0024] According to the above embodiments, by translating the text content in the picture control and the web control in the application, the technical effect that the electronic device translates all the text content in the application is achieved, the consistency of the overall display language of the application is improved, and the user experience is enhanced.
[0025] In a possible implementation of the first aspect of the embodiments of the present application, the second software module translates the first text content to obtain the second text content, including: the second software module sends the first content to the server and obtains the second text content from the server.
[0026] In a possible implementation of the first aspect of the embodiments of the present application, the first software module obtains the third parameter according to the first parameter and the first text, including: obtaining the width of the first text according to the first text and the first parameter; obtaining the third parameter according to the width of the first text and the second text.
[0027] In a possible implementation of the first aspect of the embodiments of the present application, the appearance parameters corresponding to the first text control include the border width and / or height of the first text control; the first software module obtains the third parameter according to the first parameter and the first text content, including: the first software module obtains the third parameter according to the first parameter, the second parameter, the first text content and the second text content.
[0028] In a possible implementation of the first aspect of the embodiments of the present application, the electronic device displays the third interface of the first application in response to the second operation, including: the electronic device displays the third interface, and the third interface displays the seventh text content, where the seventh text content and the second text content are in the same language.
[0029] In a possible implementation of the first aspect of the embodiments of the present application, the electronic device detects a fourth operation, and the fourth operation is used to jump to the desktop application of the electronic device; in response to the fourth operation, the electronic device displays the fourth interface of the electronic device, and the fourth interface is used to display an interface of the desktop application of the electronic device, and the fourth interface displays the eighth text content, and the eighth text content and the second text content are in the same language.
[0030] In a possible implementation of the first aspect of the embodiments of the present application, the width of the first text content is the same as the width of the second text content.
[0031] In a second aspect of the embodiments of the present application, a method for translating an interface of an application is provided. An electronic device displays a first interface of a first application, the first interface including a first text control, and the first text control including first text content. The first text content is displayed in the first interface. The first application is any application installed in the electronic device, and the first text control is any text control in the first interface, and the any text control does not involve security information. The electronic device detects a first operation for instructing the electronic device to translate the text content included in the first application interface. In response to the first operation, the electronic device displays a second interface of the first application. The second interface includes a second text control, and the second text control includes second text content. The second text content is a translation result of the first text content and is displayed in the second interface. The electronic device detects a second operation in a first area of the second interface, and the first area is located near the second text control. In response to the second operation, the electronic device displays a third interface of the first application, where the third interface is associated with the first text control.
[0032] In a possible implementation manner of the second aspect of the embodiments of the present application, in response to the second operation, the electronic device displaying the third interface of the first application includes: the electronic device displays the third interface, the third interface including a third text control, and the third text control including third text content. The third text content is displayed in the third interface, and the third text content and the second text content are in the same language.
[0033] In a possible implementation manner of the second aspect of the embodiments of the present application, the any application includes a desktop application of the electronic device.
[0034] In a possible implementation manner of the second aspect of the embodiments of the present application, the first text control is any one of the following: a text view textview control, a list view listview control.
[0035] In a possible implementation manner of the second aspect of the embodiments of the present application, the third interface being associated with the first text control includes: the third interface is an interface linked by the first text control; or, the third interface is an interface linked by a picture control associated with the first text control, and the picture control is located in the first area.
[0036] In a possible implementation of the second aspect of the embodiments of the present application, the method further includes: in response to the first operation, the electronic device translates the first text content and obtains second text content, including: in response to the first operation, the application framework layer of the electronic device translates the first text content and obtains the second text content.
[0037] It can be understood that the embodiments provided in the second aspect can be used to implement the methods provided in the foregoing first aspect and its implementation manners. Specifically, reference can be made to the methods provided in the foregoing first aspect and its implementation manners.
[0038] The third aspect of the embodiments of the present application provides a method for translating an interface of an application, including:
[0039] The electronic device obtains a first layout file, where the first layout file is used to draw a first interface of a first application, the first layout file includes first information, the first information is used to draw a first text control in the first interface, the first text control includes first text content, and the first information includes the first text content;
[0040] The electronic device displays the first interface according to the first layout file, where the first text content is displayed in the first interface;
[0041] The electronic device detects a first operation, where the first operation is used to instruct the electronic device to translate the text content included in the interface of the first application including at least the first interface;
[0042] In response to the first operation, the electronic device translates the first text content and obtains second text content, where the second text content is the translation result of the first text content;
[0043] In response to the first operation, the electronic device displays a second interface of the first application according to the first layout file and the second text content, the second interface includes a second text control, the second text control includes the second text content, and the second text content is displayed in the second interface;
[0044] The electronic device detects a second operation in a first area of the second interface, where the first area is located near the second text control;
[0045] In response to the second operation, the electronic device displays a third interface of the first application, where the third interface is associated with the first text control.
[0046] In some possible implementations of the third aspect, the electronic device may translate the first text content through the system layer of the electronic device. Specifically, when the system layer of the electronic device is about to draw the interface of the first application, the text content included in the text controls in the obtained interface (such as the software module for drawing the interface in the system layer of the electronic device, such as the first software module mentioned in the above aspects) is translated to obtain the translated text, and then the translated text is used for drawing during the drawing. Since during the interface drawing stage, the first application sends the information of the interface to be drawn to the software module for drawing the interface in the system layer of the electronic device, the software module for drawing the interface can obtain the original text included in the text controls therefrom, and then can perform translation according to the original text to obtain the translated text (such as the second software module mentioned in the above aspects), and then use the translated text for drawing.
[0047] It can be understood that the embodiments provided in the third aspect can be used to implement the methods provided in the foregoing aspects, and reference may be specifically made to the methods provided in the foregoing aspects.
[0048] In the fourth aspect of the embodiments of the present application, an electronic device is provided. The electronic device includes a first software module, a second software module, a display module, and a detection module;
[0049] The first software module is configured to: obtain a first layout file from a first application, where the first layout file is used to draw a first interface of the first application, and the first layout file includes first text content;
[0050] The first software module is further configured to: draw the first interface according to the first layout file;
[0051] The display module is configured to: display the first interface, where the first text content is displayed in the first interface;
[0052] The detection module is configured to: detect a first operation;
[0053] The first software module is further configured to: in response to the first operation, send the first text content to the second software module in the electronic device for translation, obtain second text content from the second software module, and draw a second interface of the first application according to the first layout file and the second text content, where the second text content is obtained by translating the first text content;
[0054] The display module is further configured to: in response to the first operation, display the second interface, where the second text content is displayed in the second interface;
[0055] The detection module is further configured to: detect a second operation in a first area of the second interface, where the first area is near the second text content;
[0056] The display module is further configured to: in response to the second operation, display a third interface of the first application, where the third interface is associated with the first text content.
[0057] It can be understood that the embodiments provided in the fourth aspect can be used to implement the methods provided in the foregoing aspects. Specifically, reference can be made to the methods provided in the foregoing aspects and their implementation manners.
[0058] A fifth aspect of the embodiments of the present application provides an electronic device, including one or more touch screens, one or more memories, and one or more processors; where the one or more memories store one or more programs; when the one or more processors execute the one or more programs, the electronic device implements the method described in any one of the foregoing aspects and their implementation manners.
[0059] A sixth aspect of the embodiments of the present application provides a computer-readable storage medium, including instructions, characterized in that when the instructions run on an electronic device, the electronic device executes the method described in any one of the foregoing aspects and their implementation manners.
[0060] A seventh aspect of the embodiments of the present application provides a computer program product, characterized in that when the computer program product runs on an electronic device, the electronic device executes the method described in any one of the foregoing aspects and their implementation manners.
[0061] In an eighth aspect, the embodiments of the present application provide a device, which is included in an electronic device. The device has the function of implementing the behavior of the electronic device in the foregoing aspect and the possible implementation manners of the foregoing aspect. The device can be an element in the electronic device, such as a chip or a chip system. The function can be implemented by hardware or by hardware executing corresponding software. The hardware or software includes one or more modules or units corresponding to the foregoing functions. For example, a display module or unit, a detection module or unit, a processing module or unit, etc.
[0062] In a ninth aspect, the embodiments of the present application provide a graphical user interface system on an electronic device. The electronic device has a display screen, a memory, and one or more processors. The one or more processors are used to execute one or more computer programs stored in the memory. The graphical user interface includes the graphical user interface displayed when the electronic device executes the method described in any one of the foregoing aspects and their implementation manners.
[0063] As can be seen from the above technical solutions, through some embodiments provided by the present application, users can directly perform the same interaction operations on the translation interface as on the original text interface, without having to switch back and forth between the original text interface and the translation interface to perform interaction operations, thereby simplifying user operations, improving the efficiency of human-computer interaction, and enhancing the user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0064] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the drawings in the following description are some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.
[0065] Figure 1 Structural schematic diagram of an electronic device provided by an embodiment of the present application;
[0066] Figure 2 Software structure block diagram of an electronic device provided by an embodiment of the present application;
[0067] Figures 3-1-1 to 3-5-2 Interface schematic diagram for translating the interface of an application program provided by an embodiment of the present application;
[0068] Figures 4-1 to 4-11 Schematic diagram for translating text controls in the interface of an application program provided by an embodiment of the present application;
[0069] Figures 5-1 to 5-7 Schematic diagram for translating picture controls and web page controls in the interface of an application program provided by an embodiment of the present application;
[0070] Figure 6 Schematic diagram of the workflow for multi-threaded translation of the interface of an application program provided by an embodiment of the present application;
[0071] Figures 7-1 to 7-4 Schematic diagram of the software structure and workflow of a translation module provided by an embodiment of the present application;
[0072] Figure 8 Schematic diagram of the workflow for translating the interface of an application program provided by an embodiment of the present application;
[0073] Figures 9-1 to 9-2 Schematic diagram of the workflow of software and hardware in an electronic device provided by an embodiment of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0074] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the following will clearly and completely describe the technical solutions in a possible implementation manner in conjunction with the accompanying drawings in a possible implementation manner. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all of the embodiments. All embodiments based on the embodiments of the present invention fall within the scope of protection of the present invention.
[0075] The terms used in the following embodiments of this application are only for the purpose of describing specific embodiments and are not intended to limit this application. As used in the specification and claims of this application, the singular forms "a", "an", "the", "above", "said", "this" are also intended to include the plural forms, unless the context clearly indicates otherwise. It should also be understood that the term "and / or" used in this application refers to and includes any or all possible combinations of one or more of the listed items.
[0076] The following introduces embodiments of an electronic device, a user interface for such an electronic device, and for using such an electronic device. In some embodiments, the electronic device may be a portable electronic device that also includes other functions such as a personal digital assistant and / or music player functions, such as a mobile phone, a tablet computer, a wearable electronic device with wireless communication functions (such as a smart watch), etc. Exemplary embodiments of the portable electronic device include, but are not limited to, portable electronic devices running iOS, Android, Microsoft, or other operating systems. The above portable electronic device may also be other portable electronic devices, such as a laptop computer with a touch-sensitive surface or a touch panel. It should also be understood that in some other embodiments, the above electronic device may not be a portable electronic device, but a desktop computer with a touch-sensitive surface or a touch panel.
[0077] The following first introduces the exemplary electronic device 100 provided in the following embodiments of this application. Figure 1The structural schematic diagram of the electronic device 100 is shown. The electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, a headphone jack 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, a barometric pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.
[0078] It can be understood that the structure schematically shown in the embodiments of the present invention does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than shown in the figure, or combine certain components, or split certain components, or have different component arrangements. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
[0079] The processor 110 may include one or more processing units. For example, the processor 110 may include an application processor (AP), a modem processor, a graphics processing unit (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. Among them, different processing units may be independent devices or integrated in one or more processors.
[0080] The controller may generate operation control signals according to the instruction operation code and timing signals to complete the control of fetching and executing instructions.
[0081] A memory can also be provided in the processor 110 for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. This memory can hold the instructions or data that the processor 110 has just used or recycled. If the processor 110 needs to use the instruction or data again, it can directly call it from the memory. This avoids repeated accesses, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.
[0082] In some embodiments, the processor 110 may include one or more interfaces. The interfaces may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.
[0083] The I2C interface is a bidirectional synchronous serial bus that includes a serial data line (SDA) and a serial clock line (SCL). In some embodiments, the processor 110 may include multiple groups of I2C buses. The processor 110 can be respectively coupled to the touch sensor 180K, the charger, the flash, the camera 193, etc. through different I2C bus interfaces. For example: The processor 110 can be coupled to the touch sensor 180K through the I2C interface, enabling the processor 110 and the touch sensor 180K to communicate through the I2C bus interface to implement the touch function of the electronic device 100.
[0084] The I2S interface can be used for audio communication. In some embodiments, the processor 110 may include multiple groups of I2S buses. The processor 110 can be coupled to the audio module 170 through the I2S bus to achieve communication between the processor 110 and the audio module 170. In some embodiments, the audio module 170 can transmit an audio signal to the wireless communication module 160 through the I2S interface to implement the function of answering a phone call through a Bluetooth headset.
[0085] The PCM interface can also be used for audio communication to sample, quantize, and encode analog signals. In some embodiments, the audio module 170 and the wireless communication module 160 can be coupled through the PCM bus interface. In some embodiments, the audio module 170 can also transmit audio signals to the wireless communication module 160 through the PCM interface to implement the function of answering phone calls through a Bluetooth headset. Both the I2S interface and the PCM interface can be used for audio communication.
[0086] The UART interface is a general-purpose serial data bus for asynchronous communication. This bus can be a bidirectional communication bus. It converts the data to be transmitted between serial communication and parallel communication. In some embodiments, the UART interface is generally used to connect the processor 110 and the wireless communication module 160. For example, the processor 110 communicates with the Bluetooth module in the wireless communication module 160 through the UART interface to implement the Bluetooth function. In some embodiments, the audio module 170 can transmit audio signals to the wireless communication module 160 through the UART interface to implement the function of playing music through a Bluetooth headset.
[0087] The MIPI interface can be used to connect the processor 110 to peripheral devices such as the display screen 194 and the camera 193. The MIPI interface includes a camera serial interface (CSI), a display serial interface (DSI), etc. In some embodiments, the processor 110 and the camera 193 communicate through the CSI interface to implement the shooting function of the electronic device 100. The processor 110 and the display screen 194 communicate through the DSI interface to implement the display function of the electronic device 100.
[0088] The GPIO interface can be configured through software. The GPIO interface can be configured as a control signal or a data signal. In some embodiments, the GPIO interface can be used to connect the processor 110 to the camera 193, the display screen 194, the wireless communication module 160, the audio module 170, the sensor module 180, etc. The GPIO interface can also be configured as an I2C interface, an I2S interface, a UART interface, a MIPI interface, etc.
[0089] The USB interface 130 is an interface that complies with the USB standard specification, and can specifically be a Mini USB interface, a Micro USB interface, a USB Type C interface, etc. The USB interface 130 can be used to connect a charger to charge the electronic device 100, and can also be used for data transmission between the electronic device 100 and peripheral devices. It can also be used to connect a headset to play audio through the headset. This interface can also be used to connect other electronic devices, such as AR devices, etc.
[0090] It should be understood that the interface connection relationships between the modules illustrated in the embodiments of the present invention are only illustrative descriptions and do not constitute a structural limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may also adopt different interface connection manners in the above embodiments, or a combination of multiple interface connection manners.
[0091] The charging management module 140 is used to receive a charging input from a charger. Herein, the charger may be a wireless charger or a wired charger. In some embodiments of wired charging, the charging management module 140 may receive the charging input from the wired charger through the USB interface 130. In some embodiments of wireless charging, the charging management module 140 may receive the wireless charging input through the wireless charging coil of the electronic device 100. While charging the battery 142, the charging management module 140 may also supply power to the electronic device through the power management module 141.
[0092] The power management module 141 is used to connect the battery 142, the charging management module 140, and the processor 110. The power management module 141 receives the inputs from the battery 142 and / or the charging management module 140 and supplies power to the processor 110, the internal memory 121, the display screen 194, the camera 193, the wireless communication module 160, etc. The power management module 141 may also be used to monitor parameters such as the battery capacity, the number of battery cycles, and the battery health status (leakage, impedance). In some other embodiments, the power management module 141 may also be disposed in the processor 110. In other embodiments, the power management module 141 and the charging management module 140 may also be disposed in the same device.
[0093] The wireless communication function of the electronic device 100 may be implemented through the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modulation and demodulation processor, and the baseband processor, etc.
[0094] The antenna 1 and the antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in the electronic device 100 may be used to cover a single or multiple communication frequency bands. Different antennas may also be multiplexed to improve the utilization rate of the antennas. For example, the antenna 1 may be multiplexed as the diversity antenna of the wireless local area network. In some other embodiments, the antenna may be used in combination with a tuning switch.
[0095] The mobile communication module 150 may provide a solution for wireless communication including 2G / 3G / 4G / 5G, etc., which is applied to the electronic device 100. The mobile communication module 150 may include at least one filter, switch, power amplifier, low noise amplifier (LNA), etc. The mobile communication module 150 may receive electromagnetic waves through the antenna 1, filter and amplify the received electromagnetic waves, and then transmit them to the modulation and demodulation processor for demodulation. The mobile communication module 150 may also amplify the signal modulated by the modulation and demodulation processor and convert it into electromagnetic waves through the antenna 1 for radiation. In some embodiments, at least some functional modules of the mobile communication module 150 may be disposed in the processor 110. In some embodiments, at least some functional modules of the mobile communication module 150 and at least some modules of the processor 110 may be disposed in the same device.
[0096] The modulation and demodulation processor may include a modulator and a demodulator. Among them, the modulator is used to modulate the low-frequency baseband signal to be transmitted into a medium-high frequency signal. The demodulator is used to demodulate the received electromagnetic wave signal into a low-frequency baseband signal. Subsequently, the demodulator transmits the demodulated low-frequency baseband signal to the baseband processor for processing. After being processed by the baseband processor, the low-frequency baseband signal is transmitted to the application processor. The application processor outputs a sound signal through an audio device (not limited to the speaker 170A, receiver 170B, etc.), or displays an image or video through the display screen 194. In some embodiments, the modulation and demodulation processor may be an independent device. In other embodiments, the modulation and demodulation processor may be independent of the processor 110 and disposed in the same device as the mobile communication module 150 or other functional modules.
[0097] The wireless communication module 160 may provide solutions for wireless communications applied to the electronic device 100, including wireless local area networks (WLANs) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite systems (GNSSs), frequency modulation (FM), near field communication (NFC), infrared (IR), etc. The wireless communication module 160 may be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2, performs frequency modulation and filtering processing on the electromagnetic wave signals, and sends the processed signals to the processor 110. The wireless communication module 160 may also receive signals to be sent from the processor 110, perform frequency modulation and amplification on them, and convert them into electromagnetic waves through the antenna 2 for radiation.
[0098] In some embodiments, the antenna 1 of the electronic device 100 is coupled to the mobile communication module 150, and the antenna 2 is coupled to the wireless communication module 160, so that the electronic device 100 can communicate with the network and other devices through wireless communication technologies. The wireless communication technologies may include Global System for Mobile Communications (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Time-Division Code Division Multiple Access (TD-SCDMA), Long Term Evolution (LTE), BT, GNSS, WLAN, NFC, FM, and / or IR technology, etc. The GNSS may include Global Positioning System (GPS), Global Navigation Satellite System (GLONASS), BeiDou Navigation Satellite System (BDS), Quasi-Zenith Satellite System (QZSS), and / or Satellite Based Augmentation Systems (SBAS).
[0099] The electronic device 100 implements the display function through the GPU, the display screen 194, and the application processor, etc. The GPU is a microprocessor for image processing, and is connected to the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs, which execute program instructions to generate or change the display information.
[0100] The display screen 194 is used to display images, videos, etc. The display screen 194 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), a MiniLED, a MicroLED, a Micro-OLED, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the electronic device 100 may include one or N display screens 194, where N is a positive integer greater than 1.
[0101] The electronic device 100 can implement the shooting function through the ISP, the camera 193, the video codec, the GPU, the display screen 194, and the application processor, etc.
[0102] The ISP is used to process the data fed back by the camera 193. For example, when taking a photo, the shutter is opened, and the light passes through the lens and is transmitted to the camera photosensitive element. The optical signal is converted into an electrical signal, and the camera photosensitive element transmits the electrical signal to the ISP for processing and converts it into an image visible to the naked eye. The ISP can also optimize the noise, brightness, and skin color of the image through algorithms. The ISP can also optimize parameters such as the exposure and color temperature of the shooting scene. In some embodiments, the ISP can be set in the camera 193.
[0103] The camera 193 is used to capture static images or videos. An object generates an optical image through the lens and projects it onto the photosensitive element. The photosensitive element can be a charge-coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the optical signal into an electrical signal, and then transmits the electrical signal to the ISP to convert it into a digital image signal. The ISP outputs the digital image signal to the DSP for processing. The DSP converts the digital image signal into an image signal in standard RGB, YUV, etc. formats. In some embodiments, the electronic device 100 may include one or N cameras 193, where N is a positive integer greater than 1.
[0104] The digital signal processor is used to process digital signals. In addition to processing digital image signals, it can also process other digital signals. For example, when the electronic device 100 selects a frequency point, the digital signal processor is used to perform Fourier transform on the frequency point energy, etc.
[0105] The video codec is used to compress or decompress digital videos. The electronic device 100 can support one or more video codecs. In this way, the electronic device 100 can play or record videos in multiple coding formats, such as: Moving Picture Experts Group (MPEG) 1, MPEG2, MPEG3, MPEG4, etc.
[0106] The NPU is a neural-network (NN) computing processor. By drawing on the structure of biological neural networks, such as the transmission pattern between human brain neurons, it can quickly process input information and can also continuously learn by itself. Through the NPU, applications such as intelligent cognition of the electronic device 100 can be realized, such as: image recognition, face recognition, voice recognition, text understanding, etc.
[0107] The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 through the external memory interface 120 to implement the data storage function. For example, files such as music and videos are saved in the external memory card.
[0108] The internal memory 121 can be used to store computer-executable program code, and the executable program code includes instructions. The internal memory 121 can include a program storage area and a data storage area. Among them, the program storage area can store the operating system, application programs required for at least one function (such as the sound playback function, image playback function, etc.). The data storage area can store data created during the use of the electronic device 100 (such as audio data, phone book, etc.). In addition, the internal memory 121 can include high-speed random access memory and can also include non-volatile memory, such as at least one disk storage device, flash memory device, universal flash storage (UFS), etc. The processor 110 executes various functional applications and data processing of the electronic device 100 by running the instructions stored in the internal memory 121 and / or the instructions stored in the memory provided in the processor.
[0109] The electronic device 100 can implement audio functions through the audio module 170, speaker 170A, receiver 170B, microphone 170C, headphone jack 170D, and the application processor, etc. For example, music playback, recording, etc.
[0110] The audio module 170 is used to convert digital audio information into an analog audio signal for output, and is also used to convert an analog audio input into a digital audio signal. The audio module 170 can also be used for encoding and decoding audio signals. In some embodiments, the audio module 170 can be disposed in the processor 110, or some functional modules of the audio module 170 can be disposed in the processor 110.
[0111] The speaker 170A, also known as the "loudspeaker", is used to convert an audio electrical signal into a sound signal. The electronic device 100 can listen to music or hands-free calls through the speaker 170A.
[0112] The receiver 170B, also known as the "earpiece", is used to convert an audio electrical signal into a sound signal. When the electronic device 100 answers a call or a voice message, the voice can be listened to by bringing the receiver 170B close to the human ear.
[0113] The microphone 170C, also known as the "microphone" or "transmitter", is used to convert a sound signal into an electrical signal. When making a call or sending a voice message, the user can speak by bringing the mouth close to the microphone 170C to input the sound signal into the microphone 170C. The electronic device 100 can be provided with at least one microphone 170C. In some other embodiments, the electronic device 100 can be provided with two microphones 170C, which can not only collect sound signals but also implement a noise reduction function. In some other embodiments, the electronic device 100 can also be provided with three, four or more microphones 170C to implement functions such as collecting sound signals, noise reduction, identifying the sound source, and implementing a directional recording function.
[0114] The headphone jack 170D is used to connect a wired headphone. The headphone jack 170D can be a USB interface 130, or a 3.5mm open mobile terminal platform (OMTP) standard interface, or a cellular telecommunications industry association of the USA (CTIA) standard interface.
[0115] The pressure sensor 180A is used to sense the pressure signal and can convert the pressure signal into an electrical signal. In some embodiments, the pressure sensor 180A can be set on the display screen 194. There are many types of pressure sensors 180A, such as resistive pressure sensors, inductive pressure sensors, capacitive pressure sensors, etc. The capacitive pressure sensor can be a parallel plate including at least two conductive materials. When a force acts on the pressure sensor 180A, the capacitance between the electrodes changes. The electronic device 100 determines the intensity of the pressure according to the change in capacitance. When a touch operation acts on the display screen 194, the electronic device 100 detects the touch operation intensity according to the pressure sensor 180A. The electronic device 100 can also calculate the touch position according to the detection signal of the pressure sensor 180A. In some embodiments, touch operations acting on the same touch position but with different touch operation intensities can correspond to different operation instructions. For example: when a touch operation with a touch operation intensity less than the first pressure threshold acts on the short message application icon, an instruction to view the short message is executed. When a touch operation with a touch operation intensity greater than or equal to the first pressure threshold acts on the short message application icon, an instruction to create a new short message is executed.
[0116] The gyro sensor 180B can be used to determine the motion posture of the electronic device 100. In some embodiments, the angular velocity of the electronic device 100 around three axes (i.e., x, y, and z axes) can be determined by the gyro sensor 180B. The gyro sensor 180B can be used for anti-shake shooting. For example, when the shutter is pressed, the gyro sensor 180B detects the angle of the electronic device 100 shaking, calculates the distance that the lens module needs to compensate based on the angle, and allows the lens to offset the shaking of the electronic device 100 through reverse movement to achieve anti-shake. The gyro sensor 180B can also be used for navigation and somatosensory game scenes.
[0117] The air pressure sensor 180C is used to measure air pressure. In some embodiments, the electronic device 100 calculates the altitude through the air pressure value measured by the air pressure sensor 180C to assist positioning and navigation.
[0118] The magnetic sensor 180D includes a Hall sensor. The electronic device 100 can use the magnetic sensor 180D to detect the opening and closing of the flip leather case. In some embodiments, when the electronic device 100 is a flip phone, the electronic device 100 can detect the opening and closing of the flip cover according to the magnetic sensor 180D. Then, according to the detected opening and closing state of the leather case or the opening and closing state of the flip cover, the flip cover can be automatically unlocked.
[0119] The acceleration sensor 180E can detect the magnitude of the acceleration of the electronic device 100 in all directions (generally three axes). When the electronic device 100 is stationary, the magnitude and direction of gravity can be detected. It can also be used to identify the posture of the electronic device and is applied to applications such as horizontal and vertical screen switching and pedometers.
[0120] A distance sensor 180F is used to measure distance. The electronic device 100 can measure distance by infrared or laser. In some embodiments, when shooting a scene, the electronic device 100 can use the distance sensor 180F to measure distance to achieve fast focusing.
[0121] The proximity light sensor 180G may include, for example, a light-emitting diode (LED) and a light detector, such as a photodiode. The light-emitting diode may be an infrared light-emitting diode. The electronic device 100 emits infrared light outward through the light-emitting diode. The electronic device 100 uses the photodiode to detect the infrared reflected light from a nearby object. When sufficient reflected light is detected, it can be determined that there is an object near the electronic device 100. When insufficient reflected light is detected, the electronic device 100 can determine that there is no object near the electronic device 100. The electronic device 100 can use the proximity light sensor 180G to detect when the user holds the electronic device 100 close to the ear for a call, so as to automatically turn off the screen to save power. The proximity light sensor 180G can also be used for the holster mode and automatic unlocking and locking of the pocket mode.
[0122] An ambient light sensor 180L is used to sense the ambient light brightness. The electronic device 100 can adaptively adjust the brightness of the display screen 194 according to the sensed ambient light brightness. The ambient light sensor 180L can also be used to automatically adjust the white balance when taking pictures. The ambient light sensor 180L can also cooperate with the proximity light sensor 180G to detect whether the electronic device 100 is in the pocket to prevent accidental touch.
[0123] A fingerprint sensor 180H is used to collect fingerprints. The electronic device 100 can use the collected fingerprint characteristics to achieve fingerprint unlocking, access to application locks, fingerprint photography, fingerprint answering of incoming calls, etc.
[0124] A temperature sensor 180J is used to detect temperature. In some embodiments, the electronic device 100 executes a temperature processing strategy using the temperature detected by the temperature sensor 180J. For example, when the temperature reported by the temperature sensor 180J exceeds a threshold, the electronic device 100 reduces the performance of the processor located near the temperature sensor 180J in order to reduce power consumption and implement thermal protection. In other embodiments, when the temperature is lower than another threshold, the electronic device 100 heats the battery 142 to avoid abnormal shutdown of the electronic device 100 caused by low temperature. In still other embodiments, when the temperature is lower than yet another threshold, the electronic device 100 boosts the output voltage of the battery 142 to avoid abnormal shutdown caused by low temperature.
[0125] The touch sensor 180K, also known as the "touch control device". The touch sensor 180K can be disposed on the display screen 194. The touch sensor 180K and the display screen 194 form a touch screen, also known as the "touch control screen". The touch sensor 180K is used to detect touch operations acting thereon or nearby. The touch sensor can transmit the detected touch operation to the application processor to determine the type of touch event. Visual output related to the touch operation can be provided through the display screen 194. In some other embodiments, the touch sensor 180K can also be disposed on the surface of the electronic device 100, at a different position from where the display screen 194 is located.
[0126] The bone conduction sensor 180M can acquire vibration signals. In some embodiments, the bone conduction sensor 180M can acquire vibration signals of the vibrating bone mass of the human vocal part. The bone conduction sensor 180M can also contact the human pulse to receive blood pressure pulsation signals. In some embodiments, the bone conduction sensor 180M can also be disposed in the earphone to form a bone conduction earphone. The audio module 170 can parse out voice signals based on the vibration signals of the vibrating bone mass of the vocal part acquired by the bone conduction sensor 180M to implement the voice function. The application processor can parse out heart rate information based on the blood pressure pulsation signals acquired by the bone conduction sensor 180M to implement the heart rate detection function.
[0127] The button 190 includes a power-on button, a volume button, etc. The button 190 can be a mechanical button. It can also be a touch button. The electronic device 100 can receive button inputs to generate key signal inputs related to the user settings and function control of the electronic device 100.
[0128] The motor 191 can generate vibration prompts. The motor 191 can be used for incoming call vibration prompts and can also be used for touch vibration feedback. For example, touch operations acting on different applications (such as taking pictures, playing audio, etc.) can correspond to different vibration feedback effects. Touch operations acting on different areas of the display screen 194 can also make the motor 191 correspond to different vibration feedback effects. Different application scenarios (such as time reminder, receiving information, alarm clock, games, etc.) can also correspond to different vibration feedback effects. The touch vibration feedback effect can also support customization.
[0129] The indicator 192 can be an indicator light and can be used to indicate the charging state, power change, and can also be used to indicate information, missed calls, notifications, etc.
[0130] The SIM card interface 195 is used to connect to a SIM card. The SIM card can be inserted into or removed from the SIM card interface 195 to achieve contact and separation from the electronic device 100. The electronic device 100 can support one or N SIM card interfaces, where N is a positive integer greater than 1. The SIM card interface 195 can support Nano SIM cards, Micro SIM cards, SIM cards, etc. Multiple cards can be inserted into the same SIM card interface 195 simultaneously. The types of the multiple cards can be the same or different. The SIM card interface 195 can also be compatible with different types of SIM cards. The SIM card interface 195 can also be compatible with external memory cards. The electronic device 100 interacts with the network through the SIM card to implement functions such as calls and data communication. In some embodiments, the electronic device 100 uses an eSIM, i.e., an embedded SIM card. The eSIM card can be embedded in the electronic device 100 and cannot be separated from the electronic device 100.
[0131] The software system of the electronic device 100 can adopt a layered architecture, an event-driven architecture, a microkernel architecture, a microservices architecture, or a cloud architecture. In the embodiments of the present invention, the Android system with a layered architecture is taken as an example to exemplarily illustrate the software structure of the electronic device 100.
[0132] Figure 2 It is a software structure block diagram of the electronic device 100 in the embodiments of the present invention.
[0133] The layered architecture divides the software into several layers, and each layer has a clear role 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: the application layer, the application framework layer, the Android runtime and system libraries, and the kernel layer.
[0134] The application layer may include a series of application packages.
[0135] As Figure 2 shown, the application packages may include applications such as a camera, a gallery, a calendar, a call, a map, a navigation, a WLAN, a Bluetooth, music, a video, a short message, etc.
[0136] The application framework layer provides application programming interfaces (APIs) and programming frameworks for the applications in the application layer. The application framework layer includes some predefined functions.
[0137] As Figure 2 shown, the application framework layer may include a window manager, a content provider, a view system, a translation module, a phone manager, a resource manager, a notification manager, etc.
[0138] The window manager is used to manage window programs. The window manager can obtain the display screen size, determine whether there is a status bar, lock the screen, capture the screen, etc.
[0139] The content provider is used to store and obtain data, and make this data accessible to application programs. The data may include videos, images, audio, dialed and answered calls, browsing history and bookmarks, phone books, etc.
[0140] The view system includes visual controls, such as controls for displaying text, controls for displaying pictures, etc. The view system can be used to build application programs. The display interface can be composed of one or more views. For example, a display interface including a short message notification icon can include a view for displaying text and a view for displaying pictures.
[0141] The translation module includes a translation engine or an APK file stored locally in the system for performing translation functions, etc.
[0142] The phone manager is used to provide the communication function of the electronic device 100. For example, the management of call states (including answering, hanging up, etc.).
[0143] The resource manager provides various resources for application programs, such as localized strings, icons, pictures, layout files, video files, and so on.
[0144] The notification manager enables application programs to display notification information in the status bar. It can be used to convey information of the notification type, and can automatically disappear after a short stay without user interaction. For example, the notification manager is used to inform that the download is completed, information reminder, etc. The notification manager can also be a notification that appears in the system top status bar in the form of a chart or a scroll bar text, such as the notification of a background running application program, and can also be a notification that appears on the screen in the form of a dialogue window. For example, prompting text information in the status bar, emitting a prompt tone, vibrating the electronic device, flashing the indicator light, etc.
[0145] Android Runtime includes a core library and a virtual machine. Android runtime is responsible for the scheduling and management of the Android system.
[0146] The core library consists of two parts: one part is the functional functions that need to be called by the Java language, and the other part is the core library of Android.
[0147] The application layer and the application framework layer run in the virtual machine. The virtual machine executes the Java files of the application layer and the application framework layer as binary files. The virtual machine is used to perform functions such as the management of object life cycles, stack management, thread management, security and exception management, and garbage collection.
[0148] The system library may include multiple functional modules. For example: the surface manager, Media Libraries, 3D graphics processing library (e.g., OpenGL ES), 2D graphics engine (e.g., SGL), etc.
[0149] The surface manager is used to manage the display subsystem and provides the fusion of 2D and 3D layers for multiple applications.
[0150] The media library supports the playback and recording of various common audio and video formats, as well as static image files, etc. The media library can support multiple audio and video coding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.
[0151] The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, synthesis, and layer processing, etc.
[0152] The 2D graphics engine is a drawing engine for 2D drawing.
[0153] The kernel layer is the layer between hardware and software. The kernel layer at least includes a display driver, a camera driver, an audio driver, and a sensor driver.
[0154] In some embodiments, as Figure 3-1-1 shown in S311, the electronic device displays the first interface of the first application, and the first interface displays the first text content and the first picture. The first picture includes the second text content and the first picture content. Among them, both the first text content and the second text content are in Chinese. Among them, the first text content can be any text content in the first interface (excluding the text displayed on the picture), and the first picture content can be any picture content in the first interface.
[0155] In this embodiment, in S312, when the electronic device detects a preset gesture of the user on the first interface of the first application, the electronic device displays a newly created second window. The second window displays the interfaces of "Current Page Translation", "Application Translation (This Time)", and "Application Translation (Unaffected after Exit)". The preset gesture can be clicking on certain positions of the screen, long-pressing the screen, or moving according to a preset pattern on the screen, etc. In some embodiments, the second window can be floatingly displayed on the original application window, or displayed on the side (including the four sides) or in the middle of the display screen.
[0156] In this embodiment, in S313, after the user can select "Application Translation (This Time)", a language list is displayed, and the target language for performing the translation function is selected for the application in the language list.
[0157] In this embodiment, as Figure 3-1-2 shown, in S314, after the user has finished setting, when the system detects that the user has enabled the translation function, the electronic device displays the second interface of the first application program. The second interface displays the third text content and the second picture. The second picture includes the fourth text content and the first picture content. Among them, the third text content is the translation result corresponding to the first text content, the fourth text content is the translation result corresponding to the third text content, and both the third text content and the fourth text content are in the target language.
[0158] In this embodiment, in S315, the user can directly click on the user avatar in the second interface, and the electronic device displays the third interface of the first application program. The third interface displays the fifth text content and the third picture. The third picture includes the sixth text content and the third picture content. Both the fifth text content and the sixth text content are in the target language. The fifth text content can be any text content in the third interface (excluding the text shown on the picture), and the third picture content can be any picture content in the third interface. Since the user selects "Application Translation (This Time)", and since the first application program has not exited, the electronic device translates the text content in multiple interfaces of the first application program. When the user switches the first application program to the new third interface, the electronic device directly executes the translation for the content in the third interface and displays the translated text content.
[0159] In some embodiments, as Figure 3-2-1 shown, step S321 and S322 in this embodiment are the same as steps S311 - S312 in the previous embodiment, and will not be elaborated here.
[0160] In this embodiment, in S323, after the user can select "Current Page Translation", a language list is displayed, and the target language for executing the translation function is selected for the application program in the language list.
[0161] In this embodiment, as Figure 3-2-2 shown, step S324 in this embodiment is the same as S314 in the previous embodiment, and will not be elaborated here.
[0162] In this embodiment, in S325, the user can directly click on the user avatar in the second interface, and the electronic device displays the third interface of the first application. The fifth text content and the third picture are displayed in the third interface. The third picture includes the sixth text content and the third picture content. Both the fifth text content and the sixth text content are in the original language. The fifth text content can be any text content in the third interface (excluding the text displayed on the picture), and the third picture content can be any picture content in the third interface. Since the user selects "Translate the current page", the electronic device translates the text content in the first interface. The first interface is the interface where the user triggers the translation function through a preset gesture. After the user switches the first application to the new third interface, the electronic device does not perform translation on the content in the third interface.
[0163] In some embodiments, as Figure 3-3-1 shown, steps S331 and S332 in this embodiment are the same as steps S311 - S312 in the previous embodiment, and will not be elaborated here.
[0164] In this embodiment, in S333, after the user can select "Translate the application (no impact after exit)", a language list is displayed, and the target language for performing the translation function is selected for the application in the language list.
[0165] In this embodiment, as Figure 3-3-2 shown, step S334 in this embodiment is the same as S314 in the previous embodiment, and will not be elaborated here.
[0166] In this embodiment, in S335, the user double - clicks the return button of the system to exit the current application, and the electronic device displays the third interface. The third interface is the desktop of the electronic device. The fifth text content and the third picture are displayed in the third interface. The third picture includes the sixth text content and the third picture content. Both the fifth text content and the sixth text content are in the original language. Among them, the fifth text content can be any text content in the third interface (excluding the text displayed on the picture), and the third picture content can be any picture content in the third interface.
[0167] In this embodiment, at S336, the user selects the icon of the first application (Toutiao), and the electronic device displays a fourth interface, which is the home page of the first application. The fourth interface displays seventh text content and a fourth picture. The fourth picture includes eighth text content and fourth picture content. Both the seventh text content and the eighth text content are in the target language. Since the user selects "Application Translation (does not affect after exit)", when exiting the first application, the translation function of the first application will not be closed. The electronic device translates the text content in multiple interfaces of the first application. When the user re-opens the first application, the electronic device performs translation on the home page of the first application and displays the translated text content.
[0168] In some embodiments, after the user selects to enable the translation function of the application in the second window, after the electronic device receives this information, the electronic device will turn on the translation function. In some embodiments, when the user selects the "Current Page Translation" function, the electronic device will, according to a preset trigger operation, turn off the translation function. For example, when receiving operations such as the user turning the page, swiping down, or clicking a link, the electronic device will turn off the translation function and will not perform translation on the subsequent user interfaces displayed by the first application. In some embodiments, when the user selects the "Application Translation (This time)" function, after the electronic device receives the operation instruction for the user to exit the first application, the electronic device will turn off the translation function and will not perform translation on the interfaces in the first application opened next time.
[0169] In some embodiments, as Figure 3-4-1 shown, at S341, the user opens the system settings interface of the electronic device, and the user can select the "Application Translation" menu in the system to set the translation function for the application.
[0170] At S342, the interface of the electronic device displays an application list, and the application list includes "All Applications" and the icons of each application; the user selects "All Applications", and the interface of the electronic device displays a language list, and the user selects the target language for which the application performs the translation function in the language list. In some embodiments, the "All Applications" are all the application programs of the electronic device, including the desktop program of the electronic device.
[0171] In this embodiment, at S343, as Figure 3-4-2As shown, when the user clicks to return to the desktop of the system, the electronic device displays a first interface, which is the desktop of the electronic device. The first interface displays first text content and a first picture. The first picture includes second text content and first picture content. Both the first text content and the second text content are in the target language. Since the user selects "All Applications", the electronic device translates the text content on the desktop and displays the translated text content. Among them, the first text content can be any text content on the first interface (excluding the text displayed on the picture), and the first picture content can be any picture content on the first interface.
[0172] In this embodiment, in S344, the user selects the icon of the first application (Toutiao). The electronic device displays a second interface, which is the home page of the first application. The second interface displays third text content and a second picture. The second picture includes fourth text content and second picture content. Both the third text content and the fourth text content are in the target language. Since the user enables the translation function of "All Applications", the electronic device translates the text content in multiple interfaces of the first application. When the user opens the first application, the electronic device translates the home page of the first application and displays the translated text content.
[0173] In some embodiments, as Figure 3-5-1 shown, step S351 in the embodiment is the same as step S341 in the previous embodiment, and will not be described herein again.
[0174] In S352, the interface of the electronic device displays an application list, which includes "All Applications" and the icons of each application; the user selects the first application "Toutiao", and the interface of the electronic device displays a language list. The target language for executing the translation function is selected for the application in the language list.
[0175] In this embodiment, in S353, as Figure 3-5-2 shown, the user clicks to return to the desktop of the system, and the electronic device displays a first interface, which is the desktop of the electronic device. The first interface displays first text content and a first picture. The first picture includes second text content and first picture content. Both the first text content and the second text content are in the original language.
[0176] In this embodiment, at S354, the user selects the icon of the first application (Toutiao), and the electronic device displays a second interface, which is the home page of the first application. The third text content and the second picture are displayed in the second interface. The second picture includes the fourth text content and the second picture content. Both the third text content and the fourth text content are in the target language. Since the user has enabled the translation function of the first application "Toutiao", the electronic device translates the text content in multiple interfaces of the first application. When the user opens the first application, the electronic device performs translation on the home page of the first application and displays the translated text content.
[0177] In some embodiments, after the user selects the target language of the application in the language list, it can be considered that the translation function of the application is enabled.
[0178] In some embodiments, such as Figure 4-1 and Figure 4-5 shown,
[0179] The text control drawing module S401 obtains the first information of the first text control from the first application. The first information includes the application identifier, the original text of the first text control, the original format parameters of the first text control, the sensitive parameters of the first text control, and the control graphic parameters of the first text control.
[0180] In some embodiments, the format parameters include one or more of the following parameters: format parameter, font size parameter, character spacing parameter, line spacing parameter, number of characters per line parameter, and number of lines parameter.
[0181] In some embodiments, the text control drawing module includes a text control data acquisition module, a first text control drawing module, and a text processing module. The text control drawing module obtains the parameters required for drawing the text control from the application by calling the ondraw() program interface in the view system, and refreshes and displays the text control according to the parameters.
[0182] In some embodiments, the electronic device triggers the refresh and drawing of the application interface at regular intervals according to the refresh frequency (for example, 60fps, that is, 60 refreshes per second); the text control drawing module regularly obtains the first information of the first text control from the first application.
[0183] In some embodiments, such as Figure 4-1 shown, the interface of the first application is window 40, and window 40 includes a first picture control 41, a second picture control 42, a third picture control 43, a fourth picture control 44, a fifth picture control 45, a sixth picture control 46, a seventh picture control 47, and an eighth picture control 48.
[0184] The first picture control 41 includes: a text control 41a for displaying the operator text of the mobile communication signal, a picture control 41b for displaying the mobile communication signal, a picture control 41c for displaying the mobile communication signal, a picture control 41d for displaying the wireless mesh signal, a picture control 41f for displaying the battery status, and a picture control 41g for the current time.
[0185] The second picture control 42 includes: a text control 42a for displaying the current application identifier, a picture control 42b for displaying the search, and a picture control 42c for displaying the addition.
[0186] The third picture control 43 includes: a picture control 43a for displaying the avatar of the current chat object, a text control 43b for displaying the name identifier of the current chat object, a text control 43c for displaying the chat information, and a text control 43d for displaying the information sending time.
[0187] The fourth picture control 44, the fifth picture control 45, the sixth picture control 46, and the seventh picture control 47 are similar to the control contents in the third picture control 43 and will not be elaborated here. In this embodiment, 44c and 47c display the information content of the chat, and 43c, 45c, and 46c display the type of the chat information or the reminder information.
[0188] The eighth picture control 48 includes: a picture control 48a for displaying the chat interface identifier, a text control 48b for displaying "WeChat", a picture control 48a for displaying the contact interface identifier, a text control 48c for displaying "Contacts", a picture control 48a for displaying the discovery interface identifier, a text control 48b for displaying "Discovery", a picture control 48a for displaying the my settings interface identifier, and a text control 48c for displaying "Mine".
[0189] In some embodiments, the display content of the controls in the interface of the first application is saved in an XML (Extensible Markup Language) file. For example, Figure 4-4As shown, the layout file includes the layout content of multiple controls, and the multiple controls are displayed in the first interface of the first application. The XML file of the text control contains: the size of the text control (android:layout_width = "wrap_content"; android:layout_height = "wrap_content"), the content of the displayed text (Android:text = ”China Mobile”), the format parameters of the displayed text (Android:text = ”China Mobile”), etc. The XML file of the image control contains the size of the image control (android:layout_width = "wrap_content"; android:layout_height = "wrap_content"), the content of the displayed image (android:src = "picture41"), etc.
[0190] The XML file of the application is the program code formed by the developer when designing the application interface. The developer can select Views provided by the Android system or Views developed by themselves to form the content to be displayed by the application. In some embodiments, Views can be classified into system Views and third-party Views according to the provider. System Views are provided by the Android system and can be used by each developer when designing the user interface. Third-party Views are provided by the application developer. Generally, the electronic device can identify whether it belongs to a system View or a third-party View from the type name of the View. For example, the type name of a system View can be "android.widget.Textview", and the prefix of the system View type name is "android". The type name of a third-party View can be "com.sina.weibo.feed.view.MBlogListItemButtonsView", and the prefix of the third-party View type name is the name of the application, such as "com.sina.weibo".
[0191] As Figure 4-3 As shown, in some embodiments, the mutual relationship between controls can be parsed according to the XML file, and each node in the XML file corresponds to a description of a control. In the XML file, if a node has a parent node at the upper level, then the upper-level node of this node is the parent node of this node. This node is the child node of the upper-level node. The control is the interface element displayed after the xml file included at the node is drawn.
[0192] When the interface is drawn, the content of each control is drawn according to the xml file of the control, and the controls are nested according to the parent-child relationship to form the user interface to be displayed. After the application interface drawing process is completed, the electronic device can obtain a window interface of the application to be displayed composed of all the controls to be displayed.
[0193] In some embodiments, the first text control includes native Android controls (excluding webveiw) that can be used to display text content, and the first control includes buttonview, listview, TextView, etc.
[0194] In some embodiments, the text control data acquisition module obtains the xml file in the first text control from the application, and uses the xml file to obtain the application identifier, the original text of the first text control, the original format parameters of the first text control, the sensitive parameters of the first text control, and the control graphic parameters of the first text control.
[0195] In some embodiments, the text control data acquisition module obtains the XML original file through getResources().getXml() (or through other similar instructions), obtains the XmlResourceParser object, and after parsing the attributes of the xml, obtains the content of the xml file of each control.
[0196] As Figure 4-4 shown, in this embodiment, the following is a part of the xml file of the first text control 48b:
[0197] <TextView
[0198] Android:layout_width="match_parent"
[0199] Android:layout_height="wrap_content"
[0200] Android:textSize="24sp"
[0201] Android:text="WeChat" / >
[0202] In some embodiments, the original text "WeChat" can be obtained through String src = text; the original text format parameters can be obtained through int weight = paint.measureText(src), the secure_flag sensitive parameters can be obtained through LayoutParams params = this.getLayoutParams(), and the application identifier can be obtained by analyzing the xml file.
[0203] The text control data acquisition module in S4011 sends the application identifier, the original text of the first text control, the original text format parameters of the first text control, and the sensitive parameters of the first text control to the text processing module.
[0204] The text control data acquisition module in S4012 sends the control graphic parameters to the first text control drawing module.
[0205] The text control module in S402 sends the application identifier to the translation management module.
[0206] The translation management module in S403 determines whether the first application enables the translation function according to the application identifier. In this embodiment, the translation function of the first application is turned off.
[0207] The translation module in S404 sends the information that the translation function is turned off to the text processing module.
[0208] The text processing module in S4041 obtains the information that the translation function is turned off, and sends the original text and the original text format parameters to the first text control drawing module.
[0209] The first text control drawing module in S405 draws the first text control according to the original text, the original format, the original text, and the control graphic parameters. In some embodiments, the first text control drawing module can draw the text content in the first text control through canvas.drawText(Text, x, y, paint).
[0210] The first text control drawing module in S406 sends the content to be displayed of the first text control to the display. In some embodiments, the user interface to be displayed is a visible interface after being rendered, and the rendering process will use system libraries such as font libraries, 3D graphics processing libraries, 2D graphics processing libraries, surface managers, and image libraries.
[0211] S407. The display shows the first text control. The GPU (Graphics Processing Unit) of the electronic device processes the to-be-displayed interface including the first text control that has been drawn into a multi-dimensional graphic, textures the graphic, rasterizes the graphic (the process of converting the graphic into a series of pixel points is called rasterization), and projects the rasterized graphic onto the display screen. In this way, the user interface that the user can see can be obtained.
[0212] S4101. The translation management module receives an instruction to enable the translation function. The instruction to enable the translation function can enable the translation function in ways such as S313, S323, S333, S342, S352 described in the above embodiments.
[0213] S410 The translation management module receives an instruction to enable the translation function and saves the relevant information about the enabled translation function and the target language.
[0214] S411. The text control drawing module obtains the second information of the first text control from the first application. The first information includes the application identifier, the original text of the first text control, the original format parameters of the first text control, the sensitive parameters of the first text control, and the control graphic parameters of the first text control. In some embodiments, since the text control drawing module has a timing refresh mechanism, therefore, the second information and the first information may include the same information or different information. In this embodiment, the second information and the first information include the same information.
[0215] S4111 The text control data acquisition module sends the application identifier, the original text of the first text control, the original format parameters of the first text control, and the sensitive parameters of the first text control to the text processing module.
[0216] S4112 The text control data acquisition module sends the control graphic parameters to the first text control drawing module.
[0217] S412 The text control module sends the application identifier to the translation management module.
[0218] S413. The translation management module determines whether the first application enables the translation function according to the application identifier. In this embodiment, the translation function of the first application is enabled, and the translation management module obtains the target language of the first application according to the application identifier.
[0219] S414. The translation module sends the target language to the text processing module.
[0220] S415. The text processing module obtains the source language according to the source text and determines whether the target language is the same as the source language. In this embodiment, the target language is not the same as the source language.
[0221] S416. The text processing module determines whether the first text control includes sensitive information according to the sensitive parameter. In this embodiment, the first text control does not include sensitive information.
[0222] In some embodiments, since some content displayed on the user's mobile phone may be sensitive information (such as passwords, etc.), a corresponding security mechanism is provided within the Android system. Third-party applications can notify the system that this interface contains sensitive information by setting the FLAG_SECURE attribute (sensitive parameter) for the control.
[0223] FLAG_SECURE
[0224] A electronic device ed in API level 1
[0225] public static final int FLAG_SECURE
[0226] Window flag: treat the content of the window as secure, preventing it from appearing in screenshots or from being viewed on non-secure displays.
[0227] In some embodiments, by obtaining the Secure_Flag attribute of the control, it is determined whether the current interface is sensitive information. In some embodiments, by determining whether the Secure_Flag attribute of the current page is the same as the default Secure_Flag for containing sensitive information, it is determined that the current interface does not contain sensitive parameters; if the Secure_Flag attribute of the current page is the same as the default Secure_Flag for containing sensitive information, it is determined that the current interface contains sensitive parameters, and if the Secure_Flag attribute of the current page is not the same as the default Secure_Flag for containing sensitive information, it is determined that the current interface does not contain sensitive parameters.
[0228] In this embodiment, after obtaining the secure_flag sensitive parameter, it is determined whether the current parameter includes the sensitive parameter through if((params.flags&WindowManager.LayoutParams.FLAG_SECURE)==0). When the value of the above statement is 0, the parameter of secure_flag does not include the sensitive parameter; otherwise, the parameter of secure_flag includes the sensitive parameter.
[0229] S417. The first text control drawing module sends the original text and the target language to the translation module.
[0230] S418. The translation module translates the original text according to the target language to obtain the translated text.
[0231] In some embodiments, the translation module may be a translation program in the application framework layer. Specifically, the translation program may be an APK file stored locally in the system, etc.; in some embodiments, the translation program may be an application program. Specifically, it may be a file stored in the cloud or a third-party application program. In some embodiments, the original text and the target language are input into the translation module to obtain the translated text; in this embodiment, the translation engine engine is called through String dst = engine.translate(src), and the translated text is obtained from the translation engine, where the scr is the original text and the dst is the translated text.
[0232] S419 The translation module sends the translated text to the text processing module.
[0233] S420. The text processing module calculates the width of the original text area according to the original text and the original text format parameter.
[0234] In some embodiments, the width of the original text area is obtained through int weight = paint.measureText(src), where src is the original text and paint.measureText is the method for obtaining the width according to the original text.
[0235] S421 In some embodiments, the text processing module calculates the format parameter of the translated text according to the width of the original text area and the translated text.
[0236] S4211 The text processing module sends the translated text and the format parameter of the translated text to the first text control drawing module.
[0237] In some embodiments, the first text control drawing module draws the refreshed first text control according to the translated text, the translated text format parameters, and the control graphic parameters.
[0238] In some embodiments, in this embodiment, the first module implements the drawing of text by calling canvas.drawText(dst, x, y, paint), where dst is the translated text, x and y are the coordinates of the first character of the original text relative to the view, and Paint is used to determine the style and size of the font. Among them, FontMetrics is an inner class of Paint and is used to define the original text format parameters and corresponding parameters. The parameters of the Paint can be obtained through the translated text format parameters. In some embodiments, the format parameters of the original text are obtained by paint.setTextSize(scrTextSize).
[0239] S423 The first text control drawing module sends the display content of the first text control to the display.
[0240] S424. The display displays the refreshed first text control.
[0241] In some embodiments, as Figure 4-2 , shown in 4 - 6, the steps S401 - S406, S410 - S415 are the same as those in the above embodiments and will not be elaborated here.
[0242] S416. The text processing module determines whether the first text control includes sensitive information according to the sensitive parameters. In this embodiment, the first text control includes sensitive information.
[0243] S417. The first text control drawing module draws the first text control according to the original text, the original format, the original text, and the control graphic parameters. In some embodiments, the first text control drawing module can draw the text content in the first text control through canvas.drawText(Text, x, y, paint).
[0244] The subsequent steps of sending it to the display for display are the same as those in the above embodiments and will not be elaborated here.
[0245] In some embodiments, S491 first sets the translated text format parameters to the first preset value. The first preset value includes the font size and the character spacing. In this embodiment, y, the font size of the translated text is 40.0f, and the character spacing is the default value.
[0246] S492 calculates the width of the translated text.
[0247] S493 Determine whether the width of the translated text is greater than the width of the original text or the display width of the control
[0248] S494 If the width of the translated text is greater than the width of the original text, adjust the first preset value, for example, reduce the font size or reduce the character spacing, and re-execute S491.
[0249] S495 If the width of the translated text is not greater than the width of the original text, set the current translated text format parameter to the translated text format parameter when drawing the first control.
[0250] In some embodiments, as Figure 4-1 , shown in 4-7, the method includes:
[0251] S501 The text control drawing module obtains the first information of the first text control from the first application, and the first information includes the application identifier, the original text of the first text control, the original text format parameter of the first text control, the width of the first control, the sensitive parameter of the first text control, and the control graphic parameter of the first text control.
[0252] In some embodiments, the text control data acquisition module obtains the width of the first control by calling the getMaxWidth() program interface.
[0253] S5011 The text control data acquisition module sends the application identifier, the original text of the first text control, the original text format parameter of the first text control, the width of the first control, and the sensitive parameter of the first text control to the text processing module.
[0254] S5012 The text control data acquisition module sends the control graphic parameter to the first text control drawing module.
[0255] In some embodiments, the subsequent steps S506-S506 are similar to S402-S407 in the above embodiments and will not be described in detail.
[0256] S5101. The translation management module receives an instruction to enable the translation function, and the instruction to enable the translation function can enable the translation function in the ways such as S313, S323, S333, S342, S352 described in the above embodiments.
[0257] S510. The translation management module receives an instruction to enable the translation function and saves the relevant information about the enabled translation function and the target language.
[0258] The text control drawing module obtains second information of the first text control from the first application. The first information includes the application identifier, the original text of the first text control, the original format parameters of the first text control, the width of the first control, the sensitive parameters of the first text control, and the control graphic parameters of the first text control. In some embodiments, since the text control drawing module has a timing refresh mechanism, the second information and the first information may include the same information or different information. In this embodiment, the second information and the first information include the same information.
[0259] S5111 The text control data acquisition module sends the application identifier, the original text of the first text control, the original format parameters of the first text control, the width of the first control, and the sensitive parameters of the first text control to the text processing module.
[0260] S5112 The text control data acquisition module sends the control graphic parameters to the first text control drawing module.
[0261] In some embodiments, the subsequent steps S512 - S519 are similar to S412 - S419 in the above embodiments and will not be elaborated here.
[0262] S520. The text processing module calculates the format parameters of the translated text based on the width of the control and the translated text.
[0263] S5211 The text processing module sends the translated text and the format parameters of the translated text to the first text control drawing module.
[0264] In some embodiments, the subsequent steps S521 - S523 are similar to S422 - S424 in the above embodiments and will not be elaborated here.
[0265] In some embodiments, as Figure 4-1 , shown in 4 - 8, the method includes:
[0266] S601 The text control drawing module obtains first information of the first text control from the first application. The first information includes the application identifier, the original text of the first text control, the original format parameters of the first text control, the width and height of the first control, the sensitive parameters of the first text control, and the control graphic parameters of the first text control.
[0267] In some embodiments, the text control data acquisition module obtains the width and height of the first control by calling the getMaxWidth() program interface.
[0268] The S6011 text control data acquisition module sends the application identifier, the original text of the first text control, the original format parameters of the first text control, the width and height of the first control, and the sensitive parameters of the first text control to the text processing module.
[0269] The S6012 text control data acquisition module sends the control graphic parameters to the first text control drawing module.
[0270] In some embodiments, the subsequent steps S506 - S506 are similar to S402 - S407 in the above - mentioned embodiments and will not be elaborated here.
[0271] S6101. The translation management module receives an instruction to enable the translation function, and the instruction to enable the translation function can enable the translation function in ways such as S313, S323, S333, S342, S352 described in the above - mentioned embodiments.
[0272] S610. The translation management module receives an instruction to enable the translation function and saves the relevant information about the enabled translation function and the target language.
[0273] S611. The text control drawing module obtains the second information of the first text control from the first application, and the first information includes the application identifier, the original text of the first text control, the original format parameters of the first text control, the width and height of the first control, the sensitive parameters of the first text control, and the control graphic parameters of the first text control. In some embodiments, since the text control drawing module has a timing refresh mechanism, therefore, the second information and the first information may include the same information or different information. In this embodiment, the second information and the first information include the same information.
[0274] The S6111 text control data acquisition module sends the application identifier, the original text of the first text control, the original format parameters of the first text control, the width and height of the first control, and the sensitive parameters of the first text control to the text processing module.
[0275] The S6112 text control data acquisition module sends the control graphic parameters to the first text control drawing module.
[0276] In some embodiments, the subsequent steps S612 - S619 are similar to S412 - S419 in the above - mentioned embodiments and will not be elaborated here.
[0277] S620. The text processing module calculates the format parameters and the number of translated text lines of the translated text according to the width and height of the control and the translated text.
[0278] The S6211 text processing module sends the translated text, the format parameters of the translated text, and the number of translated text lines to the first text control drawing module.
[0279] S621. In some embodiments, the first text control drawing module draws the refreshed first text control according to the translated text, the translated text format parameters, the number of lines of the translated text, and the control graphic parameters.
[0280] In some embodiments, the subsequent steps S622 - S523 are similar to S423 - S424 in the above embodiments and will not be elaborated here.
[0281] Such as Figure 4-9 and 4-10 shown, in some embodiments, the format parameters of the above - mentioned translated text can be obtained through the getTextSize() method. The getTextSize() can be getTextSize(TextView tv, int w, String str), which means obtaining the format parameters of the translated text according to the translated text str to be displayed and the area width of W.
[0282] The getTextSize() is specifically:
[0283]
[0284] In some embodiments, such as Figure 4-11 shown, S4910 sets the translated text format parameters to a first preset value, and the first preset value includes the font size and the character spacing.
[0285] S4911 sets the number of lines of the translated text to a second preset value, and calculates the width of the translated text according to the first preset value and the second preset value.
[0286] S4912 determines whether the width of the translated text is greater than the control display width or the width of the original text.
[0287] S4913 If the width of the translated text is greater than the control display width or the width of the original text, the second preset value is incremented by one, and S4911 is repeatedly executed.
[0288] S4914. If the width of the translated text is not greater than the control display width or the width of the original text, it is determined whether the height of the translated text display is greater than the height of the control, or the height of the original text display.
[0289] S4915. If the height of the translated text display is greater than the preset height, adjust the first preset value, such as reducing the font size or reducing the character spacing, and repeatedly execute S4911.
[0290] S4916. If the height of the translated text display is not greater than the preset height for adjusting the first preset value, set the current translated text format parameters as the translated text format parameters when drawing the first control.
[0291] In this embodiment, for the translation of the first control, by changing the execution process of the first text control drawing module in the application framework layer, the first text control drawing module uses ondraw() to draw the first control. During the drawing process, the translated text is directly used to replace the original text sent by the application, and the translated text is displayed on the original interface of the first control. Moreover, through the adjustment of format parameters, font deformation or chaos on the first control is avoided, and the operation experience of the translated application is improved. In addition, for a large number of applications that do not provide multilingual menus, there is no need to provide a translation language pack in the application, and there is no need to modify the original text in the application. The global translation effect of the first control can be achieved through the application framework layer at the system level of the electronic device, avoiding the application occupying a large amount of storage space and providing an experience close to the native multilingual ability for users of different languages.
[0292] In some embodiments, such as Figure 5-1 and Figure 5-5 shown, the controls of the application further include a first picture control for displaying picture content, and the method further includes:
[0293] The picture control drawing module S801 obtains the first information of the first picture control from the first application, and the first information includes the application identifier, the original picture of the first picture control, and the control graphic parameters of the first picture control.
[0294] In some embodiments, such as Figure 5-1 shown, the interface of the first application is window 50, and window 50 includes a first picture control 41, a second picture control 61, a third picture control 62, a fourth picture control 63, a first web control 70, a second web control 710, a third web control 72, and a fourth web control 73.
[0295] The first picture control 41 includes: an operator text control 41a for displaying the mobile communication signal, a picture control 41b for displaying the mobile communication signal, a picture control 41c for displaying the mobile communication signal, a picture control 41d for displaying the wireless mesh signal, a picture control 41f for displaying the battery status, and a picture control 41g for displaying the current time.
[0296] The second picture control 60 includes: a picture control 60a for displaying a search identifier, a picture control 60b for displaying a search box, and a text control 60c for displaying a search button. The text control 60c can be a textview or a button control, and both belong to the text controls for displaying text.
[0297] The third picture control 61 includes: text controls 61a - 61g for displaying column identifiers, and a picture control 61h for displaying a more content identifier.
[0298] Such as Figure 5-7 In this embodiment, the following is a part of the xml file of the first picture control 62:
[0299] <ImageView
[0300] android:layout_width = "wrap_content"
[0301] android:layout_height = "wrap_content"
[0302] android:src = "picture62"
[0303] / >
[0304] In some embodiments, the picture can obtain the picture (drawable) in the third control through the getDrawable() method or ContextCompat.getDrawable().
[0305] The S8011 picture control data acquisition module sends the application identifier and the original picture of the first picture control to the picture processing module.
[0306] The S8012 picture control data acquisition module sends the control graphic parameters to the first picture control drawing module.
[0307] The S802 picture control module sends the application identifier to the translation management module.
[0308] S803. The translation management module determines whether the first application enables the translation function according to the application identifier. In this embodiment, the translation function of the first application is turned off.
[0309] S804. The translation module sends the information that the translation function is turned off to the picture processing module.
[0310] S8041. The picture processing module obtains the information that the translation function is turned off and sends the original picture to the first picture control drawing module.
[0311] S805. The first picture control drawing module draws the first picture control according to the original picture and the control graphic parameters.
[0312] In one embodiment, the picture is first converted into a bitmap, and then the bitmap is displayed in the canvas. It can be implemented through the following programming language:
[0313] Bitmap DrawableToBitmap(Drawable drawable)
[0314] Canvas canvas = new Canvas(bitmap);
[0315] drawable.draw(canvas);
[0316] The first picture control drawing module of S806 sends the content to be displayed of the first picture control to the display.
[0317] S807. The display shows the first picture control.
[0318] The translation management module of S810 receives an instruction to enable the translation function and saves the relevant information about the enabled translation function and the target language.
[0319] S811. The picture control drawing module obtains the second information of the first picture control from the first application, and the second information includes the application identifier, the original picture of the first picture control, and the control graphic parameters of the first picture control. In some embodiments, since the picture control drawing module is a timing refresh mechanism, therefore, the second information and the first information may include the same information or different information. In this embodiment, the second information and the first information include the same information.
[0320] The picture control data acquisition module of S8111 sends the application identifier and the original picture of the first picture control to the picture processing module.
[0321] The picture control data acquisition module of S8112 sends the control graphic parameters to the first picture control drawing module.
[0322] The picture control module of S812 sends the application identifier to the translation management module.
[0323] S813. The translation management module determines whether the first application enables the translation function according to the application identifier. In this embodiment, the translation function of the first application is enabled, and the translation management module obtains the target language of the first application according to the application identifier.
[0324] S814. The translation module sends the target language to the picture processing module.
[0325] S815. The original text is obtained from the original picture through OCR (Optical Character Recognition) technology, and the content of the original picture includes the original text content and the first picture content.
[0326] S816. The picture processing module obtains the original language according to the original text and determines whether the target language is the same as the original language. In this embodiment, the target language is not the same as the original language.
[0327] S817. The first picture control drawing module sends the original text and the target language to the translation module.
[0328] S818. The translation module translates the original text according to the target language to obtain the translated text.
[0329] S819 The translation module sends the translated text to the picture processing module.
[0330] S820. Replace the original text in the original picture with the translated text to generate a second picture including the translated text. The content of the second picture includes the content of the translated text and the content of the first picture.
[0331] S821 The picture processing module sends the second picture to the first picture control drawing module.
[0332] S822 In some embodiments, the first picture control drawing module draws a refreshed first picture control according to the second picture and the control graphic parameters.
[0333] S823 The first picture control drawing module sends the display content of the first picture control to the display.
[0334] S824. The display displays the refreshed first picture control.
[0335] In some embodiments, such as Figure 5-2 , 5-3, 5-4 and Figure 5-6 shown, the control of the application further includes a first web page control for displaying web page content, and the method further includes:
[0336] S901 The web page control drawing module obtains the first information of the first web page control from the first application. The first information includes the original HTML file to be displayed by the first web page control. Control graphic parameters.
[0337] In this embodiment, the following is a part of the xml file of the first web page control 62:
[0338]
[0339] In some embodiments, such as Figure 5-7As shown, the web control data acquisition module can obtain an HTML file from the server through webView.loadurl(“http: / / www.huawei.com”), or it can obtain a local HTML file through webView.loadurl(“android_asset / xx.html”). The local HTML file is stored in the asset folder of the Android program.
[0340] S9011 The web control data acquisition module sends the application identifier and the original HTML file of the first web control to the web processing module.
[0341] S9012 The web control data acquisition module sends the control graphic parameters to the first web control drawing module.
[0342] S902 The web control module sends the application identifier to the translation management module.
[0343] S903. The translation management module determines whether the first application enables the translation function based on the application identifier. In this embodiment, the translation function of the first application is turned off.
[0344] S904. The translation module sends the information that the translation function is turned off to the web processing module.
[0345] S905 The web processing module obtains the information that the translation function is turned off, and converts the original HTML file into a first DOM tree according to the identifier in the HTML, as shown in the appendix Figure 5-3 as follows.
[0346] S905. The first web control drawing module generates a RenderObject tree and a RenderLayer tree in sequence according to the first DOM tree, and draws the first web control.
[0347] S906 The first web control drawing module sends the content to be displayed of the first web control to the display.
[0348] S907. The display shows the first web control.
[0349] S9101. The translation management module receives an instruction to enable the translation function. The instruction to enable the translation function can enable the translation function through methods such as S313, S323, S333, S342, S352 described in the above embodiments.
[0350] S910 The translation management module receives an instruction to enable the translation function, and saves the relevant information about the enabled translation function and the target language.
[0351] The web control drawing module obtains the second information of the first web control from the first application, and the second information includes the original HTML file. In some embodiments, since the web control drawing module has a timing refresh mechanism, the second information and the first information may include the same information or different information. In this embodiment, the second information and the first information include the same information.
[0352] S9111 The web control data acquisition module sends the application identifier and the original HTML file to the web processing module.
[0353] S9112 The web control data acquisition module sends the control graphic parameters to the first web control drawing module.
[0354] S912 The web control module sends the application identifier to the translation management module.
[0355] S913. The translation management module determines whether the first application enables the translation function according to the application identifier. In this embodiment, the translation function of the first application is enabled, and the translation management module obtains the target language of the first application according to the application identifier.
[0356] S914. The translation module sends the target language to the web processing module.
[0357] S915. The web processing module converts the original HTML file into a first DOM tree according to the identifiers in the HTML, as shown in the appendix Figure 5-3 and obtains the original text to be translated.
[0358] In some embodiments, the method for identifying the original text to be translated includes: scanning the DOM tree of the HTML file to find the original text to be translated. DOM is a standard defined by the World Wide Web Consortium. When loading HTML content, a DOM tree is automatically generated. The DOM tree represents the document as a tree of node objects. In the DOM tree, each node corresponds to a part of the document. Nodes can be of various types, including, for example, root nodes, element nodes, attribute nodes, text nodes, and script nodes. The original text to be translated can be identified by recognizing the comments in the HTML <title>Represents the title element node,< / title> Represents a text node. Determine the content type corresponding to each node according to the node type, and determine the text, title, person name, table, etc. as the original text to be translated.
[0359] S916. The web page processing module obtains the original language according to the original text, and determines whether the target language is the same as the original language. In this embodiment, the target language is not the same as the original language.
[0360] S917. The first web page control drawing module sends the original text and the target language to the translation module.
[0361] S918. The translation module translates the original text according to the target language to obtain the translated text.
[0362] S919. The translation module sends the translated text to the web page processing module.
[0363] S920. Replace the original text in the first DOM tree with the translated text to generate a second DOM tree including the translated text.
[0364] S921. The web page processing module sends the second DOM tree to the first web page control drawing module.
[0365] S922. In some embodiments, the first web page control drawing module sequentially generates a RenderObject tree and a RenderLayer tree according to the second DOM tree, and draws the refreshed first web page control.
[0366] S923. The first web page control drawing module sends the display content of the first web page control to the display.
[0367] S924. The display displays the refreshed first web page control.
[0368] As Figure 6 shown, in some embodiments, S411. The text control drawing module obtains the second information of the first text control from the first application, and the first information includes the application identifier, the first original text of the first text control, the original format parameter of the first text control, the sensitive parameter of the first text control, and the control graphic parameter of the first text control.
[0369] S4111. The text control data acquisition module sends the application identifier, the first original text of the first text control, the original format parameter of the first text control, and the sensitive parameter of the first text control to the text processing module.
[0370] S4112. The text control data acquisition module sends the control graphic parameter to the first text control drawing module.
[0371] The S412 text control module sends the application identifier to the translation management module.
[0372] S413. The translation management module determines whether the first application has the translation function enabled based on the application identifier. In this embodiment, the translation function of the first application is enabled, and the translation management module obtains the target language of the first application according to the application identifier.
[0373] S414. The translation module sends the target language to the text processing module.
[0374] S415. The text processing module obtains the original language according to the first original text and determines whether the target language is the same as the original language. In this embodiment, the target language is not the same as the original language.
[0375] S416. The text processing module determines whether the first text control includes sensitive information according to the sensitive parameter. In this embodiment, the first text control does not include sensitive information.
[0376] S417. The first text control drawing module sends the first original text and the target language to the translation module.
[0377] S418. The translation module translates the first original text according to the target language to obtain the first translated text.
[0378] S419 The translation module sends the first translated text to the text processing module.
[0379] S420. The text processing module calculates the width of the original text area according to the first original text and the original format parameter.
[0380] S421 In some embodiments, the text processing module calculates the format parameter of the first translated text according to the width of the original text area and the first translated text.
[0381] S4211 The text processing module sends the first translated text and the format parameter of the first translated text to the first text control drawing module.
[0382] S422 In some embodiments, the first text control drawing module draws the refreshed first text control according to the first translated text, the translated text format parameter, and the control graphic parameter.
[0383] S423 The first text control drawing module sends the display content of the first text control to the display.
[0384] S424. The display shows the refreshed first text control.
[0385] S411. The text control drawing module obtains the third information of the first text control from the first application. The first information includes the application identifier, the second original text of the first text control, the original format parameters of the first text control, the sensitive parameters of the first text control, and the control graphic parameters of the first text control. In some embodiments, since the text control drawing module has a timing refresh mechanism, the second information and the first information may include the same information or different information. In this embodiment, the second information and the first information include the same information.
[0386] S4111 The text control data acquisition module sends the application identifier, the second original text of the first text control, the original format parameters of the first text control, and the sensitive parameters of the first text control to the text processing module.
[0387] S4112 The text control data acquisition module sends the control graphic parameters to the first text control drawing module.
[0388] S412 The text control module sends the application identifier to the translation management module.
[0389] S413. The translation management module determines whether the translation function of the first application is enabled according to the application identifier. In this embodiment, the translation function of the first application is enabled, and the translation management module obtains the target language of the first application according to the application identifier.
[0390] S414. The translation module sends the target language to the text processing module.
[0391] S4350. Determine whether the second original text is the same as the first original text.
[0392] S435, if the second original text is the same as the first original text.
[0393] S4351, the text processing module sends the first translated text and the format parameters of the first translated text to the first text control drawing module.
[0394] Among them, after the electronic device finishes the last refresh, it stores the first translated text and the format parameters of the first translated text in the cache of the electronic device system; when performing the second refresh, it can directly call the first translated text and the format parameters of the first translated text used during the last refresh.
[0395] The subsequent steps S436 - S438 are similar to S422 - S424 in the above embodiment.
[0396] S445, if the second original text is different from the first original text.
[0397] The text processing module described in S446 determines whether the first text control includes sensitive information according to the sensitive parameter. In this embodiment, the first text control does not include sensitive information.
[0398] S447. The first text control drawing module sends the first and second original texts and the target language to the translation module.
[0399] S448. The translation module translates the first and second original texts according to the target language to obtain the first and second translated texts.
[0400] S449 The translation module sends the first and second translated texts to the text processing module.
[0401] S450. The text processing module calculates the width of the original text area according to the first and second original texts and the original text format parameter.
[0402] S451 In some embodiments, the text processing module calculates the format parameters of the first and second translated texts according to the width of the original text area and the first and second translated texts.
[0403] S4511 The text processing module sends the first and second translated texts and the format parameters of the first and second translated texts to the first text control drawing module.
[0404] S452 In some embodiments, the first text control drawing module draws the refreshed first text control according to the first and second translated texts, the translated text format parameters, and the control graphic parameters.
[0405] S453 The first text control drawing module sends the display content of the first text control to the display.
[0406] S454. The display displays the refreshed first text control.
[0407] In some embodiments, since the refresh frequency of the electronic device is relatively fast, and performing translation each time it is refreshed will increase the operating burden of the electronic device. Considering that users usually perform interactive operations on the electronic device at regular intervals, therefore, by increasing the judgment of the original text content, the repetitive translation work is reduced, and the operating burden of the electronic device is alleviated.
[0408] In some embodiments, after S417, the step S418 includes:
[0409] When the translation module receives the original text and the target language, when the translation module translates the original text, S700, the first module queries whether there is a corresponding storage unit in the cache according to the identifier of the application program and the target language.
[0410] As Figure 7-3 As shown in the figure, the cache is divided into different storage units according to the application identifier and the target language. Each storage unit stores the corresponding translations between the original language and the target language. The original language is the language currently used by the application detected by the application according to the text content. When the application needs to call the translation result, it can call the corresponding storage unit through the application + target language. In some embodiments, the application is the name of the application, or the globally unique identifier of the application, etc. The identifier of the target language can be a preset character. For example, Chinese is CN, English is EN, Japanese is JP, etc.
[0411] In some embodiments, such as Figure 7-4 As shown in the figure, the cache is divided into different storage units according to the application identifier, the original language, and the target language. In some embodiments, when the current language of the application changes, the user can change the language of the current application by selecting different language versions within the application. For example, when it is detected that the user changes the current language of the application from Chinese to English, at this time, the cache creates a new storage unit according to English + application identifier + target language to prevent confusion with the original storage unit and cause abnormal translation.
[0412] In some embodiments, when the application is removed from the electronic device, the storage unit corresponding to the application is deleted from the cache according to the identifier of the application. When the electronic device uninstalls the application, the electronic device will broadcast the information of the uninstalled application through the information manager of the application framework layer. The information includes the application identifier. When the cache detects the broadcast sent by the system, according to the application identifier, the cache deletes the storage unit corresponding to the application.
[0413] In this embodiment, the translation method provided in this embodiment can translate all the application program interfaces in the mobile phone. If all the translation results are loaded into the content, it will occupy a relatively large amount of memory space. When the translation results are stored in the cache according to the storage unit, it can avoid the page lag caused by the traditional translation method by calling the memory, reduce the translation processing time, speed up the text display speed, and improve the system operation efficiency.
[0414] Such as Figure 7-1 As shown in the figure, in S701, if there is a corresponding storage unit in the Cache, the translation module determines that there is a corresponding storage unit according to the application identifier and the target language, and obtains the translated text from the corresponding storage unit.
[0415] The subsequent step is to execute S419.
[0416] Such as Figure 7-2 As shown, if there is no corresponding storage unit in the Cache, a second storage unit is created according to the application identifier and the target language. The first storage unit can be identified by the application and the target language.
[0417] S703 The translation module sends the original text and the target language to the translation engine.
[0418] S704 The translation engine translates the original text according to the target language to obtain the translated text.
[0419] S705 Save the original text and the translated text to the second storage unit.
[0420] The subsequent step is to execute S419.
[0421] In the technical solution provided by the present application, since the translation is performed during the display process of the control, the system needs to provide a relatively fast translation speed during translation. By using the cache to accelerate the translation of the application interface and the display speed of the text, the translation processing time is reduced, and the interface lag caused by excessive translation is avoided.
[0422] As Figure 8 shown, in some embodiments, when the text processing module of the electronic device determines that it is necessary to call the translation module for translation, the electronic device simultaneously calls two different threads. The first thread is used to draw the control according to the original text, and the second thread is used to execute the translation process. In this way, the problem of interface display lag or blank display of the electronic device caused by translation is avoided.
[0423] In some embodiments, the first thread executes S411 - S416 in the above embodiments.
[0424] S460, after S416 ends, when the text processing module determines that it is necessary to call the translation module for translation, the first text control drawing module draws the first text control according to the original text, the original format parameters, and the control graphic parameters.
[0425] S423 The first text control drawing module sends the display content of the first text control to the display.
[0426] S424. The display shows the refreshed first text control.
[0427] At the same time, the electronic device sends the original text and the target language to the translation module in the second thread.
[0428] In the second thread, S418. The translation module translates the original text according to the target language to obtain the translated text.
[0429] After the translation module in S419 finishes translation, the translated text is sent to the text processing module in the first thread.
[0430] After the text processing module in the first thread receives the translated text, it continues to execute S420 - S424 described above.
[0431] In this embodiment, by simultaneously using different threads to handle drawing and translation tasks, the situation of display lag caused by long translation time is avoided, improving the user experience.
[0432] As Figures 9-1 to 9-2 shown, the working processes of the software and hardware of the electronic device 100 for the method of this application are illustrated by way of example.
[0433] In some embodiments, the view manager obtains the XML file of the APP in the application layer. Specifically, the view manager parses the XML of the first text control and the first picture control in the first APP, and obtains the display content in the webview through webview.loadurl().
[0434] In some embodiments, the view manager includes a text control drawing module, a picture control drawing module, and a web page control drawing module. Among them, the text control drawing module is used to draw native Android controls (excluding webveiw) that can display text content, such as buttonview, listview, Textview, etc.; the picture control drawing module is used to draw the imageview control; the web page control drawing module is used to draw the webview control.
[0435] As Figure 9-1 shown, the first software module includes a text control drawing module, a picture control drawing module, and a web page control drawing module; the second software module includes a translation module and a translation management module.
[0436] In some embodiments, the text control drawing module includes a text control data acquisition module, a first text control drawing module, and a text processing module. Among them, the text processing module is used to process the original text. The text processing module obtains the translated text through interaction with the translation management module and the translation module, which is a newly added software module in some embodiments provided by this application. The first text control drawing module is used to draw text controls including the original text or the translated text. The function of the first text control drawing module is different from that of the drawing module in the prior art. The text control data acquisition module is used to acquire the data required during display, and the function of the text control data acquisition module is different from that of the data acquisition module in the prior art.
[0437] In some embodiments, the picture control drawing module includes a picture control data acquisition module, a first picture control drawing module, and a picture processing module. Among them, the picture processing module is used to process the original text. The picture processing module interacts with the translation management module and the translation module to obtain the translated text, which is a newly added software module in some embodiments provided by this application. The first picture control drawing module is used to draw a picture control including the original text or the translated text. The function of the first picture control drawing module is different from that of the drawing module in the prior art. The picture control data acquisition module is used to acquire the data required during the display process. The function of the picture control data acquisition module is different from that of the data acquisition module in the prior art.
[0438] In some embodiments, the web control drawing module includes a web control data acquisition module, a first web control drawing module, and a web page processing module. Among them, the web page processing module is used to process the original text. The web page processing module interacts with the translation management module and the translation module to obtain the translated text, which is a newly added software module in some embodiments provided by this application. The first web control drawing module is used to draw a web control including the original text or the translated text. The function of the first web control drawing module is different from that of the drawing module in the prior art. The web control data acquisition module is used to acquire the data required during the display process. The function of the web control data acquisition module is different from that of the data acquisition module in the prior art.
[0439] As Figure 9-2 shown, the first software module includes a text control drawing module, a picture control drawing module, a web control drawing module, a text control processing module, a picture processing and drawing module, and a web control processing module; the second software module includes a translation module and a translation management module.
[0440] In some embodiments, the text processing module is used to process the original text. The text processing module interacts with the translation management module and the translation module to obtain the translated text. The text processing module includes a first text control data acquisition module and a first text processing module; it is a newly added software module in some embodiments provided by this application. The text control drawing module includes a text control data acquisition module and a first text control drawing module; the function of the text control drawing module is similar to that of the drawing module in the prior art: the text control data acquisition module is used to acquire the data required during the display process, and the first text control drawing module is used to draw the text control. The data of the text control is obtained through the text control data acquisition module.
[0441] In some embodiments, the picture processing module is used to process the original text. The picture processing module obtains the translated text through interaction with the translation management module and the translation module. The picture processing module includes a first picture control data acquisition module and a first picture processing module; it is a software module newly added in some embodiments provided by this application. The picture control drawing module includes a picture control data acquisition module and a first picture control drawing module. The functions of the picture control drawing module are similar to those of the drawing module in the prior art: the picture control data acquisition module is used to obtain the data required during the display process, and the first picture control drawing module is used to draw the picture control, and the picture control is obtained through the picture control data acquisition module.
[0442] In some embodiments, the web page processing module is used to process the original text. The web page processing module obtains the translated text through interaction with the translation management module and the translation module. The web page processing module includes a first web page control data acquisition module and a first web page processing module; it is a software module newly added in some embodiments provided by this application. The web page control drawing module includes a web page control data acquisition module and a first web page control drawing module. The functions of the web page control drawing module are similar to those of the drawing module in the prior art: the web page control data acquisition module is used to obtain the data required during the display process, and the first web page control drawing module is used to draw the web page control, and the web page control is obtained through the web page control data acquisition module.
[0443] In some embodiments, the system library renders the APP interface including multiple controls drawn by the view management module into an interface visible to the user. The rendering process will use components in the system library, such as the font library, 3D graphics processing library, 2D graphics processing library, surface manager, picture library, etc.
[0444] In some embodiments, the system library-rendered APP interface to be displayed is shown through the display screen, so that the user can see the refreshed APP interface on the display screen.
[0445] In addition, in each embodiment of this application, each functional unit can be integrated in a processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit. The various embodiments of this application can be combined arbitrarily to achieve different technical effects.
[0446] In this application, the relevant parts between the method embodiments can be referred to each other; the devices provided by each device embodiment are used to execute the methods provided by the corresponding method embodiments. Therefore, each device embodiment can be understood by referring to the relevant parts in the relevant method embodiments.
[0447] In this application, "and / or" describes the association relationship between associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, both A and B exist simultaneously, and B exists alone, where A and B can be singular or plural. The character " / " generally indicates that the associated objects before and after are in an "or" relationship.
[0448] In this application, "at least one" means one or more, and "a plurality" means two or more. "At least one of the following" or similar expressions refer to any combination of these items, including any combination of single item(s) or plural item(s). For example, "at least one of a, b, or c", or "at least one of a, b, and c" can both represent: a, b, c, a - b (i.e., a and b), a - c, b - c, or a - b - c, where a, b, and c can be single or plural respectively.
[0449] It should be understood that in various embodiments of this application, the magnitudes of the serial numbers of the above processes do not imply the order of execution. Some or all of the steps can be executed in parallel or sequentially. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation to the implementation process of the embodiments of this application.
[0450] It should be understood that although terms such as first, second, and third may be used in the embodiments of the present invention to describe various messages, requests, and terminals, these messages, requests, and terminals should not be limited to these terms. These terms are only used to distinguish the messages, requests, and terminals from each other. For example, without departing from the scope of the embodiments of the present invention, the first terminal can also be referred to as the second terminal, and similarly, the second terminal can also be referred to as the first terminal.
[0451] Depending on the context, the words "if" or "when" as used herein can be interpreted as "when...", "when...", "in response to determining", or "in response to detecting". Similarly, depending on the context, the phrase "if determined" or "if detecting (stated condition or event)" can be interpreted as "when determined", "in response to determining", "when detecting (stated condition or event)", or "in response to detecting (stated condition or event)".
[0452] Those of ordinary skill in the art can realize that the units and algorithm steps of each example described in combination with the embodiments disclosed herein can be implemented by electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Professional technicians can use different methods for each specific application to implement the described functions, but such implementation should not be considered to exceed the scope of this application.
[0453] In some embodiments of the present application, the functional modules of the electronic device can be divided according to the above method examples. For example, each functional module can be corresponding to each function, or two or more functions can be integrated into one processing module. The above integrated module can be implemented in the form of hardware. It should be noted that the division of modules in some embodiments provided in the present application is illustrative, only a logical function division, and there may be other division methods in actual implementation.
[0454] Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working processes of the above-described systems, devices, and units can refer to the corresponding processes in the foregoing method embodiments, and will not be described herein again.
[0455] Those of ordinary skill in the art can understand that all or part of the steps in implementing the above-described method embodiments can be completed by instructing relevant hardware through a program. The program can be stored in a readable storage medium of a device. When the program is executed, it includes all or part of the above steps. The storage medium can be, for example, FLASH, EEPROM, etc.
[0456] When the above-mentioned functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, a server, a network device, or a terminal device, etc.) to execute all or part of the steps of the methods described in various embodiments of this application. The aforementioned storage medium includes: various media that can store program codes, such as USB flash drives, mobile hard disks, read-only memories (ROM), random access memories (RAM), magnetic disks, or optical discs. In the above embodiments, it can be implemented in whole or in part through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center in a wired (such as coaxial cable, optical fiber, digital subscriber line) or wireless (such as infrared, wireless, microwave, etc.) manner. The computer-readable storage medium can be any available medium that a computer can access, or a data storage device such as a server or data center that includes one or more integrated available media. The available medium can be a magnetic medium (such as a floppy disk, a hard disk, a magnetic tape), an optical medium (such as a DVD), or a semiconductor medium (such as a solid-state disk).
[0457] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit them. Although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the foregoing embodiments or perform equivalent replacements for some of the technical features. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the various embodiments of the present invention.
Claims
1. A method for translating the interface of an application, characterized in that, Including: A first software module in an electronic device obtains a first layout file from a first application. The first layout file is used to draw a first interface of the first application, and the first layout file includes first text content; The first software module draws the first interface according to the first layout file; The electronic device displays the first interface, wherein the first text content is displayed in the first interface; The electronic device detects a first operation; In response to the first operation, the first software module sends the first text content to a second software module in the electronic device for translation. The first software module obtains second text content from the second software module, and the first software module draws a second interface of the first application according to the first layout file and the second text content, wherein the second text content is obtained by translating the first text content; In response to the first operation, the electronic device displays the second interface, wherein the second text content is displayed in the second interface; The electronic device detects a second operation in a first area of the second interface, and the first area is located near the second text content; In response to the second operation, the electronic device displays a third interface of the first application, wherein the third interface is associated with the first text content.
2. The method according to claim 1, wherein The first interface includes a first text control, the first layout file includes first information, the first information includes the first text content, and the first information is used to draw the first text control; The first software module in the electronic device drawing the first interface according to the first layout file includes: the first software module in the electronic device drawing the first text control according to the first information; The electronic device displaying the first interface, wherein the first text content is displayed in the first interface, includes: the electronic device displaying the first text control, wherein the first text content is displayed in the first text control; The first software module drawing the second interface according to the first layout file and the second text content includes: the first software module drawing a second text control according to the first information and the second text content; The electronic device displaying the second interface, wherein the second text content is displayed in the second interface, includes: the electronic device displaying the second text control, wherein the second text content is displayed in the second text control; The first area being located near the second text content includes: the first area being located near the second text control; The third interface being associated with the first text content includes: the third interface being associated with the first text control; 3. The method according to claim 2, wherein The third interface being associated with the first text control includes: the third interface being the interface linked by the first text control; or, the third interface being the interface linked by a picture control associated with the first text control, and the picture control is located in the first area.
4. The method according to any one of claims 1-3, characterized in that, The first layout file is an Extensible Markup Language (XML) file, and the XML file includes the first information.
5. The method according to claim 2 or 3, characterized in that, The first text control and the second text control are any one of the following: a text view control or a list view control.
6. The method according to any one of claims 1 to 3, characterized in that The first software module and the second software module belong to the application framework layer of the electronic device.
7. The method according to any one of claims 1-3, characterized in that The first software module sends the first text content to the second software module in the electronic device for translation, and the first software module obtains the second text content from the second software module, including: The first software module sends the first text content to the second software module; The second software module translates the first text content to obtain the second text content; The second software module sends the second text content to the first software module.
8. The method according to claim 7, characterized in that, The first text content is in the first language, and the second text content is in the second language; A storage module is provided in the second software module; The second software module translates the first text content to obtain the second text content, including: According to the identifier of the first application and the second language, it is determined that a first storage unit is stored in the storage module, the first storage unit corresponds to the identifier of the first application and the second language, and the second text content corresponding to the first text content is stored in the first storage unit; Obtain the second text content corresponding to the first text content from the first storage unit.
9. The method according to claim 7, wherein The first text content is in the first language, and the second text content is in the second language; A storage module and a translation engine are provided in the second software module; The second software module translates the first text content to obtain the second text content, including: According to the identifier of the first application and the second language, it is judged whether a first storage unit is stored in the storage module, and the first storage unit corresponds to the identifier of the first application and the second language; When the first storage unit is not stored in the storage module, a new first storage unit is created in the storage module; Translate the first text content through the translation engine and obtain the second text content corresponding to the first text content; Save the first text content and the corresponding second text content in the newly created first storage unit.
10. The method according to claim 2 or 3, characterized in that The first layout file further includes a first parameter and a second parameter of the first text control, the first parameter includes a format parameter of the first text content, and the second parameter includes an appearance parameter corresponding to the first text control; Before the electronic device displays the second interface, the method further includes: The first software module obtains a third parameter according to at least one of the first parameter and the second parameter, and the third parameter includes a format parameter of the second text content; The first software module draws the second text control according to the second parameter and the third parameter.
11. The method according to claim 10, characterized in that, The format parameter of the first text content or the format parameter of the second text content includes one or more of the following parameters: font parameter, font size parameter, character spacing parameter, line spacing parameter, number of characters per line parameter, and number of lines parameter.
12. The method according to claim 2 or 3, characterized in that, The first layout file further includes a fourth parameter, and the fourth parameter is used to indicate whether the first text control contains security information; Before the first software module sends the first text content to the second software module, the method further includes: The first software module confirms that the first text control does not contain security information according to the fourth parameter.
13. The method for translating the interface of an application according to any one of claims 1-3, characterized in that, The first interface includes a first picture control, the first layout file further includes third information, the third information includes a path corresponding to the first picture, the first picture includes third text content, and the third information is used to draw the first picture control; The first software module in the electronic device draws the first interface according to the first layout file, including: the first software module in the electronic device obtains the first picture according to the third information and draws the first picture control; The electronic device displays the first interface, including: the electronic device displays the first picture control, where the first picture is displayed in the first picture control, and the third text content is displayed in the first picture; In response to the first operation, the method further includes: The first software module obtains the third text content from the first picture by an optical character recognition (OCR) method, The first software module sends the third text content to the second software module for translation, The first software module obtains fourth text content from the second software module, and the fourth text content is obtained after translating the third text content, The first software module replaces the third text content in the first picture with the fourth text content to obtain a second picture including the fourth text content, The first software module draws the second picture control according to the first layout file and the second picture; The electronic device displays the second interface, including: the electronic device displays the second picture control, where the second picture is displayed in the second picture control, and the fourth text content is displayed in the second picture.
14. The method according to any one of claims 1-3, characterized in that, The first interface includes a first web page control, the first layout file includes fifth information of the first web page control, and the method further includes: the first software module in the electronic device obtains a first uniform resource locator (URL) corresponding to the first web page control from the first application according to the fifth information, obtains a first hypertext markup language (HTML) file corresponding to the first URL according to the first URL, the first HTML file includes fifth text content, and the first HTML file is used to draw the first web page control; The first software module draws the first interface according to the first layout file, including: the first software module obtains a first Document Object Model (DOM) tree corresponding to the first HTML file according to the first HTML file, and obtains the fifth text content from the first DOM tree, and draws the first web control according to the fifth text content; The electronic device displays the first interface, including: the electronic device displays the first web control, where the fifth text content is displayed in the first web control; In response to the first operation, the method further includes: The first software module sends the fifth text content to the second software module for translation, and the first software module obtains a sixth text content from the second software module, where the sixth text content is obtained after translating the fifth text content; The first software module replaces the first text content in the first DOM tree with the second text content to obtain a second DOM tree including the second text content; The first software module draws a second web control according to the first layout file and the second DOM tree; The electronic device displays the second interface, including: the electronic device displays the second web control, where the sixth text content is displayed in the second web control.
15. An electronic device includes one or more touchscreens, one or more memories, and one or more processors; wherein the one or more memories store one or more programs; characterized in that, When the one or more processors execute the one or more programs, the electronic device implements the method according to any one of claims 1 to 14.
16. A computer-readable storage medium, comprising instructions, characterized in that, When the instruction runs on the electronic device, the electronic device executes the method according to any one of claims 1 - 14.
17. A computer program product, characterized in that, When the computer program product runs on the electronic device, the electronic device executes the method according to any one of claims 1 - 14.
Citation Information
Patent Citations
Translation method and terminal
CN109286725A
Method for displaying user interface and electronic equipment
CN110597512A
Cited By
Method for translating interface of application, and related device
WO2022057889A1