WebView Text Selection - android

I want to achieve something like this -- text selection plus custom actions ..
http://www.youtube.com/watch?feature=player_embedded&v=iwmG43D0vD4
I have done sufficient research on this topic and concluded that webview text selection and overriding it functionality is not possible ..
Seems that webview's functionality is very limited atleast in the case of text manipulation.
I had decent success by accessing webview's private nativeGetSelection method ( i was able to get selected text ).. but still i was unable to suppress the default dialog box .. and using private methods dosen't seem to be a safe action tooo ..
I was about to scrap my thought of doing that project .. then i came to see that default web browser provides good text selection capability and further provides custom quick action to manipulate the text .. I am really confused at this point ....
can anyone .. with all their expertise ... point out how to achieve that behavior .. ?
what view does google docs app use to achieve that behavior .. ?

I got something similar working in 2.2 - 4.0.3. I used a javascript interface and passed all touches to it. Of course to do that you'll need enough control over the web content to include the javascript file. I have this solution in an app in production and I've put an example project on github. The github project includes the necessary js in the assets folder as well as a test page and web view that loads the test page and implements all necessary methods to handle the selection. The link to the github project is https://github.com/btate/BTAndroidWebViewSelection. Have at it.

Related

In Android TV leanback UI BrowseFragment how could I find when HeadersFragment is put away?

I'm writing a POC Android TV app for my company based on our existing mobile OTT product and backend.
I'm modifying the PageAndListRowFragment example from Google's Leanback Showcase code.
When a header option is selected (with OK or right arrow) I want the RowsFragment side to popup an AlertDialog to let me filter the content displayed ('all', 'latest', etc).
My problem is that I have the AlertDialog in the RowsFragment onCreate So, It displays as soon as the HeadersFragment is highlighted. This stops the user from scrolling down the header smoothly and is confusing because you still have to select the header item after the dialog.
Most advice on the web seems to point to overriding the OnItemViewClickedListener function on the HeadersFragment but I can't find a way to do this. (The leanback showcase uses the deprecated BrowseFragement code, Not BrowseSupportFragment and if I try to change up I get into FragmentFactory errors I'm not experienced enough to resolve).
I've also tried implementing isShowingHeaders() in the RowsFragment.
I've tried to find a stage of the fragment lifecycle in either HeadersFragment or RowsFragment that will let me popup the dialog when the RowsFragment is full screen without success.
I'm already using the PageRowFragmentFactory code in the leanback showcase code to send an EventBus message containing the header option chosen and was hoping to send a similar message to trigger the dialog.
I've tried setting up a setOnHeaderViewSelectedListener on the BrowseFragment but can't seem to successfully get it invoked.
I'm new to Android programming so apologies for my ignorance, but I'm determined to make this work somehow.
Any suggestions on the approach would be very much appreciated, thanks.

EditText-like custom view creation from the scratch (standard view)

I want to create my customized own controls apart from standard Android views/widgets including View, ScrollBar, TextView, EditText, ...
And already completed others but not TextView/EditText yet.
The two controls interact with soft-keyboard on focus or not. Plus, you can type/edit the text of the control by the keyboard. More challenging part is about controlling the caret. These problems happen because the control inherits View, not TextView/EditText.
You may ask why I chose such difficult way, not using standard ones and customize only some part of them?
That's because of one fatal problem that standard TextView/EditText cannot support large files(a few MB files) and are lagging with them. Additionally, some of the important member functions are private, not protected or public. So we cannot customize fully them as we want.
That's why I created one customized text viewer/editor that supports large files (even over 100 MB). Viewer feature already has been implemented and works well.
Now the editor feature is remaining and it's the reason why I'm here to request your help.
Please let me know what's the best solution and I'd appreciate if you can provide with some sample codes.
Thanks
P.S. This is what I've done so far.
screenshot
apk

Create UI like Chrome for Android

I want to implement this behaviour [https://github.com/gleue/TGLStackedViewController] in an app that I am trying to make.
The closest thing/the effect that I want to achieve is how the Google Chrome browser behaves.
Tile/card interface
Be able to access a form of navigation (access other tabs) when user pulls down the address bar
Be able to re-arrange the tabs in any order the user wishes
Photo taken from this Android Layout : How to implement a UI similar to deck of cards? SO question
Is there anyone out there who has tried to implement this kind of behavior? Do you guys know any libraries that can help achieve this effect? It would be very helpful! Thank you
systemUI/Recents package, as mentioned by Andrei, can be your starting point. It adds a little more to the flat rendition of chrome tabs.
I have been meaning to refactor systemUI/Recents package ever since I got the L update. I finally got to it.
A sample project is hosted at: Link
Even though the viewgroup recycles, it updates the progress map (child properties) for all children on each scroll step. This will lead to lags with large data sets. For a few hundred, it should be fine.
The sample project uses Picasso for loading and caching images from LoremPixel. Since these are random images & may repeat, you can verify that they are bound correctly by looking at bottom left of the image.
If you feel like looking through the AOSP code, the functionality you are looking for is actually open-source and you can find it in Android 5.0 in the recent apps screen. This is the code you want to look at on github.
The view you want to extract from AOSP is the RecentsView. This would be the best approach.
You could also consider extending StackView and overriding onLayout() so you get the children to lineup.
One other option is to extend ListView, override drawChild or layout methots and try to shift the views according to their position. You can find some inspiration here and here

Android - Cards UI framework

I'm using the framework from here - cardsui
How can I add a share button to the top of the cards. I've implemented it in the xml with an on click method, but the app crashes when I press it and says that the method doesn't exist (yes, I added the method to the main java file. also to the card.java file but still the app crashes...).
Has anyone used this framework and encountered this?
Thank you
You might want to check this addon for CardsUI: https://github.com/Androguide/cardsui-for-android
As developer wrote:
The Google Play cards come with more customization parameters than the other regular cards, those parameters include :
Title (String)
Description (String)
Stripe color (String)
Title Color (String)
Enable an overflow menu on the card. It's not finished yet, I still
need to implement the popup menu when clicked (Boolean)
Enable touch feedback on click or disable it (Boolean)
If you replace the overflow menu with buttons, at least you get a boolean and then handle the actions accordingly.
I wonder if you should just use a simple ListView, and apply a custom background to your adapter to give it the card UI. Then you are just using a simple ListView (with no additional framework - ie. just standard Android UI).
I describe how I did this in the following SO answer: How to create Google + cards UI in a list view?
I would guess that you ARE able to add an onClickListener to the component of your card, as this is pretty standard Android (chances are the Framework you are using DOES support this). Don't know your specific issue unless you post more code.

Android - Creating own buttons in webview, retrieving certain contents from website into webview

I'm currently doing a application (project) on android. I would like to know how to create my own buttons in webview, or creating a tab bar in webview. Also, I would want to retrieve certain contents from a website (or rather, from livejournal, to be specifc), like, I do not want the buttons that are in livejournal itself, I just want certain contents, maybe like some live journal posts. Is there any way I could do this?
Thank you so much in advance!
Instead of putting tabs in the WebView you should put the WebView in Tabs. As for pulling information from LiveJournal there are two possibilites. They either have a public api that you can access to get the data you want and use that to populate your app or they don't. If they don't your only recourse would be to pull in the raw html and try to parse it. At that point you might was well just use the webpage as is.

Categories

Resources