Giter Site home page Giter Site logo

btandroidwebviewselection's Introduction

I've Seen a lot of people trying to get user selections with a context menu working in Android web views. The problem lies in Android's use of an intermediate text view that it places between the user and the web view on selection. So the javascript in the page doesn't know what's selected.

This solution uses a javascript interface to pass touches to the page and effectively cut Android's native selection out of the equation. This has been tested from 2.2 to 4.0.3.

The example uses an html page in the assets folder with the javascript methods included. The BTWebView class implements the interface methods necessary to draw the selection layer with the handles and show the context menu. Any content you wish to use this with will need the following javascript imports.

    <script src='jquery.js'></script>
	<script src='rangy-core.js'></script>
	<script src='rangy-serializer.js'></script>
	<script src='android.selection.js'></script>

This solution employs a few libraries that deserve recognition.

<ol>
	<li>
		The <a href="http://code.google.com/p/rangy/">rangy</a> javascript library by Tim Down.
	</li>
	<li>
		A wonderful <a href="http://blahti.wordpress.com/2011/01/17/moving-views-part-2/">drag and drop</a> library by Bill Lahti.
		<br /> <em>*Note: The version of this library included in this project has been slightly modified.</em>
	</li>
	<li>
		The <a href="http://www.londatiga.net/it/how-to-create-quickaction-dialog-in-android/">Quick Action</a> library by Lorensius Londa.
		<br /> <em>*Note: The version of this library included in this project has been slightly modified.</em>
	</li>
</ol>

This project is freely available for use.

btandroidwebviewselection's People

Contributors

btate avatar netomin avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.