Search in sources :

Example 16 with SMS

use of dev.sagar.smsblocker.tech.beans.SMS in project SMSBlocker by sagarpawardev.

the class RVStarredSMSAdapter method itemRemoved.

public SMS itemRemoved(int position) {
    final String methodName = "itemRemoved(int)";
    log.justEntered(methodName);
    final SMS sms = smses.remove(position);
    notifyItemRemoved(position);
    deleteHandler = new Handler();
    deleteHandler.postDelayed(new Runnable() {

        @Override
        public void run() {
            List<SMS> list = new ArrayList<>();
            list.add(sms);
            int count = inboxUtil.unstarSMSes(list);
        }
    }, TIMEOUT_TIME);
    log.returning(methodName);
    return sms;
}
Also used : SMS(dev.sagar.smsblocker.tech.beans.SMS) Handler(android.os.Handler) ArrayList(java.util.ArrayList) List(java.util.List)

Example 17 with SMS

use of dev.sagar.smsblocker.tech.beans.SMS in project SMSBlocker by sagarpawardev.

the class RVStarredSMSAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(SMSViewHolder holder, int position) {
    final String methodName = "onBindViewHolder(SMSViewHolder, int)";
    log.justEntered(methodName);
    // Adi changes Start
    holder.tvBody.setTypeface(myFont);
    holder.tvFrom.setTypeface(myFont);
    holder.tvTime.setTypeface(myFont);
    // Adi changes End
    SMS sms = smses.get(position);
    String address = sms.getAddress();
    Contact contact = null;
    try {
        contact = ContactUtilSingleton.getInstance().getContact(context, sms.getAddress());
    } catch (ReadContactPermissionException e) {
        e.printStackTrace();
    }
    String displayName = contact.getDisplayName();
    if (displayName == null)
        displayName = address;
    long tm = sms.getDateTime();
    String socialDate = DateUtilSingleton.getInstance().socialFormat(tm);
    holder.tvTime.setText(socialDate);
    holder.tvFrom.setText(displayName);
    holder.tvBody.setText(sms.getBody());
    // Setting User Image
    Uri dpUri = contact.getPhotoThumbnail();
    if (dpUri != null) {
        holder.dpView.setPictureSrc(dpUri);
    } else {
        if (!displayName.equals(address)) {
            String c = String.valueOf(displayName.charAt(0));
            holder.dpView.setLetterText(c);
        } else {
            String str = context.getResources().getString(R.string.hash);
            holder.dpView.setLetterText(str);
        }
    }
    log.returning(methodName);
}
Also used : ReadContactPermissionException(dev.sagar.smsblocker.tech.exceptions.ReadContactPermissionException) SMS(dev.sagar.smsblocker.tech.beans.SMS) Uri(android.net.Uri) Contact(dev.sagar.smsblocker.tech.beans.Contact)

Example 18 with SMS

use of dev.sagar.smsblocker.tech.beans.SMS in project SMSBlocker by sagarpawardev.

the class RVThreadAdapter method copySelection.

public boolean copySelection() {
    final String methodName = "copySelection()";
    log.justEntered(methodName);
    if (selectedSMSes.size() != 1) {
        log.error(methodName, "Selected SMS are either greater or less than 1");
        return false;
    }
    SMS sms = selectedSMSes.get(0);
    SystemUtilSingleton systemUtil = SystemUtilSingleton.getInstance();
    systemUtil.copy(context, sms);
    log.returning(methodName);
    return true;
}
Also used : SystemUtilSingleton(dev.sagar.smsblocker.tech.utils.SystemUtilSingleton) SMS(dev.sagar.smsblocker.tech.beans.SMS)

Example 19 with SMS

use of dev.sagar.smsblocker.tech.beans.SMS in project SMSBlocker by sagarpawardev.

