From 15d607b799367b6bdc8e4d16b9b4dbd91debfb16 Mon Sep 17 00:00:00 2001 From: Conny Duck Date: Fri, 16 Nov 2018 13:31:03 +0100 Subject: [PATCH] update deps, fix some lint warnings --- app/build.gradle | 12 +++++------ .../keylesspalace/tusky/AccountActivity.kt | 4 ++-- .../tusky/EditProfileActivity.kt | 2 +- .../keylesspalace/tusky/ViewMediaActivity.kt | 4 ++-- .../tusky/fragment/ViewImageFragment.kt | 8 ++------ .../tusky/fragment/ViewMediaFragment.kt | 1 - .../tusky/fragment/ViewVideoFragment.kt | 4 ---- .../preference/PreferencesFragment.kt | 20 +++++++++---------- .../com/keylesspalace/tusky/SpanUtilsTest.kt | 16 +++++++-------- build.gradle | 2 +- 10 files changed, 32 insertions(+), 41 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 2952d343..fccfb0da 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -59,7 +59,7 @@ android { } ext.supportLibraryVersion = '28.0.0' -ext.daggerVersion = '2.17' +ext.daggerVersion = '2.19' // if libraries are changed here, they should also be changed in LicenseActivity @@ -105,16 +105,16 @@ dependencies { implementation "com.google.dagger:dagger-android:$daggerVersion" implementation "com.google.dagger:dagger-android-support:$daggerVersion" kapt "com.google.dagger:dagger-android-processor:$daggerVersion" - testImplementation 'org.robolectric:robolectric:4.0-alpha-3' - testImplementation 'org.mockito:mockito-inline:2.21.0' + testImplementation 'org.robolectric:robolectric:4.0.2' + testImplementation 'org.mockito:mockito-inline:2.23.0' androidTestImplementation('com.android.support.test.espresso:espresso-core:3.0.1', { exclude group: 'com.android.support', module: 'support-annotations' }) debugImplementation 'im.dino:dbinspector:3.4.1@aar' - implementation 'io.reactivex.rxjava2:rxjava:2.2.1' + implementation 'io.reactivex.rxjava2:rxjava:2.2.3' implementation 'io.reactivex.rxjava2:rxandroid:2.1.0' implementation 'io.reactivex.rxjava2:rxkotlin:2.3.0' implementation 'com.squareup.retrofit2:adapter-rxjava2:2.4.0' - implementation 'com.uber.autodispose:autodispose-android-archcomponents:1.0.0-RC2' - implementation 'com.uber.autodispose:autodispose-ktx:1.0.0-RC2' + implementation 'com.uber.autodispose:autodispose-android-archcomponents:1.0.0-RC3' + implementation 'com.uber.autodispose:autodispose-ktx:1.0.0-RC3' } diff --git a/app/src/main/java/com/keylesspalace/tusky/AccountActivity.kt b/app/src/main/java/com/keylesspalace/tusky/AccountActivity.kt index 734293b2..a6b373dc 100644 --- a/app/src/main/java/com/keylesspalace/tusky/AccountActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/AccountActivity.kt @@ -373,9 +373,9 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, HasSupportF accountFollowingTextView.text = numberFormat.format(account.followingCount) accountStatusesTextView.text = numberFormat.format(account.statusesCount) - accountFloatingActionButton.setOnClickListener { _ -> mention() } + accountFloatingActionButton.setOnClickListener { mention() } - accountFollowButton.setOnClickListener { _ -> + accountFollowButton.setOnClickListener { if (isSelf) { val intent = Intent(this@AccountActivity, EditProfileActivity::class.java) startActivity(intent) diff --git a/app/src/main/java/com/keylesspalace/tusky/EditProfileActivity.kt b/app/src/main/java/com/keylesspalace/tusky/EditProfileActivity.kt index c24128b3..63b03bf3 100644 --- a/app/src/main/java/com/keylesspalace/tusky/EditProfileActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/EditProfileActivity.kt @@ -142,7 +142,7 @@ class EditProfileActivity : BaseActivity(), Injectable { } } is Error -> { - val snackbar = Snackbar.make(avatarButton, R.string.error_generic, Snackbar.LENGTH_LONG); + val snackbar = Snackbar.make(avatarButton, R.string.error_generic, Snackbar.LENGTH_LONG) snackbar.setAction(R.string.action_retry) { viewModel.obtainProfile() } diff --git a/app/src/main/java/com/keylesspalace/tusky/ViewMediaActivity.kt b/app/src/main/java/com/keylesspalace/tusky/ViewMediaActivity.kt index c8faab4f..5e747078 100644 --- a/app/src/main/java/com/keylesspalace/tusky/ViewMediaActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/ViewMediaActivity.kt @@ -139,7 +139,7 @@ class ViewMediaActivity : BaseActivity(), ViewImageFragment.PhotoActionsListener actionBar.setDisplayShowHomeEnabled(true) actionBar.title = adapter.getPageTitle(initialPosition) } - toolbar.setNavigationOnClickListener { _ -> supportFinishAfterTransition() } + toolbar.setNavigationOnClickListener { supportFinishAfterTransition() } toolbar.setOnMenuItemClickListener { item: MenuItem -> when (item.itemId) { R.id.action_download -> downloadMedia() @@ -194,7 +194,7 @@ class ViewMediaActivity : BaseActivity(), ViewImageFragment.PhotoActionsListener if (grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED) { downloadMedia() } else { - showErrorDialog(toolbar, R.string.error_media_download_permission, R.string.action_retry) { _ -> downloadMedia() } + showErrorDialog(toolbar, R.string.error_media_download_permission, R.string.action_retry) { downloadMedia() } } } } diff --git a/app/src/main/java/com/keylesspalace/tusky/fragment/ViewImageFragment.kt b/app/src/main/java/com/keylesspalace/tusky/fragment/ViewImageFragment.kt index 8873f67a..57af04c2 100644 --- a/app/src/main/java/com/keylesspalace/tusky/fragment/ViewImageFragment.kt +++ b/app/src/main/java/com/keylesspalace/tusky/fragment/ViewImageFragment.kt @@ -49,10 +49,6 @@ class ViewImageFragment : ViewMediaFragment() { private lateinit var toolbar: View override lateinit var descriptionView : TextView - companion object { - private const val TAG = "ViewImageFragment" - } - override fun onAttach(context: Context) { super.onAttach(context) photoActionsListener = context as PhotoActionsListener @@ -64,9 +60,9 @@ class ViewImageFragment : ViewMediaFragment() { attacher = PhotoViewAttacher(photoView) // Clicking outside the photo closes the viewer. - attacher.setOnOutsidePhotoTapListener { _ -> photoActionsListener.onDismiss() } + attacher.setOnOutsidePhotoTapListener { photoActionsListener.onDismiss() } - attacher.setOnClickListener { _ -> onMediaTap() } + attacher.setOnClickListener { onMediaTap() } /* A vertical swipe motion also closes the viewer. This is especially useful when the photo * mostly fills the screen so clicking outside is difficult. */ diff --git a/app/src/main/java/com/keylesspalace/tusky/fragment/ViewMediaFragment.kt b/app/src/main/java/com/keylesspalace/tusky/fragment/ViewMediaFragment.kt index 47b480ba..05feab85 100644 --- a/app/src/main/java/com/keylesspalace/tusky/fragment/ViewMediaFragment.kt +++ b/app/src/main/java/com/keylesspalace/tusky/fragment/ViewMediaFragment.kt @@ -37,7 +37,6 @@ abstract class ViewMediaFragment : BaseFragment() { @JvmStatic protected val ARG_START_POSTPONED_TRANSITION = "startPostponedTransition" @JvmStatic protected val ARG_ATTACHMENT = "attach" @JvmStatic protected val ARG_AVATAR_URL = "avatarUrl" - private const val TAG = "ViewMediaFragment" @JvmStatic fun newInstance(attachment: Attachment, shouldStartPostponedTransition: Boolean): ViewMediaFragment { diff --git a/app/src/main/java/com/keylesspalace/tusky/fragment/ViewVideoFragment.kt b/app/src/main/java/com/keylesspalace/tusky/fragment/ViewVideoFragment.kt index 4ca0e0c6..483af195 100644 --- a/app/src/main/java/com/keylesspalace/tusky/fragment/ViewVideoFragment.kt +++ b/app/src/main/java/com/keylesspalace/tusky/fragment/ViewVideoFragment.kt @@ -49,10 +49,6 @@ class ViewVideoFragment : ViewMediaFragment() { override lateinit var descriptionView : TextView private lateinit var mediaController : MediaController - companion object { - private const val TAG = "ViewVideoFragment" - } - override fun setUserVisibleHint(isVisibleToUser: Boolean) { // Start/pause/resume video playback as fragment is shown/hidden super.setUserVisibleHint(isVisibleToUser) diff --git a/app/src/main/java/com/keylesspalace/tusky/fragment/preference/PreferencesFragment.kt b/app/src/main/java/com/keylesspalace/tusky/fragment/preference/PreferencesFragment.kt index 35c646f6..7923a8c1 100644 --- a/app/src/main/java/com/keylesspalace/tusky/fragment/preference/PreferencesFragment.kt +++ b/app/src/main/java/com/keylesspalace/tusky/fragment/preference/PreferencesFragment.kt @@ -42,21 +42,21 @@ class PreferencesFragment : PreferenceFragmentCompat() { textSizePreference.icon = IconicsDrawable(context, GoogleMaterial.Icon.gmd_format_size).sizePx(iconSize).color(ThemeUtils.getColor(context, R.attr.toolbar_icon_tint)) val timelineFilterPreferences = findPreference("timelineFilterPreferences") - timelineFilterPreferences.setOnPreferenceClickListener { _ -> - activity?.let { - val intent = PreferencesActivity.newIntent(it, PreferencesActivity.TAB_FILTER_PREFERENCES) - it.startActivity(intent) - it.overridePendingTransition(R.anim.slide_from_right, R.anim.slide_to_left) + timelineFilterPreferences.setOnPreferenceClickListener { + activity?.let { activity -> + val intent = PreferencesActivity.newIntent(activity, PreferencesActivity.TAB_FILTER_PREFERENCES) + activity.startActivity(intent) + activity.overridePendingTransition(R.anim.slide_from_right, R.anim.slide_to_left) } true } val httpProxyPreferences = findPreference("httpProxyPreferences") - httpProxyPreferences.setOnPreferenceClickListener { _ -> - activity?.let { - val intent = PreferencesActivity.newIntent(it, PreferencesActivity.PROXY_PREFERENCES) - it.startActivity(intent) - it.overridePendingTransition(R.anim.slide_from_right, R.anim.slide_to_left) + httpProxyPreferences.setOnPreferenceClickListener { + activity?.let { activity -> + val intent = PreferencesActivity.newIntent(activity, PreferencesActivity.PROXY_PREFERENCES) + activity.startActivity(intent) + activity.overridePendingTransition(R.anim.slide_from_right, R.anim.slide_to_left) } true } diff --git a/app/src/test/java/com/keylesspalace/tusky/SpanUtilsTest.kt b/app/src/test/java/com/keylesspalace/tusky/SpanUtilsTest.kt index f52eabf3..3b4f5c10 100644 --- a/app/src/test/java/com/keylesspalace/tusky/SpanUtilsTest.kt +++ b/app/src/test/java/com/keylesspalace/tusky/SpanUtilsTest.kt @@ -2,7 +2,7 @@ package com.keylesspalace.tusky import android.text.Spannable import com.keylesspalace.tusky.util.highlightSpans -import junit.framework.Assert +import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.Parameterized @@ -21,7 +21,7 @@ class SpanUtilsTest { fun doesntMergeAdjacentURLs() { val firstURL = "http://first.thing" val secondURL = "https://second.thing" - val inputSpannable = FakeSpannable("${firstURL} ${secondURL}") + val inputSpannable = FakeSpannable("$firstURL $secondURL") highlightSpans(inputSpannable, 0xffffff) val spans = inputSpannable.spans Assert.assertEquals(2, spans.size) @@ -55,7 +55,7 @@ class SpanUtilsTest { @Test fun matchesSpanNotAtStart() { - val inputSpannable = FakeSpannable(" ${thingToHighlight}") + val inputSpannable = FakeSpannable(" $thingToHighlight") highlightSpans(inputSpannable, 0xffffff) val spans = inputSpannable.spans Assert.assertEquals(1, spans.size) @@ -82,12 +82,12 @@ class SpanUtilsTest { fun spansDoNotOverlap() { val begin = "@begin" val end = "#end" - val inputSpannable = FakeSpannable("${begin} ${thingToHighlight} ${end}") + val inputSpannable = FakeSpannable("$begin $thingToHighlight $end") highlightSpans(inputSpannable, 0xffffff) val spans = inputSpannable.spans Assert.assertEquals(3, spans.size) - val middleSpan = spans.single ({ span -> span.start > 0 && span.end < inputSpannable.lastIndex }) + val middleSpan = spans.single { span -> span.start > 0 && span.end < inputSpannable.lastIndex } Assert.assertEquals(begin.length + 1, middleSpan.start) Assert.assertEquals(inputSpannable.length - end.length - 1, middleSpan.end) } @@ -104,15 +104,15 @@ class SpanUtilsTest { val matching = if (type == null) { ArrayList() } else { - spans.filter ({ it.start >= start && it.end <= end && type?.isAssignableFrom(it.span?.javaClass) }) - .map({ it -> it.span }) + spans.filter { it.start >= start && it.end <= end && type.isAssignableFrom(it.span?.javaClass) } + .map { it -> it.span } .let { ArrayList(it) } } return matching.toArray() as Array } override fun removeSpan(what: Any?) { - spans.removeIf({ span -> span.span == what}) + spans.removeIf { span -> span.span == what} } override fun toString(): String { diff --git a/build.gradle b/build.gradle index 10531ad7..e9fe3004 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,7 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = '1.2.71' + ext.kotlin_version = '1.3.0' repositories { jcenter() google()