-
-
Notifications
You must be signed in to change notification settings - Fork 256
More Kotlin #1406
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
More Kotlin #1406
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 0 additions & 3 deletions
3
News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/helper/AidlException.aidl
This file was deleted.
Oops, something went wrong.
51 changes: 0 additions & 51 deletions
51
News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/helper/ForegroundListener.java
This file was deleted.
Oops, something went wrong.
47 changes: 47 additions & 0 deletions
47
News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/helper/ForegroundListener.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| package de.luhmer.owncloudnewsreader.helper | ||
|
|
||
| import android.app.Activity | ||
| import android.app.Application.ActivityLifecycleCallbacks | ||
| import android.os.Bundle | ||
|
|
||
| class ForegroundListener : ActivityLifecycleCallbacks { | ||
| override fun onActivityCreated( | ||
| activity: Activity, | ||
| savedInstanceState: Bundle?, | ||
| ) { | ||
| // do nothing | ||
| } | ||
|
|
||
| override fun onActivityStarted(activity: Activity) { | ||
| numStarted++ | ||
| } | ||
|
|
||
| override fun onActivityResumed(activity: Activity) { | ||
| // do nothing | ||
| } | ||
|
|
||
| override fun onActivityPaused(activity: Activity) { | ||
| // do nothing | ||
| } | ||
|
|
||
| override fun onActivityStopped(activity: Activity) { | ||
| numStarted-- | ||
| } | ||
|
|
||
| override fun onActivitySaveInstanceState( | ||
| activity: Activity, | ||
| outState: Bundle, | ||
| ) { | ||
| // do nothing | ||
| } | ||
|
|
||
| override fun onActivityDestroyed(activity: Activity) { | ||
| // do nothing | ||
| } | ||
|
|
||
| companion object { | ||
| private var numStarted = 0 | ||
| val isInForeground: Boolean | ||
| get() = numStarted > 0 | ||
| } | ||
| } |
29 changes: 0 additions & 29 deletions
29
News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/helper/URLConnectionReader.java
This file was deleted.
Oops, something went wrong.
27 changes: 27 additions & 0 deletions
27
News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/helper/URLConnectionReader.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| @file:JvmName("URLConnectionReader") | ||
|
|
||
| package de.luhmer.owncloudnewsreader.helper | ||
|
|
||
| import java.io.BufferedReader | ||
| import java.io.IOException | ||
| import java.io.InputStreamReader | ||
| import java.net.URL | ||
|
|
||
| /** | ||
| * Created by David on 13.01.2016. | ||
| */ | ||
| @Throws(IOException::class) | ||
| fun getText(url: String?): String { | ||
| val website = URL(url) | ||
| val connection = website.openConnection() | ||
|
|
||
| val response = StringBuilder() | ||
| BufferedReader(InputStreamReader(connection.getInputStream())).use { | ||
| inReader -> | ||
| { | ||
| var inputLine: String? | ||
| while (inReader.readLine().also { inputLine = it } != null) response.append(inputLine) | ||
| } | ||
| } | ||
| return response.toString() | ||
| } |
80 changes: 0 additions & 80 deletions
80
News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/ssl/TLSSocketFactory.java
This file was deleted.
Oops, something went wrong.
86 changes: 86 additions & 0 deletions
86
News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/ssl/TLSSocketFactory.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| package de.luhmer.owncloudnewsreader.ssl | ||
|
|
||
| import java.io.IOException | ||
| import java.net.InetAddress | ||
| import java.net.Socket | ||
| import javax.net.ssl.SSLContext | ||
| import javax.net.ssl.SSLSocket | ||
| import javax.net.ssl.SSLSocketFactory | ||
|
|
||
| /* This class should enable TLSv1.1 and TLSv1.2 on devices where they are available but not enabled. | ||
| According to https://developer.android.com/reference/javax/net/ssl/SSLSocket.html | ||
| this should only affect API Level 16 - 20. | ||
|
|
||
| DISCLAIMER: The author is neither an Android/Java developer nor a software developer at all. | ||
| Since this class affects security it shouldn't be used unless it was reviewed and tested | ||
| by an qualified person. | ||
|
|
||
| */ | ||
| class TLSSocketFactory(sslContext: SSLContext) : SSLSocketFactory() { | ||
| private val socketFactory: SSLSocketFactory | ||
|
|
||
| init { | ||
| socketFactory = sslContext.socketFactory | ||
| } | ||
|
|
||
| @Throws(IOException::class) | ||
| override fun createSocket( | ||
| socket: Socket, | ||
| host: String, | ||
| port: Int, | ||
| autoClose: Boolean, | ||
| ): Socket { | ||
| val sslSocket = | ||
| socketFactory.createSocket( | ||
| socket, | ||
| host, | ||
| port, | ||
| autoClose, | ||
| ) as SSLSocket | ||
|
|
||
| // Enable all supported Protocols | ||
| sslSocket.enabledProtocols = sslSocket.supportedProtocols | ||
| return sslSocket | ||
| } | ||
|
|
||
| override fun getDefaultCipherSuites(): Array<String> { | ||
| return socketFactory.defaultCipherSuites | ||
| } | ||
|
|
||
| override fun getSupportedCipherSuites(): Array<String> { | ||
| return socketFactory.supportedCipherSuites | ||
| } | ||
|
|
||
| // NoTLS | ||
| override fun createSocket( | ||
| s: String, | ||
| i: Int, | ||
| ): Socket { | ||
| return super.createSocket() | ||
| } | ||
|
|
||
| override fun createSocket( | ||
| s: String, | ||
| i: Int, | ||
| inetAddress: InetAddress, | ||
| i2: Int, | ||
| ): Socket { | ||
| return super.createSocket() | ||
| } | ||
|
|
||
| override fun createSocket( | ||
| inetAddress: InetAddress, | ||
| i: Int, | ||
| ): Socket { | ||
| return super.createSocket() | ||
| } | ||
|
|
||
| override fun createSocket( | ||
| inetAddress: InetAddress, | ||
| i: Int, | ||
| inetAddress2: InetAddress, | ||
| i2: Int, | ||
| ): Socket { | ||
| return super.createSocket() | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.