MASARYK UNIVERSITY FACULTY OF INFORMATICS Mobile Application and Tablet Reader for Web-based Attendance Application Bachelor's Thesis MICHEL ŠUSTEK Brno, Fall 2024 MASARYK UNIVERSITY FACULTY OF INFORMATICS Mobile Application and Tablet Reader for Web-based Attendance Application Bachelor's Thesis MICHEL ŠUSTEK Advisor: Mgr. Luděk Bártek, Ph.D. Brno, Fall 2024 Declaration Hereby I declare that this paper is my original authorial work, which I have worked out on my own. A l l sources, references, and literature used or excerpted during elaboration of this work are properly cited and listed in complete reference to the due source. In the preparation of this thesis, I have used ChatGPT and Grammarly for the purpose of grammar correction and suggestions. After using these tools, I have checked the content and take full responsibility for it. Michel Šustek Advisor: Mgr. Luděk Bártek, Ph.D. iii Acknowledgements I sincerely want to thank Mgr. Ludek Bartek, PhD, for supervising my thesis, and my family and my girlfriend for everlasting support on this neverending journey. iv Abstract This bachelor's thesis focuses on the design and implementation of a cross-platform attendance application for tablets and mobile phones. Its goal is to provide a cost-effective and flexible solution that can replace traditional hardware terminals, offering comparable functionality for employee attendance tracking. The work presents a tabletbased component that uses PIN codes for user authentication and a mobile application that simplifies employee and supervisor access to attendance records, vacation balances, and other relevant information. The development process employed React Native with Expo to enable efficient, single-codebase development for both platforms. The thesis also addresses security measures, data synchronization, offline capabilities, and geolocation integration. The solution is tailored to minimize costs and complexity while delivering enhanced functionality compared to conventional hardware systems. The outcome is a functional prototype ready for further expansion, such as perimeter-based tracking or integration with personnel modules. By doing so, this work provides an innovative and sustainable attendance-tracking solution optimized for the current needs of businesses. Keywords react native, mobile application, attendance systems, application design, typescript v Contents 1 Introduction 1 1.1 Motivation for tablet readers 1 1.2 Motivation for phone application 2 2 Analysis 3 2.1 Tablet mode 4 2.1.1 Enrollment 4 2.1.2 Main Screen 5 2.1.3 Project tracking 6 2.1.4 Offline mode 6 2.1.5 PIN code generation 7 2.1.6 Settings 7 2.1.7 Pinning of the screen 7 2.2 Phone mode 8 2.2.1 Logging in 9 2.2.2 Dashboard 9 2.2.3 Reader 9 2.2.4 Workload Planning 9 2.2.5 Absence requests 10 2.2.6 Settings 10 2.2.7 Timesheet 10 2.3 REST API communication 11 2.4 Available Tools 17 2.5 React Native 18 2.5.1 Expo 20 2.6 Minimum compatibility 20 3 Design 21 3.1 Tablet mode use-case diagram 21 3.2 Phone mode use-case diagram 22 3.3 Class components vs functional components 22 3.4 Tablet mode design 23 3.5 Phone mode design 25 3.6 Used technologies 34 3.6.1 TypeScript 34 vi 3.6.2 StyleSheet API 35 3.6.3 Redux Toolkit 35 3.6.4 Expo Router 36 3.6.5 Shopify Flashlist 38 3.6.6 React Hook Form and Zod 38 4 Implementation 40 4.1 Project Structure 40 4.2 Generation of the PIN codes 42 4.3 Synchronization between tablet and remote server . . . 43 4.4 User state handling in the phone application 44 4.5 Deployment 45 5 Conclusion 47 Bibliography 48 A Use-case diagrams 51 B Application Design (PO) 53 C Source code 59 vii List of Tables viii List of Figures 2.1 Communication diagram between services 3 2.2 Enrollment process of a new tablet 5 2.3 Main Screen of an Alveno H W reader showing the design 6 2.4 Calendar overview in the web version of Alveno 10 2.5 Simple HelloWorld component written in JSX 19 2.6 Example Hello World component 19 3.1 Simple HelloWorld class component example 26 3.2 Simple HelloWorld functional component example . . . . 27 3.3 PIN code entry modal 27 3.4 Dashboard Screen 28 3.5 Settings Screen (iOS) 29 3.6 Difference between hardware (a) and tablet (b) reader . . 29 a Hardware reader screen 29 b Tablet reader screen 29 3.7 Morphing Tab Bar 30 3.8 Dashboard Screen 30 3.9 Timesheet Screen 31 3.10 Timesheet Day Detail 32 3.11 Exception Reader 32 3.12 Denied Request Message 33 3.13 Projects Reader 33 3.14 TypeScript example 34 3.15 StyleSheet API example 35 3.16 Expo Routing Example 37 3.17 Zod validation schema example 39 A . l Tablet mode use-case diagram 51 A.2 Phone Mode use-case diagram 52 B. l Dashboard 53 B.2 Dashboard - graph and vacation 54 B.3 Timesheet 55 B.4 Absence Request - Form 56 B.5 Menu design 57 B.6 Reader design 58 ix 1 Introduction The use of tablets and mobile phones has become increasingly prevalent within companies in today's business landscape. This widespread adoption reflects a growing market demand for more cost-effective solutions and dedicated mobile applications that meet the needs of employees. In response to this demand, this project focuses on developing a unified application that serves both as a tablet reader for employees' attendance and a mobile application for employees. The application aims to streamline development and maintenance processes and reduce the complexities associated with managing separate platforms by maintaining a single code base for multiple device types. The motivation behind this initiative is two-fold. • companies seek affordable solutions that do not require significant upfront investments in hardware or software, and • users' preference for mobile applications that provide quick and convenient access to essential tools and information. The application offers a versatile and efficient approach to attendance tracking and other critical functions by addressing these needs. The subsequent sections will describe the specific motivations for implementing tablet readers and developing a dedicated phone application. This thesis proposes how these applications can benefit companies with multiple work sites and a small number of employees at each location, providing them with nearly the same experience as current hardware readers at a chunk of the cost. 1.1 Motivation for tablet readers The motivation for implementing the tablet mode is to enable companies which may have numerous work sites with a small number of employees at each location (such as small shops, cafes, clinics, etc.) to allow their employees to track their time in Alveno. These employees can then use a PIN code provided to them by the application for authentication. 1 i . INTRODUCTION There are only three options for tracking working hours in Alveno: • software reader, in which the user has to have access to an internet-connected computer or a smartphone, • buying a biometric hardware reader, which is a separate device that can be relatively expensive when buying in bulk or for small companies, or • manually editing the timesheet. Tablet mode will include interfaces for employees to start and stop tracking their work, enter exceptions, and check their remaining vacation, along with some statistics about their timesheets. It is offered to companies for a monthly fee rather than a one-time upfront payment, like the hardware readers. Currently, hardware readers are divided into three categories, of which the cheapest (as of 2024) is priced at 18 000 C Z K [1]. If we consider a company that has a lot of branches and thus needs a lot of readers for each branch, this solution can be more cost-effective than buying a lot of expensive readers upfront. The cost is not the sole motivation. Tablet readers eliminate the necessity of having to support the hardware itself. They also introduce new possibilities for connectivity. For example, we can use Bluetooth Low Energy (BLE) to open doors upon arrival at the office or for tracking on-site using Bluetooth beacons [2]. Furthermore, unlike hardware readers, whose only function is to track attendance, tablets can serve multiple purposes, such as a cash register, without needing a secondary device. 1.2 Motivation for phone application Today, in many requests for proposals for attendance systems, there is a growing demand for attendance systems to include their own dedicated smartphone applications. The primary objective of this application is to fulfil that specific need. In addition, users expect quick and convenient access to information in today's world. Relying only on a web-based interface for frequent tasks is no longer sufficient, as users increasingly prefer the immediacy and ease provided by mobile applications. 2 2 Analysis Requirements state that the application will consist of two separate parts: • mobile application, • tablet reader. In this chapter, we take a look at both functional and non-functional requirements for this project, along with some technical details. There will be two modes for the application, which will be contextswitched based on the device's screen size. These screen sizes are defined in the Expo specification [3]. Devices with screen sizes smaller than 6.9" but larger than 3" are considered phones, and devices larger than 7" but smaller than 18" are categorised as tablets. This thesis will not go deep into the backend side of things due to the complexity, scope and time constraints; however, some highlevel overview is necessary for the context, and then we will dive into specifics of PIN code generation in the Section 4.2. The phone application is going to use REST API built on Windows Communication Foundation [4], which is going to then communicate with the endpoint service, which serves as a facade [5] between the endpoint service and the main application and is going to be secured using a generated token. This API is going to accept the token in the AuthorizationToken header, which is the Alveno-specific version of the Authorization [6] header. The high-level communication diagram can be seen on the Figure 2.1. The reason for the facade is the possibility of support for multiple versions and abstraction around the old source code with its Czechnamed variables for a future replacement by a modernized API. Phone / Tablet HTTPS Mobile Endpoint (WCF Service) HTTPS Web Application Services (WCF Service) Phone / Tablet Mobile Endpoint (WCF Service) Web Application Services (WCF Service) Figure 2.1: Communication diagram between services 3 2. ANALYSIS 2.1 Tablet mode The tablet mode should support the following functionality: • Pairing the app to an Alveno instance using a generated QR code or manually. • Entering attendance or project records, verification of employees using a PIN code. • Allow employees and administrators to generate new PIN codes randomly whilst avoiding commonly used PIN codes. • Allow administrators to manage the reader buttons and employees from the web. • Offline mode and synchronization of the records entered while the reader was offline. • Display information about vacation, monthly balance and similar to the employee. • Allow administrators to display the unsynchronized records and pin the application to the foreground. 2.1.1 Enrollment The tablet can be enrolled into an Alveno instance by QR code or pairing code. The enrollment can be done by an administrator on the website in the Settings section. These two enrollment ways have to be identical; if, for example, the system administrator does not wish for the application to access the camera, a pairing code with a company's identification number (IN) can be used instead. A pairing code is a 10-digit code used to pair the device to the company's Alveno instance, which the administrator can generate in the administration. This exact code is going to be stored alongside the I N in the QR code using JSON. As seen on Figure 2.2, the pairing process using the QR code is straightforward. It comprises two screens on which the user first selects if they would like to pair the tablet to their instance using a QR code 4 2. ANALYSIS User Application Server Scans the QR code OR enters IN [if entered IN manually): Enters Pairing Code . Navigates to "enrollment registration information" screen Enters Device Name . Navigates to the reader home page GET register-information , Returns information about the instance POST enrollment Returns token for communication User Application Server Figure 2.2: Enrollment process of a new tablet or entering I N and pairing code, and after confirming the code and entering the device name, the tablet is ready to be used. After successful enrollment, the administrators in the Alveno administration can list all tablet pairings registered to their instance or disable and wipe the application remotely. Administrators also need to generate PIN codes for all users who have not yet used tablet readers and assign them to the reader through the Tools tab in Alveno. 2.1.2 Main Screen The main screen will closely resemble that of the existing, more expensive hardware readers as seen on Figure 2.3. This user interface was selected to leverage users' familiarity with the current design of the hardware readers. The main screen will feature two large buttons that display each user's most common daily actions. A l l buttons can be customized by administrators and may include custom exceptions, such as "break," "out for a doctor," and so on. Information about the device's network status and clock will be located in the screen's bottom left and right corners, along with a battery indicator when the application is pinned. The main screen will feature a special button in the top right corner that allows users to access information about their remaining vacation 5 2. ANALYSIS Figure 2.3: Main Screen of an Alveno H W reader showing the design and general statistics, including overtime, remaining, planned, and used vacation hours. Additionally, the overview screen will have an automatic timeout, signing users out after 30 seconds of inactivity. 2.1.3 Project tracking The project tracking system will allow employees to monitor the time they spend on projects that the company manages for other clients. Users will be able to search for assigned projects and start or stop tracking their time. This tracking feature will only be visible if the company has purchased the project tracking module. 2.1.4 Offline mode The application must remain partially operational when the tablet is offline because some employers, for example, use Alveno to track employees on construction sites. If the application is offline, the data is saved in local storage up until successful synchronization with the server. 6 2. ANALYSIS This means that while the application does not need to allow employees to view their statistics, it must enable them to enter records. These records will be synchronized as soon as an internet connection is established. Additionally, the application must check for time continuity to prevent malicious behaviour of an employee, as changing the device's time and skipping a few hours is easy. 2.1.5 PIN code generation Due to security risks, the application does not permit users to change their P I N codes. These risks include users creating easily guessable PIN codes such as 123-456 or one user guessing another user's P I N while setting up their own. Therefore, the application must allow users to generate a new PIN code, which must not be easily guessable, avoiding combinations like 111-111, 222-222, 000-000,123-456, or similar patterns. After enrolling the device, the administrator can distribute the PIN codes verbally, via email, or through other methods. 2.1.6 Settings The tablet mode should include a user-friendly settings screen that allows employees to generate a new P I N code. Additionally, administrators should have the ability to perform specific tasks, such as disabling the reader, pinning it to the screen, or viewing unsynchronized records. 2.1.7 Pinning of the screen This will be provided on Android by the screen pinning API provided by the operating system. Due to distribution reasons, lock task mode [7], which is a stronger version of screen pinning, cannot be used. On iOS similar APIs are not available, however, an accessibility feature called Guided Access [8] is available, which is analogue to the Android's screen pinning. 7 2. ANALYSIS 2.2 Phone mode The mode enables a single employee to log in and perform actions like those on the web. This effectively eliminates the need for employees to access the web UI for common tasks such as clocking in and out, entering vacation requests, and submitting timesheets. The user interface for the mobile mode should maintain consistency with the web application and utilize colours that mirror those used in the web version. The phone mode should support the following functionality: • Allow employees to log in using their existing credentials. • Show employees their information on the dashboard like the web version. • Allow employers to track employee attendance and project involvement, including GPS location at the time of attendance entry. • Show employees their timesheet with an overview and information about each day. • Allow employees to request leave, list them and view them in a calendar. • Allow supervisors to respond to leave requests and filter them. • Allow employees to view their work plan. • Allow employees to set entry P I N code and enable biometric authentication. • Allow employees to set their preferred initial tab when launching the application. • Provide alerts for actions like returning the timesheet, approval or rejection of exceptions (requests). These categories should be consistent with the notification centre in the web application. 8 2. ANALYSIS 2.2.1 Logging in Unlike enrollment in tablet mode, logging in through phone mode will require the user to sign in with their Alveno credentials. After entering the correct credentials, the server will verify the user's permissions and grant access to the application, provided they have the necessary permissions. Employees need to log in just once; after that, the token is issued, and they can open the application without having to log in. 2.2.2 Dashboard The dashboard will display statistics similar to those currently available in Alveno on the Web. This means users will have access to essential statistics, including their overtime hours, the number of meal tickets allocated for the month, their vacation time, and more. 2.2.3 Reader Employees use the reader to track their arrival and departure, along with other exceptions. These exceptions can be set in the Alveno web application. Employers can also set a policy to force the employees to enable their GPS to mark their arrival or departure location. This is useful in many scenarios, such as construction sites or house cleaning jobs, but not limited to those. If the employee decides to disable or limit the GPS location, they cannot use the reader until they enable the location services. Additionally, if the location is saved, the employee can display it under the given exception record in the day details or in the timesheet. 2.2.4 Workload Planning Workload Planning operates as a module within Alveno. With access to this feature, employees can utilize a straightforward calendar view or a list view to view their work plans. They will not be able to modify the plan in any way for now. 9 2. ANALYSIS ©A\veh6 © ».,2024 - © W-Wa . . . . . . _ 18/130 a __ Figure 2.4: Calendar overview in the web version of Alveno 2.2.5 Absence requests The absence requests tab will allow the employee to see the requests they planned for the upcoming month in a calendar. Employees can also request leave on this screen and see the state of their requests, whether the requests were declined or approved and any comments regarding requests. The employee can also request a new absence here, or if the employee is a supervisor of other employees, they are going to be able to see the employees' requests and react to them. 2.2.6 Settings In the settings, users can manage application preferences, including options for biometric authentication and selecting their default tab. 2.2.7 Timesheet The timesheet screen will be read-only, meaning that, unlike in the web version, employees cannot make manual changes to the timesheet, such as modifying working hours or shifts. The modification will, however, be present in later versions, as it is an essential function. The timesheet will utilize the same set of icons as the web version to indicate manual edits to shifts, errors in records, and manual record 10 2. ANALYSIS editing. Additionally, the timesheet will display bonuses, overtime, and negative balances. Every icon can be long-pressed to reveal its meaning. Employees will be able to view their timesheets for a given month and submit them if they are happy with it. 2.3 REST API communication The application communication is going to be built using RESTful APIs. REST API is a set of rules and conversions for building and interacting with web services[9]. As said earlier in Section 2, the API will be built on Windows Communication Foundation (WCF) and communicate over HTTPS and secured using an Authorization token, which will be generated upon successful login. It should be noted that mobile endpoint service supports two basic paths for differentiating between tablet and phone mode application calls - PhoneAPIService.svc and TabletAPIService.svc. The supported endpoints of the REST API are as follows (at the time of writing). 11 2. ANALYSIS Method Endpoint POST account/login POST account/logout GET account/me PUT account/push-token Description Tries to log the user in. If multiple instances are detected, it returns them for the user to choose one; otherwise, returns the authorization token. Invalidates the authorization token and deactivates the device. Returns user information about the current user. Registers push token after the user has accepted notification receiving. Account-Related Endpoints (Phone) Method Endpoint Description GET GET dashboard/overview dashboard/interruptions-graph Gets information about the current workload, such as its balance and remaining vacation time. Gets information about every day in a given month to be displayed as a graph. Dashboard Related Endpoints (Phone) 12 2. ANALYSIS Method Endpoint Description GET work-plan Gets the work plan for the given month. Work Plan Related Endpoints (Phone) Method Endpoint Description GET GET absence-requests/overview absence-requests/initial-data Returns data such as allowed exceptions and their information (icon, name, whether it can be halved). Returns an overview of the user's absence requests and supervised employees' absence requests. Creates a new absence request from the given body. Changes the state of the absence request; requires the given workload to be a supervisor. POST absence-requests/create PATCH absence-requests/state Absence Requests Related Endpoints (Phone) 13 2. ANALYSIS Method Endpoint Description GET contracts/reader Gets the allowed projects in "in-work" mode for the user to start recording. GET contracts/entries Gets entries for the project recorded on the given date. POST contracts/tracking Starts tracking on the given project. If none is given, stops the tracking. POST contracts/note Saves a note for the given record. GET contracts/dashboard Gets projects that are being worked on for the given time period. Project-Related Endpoints (Phone) Method Endpoint Description GET reader Gets buttons mapping, last entered exception, and whether or not geolocation is forced. POST reader/add-entry Adds an attendance entry to the timesheet for the current timestamp. POST reader/set-note Sets a note for a given day. GET reader/exception-ent: ries Gets entered exception entries for the given day Attendance Reader Related Endpoints (Phone) 14 2. ANALYSIS Method Endpoint Description GET timesheet Gets day-by-day timesheet data of the given workload for the given month. GET timesheet/data Gets timesheet summary, such as balance and overtime, of the given workload for the given month. PATCH timesheet/state Sets the timesheet state to the given state, for example, marks it as submitted. Timesheet-Related Endpoints (Phone) Method Endpoint Description PATCH admin/regenerate-pin Generates a new PIN code for the given workload. DELETE admin/device Deactivates the authorization token associated with the device from which this path was called. Admin Related Endpoints (Tablet) Method Endpoint Description GET enrollment/information Retrieves information from the server about the company. POST enrollment/device Similar to log in - creates the device and returns the authorization token to be used on the specific device. Enrollment-Related Endpoints (Tablet) 15 2. ANALYSIS Method Endpoint POST synchronize Description Main synchronization method for synchronizing unsynchronized records. More details in Section 4.3. GET synchronize/workload Retrieves information about the given workload OID (its balance, vacation,...). Synchronization Related Endpoints (Tablet) 16 2. ANALYSIS 2.4 Available Tools There are many tools for the development of native and near-native mobile applications, and this section is dedicated to the reasons why React Native was chosen. Initially, the options considered were as follows: • React Native • Flutter • Ionic • .NET MAUI • PWA • Native Development (iOS, Android) The final requirement was to develop applications for both A n droid and iOS. Developers at my company needed to be proficient in the language to be used, which eliminated Flutter and Native Development, as they require entirely different languages (Dart and Swift/Kotlin, respectively). PWA was ruled out due to its web-based nature and poor track record with the Apple A p p Store and its ecosystem. Apple clearly states in their A p p Store Review Guidelines that applications should be app-like, not merely web clippings [10]. Although Ionic is web-based, it utilizes Cordova or Capacitor as its bundler and can create native application packages for distribution on app stores. However, since Ionic is built on the Angular framework, it was also eliminated, as our team primarily uses React for development. Finally, I chose to discard .NET M A U I due to its relatively small community, support and ecosystem compared to React Native. In conclusion, React Native emerged as the best choice. It boasts a large community and an extensive ecosystem and is based on JavaScript, which aligns well with our team's experience. 17 2. ANALYSIS 2.5 React Native React Native (RN) is an implementation of React that can be run crossplatform and interact with native environments. It is open-source and developed by Meta. Unlike React JS, which runs in the browser1 , which allows developers to create cross-platform applications for Android, iOS, Windows, macOS or the aforementioned web. Its premise is to enable developers to "Learn once, write anywhere" [11]. This is achieved by creating a translation layer called the "Bridge" [12], which facilitates communication between JavaScript (using JSON data) and native code. Developers can also create native components, which can then be used from the JavaScript code-base. Since the platforms cannot natively understand JavaScript, it uses a JavaScript Virtual Machine on iOS and Android[13]. Both React and React Native make use of so-called JSX components, which are similar to H T M L (Hypertext Markup Language) and look like H T M L embedded in JS. A simple JSX component written using R N can look something like the one shown in Figure 2.5. This simple component uses components View and Button from R N and also React Hook useState. React Hooks are functions that are prefixed with "use" and can be used only within JSX components or other hooks. These hooks cannot be called conditionally, so they can only appear at the top of the JSX component. As the specific useState hook is quite complex, more information can be found in the React documentation useState. This component will, therefore, first use the state hook and initialize it to the value 0. Then, it renders the View with the Button and text "You pressed me «count» times1 .". The onPress event on the Button increases the count by one every time the user presses the button. A n example of the component's output is shown in Figure 2.6. 1. There is also ReactDOM functionality, which allows React JS to server-side render (SSR), similarly to P H R One notable framework is NextJS, which leverages SSR. 18 2. ANALYSIS function HelloWorldO { const [ count, setCount ] = useState(O); return (