Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Commit

Permalink
Merge pull request #67 from NativeScript/tbozhikov/comply-with-seed
Browse files Browse the repository at this point in the history
- comply with nativescript-plugin-seed
- add demo webpack
- add Travis CI checks
  • Loading branch information
radeva authored Aug 11, 2017
2 parents dc8e3d7 + fd9fb1d commit 6dd3068
Show file tree
Hide file tree
Showing 107 changed files with 1,773 additions and 367 deletions.
54 changes: 20 additions & 34 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,36 +1,22 @@
# Logs
logs
.vscode
.idea
.DS_Store
*.js
*.js.map
*.log

# Runtime data
pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directory
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
logs
!src/scripts/*.js
!seed-tests/*.js
seed-tests/seed-copy/**/*.*
seed-tests/seed-copy-new-git-repo/**/*.*
demo/app/*.js
!demo/karma.conf.js
!demo/app/tests/*.js
demo/*.d.ts
!demo/references.d.ts
demo/lib
demo/platforms
demo/node_modules
node_modules

# Dist directory where grunt script produces plugin installation files
dist

#Exclude all javascript (js) files from source code
source/**/*.js

#Exclude visual studio code local folder
.vscode
publish/src
publish/package
73 changes: 73 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
matrix:
include:
- stage: "Lint"
language: node_js
os: linux
node_js: "6"
script: cd src && npm run ci.tslint && cd ../demo && npm run ci.tslint
- stage: "WebPack"
os: osx
env:
- Platform="iOS"
osx_image: xcode8.3
language: node_js
node_js: "6"
jdk: oraclejdk8
script: cd demo && npm run build.plugin && npm i && npm run build-ios-bundle
- language: android
os: linux
env:
- Platform="Android"
jdk: oraclejdk8
before_install: nvm install 6.10.3
script: cd demo && npm run build.plugin && npm i && npm run build-android-bundle
- stage: "Build and Test"
env:
- BuildAndroid="25"
language: android
os: linux
jdk: oraclejdk8
before_install: nvm install stable
script:
- cd src && npm i && npm run tsc && cd ../demo && tns build android
- os: osx
env:
- BuildiOS="10.3"
- Xcode="8.3"
osx_image: xcode8.3
language: node_js
node_js: "6"
jdk: oraclejdk8
script:
- cd src && npm i && npm run tsc && cd ../demo && tns build ios
- os: linux
language: android
dist: precise
jdk: oraclejdk8
before_script:
- echo no | android create avd --force -n test -t android-21 -b armeabi-v7a
- emulator -avd test -no-audio -no-window &
- android-wait-for-emulator
before_install:
- nvm install 6
script: cd src && npm run test.android
- os: osx
language: node_js
node_js: "6"
jdk: oraclejdk8
osx_image: xcode8.3
script: cd src && npm run test.ios

android:
components:
- tools
- platform-tools
- build-tools-25.0.2
- android-25
- extra-android-m2repository
- sys-img-armeabi-v7a-android-21

install:
- echo no | npm install -g nativescript
- tns usage-reporting disable
- tns error-reporting disable
92 changes: 86 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,90 @@
# nativescript-geolocation
# NativeScript Geolocation ![apple](https://cdn3.iconfinder.com/data/icons/picons-social/57/16-apple-32.png) ![android](https://cdn4.iconfinder.com/data/icons/logos-3/228/android-32.png)

Steps to compile the plugin.

