Use okio with AttachmentTempFileProvider

This commit is contained in:
cketti 2016-11-03 06:08:23 +01:00
parent 75b2cafddc
commit fbecc40d01
4 changed files with 5 additions and 10 deletions

View file

@ -5,3 +5,4 @@ androidSupportLibraryVersion=23.1.1
robolectricVersion=3.1.1
junitVersion=4.12
mockitoVersion=1.10.19
okioVersion=1.11.0

View file

@ -24,7 +24,7 @@ dependencies {
androidTestCompile 'com.android.support.test:runner:0.4.1'
androidTestCompile 'com.madgag.spongycastle:pg:1.51.0.0'
testCompile 'com.squareup.okio:okio:1.6.0'
testCompile "com.squareup.okio:okio:${okioVersion}"
testCompile "org.robolectric:robolectric:${robolectricVersion}"
testCompile "junit:junit:${junitVersion}"
testCompile "org.mockito:mockito-core:${mockitoVersion}"

View file

@ -25,6 +25,7 @@ dependencies {
compile project(':plugins:Android-PullToRefresh:library')
compile project(':plugins:HoloColorPicker')
compile project(':plugins:openpgp-api-lib:openpgp-api')
compile "com.squareup.okio:okio:${okioVersion}"
compile 'commons-io:commons-io:2.4'
compile "com.android.support:support-v4:${androidSupportLibraryVersion}"
compile 'net.sourceforge.htmlcleaner:htmlcleaner:2.16'

View file

@ -5,8 +5,6 @@ import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Date;
import java.util.Locale;
@ -24,7 +22,7 @@ import android.util.Log;
import com.fsck.k9.BuildConfig;
import com.fsck.k9.K9;
import com.fsck.k9.mail.filter.Hex;
import okio.ByteString;
import org.apache.commons.io.IOUtils;
@ -62,12 +60,7 @@ public class AttachmentTempFileProvider extends FileProvider {
}
private static String getTempFilenameForUri(Uri uri) {
try {
byte[] digest = MessageDigest.getInstance("SHA-1").digest(uri.toString().getBytes());
return new String(Hex.encodeHex(digest));
} catch (NoSuchAlgorithmException e) {
throw new AssertionError(e);
}
return ByteString.encodeUtf8(uri.toString()).sha1().hex();
}
private static void writeUriContentToTempFileIfNotExists(Context context, Uri uri, File tempFile)