OtherSettingsPopup.java revision 1f09dac3d664734d099765783dae1233ef023226
1/* 2 * Copyright (C) 2010 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 17package com.android.camera.ui; 18 19import com.android.camera.ListPreference; 20import com.android.camera.PreferenceGroup; 21 22import android.util.Log; 23import android.view.View; 24import android.widget.PopupWindow; 25import android.widget.TableLayout; 26import android.widget.TableRow; 27 28/* A popup window that contains several camera settings. */ 29public class OtherSettingsPopup extends PopupWindow 30 implements InLineSettingPicker.Listener { 31 private static final String TAG = "OtherSettingsPopup"; 32 private Listener mListener; 33 34 static public interface Listener { 35 public void onOtherSettingChanged(); 36 } 37 38 public void setOtherSettingChangedListener(Listener listener) { 39 mListener = listener; 40 } 41 42 public OtherSettingsPopup(View contentView, int width, int height, 43 boolean focusable) { 44 super(contentView, width, height, focusable); 45 } 46 47 public void initialize(PreferenceGroup group) { 48 TableLayout table = (TableLayout) getContentView(); 49 // Initialize each camera setting. 50 for (int i = table.getChildCount() - 1; i >= 0 ; i--) { 51 TableRow row = (TableRow) table.getChildAt(i); 52 InLineSettingPicker picker = (InLineSettingPicker) row.getChildAt(1); 53 ListPreference pref = group.findPreference(picker.getKey()); 54 if (pref != null) { 55 picker.setSettingChangedListener(this); 56 picker.initialize(pref); 57 } else { // remove the row if the preference is not supported 58 table.removeViewAt(i); 59 } 60 } 61 } 62 63 public void onSettingChanged() { 64 if (mListener != null) { 65 mListener.onOtherSettingChanged(); 66 } 67 } 68} 69