From 754de6bb0449a577d2bb9c28cca6adf0ef9554f6 Mon Sep 17 00:00:00 2001 From: steckbrief Date: Mon, 6 Feb 2017 10:01:13 +0100 Subject: relates FS#241: Implementation of http download based on okhttp --- .../ConversationsPlusApplication.java | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'src/main/java/de/thedevstack/conversationsplus/ConversationsPlusApplication.java') diff --git a/src/main/java/de/thedevstack/conversationsplus/ConversationsPlusApplication.java b/src/main/java/de/thedevstack/conversationsplus/ConversationsPlusApplication.java index d4e3ebc2..2c056867 100644 --- a/src/main/java/de/thedevstack/conversationsplus/ConversationsPlusApplication.java +++ b/src/main/java/de/thedevstack/conversationsplus/ConversationsPlusApplication.java @@ -1,8 +1,10 @@ package de.thedevstack.conversationsplus; +import android.Manifest; import android.app.Application; import android.content.Context; import android.content.pm.PackageManager; +import android.os.Build; import android.os.PowerManager; import android.preference.PreferenceManager; @@ -11,15 +13,14 @@ import java.security.SecureRandom; import de.duenndns.ssl.MemorizingTrustManager; import de.thedevstack.conversationsplus.http.HttpClient; -import de.thedevstack.conversationsplus.http.HttpConnectionManager; import de.thedevstack.conversationsplus.persistance.FileBackend; import de.thedevstack.conversationsplus.services.filetransfer.FileTransferManager; +import de.thedevstack.conversationsplus.services.filetransfer.http.download.HttpDownloadFileTransferService; import de.thedevstack.conversationsplus.services.filetransfer.http.upload.HttpUploadFileTransferService; import de.thedevstack.conversationsplus.services.filetransfer.jingle.JingleFileTransferService; import de.thedevstack.conversationsplus.utils.ImageUtil; import de.thedevstack.conversationsplus.utils.PRNGFixes; import de.thedevstack.conversationsplus.utils.SerialSingleThreadExecutor; -import okhttp3.OkHttpClient; /** * This class is used to provide static access to the applicationcontext. @@ -46,8 +47,7 @@ public class ConversationsPlusApplication extends Application { this.initializeSecurity(); ImageUtil.initBitmapCache(); FileBackend.init(); - FileTransferManager.init(new HttpUploadFileTransferService(), new JingleFileTransferService()); - HttpConnectionManager.init(); + FileTransferManager.init(new HttpUploadFileTransferService(), new JingleFileTransferService(), new HttpDownloadFileTransferService()); HttpClient.init(); } @@ -132,6 +132,14 @@ public class ConversationsPlusApplication extends Application { return powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, name); } + public static boolean hasStoragePermission() { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + return ConversationsPlusApplication.getAppContext().checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED; + } else { + return true; + } + } + public static MemorizingTrustManager getMemorizingTrustManager() { return getInstance().memorizingTrustManager; } @@ -150,11 +158,6 @@ public class ConversationsPlusApplication extends Application { getInstance().setMemorizingTrustManager(tm); } - private static void initHttpClient() { - OkHttpClient client = new OkHttpClient.Builder() - .build(); - } - public static SecureRandom getSecureRandom() { return getInstance().secureRandom; } -- cgit v1.2.3