Method and system for preventing soft keyboard from covering input area

By monitoring click and focus change events, calculating and adjusting the page scroll height, it solves the problem of the soft keyboard covering the input area in the Android system, reduces page scrolling, and improves the user experience.

CN118732920APending Publication Date: 2024-10-01EEO EDUCATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310336774.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-03-31
Publication Date
2024-10-01

AI Technical Summary

Technical Problem

In the Android system, the soft keyboard covers the input area under certain circumstances, resulting in poor user experience. Existing technologies can avoid this through page scrolling but cause the page to continuously scroll, resulting in poor user experience.

Method used

Create a gesture detector to listen for click events and focus change events, calculate the soft keyboard height and screen height, adjust page scrolling based on the user's click position and soft keyboard height, prevent unnecessary page scrolling, and recalculate the page height when text is entered or deleted. to prevent soft keyboard coverage.

Benefits of technology

It effectively prevents the soft keyboard from covering the input area, reduces unnecessary scrolling of the page, provides a good input experience, and significantly improves the user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118732920A_ABST
    Figure CN118732920A_ABST
Patent Text Reader

Abstract

The invention provides a method and system for preventing a soft keyboard from covering an input area, and the method comprises the steps: creating a gesture detector, and monitoring a click event and a focus change event of a system; when the user clicks the page to generate a click event, acquiring position information of the user clicking the page in the click event response method; when the system evokes the soft keyboard and generates a focus change event, stopping a page scrolling behavior initiated by the system in the focus change event response method; calculating the height of a soft keyboard and the height of a screen; and according to the position of the page clicked by the user, the height of the soft keyboard and the height of the screen, calculating the scrolling height of the page, and scrolling the page. The method has the advantages that the method provided by the invention can prevent the soft keyboard from covering the input area, reduces unnecessary scrolling of the page, and provides good input experience; when a user inputs or deletes characters and causes page height change, page display can be adjusted in time, and a soft keyboard is prevented from covering an input area.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of mobile terminal development, and in particular relates to a method and a system for preventing a soft keyboard from covering an input area. Background Art

[0002] With the continuous development and popularization of mobile terminals, various mobile terminals have become necessary tools for people's lives and work, especially mobile devices equipped with Android systems have occupied the largest market share. In the Android operating system, the main way of interacting with users includes soft keyboard input. At present, when Android APP uses its web view WebView component, under certain circumstances, the web page input box component (input, textarea, etc.) in WebView will be covered by the soft keyboard after focusing, and the soft keyboard cannot lift the focused form element. In this case, although text can be input normally, the content of the input text cannot be known, resulting in a very poor user experience. It is also said that in the prior art, there is a problem that the web page input box component area is easily blocked by the soft keyboard and the information display is incomplete when it is displayed.

[0003] When circumventing this problem, the prior art often uses page scrolling to avoid covering the input area. However, since the page will scroll when the soft keyboard pops up, in order to avoid covering the input area, the prior art will cause the page to scroll twice, resulting in continuous back and forth scrolling of the page, which is a poor user experience. Summary of the invention

[0004] The purpose of the present invention is to overcome the defect of the prior art that a page scrolls back and forth when a soft keyboard covers an input area.

[0005] In order to achieve the above object, the present invention proposes a method for preventing a soft keyboard from covering an input area, the method comprising:

[0006] Step S1: Create a gesture detector to monitor the system's click events and focus change events;

[0007] Step S2: When a user clicks on a page and a click event is generated, the location information of the page clicked by the user is obtained in the click event response method;

[0008] When the system evokes the soft keyboard and generates a focus change event, the page scrolling behavior initiated by the system is prevented in the focus change event response method;

[0009] Step S3: Calculate the height of the soft keyboard and the screen height;

[0010] Step S4: Calculate the height to which the page needs to be scrolled based on the position where the user clicks the page, the height of the soft keyboard, and the screen height, and scroll the page.

[0011] As an improvement to the above method, the height that the page needs to scroll to is calculated as follows:

[0012] Use the vertical coordinate of the position where the user clicks the page plus the height of the soft keyboard, and then subtract the screen height to get the height that the page needs to scroll;

[0013] When the calculated scroll height is less than 0, set the scroll height to 0.

