Webview in Android loads a text file
This project was awarded to geniustunis for $35 USD.Get free quotes for a project like this
Project Budget$10 - $30 USD
I don't care about graphic design. Make it as plain as possible as long as it fulfils the requirements specified below.
I need an android app with only two Activities. The 1st activity will contain 4 btns with the following texts: Text1,..., Text4. I will provide you with 4 text files: [url removed, login to view],...,Text4.txt. Once the btn with the text "Text(N)" is clicked, the app will show the 2nd activity passing as a parameter the file with name "Text(N).txt".
The 2nd activity must only contain a WebView that fills the whole screen both vertically and horizontally. At the bottom, a BACK btn to return to the 1st activity. The Webview will display the content of the file passed as a parameter as it is. Ex., if the txt file contains 800 lines of text, each of length 600 characters and a '\n' character at the end of the line, it should be displayed like that on the webview. NO WORD WRAP.
You must configure the Webview so that the text displayed can be zoomed in and out by pinching on the screen. As the user pinches IN on the screen, the text will become smaller and smaller until it is no longer readable. That is, the characters become so small that they appear as black dots on the screen.
If the user pinches OUT (SPREAD), the characters start becoming readable again.
The text files mostly contain the ASCII characters: -,*@#$%.=;, so don't expect to find letters on it.
The text cannot be word-wrapped. For example, when the characters are readable, the whole content will NOT be visible on the screen, so the user will have to move over the text(scroll vertically and horizontally by sliding a finger on the screen) if he wants to see more content.
Why a Webview? A webview is very responsive, so once the text is loaded, you can easily do all the gestures mentioned above to zoom in and out, as well as scrolling.
I've tried this before, and the problem I have encounter is that, since the text files are mostly made with the characters mentioned above, it cuts the text at random points. For example, if my text file contains only one line of text of length 600, it splits the line at length 27, then it splits again at line 68, and so on (SPLIT POINTS ARE RANDOM). By doing so, the Webview messes all the original text and ends displaying several lines of text instead of one and sometimes it even omits some of the characters on the text file. This might be a bug in the WebView (not sure though).
I recommend using the following configuration for the Webview in order to accomplish the zooming and scrolling gestures, as well as the proper font size.
WebView web = (WebView) findViewById([url removed, login to view]);
[url removed, login to view]().setBuiltInZoomControls(true);
[url removed, login to view]().setUseWideViewPort(true);
[url removed, login to view]().setFixedFontFamily("monospace");
[url removed, login to view]().setFantasyFontFamily("monospace");
[url removed, login to view]().setLoadWithOverviewMode(true);
[url removed, login to view]().setTextZoom(8);
[url removed, login to view]().setMinimumFontSize(4);
[url removed, login to view]().setMinimumLogicalFontSize(2);
The font used must be a Monospace font. You can use "Monospace" which is built-in in Android OS, or preferably you can use Lucida Console, which I provide in the files of this post. To get a better understanding of what I want to accomplish, please open the files mentioned above with a text editor capable of zooming in and out the text. Set the font to Lucida Console, and disable the word wrap option. As you zoom out, you will see that the text becomes a picture made with ASCII characters. That's what I want to see in the phone.
You must turn in the full project developed in JAVA, preferably using Eclipse ADT (NO XAMARIN OR PHONEGAP OR anything else). Your code must be a poem. That is, variable names must be well chosen --self explanatory. Comments must be used if you think something can be confusing. If you need to reuse code, please use functions. Be organized since I will have to read the code later on.
Looking to make some money?
- Set your budget and the timeframe
- Outline your proposal
- Get paid for your work
Hire Freelancers who also bid on this project
Looking for work?
Work on projects like this and make money from home!Sign Up Now
- The New York Times
- Wall Street Journal
- Times Online