├── .gitignore ├── .project ├── ASSETS_LICENSE.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── ic_launcher-playstore.png │ ├── java │ └── com │ │ └── example │ │ └── background │ │ ├── BlurActivity.kt │ │ ├── BlurViewModel.kt │ │ ├── Constants.kt │ │ └── workers │ │ ├── BlurWorker.kt │ │ ├── CleanupWorker.kt │ │ ├── SaveImageToFileWorker.kt │ │ └── WorkerUtils.kt │ └── res │ ├── drawable │ ├── android_cupcake.png │ ├── ic_launcher_background.xml │ ├── ic_launcher_foreground.xml │ └── test.jpg │ ├── layout │ └── activity_blur.xml │ ├── mipmap-anydpi-v26 │ ├── ic_launcher.xml │ └── ic_launcher_round.xml │ ├── mipmap-hdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-mdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xxhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xxxhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ └── values │ ├── colors.xml │ ├── strings.xml │ └── styles.xml ├── build.gradle ├── circle.yml ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | <<<<<<< HEAD 3 | secrets.txt 4 | ======= 5 | >>>>>>> aa8a8ed... Porting WorkManager codelab to Kotlin 6 | .idea/ 7 | .gradle 8 | /local.properties 9 | .DS_Store 10 | build/ 11 | /captures 12 | .externalNativeBuild 13 | app/build 14 | build 15 | <<<<<<< HEAD 16 | app/release/ 17 | ======= 18 | app/release/ 19 | >>>>>>> aa8a8ed... Porting WorkManager codelab to Kotlin 20 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | WorkManagerSample 4 | Project WorkManagerSample created by Buildship. 5 | 6 | 7 | 8 | 9 | org.eclipse.buildship.core.gradleprojectbuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.buildship.core.gradleprojectnature 16 | 17 | 18 | -------------------------------------------------------------------------------- /ASSETS_LICENSE.md: -------------------------------------------------------------------------------- 1 | # Asset Licenses 2 | 3 | The licenses for the asset files included in this demo can be found below. 4 | 5 | ## test.png 6 | 7 | Retreived from [https://www.ars.usda.gov/oc/images/photos/jun04/k11252-1/](https://www.ars.usda.gov/oc/images/photos/jun04/k11252-1/) on 28 April 2018. 8 | 9 | Photo courtesy of USDA Agricultural Research Service 10 | 11 | Photos in our Image Gallery are available free of charge and are copyright-free, public domain, images unless otherwise indicated. 12 | 13 | Please note: these photos may not be used to infer or imply ARS endorsement of any product, company, or position. 14 | 15 | When using these photos, we ask that you credit the Agricultural Research Service. You may use one of the following credit lines: 16 | 17 | Photo by (photographer's name), USDA Agricultural Research Service. 18 | Photo courtesy of USDA Agricultural Research Service. 19 | Photo courtesy of USDA ARS. -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How to become a contributor and submit your own code 2 | 3 | ## Contributor License Agreements 4 | 5 | We'd love to accept your patches! Before we can take them, we have to jump a couple of 6 | legal hurdles. 7 | 8 | Please fill out either the individual or corporate Contributor License Agreement (CLA). 9 | 10 | * If you are an individual writing original source code and you're sure you 11 | own the intellectual property, then you'll need to sign an [individual CLA] 12 | (https://cla.developers.google.com). 13 | * If you work for a company that wants to allow you to contribute your work, 14 | then you'll need to sign a [corporate CLA] 15 | (https://cla.developers.google.com). 16 | * Please make sure you sign both, Android and Google CLA 17 | 18 | Follow either of the two links above to access the appropriate CLA and 19 | instructions for how to sign and return it. Once we receive it, we'll be able to 20 | accept your pull requests. 21 | 22 | ## Contributing A Patch 23 | 24 | 1. Submit an issue describing your proposed change to the repo in question. 25 | 1. The repo owner will respond to your issue promptly. 26 | 1. If your proposed change is accepted, and you haven't already done so, sign a 27 | Contributor License Agreement (see details above). 28 | 1. Fork the desired repo, develop and test your code changes. 29 | 1. Ensure that your code adheres to the existing style in the sample to which 30 | you are contributing. Refer to the 31 | [Android Code Style Guide] 32 | (https://source.android.com/source/code-style.html) for the 33 | recommended coding standards for this organization. 34 | 1. Ensure that your code has an appropriate set of unit tests which all pass. 35 | 1. Submit a pull request. 36 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2014 The Android Open Source Project 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | > [!CAUTION] 2 | > This codelab is deprecated and will be removed soon. 3 | > 4 | > Please see https://developer.android.com/codelabs/basic-android-kotlin-compose-workmanager 5 | 6 | WorkManager Codelab 7 | =================================== 8 | 9 | This repository contains the code for the 10 | [WorkManager Codelab](https://codelabs.developers.google.com/codelabs/android-workmanager): 11 | 12 | Java version 13 | -------------- 14 | 15 | The Java version of this codelab is available under the 16 | [`Java`](https://github.com/googlecodelabs/android-workmanager/tree/java) branch of this 17 | repository. 18 | 19 | Introduction 20 | ------------ 21 | 22 | At I/O 2018 Google announced [Android Jetpack](https://developer.android.com//jetpack/), 23 | a collection of libraries, tools and architectural guidance to accelerate and simplify the 24 | development of great Android apps. One of those libraries is the 25 | [WorkManager library](https://developer.android.com/topic/libraries/architecture/workmanager/). 26 | The WorkManager library provides a unified API for deferrable one-off or recurring background tasks 27 | that need guaranteed execution. You can learn more by reading the 28 | [WorkManager Guide](https://developer.android.com/topic/libraries/architecture/workmanager/), the 29 | [WorkManager Reference](https://developer.android.com/reference/androidx/work/package-summary) 30 | or doing the 31 | [WorkManager Codelab](https://codelabs.developers.google.com/codelabs/android-workmanager). 32 | 33 | Pre-requisites 34 | -------------- 35 | 36 | * Android Studio 3.6 or later and you know how to use it. 37 | 38 | * Make sure Android Studio is updated, as well as your SDK and Gradle. 39 | Otherwise, you may have to wait for a while until all the updates are done. 40 | 41 | * A device or emulator that runs API level 16+ 42 | 43 | You need to be solidly familiar with the Kotlin programming language, 44 | object-oriented design concepts, and Android Development Fundamentals. 45 | In particular: 46 | 47 | * Basic layouts, widgets and [View Bindings](https://d.android.com/topic/libraries/view-binding) 48 | * Some familiarity with Uris and File I/O 49 | * Familiarity with [LiveData](https://developer.android.com/topic/libraries/architecture/livedata) 50 | and [ViewModel](https://developer.android.com/topic/libraries/architecture/viewmodel) 51 | 52 | Getting Started 53 | --------------- 54 | 55 | 1. [Install Android Studio](https://developer.android.com/studio/install.html), 56 | if you don't already have it. 57 | 2. Download the sample. 58 | 2. Import the sample into Android Studio. 59 | 3. Build and run the sample. 60 | 61 | License 62 | ------- 63 | 64 | Copyright 2018 Google, Inc. 65 | 66 | All image and audio files (including *.png, *.jpg, *.svg, *.mp3, *.wav 67 | and *.ogg) are licensed under the CC BY 4.0 license. All other files are 68 | licensed under the Apache 2 license. 69 | 70 | Licensed to the Apache Software Foundation (ASF) under one or more contributor 71 | license agreements. See the LICENSE file distributed with this work for 72 | additional information regarding copyright ownership. The ASF licenses this 73 | file to you under the Apache License, Version 2.0 (the "License"); you may not 74 | use this file except in compliance with the License. You may obtain a copy of 75 | the License at 76 | 77 | http://www.apache.org/licenses/LICENSE-2.0 78 | 79 | Unless required by applicable law or agreed to in writing, software 80 | distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 81 | WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 82 | License for the specific language governing permissions and limitations under 83 | the License. 84 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | .project 3 | .classpath 4 | .settings/org.eclipse.buildship.core.prefs 5 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | apply plugin: 'com.android.application' 18 | apply plugin: 'kotlin-android' 19 | apply plugin: 'kotlin-kapt' 20 | 21 | android { 22 | compileSdkVersion versions.compileSdk 23 | defaultConfig { 24 | applicationId "com.example.background" 25 | renderscriptTargetApi 11 26 | renderscriptSupportModeEnabled true 27 | vectorDrawables { 28 | useSupportLibrary true 29 | } 30 | 31 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 32 | // The following argument makes the Android Test Orchestrator run its 33 | // "pm clear" command after each test invocation. This command ensures 34 | // that the app's state is completely cleared between tests. 35 | testInstrumentationRunnerArguments clearPackageData: 'true' 36 | 37 | minSdkVersion versions.minSdk 38 | targetSdkVersion versions.targetSdk 39 | versionCode 1 40 | versionName "1.0" 41 | } 42 | buildTypes { 43 | release { 44 | minifyEnabled true 45 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 46 | } 47 | } 48 | compileOptions { 49 | sourceCompatibility JavaVersion.VERSION_1_8 50 | targetCompatibility JavaVersion.VERSION_1_8 51 | } 52 | kotlinOptions { 53 | jvmTarget = "1.8" 54 | } 55 | 56 | viewBinding { 57 | enabled = true 58 | } 59 | } 60 | 61 | dependencies { 62 | implementation "androidx.appcompat:appcompat:1.4.1" 63 | implementation "androidx.constraintlayout:constraintlayout:2.1.3" 64 | implementation "androidx.activity:activity-ktx:1.4.0" 65 | implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" 66 | implementation "androidx.work:work-runtime-ktx:$versions.work" 67 | implementation "com.github.bumptech.glide:glide:4.12.0" 68 | } 69 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # Rendescript 9 | -keepclasseswithmembernames class * { 10 | native ; 11 | } 12 | 13 | -keep class androidx.renderscript.** { *; } 14 | 15 | 16 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 39 | 40 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /app/src/main/ic_launcher-playstore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/android/codelab-android-workmanager/e0ec55e3161cbe80cf9b56b6d43b789428978a56/app/src/main/ic_launcher-playstore.png -------------------------------------------------------------------------------- /app/src/main/java/com/example/background/BlurActivity.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.example.background 18 | 19 | import android.content.Intent 20 | import android.os.Bundle 21 | import android.view.View 22 | import androidx.activity.viewModels 23 | import androidx.appcompat.app.AppCompatActivity 24 | import androidx.lifecycle.Observer 25 | import androidx.work.WorkInfo 26 | import com.example.background.databinding.ActivityBlurBinding 27 | 28 | class BlurActivity : AppCompatActivity() { 29 | 30 | private val viewModel: BlurViewModel by viewModels { BlurViewModelFactory(application) } 31 | private lateinit var binding: ActivityBlurBinding 32 | 33 | override fun onCreate(savedInstanceState: Bundle?) { 34 | super.onCreate(savedInstanceState) 35 | binding = ActivityBlurBinding.inflate(layoutInflater) 36 | setContentView(binding.root) 37 | 38 | binding.goButton.setOnClickListener { viewModel.applyBlur(blurLevel) } 39 | 40 | // Setup view output image file button 41 | binding.seeFileButton.setOnClickListener { 42 | viewModel.outputUri?.let { currentUri -> 43 | val actionView = Intent(Intent.ACTION_VIEW, currentUri) 44 | actionView.resolveActivity(packageManager)?.run { 45 | startActivity(actionView) 46 | } 47 | } 48 | } 49 | 50 | // Hookup the Cancel button 51 | binding.cancelButton.setOnClickListener { viewModel.cancelWork() } 52 | 53 | viewModel.outputWorkInfos.observe(this, workInfosObserver()) 54 | } 55 | 56 | private fun workInfosObserver(): Observer> { 57 | return Observer { listOfWorkInfo -> 58 | 59 | // Note that these next few lines grab a single WorkInfo if it exists 60 | // This code could be in a Transformation in the ViewModel; they are included here 61 | // so that the entire process of displaying a WorkInfo is in one location. 62 | 63 | // If there are no matching work info, do nothing 64 | if (listOfWorkInfo.isNullOrEmpty()) { 65 | return@Observer 66 | } 67 | 68 | // We only care about the one output status. 69 | // Every continuation has only one worker tagged TAG_OUTPUT 70 | val workInfo = listOfWorkInfo[0] 71 | 72 | if (workInfo.state.isFinished) { 73 | showWorkFinished() 74 | 75 | // Normally this processing, which is not directly related to drawing views on 76 | // screen would be in the ViewModel. For simplicity we are keeping it here. 77 | val outputImageUri = workInfo.outputData.getString(KEY_IMAGE_URI) 78 | 79 | // If there is an output file show "See File" button 80 | if (!outputImageUri.isNullOrEmpty()) { 81 | viewModel.setOutputUri(outputImageUri) 82 | binding.seeFileButton.visibility = View.VISIBLE 83 | } 84 | } else { 85 | showWorkInProgress() 86 | } 87 | } 88 | } 89 | 90 | /** 91 | * Shows and hides views for when the Activity is processing an image 92 | */ 93 | private fun showWorkInProgress() { 94 | with(binding) { 95 | progressBar.visibility = View.VISIBLE 96 | cancelButton.visibility = View.VISIBLE 97 | goButton.visibility = View.GONE 98 | seeFileButton.visibility = View.GONE 99 | } 100 | } 101 | 102 | /** 103 | * Shows and hides views for when the Activity is done processing an image 104 | */ 105 | private fun showWorkFinished() { 106 | with(binding) { 107 | progressBar.visibility = View.GONE 108 | cancelButton.visibility = View.GONE 109 | goButton.visibility = View.VISIBLE 110 | } 111 | } 112 | 113 | private val blurLevel: Int 114 | get() = 115 | when (binding.radioBlurGroup.checkedRadioButtonId) { 116 | R.id.radio_blur_lv_1 -> 1 117 | R.id.radio_blur_lv_2 -> 2 118 | R.id.radio_blur_lv_3 -> 3 119 | else -> 1 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/background/BlurViewModel.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.example.background 18 | 19 | import android.app.Application 20 | import android.content.ContentResolver 21 | import android.content.Context 22 | import android.net.Uri 23 | import androidx.lifecycle.LiveData 24 | import androidx.lifecycle.ViewModel 25 | import androidx.lifecycle.ViewModelProvider 26 | import androidx.work.Constraints 27 | import androidx.work.Data 28 | import androidx.work.ExistingWorkPolicy 29 | import androidx.work.OneTimeWorkRequest 30 | import androidx.work.OneTimeWorkRequestBuilder 31 | import androidx.work.WorkInfo 32 | import androidx.work.WorkManager 33 | import com.example.background.workers.BlurWorker 34 | import com.example.background.workers.CleanupWorker 35 | import com.example.background.workers.SaveImageToFileWorker 36 | 37 | class BlurViewModel(application: Application) : ViewModel() { 38 | 39 | private var imageUri: Uri? = null 40 | internal var outputUri: Uri? = null 41 | private val workManager = WorkManager.getInstance(application) 42 | internal val outputWorkInfos: LiveData> = workManager.getWorkInfosByTagLiveData(TAG_OUTPUT) 43 | 44 | init { 45 | // This transformation makes sure that whenever the current work Id changes the WorkInfo 46 | // the UI is listening to changes 47 | imageUri = getImageUri(application.applicationContext) 48 | } 49 | 50 | internal fun cancelWork() { 51 | workManager.cancelUniqueWork(IMAGE_MANIPULATION_WORK_NAME) 52 | } 53 | 54 | /** 55 | * Creates the input data bundle which includes the Uri to operate on 56 | * @return Data which contains the Image Uri as a String 57 | */ 58 | private fun createInputDataForUri(): Data { 59 | val builder = Data.Builder() 60 | imageUri?.let { 61 | builder.putString(KEY_IMAGE_URI, imageUri.toString()) 62 | } 63 | return builder.build() 64 | } 65 | 66 | /** 67 | * Create the WorkRequest to apply the blur and save the resulting image 68 | * @param blurLevel The amount to blur the image 69 | */ 70 | internal fun applyBlur(blurLevel: Int) { 71 | // Add WorkRequest to Cleanup temporary images 72 | var continuation = workManager 73 | .beginUniqueWork( 74 | IMAGE_MANIPULATION_WORK_NAME, 75 | ExistingWorkPolicy.REPLACE, 76 | OneTimeWorkRequest.from(CleanupWorker::class.java) 77 | ) 78 | 79 | // Add WorkRequests to blur the image the number of times requested 80 | for (i in 0 until blurLevel) { 81 | val blurBuilder = OneTimeWorkRequestBuilder() 82 | 83 | // Input the Uri if this is the first blur operation 84 | // After the first blur operation the input will be the output of previous 85 | // blur operations. 86 | if (i == 0) { 87 | blurBuilder.setInputData(createInputDataForUri()) 88 | } 89 | 90 | continuation = continuation.then(blurBuilder.build()) 91 | } 92 | 93 | // Create charging constraint 94 | val constraints = Constraints.Builder() 95 | .setRequiresCharging(true) 96 | .build() 97 | 98 | // Add WorkRequest to save the image to the filesystem 99 | val save = OneTimeWorkRequestBuilder() 100 | .setConstraints(constraints) 101 | .addTag(TAG_OUTPUT) 102 | .build() 103 | continuation = continuation.then(save) 104 | 105 | // Actually start the work 106 | continuation.enqueue() 107 | } 108 | 109 | private fun uriOrNull(uriString: String?): Uri? { 110 | return if (!uriString.isNullOrEmpty()) { 111 | Uri.parse(uriString) 112 | } else { 113 | null 114 | } 115 | } 116 | 117 | private fun getImageUri(context: Context): Uri { 118 | val resources = context.resources 119 | 120 | return Uri.Builder() 121 | .scheme(ContentResolver.SCHEME_ANDROID_RESOURCE) 122 | .authority(resources.getResourcePackageName(R.drawable.android_cupcake)) 123 | .appendPath(resources.getResourceTypeName(R.drawable.android_cupcake)) 124 | .appendPath(resources.getResourceEntryName(R.drawable.android_cupcake)) 125 | .build() 126 | } 127 | 128 | internal fun setOutputUri(outputImageUri: String?) { 129 | outputUri = uriOrNull(outputImageUri) 130 | } 131 | } 132 | 133 | class BlurViewModelFactory(private val application: Application) : ViewModelProvider.Factory { 134 | 135 | override fun create(modelClass: Class): T { 136 | return if (modelClass.isAssignableFrom(BlurViewModel::class.java)) { 137 | BlurViewModel(application) as T 138 | } else { 139 | throw IllegalArgumentException("Unknown ViewModel class") 140 | } 141 | } 142 | } 143 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/background/Constants.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | @file:JvmName("Constants") 18 | 19 | package com.example.background 20 | 21 | // Notification Channel constants 22 | 23 | // Name of Notification Channel for verbose notifications of background work 24 | @JvmField val VERBOSE_NOTIFICATION_CHANNEL_NAME: CharSequence = 25 | "Verbose WorkManager Notifications" 26 | const val VERBOSE_NOTIFICATION_CHANNEL_DESCRIPTION = 27 | "Shows notifications whenever work starts" 28 | @JvmField val NOTIFICATION_TITLE: CharSequence = "WorkRequest Starting" 29 | const val CHANNEL_ID = "VERBOSE_NOTIFICATION" 30 | const val NOTIFICATION_ID = 1 31 | 32 | // The name of the image manipulation work 33 | const val IMAGE_MANIPULATION_WORK_NAME = "image_manipulation_work" 34 | 35 | // Other keys 36 | const val OUTPUT_PATH = "blur_filter_outputs" 37 | const val KEY_IMAGE_URI = "KEY_IMAGE_URI" 38 | const val TAG_OUTPUT = "OUTPUT" 39 | 40 | const val DELAY_TIME_MILLIS: Long = 3000 41 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/background/workers/BlurWorker.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.example.background.workers 18 | 19 | import android.content.Context 20 | import android.graphics.BitmapFactory 21 | import android.net.Uri 22 | import android.text.TextUtils 23 | import android.util.Log 24 | import androidx.work.Worker 25 | import androidx.work.WorkerParameters 26 | import androidx.work.workDataOf 27 | import com.example.background.KEY_IMAGE_URI 28 | 29 | private const val TAG = "BlurWorker" 30 | class BlurWorker(ctx: Context, params: WorkerParameters) : Worker(ctx, params) { 31 | 32 | override fun doWork(): Result { 33 | val appContext = applicationContext 34 | 35 | val resourceUri = inputData.getString(KEY_IMAGE_URI) 36 | 37 | makeStatusNotification("Blurring image", appContext) 38 | 39 | // This is an utility function added to emulate slower work. 40 | sleep() 41 | 42 | return try { 43 | if (TextUtils.isEmpty(resourceUri)) { 44 | Log.e(TAG, "Invalid input uri") 45 | throw IllegalArgumentException("Invalid input uri") 46 | } 47 | 48 | val resolver = appContext.contentResolver 49 | 50 | val picture = BitmapFactory.decodeStream( 51 | resolver.openInputStream(Uri.parse(resourceUri))) 52 | 53 | val output = blurBitmap(picture, appContext) 54 | 55 | // Write bitmap to a temp file 56 | val outputUri = writeBitmapToFile(appContext, output) 57 | 58 | val outputData = workDataOf(KEY_IMAGE_URI to outputUri.toString()) 59 | 60 | Result.success(outputData) 61 | } catch (throwable: Throwable) { 62 | Log.e(TAG, "Error applying blur") 63 | throwable.printStackTrace() 64 | Result.failure() 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/background/workers/CleanupWorker.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.example.background.workers 18 | 19 | import android.content.Context 20 | import android.util.Log 21 | import androidx.work.Worker 22 | import androidx.work.WorkerParameters 23 | import com.example.background.OUTPUT_PATH 24 | import java.io.File 25 | 26 | /** 27 | * Cleans up temporary files generated during blurring process 28 | */ 29 | private const val TAG = "CleanupWorker" 30 | class CleanupWorker(ctx: Context, params: WorkerParameters) : Worker(ctx, params) { 31 | 32 | override fun doWork(): Result { 33 | // Makes a notification when the work starts and slows down the work so that 34 | // it's easier to see each WorkRequest start, even on emulated devices 35 | makeStatusNotification("Cleaning up old temporary files", applicationContext) 36 | sleep() 37 | 38 | return try { 39 | val outputDirectory = File(applicationContext.filesDir, OUTPUT_PATH) 40 | if (outputDirectory.exists()) { 41 | val entries = outputDirectory.listFiles() 42 | if (entries != null) { 43 | for (entry in entries) { 44 | val name = entry.name 45 | if (name.isNotEmpty() && name.endsWith(".png")) { 46 | val deleted = entry.delete() 47 | Log.i(TAG, "Deleted $name - $deleted") 48 | } 49 | } 50 | } 51 | } 52 | Result.success() 53 | } catch (exception: Exception) { 54 | exception.printStackTrace() 55 | Result.failure() 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/background/workers/SaveImageToFileWorker.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.example.background.workers 18 | 19 | import android.content.Context 20 | import android.graphics.BitmapFactory 21 | import android.net.Uri 22 | import android.provider.MediaStore 23 | import android.util.Log 24 | import androidx.work.workDataOf 25 | import androidx.work.Worker 26 | import androidx.work.WorkerParameters 27 | import com.example.background.KEY_IMAGE_URI 28 | import java.text.SimpleDateFormat 29 | import java.util.Date 30 | import java.util.Locale 31 | 32 | /** 33 | * Saves the image to a permanent file 34 | */ 35 | private const val TAG = "SaveImageToFileWorker" 36 | class SaveImageToFileWorker(ctx: Context, params: WorkerParameters) : Worker(ctx, params) { 37 | 38 | private val Title = "Blurred Image" 39 | private val dateFormatter = SimpleDateFormat( 40 | "yyyy.MM.dd 'at' HH:mm:ss z", 41 | Locale.getDefault() 42 | ) 43 | 44 | override fun doWork(): Result { 45 | // Makes a notification when the work starts and slows down the work so that 46 | // it's easier to see each WorkRequest start, even on emulated devices 47 | makeStatusNotification("Saving image", applicationContext) 48 | sleep() 49 | 50 | val resolver = applicationContext.contentResolver 51 | return try { 52 | val resourceUri = inputData.getString(KEY_IMAGE_URI) 53 | val bitmap = BitmapFactory.decodeStream( 54 | resolver.openInputStream(Uri.parse(resourceUri))) 55 | val imageUrl = MediaStore.Images.Media.insertImage( 56 | resolver, bitmap, Title, dateFormatter.format(Date())) 57 | if (!imageUrl.isNullOrEmpty()) { 58 | val output = workDataOf(KEY_IMAGE_URI to imageUrl) 59 | 60 | Result.success(output) 61 | } else { 62 | Log.e(TAG, "Writing to MediaStore failed") 63 | Result.failure() 64 | } 65 | } catch (exception: Exception) { 66 | exception.printStackTrace() 67 | Result.failure() 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/background/workers/WorkerUtils.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | @file:JvmName("WorkerUtils") 18 | 19 | package com.example.background.workers 20 | 21 | import android.app.NotificationChannel 22 | import android.app.NotificationManager 23 | import android.content.Context 24 | import android.graphics.Bitmap 25 | import android.net.Uri 26 | import android.os.Build 27 | import android.util.Log 28 | import androidx.annotation.WorkerThread 29 | import androidx.core.app.NotificationCompat 30 | import androidx.core.app.NotificationManagerCompat 31 | import androidx.renderscript.Allocation 32 | import androidx.renderscript.Element 33 | import androidx.renderscript.RenderScript 34 | import androidx.renderscript.ScriptIntrinsicBlur 35 | import com.example.background.CHANNEL_ID 36 | import com.example.background.DELAY_TIME_MILLIS 37 | import com.example.background.NOTIFICATION_ID 38 | import com.example.background.NOTIFICATION_TITLE 39 | import com.example.background.OUTPUT_PATH 40 | import com.example.background.R 41 | import com.example.background.VERBOSE_NOTIFICATION_CHANNEL_DESCRIPTION 42 | import com.example.background.VERBOSE_NOTIFICATION_CHANNEL_NAME 43 | import java.io.File 44 | import java.io.FileNotFoundException 45 | import java.io.FileOutputStream 46 | import java.io.IOException 47 | import java.util.UUID 48 | 49 | /** 50 | * Create a Notification that is shown as a heads-up notification if possible. 51 | * 52 | * For this codelab, this is used to show a notification so that you know when different steps 53 | * of the background work chain are starting 54 | * 55 | * @param message Message shown on the notification 56 | * @param context Context needed to create Toast 57 | */ 58 | 59 | private const val TAG = "WorkerUtils" 60 | fun makeStatusNotification(message: String, context: Context) { 61 | 62 | // Make a channel if necessary 63 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { 64 | // Create the NotificationChannel, but only on API 26+ because 65 | // the NotificationChannel class is new and not in the support library 66 | val name = VERBOSE_NOTIFICATION_CHANNEL_NAME 67 | val description = VERBOSE_NOTIFICATION_CHANNEL_DESCRIPTION 68 | val importance = NotificationManager.IMPORTANCE_HIGH 69 | val channel = NotificationChannel(CHANNEL_ID, name, importance) 70 | channel.description = description 71 | 72 | // Add the channel 73 | val notificationManager = 74 | context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager? 75 | 76 | notificationManager?.createNotificationChannel(channel) 77 | } 78 | 79 | // Create the notification 80 | val builder = NotificationCompat.Builder(context, CHANNEL_ID) 81 | .setSmallIcon(R.drawable.ic_launcher_foreground) 82 | .setContentTitle(NOTIFICATION_TITLE) 83 | .setContentText(message) 84 | .setPriority(NotificationCompat.PRIORITY_HIGH) 85 | .setVibrate(LongArray(0)) 86 | 87 | // Show the notification 88 | NotificationManagerCompat.from(context).notify(NOTIFICATION_ID, builder.build()) 89 | } 90 | 91 | /** 92 | * Method for sleeping for a fixed amount of time to emulate slower work 93 | */ 94 | fun sleep() { 95 | try { 96 | Thread.sleep(DELAY_TIME_MILLIS, 0) 97 | } catch (e: InterruptedException) { 98 | Log.e(TAG, e.message.toString()) 99 | } 100 | 101 | } 102 | 103 | /** 104 | * Blurs the given Bitmap image 105 | * @param bitmap Image to blur 106 | * @param applicationContext Application context 107 | * @return Blurred bitmap image 108 | */ 109 | @WorkerThread 110 | fun blurBitmap(bitmap: Bitmap, applicationContext: Context): Bitmap { 111 | lateinit var rsContext: RenderScript 112 | try { 113 | 114 | // Create the output bitmap 115 | val output = Bitmap.createBitmap( 116 | bitmap.width, bitmap.height, bitmap.config) 117 | 118 | // Blur the image 119 | rsContext = RenderScript.create(applicationContext, RenderScript.ContextType.DEBUG) 120 | val inAlloc = Allocation.createFromBitmap(rsContext, bitmap) 121 | val outAlloc = Allocation.createTyped(rsContext, inAlloc.type) 122 | val theIntrinsic = ScriptIntrinsicBlur.create(rsContext, Element.U8_4(rsContext)) 123 | theIntrinsic.apply { 124 | setRadius(10f) 125 | theIntrinsic.setInput(inAlloc) 126 | theIntrinsic.forEach(outAlloc) 127 | } 128 | outAlloc.copyTo(output) 129 | 130 | return output 131 | } finally { 132 | rsContext.finish() 133 | } 134 | } 135 | 136 | /** 137 | * Writes bitmap to a temporary file and returns the Uri for the file 138 | * @param applicationContext Application context 139 | * @param bitmap Bitmap to write to temp file 140 | * @return Uri for temp file with bitmap 141 | * @throws FileNotFoundException Throws if bitmap file cannot be found 142 | */ 143 | @Throws(FileNotFoundException::class) 144 | fun writeBitmapToFile(applicationContext: Context, bitmap: Bitmap): Uri { 145 | val name = String.format("blur-filter-output-%s.png", UUID.randomUUID().toString()) 146 | val outputDir = File(applicationContext.filesDir, OUTPUT_PATH) 147 | if (!outputDir.exists()) { 148 | outputDir.mkdirs() // should succeed 149 | } 150 | val outputFile = File(outputDir, name) 151 | var out: FileOutputStream? = null 152 | try { 153 | out = FileOutputStream(outputFile) 154 | bitmap.compress(Bitmap.CompressFormat.PNG, 0 /* ignored for PNG */, out) 155 | } finally { 156 | out?.let { 157 | try { 158 | it.close() 159 | } catch (ignore: IOException) { 160 | } 161 | 162 | } 163 | } 164 | return Uri.fromFile(outputFile) 165 | } 166 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/android_cupcake.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/android/codelab-android-workmanager/e0ec55e3161cbe80cf9b56b6d43b789428978a56/app/src/main/res/drawable/android_cupcake.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 22 | 25 | 26 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 22 | 26 | 27 | 29 | 32 | 35 | 38 | 41 | 42 | 44 | 45 | 48 | 51 | 54 | 57 | 60 | 63 | 66 | 69 | 72 | 75 | 78 | 81 | 86 | 91 | 96 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/test.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/android/codelab-android-workmanager/e0ec55e3161cbe80cf9b56b6d43b789428978a56/app/src/main/res/drawable/test.jpg -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_blur.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 23 | 24 | 29 | 30 | 38 | 39 | 45 | 46 | 47 | 53 | 57 | 61 | 65 | 66 | 67 | 72 | 73 | 74 | 75 | 82 | 83 | 87 |