[0014] As an improvement to the above method, when there is a submit button below the page input area, the height of the soft keyboard is the sum of the height of the soft keyboard and the height of the submit button.

[0015] As an improvement of the above method, the method further comprises:

[0016] Step S5: When the user inputs or deletes text, causing the number of text lines on the page to change, the page height is recalculated and the page is scrolled to prevent the soft keyboard from covering the input area.

[0017] As an improvement to the above method, the recalculation of the page height and the scrolling of the page are specifically as follows:

[0018] By tracking the changes in the size of the WebView Frame border, calculate the difference between the two border height values ​​before and after entering or deleting text;

[0019] Set the page scroll distance to the difference between the two border height values.

[0020] The present invention also provides a system for preventing a soft keyboard from covering an input area, which is implemented based on any of the above methods, and the system includes:

[0021] Create a gesture detector module to create gesture detectors and monitor the system's click events and focus change events;

[0022] The response event module is used to obtain the location information of the page clicked by the user in the click event response method when the user clicks on the page to generate a click event;

[0023] It is also used to prevent the page scrolling behavior initiated by the system in the focus change event response method when the system evokes the soft keyboard and generates a focus change event;

[0024] A height calculation module for calculating the height of the soft keyboard and the screen height; and

[0025] The first page scrolling module is used to calculate the height to which the page needs to be scrolled according to the position where the user clicks the page, the height of the soft keyboard and the height of the screen, and scroll the page.

[0026] As an improvement of the above system, the system further comprises:

[0027] The second scrolling page module is used to recalculate the page height and scroll the page to prevent the soft keyboard from covering the input area when the user inputs or deletes text, causing the number of text lines on the page to change.

[0028] The present invention also provides a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements any of the above methods when executing the computer program.

[0029] The present invention also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the processor executes any of the methods described above.

[0030] Compared with the prior art, the advantages of the present invention are:

[0031] 1. The method provided in this application controls the Android system page, which can prevent the soft keyboard from covering the input area, reduce unnecessary scrolling of the page, and provide a good input experience;

[0032] 2. When the user inputs or deletes text, causing the page height to change, the page display can be adjusted in time to prevent the soft keyboard from covering the input area. BRIEF DESCRIPTION OF THE DRAWINGS

[0033] Figure 1 Shown is a flow chart of a method for preventing a soft keyboard from covering an input area;

[0034] Figure 2 Shown is a schematic diagram of page scrolling calculation for preventing the soft keyboard from covering the input area. DETAILED DESCRIPTION

[0035] The technical solution of the present invention is described in detail below with reference to the accompanying drawings.

[0036] In the Android system, there is a known issue in the WebView component, which is called AndroidBug5497 in the industry. When the user focuses on a web page to input text, the virtual keyboard will blur the input area on the web page, making it difficult for the user to see what is being typed, resulting in a poor user experience.

[0037] The present application provides a method and system for preventing a soft keyboard from covering an input area, redefines several operations of the Android WebView component, completely takes over various operating behaviors of the system, and solves the problem of covering the input area and multiple page scrolling when the soft keyboard pops up.

[0038] like Figure 1As shown, the method for preventing the soft keyboard from covering the input area specifically includes:

[0039] Step S1: Create a gesture detector to monitor the system's click events and focus change events;

[0040] By monitoring the system's click events, you can capture the user's click behavior in advance and replace the system's actions with your own actions.

[0041] Step S2: When the user clicks on a page, obtain the location information of the page clicked by the user;

[0042] When the user starts typing, the system evokes the soft keyboard and generates a focus change event. In the event response method, the scrolling behavior initiated by the system is prevented.

[0043] Step S3: Calculate the height of the soft keyboard and the height of the screen;

[0044] Step S4: Calculate the height to which the page needs to be scrolled according to the position where the user clicks the page and the height of the soft keyboard, and scroll the page;

[0045] Step S5: When the user inputs or deletes text, causing the number of text lines on the page to change, the page height is recalculated and the page is scrolled to prevent the soft keyboard from covering the input area.

[0046] As an embodiment of the present application, a method for preventing the soft keyboard from covering the input area is described in detail:

