1 /* 2 * Copyright (C) 2007-2008 Esmertec AG. 3 * Copyright (C) 2007-2008 The Android Open Source Project 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 package com.android.im.app; 18 19 import android.util.Log; 20 21 import com.android.im.engine.Presence; 22 import com.android.im.plugin.BrandingResourceIDs; 23 import com.android.im.provider.Imps; 24 25 public final class PresenceUtils { PresenceUtils()26 private PresenceUtils() {} 27 convertStatus(int status)28 public static int convertStatus(int status) { 29 switch (status) { 30 case Presence.AVAILABLE: 31 return Imps.Presence.AVAILABLE; 32 33 case Presence.AWAY: 34 return Imps.Presence.AWAY; 35 36 case Presence.DO_NOT_DISTURB: 37 return Imps.Presence.DO_NOT_DISTURB; 38 39 case Presence.IDLE: 40 return Imps.Presence.IDLE; 41 42 case Presence.OFFLINE: 43 return Imps.Presence.OFFLINE; 44 45 default: 46 Log.w(ImApp.LOG_TAG, "[ContactView] Unknown presence status " + status); 47 return Imps.Presence.AVAILABLE; 48 } 49 } 50 getStatusStringRes(int status)51 public static int getStatusStringRes(int status) { 52 switch (status) { 53 case Imps.Presence.AVAILABLE: 54 return BrandingResourceIDs.STRING_PRESENCE_AVAILABLE; 55 56 case Imps.Presence.AWAY: 57 return BrandingResourceIDs.STRING_PRESENCE_AWAY; 58 59 case Imps.Presence.DO_NOT_DISTURB: 60 return BrandingResourceIDs.STRING_PRESENCE_BUSY; 61 62 case Imps.Presence.IDLE: 63 return BrandingResourceIDs.STRING_PRESENCE_IDLE; 64 65 case Imps.Presence.INVISIBLE: 66 return BrandingResourceIDs.STRING_PRESENCE_INVISIBLE; 67 68 case Imps.Presence.OFFLINE: 69 return BrandingResourceIDs.STRING_PRESENCE_OFFLINE; 70 71 default: 72 return BrandingResourceIDs.STRING_PRESENCE_AVAILABLE; 73 } 74 } 75 getStatusIconId(int status)76 public static int getStatusIconId(int status) { 77 switch (status) { 78 case Imps.Presence.AVAILABLE: 79 return BrandingResourceIDs.DRAWABLE_PRESENCE_ONLINE; 80 81 case Imps.Presence.IDLE: 82 return BrandingResourceIDs.DRAWABLE_PRESENCE_AWAY; 83 84 case Imps.Presence.AWAY: 85 return BrandingResourceIDs.DRAWABLE_PRESENCE_AWAY; 86 87 case Imps.Presence.DO_NOT_DISTURB: 88 return BrandingResourceIDs.DRAWABLE_PRESENCE_BUSY; 89 90 case Imps.Presence.INVISIBLE: 91 return BrandingResourceIDs.DRAWABLE_PRESENCE_INVISIBLE; 92 93 default: 94 return BrandingResourceIDs.DRAWABLE_PRESENCE_OFFLINE; 95 } 96 } 97 98 } 99