Search in sources :

Example 36 with Uri

use of android.net.Uri in project MaterialDrawer by mikepenz.

the class CustomApplication method onCreate.

@Override
public void onCreate() {
    super.onCreate();
    LeakCanary.install(this);
    /*
        //initialize and create the image loader logic
        DrawerImageLoader.init(new AbstractDrawerImageLoader() {
            @Override
            public void set(ImageView imageView, Uri uri, Drawable placeholder) {
                Picasso.with(imageView.getContext()).load(uri).placeholder(placeholder).into(imageView);
            }

            @Override
            public void cancel(ImageView imageView) {
                Picasso.with(imageView.getContext()).cancelRequest(imageView);
            }
        });
        */
    //initialize and create the image loader logic
    DrawerImageLoader.init(new AbstractDrawerImageLoader() {

        @Override
        public void set(ImageView imageView, Uri uri, Drawable placeholder, String tag) {
            Glide.with(imageView.getContext()).load(uri).placeholder(placeholder).into(imageView);
        }

        @Override
        public void cancel(ImageView imageView) {
            Glide.clear(imageView);
        }

        @Override
        public Drawable placeholder(Context ctx, String tag) {
            //custom ones can be checked via string. see the CustomUrlBasePrimaryDrawerItem LINE 111
            if (DrawerImageLoader.Tags.PROFILE.name().equals(tag)) {
                return DrawerUIUtils.getPlaceHolder(ctx);
            } else if (DrawerImageLoader.Tags.ACCOUNT_HEADER.name().equals(tag)) {
                return new IconicsDrawable(ctx).iconText(" ").backgroundColorRes(com.mikepenz.materialdrawer.R.color.primary).sizeDp(56);
            } else if ("customUrlItem".equals(tag)) {
                return new IconicsDrawable(ctx).iconText(" ").backgroundColorRes(R.color.md_red_500).sizeDp(56);
            }
            return super.placeholder(ctx, tag);
        }
    });
}
Also used : Context(android.content.Context) AbstractDrawerImageLoader(com.mikepenz.materialdrawer.util.AbstractDrawerImageLoader) IconicsDrawable(com.mikepenz.iconics.IconicsDrawable) Drawable(android.graphics.drawable.Drawable) ImageView(android.widget.ImageView) Uri(android.net.Uri) IconicsDrawable(com.mikepenz.iconics.IconicsDrawable)

Example 37 with Uri

use of android.net.Uri in project qksms by moezbhatti.

the class MessageUtils method lockMessage.

public static void lockMessage(Context context, MessageItem msgItem, boolean locked) {
    Uri uri;
    if ("sms".equals(msgItem.mType)) {
        uri = Sms.CONTENT_URI;
    } else {
        uri = Mms.CONTENT_URI;
    }
    final Uri lockUri = ContentUris.withAppendedId(uri, msgItem.mMsgId);
    final ContentValues values = new ContentValues(1);
    values.put("locked", locked ? 1 : 0);
    new Thread(() -> {
        context.getContentResolver().update(lockUri, values, null, null);
    }, "MainActivity.lockMessage").start();
}
Also used : ContentValues(android.content.ContentValues) Uri(android.net.Uri)

Example 38 with Uri

use of android.net.Uri in project qksms by moezbhatti.

the class AddressUtils method getFrom.

public static String getFrom(Context context, Uri uri) {
    String msgId = uri.getLastPathSegment();
    Uri.Builder builder = Mms.CONTENT_URI.buildUpon();
    builder.appendPath(msgId).appendPath("addr");
    Cursor cursor = SqliteWrapper.query(context, context.getContentResolver(), builder.build(), new String[] { Addr.ADDRESS, Addr.CHARSET }, Addr.TYPE + "=" + PduHeaders.FROM, null, null);
    if (cursor != null) {
        try {
            if (cursor.moveToFirst()) {
                String from = cursor.getString(0);
                if (!TextUtils.isEmpty(from)) {
                    byte[] bytes = PduPersister.getBytes(from);
                    int charset = cursor.getInt(1);
                    return new EncodedStringValue(charset, bytes).getString();
                }
            }
        } finally {
            cursor.close();
        }
    }
    return context.getString(R.string.hidden_sender_address);
}
Also used : EncodedStringValue(com.google.android.mms.pdu_alt.EncodedStringValue) Cursor(android.database.Cursor) Uri(android.net.Uri)

