Fix lint errors

pull/996/head
Alex Baker 5 years ago
parent 947cb2c83c
commit f3f3b1d8dc

@ -79,12 +79,12 @@ class ColorPalettePicker : InjectingDialogFragment() {
val inflater = LayoutInflater.from(context)
val view = inflater.inflate(R.layout.dialog_icon_picker, null)
ButterKnife.bind(this, view)
palette = arguments!!.getSerializable(EXTRA_PALETTE) as Palette
palette = requireArguments().getSerializable(EXTRA_PALETTE) as Palette
colors = when (palette) {
Palette.COLORS -> colorProvider.getThemeColors()
Palette.ACCENTS -> colorProvider.getAccentColors()
Palette.LAUNCHERS -> ThemeColor.LAUNCHER_COLORS.map { color ->
ThemeColor(context, ContextCompat.getColor(context!!, color))
ThemeColor(context, ContextCompat.getColor(requireContext(), color))
}
Palette.WIDGET -> colorProvider.getWidgetColors()
}
@ -111,7 +111,7 @@ class ColorPalettePicker : InjectingDialogFragment() {
builder.setNegativeButton(android.R.string.cancel, null)
} else {
builder.setPositiveButton(R.string.button_subscribe) { _: DialogInterface?, _: Int ->
context?.startActivity(Intent(context!!, PurchaseActivity::class.java))
context?.startActivity(Intent(requireContext(), PurchaseActivity::class.java))
}
}
return builder.show()

@ -49,7 +49,7 @@ class ColorWheelPicker : InjectingDialogFragment() {
override fun inject(component: DialogFragmentComponent) = component.inject(this)
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
selected = savedInstanceState?.getInt(EXTRA_SELECTED) ?: arguments!!.getInt(EXTRA_SELECTED, 0)
selected = savedInstanceState?.getInt(EXTRA_SELECTED) ?: requireArguments().getInt(EXTRA_SELECTED, 0)
val button = if (inventory.purchasedThemes()) android.R.string.ok else R.string.button_subscribe
val builder = ColorPickerDialogBuilder

@ -124,7 +124,7 @@ class DateTimePicker : InjectingBottomSheetDialogFragment() {
}
}
val timestamp = savedInstanceState?.getLong(EXTRA_SELECTED)
?: arguments!!.getLong(EXTRA_TIMESTAMP)
?: requireArguments().getLong(EXTRA_TIMESTAMP)
selected = if (timestamp > 0) DateTime(timestamp) else null
return binding.root

@ -57,13 +57,13 @@ class ThemePickerDialog : InjectingDialogFragment() {
override fun inject(component: DialogFragmentComponent) = component.inject(this)
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
selected = savedInstanceState?.getInt(EXTRA_SELECTED) ?: arguments!!.getInt(EXTRA_SELECTED)
selected = savedInstanceState?.getInt(EXTRA_SELECTED) ?: requireArguments().getInt(EXTRA_SELECTED)
val widget = arguments?.getBoolean(EXTRA_WIDGET) ?: false
val themes = resources.getStringArray(
if (widget) R.array.widget_themes else R.array.base_theme_names
)
adapter = object : ArrayAdapter<String>(activity!!, R.layout.simple_list_item_single_choice, themes) {
adapter = object : ArrayAdapter<String>(requireActivity(), R.layout.simple_list_item_single_choice, themes) {
override fun getView(position: Int, convertView: View?, parent: ViewGroup): View {
val view = super.getView(position, convertView, parent)
val textColor = if (isAvailable(position)) {
@ -79,7 +79,7 @@ class ThemePickerDialog : InjectingDialogFragment() {
dialog = dialogBuilder.newDialog()
.setTitle(R.string.theme)
.setSingleChoiceItems(adapter, arguments!!.getInt(EXTRA_SELECTED)) { _, which ->
.setSingleChoiceItems(adapter, requireArguments().getInt(EXTRA_SELECTED)) { _, which ->
selected = which
if (available()) {
deliverResult()

@ -48,7 +48,7 @@ abstract class InjectingPreferenceFragment : PreferenceFragmentCompat() {
final override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
setPreferencesFromResource(getPreferenceXml(), rootKey)
tintIcons(preferenceScreen, ContextCompat.getColor(context!!, R.color.icon_tint_with_alpha))
tintIcons(preferenceScreen, ContextCompat.getColor(requireContext(), R.color.icon_tint_with_alpha))
setupPreferences(savedInstanceState)
}
@ -76,7 +76,7 @@ abstract class InjectingPreferenceFragment : PreferenceFragmentCompat() {
protected fun tintColorPreference(resId: Int, tint: Int) {
val pref = findPreference(resId)
pref.icon = DrawableUtil.getWrapped(context!!, R.drawable.color_picker)
pref.icon = DrawableUtil.getWrapped(requireContext(), R.drawable.color_picker)
DrawableUtil.setTint(pref.icon, tint)
}
@ -117,7 +117,7 @@ abstract class InjectingPreferenceFragment : PreferenceFragmentCompat() {
abstract fun setupPreferences(savedInstanceState: Bundle?)
protected fun recreate() {
activity!!.recreate()
requireActivity().recreate()
}
protected fun findPreference(@StringRes prefId: Int): Preference {

@ -100,7 +100,7 @@ class Advanced : InjectingPreferenceFragment() {
if (resultCode == Activity.RESULT_OK) {
val uri = data!!.data!!
if (AndroidUtilities.atLeastLollipop()) {
context!!.contentResolver
requireContext().contentResolver
.takePersistableUriPermission(
uri,
Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION
@ -231,7 +231,7 @@ class Advanced : InjectingPreferenceFragment() {
.newDialog()
.setMessage(R.string.EPr_delete_task_data_warning)
.setPositiveButton(R.string.EPr_delete_task_data) { _, _ ->
context!!.deleteDatabase(database.name)
requireContext().deleteDatabase(database.name)
exitProcess(0)
}
.setNegativeButton(android.R.string.cancel, null)

@ -8,9 +8,7 @@ import android.content.pm.PackageManager
import android.content.res.Configuration
import android.os.Bundle
import android.os.Handler
import android.widget.Toast
import androidx.annotation.StringRes
import androidx.preference.ListPreference
import androidx.preference.Preference
import com.google.common.base.Strings
import com.todoroo.andlib.utility.AndroidUtilities.atLeastLollipop
@ -25,7 +23,6 @@ import org.tasks.dialogs.ColorPalettePicker
import org.tasks.dialogs.ColorPalettePicker.Companion.newColorPalette
import org.tasks.dialogs.ColorPickerAdapter
import org.tasks.dialogs.ColorWheelPicker
import org.tasks.dialogs.MyTimePickerDialog.newTimePicker
import org.tasks.dialogs.ThemePickerDialog
import org.tasks.dialogs.ThemePickerDialog.Companion.newThemePickerDialog
import org.tasks.gtasks.PlayServices
@ -41,14 +38,10 @@ import org.tasks.themes.ThemeBase.DEFAULT_BASE_THEME
import org.tasks.themes.ThemeBase.EXTRA_THEME_OVERRIDE
import org.tasks.themes.ThemeColor
import org.tasks.themes.ThemeColor.getLauncherColor
import org.tasks.time.DateTime
import org.tasks.ui.ChipProvider
import org.tasks.ui.NavigationDrawerFragment.REQUEST_PURCHASE
import org.tasks.ui.SingleCheckedArrayAdapter
import org.tasks.ui.TimePreference
import org.tasks.ui.Toaster
import org.threeten.bp.DayOfWeek
import org.threeten.bp.format.TextStyle
import javax.inject.Inject
private const val REQUEST_THEME_PICKER = 10001
@ -177,7 +170,7 @@ class LookAndFeel : InjectingPreferenceFragment() {
private fun setupLocationPickers() {
val choices =
listOf(getString(R.string.map_provider_mapbox), getString(R.string.map_provider_google))
val singleCheckedArrayAdapter = SingleCheckedArrayAdapter(context!!, choices, themeAccent)
val singleCheckedArrayAdapter = SingleCheckedArrayAdapter(requireContext(), choices, themeAccent)
val mapProviderPreference = findPreference(R.string.p_map_provider)
mapProviderPreference.onPreferenceClickListener = Preference.OnPreferenceClickListener {
dialogBuilder
@ -351,7 +344,7 @@ class LookAndFeel : InjectingPreferenceFragment() {
val packageManager: PackageManager? = context?.packageManager
for (i in ThemeColor.LAUNCHERS.indices) {
val componentName = ComponentName(
context!!,
requireContext(),
"com.todoroo.astrid.activity.TaskListActivity" + ThemeColor.LAUNCHERS[i]
)
packageManager?.setComponentEnabledSetting(

@ -144,7 +144,7 @@ class Notifications : InjectingPreferenceFragment() {
private fun checkBatteryOptimizations() {
if (atLeastMarshmallow()) {
val powerManager = context!!.getSystemService(POWER_SERVICE) as PowerManager
val powerManager = requireContext().getSystemService(POWER_SERVICE) as PowerManager
findPreference(R.string.disable_battery_optimizations).isVisible =
!powerManager.isIgnoringBatteryOptimizations(getString(R.string.app_package))
}

@ -54,7 +54,7 @@ class ScrollableWidget : InjectingPreferenceFragment() {
override fun getPreferenceXml() = R.xml.preferences_widget
override fun setupPreferences(savedInstanceState: Bundle?) {
appWidgetId = arguments!!.getInt(EXTRA_WIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID)
appWidgetId = requireArguments().getInt(EXTRA_WIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID)
widgetPreferences = WidgetPreferences(context, preferences, appWidgetId)
val row = setupSlider(R.string.p_widget_opacity, 100)

@ -72,7 +72,7 @@ class TaskerListNotification : InjectingPreferenceFragment() {
} else if (requestCode == REQUEST_SUBSCRIPTION) {
if (!inventory.purchasedTasker()) {
cancelled = true
activity!!.finish()
requireActivity().finish()
}
} else {
super.onActivityResult(requestCode, resultCode, data)

Loading…
Cancel
Save