|
7 | 7 | import android.net.Uri;
|
8 | 8 | import android.util.Log;
|
9 | 9 | import android.view.ContextThemeWrapper;
|
| 10 | +import android.view.View; |
10 | 11 | import android.widget.RemoteViews;
|
11 | 12 | import android.widget.RemoteViewsService;
|
12 | 13 |
|
13 | 14 | import androidx.annotation.NonNull;
|
14 | 15 |
|
15 | 16 | import org.andstatus.todoagenda.prefs.AllSettings;
|
16 | 17 | import org.andstatus.todoagenda.prefs.InstanceSettings;
|
| 18 | +import org.andstatus.todoagenda.prefs.OrderedEventSource; |
17 | 19 | import org.andstatus.todoagenda.prefs.TextShadingPref;
|
18 | 20 | import org.andstatus.todoagenda.provider.EventProviderType;
|
19 | 21 | import org.andstatus.todoagenda.util.InstanceId;
|
@@ -58,7 +60,7 @@ public class RemoteViewsFactory implements RemoteViewsService.RemoteViewsFactory
|
58 | 60 | static final String ACTION_OPEN_CALENDAR = PACKAGE + ".action.OPEN_CALENDAR";
|
59 | 61 | static final String ACTION_GOTO_TODAY = PACKAGE + ".action.GOTO_TODAY";
|
60 | 62 | static final String ACTION_ADD_CALENDAR_EVENT = PACKAGE + ".action.ADD_CALENDAR_EVENT";
|
61 |
| - static final String ACTION_ADD_TASK = PACKAGE + ".action.GOTO_TODAY"; |
| 63 | + static final String ACTION_ADD_TASK = PACKAGE + ".action.ADD_TASK"; |
62 | 64 | static final String ACTION_VIEW_ENTRY = PACKAGE + ".action.VIEW_ENTRY";
|
63 | 65 | static final String ACTION_REFRESH = PACKAGE + ".action.REFRESH";
|
64 | 66 | public static final String ACTION_CONFIGURE = PACKAGE + ".action.CONFIGURE";
|
@@ -343,6 +345,7 @@ private static void configureWidgetHeader(InstanceSettings settings, RemoteViews
|
343 | 345 | setActionIcons(settings, rv);
|
344 | 346 | configureGotoToday(settings, rv);
|
345 | 347 | configureAddCalendarEvent(settings, rv);
|
| 348 | + configureAddTask(settings, rv); |
346 | 349 | configureRefresh(settings, rv);
|
347 | 350 | configureOverflowMenu(settings, rv);
|
348 | 351 | }
|
@@ -379,7 +382,21 @@ private static void setActionIcons(InstanceSettings settings, RemoteViews rv) {
|
379 | 382 | }
|
380 | 383 |
|
381 | 384 | private static void configureAddCalendarEvent(InstanceSettings settings, RemoteViews rv) {
|
382 |
| - rv.setOnClickPendingIntent(R.id.add_event, getActionPendingIntent(settings, ACTION_ADD_CALENDAR_EVENT)); |
| 385 | + if (settings.getFirstSource(true) == OrderedEventSource.EMPTY) { |
| 386 | + rv.setViewVisibility(R.id.add_event, View.GONE); |
| 387 | + } else { |
| 388 | + rv.setViewVisibility(R.id.add_event, View.VISIBLE); |
| 389 | + rv.setOnClickPendingIntent(R.id.add_event, getActionPendingIntent(settings, ACTION_ADD_CALENDAR_EVENT)); |
| 390 | + } |
| 391 | + } |
| 392 | + |
| 393 | + private static void configureAddTask(InstanceSettings settings, RemoteViews rv) { |
| 394 | + if (settings.getFirstSource(false) == OrderedEventSource.EMPTY) { |
| 395 | + rv.setViewVisibility(R.id.add_task, View.GONE); |
| 396 | + } else { |
| 397 | + rv.setViewVisibility(R.id.add_task, View.VISIBLE); |
| 398 | + rv.setOnClickPendingIntent(R.id.add_task, getActionPendingIntent(settings, ACTION_ADD_TASK)); |
| 399 | + } |
383 | 400 | }
|
384 | 401 |
|
385 | 402 | private static void configureRefresh(InstanceSettings settings, RemoteViews rv) {
|
|
0 commit comments