the class RVThreadAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(final SMSViewHolder holder, int position) {
    final String methodName = "onBindViewHolder()";
    log.justEntered(methodName);
    // Adi changes Start
    Typeface myFont = Typeface.createFromAsset(context.getAssets(), "fonts/VarelaRound-Regular.ttf");
    holder.tvBody.setTypeface(myFont);
    holder.tvTime.setTypeface(myFont);
    // Adi changes End
    SMS sms = smses.get(position);
    String body = sms.getBody();
    long time = sms.getDateTime();
    long type = sms.getType();
    boolean isRead = sms.isRead();
    String socialDate = DateUtilSingleton.getInstance().socialFormat(time);
    boolean isReplySupported = sms.isReplySupported();
    if (type == SMS.TYPE_QUEUED) {
        holder.tvSending.setVisibility(View.VISIBLE);
    } else {
        holder.tvSending.setVisibility(View.GONE);
    }
    // If SMS is among saved SMS
    log.debug(methodName, "Checking Saved SMS: " + sms.isSaved() + " id: " + sms.getId());
    if (sms.isSaved()) {
        holder.btnStar.setVisibility(View.VISIBLE);
        // If marked for Unstar
        if (markedForUnstar.contains(position)) {
            holder.btnStar.setLiked(false);
        } else {
            holder.btnStar.setLiked(true);
        }
    } else {
        holder.btnStar.setVisibility(View.GONE);
    }
    // If SMS is selected in RecyclerView
    boolean isSelected = selectedSMSes.contains(sms);
    setViewSelected(holder, isSelected);
    holder.tvBody.setText(body);
    holder.tvTime.setText(socialDate);
    if (!replyNotSupportedTold && type == SMS.TYPE_RECEIVED && !isReplySupported) {
        callback.onReplyNotSupported();
    }
    // Highlight Item if required
    if (highlightPosition == position) {
        int colorFrom = context.getResources().getColor(R.color.orangeA200, null);
        int colorTo = context.getResources().getColor(R.color.transparent_light_grey, null);
        ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo);
        // milliseconds
        colorAnimation.setDuration(HIGHLIGHT_DURATION);
        colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

            @Override
            public void onAnimationUpdate(ValueAnimator animator) {
                holder.llParent.setBackgroundColor((int) animator.getAnimatedValue());
            }
        });
        colorAnimation.addListener(new Animator.AnimatorListener() {

            @Override
            public void onAnimationStart(Animator animator) {
                final String methodName = "onAnimationStart()";
                log.justEntered(methodName);
                // Nothing here
                log.returning(methodName);
            }

            @Override
            public void onAnimationEnd(Animator animator) {
                final String methodName = "onAnimationEnd()";
                log.justEntered(methodName);
                log.info(methodName, "Resetting Highlight animation");
                resetHighlight();
                log.returning(methodName);
            }

            @Override
            public void onAnimationCancel(Animator animator) {
                final String methodName = "onAnimationCancel()";
                log.justEntered(methodName);
                // Nothing here
                log.returning(methodName);
            }

            @Override
            public void onAnimationRepeat(Animator animator) {
                final String methodName = "onAnimationRepeat()";
                log.justEntered(methodName);
                // Nothing here
                log.returning(methodName);
            }
        });
        colorAnimation.start();
    }
    log.returning(methodName);
}
Also used : Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) Typeface(android.graphics.Typeface) ArgbEvaluator(android.animation.ArgbEvaluator) SMS(dev.sagar.smsblocker.tech.beans.SMS) ValueAnimator(android.animation.ValueAnimator)

Example 20 with SMS

use of dev.sagar.smsblocker.tech.beans.SMS in project SMSBlocker by sagarpawardev.

the class RVThreadAdapter method deleteSelections.

public boolean deleteSelections() {
    final String methodName = "deleteSelections()";
    log.justEntered(methodName);
    log.error(methodName, "This can be improved");
    log.info(methodName, "Selected SMS count: " + selectedSMSes.size());
    for (SMS sms : selectedSMSes) {
        log.debug(methodName, "Deleting SMS: " + sms.getBody());
        // Delete SMS from database
        inboxUtil.deleteSMS(sms);
        // Delete SMS from UI
        int position = selectedSMSes.indexOf(sms);
        smses.remove(sms);
        notifyItemRemoved(position);
    }
    selectedSMSes.clear();
    log.returning(methodName);
    return true;
}
Also used : SMS(dev.sagar.smsblocker.tech.beans.SMS)

Aggregations

SMS (dev.sagar.smsblocker.tech.beans.SMS)27 Bundle (android.os.Bundle)11 ContentResolver (android.content.ContentResolver)5 Uri (android.net.Uri)5 ArrayList (java.util.ArrayList)5 Cursor (android.database.Cursor)4 ContentValues (android.content.ContentValues)3 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)3 DBHelper (dev.sagar.smsblocker.tech.service.helper.DBHelper)3 HashSet (java.util.HashSet)2 Animator (android.animation.Animator)1 ArgbEvaluator (android.animation.ArgbEvaluator)1 ValueAnimator (android.animation.ValueAnimator)1 PendingIntent (android.app.PendingIntent)1 Intent (android.content.Intent)1 SQLiteOpenHelper (android.database.sqlite.SQLiteOpenHelper)1 Typeface (android.graphics.Typeface)1 Handler (android.os.Handler)1 SmsManager (android.telephony.SmsManager)1 SmsMessage (android.telephony.SmsMessage)1