A mobile application for manuscript signing of remote documents
Abstract
Grado en Ingeniería Informática
Full text
A mobile application for manuscript signing of remote documents industriële wetenschappen en technologie bachelor in de elektronica-ICT Eindwerk aangeboden tot het behalen van het diploma van bachelor in de elektronica-ICT door Arne Debergh Campus Oostende Academiejaar 2015 - 2016 o.l.v. Tom Cordemans, Vives Luc Vanhee, Vives Carlos Vivaracho Pascual, Escuela de Ingeniería Informática de Valladolid Javier Bastida Ibáñez, Escuela de Ingeniería Informática de Valladolid
Announcement This final project was an exam. The discovered errors during the defence presentation are not included. Deze eindverhandeling was een examen. De tijdens de verdediging geformuleerde opmerkingen werden niet opgenomen. Abstract in English This bachelor thesis is about an Android and web application for handling the signing of documents electronically. The goal is to be able to send, receive and possibly sign documents electronically, thus limiting the use of paper as well as speeding up the process. This book will cover everything I’ve been working on, from design and coding to the implementation of the application.The usage of the application will be explained with a graphic user manual. Abstract in Dutch Dit eindwerk gaat over een Android- en webapplicatie voor het elektronisch afhandelen van het ondertekenen van documenten. Het doel is om documenten elektronisch te verzenden, te ontvangen en eventueel te ondertekenen. Hierdoor wordt het gebruik van papier geminimaliseerd terwijl het ganse proces sneller kan plaatsvinden. Dit boek omvat alles waar ik aan gewerkt heb, van het ontwerp en codering tot de implementatie van de applicatie. Het gebruik van de applicatie wordt toegelicht door middel van een gebruikershandleiding. Abstract in Spanish El Proyecto que se describe en esta memoria consiste en una aplicación Android y una aplicación web para la firma electrónica de documentos. El principal objetivo es que la aplicación pueda enviar, recibir y firmar documentos electrónicamente, limitando así el uso de papel y agilizando el proceso. Esta memoria describe todo el proceso de desarrollo de la aplicación, tanto el diseño de la misma como la implementación. Esta memoria incluye a su vez un manual de usuario donde se explica el uso de la herramienta. Keywords Android, mobile application, manuscript signing, remote documents Citation Arne Debergh: A mobile application for manuscript signing of remote documents, Bachelor Thesis, Valladolid, E.T.S. De Ingeniería Informatica, 2016
Dedication in English I would like to thank Vives Oostende for giving me the opportunity of completing my studies with an Erasmus+ program. More specifically I would like to thank my internal promotor Cordemans Tom and supervising professor Vanhee Luc. I would also like to thank my parents for supporting me in my decision of a semester abroad. It would not have been possible to have such a unique experience without their support. Also, I would like to thank my external promotor Carlos Vivaracho Pascual and supervising professor Javier Bastida Ibáñez for helping me choose a project. I was always welcome at their offices to ask for help or feedback with my work. This final project has given me a taste of the field in general as well as a working culture quite different from the one in Belgium where I’m probably going to end up in. This experience as a whole will most likely prove to be an asset on the job market in the future. I have met a lot of new friends and made a lot of memories here, all of those I will hold dear for the rest of my life. My Erasmus+ period is something I will never forget. Dedication in Dutch Ik zou graag Vives Oostende bedanken om me de kans te geven mijn studies te vervolledigen met een Erasmus+ programma. Meer bepaald zou ik graag mijn interne promotor Cordemans Tom en de toezicht houdende professor Vanhee Luc bedanken. Ook mijn ouders zou ik willen bedanken om mij te steunen in mijn keuze voor een semester in het buitenland. Het zou voor mij onmogelijk geweest zijn zo’n unieke ervaring te beleven zonder hun ondersteuning. Ook zou ik graag mijn externe promotor Carlos Vivaracho Pascual en toezicht houdende professor Javier Bastida Ibáñez bedanken voor hun hulp bij het kiezen van mijn project. Ik was altijd welkom in hun kantoor om hulp of feedback op mijn gemaakte werk te vragen. Dit eindwerk heeft me kennis laten maken met het werkveld in het algemeen, alsook met een werkcultuur verschillend van de Belgische waar ik waarschijnlijk in terecht zal komen. Deze volledige ervaring zal zeer waarschijnlijk een grote troef zijn op de arbeidsmarkt. Ik heb hier veel nieuwe vrienden leren kennen, alsook veel herinneringen gemaakt, die ik voor altijd zal koesteren. Mijn Erasmus+ periode is iets wat ik nooit zal vergeten. © Arne Debergh This work was created as a thesis at the University of Valladolid, Departamento de Informática. This work is protected by copyright and law, its use without authorisation by the author is illegal, except in cases defined by law.
1 1 Table of contents 1 Table of contents .................................................................................................................................. 1 2 List of figures ........................................................................................................................................ 4 3 Introduction .......................................................................................................................................... 6 4 General description of the project ....................................................................................................... 8 4.1 Project Requirements .................................................................................................................... 8 4.1.1 Android application requirements ......................................................................................... 8 4.1.2 Database requirements ........................................................................................................ 11 4.1.3 Web application requirements ............................................................................................. 11 4.2 Methodology ............................................................................................................................... 12 4.2.1 Connecting to the database: Android login.......................................................................... 12 4.2.2 Connecting to the database: Webpage login ....................................................................... 14 4.2.3 Database Operation: Uploading documents ........................................................................ 15 4.2.4 Database Operation: Webpage documents table ................................................................ 16 4.2.5 Database Operation: Android list view own documents ..................................................... 16 4.2.6 Database Operation: Android signature upload .................................................................. 16 4.2.7 Database Operation: Android Accept/Decline document ................................................... 17 4.2.8 Webpage logout ................................................................................................................... 17 5 General description of the product .................................................................................................... 18 5.1 Programming languages and tools .............................................................................................. 18 5.1.1 Android Studio ...................................................................................................................... 18 5.1.2 Java (Android) ....................................................................................................................... 18 5.1.3 PHP ....................................................................................................................................... 18 5.1.4 MySQL................................................................................................................................... 18 5.1.5 HTML .................................................................................................................................... 18 5.1.6 CSS ........................................................................................................................................ 19 5.1.7 Server .................................................................................................................................... 19 5.2 Complete application flowchart .................................................................................................. 20 5.2.1 Android ................................................................................................................................. 20 5.2.2 Web pages ............................................................................................................................ 21 5.3 Webpage User Interface.............................................................................................................. 23 5.3.1 Index ..................................................................................................................................... 23 5.3.2 Contact ................................................................................................................................. 23 5.3.3 Adding Documents ............................................................................................................... 24
2 5.3.4 Viewing Documents .............................................................................................................. 25 5.4 Android User Interface ................................................................................................................ 26 5.4.1 Main Activity (Login) ............................................................................................................. 26 5.4.2 List view Activity ................................................................................................................... 27 5.4.3 View Document Activity ....................................................................................................... 28 5.4.4 Signature Activity.................................................................................................................. 29 5.5 Webpage code ............................................................................................................................. 30 5.5.1 General features ................................................................................................................... 30 5.5.2 Index page ............................................................................................................................ 31 5.5.3 View documents page .......................................................................................................... 31 5.5.4 Add documents page ............................................................................................................ 31 5.6 Android Code ............................................................................................................................... 33 5.6.1 MainActivity.......................................................................................................................... 33 5.6.2 PostClass ............................................................................................................................... 33 5.6.3 ListviewActivity ..................................................................................................................... 34 5.6.4 Documents ........................................................................................................................... 35 5.6.5 DocumentAdapter ................................................................................................................ 36 5.6.6 ViewDocsActivity .................................................................................................................. 36 5.6.7 SignatureActivity .................................................................................................................. 37 5.6.8 Manifest file .......................................................................................................................... 37 6 User and system requirements .......................................................................................................... 38 6.1 User requirements....................................................................................................................... 38 6.1.1 Android end user .................................................................................................................. 38 6.1.2 Webpage admin user ........................................................................................................... 38 6.2 System requirements .................................................................................................................. 39 6.2.1 Minimum required specifications ........................................................................................ 39 6.2.2 Recommended specifications............................................................................................... 39 6.2.3 Server Requirements ............................................................................................................ 39 7 Planning .............................................................................................................................................. 40 7.1 February ...................................................................................................................................... 40 7.2 March .......................................................................................................................................... 40 7.3 April ............................................................................................................................................. 41 7.4 May .............................................................................................................................................. 41 8 Software Tests .................................................................................................................................... 42 9 Android User Manual ......................................................................................................................... 43 9.1 Open the application launcher and select the app ..................................................................... 43
3 9.2 Log in ........................................................................................................................................... 43 9.3 Document overview .................................................................................................................... 44 9.4 Reading and responding to a document ..................................................................................... 45 9.5 Drawing your signature ............................................................................................................... 46 9.6 Logging out .................................................................................................................................. 46 10 Webpages user manual .................................................................................................................... 47 10.1 Navigating to the webpages ...................................................................................................... 47 10.2 View documents ........................................................................................................................ 48 10.3 Adding documents .................................................................................................................... 48 10.4 Logging out ................................................................................................................................ 49 11 Installation Manual ........................................................................................................................... 50 11.1 Placing the .apk file on your computer ..................................................................................... 50 11.2 Transfer the .apk file to your mobile phone ............................................................................. 50 11.3 Enable installation from unknown sources ............................................................................... 50 11.3.1 Android 5.0 or newer ......................................................................................................... 50 11.3.2 Android versions lower than 5.0 ........................................................................................ 50 11.3.3 Enabling installation ........................................................................................................... 50 11.4 Executing the package ............................................................................................................... 51 12 Conclusion ........................................................................................................................................ 52 13 Bibliography ...................................................................................................................................... 53
4 2 List of figures Figure 1: Smartphone OS market share (1) ............................................................................................. 6 Figure 2: Android version spread as of April 4, 2016 (2) ......................................................................... 7 Figure 3:Android Login Flowchart ........................................................................................................... 8 Figure 4:Respond to Document Flowchart.............................................................................................. 9 Figure 5:Flowchart Sign Document ....................................................................................................... 10 Figure 6: Database Tables ..................................................................................................................... 11 Figure 7: Flowchart of user_control.php script ..................................................................................... 12 Figure 8: Sequence diagram for Android login ...................................................................................... 13 Figure 9:Website Login Flowchart ......................................................................................................... 14 Figure 10: Flowchart of upload.php ...................................................................................................... 15 Figure 11: Flowchart of uploadSig.php.................................................................................................. 16 Figure 12: Flowchart of decline.php ...................................................................................................... 17 Figure 13: Flowchart Android application ............................................................................................. 20 Figure 14: Flowchart Web pages ........................................................................................................... 21 Figure 15: Index webpage ..................................................................................................................... 23 Figure 16: Contact Webpage ................................................................................................................. 23 Figure 17: Add Documents Webpage .................................................................................................... 24 Figure 18: Added Document Response ................................................................................................. 24 Figure 19: View Documents Webpage .................................................................................................. 25 Figure 20: View Document In New Tab ................................................................................................. 25 Figure 21: Screenshot of Login Activity ................................................................................................. 26 Figure 22: Screenshot of List view Activity ............................................................................................ 27 Figure 23: Screenshot of View Document Activity ................................................................................ 28 Figure 24: Screenshot of Signature Activity .......................................................................................... 29 Figure 25: Invalid email popup .............................................................................................................. 31 Figure 26: Add document email error ................................................................................................... 32 Figure 27: MainActivity class ................................................................................................................. 33 Figure 28: PostClass ............................................................................................................................... 33 Figure 29: ListviewActivity ..................................................................................................................... 34 Figure 30: BackgroundTask ................................................................................................................... 34 Figure 31: Documents ........................................................................................................................... 35 Figure 32: DocumentAdapter ................................................................................................................ 36 Figure 33: ViewDocsActivity .................................................................................................................. 36 Figure 34: SignatureActivity .................................................................................................................. 37 Figure 35: Testdroid Software Test (3) .................................................................................................. 42 Figure 36: Application Icon (4) .............................................................................................................. 43 Figure 37: Log in .................................................................................................................................... 43 Figure 38: Document overview ............................................................................................................. 44 Figure 39: Reading and responding to a document .............................................................................. 45 Figure 40: Drawing your signature ........................................................................................................ 46 Figure 41: Index Page ............................................................................................................................ 47 Figure 42: Contact page......................................................................................................................... 47 Figure 43: Viewing documents .............................................................................................................. 48 Figure 44: Adding documents ............................................................................................................... 48 Figure 45: Unknown Sources ................................................................................................................. 50
5 Figure 46: Installing the application ...................................................................................................... 51
12 4.2 Methodology In this part I will explain how the Android application connects to the server and database. Some diagrams will be used to simplify the explanation. 4.2.1 Connecting to the database: Android login When the user presses the login button on the application, the entered email and password are being posted to a specific URL. The server uses the user_control.php file to control if the values are valid. The flowchart of this script can be seen in figure 7. It will also add a new user when the entered values do not exist in the database yet. Figure 7: Flowchart of user_control.php script Firstly, the script will establish a connection with the database. A new object of the User class will be made, this class will be explained later on. Then, the script will look if the post contains an ‘email’ and ‘password’ value. If so, local values will be set accordingly to the posted ones. Next, we will check if both the values are not empty. When they are both not empty, the password value will be hashed with an md5 hash and both values will be given as arguments to the function ‘does_user_exist’. When at least one of the values is empty, the script answers with the message “You must fill out both fields”. The User class contains two functions, __construct and does_user_exist. The construct function will establish the database connection through the get_connection function of the connection.php script.
13 The function ‘does_user_exist’ will firstly send a query to the database selecting the row where the email and password fields match the entered ones. If this MySQL query contains a row, the script will answer with a welcome message, personalized to the user logging in and the connection will close. If that query would appear to be empty, a new query will be executed trying to insert a new row to the database containing the email and hashed password of the user. When the result of the executed query is a ‘1’, that means the new row was inserted successfully and the application will receive a message stating a new account was created. If the result would not be equal to ‘1’, that means the corresponding user already has a row in the database but the password was incorrect, so the script answers with a wrong password message. Figure 8: Sequence diagram for Android login
14 4.2.2 Connecting to the database: Webpage login The webpage login script is similar to the Android login script but I have made some changes to the ‘does_user_exist’ function: Figure 9:Website Login Flowchart If the user exists, the script will validate if the ‘admin’ column in the users table is equal to ‘1’. If so, a session variable will be made and set true stating that the current user is in fact an administrator. If not, this variable will be set false. If the user is non-existing, you will be redirected to an invalid login webpage. After the user is recognized, the browser will be redirected to a script which is used when the documents table webpage is being accessed. That script will look if the session variable is true or not, and later on redirect to the desired page. session_start(); if ($_SESSION['admin'] != 'true') { header("Location: http://rea.eca-simm.uva.es/projectarne/index.html"); }else { header("Location: http://rea.eca-simm.uva.es/projectarne/documents.php"); }; To view the webpage for adding documents, a similar script is used redirecting to the webpage for adding documents when the user has administrator rights.
15 4.2.3 Database Operation: Uploading documents It is possible for the employees to upload new documents and assign them to a recipient. This is done in the ‘Add Document’ webpage, which can only be accessed after logging in. When the form is posted, it will start a script called ‘upload.php’, which will handle the uploading of the file and alter the database. Figure 10: Flowchart of upload.php In the flowchart seen in figure 10, you see that the script will firstly check if the file being uploaded is a PDF file. When a valid file is used, a file name will be generated with the given email and name. The name that was entered will be converted to lower case and each space will be converted to a dash. For example when the user entered ‘THIS is Your DocUment’ as the name and ‘[email protected]’ as the email, the generated filename will be as follows: ‘this-is-your-document-de[email protected]om.pdf’. Next the email address will be validated. If the form contained a valid email address the file will be uploaded to the server, this action will be checked. The checking of file upload also takes care of documents having the exact same name. If the file was uploaded correctly, a new row containing the info of the document will be put in a new row in the database table. When the uploaded file was not a PDF, the email address was invalid, the file upload failed or a new row was added to the table, a corresponding response will be sent back to the webpage.
16 4.2.4 Database Operation: Webpage documents table After uploading documents the employees must be able to view them. Therefore exists a webpage which displays a table containing all documents. I have embedded some pieces of PHP code into the HTML code because it made for a very simple solution. To make as much rows as needed, I select all documents from the database and run them through in a while loop. The only database operation that is happening here is ‘SELECT * FROM uploads’. Every loop will generate a new row, containing the information of the document in that row. It will show the name, email of the recipient, size of the document, a button to view the PDF and a button to view the signature, when the document has been signed. Also, the background colour of the row changes depending on its status. If the document is signed, the background colour will appear green, when declined it will be red. In case the recipient has not yet responded to the document, the background colour will be neutrally white. 4.2.5 Database Operation: Android list view own documents To make a list view table of all the documents of the end user, a script called ‘list_view.php’ is being called. This script puts all rows from the uploads tale in an array containing encoded JSON strings. Every JSON string in the array contains a response message. This array will be sent to the device and it will be decoded. Only the strings containing documents of that end user will be decoded and displayed. 4.2.6 Database Operation: Android signature upload After drawing and confirming a signature on the Android application, the PNG file will be posted to another script called ‘uploadSig.php’. This script will save the uploaded file into the uploads folder and respond to the application when its operation was successful or failed. The file name of the signature will be exactly the same as the corresponding document, but with the PNG extension instead of PDF . Figure 11: Flowchart of uploadSig.php
17 4.2.7 Database Operation: Android Accept/Decline document When the users have read their document, they have 2 choices: going to the signing of the document, or declining it. If the decline button is clicked, the PostClass will be called and connect to decline.php. This script will receive the name of the document that is being declined, and use a sql query to set the signed value to ‘0’. The ‘0’ value means this document has been declined. Figure 12: Flowchart of decline.php When the users sign the document and accept their signature, the signature will be uploaded as previously mentioned. But another script called sign.php will be called as well. This script works in the same way as decline.php, but will set the signed value to ‘1’. The value ‘1’ means that the document has already been signed. 4.2.8 Webpage logout When the administrator users are done with their work on the website, they have the possibility to log out. They can do this by pressing the logout button which will call the logout.php script. This script will set the admin value to false and redirect them to the index page. After that, the users have to log back in if they want to access certain pages. <?php session_start(); $_SESSION['admin'] = 'false'; header("Location: http://rea.eca-simm.uva.es/projectarne/index.html"); ?>
18 5 General description of the product The application itself will be described here. Firstly I will explain the software and programming languages I have used to make this application. Then I will use a flowchart describing the entire lifecycle of the application. After that I will explain the layout of the application followed by an explanation of the code used. 5.1 Programming languages and tools First I will briefly explain the software tools I have used and then the programming languages in which the application has been written. 5.1.1 Android Studio The Android application was created using Android Studio. Android Studio is an IDE (Integrated Development Environment) based on the intelliJ platform. It is available for Windows, Mac OS X and Linux, and has replaced Eclipse Android Development Tools as Google’s primary IDE for native Android application development. This software is the official IDE for Android and can be freely downloaded from the Android developers website. The SDK or Software Developer Kit is also needed to start developing. 5.1.2 Java (Android) The Android programming language used is Java. The Java bytecode is not executed, instead the classes are compiled into a proprietary bytecode format and run on a virtual machine. Dalvik is a specialized virtual machine designed for Android, it is a register-based architecture, unlike Java VMs, which are stack machines. Since Android version 5.0 Dalvik was entirely replaced by Android RunTime, or ART. ART has two major advantages to Dalvik: Ahead-of-Time (AOT) compilation, which improves speed and reduces memory footprint Improved Garbage Collection (GC) 5.1.3 PHP Hypertext Pre-processor or PHP is a server-side scripting language designed for web development. It is also used as a general-purpose programming language. In this project I have used some PHP scripts to include SQL injections. These scripts are stored on the server and executed on call. They will make the server connection with the database and perform actions on the tables. 5.1.4 MySQL My Structured Query Language or MySQL is an open-source relational database management system. It is a popular choice of database for use in web applications, and is a central component of the widely used LAMP open-source web application software stack. In this application the server makes use of a MySQL Database to store the users and documents. 5.1.5 HTML HyperText Markup Language or HTML is the standard markup language being used to create web pages. Web browsers can read these files and render them into web pages. It describes the structure of a website, this makes it a markup language rather than a programming language. I wrote the web pages for the bank’s employees in HTML, supported by CSS.
19 5.1.6 CSS Cascading Style Sheets or CSS is a style sheet language used for the presentation of a document written in a markup language, such as HTML. CSS is a cornerstone technology used by most websites to create more visually engaging web pages and user interfaces. 5.1.7 Server The server used for hosting the web application is located at http://rea.eca-simm.uva.es . It’s a server of the University of Valladolid and the Apache, PHP5 and MySQL services are installed on it. These services are needed to host this web application.
20 5.2 Complete application flowchart 5.2.1 Android Figure 13: Flowchart Android application As you can see from the flowchart in figure 13, the Android application boots to the login screen. Without registering or logging in, you can’t see any documents. When logging in, the application connects to the PHP script mentioned earlier which will connect to the database and verify the credentials. If the credentials are correct the users will get to see a list of their documents with their information. The users can select a document and the application will take them to a screen in which they can view the document and respond to it. It is only possible to respond to a document when it has not been signed or declined yet. If the document has already been signed or declined the user will get a corresponding error message on his phone. When the users decline the document the application will call a script which will decline it in the database as well. Thereafter they are taken back to the list of documents. When the users accept the document they will see a blank drawing board where they can draw their signature. If necessary the screen can be cleared so that the users can start drawing again. If the signature is acceptable they can sign the document, the application will call a server-side script uploading the PNG file and accepting the document in the database. After this the users is taken to the list of documents. When the users are done using the application they can close it. The next time the app will open they have to log in once again.
21 5.2.2 Web pages Figure 14: Flowchart Web pages As seen from the flowchart in figure 14, the landing page doubles as a login page as well. The website can be used without logging in, but only the landing page and contact page are available. When the users log in, a script will verify if they are indeed a registered user and if they have administrator rights or not. If the credentials are incorrect they will be redirected to an invalid login version of the index page. If the credentials are correct but the users do not have administrator rights, they will log in correctly but will not be able to access the pages for viewing and adding documents. If the users have administrator rights they will be redirected to the page containing a table with all the documents and their information after logging in. There they have a clear overview of the documents and their status, thanks to the colouring of the table. If needed, the administrator can review the document and when signed, he can view the signature as well. To upload new documents the administrator has to navigate to the ‘upload documents’ page, where he can fill out the form. After filling out the form a script will be called verifying the recipient value consists of an email and the uploaded file is a PDF file. If not, the users will get an error on the page telling them what went wrong and they can try again.
28 5.4.3 View Document Activity In this activity, the users can read the selected document and respond to it. The main part of the layout consists of a web view, which displays the PDF file. On the bottom of the screen there are two buttons, one to sign and one to decline the selected document. This layout can be seen in figure 23. Figure 23: Screenshot of View Document Activity When the document contains multiple pages, the users are able to swipe through them using the touchscreen. The users are able to return to the list view by pressing the back button of their smartphone. The buttons will perform certain actions. When the decline button is clicked, the document will be declined and the users will be taken back to the list view where they can see the new status. When the sign button is clicked the users will be taken to the signature activity where they can draw their signature and confirm the document.
29 5.4.4 Signature Activity This activity has the exact same layout as the view document activity, but the web view has been replaced with a drawing screen. The users can draw their signature with the touchscreen and perform actions on it with the two buttons. This activity can be seen in figure 24. Figure 24: Screenshot of Signature Activity The button on the bottom left corner will call a script confirming the document as well as uploading the signature to the database. To clear the screen and start drawing again, the user can press the button on the bottom right corner. If the users haven’t drawn anything for 500ms, the screen will also clear upon touching it again. This prevents users trying to slowly forge someone else’s signature.
30 5.5 Webpage code In this chapter I will explain the code of the webpages written in HTML and CSS. The PHP scripts have already been explained in chapter 4.2. I will insert some code in this chapter but not all of it. If a reference is made to pieces of code but it has not been inserted, the file name and lines of the code will be mentioned. 5.5.1 General features 5.5.1.1 Page The head element of all pages contain the title of the page, a link to the styles.css file and some metadata about the page. All of the content of the webpages will be placed within a ‘div’ element of the class page. Implementing this method makes the webpages a little more attractive because it will look more or less as a piece of paper on top of a desk or board, depending of the background used. The page will always take up 70% of the total width and is centered. This class can be found in the styles.css file on lines 266-276. The background of the page is taken from an image and repeated in the body class in the styles.css file on lines 1-6. Each page also includes a header and footer. 5.5.1.2 Header and footer The header and footer files are included in each individual webpage. The header contains the name of the bank, the title of this project, two images and the navigation bar. <img unselectable="on" class="bank" src="img/banco.jpg" alt="Company Logo"</img> <img unselectable="on" class="vives" src="img/vives.png" alt="Vives Logo"</img> <h1>El Banco</h1> <h3 class="top">A mobile application for manuscript <br>signing of remote documents</h3> As seen in the above code, the images have been made unselectable. They each have their own class referencing to the styles.css file which will give them certain behaviour. The name of the bank is a classic ‘h1’ and the title of the project a ‘h3’ with its own CSS class. The shared ‘vives’ and ‘bank’ class arguments are: float: right; padding: 1px; margin-right: 40px; user-drag: none; user-select: none; -moz-user-select: none; -webkit-user-drag: none; -webkit-user-select: none; -ms-user-select: none; These arguments will make sure the images are in the top right corner of the webpage, as well as not being draggable or selectable. The only argument in the project title head class is ‘margin-left: 5px;’ , which leaves a little space to the left of the title. For the navigation bar I used a HTML ‘nav’ element containing a unordered list or ‘ul’ element. This contains ‘li’ elements of the class menu which will refer to other webpages or scripts on the server through ‘a’ elements.
31 <nav> <ul class="menu"> <li class="menu"><a class="menu" href="index.html">Home</a></th> <li class="menu"><a class="menu" href="documentsCheck.php">View Documents</a></th> <li class="menu"><a class="menu" href="addDocumentCheck.php">Add Document</a></th> <li class="menu"><a class="menu" href="contact.html">Contact</a></th> <li class="menu"><a class="menu" href="logout.php" >Logout</a></th> </ul> </nav> The CSS a.menu class will defines the behaviour of the text displayed, such as colour and weight of the font. It also changes the colour of the text when users hover over it. These classes can be found in the styles.css file on line 11-18. The ul.menu and li.menu classes describe the look of the navigation bar, such as background colour, and can be found on line 29-42. The footer file only contains one unselectable ‘p’ element of the footer class (line 277) declaring a copyright. 5.5.2 Index page The index page displays a small welcome message for the users which also points at the login form below it. This login form uses a ‘POST’ method and will post the entered credentials to the webuser_control.php script explained in chapter 4.2.2. The source file of this page is index.html. 5.5.3 View documents page The view documents page contains a table taking up 80% of the width of the page, it will display as many rows as there currently are documents. This is done by injecting some PHP lines into the HTML code that will use a query and a while loop to display rows of documents, as explained in chapter 4.2.4. To view the source file of this page look into documents.php. 5.5.4 Add documents page Upon visiting this webpage, the users will only get to see a upload form. This form uses a ‘POST’ method to post the entered variables to the upload.php script, explained in chapter 4.2.3. The HTML code in this file also has been injected with PHP to change its look after the users posted the form. Depending on the response of the script, the webpage will show some extra information regarding the status of the posted form. This status can either be ‘successful’, ‘unsuccessful’ or ‘invalid email’. If we use ‘John’ as recipient, not being a valid email address, the response of the script will be ‘invalid email’. Therefore we will see an error popup, as shown in figure 25. Figure 25: Invalid email popup
32 After clicking the OK button, the page will refresh and the users get to see the same page but with a personal message giving them some advice, as seen in figure 26. Figure 26: Add document email error
33 5.6 Android Code In this chapter I will explain the written Android classes, supported by the UML presentation I will try to make the code more understandable than when looking at the source code. If needed, the source code can be found on the disc provided at the end of this book. 5.6.1 MainActivity The MainActivity class, with its UML diagram shown in figure 27, is the class being used to generate the login screen. It has two methods: onCreate and openHome. onCreate is the method being called when starting the login screen. It will set the content and layout according to the activity_main.xml file and will connect the edittexts and button to the public variables. openHome is the method being used when the user clicks the button, it will take content of the edittexts and put them in strings, after that it will call upon the PostClass and start the ListViewActivity if the login was successful. Figure 27: MainActivity class 5.6.2 PostClass The PostClass is a class being used every time the application connects to the server and/or database. The UML diagram of this class can be seen in figure 28. It has a doInBackground() method that will open a connection to a given URL and post the parameters to it. This method will set the methods and properties of the connection and create a DataOutputStream to the URL. It will also retrieve the response of the script that has been called with the getResponseCode() method. All of the output will then be placed in a two StringBuilders, one being placed in the logs, the other to create toast messages and provide values to the application when needed. For example when the MainActivity has called the PostClass, the toast message being generated will be dependent of the response of the script. It can be a ‘welcome existing user’, ‘welcome new user’, ‘wrong password’ or ‘invalid email address’ response. Figure 28: PostClass
34 5.6.3 ListviewActivity The listviewActivity class has two methods: onCreate() and viewListItem(). It also has an intern class called BackgroundTask. The UML diagram of this class can be seen in figure 29. The onCreate method will set the content view according to the activity_listview.xml file. It will also get the user’s email address out of the login activity and place it in a string called userString. It will create a new listView and documentAdapter and will set the the documentAdapter to populate the listView. Afterwards it will call on the BackgroundTask, populating the listView. The viewListItem method is used when the user has clicked a select button, it will get the information from the selected document and put them in strings. Then it will start the ViewDocsActivity and with it the document name and status will be sent. Figure 29: ListviewActivity The BackgroundTask class, as seen in figure 30, will call upon the PostClass and start a connection, the response of the called script will be a JSON string. This string will be dissected and put into a stringbuilder. When the stringbuilder is filled, it will use a while loop to take every document and put all of its’ values in strings and afterwards in a document of the Documents class. This document will then be added to the documentadapter. All of these steps will be repeated with the while loop until all documents have been placed into the adapter. Figure 30: BackgroundTask
35 5.6.4 Documents The documents class describes the architecture of the documents used. This class will be called when documents are being put into a list by the DocumentAdapter to populate the ListView. A UML diagram of the class can be seen in figure 31. Figure 31: Documents The class contains 3 strings: name, email and file, which describe the corresponding information of the document. Each string has a setter and a getter, used to set or get the values of these strings when needed.
36 5.6.5 DocumentAdapter The DocumentAdapter class describes the adapter that has been written to place all needed documents into a list that will later on populate the ListView. The UML diagram of the DocumentAdapter class can be seen in figure 32. Figure 32: DocumentAdapter The adapter has a List that will contain all documents and a a row that will display the view. It also has a DocumentHolder which will hold all the information of the document and a ArrayList of tags containing extra information. The add method will add the current document to the list when called. getCount will return the size of the list at any given moment. The getItem method will return a document at the given position in the list. The getView method will generate a personalized list to display in the ListView. It uses a LayoutInflater to inflate the row with all documents. If a document has been selected the information will be put in the DocumentHolder and the tags containing the status of the document will be set. 5.6.6 ViewDocsActivity The ViewDocsActivity is the activity displaying the document that has been selected from the ListView. The UML diagram of the class can be seen in figure 33. It has 3 variables: document, status and browser. The document and status strings will be set in the onCreate method. The values of these strings will have been put as extras when the intent started this activity. The onCreate method will also set the browser WebView as new WebViewClient and load the URL of the document selected. Figure 33: ViewDocsActivity
37 The declineDocument method will call on the PostClass which will update the database. It will start the listviewActivity once again after the document has been successfully declined. When the document has already been responded to it will generate a corresponding toast message. The signDocument method will firstly verify if the document hasn’t been responded to yet. If it has been, a corresponding error toast message will be generated. If not, the method will start the SignatureActivity and put the document string as an extra. 5.6.7 SignatureActivity The SignatureActivity class will be called after the user has decided to accept a document. It contains a document string, containing the name of the document. When the activity is started, the onCreate method will set the document string from the extras that have been given through the intent. It will also set the uploadUri string, referring to the uploadSig.php script on the server and make a temporary saving path called signaturePath. The UML diagram of the class can be seen in figure 34. Figure 34: SignatureActivity When the saveSig method is called, after clicking the ‘Sign’ button, the drawing will be captured and saved temporarily to the signaturePath. Then it will call the uploadFile method uploading the recently saved signature to the server. The uploadFile method will the signature to the server through the PostClass. The serverResponseCode tells the application if the action was a success and if so, the local signature is removed. The clearSig method is called when the user clicked the ‘Clear’ button. It will clear the gestureView and refresh it so that the user can draw his signature once again. 5.6.8 Manifest file The manifest file contains the permissions and settings of the application. In this project, it states that the minimum SDK version must be 16 and the target version is 23. It also states that this application needs internet, access network state, read phone state, write external storage and read external storage permission. This file was also used to change the launcher icon of the application.
44 9.3 Document overview After logging in with the correct credentials, you get to see an overview of your documents. The table shown will display a row per document, with its title, status and a response button. This screen can be seen in figure 38. If you want to select a document, please press the select button responding to the document. After doing this you can always go back to the overview of your documents by pressing the back button on your smartphone. Figure 38: Document overview
45 9.4 Reading and responding to a document When you have selected a document, you will be able to read it on the screen that opened. This screen can be seen in figure 39. You are also able to scroll to the document. After reading the document, you can choose to respond to it by pressing the accept or decline button or you can choose to ignore it for now and go back to the overview of documents. Figure 39: Reading and responding to a document After declining the document you will be taken back to the document overview and will see that the new status of that document will be ‘declined’. When you press the accept button a new screen will open where you can draw your signature. If the document has already been signed you will be unable to sign or decline the document. When clicking one of the buttons a toast message will appear telling you the document has already been signed or declined.
46 9.5 Drawing your signature After accepting the document, a new screen will have opened. This screen can be seen in figure 40. You are able to draw your signature over there. If the drawn signature is incorrect, you can press the clear button to clear the drawing screen. If you wait a small time and press the drawing screen, it will also clear. When you are ready with drawing your signature, you can press the sign button and the document will be accepted, as well as your signature being uploaded. After signing the document you can go back to the document overview where the status of the document will have changed. Figure 40: Drawing your signature 9.6 Logging out When your work with the application is over, you can close the application as you would close any other application on your smartphone. The next time the application is started, you will have to log in again.
47 10 Webpages user manual 10.1 Navigating to the webpages Administrators are able to upload new documents or view the status of all the documents on the application’s website. These webpages can be found at: http://rea.eca-simm.uva.es/projectarne/ . You have to log in on the homepage to be able to perform actions with documents. If not logged in, you can only view the home and contact webpages seen in figures 41 and 42. Figure 41: Index Page Figure 42: Contact page
48 10.2 View documents After logging in correctly, you will be redirected to the view documents webpage seen in figure 43. Over there you get to see a table containing all of the documents currently in the database. You can quickly see if the document has been responded to due to the background colour of the row. If signed, the row will appear green. If declined, it will appear red. When the document has not been responded to yet, the background of the row will appear white. You can quickly view the original document and/or signature by pressing the ‘PDF’ or ‘PNG’ button in the document row. Figure 43: Viewing documents 10.3 Adding documents When you want to send a new document to a client, you have to navigate to the add document page as seen in figure 44. Over there you have to fill out the form. To fill it out correctly, please enter a title, correct email address and PDF document. Figure 44: Adding documents After uploading the new document you will see a link to the document overview page. If you click on it you will be redirected to the webpage.
49 10.4 Logging out If you are finished working on the webpages, you can logout by pressing the logout link in the navigation bar. This will log the current user out and redirect you to the homepage.
50 11 Installation Manual This chapter will explain how the Android application can be installed on your smartphone. This process will be explained step-by-step. It is not a difficult process since your smartphone will perform most of the work by itself. 11.1 Placing the .apk file on your computer To retrieve the .apk file, you have to insert the disk, provided at the end of this book, in your computer and copy it to your computer. The file can be found in the APK folder. 11.2 Transfer the .apk file to your mobile phone Please connect your mobile phone to your computer, and when prompted, select to use it as an external memory stick. Then you have to locate the earlier copied package and drag it to the mobile phone. Make sure you place it in a easy to be found location of your smartphone’s internal memory. 11.3 Enable installation from unknown sources This step is split up for Android versions lower than 5.0 and versions equal to or higher than 5.0. 11.3.1 Android 5.0 or newer Open up the settings menu of your smartphone. This can be done by opening the application launcher and locating the settings menu, or by dragging down the notification bar twice and pushing on the gear wheel. 11.3.2 Android versions lower than 5.0 Open your application launcher and locate the settings menu. Press it and the settings menu will open up. 11.3.3 Enabling installation This part is again equal for all versions of Android. After opening up the settings menu locate the ‘security’ tab. Under device administration you should see the option ‘unknown sources – Allow installation of apps from sources other than the Play Store’. Activate this option as seen in figure 45. Figure 45: Unknown Sources
51 11.4 Executing the package Use a file explorer to locate the installation package (.apk file) you have previously copied to the internal memory of your device. If you do not have a native file explorer application, you will have to download one from the Play Store in order to explore the internal memory of your smartphone. After locating the installation package on the phone click on it, this will open an installation dialog. Please read and accept the permissions the application uses. This process can be seen on figure 46. Figure 46: Installing the application When this is done, the application will be installed. Your application is now ready for use.
52 12 Conclusion This application can become a handy tool for its users. It is able to save valuable time and therefore also money. The application I’ve made has completed the asked objectives. It has a log in/ register system to implement a certain level of security. It implements the reading of the documents through connecting to the database, which saves space on the smartphone. This makes the application use a little bit more internet traffic but that is not a big problem nowadays. I found this application a very interesting project since I had to use my basic coding knowledge from the courses of the previous years and combine them all together. I also learned a lot by doing online research, the used languages are very well documented. Android has a very open developer community and the developers website comes in very helpful. The use of PHP and MySQL was interesting, I have used them in a totally different way than before. Some improvements could still be made to the application. These were not included since I didn’t have the time to get them fully working. The biggest improvement in my opinion would be the merging of the original document with the signature. If this application would be used by a company, I would change the layout of the Android application a bit to make it more attractive. Also the webpages would have to be personalized to the company. These are possible improvements that can be added to this project. This application can, and hopefully will, become useful in a productive environment.
53 13 Bibliography (1) International Data Corporation. (sd). Smartphone OS Market Share. Last checked on 05 11, 2016, from the IDC website: http://www.idc.com/prodserv/smartphone-os-market-share.jsp (2) Android Developer. (sd). Dashboards. Last checked on 05 11, 2016, from the Android Developers website: http://developer.android.com/about/dashboards/index.html (3) Testdroid. (sd). Testdroid – Mobile app testing. Last checked on 05 12, 2016, from the Testdroid website: http://testdroid.com/ (4) Application Icon (free for non-commercial use). (sd) Application Icon. Last checked on 05 09, 2016, from iconarchive: http://www.iconarchive.com/show/steel-system-icons-by-uriy1966/Documents-icon.html (5) Start activity from button. (sd) Start activity from button. Last checked on 05 09, 2016, from developer.android.com: http://developer.android.com/training/basics/firstapp/starting-activity.html (6) Using GestureOverlayView. (sd) Drawing in Android with GestureOverlayView. Last checked on 05 09, 2016, from intertech: http://www.intertech.com/Blog/android-gestureoverlayview-to-capture-a-quick-signature-or- drawing/ (7) Saving BitMap to device. (sd) Saving BitMap to device. Last checked on 05 09, 2016, from stackoverflow: http://stackoverflow.com/questions/17175680/error-when-save-bitmap-to-file-on-sdcard-android (8) Clear GestureOverlayView. (sd) Clearing the drawing screen. Last checked on 05 09, 2016, from stackoverflow: http://stackoverflow.com/questions/12740733/clear-gesture-from-gestureoverlayview-in-android (9) Uploading documents. (sd) Uploading documents. Last checked on 05 09, 2016, from codingcage: http://www.codingcage.com/2014/12/file-upload-and-view-with-php-and-mysql.html (10) Save PDFs. (sd) Save PDF MySQL. Last checked on 05 09, 2016, from php-mysql-tutorial: http://www.php-mysql-tutorial.com/wikis/mysql-tutorials/uploading-files-to-mysql-database.aspx (11) Android Login. (sd) Android login with MySQL, PHP. Last checked on 05 09, 2016, from youtube: https://www.youtube.com/watch?v=0Fnk9ZgsTVw (12) Android POST request. (sd) POST request. Last checked on 05 09, 2016, from wikihow: http://www.wikihow.com/Execute-HTTP-POST-Requests-in-Android (13) HTTPClient. (sd) HttpClient class. Last checked on 05 09, 2016, from codeofaninja: https://www.codeofaninja.com/2013/04/android-http-client.html (14) Upload signature. (sd) Upload file to server - Android. Last checked on 05 09, 2016, from androidexample: http://androidexample.com/Upload_File_To_Server_- _Android_Example/index.php?view=article_discription&aid=83&aaid=106