blob: e2dcc372ad0b970238903dd8af76536571ccb0f1 [file] [log] [blame]
Jian Jina7f06f82018-08-06 16:34:03 -07001/*
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
17package com.android.car.settings.system;
18
19import android.content.Context;
20import android.content.Intent;
Jian Jina7f06f82018-08-06 16:34:03 -070021
davidlncb0bfa22018-08-27 14:13:05 -070022import androidx.annotation.StringRes;
Jian Jina7f06f82018-08-06 16:34:03 -070023import androidx.car.widget.ListItem;
24import androidx.car.widget.ListItemProvider;
25import androidx.car.widget.TextListItem;
26
27import com.android.car.settings.R;
28import com.android.car.settings.common.ListItemSettingsFragment;
29
30import java.util.ArrayList;
31
32/**
33 * Fragment showing legal information.
34 */
35public class LegalInformationFragment extends ListItemSettingsFragment {
36 private static final String ACTION_WEBVIEW_LICENSE = "android.settings.WEBVIEW_LICENSE";
37
davidlncb0bfa22018-08-27 14:13:05 -070038 @Override
39 @StringRes
40 protected int getTitleId() {
41 return R.string.legal_information;
Jian Jina7f06f82018-08-06 16:34:03 -070042 }
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}