Fan Zhang | b473730 | 2017-05-31 12:43:48 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2017 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.settings.support; |
| 17 | |
| 18 | import android.app.Activity; |
| 19 | import android.content.Context; |
| 20 | import android.content.Intent; |
| 21 | import android.os.Bundle; |
| 22 | |
| 23 | import com.android.settings.R; |
Fan Zhang | b473730 | 2017-05-31 12:43:48 -0700 | [diff] [blame] | 24 | import com.android.settings.overlay.FeatureFactory; |
| 25 | import com.android.settings.overlay.SupportFeatureProvider; |
| 26 | import com.android.settings.search.BaseSearchIndexProvider; |
Raff Tsai | 966fa01 | 2019-09-25 11:19:06 +0800 | [diff] [blame] | 27 | import com.android.settingslib.search.Indexable; |
Tony Mantler | 0fcd6cb | 2018-03-26 15:17:25 -0700 | [diff] [blame] | 28 | import com.android.settingslib.search.SearchIndexable; |
Yanting Yang | 7b7aada | 2020-03-09 23:09:50 +0800 | [diff] [blame] | 29 | import com.android.settingslib.search.SearchIndexableRaw; |
Fan Zhang | b473730 | 2017-05-31 12:43:48 -0700 | [diff] [blame] | 30 | |
| 31 | import java.util.ArrayList; |
| 32 | import java.util.List; |
| 33 | |
| 34 | /** |
| 35 | * Trampoline activity that decides which version of support should be shown to the user. |
| 36 | */ |
Tony Mantler | 0fcd6cb | 2018-03-26 15:17:25 -0700 | [diff] [blame] | 37 | @SearchIndexable |
Fan Zhang | b473730 | 2017-05-31 12:43:48 -0700 | [diff] [blame] | 38 | public class SupportDashboardActivity extends Activity implements Indexable { |
| 39 | |
| 40 | @Override |
| 41 | protected void onCreate(Bundle savedInstanceState) { |
| 42 | super.onCreate(savedInstanceState); |
| 43 | SupportFeatureProvider supportFeatureProvider = FeatureFactory.getFactory(this) |
| 44 | .getSupportFeatureProvider(this); |
| 45 | |
Doris Ling | 2ced4ca | 2018-08-21 14:12:57 -0700 | [diff] [blame] | 46 | // try to launch support if we have the feature provider |
Salvador Martinez | 616397d | 2018-01-05 10:39:49 -0800 | [diff] [blame] | 47 | if (supportFeatureProvider != null) { |
Yanting Yang | 7b7aada | 2020-03-09 23:09:50 +0800 | [diff] [blame] | 48 | supportFeatureProvider.startSupport(this); |
| 49 | finish(); |
Fan Zhang | b473730 | 2017-05-31 12:43:48 -0700 | [diff] [blame] | 50 | } |
Fan Zhang | b473730 | 2017-05-31 12:43:48 -0700 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | /** |
| 54 | * For Search. |
| 55 | */ |
Raff Tsai | ac3e0d0 | 2019-09-19 17:06:45 +0800 | [diff] [blame] | 56 | public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER = |
Fan Zhang | b473730 | 2017-05-31 12:43:48 -0700 | [diff] [blame] | 57 | new BaseSearchIndexProvider() { |
| 58 | private static final String SUPPORT_SEARCH_INDEX_KEY = "support_dashboard_activity"; |
| 59 | |
| 60 | @Override |
| 61 | public List<SearchIndexableRaw> getRawDataToIndex(Context context, |
| 62 | boolean enabled) { |
| 63 | |
| 64 | final List<SearchIndexableRaw> result = new ArrayList<>(); |
| 65 | |
| 66 | // Add the activity title |
| 67 | SearchIndexableRaw data = new SearchIndexableRaw(context); |
| 68 | data.title = context.getString(R.string.page_tab_title_support); |
Yanting Yang | 7b7aada | 2020-03-09 23:09:50 +0800 | [diff] [blame] | 69 | data.screenTitle = context.getString(R.string.page_tab_title_support); |
Fan Zhang | 9011a67 | 2017-05-31 17:47:37 -0700 | [diff] [blame] | 70 | data.summaryOn = context.getString(R.string.support_summary); |
Fan Zhang | b473730 | 2017-05-31 12:43:48 -0700 | [diff] [blame] | 71 | data.intentTargetPackage = context.getPackageName(); |
| 72 | data.intentTargetClass = SupportDashboardActivity.class.getName(); |
| 73 | data.intentAction = Intent.ACTION_MAIN; |
| 74 | data.key = SUPPORT_SEARCH_INDEX_KEY; |
| 75 | result.add(data); |
| 76 | |
| 77 | return result; |
| 78 | } |
| 79 | |
| 80 | @Override |
| 81 | public List<String> getNonIndexableKeys(Context context) { |
| 82 | final List<String> keys = super.getNonIndexableKeys(context); |
| 83 | if (!context.getResources().getBoolean(R.bool.config_support_enabled)) { |
| 84 | keys.add(SUPPORT_SEARCH_INDEX_KEY); |
| 85 | } |
| 86 | return keys; |
| 87 | } |
| 88 | }; |
| 89 | } |