OSDN Git Service

original
[gb-231r1-is01/Gingerbread_2.3.3_r1_IS01.git] / packages / apps / Tag / src / com / android / apps / tag / HelpUtils.java
1 /*
2  * Copyright (C) 2010 The Android Open Source Project
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.apps.tag;
17
18 import android.content.Context;
19 import android.content.Intent;
20 import android.net.Uri;
21 import android.provider.Browser;
22
23 import java.util.Locale;
24
25 /**
26  * Utilities for building help content.
27  */
28 public class HelpUtils {
29
30     // Non-instantiable.
31     private HelpUtils() {}
32
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());
38         }
39         return str;
40     }
41
42     /**
43      * Opens up the help page in a browser.
44      */
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);
50     }
51 }