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