1 /* 2 * Copyright (C) 2023 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.settings.R; 28 import com.android.tv.twopanelsettings.slices.InfoFragment; 29 30 /** 31 * A class that hosts {@link InfoFragment}s for preferences in 32 * {@link PreferredDynamicRangeFragment}. 33 */ 34 @Keep 35 public class PreferredDynamicRangeInfo { 36 /** A class that hosts {@link InfoFragment} for Auto hdr selection preference */ 37 public static class MatchContentDynamicRangeInfoFragment 38 extends PreferredDynamicRangeInfo.BaseInfoFragment { 39 @Override getSummaryResId()40 protected int getSummaryResId() { 41 return R.string.match_content_dynamic_range_summary; 42 } 43 } 44 45 /** A class that hosts {@link InfoFragment} for system hdr selection preference */ 46 public static class PreferredDynamicRangeSystemInfoFragment 47 extends PreferredDynamicRangeInfo.BaseInfoFragment { 48 @Override getSummaryResId()49 protected int getSummaryResId() { 50 return R.string.preferred_dynamic_range_selection_system_summary; 51 } 52 } 53 54 /** A class that hosts {@link InfoFragment} for force DV selection preference */ 55 public static class ForceDVInfoFragment extends PreferredDynamicRangeInfo.ForceInfoFragment { 56 @Override getSummaryResId()57 protected int getSummaryResId() { 58 return R.string.dynamic_range_selection_force_dv_summary; 59 } 60 61 @Override getTitleResId()62 protected int getTitleResId() { 63 return R.string.dynamic_range_selection_force_dv_title; 64 } 65 } 66 67 /** A class that hosts {@link InfoFragment} for force HDR10 selection preference */ 68 public static class ForceHdrInfoFragment extends PreferredDynamicRangeInfo.ForceInfoFragment { 69 @Override getSummaryResId()70 protected int getSummaryResId() { 71 return R.string.dynamic_range_selection_force_hdr10_summary; 72 } 73 74 @Override getTitleResId()75 protected int getTitleResId() { 76 return R.string.dynamic_range_selection_force_hdr10_title; 77 } 78 } 79 80 /** A class that hosts {@link InfoFragment} for force HLG selection preference */ 81 public static class ForceHlgInfoFragment extends PreferredDynamicRangeInfo.ForceInfoFragment { 82 @Override getSummaryResId()83 protected int getSummaryResId() { 84 return R.string.dynamic_range_selection_force_hlg_summary; 85 } 86 87 @Override getTitleResId()88 protected int getTitleResId() { 89 return R.string.dynamic_range_selection_force_hlg_title; 90 } 91 } 92 93 /** A class that hosts {@link InfoFragment} for force HDR10+ selection preference */ 94 public static class ForceHdr10PlusInfoFragment 95 extends PreferredDynamicRangeInfo.ForceInfoFragment { 96 @Override getSummaryResId()97 protected int getSummaryResId() { 98 return R.string.dynamic_range_selection_force_hdr10plus_summary; 99 } 100 101 @Override getTitleResId()102 protected int getTitleResId() { 103 return R.string.dynamic_range_selection_force_hdr10plus_title; 104 } 105 } 106 107 /** A class that hosts {@link InfoFragment} for force SDR selection preference */ 108 public static class ForceSdrInfoFragment extends PreferredDynamicRangeInfo.BaseInfoFragment { 109 @Override getSummaryResId()110 protected int getSummaryResId() { 111 return R.string.dynamic_range_selection_force_sdr_summary; 112 } 113 114 @Override onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)115 public View onCreateView( 116 LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 117 View view = super.onCreateView(inflater, container, savedInstanceState); 118 ((TextView) view.findViewById(R.id.info_title)).setText( 119 R.string.dynamic_range_selection_force_sdr_title); 120 view.findViewById(R.id.info_title).setVisibility(View.VISIBLE); 121 ((TextView) view.findViewById(R.id.info_summary)).setText(getSummaryResId()); 122 view.findViewById(R.id.info_summary).setVisibility(View.VISIBLE); 123 return view; 124 } 125 } 126 127 /** A class that hosts {@link InfoFragment} for force hdr selection preference */ 128 public abstract static class ForceInfoFragment extends BaseInfoFragment { getSummaryResId()129 protected abstract int getSummaryResId(); 130 getTitleResId()131 protected abstract int getTitleResId(); 132 133 @Override onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)134 public View onCreateView( 135 LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 136 View view = super.onCreateView(inflater, container, savedInstanceState); 137 ((TextView) view.findViewById(R.id.info_title)).setText(getTitleResId()); 138 view.findViewById(R.id.info_title).setVisibility(View.VISIBLE); 139 ((TextView) view.findViewById(R.id.info_summary)).setText(getSummaryResId()); 140 view.findViewById(R.id.info_summary).setVisibility(View.VISIBLE); 141 return view; 142 } 143 } 144 145 private abstract static class BaseInfoFragment extends InfoFragment { 146 getSummaryResId()147 protected abstract int getSummaryResId(); 148 149 @Override onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)150 public View onCreateView( 151 LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 152 View view = super.onCreateView(inflater, container, savedInstanceState); 153 ((TextView) view.findViewById(R.id.info_summary)).setText(getSummaryResId()); 154 view.findViewById(R.id.info_summary).setVisibility(View.VISIBLE); 155 return view; 156 } 157 } 158 } 159