blob: b8a22b996e1ff67b137ca3ec44a658d717251a23 [file] [log] [blame]
Fan Zhangb4737302017-05-31 12:43:48 -07001/*
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 */
16package com.android.settings.support;
17
18import android.app.Activity;
19import android.content.Context;
20import android.content.Intent;
21import android.os.Bundle;
22
23import com.android.settings.R;
Fan Zhangb4737302017-05-31 12:43:48 -070024import com.android.settings.overlay.FeatureFactory;
25import com.android.settings.overlay.SupportFeatureProvider;
26import com.android.settings.search.BaseSearchIndexProvider;
Raff Tsai966fa012019-09-25 11:19:06 +080027import com.android.settingslib.search.Indexable;
Tony Mantler0fcd6cb2018-03-26 15:17:25 -070028import com.android.settingslib.search.SearchIndexable;
Yanting Yang7b7aada2020-03-09 23:09:50 +080029import com.android.settingslib.search.SearchIndexableRaw;
Fan Zhangb4737302017-05-31 12:43:48 -070030
31import java.util.ArrayList;
32import java.util.List;
33
34/**
35 * Trampoline activity that decides which version of support should be shown to the user.
36 */
Tony Mantler0fcd6cb2018-03-26 15:17:25 -070037@SearchIndexable
Fan Zhangb4737302017-05-31 12:43:48 -070038public 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 Ling2ced4ca2018-08-21 14:12:57 -070046 // try to launch support if we have the feature provider
Salvador Martinez616397d2018-01-05 10:39:49 -080047 if (supportFeatureProvider != null) {
Yanting Yang7b7aada2020-03-09 23:09:50 +080048 supportFeatureProvider.startSupport(this);
49 finish();
Fan Zhangb4737302017-05-31 12:43:48 -070050 }
Fan Zhangb4737302017-05-31 12:43:48 -070051 }
52
53 /**
54 * For Search.
55 */
Raff Tsaiac3e0d02019-09-19 17:06:45 +080056 public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
Fan Zhangb4737302017-05-31 12:43:48 -070057 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 Yang7b7aada2020-03-09 23:09:50 +080069 data.screenTitle = context.getString(R.string.page_tab_title_support);
Fan Zhang9011a672017-05-31 17:47:37 -070070 data.summaryOn = context.getString(R.string.support_summary);
Fan Zhangb4737302017-05-31 12:43:48 -070071 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}