Thriving in Android Development Using Kotlin - Gema Socorro Rodríguez - E-Book

Thriving in Android Development Using Kotlin E-Book

Gema Socorro Rodríguez

0,0
29,99 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.

Mehr erfahren.
Beschreibung

Finding resources on creating apps with the Android framework and Kotlin is easy, but discovering content that addresses the common challenges faced by app developers is difficult. This book is designed to bridge that gap and equip you with the skills to tackle everyday problems in Android development.
You'll get hands on with Android development by building an app similar to WhatsApp. Next, you'll learn how to process asynchronous messages reactively, render them using Jetpack Compose, and advance to creating and uploading a backup of these messages. As you progress, you'll develop Packtagram, an app inspired by Instagram, focused on advanced photo-editing capabilities using the latest CameraX libraries. Finally, you'll build your own Netflix-like app, integrating video playback functionality with ExoPlayer for both foreground and background operations, and enabling casting to other devices.
By the end of this book, you'll have crafted three fully functional projects across multiple platforms and gained the expertise to solve the most common challenges in Android development confidently.

Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:

EPUB
MOBI

Seitenzahl: 439

Veröffentlichungsjahr: 2024

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



Thriving in Android Development Using Kotlin

A project-based guide to using the latest Android features for developing production-grade apps

Gema Socorro Rodríguez

Thriving in Android Development Using Kotlin

Copyright © 2024 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.

Group Product Manager: Rohit Rajkumar

Publishing Product Manager: Vaideeshwari Roshan

Book Project Manager: Sonam Pandey

Senior Editor: Hayden Edwards

Technical Editor: Simran Ali

Copy Editor: Safis Editing

Indexer: Manju Arasan

Production Designer: Prashant Ghare

DevRel Marketing Coordinators: Anamika Singh and Nivedita Pandey

First published: July 2024

Production reference: 3081124

Published by Packt Publishing Ltd.

Grosvenor House

11 St Paul’s Square

Birmingham

B3 1RB, UK.

ISBN 978-1-83763-129-2

www.packtpub.com

To Amaia and Aitor, for giving me the incredible privilege of being your mom and inviting me to be part of your extraordinary worlds, filled with magic and wonder.

To Roberto, for believing in me more than I ever could myself. Thank you for being my greatest support in every challenge I face, and for spending countless nights working alongside me while I wrote this book.

I love you all.

– Gema

Contributors

About the author

Gema Socorro Rodríguez is a Google Developer Expert for Android with over 15 years’ experience. In 2009, after finishing her studies, which included building a mobile project, she started working on more mobile apps and fell in love with Android. Since then, she has worked on mobile apps as part of several teams. As her experience grew, she realized that she wanted to share with the community what she had learned; hence, she started giving talks and organizing workshops. She has also been an instructor at a mobile-specialized boot camp. She currently works as a senior Android engineer at Cabify, a popular ride-hailing company with a presence in Spain and the majority of Latin American countries.

I want to thank the wonderful Packt team for supporting and helping me write my first technical book.

I also want to thank my family, friends, and colleagues for listening to me talk about this book for months and their unwavering support.

Finally, I want to thank the Android community for being one of the most open and welcoming communities, contributing to the growth and development of countless Android developers.

About the reviewer

Hema Sai Charan Kothamasu (a.k.a. hemandroid) is a seasoned mobile app developer, armed with a B.Tech in electronics and computer engineering from Usha Rama College and a decade of expertise in Android and Flutter. Hema’s professional journey includes spearheading projects by leveraging his proficiency in frameworks such as Android, Flutter, and iOS and his adeptness in design patterns and architecture. A stalwart in the developer community, Hema is also a technical speaker at GDG Hyd Community, where he captivates audiences with dynamic talks, and a co-organizer at Flutter Hyd Community, where he fosters growth and collaboration, mentoring aspiring developers. Hema’s insightful blog offers a wealth of knowledge on mobile development.

Table of Contents

Preface

Part 1: Creating WhatsPackt, a Messaging App

1

Building the UI for Your Messaging App

Technical requirements

Defining the app structure and navigation

Modularization

Dependency injection

Navigation

Building the main screen

Adding a scaffold to the main screen

Adding the TopAppBar composable to the main screen

Adding the TabRow composable to the bottom of the main screen

Adding a pager

Adding the FloatingActionButton composable

Creating the conversations list

Modeling the conversation

Creating the ConversationList composable

Building the messages list

Modeling the Chat and Message models

Creating the MessageItem composable

Adding the TopAppBar and BottomRow composables

Adding the messages list

Summary

2

Setting Up WhatsPackt’s Messaging Abilities

Technical requirements

Using a WebSocket connection

Why WebSockets?

Integrating WebSockets

Implementing WebSocketDataSource

Receiving messages in our ViewModel

Understanding Clean Architecture implementation

Creating our Clean Architecture components

Implementing ChatViewModel

