ktlint: Fix function-signature violations
Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
parent
c075bd574a
commit
17c7f78ed9
10 changed files with 110 additions and 128 deletions
|
|
@ -15,7 +15,6 @@ ktlint_standard_chain-method-continuation = disabled
|
||||||
ktlint_standard_class-signature = disabled
|
ktlint_standard_class-signature = disabled
|
||||||
ktlint_standard_function-expression-body = disabled
|
ktlint_standard_function-expression-body = disabled
|
||||||
ktlint_standard_function-literal = disabled
|
ktlint_standard_function-literal = disabled
|
||||||
ktlint_standard_function-signature = disabled
|
|
||||||
ktlint_standard_max-line-length = disabled
|
ktlint_standard_max-line-length = disabled
|
||||||
ktlint_standard_mixed-condition-operators = disabled
|
ktlint_standard_mixed-condition-operators = disabled
|
||||||
ktlint_standard_package-name = disabled
|
ktlint_standard_package-name = disabled
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,7 @@ class TrampolineSchedulerRule : TestRule {
|
||||||
|
|
||||||
private val scheduler = Schedulers.trampoline()
|
private val scheduler = Schedulers.trampoline()
|
||||||
|
|
||||||
override fun apply(base: Statement, description: Description): Statement =
|
override fun apply(base: Statement, description: Description): Statement = object : Statement() {
|
||||||
object : Statement() {
|
|
||||||
override fun evaluate() {
|
override fun evaluate() {
|
||||||
try {
|
try {
|
||||||
RxJavaPlugins.setComputationSchedulerHandler { scheduler }
|
RxJavaPlugins.setComputationSchedulerHandler { scheduler }
|
||||||
|
|
|
||||||
|
|
@ -248,8 +248,7 @@ class StreamItemAdapterTest {
|
||||||
* @return a list of video streams, in which their video only property mirrors the provided
|
* @return a list of video streams, in which their video only property mirrors the provided
|
||||||
* [videoOnly] vararg.
|
* [videoOnly] vararg.
|
||||||
*/
|
*/
|
||||||
private fun getVideoStreams(vararg videoOnly: Boolean) =
|
private fun getVideoStreams(vararg videoOnly: Boolean) = StreamInfoWrapper(
|
||||||
StreamItemAdapter.StreamInfoWrapper(
|
|
||||||
videoOnly.map {
|
videoOnly.map {
|
||||||
VideoStream.Builder()
|
VideoStream.Builder()
|
||||||
.setId(Stream.ID_UNKNOWN)
|
.setId(Stream.ID_UNKNOWN)
|
||||||
|
|
@ -266,8 +265,7 @@ class StreamItemAdapterTest {
|
||||||
* @return a list of audio streams, containing valid and null elements mirroring the provided
|
* @return a list of audio streams, containing valid and null elements mirroring the provided
|
||||||
* [shouldBeValid] vararg.
|
* [shouldBeValid] vararg.
|
||||||
*/
|
*/
|
||||||
private fun getAudioStreams(vararg shouldBeValid: Boolean) =
|
private fun getAudioStreams(vararg shouldBeValid: Boolean) = getSecondaryStreamsFromList(
|
||||||
getSecondaryStreamsFromList(
|
|
||||||
shouldBeValid.map {
|
shouldBeValid.map {
|
||||||
if (it) {
|
if (it) {
|
||||||
AudioStream.Builder()
|
AudioStream.Builder()
|
||||||
|
|
@ -325,8 +323,7 @@ class StreamItemAdapterTest {
|
||||||
/**
|
/**
|
||||||
* Helper function that builds a secondary stream list.
|
* Helper function that builds a secondary stream list.
|
||||||
*/
|
*/
|
||||||
private fun <T : Stream> getSecondaryStreamsFromList(streams: List<T?>) =
|
private fun <T : Stream> getSecondaryStreamsFromList(streams: List<T?>) = SparseArrayCompat<SecondaryStreamHelper<T>?>(streams.size).apply {
|
||||||
SparseArrayCompat<SecondaryStreamHelper<T>?>(streams.size).apply {
|
|
||||||
streams.forEachIndexed { index, stream ->
|
streams.forEachIndexed { index, stream ->
|
||||||
val secondaryStreamHelper: SecondaryStreamHelper<T>? = stream?.let {
|
val secondaryStreamHelper: SecondaryStreamHelper<T>? = stream?.let {
|
||||||
SecondaryStreamHelper(
|
SecondaryStreamHelper(
|
||||||
|
|
|
||||||
|
|
@ -30,8 +30,7 @@ data class StreamHistoryEntry(
|
||||||
accessDate.isEqual(other.accessDate)
|
accessDate.isEqual(other.accessDate)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun toStreamInfoItem(): StreamInfoItem =
|
fun toStreamInfoItem(): StreamInfoItem = StreamInfoItem(
|
||||||
StreamInfoItem(
|
|
||||||
streamEntity.serviceId,
|
streamEntity.serviceId,
|
||||||
streamEntity.url,
|
streamEntity.url,
|
||||||
streamEntity.title,
|
streamEntity.title,
|
||||||
|
|
|
||||||
|
|
@ -160,16 +160,14 @@ class ErrorInfo private constructor(
|
||||||
|
|
||||||
const val SERVICE_NONE = "<unknown_service>"
|
const val SERVICE_NONE = "<unknown_service>"
|
||||||
|
|
||||||
private fun getServiceName(serviceId: Int?) =
|
private fun getServiceName(serviceId: Int?) = // not using getNameOfServiceById since we want to accept a nullable serviceId and we
|
||||||
// not using getNameOfServiceById since we want to accept a nullable serviceId and we
|
|
||||||
// want to default to SERVICE_NONE
|
// want to default to SERVICE_NONE
|
||||||
ServiceList.all().firstOrNull { it.serviceId == serviceId }?.serviceInfo?.name
|
ServiceList.all().firstOrNull { it.serviceId == serviceId }?.serviceInfo?.name
|
||||||
?: SERVICE_NONE
|
?: SERVICE_NONE
|
||||||
|
|
||||||
fun throwableToStringList(throwable: Throwable) = arrayOf(throwable.stackTraceToString())
|
fun throwableToStringList(throwable: Throwable) = arrayOf(throwable.stackTraceToString())
|
||||||
|
|
||||||
fun throwableListToStringList(throwableList: List<Throwable>) =
|
fun throwableListToStringList(throwableList: List<Throwable>) = throwableList.map { it.stackTraceToString() }.toTypedArray()
|
||||||
throwableList.map { it.stackTraceToString() }.toTypedArray()
|
|
||||||
|
|
||||||
fun getMessage(
|
fun getMessage(
|
||||||
throwable: Throwable?,
|
throwable: Throwable?,
|
||||||
|
|
|
||||||
|
|
@ -151,16 +151,13 @@ class FeedViewModel(
|
||||||
fun getShowFutureItemsFromPreferences() = getShowFutureItemsFromPreferences(application)
|
fun getShowFutureItemsFromPreferences() = getShowFutureItemsFromPreferences(application)
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private fun getShowPlayedItemsFromPreferences(context: Context) =
|
private fun getShowPlayedItemsFromPreferences(context: Context) = PreferenceManager.getDefaultSharedPreferences(context)
|
||||||
PreferenceManager.getDefaultSharedPreferences(context)
|
|
||||||
.getBoolean(context.getString(R.string.feed_show_watched_items_key), true)
|
.getBoolean(context.getString(R.string.feed_show_watched_items_key), true)
|
||||||
|
|
||||||
private fun getShowPartiallyPlayedItemsFromPreferences(context: Context) =
|
private fun getShowPartiallyPlayedItemsFromPreferences(context: Context) = PreferenceManager.getDefaultSharedPreferences(context)
|
||||||
PreferenceManager.getDefaultSharedPreferences(context)
|
|
||||||
.getBoolean(context.getString(R.string.feed_show_partially_watched_items_key), true)
|
.getBoolean(context.getString(R.string.feed_show_partially_watched_items_key), true)
|
||||||
|
|
||||||
private fun getShowFutureItemsFromPreferences(context: Context) =
|
private fun getShowFutureItemsFromPreferences(context: Context) = PreferenceManager.getDefaultSharedPreferences(context)
|
||||||
PreferenceManager.getDefaultSharedPreferences(context)
|
|
||||||
.getBoolean(context.getString(R.string.feed_show_future_items_key), true)
|
.getBoolean(context.getString(R.string.feed_show_future_items_key), true)
|
||||||
|
|
||||||
fun getFactory(context: Context, groupId: Long) = viewModelFactory {
|
fun getFactory(context: Context, groupId: Long) = viewModelFactory {
|
||||||
|
|
|
||||||
|
|
@ -95,8 +95,7 @@ class NotificationWorker(
|
||||||
private val TAG = NotificationWorker::class.java.simpleName
|
private val TAG = NotificationWorker::class.java.simpleName
|
||||||
private const val WORK_TAG = App.PACKAGE_NAME + "_streams_notifications"
|
private const val WORK_TAG = App.PACKAGE_NAME + "_streams_notifications"
|
||||||
|
|
||||||
private fun areNotificationsEnabled(context: Context) =
|
private fun areNotificationsEnabled(context: Context) = NotificationHelper.areNewStreamsNotificationsEnabled(context) &&
|
||||||
NotificationHelper.areNewStreamsNotificationsEnabled(context) &&
|
|
||||||
NotificationHelper.areNotificationsEnabledOnDevice(context)
|
NotificationHelper.areNotificationsEnabledOnDevice(context)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -70,8 +70,7 @@ class SubscriptionManager(context: Context) {
|
||||||
return listEntities
|
return listEntities
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updateChannelInfo(info: ChannelInfo): Completable =
|
fun updateChannelInfo(info: ChannelInfo): Completable = subscriptionTable.getSubscription(info.serviceId, info.url)
|
||||||
subscriptionTable.getSubscription(info.serviceId, info.url)
|
|
||||||
.flatMapCompletable {
|
.flatMapCompletable {
|
||||||
Completable.fromRunnable {
|
Completable.fromRunnable {
|
||||||
it.apply {
|
it.apply {
|
||||||
|
|
|
||||||
|
|
@ -173,8 +173,7 @@ internal class PackageValidator(context: Context) {
|
||||||
*/
|
*/
|
||||||
@Suppress("deprecation")
|
@Suppress("deprecation")
|
||||||
@SuppressLint("PackageManagerGetSignatures")
|
@SuppressLint("PackageManagerGetSignatures")
|
||||||
private fun getPackageInfo(callingPackage: String): PackageInfo? =
|
private fun getPackageInfo(callingPackage: String): PackageInfo? = packageManager.getPackageInfo(
|
||||||
packageManager.getPackageInfo(
|
|
||||||
callingPackage,
|
callingPackage,
|
||||||
PackageManager.GET_SIGNATURES or PackageManager.GET_PERMISSIONS
|
PackageManager.GET_SIGNATURES or PackageManager.GET_PERMISSIONS
|
||||||
)
|
)
|
||||||
|
|
@ -189,8 +188,7 @@ internal class PackageValidator(context: Context) {
|
||||||
* returns `null` as the signature.
|
* returns `null` as the signature.
|
||||||
*/
|
*/
|
||||||
@Suppress("deprecation")
|
@Suppress("deprecation")
|
||||||
private fun getSignature(packageInfo: PackageInfo): String? =
|
private fun getSignature(packageInfo: PackageInfo): String? = if (packageInfo.signatures == null || packageInfo.signatures!!.size != 1) {
|
||||||
if (packageInfo.signatures == null || packageInfo.signatures!!.size != 1) {
|
|
||||||
// Security best practices dictate that an app should be signed with exactly one (1)
|
// Security best practices dictate that an app should be signed with exactly one (1)
|
||||||
// signature. Because of this, if there are multiple signatures, reject it.
|
// signature. Because of this, if there are multiple signatures, reject it.
|
||||||
null
|
null
|
||||||
|
|
@ -202,8 +200,7 @@ internal class PackageValidator(context: Context) {
|
||||||
/**
|
/**
|
||||||
* Finds the Android platform signing key signature. This key is never null.
|
* Finds the Android platform signing key signature. This key is never null.
|
||||||
*/
|
*/
|
||||||
private fun getSystemSignature(): String =
|
private fun getSystemSignature(): String = getPackageInfo(ANDROID_PLATFORM)?.let { platformInfo ->
|
||||||
getPackageInfo(ANDROID_PLATFORM)?.let { platformInfo ->
|
|
||||||
getSignature(platformInfo)
|
getSignature(platformInfo)
|
||||||
} ?: throw IllegalStateException("Platform signature not found")
|
} ?: throw IllegalStateException("Platform signature not found")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -179,8 +179,7 @@ class PoTokenWebView private constructor(
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
//region Obtaining poTokens
|
//region Obtaining poTokens
|
||||||
override fun generatePoToken(identifier: String): Single<String> =
|
override fun generatePoToken(identifier: String): Single<String> = Single.create { emitter ->
|
||||||
Single.create { emitter ->
|
|
||||||
if (BuildConfig.DEBUG) {
|
if (BuildConfig.DEBUG) {
|
||||||
Log.d(TAG, "generatePoToken() called with identifier $identifier")
|
Log.d(TAG, "generatePoToken() called with identifier $identifier")
|
||||||
}
|
}
|
||||||
|
|
@ -373,8 +372,7 @@ class PoTokenWebView private constructor(
|
||||||
"AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.3"
|
"AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.3"
|
||||||
private const val JS_INTERFACE = "PoTokenWebView"
|
private const val JS_INTERFACE = "PoTokenWebView"
|
||||||
|
|
||||||
override fun newPoTokenGenerator(context: Context): Single<PoTokenGenerator> =
|
override fun newPoTokenGenerator(context: Context): Single<PoTokenGenerator> = Single.create { emitter ->
|
||||||
Single.create { emitter ->
|
|
||||||
runOnMainThread(emitter) {
|
runOnMainThread(emitter) {
|
||||||
val potWv = PoTokenWebView(context, emitter)
|
val potWv = PoTokenWebView(context, emitter)
|
||||||
potWv.loadHtmlAndObtainBotguard(context)
|
potWv.loadHtmlAndObtainBotguard(context)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue