Сравнить коммиты
| Автор | SHA1 | Дата | |
|---|---|---|---|
|
|
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 |
@@ -1,22 +1,33 @@
|
|||||||
apply plugin: 'com.android.application'
|
apply plugin: 'com.android.application'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 22
|
compileSdkVersion 23
|
||||||
buildToolsVersion "22.0.1"
|
buildToolsVersion '23.0.2'
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdkVersion 3
|
minSdkVersion 3
|
||||||
targetSdkVersion 22
|
targetSdkVersion 23
|
||||||
versionCode 25
|
versionCode 28
|
||||||
versionName "3.5"
|
versionName '3.8'
|
||||||
}
|
}
|
||||||
|
|
||||||
signingConfigs {
|
signingConfigs {
|
||||||
release {
|
release {
|
||||||
storeFile file('../../android.keystore')
|
storeFile file('../../android.keystore')
|
||||||
keyAlias "tananaev"
|
keyAlias 'tananaev'
|
||||||
storePassword ""
|
storePassword ''
|
||||||
keyPassword ""
|
keyPassword ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
productFlavors {
|
||||||
|
regular {
|
||||||
|
applicationId "org.traccar.client"
|
||||||
|
buildConfigField "boolean", "HIDDEN_APP", "false"
|
||||||
|
}
|
||||||
|
hidden {
|
||||||
|
applicationId "org.traccar.client.hidden"
|
||||||
|
buildConfigField "boolean", "HIDDEN_APP", "true"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,16 +41,16 @@ android {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
testCompile 'junit:junit:4.12'
|
testCompile 'junit:junit:4.12'
|
||||||
testCompile "org.robolectric:robolectric:3.0"
|
testCompile 'org.robolectric:robolectric:3.0'
|
||||||
}
|
}
|
||||||
|
|
||||||
task requestPasswords << {
|
task requestPasswords << {
|
||||||
android.signingConfigs.release.storePassword = new String(System.console().readPassword("\nStore password: "))
|
android.signingConfigs.release.storePassword = new String(System.console().readPassword('\nStore password: '))
|
||||||
android.signingConfigs.release.keyPassword = new String(System.console().readPassword("Key password: "))
|
android.signingConfigs.release.keyPassword = new String(System.console().readPassword('Key password: '))
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.whenTaskAdded { theTask ->
|
tasks.whenTaskAdded { theTask ->
|
||||||
if (theTask.name.equals("packageRelease")) {
|
if (theTask.name.equals('packageRegularRelease') || theTask.name.equals('packageHiddenRelease')) {
|
||||||
theTask.dependsOn "requestPasswords"
|
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=".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 |
@@ -6,27 +6,42 @@
|
|||||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
|
||||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||||
|
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
|
||||||
|
|
||||||
<application android:label="@string/app_name" android:icon="@drawable/ic_launcher" android:allowBackup="true" android:theme="@style/TraccarTheme">
|
<application
|
||||||
|
android:allowBackup="true"
|
||||||
|
android:icon="@mipmap/ic_launcher"
|
||||||
|
android:label="@string/app_name"
|
||||||
|
android:theme="@style/TraccarTheme">
|
||||||
|
|
||||||
<activity android:name=".MainActivity">
|
<activity android:name=".MainActivity" android:launchMode="singleTask" />
|
||||||
|
|
||||||
|
<activity-alias
|
||||||
|
android:name=".Launcher"
|
||||||
|
android:targetActivity=".MainActivity">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity-alias>
|
||||||
|
|
||||||
<activity android:name=".StatusActivity">
|
<activity android:name=".StatusActivity"/>
|
||||||
</activity>
|
|
||||||
|
|
||||||
<activity android:name=".AboutActivity">
|
<activity android:name=".AboutActivity"/>
|
||||||
|
|
||||||
|
<activity
|
||||||
|
android:name=".ShortcutActivity">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<service android:name=".TrackingService" />
|
<service android:name=".TrackingService" />
|
||||||
|
|
||||||
|
<service android:name=".TrackingService$HideNotificationService" />
|
||||||
|
|
||||||
<receiver android:name=".AutostartReceiver">
|
<receiver android:name=".AutostartReceiver">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
||||||
|
|||||||
@@ -31,8 +31,7 @@ public class DatabaseHelper extends SQLiteOpenHelper {
|
|||||||
public static final String DATABASE_NAME = "traccar.db";
|
public static final String DATABASE_NAME = "traccar.db";
|
||||||
|
|
||||||
public interface DatabaseHandler<T> {
|
public interface DatabaseHandler<T> {
|
||||||
void onSuccess(T result);
|
void onComplete(boolean success, T result);
|
||||||
void onFailure(RuntimeException error);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static abstract class DatabaseAsyncTask<T> extends AsyncTask<Void, Void, T> {
|
private static abstract class DatabaseAsyncTask<T> extends AsyncTask<Void, Void, T> {
|
||||||
@@ -58,11 +57,7 @@ public class DatabaseHelper extends SQLiteOpenHelper {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(T result) {
|
protected void onPostExecute(T result) {
|
||||||
if (error == null) {
|
handler.onComplete(error == null, result);
|
||||||
handler.onSuccess(result);
|
|
||||||
} else {
|
|
||||||
handler.onFailure(error);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012 - 2015 Anton Tananaev (anton.tananaev@gmail.com)
|
* Copyright 2012 - 2016 Anton Tananaev (anton.tananaev@gmail.com)
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -15,22 +15,29 @@
|
|||||||
*/
|
*/
|
||||||
package org.traccar.client;
|
package org.traccar.client;
|
||||||
|
|
||||||
|
import android.Manifest;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.Dialog;
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
|
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
|
||||||
import android.location.LocationManager;
|
import android.content.pm.PackageManager;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.preference.CheckBoxPreference;
|
||||||
|
import android.preference.EditTextPreference;
|
||||||
|
import android.preference.Preference;
|
||||||
import android.preference.PreferenceActivity;
|
import android.preference.PreferenceActivity;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.preference.PreferenceScreen;
|
import android.preference.TwoStatePreference;
|
||||||
import android.telephony.TelephonyManager;
|
import android.util.Patterns;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Random;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public class MainActivity extends PreferenceActivity implements OnSharedPreferenceChangeListener {
|
public class MainActivity extends PreferenceActivity implements OnSharedPreferenceChangeListener {
|
||||||
|
|
||||||
@@ -40,55 +47,137 @@ public class MainActivity extends PreferenceActivity implements OnSharedPreferen
|
|||||||
public static final String KEY_INTERVAL = "interval";
|
public static final String KEY_INTERVAL = "interval";
|
||||||
public static final String KEY_PROVIDER = "provider";
|
public static final String KEY_PROVIDER = "provider";
|
||||||
public static final String KEY_STATUS = "status";
|
public static final String KEY_STATUS = "status";
|
||||||
public static final String KEY_FOREGROUND = "foreground";
|
|
||||||
|
|
||||||
private boolean firstLaunch; // DELME
|
private static final int PERMISSIONS_REQUEST_LOCATION = 2;
|
||||||
|
|
||||||
|
private SharedPreferences sharedPreferences;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
firstLaunch = !PreferenceManager.getDefaultSharedPreferences(this).contains(KEY_PORT);
|
|
||||||
|
if (BuildConfig.HIDDEN_APP) {
|
||||||
|
removeLauncherIcon();
|
||||||
|
}
|
||||||
|
|
||||||
|
sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
addPreferencesFromResource(R.xml.preferences);
|
addPreferencesFromResource(R.xml.preferences);
|
||||||
initPreferences();
|
initPreferences();
|
||||||
|
|
||||||
if (getPreferenceScreen().getSharedPreferences().getBoolean(KEY_STATUS, false)) {
|
findPreference(KEY_DEVICE).setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||||
setPreferencesEnabled(false);
|
@Override
|
||||||
startService(new Intent(this, TrackingService.class));
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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"));
|
||||||
|
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
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
checkAndShowPortDialog(); // DELME
|
sharedPreferences.registerOnSharedPreferenceChangeListener(this);
|
||||||
getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
getPreferenceScreen().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this);
|
sharedPreferences.unregisterOnSharedPreferenceChangeListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setPreferencesEnabled(boolean enabled) {
|
private void setPreferencesEnabled(boolean enabled) {
|
||||||
PreferenceScreen preferenceScreen = getPreferenceScreen();
|
findPreference(KEY_DEVICE).setEnabled(enabled);
|
||||||
preferenceScreen.findPreference(KEY_DEVICE).setEnabled(enabled);
|
findPreference(KEY_ADDRESS).setEnabled(enabled);
|
||||||
preferenceScreen.findPreference(KEY_ADDRESS).setEnabled(enabled);
|
findPreference(KEY_PORT).setEnabled(enabled);
|
||||||
preferenceScreen.findPreference(KEY_PORT).setEnabled(enabled);
|
findPreference(KEY_INTERVAL).setEnabled(enabled);
|
||||||
preferenceScreen.findPreference(KEY_INTERVAL).setEnabled(enabled);
|
findPreference(KEY_PROVIDER).setEnabled(enabled);
|
||||||
preferenceScreen.findPreference(KEY_PROVIDER).setEnabled(enabled);
|
|
||||||
preferenceScreen.findPreference(KEY_FOREGROUND).setEnabled(enabled);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
||||||
if (key.equals(KEY_STATUS)) {
|
if (key.equals(KEY_STATUS)) {
|
||||||
if (sharedPreferences.getBoolean(KEY_STATUS, false)) {
|
if (sharedPreferences.getBoolean(KEY_STATUS, false)) {
|
||||||
setPreferencesEnabled(false);
|
startTrackingService(true, false);
|
||||||
startService(new Intent(this, TrackingService.class));
|
|
||||||
} else {
|
} else {
|
||||||
stopService(new Intent(this, TrackingService.class));
|
stopTrackingService();
|
||||||
setPreferencesEnabled(true);
|
|
||||||
}
|
}
|
||||||
} else if (key.equals(KEY_DEVICE)) {
|
} else if (key.equals(KEY_DEVICE)) {
|
||||||
findPreference(KEY_DEVICE).setSummary(sharedPreferences.getString(KEY_DEVICE, null));
|
findPreference(KEY_DEVICE).setSummary(sharedPreferences.getString(KEY_DEVICE, null));
|
||||||
@@ -106,6 +195,10 @@ public class MainActivity extends PreferenceActivity implements OnSharedPreferen
|
|||||||
if (item.getItemId() == R.id.status) {
|
if (item.getItemId() == R.id.status) {
|
||||||
startActivity(new Intent(this, StatusActivity.class));
|
startActivity(new Intent(this, StatusActivity.class));
|
||||||
return true;
|
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) {
|
} else if (item.getItemId() == R.id.about) {
|
||||||
startActivity(new Intent(this, AboutActivity.class));
|
startActivity(new Intent(this, AboutActivity.class));
|
||||||
return true;
|
return true;
|
||||||
@@ -116,48 +209,57 @@ public class MainActivity extends PreferenceActivity implements OnSharedPreferen
|
|||||||
private void initPreferences() {
|
private void initPreferences() {
|
||||||
PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
|
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_DEVICE)) {
|
if (!sharedPreferences.contains(KEY_DEVICE)) {
|
||||||
|
String id = String.valueOf(new Random().nextInt(900000) + 100000);
|
||||||
sharedPreferences.edit().putString(KEY_DEVICE, id).commit();
|
sharedPreferences.edit().putString(KEY_DEVICE, id).commit();
|
||||||
|
((EditTextPreference) findPreference(KEY_DEVICE)).setText(id);
|
||||||
}
|
}
|
||||||
findPreference(KEY_DEVICE).setSummary(sharedPreferences.getString(KEY_DEVICE, id));
|
findPreference(KEY_DEVICE).setSummary(sharedPreferences.getString(KEY_DEVICE, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
// TEMPORARY PORT CHANGE DIALOG (DELME)
|
private void startTrackingService(boolean checkPermission, boolean permission) {
|
||||||
|
if (checkPermission) {
|
||||||
private void checkAndShowPortDialog() {
|
Set<String> missingPermissions = new HashSet<>();
|
||||||
|
if (!hasPermission(Manifest.permission.ACCESS_FINE_LOCATION)) {
|
||||||
String KEY_SHOWN_PORT_DIALOG = "portDialogHasBeenShown";
|
missingPermissions.add(Manifest.permission.ACCESS_FINE_LOCATION);
|
||||||
|
}
|
||||||
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
if (!hasPermission(Manifest.permission.ACCESS_COARSE_LOCATION)) {
|
||||||
if (!preferences.getString(KEY_PORT, "5055").equals("5055")) {
|
missingPermissions.add(Manifest.permission.ACCESS_COARSE_LOCATION);
|
||||||
if (!firstLaunch) {
|
}
|
||||||
if (!preferences.contains(KEY_SHOWN_PORT_DIALOG)) {
|
if (missingPermissions.isEmpty()) {
|
||||||
showDialog(0);
|
permission = true;
|
||||||
}
|
} else {
|
||||||
|
requestPermissions(missingPermissions.toArray(new String[missingPermissions.size()]), PERMISSIONS_REQUEST_LOCATION);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
preferences.edit().putBoolean(KEY_SHOWN_PORT_DIALOG, true).commit();
|
if (permission) {
|
||||||
|
setPreferencesEnabled(false);
|
||||||
|
startService(new Intent(this, TrackingService.class));
|
||||||
|
} 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() {
|
||||||
|
stopService(new Intent(this, TrackingService.class));
|
||||||
|
setPreferencesEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Dialog onCreateDialog(int id) {
|
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(this)
|
if (requestCode == PERMISSIONS_REQUEST_LOCATION) {
|
||||||
.setMessage("Communication protocol used by the app has changed. Now it uses port 5055 on Traccar server. Do you want to change port to 5055?")
|
startTrackingService(false, grantResults[0] == PackageManager.PERMISSION_GRANTED &&
|
||||||
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
|
(permissions.length < 2 || grantResults[1] == PackageManager.PERMISSION_GRANTED));
|
||||||
@Override
|
}
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
PreferenceManager.getDefaultSharedPreferences(MainActivity.this).edit().putString(KEY_PORT, "5055").commit();
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.setNegativeButton("No", null);
|
|
||||||
|
|
||||||
return builder.create();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,8 +27,7 @@ public class RequestManager {
|
|||||||
private static final int TIMEOUT = 15 * 1000;
|
private static final int TIMEOUT = 15 * 1000;
|
||||||
|
|
||||||
public interface RequestHandler {
|
public interface RequestHandler {
|
||||||
void onSuccess();
|
void onComplete(boolean success);
|
||||||
void onFailure();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class RequestAsyncTask extends AsyncTask<String, Void, Boolean> {
|
private static class RequestAsyncTask extends AsyncTask<String, Void, Boolean> {
|
||||||
@@ -46,11 +45,7 @@ public class RequestManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(Boolean result) {
|
protected void onPostExecute(Boolean result) {
|
||||||
if (result) {
|
handler.onComplete(result);
|
||||||
handler.onSuccess();
|
|
||||||
} else {
|
|
||||||
handler.onFailure();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -17,6 +17,7 @@ package org.traccar.client;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.PowerManager;
|
import android.os.PowerManager;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
@@ -35,6 +36,9 @@ public class TrackingController implements PositionProvider.PositionListener, Ne
|
|||||||
private Handler handler;
|
private Handler handler;
|
||||||
private SharedPreferences preferences;
|
private SharedPreferences preferences;
|
||||||
|
|
||||||
|
private String address;
|
||||||
|
private int port;
|
||||||
|
|
||||||
private PositionProvider positionProvider;
|
private PositionProvider positionProvider;
|
||||||
private DatabaseHelper databaseHelper;
|
private DatabaseHelper databaseHelper;
|
||||||
private NetworkManager networkManager;
|
private NetworkManager networkManager;
|
||||||
@@ -42,7 +46,11 @@ public class TrackingController implements PositionProvider.PositionListener, Ne
|
|||||||
private PowerManager.WakeLock wakeLock;
|
private PowerManager.WakeLock wakeLock;
|
||||||
|
|
||||||
private void lock() {
|
private void lock() {
|
||||||
wakeLock.acquire(WAKE_LOCK_TIMEOUT);
|
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD_MR1) {
|
||||||
|
wakeLock.acquire();
|
||||||
|
} else {
|
||||||
|
wakeLock.acquire(WAKE_LOCK_TIMEOUT);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void unlock() {
|
private void unlock() {
|
||||||
@@ -64,6 +72,9 @@ public class TrackingController implements PositionProvider.PositionListener, Ne
|
|||||||
networkManager = new NetworkManager(context, this);
|
networkManager = new NetworkManager(context, this);
|
||||||
isOnline = networkManager.isOnline();
|
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);
|
PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
|
||||||
wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, getClass().getName());
|
wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, getClass().getName());
|
||||||
}
|
}
|
||||||
@@ -72,26 +83,35 @@ public class TrackingController implements PositionProvider.PositionListener, Ne
|
|||||||
if (isOnline) {
|
if (isOnline) {
|
||||||
read();
|
read();
|
||||||
}
|
}
|
||||||
positionProvider.startUpdates();
|
try {
|
||||||
|
positionProvider.startUpdates();
|
||||||
|
} catch (SecurityException e) {
|
||||||
|
Log.w(TAG, e);
|
||||||
|
}
|
||||||
networkManager.start();
|
networkManager.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stop() {
|
public void stop() {
|
||||||
networkManager.stop();
|
networkManager.stop();
|
||||||
positionProvider.stopUpdates();
|
try {
|
||||||
|
positionProvider.stopUpdates();
|
||||||
|
} catch (SecurityException e) {
|
||||||
|
Log.w(TAG, e);
|
||||||
|
}
|
||||||
handler.removeCallbacksAndMessages(null);
|
handler.removeCallbacksAndMessages(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPositionUpdate(Position position) {
|
public void onPositionUpdate(Position position) {
|
||||||
|
StatusActivity.addMessage(context.getString(R.string.status_location_update));
|
||||||
if (position != null) {
|
if (position != null) {
|
||||||
StatusActivity.addMessage(context.getString(R.string.status_location_update));
|
|
||||||
write(position);
|
write(position);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onNetworkUpdate(boolean isOnline) {
|
public void onNetworkUpdate(boolean isOnline) {
|
||||||
|
StatusActivity.addMessage(context.getString(R.string.status_connectivity_change));
|
||||||
if (!this.isOnline && isOnline) {
|
if (!this.isOnline && isOnline) {
|
||||||
read();
|
read();
|
||||||
}
|
}
|
||||||
@@ -122,18 +142,15 @@ public class TrackingController implements PositionProvider.PositionListener, Ne
|
|||||||
lock();
|
lock();
|
||||||
databaseHelper.insertPositionAsync(position, new DatabaseHelper.DatabaseHandler<Void>() {
|
databaseHelper.insertPositionAsync(position, new DatabaseHelper.DatabaseHandler<Void>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Void result) {
|
public void onComplete(boolean success, Void result) {
|
||||||
if (isOnline && isWaiting) {
|
if (success) {
|
||||||
read();
|
if (isOnline && isWaiting) {
|
||||||
isWaiting = false;
|
read();
|
||||||
|
isWaiting = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
unlock();
|
unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFailure(RuntimeException error) {
|
|
||||||
unlock();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,20 +159,22 @@ public class TrackingController implements PositionProvider.PositionListener, Ne
|
|||||||
lock();
|
lock();
|
||||||
databaseHelper.selectPositionAsync(new DatabaseHelper.DatabaseHandler<Position>() {
|
databaseHelper.selectPositionAsync(new DatabaseHelper.DatabaseHandler<Position>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Position result) {
|
public void onComplete(boolean success, Position result) {
|
||||||
if (result != null) {
|
if (success) {
|
||||||
send(result);
|
if (result != null) {
|
||||||
|
if (result.getDeviceId().equals(preferences.getString(MainActivity.KEY_DEVICE, null))) {
|
||||||
|
send(result);
|
||||||
|
} else {
|
||||||
|
delete(result);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
isWaiting = true;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
isWaiting = true;
|
retry();
|
||||||
}
|
}
|
||||||
unlock();
|
unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFailure(RuntimeException error) {
|
|
||||||
retry();
|
|
||||||
unlock();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,14 +183,12 @@ public class TrackingController implements PositionProvider.PositionListener, Ne
|
|||||||
lock();
|
lock();
|
||||||
databaseHelper.deletePositionAsync(position.getId(), new DatabaseHelper.DatabaseHandler<Void>() {
|
databaseHelper.deletePositionAsync(position.getId(), new DatabaseHelper.DatabaseHandler<Void>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Void result) {
|
public void onComplete(boolean success, Void result) {
|
||||||
read();
|
if (success) {
|
||||||
unlock();
|
read();
|
||||||
}
|
} else {
|
||||||
|
retry();
|
||||||
@Override
|
}
|
||||||
public void onFailure(RuntimeException error) {
|
|
||||||
retry();
|
|
||||||
unlock();
|
unlock();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -180,22 +197,16 @@ public class TrackingController implements PositionProvider.PositionListener, Ne
|
|||||||
private void send(final Position position) {
|
private void send(final Position position) {
|
||||||
log("send", position);
|
log("send", position);
|
||||||
lock();
|
lock();
|
||||||
String request = ProtocolFormatter.formatRequest(
|
String request = ProtocolFormatter.formatRequest(address, port, position);
|
||||||
preferences.getString(MainActivity.KEY_ADDRESS, null),
|
|
||||||
Integer.parseInt(preferences.getString(MainActivity.KEY_PORT, null)),
|
|
||||||
position);
|
|
||||||
|
|
||||||
RequestManager.sendRequestAsync(request, new RequestManager.RequestHandler() {
|
RequestManager.sendRequestAsync(request, new RequestManager.RequestHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess() {
|
public void onComplete(boolean success) {
|
||||||
delete(position);
|
if (success) {
|
||||||
unlock();
|
delete(position);
|
||||||
}
|
} else {
|
||||||
|
StatusActivity.addMessage(context.getString(R.string.status_send_fail));
|
||||||
@Override
|
retry();
|
||||||
public void onFailure() {
|
}
|
||||||
StatusActivity.addMessage(context.getString(R.string.status_send_fail));
|
|
||||||
retry();
|
|
||||||
unlock();
|
unlock();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -19,12 +19,16 @@ import android.annotation.TargetApi;
|
|||||||
import android.app.Notification;
|
import android.app.Notification;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
import android.app.Service;
|
import android.app.Service;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
public class TrackingService extends Service {
|
public class TrackingService extends Service {
|
||||||
|
|
||||||
private static final String TAG = TrackingService.class.getSimpleName();
|
private static final String TAG = TrackingService.class.getSimpleName();
|
||||||
@@ -32,7 +36,49 @@ public class TrackingService extends Service {
|
|||||||
|
|
||||||
private TrackingController trackingController;
|
private TrackingController trackingController;
|
||||||
|
|
||||||
private boolean foreground;
|
@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
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
@@ -42,7 +88,10 @@ public class TrackingService extends Service {
|
|||||||
trackingController = new TrackingController(this);
|
trackingController = new TrackingController(this);
|
||||||
trackingController.start();
|
trackingController.start();
|
||||||
|
|
||||||
foreground = PreferenceManager.getDefaultSharedPreferences(this).getBoolean(MainActivity.KEY_FOREGROUND, false);
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ECLAIR) {
|
||||||
|
startForeground(NOTIFICATION_ID, createNotification(this));
|
||||||
|
startService(new Intent(this, HideNotificationService.class));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -56,17 +105,6 @@ public class TrackingService extends Service {
|
|||||||
if (intent != null) {
|
if (intent != null) {
|
||||||
AutostartReceiver.completeWakefulIntent(intent);
|
AutostartReceiver.completeWakefulIntent(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ECLAIR && foreground) {
|
|
||||||
Intent notificationIntent = new Intent(this, MainActivity.class);
|
|
||||||
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
|
|
||||||
|
|
||||||
Notification notification = new Notification(android.R.drawable.stat_notify_sync_noanim, null, 0);
|
|
||||||
notification.setLatestEventInfo(
|
|
||||||
this, getString(R.string.app_name), getString(R.string.settings_status_on_summary), pendingIntent);
|
|
||||||
|
|
||||||
startForeground(NOTIFICATION_ID, notification);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@TargetApi(Build.VERSION_CODES.ECLAIR)
|
@TargetApi(Build.VERSION_CODES.ECLAIR)
|
||||||
@@ -81,7 +119,7 @@ public class TrackingService extends Service {
|
|||||||
Log.i(TAG, "service destroy");
|
Log.i(TAG, "service destroy");
|
||||||
StatusActivity.addMessage(getString(R.string.status_service_destroy));
|
StatusActivity.addMessage(getString(R.string.status_service_destroy));
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ECLAIR && foreground) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ECLAIR) {
|
||||||
stopForeground(true);
|
stopForeground(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
|
До Ширина: | Высота: | Размер: 3.5 KiB |
|
После Ширина: | Высота: | Размер: 3.6 KiB |
|
До Ширина: | Высота: | Размер: 1.7 KiB |
|
До Ширина: | Высота: | Размер: 2.2 KiB |
|
После Ширина: | Высота: | Размер: 2.4 KiB |
|
До Ширина: | Высота: | Размер: 4.8 KiB |
|
После Ширина: | Высота: | Размер: 4.8 KiB |
|
До Ширина: | Высота: | Размер: 7.4 KiB |
|
После Ширина: | Высота: | Размер: 7.2 KiB |
|
До Ширина: | Высота: | Размер: 10 KiB |
@@ -13,7 +13,7 @@
|
|||||||
android:layout_marginLeft="@dimen/about_margin"
|
android:layout_marginLeft="@dimen/about_margin"
|
||||||
android:layout_marginStart="@dimen/about_margin"
|
android:layout_marginStart="@dimen/about_margin"
|
||||||
android:layout_marginTop="@dimen/about_margin"
|
android:layout_marginTop="@dimen/about_margin"
|
||||||
android:src="@drawable/ic_launcher"
|
android:src="@drawable/logo"
|
||||||
android:contentDescription="@string/app_logo" />
|
android:contentDescription="@string/app_logo" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
|||||||
@@ -6,9 +6,14 @@
|
|||||||
android:title="@string/menu_status"
|
android:title="@string/menu_status"
|
||||||
android:showAsAction="always" />
|
android:showAsAction="always" />
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/shortcuts"
|
||||||
|
android:title="@string/menu_shortcuts"
|
||||||
|
android:showAsAction="never" />
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/about"
|
android:id="@+id/about"
|
||||||
android:title="@string/menu_about"
|
android:title="@string/menu_about"
|
||||||
android:showAsAction="ifRoom" />
|
android:showAsAction="never" />
|
||||||
|
|
||||||
</menu>
|
</menu>
|
||||||
|
|||||||
@@ -36,7 +36,7 @@
|
|||||||
|
|
||||||
<string name="status_service_create">Servicio creado</string>
|
<string name="status_service_create">Servicio creado</string>
|
||||||
<string name="status_service_destroy">Servicio destruído</string>
|
<string name="status_service_destroy">Servicio destruído</string>
|
||||||
<string name="status_send_fail">Erro en el envío</string>
|
<string name="status_send_fail">Error en el envío</string>
|
||||||
<string name="status_location_update">Posición actualizada</string>
|
<string name="status_location_update">Posición actualizada</string>
|
||||||
<string name="status_connectivity_change">Cambio conectividad</string>
|
<string name="status_connectivity_change">Cambio conectividad</string>
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
<?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-array name="settings_provider_names">
|
||||||
|
<item>GPS provider</item>
|
||||||
|
<item>Network provider</item>
|
||||||
|
<item>Mixed provider</item>
|
||||||
|
</string-array>
|
||||||
|
<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>
|
||||||
@@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
<string name="app_name">Traccar Client</string>
|
<string name="app_name">Traccar Client</string>
|
||||||
<string name="app_logo">Traccar</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_id_title">Device identifier</string>
|
||||||
<string name="settings_address_title">Server address</string>
|
<string name="settings_address_title">Server address</string>
|
||||||
@@ -28,6 +30,7 @@
|
|||||||
|
|
||||||
<string name="menu_status">Status</string>
|
<string name="menu_status">Status</string>
|
||||||
<string name="menu_about">About</string>
|
<string name="menu_about">About</string>
|
||||||
|
<string name="menu_shortcuts">Add shortcuts</string>
|
||||||
<string name="menu_clear">Clear</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_description">Real time GPS tracker for Android devices. Compatible with Traccar Server and other tracking systems.</string>
|
||||||
@@ -40,4 +43,7 @@
|
|||||||
<string name="status_location_update">Location update</string>
|
<string name="status_location_update">Location update</string>
|
||||||
<string name="status_connectivity_change">Connectivity change</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>
|
</resources>
|
||||||
|
|||||||
@@ -42,10 +42,4 @@
|
|||||||
android:summary="@string/settings_provider_summary"
|
android:summary="@string/settings_provider_summary"
|
||||||
android:title="@string/settings_provider_title" />
|
android:title="@string/settings_provider_title" />
|
||||||
|
|
||||||
<CheckBoxPreference
|
|
||||||
android:defaultValue="true"
|
|
||||||
android:key="foreground"
|
|
||||||
android:summary="@string/settings_foreground_summary"
|
|
||||||
android:title="@string/settings_foreground_title" />
|
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
@@ -40,10 +40,4 @@
|
|||||||
android:summary="@string/settings_provider_summary"
|
android:summary="@string/settings_provider_summary"
|
||||||
android:title="@string/settings_provider_title" />
|
android:title="@string/settings_provider_title" />
|
||||||
|
|
||||||
<CheckBoxPreference
|
|
||||||
android:defaultValue="true"
|
|
||||||
android:key="foreground"
|
|
||||||
android:summary="@string/settings_foreground_summary"
|
|
||||||
android:title="@string/settings_foreground_title" />
|
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
|||||||
|
После Ширина: | Высота: | Размер: 3.3 KiB |
|
После Ширина: | Высота: | Размер: 2.0 KiB |
|
После Ширина: | Высота: | Размер: 4.7 KiB |
|
После Ширина: | Высота: | Размер: 7.5 KiB |
|
После Ширина: | Высота: | Размер: 11 KiB |