1 /* 2 * Copyright (C) 2014 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 * in compliance with the License. You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software distributed under the License 10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 * or implied. See the License for the specific language governing permissions and limitations under 12 * the License. 13 */ 14 package com.android.tv.quicksettings; 15 16 import android.app.Activity; 17 import android.app.Fragment; 18 import android.os.Bundle; 19 import android.support.v14.preference.PreferenceFragment; 20 import android.support.v17.preference.LeanbackPreferenceFragment; 21 import android.support.v17.preference.LeanbackSettingsFragment; 22 import android.support.v7.preference.Preference; 23 import android.support.v7.preference.PreferenceScreen; 24 25 public class QuickSettings extends Activity { 26 27 private static final String TAG = "QuickSettings"; 28 29 @Override 30 protected void onCreate(Bundle savedInstanceState) { 31 super.onCreate(savedInstanceState); 32 33 if (savedInstanceState == null) { 34 final Fragment f = new QuickSettingsFragment(); 35 getFragmentManager().beginTransaction().add(android.R.id.content, f).commit(); 36 getFragmentManager().executePendingTransactions(); 37 } 38 } 39 40 public static class QuickSettingsFragment extends LeanbackSettingsFragment { 41 42 @Override 43 public void onPreferenceStartInitialScreen() { 44 final Fragment f = new QuickSettingsPreferenceFragment(); 45 startPreferenceFragment(f); 46 } 47 48 @Override 49 public boolean onPreferenceStartFragment(PreferenceFragment caller, Preference pref) { 50 return false; 51 } 52 53 @Override 54 public boolean onPreferenceStartScreen(PreferenceFragment caller, PreferenceScreen pref) { 55 final Fragment f = new SubSettingsFragment(); 56 final Bundle b = new Bundle(1); 57 b.putString(PreferenceFragment.ARG_PREFERENCE_ROOT, pref.getKey()); 58 f.setArguments(b); 59 startPreferenceFragment(f); 60 return true; 61 } 62 } 63 64 public static class SubSettingsFragment extends LeanbackPreferenceFragment { 65 @Override 66 public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { 67 setPreferencesFromResource(R.xml.quick_settings, rootKey); 68 } 69 } 70 71 } 72