Example 39 with Uri

use of android.net.Uri in project qksms by moezbhatti.

the class BackgroundLoaderManager method cancelCallback.

public void cancelCallback(ItemLoadedCallback callback) {
    if (Log.isLoggable(TAG, Log.DEBUG)) {
        Log.d(TAG, "Cancelling image callback " + callback);
    }
    for (final Uri uri : mCallbacks.keySet()) {
        final Set<ItemLoadedCallback> callbacks = mCallbacks.get(uri);
        callbacks.remove(callback);
    }
}
Also used : Uri(android.net.Uri)

Example 40 with Uri

use of android.net.Uri in project qksms by moezbhatti.

the class MessageUtils method handleReadReport.

public static void handleReadReport(final Context context, final Collection<Long> threadIds, final int status, final Runnable callback) {
    StringBuilder selectionBuilder = new StringBuilder(Mms.MESSAGE_TYPE + " = " + PduHeaders.MESSAGE_TYPE_RETRIEVE_CONF + " AND " + Mms.READ + " = 0" + " AND " + Mms.READ_REPORT + " = " + PduHeaders.VALUE_YES);
    String[] selectionArgs = null;
    if (threadIds != null) {
        String threadIdSelection = null;
        StringBuilder buf = new StringBuilder();
        selectionArgs = new String[threadIds.size()];
        int i = 0;
        for (long threadId : threadIds) {
            if (i > 0) {
                buf.append(" OR ");
            }
            buf.append(Mms.THREAD_ID).append("=?");
            selectionArgs[i++] = Long.toString(threadId);
        }
        threadIdSelection = buf.toString();
        selectionBuilder.append(" AND (" + threadIdSelection + ")");
    }
    final Cursor c = SqliteWrapper.query(context, context.getContentResolver(), Mms.Inbox.CONTENT_URI, new String[] { Mms._ID, Mms.MESSAGE_ID }, selectionBuilder.toString(), selectionArgs, null);
    if (c == null) {
        return;
    }
    final Map<String, String> map = new HashMap<>();
    try {
        if (c.getCount() == 0) {
            if (callback != null) {
                callback.run();
            }
            return;
        }
        while (c.moveToNext()) {
            Uri uri = ContentUris.withAppendedId(Mms.CONTENT_URI, c.getLong(0));
            map.put(c.getString(1), AddressUtils.getFrom(context, uri));
        }
    } finally {
        c.close();
    }
    OnClickListener positiveListener = new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            for (final Map.Entry<String, String> entry : map.entrySet()) {
                MmsMessageSender.sendReadRec(context, entry.getValue(), entry.getKey(), status);
            }
            if (callback != null) {
                callback.run();
            }
            dialog.dismiss();
        }
    };
    OnClickListener negativeListener = new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (callback != null) {
                callback.run();
            }
            dialog.dismiss();
        }
    };
    OnCancelListener cancelListener = new OnCancelListener() {

        @Override
        public void onCancel(DialogInterface dialog) {
            if (callback != null) {
                callback.run();
            }
            dialog.dismiss();
        }
    };
    confirmReadReportDialog(context, positiveListener, negativeListener, cancelListener);
}
Also used : ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) DialogInterface(android.content.DialogInterface) Cursor(android.database.Cursor) Uri(android.net.Uri) OnClickListener(android.content.DialogInterface.OnClickListener) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) MimeTypeMap(android.webkit.MimeTypeMap) OnCancelListener(android.content.DialogInterface.OnCancelListener)

Aggregations

Uri (android.net.Uri)6747 Intent (android.content.Intent)1547 Cursor (android.database.Cursor)894 File (java.io.File)744 Test (org.junit.Test)632 ContentValues (android.content.ContentValues)614 IOException (java.io.IOException)571 ContentResolver (android.content.ContentResolver)449 ArrayList (java.util.ArrayList)446 Bundle (android.os.Bundle)289 Context (android.content.Context)276 Bitmap (android.graphics.Bitmap)273 InputStream (java.io.InputStream)257 View (android.view.View)251 RemoteException (android.os.RemoteException)228 PendingIntent (android.app.PendingIntent)209 SuppressLint (android.annotation.SuppressLint)180 FileNotFoundException (java.io.FileNotFoundException)177 TextView (android.widget.TextView)175 ActivityNotFoundException (android.content.ActivityNotFoundException)169