diff options
author | steckbrief <steckbrief@chefmail.de> | 2017-02-06 10:01:13 +0100 |
---|---|---|
committer | steckbrief <steckbrief@chefmail.de> | 2017-02-06 10:01:13 +0100 |
commit | 754de6bb0449a577d2bb9c28cca6adf0ef9554f6 (patch) | |
tree | 279b405d94e0d86d10ed94bd34d919457944ead6 /src/main/java/de/thedevstack/conversationsplus/ConversationsPlusApplication.java | |
parent | cd633f13b8d7327e47994bb5a000f0c0b7089e7f (diff) |
relates FS#241: Implementation of http download based on okhttp
Diffstat (limited to '')
-rw-r--r-- | src/main/java/de/thedevstack/conversationsplus/ConversationsPlusApplication.java | 21 |
1 files changed, 12 insertions, 9 deletions
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; } |