From dcd53b9e1871b48060a02f7ba9de1bd1a5d6c073 Mon Sep 17 00:00:00 2001 From: joh13266 Date: Tue, 20 Jul 2021 11:08:18 -0500 Subject: [PATCH 01/30] Fix serialize inconsistency --- lib/src/models/event.dart | 18 +++++++++--------- test/device_calendar_test.dart | 20 ++++++++++++++++++-- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/lib/src/models/event.dart b/lib/src/models/event.dart index 355a0d65..66361b60 100644 --- a/lib/src/models/event.dart +++ b/lib/src/models/event.dart @@ -66,30 +66,30 @@ class Event { eventId = json['eventId']; calendarId = json['calendarId']; - title = json['title']; - description = json['description']; + title = json['eventTitle']; + description = json['eventDescription']; - final int? startTimestamp = json['start']; - final String? startLocationName = json['startTimeZone']; + final int? startTimestamp = json['eventStartDate']; + final String? startLocationName = json['eventStartTimeZone']; var startTimeZone = timeZoneDatabase.locations[startLocationName]; startTimeZone ??= local; start = startTimestamp != null ? TZDateTime.fromMillisecondsSinceEpoch(startTimeZone, startTimestamp) : TZDateTime.now(local); - final int? endTimestamp = json['end']; - final String? endLocationName = json['endTimeZone']; + final int? endTimestamp = json['eventEndDate']; + final String? endLocationName = json['eventEndTimeZone']; var endLocation = timeZoneDatabase.locations[endLocationName]; endLocation ??= local; end = endTimestamp != null ? TZDateTime.fromMillisecondsSinceEpoch(endLocation, endTimestamp) : TZDateTime.now(local); - allDay = json['allDay']; - location = json['location']; + allDay = json['eventAllDay']; + location = json['eventLocation']; availability = parseStringToAvailability(json['availability']); - var foundUrl = json['url']?.toString(); + var foundUrl = json['eventURL']?.toString(); if (foundUrl?.isEmpty ?? true) { url = null; } else { diff --git a/test/device_calendar_test.dart b/test/device_calendar_test.dart index 0b18cf0b..20bbdbf1 100644 --- a/test/device_calendar_test.dart +++ b/test/device_calendar_test.dart @@ -176,8 +176,19 @@ void main() { }); test('Event_Serialises_Correctly', () async { - final event = Event('calendarId',eventId: 'eventId',start: TZDateTime( - timeZoneDatabase.locations.entries.skip(20).first.value, 1980, 10,1,0,0,0), availability: Availability.Busy); + final startTime = TZDateTime( + timeZoneDatabase.locations.entries.skip(20).first.value, 1980, 10,1,0,0,0); + final endTime = startTime.add(Duration(hours: 1)); + var event = Event('calendarId', + eventId: 'eventId', + title: 'Test Event', + start: startTime, + end: endTime, + description: 'Test description', + availability: Availability.Busy); + event.location = 'Seattle, Washington'; + event.url = Uri.dataFromString('http://example.com/'); + final stringEvent = event.toJson(); expect(stringEvent, isNotNull); final newEvent = Event.fromJson(stringEvent); @@ -185,5 +196,10 @@ void main() { expect(newEvent.calendarId, equals(event.calendarId)); expect(newEvent.eventId, equals(event.eventId)); expect(newEvent.start, equals(event.start)); + expect(newEvent.end, equals(event.end)); + expect(newEvent.description, equals(event.description)); + expect(newEvent.url, equals(event.url)); + expect(newEvent.location, equals(event.location)); + expect(newEvent.title, equals(event.title)); }); } From e6f4f0a9f482b0512efecb3aef636690cd318c5f Mon Sep 17 00:00:00 2001 From: joh13266 Date: Thu, 22 Jul 2021 12:31:44 -0500 Subject: [PATCH 02/30] Add tests for event serialization and run in azure --- azure-pipelines.yml | 5 +++++ test/device_calendar_test.dart | 41 +++++++++++++++++++++++++--------- 2 files changed, 36 insertions(+), 10 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index e608a2d7..7caf1c32 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -27,6 +27,11 @@ stages: channel: 'stable' version: 'latest' + - task: FlutterTest@0 + displayName: 'Run library tests' + inputs: + projectDirectory: '.' + - task: FlutterBuild@0 displayName: 'Flutter build - Android' inputs: diff --git a/test/device_calendar_test.dart b/test/device_calendar_test.dart index 20bbdbf1..c5845270 100644 --- a/test/device_calendar_test.dart +++ b/test/device_calendar_test.dart @@ -175,17 +175,30 @@ void main() { expect(newAttendee.androidAttendeeDetails, isNull); }); - test('Event_Serialises_Correctly', () async { + test('Event_Serializes_Correctly', () async { final startTime = TZDateTime( - timeZoneDatabase.locations.entries.skip(20).first.value, 1980, 10,1,0,0,0); - final endTime = startTime.add(Duration(hours: 1)); + timeZoneDatabase.locations.entries.skip(20).first.value, + 1980, 10, 1, 0, 0, 0); + final endTime = TZDateTime( + timeZoneDatabase.locations.entries.skip(21).first.value, + 1980, 10, 2, 0, 0, 0); + final attendee = Attendee( + name: 'Test Attendee', + emailAddress: 'test@t.com', + role: AttendeeRole.Required, + isOrganiser: true); + final recurrence = RecurrenceRule(RecurrenceFrequency.Daily); + final reminder = Reminder(minutes: 10); var event = Event('calendarId', - eventId: 'eventId', - title: 'Test Event', - start: startTime, - end: endTime, - description: 'Test description', - availability: Availability.Busy); + eventId: 'eventId', + title: 'Test Event', + start: startTime, + end: endTime, + attendees: [attendee], + description: 'Test description', + recurrenceRule: recurrence, + reminders: [reminder], + availability: Availability.Busy); event.location = 'Seattle, Washington'; event.url = Uri.dataFromString('http://example.com/'); @@ -195,11 +208,19 @@ void main() { expect(newEvent, isNotNull); expect(newEvent.calendarId, equals(event.calendarId)); expect(newEvent.eventId, equals(event.eventId)); + expect(newEvent.title, equals(event.title)); expect(newEvent.start, equals(event.start)); expect(newEvent.end, equals(event.end)); expect(newEvent.description, equals(event.description)); expect(newEvent.url, equals(event.url)); expect(newEvent.location, equals(event.location)); - expect(newEvent.title, equals(event.title)); + expect(newEvent.attendees, isNotNull); + expect(newEvent.attendees?.length, equals(1)); + expect(newEvent.recurrenceRule, isNotNull); + expect(newEvent.recurrenceRule?.recurrenceFrequency, + equals(event.recurrenceRule?.recurrenceFrequency)); + expect(newEvent.reminders, isNotNull); + expect(newEvent.reminders?.length, equals(1)); + expect(newEvent.availability, equals(event.availability)); }); } From d5951dba9e330404c828e45742a87400d132ccac Mon Sep 17 00:00:00 2001 From: Thomas Date: Thu, 25 Nov 2021 21:41:03 +0800 Subject: [PATCH 03/30] Update badges on readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index de8f7e7a..ac505706 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Device Calendar Plugin **Your previous code will need to be modified (slightly) otherwise it will not run after update. See Timezone support for more details.** -[![pub package](https://img.shields.io/pub/v/device_calendar.svg)](https://pub.dartlang.org/packages/device_calendar) [![Build Status](https://dev.azure.com/builttoroam/Flutter%20Plugins/_apis/build/status/Device%20Calendar)](https://dev.azure.com/builttoroam/Flutter%20Plugins/_build/latest?definitionId=111) +[![pub package](https://img.shields.io/pub/v/device_calendar.svg)](https://pub.dartlang.org/packages/device_calendar) ![Pub Version (including pre-releases)](https://img.shields.io/pub/v/device_calendar?include_prereleases&label=Prerelease) [![build](https://github.com/builttoroam/device_calendar/actions/workflows/dart.yml/badge.svg?branch=develop)](https://github.com/builttoroam/device_calendar/actions/workflows/dart.yml) A cross platform plugin for modifying calendars on the user's device. From f7e48d3f528bd152581e32b9fcfee0f829a772fa Mon Sep 17 00:00:00 2001 From: Thomas Date: Thu, 25 Nov 2021 21:54:08 +0800 Subject: [PATCH 04/30] General clarity improvements --- README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index ac505706..1e579e7d 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Device Calendar Plugin -**Your previous code will need to be modified (slightly) otherwise it will not run after update. See Timezone support for more details.** +**If you're upgrading to `v4.0.0`, your previous code will need to be modified (slightly) otherwise it will not run after update. See Timezone support for more details.** [![pub package](https://img.shields.io/pub/v/device_calendar.svg)](https://pub.dartlang.org/packages/device_calendar) ![Pub Version (including pre-releases)](https://img.shields.io/pub/v/device_calendar?include_prereleases&label=Prerelease) [![build](https://github.com/builttoroam/device_calendar/actions/workflows/dart.yml/badge.svg?branch=develop)](https://github.com/builttoroam/device_calendar/actions/workflows/dart.yml) @@ -23,7 +23,7 @@ A cross platform plugin for modifying calendars on the user's device. ## Timezone support with TZDateTime -Due to feedback we received, we will be utilizing `timezone` package to better handle all the timezone data. +Due to feedback we received, starting from `v4.0.0` we will be utilizing `timezone` package to better handle all the timezone data. This is already included in this package. However, you need to add this line whenever the package is needed. @@ -57,16 +57,16 @@ event.start = TZDateTime.from(oldDateTime, _currentLocation); For other use cases, feedback or future developments on the feature, feel free to open a discussion on GitHub. -## Null migration +## Null-safety migration -From v4.0.0, device_calendar fits null safety. However, not all workflow had been checked and bugs from 3.2 still presists. +From `v3.9.0`, device_calendar is null-safe. However, not all workflow had been checked and bugs from older versions still presist. You are strongly advised to test your workflow with the new package before shipping. Better yet, please leave a note for what works and what doesn't, or contribute some bug fixes! ## Android Integration -The following will need to be added to the manifest file for your application to indicate permissions to modify calendars a needed +The following will need to be added to the `AndroidManifest.xml` file for your application to indicate permissions to modify calendars a needed ```xml @@ -75,7 +75,7 @@ The following will need to be added to the manifest file for your application to ### Proguard / R8 exceptions By default, all android apps go through R8 for file shrinking when building a release version. Currently, it interferes with some functions such as `retrieveCalendars()`. -You may add the following setting to the ProGuard rules file (thanks to [Britannio Jarrett](https://github.com/britannio)). Read more about the issue [here](https://github.com/builttoroam/device_calendar/issues/99) +You may add the following setting to the ProGuard rules file `proguard-rules.pro` (thanks to [Britannio Jarrett](https://github.com/britannio)). Read more about the issue [here](https://github.com/builttoroam/device_calendar/issues/99) ``` -keep class com.builttoroam.devicecalendar.** { *; } @@ -86,11 +86,11 @@ See [here](https://github.com/builttoroam/device_calendar/issues/99#issuecomment For more information, refer to the guide at [Android Developer](https://developer.android.com/studio/build/shrink-code#keep-code) ### AndroidX migration -**IMPORTANT**: Since version 0.1.0, this version has migrated to use AndroidX instead of the deprecated Android support libraries. When using version 0.10.0 and onwards for this plugin, please ensure your application has been migrated following the guide [here](https://developer.android.com/jetpack/androidx/migrate) +Since `v0.1.0`, this version has migrated to use AndroidX instead of the deprecated Android support libraries. When using `v0.10.0` and onwards for this plugin, please ensure your application has been migrated following the guide [here](https://developer.android.com/jetpack/androidx/migrate) ## iOS Integration -For iOS 10 support, you'll need to modify the Info.plist to add the following key/value pair +For iOS 10 support, you'll need to modify the `Info.plist` to add the following key/value pair ```xml NSCalendarsUsageDescription From 6d12e8c58eaebb54a811d3c657aabfd2db44543c Mon Sep 17 00:00:00 2001 From: Thomas Date: Thu, 25 Nov 2021 23:26:32 +0800 Subject: [PATCH 05/30] Update prerelease.yml --- .github/workflows/prerelease.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/prerelease.yml b/.github/workflows/prerelease.yml index 48cb8c38..8ee0e1ac 100644 --- a/.github/workflows/prerelease.yml +++ b/.github/workflows/prerelease.yml @@ -37,11 +37,10 @@ jobs: sed -i "0,/\#\# \[.*/s//## [${{steps.changelog_reader.outputs.version}}-$GITHUB_RUN_ID]/" CHANGELOG.md cat CHANGELOG.md - name: Publish package - uses: sakebook/actions-flutter-pub-publisher@v1.3.1 - with: - credential: ${{ secrets.CREDENTIALS }} - flutter_package: true - skip_test: false + run: | + mkdir -p $FLUTTER_HOME/.pub-cache + echo '${{ secrets.CREDENTIALS }}' > $FLUTTER_HOME/.pub-cache/credentials.json + flutter pub publish - name: Add entry to Github release uses: softprops/action-gh-release@v1 with: From cb171ee77532ced955c3190704cc439a43a4b250 Mon Sep 17 00:00:00 2001 From: Thomas Date: Thu, 25 Nov 2021 23:57:48 +0800 Subject: [PATCH 06/30] Update prerelease.yml --- .github/workflows/prerelease.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/prerelease.yml b/.github/workflows/prerelease.yml index 8ee0e1ac..f9b04418 100644 --- a/.github/workflows/prerelease.yml +++ b/.github/workflows/prerelease.yml @@ -36,11 +36,13 @@ jobs: run: | sed -i "0,/\#\# \[.*/s//## [${{steps.changelog_reader.outputs.version}}-$GITHUB_RUN_ID]/" CHANGELOG.md cat CHANGELOG.md - - name: Publish package + - name: Setup credentials run: | - mkdir -p $FLUTTER_HOME/.pub-cache - echo '${{ secrets.CREDENTIALS }}' > $FLUTTER_HOME/.pub-cache/credentials.json - flutter pub publish + cat < $PUB_CACHE/credentials.json + ${{ secrets.CREDENTIALS }} + EOF + - name: Publish package + run: flutter pub publish - name: Add entry to Github release uses: softprops/action-gh-release@v1 with: From 702b4ceadc75bcf48d33ebc85e869fbedd1b0cbc Mon Sep 17 00:00:00 2001 From: Thomas Date: Thu, 25 Nov 2021 23:58:13 +0800 Subject: [PATCH 07/30] Update release.yml --- .github/workflows/release.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c5e2eb0f..4c9865e6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -25,12 +25,13 @@ jobs: channel: "stable" - run: dart --version - run: flutter --version + - name: Setup credentials + run: | + cat < $PUB_CACHE/credentials.json + ${{ secrets.CREDENTIALS }} + EOF - name: Publish package - uses: sakebook/actions-flutter-pub-publisher@v1.3.1 - with: - credential: ${{ secrets.CREDENTIALS }} - flutter_package: true - skip_test: false + run: flutter pub publish - name: Get Changelog Entry id: changelog_reader uses: mindsers/changelog-reader-action@v2.0.0 From b49d11d4c6fa50232345a8bbdf5664ef04bf2186 Mon Sep 17 00:00:00 2001 From: Thomas Date: Fri, 26 Nov 2021 15:56:23 +0800 Subject: [PATCH 08/30] Create prerelease.yml --- .github/workflows/prerelease.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/prerelease.yml b/.github/workflows/prerelease.yml index f9b04418..108294e6 100644 --- a/.github/workflows/prerelease.yml +++ b/.github/workflows/prerelease.yml @@ -42,7 +42,7 @@ jobs: ${{ secrets.CREDENTIALS }} EOF - name: Publish package - run: flutter pub publish + run: flutter pub publish --force - name: Add entry to Github release uses: softprops/action-gh-release@v1 with: From 20aef718053cc5cd7817635381aabd008f51b552 Mon Sep 17 00:00:00 2001 From: Thomas Date: Fri, 26 Nov 2021 15:57:17 +0800 Subject: [PATCH 09/30] Update release.yml --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4c9865e6..72120c10 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -31,7 +31,7 @@ jobs: ${{ secrets.CREDENTIALS }} EOF - name: Publish package - run: flutter pub publish + run: flutter pub publish --force - name: Get Changelog Entry id: changelog_reader uses: mindsers/changelog-reader-action@v2.0.0 From 46ffaf84eb22c1c85628ef295b51a7a746fcb169 Mon Sep 17 00:00:00 2001 From: Thomas Date: Fri, 26 Nov 2021 21:37:19 +0800 Subject: [PATCH 10/30] parallel testing --- .github/workflows/dart.yml | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml index 2df8f3f8..7b28d272 100644 --- a/.github/workflows/dart.yml +++ b/.github/workflows/dart.yml @@ -16,6 +16,23 @@ on: jobs: test: name: Build test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: subosito/flutter-action@v1 + with: + channel: "stable" + - run: dart --version + - run: flutter --version + - run: flutter test + - name: publish test + run: flutter pub publish --dry-run + - name: android build + run: | + cd example + flutter build appbundle + test-macos: + name: iOS build test runs-on: macos-latest steps: - uses: actions/checkout@v2 @@ -27,12 +44,8 @@ jobs: channel: "stable" - run: dart --version - run: flutter --version - - run: flutter test - name: iOS build run: | cd example flutter build ios --release --no-codesign - - name: android build - run: | - cd example - flutter build appbundle + From 7623675a92c2f4bc06cdce9e8cdae6fa31394fc6 Mon Sep 17 00:00:00 2001 From: Thomas Date: Fri, 26 Nov 2021 22:12:00 +0800 Subject: [PATCH 11/30] cherrypick workflows, changelog --- .github/workflow/dart.yml | 38 ++++++ .github/workflow/prerelease.yml | 50 ++++++++ .github/workflow/release.yml | 42 +++++++ CHANGELOG.md | 2 +- analysis_options.yaml | 1 - azure-pipelines.yml | 203 -------------------------------- pubspec.yaml | 4 +- 7 files changed, 133 insertions(+), 207 deletions(-) create mode 100644 .github/workflow/dart.yml create mode 100644 .github/workflow/prerelease.yml create mode 100644 .github/workflow/release.yml delete mode 100644 analysis_options.yaml delete mode 100644 azure-pipelines.yml diff --git a/.github/workflow/dart.yml b/.github/workflow/dart.yml new file mode 100644 index 00000000..b62bfb91 --- /dev/null +++ b/.github/workflow/dart.yml @@ -0,0 +1,38 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +name: build + +on: + push: + branches: [develop, release, hotfix, master] + pull_request: + branches: [develop, release, hotfix, master] + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + test: + name: Build test + runs-on: macos-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-java@v1 + with: + java-version: "12.x" + - uses: subosito/flutter-action@v1 + with: + channel: "stable" + - run: dart --version + - run: flutter --version + - run: flutter test + - name: iOS build + run: | + cd example + flutter build ios --release --no-codesign + - name: android build + run: | + cd example + flutter build appbundle \ No newline at end of file diff --git a/.github/workflow/prerelease.yml b/.github/workflow/prerelease.yml new file mode 100644 index 00000000..b836df6a --- /dev/null +++ b/.github/workflow/prerelease.yml @@ -0,0 +1,50 @@ +# This is a basic workflow to help you get started with Actions + +name: prerelease + +# Controls when the workflow will run +on: + # Triggers the workflow on push or pull request events but only for the develop branch + push: + branches: [release, hotfix] + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job called "build" + prerelease: + name: Development Release + # The type of runner that the job will run on + runs-on: ubuntu-latest + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v2 + - uses: subosito/flutter-action@v1 + with: + channel: "stable" + - run: dart --version + - run: flutter --version + - name: Edit pubspec.ymal for dev release + run: | + sed -i "s/version.*/&-$GITHUB_RUN_ID/" pubspec.yaml + - name: Get Changelog Entry + id: changelog_reader + uses: mindsers/changelog-reader-action@v2.0.0 + - name: Edit changelog.md for dev release + run: | + sed -i "0,/\#\# \[.*/s//## [${{steps.changelog_reader.outputs.version}}-$GITHUB_RUN_ID]/" CHANGELOG.md + cat CHANGELOG.md + - name: Setup credentials + run: | + cat < $PUB_CACHE/credentials.json + ${{ secrets.CREDENTIALS }} + EOF + - name: Publish package + run: flutter pub publish --force + - name: Add entry to Github release + uses: softprops/action-gh-release@v1 + with: + tag_name: ${{ steps.changelog_reader.outputs.version }}+${{ github.run_id }} + prerelease: true \ No newline at end of file diff --git a/.github/workflow/release.yml b/.github/workflow/release.yml new file mode 100644 index 00000000..35967b42 --- /dev/null +++ b/.github/workflow/release.yml @@ -0,0 +1,42 @@ +# This is a basic workflow to help you get started with Actions + +name: release + +# Controls when the workflow will run +on: + # Triggers the workflow on push or pull request events but only for the develop branch + push: + branches: [master] + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job called "build" + release: + # The type of runner that the job will run on + runs-on: ubuntu-latest + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v2 + - uses: subosito/flutter-action@v1 + with: + channel: "stable" + - run: dart --version + - run: flutter --version + - name: Setup credentials + run: | + cat < $PUB_CACHE/credentials.json + ${{ secrets.CREDENTIALS }} + EOF + - name: Publish package + run: flutter pub publish --force + - name: Get Changelog Entry + id: changelog_reader + uses: mindsers/changelog-reader-action@v2.0.0 + - name: Add entry to Github release + uses: softprops/action-gh-release@v1 + with: + tag_name: ${{ steps.changelog_reader.outputs.version }} + body: ${{ steps.changelog_reader.outputs.changes }} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 061b9d2f..e0fa453b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -## 4.0.0 +## [3.9.0] * Migrated to null safety * Updated multiple underlying dependencies diff --git a/analysis_options.yaml b/analysis_options.yaml deleted file mode 100644 index d4fcc1ad..00000000 --- a/analysis_options.yaml +++ /dev/null @@ -1 +0,0 @@ -include: package:pedantic/analysis_options.yaml \ No newline at end of file diff --git a/azure-pipelines.yml b/azure-pipelines.yml deleted file mode 100644 index e608a2d7..00000000 --- a/azure-pipelines.yml +++ /dev/null @@ -1,203 +0,0 @@ -variables: - # The $(FlutterToolPath) variable is generated by the FlutterInstall task - # See code in the Flutter Build task https://github.com/aloisdeniel/vsts-flutter-tasks/blob/master/tasks/build/index.ts - flutterExecPath: $(FlutterToolPath)/flutter.bat - versionNumberRegex: '(?<=version: ).*' - -trigger: - batch: 'true' - branches: - include: - - develop - - release - - hotfix - - master - -stages: - # ----------- CI ----------- - - stage: Build - jobs: - - job: BuildAndroidAndIos - pool: - vmImage: 'macOS-latest' - steps: - - task: FlutterInstall@0 - displayName: 'Flutter install' - inputs: - channel: 'stable' - version: 'latest' - - - task: FlutterBuild@0 - displayName: 'Flutter build - Android' - inputs: - target: 'aab' - buildNumber: $(Build.BuildID) - projectDirectory: 'example' - - - task: FlutterBuild@0 - displayName: 'Flutter build - iOS' - inputs: - target: 'ios' - projectDirectory: 'example' - iosCodesign: false - - # -----------CD Pre-release ----------- - - stage: DevelopmentRelease - dependsOn: Build - condition: and(succeeded(), in(variables['Build.SourceBranch'], 'refs/heads/release', 'refs/heads/hotfix')) - jobs: - - job: ReleaseDevelopmentVersion - pool: - vmImage: 'windows-latest' - steps: - - task: FlutterInstall@0 - displayName: 'Flutter install' - inputs: - channel: 'stable' - version: 'latest' - - - task: PowerShell@2 - displayName: 'Pre-release versioning - pubspec.yaml' - inputs: - targetType: 'inline' - script: | - [string] $version = select-string -path "$(Build.SourcesDirectory)/pubspec.yaml" -pattern "$(versionNumberRegex)" | %{ $_.Matches[0].Value } - Write-Host "##vso[task.setvariable variable=currentVersion]$version" - - [string] $pubspecContent = Get-Content -Path "$(Build.SourcesDirectory)/pubspec.yaml" -Raw - - Write-Host " (i) Current version: $version" - Write-Host " (i) Original pubspec.yaml content: $pubspecContent" - - [bool] $hasMatches = $pubspecContent -match $versionRegex - - [string] $newPubspecContent = $pubspecContent -replace $version, "$version-dev.$(Build.BuildID)" - - Write-Host " (i) Updated pubspec.yaml content: $newPubspecContent" - - $newPubspecContent | Set-Content -Path "$(Build.SourcesDirectory)/pubspec.yaml" - - - task: PowerShell@2 - displayName: 'Pre-release versioning - CHANGELOG.md' - inputs: - targetType: 'inline' - script: | - [string] $changelogContent = Get-Content -Path "$(Build.SourcesDirectory)/CHANGELOG.md" -Raw - - Write-Host " (i) Current version: $env.currentVersion" - Write-Host " (i) Original CHANGELOG.md content: $changelogContent" - - [string] $newChangelogContent = $changelogContent -replace $env:currentVersion, "$env:currentVersion-dev.$(Build.BuildID)" - - Write-Host " (i) Updated CHANGELOG.md content: $newChangelogContent" - - $newChangelogContent | Set-Content -Path "$(Build.SourcesDirectory)/CHANGELOG.md" - - - task: PowerShell@2 - displayName: 'Create publisher credentials file' - inputs: - targetType: 'inline' - script: | - cd $(FlutterToolPath) - cd.. - cd .pub-cache/ - - $credentials = @{ - accessToken = "$(ACCESS_TOKEN)" - refreshToken = "$(REFRESH_TOKEN)" - tokenEndpoint = "$(TOKEN_ENDPOINT)" - scopes = @("https://www.googleapis.com/auth/userinfo.email","openid") - expiration = $(EXPIRATION) - } | ConvertTo-Json | Out-File -FilePath .\credentials.json -Encoding UTF8 - - - task: CmdLine@2 - displayName: 'Dry run publish' - inputs: - workingDirectory: '$(Build.SourcesDirectory)' - script: '$(flutterExecPath) pub publish --dry-run' - - - task: CmdLine@2 - displayName: 'Publish' - inputs: - workingDirectory: '$(Build.SourcesDirectory)' - script: '$(flutterExecPath) pub publish --force' - - # ----------- CD Production ----------- - - stage: Release - dependsOn: Build - condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master')) - jobs: - - job: Release - pool: - vmImage: 'windows-latest' - steps: - - task: FlutterInstall@0 - displayName: 'Flutter install' - inputs: - channel: 'stable' - version: 'latest' - - - task: PowerShell@2 - displayName: 'Get version from pubspec.yaml' - inputs: - targetType: 'inline' - script: | - [string] $version = select-string -path "$(Build.SourcesDirectory)/pubspec.yaml" -pattern "$(versionNumberRegex)" | %{ $_.Matches[0].Value } - - Write-Host "##vso[task.setvariable variable=currentVersion]$version" - - - task: PowerShell@2 - displayName: 'Get version summary from CHANGELOG.md' - inputs: - targetType: 'inline' - script: | - [string] $summary = select-string -path "$(Build.SourcesDirectory)/CHANGELOG.md" -pattern "($([regex]::escape($env:currentVersion))).*" | %{ $_.Matches[0].Value } - - Write-Host "##vso[task.setvariable variable=versionSummary]$summary" - - - task: PowerShell@2 - displayName: 'Create publisher credentials file' - inputs: - targetType: 'inline' - script: | - cd $(FlutterToolPath) - cd.. - cd .pub-cache/ - - $credentials = @{ - accessToken = "$(ACCESS_TOKEN)" - refreshToken = "$(REFRESH_TOKEN)" - tokenEndpoint = "$(TOKEN_ENDPOINT)" - scopes = @("https://www.googleapis.com/auth/userinfo.email","openid") - expiration = $(EXPIRATION) - } | ConvertTo-Json | Out-File -FilePath .\credentials.json -Encoding UTF8 - - - task: CmdLine@2 - displayName: 'Dry run publish' - inputs: - workingDirectory: '$(Build.SourcesDirectory)' - script: '$(flutterExecPath) pub publish --dry-run' - - - task: CmdLine@2 - displayName: 'Publish' - inputs: - workingDirectory: '$(Build.SourcesDirectory)' - script: '$(flutterExecPath) pub publish --force' - - - task: GitHubReleasePublish@1 - displayName: 'Tag a release to GitHub' - inputs: - githubEndpoint: 'GitHub Tagging' - manuallySetRepository: false - githubRepository: 'builttoroam/device_calendar' - githubTag: 'v$(currentVersion)' - githubReleaseTitle: '$(versionSummary)' - githubReleaseDraft: false - githubReleasePrerelease: false - githubIgnoreAssets: false - githubReleaseAsset: '$(Build.ArtifactStagingDirectory)/*' - githubReuseRelease: false - githubReuseDraftOnly: false - githubSkipDuplicatedAssets: false - githubEditRelease: false - githubDeleteEmptyTag: false \ No newline at end of file diff --git a/pubspec.yaml b/pubspec.yaml index a30331e0..4d90b269 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: device_calendar description: A cross platform plugin for modifying calendars on the user's device. -version: 4.0.0 +version: 3.9.0 homepage: https://github.com/builttoroam/device_calendar/tree/master dependencies: @@ -13,7 +13,7 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - pedantic: ^1.11.0 + flutter_lints: ^1.0.4 # The following section is specific to Flutter. flutter: From 9faf81aad644bf154d145261a750a61e63b6243c Mon Sep 17 00:00:00 2001 From: Thomas Date: Fri, 26 Nov 2021 22:44:35 +0800 Subject: [PATCH 12/30] folder fix --- .github/{workflow => workflows}/dart.yml | 0 .github/{workflow => workflows}/prerelease.yml | 0 .github/{workflow => workflows}/release.yml | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename .github/{workflow => workflows}/dart.yml (100%) rename .github/{workflow => workflows}/prerelease.yml (100%) rename .github/{workflow => workflows}/release.yml (100%) diff --git a/.github/workflow/dart.yml b/.github/workflows/dart.yml similarity index 100% rename from .github/workflow/dart.yml rename to .github/workflows/dart.yml diff --git a/.github/workflow/prerelease.yml b/.github/workflows/prerelease.yml similarity index 100% rename from .github/workflow/prerelease.yml rename to .github/workflows/prerelease.yml diff --git a/.github/workflow/release.yml b/.github/workflows/release.yml similarity index 100% rename from .github/workflow/release.yml rename to .github/workflows/release.yml From acdd3be970dce3e9c30f5c09cef434fdf2fa5aeb Mon Sep 17 00:00:00 2001 From: sowens-csd Date: Sat, 27 Nov 2021 07:57:35 -0500 Subject: [PATCH 13/30] Minor updates to README text. --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 1e579e7d..3b880b71 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ A cross platform plugin for modifying calendars on the user's device. ## Timezone support with TZDateTime -Due to feedback we received, starting from `v4.0.0` we will be utilizing `timezone` package to better handle all the timezone data. +Due to feedback we received, starting from `v4.0.0` we will be using the `timezone` package to better handle all timezone data. This is already included in this package. However, you need to add this line whenever the package is needed. @@ -36,7 +36,7 @@ If you don't need any timezone specific features in your app, you may use `flutt ```dart import 'package:flutter_native_timezone/flutter_native_timezone.dart'; -//As an example, our default timezone is UTC. +// As an example, our default timezone is UTC. Location _currentLocation = getLocation('Etc/UTC'); Future setCurentLocation() async { @@ -59,14 +59,14 @@ For other use cases, feedback or future developments on the feature, feel free t ## Null-safety migration -From `v3.9.0`, device_calendar is null-safe. However, not all workflow had been checked and bugs from older versions still presist. +From `v3.9.0`, device_calendar is null-safe. However, not all workflows have been checked and bugs from older versions still persist. You are strongly advised to test your workflow with the new package before shipping. Better yet, please leave a note for what works and what doesn't, or contribute some bug fixes! ## Android Integration -The following will need to be added to the `AndroidManifest.xml` file for your application to indicate permissions to modify calendars a needed +The following will need to be added to the `AndroidManifest.xml` file for your application to indicate permissions to modify calendars are needed ```xml From d8a62b369f9a7f69ecc2fc8e0205eaf4471d0a1e Mon Sep 17 00:00:00 2001 From: Thomas Date: Sun, 28 Nov 2021 22:15:17 +0800 Subject: [PATCH 14/30] V4.0.0 final prep (#370) * Removed a redundant block (#194) * cherrypick workflows, changelog * folder fix * set version to v4 * changelog update Co-authored-by: Brett Lim Co-authored-by: Nick Randolph Co-authored-by: Built to Roam Admin --- CHANGELOG.md | 21 ++++++++++----------- pubspec.yaml | 4 ++-- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 801b1942..3c44ed2d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,26 +1,25 @@ # Changelog -To benefit from the current changelog reader in CI/CD, please follow the changelog format from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). + -## [4.0.1] +## [4.0.0](https://github.com/builttoroam/device_calendar/releases/tag/4.0.0) -- Timezone plugin and logic implemented. Fixed all issues related to timezone. +- Timezone plugin and logic implemented. All issues related to timezone shoulde be fixed. +- Events.availability defaults to busy when not specified [354](https://github.com/builttoroam/device_calendar/pull/354) +- Events parameter now includes location and url. [319](https://github.com/builttoroam/device_calendar/pull/319) - Android: Fixed bug where platform exception appeared, when Events.availability was null on Event [241](https://github.com/builttoroam/device_calendar/issues/241) -- Fixed example app issues [270](https://github.com/builttoroam/device_calendar/issues/270), [268](https://github.com/builttoroam/device_calendar/issues/268) -- Android code variable order fix for issue [258](https://github.com/builttoroam/device_calendar/issues/258) +- Fixed various issues in example [270](https://github.com/builttoroam/device_calendar/issues/270), [268](https://github.com/builttoroam/device_calendar/issues/268) +- Android: deleteEvent code aligned with flutter [258](https://github.com/builttoroam/device_calendar/issues/258) +- Android: Updated to V2 embeddding [326](https://github.com/builttoroam/device_calendar/issues/326) +- iOS: Updated swift versions, possibly improved compability with Obj-C [flutter/flutter#16049 (comment)](https://github.com/flutter/flutter/issues/16049#issuecomment-611192738) -## [4.0.0] +## [3.9.0](https://github.com/builttoroam/device_calendar/releases/tag/3.9.0) - Migrated to null safety - Updated multiple underlying dependencies - Rebuilt iOS podfile - Upgraded to new Android plugins APIs for flutter -## 3.2.0 - -- Added time zone support -- Project hierarchy update and clean up - ## 3.1.0 25th March 2020 - Bug fixes and new features - Boolean variable `isDefault` added for issue [145](https://github.com/builttoroam/device_calendar/issues/145) (**NOTE**: This is not supported Android API 16 or lower, `isDefault` will always be false) diff --git a/pubspec.yaml b/pubspec.yaml index 2c9a2237..dc895d91 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: device_calendar description: A cross platform plugin for modifying calendars on the user's device. -version: 4.0.1 +version: 4.0.0 homepage: https://github.com/builttoroam/device_calendar/tree/master dependencies: @@ -15,7 +15,7 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - lints: ^1.0.1 + flutter_lints: ^1.0.4 # The following section is specific to Flutter. flutter: From 3f242166ca651fc7268152c85f7ff33e6b9f79ca Mon Sep 17 00:00:00 2001 From: Thomas Date: Fri, 3 Dec 2021 23:05:22 +0800 Subject: [PATCH 15/30] renaming --- CHANGELOG.md | 4 ++++ .../com/builttoroam/devicecalendar/CalendarDelegate.kt | 10 +++++----- .../builttoroam/devicecalendar/DeviceCalendarPlugin.kt | 4 ++-- .../com/builttoroam/devicecalendar/models/Event.kt | 4 ++-- ios/Classes/SwiftDeviceCalendarPlugin.swift | 8 ++++---- pubspec.yaml | 2 +- 6 files changed, 18 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c44ed2d..1d6fc64d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ +## [4.0.1](https://github.com/builttoroam/device_calendar/releases/tag/4.1.0) + +- Fixes event time retrieved + ## [4.0.0](https://github.com/builttoroam/device_calendar/releases/tag/4.0.0) - Timezone plugin and logic implemented. All issues related to timezone shoulde be fixed. diff --git a/android/src/main/kotlin/com/builttoroam/devicecalendar/CalendarDelegate.kt b/android/src/main/kotlin/com/builttoroam/devicecalendar/CalendarDelegate.kt index e3dc8b24..6df728be 100644 --- a/android/src/main/kotlin/com/builttoroam/devicecalendar/CalendarDelegate.kt +++ b/android/src/main/kotlin/com/builttoroam/devicecalendar/CalendarDelegate.kt @@ -471,7 +471,7 @@ class CalendarDelegate : PluginRegistry.RequestPermissionsResultListener { if (event.allDay) { val calendar = java.util.Calendar.getInstance() - calendar.timeInMillis = event.start!! + calendar.timeInMillis = event.eventStartDate!! calendar.set(java.util.Calendar.HOUR, 0) calendar.set(java.util.Calendar.MINUTE, 0) calendar.set(java.util.Calendar.SECOND, 0) @@ -481,10 +481,10 @@ class CalendarDelegate : PluginRegistry.RequestPermissionsResultListener { values.put(Events.DTEND, calendar.timeInMillis) values.put(Events.EVENT_TIMEZONE, getTimeZone(event.startTimeZone).id) } else { - values.put(Events.DTSTART, event.start!!) + values.put(Events.DTSTART, event.eventStartDate!!) values.put(Events.EVENT_TIMEZONE, getTimeZone(event.startTimeZone).id) - values.put(Events.DTEND, event.end!!) + values.put(Events.DTEND, event.eventEndDate!!) values.put(Events.EVENT_END_TIMEZONE, getTimeZone(event.endTimeZone).id) } values.put(Events.TITLE, event.title) @@ -717,8 +717,8 @@ class CalendarDelegate : PluginRegistry.RequestPermissionsResultListener { event.eventId = eventId.toString() event.calendarId = calendarId event.description = description - event.start = begin - event.end = end + event.eventStartDate = begin + event.eventEndDate = end event.allDay = allDay event.location = location event.url = url diff --git a/android/src/main/kotlin/com/builttoroam/devicecalendar/DeviceCalendarPlugin.kt b/android/src/main/kotlin/com/builttoroam/devicecalendar/DeviceCalendarPlugin.kt index a2cdba83..9a544551 100644 --- a/android/src/main/kotlin/com/builttoroam/devicecalendar/DeviceCalendarPlugin.kt +++ b/android/src/main/kotlin/com/builttoroam/devicecalendar/DeviceCalendarPlugin.kt @@ -169,8 +169,8 @@ class DeviceCalendarPlugin() : FlutterPlugin, MethodCallHandler, ActivityAware { event.eventId = call.argument(EVENT_ID_ARGUMENT) event.description = call.argument(EVENT_DESCRIPTION_ARGUMENT) event.allDay = call.argument(EVENT_ALL_DAY_ARGUMENT) ?: false - event.start = call.argument(EVENT_START_DATE_ARGUMENT)!! - event.end = call.argument(EVENT_END_DATE_ARGUMENT)!! + event.eventStartDate = call.argument(EVENT_START_DATE_ARGUMENT)!! + event.eventEndDate = call.argument(EVENT_END_DATE_ARGUMENT)!! event.startTimeZone = call.argument(EVENT_START_TIMEZONE_ARGUMENT) event.endTimeZone = call.argument(EVENT_END_TIMEZONE_ARGUMENT) event.location = call.argument(EVENT_LOCATION_ARGUMENT) diff --git a/android/src/main/kotlin/com/builttoroam/devicecalendar/models/Event.kt b/android/src/main/kotlin/com/builttoroam/devicecalendar/models/Event.kt index 2b9242af..b8a07b76 100644 --- a/android/src/main/kotlin/com/builttoroam/devicecalendar/models/Event.kt +++ b/android/src/main/kotlin/com/builttoroam/devicecalendar/models/Event.kt @@ -6,8 +6,8 @@ class Event { var eventId: String? = null var calendarId: String? = null var description: String? = null - var start: Long? = null - var end: Long? = null + var eventStartDate: Long? = null + var eventEndDate: Long? = null var startTimeZone: String? = null var endTimeZone: String? = null var allDay: Boolean = false diff --git a/ios/Classes/SwiftDeviceCalendarPlugin.swift b/ios/Classes/SwiftDeviceCalendarPlugin.swift index d1a33410..111380c2 100644 --- a/ios/Classes/SwiftDeviceCalendarPlugin.swift +++ b/ios/Classes/SwiftDeviceCalendarPlugin.swift @@ -28,8 +28,8 @@ public class SwiftDeviceCalendarPlugin: NSObject, FlutterPlugin { let calendarId: String let title: String let description: String? - let start: Int64 - let end: Int64 + let eventStartDate: Int64 + let eventEndDate: Int64 let startTimeZone: String? let allDay: Bool let attendees: [Attendee] @@ -352,8 +352,8 @@ public class SwiftDeviceCalendarPlugin: NSObject, FlutterPlugin { calendarId: calendarId, title: ekEvent.title ?? "New Event", description: ekEvent.notes, - start: Int64(ekEvent.startDate.millisecondsSinceEpoch), - end: Int64(ekEvent.endDate.millisecondsSinceEpoch), + eventStartDate: Int64(ekEvent.startDate.millisecondsSinceEpoch), + eventEndDate: Int64(ekEvent.endDate.millisecondsSinceEpoch), startTimeZone: ekEvent.timeZone?.identifier, allDay: ekEvent.isAllDay, attendees: attendees, diff --git a/pubspec.yaml b/pubspec.yaml index dc895d91..6ad9dfc1 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: device_calendar description: A cross platform plugin for modifying calendars on the user's device. -version: 4.0.0 +version: 4.0.1 homepage: https://github.com/builttoroam/device_calendar/tree/master dependencies: From 57f17509fc391bb6db90051ca36ada9a82441eac Mon Sep 17 00:00:00 2001 From: Thomas Date: Sat, 18 Dec 2021 02:02:51 +0800 Subject: [PATCH 16/30] Update device_calendar_test.dart --- test/device_calendar_test.dart | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/test/device_calendar_test.dart b/test/device_calendar_test.dart index cc34cfad..3c518cfd 100644 --- a/test/device_calendar_test.dart +++ b/test/device_calendar_test.dart @@ -64,7 +64,8 @@ void main() { final String? calendarId = null; final params = RetrieveEventsParams(); - final result = await deviceCalendarPlugin.retrieveEvents(calendarId, params); + final result = + await deviceCalendarPlugin.retrieveEvents(calendarId, params); expect(result.isSuccess, false); expect(result.errors.length, greaterThan(0)); expect(result.errors[0].errorCode, equals(ErrorCodes.invalidArguments)); @@ -105,7 +106,7 @@ void main() { test('CreateEvent_Arguments_Invalid', () async { final String? fakeCalendarId = null; - final event = Event(fakeCalendarId, availability: Availability.Busy); + final event = Event(fakeCalendarId); final result = await deviceCalendarPlugin.createOrUpdateEvent(event); expect(result!.isSuccess, false); @@ -120,7 +121,7 @@ void main() { }); final fakeCalendarId = 'fakeCalendarId'; - final event = Event(fakeCalendarId, availability: Availability.Busy); + final event = Event(fakeCalendarId); event.title = 'fakeEventTitle'; event.start = TZDateTime.now(local); event.end = event.start!.add(Duration(hours: 1)); @@ -144,7 +145,7 @@ void main() { }); final fakeCalendarId = 'fakeCalendarId'; - final event = Event(fakeCalendarId, availability: Availability.Busy); + final event = Event(fakeCalendarId); event.eventId = 'fakeEventId'; event.title = 'fakeEventTitle'; event.start = TZDateTime.now(local); @@ -178,10 +179,20 @@ void main() { test('Event_Serializes_Correctly', () async { final startTime = TZDateTime( timeZoneDatabase.locations.entries.skip(20).first.value, - 1980, 10, 1, 0, 0, 0); + 1980, + 10, + 1, + 0, + 0, + 0); final endTime = TZDateTime( timeZoneDatabase.locations.entries.skip(21).first.value, - 1980, 10, 2, 0, 0, 0); + 1980, + 10, + 2, + 0, + 0, + 0); final attendee = Attendee( name: 'Test Attendee', emailAddress: 'test@t.com', @@ -209,8 +220,10 @@ void main() { expect(newEvent.calendarId, equals(event.calendarId)); expect(newEvent.eventId, equals(event.eventId)); expect(newEvent.title, equals(event.title)); - expect(newEvent.start, equals(event.start)); - expect(newEvent.end, equals(event.end)); + expect(newEvent.start!.millisecondsSinceEpoch, + equals(event.start!.millisecondsSinceEpoch)); + expect(newEvent.end!.millisecondsSinceEpoch, + equals(event.end!.millisecondsSinceEpoch)); expect(newEvent.description, equals(event.description)); expect(newEvent.url, equals(event.url)); expect(newEvent.location, equals(event.location)); From 47bf9b0e8b7fb0c947ef82d0ad97c188b2c6efd7 Mon Sep 17 00:00:00 2001 From: Thomas Date: Sat, 18 Dec 2021 02:08:03 +0800 Subject: [PATCH 17/30] Update event.dart --- lib/src/models/event.dart | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/src/models/event.dart b/lib/src/models/event.dart index 25b3af5f..5ed9dfa6 100644 --- a/lib/src/models/event.dart +++ b/lib/src/models/event.dart @@ -56,7 +56,7 @@ class Event { this.attendees, this.recurrenceRule, this.reminders, - required this.availability, + this.availability = Availability.Busy, this.location, this.url, this.allDay = false}); @@ -72,7 +72,7 @@ class Event { description = json['eventDescription']; final int? startTimestamp = json['eventStartDate']; - final String? startLocationName = json['eventStartTimeZone']; + final String? startLocationName = json['startTimeZone']; var startTimeZone = timeZoneDatabase.locations[startLocationName]; startTimeZone ??= local; start = startTimestamp != null @@ -80,14 +80,14 @@ class Event { : TZDateTime.now(local); final int? endTimestamp = json['eventEndDate']; - final String? endLocationName = json['eventEndTimeZone']; + final String? endLocationName = json['endTimeZone']; var endLocation = timeZoneDatabase.locations[endLocationName]; endLocation ??= local; end = endTimestamp != null ? TZDateTime.fromMillisecondsSinceEpoch(endLocation, endTimestamp) : TZDateTime.now(local); - allDay = json['eventAllDay']; + allDay = json['eventAllDay'] ?? false; location = json['eventLocation']; availability = parseStringToAvailability(json['availability']); @@ -136,9 +136,11 @@ class Event { data['eventId'] = eventId; data['eventTitle'] = title; data['eventDescription'] = description; - data['eventStartDate'] = start!.millisecondsSinceEpoch; + data['eventStartDate'] = start?.millisecondsSinceEpoch ?? + TZDateTime.now(local).millisecondsSinceEpoch; data['eventStartTimeZone'] = start?.location.name; - data['eventEndDate'] = end!.millisecondsSinceEpoch; + data['eventEndDate'] = end?.millisecondsSinceEpoch ?? + TZDateTime.now(local).millisecondsSinceEpoch; data['eventEndTimeZone'] = end?.location.name; data['eventAllDay'] = allDay; data['eventLocation'] = location; From 78877c862bfd85791276cffde289c5aeb2b8ac5e Mon Sep 17 00:00:00 2001 From: Thomas Date: Mon, 29 Nov 2021 20:22:06 +0800 Subject: [PATCH 18/30] using integration test --- example/pubspec.yaml | 2 +- example/test_driver/app.dart | 11 -- example/test_driver/app_test.dart | 147 +++++++++++----------- example/test_driver/integration_test.dart | 26 ++++ test_driver/app.dart | 1 - 5 files changed, 99 insertions(+), 88 deletions(-) delete mode 100644 example/test_driver/app.dart create mode 100644 example/test_driver/integration_test.dart delete mode 100644 test_driver/app.dart diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 7e8fd492..c6eeea43 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -16,7 +16,7 @@ dependencies: cupertino_icons: dev_dependencies: - flutter_driver: + integration_test: sdk: flutter flutter_test: sdk: flutter diff --git a/example/test_driver/app.dart b/example/test_driver/app.dart deleted file mode 100644 index d4d33a8f..00000000 --- a/example/test_driver/app.dart +++ /dev/null @@ -1,11 +0,0 @@ -import 'package:flutter_driver/driver_extension.dart'; -import 'package:device_calendar_example/main.dart' as app; - -void main() { - // This line enables the extension. - enableFlutterDriverExtension(); - - // Call the `main()` function of the app, or call `runApp` with - // any widget you are interested in testing. - app.main(); -} diff --git a/example/test_driver/app_test.dart b/example/test_driver/app_test.dart index 8c9afeae..1dd39abb 100644 --- a/example/test_driver/app_test.dart +++ b/example/test_driver/app_test.dart @@ -1,93 +1,90 @@ -import 'dart:io'; - -import 'package:flutter_driver/flutter_driver.dart'; -import 'package:test/test.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:integration_test/integration_test.dart'; import 'package:uuid/uuid.dart'; +// import 'package:flutter_driver/driver_extension.dart'; +import 'package:device_calendar_example/main.dart' as app; + /// NOTE: These integration tests are currently made to be run on a physical Android device where there is at least a calendar that can be written to. -/// They will currently need to be run on a Mac as well +/// Calendar permissions are needed. See example/test_driver/integration_test.dart for how to run this void main() { + IntegrationTestWidgetsFlutterBinding.ensureInitialized(); group('Calendar plugin example', () { - FlutterDriver? driver; final eventTitle = Uuid().v1(); - final saveEventButtonFinder = find.byValueKey('saveEventButton'); + final saveEventButtonFinder = find.byKey(const Key('saveEventButton')); final eventTitleFinder = find.text(eventTitle); - setUpAll(() async { - // workaround for handling permissions based on info taken from https://github.com/flutter/flutter/issues/12561 - // this is to be run in a Mac environment - final envVars = Platform.environment; - final adbPath = envVars['ANDROID_HOME'] != null - ? envVars['ANDROID_HOME']! + '/platform-tools/adb' - : ''; - await Process.run(adbPath, [ - 'shell', - 'pm', - 'grant', - 'com.builttoroam.devicecalendarexample', - 'android.permission.INTERNET' - ]); - await Process.run(adbPath, [ - 'shell', - 'pm', - 'grant', - 'com.builttoroam.devicecalendarexample', - 'android.permission.READ_CALENDAR' - ]); - await Process.run(adbPath, [ - 'shell', - 'pm', - 'grant', - 'com.builttoroam.devicecalendarexample', - 'android.permission.WRITE_CALENDAR' - ]); - - driver = await FlutterDriver.connect(); + final firstWritableCalendarFinder = + find.byKey(const Key('writableCalendar0')); + final addEventButtonFinder = find.byKey(const Key('addEventButton')); + final titleFieldFinder = find.byKey(const Key('titleField')); + final deleteButtonFinder = find.byKey(const Key('deleteEventButton')); +//TODO: remove redundant restarts. Currently needed because the first screen is always "test starting..." + testWidgets('starts on calendars page', (WidgetTester tester) async { + app.main(); + await tester.pumpAndSettle(); + expect(find.byKey(const Key('calendarsPage')), findsOneWidget); }); + testWidgets('select first writable calendar', (WidgetTester tester) async { + app.main(); - tearDownAll(() async { - await driver?.close(); + await tester.pumpAndSettle(Duration(milliseconds: 500)); + expect(firstWritableCalendarFinder, findsOneWidget); }); + testWidgets('go to add event page', (WidgetTester tester) async { + app.main(); + await tester.pumpAndSettle(); + await tester.tap(firstWritableCalendarFinder); - test('check flutter driver health', () async { - final health = await driver?.checkHealth(); - print('flutter driver status: ${health?.status}'); - }); - - test('starts on calendars page', () async { - await driver?.waitFor(find.byValueKey('calendarsPage')); - }); - test('select first writable calendar', () async { - final writableCalendarFinder = find.byValueKey('writableCalendar0'); - await driver?.waitFor(writableCalendarFinder, - timeout: Duration(milliseconds: 500)); - await driver?.tap(writableCalendarFinder); - }); - test('go to add event page', () async { - final addEventButtonFinder = find.byValueKey('addEventButton'); - await driver?.waitFor(addEventButtonFinder); + await tester.pumpAndSettle(); + expect(addEventButtonFinder, findsOneWidget); print('found add event button'); - await driver?.tap(addEventButtonFinder); - await driver?.waitFor(saveEventButtonFinder); + await tester.tap(addEventButtonFinder); + await tester.pumpAndSettle(); + expect(saveEventButtonFinder, findsOneWidget); }); - test('try to save event without entering mandatory fields', () async { - await driver?.tap(saveEventButtonFinder); - await driver?.waitFor( - find.text('Please fix the errors in red before submitting.')); + testWidgets('try to save event without entering mandatory fields', + (WidgetTester tester) async { + app.main(); + await tester.pumpAndSettle(); + await tester.tap(firstWritableCalendarFinder); + await tester.pumpAndSettle(); + await tester.tap(addEventButtonFinder); + + await tester.pumpAndSettle(); + await tester.tap(saveEventButtonFinder); + await tester.pumpAndSettle(); + expect(find.text('Please fix the errors in red before submitting.'), + findsOneWidget); }); - test('save event with title $eventTitle', () async { - final titleFieldFinder = find.byValueKey('titleField'); - await driver?.waitFor(titleFieldFinder); - await driver?.tap(titleFieldFinder); - await driver?.enterText(eventTitle); - await driver?.tap(saveEventButtonFinder); - await driver?.waitFor(eventTitleFinder); + testWidgets('save event with title $eventTitle', + (WidgetTester tester) async { + app.main(); + await tester.pumpAndSettle(); + await tester.tap(firstWritableCalendarFinder); + await tester.pumpAndSettle(); + await tester.tap(addEventButtonFinder); + + await tester.pumpAndSettle(); + await tester.tap(titleFieldFinder); + + await tester.enterText(titleFieldFinder, eventTitle); + await tester.tap(saveEventButtonFinder); + await tester.pumpAndSettle(); + expect(eventTitleFinder, findsOneWidget); }); - test('delete event with title $eventTitle', () async { - await driver?.tap(eventTitleFinder); - final deleteButtonFinder = find.byValueKey('deleteEventButton'); - await driver?.scrollIntoView(deleteButtonFinder); - await driver?.tap(deleteButtonFinder); - await driver?.waitForAbsent(eventTitleFinder); + testWidgets('delete event with title $eventTitle', + (WidgetTester tester) async { + app.main(); + await tester.pumpAndSettle(); + await tester.tap(firstWritableCalendarFinder); + await tester.pumpAndSettle(); + await tester.tap(eventTitleFinder); + + await tester.scrollUntilVisible(deleteButtonFinder, 5); + await tester.tap(deleteButtonFinder); + await tester.pumpAndSettle(); + expect(eventTitleFinder, findsNothing); }); }); } diff --git a/example/test_driver/integration_test.dart b/example/test_driver/integration_test.dart new file mode 100644 index 00000000..3c9e4fc4 --- /dev/null +++ b/example/test_driver/integration_test.dart @@ -0,0 +1,26 @@ +import 'dart:io'; + +import 'package:integration_test/integration_test_driver.dart'; + +// make sure 'adb devices' works on your local machine, then run the following: +/* +flutter drive \ --driver=test_driver/integration_test.dart \ --target=integration_test/app_test.dart + */ + +Future main() async { + await Process.run('adb', [ + 'shell', + 'pm', + 'grant', + 'com.builttoroam.devicecalendarexample', + 'android.permission.READ_CALENDAR' + ]); + await Process.run('adb', [ + 'shell', + 'pm', + 'grant', + 'com.builttoroam.devicecalendarexample', + 'android.permission.WRITE_CALENDAR' + ]); + await integrationDriver(); +} diff --git a/test_driver/app.dart b/test_driver/app.dart deleted file mode 100644 index 8b137891..00000000 --- a/test_driver/app.dart +++ /dev/null @@ -1 +0,0 @@ - From d0c8370fc882e917781f83e6c156dd4f08d7293e Mon Sep 17 00:00:00 2001 From: Thomas Date: Tue, 30 Nov 2021 05:18:37 +0800 Subject: [PATCH 19/30] fix depreciated items --- example/lib/presentation/pages/calendar_add.dart | 10 ++++++---- example/lib/presentation/pages/calendar_event.dart | 9 +++++---- example/lib/presentation/pages/calendar_events.dart | 2 +- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/example/lib/presentation/pages/calendar_add.dart b/example/lib/presentation/pages/calendar_add.dart index 519928eb..abce3788 100644 --- a/example/lib/presentation/pages/calendar_add.dart +++ b/example/lib/presentation/pages/calendar_add.dart @@ -15,7 +15,7 @@ class _CalendarAddPageState extends State { final GlobalKey _scaffoldKey = GlobalKey(); late DeviceCalendarPlugin _deviceCalendarPlugin; - bool _autovalidate = false; + AutovalidateMode _autovalidate = AutovalidateMode.disabled; String _calendarName = ''; ColorChoice? _colorChoice; String _localAccountName = ''; @@ -32,7 +32,7 @@ class _CalendarAddPageState extends State { title: Text('Create Calendar'), ), body: Form( - autovalidate: _autovalidate, + autovalidateMode: _autovalidate, key: _formKey, child: Container( padding: EdgeInsets.all(10), @@ -81,7 +81,8 @@ class _CalendarAddPageState extends State { onPressed: () async { final form = _formKey.currentState; if (form?.validate() == false) { - _autovalidate = true; // Start validating on every change. + _autovalidate = + AutovalidateMode.always; // Start validating on every change. showInSnackBar('Please fix the errors in red before submitting.'); } else { form?.save(); @@ -115,7 +116,8 @@ class _CalendarAddPageState extends State { } void showInSnackBar(String value) { - _scaffoldKey.currentState?.showSnackBar(SnackBar(content: Text(value))); + ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(value))); + // _scaffoldKey.currentState?.showSnackBar(SnackBar(content: Text(value))); } } diff --git a/example/lib/presentation/pages/calendar_event.dart b/example/lib/presentation/pages/calendar_event.dart index b57305d3..44ee7edf 100644 --- a/example/lib/presentation/pages/calendar_event.dart +++ b/example/lib/presentation/pages/calendar_event.dart @@ -43,7 +43,7 @@ class _CalendarEventPageState extends State { TZDateTime? _endDate; late TimeOfDay _endTime; - bool _autovalidate = false; + AutovalidateMode _autovalidate = AutovalidateMode.disabled; DayOfWeekGroup? _dayOfWeekGroup = DayOfWeekGroup.None; bool _isRecurringEvent = false; @@ -181,7 +181,7 @@ class _CalendarEventPageState extends State { child: Column( children: [ Form( - autovalidate: _autovalidate, + autovalidateMode: _autovalidate, key: _formKey, child: Column( children: [ @@ -808,7 +808,8 @@ class _CalendarEventPageState extends State { onPressed: () async { final form = _formKey.currentState; if (form?.validate() == false) { - _autovalidate = true; // Start validating on every change. + _autovalidate = + AutovalidateMode.always; // Start validating on every change. showInSnackBar('Please fix the errors in red before submitting.'); } else { form?.save(); @@ -1012,6 +1013,6 @@ class _CalendarEventPageState extends State { } void showInSnackBar(String value) { - _scaffoldKey.currentState!.showSnackBar(SnackBar(content: Text(value))); + ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(value))); } } diff --git a/example/lib/presentation/pages/calendar_events.dart b/example/lib/presentation/pages/calendar_events.dart index 2172b965..0cd6f182 100644 --- a/example/lib/presentation/pages/calendar_events.dart +++ b/example/lib/presentation/pages/calendar_events.dart @@ -100,7 +100,7 @@ class _CalendarEventsPageState extends State { if (deleteSucceeded) { await _retrieveCalendarEvents(); } else { - _scaffoldstate.currentState!.showSnackBar(SnackBar( + ScaffoldMessenger.of(context).showSnackBar(SnackBar( content: Text('Oops, we ran into an issue deleting the event'), backgroundColor: Colors.red, duration: Duration(seconds: 5), From 4d2c31e46dde8745efe1fdb6bbe1d7a4a3068bd1 Mon Sep 17 00:00:00 2001 From: Thomas Date: Sat, 18 Dec 2021 23:53:17 +0800 Subject: [PATCH 20/30] gradle update --- android/build.gradle | 14 +++++++------- .../builttoroam/devicecalendar/CalendarDelegate.kt | 4 ++-- example/android/app/build.gradle | 10 +++++----- example/android/app/src/main/AndroidManifest.xml | 1 + example/android/build.gradle | 10 ++++------ example/android/gradle.properties | 3 +-- .../gradle/wrapper/gradle-wrapper.properties | 2 +- 7 files changed, 21 insertions(+), 23 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index 4f4f3a6c..278e67a2 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -2,14 +2,14 @@ group 'com.builttoroam.devicecalendar' version '1.0-SNAPSHOT' buildscript { - ext.kotlin_version = '1.3.50' + ext.kotlin_version = '1.6.0' repositories { google() - jcenter() + mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:4.1.0' + classpath 'com.android.tools.build:gradle:4.1.3' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } @@ -17,7 +17,7 @@ buildscript { rootProject.allprojects { repositories { google() - jcenter() + mavenCentral() } } @@ -41,8 +41,8 @@ android { dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - implementation 'com.google.code.gson:gson:2.8.5' - api 'androidx.appcompat:appcompat:1.0.2' + implementation 'com.google.code.gson:gson:2.8.8' + api 'androidx.appcompat:appcompat:1.4.0' implementation 'org.dmfs:lib-recur:0.11.2' - implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.5' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.0' } diff --git a/android/src/main/kotlin/com/builttoroam/devicecalendar/CalendarDelegate.kt b/android/src/main/kotlin/com/builttoroam/devicecalendar/CalendarDelegate.kt index 6df728be..f38d63df 100644 --- a/android/src/main/kotlin/com/builttoroam/devicecalendar/CalendarDelegate.kt +++ b/android/src/main/kotlin/com/builttoroam/devicecalendar/CalendarDelegate.kt @@ -1,4 +1,4 @@ -package com.builttoroam.devicecalendar +package com.builttoroam.devicecalendar import android.Manifest import android.annotation.SuppressLint @@ -863,7 +863,7 @@ class CalendarDelegate : PluginRegistry.RequestPermissionsResultListener { @Synchronized private fun generateUniqueRequestCodeAndCacheParameters(parameters: CalendarMethodsParametersCacheModel): Int { // TODO we can ran out of Int's at some point so this probably should re-use some of the freed ones - val uniqueRequestCode: Int = (_cachedParametersMap.keys.max() ?: 0) + 1 + val uniqueRequestCode: Int = (_cachedParametersMap.keys.maxOrNull() ?: 0) + 1 parameters.ownCacheKey = uniqueRequestCode _cachedParametersMap[uniqueRequestCode] = parameters diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index 9179e557..9d6a815c 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -16,7 +16,7 @@ apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { - compileSdkVersion 29 + compileSdkVersion 31 ndkVersion '22.1.7171670' sourceSets { @@ -31,7 +31,7 @@ android { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "com.builttoroam.devicecalendarexample" minSdkVersion 16 - targetSdkVersion 29 + targetSdkVersion 31 versionCode 1 versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" @@ -52,7 +52,7 @@ flutter { dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - testImplementation 'junit:junit:4.12' - androidTestImplementation 'androidx.test:runner:1.2.0' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + testImplementation 'junit:junit:4.13.2' + androidTestImplementation 'androidx.test:runner:1.4.0' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' } diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml index b66dec90..630265e9 100644 --- a/example/android/app/src/main/AndroidManifest.xml +++ b/example/android/app/src/main/AndroidManifest.xml @@ -22,6 +22,7 @@ android:value="2" /> Date: Sat, 18 Dec 2021 23:57:48 +0800 Subject: [PATCH 21/30] more renaming --- .../devicecalendar/CalendarDelegate.kt | 32 +++++++++---------- .../devicecalendar/DeviceCalendarPlugin.kt | 14 ++++---- .../devicecalendar/models/Event.kt | 14 ++++---- ios/Classes/SwiftDeviceCalendarPlugin.swift | 12 +++---- 4 files changed, 36 insertions(+), 36 deletions(-) diff --git a/android/src/main/kotlin/com/builttoroam/devicecalendar/CalendarDelegate.kt b/android/src/main/kotlin/com/builttoroam/devicecalendar/CalendarDelegate.kt index 6df728be..63ffc2e4 100644 --- a/android/src/main/kotlin/com/builttoroam/devicecalendar/CalendarDelegate.kt +++ b/android/src/main/kotlin/com/builttoroam/devicecalendar/CalendarDelegate.kt @@ -467,9 +467,9 @@ class CalendarDelegate : PluginRegistry.RequestPermissionsResultListener { private fun buildEventContentValues(event: Event, calendarId: String): ContentValues { val values = ContentValues() val duration: String? = null - values.put(Events.ALL_DAY, event.allDay) + values.put(Events.ALL_DAY, event.eventAllDay) - if (event.allDay) { + if (event.eventAllDay) { val calendar = java.util.Calendar.getInstance() calendar.timeInMillis = event.eventStartDate!! calendar.set(java.util.Calendar.HOUR, 0) @@ -479,18 +479,18 @@ class CalendarDelegate : PluginRegistry.RequestPermissionsResultListener { values.put(Events.DTSTART, calendar.timeInMillis) values.put(Events.DTEND, calendar.timeInMillis) - values.put(Events.EVENT_TIMEZONE, getTimeZone(event.startTimeZone).id) + values.put(Events.EVENT_TIMEZONE, getTimeZone(event.eventStartTimeZone).id) } else { values.put(Events.DTSTART, event.eventStartDate!!) - values.put(Events.EVENT_TIMEZONE, getTimeZone(event.startTimeZone).id) + values.put(Events.EVENT_TIMEZONE, getTimeZone(event.eventStartTimeZone).id) values.put(Events.DTEND, event.eventEndDate!!) - values.put(Events.EVENT_END_TIMEZONE, getTimeZone(event.endTimeZone).id) + values.put(Events.EVENT_END_TIMEZONE, getTimeZone(event.eventEndTimeZone).id) } - values.put(Events.TITLE, event.title) - values.put(Events.DESCRIPTION, event.description) - values.put(Events.EVENT_LOCATION, event.location) - values.put(Events.CUSTOM_APP_URI, event.url) + values.put(Events.TITLE, event.eventTitle) + values.put(Events.DESCRIPTION, event.eventDescription) + values.put(Events.EVENT_LOCATION, event.eventLocation) + values.put(Events.CUSTOM_APP_URI, event.eventURL) values.put(Events.CALENDAR_ID, calendarId) values.put(Events.DURATION, duration) values.put(Events.AVAILABILITY, getAvailability(event.availability)) @@ -713,18 +713,18 @@ class CalendarDelegate : PluginRegistry.RequestPermissionsResultListener { val availability = parseAvailability(cursor.getInt(EVENT_PROJECTION_AVAILABILITY_INDEX)) val event = Event() - event.title = title ?: "New Event" + event.eventTitle = title ?: "New Event" event.eventId = eventId.toString() event.calendarId = calendarId - event.description = description + event.eventDescription = description event.eventStartDate = begin event.eventEndDate = end - event.allDay = allDay - event.location = location - event.url = url + event.eventAllDay = allDay + event.eventLocation = location + event.eventURL = url event.recurrenceRule = parseRecurrenceRuleString(recurringRule) - event.startTimeZone = startTimeZone - event.endTimeZone = endTimeZone + event.eventStartTimeZone = startTimeZone + event.eventEndTimeZone = endTimeZone event.availability = availability return event diff --git a/android/src/main/kotlin/com/builttoroam/devicecalendar/DeviceCalendarPlugin.kt b/android/src/main/kotlin/com/builttoroam/devicecalendar/DeviceCalendarPlugin.kt index 9a544551..34b8c222 100644 --- a/android/src/main/kotlin/com/builttoroam/devicecalendar/DeviceCalendarPlugin.kt +++ b/android/src/main/kotlin/com/builttoroam/devicecalendar/DeviceCalendarPlugin.kt @@ -164,17 +164,17 @@ class DeviceCalendarPlugin() : FlutterPlugin, MethodCallHandler, ActivityAware { private fun parseEventArgs(call: MethodCall, calendarId: String?): Event { val event = Event() - event.title = call.argument(EVENT_TITLE_ARGUMENT) + event.eventTitle = call.argument(EVENT_TITLE_ARGUMENT) event.calendarId = calendarId event.eventId = call.argument(EVENT_ID_ARGUMENT) - event.description = call.argument(EVENT_DESCRIPTION_ARGUMENT) - event.allDay = call.argument(EVENT_ALL_DAY_ARGUMENT) ?: false + event.eventDescription = call.argument(EVENT_DESCRIPTION_ARGUMENT) + event.eventAllDay = call.argument(EVENT_ALL_DAY_ARGUMENT) ?: false event.eventStartDate = call.argument(EVENT_START_DATE_ARGUMENT)!! event.eventEndDate = call.argument(EVENT_END_DATE_ARGUMENT)!! - event.startTimeZone = call.argument(EVENT_START_TIMEZONE_ARGUMENT) - event.endTimeZone = call.argument(EVENT_END_TIMEZONE_ARGUMENT) - event.location = call.argument(EVENT_LOCATION_ARGUMENT) - event.url = call.argument(EVENT_URL_ARGUMENT) + event.eventStartTimeZone = call.argument(EVENT_START_TIMEZONE_ARGUMENT) + event.eventEndTimeZone = call.argument(EVENT_END_TIMEZONE_ARGUMENT) + event.eventLocation = call.argument(EVENT_LOCATION_ARGUMENT) + event.eventURL = call.argument(EVENT_URL_ARGUMENT) event.availability = parseAvailability(call.argument(EVENT_AVAILABILITY_ARGUMENT)) if (call.hasArgument(RECURRENCE_RULE_ARGUMENT) && call.argument>(RECURRENCE_RULE_ARGUMENT) != null) { diff --git a/android/src/main/kotlin/com/builttoroam/devicecalendar/models/Event.kt b/android/src/main/kotlin/com/builttoroam/devicecalendar/models/Event.kt index b8a07b76..5fc8a774 100644 --- a/android/src/main/kotlin/com/builttoroam/devicecalendar/models/Event.kt +++ b/android/src/main/kotlin/com/builttoroam/devicecalendar/models/Event.kt @@ -2,17 +2,17 @@ package com.builttoroam.devicecalendar.models class Event { - var title: String? = null + var eventTitle: String? = null var eventId: String? = null var calendarId: String? = null - var description: String? = null + var eventDescription: String? = null var eventStartDate: Long? = null var eventEndDate: Long? = null - var startTimeZone: String? = null - var endTimeZone: String? = null - var allDay: Boolean = false - var location: String? = null - var url: String? = null + var eventStartTimeZone: String? = null + var eventEndTimeZone: String? = null + var eventAllDay: Boolean = false + var eventLocation: String? = null + var eventURL: String? = null var attendees: MutableList = mutableListOf() var recurrenceRule: RecurrenceRule? = null var organizer: Attendee? = null diff --git a/ios/Classes/SwiftDeviceCalendarPlugin.swift b/ios/Classes/SwiftDeviceCalendarPlugin.swift index 111380c2..5d0cc573 100644 --- a/ios/Classes/SwiftDeviceCalendarPlugin.swift +++ b/ios/Classes/SwiftDeviceCalendarPlugin.swift @@ -26,15 +26,15 @@ public class SwiftDeviceCalendarPlugin: NSObject, FlutterPlugin { struct Event: Codable { let eventId: String let calendarId: String - let title: String - let description: String? + let eventTitle: String + let eventDescription: String? let eventStartDate: Int64 let eventEndDate: Int64 - let startTimeZone: String? - let allDay: Bool + let eventStartTimeZone: String? + let eventAllDay: Bool let attendees: [Attendee] - let location: String? - let url: String? + let eventLocation: String? + let eventURL: String? let recurrenceRule: RecurrenceRule? let organizer: Attendee? let reminders: [Reminder] From 4ed6e5da04a2074f1bb934cedc83ac829c55187b Mon Sep 17 00:00:00 2001 From: Thomas Date: Sun, 19 Dec 2021 02:15:04 +0800 Subject: [PATCH 22/30] swift renaming --- ios/Classes/SwiftDeviceCalendarPlugin.swift | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ios/Classes/SwiftDeviceCalendarPlugin.swift b/ios/Classes/SwiftDeviceCalendarPlugin.swift index 5d0cc573..fc092c88 100644 --- a/ios/Classes/SwiftDeviceCalendarPlugin.swift +++ b/ios/Classes/SwiftDeviceCalendarPlugin.swift @@ -350,15 +350,15 @@ public class SwiftDeviceCalendarPlugin: NSObject, FlutterPlugin { let event = Event( eventId: ekEvent.eventIdentifier, calendarId: calendarId, - title: ekEvent.title ?? "New Event", - description: ekEvent.notes, + eventTitle: ekEvent.title ?? "New Event", + eventDescription: ekEvent.notes, eventStartDate: Int64(ekEvent.startDate.millisecondsSinceEpoch), eventEndDate: Int64(ekEvent.endDate.millisecondsSinceEpoch), - startTimeZone: ekEvent.timeZone?.identifier, - allDay: ekEvent.isAllDay, + eventStartTimeZone: ekEvent.timeZone?.identifier, + eventAllDay: ekEvent.isAllDay, attendees: attendees, - location: ekEvent.location, - url: ekEvent.url?.absoluteString, + eventLocation: ekEvent.location, + eventURL: ekEvent.url?.absoluteString, recurrenceRule: recurrenceRule, organizer: convertEkParticipantToAttendee(ekParticipant: ekEvent.organizer), reminders: reminders, From 44eac7bfce073a44e409ef99890861c0fe8296df Mon Sep 17 00:00:00 2001 From: Thomas Date: Sun, 19 Dec 2021 21:10:39 +0800 Subject: [PATCH 23/30] build with jvm 1.8 --- android/build.gradle | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/android/build.gradle b/android/build.gradle index 278e67a2..84250c59 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -37,6 +37,14 @@ android { lintOptions { disable 'InvalidPackage' } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } + + kotlinOptions { + jvmTarget = JavaVersion.VERSION_1_8.toString() + } } dependencies { From 42dcf8247ebf57fd9ffb84b02c3e51c42653527a Mon Sep 17 00:00:00 2001 From: Thomas Date: Sun, 19 Dec 2021 23:17:57 +0800 Subject: [PATCH 24/30] test success --- example/{test_driver => integration_test}/app_test.dart | 7 +++---- .../integration_test.dart | 7 +++++-- example/lib/presentation/pages/calendar_event.dart | 4 ++-- lib/src/device_calendar.dart | 1 - lib/src/models/event.dart | 7 ++----- 5 files changed, 12 insertions(+), 14 deletions(-) rename example/{test_driver => integration_test}/app_test.dart (93%) rename example/{test_driver => integration_test}/integration_test.dart (66%) diff --git a/example/test_driver/app_test.dart b/example/integration_test/app_test.dart similarity index 93% rename from example/test_driver/app_test.dart rename to example/integration_test/app_test.dart index 1dd39abb..503a8951 100644 --- a/example/test_driver/app_test.dart +++ b/example/integration_test/app_test.dart @@ -3,11 +3,10 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import 'package:uuid/uuid.dart'; -// import 'package:flutter_driver/driver_extension.dart'; import 'package:device_calendar_example/main.dart' as app; -/// NOTE: These integration tests are currently made to be run on a physical Android device where there is at least a calendar that can be written to. -/// Calendar permissions are needed. See example/test_driver/integration_test.dart for how to run this +/// NOTE: These integration tests are currently made to be run on a physical device where there is at least a calendar that can be written to. +/// Calendar permissions are needed. See example/test_driver/integration_test.dart for how to run this on Android void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); group('Calendar plugin example', () { @@ -81,7 +80,7 @@ void main() { await tester.pumpAndSettle(); await tester.tap(eventTitleFinder); - await tester.scrollUntilVisible(deleteButtonFinder, 5); + await tester.scrollUntilVisible(deleteButtonFinder, -5); await tester.tap(deleteButtonFinder); await tester.pumpAndSettle(); expect(eventTitleFinder, findsNothing); diff --git a/example/test_driver/integration_test.dart b/example/integration_test/integration_test.dart similarity index 66% rename from example/test_driver/integration_test.dart rename to example/integration_test/integration_test.dart index 3c9e4fc4..2c840da5 100644 --- a/example/test_driver/integration_test.dart +++ b/example/integration_test/integration_test.dart @@ -2,9 +2,12 @@ import 'dart:io'; import 'package:integration_test/integration_test_driver.dart'; -// make sure 'adb devices' works on your local machine, then run the following: +// make sure 'adb devices' works on your local machine, then from the root of the plugin, run the following: /* -flutter drive \ --driver=test_driver/integration_test.dart \ --target=integration_test/app_test.dart +1. +cd example +2. +flutter drive --driver=integration_test/integration_test.dart --target=integration_test/app_test.dart */ Future main() async { diff --git a/example/lib/presentation/pages/calendar_event.dart b/example/lib/presentation/pages/calendar_event.dart index 44ee7edf..3461103c 100644 --- a/example/lib/presentation/pages/calendar_event.dart +++ b/example/lib/presentation/pages/calendar_event.dart @@ -38,10 +38,10 @@ class _CalendarEventPageState extends State { final RecurringEventDialog? _recurringEventDialog; TZDateTime? _startDate; - late TimeOfDay _startTime; + TimeOfDay? _startTime; TZDateTime? _endDate; - late TimeOfDay _endTime; + TimeOfDay? _endTime; AutovalidateMode _autovalidate = AutovalidateMode.disabled; DayOfWeekGroup? _dayOfWeekGroup = DayOfWeekGroup.None; diff --git a/lib/src/device_calendar.dart b/lib/src/device_calendar.dart index 052da7b8..369f6434 100644 --- a/lib/src/device_calendar.dart +++ b/lib/src/device_calendar.dart @@ -3,7 +3,6 @@ import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; -import 'package:meta/meta.dart'; import 'package:sprintf/sprintf.dart'; import 'package:timezone/timezone.dart'; diff --git a/lib/src/models/event.dart b/lib/src/models/event.dart index 5ed9dfa6..9f67f8b9 100644 --- a/lib/src/models/event.dart +++ b/lib/src/models/event.dart @@ -1,8 +1,5 @@ import '../../device_calendar.dart'; -import '../common/calendar_enums.dart'; import '../common/error_messages.dart'; -import 'attendee.dart'; -import 'recurrence_rule.dart'; import 'package:timezone/timezone.dart'; import 'package:collection/collection.dart'; @@ -72,7 +69,7 @@ class Event { description = json['eventDescription']; final int? startTimestamp = json['eventStartDate']; - final String? startLocationName = json['startTimeZone']; + final String? startLocationName = json['eventStartTimeZone']; var startTimeZone = timeZoneDatabase.locations[startLocationName]; startTimeZone ??= local; start = startTimestamp != null @@ -80,7 +77,7 @@ class Event { : TZDateTime.now(local); final int? endTimestamp = json['eventEndDate']; - final String? endLocationName = json['endTimeZone']; + final String? endLocationName = json['eventEndTimeZone']; var endLocation = timeZoneDatabase.locations[endLocationName]; endLocation ??= local; end = endTimestamp != null From eef5b7008a5050a1dc3788e836a7a26e917deb3b Mon Sep 17 00:00:00 2001 From: sowens-csd Date: Mon, 20 Dec 2021 09:47:23 -0500 Subject: [PATCH 25/30] feat: remove changes unrelated to intg. test --- lib/src/models/event.dart | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/src/models/event.dart b/lib/src/models/event.dart index 9f67f8b9..5ed9dfa6 100644 --- a/lib/src/models/event.dart +++ b/lib/src/models/event.dart @@ -1,5 +1,8 @@ import '../../device_calendar.dart'; +import '../common/calendar_enums.dart'; import '../common/error_messages.dart'; +import 'attendee.dart'; +import 'recurrence_rule.dart'; import 'package:timezone/timezone.dart'; import 'package:collection/collection.dart'; @@ -69,7 +72,7 @@ class Event { description = json['eventDescription']; final int? startTimestamp = json['eventStartDate']; - final String? startLocationName = json['eventStartTimeZone']; + final String? startLocationName = json['startTimeZone']; var startTimeZone = timeZoneDatabase.locations[startLocationName]; startTimeZone ??= local; start = startTimestamp != null @@ -77,7 +80,7 @@ class Event { : TZDateTime.now(local); final int? endTimestamp = json['eventEndDate']; - final String? endLocationName = json['eventEndTimeZone']; + final String? endLocationName = json['endTimeZone']; var endLocation = timeZoneDatabase.locations[endLocationName]; endLocation ??= local; end = endTimestamp != null From 188b3f43907c68d3dd928772f5fe1c280f423fe5 Mon Sep 17 00:00:00 2001 From: Thomas Date: Mon, 20 Dec 2021 23:11:03 +0800 Subject: [PATCH 26/30] fix: not matching timezone from JSON --- lib/src/models/event.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/src/models/event.dart b/lib/src/models/event.dart index 5ed9dfa6..91fff59e 100644 --- a/lib/src/models/event.dart +++ b/lib/src/models/event.dart @@ -72,7 +72,7 @@ class Event { description = json['eventDescription']; final int? startTimestamp = json['eventStartDate']; - final String? startLocationName = json['startTimeZone']; + final String? startLocationName = json['eventStartTimeZone']; var startTimeZone = timeZoneDatabase.locations[startLocationName]; startTimeZone ??= local; start = startTimestamp != null @@ -80,7 +80,7 @@ class Event { : TZDateTime.now(local); final int? endTimestamp = json['eventEndDate']; - final String? endLocationName = json['endTimeZone']; + final String? endLocationName = json['eventEndTimeZone']; var endLocation = timeZoneDatabase.locations[endLocationName]; endLocation ??= local; end = endTimestamp != null From df8fa903c0ad3b59fcada75d9ec793a74f406a36 Mon Sep 17 00:00:00 2001 From: Thomas Date: Tue, 21 Dec 2021 01:59:18 +0800 Subject: [PATCH 27/30] Update pubspec.yaml --- pubspec.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pubspec.yaml b/pubspec.yaml index 6ad9dfc1..67f8c22c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,12 +1,11 @@ name: device_calendar description: A cross platform plugin for modifying calendars on the user's device. -version: 4.0.1 +version: 4.1.0 homepage: https://github.com/builttoroam/device_calendar/tree/master dependencies: flutter: sdk: flutter - meta: ^1.7.0 collection: ^1.15.0 sprintf: ^6.0.0 timezone: ^0.8.0 From 664a2b56384d61b2899b748cfc36367c2cf59cfd Mon Sep 17 00:00:00 2001 From: Thomas Date: Tue, 21 Dec 2021 02:08:56 +0800 Subject: [PATCH 28/30] minor cleanup --- lib/src/models/event.dart | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/src/models/event.dart b/lib/src/models/event.dart index 91fff59e..9f67f8b9 100644 --- a/lib/src/models/event.dart +++ b/lib/src/models/event.dart @@ -1,8 +1,5 @@ import '../../device_calendar.dart'; -import '../common/calendar_enums.dart'; import '../common/error_messages.dart'; -import 'attendee.dart'; -import 'recurrence_rule.dart'; import 'package:timezone/timezone.dart'; import 'package:collection/collection.dart'; From c084302dd8a58ac3c16ccdd83e6f1458d0c69282 Mon Sep 17 00:00:00 2001 From: Thomas Date: Tue, 21 Dec 2021 02:16:41 +0800 Subject: [PATCH 29/30] changelog, readme updated --- CHANGELOG.md | 10 +++++++++- README.md | 15 ++++++++++----- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d6fc64d..c432fc7c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,15 @@ -## [4.0.1](https://github.com/builttoroam/device_calendar/releases/tag/4.1.0) +## [4.1.0](https://github.com/builttoroam/device_calendar/releases/tag/4.1.0) + +- Fix: Event JSONs created are now readable. +- Fix: Compliable for Flutter 2.9+ +- Fix: removed depreceated plugins from Example. +- Fix: Integration tests are now working. Android instructions are ready. +- Gradle plug-ins are updated. + +## [4.0.1](https://github.com/builttoroam/device_calendar/releases/tag/4.0.1) - Fixes event time retrieved diff --git a/README.md b/README.md index 3b880b71..bdb4d994 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # Device Calendar Plugin -**If you're upgrading to `v4.0.0`, your previous code will need to be modified (slightly) otherwise it will not run after update. See Timezone support for more details.** + +**If you're upgrading to v4, your previous code will need to be modified (slightly) otherwise it will not run after update. See [Timezone support](https://github.com/builttoroam/device_calendar#timezone-support-with-tzdatetime) for more details.** +**There are some changes to event JSON formats at v4. Pay extra care if handld event JSONs. Directly calling to and from device calendars should be unaffected.** [![pub package](https://img.shields.io/pub/v/device_calendar.svg)](https://pub.dartlang.org/packages/device_calendar) ![Pub Version (including pre-releases)](https://img.shields.io/pub/v/device_calendar?include_prereleases&label=Prerelease) [![build](https://github.com/builttoroam/device_calendar/actions/workflows/dart.yml/badge.svg?branch=develop)](https://github.com/builttoroam/device_calendar/actions/workflows/dart.yml) @@ -23,7 +25,7 @@ A cross platform plugin for modifying calendars on the user's device. ## Timezone support with TZDateTime -Due to feedback we received, starting from `v4.0.0` we will be using the `timezone` package to better handle all timezone data. +Due to feedback we received, starting from `4.0.0` we will be using the `timezone` package to better handle all timezone data. This is already included in this package. However, you need to add this line whenever the package is needed. @@ -33,7 +35,7 @@ import 'package:timezone/timezone.dart'; If you don't need any timezone specific features in your app, you may use `flutter_native_timezone` to get your devices' current timezone, then convert your previous `DateTime` with it. -```dart +```dart import 'package:flutter_native_timezone/flutter_native_timezone.dart'; // As an example, our default timezone is UTC. @@ -61,7 +63,7 @@ For other use cases, feedback or future developments on the feature, feel free t From `v3.9.0`, device_calendar is null-safe. However, not all workflows have been checked and bugs from older versions still persist. -You are strongly advised to test your workflow with the new package before shipping. +You are strongly advised to test your workflow with the new package before shipping. Better yet, please leave a note for what works and what doesn't, or contribute some bug fixes! ## Android Integration @@ -72,7 +74,9 @@ The following will need to be added to the `AndroidManifest.xml` file for your a ``` + ### Proguard / R8 exceptions + By default, all android apps go through R8 for file shrinking when building a release version. Currently, it interferes with some functions such as `retrieveCalendars()`. You may add the following setting to the ProGuard rules file `proguard-rules.pro` (thanks to [Britannio Jarrett](https://github.com/britannio)). Read more about the issue [here](https://github.com/builttoroam/device_calendar/issues/99) @@ -86,7 +90,8 @@ See [here](https://github.com/builttoroam/device_calendar/issues/99#issuecomment For more information, refer to the guide at [Android Developer](https://developer.android.com/studio/build/shrink-code#keep-code) ### AndroidX migration -Since `v0.1.0`, this version has migrated to use AndroidX instead of the deprecated Android support libraries. When using `v0.10.0` and onwards for this plugin, please ensure your application has been migrated following the guide [here](https://developer.android.com/jetpack/androidx/migrate) + +Since `v.1.0`, this version has migrated to use AndroidX instead of the deprecated Android support libraries. When using `0.10.0` and onwards for this plugin, please ensure your application has been migrated following the guide [here](https://developer.android.com/jetpack/androidx/migrate) ## iOS Integration From b4c658040b68335b37784981366cd88c57746310 Mon Sep 17 00:00:00 2001 From: Stephen Owens Date: Mon, 20 Dec 2021 13:37:53 -0500 Subject: [PATCH 30/30] type in README fixed. --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c432fc7c..69ba4021 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ ## [4.1.0](https://github.com/builttoroam/device_calendar/releases/tag/4.1.0) - Fix: Event JSONs created are now readable. -- Fix: Compliable for Flutter 2.9+ +- Fix: Compilable for Flutter 2.9+ - Fix: removed depreceated plugins from Example. - Fix: Integration tests are now working. Android instructions are ready. - Gradle plug-ins are updated.