1 /*
2  * Copyright 2020 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.device.displaysound;
18 
19 import android.os.Bundle;
20 import android.view.LayoutInflater;
21 import android.view.View;
22 import android.view.ViewGroup;
23 import android.widget.TextView;
24 
25 import androidx.annotation.Keep;
26 
27 import com.android.tv.twopanelsettings.R;
28 import com.android.tv.twopanelsettings.slices.InfoFragment;
29 
30 /**
31  * A class that hosts {@link InfoFragment}s for preferences in
32  * {@link MatchContentFrameRateFragment}.
33  */
34 @Keep
35 public class MatchContentFrameRateInfo {
36     /** A class that hosts {@link InfoFragment} for seamless match content frame rate
37      * preference. */
38     public static class SeamlessInfoFragment extends BaseInfoFragment {
39         @Override
getSummaryResId()40         protected int getSummaryResId() {
41             return R.string.match_content_frame_rate_seamless_summary;
42         }
43     }
44 
45     /** A class that hosts {@link InfoFragment} for non seamless match content frame rate
46      * preference. */
47     public static class NonSeamlessInfoFragment extends BaseInfoFragment {
48         @Override
getSummaryResId()49         protected int getSummaryResId() {
50             return R.string.match_content_frame_rate_non_seamless_summary;
51         }
52     }
53 
54     /** A class that hosts {@link InfoFragment} for never match content frame rate
55      * preference. */
56     public static class NeverInfoFragment extends BaseInfoFragment {
57         @Override
getSummaryResId()58         protected int getSummaryResId() {
59             return R.string.match_content_frame_rate_never_summary;
60         }
61     }
62 
63     private abstract static class BaseInfoFragment extends InfoFragment {
64 
getSummaryResId()65         protected abstract int getSummaryResId();
66 
67         @Override
onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)68         public View onCreateView(
69                 LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
70             View view = super.onCreateView(inflater, container, savedInstanceState);
71             ((TextView) view.findViewById(R.id.info_summary)).setText(getSummaryResId());
72             view.findViewById(R.id.info_summary).setVisibility(View.VISIBLE);
73             return view;
74         }
75     }
76 }
77