1 /* 2 * Copyright 2019, 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 package com.android.managedprovisioning.finalization; 17 18 import android.graphics.drawable.AnimatedVectorDrawable; 19 import android.os.Bundle; 20 import android.widget.ImageView; 21 import com.android.managedprovisioning.R; 22 import com.android.managedprovisioning.common.SetupGlifLayoutActivity; 23 import com.android.managedprovisioning.common.Utils; 24 import com.android.managedprovisioning.model.CustomizationParams; 25 import com.android.managedprovisioning.model.ProvisioningParams; 26 import com.google.android.setupdesign.GlifLayout; 27 28 /** 29 * This activity shows the final screen of the admin integrated flow. 30 * Only shown for work profile provisioning during setup wizard. 31 */ 32 public class FinalScreenActivity extends SetupGlifLayoutActivity { 33 34 static String EXTRA_PROVISIONING_PARAMS = 35 "com.android.managedprovisioning.PROVISIONING_PARAMS"; 36 37 private AnimatedVectorDrawable mAnimation; 38 39 @Override onCreate(Bundle savedInstanceState)40 public void onCreate(Bundle savedInstanceState) { 41 super.onCreate(savedInstanceState); 42 final ProvisioningParams provisioningParams = 43 getIntent().getParcelableExtra(EXTRA_PROVISIONING_PARAMS); 44 if (provisioningParams == null) { 45 throw new IllegalStateException("Can't show UI without provisioning params."); 46 } 47 initializeUi(provisioningParams); 48 } 49 50 @Override onStart()51 protected void onStart() { 52 super.onStart(); 53 if (mAnimation != null) { 54 mAnimation.start(); 55 } 56 } 57 58 @Override onStop()59 protected void onStop() { 60 super.onStop(); 61 if (mAnimation != null) { 62 mAnimation.stop(); 63 } 64 } 65 initializeUi(ProvisioningParams params)66 private void initializeUi(ProvisioningParams params) { 67 final int headerResId = R.string.device_provisioning_finished; 68 final int titleResId = R.string.device_provisioning_finished; 69 70 final CustomizationParams customizationParams = 71 CustomizationParams.createInstance(params, this, mUtils); 72 initializeLayoutParams(R.layout.final_screen, headerResId, customizationParams); 73 setTitle(titleResId); 74 75 final GlifLayout layout = findViewById(R.id.setup_wizard_layout); 76 final ImageView imageView = layout.findViewById(R.id.animation); 77 imageView.setImageResource(mUtils.isProfileOwnerAction(params.provisioningAction) 78 ? R.drawable.all_done_animation_wp 79 : R.drawable.all_done_animation_do); 80 mAnimation = (AnimatedVectorDrawable) imageView.getDrawable(); 81 Utils.addDoneButton(layout, v -> onDoneButtonPressed()); 82 83 if (Utils.isSilentProvisioning(this, params)) { 84 onDoneButtonPressed(); 85 } 86 } 87 onDoneButtonPressed()88 private void onDoneButtonPressed() { 89 finish(); 90 } 91 92 93 } 94