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.ui.sidepanel.parentalcontrols; 18 19 import com.android.tv.MainActivity; 20 import com.android.tv.R; 21 import com.android.tv.ui.sidepanel.Item; 22 import com.android.tv.ui.sidepanel.SideFragment; 23 import com.android.tv.ui.sidepanel.SubMenuItem; 24 import java.util.ArrayList; 25 import java.util.List; 26 27 public class ProgramRestrictionsFragment extends SideFragment { 28 private static final String TRACKER_LABEL = "Program restrictions"; 29 30 private final SideFragmentListener mSideFragmentListener = 31 new SideFragmentListener() { 32 @Override 33 public void onSideFragmentViewDestroyed() { 34 notifyDataSetChanged(); 35 } 36 }; 37 getDescription(MainActivity tvActivity)38 public static String getDescription(MainActivity tvActivity) { 39 return RatingsFragment.getDescription(tvActivity); 40 } 41 42 @Override getTitle()43 protected String getTitle() { 44 return getString(R.string.option_program_restrictions); 45 } 46 47 @Override getTrackerLabel()48 public String getTrackerLabel() { 49 return TRACKER_LABEL; 50 } 51 52 @Override getItemList()53 protected List<Item> getItemList() { 54 List<Item> items = new ArrayList<>(); 55 56 items.add( 57 new SubMenuItem( 58 getString(R.string.option_country_rating_systems), 59 RatingSystemsFragment.getDescription(getMainActivity()), 60 getMainActivity().getOverlayManager().getSideFragmentManager()) { 61 @Override 62 protected SideFragment getFragment() { 63 SideFragment fragment = new RatingSystemsFragment(); 64 fragment.setListener(mSideFragmentListener); 65 return fragment; 66 } 67 }); 68 String ratingsDescription = RatingsFragment.getDescription(getMainActivity()); 69 SubMenuItem ratingsItem = 70 new SubMenuItem( 71 getString(R.string.option_ratings), 72 ratingsDescription, 73 getMainActivity().getOverlayManager().getSideFragmentManager()) { 74 @Override 75 protected SideFragment getFragment() { 76 SideFragment fragment = new RatingsFragment(); 77 fragment.setListener(mSideFragmentListener); 78 return fragment; 79 } 80 }; 81 // When "None" is selected for rating systems, disable the Ratings option. 82 if (RatingSystemsFragment.getDescription(getMainActivity()) 83 .equals(getString(R.string.option_no_enabled_rating_system))) { 84 ratingsItem.setEnabled(false); 85 } 86 items.add(ratingsItem); 87 return items; 88 } 89 } 90