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