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