• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 android.app.Fragment;
20 import android.content.Intent;
21 import android.net.Uri;
22 import android.os.Bundle;
23 import android.provider.Settings;
24 import android.util.Log;
25 
26 import com.android.settings.AppHeader;
27 
28 public abstract class AppInfoWithHeader extends AppInfoBase {
29 
30     public static final String EXTRA_HIDE_INFO_BUTTON = "hideInfoButton";
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         AppHeader.createAppHeader(this, mPackageInfo.applicationInfo.loadIcon(mPm),
44                 mPackageInfo.applicationInfo.loadLabel(mPm), getInfoIntent(this, mPackageName), 0);
45     }
46 
getInfoIntent(Fragment fragment, String packageName)47     public static Intent getInfoIntent(Fragment fragment, String packageName) {
48         Bundle args = fragment.getArguments();
49         Intent intent = fragment.getActivity().getIntent();
50         boolean showInfo = true;
51         if (args != null && args.getBoolean(EXTRA_HIDE_INFO_BUTTON, false)) {
52             showInfo = false;
53         }
54         if (intent != null && intent.getBooleanExtra(EXTRA_HIDE_INFO_BUTTON, false)) {
55             showInfo = false;
56         }
57         Intent infoIntent = null;
58         if (showInfo) {
59             infoIntent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
60             infoIntent.setData(Uri.fromParts("package", packageName, null));
61         }
62         return infoIntent;
63     }
64 }
65