diff options
author | Amith Yamasani <yamasani@google.com> | 2012-04-23 15:35:36 -0700 |
---|---|---|
committer | Amith Yamasani <yamasani@google.com> | 2012-04-23 15:35:36 -0700 |
commit | b0b37ae21c172491bc170659b5f429601858ddc1 (patch) | |
tree | c48b8e9320be5e696c330331b7cddbde6ba93b03 /src/com/android/settings/SettingsPreferenceFragment.java | |
parent | c1da7b105ae6f224a78fa7c8e151faf16e88a55c (diff) | |
download | packages_apps_settings-b0b37ae21c172491bc170659b5f429601858ddc1.zip packages_apps_settings-b0b37ae21c172491bc170659b5f429601858ddc1.tar.gz packages_apps_settings-b0b37ae21c172491bc170659b5f429601858ddc1.tar.bz2 |
Help menus for several screens.
Bug: 5144896
Change-Id: Ib2f5146f6f62f2a33261bb165c3bf1bf13b22f38
Diffstat (limited to 'src/com/android/settings/SettingsPreferenceFragment.java')
-rw-r--r-- | src/com/android/settings/SettingsPreferenceFragment.java | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/com/android/settings/SettingsPreferenceFragment.java b/src/com/android/settings/SettingsPreferenceFragment.java index f7e3b02..8500f8d 100644 --- a/src/com/android/settings/SettingsPreferenceFragment.java +++ b/src/com/android/settings/SettingsPreferenceFragment.java @@ -21,11 +21,17 @@ import android.app.DialogFragment; import android.app.Fragment; import android.content.ContentResolver; import android.content.DialogInterface; +import android.content.Intent; import android.content.pm.PackageManager; +import android.net.Uri; import android.os.Bundle; import android.preference.PreferenceActivity; import android.preference.PreferenceFragment; +import android.text.TextUtils; import android.util.Log; +import android.view.Menu; +import android.view.MenuInflater; +import android.view.MenuItem; import android.widget.Button; /** @@ -35,13 +41,51 @@ public class SettingsPreferenceFragment extends PreferenceFragment implements Di private static final String TAG = "SettingsPreferenceFragment"; + private static final int MENU_HELP = Menu.FIRST + 100; + private SettingsDialogFragment mDialogFragment; + private String mHelpUrl; + + @Override + public void onCreate(Bundle icicle) { + super.onCreate(icicle); + + // Prepare help url and enable menu if necessary + int helpResource = getHelpResource(); + if (helpResource != 0) { + mHelpUrl = getResources().getString(helpResource); + if (!TextUtils.isEmpty(mHelpUrl)) { + setHasOptionsMenu(true); + } + } + } + @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); } + /** + * Override this if you want to show a help item in the menu, by returning the resource id. + * @return the resource id for the help url + */ + protected int getHelpResource() { + return 0; + } + + @Override + public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { + if (mHelpUrl != null) { + Intent helpIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(mHelpUrl)); + helpIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK + | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); + MenuItem helpItem = menu.add(0, MENU_HELP, 0, R.string.help_label); + helpItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); + helpItem.setIntent(helpIntent); + } + } + /* * The name is intentionally made different from Activity#finish(), so that * users won't misunderstand its meaning. |