Allow help to be defined to intent uri
Allow help uris to be either an intent uri or as uri (as they were before). Also add a default help uri, and specific helps for several screens. Bug: 15475009 Change-Id: Iff982892973f01d32ff61ea88d4844e9a7153500
This commit is contained in:
@@ -5427,6 +5427,34 @@
|
||||
<!-- Help URLs for some screens. Not specified here. Specified in product overlays --><skip/>
|
||||
<!-- Help menu label [CHAR LIMIT=20] -->
|
||||
<string name="help_label">Help & feedback</string>
|
||||
|
||||
<!-- Help URI, Default [DO NOT TRANSLATE] -->
|
||||
<string name="help_uri_default" translatable="false"></string>
|
||||
<!-- Help URI, Dashboard [DO NOT TRANSLATE] -->
|
||||
<string name="help_uri_dashboard" translatable="false"></string>
|
||||
<!-- Help URI, Android beam [DO NOT TRANSLATE] -->
|
||||
<string name="help_uri_beam" translatable="false"></string>
|
||||
<!-- Help URI, Display [DO NOT TRANSLATE] -->
|
||||
<string name="help_uri_display" translatable="false"></string>
|
||||
<!-- Help URI, Wallpaper [DO NOT TRANSLATE] -->
|
||||
<string name="help_uri_wallpaper" translatable="false"></string>
|
||||
<!-- Help URI, Interruptions [DO NOT TRANSLATE] -->
|
||||
<string name="help_uri_interruptions" translatable="false"></string>
|
||||
<!-- Help URI, Other sounds [DO NOT TRANSLATE] -->
|
||||
<string name="help_uri_other_sounds" translatable="false"></string>
|
||||
<!-- Help URI, Notifications [DO NOT TRANSLATE] -->
|
||||
<string name="help_uri_notifications" translatable="false"></string>
|
||||
<!-- Help URI, Apps [DO NOT TRANSLATE] -->
|
||||
<string name="help_uri_apps" translatable="false"></string>
|
||||
<!-- Help URI, Storage [DO NOT TRANSLATE] -->
|
||||
<string name="help_uri_storage" translatable="false"></string>
|
||||
<!-- Help URI, Accessibility [DO NOT TRANSLATE] -->
|
||||
<string name="help_uri_accessibility" translatable="false"></string>
|
||||
<!-- Help URI, Printing [DO NOT TRANSLATE] -->
|
||||
<string name="help_uri_printing" translatable="false"></string>
|
||||
<!-- Help URI, About phone [DO NOT TRANSLATE] -->
|
||||
<string name="help_uri_about" translatable="false"></string>
|
||||
|
||||
<!-- Help URL, WiFi [DO NOT TRANSLATE] -->
|
||||
<string name="help_url_wifi" translatable="false"></string>
|
||||
<!-- Help URL, Bluetooth [DO NOT TRANSLATE] -->
|
||||
|
@@ -89,6 +89,11 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment implements In
|
||||
return MetricsLogger.DEVICEINFO;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getHelpResource() {
|
||||
return R.string.help_uri_about;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
|
@@ -422,6 +422,11 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getHelpResource() {
|
||||
return R.string.help_uri_display;
|
||||
}
|
||||
|
||||
public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||
new BaseSearchIndexProvider() {
|
||||
@Override
|
||||
|
@@ -24,8 +24,10 @@ import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.net.Uri;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
@@ -33,7 +35,9 @@ import java.util.Locale;
|
||||
* browser to a particular URL, while taking into account the preferred language and app version.
|
||||
*/
|
||||
public class HelpUtils {
|
||||
private final static String TAG = HelpUtils.class.getName();
|
||||
private final static String TAG = HelpUtils.class.getSimpleName();
|
||||
|
||||
private static final int MENU_HELP = Menu.FIRST + 100;
|
||||
|
||||
/**
|
||||
* Help URL query parameter key for the preferred language.
|
||||
@@ -53,6 +57,16 @@ public class HelpUtils {
|
||||
/** Static helper that is not instantiable*/
|
||||
private HelpUtils() { }
|
||||
|
||||
public static boolean prepareHelpMenuItem(Context context, Menu menu, String helpUri) {
|
||||
MenuItem helpItem = menu.add(0, MENU_HELP, 0, R.string.help_label);
|
||||
return prepareHelpMenuItem(context, helpItem, helpUri);
|
||||
}
|
||||
|
||||
public static boolean prepareHelpMenuItem(Context context, Menu menu, int helpUriResource) {
|
||||
MenuItem helpItem = menu.add(0, MENU_HELP, 0, R.string.help_label);
|
||||
return prepareHelpMenuItem(context, helpItem, context.getString(helpUriResource));
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares the help menu item by doing the following.
|
||||
* - If the string corresponding to the helpUrlResourceId is empty or null, then the help menu
|
||||
@@ -77,22 +91,15 @@ public class HelpUtils {
|
||||
* @return returns whether the help menu item has been made visible.
|
||||
*/
|
||||
public static boolean prepareHelpMenuItem(Context context, MenuItem helpMenuItem,
|
||||
String helpUrlString) {
|
||||
if (TextUtils.isEmpty(helpUrlString)) {
|
||||
String helpUriString) {
|
||||
if (TextUtils.isEmpty(helpUriString)) {
|
||||
// The help url string is empty or null, so set the help menu item to be invisible.
|
||||
helpMenuItem.setVisible(false);
|
||||
|
||||
// return that the help menu item is not visible (i.e. false)
|
||||
return false;
|
||||
} else {
|
||||
// The help url string exists, so first add in some extra query parameters.
|
||||
final Uri fullUri = uriWithAddedParameters(context, Uri.parse(helpUrlString));
|
||||
|
||||
// Then, create an intent that will be fired when the user
|
||||
// selects this help menu item.
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, fullUri);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
| Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
|
||||
Intent intent = getHelpIntent(context, helpUriString);
|
||||
|
||||
// Set the intent to the help menu item, show the help menu item in the overflow
|
||||
// menu, and make it visible.
|
||||
@@ -111,6 +118,24 @@ public class HelpUtils {
|
||||
}
|
||||
}
|
||||
|
||||
private static Intent getHelpIntent(Context context, String helpUriString) {
|
||||
// Try to handle as Intent Uri, otherwise just treat as Uri.
|
||||
try {
|
||||
return Intent.parseUri(helpUriString,
|
||||
Intent.URI_ANDROID_APP_SCHEME | Intent.URI_INTENT_SCHEME);
|
||||
} catch (URISyntaxException e) {
|
||||
}
|
||||
// The help url string exists, so first add in some extra query parameters.
|
||||
final Uri fullUri = uriWithAddedParameters(context, Uri.parse(helpUriString));
|
||||
|
||||
// Then, create an intent that will be fired when the user
|
||||
// selects this help menu item.
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, fullUri);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
| Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
|
||||
return intent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds two query parameters into the Uri, namely the language code and the version code
|
||||
* of the app's package as gotten via the context.
|
||||
|
@@ -50,14 +50,13 @@ public abstract class SettingsPreferenceFragment extends InstrumentedPreferenceF
|
||||
|
||||
private static final String TAG = "SettingsPreferenceFragment";
|
||||
|
||||
private static final int MENU_HELP = Menu.FIRST + 100;
|
||||
private static final int DELAY_HIGHLIGHT_DURATION_MILLIS = 600;
|
||||
|
||||
private static final String SAVE_HIGHLIGHTED_KEY = "android:preference_highlighted";
|
||||
|
||||
private SettingsDialogFragment mDialogFragment;
|
||||
|
||||
private String mHelpUrl;
|
||||
private String mHelpUri;
|
||||
|
||||
// Cache the content resolver for async callbacks
|
||||
private ContentResolver mContentResolver;
|
||||
@@ -93,7 +92,7 @@ public abstract class SettingsPreferenceFragment extends InstrumentedPreferenceF
|
||||
// Prepare help url and enable menu if necessary
|
||||
int helpResource = getHelpResource();
|
||||
if (helpResource != 0) {
|
||||
mHelpUrl = getResources().getString(helpResource);
|
||||
mHelpUri = getResources().getString(helpResource);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,7 +124,7 @@ public abstract class SettingsPreferenceFragment extends InstrumentedPreferenceF
|
||||
@Override
|
||||
public void onActivityCreated(Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
if (!TextUtils.isEmpty(mHelpUrl)) {
|
||||
if (!TextUtils.isEmpty(mHelpUri)) {
|
||||
setHasOptionsMenu(true);
|
||||
}
|
||||
}
|
||||
@@ -273,14 +272,13 @@ public abstract class SettingsPreferenceFragment extends InstrumentedPreferenceF
|
||||
* @return the resource id for the help url
|
||||
*/
|
||||
protected int getHelpResource() {
|
||||
return 0;
|
||||
return R.string.help_uri_default;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
if (mHelpUrl != null && getActivity() != null) {
|
||||
MenuItem helpItem = menu.add(0, MENU_HELP, 0, R.string.help_label);
|
||||
HelpUtils.prepareHelpMenuItem(getActivity(), helpItem, mHelpUrl);
|
||||
if (mHelpUri != null && getActivity() != null) {
|
||||
HelpUtils.prepareHelpMenuItem(getActivity(), menu, mHelpUri);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -39,6 +39,11 @@ public class WallpaperTypeSettings extends SettingsPreferenceFragment implements
|
||||
return MetricsLogger.WALLPAPER_TYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getHelpResource() {
|
||||
return R.string.help_uri_wallpaper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
@@ -203,6 +203,11 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
||||
return MetricsLogger.ACCESSIBILITY;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getHelpResource() {
|
||||
return R.string.help_uri_accessibility;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
|
@@ -55,6 +55,7 @@ import android.widget.Spinner;
|
||||
|
||||
import com.android.internal.content.PackageHelper;
|
||||
import com.android.internal.logging.MetricsLogger;
|
||||
import com.android.settings.HelpUtils;
|
||||
import com.android.settings.InstrumentedFragment;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Settings.AllApplicationsActivity;
|
||||
@@ -431,6 +432,8 @@ public class ManageApplications extends InstrumentedFragment
|
||||
// No option menu
|
||||
return;
|
||||
}
|
||||
HelpUtils.prepareHelpMenuItem(getActivity(), menu, mListType == LIST_TYPE_MAIN
|
||||
? R.string.help_uri_apps : R.string.help_uri_notifications);
|
||||
mOptionsMenu = menu;
|
||||
if (mListType == LIST_TYPE_MAIN) {
|
||||
// Only show advanced options when in the main app list (from dashboard).
|
||||
|
@@ -16,7 +16,6 @@
|
||||
|
||||
package com.android.settings.dashboard;
|
||||
|
||||
import android.app.Fragment;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@@ -29,13 +28,15 @@ import android.os.Message;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
|
||||
import com.android.internal.logging.MetricsLogger;
|
||||
import com.android.settings.HelpUtils;
|
||||
import com.android.settings.InstrumentedFragment;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsActivity;
|
||||
@@ -74,6 +75,19 @@ public class DashboardSummary extends InstrumentedFragment {
|
||||
return MetricsLogger.DASHBOARD_SUMMARY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
setHasOptionsMenu(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
HelpUtils.prepareHelpMenuItem(getActivity(), menu, R.string.help_uri_dashboard);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
@@ -96,6 +96,11 @@ public class StorageSettings extends SettingsPreferenceFragment implements Index
|
||||
return MetricsLogger.DEVICEINFO_STORAGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getHelpResource() {
|
||||
return R.string.help_uri_storage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
|
@@ -17,17 +17,19 @@
|
||||
package com.android.settings.nfc;
|
||||
|
||||
import android.app.ActionBar;
|
||||
import android.app.Fragment;
|
||||
import android.content.Context;
|
||||
import android.nfc.NfcAdapter;
|
||||
import android.os.Bundle;
|
||||
import android.os.UserManager;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Switch;
|
||||
|
||||
import com.android.internal.logging.MetricsLogger;
|
||||
import com.android.settings.HelpUtils;
|
||||
import com.android.settings.InstrumentedFragment;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsActivity;
|
||||
@@ -53,6 +55,13 @@ public class AndroidBeam extends InstrumentedFragment
|
||||
mNfcAdapter = NfcAdapter.getDefaultAdapter(getActivity());
|
||||
mBeamDisallowed = ((UserManager) getActivity().getSystemService(Context.USER_SERVICE))
|
||||
.hasUserRestriction(UserManager.DISALLOW_OUTGOING_BEAM);
|
||||
setHasOptionsMenu(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
HelpUtils.prepareHelpMenuItem(getActivity(), menu, R.string.help_uri_beam);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -171,6 +171,11 @@ public class OtherSoundSettings extends SettingsPreferenceFragment implements In
|
||||
return MetricsLogger.NOTIFICATION_OTHER_SOUND;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getHelpResource() {
|
||||
return R.string.help_uri_other_sounds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
@@ -229,6 +229,11 @@ public class ZenModeSettings extends ZenModeSettingsBase
|
||||
return rt;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getHelpResource() {
|
||||
return R.string.help_uri_interruptions;
|
||||
}
|
||||
|
||||
// Enable indexing of searchable data
|
||||
public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||
new BaseSearchIndexProvider() {
|
||||
|
@@ -128,6 +128,11 @@ public class PrintSettingsFragment extends SettingsPreferenceFragment
|
||||
return MetricsLogger.PRINT_SETTINGS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getHelpResource() {
|
||||
return R.string.help_uri_printing;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
|
Reference in New Issue
Block a user