DemoImPlugin.java
上传用户:szyujian
上传日期:2016-09-20
资源大小:320k
文件大小:7k
源码类别:

android开发

开发平台:

C/C++

  1. /*
  2.  * Copyright (C) 2008 Esmertec AG.
  3.  * Copyright (C) 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.plugin.demo;
  18. import com.android.im.plugin.BrandingResourceIDs;
  19. import com.android.im.plugin.IImPlugin;
  20. import com.android.im.plugin.ImConfigNames;
  21. import com.android.im.plugin.ImpsConfigNames;
  22. import android.app.Service;
  23. import android.content.Intent;
  24. import android.os.IBinder;
  25. import android.os.RemoteException;
  26. import java.util.HashMap;
  27. import java.util.Map;
  28. /**
  29.  * Simple example of writing a plug-in for the IM application.
  30.  *
  31.  */
  32. public class DemoImPlugin extends Service {
  33.     @Override
  34.     public IBinder onBind(Intent intent) {
  35.         return mBinder;
  36.     }
  37.     /**
  38.      * The implementation of IImPlugin defined through AIDL.
  39.      */
  40.     private IBinder mBinder = new IImPlugin.Stub() {
  41.         public Map getProviderConfig() {
  42.             HashMap<String, String> config = new HashMap<String, String>();
  43.             // The protocol name MUST be IMPS now.
  44.             config.put(ImConfigNames.PROTOCOL_NAME, "IMPS");
  45.             config.put(ImpsConfigNames.HOST, "http://xxx.xxxx.xxx");
  46.             config.put(ImpsConfigNames.CLIENT_ID, "Jimmy");
  47.             config.put(ImpsConfigNames.DATA_CHANNEL, "HTTP");
  48.             config.put(ImpsConfigNames.DATA_ENCODING, "WBXML");
  49.             config.put(ImpsConfigNames.CIR_CHANNEL, "STCP");
  50.             config.put(ImpsConfigNames.CUSTOM_PRESENCE_MAPPING,
  51.                     "com.android.im.plugin.demo.DemoPresenceMapping");
  52.             return config;
  53.         }
  54.         public Map getResourceMap() throws RemoteException {
  55.             HashMap<Integer, Integer> resMapping = new HashMap<Integer, Integer>();
  56.             resMapping.put(BrandingResourceIDs.DRAWABLE_LOGO, R.drawable.im_logo);
  57.             resMapping.put(BrandingResourceIDs.DRAWABLE_PRESENCE_ONLINE,
  58.                     android.R.drawable.presence_online);
  59.             resMapping.put(BrandingResourceIDs.DRAWABLE_PRESENCE_AWAY,
  60.                     android.R.drawable.presence_away);
  61.             resMapping.put(BrandingResourceIDs.DRAWABLE_PRESENCE_BUSY,
  62.                     android.R.drawable.presence_busy);
  63.             resMapping.put(BrandingResourceIDs.DRAWABLE_PRESENCE_INVISIBLE,
  64.                     android.R.drawable.presence_invisible);
  65.             resMapping.put(BrandingResourceIDs.DRAWABLE_PRESENCE_OFFLINE,
  66.                     android.R.drawable.presence_offline);
  67.             resMapping.put(BrandingResourceIDs.DRAWABLE_SPLASH_SCREEN,
  68.                     R.drawable.im_logo_splashscr);
  69.             resMapping.put(BrandingResourceIDs.DRAWABLE_READ_CHAT,
  70.                     R.drawable.chat);
  71.             resMapping.put(BrandingResourceIDs.DRAWABLE_UNREAD_CHAT,
  72.                     R.drawable.chat_new);
  73.             resMapping.put(BrandingResourceIDs.STRING_BUDDY_LIST_TITLE,
  74.                     R.string.buddy_list_title);
  75.             resMapping.put(BrandingResourceIDs.STRING_ARRAY_SMILEY_NAMES,
  76.                     R.array.smiley_names);
  77.             resMapping.put(BrandingResourceIDs.STRING_ARRAY_SMILEY_TEXTS,
  78.                     R.array.smiley_texts);
  79.             resMapping.put(BrandingResourceIDs.STRING_PRESENCE_AVAILABLE,
  80.                     R.string.presence_available);
  81.             resMapping.put(BrandingResourceIDs.STRING_LABEL_USERNAME,
  82.                     R.string.label_username);
  83.             resMapping.put(BrandingResourceIDs.STRING_ONGOING_CONVERSATION,
  84.                     R.string.ongoing_conversation);
  85.             resMapping.put(BrandingResourceIDs.STRING_ADD_CONTACT_TITLE,
  86.                     R.string.add_contact_title);
  87.             resMapping.put(BrandingResourceIDs.STRING_LABEL_INPUT_CONTACT,
  88.                     R.string.input_contact_label);
  89.             resMapping.put(BrandingResourceIDs.STRING_BUTTON_ADD_CONTACT,
  90.                     R.string.invite_label);
  91.             resMapping.put(BrandingResourceIDs.STRING_CONTACT_INFO_TITLE,
  92.                     R.string.contact_profile_title);
  93.             resMapping.put(BrandingResourceIDs.STRING_MENU_ADD_CONTACT,
  94.                     R.string.menu_add_contact);
  95.             resMapping.put(BrandingResourceIDs.STRING_MENU_BLOCK_CONTACT,
  96.                     R.string.menu_block_contact);
  97.             resMapping.put(BrandingResourceIDs.STRING_MENU_CONTACT_LIST,
  98.                     R.string.menu_contact_list);
  99.             resMapping.put(BrandingResourceIDs.STRING_MENU_DELETE_CONTACT,
  100.                     R.string.menu_remove_contact);
  101.             resMapping.put(BrandingResourceIDs.STRING_MENU_END_CHAT,
  102.                     R.string.menu_end_conversation);
  103.             resMapping.put(BrandingResourceIDs.STRING_MENU_INSERT_SMILEY,
  104.                     R.string.menu_insert_smiley);
  105.             resMapping.put(BrandingResourceIDs.STRING_MENU_START_CHAT,
  106.                     R.string.menu_start_chat);
  107.             resMapping.put(BrandingResourceIDs.STRING_MENU_VIEW_PROFILE,
  108.                     R.string.menu_view_profile);
  109.             resMapping.put(BrandingResourceIDs.STRING_MENU_SWITCH_CHATS,
  110.                     R.string.menu_switch_chats);
  111.             resMapping.put(BrandingResourceIDs.STRING_TOAST_CHECK_SAVE_PASSWORD,
  112.                     R.string.check_save_password);
  113.             resMapping.put(BrandingResourceIDs.STRING_LABEL_SIGN_UP,
  114.                     R.string.sign_up);
  115.             return resMapping;
  116.         }
  117.         public int[] getSmileyIconIds() throws RemoteException {
  118.             return SMILEY_RES_IDS;
  119.         }
  120.     };
  121.     /**
  122.      * An array of the smiley icon IDs. Note that the sequence of the array MUST
  123.      * match the smiley texts and smiley names defined in strings.xml.
  124.      */
  125.     static final int[] SMILEY_RES_IDS = {
  126.         R.drawable.emo_im_happy,
  127.         R.drawable.emo_im_sad,
  128.         R.drawable.emo_im_winking,
  129.         R.drawable.emo_im_tongue_sticking_out,
  130.         R.drawable.emo_im_surprised,
  131.         R.drawable.emo_im_kissing,
  132.         R.drawable.emo_im_yelling,
  133.         R.drawable.emo_im_cool,
  134.         R.drawable.emo_im_money_mouth,
  135.         R.drawable.emo_im_foot_in_mouth,
  136.         R.drawable.emo_im_embarrased,
  137.         R.drawable.emo_im_angel,
  138.         R.drawable.emo_im_undecided,
  139.         R.drawable.emo_im_crying,
  140.         R.drawable.emo_im_lips_are_sealed,
  141.         R.drawable.emo_im_laughing,
  142.         R.drawable.emo_im_wtf
  143.     };
  144. }