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.settings.applications; 18 19 import static com.android.settings.applications.AppHeaderController.ActionType; 20 21 import android.app.Activity; 22 import android.os.Bundle; 23 import android.support.v7.preference.Preference; 24 import android.util.IconDrawableFactory; 25 import android.util.Log; 26 27 import com.android.settings.overlay.FeatureFactory; 28 import com.android.settingslib.applications.AppUtils; 29 30 public abstract class AppInfoWithHeader extends AppInfoBase { 31 32 private boolean mCreated; 33 34 @Override onActivityCreated(Bundle savedInstanceState)35 public void onActivityCreated(Bundle savedInstanceState) { 36 super.onActivityCreated(savedInstanceState); 37 if (mCreated) { 38 Log.w(TAG, "onActivityCreated: ignoring duplicate call"); 39 return; 40 } 41 mCreated = true; 42 if (mPackageInfo == null) return; 43 final Activity activity = getActivity(); 44 final Preference pref = FeatureFactory.getFactory(activity) 45 .getApplicationFeatureProvider(activity) 46 .newAppHeaderController(this, null /* appHeader */) 47 .setIcon(IconDrawableFactory.newInstance(activity) 48 .getBadgedIcon(mPackageInfo.applicationInfo)) 49 .setLabel(mPackageInfo.applicationInfo.loadLabel(mPm)) 50 .setSummary(mPackageInfo) 51 .setIsInstantApp(AppUtils.isInstant(mPackageInfo.applicationInfo)) 52 .setPackageName(mPackageName) 53 .setUid(mPackageInfo.applicationInfo.uid) 54 .setButtonActions(ActionType.ACTION_APP_INFO, ActionType.ACTION_NONE) 55 .done(activity, getPrefContext()); 56 getPreferenceScreen().addPreference(pref); 57 } 58 } 59