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