[0047] Step 1: Create a gesture detector GestureDetector and a detection listener GestureDetector.SimpleOnGestureListener, listen to the onSingleTapUp method (click event) and the FocusChange method (focus change event), capture the user's behavior in advance, and re-identify the user's click event;

[0048] Step 2: When the user clicks on the page, the MotionEvent object of the gesture event is obtained according to the position where the user clicks, and the horizontal and vertical coordinates RawX and RawY measured according to the screen are obtained according to the MotionEvent object;

[0049] Step 3: When the soft keyboard pops up and a focus change event occurs, use the androidx.recyclerview.widget.RecyclerView#stopScroll method in the method that responds to the focus change to prevent the system from automatically scrolling;

[0050] Step 4: Calculate the height of the soft keyboard and the screen height. The height of the soft keyboard is obtained by subtracting the height of the visible range after the soft keyboard pops up from the screen height. The screen height is obtained through the DecorView object. The visible height is obtained through the android.view.View#getWindowVisibleDisplayFrame method.

[0051] Step 5: Add the vertical coordinate of the click position obtained in step 2 to the height of the soft keyboard calculated in step 4, and then subtract the height of the screen to get a difference; when the input page has a submit button, the height of the soft keyboard also needs to include the height of the submit button. The submit button represents a type of button that ends the current input, such as: submit, save, confirm, finish, set, previous / next, previous / next page, continue, return, cancel, end, start, yes, no, calculate, translate, send, close, test, run, etc.

[0052] Step 6: Determine the difference calculated in step 5. If the difference is less than 0, it is considered that the user clicked outside the soft keyboard area and the page does not need to be scrolled. If the difference is greater than 0, it is considered that the user clicked on the position covered by the soft keyboard and scrolling is required to avoid the risk of the cursor being covered. The scrolling distance is the difference.

[0053] Step 7: After the user enters the text, the front end records the current height through the change of the WebView Frame border size. After the user enters or deletes the text, the new height is recorded and the difference between the two values ​​is calculated to perceive the page wrapping;

[0054] Step 8: The client obtains the difference calculated in step 7 through js interaction, and scrolls the page according to the difference to prevent the soft keyboard from blocking the input area during the input process.

[0055] By controlling the Android system page through this method, the soft keyboard can be prevented from covering the input area, and unnecessary scrolling of the page can be reduced, providing a good input experience.

[0056] The present invention may also provide a computer device, comprising: at least one processor, a memory, at least one network interface and a user interface. The various components in the device are coupled together through a bus system. It is understood that the bus system is used to achieve connection and communication between these components. In addition to the data bus, the bus system also includes a power bus, a control bus and a status signal bus.

[0057] The user interface may include a display, a keyboard or a pointing device, such as a mouse, a trackball, a touch pad or a touch screen.

[0058] It is understood that the memory in the embodiments disclosed in the present application may be a volatile memory or a non-volatile memory, or may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM), and direct memory bus random access memory (DRRAM). The memories described herein are intended to include, but are not limited to, these and any other suitable types of memories.

[0059] In some embodiments, the memory stores the following elements, executable modules or data structures, or a subset thereof, or an extended set thereof: an operating system and applications.

[0060] The operating system includes various system programs, such as a framework layer, a core library layer, a driver layer, etc., which are used to implement various basic services and process hardware-based tasks. The application includes various application programs, such as a media player (Media Player), a browser (Browser), etc., which are used to implement various application services. The program for implementing the method of the embodiment of the present disclosure can be included in the application.

[0061] In the above embodiment, the processor may also call a program or instruction stored in the memory, specifically, a program or instruction stored in an application program, and is used to:

[0062] Execute the steps of the above method.

