1 /* 2 * Copyright (C) 2015 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.android.tv.settings.device.storage; 18 19 import android.content.Context; 20 import android.content.pm.PackageManager; 21 import android.os.Bundle; 22 import android.view.View; 23 24 import androidx.annotation.Nullable; 25 26 import com.android.tv.settings.R; 27 import com.android.tv.settings.dialog.ProgressDialogFragment; 28 29 public class MoveAppProgressFragment extends ProgressDialogFragment { 30 31 private static final String ARG_APP_TITLE = "appTitle"; 32 newInstance(CharSequence appTitle)33 public static MoveAppProgressFragment newInstance(CharSequence appTitle) { 34 final MoveAppProgressFragment fragment = new MoveAppProgressFragment(); 35 final Bundle b = new Bundle(1); 36 b.putCharSequence(ARG_APP_TITLE, appTitle); 37 fragment.setArguments(b); 38 return fragment; 39 } 40 41 @Override onViewCreated(View view, @Nullable Bundle savedInstanceState)42 public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { 43 super.onViewCreated(view, savedInstanceState); 44 final CharSequence appTitle = getArguments().getCharSequence(ARG_APP_TITLE); 45 setTitle(getActivity().getString(R.string.storage_wizard_move_app_progress_title, 46 appTitle)); 47 setSummary(getActivity().getString(R.string.storage_wizard_move_app_progress_description, 48 appTitle)); 49 } 50 moveStatusToMessage(Context context, int returnCode)51 public static CharSequence moveStatusToMessage(Context context, int returnCode) { 52 switch (returnCode) { 53 case PackageManager.MOVE_FAILED_INSUFFICIENT_STORAGE: 54 return context.getString(R.string.insufficient_storage); 55 case PackageManager.MOVE_FAILED_DEVICE_ADMIN: 56 return context.getString(R.string.move_error_device_admin); 57 case PackageManager.MOVE_FAILED_DOESNT_EXIST: 58 return context.getString(R.string.does_not_exist); 59 case PackageManager.MOVE_FAILED_INVALID_LOCATION: 60 return context.getString(R.string.invalid_location); 61 case PackageManager.MOVE_FAILED_SYSTEM_PACKAGE: 62 return context.getString(R.string.system_package); 63 case PackageManager.MOVE_FAILED_INTERNAL_ERROR: 64 default: 65 return context.getString(R.string.insufficient_storage); 66 } 67 } 68 69 } 70