Jian Jin | a7f06f8 | 2018-08-06 16:34:03 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2018 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.car.settings.system; |
| 18 | |
| 19 | import android.content.Context; |
| 20 | import android.content.Intent; |
Jian Jin | a7f06f8 | 2018-08-06 16:34:03 -0700 | [diff] [blame] | 21 | |
davidln | cb0bfa2 | 2018-08-27 14:13:05 -0700 | [diff] [blame^] | 22 | import androidx.annotation.StringRes; |
Jian Jin | a7f06f8 | 2018-08-06 16:34:03 -0700 | [diff] [blame] | 23 | import androidx.car.widget.ListItem; |
| 24 | import androidx.car.widget.ListItemProvider; |
| 25 | import androidx.car.widget.TextListItem; |
| 26 | |
| 27 | import com.android.car.settings.R; |
| 28 | import com.android.car.settings.common.ListItemSettingsFragment; |
| 29 | |
| 30 | import java.util.ArrayList; |
| 31 | |
| 32 | /** |
| 33 | * Fragment showing legal information. |
| 34 | */ |
| 35 | public class LegalInformationFragment extends ListItemSettingsFragment { |
| 36 | private static final String ACTION_WEBVIEW_LICENSE = "android.settings.WEBVIEW_LICENSE"; |
| 37 | |
davidln | cb0bfa2 | 2018-08-27 14:13:05 -0700 | [diff] [blame^] | 38 | @Override |
| 39 | @StringRes |
| 40 | protected int getTitleId() { |
| 41 | return R.string.legal_information; |
Jian Jin | a7f06f8 | 2018-08-06 16:34:03 -0700 | [diff] [blame] | 42 | } |
| 43 | |
| 44 | @Override |
| 45 | public ListItemProvider getItemProvider() { |
| 46 | return new ListItemProvider.ListProvider(getListItems()); |
| 47 | } |
| 48 | |
| 49 | private ArrayList<ListItem> getListItems() { |
| 50 | ArrayList<ListItem> listItems = new ArrayList<>(); |
| 51 | |
| 52 | listItems.add(createSystemWebviewLicensesListItem()); |
| 53 | listItems.add(createThirdPartyLicensesListItem()); |
| 54 | |
| 55 | return listItems; |
| 56 | } |
| 57 | |
| 58 | private TextListItem createSystemWebviewLicensesListItem() { |
| 59 | Context context = requireContext(); |
| 60 | return createSimpleListItem(R.string.webview_license_title, v -> { |
| 61 | Intent intent = new Intent(); |
| 62 | intent.setAction(ACTION_WEBVIEW_LICENSE); |
| 63 | context.startActivity(intent); |
| 64 | }); |
| 65 | } |
| 66 | |
| 67 | private TextListItem createThirdPartyLicensesListItem() { |
| 68 | Context context = requireContext(); |
| 69 | return createSimpleListItem(R.string.settings_license_activity_title, v -> { |
| 70 | Intent intent = new Intent(context, ThirdPartyLicensesActivity.class); |
| 71 | context.startActivity(intent); |
| 72 | }); |
| 73 | } |
| 74 | } |