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