Jeff Sharkey | 4f425c8 | 2016-07-18 18:28:55 -0600 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 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 | |
| 17 | package com.android.settings; |
| 18 | |
| 19 | import android.app.Activity; |
| 20 | import android.content.ActivityNotFoundException; |
| 21 | import android.content.Intent; |
| 22 | import android.content.res.Resources; |
| 23 | import android.os.Bundle; |
Fan Zhang | d96f3bf | 2017-06-22 09:40:42 -0700 | [diff] [blame] | 24 | import android.text.TextUtils; |
Jeff Sharkey | 4f425c8 | 2016-07-18 18:28:55 -0600 | [diff] [blame] | 25 | import android.util.Log; |
| 26 | |
| 27 | import com.android.settingslib.HelpUtils; |
| 28 | |
| 29 | public class HelpTrampoline extends Activity { |
| 30 | private static final String TAG = "HelpTrampoline"; |
| 31 | |
| 32 | @Override |
| 33 | public void onCreate(Bundle savedInstanceState) { |
| 34 | super.onCreate(savedInstanceState); |
| 35 | |
| 36 | try { |
| 37 | final String name = getIntent().getStringExtra(Intent.EXTRA_TEXT); |
Fan Zhang | d96f3bf | 2017-06-22 09:40:42 -0700 | [diff] [blame] | 38 | if (TextUtils.isEmpty(name)) { |
| 39 | finishAndRemoveTask(); |
| 40 | return; |
| 41 | } |
| 42 | |
Jeff Sharkey | 4f425c8 | 2016-07-18 18:28:55 -0600 | [diff] [blame] | 43 | final int id = getResources().getIdentifier(name, "string", getPackageName()); |
| 44 | final String value = getResources().getString(id); |
| 45 | |
| 46 | final Intent intent = HelpUtils.getHelpIntent(this, value, null); |
| 47 | if (intent != null) { |
Badhri Jagan Sridharan | d452bd5 | 2017-05-10 17:11:24 -0700 | [diff] [blame] | 48 | /* |
| 49 | * TODO: b/38230998. |
| 50 | * Move to startActivity once the HelpUtils.getHelpIntent is refactored |
| 51 | */ |
| 52 | startActivityForResult(intent, 0); |
Jeff Sharkey | 4f425c8 | 2016-07-18 18:28:55 -0600 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | } catch (Resources.NotFoundException | ActivityNotFoundException e) { |
| 56 | Log.w(TAG, "Failed to resolve help", e); |
| 57 | } |
| 58 | |
| 59 | finish(); |
| 60 | } |
| 61 | } |