blob: f6150c71b2ffe069ca01c5edaf7426de76861b32 [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;
21import android.os.Bundle;
22
23import 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
38 /**
39 * Factory method for creating the fragment.
40 */
41 public static LegalInformationFragment newInstance() {
42 LegalInformationFragment fragment = new LegalInformationFragment();
43 Bundle bundle = ListItemSettingsFragment.getBundle();
44 bundle.putInt(EXTRA_TITLE_ID, R.string.legal_information);
45 fragment.setArguments(bundle);
46 return fragment;
47 }
48
49 @Override
50 public ListItemProvider getItemProvider() {
51 return new ListItemProvider.ListProvider(getListItems());
52 }
53
54 private ArrayList<ListItem> getListItems() {
55 ArrayList<ListItem> listItems = new ArrayList<>();
56
57 listItems.add(createSystemWebviewLicensesListItem());
58 listItems.add(createThirdPartyLicensesListItem());
59
60 return listItems;
61 }
62
63 private TextListItem createSystemWebviewLicensesListItem() {
64 Context context = requireContext();
65 return createSimpleListItem(R.string.webview_license_title, v -> {
66 Intent intent = new Intent();
67 intent.setAction(ACTION_WEBVIEW_LICENSE);
68 context.startActivity(intent);
69 });
70 }
71
72 private TextListItem createThirdPartyLicensesListItem() {
73 Context context = requireContext();
74 return createSimpleListItem(R.string.settings_license_activity_title, v -> {
75 Intent intent = new Intent(context, ThirdPartyLicensesActivity.class);
76 context.startActivity(intent);
77 });
78 }
79}