1 /* 2 * Copyright (C) 2011 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.camera.ui; 18 19 import android.content.Context; 20 import android.view.LayoutInflater; 21 import android.view.ViewGroup; 22 23 import com.android.camera.PreferenceGroup; 24 import com.android.camera.R; 25 26 public class OtherSettingIndicatorButton extends AbstractIndicatorButton { 27 @SuppressWarnings("unused") 28 private static final String TAG = "OtherSettingIndicatorButton"; 29 private PreferenceGroup mPreferenceGroup; 30 private String[] mPrefKeys; 31 private OtherSettingsPopup.Listener mListener; 32 33 public void setSettingChangedListener(OtherSettingsPopup.Listener listener) { 34 mListener = listener; 35 } 36 37 public OtherSettingIndicatorButton(Context context, int resId, 38 PreferenceGroup preferenceGroup, String[] prefKeys) { 39 super(context); 40 setImageResource(resId); 41 mPreferenceGroup = preferenceGroup; 42 mPrefKeys = prefKeys; 43 } 44 45 @Override 46 public void overrideSettings(final String ... keyvalues) { 47 if (mPopup == null) { 48 initializePopup(); 49 } 50 ((OtherSettingsPopup)mPopup).overrideSettings(keyvalues); 51 } 52 53 @Override 54 protected void initializePopup() { 55 LayoutInflater inflater = (LayoutInflater) getContext().getSystemService( 56 Context.LAYOUT_INFLATER_SERVICE); 57 ViewGroup root = (ViewGroup) getRootView().findViewById(R.id.frame_layout); 58 59 OtherSettingsPopup popup = (OtherSettingsPopup) inflater.inflate( 60 R.layout.other_setting_popup, root, false); 61 popup.setSettingChangedListener(mListener); 62 popup.initialize(mPreferenceGroup, mPrefKeys); 63 root.addView(popup); 64 mPopup = popup; 65 } 66 } 67