-
Notifications
You must be signed in to change notification settings - Fork 42
3. Development
This class is responsible for the main functionality of the app. It handles the following:
- Authentification and GUI setup (#authAndGuiInit, #initActivity, #GuiSetup)
- Navigation (#onNavigationItemSelected)
- Reminder functions (#reminderServiceConnection, #notifyReminderService)
- Create/delete Lists (#addListToNav, #startListDialog, #onCustomMenuItemClickListener)
- Create tasks (#initFab)
- Filter tasks (#onOptionsItemSelected)
- Display tasks (#showAllTasks, #showTasksOfList)
- Long click operations on tasks (#onCreateContextMenu, #onContextItemSelected)
- Hints (#hints)
Manages the following functionality of an expandable task item:
- Set the view of a expandable task item (#getGroupView)
- Snackbar when deleting (#getGroupView)
- Filter and sorting conditions (#addSortCondition, #removeSortCondition, #filterTasks, #sortTasks)
- Computes progress of a task by the number of done subtasks (#hasAutoProgress, #getProgressDone)
This class handles the dialog that appears when a task will be created or edited:
- Initialize the view of the dialog (#initGui)
- Handle if progress is dependend on done subtasks (#hasAutoProgress, #makeProgressGone)
- Reminder- & deadline values default -1
- Context menus for priority and list (#onCreateContextMenu, #onMenuItemSelected, #updateLists)
ToDo List uses a sqlite database where tables for tasks (TTodoTask), subtasks (TTodoSubTask) and lists (TTodoList) are stored. To organize these tables, the app uses the class DatabaseHelper and DBQueryHandler
This class extends SQLiteOpenHelper and is responsible for fundamental things such as:
- Create all tables mentioned above (#createAll)
- Delete all tables (#deleteAll)
To get an instance of the database the common way is to use DatabaseHelper.getInstance(Context context)
.
You can get readable or writable Database by calling #getReadableDatabase or #getWritableDatabase. This is important to work with DBQueryhandler.
With this class the developer is able to update and change entries of the tables:
- get next task to do (#getNextDueTask)
- get tasks for reminder (#getTasksToRemind)
- delete a list (#deleteTodoList)
- delete a task (#deleteTodoTask)
- get all todo tasks (#getAllTodoTasks)
... methods are self-explaining.
The class ReminderService defines a service that is responsible to set a notification for the next due task. It is used inside the MainActivity by calling notifyReminderService(TodoTask currentTask)
. To catch tasks that have a reminder-time DBQueryHandler.getTaskToRemind(SQLiteDatabase, long, HashSet<Integer>)
can be called. The service uses an AlarmManager to awaken itself and trigger a notification.
The NotificationHelper is a class that is used in ReminderService in order to manage notifications. This class creates notifications based on the used SDK-version of the device. SDK-versions that are <= 26 need so called NotificationChannels which are created in createChannel()
.
The widget consists of 4 classes that will be explained in the following section.
This class represents the initialization of the appwidget. What it does is to let a user configure the list of which the tasks will be shown on the widget. It defines the view in the onCreate()
method where a spinner is used to choose one of the existing lists that the user has created beforehand. A click on the button stores the chosen list as shared preference with the saveTitlePref(Context context, int AppWidgetId, String text)
method and can be loaded by loadTitlePref(Context context, int AppWidgetID)
. In order to show all currently available lists updateLists()
is called to update the "lists" ArrayAdapter. To return the string of the chosen list getSelectedItem()
can be called.
The WidgetViewsFactory class extends RemoteViewsFactory and defines the view of the individual tasks inside the ListView of the appwidget in getViewAt(int position)
. To get the set list out of the configuration activity, getListName(Context context, int AppWidgetId)
returns a String of the list's name by calling loadTitlePref()
of TodoListWidgetConfigureActivity that returns the shared preference which was stored before.
This class is a service that extends RemoteViewsService and does nothing but creating a new WidgetViewsFactory object that will be needed in TodoListWidget.
Here are updates and clicks on the widget itself managed. The layout of the overall widget is defined by a RemoteView "views". The onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds)
method is responsible for updating the content of our widget. The whole update implementation can be found in updateAppWidget(Context context, AppWidgetManager appWidgetManager, int appWidgetId)
that is called in onUpdate.