Jetpack Compose 1.2 Essentials: Developing Android Apps with Jetpack Compose 1.2, Android Studio, and Kotlin
- Length: 564 pages
- Edition: 1
- Language: English
- Publisher: Payload Media
- Publication Date: 2022-09-20
- ISBN-10: 1951442504
- ISBN-13: 9781951442507
- Sales Rank: #585273 (See Top 100 Books)
Fully updated for Jetpack Compose 1.2, this book will teach you how to build Android applications using Jetpack Compose, Android Studio, and the Kotlin programming language.
Beginning with the basics, this book explains how to set up an Android Studio development environment.
The book also includes in-depth chapters introducing the Kotlin programming language including data types, operators, control flow, functions, lambdas, object-oriented programming, and asynchronous programming using coroutines.
An introduction to the key concepts of Jetpack Compose and Android project architecture is followed by a guided tour of Android Studio in Compose development mode. The book also covers the creation of custom Composables and explains how these functions are combined to create user interface layouts including the use of row, column, box, and list components.
Other topics covered include data handling using state properties, key user interface design concepts such as modifiers, navigation bars, and user interface navigation. Additional chapters explore building your own re-usable custom layout components.
The book also includes chapters covering graphics drawing, user interface animation, transitions, Kotlin Flows, and gesture handling.
Chapters are also included covering view models, SQLite databases, Room database access, the Database Inspector, live data, and custom theme creation. An introduction to the upcoming Material Design 3 guidelines is also covered, including details on how to migrate from Material Design 2.
Finally, the book explains how to package up a completed app and upload it to the Google Play Store for publication.
Along the way, the topics covered in the book are put into practice through detailed tutorials, the source code for which is also available for download.
Assuming you already have some rudimentary programming experience, are ready to download Android Studio and the Android SDK, and have access to a Windows, Mac, or Linux system, you are ready to get started.
1. Start Here 1.1 For Kotlin programmers 1.2 For new Kotlin programmers 1.3 Downloading the code samples 1.4 Feedback 1.5 Errata 2. Setting up an Android Studio Development Environment 2.1 System requirements 2.2 Downloading the Android Studio package 2.3 Installing Android Studio 2.3.1 Installation on Windows 2.3.2 Installation on macOS 2.3.3 Installation on Linux 2.4 The Android Studio setup wizard 2.5 Installing additional Android SDK packages 2.6 Making the Android SDK tools command-line accessible 2.6.1 Windows 8.1 2.6.2 Windows 10 2.6.3 Windows 11 2.6.4 Linux 2.6.5 macOS 2.7 Android Studio memory management 2.8 Updating Android Studio and the SDK 2.9 Summary 3. A Compose Project Overview 3.1 About the project 3.2 Creating the project 3.3 Creating an activity 3.4 Defining the project and SDK settings 3.5 Previewing the example project 3.6 Reviewing the main activity 3.7 Preview updates 3.8 Upgrading to Jetpack Compose 1.2 3.9 Summary 4. An Example Compose Project 4.1 Getting started 4.2 Removing the template Code 4.3 The Composable hierarchy 4.4 Adding the DemoText composable 4.5 Previewing the DemoText composable 4.6 Adding the DemoSlider composable 4.7 Adding the DemoScreen composable 4.8 Previewing the DemoScreen composable 4.9 Testing in interactive mode 4.10 Completing the project 4.11 Summary 5. Creating an Android Virtual Device (AVD) in Android Studio 5.1 About Android Virtual Devices 5.2 Starting the emulator 5.3 Running the application in the AVD 5.4 Running on multiple devices 5.5 Stopping a running application 5.6 Supporting dark theme 5.7 Running the emulator in a separate window 5.8 Enabling the device frame 5.9 Summary 6. Using and Configuring the Android Studio AVD Emulator 6.1 The emulator environment 6.2 The emulator toolbar options 6.3 Working in zoom mode 6.4 Resizing the emulator window 6.5 Extended control options 6.5.1 Location 6.5.2 Displays 6.5.3 Cellular 6.5.4 Battery 6.5.5 Camera 6.5.6 Phone 6.5.7 Directional pad 6.5.8 Microphone 6.5.9 Fingerprint 6.5.10 Virtual sensors 6.5.11 Snapshots 6.5.12 Record and playback 6.5.13 Google Play 6.5.14 Settings 6.5.15 Help 6.6 Working with snapshots 6.7 Configuring fingerprint emulation 6.8 The emulator in tool window mode 6.9 Summary 7. A Tour of the Android Studio User Interface 7.1 The Welcome Screen 7.2 The Main Window 7.3 The Tool Windows 7.4 Android Studio Keyboard Shortcuts 7.5 Switcher and Recent Files Navigation 7.6 Changing the Android Studio Theme 7.7 Summary 8. Testing Android Studio Apps on a Physical Android Device 8.1 An overview of the Android Debug Bridge (ADB) 8.2 Enabling USB debugging ADB on Android devices 8.2.1 macOS ADB configuration 8.2.2 Windows ADB configuration 8.2.3 Linux adb configuration 8.3 Resolving USB connection issues 8.4 Enabling wireless debugging on Android devices 8.5 Testing the adb connection 8.6 Summary 9. The Basics of the Android Studio Code Editor 9.1 The Android Studio editor 9.2 Code mode 9.3 Splitting the editor window 9.4 Code completion 9.5 Statement completion 9.6 Parameter information 9.7 Parameter name hints 9.8 Code generation 9.9 Code folding 9.10 Quick documentation lookup 9.11 Code reformatting 9.12 Finding sample code 9.13 Live templates 9.14 Summary 10. An Overview of the Android Architecture 10.1 The Android software stack 10.2 The Linux kernel 10.3 Android runtime – ART 10.4 Android libraries 10.4.1 C/C++ libraries 10.5 Application framework 10.6 Applications 10.7 Summary 11. An Introduction to Kotlin 11.1 What is Kotlin? 11.2 Kotlin and Java 11.3 Converting from Java to Kotlin 11.4 Kotlin and Android Studio 11.5 Experimenting with Kotlin 11.6 Semi-colons in Kotlin 11.7 Summary 12. Kotlin Data Types, Variables and Nullability 12.1 Kotlin data types 12.1.1 Integer data types 12.1.2 Floating point data types 12.1.3 Boolean data type 12.1.4 Character data type 12.1.5 String data type 12.1.6 Escape sequences 12.2 Mutable variables 12.3 Immutable variables 12.4 Declaring mutable and immutable variables 12.5 Data types are objects 12.6 Type annotations and type inference 12.7 Nullable type 12.8 The safe call operator 12.9 Not-null assertion 12.10 Nullable types and the let function 12.11 Late initialization (lateinit) 12.12 The Elvis operator 12.13 Type casting and type checking 12.14 Summary 13. Kotlin Operators and Expressions 13.1 Expression syntax in Kotlin 13.2 The Basic assignment operator 13.3 Kotlin arithmetic operators 13.4 Augmented assignment operators 13.5 Increment and decrement operators 13.6 Equality operators 13.7 Boolean logical operators 13.8 Range operator 13.9 Bitwise operators 13.9.1 Bitwise inversion 13.9.2 Bitwise AND 13.9.3 Bitwise OR 13.9.4 Bitwise XOR 13.9.5 Bitwise left shift 13.9.6 Bitwise right shift 13.10 Summary 14. Kotlin Control Flow 14.1 Looping control flow 14.1.1 The Kotlin for-in Statement 14.1.2 The while loop 14.1.3 The do ... while loop 14.1.4 Breaking from Loops 14.1.5 The continue statement 14.1.6 Break and continue labels 14.2 Conditional control flow 14.2.1 Using the if expressions 14.2.2 Using if ... else … expressions 14.2.3 Using if ... else if ... Expressions 14.2.4 Using the when statement 14.3 Summary 15. An Overview of Kotlin Functions and Lambdas 15.1 What is a function? 15.2 How to declare a Kotlin function 15.3 Calling a Kotlin function 15.4 Single expression functions 15.5 Local functions 15.6 Handling return values 15.7 Declaring default function parameters 15.8 Variable number of function parameters 15.9 Lambda expressions 15.10 Higher-order functions 15.11 Summary 16. The Basics of Object-Oriented Programming in Kotlin 16.1 What is an object? 16.2 What is a class? 16.3 Declaring a Kotlin class 16.4 Adding properties to a class 16.5 Defining methods 16.6 Declaring and initializing a class instance 16.7 Primary and secondary constructors 16.8 Initializer blocks 16.9 Calling methods and accessing properties 16.10 Custom accessors 16.11 Nested and inner classes 16.12 Companion objects 16.13 Summary 17. An Introduction to Kotlin Inheritance and Subclassing 17.1 Inheritance, classes, and subclasses 17.2 Subclassing syntax 17.3 A Kotlin inheritance example 17.4 Extending the functionality of a subclass 17.5 Overriding inherited methods 17.6 Adding a custom secondary constructor 17.7 Using the SavingsAccount class 17.8 Summary 18. An Overview of Compose 18.1 Development before Compose 18.2 Compose declarative syntax 18.3 Compose is data-driven 18.4 Summary 19. Composable Functions Overview 19.1 What is a composable function? 19.2 Stateful vs. stateless composables 19.3 Composable function syntax 19.4 Foundation and Material composables 19.5 Summary 20. An Overview of Compose State and Recomposition 20.1 The basics of state 20.2 Introducing recomposition 20.3 Creating the StateExample project 20.4 Declaring state in a composable 20.5 Unidirectional data flow 20.6 State hoisting 20.7 Saving state through configuration changes 20.8 Summary 21. An Introduction to Composition Local 21.1 Understanding CompositionLocal 21.2 Using CompositionLocal 21.3 Creating the CompLocalDemo project 21.4 Designing the layout 21.5 Adding the CompositionLocal state 21.6 Accessing the CompositionLocal state 21.7 Testing the design 21.8 Summary 22. An Overview of Compose Slot APIs 22.1 Understanding slot APIs 22.2 Declaring a slot API 22.3 Calling slot API composables 22.4 Summary 23. A Compose Slot API Tutorial 23.1 About the project 23.2 Creating the SlotApiDemo project 23.3 Preparing the MainActivity class file 23.4 Creating the MainScreen composable 23.5 Adding the ScreenContent composable 23.6 Creating the Checkbox composable 23.7 Implementing the ScreenContent slot API 23.8 Adding an Image drawable resource 23.9 Writing the TitleImage composable 23.10 Completing the MainScreen composable 23.11 Previewing the project 23.12 Summary 24. Using Modifiers in Compose 24.1 An overview of modifiers 24.2 Creating the ModifierDemo project 24.3 Creating a modifier 24.4 Modifier ordering 24.5 Adding modifier support to a composable 24.6 Common built-in modifiers 24.7 Combining modifiers 24.8 Summary 25. Composing Layouts with Row and Column 25.1 Creating the RowColDemo project 25.2 Row composable 25.3 Column composable 25.4 Combining Row and Column composables 25.5 Layout alignment 25.6 Layout arrangement positioning 25.7 Layout arrangement spacing 25.8 Row and Column scope modifiers 25.9 Scope modifier weights 25.10 Summary 26. Box Layouts in Compose 26.1 An introduction to the Box composable 26.2 Creating the BoxLayout project 26.3 Adding the TextCell composable 26.4 Adding a Box layout 26.5 Box alignment 26.6 BoxScope modifiers 26.7 Using the clip() modifier 26.8 Summary 27. Custom Layout Modifiers 27.1 Compose layout basics 27.2 Custom layouts 27.3 Creating the LayoutModifier project 27.4 Adding the ColorBox composable 27.5 Creating a custom layout modifier 27.6 Understanding default position 27.7 Completing the layout modifier 27.8 Using a custom modifier 27.9 Working with alignment lines 27.10 Working with baselines 27.11 Summary 28. Building Custom Layouts 28.1 An overview of custom layouts 28.2 Custom layout syntax 28.3 Using a custom layout 28.4 Creating the CustomLayout project 28.5 Creating the CascadeLayout composable 28.6 Using the CascadeLayout composable 28.7 Summary 29. A Guide to ConstraintLayout in Compose 29.1 An introduction to ConstraintLayout 29.2 How ConstraintLayout works 29.2.1 Constraints 29.2.2 Margins 29.2.3 Opposing constraints 29.2.4 Constraint bias 29.2.5 Chains 29.2.6 Chain styles 29.3 Configuring dimensions 29.4 Guideline helper 29.5 Barrier helper 29.6 Summary 30. Working with ConstraintLayout in Compose 30.1 Calling ConstraintLayout 30.2 Generating references 30.3 Assigning a reference to a composable 30.4 Adding constraints 30.5 Creating the ConstraintLayout project 30.6 Adding the ConstraintLayout library 30.7 Adding a custom button composable 30.8 Basic constraints 30.9 Opposing constraints 30.10 Constraint bias 30.11 Constraint margins 30.12 The importance of opposing constraints and bias 30.13 Creating chains 30.14 Working with guidelines 30.15 Working with barriers 30.16 Decoupling constraints with constraint sets 30.17 Summary 31. Working with IntrinsicSize in Compose 31.1 Intrinsic measurements 31.2 Max. vs Min. Intrinsic Size measurements 31.3 About the example project 31.4 Creating the IntrinsicSizeDemo project 31.5 Creating the custom text field 31.6 Adding the Text and Box components 31.7 Adding the top-level Column 31.8 Testing the project 31.9 Applying IntrinsicSize.Max measurements 31.10 Applying IntrinsicSize.Min measurements 31.11 Summary 32. Coroutines and LaunchedEffects in Jetpack Compose 32.1 What are coroutines? 32.2 Threads vs. coroutines 32.3 Coroutine Scope 32.4 Suspend functions 32.5 Coroutine dispatchers 32.6 Coroutine builders 32.7 Jobs 32.8 Coroutines – suspending and resuming 32.9 Coroutine channel communication 32.10 Understanding side effects 32.11 Summary 33. An Overview of Lists and Grids in Compose 33.1 Standard vs. lazy lists 33.2 Working with Column and Row lists 33.3 Creating lazy lists 33.4 Enabling scrolling with ScrollState 33.5 Programmatic scrolling 33.6 Sticky headers 33.7 Responding to scroll position 33.8 Creating a lazy grid 33.9 Summary 34. A Compose Row and Column List Tutorial 34.1 Creating the ListDemo project 34.2 Creating a Column-based list 34.3 Enabling list scrolling 34.4 Manual scrolling 34.5 A Row list example 34.6 Summary 35. A Compose Lazy List Tutorial 35.1 Creating the LazyListDemo project 35.2 Adding list data to the project 35.3 Reading the XML data 35.4 Handling image loading 35.5 Designing the list item composable 35.6 Building the lazy list 35.7 Testing the project 35.8 Making list items clickable 35.9 Summary 36. Lazy List Sticky Headers and Scroll Detection 36.1 Grouping the list item data 36.2 Displaying the headers and items 36.3 Adding sticky headers 36.4 Reacting to scroll position 36.5 Adding the scroll button 36.6 Testing the finished app 36.7 Summary 37. Compose Visibility Animation 37.1 Creating the AnimateVisibility project 37.2 Animating visibility 37.3 Defining enter and exit animations 37.4 Animation specs and animation easing 37.5 Repeating an animation 37.6 Different animations for different children 37.7 Auto-starting an animation 37.8 Implementing crossfading 37.9 Summary 38. Compose State-Driven Animation 38.1 Understanding state-driven animation 38.2 Introducing animate as state functions 38.3 Creating the AnimateState project 38.4 Animating rotation with animateFloatAsState 38.5 Animating color changes with animateColorAsState 38.6 Animating motion with animateDpAsState 38.7 Adding spring effects 38.8 Working with keyframes 38.9 Combining multiple animations 38.10 Using the Animation Inspector 38.11 Summary 39. Canvas Graphics Drawing in Compose 39.1 Introducing the Canvas component 39.2 Creating the CanvasDemo project 39.3 Drawing a line and getting the canvas size 39.4 Drawing dashed lines 39.5 Drawing a rectangle 39.6 Applying rotation 39.7 Drawing circles and ovals 39.8 Drawing gradients 39.9 Drawing arcs 39.10 Drawing paths 39.11 Drawing points 39.12 Drawing an image 39.13 Summary 40. Working with ViewModels in Compose 40.1 What is Android Jetpack? 40.2 The “old” architecture 40.3 Modern Android architecture 40.4 The ViewModel component 40.5 ViewModel implementation using state 40.6 Connecting a ViewModel state to an activity 40.7 ViewModel implementation using LiveData 40.8 Observing ViewModel LiveData within an activity 40.9 Summary 41. A Compose ViewModel Tutorial 41.1 About the project 41.2 Creating the ViewModelDemo project 41.3 Adding the ViewModel 41.4 Accessing DemoViewModel from MainActivity 41.5 Designing the temperature input composable 41.6 Designing the temperature input composable 41.7 Completing the user interface design 41.8 Testing the app 41.9 Summary 42. An Overview of Android SQLite Databases 42.1 Understanding database tables 42.2 Introducing database schema 42.3 Columns and data types 42.4 Database rows 42.5 Introducing primary keys 42.6 What is SQLite? 42.7 Structured Query Language (SQL) 42.8 Trying SQLite on an Android Virtual Device (AVD) 42.9 The Android Room persistence library 42.10 Summary 43. Room Databases and Compose 43.1 Revisiting modern app architecture 43.2 Key elements of Room database persistence 43.2.1 Repository 43.2.2 Room database 43.2.3 Data Access Object (DAO) 43.2.4 Entities 43.2.5 SQLite database 43.3 Understanding entities 43.4 Data Access Objects 43.5 The Room database 43.6 The Repository 43.7 In-Memory databases 43.8 Database Inspector 43.9 Summary 44. A Compose Room Database and Repository Tutorial 44.1 About the RoomDemo project 44.2 Creating the RoomDemo project 44.3 Modifying the build configuration 44.4 Building the entity 44.5 Creating the Data Access Object 44.6 Adding the Room database 44.7 Adding the repository 44.8 Adding the ViewModel 44.9 Designing the user interface 44.10 Writing a ViewModelProvider Factory class 44.11 Completing the MainScreen function 44.12 Testing the RoomDemo app 44.13 Using the Database Inspector 44.14 Summary 45. An Overview of Navigation in Compose 45.1 Understanding navigation 45.2 Declaring a navigation controller 45.3 Declaring a navigation host 45.4 Adding destinations to the navigation graph 45.5 Navigating to destinations 45.6 Passing arguments to a destination 45.7 Working with bottom navigation bars 45.8 Summary 46. A Compose Navigation Tutorial 46.1 Creating the NavigationDemo project 46.2 About the NavigationDemo project 46.3 Declaring the navigation routes 46.4 Adding the home screen 46.5 Adding the welcome screen 46.6 Adding the profile screen 46.7 Creating the navigation controller and host 46.8 Implementing the screen navigation 46.9 Passing the user name argument 46.10 Testing the project 46.11 Summary 47. A Compose Bottom Navigation Bar Tutorial 47.1 Creating the BottomBarDemo project 47.2 Declaring the navigation routes 47.3 Designing bar items 47.4 Creating the bar item list 47.5 Adding the destination screens 47.6 Creating the navigation controller and host 47.7 Designing the navigation bar 47.8 Working with the Scaffold component 47.9 Testing the project 47.10 Summary 48. Detecting Gestures in Compose 48.1 Compose gesture detection 48.2 Creating the GestureDemo project 48.3 Detecting click gestures 48.4 Detecting taps using PointerInputScope 48.5 Detecting drag gestures 48.6 Detecting drag gestures using PointerInputScope 48.7 Scrolling using the scrollable modifier 48.8 Scrolling using the scroll modifiers 48.9 Detecting pinch gestures 48.10 Detecting rotation gestures 48.11 Detecting translation gestures 48.12 Summary 49. Detecting Swipe Gestures in Compose 49.1 Swipe gestures and anchors 49.2 Detecting swipe gestures 49.3 Declaring the anchors map 49.4 Declaring thresholds 49.5 Moving a component in response to a swipe 49.6 About the SwipeDemo project 49.7 Creating the SwipeDemo project 49.8 Setting up the swipeable state and anchors 49.9 Designing the parent Box 49.10 Testing the project 49.11 Summary 50. An Introduction to Kotlin Flow 50.1 Understanding Flows 50.2 Creating the sample project 50.3 Adding a view model to the project 50.4 Declaring the flow 50.5 Emitting flow data 50.6 Collecting flow data as state 50.7 Transforming data with intermediaries 50.8 Collecting flow data 50.9 Adding a flow buffer 50.10 More terminal flow operators 50.11 Flow flattening 50.12 Combining multiple flows 50.13 Hot and cold flows 50.14 StateFlow 50.15 SharedFlow 50.16 Converting a flow from cold to hot 50.17 Summary 51. A Jetpack Compose SharedFlow Tutorial 51.1 About the project 51.2 Creating the SharedFlowDemo project 51.3 Adding a view model to the project 51.4 Declaring the SharedFlow 51.5 Collecting the flow values 51.6 Testing the SharedFlowDemo app 51.7 Handling flows in the background 51.8 Summary 52. Creating, Testing, and Uploading an Android App Bundle 52.1 The release preparation process 52.2 Android app bundles 52.3 Register for a Google Play Developer Console account 52.4 Configuring the app in the console 52.5 Enabling Google Play app signing 52.6 Creating a keystore file 52.7 Creating the Android app bundle 52.8 Generating test APK files 52.9 Uploading the app bundle to the Google Play Developer Console 52.10 Exploring the app bundle 52.11 Managing testers 52.12 Rolling the app out for testing 52.13 Uploading new app bundle revisions 52.14 Analyzing the app bundle file 52.15 Summary 53. An Overview of Android In-App Billing 53.1 Preparing a project for In-App purchasing 53.2 Creating In-App products and subscriptions 53.3 Billing client initialization 53.4 Connecting to the Google Play Billing library 53.5 Querying available products 53.6 Starting the purchase process 53.7 Completing the purchase 53.8 Querying previous purchases 53.9 Summary 54. An Android In-App Purchasing Tutorial 54.1 About the In-App purchasing example project 54.2 Creating the InAppPurchase project 54.3 Adding libraries to the project 54.4 Adding the App to the Google Play Store 54.5 Creating an In-App product 54.6 Enabling license testers 54.7 Creating a purchase helper class 54.8 Adding the StateFlow streams 54.9 Initializing the billing client 54.10 Querying the product 54.11 Handling purchase updates 54.12 Launching the purchase flow 54.13 Consuming the product 54.14 Restoring a previous purchase 54.15 Completing the MainActivity 54.16 Testing the app 54.17 Troubleshooting 54.18 Summary 55. Working with Compose Theming 55.1 Material Design 2 vs Material Design 3 55.2 Material Design 2 theming 55.3 Material Design 3 theming 55.4 Building a custom theme 55.5 Summary 56. A Material Design 3 Theming Tutorial 56.1 Creating the ThemeDemo project 56.2 Adding the Material Design 3 library 56.3 Designing the user interface 56.4 Building a new theme 56.5 Adding the theme to the project 56.6 Enabling dynamic colors 56.7 Summary 57. An Overview of Gradle in Android Studio 57.1 An overview of Gradle 57.2 Gradle and Android Studio 57.2.1 Sensible defaults 57.2.2 Dependencies 57.2.3 Build variants 57.2.4 Manifest entries 57.2.5 APK signing 57.2.6 ProGuard support 57.3 The Properties and Settings Gradle build files 57.4 The top-level gradle build file 57.5 Module level Gradle build files 57.6 Configuring signing settings in the build file 57.7 Running Gradle tasks from the command-line 57.8 Summary Index
Donate to keep this site alive
1. Disable the AdBlock plugin. Otherwise, you may not get any links.
2. Solve the CAPTCHA.
3. Click download link.
4. Lead to download server to download.