Home | History | Annotate | Download | only in ui
      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 
     17 package com.android.camera.ui;
     18 
     19 import android.content.Context;
     20 
     21 import com.android.camera.R;
     22 import com.android.camera.IconListPreference;
     23 
     24 class GpsIndicator extends BasicIndicator {
     25 
     26     private static final int GPS_ON_INDEX = 1;
     27 
     28     private ResourceTexture mNoSignalIcon;
     29     private boolean mHasSignal = false;
     30 
     31     public GpsIndicator(Context context, IconListPreference preference) {
     32         super(context, preference);
     33     }
     34 
     35     @Override
     36     protected ResourceTexture getIcon() {
     37         if (mIndex == GPS_ON_INDEX && !mHasSignal) {
     38             if (mNoSignalIcon == null) {
     39                 Context context = getGLRootView().getContext();
     40                 mNoSignalIcon = new ResourceTexture(
     41                         context, R.drawable.ic_viewfinder_gps_no_signal);
     42             }
     43             return mNoSignalIcon;
     44         }
     45         return super.getIcon();
     46     }
     47 
     48     public void setHasSignal(boolean hasSignal) {
     49         if (mHasSignal == hasSignal) return;
     50         mHasSignal = hasSignal;
     51         invalidate();
     52     }
     53 
     54     @Override
     55     protected void onPreferenceChanged(int newIndex) {
     56         mHasSignal = false;
     57         super.onPreferenceChanged(newIndex);
     58     }
     59 }
     60