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:
parent
bbf3286d8e
commit
0db1a23c4f
19 changed files with 99 additions and 61 deletions
|
@ -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) {
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue