From c6fdc0e8021f4e7cfdb8e3c1c1078551eda7bcae Mon Sep 17 00:00:00 2001 From: Christian Adams Date: Sun, 24 Nov 2024 19:19:29 +0100 Subject: [PATCH] Fixed lint error and warnings. --- .../view/ExpandableTodoTaskAdapter.kt | 12 +++++------- .../privacyfriendlytodolist/view/MainActivity.kt | 6 +++--- .../privacyfriendlytodolist/view/RecyclerActivity.kt | 2 +- .../secuso/privacyfriendlytodolist/view/Settings.kt | 4 +++- .../view/widget/TodoListWidget.kt | 5 +++-- 5 files changed, 15 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/org/secuso/privacyfriendlytodolist/view/ExpandableTodoTaskAdapter.kt b/app/src/main/java/org/secuso/privacyfriendlytodolist/view/ExpandableTodoTaskAdapter.kt index 626d3db..5aa2dee 100644 --- a/app/src/main/java/org/secuso/privacyfriendlytodolist/view/ExpandableTodoTaskAdapter.kt +++ b/app/src/main/java/org/secuso/privacyfriendlytodolist/view/ExpandableTodoTaskAdapter.kt @@ -37,8 +37,6 @@ import org.secuso.privacyfriendlytodolist.R import org.secuso.privacyfriendlytodolist.model.ModelServices import org.secuso.privacyfriendlytodolist.model.TodoSubtask import org.secuso.privacyfriendlytodolist.model.TodoTask -import org.secuso.privacyfriendlytodolist.service.JobManager -import org.secuso.privacyfriendlytodolist.util.AlarmMgr import org.secuso.privacyfriendlytodolist.util.Helper import org.secuso.privacyfriendlytodolist.util.LogTag import org.secuso.privacyfriendlytodolist.util.PreferenceMgr @@ -418,7 +416,7 @@ class ExpandableTodoTaskAdapter(private val context: Context, private val model: actualConvertView.findViewById(R.id.pb_task_progress) ) tvh.done.tag = currentTask.getId() - tvh.done.setChecked(currentTask.isDone()) + tvh.done.isChecked = currentTask.isDone() tvh.done.jumpDrawablesToCurrentState() actualConvertView.tag = tvh } @@ -469,14 +467,14 @@ class ExpandableTodoTaskAdapter(private val context: Context, private val model: } tvh.deadlineColorBar.setBackgroundColor(Helper.getDeadlineColor(context, currentTask.getDeadlineColor(PreferenceMgr.getDefaultReminderTimeSpan(context)))) - tvh.done.setChecked(currentTask.isDone()) + tvh.done.isChecked = currentTask.isDone() tvh.done.jumpDrawablesToCurrentState() tvh.done.setOnCheckedChangeListener { buttonView, isChecked -> if (buttonView.isPressed) { val snackBar = Snackbar.make(buttonView, R.string.snack_check, Snackbar.LENGTH_LONG) snackBar.setAction(R.string.snack_undo) { val inverted = !isChecked - buttonView.setChecked(inverted) + buttonView.isChecked = inverted currentTask.setDone(buttonView.isChecked) currentTask.setAllSubtasksDone(inverted) currentTask.getProgress(hasAutoProgress()) @@ -604,7 +602,7 @@ class ExpandableTodoTaskAdapter(private val context: Context, private val model: } svh.deadlineColorBar.setBackgroundColor(Helper.getDeadlineColor(context, currentTask.getDeadlineColor(PreferenceMgr.getDefaultReminderTimeSpan(context)))) - svh.done.setChecked(currentSubtask.isDone()) + svh.done.isChecked = currentSubtask.isDone() svh.done.jumpDrawablesToCurrentState() svh.done.setOnCheckedChangeListener { buttonView, isChecked -> if (buttonView.isPressed) { @@ -808,7 +806,7 @@ class ExpandableTodoTaskAdapter(private val context: Context, private val model: subtasksMetaData.add(SubtaskMetaData()) } while (expectedSize < subtasksMetaData.size) { - subtasksMetaData.removeLast() + subtasksMetaData.removeAt(subtasksMetaData.size - 1) } } diff --git a/app/src/main/java/org/secuso/privacyfriendlytodolist/view/MainActivity.kt b/app/src/main/java/org/secuso/privacyfriendlytodolist/view/MainActivity.kt index c287e29..e0fd546 100644 --- a/app/src/main/java/org/secuso/privacyfriendlytodolist/view/MainActivity.kt +++ b/app/src/main/java/org/secuso/privacyfriendlytodolist/view/MainActivity.kt @@ -754,7 +754,7 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte openContextMenu(exLv) } exLv!!.setAdapter(expandableTodoTaskAdapter) - exLv!!.setEmptyView(emptyView) + exLv!!.emptyView = emptyView } override fun onCreateContextMenu(menu: ContextMenu, v: View, menuInfo: ContextMenuInfo?) { @@ -1086,10 +1086,10 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte val anim: Animation = AlphaAnimation(0.0f, 1.0f) if (numberOfLists == 0 && numberOfTasksNotInRecycleBin == 0) { initialAlert!!.visibility = View.VISIBLE - anim.setDuration(1500) + anim.duration = 1500 anim.startOffset = 20 anim.repeatMode = Animation.REVERSE - anim.setRepeatCount(Animation.INFINITE) + anim.repeatCount = Animation.INFINITE initialAlert!!.startAnimation(anim) } else /* if numberOfLists != 0 || numberOfTasksNotInRecycleBin != 0 */ { initialAlert!!.visibility = View.GONE diff --git a/app/src/main/java/org/secuso/privacyfriendlytodolist/view/RecyclerActivity.kt b/app/src/main/java/org/secuso/privacyfriendlytodolist/view/RecyclerActivity.kt index 645eb8c..bcef682 100644 --- a/app/src/main/java/org/secuso/privacyfriendlytodolist/view/RecyclerActivity.kt +++ b/app/src/main/java/org/secuso/privacyfriendlytodolist/view/RecyclerActivity.kt @@ -139,7 +139,7 @@ class RecyclerActivity : AppCompatActivity() { openContextMenu(exLv) } exLv.setAdapter(expandableTodoTaskAdapter) - exLv.setEmptyView(tv) + exLv.emptyView = tv } } diff --git a/app/src/main/java/org/secuso/privacyfriendlytodolist/view/Settings.kt b/app/src/main/java/org/secuso/privacyfriendlytodolist/view/Settings.kt index 27f880e..bc599a6 100644 --- a/app/src/main/java/org/secuso/privacyfriendlytodolist/view/Settings.kt +++ b/app/src/main/java/org/secuso/privacyfriendlytodolist/view/Settings.kt @@ -54,7 +54,9 @@ class Settings : AppCompatActivity() { //upArrow.setColorFilter(ContextCompat.getColor(this, R.color.white), PorterDuff.Mode.SRC_ATOP); //getSupportActionBar().setHomeAsUpIndicator(upArrow); } - supportFragmentManager.beginTransaction().replace(R.id.fragment_container, MyPreferenceFragment()).commit() + val transaction = supportFragmentManager.beginTransaction() + transaction.replace(R.id.fragment_container, MyPreferenceFragment()) + transaction.commit() } override fun onOptionsItemSelected(item: MenuItem): Boolean { diff --git a/app/src/main/java/org/secuso/privacyfriendlytodolist/view/widget/TodoListWidget.kt b/app/src/main/java/org/secuso/privacyfriendlytodolist/view/widget/TodoListWidget.kt index 249c70c..97a1f48 100644 --- a/app/src/main/java/org/secuso/privacyfriendlytodolist/view/widget/TodoListWidget.kt +++ b/app/src/main/java/org/secuso/privacyfriendlytodolist/view/widget/TodoListWidget.kt @@ -64,7 +64,7 @@ class TodoListWidget : AppWidgetProvider(), ModelObserver { override fun onTodoDataChanged(context: Context, changedLists: Int, changedTasks: Int, changedSubtasks: Int) { val appWidgetManager = AppWidgetManager.getInstance(context) - val thisComponentName = ComponentName(context.packageName, TodoListWidget::class.java.getName()) + val thisComponentName = ComponentName(context.packageName, TodoListWidget::class.java.name) val appWidgetIds = appWidgetManager.getAppWidgetIds(thisComponentName) for (appWidgetId in appWidgetIds) { appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetId, R.id.listview_widget) @@ -73,7 +73,7 @@ class TodoListWidget : AppWidgetProvider(), ModelObserver { private fun initialUpdate(context: Context) { val appWidgetManager = AppWidgetManager.getInstance(context) - val thisComponentName = ComponentName(context.packageName, TodoListWidget::class.java.getName()) + val thisComponentName = ComponentName(context.packageName, TodoListWidget::class.java.name) val appWidgetIds = appWidgetManager.getAppWidgetIds(thisComponentName) onUpdate(context, appWidgetManager, appWidgetIds) } @@ -86,6 +86,7 @@ class TodoListWidget : AppWidgetProvider(), ModelObserver { } } + @Suppress("UnnecessaryVariable") private fun update(context: Context, appWidgetManager: AppWidgetManager, appWidgetId: Int, title: String? = null) { val view = RemoteViews(context.packageName, R.layout.todo_list_widget)