@Override public void onReceive(Context context, Intent intent) { ContextManager.setContext(context); // if we aren't logged in, don't expose features if (!ProducteevUtilities.INSTANCE.isLoggedIn()) return; StoreObject[] dashboards = ProducteevDataService.getInstance().getDashboards(); // If user does not have any dashboards, don't show this section at all if (dashboards.length == 0) return; FilterListHeader producteevHeader = new FilterListHeader(context.getString(R.string.producteev_FEx_header)); long currentUserId = Preferences.getLong(ProducteevUtilities.PREF_USER_ID, -1); // load dashboards Filter[] dashboardFilters = new Filter[dashboards.length]; for (int i = 0; i < dashboards.length; i++) dashboardFilters[i] = filterFromList(context, new ProducteevDashboard(dashboards[i]), currentUserId); FilterCategory producteevDashboards = new FilterCategory(context.getString(R.string.producteev_FEx_dashboard), dashboardFilters); // load responsible people, assigned by me TreeSet<ProducteevUser> people = loadResponsiblePeople(dashboards); Filter[] peopleByMeFilters = new Filter[people.size()]; int index = 0; for (ProducteevUser person : people) peopleByMeFilters[index++] = filterUserAssignedByMe(context, person, currentUserId); FilterCategory producteevUsersByMeCategory = new FilterCategory( context.getString(R.string.producteev_FEx_responsible_byme), peopleByMeFilters); // load responsible people, assigned by others Filter[] peopleByOthersFilters = new Filter[people.size()]; index = 0; for (ProducteevUser person : people) peopleByOthersFilters[index++] = filterUserAssignedByOthers(context, person, currentUserId); FilterCategory producteevUsersByOthersCategory = new FilterCategory( context.getString(R.string.producteev_FEx_responsible_byothers), peopleByOthersFilters); // transmit filter list FilterListItem[] list = new FilterListItem[4]; list[0] = producteevHeader; list[1] = producteevDashboards; list[2] = producteevUsersByMeCategory; list[3] = producteevUsersByOthersCategory; Intent broadcastIntent = new Intent(AstridApiConstants.BROADCAST_SEND_FILTERS); broadcastIntent.putExtra(AstridApiConstants.EXTRAS_ADDON, ProducteevUtilities.IDENTIFIER); broadcastIntent.putExtra(AstridApiConstants.EXTRAS_RESPONSE, list); context.sendBroadcast(broadcastIntent, AstridApiConstants.PERMISSION_READ); }
@Override public void onReceive(Context context, Intent intent) { // if we aren't logged in, don't expose sync action if (!ProducteevUtilities.INSTANCE.isLoggedIn()) return; Intent syncIntent = new Intent( ProducteevBackgroundService.SYNC_ACTION, null, context, ProducteevBackgroundService.class); PendingIntent pendingIntent = PendingIntent.getService(context, 0, syncIntent, PendingIntent.FLAG_UPDATE_CURRENT); SyncAction syncAction = new SyncAction(context.getString(R.string.producteev_PPr_header), pendingIntent); Intent broadcastIntent = new Intent(AstridApiConstants.BROADCAST_SEND_SYNC_ACTIONS); broadcastIntent.putExtra(AstridApiConstants.EXTRAS_ADDON, ProducteevUtilities.IDENTIFIER); broadcastIntent.putExtra(AstridApiConstants.EXTRAS_RESPONSE, syncAction); context.sendBroadcast(broadcastIntent, AstridApiConstants.PERMISSION_READ); }