WO2023030030A9 - 翻译方法及电子设备 - Google Patents
翻译方法及电子设备 Download PDFInfo
- Publication number
- WO2023030030A9 WO2023030030A9 PCT/CN2022/113390 CN2022113390W WO2023030030A9 WO 2023030030 A9 WO2023030030 A9 WO 2023030030A9 CN 2022113390 W CN2022113390 W CN 2022113390W WO 2023030030 A9 WO2023030030 A9 WO 2023030030A9
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- translation
- state
- user
- text
- floating window
- Prior art date
Links
- 238000013519 translation Methods 0.000 title claims abstract description 413
- 238000000034 method Methods 0.000 title claims abstract description 96
- 238000007667 floating Methods 0.000 claims abstract description 713
- 230000004044 response Effects 0.000 claims description 49
- 238000004590 computer program Methods 0.000 claims description 12
- 230000001960 triggered effect Effects 0.000 claims description 12
- 238000003860 storage Methods 0.000 claims description 5
- 230000008569 process Effects 0.000 abstract description 26
- 230000014616 translation Effects 0.000 description 347
- 230000000694 effects Effects 0.000 description 55
- 238000012545 processing Methods 0.000 description 32
- 230000000875 corresponding effect Effects 0.000 description 29
- 238000010586 diagram Methods 0.000 description 23
- 230000006870 function Effects 0.000 description 21
- 230000008859 change Effects 0.000 description 18
- 230000006399 behavior Effects 0.000 description 8
- 238000011161 development Methods 0.000 description 7
- 230000009466 transformation Effects 0.000 description 6
- 238000013461 design Methods 0.000 description 5
- 238000012544 monitoring process Methods 0.000 description 5
- 230000007704 transition Effects 0.000 description 5
- 238000005516 engineering process Methods 0.000 description 3
- 239000000725 suspension Substances 0.000 description 3
- 241000876466 Varanus bengalensis Species 0.000 description 2
- 238000013528 artificial neural network Methods 0.000 description 2
- 238000005520 cutting process Methods 0.000 description 2
- 230000008034 disappearance Effects 0.000 description 2
- 238000009826 distribution Methods 0.000 description 2
- 230000006872 improvement Effects 0.000 description 2
- 238000003058 natural language processing Methods 0.000 description 2
- 230000036316 preload Effects 0.000 description 2
- 238000003825 pressing Methods 0.000 description 2
- 230000010076 replication Effects 0.000 description 2
- GRRMZXFOOGQMFA-UHFFFAOYSA-J YoYo-1 Chemical compound [I-].[I-].[I-].[I-].C12=CC=CC=C2C(C=C2N(C3=CC=CC=C3O2)C)=CC=[N+]1CCC[N+](C)(C)CCC[N+](C)(C)CCC[N+](C1=CC=CC=C11)=CC=C1C=C1N(C)C2=CC=CC=C2O1 GRRMZXFOOGQMFA-UHFFFAOYSA-J 0.000 description 1
- 230000001133 acceleration Effects 0.000 description 1
- 230000009471 action Effects 0.000 description 1
- 238000004458 analytical method Methods 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 230000008901 benefit Effects 0.000 description 1
- 238000004364 calculation method Methods 0.000 description 1
- 239000000969 carrier Substances 0.000 description 1
- 238000006243 chemical reaction Methods 0.000 description 1
- 238000004891 communication Methods 0.000 description 1
- 230000004927 fusion Effects 0.000 description 1
- 230000003993 interaction Effects 0.000 description 1
- 230000009191 jumping Effects 0.000 description 1
- 238000010295 mobile communication Methods 0.000 description 1
- 230000001151 other effect Effects 0.000 description 1
- 230000000750 progressive effect Effects 0.000 description 1
- 238000009877 rendering Methods 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F40/00—Handling natural language data
- G06F40/40—Processing or translation of natural language
- G06F40/58—Use of machine translation, e.g. for multi-lingual retrieval, for server-side translation for client devices or for real-time translation
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/01—Input arrangements or combined input and output arrangements for interaction between user and computer
- G06F3/048—Interaction techniques based on graphical user interfaces [GUI]
- G06F3/0484—Interaction techniques based on graphical user interfaces [GUI] for the control of specific functions or operations, e.g. selecting or manipulating an object, an image or a displayed text element, setting a parameter value or selecting a range
- G06F3/04842—Selection of displayed objects or displayed text elements
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/01—Input arrangements or combined input and output arrangements for interaction between user and computer
- G06F3/048—Interaction techniques based on graphical user interfaces [GUI]
- G06F3/0481—Interaction techniques based on graphical user interfaces [GUI] based on specific properties of the displayed interaction object or a metaphor-based environment, e.g. interaction with desktop elements like windows or icons, or assisted by a cursor's changing behaviour or appearance
- G06F3/0482—Interaction with lists of selectable items, e.g. menus
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/01—Input arrangements or combined input and output arrangements for interaction between user and computer
- G06F3/048—Interaction techniques based on graphical user interfaces [GUI]
- G06F3/0487—Interaction techniques based on graphical user interfaces [GUI] using specific features provided by the input device, e.g. functions controlled by the rotation of a mouse with dual sensing arrangements, or of the nature of the input device, e.g. tap gestures based on pressure sensed by a digitiser
- G06F3/0488—Interaction techniques based on graphical user interfaces [GUI] using specific features provided by the input device, e.g. functions controlled by the rotation of a mouse with dual sensing arrangements, or of the nature of the input device, e.g. tap gestures based on pressure sensed by a digitiser using a touch-screen or digitiser, e.g. input of commands through traced gestures
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/54—Interprogram communication
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F2203/00—Indexing scheme relating to G06F3/00 - G06F3/048
- G06F2203/048—Indexing scheme relating to G06F3/048
- G06F2203/04803—Split screen, i.e. subdividing the display area or the window area into separate subareas
Definitions
- the present application relates to the field of computer technology, in particular to a translation method and electronic equipment.
- Translation is in great demand for users who often need to consult foreign language documents.
- the built-in translation application of the mobile terminal or the installed third-party translation application can meet the translation needs of these user groups anytime and anywhere, and translate the words or sentences that need to be queried into the target language in real time, thus bringing great convenience to users.
- most of the translation applications currently on the market require the user to switch back and forth between the current application and the translation application after obtaining the text to be translated to obtain the translation results. The operation steps are cumbersome, resulting in low translation efficiency and affecting user experience.
- the application proposes a translation method and electronic equipment.
- a floating window can be displayed on the current page of the current application program, and the translation result of the word selected by the user can be presented in the floating window.
- the floating window does not compete with the current application page window for focus, so the user can continue to browse the original text after querying a word without closing the floating window.
- the floating window can be displayed on the current page of the current application by selecting the word to be translated, and the newly selected word will be displayed in the floating window
- the translation result of the word It is especially suitable for scenarios where users need continuous translation, and it does not affect the user's experience of browsing the original text during the process of using the application.
- a translation method including an electronic device and an application program, displaying a first interface of the application program, the first interface including a first text and a first floating ball control; in response to the user’s response to the first interface of the application program A first operation of a text, displaying a first control, the first control includes a copy option and a translation option; in response to the user’s copy operation on the copy option, the first text is written into the clip of the electronic device After the copy operation, in response to the user’s operation of the floating ball on the first floating ball control, a floating window is displayed on the first interface, where the floating window includes the first text and the The first translation corresponding to the first text, the floating window displays the first state; in response to the user’s second operation on the first text, the first control is displayed; in response to the user’s translation of the translation option Operation, the floating window is displayed on the first interface, the floating window displays a second state, and the second state is the same as or different from the first state.
- the first interface of the application includes a page with text, such as a reading page in a reading application, which has text that can be read, or a web page in a browser, which has text content that can be browsed, and for example
- the chat interface of the chat application class has the text input by the user, and the note page of the memo class, for example, has the note content entered by the user saved by the user.
- the copy option may also be replaced by a cut option.
- the first text does not include a website address, an email address, or a password generated by a machine, and the first text is different from a system language of the electronic device.
- the machine-generated passwords include passwords such as Taobao passwords or Douyin passwords, which are generally used to correspond to specific commodities or video pages, so it is judged that the user does not need to translate such texts at this time. In this way, the interruption to the user can be reduced as much as possible, and the user experience can be improved.
- the application programs do not include consumer, entertainment or video applications.
- consumer applications include applications such as Taobao or JD.com
- entertainment applications include applications such as Douyin or games
- video applications include applications such as Tencent Video or iQiyi.
- the first operation includes any one of a selection operation, a touch operation, a click operation, a slide operation, a long press operation, or a double-click operation on the first text
- the second The operation includes any one of a selection operation, a touch operation, a click operation, a slide operation, a long-press operation or a double-click operation on the first text.
- first operation and second operation are to select text, so there are many ways how to select the text that the user needs to translate, which is not limited in the implementation manner of the present application.
- the method further includes not displaying the first floating ball control and/or the first control on the first interface after the floating window is displayed on the first interface.
- the above-mentioned first floating ball control and the first control are hidden and displayed.
- the number of icons that duplicate functions on the current page of the current application can be reduced to the greatest extent possible, reducing the interruption to the user, and at the same time, displaying the floating window necessary for the user's translation operation to improve the user experience.
- the first state of the floating window includes any one of a bottom state, a half-screen state, or a full-screen state
- the second state of the floating window includes a bottom state, a half-screen state, or a bottom state. Either screen mode or full screen mode.
- the floating window includes three forms, and different states are divided into bottom state, half-screen state and full-screen state from low to high according to the height of the screen occupied. It displays floating window forms in different states according to the user's selection. Correspondingly, due to the difference in the display area of the floating window, the translation result content displayed in the full screen state will be more than that in the half screen state and the bottom state. Similarly, the translation result content displayed in the half screen state will be more than that in the bottom state. In this way, by displaying the floating windows in different forms, the user's experience with the floating windows is enriched and the user experience is improved.
- the state of the floating window can be a half-screen state, so that in this state, the user can obtain the queried word in the floating window
- the translation results can also be conveniently operated on the first interface of the current page, with greater user selectivity and better user experience.
- the first interface further includes a first area, and the first area is an area of the first interface except for the floating window.
- the current page of the application when the floating window is displayed, the current page of the application includes the floating window and the remaining area other than the area occupied by the floating window in the current page, wherein the first area may be the area occupied by the floating window in the current page The rest of the area outside the area.
- the user can conveniently browse or slide the content of the first interface of the current application at any time during the process of using the floating window.
- the floating window in response to a user's third operation on the first area, displays a third state, and the third state includes any of bottom state, half-screen state or full-screen state One, the third state is the same as or different from the first state, and the third state is the same as or different from the second state.
- the size of the first region is variable, and the size of the region varies according to the shape of the floating window. It can be understood that, when the floating window is in the bottom state, the area of the first region is larger than that when the floating window is in the middle state. It can be understood that, when the floating window is in the intermediate state, the area of the first region thereof is larger than that of the first region when the floating window is in the full-screen state. In this way, by setting the size of the first area and its adaptively adjusted area relative to the different forms of the floating window, the user can conveniently browse or slide the content of the first interface of the current application at any time during the use of the floating window.
- the third state of the floating window can be the bottom state, so as to intuitively give the user feedback that the current focus has shifted to the first interface of the current application operated by the user instead of floating window. In this way, the user's experience of using the floating window can be effectively improved.
- the third operation includes any one of a touch operation, a click operation, a slide operation, or a long press operation on the first area.
- the first interface further includes second text
- the first control is displayed in response to a fourth operation performed by the user on the second text
- the fourth operation includes Any one of the selection operation, touch operation, click operation, slide operation, long press operation or double-click operation of the second text
- the second text is the same as or different from the first text
- the second text Excluding URLs, email addresses or using machine-generated passwords, the second text is different from the system language of the electronic device.
- the user can also continue to query a new word, that is, the second text, so that the user does not need to exit the current application and switch to a third-party translation application to query the word.
- Real-time query of translation can be realized on the current page, eliminating the need to switch back and forth between the current application and the translation application to obtain translation results, and improving translation efficiency.
- the second text is written into the clipboard of the electronic device, a floating window is displayed on the first interface, and the The floating window displays a fourth state, the floating window includes the second text and the second translation corresponding to the second text, the floating window does not include the first text and the first translation, and the first translation
- the fourth state is the same as or different from the third state.
- the user can also continue to query a new word, that is, the second text. Then, the system puts the latest word selected by the user into the clipboard and requests the translation result from the translation server. Since the clipboard will keep the text copied or cut by the user last time, when the second text is written into the clipboard , the first text is covered. When the user triggers to display the floating window, the second text and its corresponding translation are displayed in the floating window. At this time, the first text and its corresponding translation are no longer displayed.
- the user does not need to exit the current application and switch to a third-party translation application to query words, and the real-time query of translation can be realized on the current page of the current application, eliminating the need to switch back and forth between the current application and the translation application to obtain translation results , improving translation efficiency.
- the state of the floating window can be set to be the same as the state of the floating window displayed last time according to the user's habits, or it can be different, which will improve the user's ability to use the floating window. experience.
- the state of the floating window can be half-screen, so that in this state, the user can obtain the translation result of the queried word in the floating window, and can also conveniently operate On the first interface of the current page, users have more options and better user experience.
- the floating window in response to the user's translation operation on the translation option, the floating window is displayed on the first interface, the floating window displays a fifth state, and the floating window includes the first The second text and the second translation corresponding to the second text, the floating window does not include the first text and the first translation, and the fifth state is the same as or different from the third state.
- the user can also continue to query a new word, that is, the second text.
- a new word that is, the second text.
- the user's intention clearly shows that the user needs to translate the currently newly selected word.
- the system puts the latest word selected by the user into the clipboard and requests the translation result from the translation server. Since the clipboard will keep the text copied or cut by the user last time, when the second text is written into the clipboard , the first text is covered.
- the user triggers to display the floating window, the second text and its corresponding translation are displayed in the floating window. At this time, the first text and its corresponding translation are no longer displayed.
- the user does not need to exit the current application and switch to a third-party translation application to query words, and the real-time query of translation can be realized on the current page of the current application, eliminating the need to switch back and forth between the current application and the translation application to obtain translation results , improving translation efficiency.
- the state of the floating window can be set to be the same as the state of the floating window displayed last time according to the user's habits, or it can be different, which will improve the user's ability to use the floating window. experience.
- the state of the floating window can be half-screen, so that in this state, the user can obtain the translation result of the queried word in the floating window, and can also conveniently operate On the first interface of the current page, users have more options and better user experience.
- the floating window is slidable, and the floating window includes any one or more of a bottom state, a half-screen state or a full-screen state, and the floating window is in the bottom state , the half-screen state or any one or more of the full-screen state.
- the floating window can display different forms according to different operations of the user.
- the different needs of the user for the display form of the floating window are met, and at the same time, the user can choose whether to display more translated content according to different scenarios, which enriches the user experience.
- the floating window in response to the user's first sliding operation on the floating window in the first state, after it is determined that the sliding operation satisfies a sliding condition, the floating window displays a sixth state, and the floating window displays a sixth state.
- the sixth state is different from the first state, and the sixth state includes any one of bottom state, half-screen state or full-screen state; after judging that the sliding operation does not meet the sliding condition, the floating window displays the seventh state, the seventh state is the same as the first state, and the seventh state includes any one of a bottom state, a half-screen state or a full-screen state.
- the sliding of the floating window has its judging conditions, that is, for example, in the half-screen state of the floating window, not all operations of sliding the floating window up by the user will display the floating window as a full-screen state, that is, in When the sliding condition is satisfied, the floating window will be displayed from the half-screen state to the full-screen state; if the condition is not met, the floating window will remain in the half-screen state. In this way, by setting the sliding condition, the random movement of the floating window caused by the user's mistaken touch is prevented, and the user experience is improved.
- the floating window in the first state is a state shown in the floating window displayed after the user performs a copy operation on the first text.
- the floating window in response to the user's second sliding operation on the floating window in the second state, after judging that the sliding operation satisfies a sliding condition, the floating window displays an eighth state, and the floating window displays an eighth state.
- the eighth state is different from the second state; after judging that the sliding operation does not satisfy the sliding condition, the floating window displays a ninth state, the ninth state is the same as the second state, and the eighth state includes Any one of bottom state, half screen state or full screen state, the ninth state includes any one of bottom state, half screen state or full screen state.
- the sliding of the floating window has its judging conditions, that is, for example, in the half-screen state of the floating window, not all operations of sliding the floating window up by the user will display the floating window as a full-screen state, that is, in When the sliding condition is satisfied, the floating window will be displayed from the half-screen state to the full-screen state; if the condition is not met, the floating window will remain in the half-screen state. In this way, by setting the sliding condition, the random movement of the floating window caused by the user's mistaken touch is prevented, and the user experience is improved.
- the floating window in the second state is a state shown in the floating window displayed after the user performs a translation operation on the first text.
- the sliding condition includes satisfying any one or more of a sliding distance, a sliding speed, and a sliding direction. In this way, by setting the sliding condition, the random movement of the floating window caused by the user's mistaken touch is prevented, and the user experience is improved.
- judging that the sliding distance satisfies a condition includes judging that the sliding distance is greater than a quarter of a screen height of the electronic device.
- the floating window is in the bottom state and the half screen state Or switching between the half-screen state and the full-screen state; if the sliding distance is greater than three quarters of the screen height of the electronic device, the floating window is switched between the bottom state and the full-screen state .
- the floating window when the sliding speed satisfies the condition, the user slides the floating window upwards, and when the sliding distance is greater than three quarters of the height of the screen of the electronic device, the floating window displays for full screen. In this way, by setting the sliding condition, the random movement of the floating window caused by the user's mistaken touch is prevented, and the user experience is improved.
- the floating ball preloads the first detailed translation corresponding to the first translation before sliding from the half-screen state to the full-screen state, and the first detailed translation It includes content that the first translation is displayed in the floating window in the full-screen state and not displayed in the floating window in the half-screen state.
- the floating window further includes a first internal window, and the first internal window includes the first translation and/or the first detailed translation.
- the floating window includes a first internal window for displaying translation results.
- the first internal window is slidable, and is used to display content corresponding to the first translation.
- the floating window includes the first internal window, which is different from the sliding logic of the floating window itself in the three states. Due to the bottom layer display of Android, the first internal window inside the floating window also needs to design the sliding logic separately. Therefore, the user When using the floating window, more translation result content can be displayed by sliding the first inner window in the floating window, thereby improving user experience.
- the floating ball and floating window set in the system window do not have the function of activity.
- the floating ball and floating window Similar to the activity in the application window, that is, display content and operations based on the user sliding on the floating ball and floating window, it is necessary to additionally set sliding operations and sliding conflicts in the system window, and According to the user's click and other operations, determine the focus of the response window, etc.
- the first internal window displays the second detailed translation
- the second The detailed translation includes a portion of said first detailed translation
- the floating window includes the first internal window, which is different from the sliding logic of the floating window itself in the three states. Due to the bottom layer display of Android, the first internal window inside the floating window also needs to design the sliding logic separately. Therefore, the user When using the floating window, more translation result content can be displayed by sliding the first inner window in the floating window, thereby improving user experience.
- both the second detailed translation and the first detailed translation are translation result contents corresponding to the first translation
- the complete translation result of the first text includes the first translation, the first detailed translation and the second detailed translation.
- the first translation is the Chinese translation result of the word corresponding to the simple first text
- the first detailed translation is a partial example sentence corresponding to the first text.
- the second detailed translation is used to display the translation result content not displayed in the first translation and the first detailed translation, such as more dictionary example sentences, etc. .
- the first interface before displaying the first interface of the application program including the first floating ball control, it further includes: the first interface further includes third text, and in response to the user's In the fifth operation of the third text, the first interface displays a second control, wherein the fifth operation includes a selection operation, a touch operation, a click operation, a slide operation, and a long press operation on the third text or any one of the double-click operations, the third text is the same as or different from the first text, and the third text does not include URLs, mailboxes or passwords generated by machines, and the third text is not the same as the electronic The system language of the device is different.
- the options in the second control include a copy option or a cut option.
- the first interface displays the second floating ball control, and the sixth operation includes the Any one of the copy operation of the copy option or the cut operation of the cut option.
- the second floating ball control is configured to provide the user with an entry to display translation results. After the user clicks or touches the second floating ball control, a floating window with translation results is displayed. Optionally, after the floating window is displayed, the second floating ball control disappears or remains displayed, which is not limited in this application.
- the first floating ball control is set to display the first floating ball control after the user does not trigger any click or touch operation on the second floating ball control within a preset time. At this time, it is determined that the user does not need to perform the translation operation. Therefore, when the user triggers the copy operation, the user's copy behavior will be determined as a normal text copy behavior, and the first floating ball control will continue to be displayed.
- the system judges that the user has the intention of translation at this time, and thus displays a floating ball on the current page of the current application , if the user needs to continue to display the translation results at this time, he can continue to click the above-mentioned second floating ball control to display the translation results in the floating window.
- the translation intention of the user is recognized, thereby displaying the second floating ball control for prompting to display the translation result, and according to the user's operation, it is selected whether to display the floating window to display the translation result.
- the user does not need to exit the current application and switch to a third-party translation application to query words, and the real-time query of translation can be realized on the current page of the current application, eliminating the need to switch back and forth between the current application and the translation application to obtain translation results , improving translation efficiency.
- the method further includes: displaying the floating window in response to the user's seventh operation on the second floating ball control, the floating window including the third text and the third text
- the seventh operation includes any one of a touch operation, a click operation, or a long press operation.
- the system judges that the user has the intention of translation at this time, and thus displays a floating ball on the current page of the current application , if the user needs to continue to display the translation results at this time, he can continue to click the above-mentioned second floating ball control to display the translation results in the floating window.
- the translation intention of the user is recognized, thereby displaying the second floating ball control for prompting to display the translation result, and according to the user's operation, it is selected whether to display the floating window to display the translation result.
- the user does not need to exit the current application and switch to a third-party translation application to query words, and the real-time query of translation can be realized on the current page of the current application, eliminating the need to switch back and forth between the current application and the translation application to obtain translation results , improving translation efficiency.
- it further includes, before displaying the second floating ball control, displaying a floating ball logo, and after a first preset time, the floating ball logo disappears, and the second floating ball control is displayed.
- Ball controls before displaying the second floating ball control, displaying a floating ball logo, and after a first preset time, the floating ball logo disappears, and the second floating ball control is displayed. Ball controls.
- the floating ball mark is used to display that the system is recognizing or judging the user's intention, and when it is judged that the user's intention is to translate the selected text, a second floating ball control is displayed.
- the floating ball mark is used to display the waiting mark for the electronic device to request the translation result from the translation server.
- the first preset time is a short time in units of seconds, and the specific time is not limited in this application.
- the floating ball mark is used to judge that the sixth operation satisfies a translation condition, and the translation condition includes the language type of the third text, the content of the third text, or the Any one or more of the types of applications.
- judging whether the translation conditions are met includes: judging whether the copied text contains the current non-system language of the mobile phone; judging whether the non-system language contained in the copied text is a preset language supported by the mobile phone system; judging whether the copied text Whether it conforms to a certain text type; determine whether the source application of the copied text meets a certain application type. In this way, by setting translation conditions, unnecessary pop-ups or reminders of translation floating balls or floating windows are reduced, thereby reducing interruptions to users and improving user experience.
- the second floating ball control is the same as the first floating ball control displayed on the first interface of the application program on the first interface of the electronic device.
- One side, the positions displayed on the same side of the two are the same or different.
- the first floating ball control and the second floating ball control are slidable, and can be displayed in different areas of the first interface of the electronic device by user's operation.
- the two are arranged on the same side of the electronic device, such as the right side of the first interface of the electronic device, and their positional relationship may include an up-down relationship.
- the first floating ball control is displayed on the upper right side of the first interface
- the second floating ball control is displayed on the upper right side of the first interface. Controls are displayed on the lower right side of the first interface.
- the first floating ball control and the second floating ball control are displayed at the same position. In this way, it conforms to the common user habit of the user and improves the user experience.
- it also includes: judging that any one of the user's touch operation, click operation, slide operation or long press operation on the second floating ball control is not detected within the second preset time , cancel the display of the second floating ball control, and display the first floating ball control.
- the second preset time is a shorter time in units of seconds, and the specific time is not limited in this application.
- the state display of the floating ball is changed from the second floating ball control to the first floating ball control, and displayed on one side of the first interface , when the user has a translation intention again, the translation operation can be performed again by operating the first floating ball control, which is convenient and quick, and improves the user experience.
- a floating window is displayed on the first interface, where the floating window includes the third text and the For the third translation corresponding to the third text, the eighth operation includes any one of a touch operation, a click operation, or a long press operation.
- the state display of the floating ball is changed from the second floating ball control to the first floating ball control, and displayed on one side of the first interface , when the user has a translation intention again, the translation operation can be performed again by operating the first floating ball control, which is convenient and quick, and improves the user experience.
- the first interface further includes fourth text, and if the first interface displays the first floating ball control, in response to the user's ninth operation on the fourth text, the The first interface displays the second control, and in response to the user's tenth operation on the second control, the first interface continues to display the first floating ball control, wherein the ninth operation includes Any one of the selection operation, touch operation, click operation, slide operation, long press operation or double-click operation of the fourth text, and the tenth operation includes the copy operation of the copy option of the second control or In any one of the cutting operations of the cutting option, the fourth text is the same as or different from the third text, and the fourth text does not include a URL, an email address, or a password generated by a machine, and the The fourth text is different from the system language of the electronic device.
- the first floating ball control that is, the user's copy operation on the fourth text is judged by the system as a normal copy text operation.
- the user can understand when translation is required and when the normal operation of copying text is displayed, and when the user needs translation, the user can immediately operate the first floating ball control, thereby Display a floating window to display the content of the translation result.
- the interference to the user is reduced, and it is convenient for the user to quickly obtain the content of the translation result, which improves the user experience.
- a floating window is displayed on the first interface, where the floating window includes the fourth text and the The fourth translation corresponding to the fourth text, the eleventh operation includes any one of a touch operation, a click operation, or a long press operation on the first floating ball control.
- the user when the user has a need for translation, the user can immediately operate the first floating ball control, so as to display the floating window and display the content of the translation result.
- the interference to the user is reduced, and it is convenient for the user to quickly obtain the content of the translation result, which improves the user experience.
- the floating window is a system window, and the system window is different from the application window of the application program.
- the floating ball and the floating window involved in the embodiments of the present application are system windows, they cannot be set in the application window, they do not belong to any application, they are created by the system, and only belong to the system itself.
- the floating window is a non-modal dialog box, and when the floating window is displayed on the first interface, any one of the first interface or the floating window can be sliding.
- An exemplary non-modal dialog box has the advantage of not grabbing the focus of the window.
- the floating window can be returned to the bottom state by touching or clicking the area outside the floating window, thereby continuing to browse The content of the current application to improve the user experience.
- the window attribute of the floating window is set to include FLAG_NOT_TOUCH_MODAL, and the floating window does not seize the window focus with the first interface of the application program, including: when the first interface When displaying the floating window, if the first interface is slid, the floating window does not disappear, and in response to the floating window being slid, the first interface does not disappear; if the floating window is slid, the The first interface does not disappear, and in response to the first interface being slid, the floating window does not disappear.
- the window attribute of the floating window is set to FLAG_NOT_TOUCH_MODAL, so in this mode, the system will pass the touch/click event outside the current window area to the underlying window, and the click event within the current window area will be processed by the current window .
- the window is passed to the current reading application, and then the user can continue to browse the page of the current reading application.
- the floating window continues to process the user's touch or click event.
- the first interface displays the first floating ball control.
- the closing of the floating window is used to close the floating window.
- the floating window is closed, and it is still displayed on one side of the first interface of the electronic device in the form of a first floating ball control.
- the user needs translation again, he can immediately operate the first floating ball control, thereby displaying the floating window and displaying the content of the translation result.
- the interference to the user is reduced, and it is convenient for the user to quickly obtain the content of the translation result, which improves the user experience.
- the embodiment of the present application provides an electronic device, the electronic device includes a memory for storing computer program instructions and a processor for executing the program instructions, wherein when the computer program instructions are executed by the processor, trigger The electronic device performs the method of any one of the first aspect.
- the second aspect and any implementation manner of the second aspect correspond to the first aspect and any implementation manner of the first aspect respectively.
- technical effects corresponding to the second aspect and any implementation manner of the second aspect reference may be made to the technical effects corresponding to the above-mentioned first aspect and any implementation manner of the first aspect, and details are not repeated here.
- an embodiment of the present application provides a computer-readable storage medium, in which a computer program is stored, and when running on a computer, the computer executes the method of any one of the first aspect.
- the third aspect and any implementation manner of the third aspect correspond to the first aspect and any implementation manner of the first aspect respectively.
- the technical effects corresponding to the third aspect and any one of the implementation manners of the third aspect refer to the above-mentioned first aspect and the technical effects corresponding to any one of the implementation manners of the first aspect, which will not be repeated here.
- an embodiment of the present application provides a computer program product, the computer program product includes a computer program, and when running on a computer, causes the computer to execute the method of any one of the first aspect.
- the fourth aspect and any implementation manner of the fourth aspect correspond to the first aspect and any implementation manner of the first aspect respectively.
- the technical effects corresponding to the fourth aspect and any one of the implementation manners of the fourth aspect refer to the above-mentioned first aspect and the technical effects corresponding to any one of the implementation manners of the first aspect, and details are not repeated here.
- all or part of the program in the fifth aspect may be stored on a storage medium packaged with the processor, or part or all may be stored on a memory not packaged with the processor.
- FIG. 1 is a schematic diagram of an electronic device provided in an embodiment of the present application.
- FIG. 2A is a software structural block diagram of an electronic device provided by an embodiment of the present application.
- Fig. 2B is a software structural block diagram of the window manager of the electronic device provided by the embodiment of the present application.
- FIG. 3 is a schematic diagram of triggering a translation interface provided by an embodiment of the present application.
- Fig. 4A is a schematic diagram of a floating ball on the translation interface provided by the embodiment of the present application.
- Fig. 4B is a schematic diagram of a floating ball on the translation interface provided by the embodiment of the present application.
- Fig. 5A is a schematic diagram of a state change of a floating window provided by an embodiment of the present application.
- FIG. 5B is a schematic diagram of a state change of a floating window provided by an embodiment of the present application.
- FIG. 6 is a schematic diagram of a state change of a floating window provided by an embodiment of the present application.
- FIG. 7 is a schematic diagram of a state change of a floating window provided by an embodiment of the present application.
- FIG. 8 is a schematic diagram of a state change of a floating window provided by an embodiment of the present application.
- FIG. 9 is a schematic diagram of a state change of a floating window provided by an embodiment of the present application.
- FIG. 10A is a schematic diagram of state changes of a floating window in a continuous copying scenario provided by an embodiment of the present application.
- FIG. 10B is a schematic diagram of state changes of a floating window in a continuous copying scenario provided by an embodiment of the present application.
- Fig. 11 is a schematic diagram of state changes of a non-modal floating window provided by the embodiment of the present application.
- Fig. 12 is a schematic diagram of changes in content preloading of a floating window provided by the embodiment of the present application.
- Fig. 13 is a schematic diagram of the internal sliding of a floating window provided by the embodiment of the present application.
- Fig. 14 is a schematic diagram of state changes of a floating window in a flipped state provided by an embodiment of the present application.
- Fig. 15 is a schematic diagram of state changes of a non-modal floating window in a flipped state provided by an embodiment of the present application;
- Fig. 16 is a logic implementation flowchart provided by the embodiment of the present application.
- FIG. 17 is a logic implementation timing diagram provided by the embodiment of the present application.
- Fig. 18 is a schematic diagram of triggering another translation interface provided by the embodiment of the present application.
- FIG. 19 is a schematic diagram of triggering another translation interface provided by the embodiment of the present application.
- the chat content can be translated, click or long press the text, and select the "Translate” button to display the chat content in real time Translation results.
- the translation result will be presented near the chat content.
- the current application itself does not support the translation function in the application, such as the reading application
- the user needs to copy or memorize the text to be translated, such as an English word
- switch out of the current application open the translation application, paste the English word or manually Input it into the input box, click the translate button, and the translation result will be displayed, thus completing the translation operation.
- the steps of the above-mentioned operation method are cumbersome, resulting in low translation efficiency and affecting user experience.
- an improvement method is to realize text translation by reading words from the screen through a reading application or a browser plug-in or a plug-in provided by a translation software, that is, by opening the reading application or a browser plug-in or a plug-in provided by a translation software in the background.
- a reading application or a browser plug-in or a plug-in provided by a translation software that is, by opening the reading application or a browser plug-in or a plug-in provided by a translation software in the background.
- instant translation results are realized without opening the translation web page or translation software.
- the above method still requires the user to install an additional plug-in to realize it, which increases the threshold for the user to use.
- electronic devices such as mobile phones, it is difficult to implement due to the limitation of the underlying control logic of the mobile phone system.
- Another improvement method is to actively monitor the clipboard content of the system through the translation application, so that when the user switches from the current reading application to the translation application, the translation application can automatically obtain the content of the clipboard and display the translation result of the content , eliminating the hassle of manual input.
- the above operation method still requires the user to leave the current application and switch to the translation application to obtain the translation result, which makes the operation method more cumbersome and reduces the translation efficiency.
- the above methods are all translations at the application level, that is to say , the former is a translation plug-in integrated in an application, and the latter is a complete and independent translation application, which does not involve the use of the underlying functions of the mobile phone system to achieve translation, such as translation based on the mobile phone system level polished by the Android system.
- the embodiments of the present application provide a translation method and an electronic device to improve user experience by improving the bottom layer of the mobile phone system.
- the electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (universal serial bus, USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, and an antenna 2 , mobile communication module 150, wireless communication module 160, audio module 170, speaker 170A, receiver 170B, microphone 170C, earphone jack 170D, sensor module 180, button 190, motor 191, indicator 192, camera 193, display screen 194, and A subscriber identification module (subscriber identification module, SIM) card interface 195 and the like.
- SIM subscriber identification module
- the sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a touch sensor 180K, and an ambient light sensor 180L.
- the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the electronic device 100 .
- the electronic device 100 may include more or fewer components than shown in the figure, or combine certain components, or separate certain components, or arrange different components.
- the illustrated components can be realized in hardware, software or a combination of software and hardware.
- the processor 110 may include one or more processing units, for example: the processor 110 may include an application processor (application processor, AP), a modem processor, a graphics processing unit (graphics processing unit, GPU), an image signal processor (image signal processor, ISP), controller, memory, video codec, digital signal processor (digital signal processor, DSP), baseband processor, and/or neural network processor (neural-network processing unit, NPU) wait. Wherein, different processing units may be independent devices, or may be integrated in one or more processors. For example, the processor 110 is configured to execute the method for detecting ambient light in the embodiment of the present application.
- the controller may be the nerve center and command center of the electronic device 100 .
- the controller can generate an operation control signal according to the instruction opcode and timing signal, and complete the control of fetching and executing the instruction.
- a memory may also be provided in the processor 110 for storing instructions and data.
- the memory in processor 110 is a cache memory.
- the memory may hold 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 be directly called from the memory. Repeated access is avoided, and the waiting time of the processor 110 is reduced, thereby improving the efficiency of the system.
- the electronic device 100 realizes the display function through the GPU, the display screen 194 , and the application processor.
- the GPU is a microprocessor for image processing, and is connected to the display screen 194 and the application processor. GPUs are used to perform mathematical and geometric calculations for graphics rendering.
- Processor 110 may include one or more GPUs that execute program instructions to generate or change display information.
- the display screen 194 is used to display images, videos and the like.
- the display screen 194 includes a display panel.
- the display panel may use an organic light-emitting diode (OLED).
- OLED organic light-emitting diode
- the electronic device 100 may include 1 or N display screens 194 , where N is a positive integer greater than 1.
- the Android system can be divided into five layers, which are applications, application framework, Android runtime, system library, and hardware abstraction layer.
- layer, HAL not shown in the figure
- kernel layer kernel layer
- the application program layer may include a series of application program packages.
- the application layer may include applications such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, and short message (applications may be referred to as applications for short), and this embodiment of the present application does not make any limit.
- the application layer may further include a situation awareness module, a business logic processing module, a business presentation module, and the like.
- the context awareness module, the business logic processing module and the business presentation module may be independent APPs, or may be integrated into different APPs, or may be integrated into the same APP, which is not limited in this application.
- the situational awareness module operates permanently or with low power consumption, and has the ability to perceive external facts or environments.
- the situational awareness module can detect related events and obtain the status of events from other applications in the application layer or application framework layer or system layer or kernel layer through API (Application Programming Interface), such as detecting Bluetooth connection, network connection, monitoring user SMS, custom timers, etc.
- API Application Programming Interface
- the main function of the context awareness module is to monitor whether there is a copy event on the clipboard, and when it detects that there is a copy event on the clipboard, it notifies the business logic processing module of the copy event.
- the context awareness module can also be used to obtain the source application (APP) of the clipped content in the clipboard, that is, the name of the application package.
- APP source application
- the content of the clipboard recognizes that the clipped content is copied from a specific application through the context awareness module.
- the situation awareness module can also detect whether there is an operation to exit the current page, and notify the business logic processing module when an operation to exit the current page is detected.
- the business logic processing module (such as: computing engine) has business logic processing capabilities, and is used to realize the logic of displaying and disappearing of various floating balls or floating windows. For example, the business logic processing module receives the copy event triggered by the user and the clipboard content sent by the context awareness module, and judges whether the translation condition is satisfied, thereby judging whether to display the floating ball. The business logic processing module can also judge whether to display the floating window and display the translation result in the floating window according to the click event of the floating ball triggered by the user and the content of the translation result obtained from the third-party server. In addition, the business logic processing module can also be used to determine whether to display or disappear the floating ball or the floating window on the electronic device according to the disappearance event of the floating ball or the floating window triggered by the user.
- the business logic processing module can also identify copied text or text extracted by OCR technology. For example, it may be recognized that the text is at least one of types such as schedule, link to be shared, Taobao password, and URL. In another example, the language of the text can also be identified.
- the service presentation module (such as: YOYO suggestion) is used to display or disappear the floating ball or floating window on the screen of the mobile phone.
- the service presentation module receives a command to display a floating ball or a floating window sent by the business logic processing module, and notifies the window manager to display the floating ball or floating window on the electronic device.
- the service presentation module can also present the text copied by the user and the corresponding translation results in the floating window.
- the service presentation module can also notify the window manager to display or disappear the floating ball or floating window on the electronic device according to the disappearance event of the floating ball or floating window triggered by the user.
- the application framework layer may include a window manager, a content provider, a view system, a resource manager, a notification manager, etc., an activity manager, a clipboard manager, etc., and this embodiment of the present application does not any restrictions.
- the window manager is used to manage window programs.
- the window manager can obtain the size of the display screen, determine whether there is a status bar, lock the screen, capture the screen, etc.
- the clipboard manager is used to manage the clipboard.
- the clipboard is a temporary storage area for temporarily storing exchanged information.
- the activity manager is used to manage the life cycle of each application program and the navigation fallback function, and is responsible for creating the main thread of Android and maintaining the life cycle of each application program.
- the resource manager provides various resources for the application, such as localized strings, icons, pictures, layout files, video files, and so on.
- the notification manager enables the application to display notification information in the status bar, which can be used to convey notification-type messages, and can automatically disappear after a short stay without user interaction.
- the notification manager is used to notify the download completion, message reminder, etc.
- the notification manager can also be a notification that appears on the top status bar of the system in the form of a chart or scroll bar text, such as a notification of an application running in the background, or a notification that appears on the screen in the form of a dialog window.
- prompting text information in the status bar issuing a prompt sound, vibrating the electronic device, and flashing the indicator light, etc.
- the application layer and the application framework layer run in virtual machines.
- the virtual machine executes the java files of the application program layer and the application program framework layer as binary files.
- the virtual machine is used to perform functions such as object life cycle management, stack management, thread management, security and exception management, and garbage collection.
- the system library may include multiple functional modules.
- surface manager surface manager
- media library Media Libraries
- 3D graphics processing library eg: OpenGL ES
- 2D graphics engine eg: SGL
- the surface manager is used to manage the display subsystem and provides the fusion of 2D and 3D layers for multiple applications.
- the kernel layer is the layer between hardware and software.
- the kernel layer includes at least a display driver, a camera driver, an audio driver, and a sensor driver.
- the window manager includes application windows, sub-windows (not shown) and system windows.
- the application window corresponds to the application window of a certain application, such as the application window of a reading application, which is used to display the content in the reading application, or the application window of the translation application, which is used to display the content of the translation application, and is also an example of the memo application
- the application window of is used to display the contents of the Notes application.
- the interface of each application is composed of activities, and activities are composed of views, views are the existence forms of windows, and windows are the carriers of views.
- the application process is notified that any activity belongs to the application process. That is to say, for example, the reading application corresponds to one activity, and since the memo application is different from the reading application, it corresponds to another activity.
- the default window type of all activities is the base window (TYPE_BASE_APPLICATION), that is, all other types of application windows will appear on top of the base window.
- the child window is attached to the parent window, that is, it cannot exist independently, and needs to depend on an application, such as application input method window, application prompt window, etc.
- an application such as application input method window, application prompt window, etc.
- the parent window is invisible, the child window is also invisible.
- the system window is different from the application window and does not need to correspond to the Activity. Unlike child windows, there is no need to have a parent window.
- the system window does not belong to any application, it is created by the system and only belongs to the system itself, and often needs to declare permissions to create, such as shutdown dialog window, status bar window, search bar window, input method window, warning dialog box, system volume bar wait.
- the hierarchy of the system window is generally higher than that of the application window and sub-windows.
- a floating ball and a floating window are arranged in the system window. From the above analysis, it can be seen that the floating ball and the floating window are system windows and cannot be set in the application window.
- the essence of the floating window and the floating ball is to hand over a view to a window manager for management.
- the z-axis range of the application window is 1-99
- the range of the sub-window is 1001-1999
- the system window is (2000- 2999)
- the floating window and the floating ball can only be implemented within the scope of the system window. If you want to pop up a custom system-level window, you need to dynamically apply for permission.
- the Z-axis is the concept of the hierarchy of the Android window, and the window with a larger Z-axis is on the top layer.
- the floating ball and floating window set in the system window do not have the function of activity.
- the floating ball and floating window similar to the activity in the application window that is, display content and operations based on the user sliding on the floating ball and floating window
- translation is taken as an example.
- the default language set by the system in the electronic device (take “mobile phone” as an example) is Simplified Chinese.
- an option switch such as "copy trigger translation” is set in the setting interface of the mobile phone.
- the translation function in the application implementation mode displays the translation results.
- the translation result may be the translated original text (such as copied text) and/or the translated translation.
- the mobile phone can directly present translation results according to the identified intention to perform translation, so as to quickly satisfy the user's intention to perform translation.
- the mobile phone will judge the possible intention of the user according to the user's operation of copying text, such as adding a schedule, adding a memo, One or more of the intentions of sharing to the application, adding to favorites, adding to the dictionary, and opening map navigation.
- the types of possible user intentions judged by the mobile phone after the user copies the text are not limited.
- the user opens a reading page in the reading application, and a paragraph of English is displayed.
- the user selects the word "patent”, and the system pops up an option bar 301, which at least includes an operation option such as "copy”.
- the mobile phone monitors the content change in the clipboard, it will trigger the recognition of the user's intention to copy the text. It should be understood that after the user performs a copy operation on the text, the copied text will be stored in the clipboard, so that the content in the clipboard will change. Therefore, after the content in the clipboard changes, that is, after the user enters the copy operation.
- the mobile phone After the user clicks the "Copy" option, the mobile phone attempts to identify the user's intention after copying the text, so a floating ball logo 302 as shown in (b) in Figure 3 pops up to indicate that the mobile phone is identifying the user's intention. For example, the mobile phone can recognize the intent based on the text content of the copied text, user portraits and other data. In the identification process, the user's intention can be identified without the user's operation, that is, without the user clicking any content on the page in (b) in FIG. 3 .
- the system When the system recognizes that the user's intention is to need to translate the word "patent", it displays a floating ball 303 in the first state as shown in (c) in Figure 3, and the floating ball 303 in the first state is used to provide the user with a An entry to display translation results.
- a floating window 304 is displayed in (d) of FIG. 3 and a translation result of "patent” is displayed in the floating window 304 .
- the translation results displayed in the floating window 304 include the English word "patent” copied by the user and the translation result of the Chinese definition of the word, namely "patent".
- the interface displayed in the floating window 304 also includes voice reading, copying the text of the translation result, switching translation languages, and the like.
- the initial state displayed by the floating window 304 that is, the default form displayed after the user clicks on the floating ball 303, is a half-screen state, occupying about half of the screen of the mobile phone.
- the floating ball 303 is canceled to achieve better user experience.
- the floating ball 303 and the floating window 304 are two different types of windows on the Android mobile terminal. Suspension is relative. For example, upper-level elements can be called “suspension" elements. For example, the content area of the navigation bar and tab bar relative to the lower level is suspension.
- the floating ball 303 is set as an entry linking to the floating window 304 to guide the user to click the floating ball 303 to display the translation result in the floating window 304 in the scene where the translation result needs to be displayed.
- the floating window 304 is set as a content presentation window for displaying translation results.
- floating ball and the floating window involved in the embodiments of the present application are system windows and cannot be set in the application window.
- Android has strict controls on floating balls and floating windows, popping up custom system-level windows requires dynamic application for permissions.
- the mobile phone when the default language set by the system in the mobile phone is Simplified Chinese, the mobile phone recognizes that the language copied by the user is not the current system language of the mobile phone (that is, the default language set by the mobile phone), then the user's intention can be recognized including performing translation. For example, when the language of the text copied by the user is a language other than simplified Chinese such as English, Japanese, French, etc., the mobile phone will recognize the user's translation intention, thereby displaying the floating ball logo 302 and the floating ball 303 . Generally speaking, the default language set on the mobile phone is the language the user is familiar with, and there is no need to translate it.
- whether the text copied by the mobile phone triggers the execution of translation is related to the default language set by the system and the language of the copied text. If the mobile phone recognizes that the language of the text copied by the user is not the current system language of the mobile phone (ie the default language set by the mobile phone), it can recognize the user's intention including performing translation. Specifically, for example, when the default language set by the system in the mobile phone is Simplified Chinese, the following combinations may be included:
- the first combination the copied text includes both system language and non-system language text.
- the copied text includes both Chinese and French
- the mobile phone since the mobile phone recognizes that the copied text includes non-Chinese French text, after the user copies the text, the translation operation will still be triggered, that is, a pop-up will be displayed as shown in Figure 3
- the floating ball logo 302 shown in (b) automatically displays the floating ball 303 in the first state as shown in (c) in FIG. 3 after a period of time.
- the second combination the copied text is the non-system language text set by the application itself.
- the application language set by the current application is English
- the user copies the English text in the application since the mobile phone recognizes that the copied text includes non-Chinese text, the translation operation will still be triggered after the user copies the text.
- the floating ball logo 302 as shown in (b) in FIG. 3 pops up and automatically displays the floating ball 303 in the first state as in (c) in FIG.
- the copied text is the non-system language text entered by the user.
- the user selects and copies a piece of English text entered by the user. Since the mobile phone recognizes that the copied text includes non-Chinese text, after the user copies the text, it will still be displayed. Trigger the translation operation, that is, display and pop up the floating ball logo 302 as shown in (b) in FIG. 3 and automatically display the floating ball 303 in the first state as in (c) in FIG. 3 after a period of time.
- the mobile phone also needs to recognize that the language of the copied text is a preset language, where the preset language refers to a language supported by the mobile phone system or translation application on the mobile phone, so that the user's intention can be recognized Includes performing translations. If the mobile phone does not support the translation of the language of the copied text at all, the translation result cannot be obtained. In this case, it will be recognized that there is no intention to perform translation.
- the mobile phone also needs to recognize that the copied text needs to satisfy a certain text type.
- a certain text type exemplary, that is, it is not a URL link, an email address, or a character string with a specific meaning such as a machine-generated password (such as a Taobao password), so that the user's intention including translation can be identified.
- a machine-generated password such as a Taobao password
- These above-mentioned character strings with specific meanings are usually just identifiers, for example, used to distinguish different web pages, different mailboxes, different Taobao products, etc., and do not have linguistic meaning. Therefore, there is no need for translation.
- the mobile phone also needs to identify that the source application of the currently copied text needs to meet a certain application type.
- the application is not a separate professional translation application such as a translation application, or a shopping and entertainment application such as Taobao and Douyin, that the user's intention can be recognized including performing translation.
- the mobile phone determines that the user does not need translation at this time, so after the user copies the text, the floating ball logo 302 and the floating ball 303 will not be displayed.
- the mobile phone determines that the user does not need translation at this time, so after the user copies the text, the floating ball logo 302 and Suspended ball 303.
- the mobile phone uses to identify the user's operation intention.
- the mobile phone can determine the translation intention of the user after copying the text according to the current application type, the type of text copied by the user, and the context displayed by the current application.
- mobile phones can use Natural Language Processing (NLP) to comprehensively analyze and predict users' behavior habits and APP usage.
- NLP Natural Language Processing
- the copy operation is mainly used as an example to trigger the identification intention of the mobile phone.
- the recognition intention of the mobile phone may also be triggered by operations such as selecting text, long-pressing, crossing out, and double-clicking.
- the floating ball 401 will present the second state, that is, the floating ball 402 in the second state in (b) of FIG. 4A , to improve user experience.
- the preset time is a short time in seconds, and the specific time is not limited in this application.
- the user's copying behavior will be determined as a normal text copying behavior, and the floating ball 401 in the first state as shown in (a) in FIG. 4A will not be displayed. That is to say, at this time, the user's copying behavior will not trigger the translation operation. For example, if the user selects a word in (c) in Figure 4A, such as "law”, and clicks "Copy", since the mobile phone judges that the user does not need to perform translation operations at this time, the mobile phone will not display ( The floating ball 401 in the first state in a) continues to display the floating ball 402 in the second state, ie (d) in FIG. 4A . That is to say, although in FIG.
- the user has copied the word "law", at this time, due to the state of the hovering ball in the second state, it is judged that the user does not need to perform a translation operation, therefore, when the user triggers the word "law" to be copied When operating, the translation result is not requested, and the mobile phone performs the copy operation of the Android system itself.
- the floating ball in the first state is set to provide the user with an entry to display the translation result.
- a floating window with translation results is displayed.
- the floating ball in the first state disappears or remains displayed, which is not limited in this application.
- the floating ball in the second state is set to display the floating ball in the second state after the user does not trigger any click or touch operation on the floating ball in the first state within a preset time. At this time, it is determined that the user does not need to perform the translation operation. Therefore, when the user triggers the copy operation, the user's copy behavior will be determined as a normal text copy behavior, and the floating ball in the second state will continue to be displayed.
- the first floating ball control corresponds to the floating ball in the second state
- the second floating ball control corresponds to the floating ball in the first state
- the user in (a) in FIG. 4B did not trigger any click or touch operation on the hovering ball 401 in the first state within the preset time, and the hovering in the second state in (b) in FIG. 4B is displayed.
- Ball 402. If the user needs to perform a translation operation while the floating ball in the second state is displayed, as shown in (c) in FIG. 4B , the user needs to trigger the operation of clicking or touching the floating ball 402 in the second state.
- the floating window in the embodiment of the present application is divided into three forms according to different heights occupied by the screen, that is, a bottom state, a half-screen state and a full-screen state.
- the floating window in the bottom state is located at the bottom of the screen of the current application and does not display any translation result content, which is beneficial for users to continue to access the content in the current application to improve user experience.
- the half-screen floating window occupies about half of the screen of the current application and displays part of the translation results.
- the half-screen floating window can also be used as a default floating window as an example, that is, the floating window in the first form displayed after the user copies text.
- the full-screen floating window can exemplarily occupy the entire current application screen, and its expansion is based on the user's drag operation to display more translation result content than the half-screen floating window, so as to improve user experience.
- FIG. 5A to FIG. 9 it is used to exemplarily show the sliding effect of the floating window in the embodiment of the present application and the logic of the transformation of the floating window among the three different forms.
- the following exemplary expansion describes the implementation of the present application.
- the shape transformation of the floating window is related to the user's sliding speed and sliding distance.
- the floating ball and the floating window are realized by the window manager, and the form control and switching of the bottom state, the half-screen state and the full-screen state of the floating window are controlled by the property parameter y in the window manager, which controls the height of the floating window in different forms.
- the floating ball and the floating window in the embodiments of the present application do not seize the focus of the current application.
- the focus event is on the original text of the current reading application.
- the floating ball logo 302 is displayed and after a period of time, the floating ball 303 in the first state as shown in (c) in FIG. 3 is automatically displayed. At this time, the focus event is still on the original text of the current application, and the floating ball does not seize the focus.
- the floating window 304 is displayed in (d) in FIG.
- the focus window refers to the window currently interacting with the user, which is responsible for receiving key events and touch events.
- the update of the focused window will be involved.
- the window attributes of the floating ball and the floating window are processed in the embodiment of the present application. Specifically, when the floating window is in half-screen or full-screen state, set the window property of the floating window to FLAG_NOT_TOUCH_MODAL to control focus event processing; when the floating window is in the bottom state, set the window property of the floating window to FLAG_NOT_FOCUSABLE The focus event is handed over to the original text of the current application for processing.
- the current application is the reading application currently used by the current user in the implementation manner of this application.
- FLAG_NOT_FOCUSABLE Indicates that the current window does not need to acquire focus, nor does it need to receive various input events. This flag will enable FLAG_NOT_TOUCH_MODAL at the same time, and the final event will be directly passed to the lower window with specific focus.
- FLAG_NOT_TOUCH_MODAL Indicates that in this mode, the system will pass touch/click events outside the current window area to the underlying window, and click events within the current window area will be processed by the current window. This flag is very important. Generally speaking, this flag needs to be turned on, otherwise other windows will not be able to receive touch/click events.
- the activity of the application window is encapsulated by Android itself, and the corresponding activity can be called directly when using it.
- the floating ball and the floating window involved in the implementation of the present application are system windows, no corresponding activity is provided in the Android framework to manage and call them. Therefore, in order to achieve an effect similar to the activity in the application window on the system window, An additional set of sliding logic implementations needs to be designed, including:
- the sliding effect in the embodiment of the present application has different response events according to the user's sliding speed on the screen.
- the specific implementation logic is disclosed in the description of FIG. 5A and FIG. 5B below, and will not be repeated here.
- the embodiments of the present application provide the realization of anti-mistouch.
- the user's finger touches the screen the user's finger shakes when touching the screen, so it is necessary to distinguish whether the user's operation is a sliding event or a touch or click event.
- the activity of the application window itself has the function of preventing false touches.
- the floating ball and the floating window involved in the implementation of the present application are system windows, no corresponding function is provided in the framework of Android. Therefore, , in order to achieve an anti-mistouch effect similar to the activity in the application window in the system window, it is necessary to design an additional set of sliding logic implementation, which includes: setting a movement threshold, when the user's finger touches the floating window, it is judged whether to trigger the move event.
- FIG. 5A presents a floating window 501 in a half-screen state.
- the dividing line 502 is the middle dividing line of the area outside the floating window 501 in the mobile phone screen, that is, the dividing line 502 is the dividing line between the half-screen state height and the full-screen state height of the floating window.
- the floating window presents a full-screen floating window 503 as shown in (c) of FIG. 5A .
- the dividing line 502 may be the dividing line between the height of the half-screen state and the height of the full-screen state, or the dividing line between the height of the half-screen state and the height of the bottom state. It selects different dividing lines according to the current height of the floating window and the direction in which the user drags the floating window.
- the state of the floating window is not only related to whether the user drags the floating window beyond the middle line between the two states, but also related to the speed at which the user drags the floating window.
- the floating window 501 presents a full-screen state as shown in (c) in FIG. Sliding up quickly does not need to exceed the dividing line 502, and only needs to meet the fast sliding condition to present the full-screen state in (c) in Figure 5A; optionally, when the user drags the floating window 501 to slide upwards, simultaneously The full-screen state shown in (c) in FIG. 5A can only be presented if the fast sliding is satisfied and the dividing line is exceeded.
- FIG. 5B when the user drags the floating window 501 in (a) of 5B to slide upward slowly, if the user drags the floating window 501 upward beyond the dividing line 502 at this time, the floating window A full screen state as in (c) in FIG. 5A is presented. If the user does not drag the floating window 501 upward beyond the dividing line 502 at this time, that is, the state in (b) in Figure 5B, the floating window maintains or rebounds to half the screen in (c) in Figure 5B state.
- the implementation of the continuous transformation of the floating window switching from the full-screen state to the half-screen state and then switching to the bottom state is described in detail.
- the transition of the state of the floating window is related to the speed at which the user drags the floating window and whether the user drags it beyond the dividing line.
- FIG. 6 presents a floating window 601 in a full-screen state.
- the dividing line 602 is a dividing line between the half-screen state height and the full-screen state height of the floating window.
- the floating window presents a half-screen floating window 603 as shown in (c) of FIG. 6 .
- the dividing line 604 is a dividing line between the height of the half-screen state and the height of the bottom state of the floating window.
- the state of the floating window is not only related to whether the user drags the floating window beyond the middle line between the two states, but also related to the speed at which the user drags the floating window. Its implementation is as in the above-mentioned implementation process of FIG. 5A and FIG. 5B , which will not be repeated here.
- FIG. 7 presents a floating window 701 in a full-screen state.
- the dividing line 702 is a dividing line between the half-screen state height and the full-screen state height of the floating window.
- the dividing line 704 is a dividing line between the height of the half-screen state and the height of the bottom state of the floating window.
- the state of the floating window is not only related to whether the user drags the floating window beyond the middle line between the two states, but also related to the speed at which the user drags the floating window. Its implementation is as in the above-mentioned implementation process of FIG. 5A and FIG. 5B , which will not be repeated here.
- the implementation of the continuous transformation of the floating window switching from the bottom state to the half-screen state and then to the full-screen state is described in detail.
- the transition of the state of the floating window is related to the speed at which the user drags the floating window and whether the user drags it beyond the dividing line.
- FIG. 8 presents the floating window 801 in the bottom state.
- the dividing line 802 is a dividing line between the height of the half-screen state and the height of the bottom state of the floating window.
- the floating window presents a half-screen floating window 803 as shown in (c) of FIG. 8 .
- the user can continue to drag the half-screen floating window 803 upwards to present floating windows in different states.
- the dividing line 804 is a dividing line between the half-screen state height and the full-screen state height of the floating window.
- the state of the floating window is not only related to whether the user drags the floating window beyond the middle line between the two states, but also related to the speed at which the user drags the floating window. Its realization is as the above-mentioned realization process of Fig. 5A and Fig. 5B, so it will not be repeated here.
- FIG. 9 the implementation of the transformation of the floating window directly switched from the bottom state to the full screen state is described in detail. Its implementation does not need to go through the process from the bottom state to the half screen state, and then from the half screen state to the full screen state, but directly switches from the bottom state to the full screen state according to the user's operation.
- the transition of the state of the floating window is related to the speed at which the user drags the floating window and whether the user drags it beyond the dividing line.
- (a) in FIG. 9 presents the floating window 901 in the bottom state.
- the dividing line 902 is a dividing line between the height of the half-screen state and the height of the bottom state of the floating window.
- the dividing line 904 is the dividing line between the half-screen state height and the full-screen state height of the floating window.
- the state of the floating window is not only related to whether the user drags the floating window beyond the middle line between the two states, but also related to the speed at which the user drags the floating window. Its implementation is as in the above-mentioned implementation process of FIG. 5A and FIG. 5B , which will not be repeated here.
- the floating window 1001 in (a) in FIG. 10A presents a half-screen state.
- the area 1002 outside the floating window is the area of the mobile phone screen except for the floating window 1001 .
- the floating window in the embodiment of the present application does not seize the focus of the current application, the user can still slide the original text of the current application. Therefore, when the area outside the floating window 1002 detects the user's touch or click operation, it is determined that the user has When the intention is to browse the original text of the current application instead of translation, the floating window displays the bottom state in (c) in Figure 10A, so that the user can browse the original text of the current application.
- an option bar 1004 pops up, and the option bar 1004 includes at least an operation option such as "copy”.
- the mobile phone monitors the content change in the clipboard, it will trigger the recognition of the user's intention to copy the text. It should be understood that after the user performs a copy operation on the text, the copied text will be stored in the clipboard, so that the content in the clipboard will change. Therefore, after the content in the clipboard changes, that is, after the user enters the copy operation.
- a half-screen floating window 1005 as shown in (e) in Figure 10A pops up, displaying the translation result of "development".
- the translation results displayed in the floating window 1005 include the translation results of the English word "development” copied by the user and the Chinese definition of the word, namely "development”.
- the floating window 1005 also displays other additional content, the content of which is displayed in the floating window 304 as shown in (d) in FIG. 3 , which will not be repeated here.
- the initial state displayed by the floating window 1005 is a half-screen state, occupying about half of the screen of the mobile phone.
- the floating ball may be displayed at the same time, or may not be displayed, so as to achieve a better user experience.
- the floating window 1001 that does not seize the focus in (b) in FIG. 10A is also called a non-modal dialog box.
- the floating window can be returned to the bottom state, so as to continue browsing the content of the current application and improve the user experience. That is to say, if the focus of the floating window 1001 in (b) in FIG. 10A has not been processed as in the embodiment of the present application, that is, if the floating window is a modal dialog box, the floating window 1001 will seize the focus of the current reading application. Focus, the user must close the floating window before continuing to browse and read the original text of the application.
- step 4 every time the user completes a translation, the user needs to close the translation result (step 1 operation), select the new text again (step 2 operation) and copy it (step 3 operation), and then click the shortcut entry of the translation function again ( Step 4) to complete the next translation, that is, at least 4 steps to complete the next translation.
- step 4 click the shortcut entry of the translation function again ( Step 4) to complete the next translation, that is, at least 4 steps to complete the next translation.
- a modal dialog box means that when it is displayed, the program will suspend execution until the modal dialog box is closed before continuing to perform other tasks in the program, such as clicking the OK, Cancel, Close button, etc. to close the dialog box.
- the window attribute of the floating window is set to
- the floating window 1001 when the floating window 1001 is in the half-screen state (a) shown in FIG. 10B , the user can still continue to trigger the copy translation operation.
- the floating window 1003 presents a bottom state.
- the floating window 1001 In the continuous copying scenario in FIG. 10B , the floating window 1001 is always in a half-screen state.
- an option bar 1006 pops up, and the option bar 1006 includes at least an operation option such as "copy”. 1001 maintains a half-screen state.
- the mobile phone monitors the content change in the clipboard, it will trigger the recognition of the user's intention to copy the text. It should be understood that after the user performs a copy operation on the text, the copied text will be stored in the clipboard, so that the content in the clipboard will change. Therefore, after the content in the clipboard changes, that is, after the user enters the copy operation.
- the mobile phone After the user clicks the "Copy” option, the mobile phone attempts to recognize the user's intention after copying the text, and thus displays a half-screen floating window 1007 as shown in (c) in Figure 10B, displaying the translation result of "development".
- the content of the translation result displayed in the floating window 1007 is consistent with that of the half-screen floating window 1005 shown in (e) in FIG. 10A , and will not be repeated here.
- the mobile phone can directly trigger another translation in response to the user's operation of continuously copying the same or different texts.
- the floating window is in the bottom state as shown in (d) in FIG. 10A, it will be displayed in a half-screen state as shown in (e) in FIG. 10A to display the translation result of the new text.
- the floating window is in the half-screen state as shown in (a) in FIG. 10B , the translation result of the new text is directly displayed in the half-screen state. That is to say, compared with the conventional technology, the solution of this application can directly trigger the mobile phone to translate the new text and display it after the user copies the new text as long as the floating window is not closed during multiple consecutive translations. Translation results. There is no need for the user to manually trigger the translation again after copying the new text. Thereby, the rapidity of continuous translation can be improved.
- the floating window 1101 in (a) in FIG. 11 presents a full-screen state.
- the area outside the floating window 1102 is the area of the mobile phone screen except for the floating window 1101 .
- the floating window in the embodiment of the present application does not seize the focus of the current application, the user can still slide the original text of the current application. Therefore, when the area outside the floating window 1102 detects the user's touch or click operation, it is determined that the user has When the intention is to browse the original text of the current application instead of translation, the floating window displays the bottom state in (b) in Figure 11, so that the user can browse the original text of the current application. Its implementation is shown in (b) in FIG. 10A , which will not be repeated here.
- the window property FLAG_LAYOUT_NO_LIMIT is set to achieve the effect of preloading the content of the translation result.
- NO_LIMIT means that the content can be drawn outside the screen, and the content will be displayed directly when the floating window is dragged.
- the floating window 1201 displays a half-screen state as shown in (a) in Figure 12, the bottom of the floating window additionally draws a floating window bottom area 1202 outside the screen, which is used to preload the remaining translation content of the floating window 1201 in advance , the bottom area 1202 of the floating window is invisible to the user in the half-screen state of the floating window.
- the user can drag the translation result content in the floating window to obtain more and more complete translation result content.
- the content of the translation results shown in (a) in Figure 13 to (b) in Figure 13 to (c) in Figure 13 is a progressive relationship, that is, according to the user's sliding operation, more information is displayed in the floating window The content of the translated results.
- the floating ball and the floating window involved in the embodiments of the present application are system windows and do not have the function of activity, the pages in the floating window do not have the sliding function.
- the touch/click event and oninterceptTouch event of the window are intercepted by the viewglobal event.
- the view that Viewglobal is used to display to the user is a single or the entire view, which is controlled by ouinterceptTouch.
- the mobile phone receives a touch/click event, it is judged by the outtouch event that the touch/click is in the floating window or outside the floating window.
- it is necessary to rewrite the ontouch and oninterceptTouch events of the content container of the window manager to control sliding and specific event distribution.
- the sliding of the area in the floating window is the same as or different from the sliding logic implementation of the bottom state, half-screen state and full-screen state of the floating window above.
- FIG. 14 it is the display form of the floating window when the screen of the mobile phone is flipped, that is, in landscape mode.
- the floating window in the vertical screen state has three presentation modes: bottom state, half screen state and full screen state.
- the floating window has bottom state 1401 and full screen state.
- State 1403 two presentation modes.
- the dividing line 1402 is the dividing line between the bottom state height of the floating window and the full screen state height.
- FIG. 15 it is a non-modal floating window that does not seize focus in the embodiment of the present application when the screen of the mobile phone is flipped, that is, in landscape mode. Its implementation is as described above in FIG. 10A to FIG. 11 , and will not be repeated here.
- the floating window in the horizontal screen state also has a non-modal dialog box as shown in Figure 10A to Figure 11 in the vertical screen state, and it can also realize continuous copying as shown in Figure 10A to Figure 11, and it also has a dialog box as shown in Figure 12
- Figure 10A to Figure 11 in the vertical screen state
- Figure 10A to Figure 11 in the vertical screen state
- dialog box 12 The effect of sliding in the floating window and pre-loading the content of the translation result, the specific description of the above implementation is the same as the above-mentioned vertical screen state, and will not be repeated here.
- the area outside the floating window 1502 is the area of the screen of the mobile phone except the floating window.
- the horizontal screen state it is the top status bar area in the vertical screen state.
- the floating window in the embodiment of this application does not seize the focus of the current application, the user can still slide the original text of the current application. Therefore, when the area outside the floating window 1502 detects the user's touch or click operation, it is determined that the user has When the intention is to browse the original text of the current application instead of translation, the floating window is displayed from the full screen state in (a) in Figure 15 to the bottom state in (b) in Figure 15, so that the user can browse the original text of the current application.
- the maximum horizontal width of the floating window in the bottom state and full screen state should not overlap with the top status bar area in the vertical screen state, that is, the horizontal width of the floating window in the horizontal screen state can be designed as It does not occupy the entire width of the screen in landscape mode, and reserves the operation of the status bar area for users to improve user experience.
- FIG. 16 it is an implementation flowchart in the embodiment of the present application, which specifically includes:
- S1601 The user triggers a replication event.
- S1602 The electronic device determines that the translation condition is satisfied.
- S1603 The electronic device displays the floating ball.
- FIG. 17 it is a flow chart of logic implementation in the implementation mode of the present application, which specifically includes:
- the business logic processing module sends an instruction to subscribe to the replication fence to the situation awareness module.
- S1702 The situation awareness module sends an instruction to the clipboard manager to monitor the copy fence.
- the mobile phone monitors the content change in the clipboard, it will trigger to recognize the user's intention to copy the text. It should be understood that after the user performs a copy operation on the text, the copied text will be stored in the clipboard, so that the content in the clipboard will change.
- S1704 The user triggers a copy event, and the clipboard manager senses the content change in the clipboard.
- the user copies text on the opened page of the current application, and after monitoring content changes in the clipboard, it triggers recognition of the user's intention to copy the text.
- the copy operation is mainly taken as an example to trigger the identification intention of the mobile phone.
- the recognition intention of the mobile phone may also be triggered by operations such as selecting text, long-pressing, crossing out, and double-clicking.
- S1705 The situation awareness module monitors the clipboard event.
- S1706 The clipboard manager sends the content of the clipboard to the situation awareness module.
- the clipboard manager saves the last copied text by the user and sends it to the context awareness module, the content includes the copied text and the specific application from which the copied text is obtained, that is, the application source of the copied text.
- the clipboard manager itself does not have the ability to identify the application source of the copied text.
- the context awareness module obtains the text copied by the user from the clipboard manager, and obtains the application package name from the content of the clipboard.
- the context awareness module identifies the application source of the copied text from the contents of the clipboard.
- S1708 The context awareness module sends the clipboard content and the application package name to the business logic processing module.
- S1709 The business logic processing module judges whether the translation condition is satisfied according to the received clipboard content and the application package name.
- the business logic processing module judges whether the translation conditions are met, including:
- the copied text includes both system language and non-system language text.
- the copied text includes both Chinese and French
- the mobile phone recognizes that the copied text includes non-Chinese French text, the translation operation will still be triggered after the user copies the text;
- the second combination the copied text is the non-system language text set by the application itself.
- the application language set by the current application is English
- the user copies the English text in the application since the mobile phone recognizes that the copied text includes non-Chinese text, the translation operation will still be triggered after the user copies the text. ;
- the copied text is the non-system language text entered by the user.
- the user selects and copies a piece of English text entered by the user. Since the mobile phone recognizes that the copied text includes non-Chinese text, after the user copies the text, it will still be displayed. trigger the execution of the translation;
- the non-system language contained in the copied text is a default language supported by the mobile phone system. For example, if the non-system language text copied by the user, such as Russian, is not the default language supported by the mobile phone system itself, the translation conditions are not met;
- d. Determine whether the source application of the copied text satisfies a certain application type. For example, if the application is not a separate professional translation application such as a translation application, or is not a shopping and entertainment application such as Taobao and Douyin, it is judged to meet the translation requirements;
- the mobile terminal is responsible for obtaining the translation result content of the acquired text copied by the user through the translation server.
- the translation server can be a third-party professional translation service provider, or a translation server provided by the mobile terminal manufacturer. This application The implementation manner is not limited here.
- the mobile terminal can also obtain the content of the translation result from the translation application installed in the mobile terminal or the built-in translation dictionary of the mobile terminal system, so that the offline translation function can be realized without using the cloud service.
- the service presentation module is used to coordinate the window manager to present the floating ball and the floating window on the mobile phone interface.
- S1712 The service presentation module sends an instruction to display the floating ball to the window manager.
- the window manager is responsible for coordinating and constructing the display of the floating ball, which needs to cooperate with the service presentation module.
- the translation server sends the content of the translation result to the business logic processing module.
- S1715 The service presentation module displays the floating ball.
- S1716 The user triggers an event of clicking the floating ball.
- the service logic processing module when the service presentation module displays the floating ball, the service logic processing module already has translation result content corresponding to the text copied by the user. Therefore, when the user needs to display the content of the translation result, the user can touch or click the floating ball to display the translation result.
- S1717 The business logic processing module judges and displays the translation result.
- the business logic processing module determines whether to display the received translation result content according to the user's touch or click on the floating ball event. If it is judged to display the content of the translation result, it is judged to display the floating window.
- the floating window and the floating ball may be displayed at the same time, or one of them may be displayed.
- S1719 The service presentation module sends an instruction to the window manager to display the floating window.
- S1720 The window manager returns an instruction to display the floating window to the service presentation module.
- the business logic processing module sends an instruction to display the translation result to the business presentation module.
- the floating window in the embodiment of the present application is divided into three forms according to different heights occupied by the screen, namely bottom state, half-screen state and full-screen state.
- the three forms of floating windows can be switched between each other according to the user's operation.
- the floating window is a non-modal dialog box.
- the user can realize the continuous copying of the copied text, without the need for the user to close the floating window again and manually trigger the translation after copying the new text.
- the floating window in the embodiment of the present application does not seize the focus of the window.
- the user can return the floating window to the bottom state by touching or clicking the area outside the floating window, thereby continuing to browse the current application. content without closing the floating window.
- S1723 The user triggers an event of touching or clicking an area outside the floating window.
- S1724 The service presentation module sends an instruction to the window manager to display the floating window in the bottom state.
- S1725 The window manager returns an instruction to display the floating window in the bottom state to the service presentation module.
- S1726 The service presentation module displays a floating window in a bottom state.
- FIG. 18 it is another embodiment of the present application, and its implementation is consistent with the above-mentioned implementations in FIG. 1 to FIG. 17 .
- the differences include:
- the option bar 1801 includes at least an operation option such as "translate".
- the option bar 301 includes a "copy” option, which is used for the mobile phone to trigger recognition of the user's intention to copy the text after monitoring the content change in the clipboard.
- the option "translate” directly indicates the user's intention to translate the text, it can be used to directly trigger the operation of performing translation.
- the mobile phone directly displays the floating window 1802 in (b) in FIG. 18 .
- the floating window 1802 is the same as the floating window 304 shown in (d) of FIG. 3 , and shows the same translation result.
- the initial state of the floating window is a half-screen state, and it may also be a bottom state or a full-screen state.
- the mobile phone since the user selects and clicks the option "translate” in the option bar 1801, the mobile phone directly displays the floating window 1802. Therefore, in this embodiment of the present application, for example, the text in (b) in FIG. 3 will not be displayed.
- the option column 1901 includes both “copy” and “translation” options, which is different from that in (a) in FIG. 3 , the option column 301 includes For the "Copy” option, in (a) of FIG. 18 , the option column 1801 includes at least an operation option such as "Translate”.
- the user can touch or click the floating ball 1902 to trigger the execution of translation, and the corresponding translation result content is displayed in the floating window 1903 in (b) of FIG. 19 .
- the implementation of the floating ball 1902 corresponds to that of the floating ball 402 in FIG. 4A
- the implementation of the floating window 1903 is the same as that of the aforementioned FIGS. 1 to 18 ; or
- the user can touch or click the "Translate” option in the option bar 1901, and the corresponding translation result content will be displayed in the floating window 1903 in (b) of FIG. 19 .
- the implementation of triggering the execution of translation by the “translation” option is the same as that in FIG. 18
- the implementation of the floating window 1903 is the same as that in FIGS. 1 to 18 described above.
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Human Computer Interaction (AREA)
- Health & Medical Sciences (AREA)
- Artificial Intelligence (AREA)
- Audiology, Speech & Language Pathology (AREA)
- Computational Linguistics (AREA)
- General Health & Medical Sciences (AREA)
- Software Systems (AREA)
- User Interface Of Digital Computer (AREA)
Abstract
一种翻译方法及电子设备(100),在需要查阅外文文献的场景,用户选中需要翻译的单词,显示具有复制及翻译选项的选项栏(301),根据用户的不同操作,在当前应用程序的当前页面显示悬浮窗(304,404),并在悬浮窗(304,404)内呈现该单词的翻译结果,在当前应用继续浏览页面的过程中,当用户有新的单词需要查询时,选中该单词,根据用户的不同操作,便可以在当前应用程序的当前页面显示悬浮窗(304,404),并在悬浮窗(304,404)内显示该单词的翻译结果,该悬浮窗(304,404)不与当前应用的页面窗口抢占焦点,因而用户在查询完一个单词后,可以继续浏览原文,而无需将悬浮窗(304,404)关闭。该翻译方法及电子设备适用于用户需要连续翻译的场景,在用户使用应用程序的过程中,不影响用户浏览原文的体验。
Description
本申请要求于2021年09月02日提交国家知识产权局、申请号为202111028829.9、发明名称为“翻译方法及电子设备”的中国专利申请的优先权,以及于2022年01月10日提交国家知识产权局、申请号为202210023045.5、发明名称为“翻译方法及电子设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
本申请涉及计算机技术领域,具体地涉及一种翻译方法及电子设备。
翻译,尤其是机器翻译,对于经常需要查阅外文文献的用户有很大的需求。移动终端内置的翻译应用或者安装的第三方翻译应用可以满足这些用户群体随时随地翻译的需求,将需要查询的单词或这语句实时翻译成目标语言,从而为用户带来极大的便利。然而,当前市场上的翻译应用,大多需要用户在获取待翻译文本后,在当前应用与翻译应用之间来回切换以获取翻译结果,操作步骤繁琐,导致翻译效率低下,影响用户体验。
发明内容
本申请提出了一种翻译方法及电子设备。在该方法中,用户在使用应用程序阅读外文文献时,通过选中需要翻译的单词,便可以在当前应用程序的当前页面显示悬浮窗,并在悬浮窗内呈现用户选中单词的翻译结果。另外,该悬浮窗不与当前应用的页面窗口抢占焦点,因而用户在查询完一个单词后,可以继续浏览原文,而无需将悬浮窗关闭。在当前应用继续浏览页面的过程中,当用户有新的单词需要查询时,还可以通过选中需要翻译的单词,便可以在当前应用程序的当前页面显示悬浮窗,并在悬浮窗内显示新选中单词的翻译结果。尤其适用于用户需要连续翻译的场景,在用户使用应用程序的过程中,不影响用户浏览原文的体验。
第一方面,提供一种翻译方法,包括电子设备及应用程序,显示所述应用程序的第一界面,所述第一界面包括第一文本及第一悬浮球控件;响应于用户对所述第一文本的第一操作,显示第一控件,所述第一控件包括复制选项及翻译选项;响应于用户对所述复制选项的复制操作,所述第一文本被写入所述电子设备的剪切板,在所述复制操作后,响应于用户对所述第一悬浮球控件的悬浮球操作,在所述第一界面显示悬浮窗,其中,所述悬浮窗包括所述第一文本及所述第一文本对应的第一译文,所述悬浮窗显示第一状态;响应于用户对所述第一文本的第二操作,显示所述第一控件;响应于用户对所述翻译选项的翻译操作,在所述第一界面显示所述悬浮窗,所述悬浮窗显示第二状态,所述第二状态与所述第一状态相同或不同。
示例性的,应用程序的第一界面包括具有文本的页面,例如阅读应用中的阅读页面,其具有可以阅读的文字,又例如浏览器中的网页,其具有可供浏览的文字内容, 又例如聊天应用类的聊天界面,其具有用户输入的文字文本,又例如备忘录类的笔记页面,其具有用户保存的用户输入的笔记内容。
这样,用户在使用应用程序阅读外文文献时,通过选中需要翻译的单词,便可以在当前应用程序的当前页面显示悬浮窗,并在悬浮窗内呈现用户选中单词的翻译结果,从而用户无需退出当前应用并切换到第三方翻译应用以查询单词,在当前应用的当前页面便可以实现对翻译的实时查询,省去了在当前应用与翻译应用之间来回切换以获取翻译结果,提高了翻译效率。
在一种可能的实现方式中,所述复制选项还可以被替换成剪切选项。
在一种可能的实现方式中,所述第一文本不包括网址、邮箱或利用机器生成的口令,所述第一文本与所述电子设备的系统语言不同。
示例性的,机器生成的口令包括例如淘口令或抖音口令等口令,其一般用于对应于特定的商品或者视频页面,因而判断此时用户对这类文本没有翻译的需求。这样,可以尽可能减小对用户的打扰,提高用户体验。
在一种可能的实现方式中,所述应用程序不包括消费类、娱乐类或视频类应用。
示例性的,消费类应用包括淘宝或京东等应用,娱乐类应用包括抖音或游戏等应用,视频类应用包括腾讯视频或爱奇艺等应用。用户在使用上述应用的过程中,判断用户是在娱乐状态,因而判断此时用户对这类文本没有翻译的需求。这样,可以尽可能减小对用户的打扰,提高用户体验。
在一种可能的实现方式中,所述第一操作包括对所述第一文本的选中操作、触摸操作、点击操作、滑动操作、长按操作或双击操作中的任意一种,所述第二操作包括对所述第一文本的选中操作、触摸操作、点击操作、滑动操作、长按操作或双击操作中的任意一种。
示例性的,上述第一操作及第二操作的目的是为了选中文字,因而对如何选中用户需要翻译的文字有多种方式,本申请的实施方式中对此不做限定。
在一种可能的实现方式中,还包括在所述第一界面显示悬浮窗后,所述第一界面不显示所述第一悬浮球控件和/或所述第一控件。
示例性的,当悬浮窗被显示后,隐藏显示上述第一悬浮球控件及第一控件。这样,可以最大程序的减少在当前应用当前页面的功能重复的图标数量,减少对用户的打扰,同时,又能展示用户翻译操作所必须的悬浮窗,提高用户体验。
在一种可能的实现方式中,所述悬浮窗的所述第一状态包括底部态、半屏态或全屏态中的任意一种,所述悬浮窗的所述第二状态包括底部态、半屏态或全屏态中的任意一种。
示例性的,悬浮窗包括3种形态,不同状态根据占据的屏幕的高度,从低到高依次分为底部态、半屏态及全屏态。其根据用户的选择,显示不同状态的悬浮窗形态。相应的,由于悬浮窗展示的面积的不同,全屏态显示的翻译结果内容会比半屏态及底部态更多,同样的,半屏态显示的翻译结果内容会比底部态更多。这样,通过展示不同形态的悬浮窗,丰富用户对于悬浮窗的体验,提高了用户体验。
示例性的,当用户查询新的单词时,悬浮窗的状态,例如第一状态及第二状态,可以是半屏态,从而,该状态下,用户既可以在悬浮窗内获取所查询的单词的翻译结 果,也可以方便的操作当前页面的第一界面,用户的选择性更大,用户体验更好。
在一种可能的实现方式中,在显示所述悬浮窗后,所述第一界面还包括第一区域,所述第一区域为所述第一界面中除所述悬浮窗之外的区域。
示例性的,当悬浮窗显示的时候,应用程序的当前页面包括悬浮窗及当前页面中被悬浮窗占据的区域之外的剩余区域,其中,第一区域可以是当前页面中被悬浮窗占据的区域之外的剩余区域。这样,通过设置第一区域,满足用户在使用悬浮窗的过程中随时可以方便的浏览或滑动当前应用程序第一界面内容的需求。
在一种可能的实现方式中,响应于用户对所述第一区域的第三操作,所述悬浮窗显示第三状态,所述第三状态包括底部态、半屏态或全屏态中的任意一种,所述第三状态与所述第一状态相同或不同,所述第三状态与所述第二状态相同或不同。
示例性的,可以理解的是,第一区域的大小是可变的,其区域大小变化根据悬浮窗所处的形态的不同而不同。可以理解的是,当悬浮窗为底部态时,其第一区域的面积比悬浮窗为中间态时的第一区域的面积更大。可以理解的是,当悬浮窗为中间态时,其第一区域的面积比悬浮窗为全屏态时的第一区域的面积更大。这样,通过设置第一区域及其相对于悬浮窗不同形态的适应性调整的区域大小,满足用户在使用悬浮窗的过程中随时可以方便的浏览或滑动当前应用程序第一界面内容的需求。
示例性的,在第一区域被执行第三操作后,悬浮窗的第三状态可以是底部态,从而可以直观的给用户反馈当前焦点转换到了用户操作的当前应用的第一界面,而不是悬浮窗。这样,可以有效的提升用户使用悬浮窗的体验。
在一种可能的实现方式中,所述第三操作包括对所述第一区域的触摸操作、点击操作、滑动操作或长按操作中的任意一种。
在一种可能的实现方式中,所述第一界面还包括第二文本,响应于用户对所述第二文本的第四操作,显示所述第一控件,其中,所述第四操作包括对所述第二文本的选中操作、触摸操作、点击操作、滑动操作、长按操作或双击操作中的任意一种,所述第二文本与所述第一文本相同或不同,所述第二文本不包括网址、邮箱或利用机器生成的口令,所述第二文本与所述电子设备的系统语言不同。
示例性的,当用户查询一个单词的翻译结果后,用户还可以继续查询新的单词,即第二文本,从而,用户无需退出当前应用并切换到第三方翻译应用以查询单词,在当前应用的当前页面便可以实现对翻译的实时查询,省去了在当前应用与翻译应用之间来回切换以获取翻译结果,提高了翻译效率。
在一种可能的实现方式中,响应于用户对所述复制选项的复制操作,所述第二文本被写入所述电子设备的剪切板,在所述第一界面显示悬浮窗,所述悬浮窗显示第四状态,所述悬浮窗包括所述第二文本及所述第二文本对应的第二译文,所述悬浮窗不包括所述第一文本及所述第一译文,所述第四状态与所述第三状态相同或不同。
示例性的,当用户查询一个单词的翻译结果后,用户还可以继续查询新的单词,即第二文本。继而,系统将用户最新选中的单词放入剪切板中并向翻译服务器请求翻译结果,由于剪切板会保留用户最近一次复制或剪切的文本,因而当第二文本被写入剪切板时,第一文本即被覆盖了,当用户触发显示悬浮窗时,悬浮窗内显示第二文本及其对应的译文,此时,第一文本及其对应的译文便不再显示。这样,用户无需退出 当前应用并切换到第三方翻译应用以查询单词,在当前应用的当前页面便可以实现对翻译的实时查询,省去了在当前应用与翻译应用之间来回切换以获取翻译结果,提高了翻译效率。
示例性的,当用户还可以继续查询新的单词时,悬浮窗的状态可以根据用户的习惯设置为与上一次显示的悬浮窗状态相同,也可以不同,其都会对提高用户对悬浮窗使用的体验。
示例性的,当用户继续查询新的单词时,悬浮窗的状态可以是半屏态,从而,该状态下,用户既可以在悬浮窗内获取所查询的单词的翻译结果,也可以方便的操作当前页面的第一界面,用户的选择性更大,用户体验更好。
在一种可能的实现方式中,响应于用户对所述翻译选项的翻译操作,在所述第一界面显示所述悬浮窗,所述悬浮窗显示第五状态,所述悬浮窗包括所述第二文本及所述第二文本对应的第二译文,所述悬浮窗不包括所述第一文本及所述第一译文,所述第五状态与所述第三状态相同或不同。
示例性的,当用户查询一个单词的翻译结果后,用户还可以继续查询新的单词,即第二文本。此时,由于用户触发的是翻译操作,而不是复制操作,因而用户的意图非常明确的显示了用户需要翻译当前新选中的单词。继而,系统将用户最新选中的单词放入剪切板中并向翻译服务器请求翻译结果,由于剪切板会保留用户最近一次复制或剪切的文本,因而当第二文本被写入剪切板时,第一文本即被覆盖了,当用户触发显示悬浮窗时,悬浮窗内显示第二文本及其对应的译文,此时,第一文本及其对应的译文便不再显示。这样,用户无需退出当前应用并切换到第三方翻译应用以查询单词,在当前应用的当前页面便可以实现对翻译的实时查询,省去了在当前应用与翻译应用之间来回切换以获取翻译结果,提高了翻译效率。
示例性的,当用户还可以继续查询新的单词时,悬浮窗的状态可以根据用户的习惯设置为与上一次显示的悬浮窗状态相同,也可以不同,其都会对提高用户对悬浮窗使用的体验。
示例性的,当用户继续查询新的单词时,悬浮窗的状态可以是半屏态,从而,该状态下,用户既可以在悬浮窗内获取所查询的单词的翻译结果,也可以方便的操作当前页面的第一界面,用户的选择性更大,用户体验更好。
在一种可能的实现方式中,所述悬浮窗是可滑动的,所述悬浮窗包括底部态、半屏态或全屏态中的任意一种或多种,所述悬浮窗在所述底部态、所述半屏态或所述全屏态中的任意一种或多种之间滑动。
示例性的,悬浮窗可以根据用户的不同操作,展示不同的形态。这样,满足了用户对于悬浮窗展示形态的不同需求,同时用户根据不同场景,选择是否展示更多的翻译内容,丰富了用户的体验。
在一种可能的实现方式中,响应于用户对所述悬浮窗在所述第一状态的第一滑动操作,判断所述滑动操作满足滑动条件后,所述悬浮窗显示第六状态,所述第六状态与所述第一状态不同,所述第六状态包括底部态、半屏态或全屏态中的任意一种;判断所述滑动操作不满足滑动条件后,所述悬浮窗显示第七状态,所述第七状态与所述第一状态相同,所述第七状态包括底部态、半屏态或全屏态中的任意一种。
示例性的,悬浮窗的滑动具有其判断条件,也就是说,例如在悬浮窗的半屏状态下,并不是用户所有的将悬浮窗向上滑动的操作都会将悬浮窗展示为全屏态,即在满足滑动条件下,将悬浮窗由半屏态展示为全屏态,在不满足条件的情况下,悬浮窗维持展示半屏态。这样,通过设置滑动条件,防止用户误触造成的悬浮窗的随意移动,提高了用户体验。
示例性的,第一状态的悬浮窗为用户在对第一文本执行复制操作后显示的悬浮窗展示的状态。
在一种可能的实现方式中,响应于用户对所述悬浮窗在所述第二状态的第二滑动操作,判断所述滑动操作满足滑动条件后,所述悬浮窗显示第八状态,所述第八状态与所述第二状态不同;判断所述滑动操作不满足滑动条件后,所述悬浮窗显示第九状态,所述第九状态与所述第二状态相同,所述第八状态包括底部态、半屏态或全屏态中的任意一种,所述第九状态包括底部态、半屏态或全屏态中的任意一种。
示例性的,悬浮窗的滑动具有其判断条件,也就是说,例如在悬浮窗的半屏状态下,并不是用户所有的将悬浮窗向上滑动的操作都会将悬浮窗展示为全屏态,即在满足滑动条件下,将悬浮窗由半屏态展示为全屏态,在不满足条件的情况下,悬浮窗维持展示半屏态。这样,通过设置滑动条件,防止用户误触造成的悬浮窗的随意移动,提高了用户体验。
示例性的,第二状态的悬浮窗为用户在对第一文本执行翻译操作后显示的悬浮窗展示的状态。
在一种可能的实现方式中,所述滑动条件包括满足滑动距离、滑动速度、滑动方向中的任意一者或多者。这样,通过设置滑动条件,防止用户误触造成的悬浮窗的随意移动,提高了用户体验。
在一种可能的实现方式中,判断所述滑动距离满足条件包括判断所述滑动距离大于所述电子设备屏幕高度四分之一。
示例性的,例如在悬浮窗的半屏状态下,在滑动速度满足条件的情况下,用户将悬浮窗向上滑动的操作,其滑动距离大于所述电子设备屏幕高度四分之一,悬浮窗展示为全屏态。这样,通过设置滑动条件,防止用户误触造成的悬浮窗的随意移动,提高了用户体验。
在一种可能的实现方式中,若所述滑动距离大于所述电子设备屏幕高度四分之一且小于屏幕高度四分之三时,所述悬浮窗在所述底部态及所述半屏态或所述半屏态及所述全屏态之间切换;若所述滑动距离大于所述电子设备屏幕高度四分之三时,所述悬浮窗在所述底部态及所述全屏态之间切换。
示例性的,例如在悬浮窗的底部状态下,在滑动速度满足条件的情况下,用户将悬浮窗向上滑动的操作,其滑动距离大于所述电子设备屏幕高度四分之三时,悬浮窗展示为全屏态。这样,通过设置滑动条件,防止用户误触造成的悬浮窗的随意移动,提高了用户体验。
在一种可能的实现方式中,还包括,所述悬浮球在所述半屏态滑动至所述全屏态前,预加载所述第一译文对应的第一详细译文,所述第一详细译文包括所述第一译文显示在所述全屏态的悬浮窗内且未显示在所述半屏态的所述悬浮窗内的内容。
示例性的,例如在悬浮窗的半屏状态下,由于半屏态悬浮窗的面积限制,无法展示更多的翻译结果内容。因而,在当前状态下,判断用户可能需要扩展到全屏态以展示更多的翻译结果内容,系统会提前加载该部分未显示在半屏态悬浮窗而会显示在全屏态悬浮窗的翻译结果内容。这样,用户在由半屏态悬浮窗展开成全屏态悬浮窗时,由于该部分翻译结果内容已经被提前加载,因而可以在滑动过程中可以展示比没有预加载翻译内容更加细腻的滑动效果,也不会锯齿等影响用户体验的效果,大大提升了用户使用悬浮窗的体验。
在一种可能的实现方式中,所述悬浮窗还包括第一内部窗口,所述第一内部窗口包括所述第一译文和/或所述第一详细译文。
示例性的,悬浮窗包括第一内部窗口,其用于展示翻译结果。
在一种可能的实现方式中,还包括,所述第一内部窗口是可滑动的,用于显示所述第一译文对应的内容。
示例性的,悬浮窗包括第一内部窗口,区别与悬浮窗本身在3种状态下的滑动逻辑,由于安卓底层的显示,悬浮窗内部的第一内部窗口也需要单独设计滑动逻辑,因而,用户在使用悬浮窗时,可以通过滑动悬浮窗内的第一内部窗口,显示更多的翻译结果内容,提升用户体验。
示例性的,由于应用程序中每个应用的界面由一个个activity组成且任何activity都隶属于应用进程,因而在系统窗口设置的悬浮球及悬浮窗不具备activity的功能。为了获得悬浮球及悬浮窗可以获得类似于应用窗口内的activity的效果,即显示内容及基于用户在悬浮球及悬浮窗滑动的操作,需要额外在系统窗口内部设置滑动操作、滑动冲突等,以及根据用户的点击等操作,判断响应窗口的焦点等。
在一种可能的实现方式中,当所述悬浮窗处于全屏态时,响应于用户对数第一内部窗口的第二滑动操作,所述第一内部窗口显示第二详细译文,所述第二详细译文包括部分所述第一详细译文。
示例性的,悬浮窗包括第一内部窗口,区别与悬浮窗本身在3种状态下的滑动逻辑,由于安卓底层的显示,悬浮窗内部的第一内部窗口也需要单独设计滑动逻辑,因而,用户在使用悬浮窗时,可以通过滑动悬浮窗内的第一内部窗口,显示更多的翻译结果内容,提升用户体验。
示例性的,第二详细译文与第一详细译文都是对应于第一译文的翻译结果内容,第一文本的完整的翻译结果包括第一译文,第一详细译文及第二详细译文。例如,第一译文为简单的第一文本对应的单词的中文翻译结果,第一详细译文为第一文本对应的部分例句,在悬浮窗处于全屏态时,完整展示第一译文及第一详细译文,由于单词可能有更多的例句,当用户在第一内部窗口滑动时,第二详细译文用于展示前述第一译文及第一详细译文没有展示的翻译结果内容,例如更多的词典例句等。
在一种可能的实现方式中,在显示包括所述第一悬浮球控件的所述应用程序的所述第一界面前,还包括:所述第一界面还包括第三文本,响应于用户对所述第三文本的第五操作,所述第一界面显示第二控件,其中,所述第五操作包括对所述第三文本的选中操作、触摸操作、点击操作、滑动操作、长按操作或双击操作中的任意一种,所述第三文本与所述第一文本相同或不同,所述第三文本不包括网址、邮箱或利用机 器生成的口令,所述第三文本与所述电子设备的系统语言不同。
在一种可能的实现方式中,所述第二控件中的选项包括复制选项或剪切选项。
在一种可能的实现方式中,响应于用户对所述第二控件的第六操作,所述第一界面显示第二悬浮球控件,所述第六操作包括对所述第二控件的所述复制选项的复制操作或对所述剪切选项的剪切操作中的任意一种。
示例性的,第二悬浮球控件被设定为用于向用户提供一个显示翻译结果的入口。当用户点击或触摸第二悬浮球控件后,显示具有翻译结果的悬浮窗。可选的,在显示悬浮窗后,第二悬浮球控件消失或者继续保持显示,本申请在此不做限定。
示例性的,第一悬浮球控件被设定为在预设时间内用户未对第二悬浮球控件触发任何点击或者触摸操作后,显示第一悬浮球控件。此时,判断用户不需要执行翻译操作。因而,在用户触发复制操作时,用户的复制行为将被判定为正常的复制文本行为,继续显示第一悬浮球控件。
示例性的,用户在使用应用程序阅读外文文献时,通过选中需要翻译的单词,选择复制或剪切操作后,系统判断用户此时有翻译的意图,因而在当前应用程序的当前页面显示悬浮球,若此时用户有继续显示翻译结果的需求,可以继续点击上述第二悬浮球控件以在悬浮窗显示翻译结果。这样,通过判断用户的意图,识别用户翻译的意图,从而显示用于提示展示翻译结果的第二悬浮球控件,并根据用户的操作,选择是否展示悬浮窗以显示翻译结果。这样,用户无需退出当前应用并切换到第三方翻译应用以查询单词,在当前应用的当前页面便可以实现对翻译的实时查询,省去了在当前应用与翻译应用之间来回切换以获取翻译结果,提高了翻译效率。
在一种可能的实现方式中,还包括,响应于用户对所述第二悬浮球控件的第七操作,显示所述悬浮窗,所述悬浮窗包括所述第三文本及所述第三文本对应的第三译文,所述第七操作包括触摸操作、点击操作或长按操作中的任意一种。
示例性的,用户在使用应用程序阅读外文文献时,通过选中需要翻译的单词,选择复制或剪切操作后,系统判断用户此时有翻译的意图,因而在当前应用程序的当前页面显示悬浮球,若此时用户有继续显示翻译结果的需求,可以继续点击上述第二悬浮球控件以在悬浮窗显示翻译结果。这样,通过判断用户的意图,识别用户翻译的意图,从而显示用于提示展示翻译结果的第二悬浮球控件,并根据用户的操作,选择是否展示悬浮窗以显示翻译结果。这样,用户无需退出当前应用并切换到第三方翻译应用以查询单词,在当前应用的当前页面便可以实现对翻译的实时查询,省去了在当前应用与翻译应用之间来回切换以获取翻译结果,提高了翻译效率。
在一种可能的实现方式中,还包括,在显示所述第二悬浮球控件前,显示悬浮球标识,且在第一预设时间后,所述悬浮球标识消失,显示所述第二悬浮球控件。
示例性的,例如悬浮球标识用于显示系统正在识别或判断用户的意图,当判断用户的意图是翻译选中的文本时,显示第二悬浮球控件。又例如悬浮球标识用于展示电子设备向翻译服务器请求翻译结果的等待标识。
示例性的,第一预设时间以秒为单位的较短时间,具体多少时间,本申请在此不做限定。
在一种可能的实现方式中,所述悬浮球标识用于判断所述第六操作满足翻译条件, 所述翻译条件包括所述第三文本的语言类型、所述第三文本的内容或所述应用程序的类型中的任意一者或多者。
示例性的,判断是否满足翻译条件,包括:判断复制的文本中是否包含手机当前的非系统语言;判断复制的文本中包含的非系统语言是否为手机系统支持的预设语言;判断复制的文本是否符合一定的文本类型;判断复制的文本的来源应用是否满足一定的应用类型。这样,通过设置翻译条件,减少了不必要的翻译悬浮球或者悬浮窗的弹出或提醒,从而减少对用户的打扰,提高用户体验。
在一种可能的实现方式中,所述第二悬浮球控件与所述第一悬浮球控件在所述应用程序的所述第一界面显示在所述电子设备的所述第一界面的相同的一侧,二者所述相同一侧显示的位置相同或不同。
示例性的,第一悬浮球控件及第二悬浮球控件是可滑动的,其可以用户的操作,显示在电子设备的第一界面的不同区域。二者设置在电子设备相同的一侧,例如电子设备的第一界面的右侧,其位置关系可以包括上下关系,例如第一悬浮球控件显示在第一界面的右侧上部,第二悬浮球控件显示在第一界面的右侧下部。又例如第一悬浮球控件及第二悬浮球控件显示在相同的位置。这样,符合用户常用的用户习惯,提高用户体验。
在一种可能的实现方式中,还包括,判断在第二预设时间内未检测到用户对所述第二悬浮球控件的触摸操作、点击操作、滑动操作或长按操作中的任意一种,取消显示所述第二悬浮球控件,显示所述第一悬浮球控件。
示例性的,第二预设时间以秒为单位的较短时间,具体多少时间,本申请在此不做限定。
示例性的,在第二预设时间后,判断用户暂时没有翻译的意图,因而将悬浮球由第二悬浮球控件变成第一悬浮球控件的状态显示,并显示于第一界面的一侧,当用户再一次有翻译意图时,对第一悬浮球控件进行操作,便可以再次执行翻译操作,方便快捷,提高了用户体验。
在一种可能的实现方式中,响应于用户对所述第一悬浮球控件的第八操作,在所述第一界面显示悬浮窗,其中,所述悬浮窗包括所述第三文本及所述第三文本对应的第三译文,所述第八操作包括触摸操作、点击操作或长按操作中的任意一种。
示例性的,在第二预设时间后,判断用户暂时没有翻译的意图,因而将悬浮球由第二悬浮球控件变成第一悬浮球控件的状态显示,并显示于第一界面的一侧,当用户再一次有翻译意图时,对第一悬浮球控件进行操作,便可以再次执行翻译操作,方便快捷,提高了用户体验。
在一种可能的实现方式中,所述第一界面还包括第四文本,若所述第一界面显示所述第一悬浮球控件,响应于用户对所述第四文本的第九操作,所述第一界面显示所述第二控件,响应于用户对所述第二控件的第十操作,所述第一界面继续显示所述第一悬浮球控件,其中,所述第九操作包括对所述第四文本的选中操作、触摸操作、点击操作、滑动操作、长按操作或双击操作中的任意一种,所述第十操作包括对所述第二控件的所述复制选项的复制操作或对所述剪切选项的剪切操作中的任意一种,所述第四文本与所述第三文本相同或不同,所述第四文本不包括网址、邮箱或利用机器生 成的口令,所述第四文本与所述电子设备的系统语言不同。
示例性的,在显示第一悬浮球控件的状态下,由于系统判断用户暂时没有翻译的意图,因而,当用户复制第四文本的时候,系统不会触发翻译操作而显示悬浮窗,电子设备继续第一悬浮球控件,即用户对第四文本的复制操作被系统判断为普通的复制文本操作。这样,通过展示悬浮球控件状态的不同,用户可以理解何时需要翻译,何时展示普通的复制文本的操作,而当用户有翻译需求时,又可以立即对第一悬浮球控件进行操作,从而显示悬浮窗,展示翻译结果内容。减少了对用户的干扰,又方便用户迅速获取翻译结果内容,提高了用户体验。
在一种可能的实现方式中,响应于用户对所述第一悬浮球控件的第十一操作,在所述第一界面显示悬浮窗,其中,所述悬浮窗包括所述第四文本及所述第四文本对应的第四译文,所述第十一操作包括对所述第一悬浮球控件的触摸操作、点击操作或长按操作中的任意一种。
示例性的,当用户有翻译需求时,可以立即对第一悬浮球控件进行操作,从而显示悬浮窗,展示翻译结果内容。减少了对用户的干扰,又方便用户迅速获取翻译结果内容,提高了用户体验。
在一种可能的实现方式中,所述悬浮窗为系统窗口,所述系统窗口与所述应用程序的应用窗口不同。
示例性的,由于本申请实施方式中所涉及的悬浮球及悬浮窗为系统窗口,无法设置于应用窗口中,其不属于任何一个应用,其由系统来创建,只属于系统本身。
在一种可能的实现方式中,所述悬浮窗为非模态对话框,当所述第一界面显示所述悬浮窗时,所述第一界面或所述悬浮窗中的任意一者是可滑动的。
示例性的,非模态对话框,其优点在于不抢占窗口的焦点,用户在使用本申请实施方式的悬浮窗时,通过触摸或点击悬浮窗外区域即可将悬浮窗返回底部态,从而继续浏览当前应用的内容,提高用户的体验。
在一种可能的实现方式中,所述悬浮窗的窗口属性被设置为包括FLAG_NOT_TOUCH_MODAL,所述悬浮窗不与所述应用程序的所述第一界面抢占窗口焦点,包括:当所述第一界面显示所述悬浮窗时,若所述第一界面被滑动,所述悬浮窗不消失,响应于所述悬浮窗被滑动,所述第一界面不消失;若所述悬浮窗被滑动,所述第一界面不消失,响应于所述第一界面被滑动,所述悬浮窗不消失。
示例性的,悬浮窗的窗口属性被设置为FLAG_NOT_TOUCH_MODAL,因而在此模式下,系统会将当前窗口区域以外的触摸/点击事件传递给底层的窗口,当前窗口区域以内的单击事件则当前窗口处理。当手机检测到在悬浮窗外区域的触摸或点击事件时,将窗口传递给当前的阅读应用,进而用户可以继续浏览当前阅读应用的页面。当手机检测到在悬浮窗区域的触摸或点击事件时,则继续由悬浮窗处理用户的触摸或点击事件。
在一种可能的实现方式中,当所述悬浮窗被关闭时,所述第一界面显示所述第一悬浮球控件。
示例性的,悬浮窗的关闭,例如点击或触摸悬浮窗上的“X”图标,用以关闭悬浮窗。此时,悬浮窗关闭,其仍以第一悬浮球控件的形式展示在电子设备第一界面的一侧。这样,用户再一次有翻译需求时,可以立即对第一悬浮球控件进行操作,从而显 示悬浮窗,展示翻译结果内容。减少了对用户的干扰,又方便用户迅速获取翻译结果内容,提高了用户体验。
第二方面,本申请实施例提供一种电子设备,电子设备包括用于存储计算机程序指令的存储器和用于执行程序指令的处理器,其中,当该计算机程序指令被该处理器执行时,触发电子设备执行第一方面任一项的方法。
第二方面以及第二方面的任意一种实现方式分别与第一方面以及第一方面的任意一种实现方式相对应。第二方面以及第二方面的任意一种实现方式所对应的技术效果可参见上述第一方面以及第一方面的任意一种实现方式所对应的技术效果,此处不再赘述。
第三方面,本申请实施例提供一种计算机可读存储介质,计算机可读存储介质中存储有计算机程序,当其在计算机上运行时,使得计算机执行第一方面任一项的方法。
第三方面以及第三方面的任意一种实现方式分别与第一方面以及第一方面的任意一种实现方式相对应。第三方面以及第三方面的任意一种实现方式所对应的技术效果可参见上述第一方面以及第一方面的任意一种实现方式所对应的技术效果,此处不再赘述。
第四方面,本申请实施例提供一种计算机程序产品,计算机程序产品包括计算机程序,当其在计算机上运行时,使得计算机执行第一方面任一项的方法。
第四方面以及第四方面的任意一种实现方式分别与第一方面以及第一方面的任意一种实现方式相对应。第四方面以及第四方面的任意一种实现方式所对应的技术效果可参见上述第一方面以及第一方面的任意一种实现方式所对应的技术效果,此处不再赘述。
在一种可能的设计中,第五方面中的程序可以全部或者部分存储在与处理器封装在一起的存储介质上,也可以部分或者全部存储在不与处理器封装在一起的存储器上。
为了更清楚地说明本申请实施例的技术方案,下面将对实施例中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其它的附图。
图1为本申请实施例提供的电子设备示意图;
图2A为本申请实施例提供的电子设备的软件结构框图;
图2B为本申请实施例提供的电子设备的窗口管理器的软件结构框图;
图3为本申请实施例提供的一种翻译界面触发示意图;
图4A为本申请实施例提供的一种翻译界面悬浮球示意图;
图4B为本申请实施例提供的一种翻译界面悬浮球示意图;
图5A为本申请实施例提供的一种悬浮窗状态变化示意图;
图5B为本申请实施例提供的一种悬浮窗状态变化示意图;
图6为本申请实施例提供的一种悬浮窗状态变化示意图;
图7为本申请实施例提供的一种悬浮窗状态变化示意图;
图8为本申请实施例提供的一种悬浮窗状态变化示意图;
图9为本申请实施例提供的一种悬浮窗状态变化示意图;
图10A为本申请实施例提供的一种连续复制场景下悬浮窗状态变化示意图;
图10B为本申请实施例提供的一种连续复制场景下悬浮窗状态变化示意图;
图11为本申请实施例提供的一种非模态悬浮窗状态变化示意图;
图12为本申请实施例提供的一种悬浮窗内容预加载变化示意图;
图13为本申请实施例提供的一种悬浮窗内部滑动示意图;
图14为本申请实施例提供的一种翻转状态下悬浮窗状态变化示意图;
图15为本申请实施例提供的一种翻转状态下非模态悬浮窗状态变化示意图;
图16为本申请实施例提供的一种逻辑实现流程图;
图17为本申请实施例提供的一种逻辑实现时序图;
图18为本申请实施例提供的另一种翻译界面触发示意图;
图19为本申请实施例提供的另一种翻译界面触发示意图。
为了更好的理解本申请的技术方案,下面结合附图对本申请实施例进行详细描述。
应当明确,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其它实施例,都属于本申请保护的范围。在本申请实施例中使用的术语是仅仅出于描述特定实施例的目的,而非旨在限制本申请。在本申请实施例和所附权利要求书中所使用的单数形式的“一种”、“所述”和“该”也旨在包括多数形式,除非上下文清楚地表示其他含义。应当理解,本文中使用的术语“和/或”仅仅是一种描述关联对象的关联关系,表示可以存在三种关系,例如,甲和/或乙,可以表示:单独存在甲,同时存在甲和乙,单独存在乙这三种情况。另外,本文中字符“/”,一般表示前后关联对象是一种“或”的关系。还应当理解,当在本申请说明书和所附权利要求书中使用时,术语“包括”指示所描述特征、整体、步骤、操作、元素和/或组件的存在,但并不排除一个或多个其它特征、整体、步骤、操作、元素、组件和/或其集合的存在或添加。另外,在本申请说明书和所附权利要求书的描述中,术语“第一”、“第二”、“第三”、“第四”等仅用于区分描述,而不能理解为指示或暗示相对重要性。
用户在阅读外文文献时,例如利用阅读应用浏览英文文献时,遇到查阅外文文献中生词的需求,用户通常会诉诸电子设备(以下以“手机”为例)中已经安装的翻译应用。
如果当前应用本身支持在应用内的翻译功能,例如目前市面上的聊天类应用,可以选中需要翻译的聊天内容,在点击或长按该文本后,选中“翻译”按钮,实时显示该聊天内容的翻译结果。通常,该翻译结果会呈现在该聊天内容附近。当用户需要再次翻译聊天内容时,需要重复上述操作以显示翻译结果。
如果当前应用本身不支持在应用内的翻译功能,例如阅读应用,用户需要复制或者记忆需要翻译的文本,例如某个英文单词,然后切换出当前应用,打开翻译应用,将该英文单词粘贴或手动输入至输入框,点击翻译按钮后,显示翻译结果,从而完成翻译操作。显然,上述操作方式步骤繁琐,致翻译效率低下,影响用户体验。
进而,一种改进方式是通过阅读应用或浏览器插件或翻译软件提供的插件,实现 屏幕取词进行文本翻译,即通过在后台打开该阅读应用或浏览器插件或翻译软件提供的插件,在用户选中需要翻译的文本时,实现即时的翻译结果,无需打开翻译网页或者翻译软件。然而,上述方式仍需要用户额外安装插件才能实现,增加了用户使用的门槛。另外,在电子设备例如手机中,受限于手机系统底层的控制逻辑,较难实现。
进而,另一种改进方式是通过翻译应用主动监控系统的剪切板内容,从而在用户从当前阅读应用切换到翻译应用时,翻译应用可以自动获取剪切板的内容并显示该内容的翻译结果,免去了手动输入的麻烦。然而,上述操作方式仍然需要用户离开当前应用并切换到翻译应用才能获取翻译结果,使得操作方式较为繁琐,降低了翻译的效率。
由此,无论当前应用本身支持在应用内的翻译功能,或者当前应用本身不支持在应用内的翻译功能而需要切换至翻译应用显示翻译结果,上述方式都是在应用级的翻译,也就是说,前者是集成在某个应用内部的翻译插件,后者是完整的独立的翻译应用,皆不涉及利用手机系统底层的功能实现翻译,例如基于安卓系统为底层打磨的手机系统级别实现的翻译。
基于此,本申请实施例提供一种翻译方法及电子设备,通过在手机系统底层的改进,以提高用户体验。
参见图1,为本申请实施例提供的一种电子设备的结构示意图。电子设备100可以包括处理器110,外部存储器接口120,内部存储器121,通用串行总线(universal serial bus,USB)接口130,充电管理模块140,电源管理模块141,电池142,天线1,天线2,移动通信模块150,无线通信模块160,音频模块170,扬声器170A,受话器170B,麦克风170C,耳机接口170D,传感器模块180,按键190,马达191,指示器192,摄像头193,显示屏194,以及用户标识模块(subscriber identification module,SIM)卡接口195等。其中传感器模块180可以包括压力传感器180A,陀螺仪传感器180B,磁传感器180D,加速度传感器180E,距离传感器180F,接近光传感器180G,指纹传感器180H,触摸传感器180K,环境光传感器180L等。
可以理解的是,本申请实施例示意的结构并不构成对电子设备100的具体限定。在本申请另一些实施例中,电子设备100可以包括比图示更多或更少的部件,或者组合某些部件,或者拆分某些部件,或者不同的部件布置。图示的部件可以以硬件,软件或软件和硬件的组合实现。
处理器110可以包括一个或多个处理单元,例如:处理器110可以包括应用处理器(application processor,AP),调制解调处理器,图形处理器(graphics processing unit,GPU),图像信号处理器(image signal processor,ISP),控制器,存储器,视频编解码器,数字信号处理器(digital signal processor,DSP),基带处理器,和/或神经网络处理器(neural-network processing unit,NPU)等。其中,不同的处理单元可以是独立的器件,也可以集成在一个或多个处理器中。例如,处理器110用于执行本申请实施例中的环境光的检测方法。
其中,控制器可以是电子设备100的神经中枢和指挥中心。控制器可以根据指令操作码和时序信号,产生操作控制信号,完成取指令和执行指令的控制。
处理器110中还可以设置存储器,用于存储指令和数据。在一些实施例中,处理 器110中的存储器为高速缓冲存储器。该存储器可以保存处理器110刚用过或循环使用的指令或数据。如果处理器110需要再次使用该指令或数据,可从存储器中直接调用。避免了重复存取,减少了处理器110的等待时间,因而提高了系统的效率。
电子设备100通过GPU,显示屏194,以及应用处理器等实现显示功能。GPU为图像处理的微处理器,连接显示屏194和应用处理器。GPU用于执行数学和几何计算,用于图形渲染。处理器110可包括一个或多个GPU,其执行程序指令以生成或改变显示信息。
显示屏194用于显示图像,视频等。显示屏194包括显示面板。显示面板可以采用有机发光二极管(organic light-emitting diode,OLED)。在一些实施例中,电子设备100可以包括1个或N个显示屏194,N为大于1的正整数。
如图2A所示,可以将Android系统分为五层,分别为应用程序层(applications)、应用程序框架层(application framework)、安卓运行时(Android runtime)和系统库、硬件抽象层(hardware abstract layer,HAL,图中未示出)以及内核层(kernel)。
其中,应用程序层可以包括一系列应用程序包。例如,应用程序层可以包括相机,图库,日历,通话,地图,导航,WLAN,蓝牙,音乐,视频,短信息等应用程序(应用程序可以简称为应用),本申请实施例对此不做任何限制。
本申请实施例中,应用程序层还可以包括情景感知模块、业务逻辑处理模块和业务呈现模块等。情景感知模块、业务逻辑处理模块和业务呈现模块可以是独立的APP,或者可以分别集成在不同的APP中,或者可以集成在同一个APP中,本申请不做限定。
其中,情境感知模块,常驻运行或以低功耗形式运行,具有感知外部事实或者环境的能力。情境感知模块可以通过API(应用程序接口)从应用程序层的其他应用程序或应用程序框架层或系统层或内核层来检测相关事件和获取事件的状态,比如检测蓝牙连接、网络连接、监测用户短信、定制定时器等。在本申请实施例中,情境感知模块主要作用是监听剪贴板是否有复制事件,当监听到剪贴板有复制事件,将复制事件通知给业务逻辑处理模块。情境感知模块还可以用于获取剪切板中的剪切内容的来源应用(APP),即应用包名。也就是说,剪切板内容通过情境感知模块识别该剪切的内容是从某个具体的应用中复制的。另外,情境感知模块还可以检测是否有退出当前页面的操作,当检测到退出当前页面的操作,通知业务逻辑处理模块。
业务逻辑处理模块(如:计算引擎)具有业务逻辑处理能力,用于实现各种悬浮球或悬浮窗的展示,消失的逻辑。例如,业务逻辑处理模块接收到用户触发的复制事件及情境感知模块发送的剪切板内容,判断是否满足翻译条件,从而判断是否显示悬浮球。业务逻辑处理模块还可以根据用户触发的点击悬浮球事件以及从第三方服务器获取的翻译结果内容,判断是否显示悬浮窗并将翻译结果显示在悬浮窗内。另外,业务逻辑处理模块还可以用于根据用户触发的悬浮球或悬浮窗消失的事件,判断是否将电子设备上的悬浮球或悬浮窗展示或者消失。
此外,业务逻辑处理模块还可以识别复制文本或者OCR技术提取的文本。例如可以识别出文本为日程、待分享链接、淘宝口令、网址等类型中的至少一种。又例如还可以识别出文本的语种。
业务呈现模块(如:YOYO建议),用于将悬浮球或悬浮窗显示或者消失在手机的 屏幕上。例如,业务呈现模块接收到业务逻辑处理模块发送的显示悬浮球或悬浮窗的命令,通知窗口管理器将该悬浮球或悬浮窗显示在电子设备上。同时,业务呈现模块还可以在悬浮窗内呈现用户复制的文本及其对应的翻译结果。另外,业务呈现模块还可以用户根据用户触发的悬浮球或悬浮窗消失的事件,通知窗口管理器将电子设备上的悬浮球或悬浮窗展示或者消失。
如图2A所示,应用程序框架层可以包括窗口管理器,内容提供器,视图系统,资源管理器,通知管理器等,活动管理器,剪贴板管理器等,本申请实施例对此不做任何限制。
窗口管理器用于管理窗口程序,窗口管理器可以获取显示屏大小,判断是否有状态栏,锁定屏幕,截取屏幕等。
剪贴板管理器用于对剪贴板进行管理。剪贴板是用于临时存放交换信息的临时存储区域。
活动管理器用于管理各个应用程序的生命周期以及导航回退功能,负责Android的主线程创建,各个应用程序的生命周期的维护。
资源管理器为应用程序提供各种资源,比如本地化字符串,图标,图片,布局文件,视频文件等等。
通知管理器使应用程序可以在状态栏中显示通知信息,可以用于传达告知类型的消息,可以短暂停留后自动消失,无需用户交互。比如通知管理器被用于告知下载完成,消息提醒等。通知管理器还可以是以图表或者滚动条文本形式出现在系统顶部状态栏的通知,例如后台运行的应用程序的通知,还可以是以对话窗口形式出现在屏幕上的通知。例如在状态栏提示文本信息,发出提示音,电子设备振动,指示灯闪烁等。
应用程序层和应用程序框架层运行在虚拟机中。虚拟机将应用程序层和应用程序框架层的java文件执行为二进制文件。虚拟机用于执行对象生命周期的管理,堆栈管理,线程管理,安全和异常的管理,以及垃圾回收等功能。
如图2A所示,系统库可以包括多个功能模块。例如:表面管理器(surface manager),媒体库(Media Libraries),三维图形处理库(例如:OpenGL ES),2D图形引擎(例如:SGL)等。
表面管理器用于对显示子系统进行管理,并且为多个应用程序提供了2D和3D图层的融合。
如图2A所示,内核层是硬件和软件之间的层。内核层至少包含显示驱动,摄像头驱动,音频驱动,传感器驱动。
结合图2B所示,具体而言,窗口管理器包括应用窗口,子窗口(未示出)及系统窗口。
应用窗口对应于某个应用的应用窗口,例如某个阅读应用的应用窗口,用于显示阅读应用内的内容,又例如翻译应用的应用窗口,用于显示翻译应用内的内容,又例如备忘录应用的应用窗口,用于显示备忘录应用内的内容。每个应用的界面由一个个activity组成,而activity又由view组成,view是窗口的存在形式,窗口是view的载体。当启动activity时,通知应用进程,任何activity都隶属于应用进程。也就是说,例如阅读应用对应一个activity,备忘录应用由于与阅读应用是不同的应用, 因而对应另一个activity。所有activity默认的窗口类型是基窗口(TYPE_BASE_APPLICATION),即所有其他类型的应用窗口将出现在基窗口上层。
子窗口依附于父窗口,即不能独立存在,需要依赖一个应用,如应用输入法窗口、应用提示框窗口等。当父窗口不可见时,子窗口也不可见。
系统窗口与应用窗口不同,不需要对应Activity。与子窗口不同,不需要有父窗口。系统窗口不属于任何一个应用,由系统来创建,只属于系统本身,往往需要声明权限才能创建,例如关机对话框窗口,状态栏窗口、搜索条窗口、输入法窗口、警告对话框、系统音量条等。
需要说明的是,系统窗口的层级一般高于应用窗口及子窗口。
继续结合图2B所示,本申请的实施例中,系统窗口中设置有悬浮球及悬浮窗。由上述分析可知,悬浮球及悬浮窗为系统窗口,无法设置于应用窗口中。
悬浮窗及悬浮球的本质是将一个view交个窗口管理器管理,由于安卓底层的系统限制,应用窗口z轴范围是1~99,子窗口的范围是1001~1999,系统窗口是(2000~2999),因而,悬浮窗及悬浮球只能在系统窗口范围中实现,如果要弹出自定义系统级窗口需要动态申请权限。Z轴是安卓窗口的层级的概念,Z轴越大的窗口越居于顶层。
进一步地,由于应用程序中每个应用的界面由一个个activity组成且任何activity都隶属于应用进程,因而在系统窗口设置的悬浮球及悬浮窗不具备activity的功能。为了获得悬浮球及悬浮窗可以获得类似于应用窗口内的activity的效果,即显示内容及基于用户在悬浮球及悬浮窗滑动的操作,需要额外在系统窗口内部设置滑动操作、滑动冲突等,以及根据用户的点击等操作,判断响应窗口的焦点等。具体根据以下内容的表述展开而更加清晰。
本申请的一种实施方式中,以执行翻译为例。示例性的,电子设备(以“手机”为例)中系统设置的默认语言是简体中文。示例性的,在一些实施方式中,在手机的设置界面中设置有例如“复制触发翻译”的选项开关,当用户选择开启该功能后,当用户复制非系统默认语言的文字时,会触发本申请实施方式中的翻译功能,显示翻译结果。其中,该翻译结果可以是翻译原文(如复制文本)和/或翻译译文。如此,手机可以根据识别出的执行翻译的意图直接呈现翻译结果,从而可以快速满足用户执行翻译的意图。示例性的,在另一些实施方式中,手机的设置界面中无需设置有例如“复制触发翻译”的选项开关,手机会根据用户复制文字的操作判断用户可能的意图,例如添加日程、添加备忘录、分享到应用、添加收藏、添加到词典和打开地图导航等意图中一项或多项,本申请的实施方式中对用户复制文字后手机判断的可能的用户意图的种类不做限定。
参考图3所示,示例性的,以阅读应用为例,用户打开阅读应用中的某个阅读页面,显示一段英文。图3中的(a)中,在需要翻译的场景下,用户选中“patent”这个单词,系统弹出选项栏301,该选项栏301至少包括例如“复制”的操作选项。手机在监听到剪切板中的内容变化后,则会触发识别用户复制文本的意图。应理解,在用户执行对文本的复制操作后,复制的文本则会被存入剪切板中,从而剪切板中的内容会发生变化。因此,剪切板中的内容变化后,也即用户输入复制操作后。用户点击“复制”选项后,手机试图识别用户复制文字后的意图,因而弹出如图3中的(b)中 所示的悬浮球标识302,用于指示手机正在识别用户的意图。例如,手机可根据复制文本的文本内容、用户画像等数据识别出意图。在识别过程中,无需用户的操作,即无需用户点击如图3中的(b)中页面的任何内容,便可以识别用户的意图。当系统识别出用户的意图是需要翻译“patent”这个单词时,显示如图3中的(c)中的第一状态的悬浮球303,该第一状态的悬浮球303用于向用户提供一个显示翻译结果的入口。响应于用户对悬浮球303的点击或者触摸操作,在图3中的(d)中显示悬浮窗304并在悬浮窗304内展示“patent”的翻译结果。悬浮窗304显示的翻译结果包括用户复制的待查询的英文单词“patent”,以及该单词的中文释义的翻译结果,即“专利”。悬浮窗304显示的界面还包括语音朗读、复制翻译结果的文本、翻译语种切换等。示例性的,悬浮窗304显示的初始状态,即由用户点击悬浮球303后显示的默认形态为半屏态,大小约占据一半的手机屏幕。示例性的,由于悬浮窗304的显示,则取消显示悬浮球303,以达到更好的用户体验。
需要说明的是,悬浮球303与悬浮窗304是安卓移动端的两种不同类型的窗口。悬浮是相对的,例如上层元素就可以称之为“悬浮”元素,比如导航栏、标签栏相对于下层的内容区就是悬浮。在本申请的实施方式中,悬浮球303被设定为链接至悬浮窗304的入口,引导用户在需要显示翻译结果的场景,点击悬浮球303即可在悬浮窗304呈现翻译结果。悬浮窗304被设定为显示翻译结果的内容呈现窗口。
需要说明的是,本申请实施方式中所涉及的悬浮球及悬浮窗为系统窗口,无法设置于应用窗口中。另外,由于安卓对于悬浮球及悬浮窗管控较为严格,因而,弹出自定义系统级窗口需要动态申请权限。
其中,当手机中系统设置的默认语言是简体中文时,手机识别用户复制文本的语言不是手机当前的系统语言(即手机设置的默认语言),则可以识别出用户的意图包括执行翻译。例如,当用户复制的文本的语言为例如英文、日文、法文等除简体中文之外的语言时,手机会识别用户的翻译意图,从而显示悬浮球标识302及悬浮球303等。通常而言,手机设置的默认语言是用户熟悉的语言,无需对其进行翻译。
其中,如上所述,手机复制的文本是否触发执行翻译与系统设置的默认语言及复制文本的语言有关。手机识别用户复制文本的语言不是手机当前的系统语言(即手机设置的默认语言),则可以识别出用户的意图包括执行翻译。具体而言,示例性的,当手机中系统设置的默认语言是简体中文时,可以包括如下组合:
第一种组合:复制的文本同时包括系统语言及非系统语言文本。例如当复制的文本中同时包括中文及法文时,由于手机识别到复制的文本中包括非中文的法文文本,因而,用户复制文本后,仍然会触发执行翻译的操作,即显示弹出如图3中的(b)中所示的悬浮球标识302并在一段时间后自动显示如图3中的(c)中的第一状态的悬浮球303。
第二种组合:复制的文本为应用程序本身设置的非系统语言的文本。例如当前应用设置的应用语言为英文时,当用户复制该应用中的英文文本时,由于手机识别到复制的文本中包括非中文的文本,因而,用户复制文本后,仍然会触发执行翻译的操作,即显示弹出如图3中的(b)中所示的悬浮球标识302并在一段时间后自动显示如图3中的(c)中的第一状态的悬浮球303。
第三种组合:复制的文本为用户输入的非系统语言的文本。例如在聊天应用或备忘录等用户可以手动输入文本的应用中,用户选中并复制一段用户输入的英文文本,由于手机识别到复制的文本中包括非中文的文本,因而,用户复制文本后,仍然会触发执行翻译的操作,即显示弹出如图3中的(b)中所示的悬浮球标识302并在一段时间后自动显示如图3中的(c)中的第一状态的悬浮球303。
在本申请的一些实施方式中,手机还需要识别出复制文本的语言是预设语言,其中,预设语言是指手机系统或者手机上的翻译应用支持翻译的语言,才可以识别出用户的意图包括执行翻译。若手机根本不支持翻译复制文本的语言,则无法得到翻译结果,针对该情况,则将识别为不存在执行翻译的意图。
在本申请的另一些实施方式中,手机还需要识别出复制文本需要满足一定的文本类型。示例性的,即不是网址链接、邮箱或者利用机器生成的口令(如淘宝口令)等具有特定含义的字符串,才可以识别出用户的意图包括执行翻译。上述这些具有特定含义的字符串,通常只是标识符,例如,用于区别不同的网页、不同的邮箱、不同的淘宝商品等,并不具备语言上的含义。因此,不存在翻译的需求。
在本申请的另一些实施方式中,手机还需要识别出当前复制文本的来源应用需要满足一定的应用类型。示例性的,即该应用不是翻译应用等单独的专业性翻译应用,或者不是淘宝、抖音等购物娱乐类应用,才可以识别出用户的意图包括执行翻译。例如,当用户在淘宝应用中复制非系统默认语言的文字时,手机判定用户此时不存在翻译需求,因而在用户复制文本后,不会显示悬浮球标识302及悬浮球303。同样的,当用户在专业的翻译软件,例如有道翻译中复制非系统默认语言的文字时,手机判定用户此时不存在翻译需求,因而在用户复制文本后,不会显示悬浮球标识302及悬浮球303。
需要说明的是,本申请的实施方式中对于手机使用何种方式对用户的操作进行意图识别不做限定。例如手机可以根据当前的应用类型、用户复制的文本类型以及当前应用显示的上下文,判断用户复制文字后的翻译意图等。又例如,手机可以通过使用自然语言处理(Natural Language Processing,NLP)对用户的行为习惯、使用APP的情况等进行综合分析和预测。
需要说明的是,在本申请实施方式中,主要以复制操作为例,来触发手机识别意图。但是实际实施时,并不以此为限。例如,也可以以对文本的选中操作、长按操作、划线操作、双击操作等操作触发手机识别意图。
参考图4A所示,若用户在图4A中的(a)中,在预设时间内未对第一状态的悬浮球401,即上述图3中的(c)中的悬浮球303,触发任何点击或者触摸操作,判断用户此时不需要执行翻译操作,则悬浮球401将呈现第二状态,即图4A中的(b)中第二状态的悬浮球402,以提高用户体验。预设时间以秒为单位的较短时间,具体多少时间,本申请在此不做限定。此时,用户的复制行为将被判定为正常的复制文本行为,而不会显示如图4A中的(a)中的第一状态的悬浮球401。也就是说,此时用户的复制行为不会触发执行翻译的操作。例如,若用户在图4A中的(c)中选中一个单词,例如“law”,点击“复制”后,由于手机判断用户此时不需要执行翻译操作,手机不会显示如图4A中的(a)中的第一状态的悬浮球401,继续显示第二状态的悬浮球402, 即图4A中的(d)。也就是说,尽管在图4A中,用户复制了单词“law”,此时由于处于第二状态的悬浮球的状态下,判断用户不需要执行翻译操作,因而,在用户触发复制单词“law”操作时,不会请求翻译结果,手机执行安卓系统本身的复制操作。
需要说明的是,用户在图3中选中的单词是“patent”,在图4A中选中的单词是“law”,显然,用户选中的单词不同,也就是说,用户意图执行翻译的单词不同。
示例性的,由于手机的剪切板默认保存最近一次复制的单词,因而在图4A中的(c)中,若用户选中单词例如“law”,点击“复制”后,再点击悬浮球402,由于判断用户需要执行翻译的意图,因而会显示如图3中的(d)中的悬浮窗,但是翻译的单词由原先的“patent”变成了用户最新复制的“law”,并在悬浮窗显示“law”的翻译结果。也就是说,由于手机的剪切板默认保存最近一次复制的单词,因而,在悬浮球402状态下,若用户点击悬浮球402执行翻译操作,悬浮窗会显示用户在点击悬浮球402前最近一次剪切板保存的文本的相应翻译结果。
其中,第一状态的悬浮球被设定为用于向用户提供一个显示翻译结果的入口。当用户点击或触摸第一状态的悬浮球后,显示具有翻译结果的悬浮窗。可选的,在显示悬浮窗后,第一状态的悬浮球消失或者继续保持显示,本申请在此不做限定。
其中,第二状态的悬浮球被设定为在预设时间内用户未对第一状态的悬浮球触发任何点击或者触摸操作后,显示第二状态的悬浮球。此时,判断用户不需要执行翻译操作。因而,在用户触发复制操作时,用户的复制行为将被判定为正常的复制文本行为,继续显示第二状态的悬浮球。
示例性的,第一悬浮球控件对应于第二状态的悬浮球,第二悬浮球控件对应于第一状态的悬浮球。
结合图4B所示,图4B中的(a)中用户的预设时间内未对第一状态的悬浮球401触发任何点击或者触摸操作,显示图4B中的(b)中第二状态的悬浮球402。若用户需要在第二状态的悬浮球显示的状态下执行翻译的操作,如图4B中的(c)所示,用户需要触发点击或者触摸第二状态的悬浮球402的操作。由于此时手机已缓存有图3中的(a)中用户选择的“patent”单词的翻译结果,且由于手机的剪切板默认保存最近一次复制的单词并没有检测到剪切板内容发生变化,因而在用户触发点击或者触摸第二状态的悬浮球402的操作后,显示图4B中的(d)中悬浮窗404,呈现“patent”单词的翻译结果。
以下展开描述本申请上述实施方式中提供悬浮窗的滑动效果示例。由前文描述可知,由于本申请实施方式中所涉及的悬浮球及悬浮窗为系统窗口,无法设置于应用窗口中,其不属于任何一个应用,其由系统来创建,只属于系统本身。另外,应用程序中每个应用的界面由一个个activity组成且任何activity都隶属于应用进程,因而在系统窗口设置的悬浮球及悬浮窗没有固定容器处理滑动和滑动冲突,不具备activity的功能。为了获得悬浮球及悬浮窗可以获得类似于应用窗口内的activity的效果,即显示内容及基于用户在悬浮球及悬浮窗滑动的操作,需要额外在系统窗口内部设置滑动操作、滑动冲突等,以及根据用户的点击等操作,判断响应窗口的焦点等。
示例性的,本申请实施方式悬浮窗,根据占据屏幕的高度的不同,分为3种形态, 即底部态,半屏态及全屏态。底部态的悬浮窗位于当前应用的屏幕底部,不显示任何翻译结果内容,有利于用户继续访问当前应用内的内容,以提高用户体验。半屏态的悬浮窗占据当前应用的屏幕约一半左右的大小,显示部分翻译结果内容。半屏态的悬浮窗也可以示例性的作为默认的悬浮窗形态,即当用户复制文本后显示的第一个形态的悬浮窗。全屏态的悬浮窗可以示例性的占据整个当前应用的屏幕,其展开基于用户的拖动操作而展开,用于显示比半屏态悬浮窗更多的翻译结果内容,以提高用户体验。
参考图5A至图9所示,用于示例性的展示本申请实施方式中的悬浮窗的滑动效果以及悬浮窗在3种不同形态之间的变换的逻辑。以下示例性的展开描述本申请的实现方式。
1)具体而言,悬浮窗的形态变换与用户的滑动速度及滑动距离有关。悬浮球及悬浮窗由窗口管理器实现,悬浮窗底部态,半屏态及全屏态的形态控制与切换由窗口管理器中的属性参数y控制,即控制不同形态悬浮窗的高度。
2)具体而言,本申请实施方式中的悬浮球及悬浮窗不抢占当前应用的焦点。例如图3中,用户复制文本时,焦点事件在当前阅读应用的原文上。当用户点击“复制”选项后,显示悬浮球标识302并在一段时间后自动显示如图3中的(c)中的第一状态的悬浮球303。此时,焦点事件还是在当前应用的原文上,悬浮球不抢占焦点。当用户点击或者触摸悬浮球303后,在图3中的(d)中显示悬浮窗304,此时,用户仍然能够滑动当前应用的原文,悬浮窗不抢占焦点。
焦点窗口是指当前正在与用户交互的窗口,该窗口负责接收键事件和触摸事件。当启动新的Activity、添加新的窗口、移除旧窗口、分屏来回操作时,都会涉及到焦点窗口的更新。一般而言,一个窗口中一个时间内可以有一个具有焦点的窗口。也就是说,如果不对悬浮窗的焦点控制做处理,在上述图3中的(d)中显示悬浮窗304后,用户无法滑动当前应用的原文,用户必须关闭当前的悬浮窗304后,才能返回当前应用的原文,并继续滑动原文。
为了实现悬浮球及悬浮窗不抢占当前应用的焦点,本申请的实施方式中对悬浮球及悬浮窗的窗口属性等做了处理。具体而言,在悬浮窗处于半屏态及全屏态时,将悬浮窗的窗口属性设置为FLAG_NOT_TOUCH_MODAL用以控制焦点事件处理;在悬浮窗处于底部态时,将悬浮窗的窗口属性设置为FLAG_NOT_FOCUSABLE用以把焦点事件交给当前应用的原文处理,当前应用即本申请实施方式中当前用户正在使用的阅读应用。
FLAG_NOT_FOCUSABLE:表示当前窗口不需要获取焦点,也不需要接收各种输入事件,此标记会同时启用FLAG_NOT_TOUCH_MODAL,最终事件会直接传递给下层的具体焦点的窗口。
FLAG_NOT_TOUCH_MODAL:表示在此模式下,系统会将当前窗口区域以外的触摸/点击事件传递给底层的窗口,当前窗口区域以内的单击事件则当前窗口处理。这个标记很重要,一般来说都需要开启此标记,否则其他窗口将无法收到触摸/点击事件。
3)具体而言,由于本申请实施方式中所涉及的悬浮球及悬浮窗为系统窗口,不具备activity的功能,为了获得悬浮球及悬浮窗可以获得类似于应用窗口内的activity的效果,即显示内容及基于用户在悬浮球及悬浮窗滑动的操作,需要额外在系统窗口内部设置滑动操作、滑动冲突等。
本申请的实施方式中,为了实现上述悬浮窗的滑动效果,需要重写窗口管理器内容容器的ontouch和oninterceptTouch事件,控制滑动和具体的事件分发。
在安卓的架构中,应用窗口的activity是安卓本身封装的,使用时直接调用相应的activity即可。然而由于本申请实施方式中所涉及的悬浮球及悬浮窗为系统窗口,安卓的架构中没有提供相应的activity来管理及调用,因而,为了在系统窗口实现类似于应用窗口内的activity的效果,需要额外设计一套滑动逻辑实现,具体包括:
a.监听用户在手机屏幕上的触摸事件;
b.监听用户在屏幕上手指的滑动速度和方向;具体通过用户手指在屏幕上的触点以及触点在屏幕上的相对位置判断;
c.根据用户手指在屏幕上的偏移量更新悬浮窗位置;
d.当用户手指离开屏幕时,处理悬浮窗滑动结果,并释放手势速度方向监听;
4)具体而言,本申请的实施方式中的滑动效果根据用户在屏幕上的滑动速度不同而有不同的响应事件。具体的实现逻辑在下文图5A及图5B的阐述中公开,此处不再赘述。
5)具体而言,本申请的实施方式提供了防误触的实现。当用户的手指触摸屏幕时,用户的手指在触摸屏幕时是抖动的,因而需要区分用户的操作是滑动还是触摸或点击事件。
在安卓的架构中,应用窗口的activity本身具备防误触的功能,然而,由于本申请实施方式中所涉及的悬浮球及悬浮窗为系统窗口,安卓的架构中没有提供相应的功能实现,因而,为了在系统窗口实现类似于应用窗口内的activity的防误触效果,需要额外设计一套滑动逻辑实现,具体包括:设定一个移动阈值,当用户手指触碰悬浮窗时,判断是否触发move事件。即,如果用户手指在手机屏幕上的移动距离小于移动阈值,则判断此次操作为点击事件;如果用户手指在手机屏幕上的移动距离超过移动阈值,则判断此次操作为滑动事件。
结合图5A所示,具体展开描述悬浮窗从半屏态切换至全屏态的变换实现。悬浮窗状态的变换与用户拖动悬浮窗滑动的速度以及是否拖动超过分割线有关。示例性的,图5A中的(a)中呈现的是半屏态状态下的悬浮窗501。图5A中的(b)中,分割线502是手机屏幕中悬浮窗501之外区域的中间分割线,即分割线502为悬浮窗半屏态高度及全屏态高度之间的分割线。当用户的手指将悬浮窗501向上拖动超过分割线502时,悬浮窗呈现如图5A中的(c)中的全屏态悬浮窗503。
其中,分割线502可以是半屏态高度与全屏态高度之间的分割线,也可以是半屏态高度与底部态高度之间的分割线。其根据当前悬浮窗所处的高度以及用户拖动悬浮窗滑动的方向不同而选择不同的分割线。
其中,悬浮窗的状态除了与用户是否拖动悬浮窗超过两个状态之间的中间线之外,还与用户拖动悬浮窗的速度有关。
示例性的,当用户拖动悬浮窗501快速向上滑动时,悬浮窗501呈现如图5A中的(c)中的全屏态,在快速滑动的情况下,可选的,用户拖动悬浮窗501快速向上滑动可以不用超过分割线502,仅需要满足快速滑动条件即可呈现如图5A中的(c)中的全屏态;可选的,也可以在用户拖动悬浮窗501向上滑动时,同时满足快速滑动及超 过分割线,才能呈现如图5A中的(c)中的全屏态。
示例性的,结合图5B所示,当用户拖动5B中的(a)中的悬浮窗501慢速向上滑动时,如果此时用户将悬浮窗501向上拖动超过分割线502时,悬浮窗呈现如图5A中的(c)中的全屏态。如果此时用户没有将悬浮窗501向上拖动超过分割线502时,即如图5B中的(b)中的状态,悬浮窗维持或回弹至如图5B中的(c)中的半屏态。
结合图6所示,具体展开描述悬浮窗从全屏态切换至半屏态,继而又切换至底部态的连续的变换实现。悬浮窗状态的变换与用户拖动悬浮窗滑动的速度以及是否拖动超过分割线有关。示例性的,图6中的(a)中呈现的是全屏态状态下的悬浮窗601。图6中的(b)中,分割线602是为悬浮窗半屏态高度及全屏态高度之间的分割线。当用户的手指将全屏态悬浮窗601向下拖动超过分割线602时,悬浮窗呈现如图6中的(c)中的半屏态悬浮窗603。此时,用户还可以继续向下拖动半屏态悬浮窗603以呈现不同状态的悬浮窗。图6中的(d)中,分割线604是为悬浮窗半屏态高度及底部态高度之间的分割线。当用户的手指将半屏态悬浮窗603向下拖动超过分割线604时,悬浮窗呈现如图6中的(e)中的底部态悬浮窗605。
其中,悬浮窗的状态除了与用户是否拖动悬浮窗超过两个状态之间的中间线之外,还与用户拖动悬浮窗的速度有关。其实现如上述图5A及图5B的实现过程,在此不再赘述。
结合图7所示,具体展开描述悬浮窗从全屏态直接切换至底部态的变换实现。其实现不必经过全屏态至半屏态,再由半屏态至底部态的过程,而是根据用户的操作,直接从全屏态切换至底部态。悬浮窗状态的变换与用户拖动悬浮窗滑动的速度以及是否拖动超过分割线有关。示例性的,图7中的(a)中呈现的是全屏态状态下的悬浮窗701。分割线702是为悬浮窗半屏态高度及全屏态高度之间的分割线。分割线704是为悬浮窗半屏态高度及底部态高度之间的分割线。当用户的手指将全屏态悬浮窗701向下拖动同时超过分割线702及分割线704时,悬浮窗呈现如图7中的(b)中的底部态悬浮窗703。
其中,悬浮窗的状态除了与用户是否拖动悬浮窗超过两个状态之间的中间线之外,还与用户拖动悬浮窗的速度有关。其实现如上述图5A及图5B的实现过程,在此不再赘述。
结合图8所示,具体展开描述悬浮窗从底部态切换至半屏态,继而又切换至全屏态的连续的变换实现。悬浮窗状态的变换与用户拖动悬浮窗滑动的速度以及是否拖动超过分割线有关。示例性的,图8中的(a)中呈现的是底部态状态下的悬浮窗801。图8中的(b)中,分割线802是为悬浮窗半屏态高度及底部态高度之间的分割线。当用户的手指将底部态悬浮窗801向上拖动超过分割线802时,悬浮窗呈现如图8中的(c)中的半屏态悬浮窗803。此时,用户还可以继续向上拖动半屏态悬浮窗803以呈现不同状态的悬浮窗。图8中的(d)中,分割线804是为悬浮窗半屏态高度及全屏态高度之间的分割线。当用户的手指将半屏态悬浮窗803向上拖动超过分割线804时,悬浮窗呈现如图8中的(e)中的底部态悬浮窗805。
其中,悬浮窗的状态除了与用户是否拖动悬浮窗超过两个状态之间的中间线之外,还与用户拖动悬浮窗的速度有关。其实现如上述图5A及图5B的实现过程,在此不再 赘述。
结合图9所示,具体展开描述悬浮窗从底部态直接切换至全屏态的变换实现。其实现不必经过底部态至半屏态,再由半屏态至全屏态的过程,而是根据用户的操作,直接从底部态切换至全屏态。悬浮窗状态的变换与用户拖动悬浮窗滑动的速度以及是否拖动超过分割线有关。示例性的,图9中的(a)中呈现的是底部态状态下的悬浮窗901。分割线902是为悬浮窗半屏态高度及底部态高度之间的分割线。分割线904是为悬浮窗半屏态高度及全屏态高度之间的分割线。当用户的手指将底部态悬浮窗701向上拖动同时超过分割线902及分割线904时,悬浮窗呈现如图9中的(b)中的底部态悬浮窗903。
其中,悬浮窗的状态除了与用户是否拖动悬浮窗超过两个状态之间的中间线之外,还与用户拖动悬浮窗的速度有关。其实现如上述图5A及图5B的实现过程,在此不再赘述。
以下参考图10A及图10B描述本申请实施方式中用户连续复制的场景。示例性的,以下描述也将展开描述本申请实施方式中不抢占焦点的非模态的悬浮窗的实现方式。
结合图10A所示,图10A中的(a)中悬浮窗1001呈现半屏态。图10A中的(b)中,悬浮窗外区域1002为手机屏幕中除了悬浮窗1001之外的区域。如前文所述,由于本申请实施方式中的悬浮窗不抢占当前应用的焦点,用户仍然能够滑动当前应用的原文,因而,当悬浮窗外区域1002检测到用户的触摸或点击操作时,判断用户此时的意图是浏览当前应用的原文而不是翻译,悬浮窗显示如图10A中的(c)中的底部态,从而用户可以浏览当前应用的原文。当用户需要继续翻译新的单词时,如图10A中的(d)所示,用户选中单词“development”后,弹出选项栏1004,该选项栏1004至少包括例如“复制”的操作选项。手机在监听到剪切板中的内容变化后,则会触发识别用户复制文本的意图。应理解,在用户执行对文本的复制操作后,复制的文本则会被存入剪切板中,从而剪切板中的内容会发生变化。因此,剪切板中的内容变化后,也即用户输入复制操作后。用户点击“复制”选项后,手机试图识别用户复制文字后的意图,因而弹出如图10A中的(e)所示的半屏态悬浮窗1005,展示“development”的翻译结果。悬浮窗1005显示的翻译结果包括用户复制的待查询的英文单词“development”以及该单词的中文释义的翻译结果,即“发展”。悬浮窗1005还显示其他额外的内容,其内容如图3中的(d)中显示悬浮窗304显示的内容,在此不再赘述。示例性的,悬浮窗1005显示的初始状态为半屏态,大小约占据一半的手机屏幕。示例性的,由于悬浮窗1005的显示,可以同时显示悬浮球,也可以不显示悬浮球,以达到更好的用户体验。
需要说明的是,图10A中的(b)中当悬浮窗外区域1002检测到用户的触摸或点击操作时,判断用户此时的意图是浏览当前应用的原文而不是翻译,悬浮窗显示如图10A中的(c)中的底部态,从而用户可以浏览当前应用的原文。具体而言,通过监听用户在悬浮窗外区域1002的触摸或点击操作,从而触发了ACTION_OUTSIDE事件,从而中半屏态转而显示底部态,此过程与用户操作当前应用的原文不冲突。
需要说明的是,图10A中的(b)中不抢占焦点的悬浮窗1001也被成为非模态对话框,其优点在于不抢占窗口的焦点,用户在使用本申请实施方式的悬浮窗时,通过 触摸或点击悬浮窗外区域即可将悬浮窗返回底部态,从而继续浏览当前应用的内容,提高用户的体验。也就是说,如果图10A中的(b)中悬浮窗1001的焦点没有如本申请实施方式中做过处理,即如果该悬浮窗是模态的对话框,悬浮窗1001将抢占当前阅读应用的焦点,用户必须关闭悬浮窗后,才能继续浏览阅读应用的原文。如此,用户每完成一次翻译后,用户需要关闭翻译结果(第1步操作),再次选中新的文本(第2步操作)并复制(第3步操作),而后再次点击翻译功能的快捷入口(第4步操作)才能完成下一次翻译,即至少4步操作才能完成下一次翻译。从而导致连续翻译的过程十分复杂。
模态对话框是指当其显示时,程序会暂停执行,直到关闭这个模态对话框后,才能继续执行程序中其他任务,如单击确定、取消、关闭按钮等将该对话框关闭。
当非模态对话框显示时,允许转而执行程序中其他任务,而不用关闭这个对话框。
如前文所述,在本申请实施方式中,悬浮窗的窗口属性被设置为
FLAG_NOT_TOUCH_MODAL,因而在此模式下,系统会将当前窗口区域以外的触摸/点击事件传递给底层的窗口,当前窗口区域以内的单击事件则当前窗口处理。继续以图10A中的(b)为例,当手机检测到在悬浮窗外区域1002的触摸或点击事件时,将窗口传递给当前的阅读应用,进而用户可以继续浏览当前阅读应用的页面。当手机检测到在悬浮窗区域1001的触摸或点击事件时,则继续由悬浮窗1001处理用户的触摸或点击事件。
结合图10B所示,示例性的,在连续翻译的场景下,当悬浮窗1001处于如图10B中的(a)半屏态时,用户仍然可以继续触发复制翻译操作。区别于上述图10A中的(a)至图10A中的(e)中的连续复制场景下,当用户在图10A中的(d)中复制一个新的文本时,悬浮窗1003呈现底部态。在图10B的连续复制场景下,悬浮窗1001始终处于半屏态。
当用户需要继续翻译新的单词时,如图10B中的(b)所示,用户选中单词“development”后,弹出选项栏1006,该选项栏1006至少包括例如“复制”的操作选项,悬浮窗1001保持半屏态。手机在监听到剪切板中的内容变化后,则会触发识别用户复制文本的意图。应理解,在用户执行对文本的复制操作后,复制的文本则会被存入剪切板中,从而剪切板中的内容会发生变化。因此,剪切板中的内容变化后,也即用户输入复制操作后。用户点击“复制”选项后,手机试图识别用户复制文字后的意图,因而展示如图10B中的(c)所示的半屏态悬浮窗1007,展示“development”的翻译结果。悬浮窗1007展示的翻译结果内容与图10A中的(e)所示的半屏态悬浮窗1005一致,在此不再赘述。
应注意,上述描述仅说明了两次连续翻译的过程,若存在两次以上的连续翻译的需求,手机可以重复执行图10A及图10B的过程,以完成两次以上的连续翻译。
如此,在一次翻译完成后,手机响应于用户对相同或不同文本的连续复制的操作,可以直接触发另一次翻译。如悬浮窗为如图10A中的(d)中底部态,则将其显示至如图10A中的(e)的半屏态,显示新的文本的翻译结果。如悬浮窗为如图10B中的(a)中半屏态,则直接在半屏态显示新的文本的翻译结果。也就是说,相较于常规技术,本申请方案在多次连续翻译的过程中,只要悬浮窗未被关闭,则在用户复制新的文本 后,就可直接触发手机翻译该新的文本并显示翻译结果。而无需用户在复制新的文本后再次手动触发翻译。从而可以提升连续翻译的快捷性。
结合图11所示,图11中的(a)中的悬浮窗1101呈现全屏态。悬浮窗外区域1102为手机屏幕中除了悬浮窗1101之外的区域。如前文所述,由于本申请实施方式中的悬浮窗不抢占当前应用的焦点,用户仍然能够滑动当前应用的原文,因而,当悬浮窗外区域1102检测到用户的触摸或点击操作时,判断用户此时的意图是浏览当前应用的原文而不是翻译,悬浮窗显示如图11中的(b)中的底部态,从而用户可以浏览当前应用的原文。其实现方式如图10A中的(b),在此不再赘述。
参考图12所示,为了增加细腻的滑动效果,通过设置窗口属性FLAG_LAYOUT_NO_LIMIT以实现预先加载翻译结果内容的效果。NO_LIMIT代表可以在屏幕之外绘制内容,在拖动悬浮窗时直接显示该内容。当悬浮窗1201显示如图12中的(a)中的半屏态时,悬浮窗底部在屏幕之外额外绘制了悬浮窗底部区域1202,该区域用于提前预加载悬浮窗1201的剩余翻译内容,悬浮窗底部区域1202在悬浮窗半屏态下对用户不可见。如图12中的(b),当用户将悬浮窗1201由半屏态拖动至如图12中的(c)全屏态时,由于已经提前在悬浮窗底部在屏幕之外额外绘制了悬浮窗底部区域1202,不需要额外绘制悬浮窗1201外剩余翻译内容的绘制,从而使用户在拖动悬浮窗的过程中不会出现锯齿、跳动等效果,显示效果更加细腻,提高了用户体验。
参考图13所示,如图13中的(a)所示全屏态的悬浮窗时,用户可以拖动悬浮窗内的翻译结果内容,从而获得更多更完整的翻译结果内容。如图13中的(a)至图13中的(b)至如图13中的(c)所示的翻译结果内容为一个递进关系,即根据用户的滑动操作,悬浮窗内显示更多的翻译结果内容。
如前文所述,由于本申请实施方式中所涉及的悬浮球及悬浮窗为系统窗口,不具备activity的功能,因而悬浮窗内的页面不具备滑动功能。
在安卓的架构中,窗口的触摸/点击事件和oninterceptTouch事件是由viewglobal事件来拦截。Viewglobal用于展示给用户显示的视图是单个或整个view,其由ouinterceptTouch来控制。当手机接收到一个触摸/点击事件后,由outouch事件判断是触摸/点击在悬浮窗内或这悬浮窗外区域。本申请的实施方式中,为了实现上述悬浮窗的滑动效果,需要重写窗口管理器内容容器的ontouch和oninterceptTouch事件,控制滑动和具体的事件分发。
为了获得类似于应用窗口内的activity的效果,即使得用户可以在悬浮窗内实现滑动效果,需要额外设计一套滑动逻辑实现。当判断触摸/点击在悬浮窗内区域时,额外增加悬浮窗内区域的滑动逻辑实现,即子view,以便于用于在悬浮窗内通过滑动展示更多的翻译结果内容。具体包括:
a.监听用户在手机屏幕上的触摸事件;
b.监听用户在屏幕上手指的滑动事件,如果检测到滑动事件且判断子view不需要滑动,则判断悬浮窗滑动;如果检测到滑动事件且判断子view需要滑动,则由子view处理滑动事件;
c.根据用户手指在屏幕上的偏移量更新悬浮窗位置;
d.当用户手指离开屏幕时,处理悬浮窗滑动结果;
可选的,此处悬浮窗内区域的滑动相同或不同于前文悬浮窗的底部态半屏态及全屏态的滑动逻辑实现。
参考图14所示,为手机屏幕在翻转状态,即横屏模式,的悬浮窗展示形态。不同于前述图1至图13的手机在竖屏状态悬浮窗具有底部态、半屏态及全屏态的3种呈现方式,示例性的,在横屏模式下,悬浮窗具有底部态1401及全屏态1403两种呈现方式。分割线1402是为悬浮窗底部态高度及全屏态高度之间的分割线。当用户的手指将如图14中的(a)底部态悬浮窗1401向上拖动超过分割线1402时,悬浮窗呈现如图14中的(b)中的全屏态悬浮窗1403。其触发方式如图1至图4B的表述,其滑动逻辑及实现如图5A至图9的表述,在此不再赘述。
参考图15所示,为手机屏幕在翻转状态,即横屏模式,本申请实施方式中不抢占焦点的非模态的悬浮窗。其实现方式如前文中图10A至图11的表述,在此不再赘述。
其中,横屏状态的悬浮窗也具备竖屏状态下悬浮窗如图10A至图11的非模态对话框,其也可以实现如图10A至图11的连续复制,其也具备如图12的悬浮窗内滑动及预先加载翻译结果内容的效果,上述实现的具体描述同前述竖屏状态,在此不再赘述。
其中,悬浮窗外区域1502为手机屏幕中除了悬浮窗之外的区域。示例性的,在横屏状态下,其为竖屏状态下顶部的状态栏区域。如前文所述,由于本申请实施方式中的悬浮窗不抢占当前应用的焦点,用户仍然能够滑动当前应用的原文,因而,当悬浮窗外区域1502检测到用户的触摸或点击操作时,判断用户此时的意图是浏览当前应用的原文而不是翻译,悬浮窗由图15中的(a)的全屏态显示为如图15中的(b)中的底部态,从而用户可以浏览当前应用的原文。
可选的,在横屏状态下,悬浮窗在底部态和全屏态的横向最大宽度应不与竖屏状态下顶部的状态栏区域重叠,即横屏状态下的悬浮窗的横向宽度可设计为不占满整个横屏状态下屏幕的宽度,为用户预留状态栏区域的操作,以提高用户体验。
参考图16所示,为本申请实施方式中的实现流程图,具体包括:
S1601:用户触发复制事件。
S1602:电子设备判断满足翻译条件。
S1603:电子设备显示悬浮球。
S1604:用户点击悬浮球。
S1605:悬浮窗显示半屏态。
S1606-S1607:根据用户的不同操作,悬浮窗在底部态S1607、半屏态S1605及全屏态S1607之间转换。
上述实现流程在前文已有描述,具体参见图1至图15的描述,在此不再赘述。
参考图17所示,为本申请实施方式中的逻辑实现流程图,具体包括:
S1701:业务逻辑处理模块向情境感知模块发出订阅复制围栏的指令。
S1702:情境感知模块向剪切板管理器发出监控复制围栏的指令。
S1703:剪切板管理器监听复制事件。
示例性的,当手机在监听到剪切板中的内容变化后,则会触发识别用户复制文本的意图。应理解,在用户执行对文本的复制操作后,复制的文本则会被存入剪切板中,从而剪切板中的内容会发生变化。
S1704:用户触发复制事件,由剪切板管理器感知剪切板中的内容变化。
示例性的,在需要翻译的场景下,用户在打开的当前应用的页面复制文本,监听到剪切板中的内容变化后,则会触发识别用户复制文本的意图。
示例性的,在本申请实施方式中,主要以复制操作为例,来触发手机识别意图。但是实际实施时,并不以此为限。例如,也可以以对文本的选中操作、长按操作、划线操作、双击操作等操作触发手机识别意图。
S1705:情境感知模块监听剪切板事件。
S1706:剪切板管理器向情境感知模块发送剪切板内容。
示例性的,剪切板管理器保存用户最近一次复制的文本并将其发送至情境感知模块,该内容包括复制的文本以及从具体的哪个应用获取的复制文本,即复制文本的应用来源。在安卓提供的架构中,剪切板管理器本身并不具备识别复制文本的应用来源,
S1707:情境感知模块从剪切板管理器获取用户复制的文本,从剪切板内容中获取应用包名。
示例性的,情境感知模块从剪切板内容中识别复制文本的应用来源。
S1708:情境感知模块向业务逻辑处理模块发送剪切板内容及应用包名。
S1709:业务逻辑处理模块根据接收到的剪切板内容及应用包名,判断是否满足翻译条件。
示例性的,业务逻辑处理模块判断是否满足翻译条件,包括:
a.判断复制的文本中是否包含手机当前的非系统语言。手机复制的文本是否触发执行翻译与系统设置的默认语言及复制文本的语言有关。例如,当手机中系统设置的默认语言是简体中文时,可以包括如下组合的任何一种则可以被视为满足翻译条件:
第一种组合:复制的文本同时包括系统语言及非系统语言文本。例如当复制的文本中同时包括中文及法文时,由于手机识别到复制的文本中包括非中文的法文文本,因而,用户复制文本后,仍然会触发执行翻译的操作;
第二种组合:复制的文本为应用程序本身设置的非系统语言的文本。例如当前应用设置的应用语言为英文时,当用户复制该应用中的英文文本时,由于手机识别到复制的文本中包括非中文的文本,因而,用户复制文本后,仍然会触发执行翻译的操作;
第三种组合:复制的文本为用户输入的非系统语言的文本。例如在聊天应用或备忘录等用户可以手动输入文本的应用中,用户选中并复制一段用户输入的英文文本,由于手机识别到复制的文本中包括非中文的文本,因而,用户复制文本后,仍然会触发执行翻译的操作;
b.判断复制的文本中包含的非系统语言是否为手机系统支持的预设语言。例如若用户复制的非系统语言文本,例如俄罗斯语,不是手机系统本身支持的预设语言,则不满足翻译条件;
c.判断复制的文本是否符合一定的文本类型。例如不是网址链接、邮箱或者利用机器生成的口令(如淘宝口令)等具有特定含义的字符串,则判断满足翻译条件;
d.判断复制的文本的来源应用是否满足一定的应用类型。例如该应用不是翻译应用等单独的专业性翻译应用,或者不是淘宝、抖音等购物娱乐类应用,则判断满足翻译条件;
需要说明的是,以上罗列的判断条件abcd可以同时满足,也可以满足其中的任何一种或多种,本申请的实施方式在此不做限定。
S1710:当判断满足翻译条件时,业务逻辑处理模块向翻译服务器发送剪切板内容,用以请求翻译结果。
示例性的,手机端负责将获取的用户复制的文本通过翻译服务器获取翻译结果内容,该翻译服务器可以是第三方的专业性翻译服务提供商,也可以是手机端厂商提供的翻译服务器,本申请的实施方式在此不做限定。
示例性的,手机端也可以向手机端内安装的翻译应用或手机端系统内置的翻译词典获取翻译结果内容,从而不用通过云端服务,可以实现不联网的状态下脱机实现翻译的功能。
S1711:当判断满足翻译条件时,业务逻辑处理模块向业务呈现模块发出通知显示悬浮球的指令。
示例性的,业务呈现模块用于协调窗口管理器在手机界面呈现悬浮球及悬浮窗。
S1712:业务呈现模块向窗口管理器发出显示悬浮球的指令。
S1713:窗口管理器向业务呈现模块返回显示悬浮球的指令。
示例性的,窗口管理器负责协调构建悬浮球的显示,其需要与业务呈现模块相互配合。
S1714:翻译服务器向业务逻辑处理模块发送翻译结果内容。
S1715:业务呈现模块显示悬浮球。
S1716:用户触发点击悬浮球事件。
示例性的,在业务呈现模块显示悬浮球时,业务逻辑处理模块中已有用户复制文本对应的翻译结果内容。因而,当用户需要显示翻译结果内容时,即触摸或点击悬浮球,即可显示翻译结果。
S1717:业务逻辑处理模块判断显示翻译结果。
示例性的,业务逻辑处理模块根据用户的触摸或点击悬浮球事件,判断是否显示已接收到的翻译结果内容。如果判断显示翻译结果内容,则判断显示悬浮窗。
S1718:当判断显示翻译结果时,业务逻辑处理模块向业务呈现模块发出通知显示悬浮窗的指令。
示例性的,可选的,悬浮窗与悬浮球可以同时显示,也可以显示二者中的一者。
S1719:业务呈现模块向窗口管理器发出显示悬浮窗的指令。
S1720:窗口管理器向业务呈现模块返回显示悬浮窗的指令。
S1721:业务逻辑处理模块向业务呈现模块发出显示翻译结果的指令。
S1722:业务呈现模块显示悬浮窗及翻译结果。
示例性的,本申请实施方式悬浮窗,根据占据屏幕的高度的不同,分为3种形态,即底部态,半屏态及全屏态。三种形态的悬浮窗之间根据用户的操作,可以互相切换。
示例性的,悬浮窗为非模态对话框,在悬浮窗显示的状态下,用户可以实现复制 文本的连续复制,而无需用户在复制新的文本后再次关闭悬浮窗并手动触发翻译。
示例性的,本申请实施方式悬浮窗不抢占窗口的焦点,用户在使用本申请实施方式的悬浮窗时,通过触摸或点击悬浮窗外区域即可将悬浮窗返回底部态,从而继续浏览当前应用的内容,而无需关闭悬浮窗。
S1723:用户触发触摸或点击悬浮窗外区域的事件。
S1724:业务呈现模块向窗口管理器发出显示底部态悬浮窗的指令。
S1725:窗口管理器向业务呈现模块返回显示底部态悬浮窗的指令。
S1726:业务呈现模块显示底部态悬浮窗。
参考图18所示,为本申请的另一种实施方式,其实现方式与上述图1至图17的实现方式一致,示例性的,区别包括:
第一,在图18中的(a)中,用户选中文本后,选项栏1801至少包括例如“翻译”的操作选项。而在前述图3中的(a)中,选项栏301包括“复制”选项,其用于手机在监听到剪切板中的内容变化后,则会触发识别用户复制文本的意图。在图18中的(a)中,由于“翻译”这个选项直接说明用户需要翻译文本的意图,因而其可用于直接触发执行翻译的操作。
第二,在用户选择点击选项栏1801中“翻译”的选项后,手机直接显示图18中的(b)中的悬浮窗1802。悬浮窗1802与图3中的(d)中显示的悬浮窗304相同,展示与其相同的翻译结果。可选的,悬浮窗的初始状态为半屏态,其也可以是底部态或全屏态。
第三,由于用户选择点击选项栏1801中“翻译”的选项后手机直接显示悬浮窗1802,因而,在本申请该实施方式中,示例性的,不会显示例如图3中的(b)中所示的悬浮球标识302、如图3中的(c)中的第一状态的悬浮球303以及如图4A中的(b)中第二状态的悬浮球402。
参考图19所示,为本申请的另一种实施方式,其实现方式与上述图1至图18的实现方式一致。示例性的,图19的实施方式中,图19中的(a)中,选项栏1901同时包括“复制”及“翻译”选项,其区别于图3中的(a)中,选项栏301包括“复制”选项,图18中的(a)中,选项栏1801至少包括例如“翻译”的操作选项。因而,在本申请图19的实施方式中,同时具备图1至图17及图18的实现方式,即用户既可以通过图1至图17的“复制”的实现方式触发执行翻译,也可以通过图18的“翻译”的实现方式触发翻译。因而,用户可以灵活根据用户偏好选择二者之中的一者或二者。
示例性的,以用户通过图1至图17“复制”的方式触发执行翻译为例。图19中的(a)所描述的是用户在执行图3中的(a)的方式“复制”“patent”这个单词触发执行翻译,经过图3中的(b)及图3中的(c)的实现后,用户因未在预设时间点击悬浮球303,因而手机界面展示图4A中的(b)的界面。若用户此时需要执行翻译,例如用户需要翻译“development”这个单词,可选的,包括如下方式:
第一,用户可以触摸或点击悬浮球1902以触发执行翻译,在图19中的(b)中的悬浮窗1903中显示对应的翻译结果内容。应注意,悬浮球1902的实现方式对应于图4A的悬浮球402,悬浮窗1903的实现方式同前述图1至图18;或者
第二,用户可以触摸或点击选项栏1901中“翻译”选项,在图19中的(b)中的 悬浮窗1903中显示对应的翻译结果内容。应注意,“翻译”选项触发执行翻译的实现方式同图18,悬浮窗1903的实现方式同前述图1至图18。
以上所述,仅为本发明的具体实施方式,任何熟悉本技术领域的技术人员在本发明揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本发明的保护范围之内。本发明的保护范围应以所述权利要求的保护范围为准。
Claims (41)
- 一种翻译方法,包括电子设备及应用程序,其特征在于,包括:显示所述应用程序的第一界面,所述第一界面包括第一文本及第一悬浮球控件;响应于用户对所述第一文本的第一操作,显示第一控件,所述第一控件包括复制选项及翻译选项;响应于用户对所述复制选项的复制操作,所述第一文本被写入所述电子设备的剪切板,在所述复制操作后,响应于用户对所述第一悬浮球控件的悬浮球操作,在所述第一界面显示悬浮窗,其中,所述悬浮窗包括所述第一文本及所述第一文本对应的第一译文,所述悬浮窗显示第一状态;响应于用户对所述第一文本的第二操作,显示所述第一控件;响应于用户对所述翻译选项的翻译操作,在所述第一界面显示所述悬浮窗,所述悬浮窗显示第二状态,所述第二状态与所述第一状态相同或不同。
- 根据权利要求1所述的翻译方法,其特征在于:所述复制选项还可以被替换成剪切选项。
- 根据权利要求1所述的翻译方法,其特征在于:所述第一文本不包括网址、邮箱或利用机器生成的口令,所述第一文本与所述电子设备的系统语言不同。
- 根据权利要求1所述的翻译方法,其特征在于:所述应用程序不包括消费类、娱乐类或视频类应用。
- 根据权利要求1所述的翻译方法,其特征在于:所述第一操作包括对所述第一文本的选中操作、触摸操作、点击操作、滑动操作、长按操作或双击操作中的任意一种,所述第二操作包括对所述第一文本的选中操作、触摸操作、点击操作、滑动操作、长按操作或双击操作中的任意一种。
- 根据权利要求1所述的翻译方法,其特征在于:还包括在所述第一界面显示悬浮窗后,所述第一界面不显示所述第一悬浮球控件和/或所述第一控件。
- 根据权利要求1所述的翻译方法,其特征在于:所述悬浮窗的所述第一状态包括底部态、半屏态或全屏态中的任意一种,所述悬浮窗的所述第二状态包括底部态、半屏态或全屏态中的任意一种。
- 根据权利要求1所述的翻译方法,其特征在于:在显示所述悬浮窗后,所述第一界面还包括第一区域,所述第一区域为所述第一界面中除所述悬浮窗之外的区域。
- 根据权利要求8所述的翻译方法,其特征在于:响应于用户对所述第一区域的第三操作,所述悬浮窗显示第三状态,所述第三状态包括底部态、半屏态或全屏态中的任意一种,所述第三状态与所述第一状态相同或不同,所述第三状态与所述第二状态相同或不同。
- 根据权利要求9所述的翻译方法,其特征在于:所述第三操作包括对所述第一区域的触摸操作、点击操作、滑动操作或长按操作中的任意一种。
- 根据权利要求9所述的翻译方法,其特征在于:所述第一界面还包括第二文本,响应于用户对所述第二文本的第四操作,显示所述第一控件,其中,所述第四操作包括对所述第二文本的选中操作、触摸操作、点击操作、滑动操作、长按操作或双击操作中的任意一种,所述第二文本与所述第一文本相同或不同,所述第二文本不包 括网址、邮箱或利用机器生成的口令,所述第二文本与所述电子设备的系统语言不同。
- 根据权利要求11所述的翻译方法,其特征在于:响应于用户对所述复制选项的复制操作,所述第二文本被写入所述电子设备的剪切板,在所述第一界面显示悬浮窗,所述悬浮窗显示第四状态,所述悬浮窗包括所述第二文本及所述第二文本对应的第二译文,所述悬浮窗不包括所述第一文本及所述第一译文,所述第四状态与所述第三状态相同或不同。
- 根据权利要求11所述的翻译方法,其特征在于:响应于用户对所述翻译选项的翻译操作,在所述第一界面显示所述悬浮窗,所述悬浮窗显示第五状态,所述悬浮窗包括所述第二文本及所述第二文本对应的第二译文,所述悬浮窗不包括所述第一文本及所述第一译文,所述第五状态与所述第三状态相同或不同。
- 根据权利要求1所述的翻译方法,其特征在于:所述悬浮窗是可滑动的,所述悬浮窗包括底部态、半屏态或全屏态中的任意一种或多种,所述悬浮窗在所述底部态、所述半屏态或所述全屏态中的任意一种或多种之间滑动。
- 根据权利要求14所述的翻译方法,其特征在于:响应于用户对所述悬浮窗在所述第一状态的第一滑动操作,判断所述滑动操作满足滑动条件后,所述悬浮窗显示第六状态,所述第六状态与所述第一状态不同,所述第六状态包括底部态、半屏态或全屏态中的任意一种;判断所述滑动操作不满足滑动条件后,所述悬浮窗显示第七状态,所述第七状态与所述第一状态相同,所述第七状态包括底部态、半屏态或全屏态中的任意一种。
- 根据权利要求14所述的翻译方法,其特征在于:响应于用户对所述悬浮窗在所述第二状态的第二滑动操作,判断所述滑动操作满足滑动条件后,所述悬浮窗显示第八状态,所述第八状态与所述第二状态不同;判断所述滑动操作不满足滑动条件后,所述悬浮窗显示第九状态,所述第九状态与所述第二状态相同,所述第八状态包括底部态、半屏态或全屏态中的任意一种,所述第九状态包括底部态、半屏态或全屏态中的任意一种。
- 根据权利要求15或16所述的翻译方法,其特征在于:所述滑动条件包括满足滑动距离、滑动速度、滑动方向中的任意一者或多者。
- 根据权利要求17所述的翻译方法,其特征在于:判断所述滑动距离满足条件包括判断所述滑动距离大于所述电子设备屏幕高度四分之一。
- 根据权利要求18所述的翻译方法,其特征在于:还包括,若所述滑动距离大于所述电子设备屏幕高度四分之一且小于屏幕高度四分之三时,所述悬浮窗在所述底部态及所述半屏态或所述半屏态及所述全屏态之间切换;若所述滑动距离大于所述电子设备屏幕高度四分之三时,所述悬浮窗在所述底部态及所述全屏态之间切换。
- 根据权利要求14所述的翻译方法,其特征在于:还包括,所述悬浮球在所述半屏态滑动至所述全屏态前,预加载所述第一译文对应的第一详细译文,所述第一详细译文包括所述第一译文显示在所述全屏态的悬浮窗内且未显示在所述半屏态的所述悬浮窗内的内容。
- 根据权利要求20所述的翻译方法,其特征在于:所述悬浮窗还包括第一内部窗口,所述第一内部窗口包括所述第一译文和/或所述第一详细译文。
- 根据权利要求21所述的翻译方法,其特征在于:还包括,所述第一内部窗口是可滑动的,用于显示所述第一译文对应的内容。
- 根据权利要求22所述的翻译方法,其特征在于:当所述悬浮窗处于全屏态时,响应于用户对数第一内部窗口的第二滑动操作,所述第一内部窗口显示第二详细译文,所述第二详细译文包括部分所述第一详细译文。
- 根据权利要求1所述的翻译方法,其特征在于:在显示包括所述第一悬浮球控件的所述应用程序的所述第一界面前,还包括:所述第一界面还包括第三文本,响应于用户对所述第三文本的第五操作,所述第一界面显示第二控件,其中,所述第五操作包括对所述第三文本的选中操作、触摸操作、点击操作、滑动操作、长按操作或双击操作中的任意一种,所述第三文本与所述第一文本相同或不同,所述第三文本不包括网址、邮箱或利用机器生成的口令,所述第三文本与所述电子设备的系统语言不同。
- 根据权利要求24所述的翻译方法,其特征在于:所述第二控件中的选项包括复制选项或剪切选项。
- 根据权利要求25所述的翻译方法,其特征在于:响应于用户对所述第二控件的第六操作,所述第一界面显示第二悬浮球控件,所述第六操作包括对所述第二控件的所述复制选项的复制操作或对所述剪切选项的剪切操作中的任意一种。
- 根据权利要求26所述的翻译方法,其特征在于:还包括,响应于用户对所述第二悬浮球控件的第七操作,显示所述悬浮窗,所述悬浮窗包括所述第三文本及所述第三文本对应的第三译文,所述第七操作包括触摸操作、点击操作或长按操作中的任意一种。
- 根据权利要求26所述的翻译方法,其特征在于:还包括,在显示所述第二悬浮球控件前,显示悬浮球标识,且在第一预设时间后,所述悬浮球标识消失,显示所述第二悬浮球控件。
- 根据权利要求28所述的翻译方法,其特征在于:所述悬浮球标识用于判断所述第六操作满足翻译条件,所述翻译条件包括所述第三文本的语言类型、所述第三文本的内容或所述应用程序的类型中的任意一者或多者。
- 根据权利要求26所述的翻译方法,其特征在于:所述第二悬浮球控件与所述第一悬浮球控件在所述应用程序的所述第一界面显示在所述电子设备的所述第一界面的相同的一侧,二者所述相同一侧显示的位置相同或不同。
- 根据权利要求26所述的翻译方法,其特征在于:还包括,判断在第二预设时间内未检测到用户对所述第二悬浮球控件的触摸操作、点击操作、滑动操作或长按操作中的任意一种,取消显示所述第二悬浮球控件,显示所述第一悬浮球控件。
- 根据权利要求31所述的翻译方法,其特征在于:响应于用户对所述第一悬浮球控件的第八操作,在所述第一界面显示悬浮窗,其中,所述悬浮窗包括所述第三文本及所述第三文本对应的第三译文,所述第八操作包括触摸操作、点击操作或长按操作中的任意一种。
- 根据权利要求31所述的翻译方法,其特征在于:所述第一界面还包括第四文本,若所述第一界面显示所述第一悬浮球控件,响应于用户对所述第四文本的第九操作,所述第一界面显示所述第二控件,响应于用户对所述第二控件的第十操作,所述 第一界面继续显示所述第一悬浮球控件,其中,所述第九操作包括对所述第四文本的选中操作、触摸操作、点击操作、滑动操作、长按操作或双击操作中的任意一种,所述第十操作包括对所述第二控件的所述复制选项的复制操作或对所述剪切选项的剪切操作中的任意一种,所述第四文本与所述第三文本相同或不同,所述第四文本不包括网址、邮箱或利用机器生成的口令,所述第四文本与所述电子设备的系统语言不同。
- 根据权利要求33所述的翻译方法,其特征在于:响应于用户对所述第一悬浮球控件的第十一操作,在所述第一界面显示悬浮窗,其中,所述悬浮窗包括所述第四文本及所述第四文本对应的第四译文,所述第十一操作包括对所述第一悬浮球控件的触摸操作、点击操作或长按操作中的任意一种。
- 根据权利要求1-34中任一项所述的翻译方法,其特征在于:所述悬浮窗为系统窗口,所述系统窗口与所述应用程序的应用窗口不同。
- 根据权利要求1-34中任一项所述的翻译方法,其特征在于:所述悬浮窗为非模态对话框,当所述第一界面显示所述悬浮窗时,所述第一界面或所述悬浮窗中的任意一者是可滑动的。
- 根据权利要求1-34中任一项所述的翻译方法,其特征在于:所述悬浮窗的窗口属性被设置为包括FLAG_NOT_TOUCH_MODAL,所述悬浮窗不与所述应用程序的所述第一界面抢占窗口焦点,包括:当所述第一界面显示所述悬浮窗时,若所述第一界面被滑动,所述悬浮窗不消失,响应于所述悬浮窗被滑动,所述第一界面不消失;若所述悬浮窗被滑动,所述第一界面不消失,响应于所述第一界面被滑动,所述悬浮窗不消失。
- 根据权利要求1-34中任一项所述的翻译方法,其特征在于:当所述悬浮窗被关闭时,所述第一界面显示所述第一悬浮球控件。
- 一种电子设备,其特征在于,所述电子设备包括用于存储计算机程序指令的存储器和用于执行程序指令的处理器,其中,当该计算机程序指令被该处理器执行时,触发所述电子设备执行权利要求1-38中任一项所述的方法。
- 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质中存储有计算机程序,当其在计算机上运行时,使得计算机执行权利要求1-38中任一项所述的方法。
- 一种计算机程序产品,其特征在于,所述计算机程序产品包括计算机程序,当其在计算机上运行时,使得计算机执行权利要求1-38中任一项所述的方法。
Priority Applications (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
US18/004,797 US20240127007A1 (en) | 2021-09-02 | 2022-08-18 | Translation Method and Electronic Device |
EP22839626.3A EP4170476A4 (en) | 2021-09-02 | 2022-08-18 | TRANSLATION METHOD AND ELECTRONIC DEVICE |
Applications Claiming Priority (4)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111028829 | 2021-09-02 | ||
CN202111028829.9 | 2021-09-02 | ||
CN202210023045.5A CN115756269A (zh) | 2021-09-02 | 2022-01-10 | 翻译方法及电子设备 |
CN202210023045.5 | 2022-01-10 |
Publications (2)
Publication Number | Publication Date |
---|---|
WO2023030030A1 WO2023030030A1 (zh) | 2023-03-09 |
WO2023030030A9 true WO2023030030A9 (zh) | 2023-08-31 |
Family
ID=85348991
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2022/113390 WO2023030030A1 (zh) | 2021-09-02 | 2022-08-18 | 翻译方法及电子设备 |
Country Status (4)
Country | Link |
---|---|
US (1) | US20240127007A1 (zh) |
EP (1) | EP4170476A4 (zh) |
CN (1) | CN115756269A (zh) |
WO (1) | WO2023030030A1 (zh) |
Families Citing this family (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN117270720A (zh) * | 2023-04-28 | 2023-12-22 | 荣耀终端有限公司 | 一种页面显示方法及电子设备 |
CN116204093B (zh) * | 2023-04-28 | 2023-10-20 | 荣耀终端有限公司 | 一种页面显示方法及电子设备 |
Family Cites Families (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102722479B (zh) * | 2011-03-30 | 2015-11-04 | 腾讯科技(深圳)有限公司 | 一种实现语言翻译的方法及装置 |
US20150227509A1 (en) * | 2014-02-13 | 2015-08-13 | Kobo Inc. | Providing translation of a text item from a displayed portion of text content |
CN107153541B (zh) * | 2017-04-20 | 2020-07-03 | 北京小米移动软件有限公司 | 浏览交互处理方法及装置 |
CN107943796B (zh) * | 2017-11-17 | 2022-03-04 | 珠海市魅族科技有限公司 | 一种翻译方法和装置、终端、可读存储介质 |
CN108415752A (zh) * | 2018-03-12 | 2018-08-17 | 广东欧珀移动通信有限公司 | 用户界面显示方法、装置、设备及存储介质 |
CN108595445A (zh) * | 2018-04-23 | 2018-09-28 | Oppo广东移动通信有限公司 | 翻译方法、装置及终端 |
CN110166586B (zh) * | 2019-04-18 | 2021-01-08 | 维沃移动通信(深圳)有限公司 | 一种内容显示方法及终端设备 |
CN110442879B (zh) * | 2019-04-30 | 2024-02-13 | 华为技术有限公司 | 一种内容翻译的方法和终端 |
CN112183121B (zh) * | 2019-09-20 | 2022-02-25 | 华为技术有限公司 | 机器翻译的方法和电子设备 |
-
2022
- 2022-01-10 CN CN202210023045.5A patent/CN115756269A/zh active Pending
- 2022-08-18 EP EP22839626.3A patent/EP4170476A4/en active Pending
- 2022-08-18 US US18/004,797 patent/US20240127007A1/en active Pending
- 2022-08-18 WO PCT/CN2022/113390 patent/WO2023030030A1/zh active Application Filing
Also Published As
Publication number | Publication date |
---|---|
CN115756269A (zh) | 2023-03-07 |
EP4170476A4 (en) | 2024-01-24 |
WO2023030030A1 (zh) | 2023-03-09 |
US20240127007A1 (en) | 2024-04-18 |
EP4170476A1 (en) | 2023-04-26 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US10841265B2 (en) | Apparatus and method for providing information | |
CN114467068B (zh) | 基于应用布局和用户工作流来定位用户界面组件 | |
WO2023030030A9 (zh) | 翻译方法及电子设备 | |
US10133396B2 (en) | Virtual input device using second touch-enabled display | |
WO2023088068A1 (zh) | 窗口切换方法、电子设备及可读存储介质 | |
US20210311599A1 (en) | Operation methods of a smart interactive tablet, storage medium and related equipment | |
US10122839B1 (en) | Techniques for enhancing content on a mobile device | |
JP2016048563A (ja) | ユーザインタフェースとの制限対話を設定するためのデバイス、方法及びグラフィカルユーザインタフェース | |
CN113805743A (zh) | 切换显示窗口的方法和电子设备 | |
EP3356922B1 (en) | A method for rendering a transient graphical object and an apparatus | |
WO2021135578A1 (zh) | 页面处理方法、装置、存储介质及终端设备 | |
KR20140034100A (ko) | 휴대단말과 외부 표시장치 연결 운용 방법 및 이를 지원하는 장치 | |
KR20160073714A (ko) | 전자 기기 및 이의 웹 페이지 디스플레이 방법 | |
CN114997186B (zh) | 翻译控件的控制方法及电子设备 | |
JP7476645B2 (ja) | 携帯型情報端末及びプログラム | |
CN107220377B (zh) | 搜索方法、电子设备及计算机存储介质 | |
WO2021244459A1 (zh) | 一种输入方法及电子设备 | |
CN115033153B (zh) | 应用程序推荐方法及电子设备 | |
CN114461312B (zh) | 显示的方法、电子设备及存储介质 | |
US20220004286A1 (en) | Adapted overlay help system | |
CN116149530A (zh) | 翻译方法及电子设备 | |
WO2023131312A1 (zh) | 窗口交互方法和电子设备 | |
WO2023131313A1 (zh) | 窗口交互方法和电子设备 | |
WO2023024566A1 (zh) | 一种翻译方法及电子设备 | |
WO2023231645A1 (zh) | 搜索方法、装置、电子设备和可读存储介质 |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
WWE | Wipo information: entry into national phase |
Ref document number: 18004797 Country of ref document: US |
|
ENP | Entry into the national phase |
Ref document number: 2022839626 Country of ref document: EP Effective date: 20230118 |
|
NENP | Non-entry into the national phase |
Ref country code: DE |