Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
f517f65
Add script to format all files
ben-xD Nov 29, 2021
b13f4bb
Improve steps for getting started with contributing
ben-xD Nov 29, 2021
e676238
Remove unnecessary readme, since contents have been merged into main …
ben-xD Nov 29, 2021
715902d
Add emoji so each line is clearer
ben-xD Nov 29, 2021
18586a8
Add removed section
ben-xD Nov 29, 2021
53504a3
Add formatting checks for Swift and Java
ben-xD Nov 29, 2021
df021bd
Use macos & brew instead of ubuntu & mint
ben-xD Nov 29, 2021
8551b4d
Rename job
ben-xD Nov 29, 2021
9ad8441
Introduce some temporary formatting issues to confirm all formatting …
ben-xD Nov 29, 2021
d919523
Update args for java formatter
ben-xD Nov 29, 2021
01ce781
Revert "Introduce some temporary formatting issues to confirm all for…
ben-xD Nov 29, 2021
9ea9f6f
Introduce formatting issue in Swift to test CI formatter
ben-xD Nov 29, 2021
04f8be8
Add checkout action
ben-xD Nov 29, 2021
f76909d
Revert "Introduce formatting issue in Swift to test CI formatter"
ben-xD Nov 29, 2021
d963fda
Add pre-commit hook and guidance on how to use it
ben-xD Dec 1, 2021
c238016
Add note about SourceTree
ben-xD Dec 1, 2021
23104b7
Remove outdated comment
ben-xD Dec 1, 2021
252e1ce
Update message
ben-xD Dec 1, 2021
cd69001
Rename .githooks directory to `hooks`
ben-xD Dec 4, 2021
80b6265
Check `android` files only, to avoid checking formatting for dependen…
ben-xD Dec 4, 2021
0689c36
Move dependency checks into a separate file
ben-xD Dec 4, 2021
ba7f505
Replace emojis with simpler messages
ben-xD Dec 4, 2021
12a10db
Allow scripts to be run from any directory
ben-xD Dec 4, 2021
21f7e42
Remove whitespace in log lines
ben-xD Dec 4, 2021
57acd83
Replace `bash` with `source` in script
ben-xD Dec 4, 2021
828ce6f
Use emoji to be clearer
ben-xD Dec 4, 2021
38afe16
Elaborate on device deactivation documentation
ben-xD Dec 6, 2021
abb0dfc
Improve error message if google-java-format is not installed
ben-xD Dec 15, 2021
0fe71e9
Elaborate on run/debug and formatting scripts
ben-xD Dec 15, 2021
a4bf72c
Only attempt to format/lint source code files, avoiding symlinked fil…
ben-xD Dec 15, 2021
6fbe8fa
Add more notes about pre-commit script
ben-xD Dec 15, 2021
eeb2f90
Fix typo and add more info to contributing.md
ben-xD Dec 15, 2021
77ee8cb
Move out 2 bullet points into sections
ben-xD Dec 15, 2021
2cfab16
Add link to docs
ben-xD Dec 15, 2021
67d4d32
Add more detail to contributing guide
ben-xD Dec 15, 2021
7f5c0a7
Add more information about IDE autoformatting
ben-xD Dec 15, 2021
0fa392f
Merge branch 'enhancement/formatting-guide' into time_function_implem…
ikbalkaya Dec 16, 2021
cfe177b
Code formatting
ikbalkaya Dec 16, 2021
acde5ba
Codegen for realtime stats
ikbalkaya Dec 16, 2021
94ab763
Stats encoding from Android side
ikbalkaya Dec 20, 2021
a0e4b9c
Moved stats mapping from realtime to rest
ikbalkaya Dec 21, 2021
a473266
File formatting
ikbalkaya Dec 21, 2021
f3fb908
Created StatsEncoder for iOS
ikbalkaya Dec 21, 2021
147c08b
Stats encoding mappings in Obj-C
ikbalkaya Dec 21, 2021
8a5e998
Fix function calls in StatsEncoders
ikbalkaya Dec 22, 2021
29766e9
Stats function mapping in Objective-C
ikbalkaya Dec 22, 2021
a79f96a
File formattings
ikbalkaya Dec 22, 2021
96b9cc7
Fix messageCategory encoding
ikbalkaya Dec 23, 2021
b61b0bd
File formatting
ikbalkaya Dec 23, 2021
ca03987
Added params to the call in example app and confirmed it's working in…
ikbalkaya Dec 23, 2021
38e9ed1
Added param query builder for stat params
ikbalkaya Dec 23, 2021
bc81244
file formatting
ikbalkaya Dec 23, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,28 @@ on:
- main

