Skip to content

Commit

Permalink
Update HyperTrack SDK Android to 7.4.3 (#27)
Browse files Browse the repository at this point in the history
Refactor justfile
  • Loading branch information
pavel-kuznetsov-hypertrack authored Feb 28, 2024
1 parent 755e436 commit eecd25c
Show file tree
Hide file tree
Showing 13 changed files with 163 additions and 124 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[*.{kt,kts}]
ktlint_standard_enum-entry-name-case = disabled
ktlint_standard_no-wildcard-imports = disabled
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [2.1.2] - 2024-02-28

### Changed

- Updated HyperTrack SDK Android to [7.4.3](https://github.com/hypertrack/sdk-android/releases/tag/7.4.3)

## [2.1.1] - 2024-02-16

### Changed
Expand Down Expand Up @@ -332,3 +338,4 @@ We are excited to announce the release of HyperTrack Cordova SDK 2.0.0, a major
[2.0.1]: https://github.com/hypertrack/cordova-plugin-hypertrack/releases/2.0.1
[2.1.0]: https://github.com/hypertrack/cordova-plugin-hypertrack/releases/tag/2.1.0
[2.1.1]: https://github.com/hypertrack/cordova-plugin-hypertrack/releases/tag/2.1.1
[2.1.2]: https://github.com/hypertrack/cordova-plugin-hypertrack/releases/tag/2.1.2
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![GitHub](https://img.shields.io/github/license/hypertrack/cordova-plugin-hypertrack?color=orange)](./LICENSE)
[![npm](https://img.shields.io/npm/v/cordova-plugin-hypertrack-v3.svg)](https://www.npmjs.com/package/cordova-plugin-hypertrack-v3)
[![iOS SDK](https://img.shields.io/badge/iOS%20SDK-5.4.1-brightgreen.svg)](https://github.com/hypertrack/sdk-ios)
[![Android SDK](https://img.shields.io/badge/Android%20SDK-7.4.2-brightgreen.svg)](https://github.com/hypertrack/sdk-android)
[![Android SDK](https://img.shields.io/badge/Android%20SDK-7.4.3-brightgreen.svg)](https://github.com/hypertrack/sdk-android)

[HyperTrack](https://www.hypertrack.com/) lets you add live location tracking to your mobile app. Live location is made available along with ongoing activity, tracking controls and tracking outage with reasons.

Expand Down
49 changes: 39 additions & 10 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ alias d := docs
alias gd := get-dependencies
alias od := open-docs
alias pt := push-tag
alias ogp := open-github-prs
alias ogr := open-github-releases
alias r := release
alias s := setup
alias us := update-sdk
alias usa := update-sdk-android
alias usal := update-sdk-android-latest
Expand All @@ -13,6 +16,10 @@ alias usil := update-sdk-ios-latest
alias usl := update-sdk-latest
alias v := version

PACKAGE_URL := "https://www.npmjs.com/package/cordova-plugin-hypertrack-v3/v/"
REPOSITORY_NAME := "cordova-plugin-hypertrack"
SDK_NAME := "HyperTrack SDK Cordova"

# Source: https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
# \ are escaped
SEMVER_REGEX := "(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?"
Expand All @@ -24,15 +31,13 @@ SEMVER_REGEX := "(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d
_ask-confirm:
@bash -c 'read confirmation; if [[ $confirmation != "y" && $confirmation != "Y" ]]; then echo "Okay 😮‍💨 😅"; exit 1; fi'

build: get-dependencies hooks
build: get-dependencies hooks docs

clean: _clear-node-modules
clean:
rm package-lock.json

_clear-node-modules:
rm -rf node_modules

docs: hooks
docs: lint
# no doc generation for cordova for now

get-dependencies:
Expand All @@ -49,7 +54,20 @@ _latest-ios:
@curl -s https://cocoapods.org/pods/HyperTrack | grep -m 1 -o -E "HyperTrack <span>{{SEMVER_REGEX}}" | grep -o -E '{{SEMVER_REGEX}}' | head -n 1

open-docs: docs
open docs/index.html
code API-DOCUMENTATION.md

lint:
ktlint --format .

_open-github-release-data:
code CHANGELOG.md
just open-github-releases

open-github-prs:
open "https://github.com/hypertrack/{{REPOSITORY_NAME}}/pulls"

open-github-releases:
open "https://github.com/hypertrack/{{REPOSITORY_NAME}}/releases"

push-tag:
#!/usr/bin/env sh
Expand All @@ -62,23 +80,25 @@ push-tag:
echo "You are not on main branch"
fi
release publish="dry-run": build
release type="dry-run": setup build
#!/usr/bin/env sh
set -euo pipefail
./.githooks/pre-push
VERSION=$(just version)
if [ {{publish}} = "publish" ]; then
if [ "{{type}}" = "publish" ] ; then
BRANCH=$(git branch --show-current)
if [ $BRANCH != "master" ]; then
echo "You must be on main branch to publish a new version (current branch: $BRANCH))"
exit 1
fi
echo "Are you sure you want to publish version $VERSION? (y/N)"
just _ask-confirm
npm publish
open "https://www.npmjs.com/package/cordova-plugin-hypertrack-v3/v/$VERSION"
open "https://github.com/hypertrack/cordova-plugin-hypertrack/releases/tag/$VERSION"
open "{{PACKAGE_URL}}$VERSION"
open "https://github.com/hypertrack/{{REPOSITORY_NAME}}/releases/tag/$VERSION"
else
echo "Dry run for version $VERSION"
npm publish --dry-run
fi
Expand Down Expand Up @@ -130,6 +150,9 @@ update-sdk wrapper_version ios_version android_version commit="true" branch="tru
git add .
git commit -m "Update HyperTrack SDK iOS to {{ios_version}} and Android to {{android_version}}"
fi
if [ "{{branch}}" = "true" ] && [ "{{commit}}" = "true" ] ; then
just open-github-prs
fi
update-sdk-android wrapper_version android_version commit="true" branch="true": build
#!/usr/bin/env sh
Expand All @@ -148,6 +171,9 @@ update-sdk-android wrapper_version android_version commit="true" branch="true":
git add .
git commit -m "Update HyperTrack SDK Android to {{android_version}}"
fi
if [ "{{branch}}" = "true" ] && [ "{{commit}}" = "true" ] ; then
just open-github-prs
fi
update-sdk-ios wrapper_version ios_version commit="true" branch="true": build
#!/usr/bin/env sh
Expand All @@ -166,6 +192,9 @@ update-sdk-ios wrapper_version ios_version commit="true" branch="true": build
git add .
git commit -m "Update HyperTrack SDK iOS to {{ios_version}}"
fi
if [ "{{branch}}" = "true" ] && [ "{{commit}}" = "true" ] ; then
just open-github-prs
fi
_update-sdk-android-version-file android_version:
./scripts/update_file.sh src/android/HypertrackPlugin.gradle "HYPERTRACK_SDK_VERSION = '.*'" "HYPERTRACK_SDK_VERSION = '{{android_version}}'"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "2.1.1",
"version": "2.1.2",
"name": "cordova-plugin-hypertrack-v3",
"cordova_name": "Cordova HyperTrack Plugin",
"description": "Cordova Plugin for native HyperTrack SDKs",
Expand Down
2 changes: 1 addition & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id="cordova-plugin-hypertrack-v3"
version="2.1.1">
version="2.1.2">
<name>HyperTrackPlugin</name>
<description>Cordova HyperTrack Plugin is a wrapper around native iOS and Android SDKs that allows to integrate HyperTrack into Cordova apps.</description>
<license>MIT</license>
Expand Down
3 changes: 3 additions & 0 deletions scripts/update_changelog.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#!/bin/bash
set -euo pipefail

android_version=""
ios_version=""

while [ "$#" -gt 0 ]; do
case "$1" in
-w)
Expand Down
20 changes: 12 additions & 8 deletions src/android/HyperTrackCordovaPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import org.json.JSONObject
import java.util.*

class HyperTrackCordovaPlugin : CordovaPlugin() {

private var errorsEventStream: CallbackContext? = null
private var isAvailableEventStream: CallbackContext? = null
private var isTrackingEventStream: CallbackContext? = null
Expand Down Expand Up @@ -74,9 +73,10 @@ class HyperTrackCordovaPlugin : CordovaPlugin() {
locateSubscription?.cancel()
locateEventStream?.let { disposeCallback(it) }
locateEventStream = callbackContext
locateSubscription = HyperTrack.locate {
sendEvent(callbackContext, serializeLocateResult(it))
}
locateSubscription =
HyperTrack.locate {
sendEvent(callbackContext, serializeLocateResult(it))
}
Success(NoCallback)
}
SdkMethod.setIsAvailable -> {
Expand Down Expand Up @@ -162,7 +162,10 @@ class HyperTrackCordovaPlugin : CordovaPlugin() {
}
}

private fun sendEvent(callbackContext: CallbackContext, data: Any) {
private fun sendEvent(
callbackContext: CallbackContext,
data: Any,
) {
try {
when (data) {
is String -> {
Expand Down Expand Up @@ -190,9 +193,10 @@ class HyperTrackCordovaPlugin : CordovaPlugin() {
}

private fun disposeCallback(callbackContext: CallbackContext) {
val result = PluginResult(PluginResult.Status.NO_RESULT, "").also {
it.keepCallback = false
}
val result =
PluginResult(PluginResult.Status.NO_RESULT, "").also {
it.keepCallback = false
}
callbackContext.sendPluginResult(result)
}

Expand Down
2 changes: 1 addition & 1 deletion src/android/HyperTrackPlugin.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ def ANDROID_FCM_VERSION = System.getenv('ANDROID_FCM_VERSION') ?: rootProject.ha
buildscript {

ext {
HYPERTRACK_SDK_VERSION = '7.4.2'
HYPERTRACK_SDK_VERSION = '7.4.3'
ANDROID_GRADLE_TOOLS_VERSION = System.getenv('ANDROID_GRADLE_TOOLS_VERSION') ?: rootProject.hasProperty('ANDROID_GRADLE_TOOLS_VERSION') ? rootProject.ext.ANDROID_GRADLE_TOOLS_VERSION : '3.5.3'
ANDROID_GOOGLE_SERVICES_VERSION = System.getenv('ANDROID_GOOGLE_SERVICES_VERSION') ?: rootProject.hasProperty('ANDROID_GOOGLE_SERVICES_VERSION') ? rootProject.ext.ANDROID_GOOGLE_SERVICES_VERSION : '4.3.3'
ext.gradleNumberVersion = ANDROID_GRADLE_TOOLS_VERSION.substring(0, ANDROID_GRADLE_TOOLS_VERSION.lastIndexOf(".")).toFloat()
Expand Down
2 changes: 1 addition & 1 deletion src/android/common/GeotagData.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ import android.location.Location
*/
internal data class GeotagData(
val data: Map<String, Any?>,
val expectedLocation: Location?
val expectedLocation: Location?,
)
31 changes: 15 additions & 16 deletions src/android/common/HyperTrackSdkWrapper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import com.hypertrack.sdk.android.HyperTrack
import com.hypertrack.sdk.android.HyperTrack.metadata
import com.hypertrack.sdk.android.Json
import com.hypertrack.sdk.android.Result
import com.hypertrack.sdk.cordova.plugin.common.Serialization.deserializeIsAvailable
import com.hypertrack.sdk.cordova.plugin.common.Serialization.deserializeName
import com.hypertrack.sdk.cordova.plugin.common.Serialization.deserializeGeotagData
import com.hypertrack.sdk.cordova.plugin.common.Serialization.deserializeIsAvailable
import com.hypertrack.sdk.cordova.plugin.common.Serialization.deserializeIsTracking
import com.hypertrack.sdk.cordova.plugin.common.Serialization.deserializeMetadata
import com.hypertrack.sdk.cordova.plugin.common.Serialization.deserializeName
import com.hypertrack.sdk.cordova.plugin.common.Serialization.serializeDeviceId
import com.hypertrack.sdk.cordova.plugin.common.Serialization.serializeErrors
import com.hypertrack.sdk.cordova.plugin.common.Serialization.serializeIsAvailable
Expand All @@ -28,20 +28,20 @@ typealias Serialized = Map<String, Any?>
* It receives serialized params.
*/
internal object HyperTrackSdkWrapper {

fun addGeotag(args: Serialized): WrapperResult<Serialized> {
return deserializeGeotagData(args)
.flatMapSuccess { geotag ->
// TODO: return proper error if JSON is wrong
val geotagMetadata = Json.fromMap(geotag.data)!!
val expectedLocation = geotag
.expectedLocation
?.let {
HyperTrack.Location(
latitude = it.latitude,
longitude = it.longitude
)
}
val expectedLocation =
geotag
.expectedLocation
?.let {
HyperTrack.Location(
latitude = it.latitude,
longitude = it.longitude,
)
}
if (expectedLocation != null) {
HyperTrack
.addGeotag(geotagMetadata, expectedLocation)
Expand Down Expand Up @@ -76,13 +76,13 @@ internal object HyperTrackSdkWrapper {

fun getIsAvailable(): WrapperResult<Serialized> {
return Success(
serializeIsAvailable(HyperTrack.isAvailable)
serializeIsAvailable(HyperTrack.isAvailable),
)
}

fun getIsTracking(): WrapperResult<Serialized> {
return Success(
serializeIsTracking(HyperTrack.isTracking)
serializeIsTracking(HyperTrack.isTracking),
)
}

Expand All @@ -100,13 +100,13 @@ internal object HyperTrackSdkWrapper {

fun getMetadata(): WrapperResult<Serialized> {
return Success(
serializeMetadata(HyperTrack.metadata.toMap())
serializeMetadata(HyperTrack.metadata.toMap()),
)
}

fun getName(): WrapperResult<Serialized> {
return Success(
serializeName(HyperTrack.name)
serializeName(HyperTrack.name),
)
}

Expand Down Expand Up @@ -140,5 +140,4 @@ internal object HyperTrackSdkWrapper {
HyperTrack.name = name
}
}

}
Loading

0 comments on commit eecd25c

Please sign in to comment.