Update Deps + Cleanup (#1158)

* Fix Typo

* Update build.gradle

* Update Deps

* Update Tests

* Fixes Tests

Without this some tests fail on my PC...

+ also:
"Put this in your gradle.properties:

android.enableUnitTestBinaryResources=true"
from http://robolectric.org/migrating/#project-configuration

* Make everything private

* Fix Warning

* Update TimelineFragment.java

* Update build.gradle

* Update gradle-wrapper.properties

* Update gradle-wrapper.properties

* Update gradle-wrapper.properties

* Fix Compile Errors

e.g.

Type inference failed. Expected type mismatch: inferred type is Preference? but Preference was expected

Type inference failed. Please try to specify type arguments explicitly.

* fix crash

* Grandle Wrapper 5.3

* Revert "Fix Compile Errors"

This reverts commit 4a774a4fe3ce82c84bd7b4d78e1a1c64af97cd0d.

* requirePreference

* oops

* Cleanup

* Update gradle-wrapper.properties
This commit is contained in:
Bernd 2019-03-30 15:18:16 +01:00 committed by Konrad Pozniak
parent bbf3286d8e
commit 0db1a23c4f
19 changed files with 99 additions and 61 deletions

View File

@ -95,14 +95,14 @@ dependencies {
implementation 'com.google.android.material:material:1.1.0-alpha04'
implementation 'androidx.exifinterface:exifinterface:1.0.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.preference:preference:1.1.0-alpha03'
implementation 'androidx.preference:preference:1.1.0-alpha04'
implementation 'com.squareup.retrofit2:retrofit:2.5.0'
implementation 'com.squareup.retrofit2:converter-gson:2.5.0'
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.5.0'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.squareup.okhttp3:okhttp:3.13.1'
implementation 'com.squareup.okhttp3:logging-interceptor:3.13.1'
implementation "org.conscrypt:conscrypt-android:2.0.0"
implementation 'org.conscrypt:conscrypt-android:2.0.0'
implementation 'com.jakewharton.picasso:picasso2-okhttp3-downloader:1.1.0'
implementation 'com.github.connyduck:sparkbutton:2.0.0'
implementation 'com.github.chrisbanes:PhotoView:2.3.0'
@ -130,13 +130,12 @@ dependencies {
kapt "com.google.dagger:dagger-android-processor:$daggerVersion"
testImplementation 'org.robolectric:robolectric:4.2'
testImplementation 'org.mockito:mockito-inline:2.24.0'
testImplementation "com.nhaarman.mockitokotlin2:mockito-kotlin:2.1.0"
testImplementation 'com.nhaarman.mockitokotlin2:mockito-kotlin:2.1.0'
androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
exclude group: 'com.android.support', module: 'support-annotations'
})
androidTestImplementation('android.arch.persistence.room:testing:1.1.1')
androidTestImplementation "androidx.test.ext:junit:1.1.0"
testImplementation "androidx.test.ext:junit:1.1.0"
androidTestImplementation 'android.arch.persistence.room:testing:1.1.1'
testImplementation 'androidx.test.ext:junit:1.1.0'
debugImplementation 'im.dino:dbinspector:3.4.1@aar'
implementation 'io.reactivex.rxjava2:rxjava:2.2.6'
implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'

View File

@ -10,7 +10,7 @@ import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
const val TEST_DB = "mirgation_test"
const val TEST_DB = "migration_test"
@RunWith(AndroidJUnit4::class)
class MigrationsTest {

View File

@ -182,7 +182,7 @@ class TimelineDAOTest {
return Triple(status, author, reblogAuthor)
}
fun createPlaceholder(serverId: String, timelineUserId: Long): TimelineStatusEntity {
private fun createPlaceholder(serverId: String, timelineUserId: Long): TimelineStatusEntity {
return TimelineStatusEntity(
serverId = serverId,
url = null,

View File

@ -135,7 +135,7 @@ public class TimelineFragment extends SFragment implements
@Inject
public EventHub eventHub;
@Inject
public TimelineRepository timelineRepo;
TimelineRepository timelineRepo;
@Inject
public AccountManager accountManager;
@ -1102,9 +1102,10 @@ public class TimelineFragment extends SFragment implements
Either<Placeholder, Status> lastOfNew = newStatuses.get(newStatuses.size() - 1);
int index = statuses.indexOf(lastOfNew);
for (int i = 0; i < index; i++) {
statuses.remove(0);
if (index >= 0) {
statuses.subList(0, index).clear();
}
int newIndex = newStatuses.indexOf(statuses.get(0));
if (newIndex == -1) {
if (index == -1 && fullFetch) {

View File

@ -76,18 +76,18 @@ class AccountPreferencesFragment : PreferenceFragmentCompat(),
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
addPreferencesFromResource(R.xml.account_preferences)
notificationPreference = findPreference("notificationPreference")
tabPreference = findPreference("tabPreference")
mutedUsersPreference = findPreference("mutedUsersPreference")
blockedUsersPreference = findPreference("blockedUsersPreference")
defaultPostPrivacyPreference = findPreference("defaultPostPrivacy") as ListPreference
defaultMediaSensitivityPreference = findPreference("defaultMediaSensitivity") as SwitchPreference
mediaPreviewEnabledPreference = findPreference("mediaPreviewEnabled") as SwitchPreference
alwaysShowSensitiveMediaPreference = findPreference("alwaysShowSensitiveMedia") as SwitchPreference
homeFiltersPreference = findPreference("homeFilters")
notificationFiltersPreference = findPreference("notificationFilters")
publicFiltersPreference = findPreference("publicFilters")
threadFiltersPreference = findPreference("threadFilters")
notificationPreference = requirePreference("notificationPreference")
tabPreference = requirePreference("tabPreference")
mutedUsersPreference = requirePreference("mutedUsersPreference")
blockedUsersPreference = requirePreference("blockedUsersPreference")
defaultPostPrivacyPreference = requirePreference("defaultPostPrivacy") as ListPreference
defaultMediaSensitivityPreference = requirePreference("defaultMediaSensitivity") as SwitchPreference
mediaPreviewEnabledPreference = requirePreference("mediaPreviewEnabled") as SwitchPreference
alwaysShowSensitiveMediaPreference = requirePreference("alwaysShowSensitiveMedia") as SwitchPreference
homeFiltersPreference = requirePreference("homeFilters")
notificationFiltersPreference = requirePreference("notificationFilters")
publicFiltersPreference = requirePreference("publicFilters")
threadFiltersPreference = requirePreference("threadFilters")
notificationPreference.icon = IconicsDrawable(notificationPreference.context, GoogleMaterial.Icon.gmd_notifications).sizePx(iconSize).color(ThemeUtils.getColor(notificationPreference.context, R.attr.toolbar_icon_tint))
mutedUsersPreference.icon = getTintedIcon(R.drawable.ic_mute_24dp)

View File

@ -42,35 +42,35 @@ class NotificationPreferencesFragment : PreferenceFragmentCompat(), Preference.O
if (activeAccount != null) {
val notificationPref = findPreference("notificationsEnabled") as SwitchPreference
val notificationPref = requirePreference("notificationsEnabled") as SwitchPreference
notificationPref.isChecked = activeAccount.notificationsEnabled
notificationPref.onPreferenceChangeListener = this
val mentionedPref = findPreference("notificationFilterMentions") as SwitchPreference
val mentionedPref = requirePreference("notificationFilterMentions") as SwitchPreference
mentionedPref.isChecked = activeAccount.notificationsMentioned
mentionedPref.onPreferenceChangeListener = this
val followedPref = findPreference("notificationFilterFollows") as SwitchPreference
val followedPref = requirePreference("notificationFilterFollows") as SwitchPreference
followedPref.isChecked = activeAccount.notificationsFollowed
followedPref.onPreferenceChangeListener = this
val boostedPref = findPreference("notificationFilterReblogs") as SwitchPreference
val boostedPref = requirePreference("notificationFilterReblogs") as SwitchPreference
boostedPref.isChecked = activeAccount.notificationsReblogged
boostedPref.onPreferenceChangeListener = this
val favoritedPref = findPreference("notificationFilterFavourites") as SwitchPreference
val favoritedPref = requirePreference("notificationFilterFavourites") as SwitchPreference
favoritedPref.isChecked = activeAccount.notificationsFavorited
favoritedPref.onPreferenceChangeListener = this
val soundPref = findPreference("notificationAlertSound") as SwitchPreference
val soundPref = requirePreference("notificationAlertSound") as SwitchPreference
soundPref.isChecked = activeAccount.notificationSound
soundPref.onPreferenceChangeListener = this
val vibrationPref = findPreference("notificationAlertVibrate") as SwitchPreference
val vibrationPref = requirePreference("notificationAlertVibrate") as SwitchPreference
vibrationPref.isChecked = activeAccount.notificationVibration
vibrationPref.onPreferenceChangeListener = this
val lightPref = findPreference("notificationAlertLight") as SwitchPreference
val lightPref = requirePreference("notificationAlertLight") as SwitchPreference
lightPref.isChecked = activeAccount.notificationLight
lightPref.onPreferenceChangeListener = this
}

View File

@ -25,6 +25,10 @@ import com.keylesspalace.tusky.util.getNonNullString
import com.mikepenz.google_material_typeface_library.GoogleMaterial
import com.mikepenz.iconics.IconicsDrawable
fun PreferenceFragmentCompat.requirePreference(key: String): Preference {
return findPreference(key)!!
}
class PreferencesFragment : PreferenceFragmentCompat() {
private val iconSize by lazy {resources.getDimensionPixelSize(R.dimen.preference_icon_size)}
@ -33,16 +37,16 @@ class PreferencesFragment : PreferenceFragmentCompat() {
addPreferencesFromResource(R.xml.preferences)
val themePreference: Preference = findPreference("appTheme")
val themePreference: Preference = requirePreference("appTheme")
themePreference.icon = IconicsDrawable(themePreference.context, GoogleMaterial.Icon.gmd_palette).sizePx(iconSize).color(ThemeUtils.getColor(themePreference.context, R.attr.toolbar_icon_tint))
val emojiPreference: Preference = findPreference("emojiCompat")
val emojiPreference: Preference = requirePreference("emojiCompat")
emojiPreference.icon = IconicsDrawable(emojiPreference.context, GoogleMaterial.Icon.gmd_sentiment_satisfied).sizePx(iconSize).color(ThemeUtils.getColor(emojiPreference.context, R.attr.toolbar_icon_tint))
val textSizePreference: Preference = findPreference("statusTextSize")
val textSizePreference: Preference = requirePreference("statusTextSize")
textSizePreference.icon = IconicsDrawable(textSizePreference.context, GoogleMaterial.Icon.gmd_format_size).sizePx(iconSize).color(ThemeUtils.getColor(textSizePreference.context, R.attr.toolbar_icon_tint))
val timelineFilterPreferences: Preference = findPreference("timelineFilterPreferences")
val timelineFilterPreferences: Preference = requirePreference("timelineFilterPreferences")
timelineFilterPreferences.setOnPreferenceClickListener {
activity?.let { activity ->
val intent = PreferencesActivity.newIntent(activity, PreferencesActivity.TAB_FILTER_PREFERENCES)
@ -52,7 +56,7 @@ class PreferencesFragment : PreferenceFragmentCompat() {
true
}
val httpProxyPreferences: Preference = findPreference("httpProxyPreferences")
val httpProxyPreferences: Preference = requirePreference("httpProxyPreferences")
httpProxyPreferences.setOnPreferenceClickListener {
activity?.let { activity ->
val intent = PreferencesActivity.newIntent(activity, PreferencesActivity.PROXY_PREFERENCES)
@ -62,7 +66,7 @@ class PreferencesFragment : PreferenceFragmentCompat() {
true
}
val languagePreference: Preference = findPreference("language")
val languagePreference: Preference = requirePreference("language")
languagePreference.icon = IconicsDrawable(languagePreference.context, GoogleMaterial.Icon.gmd_translate).sizePx(iconSize).color(ThemeUtils.getColor(languagePreference.context, R.attr.toolbar_icon_tint))
}
@ -73,7 +77,7 @@ class PreferencesFragment : PreferenceFragmentCompat() {
private fun updateHttpProxySummary() {
val httpProxyPref: Preference = findPreference("httpProxyPreferences")
val httpProxyPref: Preference = requirePreference("httpProxyPreferences")
val sharedPreferences = preferenceManager.sharedPreferences

View File

@ -18,6 +18,7 @@ package com.keylesspalace.tusky.fragment.preference
import android.content.SharedPreferences
import android.os.Bundle
import androidx.preference.EditTextPreference
import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat
import com.keylesspalace.tusky.R
@ -61,7 +62,7 @@ class ProxyPreferencesFragment : PreferenceFragmentCompat(), SharedPreferences.O
private fun updateSummary(key: String) {
when (key) {
"httpProxyServer", "httpProxyPort" -> {
val editTextPreference = findPreference(key) as EditTextPreference
val editTextPreference = requirePreference(key) as EditTextPreference
editTextPreference.summary = editTextPreference.text
}
}

View File

@ -99,7 +99,7 @@ class BottomSheetActivityTest {
}
@RunWith(Parameterized::class)
class UrlMatchingTests(val url: String, val expectedResult: Boolean) {
class UrlMatchingTests(private val url: String, private val expectedResult: Boolean) {
companion object {
@Parameterized.Parameters(name = "match_{0}")
@JvmStatic

View File

@ -38,7 +38,7 @@ import org.mockito.Mockito
import org.mockito.Mockito.`when`
import org.mockito.Mockito.mock
import org.robolectric.Robolectric
import org.robolectric.RobolectricTestRunner
import androidx.test.ext.junit.runners.AndroidJUnit4
import org.robolectric.annotation.Config
import org.robolectric.fakes.RoboMenuItem
import retrofit2.Call
@ -51,15 +51,15 @@ import retrofit2.Response
*/
@Config(application = FakeTuskyApplication::class)
@RunWith(RobolectricTestRunner::class)
@RunWith(AndroidJUnit4::class)
class ComposeActivityTest {
lateinit var activity: ComposeActivity
lateinit var accountManagerMock: AccountManager
lateinit var apiMock: MastodonApi
lateinit var themeUtilsMock: ThemeUtils
private lateinit var activity: ComposeActivity
private lateinit var accountManagerMock: AccountManager
private lateinit var apiMock: MastodonApi
private lateinit var themeUtilsMock: ThemeUtils
val account = AccountEntity(
private val account = AccountEntity(
id = 1,
domain = "example.token",
accessToken = "token",
@ -259,7 +259,7 @@ class ComposeActivityTest {
"Example instance for testing",
"admin@example.token",
"2.6.3",
HashMap<String, String>(),
HashMap(),
null,
null,
listOf("en"),

View File

@ -6,7 +6,7 @@ package com.keylesspalace.tusky
class FakeTuskyApplication : TuskyApplication() {
lateinit var locator: ServiceLocator
private lateinit var locator: ServiceLocator
override fun initSecurityProvider() {
// No-op

View File

@ -105,7 +105,7 @@ class SpanUtilsTest {
ArrayList<T>()
} else {
spans.filter { it.start >= start && it.end <= end && type.isAssignableFrom(it.span?.javaClass) }
.map { it -> it.span }
.map { it.span }
.let { ArrayList(it) }
}
return matching.toArray() as Array<T>

View File

@ -39,23 +39,23 @@ class TimelineRepositoryTest {
lateinit var mastodonApi: MastodonApi
@Mock
lateinit var accountManager: AccountManager
private lateinit var accountManager: AccountManager
lateinit var gson: Gson
private lateinit var gson: Gson
lateinit var subject: TimelineRepository
private lateinit var subject: TimelineRepository
lateinit var testScheduler: TestScheduler
private lateinit var testScheduler: TestScheduler
val limit = 30
val account = AccountEntity(
private val limit = 30
private val account = AccountEntity(
id = 2,
accessToken = "token",
domain = "domain.com",
isActive = true
)
val htmlConverter = object : HtmlConverter {
private val htmlConverter = object : HtmlConverter {
override fun fromHtml(html: String): Spanned {
return SpanUtilsTest.FakeSpannable(html)
}

View File

@ -7,7 +7,7 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build.jetifier:jetifier-processor:1.0.0-beta02'
classpath 'com.android.tools.build.jetifier:jetifier-processor:1.0.0-beta04'
classpath 'com.android.tools.build:gradle:3.3.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}

View File

@ -17,3 +17,4 @@ org.gradle.parallel=true
android.enableJetifier=true
android.useAndroidX=true
android.enableUnitTestBinaryResources=true

Binary file not shown.

View File

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.3-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

18
gradlew vendored
View File

@ -1,5 +1,21 @@
#!/usr/bin/env sh
#
# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
##
## Gradle start up script for UN*X
@ -28,7 +44,7 @@ APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m"'
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"

18
gradlew.bat vendored
View File

@ -1,3 +1,19 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem http://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@ -14,7 +30,7 @@ set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m"
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome