-
Notifications
You must be signed in to change notification settings - Fork 249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update widgets when task starts or becomes due #925
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Copyright 2020 dmfs GmbH | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.dmfs.tasks.actions; | ||
|
||
import android.appwidget.AppWidgetManager; | ||
import android.content.ComponentName; | ||
import android.content.ContentProviderClient; | ||
import android.content.Context; | ||
import android.net.Uri; | ||
|
||
import org.dmfs.android.contentpal.RowDataSnapshot; | ||
import org.dmfs.tasks.contract.TaskContract; | ||
import org.dmfs.tasks.homescreen.TaskListWidgetProvider; | ||
import org.dmfs.tasks.R; | ||
|
||
|
||
/** | ||
* A {@link TaskAction} that updates the widgets. | ||
* | ||
* @author Trogel | ||
*/ | ||
public final class UpdateWidgetsAction implements TaskAction | ||
{ | ||
private final static String TAG = "UpdateWidgetsAction"; | ||
|
||
public UpdateWidgetsAction() | ||
{ | ||
} | ||
|
||
|
||
@Override | ||
public void execute(Context context, ContentProviderClient contentProviderClient, RowDataSnapshot<TaskContract.Instances> rowSnapshot, Uri taskUri) | ||
{ | ||
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context); | ||
final ComponentName componentName = new ComponentName(context, TaskListWidgetProvider.class); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currently we have two widget providers (mostly for backwards compatibility). Please ensure to update both. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, did not see the other. Hope I got it right. |
||
final int[] appWidgetIds = appWidgetManager.getAppWidgetIds(componentName); | ||
appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetIds, R.id.task_list_widget_lv); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -233,7 +233,7 @@ public RemoteViews getViewAt(int position) | |
row.setTextViewText(android.R.id.text1, mDueDateFormatter.format(dueDate, DateFormatContext.WIDGET_VIEW)); | ||
|
||
// highlight overdue dates & times | ||
if ((!dueDate.allDay && dueDate.before(mNow) || dueDate.allDay | ||
if ((!dueDate.allDay && Time.compare(dueDate, mNow) <= 0 || dueDate.allDay | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks unrelated to the issue. Why did you make this change? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While working on this fix I observed some cases where the update was processed right within the second of the due date. I noticed that in those cases the task did not turn red but remained white in the widget. That seemed wrong. The reason was that dueDate was not before but exactly equal to mNow – at least in Therefore I changed this comparison essentially from |
||
&& (dueDate.year < mNow.year || dueDate.yearDay <= mNow.yearDay && dueDate.year == mNow.year)) | ||
&& !items[position].getIsClosed()) | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove unused field.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, that was a relict of some debug logging. Removed.