Search in sources :

Example 1 with Transaction

use of com.moez.QKSMS.mmssms.Transaction in project qksms by moezbhatti.

the class HeadlessSmsSendService method onHandleIntent.

@Override
protected void onHandleIntent(Intent intent) {
    String action = intent.getAction();
    if (!TelephonyManager.ACTION_RESPOND_VIA_MESSAGE.equals(action)) {
        return;
    }
    Bundle extras = intent.getExtras();
    if (extras != null) {
        String body = extras.getString(Intent.EXTRA_TEXT);
        Uri intentUri = intent.getData();
        String recipients = getRecipients(intentUri);
        if (!TextUtils.isEmpty(recipients) && !TextUtils.isEmpty(body)) {
            String[] destinations = TextUtils.split(recipients, ";");
            Transaction sendTransaction = new Transaction(this, SmsHelper.getSendSettings(this));
            Message message = new Message(body, destinations);
            message.setType(Message.TYPE_SMSMMS);
            sendTransaction.sendNewMessage(message, Transaction.NO_THREAD_ID);
            NotificationManager.update(this);
        }
    }
}
Also used : Transaction(com.moez.QKSMS.mmssms.Transaction) Message(com.moez.QKSMS.mmssms.Message) Bundle(android.os.Bundle) Uri(android.net.Uri)

Example 2 with Transaction

use of com.moez.QKSMS.mmssms.Transaction in project qksms by moezbhatti.

the class PushbulletService method onMessageReceived.

@Override
protected void onMessageReceived(String conversationIden, String body) {
    long threadId = Long.parseLong(conversationIden);
    ConversationLegacy conversation = new ConversationLegacy(getApplicationContext(), threadId);
    Transaction sendTransaction = new Transaction(getApplicationContext(), SmsHelper.getSendSettings(getApplicationContext()));
    Message message = new com.moez.QKSMS.mmssms.Message(body, conversation.getAddress());
    message.setType(com.moez.QKSMS.mmssms.Message.TYPE_SMSMMS);
    sendTransaction.sendNewMessage(message, conversation.getThreadId());
    QKReplyActivity.dismiss(conversation.getThreadId());
    NotificationManager.update(getApplicationContext());
}
Also used : ConversationLegacy(com.moez.QKSMS.data.ConversationLegacy) Transaction(com.moez.QKSMS.mmssms.Transaction) Message(com.moez.QKSMS.mmssms.Message)

Example 3 with Transaction

use of com.moez.QKSMS.mmssms.Transaction in project qksms by moezbhatti.

the class EndlessJabber method SendSMS.

@Override
public void SendSMS(Context context, String[] recipients, String body, boolean send) {
    Log.d(TAG, "SendSMS");
    Transaction sendTransaction = new Transaction(context, SmsHelper.getSendSettings(context));
    Message message = new Message();
    message.setType(com.moez.QKSMS.mmssms.Message.TYPE_SMSMMS);
    message.setAddresses(recipients);
    message.setText(body);
    sendTransaction.sendNewMessage(message, 0);
}
Also used : Transaction(com.moez.QKSMS.mmssms.Transaction) Message(com.moez.QKSMS.mmssms.Message)

Example 4 with Transaction

use of com.moez.QKSMS.mmssms.Transaction in project qksms by moezbhatti.

the class EndlessJabber method SendMMS.

@Override
public void SendMMS(Context context, String[] recipients, MMSPart[] parts, String subject, boolean save, boolean send) {
    Log.d(TAG, "SendMMS");
    Transaction sendTransaction = new Transaction(context, SmsHelper.getSendSettings(context));
    Message message = new Message();
    message.setType(com.moez.QKSMS.mmssms.Message.TYPE_SMSMMS);
    message.setAddresses(recipients);
    message.setSubject(subject);
    message.setSave(save);
    sendTransaction.sendNewMessage(message, 0);
}
Also used : Transaction(com.moez.QKSMS.mmssms.Transaction) Message(com.moez.QKSMS.mmssms.Message)

Example 5 with Transaction

use of com.moez.QKSMS.mmssms.Transaction in project qksms by moezbhatti.

the class ComposeView method sendSms.

public void sendSms() {
    String body = mReplyText.getText().toString();
    final Drawable attachment;
    if (mAttachment.hasAttachment()) {
        attachment = mAttachment.getDrawable();
    } else {
        attachment = null;
    }
    String[] recipients = null;
    if (mConversation != null) {
        recipients = mConversation.getRecipients().getNumbers();
        for (int i = 0; i < recipients.length; i++) {
            recipients[i] = PhoneNumberUtils.stripSeparators(recipients[i]);
        }
    } else if (mRecipientProvider != null) {
        recipients = mRecipientProvider.getRecipientAddresses();
    }
    // If we have some recipients, send the message!
    if (recipients != null && recipients.length > 0) {
        clearAttachment();
        mReplyText.setText("");
        AnalyticsManager.getInstance().sendEvent(AnalyticsManager.CATEGORY_MESSAGES, AnalyticsManager.ACTION_SEND_MESSAGE, mLabel);
        Transaction sendTransaction = new Transaction(mContext, SmsHelper.getSendSettings(mContext));
        com.moez.QKSMS.mmssms.Message message = new com.moez.QKSMS.mmssms.Message(body, recipients);
        message.setType(com.moez.QKSMS.mmssms.Message.TYPE_SMSMMS);
        if (attachment != null) {
            message.setImage(ImageUtils.drawableToBitmap(attachment));
        }
        // Notify the listener about the new text message
        if (mOnSendListener != null) {
            mOnSendListener.onSend(recipients, message.getSubject());
        }
        long threadId = mConversation != null ? mConversation.getThreadId() : 0;
        if (!message.toString().equals("")) {
            sendTransaction.sendNewMessage(message, threadId);
        }
        NotificationManager.update(mContext);
        if (mConversationLegacy != null) {
            mConversationLegacy.markRead();
        }
        // Reset the image button state
        updateButtonState();
    // Otherwise, show a toast to the user to prompt them to add recipients.
    } else {
        Toast.makeText(mContext, mRes.getString(R.string.error_no_recipients), Toast.LENGTH_SHORT).show();
    }
}
Also used : Transaction(com.moez.QKSMS.mmssms.Transaction) Drawable(android.graphics.drawable.Drawable) AnimationDrawable(android.graphics.drawable.AnimationDrawable)

Aggregations

Transaction (com.moez.QKSMS.mmssms.Transaction)7 Message (com.moez.QKSMS.mmssms.Message)6 Bundle (android.os.Bundle)2 PendingIntent (android.app.PendingIntent)1 Intent (android.content.Intent)1 AnimationDrawable (android.graphics.drawable.AnimationDrawable)1 Drawable (android.graphics.drawable.Drawable)1 Uri (android.net.Uri)1 ConversationLegacy (com.moez.QKSMS.data.ConversationLegacy)1