Unable to add / remove Event Reminder using Google Apps Calendar v3 API - java

I am trying to update an event in a Google Calendar: change the color and remove or add event reminders. I can easily update the color, but I can't find a way to remove the default reminder, or even add a new one.
Here is my code:
Event googleEvent = client.events().get(cal, events.getItems().get(i).getId()).execute();
ArrayList<EventReminder> listEventReminder = new ArrayList<EventReminder>();
Reminders reminders = googleEvent.getReminders();
reminders.setUseDefault(false);
EventReminder reminder = new EventReminder();
reminder.setMethod("popup");
reminder.setMinutes(42);
listEventReminder.add(reminder);
reminders.setOverrides(listEventReminder);
googleEvent.setColorId("10");
googleEvent.setReminders(reminders);
client.events().update(cal, googleEvent.getId(), googleEvent).queue(batch, callback);
The color of the event is properly updated (to green) however, the reminder is still set on "popup 10 min"

Related

Accessibility service dispatchGesture swiping the screen not tapping

I have been trying to make the accessibility service dispatchGesture with a click and not a swipe.
This code is just swiping down on the screen, and not actually clicking on the x,y cords.
What I have tried.
Path clickPath = new Path();
clickPath.moveTo(Float.intBitsToFloat(x), Float.intBitsToFloat(y));
GestureDescription.Builder gestureBuilder = new GestureDescription.Builder();
gestureBuilder.addStroke(new GestureDescription.StrokeDescription(clickPath, 0, 1));
dispatchGesture(gestureBuilder.build(), null, null);
I have also tried replaced the clickPath.moveTo to add clickPath.addCircle, and clickPath.addRect, But both of those just crash the application.
I know this question was a few months ago, but from what I've seen, your duration is too short. I wasn't able to get touch events to register with a duration of less than 50ms. I also passed a custom handler:
val handler = Handler(Looper.myLooper()!!)
It's possible that one or both of these could be the source of the reason it wasn't working for you. In general, you seem to be doing the same thing that I am, and I'm having some success with it.

Vaadin Calendar event selected style change on click

I am trying to change the style of an event in the Vaadin Calendar component when clicking on it. This is what I do:
eventCalendar.setHandler((CalendarComponentEvents.EventClick event) -> {
/* some code to iterate the container and remove selected style from other events*/
((BasicEvent) event.getCalendarEvent()).setStyleName("event-selected");
});
But nothing happens. The class is not added.
Some hours later, two observations saved the day:
Firstly, setting the style name on the event itself does not trigger a refresh, so we just need to add eventCalendar.markAsDirty() to the handler method.
Secondly, setStyleName doesn't add a CSS class with that name to the Calendar Event element. It adds a class with the .v-calendar-event- prefix (e.g. in my example that would become .v-calendar-event-event-selected.
So, the solution was to make the following update to the UI class:
eventCalendar.setHandler((CalendarComponentEvents.EventClick event) -> {
/* some code to iterate the container and remove selected style from other events*/
((BasicEvent) event.getCalendarEvent()).setStyleName("selected");
eventCalendar.markAsDirty();
});
and add the following class to the styles.scss, inside the root name of the Vaadin theme:
.v-calendar-event-selected{
/*however I wanted the selected event to look like*/
}

Unable to add reminders to Google Calendar event

I am able to create events programmatically which are added to my Google Calendar (API v3) fine, but none of these events have reminders on them. I have followed the answers on other SO questions and my reminder code looks like the following:
Event.Reminders reminders = new Event.Reminders()
.setUseDefault(false)
.setOverrides(Arrays.asList(
new EventReminder().setMethod("email").setMinutes(60),
new EventReminder().setMethod("popup").setMinutes(10)));
I have tried with setUseDefault(true) in place of the overrides and I still see nothing in the notifications section.
I tried adding setSendNotifications(true) but that hasn't been of any help adding the reminders themselves.
It might be worth noting that the account associated with this calendar uses an email that is not hosted through Google.

how can i open the calendar from my app?

I am building an app for the android, i dont need my app to have a calendar be part of it(plus it would defeat the purpose), my app allows the user to listen to a radio station, and needs the option to set an event to(remember to listen to the radio at a specific time), if the app has its own calendar then the event alarms will only go off if the user has the app open... pointless. i have been looking and cannot find, is there a way to use an intent or something else to open a google calendar or some other calendar that Android might have?
i need to put my intent(/ other code) in my listener which i already have and looks like this for now
private View.OnClickListener reminder = new View.OnClickListener() {
#Override
public void onClick(View v) {
// open calendar code goes here.
}
};
i dont need the app to pre-fill in any field in the calendar just open it, i will leave the rest up to the user.
all help is welcome and thank you
If you just want to open the calendar you can use and intent with EITHER of these component names (you might have to cater for both if you want to support older phones)
Intent i = new Intent();
//Froyo or greater (mind you I just tested this on CM7 and the less than froyo one worked so it depends on the phone...)
cn = new ComponentName("com.google.android.calendar", "com.android.calendar.LaunchActivity");
//less than Froyo
cn = new ComponentName("com.android.calendar", "com.android.calendar.LaunchActivity");
i.setComponent(cn);
startActivity(i);
If you want to go to the add event screen (which sounds better for your purpose) use something like:
//all version of android
Intent i = new Intent();
// mimeType will popup the chooser any for any implementing application (e.g. the built in calendar or applications such as "Business calendar"
i.setType("vnd.android.cursor.item/event");
// the time the event should start in millis. This example uses now as the start time and ends in 1 hour
i.putExtra("beginTime", new Date().getTime());
i.putExtra("endTime", new Date().getTime() + DateUtils.HOUR_IN_MILLIS);
// the action
i.setAction(Intent.ACTION_EDIT);
startActivity(i);
(code is untested, copied from an existing project)

How to force redraw of an ex-invisible group's content in SWT?

I'm a total noob in SWT, just getting started, but I have previously worked with GUI frameworks such as Swing.
I have a Composite which contains a Group and a Button. The Group is initially set to invisible (using group.setVisible(false)), and is set to visible when clicking the button. This starts a thread which perform some calculations, updating a label inside the group with the progress (kind of a manual progress bar. This is what the customer wants :) ).
Anyway, for some reason, the group only appears after the thread has finished running, and I can't seem to make it appear, no matter what I've used (tried calling this.pack(), this.layout(), this.getShell().layout(), redraw() on a variety of controls in the path - nothing).
Here's how I create the group:
statusGroup = new Group(this, SWT.SHADOW_NONE);
statusGroup.setLayout(null);
statusGroup.setVisible(false);
percentCompleteLabel = new Label(statusGroup, SWT.NONE);
percentCompleteLabel.setText("0% complete");
Here's how I'm updating it from the Button's SelectionListener:
this.statusGroup.setVisible(true);
this.statusGroup.pack(true);
this.statusGroup.layout();
this.getShell().layout();
myThreadStartupCode(); // psuedo
while (!workIsDone) // psuedo
{
final int progress = myProgressCalcMethod(); // psuedo
percentCompleteLabel.setText(progress + "% complete");
percentCompleteLabel.pack(true);
this.layout();
this.redraw();
Thread.sleep(100);
}
Any clue would be appreciated.
Apparently, the solution is to use Display.getCurrent().update();

Categories