2 * Copyright (C) 2010 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 package com.android.apps.tag;
18 import android.content.Context;
19 import android.content.Intent;
20 import android.net.Uri;
21 import android.provider.Browser;
23 import java.util.Locale;
26 * Utilities for building help content.
28 public class HelpUtils {
31 private HelpUtils() {}
33 private static String replaceLocale(String str) {
34 // Substitute locale if present in string
35 if (str.contains("%locale%")) {
36 Locale locale = Locale.getDefault();
37 str = str.replace("%locale%", locale.getLanguage());
43 * Opens up the help page in a browser.
45 public static void openHelp(final Context context) {
46 Uri uri = Uri.parse(replaceLocale(context.getString(R.string.more_info_url)));
47 Intent intent = new Intent(Intent.ACTION_VIEW, uri);
48 intent.putExtra(Browser.EXTRA_APPLICATION_ID, context.getPackageName());
49 context.startActivity(intent);