[0063] The above method can be applied to a processor or implemented by a processor. The processor may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by an integrated logic circuit of hardware in the processor or an instruction in the form of software. The above processor may be a general processor, a digital signal processor (Digital Signal Processor, DSP), an application specific integrated circuit (Application Specific Integrated Circuit, ASIC), a field programmable gate array (Field Programmable Gate Array, FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The above-disclosed methods, steps and logic block diagrams can be implemented or executed. The general processor may be a microprocessor or the processor may also be any conventional processor, etc. The steps of the above-disclosed method can be directly embodied as a hardware decoding processor to execute, or the hardware and software modules in the decoding processor are combined to execute. The software module can be located in a mature storage medium in the field such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory, and the processor reads the information in the memory and completes the steps of the above method in combination with its hardware.

[0064] It is understood that the embodiments described in the present invention can be implemented by hardware, software, firmware, middleware, microcode or a combination thereof. For hardware implementation, the processing unit can be implemented in one or more application specific integrated circuits (ASIC), digital signal processors (DSP), digital signal processing devices (DSPD), programmable logic devices (PLD), field programmable gate arrays (FPGA), general processors, controllers, microcontrollers, microprocessors, other electronic units for performing the functions described in the present application or a combination thereof.

[0065] For software implementation, the technology of the present invention can be implemented by executing the functional modules (such as procedures, functions, etc.) of the present invention. The software code can be stored in a memory and executed by a processor. The memory can be implemented in the processor or outside the processor.

[0066] The present invention may also provide a non-volatile storage medium for storing a computer program. When the computer program is executed by a processor, each step in the above method embodiment can be implemented.

[0067] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit the present invention. Although the present invention is described in detail with reference to the embodiments, it should be understood by those skilled in the art that any modification or equivalent replacement of the technical solutions of the present invention does not depart from the spirit and scope of the technical solutions of the present invention and should be included in the scope of the claims of the present invention.

Claims

1. A method for preventing a soft keyboard from covering an input area, the method comprising: Step S1: Create a gesture detector to monitor the system's click events and focus change events; Step S2: When a user clicks on a page and a click event is generated, the location information of the page clicked by the user is obtained in the click event response method; When the system evokes the soft keyboard and generates a focus change event, the page scrolling behavior initiated by the system is prevented in the focus change event response method; Step S3: Calculate the height of the soft keyboard and the height of the screen; Step S4: Calculate the height to which the page needs to be scrolled based on the position where the user clicks the page, the height of the soft keyboard, and the screen height, and scroll the page.

2. The method for preventing a soft keyboard from covering an input area according to claim 1, characterized in that: The height that the calculation page needs to scroll is specifically: Use the vertical coordinate of the position where the user clicks the page plus the height of the soft keyboard, and then subtract the screen height to get the height that the page needs to scroll; When the calculated scroll height is less than 0, set the scroll height to 0.

3. The method for preventing a soft keyboard from covering an input area according to claim 2, characterized in that: When there is a submit button below the page input area, the height of the soft keyboard is the sum of the height of the soft keyboard and the height of the submit button.

4. The method for preventing a soft keyboard from covering an input area according to claim 1, characterized in that: The method further comprises: Step S5: When the user inputs or deletes text, causing the number of text lines on the page to change, the page height is recalculated and the page is scrolled to prevent the soft keyboard from covering the input area.

5. The method for preventing a soft keyboard from covering an input area according to claim 4, characterized in that: The recalculation of the page height and scrolling of the page are specifically as follows: By tracking the changes in the WebViewFrame border size, calculate the difference between the two border height values ​​before and after entering or deleting text; Set the page scroll distance to the difference between the two border height values.

6. A system for preventing a soft keyboard from covering an input area, implemented based on any of the methods described in claims 1-5, characterized in that: The system comprises: Create a gesture detector module to create gesture detectors and monitor the system's click events and focus change events; The response event module is used to obtain the location information of the page clicked by the user in the click event response method when the user clicks the page to generate a click event; it is also used to prevent the page scrolling behavior initiated by the system in the focus change event response method when the system evokes the soft keyboard and generates a focus change event; A height calculation module for calculating the height of the soft keyboard and the screen height; and The first page scrolling module is used to calculate the height to which the page needs to be scrolled according to the position where the user clicks the page, the height of the soft keyboard and the height of the screen, and scroll the page.

7. The system for preventing a soft keyboard from covering an input area according to claim 6, characterized in that: The system further comprises: The second scrolling page module is used to recalculate the page height and scroll the page to prevent the soft keyboard from covering the input area when the user inputs or deletes text, causing the number of text lines on the page to change.

8. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the method according to any one of claims 1 to 5 is implemented.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, which, when executed by a processor, causes the processor to perform the method according to any one of claims 1 to 5.