webview.findnext() start highlighting from the current position of touch in the screen - android-studio

I'm new in android studio. I'm working on a simple project. It uses a webview which loads the html page. I also use an action bar for searching, refreshing , ... in the page bellow:
By pressing the search button, findAllAsync() method is used to find and highlight all the matches in the page (matches are shown in yellow color). The next button in the action bar uses the findnext(true) method and allows user to move between the highlighted matches. Using this method, the next one is highlighted in red color:
next.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
st = et.getText().toString();
if(!st.equals("")&& st!=null) {
ourBrow.findNext(true);
}//not null
}//on click
});// next Button click
If I only scroll or zoom in the webview everything is ok and the find next is continued from the previous one in the page. However if i touch somewhere in the webview and then click the next button, the red highlighting is not continued from the previous position in the page. For example if the previous red highlighted is at the first of the page and i touch the end of the page and when i click the next button, the middle yellow matches are escaped and the last one which is in end of the page is highlighted in red color and red highlighting is continued from this position.
Since i need the user can continue search from the previous position and touching the screen does not affect this order, i searched a lot. I tried to disable touch event of the webview but keeping zoom and scroll ability based on the Android disable WebView touch but keep zooming/scrolling. But my problem is still unsolved. Please kindly help me to solve this problem.
thanks.
Edit:
To solve this problem i tried to clear focus of the view(How to remove focus without setting focus to another control?). But it doesn't work:
View current = getCurrentFocus();
if (current != null) current.clearFocus();
ourBrow.findNext(true);

I would recommend the following not the best approach (and it depend on your web page) but it will work, render the content of your web page to html using :
webview.loadData(URLEncoder.encode(result).replaceAll("\\+", " "), "text/html", Encoding.UTF_8.toString());
Than do whatever you want with your text highlight the way you want and then render it back to web page like this:
myTextView.setText(Html.fromHtml("Your HTML Page"));
API after nugget:
myTextView.setText(Html.fromHtml("Your HTML Page", Html.FROM_HTML_MODE_COMPACT));
Hope it helps

Related

WinRT XAML - how to fix higlight issues?