$ ./create.sh
[![npm](https://img.shields.io/npm/v/nativescript-geolocation.svg)](https://www.npmjs.com/package/nativescript-geolocation)
[![npm](https://img.shields.io/npm/dm/nativescript-geolocation.svg)](https://www.npmjs.com/package/nativescript-geolocation)
[![Build Status](https://travis-ci.org/NativeScript/nativescript-geolocation.svg?branch=master)](https://travis-ci.org/NativeScript/nativescript-geolocation)

This will produce a `dist` folder based on all JavaScript files within `source` folder. Values inside `source/package.json` controls the number of plugin version.
Geolocation plugin to use for getting current location, monitor movement, etc.

Sample application can be found here:
https://github.com/NativeScript/nativescript-geolocation-demo
## Installation

In Command prompt / Terminal navigate to your application root folder and run:

```
tns plugin add nativescript-geolocation
```

## Usage

The best way to explore the usage of the plugin is to inspect the demo app in the plugin's root folder.
In `demo` folder you can find the usage of the plugin for TypeScript non-Angular application. Refer to `demo/app/main-page.ts`.

In short here are the steps:

### Import the plugin

*TypeScript*
```
import * as geolocation from "nativescript-geolocation";
import { Accuracy } from "ui/enums"; // used to describe at what accuracy the location should be get
```

*Javascript*
```
var geolocation = require("nativescript-geolocation");
```

### Request permissions

```
geolocation.enableLocationRequest();
```

### Call plugin methods

````
// Get current location with high accuracy
geolocation.getCurrentLocation({ desiredAccuracy: Accuracy.high, updateDistance: 0.1, maximumAge: 5000, timeout: 20000 })
````

## API

### Properties

#### Location

| Property | Default | Description |
| --- | --- | --- |
| latitude | - | The latitude of the geolocation, in degrees. |
| longitude | - | The longitude of the geolocation, in degrees. |
| altitude | - | The altitude (if available), in meters above sea level. |
| horizontalAccuracy | - | The horizontal accuracy, in meters. |
| verticalAccuracy | - | The vertical accuracy, in meters. |
| speed | - | The speed, in meters/second over ground. |
| timestamp | - | The time at which this location was determined. |

#### Options

| Property | Default | Description |
| --- | --- | --- |
| desiredAccuracy? | Accuracy.high | Specifies desired accuracy in meters. |
| updateDistance | iOS - no filter, Android - 0 meters | Update distance filter in meters. Specifies how often to update the location. |
| minimumUpdateTime | - | Minimum time interval between location updates, in milliseconds (ignored on iOS). |
| maximumAge | - | How old locations to receive in ms. |
| timeout | - | How long to wait for a location in ms. |

### Methods

| Method | Returns | Description |
| --- | --- | --- |
| getCurrentLocation(options: Options) | Promise<Location> | Get current location applying the specified options (if any). |
| watchLocation(successCallback: successCallbackType, errorCallback: errorCallbackType, options: Options) | number | Monitor for location change. |
| clearWatch(watchId: number) | void | Stop monitoring for location change. Parameter expected is the watchId returned from `watchLocation`. |
| enableLocationRequest(always?: boolean) | Promise<void> | Ask for permissions to use location services. The option `always` is application for iOS only. [Read more about its usage](https://developer.apple.com/documentation/corelocation/cllocationmanager/1620551-requestalwaysauthorization) . |
| isEnabled | boolean| Returns `true` if location services are enabled. |
| distance(loc1: Location, loc2: Location) | number | Calculate the distance between two locations. Returns the distance in meters. |

## License

Apache License Version 2.0, January 2004
31 changes: 0 additions & 31 deletions compile.sh

This file was deleted.

11 changes: 0 additions & 11 deletions create.sh

This file was deleted.

43 changes: 43 additions & 0 deletions demo/app/App_Resources/Android/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="__PACKAGE__"
android:versionCode="1"
android:versionName="1.0">

<supports-screens
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"/>

<uses-sdk
android:minSdkVersion="17"
android:targetSdkVersion="__APILEVEL__"/>

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET"/>

<application
android:name="com.tns.NativeScriptApplication"
android:allowBackup="true"
android:icon="@drawable/icon"
android:label="@string/app_name"
android:theme="@style/AppTheme">

<activity
android:name="com.tns.NativeScriptActivity"
android:label="@string/title_activity_kimera"
android:configChanges="keyboardHidden|orientation|screenSize"
android:theme="@style/LaunchScreenTheme">

<meta-data android:name="SET_THEME_ON_LAUNCH" android:resource="@style/AppTheme" />

<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.tns.ErrorReportActivity"/>
</application>
</manifest>
16 changes: 16 additions & 0 deletions demo/app/App_Resources/Android/app.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Add your native dependencies here:

// Uncomment to add recyclerview-v7 dependency
//dependencies {
// compile 'com.android.support:recyclerview-v7:+'
//}

android {
defaultConfig {
generatedDensities = []
applicationId = "org.nativescript.demo"
}
aaptOptions {
additionalParameters "--no-version-vectors"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" android:gravity="fill">
<item>
<bitmap android:gravity="fill" android:src="@drawable/background" />
</item>
<item>
<bitmap android:gravity="center" android:src="@drawable/logo" />
</item>
</layer-list>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions demo/app/App_Resources/Android/values-v21/colors.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ns_accent">#3d5afe</color>
</resources>
23 changes: 23 additions & 0 deletions demo/app/App_Resources/Android/values-v21/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<!-- Application theme -->
<style name="AppTheme" parent="AppThemeBase">
<item name="android:datePickerStyle">@style/SpinnerDatePicker</item>
<item name="android:timePickerStyle">@style/SpinnerTimePicker</item>
</style>

<!-- Default style for DatePicker - in spinner mode -->
<style name="SpinnerDatePicker" parent="android:Widget.Material.Light.DatePicker">
<item name="android:datePickerMode">spinner</item>
</style>

<!-- Default style for TimePicker - in spinner mode -->
<style name="SpinnerTimePicker" parent="android:Widget.Material.Light.TimePicker">
<item name="android:timePickerMode">spinner</item>
</style>

<style name="NativeScriptToolbarStyle" parent="NativeScriptToolbarStyleBase">
<item name="android:elevation">4dp</item>
</style>
</resources>
7 changes: 7 additions & 0 deletions demo/app/App_Resources/Android/values/colors.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ns_primary">#F5F5F5</color>
<color name="ns_primaryDark">#757575</color>
<color name="ns_accent">#33B5E5</color>
<color name="ns_blue">#272734</color>
</resources>
Loading

0 comments on commit 6dd3068

Please sign in to comment.