1 /* 2 * Copyright (C) 2021 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.library; 18 19 import android.annotation.SystemApi; 20 import android.content.Context; 21 import android.content.Intent; 22 import android.os.Bundle; 23 24 import com.android.tv.settings.library.data.StateManager; 25 26 import java.util.List; 27 28 /** 29 * @hide Provides access to TvSettings data. 30 */ 31 @SystemApi 32 public final class SettingsManager { 33 private static final String TAG = "TvSettingsManager"; 34 private com.android.tv.settings.library.UIUpdateCallback mUIUpdateCallback; 35 private final Context mContext; 36 37 /** @hide */ 38 @SystemApi SettingsManager(Context context)39 public SettingsManager(Context context) { 40 this.mContext = context; 41 } 42 43 /** @hide */ 44 @SystemApi getPreferences(int state)45 public List<PreferenceCompat> getPreferences(int state) { 46 return null; 47 } 48 49 /** @hide */ 50 @SystemApi getPreference(int state, String key)51 public PreferenceCompat getPreference(int state, String key) { 52 return null; 53 } 54 55 /** @hide */ 56 @SystemApi registerListener(com.android.tv.settings.library.UIUpdateCallback callback)57 public void registerListener(com.android.tv.settings.library.UIUpdateCallback callback) { 58 mUIUpdateCallback = callback; 59 } 60 61 /** @hide */ 62 @SystemApi unRegisterListener()63 public void unRegisterListener() { 64 mUIUpdateCallback = null; 65 } 66 67 68 /** @hide */ 69 @SystemApi createState(int stateIdentifier)70 public State createState(int stateIdentifier) { 71 return StateManager.createState(mContext, stateIdentifier, mUIUpdateCallback); 72 } 73 74 /** @hide */ 75 @SystemApi onAttach(State state)76 public void onAttach(State state) { 77 state.onAttach(); 78 } 79 80 /** @hide */ 81 @SystemApi onCreate(State state, Bundle extras)82 public void onCreate(State state, Bundle extras) { 83 state.onCreate(extras); 84 } 85 86 /** @hide */ 87 @SystemApi onStart(State state)88 public void onStart(State state) { 89 state.onStart(); 90 } 91 92 /** @hide */ 93 @SystemApi onResume(State state)94 public void onResume(State state) { 95 state.onResume(); 96 } 97 98 /** @hide */ 99 @SystemApi onPause(State state)100 public void onPause(State state) { 101 state.onPause(); 102 } 103 104 /** @hide */ 105 @SystemApi onStop(State state)106 public void onStop(State state) { 107 state.onStop(); 108 } 109 110 /** @hide */ 111 @SystemApi onDestroy(State state)112 public void onDestroy(State state) { 113 state.onDestroy(); 114 } 115 116 /** @hide */ 117 @SystemApi onPreferenceClick(State state, String[] key, boolean status)118 public boolean onPreferenceClick(State state, String[] key, boolean status) { 119 if (state == null || key == null || key.length == 0) { 120 return false; 121 } 122 return state.onPreferenceTreeClick(key, status); 123 } 124 125 /** @hide */ 126 @SystemApi onDisplayPreferenceDialog(State state, String[] key)127 public void onDisplayPreferenceDialog(State state, String[] key) { 128 if (state != null && key != null && key.length > 0) { 129 state.onDisplayDialogPreference(key); 130 } 131 } 132 133 /** @hide */ 134 @SystemApi onActivityResult(State state, int code, int resultCode, Intent data)135 public void onActivityResult(State state, int code, int resultCode, Intent data) { 136 state.onActivityResult(ManagerUtil.getRequestCode(code), resultCode, data); 137 } 138 139 /** @hide */ 140 @SystemApi onPreferenceChange(State state, String[] key, Object newValue)141 public boolean onPreferenceChange(State state, String[] key, Object newValue) { 142 return state.onPreferenceChange(key, newValue); 143 } 144 } 145