jobs:
check:
swift:
name: "Swift formatting checks"
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: 'Install SwiftFormat'
run: 'brew install swiftformat'

- name: Run SwiftFormat
run: swiftformat --lint --swiftversion 5.5 .
java:
name: "Java formatting checks"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: axel-op/googlejavaformat-action@v3
with:
args: "--set-exit-if-changed --dry-run"
dart:
name: "Dart formatting and analyzer checks"
runs-on: ubuntu-latest
steps:

Expand All @@ -20,7 +41,7 @@ jobs:
cd test_integration && flutter pub get && cd ..
cd example && flutter pub get && cd ..

- name: 'Check formatting issues in the code'
- name: 'Check Dart formatting issues in the code'
run: flutter format --set-exit-if-changed .

- name: 'Flutter analyze help'
Expand Down
138 changes: 99 additions & 39 deletions CONTRIBUTING.md

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions PushNotifications.md
Original file line number Diff line number Diff line change
Expand Up @@ -358,9 +358,11 @@ Take a look at the example app platform specific code to handle messages. For iO

**iOS:** Some iOS dependencies perform techniques such as [method swizzling](https://nshipster.com/method-swizzling/) which break other iOS dependencies and Flutter Plugin packages.

### Deactivating the device
## Device deactivation

Do this only if you do not want the device to receive push notifications at all. You usually do not need to run this at all.
Do this only if you do not want the device to receive push notifications at all. You usually do not need to run this at all, and especially don't need to deactivate and re-activate on every launch.

Like device activation, the `Future` returned by `activate` is not guaranteed to complete quickly.

```dart
try {
Expand Down
121 changes: 121 additions & 0 deletions android/src/main/java/io/ably/flutter/plugin/AblyMessageCodec.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import io.ably.lib.types.MessageExtras;
import io.ably.lib.types.Param;
import io.ably.lib.types.PresenceMessage;
import io.ably.lib.types.Stats;
import io.ably.lib.util.Crypto;
import io.ably.lib.util.Log;
import io.flutter.plugin.common.StandardMessageCodec;
Expand Down Expand Up @@ -121,6 +122,7 @@ public AblyMessageCodec(CipherParamsStorage cipherParamsStorage) {
put(
PlatformConstants.CodecTypes.realtimeHistoryParams,
new CodecPair<>(null, self::decodeRealtimeHistoryParams));
put(PlatformConstants.CodecTypes.stats, new CodecPair<>(self::encodeStats, null));
put(
PlatformConstants.CodecTypes.restPresenceParams,
new CodecPair<>(null, self::decodeRestPresenceParams));
Expand Down Expand Up @@ -168,6 +170,125 @@ public AblyMessageCodec(CipherParamsStorage cipherParamsStorage) {
};
}

private Map<String, Object> encodeStats(Stats stats) {
if (stats == null) return null;
final HashMap<String, Object> jsonMap = new HashMap<>();
writeValueToJson(jsonMap, PlatformConstants.TxStats.all, encodeStatsMessageTypes(stats.all));
writeValueToJson(
jsonMap, PlatformConstants.TxStats.apiRequests, encodeStatsRequestCount(stats.apiRequests));
writeValueToJson(
jsonMap, PlatformConstants.TxStats.channels, encodeStatsResourceCount(stats.channels));
writeValueToJson(
jsonMap,
PlatformConstants.TxStats.connections,
encodeStatsConnectionTypes(stats.connections));
writeValueToJson(
jsonMap, PlatformConstants.TxStats.inbound, encodeStatsMessageTraffic(stats.inbound));
writeValueToJson(jsonMap, PlatformConstants.TxStats.intervalId, stats.intervalId);
writeValueToJson(
jsonMap, PlatformConstants.TxStats.outbound, encodeStatsMessageTraffic(stats.outbound));
writeValueToJson(
jsonMap, PlatformConstants.TxStats.persisted, encodeStatsMessageTypes(stats.persisted));
writeValueToJson(
jsonMap,
PlatformConstants.TxStats.tokenRequests,
encodeStatsRequestCount(stats.tokenRequests));
return jsonMap;
}

private Map<String, Object> encodeStatsMessageTraffic(Stats.MessageTraffic messageTraffic) {
if (messageTraffic == null) return null;
final HashMap<String, Object> jsonMap = new HashMap<>();
writeValueToJson(
jsonMap,
PlatformConstants.TxStatsMessageTraffic.all,
encodeStatsMessageTypes(messageTraffic.all));
writeValueToJson(
jsonMap,
PlatformConstants.TxStatsMessageTraffic.realtime,
encodeStatsMessageTypes(messageTraffic.realtime));
writeValueToJson(
jsonMap,
PlatformConstants.TxStatsMessageTraffic.rest,
encodeStatsMessageTypes(messageTraffic.rest));
writeValueToJson(
jsonMap,
PlatformConstants.TxStatsMessageTraffic.webhook,
encodeStatsMessageTypes(messageTraffic.webhook));
return jsonMap;
}

private Map<String, Object> encodeStatsConnectionTypes(Stats.ConnectionTypes connectionTypes) {
if (connectionTypes == null) return null;
final HashMap<String, Object> jsonMap = new HashMap<>();
writeValueToJson(
jsonMap,
PlatformConstants.TxStatsConnectionTypes.all,
encodeStatsResourceCount(connectionTypes.all));
writeValueToJson(
jsonMap,
PlatformConstants.TxStatsConnectionTypes.plain,
encodeStatsResourceCount(connectionTypes.plain));
writeValueToJson(
jsonMap,
PlatformConstants.TxStatsConnectionTypes.tls,
encodeStatsResourceCount(connectionTypes.tls));
return jsonMap;
}

private Map<String, Object> encodeStatsResourceCount(Stats.ResourceCount resourceCount) {
if (resourceCount == null) return null;
final HashMap<String, Object> jsonMap = new HashMap<>();
writeValueToJson(jsonMap, PlatformConstants.TxStatsResourceCount.mean, resourceCount.mean);
writeValueToJson(jsonMap, PlatformConstants.TxStatsResourceCount.min, resourceCount.min);
writeValueToJson(jsonMap, PlatformConstants.TxStatsResourceCount.opened, resourceCount.opened);
writeValueToJson(jsonMap, PlatformConstants.TxStatsResourceCount.peak, resourceCount.peak);
writeValueToJson(
jsonMap, PlatformConstants.TxStatsResourceCount.refused, resourceCount.refused);
return jsonMap;
}

private Map<String, Object> encodeStatsRequestCount(Stats.RequestCount apiRequests) {
if (apiRequests == null) return null;
final HashMap<String, Object> jsonMap = new HashMap<>();
writeValueToJson(
jsonMap, PlatformConstants.TxStatsRequestCount.succeeded, apiRequests.succeeded);
writeValueToJson(jsonMap, PlatformConstants.TxStatsRequestCount.failed, apiRequests.failed);
writeValueToJson(jsonMap, PlatformConstants.TxStatsRequestCount.refused, apiRequests.refused);
return jsonMap;
}

private Map<String, Object> encodeStatsMessageTypes(Stats.MessageTypes messageTypes) {
if (messageTypes == null) return null;
final HashMap<String, Object> jsonMap = new HashMap<>();
writeValueToJson(
jsonMap,
PlatformConstants.TxStatsMessageTypes.all,
encodeMessageCategory(messageTypes.all));
writeValueToJson(
jsonMap,
PlatformConstants.TxStatsMessageTypes.messages,
encodeMessageCategory(messageTypes.messages));
writeValueToJson(
jsonMap,
PlatformConstants.TxStatsMessageTypes.presence,
encodeMessageCategory(messageTypes.presence));
return jsonMap;
}

// This is different in other platform and will correspond to StatsMessageCount for other
// libraries
private Map<String, Object> encodeMessageCategory(Stats.MessageCategory category) {
if (category == null) return null;
if (category.category == null) return null;
final HashMap<String, Object> jsonMap = new HashMap<>();

writeValueToJson(jsonMap, PlatformConstants.TxStatsMessageCount.count, category.count);
writeValueToJson(jsonMap, PlatformConstants.TxStatsMessageCount.data, category.data);

return jsonMap;
}

@Override
protected Object readValueOfType(final byte type, final ByteBuffer buffer) {
CodecPair pair = codecMap.get(type);
Expand Down
Loading