mirror of
https://github.com/tuskyapp/Tusky
synced 2025-01-29 14:09:25 +01:00
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.
This commit is contained in:
parent
cb3331b535
commit
4a774a4fe3
@ -15,6 +15,7 @@
|
||||
|
||||
package com.keylesspalace.tusky.fragment.preference
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.os.Build
|
||||
@ -57,19 +58,19 @@ class AccountPreferencesFragment : PreferenceFragmentCompat(),
|
||||
@Inject
|
||||
lateinit var eventHub: EventHub
|
||||
|
||||
private lateinit var notificationPreference: Preference
|
||||
private lateinit var tabPreference: Preference
|
||||
private lateinit var mutedUsersPreference: Preference
|
||||
private lateinit var blockedUsersPreference: Preference
|
||||
private var notificationPreference: Preference? = null
|
||||
private var tabPreference: Preference? = null
|
||||
private var mutedUsersPreference: Preference? = null
|
||||
private var blockedUsersPreference: Preference? = null
|
||||
|
||||
private lateinit var defaultPostPrivacyPreference: ListPreference
|
||||
private lateinit var defaultMediaSensitivityPreference: SwitchPreference
|
||||
private lateinit var alwaysShowSensitiveMediaPreference: SwitchPreference
|
||||
private lateinit var mediaPreviewEnabledPreference: SwitchPreference
|
||||
private lateinit var homeFiltersPreference: Preference
|
||||
private lateinit var notificationFiltersPreference: Preference
|
||||
private lateinit var publicFiltersPreference: Preference
|
||||
private lateinit var threadFiltersPreference: Preference
|
||||
private var defaultPostPrivacyPreference: ListPreference? = null
|
||||
private var defaultMediaSensitivityPreference: SwitchPreference? = null
|
||||
private var alwaysShowSensitiveMediaPreference: SwitchPreference? = null
|
||||
private var mediaPreviewEnabledPreference: SwitchPreference? = null
|
||||
private var homeFiltersPreference: Preference? = null
|
||||
private var notificationFiltersPreference: Preference? = null
|
||||
private var publicFiltersPreference: Preference? = null
|
||||
private var threadFiltersPreference: Preference? = null
|
||||
|
||||
private val iconSize by lazy {resources.getDimensionPixelSize(R.dimen.preference_icon_size)}
|
||||
|
||||
@ -80,32 +81,32 @@ class AccountPreferencesFragment : PreferenceFragmentCompat(),
|
||||
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
|
||||
defaultPostPrivacyPreference = findPreference("defaultPostPrivacy")
|
||||
defaultMediaSensitivityPreference = findPreference("defaultMediaSensitivity")
|
||||
mediaPreviewEnabledPreference = findPreference("mediaPreviewEnabled")
|
||||
alwaysShowSensitiveMediaPreference = findPreference("alwaysShowSensitiveMedia")
|
||||
homeFiltersPreference = findPreference("homeFilters")
|
||||
notificationFiltersPreference = findPreference("notificationFilters")
|
||||
publicFiltersPreference = findPreference("publicFilters")
|
||||
threadFiltersPreference = findPreference("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)
|
||||
blockedUsersPreference.icon = IconicsDrawable(blockedUsersPreference.context, GoogleMaterial.Icon.gmd_block).sizePx(iconSize).color(ThemeUtils.getColor(blockedUsersPreference.context, R.attr.toolbar_icon_tint))
|
||||
notificationPreference?.icon = IconicsDrawable(notificationPreference?.context, GoogleMaterial.Icon.gmd_notifications).sizePx(iconSize).color(ThemeUtils.getColor(notificationPreference?.context as Context, R.attr.toolbar_icon_tint))
|
||||
mutedUsersPreference?.icon = getTintedIcon(R.drawable.ic_mute_24dp)
|
||||
blockedUsersPreference?.icon = IconicsDrawable(blockedUsersPreference?.context, GoogleMaterial.Icon.gmd_block).sizePx(iconSize).color(ThemeUtils.getColor(blockedUsersPreference?.context as Context, R.attr.toolbar_icon_tint))
|
||||
|
||||
notificationPreference.onPreferenceClickListener = this
|
||||
tabPreference.onPreferenceClickListener = this
|
||||
mutedUsersPreference.onPreferenceClickListener = this
|
||||
blockedUsersPreference.onPreferenceClickListener = this
|
||||
homeFiltersPreference.onPreferenceClickListener = this
|
||||
notificationFiltersPreference.onPreferenceClickListener = this
|
||||
publicFiltersPreference.onPreferenceClickListener = this
|
||||
threadFiltersPreference.onPreferenceClickListener = this
|
||||
notificationPreference?.onPreferenceClickListener = this
|
||||
tabPreference?.onPreferenceClickListener = this
|
||||
mutedUsersPreference?.onPreferenceClickListener = this
|
||||
blockedUsersPreference?.onPreferenceClickListener = this
|
||||
homeFiltersPreference?.onPreferenceClickListener = this
|
||||
notificationFiltersPreference?.onPreferenceClickListener = this
|
||||
publicFiltersPreference?.onPreferenceClickListener = this
|
||||
threadFiltersPreference?.onPreferenceClickListener = this
|
||||
|
||||
defaultPostPrivacyPreference.onPreferenceChangeListener = this
|
||||
defaultMediaSensitivityPreference.onPreferenceChangeListener = this
|
||||
mediaPreviewEnabledPreference.onPreferenceChangeListener = this
|
||||
alwaysShowSensitiveMediaPreference.onPreferenceChangeListener = this
|
||||
defaultPostPrivacyPreference?.onPreferenceChangeListener = this
|
||||
defaultMediaSensitivityPreference?.onPreferenceChangeListener = this
|
||||
mediaPreviewEnabledPreference?.onPreferenceChangeListener = this
|
||||
alwaysShowSensitiveMediaPreference?.onPreferenceChangeListener = this
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
@ -113,14 +114,14 @@ class AccountPreferencesFragment : PreferenceFragmentCompat(),
|
||||
|
||||
accountManager.activeAccount?.let {
|
||||
|
||||
defaultPostPrivacyPreference.value = it.defaultPostPrivacy.serverString()
|
||||
defaultPostPrivacyPreference.icon = getIconForVisibility(it.defaultPostPrivacy)
|
||||
defaultPostPrivacyPreference?.value = it.defaultPostPrivacy.serverString()
|
||||
defaultPostPrivacyPreference?.icon = getIconForVisibility(it.defaultPostPrivacy)
|
||||
|
||||
defaultMediaSensitivityPreference.isChecked = it.defaultMediaSensitivity
|
||||
defaultMediaSensitivityPreference.icon = getIconForSensitivity(it.defaultMediaSensitivity)
|
||||
defaultMediaSensitivityPreference?.isChecked = it.defaultMediaSensitivity
|
||||
defaultMediaSensitivityPreference?.icon = getIconForSensitivity(it.defaultMediaSensitivity)
|
||||
|
||||
mediaPreviewEnabledPreference.isChecked = it.mediaPreviewEnabled
|
||||
alwaysShowSensitiveMediaPreference.isChecked = it.alwaysShowSensitiveMedia
|
||||
mediaPreviewEnabledPreference?.isChecked = it.mediaPreviewEnabled
|
||||
alwaysShowSensitiveMediaPreference?.isChecked = it.alwaysShowSensitiveMedia
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -42,37 +42,37 @@ class NotificationPreferencesFragment : PreferenceFragmentCompat(), Preference.O
|
||||
|
||||
if (activeAccount != null) {
|
||||
|
||||
val notificationPref = findPreference("notificationsEnabled") as SwitchPreference
|
||||
notificationPref.isChecked = activeAccount.notificationsEnabled
|
||||
notificationPref.onPreferenceChangeListener = this
|
||||
val notificationPref: SwitchPreference? = findPreference("notificationsEnabled")
|
||||
notificationPref?.isChecked = activeAccount.notificationsEnabled
|
||||
notificationPref?.onPreferenceChangeListener = this
|
||||
|
||||
val mentionedPref = findPreference("notificationFilterMentions") as SwitchPreference
|
||||
mentionedPref.isChecked = activeAccount.notificationsMentioned
|
||||
mentionedPref.onPreferenceChangeListener = this
|
||||
val mentionedPref: SwitchPreference? = findPreference("notificationFilterMentions")
|
||||
mentionedPref?.isChecked = activeAccount.notificationsMentioned
|
||||
mentionedPref?.onPreferenceChangeListener = this
|
||||
|
||||
val followedPref = findPreference("notificationFilterFollows") as SwitchPreference
|
||||
followedPref.isChecked = activeAccount.notificationsFollowed
|
||||
followedPref.onPreferenceChangeListener = this
|
||||
val followedPref: SwitchPreference? = findPreference("notificationFilterFollows")
|
||||
followedPref?.isChecked = activeAccount.notificationsFollowed
|
||||
followedPref?.onPreferenceChangeListener = this
|
||||
|
||||
val boostedPref = findPreference("notificationFilterReblogs") as SwitchPreference
|
||||
boostedPref.isChecked = activeAccount.notificationsReblogged
|
||||
boostedPref.onPreferenceChangeListener = this
|
||||
val boostedPref: SwitchPreference? = findPreference("notificationFilterReblogs")
|
||||
boostedPref?.isChecked = activeAccount.notificationsReblogged
|
||||
boostedPref?.onPreferenceChangeListener = this
|
||||
|
||||
val favoritedPref = findPreference("notificationFilterFavourites") as SwitchPreference
|
||||
favoritedPref.isChecked = activeAccount.notificationsFavorited
|
||||
favoritedPref.onPreferenceChangeListener = this
|
||||
val favoritedPref: SwitchPreference? = findPreference("notificationFilterFavourites")
|
||||
favoritedPref?.isChecked = activeAccount.notificationsFavorited
|
||||
favoritedPref?.onPreferenceChangeListener = this
|
||||
|
||||
val soundPref = findPreference("notificationAlertSound") as SwitchPreference
|
||||
soundPref.isChecked = activeAccount.notificationSound
|
||||
soundPref.onPreferenceChangeListener = this
|
||||
val soundPref: SwitchPreference? = findPreference("notificationAlertSound")
|
||||
soundPref?.isChecked = activeAccount.notificationSound
|
||||
soundPref?.onPreferenceChangeListener = this
|
||||
|
||||
val vibrationPref = findPreference("notificationAlertVibrate") as SwitchPreference
|
||||
vibrationPref.isChecked = activeAccount.notificationVibration
|
||||
vibrationPref.onPreferenceChangeListener = this
|
||||
val vibrationPref: SwitchPreference? = findPreference("notificationAlertVibrate")
|
||||
vibrationPref?.isChecked = activeAccount.notificationVibration
|
||||
vibrationPref?.onPreferenceChangeListener = this
|
||||
|
||||
val lightPref = findPreference("notificationAlertLight") as SwitchPreference
|
||||
lightPref.isChecked = activeAccount.notificationLight
|
||||
lightPref.onPreferenceChangeListener = this
|
||||
val lightPref: SwitchPreference? = findPreference("notificationAlertLight")
|
||||
lightPref?.isChecked = activeAccount.notificationLight
|
||||
lightPref?.onPreferenceChangeListener = this
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
package com.keylesspalace.tusky.fragment.preference
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import androidx.preference.Preference
|
||||
import androidx.preference.PreferenceFragmentCompat
|
||||
@ -33,17 +34,17 @@ class PreferencesFragment : PreferenceFragmentCompat() {
|
||||
|
||||
addPreferencesFromResource(R.xml.preferences)
|
||||
|
||||
val themePreference: Preference = findPreference("appTheme")
|
||||
themePreference.icon = IconicsDrawable(themePreference.context, GoogleMaterial.Icon.gmd_palette).sizePx(iconSize).color(ThemeUtils.getColor(themePreference.context, R.attr.toolbar_icon_tint))
|
||||
val themePreference: Preference? = findPreference("appTheme")
|
||||
themePreference?.icon = IconicsDrawable(themePreference?.context, GoogleMaterial.Icon.gmd_palette).sizePx(iconSize).color(ThemeUtils.getColor(themePreference?.context as Context, R.attr.toolbar_icon_tint))
|
||||
|
||||
val emojiPreference: Preference = findPreference("emojiCompat")
|
||||
emojiPreference.icon = IconicsDrawable(emojiPreference.context, GoogleMaterial.Icon.gmd_sentiment_satisfied).sizePx(iconSize).color(ThemeUtils.getColor(emojiPreference.context, R.attr.toolbar_icon_tint))
|
||||
val emojiPreference: Preference? = findPreference("emojiCompat")
|
||||
emojiPreference?.icon = IconicsDrawable(emojiPreference?.context, GoogleMaterial.Icon.gmd_sentiment_satisfied).sizePx(iconSize).color(ThemeUtils.getColor(emojiPreference?.context as Context, R.attr.toolbar_icon_tint))
|
||||
|
||||
val textSizePreference: Preference = findPreference("statusTextSize")
|
||||
textSizePreference.icon = IconicsDrawable(textSizePreference.context, GoogleMaterial.Icon.gmd_format_size).sizePx(iconSize).color(ThemeUtils.getColor(textSizePreference.context, R.attr.toolbar_icon_tint))
|
||||
val textSizePreference: Preference? = findPreference("statusTextSize")
|
||||
textSizePreference?.icon = IconicsDrawable(textSizePreference?.context, GoogleMaterial.Icon.gmd_format_size).sizePx(iconSize).color(ThemeUtils.getColor(textSizePreference?.context as Context, R.attr.toolbar_icon_tint))
|
||||
|
||||
val timelineFilterPreferences: Preference = findPreference("timelineFilterPreferences")
|
||||
timelineFilterPreferences.setOnPreferenceClickListener {
|
||||
val timelineFilterPreferences: Preference? = findPreference("timelineFilterPreferences")
|
||||
timelineFilterPreferences?.setOnPreferenceClickListener {
|
||||
activity?.let { activity ->
|
||||
val intent = PreferencesActivity.newIntent(activity, PreferencesActivity.TAB_FILTER_PREFERENCES)
|
||||
activity.startActivity(intent)
|
||||
@ -52,8 +53,8 @@ class PreferencesFragment : PreferenceFragmentCompat() {
|
||||
true
|
||||
}
|
||||
|
||||
val httpProxyPreferences: Preference = findPreference("httpProxyPreferences")
|
||||
httpProxyPreferences.setOnPreferenceClickListener {
|
||||
val httpProxyPreferences: Preference? = findPreference("httpProxyPreferences")
|
||||
httpProxyPreferences?.setOnPreferenceClickListener {
|
||||
activity?.let { activity ->
|
||||
val intent = PreferencesActivity.newIntent(activity, PreferencesActivity.PROXY_PREFERENCES)
|
||||
activity.startActivity(intent)
|
||||
@ -62,8 +63,8 @@ class PreferencesFragment : PreferenceFragmentCompat() {
|
||||
true
|
||||
}
|
||||
|
||||
val languagePreference: Preference = findPreference("language")
|
||||
languagePreference.icon = IconicsDrawable(languagePreference.context, GoogleMaterial.Icon.gmd_translate).sizePx(iconSize).color(ThemeUtils.getColor(languagePreference.context, R.attr.toolbar_icon_tint))
|
||||
val languagePreference: Preference? = findPreference("language")
|
||||
languagePreference?.icon = IconicsDrawable(languagePreference?.context, GoogleMaterial.Icon.gmd_translate).sizePx(iconSize).color(ThemeUtils.getColor(languagePreference?.context as Context, R.attr.toolbar_icon_tint))
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
@ -73,7 +74,7 @@ class PreferencesFragment : PreferenceFragmentCompat() {
|
||||
|
||||
private fun updateHttpProxySummary() {
|
||||
|
||||
val httpProxyPref: Preference = findPreference("httpProxyPreferences")
|
||||
val httpProxyPref: Preference? = findPreference("httpProxyPreferences")
|
||||
|
||||
val sharedPreferences = preferenceManager.sharedPreferences
|
||||
|
||||
@ -85,14 +86,14 @@ class PreferencesFragment : PreferenceFragmentCompat() {
|
||||
val httpPort = sharedPreferences.getNonNullString("httpProxyPort", "-1").toInt()
|
||||
|
||||
if (httpProxyEnabled && httpServer.isNotBlank() && httpPort > 0 && httpPort < 65535) {
|
||||
httpProxyPref.summary = "$httpServer:$httpPort"
|
||||
httpProxyPref?.summary = "$httpServer:$httpPort"
|
||||
return
|
||||
}
|
||||
} catch (e: NumberFormatException) {
|
||||
// user has entered wrong port, fall back to empty summary
|
||||
}
|
||||
|
||||
httpProxyPref.summary = ""
|
||||
httpProxyPref?.summary = ""
|
||||
|
||||
}
|
||||
|
||||
|
@ -61,8 +61,8 @@ class ProxyPreferencesFragment : PreferenceFragmentCompat(), SharedPreferences.O
|
||||
private fun updateSummary(key: String) {
|
||||
when (key) {
|
||||
"httpProxyServer", "httpProxyPort" -> {
|
||||
val editTextPreference = findPreference(key) as EditTextPreference
|
||||
editTextPreference.summary = editTextPreference.text
|
||||
val editTextPreference: EditTextPreference? = findPreference(key)
|
||||
editTextPreference?.summary = editTextPreference?.text
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user