Help menus for several screens.
Bug: 5144896 Change-Id: Ib2f5146f6f62f2a33261bb165c3bf1bf13b22f38
This commit is contained in:
@@ -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.
|
||||
|
Reference in New Issue
Block a user