Handling synchronization and errors

Obtaining chat screen initialization data

Handling errors in the WebSocket

Adding push notifications

Setting up Firebase

Sending the FCM token to Firebase

Preparing the app to receive push notifications

Replacing the Websocket with Firestore

What is Firestore?

Chat data structure

Creating a FirestoreMessagesDataSource class

Summary

3

Backing Up Your WhatsPackt Messages

Technical requirements

Understanding Room

Key features of Room

Room’s architecture and components

Implementing Room in WhatsPackt

Adding dependencies

Creating the database

Creating entity classes

Creating DAOs

Creating a LocalMessagesDataSource data source

Handling two data sources in the MessagesRepository component

Getting to know Firebase Storage

How Firebase Storage works

Setting up Firebase Storage

Creating UploadMessagesUseCase

Scheduling WorkManager to send backups

Introducing the Worker class

Configuring the WorkRequest component

Creating our Worker instance

Setting up the WorkRequest class

Using Amazon S3 for storage

Integrating the AWS S3 SDK

Setting up Amazon Cognito

Creating an AWS S3 Storage provider and integrating it into our code

Summary

Part 2: Creating Packtagram, a Photo Media App

4

Building the Packtagram UI

Technical requirements

Setting up Packtagram’s modules and dependencies

Setting up a version catalog

Modularizing our app

Getting to know Koin

Setting up Koin

Creating the stories screen

Creating the newsfeed screen and its components

Creating the NewsFeed list

Creating the PostItem composable

Using Retrofit and Moshi to retrieve newsfeed information

Adding the Retrofit and Moshi dependencies

Creating the data source for the newsfeed

Creating the repository

Creating the GetTheNewsFeedUseCase

Integrating the use case into our ViewModel

Implementing pagination in the newsfeed

Summary

5

Creating a Photo Editor Using CameraX

Technical requirements

Getting to know CameraX

The evolution of camera libraries in Android

The importance and advantages of CameraX

Setting up CameraX

Learning about CameraX’s core concepts

Integrating CameraX into our Packtagram app

Setting up the permissions checker with Accompanist

Creating our own CameraPreview

Adding photo-saving functionality

Adding photo-editing functionalities

Adding filters

Adding a text overlay

Using ML to categorize photos and generate hashtags

Summary

6

Adding Video and Editing Functionality to Packtagram

Technical requirements

Adding video functionality to our app

Getting to know FFmpeg

The components of FFmpeg

Key features of FFmpeg

Integrating mobile-ffmpeg into our project

Understanding the FFmpeg command-line syntax

Advanced syntax and options in FFmpeg

Using mobile-ffmpeg to execute FFmpeg commands

Adding a caption to the video with FFmpeg

Adding a filter to a video with FFmpeg

Uploading the video

Summary

Part 3: Creating Packtflix, a Video Media App

7

Starting a Video Streaming App and Adding Authentication

Technical requirements

Creating the app’s structure and modules

Setting up the dependency injection framework

Building the login screen

Authenticating the app’s users

Creating the user model

Using Retrofit to get the authorization token

Using DataStore to store the token

Sending the authorization token in requests

Creating your movie list

Building the models

Building the MoviesScreen composable

Making the movie and series detail screen

Creating the detail models

Building the DetailScreen

Summary

8

Adding Media Playback to Packtflix with ExoPlayer

Technical requirements

Reviewing Android’s media options

Learning about the MediaPlayer API

Learning about VideoView

Understanding the basics of ExoPlayer

Exploring ExoPlayer’s architecture

Integrating ExoPlayer into our project

Creating the video playback user interface

Building PlaybackScreen and its composables

Making the controls disappear when playing the content

Playing video using ExoPlayer

Creating PlaybackActivity

Creating PlaybackViewModel

Connecting the controls with ExoPlayer

Implementing the video controls in PlaybackViewModel

Adding subtitles to the video player

Summary

9

Extending Video Playback in Your Packtflix App

Technical requirements

Getting to know the PiP API

PiP requirements

Entering and exiting PiP mode programmatically

Using PiP to continue playback in the background

Implementing PiP

Understanding how to add actions to the PiP mode

Adding actions to the PiP mode

Getting to know MediaRouter

Setting up MediaRouter

Discovering media routes

Connecting to Google Chromecast devices

Summary

Index

Other Books You May Enjoy

Part 1:Creating WhatsPackt, a Messaging App

In this part, you will learn to build and structure a messaging app called WhatsPackt, implement real-time communication using WebSockets, and ensure data persistence and backup with Room and Cloud Storage for Firebase. You will gain hands-on experience in creating user interfaces, handling message synchronization, and implementing push notifications, culminating in a robust and reliable messaging system.

This part includes the following chapters:

Chapter 1, Building the UI for Your Messaging AppChapter 2, Setting Up WhatsPackt’s Messaging AbilitiesChapter 3, Backing Up Your WhatsPackt Messages