Skip to content

Commit

Permalink
changes for 0.12+2 release
Browse files Browse the repository at this point in the history
  • Loading branch information
MaikuB committed May 28, 2019
1 parent 9a1c860 commit 449633d
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 50 deletions.
5 changes: 4 additions & 1 deletion device_calendar/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# 0.1.2+2 28th May 2019
* Non-functional release. Minor refactoring in Android code to address issues found in Codefactor and fix build status badge in README

## 0.1.2+1 17th May 2019
* Non-functional. Fixed formatting in changelog and code comments
* Non-functional release. Fixed formatting in changelog and code comments
* Added more info about potential issues in consuming the plugin within an Objective-C project

## 0.1.2 - 16th May 2019
Expand Down
2 changes: 1 addition & 1 deletion device_calendar/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Device Calendar Plugin

[![pub package](https://img.shields.io/pub/v/device_calendar.svg)](https://pub.dartlang.org/packages/device_calendar) [![Build Status](https://travis-ci.org/builttoroam/flutter_plugins.svg?branch=master)](https://travis-ci.org/builttoroam/flutter_plugins)
[![pub package](https://img.shields.io/pub/v/device_calendar.svg)](https://pub.dartlang.org/packages/device_calendar) [![Build Status](https://travis-ci.org/builttoroam/flutter_plugins.svg)](https://travis-ci.org/builttoroam/flutter_plugins)

A cross platform plugin for modifying calendars on the user's device.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,69 +90,93 @@ public class CalendarDelegate : PluginRegistry.RequestPermissionsResultListener

when (cachedValues.calendarDelegateMethodCode) {
RETRIEVE_CALENDARS_METHOD_CODE -> {
if (permissionGranted) {
retrieveCalendars(cachedValues.pendingChannelResult)
} else {
finishWithError(NOT_AUTHORIZED, NOT_AUTHORIZED_MESSAGE, cachedValues.pendingChannelResult)
}

_cachedParametersMap.remove(requestCode)

return true
return handleRetrieveCalendarsRequest(permissionGranted, cachedValues, requestCode)
}
RETRIEVE_EVENTS_METHOD_CODE -> {
if (permissionGranted) {
retrieveEvents(cachedValues.calendarId, cachedValues.calendarEventsStartDate, cachedValues.calendarEventsEndDate, cachedValues.calendarEventsIds, cachedValues.pendingChannelResult)
} else {
finishWithError(NOT_AUTHORIZED, NOT_AUTHORIZED_MESSAGE, cachedValues.pendingChannelResult)
}

_cachedParametersMap.remove(requestCode)

return true
return handleRetrieveEventsRequest(permissionGranted, cachedValues, requestCode)
}
RETRIEVE_CALENDAR_METHOD_CODE -> {
if (permissionGranted) {
retrieveCalendar(cachedValues.calendarId, cachedValues.pendingChannelResult)
} else {
finishWithError(NOT_AUTHORIZED, NOT_AUTHORIZED_MESSAGE, cachedValues.pendingChannelResult)
}

_cachedParametersMap.remove(requestCode)

return true
return handleRetrieveCalendarRequest(permissionGranted, cachedValues, requestCode)
}
CREATE_OR_UPDATE_EVENT_METHOD_CODE -> {
if (permissionGranted) {
createOrUpdateEvent(cachedValues.calendarId, cachedValues.event, cachedValues.pendingChannelResult)
} else {
finishWithError(NOT_AUTHORIZED, NOT_AUTHORIZED_MESSAGE, cachedValues.pendingChannelResult)
}

_cachedParametersMap.remove(requestCode)

return true
return handleCreateOrUpdateEventRequest(permissionGranted, cachedValues, requestCode)
}
DELETE_EVENT_METHOD_CODE -> {
if (permissionGranted) {
deleteEvent(cachedValues.eventId, cachedValues.calendarId, cachedValues.pendingChannelResult)
} else {
finishWithError(NOT_AUTHORIZED, NOT_AUTHORIZED_MESSAGE, cachedValues.pendingChannelResult)
}

_cachedParametersMap.remove(requestCode)

return true
return handleDeleteEventRequest(permissionGranted, cachedValues, requestCode)
}
REQUEST_PERMISSIONS_METHOD_CODE -> {
finishWithSuccess(permissionGranted, cachedValues.pendingChannelResult)
return true
return handlePermissionsRequest(permissionGranted, cachedValues)
}
}

return false
}

private fun handlePermissionsRequest(permissionGranted: Boolean, cachedValues: CalendarMethodsParametersCacheModel): Boolean {
finishWithSuccess(permissionGranted, cachedValues.pendingChannelResult)
return true
}

private fun handleDeleteEventRequest(permissionGranted: Boolean, cachedValues: CalendarMethodsParametersCacheModel, requestCode: Int): Boolean {
if (permissionGranted) {
deleteEvent(cachedValues.eventId, cachedValues.calendarId, cachedValues.pendingChannelResult)
} else {
finishWithError(NOT_AUTHORIZED, NOT_AUTHORIZED_MESSAGE, cachedValues.pendingChannelResult)
}

_cachedParametersMap.remove(requestCode)

return true
}

private fun handleCreateOrUpdateEventRequest(permissionGranted: Boolean, cachedValues: CalendarMethodsParametersCacheModel, requestCode: Int): Boolean {
if (permissionGranted) {
createOrUpdateEvent(cachedValues.calendarId, cachedValues.event, cachedValues.pendingChannelResult)
} else {
finishWithError(NOT_AUTHORIZED, NOT_AUTHORIZED_MESSAGE, cachedValues.pendingChannelResult)
}

_cachedParametersMap.remove(requestCode)

return true
}

private fun handleRetrieveCalendarRequest(permissionGranted: Boolean, cachedValues: CalendarMethodsParametersCacheModel, requestCode: Int): Boolean {
if (permissionGranted) {
retrieveCalendar(cachedValues.calendarId, cachedValues.pendingChannelResult)
} else {
finishWithError(NOT_AUTHORIZED, NOT_AUTHORIZED_MESSAGE, cachedValues.pendingChannelResult)
}

_cachedParametersMap.remove(requestCode)

return true
}

private fun handleRetrieveEventsRequest(permissionGranted: Boolean, cachedValues: CalendarMethodsParametersCacheModel, requestCode: Int): Boolean {
if (permissionGranted) {
retrieveEvents(cachedValues.calendarId, cachedValues.calendarEventsStartDate, cachedValues.calendarEventsEndDate, cachedValues.calendarEventsIds, cachedValues.pendingChannelResult)
} else {
finishWithError(NOT_AUTHORIZED, NOT_AUTHORIZED_MESSAGE, cachedValues.pendingChannelResult)
}

_cachedParametersMap.remove(requestCode)

return true
}

private fun handleRetrieveCalendarsRequest(permissionGranted: Boolean, cachedValues: CalendarMethodsParametersCacheModel, requestCode: Int): Boolean {
if (permissionGranted) {
retrieveCalendars(cachedValues.pendingChannelResult)
} else {
finishWithError(NOT_AUTHORIZED, NOT_AUTHORIZED_MESSAGE, cachedValues.pendingChannelResult)
}

_cachedParametersMap.remove(requestCode)

return true
}

public fun requestPermissions(pendingChannelResult: MethodChannel.Result) {
if (arePermissionsGranted()) {
finishWithSuccess(true, pendingChannelResult)
Expand Down
2 changes: 1 addition & 1 deletion device_calendar/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: device_calendar
description: A cross platform plugin for modifying calendars on the user's device.
version: 0.1.2+1
version: 0.1.2+2
author: Built to Roam <[email protected]>
homepage: https://github.com/builttoroam/flutter_plugins/tree/develop/device_calendar

Expand Down

0 comments on commit 449633d

Please sign in to comment.