When I'm testing my app on a mouse-driven device, I'm seeing a couple of odd highlight issues that I would like to try and resolve.
The first occurs when I call up the app bar, hover the mouse over a button (at which point the button goes grey) and then press Escape to dismiss the app bar. If I then call up the app bar again, the button has stayed grey, even if the mouse isn't over it, and remains in that state until I move the mouse over it and then away again.
I can't immediately see a property of the button that I can reset to clear that state when the app bar gets dismissed.
The other oddity I'm seeing is that sometimes the first item in the list on the page will get a box drawn around it:
This seems to happen when the app bar is being dismissed. I'm guessing that this is because the item is in a particular state that causes the box to appear but I'm not sure what state or how to clear it. The box does not appear during normal use of my app.
Thanks for any clarification or solutions you can provide.
I found a simple way to workaround this issue. In the code for Clicked/Tapped set Visibility of the button:
CreateNewDatabase.Visibility = Visibility.Collapsed;
CreateNewDatabase.Visibility = Visibility.Visible;
It will reset button state to Normal.
Hope this helps!
So, the issue is that the VisualState for the Button is being set to PointedOver, and then not being unset (because your mouse isn't leaving the bounds of the control and therefore triggering a PointerExited event). What this means is that you'll have to manually set the VisualState of the Button if you want it to change in this manner. You could do it on AppBar's Closed event. Basically, do a recursive check of all Children of the Content property of the AppBar using the VisualTreeHelper. Check to see if the Child is a Button. If it is, set its VisualState using VisualStateManager.GoToState().
I've also figured out what was causing the black box around the button - it is to indicate that the button has Focus.
The rather strange thing is that I'm not really sure why that specific button is getting focus or how a user is supposed to give focus to a button without it just randomly happening so, until I figure that out, I've decided to comment out the Focus state support from the Visual Manager XAML used in the default GridView item style.

In XPages mobile app, how to avoid appending resetContent=false/true after pressing Done?

I've a mobile page developed with ExtLib mobile controls:
http://hostname/mydb.nsf/MobileTest.xsp
The page consists of two appPages (i.e. a "mainPage" appPage & a "subPage" appPage).
Click on an entry in the mainPage will move to the subPage. Click on the "Done" button in the subPage will move back to the mainPage. After moving back to the mainPage, the resulting URL will automatically change to: http://hostname/mydb.nsf/MobileTest.xsp#mainPage&resetContent=false
When this happened, if I press the browser's refresh button on my iPhone, instead of showing the mainPage, a grey blank page will be displayed. Then, if I manually remove &resetContent=false from the URL and press the refresh button again, the mainPage will be displayed properly.
So, is there any way to suppress appending &resetContent=false (or true) after clicking on a Done button?
I have found the cause of this and have put a fix into the ExtLib, it will be in the next release. I don't know when that will be at the minute but will update when I know
See answer:
http://www.openntf.org/internal/home.nsf/response.xsp?action=openDocument&documentId=0B41430C59FA242C862579D50034D72A

IME in landscape view is not working - Next button does not respond

I have an app, one activity is a form with multiple fields. In landscape mode when clicking into the first field the fullscreen IME kicks in, with a "Next" button.
The "Next" button, however, does not respond at all. No errors are thrown, nothing logged related to this - it just doesn't move to the next (of about 12) text fields.
Same (lack of) behavior when other fields are selected on the form and text entered/not entered in landscape view - non-responsive next button.
The final EditText field correctly shows a "Done" button...which is also unresponsive.
I've had no luck searching forums and Googling this, and nothing I've been able to find related to the IME has helped to this point.
One option, of course, is to force portrait mode (which works fine), but I would rather avoid that klunky workaround.
Any suggestions, references to code/examples related to this would be greatly appreciated.
Resolved using android:imeOptions="actionDone" in the EditText layout if the next element is not an EditText view, or if at the end of the form. All other EditText layouts added android:imeOptions="actionNext".
This allows a full-screen IME in landscape view to navigate from one EditText to the next, form an EditText out of the IME if the next field is a button or spinner (any non-EditText field), and exit the full-screen IME after the last form field.

Change "back" NavigationItem text in Monotouch?

Is it possible to change the "Back" button text in a NavigationItem? At present, the caption of the back button assumes the title of the previous layer in the navigation stack, which is expected.
However, the NavigationItem's LeftBarButtonItem can be changed using code such as this:
UIBarButtonItem backButton = new UIBarButtonItem("Back", UIBarButtonItemStyle.Plain, null);
myNewView.NavigationItem.SetLeftBarButtonItem(backButton, true);
This works and the back button is displayed as expected, but the button is a square and does not navigate back to the previous layer as expected. I'm guessing that the correct event needs to be assigned to it, but I have no idea what it should be.
How would one go about ensuring that the new UIBarButtonItem has the correct event and arrow shape?
Note: I have also tried re-using the `LeftBarButtonItem' as suggested in this SO question, but I still don't know how to customize the button caption. I am probably just missing the obvious.
Thanks!
Set the title on the previous viewcontrollers navigationitem. I answered this before and will look up the link.
Ah, yes: Separate title in NavigationBar and navigation buttons

UIWebView example code for in-app browser?

Anyone have some sample code for an in-app browser that they would like to share?
I am looking to add a browser view in my app that is pushed and includes a toolbar with four buttons: back, forward, stop/refresh and actions. However, I'd like to show somewhat transparent and none-tapable buttons when you can't go forward or back, and also have the stop/refresh button show the appropriate icon when it's loading and done loading?
My issue is currently that I cannot get "blanked out" back and forward that cannot be tapped if you cannot go back in the web history. Also, how do I change out the stop icon with the refreshing icon when the view is loading?
For tool bar items, simply set "item.enabled = webview.canGoForward;" (or canGoBack). To change the refresh/stop button you can set item.customView if you want to use a progress view or some such, otherwise if you just want to use a static image you can set item.image. All this is in the documentation as well.

Resources