Calendar icon indicating copy to clipboard operation
Calendar copied to clipboard

[Feature Request] Adding the "Go to location" button to the widget

Open Santodan opened this issue 5 months ago • 2 comments

Checklist

  • [x] I made sure that there are no existing issues - open or closed - to which I could contribute my information.
  • [x] I made sure that there are no existing discussions - open or closed - to which I could contribute my information.
  • [x] I have read the FAQs inside the app (Menu -> About -> FAQs) and my problem isn't listed.
  • [x] I have taken the time to fill in all the required details. I understand that the request will be dismissed otherwise.
  • [x] This issue contains only one feature request.
  • [x] I have read and understood the contribution guidelines.

Feature description

Just like there is a "Go To location" button when editing an event - from the commit https://github.com/FossifyOrg/Calendar/commit/1bf5e223faafc09c0c30b22dbec344ab1cccf387 - I would like to know if there was the possibility to add it to the widget

Why do you want this feature?

This would be a good feature to be added to the widget, this way a person doesn't need to enter in the edit view to be able to go to the event location. This feature is already present in a lot of other applications.

Additional information

I asked ChatGPT about it and this was what he provided, I'm not a programmer, so I don't know if it is correct or not:

1. Review the Event Editor Implementation

In the event editor screen, you'll find code like:

// In EventEditorActivity or its ViewModel:
buttonGoToLocation.setOnClickListener {
    val uri = Uri.parse("geo:0,0?q=${event.location}")
    startActivity(Intent(Intent.ACTION_VIEW, uri))
}

Search for usage of "geo:" or Intent.ACTION_VIEW in editor code. That’s how they launch maps with the event location.

2. Update the Widget Layout

Locate the widget XML (likely under app/src/main/res/layout), something like:

  • widget_event_item.xml
  • or widget_simple_event_list.xml

Add a map button:

<ImageView
    android:id="@+id/widget_btn_location"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/ic_map_marker" />

3. Modify the Widget Provider

In the AppWidgetProvider, often CalendarWidgetProvider.kt, modify the updateWidget():

  • Create PendingIntent Inside the loop building RemoteViews for each event
val location = event.location
if (!location.isNullOrBlank()) {
    val geoUri = Uri.parse("geo:0,0?q=" + Uri.encode(location))
    val intent = Intent(Intent.ACTION_VIEW, geoUri)
    val pi = PendingIntent.getActivity(context, event.id.hashCode(), intent, flags)
    rv.setOnClickPendingIntent(R.id.widget_btn_location, pi)
    rv.setViewVisibility(R.id.widget_btn_location, View.VISIBLE)
} else {
    rv.setViewVisibility(R.id.widget_btn_location, View.GONE)
}

Make sure you invoke rv.setOnClickPendingIntent() for your new button ID.

  • Import Constants Ensure you include proper PendingIntent flags (e.g., PendingIntent.FLAG_UPDATE_CURRENT) and context.

4. Permissions & Intent Handling

No special permissions are required—map launches are implicit Intents directed to the Maps application.

Santodan avatar Jun 20 '25 11:06 Santodan

This feature is already present in a lot of other applications.

Could you list some of them? I only know of DigiCal.

naveensingh avatar Jun 20 '25 11:06 naveensingh

This feature is already present in a lot of other applications.

Could you list some of them? I only know of DigiCal.

I now that Business Calendar and DigiCal use it. Business Calendar was my main one until I moved to an Honor phone and starting facing issues with it, which I'm not facing with fossify

Santodan avatar Jun 20 '25 13:06 Santodan