• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2015 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.tv.settings.about;
18 
19 import android.content.Context;
20 import android.os.Bundle;
21 
22 import androidx.annotation.Keep;
23 import androidx.preference.PreferenceScreen;
24 
25 import com.android.internal.logging.nano.MetricsProto;
26 import com.android.tv.settings.PreferenceUtils;
27 import com.android.tv.settings.R;
28 import com.android.tv.settings.SettingsPreferenceFragment;
29 
30 @Keep
31 public class LegalFragment extends SettingsPreferenceFragment {
32 
33     private static final String KEY_TERMS = "terms";
34     private static final String KEY_LICENSE = "license";
35     private static final String KEY_COPYRIGHT = "copyright";
36     private static final String KEY_WEBVIEW_LICENSE = "webview_license";
37     private static final String KEY_ADS = "ads";
38 
39     @Override
onCreatePreferences(Bundle savedInstanceState, String rootKey)40     public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
41         setPreferencesFromResource(R.xml.about_legal, null);
42         final PreferenceScreen screen = getPreferenceScreen();
43 
44         final Context context = getActivity();
45         PreferenceUtils.resolveSystemActivityOrRemove(context, screen,
46                 findPreference(KEY_TERMS), PreferenceUtils.FLAG_SET_TITLE);
47         PreferenceUtils.resolveSystemActivityOrRemove(context, screen,
48                 findPreference(KEY_LICENSE), PreferenceUtils.FLAG_SET_TITLE);
49         PreferenceUtils.resolveSystemActivityOrRemove(context, screen,
50                 findPreference(KEY_COPYRIGHT), PreferenceUtils.FLAG_SET_TITLE);
51         PreferenceUtils.resolveSystemActivityOrRemove(context, screen,
52                 findPreference(KEY_WEBVIEW_LICENSE), PreferenceUtils.FLAG_SET_TITLE);
53         PreferenceUtils.resolveSystemActivityOrRemove(context, screen,
54                 findPreference(KEY_ADS), PreferenceUtils.FLAG_SET_TITLE);
55     }
56 
57     @Override
getMetricsCategory()58     public int getMetricsCategory() {
59         return MetricsProto.MetricsEvent.ABOUT_LEGAL_SETTINGS;
60     }
61 }
62