• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2014, Google Inc.
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.mail.ui;
17 
18 import android.app.ActionBar;
19 import android.app.Activity;
20 import android.content.pm.PackageInfo;
21 import android.content.pm.PackageManager;
22 import android.os.Bundle;
23 
24 import com.android.mail.R;
25 import com.android.mail.utils.LogTag;
26 import com.android.mail.utils.LogUtils;
27 
28 /**
29  * This activity customizes its ActionBar and leaves the heavy lifting to its child HelpFragment.
30  */
31 public class HelpActivity extends Activity {
32 
33     private static final String LOG_TAG = LogTag.getLogTag();
34 
35     public static final String PARAM_HELP_URL = "help.url";
36 
37     @Override
onCreate(Bundle savedInstanceState)38     protected void onCreate(Bundle savedInstanceState) {
39         super.onCreate(savedInstanceState);
40 
41         setContentView(R.layout.help_activity);
42 
43         // Customize the action bar behavior and display
44         final ActionBar actionBar = getActionBar();
45         if (actionBar != null) {
46             actionBar.setDisplayHomeAsUpEnabled(true);
47             actionBar.setTitle(R.string.help_and_info);
48 
49             final PackageManager packageManager = getPackageManager();
50             if (packageManager != null) {
51                 try {
52                     final String appName = getString(R.string.app_name);
53                     final PackageInfo pi = packageManager.getPackageInfo(getPackageName(), 0);
54                     actionBar.setSubtitle(getString(R.string.version, appName, pi.versionName));
55                 } catch (PackageManager.NameNotFoundException e) {
56                     // Can't find version? Oh well. Just leave it blank.
57                     LogUtils.wtf(LOG_TAG, e, "Unable to locate application version.");
58                 }
59             }
60         }
61     }
62 }