Android Widget only supports top level of checklist dailies - CSCI-462-01-2021/Fork-Bomb GitHub Wiki

Android Widget only supports top level of checklist dailies - #652 (habitica-android)

Status:

  • Collin requested to be assigned topic 02/11
  • The first solution was tested and proposed, but a second solution was preferred instead
  • Steady progress has been made on the second solution, but it is not yet ready for a pull request.

This issue is specific to Android Widgets.

  • General Notes:

    • The problem appears to be that, while the app fills out the rows of the widget with the tasks, there is no catch to handle tasks with sub-tasks.
    • The method (getViewAt()) where the rows were populated was found in the TaskListFactory.kt
    • We have not been able to locate where getViewAt() was called and thus unable to call it again for sub-tasks
      • This approach does not seem feasible at this time
    • While we were able to add the catch for tasks with sub-tasks, we have been unsuccessful in opening the app within the if-statement due to the type of intention available in the method.
    • (3-18) A new approach is being tried in which the action is assigned to the intent in the task list factory rather than the task list provider. This allows us to assign a different action to checklist tasks. This approach is making progress and appears to be working so far.
      • This approach has worked and allowed us to open the app when a user selects a checklist task rather than check off the task.
      • We are continuing to refine the approach in hopes of opening the app to the task list rather than the main screen (the habit list)
    • (3-19) An update to the Habitica issue was made filling them in on our progress (finished solution) and our options for further steps.
    • (3-22) Sara Olson responded saying they will consider our workaround. We will add finishing touches and submit a pull request this week. Collin may research this further if they want more work done.
  • File Notes:

    • src\main\java\com\habitrpg\android\habitica\widget\TaskListFactory.kt
    • src\main\java\com\habitrpg\android\habitica\widget\TaskListWidgetProvider.kt
    • android\appwidget\AppWidgetProvider.java
    • src\main\java\com\habitrpg\android\habitica\widget\DailiesListFactory.kt
    • src\main\java\com\habitrpg\android\habitica\widget\DailiesWidgetProvider.kt
    • src\main\java\com\habitrpg\android\habitica\widget\DailiesWidgetService.kt
    • src\main\java\com\habitrpg\android\habitica\widget\TaskListFactory.kt (this one seems like the best launching point)
      90 remoteView.setOnClickFillInIntent(R.id.widget_list_row, fillInIntent)
      • android\widget\RemoteViews.java
    • src\main\java\com\habitrpg\android\habitica\widget\BaseWidgetProvider.kt
  • Original (Rejected) Solution:

    • Checklist tasks are marked in the widget with an additional icon. When they are selected, rather than checking it off along with its subtasks, the app is opened to allow the user to select which subtasks were completed.
    • The views for both the To Do's and Dailies widget views were altered to add space for an icon to indicate a checklist item
    • TaskListFactory.kt was altered to assign the usual action to regular tasks, and a checklist action to checklist tasks. In the case of checklist tasks, it also sets the new icon the view to be visible.
    • TaskListWidgetProvider.kt was altered to no longer fill in the intent's action, as that is now done in TaskListFactory.kt. an additional If statement was added to the onRecieve() function to handle the checklist action and open the app when checklist tasks were selected in the widget.
    • This solution was dismissed in favor of listing the checklist options as permanently visible in the widget
  • Second Solution:

    • Display checklist tasks in a permanently-expanded form in the widget. When subtasks are selected, they are checked off. If all subtasks are selected, the overall task is checked off. If the overall task is checked, then all subtasks are marked as checked as well.
    • This solution is a lot more involved than the former and involves two parts:
      1. Edit TaskListFactory to render more lines in the RemoteView using the addView() method
      2. Add support in an unknown activity to receive an intent from the new views
    • The first part has been proven possible to an extent, but the second part might be more complicated than we originally bargained for.
  • Update: The graphics portion of the work appears to be completed, and it is now a matter of managing intents so that the proper actions occur when an overall task or one of it's subtasks is selected.

  • Pull Request:

    • Insert link to pull request here