@Override
 public void exitFromChatMode(String number) {
   Logger.d(TAG, "exitFromChatMode() entry, number " + number);
   if (PluginUtils.getMessagingMode() == 0) {
     if (number.startsWith(IpMessageConsts.JOYN_START)) {
       number = number.substring(4);
     }
   }
   Message controllerMessage =
       PluginController.obtainMessage(
           ChatController.EVENT_HIDE_WINDOW, PhoneUtils.formatNumberToInternational(number));
   controllerMessage.sendToTarget();
   super.exitFromChatMode(number);
 }
Exemplo n.º 2
0
  @Override
  public Cursor query(
      Uri uri, String[] projectionIn, String selection, String[] selectionArgs, String sort) {
    SQLiteQueryBuilder qb = new SQLiteQueryBuilder();

    // Generate the body of the query
    int match = uriMatcher.match(uri);
    switch (match) {
      case CHATS:
      case RCSAPI_CHATS:
        qb.setTables(TABLE_CHAT);
        break;
      case MESSAGES:
      case RCSAPI_MESSAGES:
        qb.setTables(TABLE_MESSAGE);
        break;
      case CHAT_ID:
      case RCSAPI_CHAT_ID:
        qb.setTables(TABLE_CHAT);
        qb.appendWhere(ChatData.KEY_CHAT_ID + "=");
        qb.appendWhere(uri.getPathSegments().get(1));
        break;
      case MESSAGE_ID:
      case RCSAPI_MESSAGE_ID:
        qb.setTables(TABLE_MESSAGE);
        qb.appendWhere(
            MessageData.KEY_CHAT_ID
                + "= '"
                + PhoneUtils.formatNumberToInternational(uri.getPathSegments().get(1))
                + "'");
        break;
      default:
        throw new IllegalArgumentException("Unknown URI " + uri);
    }

    SQLiteDatabase db = openHelper.getReadableDatabase();
    Cursor c = qb.query(db, projectionIn, selection, selectionArgs, null, null, sort);

    // Register the contexts ContentResolver to be notified if the cursor result set changes
    if (c != null) {
      c.setNotificationUri(getContext().getContentResolver(), uri);
    }

    return c;
  }
Exemplo n.º 3
0
 @Override
 public int delete(Uri uri, String where, String[] whereArgs) {
   SQLiteDatabase db = openHelper.getWritableDatabase();
   int count = 0;
   switch (uriMatcher.match(uri)) {
     case CHATS:
     case RCSAPI_CHATS:
       count = db.delete(TABLE_CHAT, where, whereArgs);
       break;
     case CHAT_ID:
     case RCSAPI_CHAT_ID:
       count =
           db.delete(
               TABLE_CHAT,
               ChatData.KEY_ID
                   + "="
                   + uri.getPathSegments().get(1)
                   + (!TextUtils.isEmpty(where) ? " AND (" + where + ')' : ""),
               whereArgs);
       break;
     case MESSAGES:
     case RCSAPI_MESSAGES:
       count = db.delete(TABLE_MESSAGE, where, whereArgs);
       break;
     case MESSAGE_ID:
     case RCSAPI_MESSAGE_ID:
       count =
           db.delete(
               TABLE_MESSAGE,
               MessageData.KEY_ID
                   + "="
                   + PhoneUtils.formatNumberToInternational(uri.getPathSegments().get(1))
                   + (!TextUtils.isEmpty(where) ? " AND (" + where + ')' : ""),
               whereArgs);
       break;
     default:
       throw new SQLException("Failed to delete row " + uri);
   }
   getContext().getContentResolver().notifyChange(uri, null);
   return count;
 }
 @Override
 public void sendChatMode(String number, int status) {
   Logger.d(TAG, "sendChatMode() the number is " + number + " status is " + status);
   boolean isEmpty = true;
   if (PluginUtils.getMessagingMode() == 0) {
     if (number.startsWith(IpMessageConsts.JOYN_START)) {
       number = number.substring(4);
     }
   }
   if (status == ContactStatus.STOP_TYPING) {
     isEmpty = true;
   } else if (status == ContactStatus.TYPING) {
     isEmpty = false;
   }
   Message controllerMessage =
       PluginController.obtainMessage(
           ChatController.EVENT_TEXT_CHANGED,
           PhoneUtils.formatNumberToInternational(number),
           isEmpty);
   controllerMessage.sendToTarget();
 }
 @Override
 public void enterChatMode(String number) {
   Logger.d(TAG, "enterChatMode() entry, number " + number);
   if (PluginUtils.getMessagingMode() == 0) {
     if (number.startsWith(IpMessageConsts.JOYN_START)) {
       number = number.substring(4);
     }
   }
   Message controllerMessage =
       PluginController.obtainMessage(
           ChatController.EVENT_SHOW_WINDOW, PhoneUtils.formatNumberToInternational(number));
   controllerMessage.sendToTarget();
   if ((PluginUtils.getMessagingMode() == 1) && (PluginUtils.translateThreadId(number) == 1)) {
     Logger.v(TAG, "enterChatMode(), open Window = " + number);
     Intent intent = new Intent(InvitationDialog.ACTION);
     intent.putExtra(RcsNotification.CONTACT, number);
     intent.putExtra(InvitationDialog.KEY_STRATEGY, InvitationDialog.STRATEGY_IPMES_SEND_BY_SMS);
     intent.putExtra("showDialog", true);
     intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
     AndroidFactory.getApplicationContext().startActivity(intent);
   }
   super.enterChatMode(number);
 }