2015-03-31 15:44:41 -07:00
|
|
|
package org.thoughtcrime.securesms.mms;
|
|
|
|
|
|
|
|
import android.content.ContentResolver;
|
|
|
|
import android.content.Context;
|
|
|
|
import android.net.Uri;
|
|
|
|
import android.util.Log;
|
|
|
|
|
|
|
|
import com.bumptech.glide.load.data.StreamLocalUriFetcher;
|
|
|
|
|
|
|
|
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
|
|
|
|
|
|
|
import java.io.FileNotFoundException;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.InputStream;
|
|
|
|
|
|
|
|
public class DecryptableStreamLocalUriFetcher extends StreamLocalUriFetcher {
|
2015-10-12 18:25:05 -07:00
|
|
|
|
2015-03-31 15:44:41 -07:00
|
|
|
private static final String TAG = DecryptableStreamLocalUriFetcher.class.getSimpleName();
|
2015-10-12 18:25:05 -07:00
|
|
|
|
|
|
|
private Context context;
|
2015-03-31 15:44:41 -07:00
|
|
|
private MasterSecret masterSecret;
|
|
|
|
|
|
|
|
public DecryptableStreamLocalUriFetcher(Context context, MasterSecret masterSecret, Uri uri) {
|
|
|
|
super(context, uri);
|
2015-10-12 18:25:05 -07:00
|
|
|
this.context = context;
|
2015-03-31 15:44:41 -07:00
|
|
|
this.masterSecret = masterSecret;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected InputStream loadResource(Uri uri, ContentResolver contentResolver) throws FileNotFoundException {
|
|
|
|
try {
|
2015-10-12 18:25:05 -07:00
|
|
|
return PartAuthority.getAttachmentStream(context, masterSecret, uri);
|
2015-03-31 15:44:41 -07:00
|
|
|
} catch (IOException ioe) {
|
|
|
|
Log.w(TAG, ioe);
|
|
|
|
throw new FileNotFoundException("PartAuthority couldn't load Uri resource.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|