FACULTY OF MATHEMATICS AND INFORMATICS A Translation Study Case: In Dubious Battle by John Steinbeck Final thesis: Android application for managing… [305527]
2020
UNIVERSITY OF PITEȘTI
FACULTY OF MATHEMATICS AND INFORMATICS
A Translation Study Case: In Dubious Battle by
John Steinbeck
Final thesis: [anonimizat] "EZ-Ticket", any event organizer user has an easy and convenient way to analyze attendance figures and manage access to the event .
Its primary use is to have clerks use it as a scanner at the gates. Each barcode scanned off of an event ticket is compared to those stored in the database. [anonimizat]. The application takes into account various cases when scanning a barcode. If a [anonimizat]. [anonimizat] a barcode. [anonimizat].
[anonimizat], [anonimizat] a particular event. Also, [anonimizat] (a known, given number) is lowered by one. This feature was implemented to comply with safety regulations and to help organizers avoid overcrowding.
[anonimizat], interface and logo are as important as functionality itself. The name conveys the idea of convenience and simplicity. [anonimizat] a blue ticket with the letters „EZ” incripted, on a white background. The color scheme for this application is in fact a combination of white and blue. White was used mostly for backgrounds and blue for action bars. Overall, the interface was kept simple and easy to use to underline the convenience and simplicity aspects.
The company with the name “Android” started with the design and development of her own operating system in the summer of 2005 when the google bought this. Android works with a Linux-Kernel from Sun Microsystems (Oracle since 2010) [anonimizat]. To develop new applications for desktop PCs many programmers prefer Java or C. To developing new apps for smartphones in Java are easier for them. Apple released in 2007 their iPhone to achieve the next goal in computing.
[anonimizat], is generally refer to as a phone, which is a poor labelling. [anonimizat]. In 1992 [anonimizat] a Smartphone to a wider audience. [anonimizat], [anonimizat]. The Android platform was spawned from the efforts of an organization known as the Open Handset Alliance (OHA), which had at the outset the mission of collaborating to “build a better mobile phone.” Today, [anonimizat], as the latest news item dates to 2011.
However, [anonimizat]urers, and software vendors has grown into the world’s most popular platform. Is Google the “man behind the curtain” of the OHA? Maybe, but no matter. In the decade since its introduction, Android is offered in the market by many large players across the globe and across numerous industries. Samsung, also a member of the OHA, is the leading manufacturer of smartphone devices worldwide, thanks to Android. Although a single device (the G1 device manufactured by HTC and provisioned on the T-Mobile network) started it all, Android devices are now available in virtually every market on the planet — not just for mobile phones.
Chapter 1. Fundamentals of Android
What is Android?
Android is an operating system and programming platform developed by Google for mobile phones and other mobile devices, such as tablets. It can run on many different devices from many different manufacturers. Android includes a software development kit (SDK) that helps you write original code and assemble software modules to create apps for Android users. Android also provides a marketplace to distribute apps. Altogether, Android represents an ecosystem for mobile apps.
In the market they are already several competing mobile phone software stacks, so why is there such interest in Android?
In the development and sale of a new generation of mobile phone application software android has the potential for removing the barriers to success. Just as the standardized PC and Macintosh platforms created markets for desktop and server software, Android, by providing a standard mobile phone application environment, will create a market for mobile applications and the opportunity for applications developers to profit from those applications. In the developers’ conference from May 2013, Google presented the new development environment for. The new IDE is intended to replace Eclipse and is based on the "IntelliJ IDEA" Java-IDE by JetBrains. The powerful Code-Editor with built-in functions such as "Smart Editing", which ensures better legible code, or "Advanced Code Refactoring” is one of the core components of Android Studio. Android Studio introduced another novel feature for the Gradle Build System . It replaces the Ant Build System used until now. Gradle allows developers to create various configurations so that different app versions can be produced using the same code. When you want to release a free and a paid version this is really useful for an app. Gradle improves the reusability of the code and the integration on a build server. Similar to Eclipse, the layout of an app can be created either in the text editor or in a graphical interface (design mode) in Android Studio. The Android Studio design mode was improved whit the layout who shows the different resolutions, Android versions and country-specific special features in the preview. In Android Studio were integrated a series of new features and services. The developer console gives developers tips for optimizing an app and it also allows uploading the “string files” (strings.xml) to be translated to a central server, and to insert them again in the app after translating them. Android Studio was enhanced with an option to add Google Cloud Messaging (CGM) to the project that allows sending messages to the app and receiving the messages from the app on the cloud server. It is not a new feature to connect an Android app with a cloud server/ App Engine Server app. Novelty for Android app was the integration in app project . Earlier, it was essential to create an App Engine Server app and an Android app that is sup- posed to work with this server app separately from each other.
Google in collaboration with JetBrains has been developed Android Studio and is based on the community version of IntelliJ. JetBrains Java IDE InelliJ sup- ports Android app development since 2 years. IntelliJ Version 12 has new features that have been developed in collaboration with Google, but not yet integrated. These will be integrated in Version 13+. Like before, even the new version will support a series of development environments such as Java, Android, Adobe Gaming SDK, Groovy, Scala. Android Studio will be restricted to the development of An- droid apps. Google has not specified an official release date for Android Studio. Android Studio is still being developed and should not be used in the productive app development as yet. However, since a major part of the IDE is already functional, users can still start befriending Android Studio. This is recommended since they can rev up once the finished version is released.
About Android
Android is an operating system based on the Linux kernel and designed primarily for touchscreen mobile devices such as smart-phones and tablet computers. Android was created by Andy Rubin as an operating system for mobile phones around the beginning of twenty-first century. In 2005, Google acquired Android Inc., and just after made Andy Rubin the Director of Mobile Platforms for Google. This was a great business decision for Google to purchase the talent and intellectual property necessary to assert the company into this emerging space, which has been become known as Internet 2.0.
Internet 2.0 was a great step in the history of computer science. It allows users of consumer electronics to access content via varied data networks through a lot of portable consumer electronic devices, such as touchscreen tablets, smartphones, e-books, iTVs and set-top boxes. This thing has had a big impact by putting new media content such as 3D animation, digital audio, games, HD imagery into our lives at every turn. Android has become a great tool that digital artists will use to develpo media creations that users have never experienced before. Over the past years, Android has evolved into an extremely reliable operating system platform, having gone from version 1.0 to more stable versions at 3.0, 4.4, 5.0, 7.0. Today, Android has the power of a full-blown computer operating system. It is based on the Linux open source platform and one of the world’s most popular programming languages Oracle’s Java.
How do Android Apps Work?
There are different ways the programs run on various platforms. The lowest level software can be written in machine code that runs directly on the microprocessor. This is shown in Figure 1.2. Since it is difficult to develop complex applications in machine code, operating systems are used. Operating systems provide a communication and control layer between the application software and the hardware as shown in Figure 1.3. If we want to develop a native application for running on a specific hardware/operating system, we have to do this using a compiler and linker. Compiler and linker takes the source code and creates the executable file that actually runs on the operating system as shown in Figure 1.4. For example, if we want to develop an application in C++ programming language, we have to utilize the compilation/linking process.
Figure 1.2. Machine code – hardware relation
The main advantage of native applications is their speed. However, the disadvantage is the incompatibility across different platforms. For example, we cannot run a native Windows application on Ubuntu and vice versa. Virtual machine concept is developed to overcome this limitation. Virtual machine is software that runs on the operating system and provides an abstraction to the developer as shown in Figure 1.5. The application software runs on top of the virtual machine.
Figure 1.3. Operating system layer between the hardware and the app
Figure 1.4. Creating a native executable from the source code
Therefore, as long as a computer has the virtual machine running, the application software can run on that computer independent of the hardware and the operating system. A good example is the Java Virtual Machine (JVM). JVM runs on almost all operating systems and platforms. Therefore, when we develop Java software, it will be run on the JVM independent of the operating system/platform.
The obvious advantage of developing apps that run on virtual machines can then be stated as: “develop once and run on all platforms”. However, applications running on virtual machines are slower than native applications.
General development process of virtual machine applications is summarized in Figure 1.6.
Figure 1.5. Virtual machine between the app and the operating system
Figure 1.6. Creating an intermediate code from the source code – intermediate code is interpreted by the virtual machine
Similar to Java applications, Android applications also run on a JVM. There are two special virtual machines used in Android: Dalvik Virtual Machine (DVM) and Android Runtime (ART). These are specialized JVMs which can run on low system resources. The .apk files (executables of Android apps) actually run on these virtual machines. DVM has been the default runtime environment (~ virtual machine) until the Lollipop release (Android 5.0). ART is introduced by Android 4.0 and has been the default VM as of Android 5.0. DVM and ART basically do the same job: running Android apps independent of the platform. The main advantage of ART over DVM is the utilization of a concept called Ahead of Time (AOT) compilation instead of Just in Time (JIT) approach. In AOT, apps are compiled during installation hence they load faster with lower CPU usage. On the other hand, JIT compilation provides lower storage space consumption with relatively longer loading times.
The evolution from the first to the latest version of android
In past mobile phones were used only to make calls but with the introduction of smartphone the mobile phone has evolved to a low powered hand held processing system. This evolution was caused by the operating system for the mobile phones making them smart that have processing and storage of their own.
Now the mobile provides numerous functionalities from calling to texting, multimedia sharing, emails, socializing applications, word processor, excel sheets to various multiplayer games and much more. The operating system for these is Android by Google. Among the competitors in smartphone operating system industry Android holds the largest market share in terms of units shipped worldwide and number of users. Android is an open source operating system based on Linux kernel on which applications run on an application framework that controls the activities supported by the libraries and Dalvik virtual machine which compiles and converts all java class files into a single file. There can be number of virtual machines running simultaneously on a single device handling different applications or instances of an application. Android operating system provides memory management, process management to the applications and services running. Each release of android improved user experience and brought enhanced features. This paper presents a study of evolution that each release brought to the android operating system
Smart phones in today’s world have become so popular that they have captured a big economical market along with a large number of users each using different types of smart phones with varying features. The most prominent thing that distinguish smartphones industry and their user base is the operating system being used among which popular are Android, iOS and Windows phone. With the statistical figures from International Data Corporation (IDC), the smartphone industry grew by 1.1% last year and by third quarter of the year more than 350 million units were shipped worldwide. Android has maintained its position on score board with market share of 86.8%.
This increase in the demand of android phones trade, customers concern is to select and buy the phone that meets their requirement within affordable price. In the present era of competition different vendors are trying to make profit by using the Android OS because of its acceptance among the users. With each day the struggle and efforts been put to give an operating system that is compatible with most hardware and provide all the necessary feature to the users in an efficient way Android production is growing. Every corporation desires to give best quality in their android phones and as well improving features to be its main objective. The immense usage of android lead in the direction of advance method about usability, multitasking, accessibility, protection of end user-private data and many more, in which each release is expected to cater the mentioned issues provide something new to the user. The architecture of the android phones was first developed by Android Inc. now owned by Google and launched Android Open Source Project in 2007. That statement was taken by the foundation of the Open Handset Alliance.
The software used in it launched under the Apache license as an open source. The Open Handset Alliance is a collection of many hardware, software and telecom Firms may also include Intel, Google, NVIDIA, Qualcomm, Motorola, HTC and T-Mobile, in which Android is the adapted-able OS. Its core objective is to build up advance equipment according to its technology that may considerably less the time and cost as well and also enhance the services and provides best features to customer. At present android version in use are kit Kat, Marshmallow and ginger bread. Table below shows the history of Android operating system from initial release to the day. Operating system that acts as a bridge between user and the hardware, same is with Android OS. We talk about android Operating system the latest version is Nougat this version upgraded up to 7.0-7.12 which is based on Linux 4.4.1 kernel that consist upon layers, the architecture of which is shown in figure 1. The application layer in an android operating system is the top layer that include utilities like SMS, contacts, phone, browser, camera, media player, cleaner, etc.
All of which are develop in Java programming language. The utilities or applications require application framework as a base to setup up and work. Application framework is large set of analysis used for developing an apps with attractive GUI that may consist of check list, navigation menus, text box, button, check box, and more likely an embedded and responsive web browser. A Resource Manager provides access to resource as well but not access to source codelike restricted String, GUI and design.
Table 1. Versions of Android Operating System
Notification Manager enable all apps to show routine alert on the screen. Activity Manager Control the lifecycle process of apps also offer an ordinary routing back stack. Beneath library layer consist a set of java library files applied by wide range of the Android Operating system processes and also offer maintenance to the Application framework. In Android Runtime layer focus is on the set of core libraries and a Java Dalvik VM Dalvik virtual machine which can redevelop and adapted via Google to become suitable source for Android OS. Linux kernel is placed at the bottom layer of android OS to perform the task of fastest layer among the hardware and software of Android. It may also provide major structure services of Operating System like protection/security, memory management, processes functions, network system, driver modules and functions such as management of threads of Dalvik virtual machine included in the Linux kernel system.
Fig 1. Architecture of Android Operating System
Android operating system run in the Linux kernel, its application are developed in Java language so its task is to execute the applications on Java virtual machine called Dalvik VM. Dalvik has been redeveloped and optimized by Google as for the hardware aspect of smart phone devices. In smart phone operating system a tool called .dx exist in the smart phone software development kit which convert Java files compile in a standard Java compiler into the dex formats, that join together all of the Java class files and remove unnecessary data in each Java class files. Characteristics of Dalvik virtual machine is as follows; Smart phone application run in a instance of a Dalvik virtual machine. There may exist various instances of Dalvik virtual machine instance on single machine, each instance runs in the form of chunks or separate Linux process. Dalvik virtual machine depend on the original OS Linux kernel for the execution, isolation memory manage process and threads supporting. Dalvik virtual machine is register based process.
Each application in android operating system is running separately of other and has memory spaces reserved for them making each one data inaccessible to others.
For communication among applications message parsing is used. With the release of Android cupcake in 2009 API level 3 was used and the operating system supported widgets, search browsers, navigation applications that included free data of map to act as a navigation device. Content can be updated and synchronized over the internet without the need of a computer system. Android Donut Operating System released the same year of cupcake used API level 4 that provided the features of phones screenshot capture and voice commands along with the features that were available in cupcake. To enhance user experience Android Éclair release used API Level 5 that enabled the operating system to support low density display screens from 320×240 to 854×480 high density screens. Instead of separate navigation centralized access was provided to user by selecting a contact on which call, message and email can be made with a tap.
Manage multiple email accounts with a universal account. Search and time based deletion of SMS and MMS. Camera, browser features were improved and virtual keyboard was introduced with intelligent auto correct feature. To accelerate the hardware graphics architecture was modified for better performance. With the next release of froyo by Google it was claimed to have the fastest browser than any other smartphone would have in 2010 that used API level 8 with an improved performance rate of 2.5 times then all the previous versions released. To improve the security of the devices alpha numeral and numeral options were added in password and remote access to reset device data in case of theft or robbery to protect the privacy and integrity of the users. Before the release of froyo android operating system only allowed installation of the applications to be done on the device memory, whereas with froyo users can now install the applications on the external media as well. Among improved camera features and remote access through android cloud APIs for gesture detection for multi touch and OpenGL 2 for ETC1 text compression, YUV images was also supported by the operating system.
As the android operating system was initially developed by Android Inc. which was based on Linux kernels so google did not do the things from scratch and focused on providing better user experience by continuing the work of Android Inc. Platform was initially developed by Android Inc. So, with the release of Android gingerbread with API level 9 Linux kernel was upgraded to 2.6.35 due to which the operating system was now able to manage power more efficiently with refined user interface. New devices were coming popular in market that have large displays, and need for communication over internet. With android gingerbread near field communication (NFC) was added that could have high frequency communication with in the radius of 10 cm. To meet the market demand gingerbread supported SIP: Session Initiation Protocol for audio and video calling if the device has a 3g or Wi-Fi connection of internet. The introduction of SIP broke the traditional barriers of communication and the worry for billing for its users. Other features included audio encoding, video playback, multi touch virtual keyboard and gyroscope sensor which in extension to accelerometer that sense the alignment of phone calculates the rotation rate around x, y and z axis which can also be termed as twists. Accelerometer measured the linear and gyroscope measured the angular movement of the device this addition paved way in support of virtual reality
With the second big release of honeycomb in 2011 google also introduced its first smartphone Nexus S in liaison with Samsung. Honeycomb revolutionized the android operating system by the support of multicore processor environment with symmetric multiprocessing due to which multitasking was possible with all screens active at the moment. This update to the operating system was a major advancement among other updates that include enhanced web browsing experience, google talk, 3d effects in google map and multiple home screens to let the user customize the interface as per their wish. The last release of 2011 was ice cream sandwich API level 14; the ice-cream sandwich release was compatible with both low and high resolution devices. Multitasking ability of operating system was further enhanced in which the opened applications can be switched in between by seeing the list of running applications. Notifications appearance was enhanced by removing the popups and showing them in the top of the screen where a certain a notification will show its detail on tap. Ice cream sandwich operating system was improved to open microphone voice command for which the system is always ready to receive voice commands and process them instead of first starting the service before use. While the device is lock previously all applications are stopped and cannot be accessed whereas in ice cream sandwich operating system lets user answer the incoming calls, move among the playing media, and for authorization of user in addition to alpha numerals and numerals face lock feature is introduced to verify the authenticity of the user. Pertaining to the users demand camera features were refined that included increased snap shot speed, continuous focus, zero shutter, panorama for image and at the same time recording videos of high definition. Ice cream sandwich release paved the way for future in which innovative, interesting, customized applications and features can be provided to users. Example of which is Android Beem based on NFC that would allow the users to share the content at a much higher speed which was not possible before. Jellybean release came in 2012 with API level 16 that revamped all predecessors not in terms of speed and performance but user experience in which all core features of Ice cream sandwich were intact with widgets being intelligent to replace themselves based on the addition or deletion of any widget instead of lying still. For smooth user experience user interface design, had refresh rate of 60 frame per second to make it more responsive. Other enhancements included support for five languages with right to left languages support, digital rights management, security measures, low energy Bluetooth for audio, video calling and remote access. A drawback in the schema was operating system does not prevent acquisition of device location even though Wi-Fi is turned off.
KitKat operating system was released in 2012 with API level 19 in which the along with user interface focus was equally put on speed and performance as well that was achieved with improved multiple sensors feedback, use of tri-core CPU, improved battery usage for long lasting battery time, resolution up to four thousand and updated schema for user interface. With KitKat operating system applications installed in devices can be exchanged with other device and all previous versions of android were upgradeable to the KitKat. The edge to edge technology enabled the users to not only remotely access their device but also to perform activities like cloud printing, managing resources and many more. Android lollipop with API level 21 was released in 2015 to enhance users’ experience with 3D views now elements can be viewed in real time with shadows as the object moves. With shared visual elements transition of elements from one state to another is done smoothly and seamlessly. With the new design threads are rendered for smooth execution of animations even though there comes a delay in the user interface main thread. The lollipop version does not compromise on the performance of system for which it runs on new Ahead of time just in time and Android Run Time codes built from scratch to meet the needs that supports 64-bit MIPS and ARM architecture. This update fulfilled the need to efficiently reduce garbage and keeping the applications responsive without affecting their performance. To strengthen the claim of high performance android KitKat offers enhance audio, video synchronization by the use of pipelining for smooth output. For productivity, new sensors were introduced that included sensor for heart rate, to detect interactions such as flick, swipe, pinch etc. interaction sensors and for activity recognition tilt sensor. The new added APIs improved battery performance, accessibility, web view, screen capture and camera features.Android marshmallow API Level 23 was released same year of KitKat in which finger print detection was introduced with which number tasks can be performed such as unlocking the device, answering incoming call and holding up outgoing calls, browsing images in gallery, capturing and recording in camera and many more but as per security authenticity and integrity of users’ device and data operating system was able to provide an extra added layer by fingerprint sensor. Previously when an application was installed it was mandatory to grant all the permissions asked at the time of installation and it cannot be altered later on. With marshmallow, it lets the user change the application permissions to empower the user. For fast charging type C cable was introduced and doze mode enables operating system to save more power and can almost double the battery time. Notifications and camera can also be accessed while the screen is lock. The most recent release of android operating system is Android Nougat with API level 25 in 2016. In nougat operating system, the most prominent feature is of multitasking of applications in split screen. With marshmallow performance, look feel and performance was delivered to the best and nougat focus was to improve the existing features provided by marshmallow.
Table 2. Features of Android Operating System
Android versions history
The version of android is updating day by day since its relase.
Now, the question comes, why is a new version always needed? It is very simple, these updates to the base operating system mainly focusing on fixing bugs as well as adding new features to provide more comfortable environment.
This is the most recent released versions of android:
Let’s say something about each one and see every novelty they came up with.
Gingerbread
Launched in December of 2010, Android Gingerbread was the first major overhaul of the OS, bringing cutting edge technologies like NFC (near-field communication), while improving performance and application management. Additionally, the user interface was given a makeover to facilitate user interaction and minimize resources.
Unlike previous versions of Android, Gingerbread received updates for a long period of time. Mainly, this was due to the fact that version 3.0 Honeycomb was tablet-only, thus mobile carriers continued selling phones that ran on Android 2.3, making it a key target for developers for the next two years. This version refined the user interface, improved the soft keyboard and copy/paste features, and added support for Near Field Communication.
Fig 1. Gingerbread android interface
Ice Cream Sandwich
Android 4.0 also upgraded the interface, while still adhering to the holographic standard set the previous version. Monotone white and grey tones were removed from the menu and a new font was introduced ,"Roboto", specially designed for smartphones with high resolution screens. Although the icons used had a futuristic design, they lacked the science-fiction style of Android Honeycomb.
This version in particular, placed a great deal of focus on details. Among others, all the lines and useless buttons were removed from the design and a few interface behaviours were implemented. For example, a flash of blue energy when scrolling to the end of a list, or a glowing outline when icons would be rearranged. Into a "cohesive whole.
This version had new features added to the Smartphone’s Such as photo enhancements, offline email searching, facial recognition unlock, network data, and usage monitoring Furthermore, Ice Cream Sandwich brought common design elements to Google's own applications , like the action bar and overflow menus. These design traits would evolve over time, but the most important aspect of this version were the guidelines implemented by Google. Although it was unprecedented, this was done in order to aesthetically blend applications in the "Holo" ecosystem. There were also changes regarding functionality. Following the trend set by tablets, smartphones now had buttons on the touchscreen. A specially dedicated button to switch between recent applications was added too, as more and more users used their phones for multi-tasking.
Fig 2. Ice Cream Sandwich interface
Jelly Bean
From a mechanical point of view, Android had come a long way from its first version on the T-Mobile G1. Now, the second phase of development would focus on performance improvement. More precisely, reducing the execution time and resources needed to carry out any given task. The first steps in this direction were made once Android 4.1, informally known as Jelly Bean, rolled around. The special attention this project got made version 4.1 the longest running Android version of all time, receiving updates from summer of 2012 to autumn of 2013.For developers, new accessibility APIs were added, expanded language support with bi-directional text support and user-supplied keymaps, support for managing external input devices (video game controllers), and low-level access to hardware and software audio/video codecs . In this version, the home screen was presented with new features, like the ability of shortcuts and widgets to rearrange themselves when moving or resizing an item, and the notification system was improved, introducing the concept of "consumable" and "actionable" notifications .Now that Android was regarded market leader in most countries around the world, aspect played a more important role. Fluid transitions, improved scrolling animations and an overall smoother visual experience were pivotal to this project.
This was also the first version to introduce Google Now . By monitoring commonly input keyboard data from conversations or internet searches, Google Now would proactively deliver relevant results to the user, in the form of "cards". Specialized cards existed for birthdays, movies, nearby events or locations, sports, restaurant reservations and weather, among others. At the time, the feature was virtually praised, being named "Innovation of the year" for 2012, by Popular Science magazine. The new focus on responsiveness with Project Butter, Jelly Bean brings multi-user accounts, actionable notifications, lock screen widgets, quick-settings in the notification bar, Photosphere to the "stock" Android camera and Google Now. Jelly Bean is hailed by many as the turning point for Android, where all the great services and customization options finally meet great design guidelines.
Fig 3. Jelly Bean interface
KitKat
The android version KitKat was launched on October 31st 2013, and although it did not represent a total re-think of Android's visual style, it did bring some changes. Translucent status bars and software keys opened up the large 5-inch screens of the time, and lighter, brighter colors throughout the UI made Android seem more approachable .
Moreover, the built-in application launcher was revised to incorporate Google Now to the leftmost panel of the home screen, underscoring thus the importance of predictive search to Google's vision of Android. Starting with the focus on visual improvement for Android 4.1, the main goal of this version was overall performance improvement, particularly on low-end devices. A special developing tool entitled "procstats" was engineered to analyze the random accessed memory for applications, especially those running background services . The collected data was then used to optimize and decouple the inefficient applications and programs.
The KitKat android version brought a lighter, flatter and far more colorful look to Android, but many more changes were under the hood. These were the foundation for things like the Google Now launcher, SMS integration with Hangouts, and easier and faster use all around.
Fig 4. KitKat interface
Oreo
It contains a number of major features, including notification grouping, picture-in picture support for video, performance improvements and battery usage optimization, and support for autofillers, Bluetooth 5, system-level integration with VoIP apps, wide color gamut’s, and Wi-Fi Aware. Android Oreo also introduces two major platform features: Android Go – a software distribution of the operating system for low-end devices – and support for implementing a hardware abstraction layer.
The aspect of the OS was kept mostly unchanged from previous versions, with a few minor changes. The "Settings" application features a new design, with a white theme and deeper categorization of different settings, while the ringtone, alarm and notification settings now contain an option for adding custom sounds to the list . The Android 8.1 update supports the display of battery percentages for connected Bluetooth devices, made the notification shade slightly translucent, and dimmed the on-screen navigation keys in order to reduce the possibility of screen burn
Fig 5. Oreo interface
Lollipop
The android 5.0 Lollipop was released by the Google with the Nexus 6 and Nexus 9, and it ushered in a new design language and support for 64-bit devices. It's also the first time Google has provided developer beta previews of the software.
This android version was launched in October of 2014 and it came with a radical change of style, having the "Holo" design pattern replaced with "Material Design" . This meant brighter colors, thinner fonts and a meticulously thought out design, with many grid-based layouts that built on the idea of folding layers of paper. Notifications could now be accessed from the lock screen and displayed inside applications, as banners placed in the upper part of the screen. For the first time ever, design guidelines and thousand of new APIs were released to developers beforehand, through the "Android L" package
Still, Android Lollipop did not bring changes only on a design level. The new "Tap and Go" setup process made it simpler to transition from one version of Android to another, "Guest" mode and pinned applications were developed for situations when somebody else other than the user would control the device and "Overview", the new multitasking view, made for a better way to switch between applications . Moreover, Google made internal changes, with Android Runtime (ART) officially replacing Dalvik, thus improving performance .
A number of system characteristics focused on separating personal and professional data were introduced as well, under the moniker "Android for Work" . Furthermore, with the "Smart Lock" function, devices could be configured to remain unlocked while in a certain location or connected to a specific Bluetooth device . Lollipop was also supposed to have built-in device encryption on all capable smartphones. However, due to performance related issues, this feature was postponed until the next version
Fig 6. Lollipop interface
Marshmallow
Android 6.0 gets better control over permissions, allowing you to control what parts of your data apps can access, rather than approve it by simply installing the app in the first place. That's just the beginning, and features like app linking and the new Assist API will allow developers to build better and more powerful apps.
Perhaps the biggest improvement of this version was the redesigned permission-model. This meant applications were no longer automatically granted all of their permissions at installation time. Rather, an opt-in system was now used, in which users were prompted to grant or deny individual permissions (such as the ability to use a device's camera) when they are needed for the first time. The grants are remembered and can be revoked by the user at any time . However, the new model can only be used by applications developed from Marshmallow onwards, with older applications retaing their all-or-nothing approach
Fig 8. Marshmallow interface
Nougat
Nougat introduces notable changes to the operating system and its development platform, including the ability to display multiple apps on-screen at once in a split-screen view, support for inline replies to notifications, and an expanded "Doze" power-saving mode that restricts device functionality once the screen has been off for a period of time. Additionally, the platform switched to an OpenJDK-based Java environment and received support for the Vulkan graphics rendering API, and "seamless" system updates on supported devices.
On the user interface side, Nougat redesigned the notification shade, which now featured a smaller row of icons for settings, replacing notification cards with a new "sheet" design, and allowing inline replies for notifications. Moreover, this version introduced the concept of bundled notifications, and greater per-application control over them.
Fig 9. Nougat interface
Pie
Android 9 Pie brings Google's updated Material Design spec (don't call it "Material Design 2") to Android OS, and it begins a wave of UI updates that will spread across Google's entire portfolio. In Android, that means revamped interfaces for the notification panel, Recent Apps, settings, and various bits of system UI. For future smartphone designs (like, say, the Pixel 3), Android 9 includes an experimental gesture navigation system and built-in notch support. There's also a new screenshot editor, lots of improvements for text selection, and changes to the way rotation works.
Fig 10. Pie interface
Chapter 2
2.1 Android Studio User Interface
Android Studio is a powerful and feature rich development environment that is, to a large extent, intuitive to use. That being said, taking the time now to gain familiarity with the layout and organization of the Android Studio user interface will considerably shorten the learning curve in later chapters of the book. With this in mind, this chapter will provide an initial overview of the various areas and components that make up the Android Studio environment.
2.2 Welcome Screen
Any time that Android Studio “welcome screen” is displayed this is running with no projects currently open (the projects can be closed any time by selecting the File ->Close Project menu option). While a project was still open when android studio was exited, the tool will by-pass the welcome screen next time it is launched, automatically opening the previously active project.
The quick start menu offers, in addition to a list of recent projects, a number of options for completing tasks, such as opening, creating and importing projects along with access to projects currently under version control. In addition, this configure option provides access tot the SDK Manager with a vast array of settings and configuration options. Next I will present the fact that there is no aspect that cannot be modified in android studio according to the desired specification.
The status bar along the bottom edge of the window provides information about the version of Android Studio currently running, along with a link to check if updates are available for download.
2.3 The Main Window
The Android Studio main window will appear, when a new project is created, or an existing one is opened. Each one multiple projects will be assign its own main window when multiple projects are open simultaneously. The precise configuration of the window will vary depending on which tools and panels were displayed the last time the project was open, but will typically resemble like in the next image:
As we can see the menu is represented as follows:
A – Menu Bar – has a series of menus for placing orders in the android studio environment
B – Toolbar – represents a selection of frequently made shortcuts or shortcuts. Positioned as handy as possible the toolbar buttons provide quick access to a selection of actions on the menu bar. The toolbar can be customized by right-clicking on the bar and selecting the Customize Menus and Toolbars… menu option.
C – Navigation Bar – it is very simple to switch from one file or folder to another that make up a project using the navigation bar. Clicking on an element in the navigation bar will drop down a menu listing the subfolders and files at that location ready for selection. This provides an alternative to the Project tool window.
D – Editor Window – it shows the contents of the file the developer is working on and running. What gets displayed in this location, however, is subject to context. When editing code, for example, the code editor will appear. When working on a user interface layout file, on the other hand, the user interface Designer tool will appear. When multiple files are open, each file is represented by a tab located along the top edge of the editor as shown in next picture:
E – Status Bar – displays informational messages about the project and the activities of Android Studio together with the tools menu button located in the far left corner. Hovering over items in the status bar will provide a description of that field. Many fields are interactive, allowing the user to click to perform tasks or obtain more detailed status information.
F – Project Tool Window – The project tool window provides a hierarchical overview of the project file structure allowing navigation to specific files and folders to be performed. The drop-down menu in the toolbar can be used to display the project in a number of different ways. The default setting is the Android view which is the mode primarily used in the remainder of this book. The project tool window is just one of a number of tool windows available within the Android Studio environment.
2.3 The Tool Windows
Android Studio also includes a number of other windows which, when enabled, are displayed along the bottom and sides of the main window. For accessed the tool window need to hovering the mouse pointer over the button in the far left hand corner of the status bar without clicking the mouse button, like in image:
In order for the corresponding tool window to appear in the main window, it is necessary to Select an item from the access menu.
Alternatively, to displayed a set of tool window bars is need to click on the access menu icon in the status bar. These bars appear along the right, left and bottom edges of the main window and contain buttons for showing and hiding the tool windows. When the tool window bars are displayed, a second click on the button in the status bar will hide them.
The red arrows displayed in the picture above expose the fact that when we click on the bottom bar we will display the corresponding tool window whilst and a second click will hide it.The buttons can be prefixed with a number (for example 1: Project) which indicates that the tool window can also be displayed by pressing the Alt key on the keyboard. The location of a button in a tool window bar indicates the side of the window against which the window will appear when displayed. These positions can be changed by clicking and dragging the buttons to different locations in other window tool bars.
Along the top edge each tool window has its own toolbar. Although all tool windows contain a setting option, represented by the cog icon, which allows you to change different aspects of the window, the buttons in these toolbars vary from tool to tool.
The following picture shows the settings menu for the project viewer tool window. Options are available, for example, to unlock a window and allow it to float outside the boundaries of the main Android Studio window.
An additional way to hide the viewport window is to use a button on the far right of the toolbar. A search for items in a tool window can be done by simply focusing that window by clicking on it and then typing the search term (for example, the name of a file in the Project Tool window). A search box will appear in the toolbar of the window and the items that match the highlighted search.
The most used tools and window interfaces in Android Studio are the following:
Project – The project view provides an overview of the structure of the files that make up the project, which allows fast navigation between files. Generally, double-clicking a file in the project view will cause that file to be uploaded to the appropriate editing tool.
Structure – high-level view of the source file structure currently displayed in the editor is possible due to the structure tool. Existing information consists of lists of elements such as classes, methods, and variables in the file. Selecting an item from the structure list will take you to that location in the source file in the editor window.
Favorites – A variety of project items can be added to the favorites list. Right-clicking on a file in the project view, for example, provides access to an Add to Favorites menu option. Similarly, a method in a source file can be added as a favorite by right-clicking on it in the Structure tool window. Anything added to a Favorites list can be accessed through this Favorites tool window.
Build Variants – a quick way to configure the different compilation targets for the current application project is the tool window for build variants.
TODO – this tool provides a place to examine items that have not yet been completed in the project. Android Studio compiles this list by scanning the source files that make up the project to look for comments that match the specified TODO models. Revision and modification can be done by selecting the menu option File -> Settings … and navigating to the TODO page listed in IDE Settings.
Messages – The messages tool window records output from the Gradle build system and can be useful for identifying the causes of build problems when compiling application projects
Android – The Android tool window provides access to the Android debugging system. Within this window tasks such as monitoring log output from a running application, taking screenshots and videos of the application, stopping a process and performing basic debugging tasks can be performed.
Terminal – Provides access to a terminal window on the system on which Android Studio is running. On Windows systems this is the Command Prompt interface, whilst on Linux and Mac OS X systems this takes the form of a Terminal prompt.
Run – The run tool window becomes available when an application is currently running and provides a view of the results of the run together with options to stop or restart a running process. If an application is failing to install and run on a device or emulator, this window will typically provide diagnostic information relating to the problem.
Event Log – The event log window displays messages relating to events and activities performed within Android Studio. The successful build of a project, for example, or the fact that an application is now running will be reported within this window tool.
Gradle Console – The Gradle console is used to display all output from the Gradle system as projects are built from within Android Studio. This will include information about the success or otherwise of the build process together with details of any errors or warnings.
Maven Projects – Maven is a project management and build system designed to ease the development of complex Java based projects and overlaps in many areas with the functionality provided by Gradle. Google has chosen Gradle as the underlying build system for Android development, so unless you are already familiar with Maven or have existing Maven projects to import, your time will be better spent learning and adopting Gradle for your projects. The Maven projects tool window can be used to add, manage and import Maven based projects within Android Studio.
Gradle – The Gradle tool window provides a view onto the Gradle tasks that make up the project build configuration. The window lists the tasks that are involved in compiling the various elements of the project into an executable application. Right-click on a top level Gradle task and select the Open Gradle Config menu option to load the Gradle build file for the current project into the editor. Gradle will be covered in greater detail later in this book.
Commander – The Commander window tool can best be described as a combination of the Project and Structure tool windows, allowing the file hierarchy of the project to be traversed and for the various elements that make up classes to be inspected and loaded into the editor or designer windows.
Memory Monitor – Connects to running Android applications and monitors memory usage statistics in the form of a real-time graph.
Designer – Available when the UI Designer is active, this tool window provides access to the designer’s Component Tree and Properties panels.
Android Studio includes an abundance of keyboard shortcuts designed to save time when performing common tasks. A full keyboard shortcut keymap listing can be viewed and printed from within the Android Studio project window by selecting the Help -> Default Keymap Reference menu option.
Another useful mechanism for navigating within the Android Studio main window involves the use of the Switcher. Accessed via the Ctrl-Tab keyboard shortcut, the switcher appears as a panel listing both the tool windows and currently open files
Once displayed, the switcher will remain visible for as long as the Ctrl key remains depressed. Repeatedly tapping the Tab key whilst holding down the Ctrl key will cycle through the various selection options, whilst releasing the Ctrl key causes the currently highlighted item to be selected and displayed within the main window.
In addition to the switcher, navigation to recently opened files is provided by the Recent Files panel (Figure 4-8). This can be accessed using the Ctrl-E keyboard shortcut (Cmd-E on Mac OS X). Once displayed, either the mouse pointer can be used to select an option or, alternatively, the keyboard arrow keys can be used to scroll through the file name and tool window options. Pressing the Enter key will select the currently highlighted item.
2.4 Firebase
Introduction
In 2014, Google completed the acquisition of a San Francisco-based company named Firebase, Inc. Firebase, Inc. provided a range of developer solutions designed to accelerate the integration of cloud-based features into mobile and web apps. After purchasing the company, Google combined the services provided by Firebase with a number of complementary features previously included as part of the Google Cloud Platform. The combined features from the two platforms are what is now known simply as Firebase.
2.4.1 Structure of technologies
These technologies is connected together using Analytics. An important aspect of these technologies you can choose which that you want to use in your app or site.
I need to have in consideration about many of the technologies because are available at no cost like Analytics, App Indexing, Authentication, Cloud Messaging, Crash Reporting, Dynamic Links, Invites, Notifications and Remote config, but others they are having a free tier that will work for testing and with reasonable limits for smaller apps. An example is Realtime Database, in this I can store free 1gb of data and have 100 simultaneous connections.
Firebase Authentication
Many apps and web services need to provide some form of authentication system in order to identify users, control access to premium content and to protect user data. Without some way to identify one user from another it would also be impossible for the app to know which data and settings belong to which user. Authentication options can range from requiring an email address and a password to allowing users to sign in using credentials from third-party platforms such as Facebook, Google and Twitter. Regardless of the motivations for adding user authentication to an app, developers often find that implementation is much more complex than it seems on the surface. Not only must authentication be performed securely and reliably, it must also allow for users to change their account settings, provide support for forgotten passwords and integrate with a range of vastly different third-party authentication APIs. Databases have to be implemented and stored securely and an administration interface developed for manually adding, editing and deleting users. Fortunately there is an easier option than building all of this infrastructure. All of these requirements can be met with minimal effort by using Firebase Authentication.
Firebase authentication provides a way to add user account creation and connect to an application with a minimum amount of coding. Any user who logs in to firebase is assigned a unique firebase user id which can be used to integrate other Firebase services, such as data storage and cloud messaging. Firebase uses the concept of authentication providers to facilitate the identification and registration of users.
The list of supported Firebase authentication providers currently consists of Google, Facebook, Twitter, GitHub, phone number and email / password authentication. Firebase also provides support for users to log in anonymously a temporary account, and then connect that account to an authentication provider-based account. In addition to integration with supported authentication providers, Firebase also supports integration with custom authentication systems.
Firebase supports all standard authentication features, such as forgotten password management and management user accounts and profiles both programmatically and through the Firebase console. Two forms of Firebase authentication are available, one involving the use of Firebase UI Auth and the other one lower level approach using the Firebase SDK. In practice, these involve the use of the next Firebase collection authentication classes.
The Realtime Database
Intuitively, a real-time database may be seen as a classic database which is able to handle workloads whose states are permanently changing by using real-time processing.
The formal description of a real-time database from the definition of real-time processing presented above of a Real-time database data follows a series of time constraints. These are the temporal characteristics of the data stored in the database, the calendar performance questions and objectives.
The real-time database differs for the most part from a traditional database performance targets, time constraints that are in microseconds or even nanoseconds and through its ability to estimate the average of failed transactions and the cost incurred in these failed transactions.
Furthermore, like conventional databases, real-time databases have to respect ACID properties which are :
Atomicity : In the end, a transaction is never half-completed. It is completely done or not.
Consistency : Transactions are run in a given specific order.
Isolation : Transactions cannot see actions of another transaction while it is not yet committed.
Durability : Once committed, a transaction cannot be modified.
Storage Firebase
As explained before, Firebase Real-Time Database system is cloud-stored and encoded as JSON objects. The database can be seen as a tree where each information is stored as a node coded in JSON with an associated key. The data itself is structured according regular expression rules language.
In a Firebase database, there is no tables or records. A node is added to the existing structure when a new data is added into the database. This kind of tree can accept up to 32 level of node. In order to keep the data safe, it is important to know that giving access to a node is also giving access to all children of this node. This is why Firebase documentation recommands to keep a relatively at JSON tree.
For store files such as photos or videos it’s requirement that apps. Particularly one that deals with large files such as videos for building and managing an infrastructure to handle this – that can be a difficult and expensive proposition. Whit simple API from Google Cloud Storage, Firebase are more easier to use doing backed up.
Hosting
Firebase has the benefit for using, because get hosting space that we can use to host static assets such as CSS, HTML, JavaScript or images. JavaScript frameworks help us to build some pretty sophisticated sites. With Firebase all users have a fast connection wherever they are because the content in Firebase hosting is edge-cached on solid state devices at a variety of Content Delivery networks around the world.
Firebase Cloud Messaging
To connected devices via messages and notifications are made Firebase Cloud Messaging. Have capacity to delivered with 98% of messages to connected devices in 500ms or less, or in a massively scalable, with an infrastructure that delivers over a trillion messages each week. Is capable to deliver messages to a single user or more users and avoid unwanted notification ‘spam’.
Firebase Remote Config
Remote Config is a cloud service that provides server-side variables that can be driven by analytics, allowing you to change the behavior and/or appearance of your app without requiring an app update. For example, if you are building an e-commerce app, and you want to periodically provide discounts to your users, you could have a remote config variable that contains the value of the discount. Traditionally it could be 0%, but at certain times of the year you could set it to 10%. But then you could go further – what if you want to give a bigger discount to people in a country that you want to grow in – you can set the value based on analytics to give them, say 20%.
App Indexing
A common scenario is that a user installs your app, but then it gets lost in their universe of applications. But an everyday scenario is that they search on their phone. Logically, if they are searching for content that’s already in your app, and they previously made the decision to install that app, then the app should be surfaced, and the content should be opened in that app directly from search.
Google Analytics for Firebase
At the heart of Firebase is analytics, a solution that’s free to use and very comprehensive. It has a number of common analytics that it will gather for you without writing any code, as well as the ability to define custom analytics that will be gathered for you. It helps you understand your audience well, which can be used to continually grow your app, as well as driving technologies such as Firebase Remote Config, and Cloud Messaging!
Chapter 3 Describe application
EZ-Ticket – Application description
Through "EZ-Ticket", any event organizer user has an easy and convenient way to analyze attendance figures and manage access to the event .
Its primary use is to have clerks use it as a scanner at the gates. Each barcode scanned off of an event ticket is compared to those stored in the database. If it matches the event in question, the application will signal that to the clerk and entrance may be allowed. The application takes into account various cases when scanning a barcode. If a barcode does not belong to the database, the clerk will be notified. As well, when the barcode has already been scanned or the internal scanner does not recognize it as a barcode. Error messages according to each specific case will be displayed to the user, in order to simplify the interaction with the participants and maintain fluidity at the gates.
Its second use is for event organizers, who can see in realtime the attendace figures, with the application fetching from the database, the number of tickets that have been scanned for a particular event. Also, for each ticket scanned, the venue capacity for that event (a known, given number) is lowered by one. This feature was implemented to comply with safety regulations and to help organizers avoid overcrowding.
In the world of Android applications, the name, interface and logo are as important as functionality itself. The name conveys the idea of convenience and simplicity. On the graphic side, the logo is a blue ticket with the letters „EZ” incripted, on a white background. The color scheme for this application is in fact a combination of white and blue. White was used mostly for backgrounds and blue for action bars. Overall, the interface was kept simple and easy to use to underline the convenience and simplicity aspects.
Firebase
This Android application was integrated with Firebase to ensure scalability, optimal back-end processes and overall responsiveness. Additionally, the Firebase platform provides multiple login/logout procedures with pre-programmed user interfaces, the ability to send cloud messages, and multiple data insight tools, such as Crashlytics.
In order to create a new Firebase project, one must log in to the Firebase console with a Google account, and click on the "Add project" button, to insert the project name and region.
Now, the developer can start integrating Firebase in their Android application. Firstly, the application must be registered. This is a process consisting of having the name of the
Android package specified, in our case, com.android.ezticket, and the debug SHA-1 signing certificate. This certificate is a combination of 20 groups of numbers and letters, separated by colons and generated by running the following line of code in the Command Prompt window: keytool -exportcert -list -v \-alias androiddebugkey -keystore %USERPROFILE%\.android\debug.keystore. The resulted output will be a code like in the following example: DA:39:A3:EE:5E:6B:4B:0D:32:55:BF:EF:95:60:18:90:AF:D8:07:09.
In the next step, the automatically generated Google Services JSON containing key data, is downloaded and pasted inside the app/ folder in Android Studio. Here is a brief look at the the JSON file:
{
"project_info": {
"project_number": "281259134522",
"firebase_url": "https://ez-ticket-bfabe.firebaseio.com",
"project_id": "ez-ticket-bfabe",
"storage_bucket": "ez-ticket-bfabe.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:281259134522:android:a6b3d6771e4b4d667bef03",
"android_client_info": {
"package_name": "com.android.ezticket"
}
},
"oauth_client": [
{
"client_id": "281259134522-76ichoag1uml4a2g3vf80p033nlj1msr.apps.googleusercontent.com",
"client_type": 1,
"android_info": {
"package_name": "com.android.ezticket",
"certificate_hash": "beaf733558ba2d63843ccfdcd4b68497f1de7a29"
}
},
{
"client_id": "281259134522-lsnat79a2of4hjikau8v0cel396qghfk.apps.googleusercontent.com",
"client_type": 3
}
]
(…)
Finally, the following lines must be added to the project-level build.gradle and application-level build.gradle files, respectively.
classpath 'com.google.gms:google-services:3.2.0' //to project build.gradle
implementation 'com.google.firebase:firebase-core:11.8.0 //to application
build.gradle
apply plugin: 'com.google.gms.google-services' //to application level
build.gradle
Real-time database
One of the reasons the Firebase service was chosen in the development of this application was its real-time database. It stores data in a JSON format that can be exported and then imported on any device. "EZ-Ticket" uses this database to store information about upcoming events.
For users to be able to read or write data, they have to be signed in, as per database rules: ".read": "auth != null",".write": "auth != null".
The database has three main nodes, BarcodeDatabase, EventDatabase and ScannedList, each with their own children. We will be breaking down every node and their children’s properties.
Every scannable barcode is stored in the BarcodeDatabase node. Each child is a unique, randomly generated ID. When the child is expanded, such information as the barcode itself (as a string) and the event id that it belongs to, are displayed.
In the EventDatabase node, the main child is the event ID. Each event contains fields detailing the address, venue capacity, date, title, and seats remaining. After every scan, the application checks which event the scanned barcode belongs to and decrements the remaining seats available in the EventDatabase. Here, the eventid field acts as a foreign key.
After a scan has been performed, the resulting barcode goes in the ScannedList node , along with the event ID.
LoginActivity.java
This Java class handles the login procedure. EZ-Ticket uses an email address/password pair to authenticate users, provided through the Firebase platform. The email addresses stored in the phone's memory are shown as default options for account creation.
Depending on the state of the current user, the application has certain behaviours. This state is obtained through the MyFirebaseInstanceIDService.java.
@Override
public void onTokenRefresh() {
// Get updated InstanceID token.
String refreshedToken = FirebaseInstanceId.getInstance().getToken(); //este preluat jetonul de acces al utilizatorului
Log.d(TAG, "Refreshed token: " + refreshedToken);
sendRegistrationToServer(refreshedToken); //se trimite catre server jetonul de acces al fiecarui user
}
private void sendRegistrationToServer(String token) { //metoda pentru a trimite catre server jetonul de acces
try {
Log.d(TAG, "sendRegistrationToServer: sending token to server: " + token);
DatabaseReference reference = FirebaseDatabase.getInstance().getReference();
reference.child("users")
.child(FirebaseAuth.getInstance().getCurrentUser().getUid())
.child("messaging_token")
.setValue(token);
} catch (NullPointerException e) {
e.printStackTrace();
}
}
If there is no current user logged in, a SignInIntent is built, with the related back-end affairs handled by the Firebase platform. However, if there is a current user signed in, a "toast" message welcoming the user back will be displayed, and the user will be redirected to the main activity.
if (FirebaseAuth.getInstance().getCurrentUser() == null) {
startActivityForResult(
AuthUI.getInstance()
.createSignInIntentBuilder()
.setTheme(R.style.AppTheme)
.setLogo(R.drawable.logo_googleg_color_18dp)
.build(),
SIGN_IN_REQUEST_CODE
);
}
else {
Toast.makeText(this,
"Welcome " + FirebaseAuth.getInstance()
.getCurrentUser()
.getDisplayName(),
Toast.LENGTH_SHORT)
.show();
Intent ezticket;
ezticket = new Intent(getApplicationContext(),
MainActivity.class);
startActivity(ezticket);
finish();
MainActivity.java
The MainActivity.java class acts as the container for the application’s listview layout. The user’s currently scanned events are displayed in a list, in the order they were scanned.
Print aici cu lista de scanari si side by side cu meniul deschis
The actions for the application’s main menu are also defined in this class. The overflow menu has the following options:
Delete list, to delete the list of currently scanned barcodes;
About, to access information about the current application version and the developer;
Event manager, to open another screen detailing the events the are taking place
Sign out, to sign the currently connected user out.
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.delete_list) {
ref.child("ScannedList").removeValue();
hash2.clear finish();
} else if (item.getItemId() == R.id.about) {
Intent intent = new Intent(getApplicationContext(), About.class);
startActivity(intent);
}
else if (item.getItemId() == R.id.event_manager) {
Intent intent = new Intent(getApplicationContext(),
EventManager.class);
startActivity(intent);
}
else if (item.getItemId() == R.id.logout) {
AuthUI.getInstance().signOut(this)
.addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
Toast.makeText(MainActivity.this,
"You have been signed out.",
Toast.LENGTH_LONG)
.show();
finish();
}
});
}
return true;
}
Alongside the main menu, there is also a context menu, that activates when a long press action is recorded by the touchscreen. It has one option, Delete, and it’s only active inside the main screen. When a long press occurs, the list item that was detected as part of the area the action took place, has its barcode value extracted. Then, the application queries the Firebase database for scanned barcodes equal to that value, with every occurrence removed.
@Override
public boolean onContextItemSelected(MenuItem item) {
if (item.getTitle().equals("Delete")) {
final AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
final DatabaseReference ref = FirebaseDatabase.getInstance().getReference();
Query query = ref.child("ScannedList").child(currentuser).orderByChild("barcode").equalTo(hash2.get(info.position + ""));
query.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
for (DataSnapshot appleSnapshot : dataSnapshot.getChildren()) {
appleSnapshot.getRef().removeValue();
hash2.clear(); } }
@Override
public void onCancelled(DatabaseError databaseError) {
Log.e("TAG", "onCancelled", databaseError.toException());
}
});
} else {
return false;
}
return true;
}
This class also contains the Scan button, in the form of a floating action button. With the help of the ZXing library, a scan action is initiated every time a click occurs in the button area. To use this external library, first, the following line of code must be added to the application-level build.gradle file:
implementation 'com.journeyapps:zxing-android-embedded:3.4.0'
After a scan action has occurred, a number possible outcomes are taken into account:
A barcode that did not belong to the database has been scanned – a toast with the following message will be displayed:
Toast.makeText(getApplicationContext(), "Ticket not found in our
database.", Toast.LENGTH_LONG).show();
An already scanned barcode has been scanned – a toast with the following message will be displayed:
Toast.makeText(getApplicationContext(), "Ticket not found in our
database.", Toast.LENGTH_LONG).show();
The barcode scanned is not valid, or not a barcode at all – the following toast will be displayed:
Toast.makeText(getApplicationContext(), "Please scan a valid barcode", Toast.LENGTH_LONG).show();
Finally, if the scan has been successful, a “Succes!” message will be displayed:
Toast.makeText(this,"Success!", Toast.LENGTH_LONG).show();
EventManager.java
The EventManager.java class displays the events that are stored in the Firebase database. These events are introduced manually, as well as their respective barcodes. The only way to reach this class, is through the context menu in the MainActivity.java class.
The layout of this class is a listview, with each entry coming from the database. When a particular item is pressed on, data about the event chosen is extracted through the Model.java class. After that, an alert dialog is created, displaying that information .
AlertDialog.Builder builder = new AlertDialog.Builder(EventManager.this);
builder.setTitle(model.getEvent());
builder.setMessage("\n"+model.getAddress()+"\n"+model.getDate()+"\n"
+"\n"+model.getRemaining()+ " seats remaining");
builder.setPositiveButton("OK", null);
AlertDialog dialog = builder.create();
dialog.show();
Model.java
The Model.java class is used in order to optimize the data extraction process. This type of class is pivotal to the Firebase architecture, as basically every field from the database with a get() and set() methods declared, can be obtained through it.
private String barcode;
private String address;
private String event;
private Long eventid;
private String capacity;
private String date;
private Long remaining;
By creating model objects, the get() and set() methods for these parameters, can be accessed from practically every class inside the Android Project.
public String getBarcode() { return barcode; }
public void setBarcode(String barcode) { this.barcode = barcode; }
public String getAddress() {return address; }
public void setAddress(String address) {this.address = address;}
public String getEvent() {return event;}
public void setEvent (String event) {this.event = event;}
public Long getEventid() {return eventid;}
public void setEventid (Long eventid) {this.eventid = eventid;}
public String getCapacity() {return capacity;}
public void setCapacity (String capacity) {this.capacity = capacity;}
public Long getRemaining() {return remaining;}
public void setRemaining (Long remaining) {this.remaining = remaining;}
public String getDate() {return date; }
public void setDate (String date) {this.date = date;}
Copyright Notice
© Licențiada.org respectă drepturile de proprietate intelectuală și așteaptă ca toți utilizatorii să facă același lucru. Dacă consideri că un conținut de pe site încalcă drepturile tale de autor, te rugăm să trimiți o notificare DMCA.
Acest articol: FACULTY OF MATHEMATICS AND INFORMATICS A Translation Study Case: In Dubious Battle by John Steinbeck Final thesis: Android application for managing… [305527] (ID: 305527)
Dacă considerați că acest conținut vă încalcă drepturile de autor, vă rugăm să depuneți o cerere pe pagina noastră Copyright Takedown.
