Сравнить коммиты
| Автор | SHA1 | Дата | |
|---|---|---|---|
|
|
bb49b11bf4 | ||
|
|
b72b7dfa6f | ||
|
|
c4d4e9ff40 | ||
|
|
bcfa577e91 | ||
|
|
ac1ca8df2f | ||
|
|
e0dfc8fe66 | ||
|
|
7dc7f32110 | ||
|
|
6bffc7bbc1 | ||
|
|
aaa6092501 | ||
|
|
8cd3601a4f | ||
|
|
088adcaa24 | ||
|
|
0365837e4d | ||
|
|
f952e16c00 | ||
|
|
b7fb6445ef | ||
|
|
bc3f47e296 | ||
|
|
c60f749a67 | ||
|
|
821f24ce2b | ||
|
|
62c713e97a | ||
|
|
ab587d465e | ||
|
|
f82e89409d | ||
|
|
7e6d4f5822 | ||
|
|
b8a099189e | ||
|
|
e961df85d5 | ||
|
|
44648cf142 | ||
|
|
d916bf432e | ||
|
|
09a62e639e | ||
|
|
d1912bd430 | ||
|
|
052320f981 | ||
|
|
140a3ebece | ||
|
|
603e7bb3e0 | ||
|
|
f81db810ff | ||
|
|
1ca71f80c6 | ||
|
|
5d101b6f6e | ||
|
|
dc949e0152 | ||
|
|
96d9127a4a | ||
|
|
2194290935 | ||
|
|
78bf7f3169 | ||
|
|
e2d0329635 | ||
|
|
a64da65c6f | ||
|
|
8a3d86c173 | ||
|
|
c78cac2da5 | ||
|
|
5f7a1a8bfd | ||
|
|
16f743e90a | ||
|
|
429dda1e37 | ||
|
|
0ac173c043 | ||
|
|
9ae90d2edc | ||
|
|
27a99a6af1 | ||
|
|
5ac0610bd5 | ||
|
|
b109de92c4 | ||
|
|
be0d556ed6 | ||
|
|
1861d9ca34 | ||
|
|
c0cc6e8e55 | ||
|
|
1cc3a2d9d1 | ||
|
|
9263b4e08b | ||
|
|
77213ecc91 | ||
|
|
3214944d69 | ||
|
|
3e786e474d | ||
|
|
0850ac09b0 | ||
|
|
50e6c00bd0 | ||
|
|
0e4918ba22 | ||
|
|
8027c5be9f | ||
|
|
6084bfdfbe | ||
|
|
b560577d96 | ||
|
|
92137c83bd | ||
|
|
3617700351 | ||
|
|
c803eb7bff | ||
|
|
7fe765d124 | ||
|
|
3235229d1e | ||
|
|
25e035e59d | ||
|
|
b63bf4779e | ||
|
|
2cf1213535 | ||
|
|
03266a8c78 | ||
|
|
3782fd0003 | ||
|
|
fc83e7525a | ||
|
|
596ede019c | ||
|
|
2593ec7d2e | ||
|
|
14894c294e | ||
|
|
fe9132e46a | ||
|
|
26bc00f5fd | ||
|
|
d5e2a3155c | ||
|
|
d49bc6ad28 | ||
|
|
c008c5f65e | ||
|
|
e4f167f17b | ||
|
|
346ad93ca0 | ||
|
|
3f4663c570 | ||
|
|
7396e9c436 | ||
|
|
59037d5fb1 | ||
|
|
5591bec9e9 | ||
|
|
e4151ac228 | ||
|
|
630cf8eb86 | ||
|
|
222497d6ff | ||
|
|
0f9645120b | ||
|
|
9ffc0aa773 | ||
|
|
9d93c1d001 | ||
|
|
ac6f648062 | ||
|
|
06c741e6b5 | ||
|
|
ceaf4d526c | ||
|
|
6d4d0d74cd | ||
|
|
0186b8fc6e | ||
|
|
16c634b9f5 | ||
|
|
4aac812c8a | ||
|
|
9a2388011e | ||
|
|
cd2277c3fd | ||
|
|
88d4ff69b7 | ||
|
|
4e7082bed6 | ||
|
|
d5224546c5 | ||
|
|
29a0cd03ae | ||
|
|
56f4534485 | ||
|
|
82ce44b64d | ||
|
|
4f94c51e11 | ||
|
|
63b7566296 | ||
|
|
af48a89874 | ||
|
|
2266bab317 | ||
|
|
01060cf454 | ||
|
|
1d6da0c9d9 | ||
|
|
be4f842a79 | ||
|
|
f611b1b597 | ||
|
|
30412eb7b8 | ||
|
|
d2399a5fed | ||
|
|
026c3e1534 | ||
|
|
a1c7d75cc1 | ||
|
|
5e2f35fae0 | ||
|
|
97ead868cd | ||
|
|
61d0098c69 | ||
|
|
a32a50c1f7 | ||
|
|
5b187036d2 | ||
|
|
4e70977d95 | ||
|
|
66161cf9ac | ||
|
|
579c00b860 | ||
|
|
ea89c638b7 | ||
|
|
dd1b0be0c0 | ||
|
|
cdea58caa4 | ||
|
|
fb3b7658a8 | ||
|
|
39e126cc6d | ||
|
|
18dd857d6d | ||
|
|
74fb9c19c1 | ||
|
|
8bdc5e1a65 | ||
|
|
42aa93342c | ||
|
|
6d0db55b60 |
@@ -1,4 +1,5 @@
|
||||
.gradle
|
||||
/local.properties
|
||||
/.idea/workspace.xml
|
||||
.DS_Store
|
||||
.idea/
|
||||
local.properties
|
||||
*.iml
|
||||
build/
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
traccar-client
|
||||
@@ -1,23 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<option name="DEFAULT_COMPILER" value="Javac" />
|
||||
<resourceExtensions />
|
||||
<wildcardResourcePatterns>
|
||||
<entry name="!?*.java" />
|
||||
<entry name="!?*.form" />
|
||||
<entry name="!?*.class" />
|
||||
<entry name="!?*.groovy" />
|
||||
<entry name="!?*.scala" />
|
||||
<entry name="!?*.flex" />
|
||||
<entry name="!?*.kt" />
|
||||
<entry name="!?*.clj" />
|
||||
</wildcardResourcePatterns>
|
||||
<annotationProcessing>
|
||||
<profile default="true" name="Default" enabled="false">
|
||||
<processorPath useClasspath="true" />
|
||||
</profile>
|
||||
</annotationProcessing>
|
||||
</component>
|
||||
</project>
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
<component name="CopyrightManager">
|
||||
<settings default="">
|
||||
<module2copyright />
|
||||
</settings>
|
||||
</component>
|
||||
@@ -1,5 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
|
||||
</project>
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="GradleSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
</GradleProjectSettings>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" assert-keyword="true" jdk-15="true" project-jdk-name="1.7" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="masterDetails">
|
||||
<states>
|
||||
<state key="ProjectJDKs.UI">
|
||||
<settings>
|
||||
<last-edited>1.7</last-edited>
|
||||
<splitter-proportions>
|
||||
<option name="proportions">
|
||||
<list>
|
||||
<option value="0.2" />
|
||||
</list>
|
||||
</option>
|
||||
</splitter-proportions>
|
||||
</settings>
|
||||
</state>
|
||||
</states>
|
||||
</component>
|
||||
</project>
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/traccar-client/traccar-client.iml" filepath="$PROJECT_DIR$/traccar-client/traccar-client.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/traccar-client-android.iml" filepath="$PROJECT_DIR$/traccar-client-android.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
<component name="DependencyValidationManager">
|
||||
<state>
|
||||
<option name="SKIP_IMPORT_STATEMENTS" value="false" />
|
||||
</state>
|
||||
</component>
|
||||
@@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="" />
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
# [Traccar Client for Android](https://www.traccar.org/client)
|
||||
|
||||
## Contacts
|
||||
|
||||
Author - Anton Tananaev ([anton.tananaev@gmail.com](mailto:anton.tananaev@gmail.com))
|
||||
|
||||
Website - [https://www.traccar.org/client](https://www.traccar.org/client)
|
||||
|
||||
## Overview
|
||||
|
||||
Traccar Client is an Android GPS tracking application. It can work with Traccar open source server software.
|
||||
|
||||
## License
|
||||
|
||||
Apache License, Version 2.0
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
@@ -1,27 +0,0 @@
|
||||
traccar-client
|
||||
|
||||
Web page - http://www.traccar.org
|
||||
|
||||
Author - Anton Tananaev (anton.tananaev@gmail.com)
|
||||
|
||||
SUMMARY:
|
||||
|
||||
Traccar Client is Android GPS tracking application. In can work with
|
||||
Traccar open source server software.
|
||||
|
||||
LICENSE:
|
||||
|
||||
Apache License, Version 2.0
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
compileSdkVersion 23
|
||||
buildToolsVersion '23.0.3'
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion 3
|
||||
targetSdkVersion 23
|
||||
versionCode 30
|
||||
versionName '3.10'
|
||||
}
|
||||
|
||||
signingConfigs {
|
||||
release {
|
||||
storeFile file('../../android.keystore')
|
||||
keyAlias 'tananaev'
|
||||
storePassword ''
|
||||
keyPassword ''
|
||||
}
|
||||
}
|
||||
|
||||
productFlavors {
|
||||
regular {
|
||||
applicationId "org.traccar.client"
|
||||
buildConfigField "boolean", "HIDDEN_APP", "false"
|
||||
}
|
||||
hidden {
|
||||
applicationId "org.traccar.client.hidden"
|
||||
buildConfigField "boolean", "HIDDEN_APP", "true"
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
signingConfig signingConfigs.release
|
||||
}
|
||||
}
|
||||
|
||||
lintOptions {
|
||||
checkReleaseBuilds false
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testCompile 'junit:junit:4.12'
|
||||
testCompile 'org.robolectric:robolectric:3.0'
|
||||
}
|
||||
|
||||
task requestPasswords << {
|
||||
android.signingConfigs.release.storePassword = new String(System.console().readPassword('\nStore password: '))
|
||||
android.signingConfigs.release.keyPassword = new String(System.console().readPassword('Key password: '))
|
||||
}
|
||||
|
||||
tasks.whenTaskAdded { theTask ->
|
||||
if (theTask.name.equals('packageRegularRelease') || theTask.name.equals('packageHiddenRelease')) {
|
||||
theTask.dependsOn 'requestPasswords'
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" />
|
||||
|
||||
<application
|
||||
android:label="@string/hidden_app_name"
|
||||
tools:replace="label">
|
||||
|
||||
<receiver android:name="org.traccar.client.DialLaunchReceiver" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.NEW_OUTGOING_CALL" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
|
После Ширина: | Высота: | Размер: 5.5 KiB |
|
После Ширина: | Высота: | Размер: 3.3 KiB |
|
После Ширина: | Высота: | Размер: 8.0 KiB |
|
После Ширина: | Высота: | Размер: 14 KiB |
|
После Ширина: | Высота: | Размер: 20 KiB |
@@ -0,0 +1,53 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="org.traccar.client">
|
||||
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/TraccarTheme">
|
||||
|
||||
<activity android:name=".MainActivity" android:launchMode="singleTask" />
|
||||
|
||||
<activity-alias
|
||||
android:name=".Launcher"
|
||||
android:targetActivity=".MainActivity">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity-alias>
|
||||
|
||||
<activity android:name=".StatusActivity"/>
|
||||
|
||||
<activity android:name=".AboutActivity"/>
|
||||
|
||||
<activity
|
||||
android:name=".ShortcutActivity">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<service android:name=".TrackingService" />
|
||||
|
||||
<service android:name=".TrackingService$HideNotificationService" />
|
||||
|
||||
<receiver android:name=".AutostartReceiver">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@@ -0,0 +1,134 @@
|
||||
/*
|
||||
* Copyright (C) 2013 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.support.v4.content;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.PowerManager;
|
||||
import android.util.Log;
|
||||
import android.util.SparseArray;
|
||||
|
||||
/**
|
||||
* Helper for the common pattern of implementing a {@link BroadcastReceiver}
|
||||
* that receives a device wakeup event and then passes the work off
|
||||
* to a {@link android.app.Service}, while ensuring that the
|
||||
* device does not go back to sleep during the transition.
|
||||
*
|
||||
* <p>This class takes care of creating and managing a partial wake lock
|
||||
* for you; you must request the {@link android.Manifest.permission#WAKE_LOCK}
|
||||
* permission to use it.</p>
|
||||
*
|
||||
* <h3>Example</h3>
|
||||
*
|
||||
* <p>A {@link WakefulBroadcastReceiver} uses the method
|
||||
* {@link WakefulBroadcastReceiver#startWakefulService startWakefulService()}
|
||||
* to start the service that does the work. This method is comparable to
|
||||
* {@link android.content.Context#startService startService()}, except that
|
||||
* the {@link WakefulBroadcastReceiver} is holding a wake lock when the service
|
||||
* starts. The intent that is passed with
|
||||
* {@link WakefulBroadcastReceiver#startWakefulService startWakefulService()}
|
||||
* holds an extra identifying the wake lock.</p>
|
||||
*
|
||||
* {@sample development/samples/Support4Demos/src/com/example/android/supportv4/content/SimpleWakefulReceiver.java complete}
|
||||
*
|
||||
* <p>The service (in this example, an {@link android.app.IntentService}) does
|
||||
* some work. When it is finished, it releases the wake lock by calling
|
||||
* {@link WakefulBroadcastReceiver#completeWakefulIntent
|
||||
* completeWakefulIntent(intent)}. The intent it passes as a parameter
|
||||
* is the same intent that the {@link WakefulBroadcastReceiver} originally
|
||||
* passed in.</p>
|
||||
*
|
||||
* {@sample development/samples/Support4Demos/src/com/example/android/supportv4/content/SimpleWakefulService.java complete}
|
||||
*/
|
||||
public abstract class WakefulBroadcastReceiver extends BroadcastReceiver {
|
||||
private static final String EXTRA_WAKE_LOCK_ID = "android.support.content.wakelockid";
|
||||
|
||||
private static final SparseArray<PowerManager.WakeLock> mActiveWakeLocks
|
||||
= new SparseArray<PowerManager.WakeLock>();
|
||||
private static int mNextId = 1;
|
||||
|
||||
/**
|
||||
* Do a {@link android.content.Context#startService(android.content.Intent)
|
||||
* Context.startService}, but holding a wake lock while the service starts.
|
||||
* This will modify the Intent to hold an extra identifying the wake lock;
|
||||
* when the service receives it in {@link android.app.Service#onStartCommand
|
||||
* Service.onStartCommand}, it should pass back the Intent it receives there to
|
||||
* {@link #completeWakefulIntent(android.content.Intent)} in order to release
|
||||
* the wake lock.
|
||||
*
|
||||
* @param context The Context in which it operate.
|
||||
* @param intent The Intent with which to start the service, as per
|
||||
* {@link android.content.Context#startService(android.content.Intent)
|
||||
* Context.startService}.
|
||||
*/
|
||||
public static ComponentName startWakefulService(Context context, Intent intent) {
|
||||
synchronized (mActiveWakeLocks) {
|
||||
int id = mNextId;
|
||||
mNextId++;
|
||||
if (mNextId <= 0) {
|
||||
mNextId = 1;
|
||||
}
|
||||
|
||||
intent.putExtra(EXTRA_WAKE_LOCK_ID, id);
|
||||
ComponentName comp = context.startService(intent);
|
||||
if (comp == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
PowerManager pm = (PowerManager)context.getSystemService(Context.POWER_SERVICE);
|
||||
PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
|
||||
"wake:" + comp.flattenToShortString());
|
||||
wl.setReferenceCounted(false);
|
||||
wl.acquire(60*1000);
|
||||
mActiveWakeLocks.put(id, wl);
|
||||
return comp;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Finish the execution from a previous {@link #startWakefulService}. Any wake lock
|
||||
* that was being held will now be released.
|
||||
*
|
||||
* @param intent The Intent as originally generated by {@link #startWakefulService}.
|
||||
* @return Returns true if the intent is associated with a wake lock that is
|
||||
* now released; returns false if there was no wake lock specified for it.
|
||||
*/
|
||||
public static boolean completeWakefulIntent(Intent intent) {
|
||||
final int id = intent.getIntExtra(EXTRA_WAKE_LOCK_ID, 0);
|
||||
if (id == 0) {
|
||||
return false;
|
||||
}
|
||||
synchronized (mActiveWakeLocks) {
|
||||
PowerManager.WakeLock wl = mActiveWakeLocks.get(id);
|
||||
if (wl != null) {
|
||||
wl.release();
|
||||
mActiveWakeLocks.remove(id);
|
||||
return true;
|
||||
}
|
||||
// We return true whether or not we actually found the wake lock
|
||||
// the return code is defined to indicate whether the Intent contained
|
||||
// an identifier for a wake lock that it was supposed to match.
|
||||
// We just log a warning here if there is no wake lock found, which could
|
||||
// happen for example if this function is called twice on the same
|
||||
// intent or the process is killed and restarted before processing the intent.
|
||||
Log.w("WakefulBroadcastReceive", "No active wake lock id #" + id);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,22 +15,20 @@
|
||||
*/
|
||||
package org.traccar.client;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v4.content.WakefulBroadcastReceiver;
|
||||
|
||||
public class AutostartReceiver extends BroadcastReceiver {
|
||||
|
||||
public static final String LOG_TAG = "Traccar.AutostartReceiver";
|
||||
public class AutostartReceiver extends WakefulBroadcastReceiver {
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
if (sharedPreferences.getBoolean(TraccarActivity.KEY_STATUS, false)) {
|
||||
context.startService(new Intent(context, TraccarService.class));
|
||||
}
|
||||
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
if (sharedPreferences.getBoolean(MainActivity.KEY_STATUS, false)) {
|
||||
startWakefulService(context, new Intent(context, TrackingService.class));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
/*
|
||||
* Copyright 2015 Anton Tananaev (anton.tananaev@gmail.com)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.traccar.client;
|
||||
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.database.SQLException;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.database.sqlite.SQLiteOpenHelper;
|
||||
import android.os.AsyncTask;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class DatabaseHelper extends SQLiteOpenHelper {
|
||||
|
||||
public static final int DATABASE_VERSION = 1;
|
||||
public static final String DATABASE_NAME = "traccar.db";
|
||||
|
||||
public interface DatabaseHandler<T> {
|
||||
void onComplete(boolean success, T result);
|
||||
}
|
||||
|
||||
private static abstract class DatabaseAsyncTask<T> extends AsyncTask<Void, Void, T> {
|
||||
|
||||
private DatabaseHandler<T> handler;
|
||||
private RuntimeException error;
|
||||
|
||||
public DatabaseAsyncTask(DatabaseHandler<T> handler) {
|
||||
this.handler = handler;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected T doInBackground(Void... params) {
|
||||
try {
|
||||
return executeMethod();
|
||||
} catch (RuntimeException error) {
|
||||
this.error = error;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract T executeMethod();
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(T result) {
|
||||
handler.onComplete(error == null, result);
|
||||
}
|
||||
}
|
||||
|
||||
private SQLiteDatabase db;
|
||||
|
||||
public DatabaseHelper(Context context) {
|
||||
super(context, DATABASE_NAME, null, DATABASE_VERSION);
|
||||
db = getWritableDatabase();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(SQLiteDatabase db) {
|
||||
db.execSQL("CREATE TABLE position (" +
|
||||
"id INTEGER PRIMARY KEY AUTOINCREMENT," +
|
||||
"deviceId TEXT," +
|
||||
"time INTEGER," +
|
||||
"latitude REAL," +
|
||||
"longitude REAL," +
|
||||
"altitude REAL," +
|
||||
"speed REAL," +
|
||||
"course REAL," +
|
||||
"battery REAL)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||
db.execSQL("DROP TABLE IF EXISTS position;");
|
||||
onCreate(db);
|
||||
}
|
||||
|
||||
public void insertPosition(Position position) {
|
||||
ContentValues values = new ContentValues();
|
||||
values.put("deviceId", position.getDeviceId());
|
||||
values.put("time", position.getTime().getTime());
|
||||
values.put("latitude", position.getLatitude());
|
||||
values.put("longitude", position.getLongitude());
|
||||
values.put("altitude", position.getAltitude());
|
||||
values.put("speed", position.getSpeed());
|
||||
values.put("course", position.getCourse());
|
||||
values.put("battery", position.getBattery());
|
||||
|
||||
db.insertOrThrow("position", null, values);
|
||||
}
|
||||
|
||||
public void insertPositionAsync(final Position position, DatabaseHandler<Void> handler) {
|
||||
new DatabaseAsyncTask<Void>(handler) {
|
||||
@Override
|
||||
protected Void executeMethod() {
|
||||
insertPosition(position);
|
||||
return null;
|
||||
}
|
||||
}.execute();
|
||||
}
|
||||
|
||||
public Position selectPosition() {
|
||||
Position position = new Position();
|
||||
|
||||
Cursor cursor = db.rawQuery("SELECT * FROM position ORDER BY id LIMIT 1", null);
|
||||
try {
|
||||
if (cursor.getCount() > 0) {
|
||||
|
||||
cursor.moveToFirst();
|
||||
|
||||
position.setId(cursor.getLong(cursor.getColumnIndex("id")));
|
||||
position.setDeviceId(cursor.getString(cursor.getColumnIndex("deviceId")));
|
||||
position.setTime(new Date(cursor.getLong(cursor.getColumnIndex("time"))));
|
||||
position.setLatitude(cursor.getDouble(cursor.getColumnIndex("latitude")));
|
||||
position.setLongitude(cursor.getDouble(cursor.getColumnIndex("longitude")));
|
||||
position.setAltitude(cursor.getDouble(cursor.getColumnIndex("altitude")));
|
||||
position.setSpeed(cursor.getDouble(cursor.getColumnIndex("speed")));
|
||||
position.setCourse(cursor.getDouble(cursor.getColumnIndex("course")));
|
||||
position.setBattery(cursor.getDouble(cursor.getColumnIndex("battery")));
|
||||
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} finally {
|
||||
cursor.close();
|
||||
}
|
||||
|
||||
return position;
|
||||
}
|
||||
|
||||
public void selectPositionAsync(DatabaseHandler<Position> handler) {
|
||||
new DatabaseAsyncTask<Position>(handler) {
|
||||
@Override
|
||||
protected Position executeMethod() {
|
||||
return selectPosition();
|
||||
}
|
||||
}.execute();
|
||||
}
|
||||
|
||||
public void deletePosition(long id) {
|
||||
if (db.delete("position", "id = ?", new String[] { String.valueOf(id) }) != 1) {
|
||||
throw new SQLException();
|
||||
}
|
||||
}
|
||||
|
||||
public void deletePositionAsync(final long id, DatabaseHandler<Void> handler) {
|
||||
new DatabaseAsyncTask<Void>(handler) {
|
||||
@Override
|
||||
protected Void executeMethod() {
|
||||
deletePosition(id);
|
||||
return null;
|
||||
}
|
||||
}.execute();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright 2015 Anton Tananaev (anton.tananaev@gmail.com)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.traccar.client;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
public class DialLaunchReceiver extends BroadcastReceiver {
|
||||
|
||||
private static final String LAUNCHER_NUMBER = "8722227"; // TRACCAR
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
String phoneNumber = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
|
||||
if (phoneNumber.equals(LAUNCHER_NUMBER)) {
|
||||
setResultData(null);
|
||||
Intent appIntent = new Intent(context, MainActivity.class);
|
||||
appIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(appIntent);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,276 @@
|
||||
/*
|
||||
* Copyright 2012 - 2016 Anton Tananaev (anton.tananaev@gmail.com)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.traccar.client;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.AlarmManager;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.preference.CheckBoxPreference;
|
||||
import android.preference.EditTextPreference;
|
||||
import android.preference.Preference;
|
||||
import android.preference.PreferenceActivity;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.preference.TwoStatePreference;
|
||||
import android.util.Patterns;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class MainActivity extends PreferenceActivity implements OnSharedPreferenceChangeListener {
|
||||
|
||||
public static final String KEY_DEVICE = "id";
|
||||
public static final String KEY_ADDRESS = "address";
|
||||
public static final String KEY_PORT = "port";
|
||||
public static final String KEY_INTERVAL = "interval";
|
||||
public static final String KEY_PROVIDER = "provider";
|
||||
public static final String KEY_STATUS = "status";
|
||||
|
||||
private static final int PERMISSIONS_REQUEST_LOCATION = 2;
|
||||
|
||||
private SharedPreferences sharedPreferences;
|
||||
|
||||
private AlarmManager alarmManager;
|
||||
private PendingIntent alarmIntent;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
if (BuildConfig.HIDDEN_APP) {
|
||||
removeLauncherIcon();
|
||||
}
|
||||
|
||||
sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
addPreferencesFromResource(R.xml.preferences);
|
||||
initPreferences();
|
||||
|
||||
findPreference(KEY_DEVICE).setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
return newValue != null && !newValue.equals("");
|
||||
}
|
||||
});
|
||||
findPreference(KEY_ADDRESS).setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO) {
|
||||
return newValue != null && Patterns.DOMAIN_NAME.matcher((String) newValue).matches();
|
||||
} else {
|
||||
return newValue != null && !((String) newValue).isEmpty();
|
||||
}
|
||||
}
|
||||
});
|
||||
findPreference(KEY_PORT).setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
if (newValue != null) {
|
||||
try {
|
||||
int value = Integer.parseInt((String) newValue);
|
||||
if (value > 0 && value <= 65536) {
|
||||
return true;
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
findPreference(KEY_INTERVAL).setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
if (newValue != null) {
|
||||
try {
|
||||
Integer.parseInt((String) newValue);
|
||||
return true;
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
if (sharedPreferences.getBoolean(KEY_STATUS, false)) {
|
||||
startTrackingService(true, false);
|
||||
}
|
||||
|
||||
alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
|
||||
alarmIntent = PendingIntent.getBroadcast(this, 0, new Intent(this, AutostartReceiver.class), 0);
|
||||
}
|
||||
|
||||
private void removeLauncherIcon() {
|
||||
String className = MainActivity.class.getCanonicalName().replace(".MainActivity", ".Launcher");
|
||||
ComponentName componentName = new ComponentName(getPackageName(), className);
|
||||
PackageManager packageManager = getPackageManager();
|
||||
if (packageManager.getComponentEnabledSetting(componentName) != PackageManager.COMPONENT_ENABLED_STATE_DISABLED) {
|
||||
packageManager.setComponentEnabledSetting(
|
||||
componentName, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setIcon(android.R.drawable.ic_dialog_alert);
|
||||
builder.setMessage(getString(R.string.hidden_alert));
|
||||
builder.setPositiveButton(android.R.string.ok, null);
|
||||
builder.show();
|
||||
}
|
||||
}
|
||||
|
||||
private void addShortcuts(boolean start, int name) {
|
||||
Intent shortcutIntent = new Intent(Intent.ACTION_MAIN);
|
||||
shortcutIntent.setComponent(new ComponentName(getPackageName(), ShortcutActivity.class.getCanonicalName()));
|
||||
shortcutIntent.putExtra(ShortcutActivity.EXTRA_ACTION, start);
|
||||
|
||||
Intent installShortCutIntent = new Intent("com.android.launcher.action.INSTALL_SHORTCUT");
|
||||
installShortCutIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
|
||||
installShortCutIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(name));
|
||||
installShortCutIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
|
||||
Intent.ShortcutIconResource.fromContext(this, R.mipmap.ic_launcher));
|
||||
|
||||
sendBroadcast(installShortCutIntent);
|
||||
}
|
||||
|
||||
private boolean hasPermission(String permission) {
|
||||
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP_MR1) {
|
||||
return true;
|
||||
}
|
||||
return checkSelfPermission(permission) == PackageManager.PERMISSION_GRANTED;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
sharedPreferences.registerOnSharedPreferenceChangeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
sharedPreferences.unregisterOnSharedPreferenceChangeListener(this);
|
||||
}
|
||||
|
||||
private void setPreferencesEnabled(boolean enabled) {
|
||||
findPreference(KEY_DEVICE).setEnabled(enabled);
|
||||
findPreference(KEY_ADDRESS).setEnabled(enabled);
|
||||
findPreference(KEY_PORT).setEnabled(enabled);
|
||||
findPreference(KEY_INTERVAL).setEnabled(enabled);
|
||||
findPreference(KEY_PROVIDER).setEnabled(enabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
||||
if (key.equals(KEY_STATUS)) {
|
||||
if (sharedPreferences.getBoolean(KEY_STATUS, false)) {
|
||||
startTrackingService(true, false);
|
||||
} else {
|
||||
stopTrackingService();
|
||||
}
|
||||
} else if (key.equals(KEY_DEVICE)) {
|
||||
findPreference(KEY_DEVICE).setSummary(sharedPreferences.getString(KEY_DEVICE, null));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.main, menu);
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
if (item.getItemId() == R.id.status) {
|
||||
startActivity(new Intent(this, StatusActivity.class));
|
||||
return true;
|
||||
} else if (item.getItemId() == R.id.shortcuts) {
|
||||
addShortcuts(true, R.string.shortcut_start);
|
||||
addShortcuts(false, R.string.shortcut_stop);
|
||||
return true;
|
||||
} else if (item.getItemId() == R.id.about) {
|
||||
startActivity(new Intent(this, AboutActivity.class));
|
||||
return true;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
private void initPreferences() {
|
||||
PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
|
||||
|
||||
if (!sharedPreferences.contains(KEY_DEVICE)) {
|
||||
String id = String.valueOf(new Random().nextInt(900000) + 100000);
|
||||
sharedPreferences.edit().putString(KEY_DEVICE, id).commit();
|
||||
((EditTextPreference) findPreference(KEY_DEVICE)).setText(id);
|
||||
}
|
||||
findPreference(KEY_DEVICE).setSummary(sharedPreferences.getString(KEY_DEVICE, null));
|
||||
}
|
||||
|
||||
private void startTrackingService(boolean checkPermission, boolean permission) {
|
||||
if (checkPermission) {
|
||||
Set<String> missingPermissions = new HashSet<>();
|
||||
if (!hasPermission(Manifest.permission.ACCESS_FINE_LOCATION)) {
|
||||
missingPermissions.add(Manifest.permission.ACCESS_FINE_LOCATION);
|
||||
}
|
||||
if (!hasPermission(Manifest.permission.ACCESS_COARSE_LOCATION)) {
|
||||
missingPermissions.add(Manifest.permission.ACCESS_COARSE_LOCATION);
|
||||
}
|
||||
if (missingPermissions.isEmpty()) {
|
||||
permission = true;
|
||||
} else {
|
||||
requestPermissions(missingPermissions.toArray(new String[missingPermissions.size()]), PERMISSIONS_REQUEST_LOCATION);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (permission) {
|
||||
setPreferencesEnabled(false);
|
||||
startService(new Intent(this, TrackingService.class));
|
||||
alarmManager.setInexactRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,
|
||||
15000, 15000, alarmIntent);
|
||||
} else {
|
||||
sharedPreferences.edit().putBoolean(KEY_STATUS, false).commit();
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
|
||||
TwoStatePreference preference = (TwoStatePreference) findPreference(KEY_STATUS);
|
||||
preference.setChecked(false);
|
||||
} else {
|
||||
CheckBoxPreference preference = (CheckBoxPreference) findPreference(KEY_STATUS);
|
||||
preference.setChecked(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void stopTrackingService() {
|
||||
alarmManager.cancel(alarmIntent);
|
||||
stopService(new Intent(this, TrackingService.class));
|
||||
setPreferencesEnabled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
|
||||
if (requestCode == PERMISSIONS_REQUEST_LOCATION) {
|
||||
startTrackingService(false, grantResults[0] == PackageManager.PERMISSION_GRANTED &&
|
||||
(permissions.length < 2 || grantResults[1] == PackageManager.PERMISSION_GRANTED));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* Copyright 2015 Anton Tananaev (anton.tananaev@gmail.com)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.traccar.client;
|
||||
|
||||
import android.content.Context;
|
||||
import android.location.GpsStatus;
|
||||
import android.location.Location;
|
||||
import android.location.LocationListener;
|
||||
import android.location.LocationManager;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
|
||||
public class MixedPositionProvider extends PositionProvider implements LocationListener, GpsStatus.Listener {
|
||||
|
||||
private static int FIX_TIMEOUT = 30 * 1000;
|
||||
|
||||
private LocationListener backupListener;
|
||||
private long lastFixTime;
|
||||
|
||||
public MixedPositionProvider(Context context, PositionListener listener) {
|
||||
super(context, listener);
|
||||
}
|
||||
|
||||
public void startUpdates() {
|
||||
lastFixTime = System.currentTimeMillis();
|
||||
locationManager.addGpsStatusListener(this);
|
||||
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, period, 0, this);
|
||||
}
|
||||
|
||||
public void stopUpdates() {
|
||||
locationManager.removeUpdates(this);
|
||||
locationManager.removeGpsStatusListener(this);
|
||||
stopBackupProvider();
|
||||
}
|
||||
|
||||
private void startBackupProvider() {
|
||||
Log.i(TAG, "backup provider start");
|
||||
if (backupListener == null) {
|
||||
|
||||
backupListener = new LocationListener() {
|
||||
@Override
|
||||
public void onLocationChanged(Location location) {
|
||||
Log.i(TAG, "backup provider location");
|
||||
updateLocation(location);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStatusChanged(String s, int i, Bundle bundle) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProviderEnabled(String s) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProviderDisabled(String s) {
|
||||
}
|
||||
};
|
||||
|
||||
locationManager.requestLocationUpdates(
|
||||
LocationManager.NETWORK_PROVIDER, period, 0, backupListener);
|
||||
}
|
||||
}
|
||||
|
||||
private void stopBackupProvider() {
|
||||
Log.i(TAG, "backup provider stop");
|
||||
if (backupListener != null) {
|
||||
locationManager.removeUpdates(backupListener);
|
||||
backupListener = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLocationChanged(Location location) {
|
||||
Log.i(TAG, "provider location");
|
||||
stopBackupProvider();
|
||||
lastFixTime = System.currentTimeMillis();
|
||||
updateLocation(location);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStatusChanged(String provider, int status, Bundle extras) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProviderEnabled(String provider) {
|
||||
Log.i(TAG, "provider enabled");
|
||||
stopBackupProvider();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProviderDisabled(String provider) {
|
||||
Log.i(TAG, "provider disabled");
|
||||
startBackupProvider();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGpsStatusChanged(int event) {
|
||||
if (backupListener == null && System.currentTimeMillis() - (lastFixTime + period) > FIX_TIMEOUT) {
|
||||
startBackupProvider();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright 2015 Anton Tananaev (anton.tananaev@gmail.com)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.traccar.client;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.util.Log;
|
||||
|
||||
public class NetworkManager extends BroadcastReceiver {
|
||||
|
||||
private static final String TAG = NetworkManager.class.getSimpleName();
|
||||
|
||||
private Context context;
|
||||
private NetworkHandler handler;
|
||||
private ConnectivityManager connectivityManager;
|
||||
|
||||
public NetworkManager(Context context, NetworkHandler handler) {
|
||||
this.context = context;
|
||||
this.handler = handler;
|
||||
connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
}
|
||||
|
||||
public interface NetworkHandler {
|
||||
void onNetworkUpdate(boolean isOnline);
|
||||
}
|
||||
|
||||
public boolean isOnline() {
|
||||
NetworkInfo activeNetwork = connectivityManager.getActiveNetworkInfo();
|
||||
return activeNetwork != null && activeNetwork.isConnectedOrConnecting();
|
||||
}
|
||||
|
||||
public void start() {
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
|
||||
context.registerReceiver(this, filter);
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
context.unregisterReceiver(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (intent.getAction().equals(ConnectivityManager.CONNECTIVITY_ACTION) && handler != null) {
|
||||
boolean isOnline = isOnline();
|
||||
Log.i(TAG, "network " + (isOnline ? "on" : "off"));
|
||||
handler.onNetworkUpdate(isOnline);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright 2015 Anton Tananaev (anton.tananaev@gmail.com)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.traccar.client;
|
||||
|
||||
import android.location.Location;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class Position {
|
||||
|
||||
public Position() {
|
||||
}
|
||||
|
||||
public Position(String deviceId, Location location, double battery) {
|
||||
this.deviceId = deviceId;
|
||||
time = new Date(location.getTime());
|
||||
latitude = location.getLatitude();
|
||||
longitude = location.getLongitude();
|
||||
altitude = location.getAltitude();
|
||||
speed = location.getSpeed() * 1.943844; // speed in knots
|
||||
course = location.getBearing();
|
||||
this.battery = battery;
|
||||
}
|
||||
|
||||
private long id;
|
||||
public long getId() { return id; }
|
||||
public void setId(long id) { this.id = id; }
|
||||
|
||||
private String deviceId;
|
||||
public String getDeviceId() { return deviceId; }
|
||||
public void setDeviceId(String deviceId) { this.deviceId = deviceId; }
|
||||
|
||||
private Date time;
|
||||
public Date getTime() { return time; }
|
||||
public void setTime(Date time) { this.time = time; }
|
||||
|
||||
private double latitude;
|
||||
public double getLatitude() { return latitude; }
|
||||
public void setLatitude(double latitude) { this.latitude = latitude; }
|
||||
|
||||
private double longitude;
|
||||
public double getLongitude() { return longitude; }
|
||||
public void setLongitude(double longitude) { this.longitude = longitude; }
|
||||
|
||||
private double altitude;
|
||||
public double getAltitude() { return altitude; }
|
||||
public void setAltitude(double altitude) { this.altitude = altitude; }
|
||||
|
||||
private double speed;
|
||||
public double getSpeed() { return speed; }
|
||||
public void setSpeed(double speed) { this.speed = speed; }
|
||||
|
||||
private double course;
|
||||
public double getCourse() { return course; }
|
||||
public void setCourse(double course) { this.course = course; }
|
||||
|
||||
private double battery;
|
||||
public double getBattery() { return battery; }
|
||||
public void setBattery(double battery) { this.battery = battery; }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Copyright 2013 - 2015 Anton Tananaev (anton.tananaev@gmail.com)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.traccar.client;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.SharedPreferences;
|
||||
import android.location.Location;
|
||||
import android.location.LocationManager;
|
||||
import android.os.BatteryManager;
|
||||
import android.os.Build;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
|
||||
public abstract class PositionProvider {
|
||||
|
||||
protected static final String TAG = PositionProvider.class.getSimpleName();
|
||||
|
||||
public interface PositionListener {
|
||||
void onPositionUpdate(Position position);
|
||||
}
|
||||
|
||||
private final PositionListener listener;
|
||||
|
||||
private final Context context;
|
||||
private final SharedPreferences preferences;
|
||||
protected final LocationManager locationManager;
|
||||
|
||||
private String deviceId;
|
||||
protected String type;
|
||||
protected final long period;
|
||||
|
||||
private long lastUpdateTime;
|
||||
|
||||
public PositionProvider(Context context, PositionListener listener) {
|
||||
this.context = context;
|
||||
this.listener = listener;
|
||||
|
||||
preferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
|
||||
|
||||
deviceId = preferences.getString(MainActivity.KEY_DEVICE, null);
|
||||
period = Integer.parseInt(preferences.getString(MainActivity.KEY_INTERVAL, null)) * 1000;
|
||||
|
||||
type = preferences.getString(MainActivity.KEY_PROVIDER, null);
|
||||
}
|
||||
|
||||
public abstract void startUpdates();
|
||||
|
||||
public abstract void stopUpdates();
|
||||
|
||||
protected void updateLocation(Location location) {
|
||||
if (location != null && location.getTime() - lastUpdateTime >= period) {
|
||||
Log.i(TAG, "location new");
|
||||
lastUpdateTime = location.getTime();
|
||||
listener.onPositionUpdate(new Position(deviceId, location, getBatteryLevel()));
|
||||
} else {
|
||||
Log.i(TAG, location != null ? "location old" : "location nil");
|
||||
}
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.ECLAIR)
|
||||
private double getBatteryLevel() {
|
||||
if (android.os.Build.VERSION.SDK_INT > Build.VERSION_CODES.ECLAIR) {
|
||||
Intent batteryIntent = context.registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
|
||||
int level = batteryIntent.getIntExtra(BatteryManager.EXTRA_LEVEL, 0);
|
||||
int scale = batteryIntent.getIntExtra(BatteryManager.EXTRA_SCALE, 1);
|
||||
return (level * 100.0) / scale;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright 2012 - 2015 Anton Tananaev (anton.tananaev@gmail.com)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.traccar.client;
|
||||
|
||||
import android.location.Location;
|
||||
import android.net.Uri;
|
||||
|
||||
public class ProtocolFormatter {
|
||||
|
||||
public static String formatRequest(String address, int port, Position position) {
|
||||
|
||||
Uri.Builder builder = new Uri.Builder();
|
||||
builder.scheme("http").encodedAuthority(address + ':' + port)
|
||||
.appendQueryParameter("id", position.getDeviceId())
|
||||
.appendQueryParameter("timestamp", String.valueOf(position.getTime().getTime() / 1000))
|
||||
.appendQueryParameter("lat", String.valueOf(position.getLatitude()))
|
||||
.appendQueryParameter("lon", String.valueOf(position.getLongitude()))
|
||||
.appendQueryParameter("speed", String.valueOf(position.getSpeed()))
|
||||
.appendQueryParameter("bearing", String.valueOf(position.getCourse()))
|
||||
.appendQueryParameter("altitude", String.valueOf(position.getAltitude()))
|
||||
.appendQueryParameter("batt", String.valueOf(position.getBattery()));
|
||||
|
||||
return builder.build().toString();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright 2015 Anton Tananaev (anton.tananaev@gmail.com)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.traccar.client;
|
||||
|
||||
import android.os.AsyncTask;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
|
||||
public class RequestManager {
|
||||
|
||||
private static final int TIMEOUT = 15 * 1000;
|
||||
|
||||
public interface RequestHandler {
|
||||
void onComplete(boolean success);
|
||||
}
|
||||
|
||||
private static class RequestAsyncTask extends AsyncTask<String, Void, Boolean> {
|
||||
|
||||
private RequestHandler handler;
|
||||
|
||||
public RequestAsyncTask(RequestHandler handler) {
|
||||
this.handler = handler;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Boolean doInBackground(String... request) {
|
||||
return sendRequest(request[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Boolean result) {
|
||||
handler.onComplete(result);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean sendRequest(String request) {
|
||||
InputStream inputStream = null;
|
||||
try {
|
||||
URL url = new URL(request);
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
connection.setReadTimeout(TIMEOUT);
|
||||
connection.setConnectTimeout(TIMEOUT);
|
||||
connection.connect();
|
||||
inputStream = connection.getInputStream();
|
||||
while (inputStream.read() != -1);
|
||||
return true;
|
||||
} catch (IOException error) {
|
||||
return false;
|
||||
} finally {
|
||||
try {
|
||||
if (inputStream != null) {
|
||||
inputStream.close();
|
||||
}
|
||||
} catch (IOException secondError) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendRequestAsync(String request, RequestHandler handler) {
|
||||
RequestAsyncTask task = new RequestAsyncTask(handler);
|
||||
task.execute(request);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright 2016 Anton Tananaev (anton.tananaev@gmail.com)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.traccar.client;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.widget.Toast;
|
||||
|
||||
public class ShortcutActivity extends Activity {
|
||||
|
||||
public static final String EXTRA_ACTION = "shortcutAction";
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
checkShortcutAction(getIntent());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onNewIntent(Intent intent) {
|
||||
super.onNewIntent(intent);
|
||||
checkShortcutAction(intent);
|
||||
}
|
||||
|
||||
private void checkShortcutAction(Intent intent) {
|
||||
if (intent.hasExtra(EXTRA_ACTION)) {
|
||||
boolean start = intent.getBooleanExtra(EXTRA_ACTION, false);
|
||||
PreferenceManager.getDefaultSharedPreferences(this)
|
||||
.edit().putBoolean(MainActivity.KEY_STATUS, start).commit();
|
||||
if (start) {
|
||||
startService(new Intent(this, TrackingService.class));
|
||||
Toast.makeText(this, R.string.status_service_create, Toast.LENGTH_SHORT).show();
|
||||
} else {
|
||||
stopService(new Intent(this, TrackingService.class));
|
||||
Toast.makeText(this, R.string.status_service_destroy, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright 2015 Anton Tananaev (anton.tananaev@gmail.com)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.traccar.client;
|
||||
|
||||
import android.content.Context;
|
||||
import android.location.Location;
|
||||
import android.location.LocationListener;
|
||||
import android.location.LocationManager;
|
||||
import android.os.Bundle;
|
||||
|
||||
public class SimplePositionProvider extends PositionProvider implements LocationListener {
|
||||
|
||||
public SimplePositionProvider(Context context, PositionListener listener) {
|
||||
super(context, listener);
|
||||
if (!type.equals(LocationManager.NETWORK_PROVIDER)) {
|
||||
type = LocationManager.GPS_PROVIDER;
|
||||
}
|
||||
}
|
||||
|
||||
public void startUpdates() {
|
||||
locationManager.requestLocationUpdates(type, period, 0, this);
|
||||
}
|
||||
|
||||
public void stopUpdates() {
|
||||
locationManager.removeUpdates(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLocationChanged(Location location) {
|
||||
updateLocation(location);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStatusChanged(String provider, int status, Bundle extras) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProviderEnabled(String provider) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProviderDisabled(String provider) {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -19,12 +19,10 @@ import java.text.DateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import android.app.ListActivity;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
@@ -32,7 +30,9 @@ import android.widget.ArrayAdapter;
|
||||
|
||||
public class StatusActivity extends ListActivity {
|
||||
|
||||
private static final List<String> messages = new LinkedList<String>();
|
||||
private static final int LIMIT = 20;
|
||||
|
||||
private static final LinkedList<String> messages = new LinkedList<String>();
|
||||
private static final Set<ArrayAdapter<String>> adapters = new HashSet<ArrayAdapter<String>>();
|
||||
|
||||
private static void notifyAdapters() {
|
||||
@@ -42,10 +42,12 @@ public class StatusActivity extends ListActivity {
|
||||
}
|
||||
|
||||
public static void addMessage(String message) {
|
||||
Log.i(TraccarActivity.LOG_TAG, message);
|
||||
DateFormat format = DateFormat.getTimeInstance(DateFormat.SHORT);
|
||||
message = format.format(new Date()) + " - " + message;
|
||||
messages.add(message);
|
||||
while (messages.size() > LIMIT) {
|
||||
messages.removeFirst();
|
||||
}
|
||||
notifyAdapters();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,227 @@
|
||||
/*
|
||||
* Copyright 2015 Anton Tananaev (anton.tananaev@gmail.com)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.traccar.client;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.os.PowerManager;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
|
||||
public class TrackingController implements PositionProvider.PositionListener, NetworkManager.NetworkHandler {
|
||||
|
||||
private static final String TAG = TrackingController.class.getSimpleName();
|
||||
private static final int RETRY_DELAY = 30 * 1000;
|
||||
private static final int WAKE_LOCK_TIMEOUT = 60 * 1000;
|
||||
|
||||
private boolean isOnline;
|
||||
private boolean isWaiting;
|
||||
|
||||
private Context context;
|
||||
private Handler handler;
|
||||
private SharedPreferences preferences;
|
||||
|
||||
private String address;
|
||||
private int port;
|
||||
|
||||
private PositionProvider positionProvider;
|
||||
private DatabaseHelper databaseHelper;
|
||||
private NetworkManager networkManager;
|
||||
|
||||
private PowerManager.WakeLock wakeLock;
|
||||
|
||||
private void lock() {
|
||||
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD_MR1) {
|
||||
wakeLock.acquire();
|
||||
} else {
|
||||
wakeLock.acquire(WAKE_LOCK_TIMEOUT);
|
||||
}
|
||||
}
|
||||
|
||||
private void unlock() {
|
||||
if (wakeLock.isHeld()) {
|
||||
wakeLock.release();
|
||||
}
|
||||
}
|
||||
|
||||
public TrackingController(Context context) {
|
||||
this.context = context;
|
||||
handler = new Handler();
|
||||
preferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
if (preferences.getString(MainActivity.KEY_PROVIDER, null).equals("mixed")) {
|
||||
positionProvider = new MixedPositionProvider(context, this);
|
||||
} else {
|
||||
positionProvider = new SimplePositionProvider(context, this);
|
||||
}
|
||||
databaseHelper = new DatabaseHelper(context);
|
||||
networkManager = new NetworkManager(context, this);
|
||||
isOnline = networkManager.isOnline();
|
||||
|
||||
address = preferences.getString(MainActivity.KEY_ADDRESS, null);
|
||||
port = Integer.parseInt(preferences.getString(MainActivity.KEY_PORT, null));
|
||||
|
||||
PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
|
||||
wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, getClass().getName());
|
||||
}
|
||||
|
||||
public void start() {
|
||||
if (isOnline) {
|
||||
read();
|
||||
}
|
||||
try {
|
||||
positionProvider.startUpdates();
|
||||
} catch (SecurityException e) {
|
||||
Log.w(TAG, e);
|
||||
}
|
||||
networkManager.start();
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
networkManager.stop();
|
||||
try {
|
||||
positionProvider.stopUpdates();
|
||||
} catch (SecurityException e) {
|
||||
Log.w(TAG, e);
|
||||
}
|
||||
handler.removeCallbacksAndMessages(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPositionUpdate(Position position) {
|
||||
StatusActivity.addMessage(context.getString(R.string.status_location_update));
|
||||
if (position != null) {
|
||||
write(position);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNetworkUpdate(boolean isOnline) {
|
||||
StatusActivity.addMessage(context.getString(R.string.status_connectivity_change));
|
||||
if (!this.isOnline && isOnline) {
|
||||
read();
|
||||
}
|
||||
this.isOnline = isOnline;
|
||||
}
|
||||
|
||||
//
|
||||
// State transition examples:
|
||||
//
|
||||
// write -> read -> send -> delete -> read
|
||||
//
|
||||
// read -> send -> retry -> read -> send
|
||||
//
|
||||
|
||||
private void log(String action, Position position) {
|
||||
if (position != null) {
|
||||
action += " (" +
|
||||
"id:" + position.getId() +
|
||||
" time:" + position.getTime().getTime() / 1000 +
|
||||
" lat:" + position.getLatitude() +
|
||||
" lon:" + position.getLongitude() + ")";
|
||||
}
|
||||
Log.d(TAG, action);
|
||||
}
|
||||
|
||||
private void write(Position position) {
|
||||
log("write", position);
|
||||
lock();
|
||||
databaseHelper.insertPositionAsync(position, new DatabaseHelper.DatabaseHandler<Void>() {
|
||||
@Override
|
||||
public void onComplete(boolean success, Void result) {
|
||||
if (success) {
|
||||
if (isOnline && isWaiting) {
|
||||
read();
|
||||
isWaiting = false;
|
||||
}
|
||||
}
|
||||
unlock();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void read() {
|
||||
log("read", null);
|
||||
lock();
|
||||
databaseHelper.selectPositionAsync(new DatabaseHelper.DatabaseHandler<Position>() {
|
||||
@Override
|
||||
public void onComplete(boolean success, Position result) {
|
||||
if (success) {
|
||||
if (result != null) {
|
||||
if (result.getDeviceId().equals(preferences.getString(MainActivity.KEY_DEVICE, null))) {
|
||||
send(result);
|
||||
} else {
|
||||
delete(result);
|
||||
}
|
||||
} else {
|
||||
isWaiting = true;
|
||||
}
|
||||
} else {
|
||||
retry();
|
||||
}
|
||||
unlock();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void delete(Position position) {
|
||||
log("delete", position);
|
||||
lock();
|
||||
databaseHelper.deletePositionAsync(position.getId(), new DatabaseHelper.DatabaseHandler<Void>() {
|
||||
@Override
|
||||
public void onComplete(boolean success, Void result) {
|
||||
if (success) {
|
||||
read();
|
||||
} else {
|
||||
retry();
|
||||
}
|
||||
unlock();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void send(final Position position) {
|
||||
log("send", position);
|
||||
lock();
|
||||
String request = ProtocolFormatter.formatRequest(address, port, position);
|
||||
RequestManager.sendRequestAsync(request, new RequestManager.RequestHandler() {
|
||||
@Override
|
||||
public void onComplete(boolean success) {
|
||||
if (success) {
|
||||
delete(position);
|
||||
} else {
|
||||
StatusActivity.addMessage(context.getString(R.string.status_send_fail));
|
||||
retry();
|
||||
}
|
||||
unlock();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void retry() {
|
||||
log("retry", null);
|
||||
handler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (isOnline) {
|
||||
read();
|
||||
}
|
||||
}
|
||||
}, RETRY_DELAY);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
/*
|
||||
* Copyright 2012 - 2015 Anton Tananaev (anton.tananaev@gmail.com)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.traccar.client;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Notification;
|
||||
import android.app.PendingIntent;
|
||||
import android.app.Service;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.os.IBinder;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class TrackingService extends Service {
|
||||
|
||||
private static final String TAG = TrackingService.class.getSimpleName();
|
||||
private static final int NOTIFICATION_ID = 1;
|
||||
|
||||
private TrackingController trackingController;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private static Notification createNotification(Context context) {
|
||||
Intent notificationIntent = new Intent(context, MainActivity.class);
|
||||
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);
|
||||
|
||||
Notification notification = new Notification(android.R.drawable.stat_notify_sync_noanim, null, 0);
|
||||
try {
|
||||
Method method = notification.getClass().getMethod("setLatestEventInfo", Context.class, CharSequence.class, CharSequence.class, PendingIntent.class);
|
||||
try {
|
||||
method.invoke(notification, context, context.getString(R.string.app_name), context.getString(R.string.settings_status_on_summary), pendingIntent);
|
||||
} catch (IllegalArgumentException | IllegalAccessException | InvocationTargetException e) {
|
||||
Log.w(TAG, e);
|
||||
}
|
||||
} catch (SecurityException | NoSuchMethodException e) {
|
||||
Log.w(TAG, e);
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
|
||||
notification.priority = Notification.PRIORITY_MIN;
|
||||
}
|
||||
|
||||
return notification;
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.ECLAIR)
|
||||
public static class HideNotificationService extends Service {
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
startForeground(NOTIFICATION_ID, createNotification(this));
|
||||
stopForeground(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
stopSelfResult(startId);
|
||||
return START_NOT_STICKY;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
Log.i(TAG, "service create");
|
||||
StatusActivity.addMessage(getString(R.string.status_service_create));
|
||||
|
||||
trackingController = new TrackingController(this);
|
||||
trackingController.start();
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ECLAIR) {
|
||||
startForeground(NOTIFICATION_ID, createNotification(this));
|
||||
startService(new Intent(this, HideNotificationService.class));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void onStart(Intent intent, int startId) {
|
||||
if (intent != null) {
|
||||
AutostartReceiver.completeWakefulIntent(intent);
|
||||
}
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.ECLAIR)
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
onStart(intent, startId);
|
||||
return START_STICKY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
Log.i(TAG, "service destroy");
|
||||
StatusActivity.addMessage(getString(R.string.status_service_destroy));
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ECLAIR) {
|
||||
stopForeground(true);
|
||||
}
|
||||
|
||||
if (trackingController != null) {
|
||||
trackingController.stop();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
После Ширина: | Высота: | Размер: 3.6 KiB |
|
После Ширина: | Высота: | Размер: 2.4 KiB |
|
После Ширина: | Высота: | Размер: 4.8 KiB |
|
После Ширина: | Высота: | Размер: 7.2 KiB |
@@ -8,10 +8,12 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_marginLeft="@dimen/about_margin"
|
||||
android:layout_marginStart="@dimen/about_margin"
|
||||
android:layout_marginTop="@dimen/about_margin"
|
||||
android:src="@drawable/ic_launcher"
|
||||
android:src="@drawable/logo"
|
||||
android:contentDescription="@string/app_logo" />
|
||||
|
||||
<LinearLayout
|
||||
@@ -19,6 +21,7 @@
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_margin="@dimen/about_margin"
|
||||
android:layout_toRightOf="@+id/logo"
|
||||
android:layout_toEndOf="@+id/logo"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<TextView
|
||||
@@ -6,9 +6,14 @@
|
||||
android:title="@string/menu_status"
|
||||
android:showAsAction="always" />
|
||||
|
||||
<item
|
||||
android:id="@+id/shortcuts"
|
||||
android:title="@string/menu_shortcuts"
|
||||
android:showAsAction="never" />
|
||||
|
||||
<item
|
||||
android:id="@+id/about"
|
||||
android:title="@string/menu_about"
|
||||
android:showAsAction="ifRoom" />
|
||||
android:showAsAction="never" />
|
||||
|
||||
</menu>
|
||||
@@ -0,0 +1,35 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<resources>
|
||||
<string name="app_name">Traccar klient</string>
|
||||
<string name="app_logo">Traccar</string>
|
||||
<string name="settings_id_title">Identifikátor zařízení</string>
|
||||
<string name="settings_address_title">Adresa serveru</string>
|
||||
<string name="settings_address_summary">Doménové jméno nebo IP adresa</string>
|
||||
<string name="settings_port_title">Port</string>
|
||||
<string name="settings_port_summary">TCP port sledovacího serveru</string>
|
||||
<string name="settings_interval_title">Frekvence</string>
|
||||
<string name="settings_interval_summary">Interval zpráv v sekundách</string>
|
||||
<string name="settings_status_title">Stav služby</string>
|
||||
<string name="settings_status_off">Start</string>
|
||||
<string name="settings_status_on">Stop</string>
|
||||
<string name="settings_status_off_summary">Zastaveno</string>
|
||||
<string name="settings_status_on_summary">Spuštěno</string>
|
||||
<string name="settings_provider_title">Poskytovatel zaměření</string>
|
||||
<string name="settings_provider_summary">Zdroj zaměřovacích dat</string>
|
||||
<string name="settings_provider_gps">GPS</string>
|
||||
<string name="settings_provider_network">Mobilní síť</string>
|
||||
<string name="settings_provider_mixed">Obojí</string>
|
||||
<string name="settings_foreground_title">Popředí služba</string>
|
||||
<string name="settings_foreground_summary">Zvýšit prioritu služba</string>
|
||||
<string name="menu_status">Stav</string>
|
||||
<string name="menu_about">O aplikaci</string>
|
||||
<string name="menu_clear">Vyčistit</string>
|
||||
<string name="about_description">GPS sledovací aplikace pracující v reálném čase pro zařízení s operačním systémem Android. Kompatibilní s Traccar serverem a dalšími sledovacími systémy.</string>
|
||||
<string name="about_license">Tato aplikace je zdarma a open source, zdrojový kód je licencován pod Apache License Version 2.0 a je přístupný na GitHub.</string>
|
||||
<string name="about_web">Pro více informací navštivte\nwww.traccar.org/client</string>
|
||||
<string name="status_service_create">Služba vytvořena</string>
|
||||
<string name="status_service_destroy">Služba zastavena</string>
|
||||
<string name="status_send_fail">Odesílání selhalo</string>
|
||||
<string name="status_location_update">Aktualizace pozice</string>
|
||||
<string name="status_connectivity_change">Změna připojení</string>
|
||||
</resources>
|
||||
@@ -0,0 +1,35 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<resources>
|
||||
<string name="app_name">Traccar klient</string>
|
||||
<string name="app_logo">Traccar</string>
|
||||
<string name="settings_id_title">Indentificere Enhed</string>
|
||||
<string name="settings_address_title">Server adresse</string>
|
||||
<string name="settings_address_summary">Domænenavn eller IP adresse</string>
|
||||
<string name="settings_port_title">Server port</string>
|
||||
<string name="settings_port_summary">Tracking server TCP port</string>
|
||||
<string name="settings_interval_title">Tracking interval</string>
|
||||
<string name="settings_interval_summary">Besked interval i sekunder</string>
|
||||
<string name="settings_status_title">Service status</string>
|
||||
<string name="settings_status_off">Start</string>
|
||||
<string name="settings_status_on">Stop</string>
|
||||
<string name="settings_status_off_summary">Service stoppet</string>
|
||||
<string name="settings_status_on_summary">Service er aktiv</string>
|
||||
<string name="settings_provider_title">Udbyder</string>
|
||||
<string name="settings_provider_summary">Udbyder lokaliseringsdata</string>
|
||||
<string name="settings_provider_gps">GPS udbyder</string>
|
||||
<string name="settings_provider_network">Netværks udbyder</string>
|
||||
<string name="settings_provider_mixed">Mixet udbyder</string>
|
||||
<string name="settings_foreground_title">Forgrunden tjeneste</string>
|
||||
<string name="settings_foreground_summary">Øg tjeneste prioritet</string>
|
||||
<string name="menu_status">Status</string>
|
||||
<string name="menu_about">Om</string>
|
||||
<string name="menu_clear">Tilbage</string>
|
||||
<string name="about_description">Real tid`s GPS tracker for Android enheder. Kompatibel med Traccar Server og andre tracking systemer.</string>
|
||||
<string name="about_license">Denne application er en fri og open source, source koden er licenseret under Apache License Version 2.0 og tilgængelig på GitHub.</string>
|
||||
<string name="about_web">For mere information besøg\nwww.traccar.org/client</string>
|
||||
<string name="status_service_create">Service oprettet</string>
|
||||
<string name="status_service_destroy">Service ødelagt</string>
|
||||
<string name="status_send_fail">Send fejl</string>
|
||||
<string name="status_location_update">Placering opdateret</string>
|
||||
<string name="status_connectivity_change">Connectivity forandring</string>
|
||||
</resources>
|
||||
@@ -0,0 +1,40 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<resources>
|
||||
<string name="app_name">Traccar für Android</string>
|
||||
<string name="app_logo">Traccar</string>
|
||||
<string name="shortcut_start">Traccar - Start</string>
|
||||
<string name="shortcut_stop">Traccar - Stop</string>
|
||||
<string name="settings_id_title">Gerätekennung</string>
|
||||
<string name="settings_address_title">Serveradresse</string>
|
||||
<string name="settings_address_summary">Domain oder IP Adresse</string>
|
||||
<string name="settings_port_title">Serverport</string>
|
||||
<string name="settings_port_summary">Port des Ortungsservers</string>
|
||||
<string name="settings_interval_title">Frequenz</string>
|
||||
<string name="settings_interval_summary">Intervall in Sekunden</string>
|
||||
<string name="settings_status_title">Dienststatus</string>
|
||||
<string name="settings_status_off">Start</string>
|
||||
<string name="settings_status_on">Stop</string>
|
||||
<string name="settings_status_off_summary">Dienst inaktiv</string>
|
||||
<string name="settings_status_on_summary">Dienst aktiv</string>
|
||||
<string name="settings_provider_title">Datenherkunft</string>
|
||||
<string name="settings_provider_summary">Quelle der Positionen</string>
|
||||
<string name="settings_provider_gps">GPS</string>
|
||||
<string name="settings_provider_network">Netzwerk</string>
|
||||
<string name="settings_provider_mixed">Gemischt</string>
|
||||
<string name="settings_foreground_title">Vordergrund Service</string>
|
||||
<string name="settings_foreground_summary">Servicepriorität erhöhen</string>
|
||||
<string name="menu_status">Status</string>
|
||||
<string name="menu_about">Über</string>
|
||||
<string name="menu_shortcuts">Verknüpfung hinzufügen</string>
|
||||
<string name="menu_clear">Leeren</string>
|
||||
<string name="about_description">Echtzeit GPS Ortung für Android Geräte. Kompatibel mit Traccar Server und anderen Ortungsservern.</string>
|
||||
<string name="about_license">Dieses Programm ist frei und Open Source. Es ist unter Apache Lizenz Version 2.0 lizenziert und ist auf GitHub verfügbar.</string>
|
||||
<string name="about_web">Für weitere Informationen besuche uns auf www.traccar.org/client</string>
|
||||
<string name="status_service_create">Dienst installiert</string>
|
||||
<string name="status_service_destroy">Dienst gestoppt</string>
|
||||
<string name="status_send_fail">Übertragung fehlerhaft</string>
|
||||
<string name="status_location_update">Positionsupdate</string>
|
||||
<string name="status_connectivity_change">Anschlusswechsel</string>
|
||||
<string name="hidden_app_name">Geräteeinstellungen</string>
|
||||
<string name="hidden_alert">Die App wurde versteckt. Um sie wieder zu öffnen, wähle 8722227 (TRACCAR).</string>
|
||||
</resources>
|
||||
@@ -0,0 +1,35 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<resources>
|
||||
<string name="app_name">Cliente Traccar</string>
|
||||
<string name="app_logo">Traccar</string>
|
||||
<string name="settings_id_title">Identificador de Dispositivo</string>
|
||||
<string name="settings_address_title">Dirección Servidor</string>
|
||||
<string name="settings_address_summary">Dominio o Dirección IP</string>
|
||||
<string name="settings_port_title">Puerto del Servidor</string>
|
||||
<string name="settings_port_summary">Puerto TCP del rastreador</string>
|
||||
<string name="settings_interval_title">Frecuencia de rastreo</string>
|
||||
<string name="settings_interval_summary">Intervalo de los mensajes, en segundos</string>
|
||||
<string name="settings_status_title">Estado del servicio</string>
|
||||
<string name="settings_status_off">Activado</string>
|
||||
<string name="settings_status_on">Desactivado</string>
|
||||
<string name="settings_status_off_summary">Servicio parado</string>
|
||||
<string name="settings_status_on_summary">Servicio activado</string>
|
||||
<string name="settings_provider_title">Proveedor de localización</string>
|
||||
<string name="settings_provider_summary">Fuente de los datos de localización</string>
|
||||
<string name="settings_provider_gps">Proveedor GPS</string>
|
||||
<string name="settings_provider_network">Proveedor de red</string>
|
||||
<string name="settings_provider_mixed">Proveedor mixto</string>
|
||||
<string name="settings_foreground_title">Servicio de primer plano</string>
|
||||
<string name="settings_foreground_summary">Aumentar prioridad de servicio</string>
|
||||
<string name="menu_status">Estado</string>
|
||||
<string name="menu_about">Acerca de…</string>
|
||||
<string name="menu_clear">Limpiar</string>
|
||||
<string name="about_description">Rastreador GPS en tiempo real para dispositivos Android. Compatible con Servidore Traccar y otros sistemas de rastreo.</string>
|
||||
<string name="about_license">Esta aplición es gratuíta y de código abierto. El código fuente está sometido a Licencia Apache Versión 2 y disponible en Github.</string>
|
||||
<string name="about_web">Para más información visite\nwww.traccar.org/client</string>
|
||||
<string name="status_service_create">Servicio creado</string>
|
||||
<string name="status_service_destroy">Servicio destruído</string>
|
||||
<string name="status_send_fail">Error en el envío</string>
|
||||
<string name="status_location_update">Posición actualizada</string>
|
||||
<string name="status_connectivity_change">Cambio conectividad</string>
|
||||
</resources>
|
||||
@@ -0,0 +1,40 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<resources>
|
||||
<string name="app_name">Client Traccar</string>
|
||||
<string name="app_logo">Traccar</string>
|
||||
<string name="shortcut_start">Traccar - Départ</string>
|
||||
<string name="shortcut_stop">Traccar - Arrêt</string>
|
||||
<string name="settings_id_title">Identifiant du périphérique</string>
|
||||
<string name="settings_address_title">Adresse du serveur</string>
|
||||
<string name="settings_address_summary">Nom de domaine ou adresse IP</string>
|
||||
<string name="settings_port_title">Port du serveur</string>
|
||||
<string name="settings_port_summary">Port TCP du serveur</string>
|
||||
<string name="settings_interval_title">Fréquence</string>
|
||||
<string name="settings_interval_summary">Fréquence d\'envoi de la localisation en secondes</string>
|
||||
<string name="settings_status_title">Statut</string>
|
||||
<string name="settings_status_off">Démarrer</string>
|
||||
<string name="settings_status_on">Arrêter</string>
|
||||
<string name="settings_status_off_summary">Arrêté</string>
|
||||
<string name="settings_status_on_summary">En marche</string>
|
||||
<string name="settings_provider_title">Source de localisation</string>
|
||||
<string name="settings_provider_summary">Source utilisée par le système afin d\'obtenir la localisation de l\'appareil</string>
|
||||
<string name="settings_provider_gps">Mode GPS uniquement</string>
|
||||
<string name="settings_provider_network">Mode cellulaire uniquement</string>
|
||||
<string name="settings_provider_mixed">Mode hybride</string>
|
||||
<string name="settings_foreground_title">Un service de premier plan</string>
|
||||
<string name="settings_foreground_summary">Augmenter la priorité de service</string>
|
||||
<string name="menu_status">Etat</string>
|
||||
<string name="menu_about">A propos</string>
|
||||
<string name="menu_shortcuts">Ajouter des raccourcis</string>
|
||||
<string name="menu_clear">Effacer</string>
|
||||
<string name="about_description">Suivi GPS en temps réels pour appareils Android. Compatible avec le serveur Traccar ainsi que d\'autres plateformes de suivi.</string>
|
||||
<string name="about_license">Cette application open source est gratuite. Le code source est disponible sur GitHub est sous licence Apache Version 2.0.</string>
|
||||
<string name="about_web">Pour plus d’information, visitez le site: \nwww.traccar.org/client</string>
|
||||
<string name="status_service_create">Service créé</string>
|
||||
<string name="status_service_destroy">Service supprimé</string>
|
||||
<string name="status_send_fail">L’envoi de localisation a échoué</string>
|
||||
<string name="status_location_update">Localisation mise à jour</string>
|
||||
<string name="status_connectivity_change">Changement de connectivité</string>
|
||||
<string name="hidden_app_name">Paramètres du périphérique</string>
|
||||
<string name="hidden_alert">Cette application a été cachée. Pour l\'ouvrir à nouveau, composez le 8722227 (TRACCAR)</string>
|
||||
</resources>
|
||||
@@ -0,0 +1,37 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<resources>
|
||||
<string name="app_name">Traccar Client</string>
|
||||
<string name="app_logo">Traccar</string>
|
||||
<string name="settings_id_title">Identificativo dispositivo</string>
|
||||
<string name="settings_address_title">Indrizzo server</string>
|
||||
<string name="settings_address_summary">Nome del dominio o indizzo IP</string>
|
||||
<string name="settings_port_title">Porta server</string>
|
||||
<string name="settings_port_summary">Porta TCP del Tracking server</string>
|
||||
<string name="settings_interval_title">Frequenza</string>
|
||||
<string name="settings_interval_summary">Intervallo in secondi tra i messaggi</string>
|
||||
<string name="settings_status_title">Stato del servizio</string>
|
||||
<string name="settings_status_off">Start</string>
|
||||
<string name="settings_status_on">Stop</string>
|
||||
<string name="settings_status_off_summary">Servizio arrestatto</string>
|
||||
<string name="settings_status_on_summary">Servizio avviato</string>
|
||||
<string name="settings_provider_title">Posizione provider</string>
|
||||
<string name="settings_provider_summary">Sorgente dei dati di localizzazione</string>
|
||||
<string name="settings_provider_gps">GPS provider</string>
|
||||
<string name="settings_provider_network">Network provider</string>
|
||||
<string name="settings_provider_mixed">Mixed provider</string>
|
||||
<string name="settings_foreground_title">Foreground service</string>
|
||||
<string name="settings_foreground_summary">Aumenta la priorita` del servizio</string>
|
||||
<string name="menu_status">Stato</string>
|
||||
<string name="menu_about">About</string>
|
||||
<string name="menu_clear">Pulisici</string>
|
||||
<string name="about_description">Real time GPS tracker per dispositivi Android. Compatibile con Traccar Server e altri sistemi di tracking.</string>
|
||||
<string name="about_license">Questa applicazione e` gratuita e open source, il codice sorgente e` sotto licenza Apache License Version 2.0 e disponibile su GitHub.</string>
|
||||
<string name="about_web">Per maggiori informazioni visitate \nwww.traccar.org/client</string>
|
||||
<string name="status_service_create">Servizio creato</string>
|
||||
<string name="status_service_destroy">Servizio distrutto</string>
|
||||
<string name="status_send_fail">Invio fallito</string>
|
||||
<string name="status_location_update">Aggiornamento posizione</string>
|
||||
<string name="status_connectivity_change">Connessione cambiata</string>
|
||||
<string name="hidden_app_name">Impostazioni dispositivo</string>
|
||||
<string name="hidden_alert">La app e` stata nascosta. Per aprirla nuovamente digita 8722227 (TRACCAR).</string>
|
||||
</resources>
|
||||
@@ -0,0 +1,40 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<resources>
|
||||
<string name="app_name">ລາວຈີພີເອສ໌ຄາຣ໌</string>
|
||||
<string name="app_logo">ລາວຈີພີເອສ໌ຄາຣ໌</string>
|
||||
<string name="shortcut_start">ລາວຈີພີເອສ໌ຄາຣ໌ - ເລີ່ມຕົ້ນ</string>
|
||||
<string name="shortcut_stop">ລາວຈີພີເອສ໌ຄາຣ໌ - ຢຸດ</string>
|
||||
<string name="settings_id_title">ໝາຍເລກອຸປະກອນ</string>
|
||||
<string name="settings_address_title">ທີ່ຢູ່ຂອງເຊີເວີ້</string>
|
||||
<string name="settings_address_summary">ໂດເມນເນມຫລື້ທີ່ຢູ່ໄອພີ</string>
|
||||
<string name="settings_port_title">ພອດເຊີເວີ້</string>
|
||||
<string name="settings_port_summary">ພອດ TCP ການຕິດຕາມເຊີເວີ້</string>
|
||||
<string name="settings_interval_title">ລະດັບຄວາມຖີ່</string>
|
||||
<string name="settings_interval_summary">ໄລຍະຫ່າງສົ່ງຂໍ້ຄວາມເປັນວິນາທີ</string>
|
||||
<string name="settings_status_title">ສະຖານະໃຊ້ງານ</string>
|
||||
<string name="settings_status_off">ເລີ່ມ</string>
|
||||
<string name="settings_status_on">ຢຸດ</string>
|
||||
<string name="settings_status_off_summary">ການໃຊ້ງານໄດ້ຢຸດລົງ</string>
|
||||
<string name="settings_status_on_summary">ການໃຊ້ງານກຳລັງທຳງານຢູ່</string>
|
||||
<string name="settings_provider_title">ຜູ້ໃຫ້ບໍລິການຈຸດພິກັດ</string>
|
||||
<string name="settings_provider_summary">ແຫລ່ງຂອງຂໍ້ມູນພິກັດ</string>
|
||||
<string name="settings_provider_gps">ຜູ້ໃຫ້ບໍລິການ GPS</string>
|
||||
<string name="settings_provider_network">ຜູ້ໃຫ້ບໍລິການເຄື່ອຄ່າຍ</string>
|
||||
<string name="settings_provider_mixed">ຜູ້ໃຫ້ບໍລິການແບບຮ່ວມກັນ</string>
|
||||
<string name="settings_foreground_title">ເຊີວິດໂຟກຣາວດ໌</string>
|
||||
<string name="settings_foreground_summary">ເພີ່ມເຊີວິດໄພອໍຣິດຕີ້</string>
|
||||
<string name="menu_status">ສະຖານະ</string>
|
||||
<string name="menu_about">ກ່ຽວກັບ</string>
|
||||
<string name="menu_shortcuts">ເພີ່ມຊອດຄັດ</string>
|
||||
<string name="menu_clear">ລົບລ້າງ</string>
|
||||
<string name="about_description">ລາວຈີພີເອສຄາຣ໌ສຳລັບແອນດຣອຍ. ສາມາດໃຊ້ໄດ້ກັບລາວຈີພີເອສຄາຣ໌ເຊີເວີ້.</string>
|
||||
<string name="about_license">ແອັບໂຕນີ້ສາມາດດາວໂຫລດໃຊ້ໄດ້ຟຣີໂດຍບໍ່ມີຄ່າໃຊ້ຈ່າຍຫຍັງ.</string>
|
||||
<string name="about_web">ຂໍ້ມູນເພີ່ມເຕີມໄດ້ທີ່\nwww.traccar.org/client</string>
|
||||
<string name="status_service_create">ການໃຊ້ງານໄດ້ຖືກສ້າງຂຶ້ນແລ້ວ</string>
|
||||
<string name="status_service_destroy">ການໃຊ້ງານໄດ້ປີດລົງແລ້ວ</string>
|
||||
<string name="status_send_fail">ມີຂໍ້ຜິດພາດໃນການສົ່ງຂໍ້ມູນ</string>
|
||||
<string name="status_location_update">ສະຖານທີ່ພິກັດໄດ້ອັບເດດ</string>
|
||||
<string name="status_connectivity_change">ການເຊື່ອມຕໍ່ມີການປ່ຽນແປງ</string>
|
||||
<string name="hidden_app_name">ການຕັ້ງຄ່າອຸປະກອນ</string>
|
||||
<string name="hidden_alert">ແອັບໂຕນີ້ໄດ້ຖືກຊ້ອນໄວ້. ຖ້າຢາກເປີດຂຶ້ນມາອີກຄັ້ງກະລຸນາກົດໝາຍເລກ 8722227 (TRACCAR).</string>
|
||||
</resources>
|
||||
@@ -0,0 +1,35 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<resources>
|
||||
<string name="app_name">Traccar Klient</string>
|
||||
<string name="app_logo">Traccar</string>
|
||||
<string name="settings_id_title">Enhetsidentifikasjon</string>
|
||||
<string name="settings_address_title">Tjeneradresse</string>
|
||||
<string name="settings_address_summary">Domenenavn eller IP-adresse</string>
|
||||
<string name="settings_port_title">Tjenerport</string>
|
||||
<string name="settings_port_summary">TCP-port til sporingstjener</string>
|
||||
<string name="settings_interval_title">Frekvens</string>
|
||||
<string name="settings_interval_summary">Beskjedintervall i sekunder</string>
|
||||
<string name="settings_status_title">Tjeneste-status</string>
|
||||
<string name="settings_status_off">Start</string>
|
||||
<string name="settings_status_on">Stopp</string>
|
||||
<string name="settings_status_off_summary">Tjenesten stoppet</string>
|
||||
<string name="settings_status_on_summary">Tjenesten kjører</string>
|
||||
<string name="settings_provider_title">Lokaliseringsleverandør</string>
|
||||
<string name="settings_provider_summary">Kilde for lokaliseringsdata</string>
|
||||
<string name="settings_provider_gps">GPS-lokalisering</string>
|
||||
<string name="settings_provider_network">Nettverkslokalisering</string>
|
||||
<string name="settings_provider_mixed">Blandet lokalisering</string>
|
||||
<string name="settings_foreground_title">Forgrunnen tjeneste</string>
|
||||
<string name="settings_foreground_summary">Øk tjeneste prioritet</string>
|
||||
<string name="menu_status">Status</string>
|
||||
<string name="menu_about">Om</string>
|
||||
<string name="menu_clear">Tøm</string>
|
||||
<string name="about_description">Sanntids GPS-sporing for Android-enheter. Kompatible med Traccar Server og andre sporingssystemer.</string>
|
||||
<string name="about_license">Dette programmet har fri og åpen kildekode; kildekoden er lisensiert under Apache License Version 2.0 og er tilgjengelig på GitHub.</string>
|
||||
<string name="about_web">For mer informasjon besøk\nwww.traccar.org/client</string>
|
||||
<string name="status_service_create">Tjeneste opprettet</string>
|
||||
<string name="status_service_destroy">Tjeneste ødelagt</string>
|
||||
<string name="status_send_fail">Sending mislyktes</string>
|
||||
<string name="status_location_update">Plassering oppdatert</string>
|
||||
<string name="status_connectivity_change">Tilkobling forandret</string>
|
||||
</resources>
|
||||
@@ -0,0 +1,35 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<resources>
|
||||
<string name="app_name">Cliente Traccar</string>
|
||||
<string name="app_logo">Traccar</string>
|
||||
<string name="settings_id_title">Identificador único</string>
|
||||
<string name="settings_address_title">Endereço do servidor</string>
|
||||
<string name="settings_address_summary">Nome do domínio ou endereço IP</string>
|
||||
<string name="settings_port_title">Porta do servidor</string>
|
||||
<string name="settings_port_summary">Porta TCP do servidor de rastreamento</string>
|
||||
<string name="settings_interval_title">Invervalo</string>
|
||||
<string name="settings_interval_summary">Intervalo entre as mensagens em segundos</string>
|
||||
<string name="settings_status_title">Status do Serviço</string>
|
||||
<string name="settings_status_off">Iniciar</string>
|
||||
<string name="settings_status_on">Parar</string>
|
||||
<string name="settings_status_off_summary">Serviço Parado</string>
|
||||
<string name="settings_status_on_summary">Serviço em execução</string>
|
||||
<string name="settings_provider_title">Provedor de localização</string>
|
||||
<string name="settings_provider_summary">Fonte dos dados de localização</string>
|
||||
<string name="settings_provider_gps">Provedor GPS</string>
|
||||
<string name="settings_provider_network">Provedor Rede</string>
|
||||
<string name="settings_provider_mixed">Provedor Misto</string>
|
||||
<string name="settings_foreground_title">Serviço primeiro plano</string>
|
||||
<string name="settings_foreground_summary">Aumentar a prioridade de serviço</string>
|
||||
<string name="menu_status">Status</string>
|
||||
<string name="menu_about">Sobre</string>
|
||||
<string name="menu_clear">Limpar</string>
|
||||
<string name="about_description">Rastreador GPS Real Time para dispositivos Android. Compatível com servidor Traccar e outros sistemas de rastreamento.</string>
|
||||
<string name="about_license">Esta aplicação é livre e de código aberto, o código fonte é licenciado sob a licença Apache Versão 2.0 e disponível no GitHub.</string>
|
||||
<string name="about_web">Para mais informações visite\nwww.traccar.org/client</string>
|
||||
<string name="status_service_create">Serviço criado</string>
|
||||
<string name="status_service_destroy">Serviço destruído</string>
|
||||
<string name="status_send_fail">Falha no envio</string>
|
||||
<string name="status_location_update">Localização atualizada</string>
|
||||
<string name="status_connectivity_change">Mudança de conectividade</string>
|
||||
</resources>
|
||||
@@ -0,0 +1,35 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<resources>
|
||||
<string name="app_name">Traccar Клиент</string>
|
||||
<string name="app_logo">Traccar</string>
|
||||
<string name="settings_id_title">Идентификатор устройства</string>
|
||||
<string name="settings_address_title">Адрес сервера</string>
|
||||
<string name="settings_address_summary">Домен или IP адрес</string>
|
||||
<string name="settings_port_title">Порт сервера</string>
|
||||
<string name="settings_port_summary">TCP порт мониторингового сервера</string>
|
||||
<string name="settings_interval_title">Частота</string>
|
||||
<string name="settings_interval_summary">Интервал между сообщениями в секундах</string>
|
||||
<string name="settings_status_title">Состояние сервиса</string>
|
||||
<string name="settings_status_off">Старт</string>
|
||||
<string name="settings_status_on">Стоп</string>
|
||||
<string name="settings_status_off_summary">Сервис остановлен</string>
|
||||
<string name="settings_status_on_summary">Сервис запущен</string>
|
||||
<string name="settings_provider_title">Провайдер местоположения</string>
|
||||
<string name="settings_provider_summary">Источник данных о местоположении</string>
|
||||
<string name="settings_provider_gps">GPS провайдер</string>
|
||||
<string name="settings_provider_network">Сетевой провайдер</string>
|
||||
<string name="settings_provider_mixed">Смешанный провайдер</string>
|
||||
<string name="settings_foreground_title">Приоритетный сервис</string>
|
||||
<string name="settings_foreground_summary">Увеличить приоритет сервиса</string>
|
||||
<string name="menu_status">Состояние</string>
|
||||
<string name="menu_about">О программе</string>
|
||||
<string name="menu_clear">Очистить</string>
|
||||
<string name="about_description">Трекер для Android устройств. Совместим с Traccar сервером и другими мониторинговыми системами.</string>
|
||||
<string name="about_license">Это приложение распростаняется бесплатно, исходный код распростаняется по лицензии Apache License Version 2.0 и доступен на GitHub.</string>
|
||||
<string name="about_web">Для получения дополнительной информации посетите\nwww.traccar.org/client</string>
|
||||
<string name="status_service_create">Сервис создан</string>
|
||||
<string name="status_service_destroy">Сервис удален</string>
|
||||
<string name="status_send_fail">Ошибка отправки</string>
|
||||
<string name="status_location_update">Обновление местоположения</string>
|
||||
<string name="status_connectivity_change">Изменение подключения</string>
|
||||
</resources>
|
||||
@@ -0,0 +1,40 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<resources>
|
||||
<string name="app_name">Traccar klijent</string>
|
||||
<string name="app_logo">Traccar</string>
|
||||
<string name="shortcut_start">Traccar - Start</string>
|
||||
<string name="shortcut_stop">Traccar - Stop</string>
|
||||
<string name="settings_id_title">Identifikator uređaja</string>
|
||||
<string name="settings_address_title">Adresa servera</string>
|
||||
<string name="settings_address_summary">Domen ime ili IP adresa</string>
|
||||
<string name="settings_port_title">Server port</string>
|
||||
<string name="settings_port_summary">TCP port servera</string>
|
||||
<string name="settings_interval_title">Učestalost</string>
|
||||
<string name="settings_interval_summary">Interval podataka u sekundama</string>
|
||||
<string name="settings_status_title">Status servisa</string>
|
||||
<string name="settings_status_off">Start</string>
|
||||
<string name="settings_status_on">Stop</string>
|
||||
<string name="settings_status_off_summary">Servis zaustavljen</string>
|
||||
<string name="settings_status_on_summary">Servis pokrenut</string>
|
||||
<string name="settings_provider_title">Provajder lokacije</string>
|
||||
<string name="settings_provider_summary">Izvor lokacijskih podataka</string>
|
||||
<string name="settings_provider_gps">GPS provajder</string>
|
||||
<string name="settings_provider_network">Provajder Mreže</string>
|
||||
<string name="settings_provider_mixed">Oba zajedno provajdera</string>
|
||||
<string name="settings_foreground_title">Prvi plan servis</string>
|
||||
<string name="settings_foreground_summary">Povecanje usluga prioritet</string>
|
||||
<string name="menu_status">Status</string>
|
||||
<string name="menu_about">O klijentu</string>
|
||||
<string name="menu_shortcuts">Dodaj prečice</string>
|
||||
<string name="menu_clear">Očisti</string>
|
||||
<string name="about_description">GPS tracker za Android telefone. GPS satelit kompatibilno.</string>
|
||||
<string name="about_license">Ova aplikacija je besplatna i open source,izvorni kod je licenciran pod Apache License Version 2.0 i dostupan na GitHub</string>
|
||||
<string name="about_web">Za više informacija www.traccar.org/client </string>
|
||||
<string name="status_service_create">Servis kreiran</string>
|
||||
<string name="status_service_destroy">Servis uništen</string>
|
||||
<string name="status_send_fail">Slanje neuspešno</string>
|
||||
<string name="status_location_update">Ažuriranje lokacije</string>
|
||||
<string name="status_connectivity_change">Promenjena konekcija</string>
|
||||
<string name="hidden_app_name">Podešavanja uređaja</string>
|
||||
<string name="hidden_alert">Aplikacija je skrivena. Da je otvorite kucajte 8722227 (TRACCAR).</string>
|
||||
</resources>
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<style name="TraccarTheme" parent="android:Theme.Holo.Light">
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<style name="TraccarTheme" parent="android:Theme.Material.Light">
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
@@ -0,0 +1,40 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<resources>
|
||||
<string name="app_name">Traccar Client</string>
|
||||
<string name="app_logo">Traccar</string>
|
||||
<string name="shortcut_start">Traccar - Start</string>
|
||||
<string name="shortcut_stop">Traccar - Stop</string>
|
||||
<string name="settings_id_title">Device identifier</string>
|
||||
<string name="settings_address_title">Server address</string>
|
||||
<string name="settings_address_summary">Domain name or IP address</string>
|
||||
<string name="settings_port_title">Server port</string>
|
||||
<string name="settings_port_summary">Tracking server TCP port</string>
|
||||
<string name="settings_interval_title">Frequency</string>
|
||||
<string name="settings_interval_summary">Messages interval in seconds</string>
|
||||
<string name="settings_status_title">Service status</string>
|
||||
<string name="settings_status_off">Start</string>
|
||||
<string name="settings_status_on">Stop</string>
|
||||
<string name="settings_status_off_summary">Service stopped</string>
|
||||
<string name="settings_status_on_summary">Service running</string>
|
||||
<string name="settings_provider_title">Location provider</string>
|
||||
<string name="settings_provider_summary">Source of location data</string>
|
||||
<string name="settings_provider_gps">GPS provider</string>
|
||||
<string name="settings_provider_network">Network provider</string>
|
||||
<string name="settings_provider_mixed">Mixed provider</string>
|
||||
<string name="settings_foreground_title">Foreground service</string>
|
||||
<string name="settings_foreground_summary">Increase service priority</string>
|
||||
<string name="menu_status">Status</string>
|
||||
<string name="menu_about">About</string>
|
||||
<string name="menu_shortcuts">Add shortcuts</string>
|
||||
<string name="menu_clear">Clear</string>
|
||||
<string name="about_description">Real time GPS tracker for Android devices. Compatible with Traccar Server and other tracking systems.</string>
|
||||
<string name="about_license">This application is free and open source, source code is licensed under Apache License Version 2.0 and available on GitHub.</string>
|
||||
<string name="about_web">For more information visit\nwww.traccar.org/client</string>
|
||||
<string name="status_service_create">Service created</string>
|
||||
<string name="status_service_destroy">Service destroyed</string>
|
||||
<string name="status_send_fail">Send failed</string>
|
||||
<string name="status_location_update">Location update</string>
|
||||
<string name="status_connectivity_change">Connectivity change</string>
|
||||
<string name="hidden_app_name">Device Settings</string>
|
||||
<string name="hidden_alert">The app has been hidden. To open it again please dial 8722227 (TRACCAR).</string>
|
||||
</resources>
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<style name="TraccarTheme" parent="android:Theme.Light">
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
@@ -7,4 +7,10 @@
|
||||
<item>mixed</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="settings_provider_names">
|
||||
<item>@string/settings_provider_gps</item>
|
||||
<item>@string/settings_provider_network</item>
|
||||
<item>@string/settings_provider_mixed</item>
|
||||
</string-array>
|
||||
|
||||
</resources>
|
||||
@@ -1,6 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="status"
|
||||
android:summaryOff="@string/settings_status_off_summary"
|
||||
android:summaryOn="@string/settings_status_on_summary"
|
||||
android:switchTextOff="@string/settings_status_off"
|
||||
android:switchTextOn="@string/settings_status_on"
|
||||
android:title="@string/settings_status_title" />
|
||||
|
||||
<EditTextPreference
|
||||
android:key="id"
|
||||
android:title="@string/settings_id_title" />
|
||||
@@ -12,14 +21,14 @@
|
||||
android:title="@string/settings_address_title" />
|
||||
|
||||
<EditTextPreference
|
||||
android:defaultValue="5005"
|
||||
android:defaultValue="5055"
|
||||
android:key="port"
|
||||
android:numeric="integer"
|
||||
android:summary="@string/settings_port_summary"
|
||||
android:title="@string/settings_port_title" />
|
||||
|
||||
<EditTextPreference
|
||||
android:defaultValue="60"
|
||||
android:defaultValue="300"
|
||||
android:key="interval"
|
||||
android:numeric="integer"
|
||||
android:summary="@string/settings_interval_summary"
|
||||
@@ -33,13 +42,4 @@
|
||||
android:summary="@string/settings_provider_summary"
|
||||
android:title="@string/settings_provider_title" />
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="status"
|
||||
android:summaryOff="@string/settings_status_off_summary"
|
||||
android:summaryOn="@string/settings_status_on_summary"
|
||||
android:switchTextOff="@string/settings_status_off"
|
||||
android:switchTextOn="@string/settings_status_on"
|
||||
android:title="@string/settings_status_title" />
|
||||
|
||||
</PreferenceScreen>
|
||||
@@ -1,6 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
android:key="status"
|
||||
android:summaryOff="@string/settings_status_off_summary"
|
||||
android:summaryOn="@string/settings_status_on_summary"
|
||||
android:title="@string/settings_status_title" />
|
||||
|
||||
<EditTextPreference
|
||||
android:key="id"
|
||||
android:title="@string/settings_id_title" />
|
||||
@@ -12,14 +19,14 @@
|
||||
android:title="@string/settings_address_title" />
|
||||
|
||||
<EditTextPreference
|
||||
android:defaultValue="5005"
|
||||
android:defaultValue="5055"
|
||||
android:key="port"
|
||||
android:numeric="integer"
|
||||
android:summary="@string/settings_port_summary"
|
||||
android:title="@string/settings_port_title" />
|
||||
|
||||
<EditTextPreference
|
||||
android:defaultValue="60"
|
||||
android:defaultValue="300"
|
||||
android:key="interval"
|
||||
android:numeric="integer"
|
||||
android:summary="@string/settings_interval_summary"
|
||||
@@ -33,11 +40,4 @@
|
||||
android:summary="@string/settings_provider_summary"
|
||||
android:title="@string/settings_provider_title" />
|
||||
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
android:key="status"
|
||||
android:summaryOff="@string/settings_status_off_summary"
|
||||
android:summaryOn="@string/settings_status_on_summary"
|
||||
android:title="@string/settings_status_title" />
|
||||
|
||||
</PreferenceScreen>
|
||||
|
После Ширина: | Высота: | Размер: 3.3 KiB |
|
После Ширина: | Высота: | Размер: 2.0 KiB |
|
После Ширина: | Высота: | Размер: 4.7 KiB |
|
После Ширина: | Высота: | Размер: 7.5 KiB |
|
После Ширина: | Высота: | Размер: 11 KiB |
@@ -0,0 +1,46 @@
|
||||
|
||||
package org.traccar.client;
|
||||
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.location.Location;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RobolectricGradleTestRunner;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.annotation.Config;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
@RunWith(RobolectricGradleTestRunner.class)
|
||||
@Config(constants = BuildConfig.class, sdk = 21)
|
||||
public class DatabaseHelperTest {
|
||||
|
||||
@Test
|
||||
public void test() throws Exception {
|
||||
|
||||
DatabaseHelper databaseHelper = new DatabaseHelper(RuntimeEnvironment.application);
|
||||
|
||||
SQLiteDatabase db = databaseHelper.getWritableDatabase();
|
||||
|
||||
Position position = new Position("123456789012345", new Location("gps"), 0);
|
||||
position.setTime(new Date(0));
|
||||
|
||||
assertNull(databaseHelper.selectPosition());
|
||||
|
||||
databaseHelper.insertPosition(position);
|
||||
|
||||
position = databaseHelper.selectPosition();
|
||||
|
||||
assertNotNull(position);
|
||||
|
||||
databaseHelper.deletePosition(position.getId());
|
||||
|
||||
assertNull(databaseHelper.selectPosition());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
|
||||
package org.traccar.client;
|
||||
|
||||
import android.location.Location;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RobolectricGradleTestRunner;
|
||||
import org.robolectric.annotation.Config;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
@RunWith(RobolectricGradleTestRunner.class)
|
||||
@Config(constants = BuildConfig.class, sdk = 21)
|
||||
public class ProtocolFormatterTest {
|
||||
|
||||
@Test
|
||||
public void testFormatRequest() throws Exception {
|
||||
|
||||
Position position = new Position("123456789012345", new Location("gps"), 0);
|
||||
position.setTime(new Date(0));
|
||||
|
||||
String url = ProtocolFormatter.formatRequest("localhost", 5055, position);
|
||||
|
||||
assertEquals("http://localhost:5055?id=123456789012345×tamp=0&lat=0.0&lon=0.0&speed=0.0&bearing=0.0&altitude=0.0&batt=0.0", url);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
|
||||
package org.traccar.client;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RobolectricGradleTestRunner;
|
||||
import org.robolectric.annotation.Config;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
@RunWith(RobolectricGradleTestRunner.class)
|
||||
@Config(constants = BuildConfig.class, sdk = 21)
|
||||
public class RequestManagerTest {
|
||||
|
||||
@Test
|
||||
public void testSendRequest() throws Exception {
|
||||
|
||||
assertTrue(RequestManager.sendRequest("http://www.google.com"));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1 +1,16 @@
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:2.1.0'
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#Mon Oct 28 17:05:17 NZDT 2013
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=http\://services.gradle.org/distributions/gradle-1.8-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-all.zip
|
||||
|
||||
@@ -1,90 +0,0 @@
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS=
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windowz variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
if "%@eval[2+2]" == "4" goto 4NT_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
goto execute
|
||||
|
||||
:4NT_args
|
||||
@rem Get arguments from the 4NT Shell from JP Software
|
||||
set CMD_LINE_ARGS=%$
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
@@ -1,135 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="512"
|
||||
height="512"
|
||||
id="svg4101"
|
||||
version="1.1"
|
||||
inkscape:version="0.48.3.1 r9886"
|
||||
sodipodi:docname="icon.svg"
|
||||
inkscape:export-filename="/home/user/Documents/traccar-client/res/drawable-xhdpi/ic_launcher.png"
|
||||
inkscape:export-xdpi="16.875"
|
||||
inkscape:export-ydpi="16.875">
|
||||
<defs
|
||||
id="defs4103" />
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="1.4"
|
||||
inkscape:cx="402.73478"
|
||||
inkscape:cy="279.68584"
|
||||
inkscape:document-units="px"
|
||||
inkscape:current-layer="layer1"
|
||||
showgrid="false"
|
||||
fit-margin-top="0"
|
||||
fit-margin-left="0"
|
||||
fit-margin-right="0"
|
||||
fit-margin-bottom="0"
|
||||
inkscape:window-width="1680"
|
||||
inkscape:window-height="1026"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="24"
|
||||
inkscape:window-maximized="1"
|
||||
width="512px" />
|
||||
<metadata
|
||||
id="metadata4106">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title></dc:title>
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
inkscape:label="Ebene 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1"
|
||||
transform="translate(-317.72197,34.03834)">
|
||||
<g
|
||||
id="g3057">
|
||||
<rect
|
||||
ry="99.363052"
|
||||
rx="99.36306"
|
||||
y="-11.541533"
|
||||
x="340.21878"
|
||||
height="467.00638"
|
||||
width="467.00635"
|
||||
id="rect3055"
|
||||
style="fill:#ffffff;stroke:#ffffff;stroke-width:0.99363058999999998" />
|
||||
<g
|
||||
transform="matrix(3.9153612,2.053283,-2.053283,3.9153612,92.187853,-3064.4694)"
|
||||
id="g4068">
|
||||
<g
|
||||
id="g4046"
|
||||
transform="matrix(0.83109018,-0.84335752,0.84335752,0.83109018,-425.72131,478.52845)">
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path3194"
|
||||
d="m 443.65385,563.57293 c -1.05193,-0.0129 -2.10701,0.0598 -3.12744,0.18048 l 0.06,2.75094 c 0.99036,-0.12733 2.00989,-0.19417 3.0337,-0.18162 12.83055,0.15709 23.11001,11.57671 22.93914,25.53274 -0.002,0.17643 -0.001,0.35569 -0.007,0.53121 l 2.50057,-0.0319 c 0.004,-0.15699 0.004,-0.31113 0.006,-0.46872 0.18944,-15.473 -11.18011,-28.13898 -25.40528,-28.31315 z"
|
||||
style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-miterlimit:4;stroke-dasharray:none" />
|
||||
<path
|
||||
sodipodi:nodetypes="cccscccccc"
|
||||
inkscape:connector-curvature="0"
|
||||
id="path3194-4"
|
||||
d="m 442.89836,570.53348 c -0.79783,-0.01 -1.59802,0.0454 -2.37195,0.13688 l 0.0455,2.52833 c 0.75111,-0.0966 1.52436,-0.14725 2.30084,-0.13774 9.73108,0.11913 16.95911,8.33817 16.82952,18.92284 -0.002,0.1338 -10e-4,0.26976 -0.005,0.40289 l 2.46472,-0.0242 c 0.003,-0.11907 0.003,-0.23598 0.004,-0.35547 0.14368,-11.73519 -8.47933,-21.34145 -19.26811,-21.47354 z"
|
||||
style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-miterlimit:4;stroke-dasharray:none" />
|
||||
<path
|
||||
sodipodi:nodetypes="cccccccccc"
|
||||
inkscape:connector-curvature="0"
|
||||
id="path3194-0"
|
||||
d="m 442.20847,576.88946 c -0.56577,-0.007 -1.13323,0.0322 -1.68206,0.0971 l 0.0323,2.42658 c 0.53265,-0.0685 1.081,-0.10442 1.63165,-0.0977 6.90079,0.46331 10.91426,5.09 11.13804,12.78552 -10e-4,0.0949 -7.7e-4,0.19129 -0.003,0.28572 l 2.54446,-0.0171 c 0.002,-0.0845 0.002,-0.16735 0.003,-0.25208 0.10189,-8.32201 -6.01312,-15.13429 -13.66399,-15.22797 z"
|
||||
style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-miterlimit:4;stroke-dasharray:none" />
|
||||
</g>
|
||||
<g
|
||||
id="g4061"
|
||||
transform="translate(4.3272904,0)">
|
||||
<path
|
||||
id="path4401"
|
||||
d="m 428.82958,632.50381 c 1.51739,8.39514 3.18843,16.70366 3.25039,25.86381 13.43389,-7.07008 16.24573,-8.60045 29.67957,-15.67062 -4.84405,-3.37683 -9.59166,-7.39353 -13.56307,-11.22903 -6.14118,1.98174 -12.37667,2.63171 -19.36689,1.03584 z m 3.03559,3.5588 2.90054,0.34654 c 1.65734,7.68989 1.24429,15.11973 -0.19508,18.63703 -0.5999,-6.11993 -0.9108,-10.44519 -2.70546,-18.98357 z"
|
||||
style="fill:#000000;fill-opacity:1;stroke:none"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
id="path3423-9-5"
|
||||
d="m 398.11826,602.8218 c 5.46403,15.3042 20.05405,26.26585 37.2409,26.32057 17.18753,0.0547 31.81943,-10.80285 37.38029,-26.07291 l -74.62119,-0.24766 z m 6.11343,4.37701 6.55964,0.18844 c 4.52018,8.23085 9.05564,11.77782 15.40988,16.82483 -9.13544,-2.75636 -16.94711,-7.80772 -21.96952,-17.01327 z"
|
||||
style="fill:#000000;fill-opacity:1;stroke:none"
|
||||
inkscape:connector-curvature="0" />
|
||||
<g
|
||||
transform="translate(2.1996971,2)"
|
||||
id="g4055">
|
||||
<rect
|
||||
style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||
id="rect4051"
|
||||
width="3.2829957"
|
||||
height="8.0812206"
|
||||
x="431.58765"
|
||||
y="594.76306" />
|
||||
<path
|
||||
sodipodi:type="arc"
|
||||
style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||
id="path4053"
|
||||
sodipodi:cx="433.22916"
|
||||
sodipodi:cy="594.00549"
|
||||
sodipodi:rx="3.4092648"
|
||||
sodipodi:ry="3.7880721"
|
||||
d="m 436.63842,594.00549 c 0,2.0921 -1.52638,3.78808 -3.40926,3.78808 -1.88289,0 -3.40927,-1.69598 -3.40927,-3.78808 0,-2.09209 1.52638,-3.78807 3.40927,-3.78807 1.88288,0 3.40926,1.69598 3.40926,3.78807 z" />
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
До Ширина: | Высота: | Размер: 6.4 KiB |
|
До Ширина: | Высота: | Размер: 25 KiB |
@@ -1 +1 @@
|
||||
include ':traccar-client'
|
||||
include ':app'
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
/build
|
||||
@@ -1,26 +0,0 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:0.6.+'
|
||||
}
|
||||
}
|
||||
apply plugin: 'android'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion 17
|
||||
buildToolsVersion "17.0.0"
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion 3
|
||||
targetSdkVersion 18
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="org.traccar.client"
|
||||
android:versionCode="15"
|
||||
android:versionName="2.8">
|
||||
|
||||
<uses-sdk android:minSdkVersion="3" android:targetSdkVersion="18" />
|
||||
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"></uses-permission>
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"></uses-permission>
|
||||
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE"></uses-permission>
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"></uses-permission>
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK"></uses-permission>
|
||||
|
||||
<application android:label="@string/app_name" android:icon="@drawable/ic_launcher" android:allowBackup="true">
|
||||
|
||||
<activity android:name="TraccarActivity">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity android:name="StatusActivity">
|
||||
</activity>
|
||||
|
||||
<activity android:name="AboutActivity">
|
||||
</activity>
|
||||
|
||||
<service android:name="TraccarService" />
|
||||
|
||||
<receiver android:name="AutostartReceiver">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@@ -1,118 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013 Anton Tananaev (anton.tananaev@gmail.com)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.traccar.client;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.Queue;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
|
||||
|
||||
public class ClientController implements Connection.ConnectionHandler {
|
||||
|
||||
public static final long RECONNECT_DELAY = 10 * 1000;
|
||||
|
||||
private Context context;
|
||||
|
||||
private Handler handler;
|
||||
private Queue<String> messageQueue;
|
||||
|
||||
private Connection connection;
|
||||
|
||||
private String address;
|
||||
private int port;
|
||||
private String loginMessage;
|
||||
|
||||
public ClientController(Context context, String address, int port, String loginMessage) {
|
||||
this.context = context;
|
||||
messageQueue = new LinkedList<String>();
|
||||
this.address = address;
|
||||
this.port = port;
|
||||
this.loginMessage = loginMessage;
|
||||
}
|
||||
|
||||
public void start() {
|
||||
handler = new Handler();
|
||||
connection = new Connection(this);
|
||||
connection.connect(address, port);
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
connection.close();
|
||||
handler.removeCallbacksAndMessages(null);
|
||||
}
|
||||
|
||||
private void reconnect() {
|
||||
handler.removeCallbacksAndMessages(null);
|
||||
connection.close();
|
||||
connection = new Connection(this);
|
||||
connection.connect(address, port);
|
||||
}
|
||||
|
||||
private void delayedReconnect() {
|
||||
connection.close();
|
||||
handler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
connection = new Connection(ClientController.this);
|
||||
connection.connect(address, port);
|
||||
}
|
||||
}, RECONNECT_DELAY);
|
||||
}
|
||||
|
||||
public void setNewServer(String address, int port) {
|
||||
this.address = address;
|
||||
this.port = port;
|
||||
reconnect();
|
||||
}
|
||||
|
||||
public void setNewLogin(String loginMessage) {
|
||||
this.loginMessage = loginMessage;
|
||||
reconnect();
|
||||
}
|
||||
|
||||
public void setNewLocation(String locationMessage) {
|
||||
messageQueue.offer(locationMessage);
|
||||
if (!connection.isClosed() && !connection.isBusy()) {
|
||||
connection.send(messageQueue.poll());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnected(boolean result) {
|
||||
if (result) {
|
||||
StatusActivity.addMessage(context.getString(R.string.status_connection_success));
|
||||
connection.send(loginMessage);
|
||||
} else {
|
||||
StatusActivity.addMessage(context.getString(R.string.status_connection_fail));
|
||||
delayedReconnect();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSent(boolean result) {
|
||||
if (result) {
|
||||
if (!messageQueue.isEmpty()) {
|
||||
connection.send(messageQueue.poll());
|
||||
}
|
||||
} else {
|
||||
StatusActivity.addMessage(context.getString(R.string.status_send_fail));
|
||||
delayedReconnect();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,157 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012 - 2013 Anton Tananaev (anton.tananaev@gmail.com)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.traccar.client;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.OutputStream;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Socket;
|
||||
|
||||
import android.os.AsyncTask;
|
||||
import android.util.Log;
|
||||
|
||||
/**
|
||||
* Asynchronous connection
|
||||
*
|
||||
* All methods should be called from UI thread only.
|
||||
*/
|
||||
public class Connection implements Closeable {
|
||||
|
||||
public static final String LOG_TAG = "Traccar.Connection";
|
||||
public static final int SOCKET_TIMEOUT = 10 * 1000;
|
||||
|
||||
/**
|
||||
* Callback interface
|
||||
*/
|
||||
public interface ConnectionHandler {
|
||||
void onConnected(boolean result);
|
||||
void onSent(boolean result);
|
||||
}
|
||||
|
||||
private ConnectionHandler handler;
|
||||
|
||||
private Socket socket;
|
||||
private OutputStream socketStream;
|
||||
|
||||
private boolean closed;
|
||||
private boolean busy;
|
||||
|
||||
public boolean isClosed() {
|
||||
return closed;
|
||||
}
|
||||
|
||||
public boolean isBusy() {
|
||||
return busy;
|
||||
}
|
||||
|
||||
public Connection(ConnectionHandler handler) {
|
||||
this.handler = handler;
|
||||
closed = false;
|
||||
busy = false;
|
||||
}
|
||||
|
||||
public void connect(final String address, final int port) {
|
||||
busy = true;
|
||||
|
||||
new AsyncTask<Void, Void, Boolean>() {
|
||||
|
||||
@Override
|
||||
protected Boolean doInBackground(Void... params) {
|
||||
try {
|
||||
socket = new Socket();
|
||||
socket.connect(new InetSocketAddress(address, port));
|
||||
socket.setSoTimeout(SOCKET_TIMEOUT);
|
||||
socketStream = socket.getOutputStream();
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
Log.w(LOG_TAG, e.getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCancelled() {
|
||||
if (!closed) {
|
||||
busy = false;
|
||||
handler.onConnected(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Boolean result) {
|
||||
if (!closed) {
|
||||
busy = false;
|
||||
handler.onConnected(result);
|
||||
}
|
||||
}
|
||||
|
||||
}.execute();
|
||||
|
||||
}
|
||||
|
||||
public void send(String message) {
|
||||
busy = true;
|
||||
|
||||
new AsyncTask<String, Void, Boolean>() {
|
||||
|
||||
@Override
|
||||
protected Boolean doInBackground(String... params) {
|
||||
try {
|
||||
socketStream.write(params[0].getBytes());
|
||||
socketStream.flush();
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
Log.w(LOG_TAG, e.getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCancelled() {
|
||||
if (!closed) {
|
||||
busy = false;
|
||||
handler.onSent(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Boolean result) {
|
||||
if (!closed) {
|
||||
busy = false;
|
||||
handler.onSent(result);
|
||||
}
|
||||
}
|
||||
|
||||
}.execute(message);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
closed = true;
|
||||
try {
|
||||
if (socketStream != null) {
|
||||
socketStream.close();
|
||||
}
|
||||
if (socket != null) {
|
||||
socket.close();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e(LOG_TAG, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,139 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013 Anton Tananaev (anton.tananaev@gmail.com)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.traccar.client;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import android.content.Context;
|
||||
import android.location.Location;
|
||||
import android.location.LocationListener;
|
||||
import android.location.LocationManager;
|
||||
import android.location.LocationProvider;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
|
||||
public class PositionProvider {
|
||||
|
||||
public static final String PROVIDER_MIXED = "mixed";
|
||||
public static final long PERIOD_DELTA = 10 * 1000;
|
||||
public static final long RETRY_PERIOD = 60 * 1000;
|
||||
|
||||
public interface PositionListener {
|
||||
public void onPositionUpdate(Location location);
|
||||
}
|
||||
|
||||
private final Context context;
|
||||
|
||||
private final Handler handler;
|
||||
private final LocationManager locationManager;
|
||||
private final long period;
|
||||
private final PositionListener listener;
|
||||
|
||||
private boolean useFine;
|
||||
private boolean useCoarse;
|
||||
|
||||
public PositionProvider(Context context, String type, long period, PositionListener listener) {
|
||||
this.context = context;
|
||||
handler = new Handler(this.context.getMainLooper());
|
||||
locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
|
||||
this.period = period;
|
||||
this.listener = listener;
|
||||
|
||||
// Determine providers
|
||||
if (type.equals(PROVIDER_MIXED)) {
|
||||
useFine = true;
|
||||
useCoarse = true;
|
||||
} else if (type.equals(LocationManager.GPS_PROVIDER)) {
|
||||
useFine = true;
|
||||
} else if (type.equals(LocationManager.NETWORK_PROVIDER)) {
|
||||
useCoarse = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void startUpdates() {
|
||||
if (useFine) {
|
||||
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, period, 0, fineLocationListener);
|
||||
}
|
||||
if (useCoarse) {
|
||||
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, period, 0, coarseLocationListener);
|
||||
}
|
||||
handler.postDelayed(updateTask, period);
|
||||
}
|
||||
|
||||
public void stopUpdates() {
|
||||
handler.removeCallbacks(updateTask);
|
||||
locationManager.removeUpdates(fineLocationListener);
|
||||
locationManager.removeUpdates(coarseLocationListener);
|
||||
}
|
||||
|
||||
private final Runnable updateTask = new Runnable() {
|
||||
|
||||
private boolean tryProvider(String provider) {
|
||||
Location location = locationManager.getLastKnownLocation(provider);
|
||||
|
||||
if (location != null && new Date().getTime() - location.getTime() <= period + PERIOD_DELTA) {
|
||||
listener.onPositionUpdate(location);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (useFine && tryProvider(LocationManager.GPS_PROVIDER)) {
|
||||
} else if (useCoarse && tryProvider(LocationManager.NETWORK_PROVIDER)) {
|
||||
} else {
|
||||
listener.onPositionUpdate(null);
|
||||
}
|
||||
handler.postDelayed(this, period);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
private final InternalLocationListener fineLocationListener = new InternalLocationListener();
|
||||
private final InternalLocationListener coarseLocationListener = new InternalLocationListener();
|
||||
|
||||
private class InternalLocationListener implements LocationListener {
|
||||
|
||||
@Override
|
||||
public void onLocationChanged(Location location) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProviderDisabled(String provider) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProviderEnabled(String provider) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStatusChanged(final String provider, int status, Bundle extras) {
|
||||
if (status == LocationProvider.TEMPORARILY_UNAVAILABLE || status == LocationProvider.OUT_OF_SERVICE) {
|
||||
handler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
locationManager.removeUpdates(InternalLocationListener.this);
|
||||
locationManager.requestLocationUpdates(provider, period, 0, InternalLocationListener.this);
|
||||
}
|
||||
}, RETRY_PERIOD);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012 - 2013 Anton Tananaev (anton.tananaev@gmail.com)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.traccar.client;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Formatter;
|
||||
import java.util.Locale;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import android.location.Location;
|
||||
|
||||
/**
|
||||
* Protocol formatting
|
||||
*/
|
||||
public class Protocol {
|
||||
|
||||
/**
|
||||
* Format device id message
|
||||
*/
|
||||
public static String createLoginMessage(String id) {
|
||||
StringBuilder s = new StringBuilder("$PGID,");
|
||||
Formatter f = new Formatter(s, Locale.ENGLISH);
|
||||
|
||||
s.append(id);
|
||||
|
||||
byte checksum = 0;
|
||||
for (byte b : s.substring(1).getBytes()) {
|
||||
checksum ^= b;
|
||||
}
|
||||
f.format("*%02x\r\n", (int) checksum);
|
||||
f.close();
|
||||
|
||||
return s.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Format location message
|
||||
*/
|
||||
public static String createLocationMessage(Location l) {
|
||||
StringBuilder s = new StringBuilder("$GPRMC,");
|
||||
Formatter f = new Formatter(s, Locale.ENGLISH);
|
||||
Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC"), Locale.ENGLISH);
|
||||
calendar.setTimeInMillis(l.getTime());
|
||||
|
||||
f.format("%1$tH%1$tM%1$tS.%1$tL,A,", calendar);
|
||||
|
||||
double lat = l.getLatitude();
|
||||
double lon = l.getLongitude();
|
||||
f.format("%02d%07.4f,%c,", (int) Math.abs(lat), Math.abs(lat) % 1 * 60, lat < 0 ? 'S' : 'N' );
|
||||
f.format("%03d%07.4f,%c,", (int) Math.abs(lon), Math.abs(lon) % 1 * 60, lon < 0 ? 'W' : 'E' );
|
||||
|
||||
double speed = l.getSpeed() * 1.943844; // speed in knots
|
||||
f.format("%.2f,%.2f,", speed, l.getBearing());
|
||||
f.format("%1$td%1$tm%1$ty,,", calendar);
|
||||
|
||||
byte checksum = 0;
|
||||
for (byte b : s.substring(1).getBytes()) {
|
||||
checksum ^= b;
|
||||
}
|
||||
f.format("*%02x\r\n", (int) checksum);
|
||||
f.close();
|
||||
|
||||
return s.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,128 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012 Anton Tananaev (anton.tananaev@gmail.com)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.traccar.client;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.app.ActivityManager.RunningServiceInfo;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceActivity;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
|
||||
/**
|
||||
* Main user interface
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class TraccarActivity extends PreferenceActivity {
|
||||
|
||||
public static final String LOG_TAG = "traccar";
|
||||
|
||||
public static final String KEY_ID = "id";
|
||||
public static final String KEY_ADDRESS = "address";
|
||||
public static final String KEY_PORT = "port";
|
||||
public static final String KEY_INTERVAL = "interval";
|
||||
public static final String KEY_PROVIDER = "provider";
|
||||
public static final String KEY_STATUS = "status";
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
addPreferencesFromResource(R.xml.preferences);
|
||||
initPreferences();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(
|
||||
preferenceChangeListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
getPreferenceScreen().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(
|
||||
preferenceChangeListener);
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
OnSharedPreferenceChangeListener preferenceChangeListener = new OnSharedPreferenceChangeListener() {
|
||||
@Override
|
||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
||||
if (key.equals(KEY_STATUS)) {
|
||||
if (sharedPreferences.getBoolean(KEY_STATUS, false)) {
|
||||
startService(new Intent(TraccarActivity.this, TraccarService.class));
|
||||
} else {
|
||||
stopService(new Intent(TraccarActivity.this, TraccarService.class));
|
||||
}
|
||||
} else if (key.equals(KEY_ID)) {
|
||||
findPreference(KEY_ID).setSummary(sharedPreferences.getString(KEY_ID, null));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
MenuInflater inflater = getMenuInflater();
|
||||
inflater.inflate(R.menu.main, menu);
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
if (item.getItemId() == R.id.status) {
|
||||
startActivity(new Intent(this, StatusActivity.class));
|
||||
return true;
|
||||
} else if (item.getItemId() == R.id.about) {
|
||||
startActivity(new Intent(this, AboutActivity.class));
|
||||
return true;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
private boolean isServiceRunning() {
|
||||
ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
|
||||
for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
|
||||
if (TraccarService.class.getName().equals(service.service.getClassName())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void initPreferences() {
|
||||
PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
|
||||
|
||||
TelephonyManager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
|
||||
String id = telephonyManager.getDeviceId();
|
||||
|
||||
SharedPreferences sharedPreferences = getPreferenceScreen().getSharedPreferences();
|
||||
|
||||
if (!sharedPreferences.contains(KEY_ID)) {
|
||||
sharedPreferences.edit().putString(KEY_ID, id).commit();
|
||||
}
|
||||
findPreference(KEY_ID).setSummary(sharedPreferences.getString(KEY_ID, id));
|
||||
|
||||
sharedPreferences.edit().putBoolean(KEY_STATUS, isServiceRunning()).commit();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,167 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012 - 2013 Anton Tananaev (anton.tananaev@gmail.com)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.traccar.client;
|
||||
|
||||
import android.app.Service;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
|
||||
import android.location.Location;
|
||||
import android.os.IBinder;
|
||||
import android.os.PowerManager;
|
||||
import android.os.PowerManager.WakeLock;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
|
||||
/**
|
||||
* Background service
|
||||
*/
|
||||
public class TraccarService extends Service {
|
||||
|
||||
public static final String LOG_TAG = "Traccar.TraccarService";
|
||||
|
||||
private String id;
|
||||
private String address;
|
||||
private int port;
|
||||
private int interval;
|
||||
private String provider;
|
||||
|
||||
private SharedPreferences sharedPreferences;
|
||||
private ClientController clientController;
|
||||
private PositionProvider positionProvider;
|
||||
|
||||
private WakeLock wakeLock;
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
StatusActivity.addMessage(getString(R.string.status_service_create));
|
||||
|
||||
PowerManager powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
|
||||
wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, getClass().getName());
|
||||
wakeLock.acquire();
|
||||
}
|
||||
|
||||
public void onStart(Intent intent, int startId) {
|
||||
StatusActivity.addMessage(getString(R.string.status_service_start));
|
||||
|
||||
sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
|
||||
try {
|
||||
id = sharedPreferences.getString(TraccarActivity.KEY_ID, null);
|
||||
address = sharedPreferences.getString(TraccarActivity.KEY_ADDRESS, null);
|
||||
provider = sharedPreferences.getString(TraccarActivity.KEY_PROVIDER, null);
|
||||
port = Integer.valueOf(sharedPreferences.getString(TraccarActivity.KEY_PORT, null));
|
||||
interval = Integer.valueOf(sharedPreferences.getString(TraccarActivity.KEY_INTERVAL, null));
|
||||
} catch (Exception error) {
|
||||
Log.w(LOG_TAG, error);
|
||||
}
|
||||
|
||||
clientController = new ClientController(this, address, port, Protocol.createLoginMessage(id));
|
||||
clientController.start();
|
||||
|
||||
positionProvider = new PositionProvider(this, provider, interval * 1000, positionListener);
|
||||
positionProvider.startUpdates();
|
||||
|
||||
sharedPreferences.registerOnSharedPreferenceChangeListener(preferenceChangeListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
onStart(intent, startId);
|
||||
return START_STICKY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
StatusActivity.addMessage(getString(R.string.status_service_destroy));
|
||||
|
||||
if (sharedPreferences != null) {
|
||||
sharedPreferences.unregisterOnSharedPreferenceChangeListener(preferenceChangeListener);
|
||||
}
|
||||
|
||||
if (positionProvider != null) {
|
||||
positionProvider.stopUpdates();
|
||||
}
|
||||
|
||||
if (clientController != null) {
|
||||
clientController.stop();
|
||||
}
|
||||
|
||||
wakeLock.release();
|
||||
}
|
||||
|
||||
private PositionProvider.PositionListener positionListener = new PositionProvider.PositionListener() {
|
||||
|
||||
@Override
|
||||
public void onPositionUpdate(Location location) {
|
||||
if (location != null) {
|
||||
StatusActivity.addMessage(getString(R.string.status_location_update));
|
||||
clientController.setNewLocation(Protocol.createLocationMessage(location));
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
OnSharedPreferenceChangeListener preferenceChangeListener = new OnSharedPreferenceChangeListener() {
|
||||
|
||||
@Override
|
||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
||||
StatusActivity.addMessage(getString(R.string.status_preference_update));
|
||||
try {
|
||||
if (key.equals(TraccarActivity.KEY_ADDRESS)) {
|
||||
|
||||
address = sharedPreferences.getString(TraccarActivity.KEY_ADDRESS, null);
|
||||
clientController.setNewServer(address, port);
|
||||
|
||||
} else if (key.equals(TraccarActivity.KEY_PORT)) {
|
||||
|
||||
port = Integer.valueOf(sharedPreferences.getString(TraccarActivity.KEY_PORT, null));
|
||||
clientController.setNewServer(address, port);
|
||||
|
||||
} else if (key.equals(TraccarActivity.KEY_INTERVAL)) {
|
||||
|
||||
interval = Integer.valueOf(sharedPreferences.getString(TraccarActivity.KEY_INTERVAL, null));
|
||||
positionProvider.stopUpdates();
|
||||
positionProvider = new PositionProvider(TraccarService.this, provider, interval * 1000, positionListener);
|
||||
positionProvider.startUpdates();
|
||||
|
||||
} else if (key.equals(TraccarActivity.KEY_ID)) {
|
||||
|
||||
id = sharedPreferences.getString(TraccarActivity.KEY_ID, null);
|
||||
clientController.setNewLogin(Protocol.createLoginMessage(id));
|
||||
|
||||
} else if (key.equals(TraccarActivity.KEY_PROVIDER)) {
|
||||
|
||||
provider = sharedPreferences.getString(TraccarActivity.KEY_PROVIDER, null);
|
||||
positionProvider.stopUpdates();
|
||||
positionProvider = new PositionProvider(TraccarService.this, provider, interval * 1000, positionListener);
|
||||
positionProvider.startUpdates();
|
||||
|
||||
}
|
||||
} catch (Exception error) {
|
||||
Log.w(LOG_TAG, error);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
До Ширина: | Высота: | Размер: 2.7 KiB |
|
До Ширина: | Высота: | Размер: 1.2 KiB |
|
До Ширина: | Высота: | Размер: 1.7 KiB |
|
До Ширина: | Высота: | Размер: 3.6 KiB |
|
До Ширина: | Высота: | Размер: 5.3 KiB |
@@ -1,44 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<string name="app_name">Traccar klient</string>
|
||||
<string name="app_logo">Traccar</string>
|
||||
|
||||
<string name="settings_id_title">Identifikátor zařízení</string>
|
||||
<string name="settings_address_title">Adresa serveru</string>
|
||||
<string name="settings_address_summary">Doménové jméno nebo IP adresa</string>
|
||||
<string name="settings_port_title">Port</string>
|
||||
<string name="settings_port_summary">TCP port sledovacího serveru</string>
|
||||
<string name="settings_interval_title">Frekvence</string>
|
||||
<string name="settings_interval_summary">Interval zpráv v sekundách</string>
|
||||
<string name="settings_status_title">Stav služby</string>
|
||||
<string name="settings_status_off">Start</string>
|
||||
<string name="settings_status_on">Stop</string>
|
||||
<string name="settings_status_off_summary">Zastaveno</string>
|
||||
<string name="settings_status_on_summary">Spuštěno</string>
|
||||
<string name="settings_provider_title">Poskytovatel zaměření</string>
|
||||
<string name="settings_provider_summary">Zdroj zaměřovacích dat</string>
|
||||
<string-array name="settings_provider_names">
|
||||
<item>GPS</item>
|
||||
<item>Mobilní síť</item>
|
||||
<item>Obojí</item>
|
||||
</string-array>
|
||||
|
||||
<string name="menu_status">Stav</string>
|
||||
<string name="menu_about">O aplikaci</string>
|
||||
<string name="menu_clear">Vyčistit</string>
|
||||
|
||||
<string name="about_description">GPS sledovací aplikace pracující v reálném čase pro zařízení s operačním systémem Android. Kompatibilní s Traccar serverem a dalšími sledovacími systémy.</string>
|
||||
<string name="about_license">Tato aplikace je zdarma a open source, zdrojový kód je licencován pod Apache License Version 2.0 a je přístupný na GitHub.</string>
|
||||
<string name="about_web">Pro více informací navštivte\nwww.traccar.org/client</string>
|
||||
|
||||
<string name="status_service_create">Služba vytvořena</string>
|
||||
<string name="status_service_start">Služba spuštěna</string>
|
||||
<string name="status_service_destroy">Služba zastavena</string>
|
||||
<string name="status_connection_success">Spojení se zdařilo</string>
|
||||
<string name="status_connection_fail">Spojení selhalo</string>
|
||||
<string name="status_send_fail">Odesílání selhalo</string>
|
||||
<string name="status_location_update">Aktualizace pozice</string>
|
||||
<string name="status_preference_update">Aktualizace nastavení</string>
|
||||
|
||||
</resources>
|
||||
@@ -1,44 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<string name="app_name">Traccar für Android</string>
|
||||
<string name="app_logo">Traccar</string>
|
||||
|
||||
<string name="settings_id_title">Gerätekennung</string>
|
||||
<string name="settings_address_title">Serveradresse</string>
|
||||
<string name="settings_address_summary">Domain oder IP Adresse</string>
|
||||
<string name="settings_port_title">Serverport</string>
|
||||
<string name="settings_port_summary">Port des Ortungsservers</string>
|
||||
<string name="settings_interval_title">Frequenz</string>
|
||||
<string name="settings_interval_summary">Intervall in Sekunden</string>
|
||||
<string name="settings_status_title">Dienststatus</string>
|
||||
<string name="settings_status_off">Start</string>
|
||||
<string name="settings_status_on">Stop</string>
|
||||
<string name="settings_status_off_summary">Dienst inaktiv</string>
|
||||
<string name="settings_status_on_summary">Dienst aktiv</string>
|
||||
<string name="settings_provider_title">Datenherkunft</string>
|
||||
<string name="settings_provider_summary">Quelle der Positionen</string>
|
||||
<string-array name="settings_provider_names">
|
||||
<item>GPS</item>
|
||||
<item>Netzwerk</item>
|
||||
<item>Gemischt</item>
|
||||
</string-array>
|
||||
|
||||
<string name="menu_status">Status</string>
|
||||
<string name="menu_about">Über</string>
|
||||
<string name="menu_clear">Leeren</string>
|
||||
|
||||
<string name="about_description">Echtzeit GPS Ortung für Android Geräte. Kompatibel mit Traccar Server und anderen Ortungsservern.</string>
|
||||
<string name="about_license">Dieses Programm ist frei und Open Source. Es ist unter Apache Lizenz Version 2.0 lizenziert und ist auf GitHub verfügbar.</string>
|
||||
<string name="about_web">Für weitere Informationen besuche uns auf \nwww.traccar.org/client</string>
|
||||
|
||||
<string name="status_service_create">Dienst installiert</string>
|
||||
<string name="status_service_start">Dienst gestartet</string>
|
||||
<string name="status_service_destroy">Dienst zerstört</string>
|
||||
<string name="status_connection_success">Verbindung erfolgreich</string>
|
||||
<string name="status_connection_fail">Verbindung fehlerhaft</string>
|
||||
<string name="status_send_fail">Übertragung fehlerhaft</string>
|
||||
<string name="status_location_update">Positionsupdate</string>
|
||||
<string name="status_preference_update">Prioritätsupdate</string>
|
||||
|
||||
</resources>
|
||||
@@ -1,44 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<string name="app_name">Cliente Traccar</string>
|
||||
<string name="app_logo">Traccar</string>
|
||||
|
||||
<string name="settings_id_title">Identificador de Dispositivo</string>
|
||||
<string name="settings_address_title">Dirección Servidor</string>
|
||||
<string name="settings_address_summary">Dominio o Dirección IP</string>
|
||||
<string name="settings_port_title">Puerto del Servidor</string>
|
||||
<string name="settings_port_summary">Puerto TCP del rastreador</string>
|
||||
<string name="settings_interval_title">Frecuencia de rastreo</string>
|
||||
<string name="settings_interval_summary">Intervalo de los mensajes, en segundos</string>
|
||||
<string name="settings_status_title">Estado del servicio</string>
|
||||
<string name="settings_status_off">Activado</string>
|
||||
<string name="settings_status_on">Desactivado</string>
|
||||
<string name="settings_status_off_summary">Servicio parado</string>
|
||||
<string name="settings_status_on_summary">Servicio activado</string>
|
||||
<string name="settings_provider_title">Proveedor de localización</string>
|
||||
<string name="settings_provider_summary">Fuente de los datos de localización</string>
|
||||
<string-array name="settings_provider_names">
|
||||
<item>Proveedor GPS</item>
|
||||
<item>Proveedor de red</item>
|
||||
<item>Proveedor mixto</item>
|
||||
</string-array>
|
||||
|
||||
<string name="menu_status">Estado</string>
|
||||
<string name="menu_about">Acerca de…</string>
|
||||
<string name="menu_clear">Limpiar</string>
|
||||
|
||||
<string name="about_description">Rastreador GPS en tiempo real para dispositivos Android. Compatible con Servidore Traccar y otros sistemas de rastreo.</string>
|
||||
<string name="about_license">Esta aplición es gratuíta y de código abierto. El código fuente está sometido a Licencia Apache Versión 2 y disponible en Github.</string>
|
||||
<string name="about_web">Para más información visite\nwww.traccar.org/client</string>
|
||||
|
||||
<string name="status_service_create">Servicio creado</string>
|
||||
<string name="status_service_start">Service arrancado</string>
|
||||
<string name="status_service_destroy">Servicio destruído</string>
|
||||
<string name="status_connection_success">Conexión realizada</string>
|
||||
<string name="status_connection_fail">Fallo en la conexión</string>
|
||||
<string name="status_send_fail">Erro en el envío</string>
|
||||
<string name="status_location_update">Posición actualizada</string>
|
||||
<string name="status_preference_update">Preferencias actualizadas</string>
|
||||
|
||||
</resources>
|
||||
@@ -1,44 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<string name="app_name">Traccar</string>
|
||||
<string name="app_logo">Traccar</string>
|
||||
|
||||
<string name="settings_id_title">Identifiant du périphérique</string>
|
||||
<string name="settings_address_title">Adresse du serveur</string>
|
||||
<string name="settings_address_summary">Nom de domaine ou adresse IP</string>
|
||||
<string name="settings_port_title">Port du serveur</string>
|
||||
<string name="settings_port_summary">Port TCP du serveur</string>
|
||||
<string name="settings_interval_title">Fréquence</string>
|
||||
<string name="settings_interval_summary">Fréquence d\'envoi de la localisation en secondes</string>
|
||||
<string name="settings_status_title">Statut</string>
|
||||
<string name="settings_status_off">Démarrer</string>
|
||||
<string name="settings_status_on">Arrêter</string>
|
||||
<string name="settings_status_off_summary">Arrêté</string>
|
||||
<string name="settings_status_on_summary">En marche</string>
|
||||
<string name="settings_provider_title">Source de localisation</string>
|
||||
<string name="settings_provider_summary">Source utilisée par le système afin d\'obtenir la localisation de l\'appareil</string>
|
||||
<string-array name="settings_provider_names">
|
||||
<item>Mode GPS uniquement</item>
|
||||
<item>Mode cellulaire uniquement</item>
|
||||
<item>Mode hybride</item>
|
||||
</string-array>
|
||||
|
||||
<string name="menu_status">Etat</string>
|
||||
<string name="menu_about">A propos</string>
|
||||
<string name="menu_clear">Effacer</string>
|
||||
|
||||
<string name="about_description">Suivi GPS en temps réels d\'appareils Android. Compatible avec le serveur Traccar ainsi que d\'autres plateformes de suivi.</string>
|
||||
<string name="about_license">Cette application open source est gratuite. Le code source disponible sur GitHub est sous licence Apache Version 2.0.</string>
|
||||
<string name="about_web">Pour plus d’information, visitez le site: \nwww.traccar.org/client</string>
|
||||
|
||||
<string name="status_service_create">Service créé</string>
|
||||
<string name="status_service_start">Service démarré</string>
|
||||
<string name="status_service_destroy">Service supprimé</string>
|
||||
<string name="status_connection_success">Connexion établie avec le serveur</string>
|
||||
<string name="status_connection_fail">Echec de la connexion au serveur</string>
|
||||
<string name="status_send_fail">L’envoi de localisation a échoué</string>
|
||||
<string name="status_location_update">Localisation mise à jour</string>
|
||||
<string name="status_preference_update">Mise à jour des préférences</string>
|
||||
|
||||
</resources>
|
||||
@@ -1,44 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<string name="app_name">Cliente Traccar</string>
|
||||
<string name="app_logo">Traccar</string>
|
||||
|
||||
<string name="settings_id_title">Identificador único</string>
|
||||
<string name="settings_address_title">Endereço do servidor</string>
|
||||
<string name="settings_address_summary">Nome do domínio ou endereço IP</string>
|
||||
<string name="settings_port_title">Porta do servidor</string>
|
||||
<string name="settings_port_summary">Porta TCP do servidor de rastreamento</string>
|
||||
<string name="settings_interval_title">Invervalo</string>
|
||||
<string name="settings_interval_summary">Intervalo entre as mensagens em segundos</string>
|
||||
<string name="settings_status_title">Status do Serviço</string>
|
||||
<string name="settings_status_off">Iniciar</string>
|
||||
<string name="settings_status_on">Parar</string>
|
||||
<string name="settings_status_off_summary">Serviço Parado</string>
|
||||
<string name="settings_status_on_summary">Serviço em execução</string>
|
||||
<string name="settings_provider_title">Provedor de localização</string>
|
||||
<string name="settings_provider_summary">Fonte dos dados de localização</string>
|
||||
<string-array name="settings_provider_names">
|
||||
<item>Provedor GPS</item>
|
||||
<item>Provedor Rede</item>
|
||||
<item>Provedor Misto</item>
|
||||
</string-array>
|
||||
|
||||
<string name="menu_status">Status</string>
|
||||
<string name="menu_about">Sobre</string>
|
||||
<string name="menu_clear">Limpar</string>
|
||||
|
||||
<string name="about_description">Rastreador GPS Real Time para dispositivos Android. Compatível com servidor Traccar e outros sistemas de rastreamento.</string>
|
||||
<string name="about_license">Esta aplicação é livre e de código aberto, o código fonte é licenciado sob a licença Apache Versão 2.0 e disponível no GitHub.</string>
|
||||
<string name="about_web">Para mais informações visite\nwww.traccar.org/client</string>
|
||||
|
||||
<string name="status_service_create">Serviço criado</string>
|
||||
<string name="status_service_start">Serviço iniciado</string>
|
||||
<string name="status_service_destroy">Serviço destruído</string>
|
||||
<string name="status_connection_success">Sucesso na conexão</string>
|
||||
<string name="status_connection_fail">Falha na conexão</string>
|
||||
<string name="status_send_fail">Falha no envio</string>
|
||||
<string name="status_location_update">Localização atualizada</string>
|
||||
<string name="status_preference_update">Preferências atualizadas</string>
|
||||
|
||||
</resources>
|
||||
@@ -1,44 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<string name="app_name">Traccar Клиент</string>
|
||||
<string name="app_logo">Traccar</string>
|
||||
|
||||
<string name="settings_id_title">Идентификатор устройства</string>
|
||||
<string name="settings_address_title">Адрес сервера</string>
|
||||
<string name="settings_address_summary">Домен или IP адрес</string>
|
||||
<string name="settings_port_title">Порт сервера</string>
|
||||
<string name="settings_port_summary">TCP порт мониторингового сервера</string>
|
||||
<string name="settings_interval_title">Частота</string>
|
||||
<string name="settings_interval_summary">Интервал между сообщениями в секундах</string>
|
||||
<string name="settings_status_title">Состояние сервиса</string>
|
||||
<string name="settings_status_off">Старт</string>
|
||||
<string name="settings_status_on">Стоп</string>
|
||||
<string name="settings_status_off_summary">Сервис остановлен</string>
|
||||
<string name="settings_status_on_summary">Сервис запущен</string>
|
||||
<string name="settings_provider_title">Провайдер местоположения</string>
|
||||
<string name="settings_provider_summary">Источник данных о местоположении</string>
|
||||
<string-array name="settings_provider_names">
|
||||
<item>GPS провайдер</item>
|
||||
<item>Сетевой провайдер</item>
|
||||
<item>Смешанный провайдер</item>
|
||||
</string-array>
|
||||
|
||||
<string name="menu_status">Состояние</string>
|
||||
<string name="menu_about">О программе</string>
|
||||
<string name="menu_clear">Очистить</string>
|
||||
|
||||
<string name="about_description">Трекер для Android устройств. Совместим с Traccar сервером и другими мониторинговыми системами.</string>
|
||||
<string name="about_license">Это приложение распростаняется бесплатно, исходный код распростаняется по лицензии Apache License Version 2.0 и доступен на GitHub.</string>
|
||||
<string name="about_web">Для получения дополнительной информации посетите\nwww.traccar.org/client</string>
|
||||
|
||||
<string name="status_service_create">Сервис создан</string>
|
||||
<string name="status_service_start">Сервис запущен</string>
|
||||
<string name="status_service_destroy">Сервис удален</string>
|
||||
<string name="status_connection_success">Соедниение установлено</string>
|
||||
<string name="status_connection_fail">Ошибка установки соединения</string>
|
||||
<string name="status_send_fail">Ошибка отправки</string>
|
||||
<string name="status_location_update">Обновление местоположения</string>
|
||||
<string name="status_preference_update">Обновление настроек</string>
|
||||
|
||||
</resources>
|
||||