Сравнить коммиты
| Автор | SHA1 | Дата | |
|---|---|---|---|
|
|
088adcaa24 | ||
|
|
0365837e4d | ||
|
|
f952e16c00 | ||
|
|
b7fb6445ef | ||
|
|
bc3f47e296 | ||
|
|
c60f749a67 | ||
|
|
821f24ce2b | ||
|
|
62c713e97a | ||
|
|
ab587d465e | ||
|
|
f82e89409d | ||
|
|
7e6d4f5822 | ||
|
|
b8a099189e | ||
|
|
e961df85d5 | ||
|
|
44648cf142 | ||
|
|
d916bf432e |
@@ -2,13 +2,13 @@ apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
compileSdkVersion 23
|
||||
buildToolsVersion '23.0.1'
|
||||
buildToolsVersion '23.0.2'
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion 3
|
||||
targetSdkVersion 23
|
||||
versionCode 26
|
||||
versionName '3.6'
|
||||
versionCode 29
|
||||
versionName '3.9'
|
||||
}
|
||||
|
||||
signingConfigs {
|
||||
@@ -22,9 +22,11 @@ android {
|
||||
|
||||
productFlavors {
|
||||
regular {
|
||||
applicationId "org.traccar.client"
|
||||
buildConfigField "boolean", "HIDDEN_APP", "false"
|
||||
}
|
||||
hidden {
|
||||
applicationId "org.traccar.client.hidden"
|
||||
buildConfigField "boolean", "HIDDEN_APP", "true"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
android:label="@string/hidden_app_name"
|
||||
tools:replace="label">
|
||||
|
||||
<receiver android:name=".DialLaunchReceiver" >
|
||||
<receiver android:name="org.traccar.client.DialLaunchReceiver" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.NEW_OUTGOING_CALL" />
|
||||
</intent-filter>
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
<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"
|
||||
@@ -30,6 +31,13 @@
|
||||
|
||||
<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" />
|
||||
|
||||
@@ -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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,24 +17,20 @@ package org.traccar.client;
|
||||
|
||||
import android.Manifest;
|
||||
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.SharedPreferences;
|
||||
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.location.LocationManager;
|
||||
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.PreferenceScreen;
|
||||
import android.preference.TwoStatePreference;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.util.Patterns;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
|
||||
@@ -68,13 +64,59 @@ public class MainActivity extends PreferenceActivity implements OnSharedPreferen
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
private void removeLauncherIcon() {
|
||||
ComponentName componentName = new ComponentName(getPackageName(), getPackageName() + ".Launcher");
|
||||
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(
|
||||
@@ -88,6 +130,20 @@ public class MainActivity extends PreferenceActivity implements OnSharedPreferen
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
@@ -108,12 +164,11 @@ public class MainActivity extends PreferenceActivity implements OnSharedPreferen
|
||||
}
|
||||
|
||||
private void setPreferencesEnabled(boolean enabled) {
|
||||
PreferenceScreen preferenceScreen = getPreferenceScreen();
|
||||
preferenceScreen.findPreference(KEY_DEVICE).setEnabled(enabled);
|
||||
preferenceScreen.findPreference(KEY_ADDRESS).setEnabled(enabled);
|
||||
preferenceScreen.findPreference(KEY_PORT).setEnabled(enabled);
|
||||
preferenceScreen.findPreference(KEY_INTERVAL).setEnabled(enabled);
|
||||
preferenceScreen.findPreference(KEY_PROVIDER).setEnabled(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
|
||||
@@ -140,6 +195,10 @@ public class MainActivity extends PreferenceActivity implements OnSharedPreferen
|
||||
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;
|
||||
@@ -160,7 +219,7 @@ public class MainActivity extends PreferenceActivity implements OnSharedPreferen
|
||||
|
||||
private void startTrackingService(boolean checkPermission, boolean permission) {
|
||||
if (checkPermission) {
|
||||
Set<String> missingPermissions = new HashSet<String>();
|
||||
Set<String> missingPermissions = new HashSet<>();
|
||||
if (!hasPermission(Manifest.permission.ACCESS_FINE_LOCATION)) {
|
||||
missingPermissions.add(Manifest.permission.ACCESS_FINE_LOCATION);
|
||||
}
|
||||
|
||||
@@ -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.SharedPreferences;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.os.PowerManager;
|
||||
import android.preference.PreferenceManager;
|
||||
@@ -33,6 +34,7 @@ public class TrackingController implements PositionProvider.PositionListener, Ne
|
||||
|
||||
private Context context;
|
||||
private Handler handler;
|
||||
private SharedPreferences preferences;
|
||||
|
||||
private String address;
|
||||
private int port;
|
||||
@@ -44,7 +46,11 @@ public class TrackingController implements PositionProvider.PositionListener, Ne
|
||||
private PowerManager.WakeLock wakeLock;
|
||||
|
||||
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() {
|
||||
@@ -56,7 +62,7 @@ public class TrackingController implements PositionProvider.PositionListener, Ne
|
||||
public TrackingController(Context context) {
|
||||
this.context = context;
|
||||
handler = new Handler();
|
||||
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
preferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
if (preferences.getString(MainActivity.KEY_PROVIDER, null).equals("mixed")) {
|
||||
positionProvider = new MixedPositionProvider(context, this);
|
||||
} else {
|
||||
@@ -77,13 +83,21 @@ public class TrackingController implements PositionProvider.PositionListener, Ne
|
||||
if (isOnline) {
|
||||
read();
|
||||
}
|
||||
positionProvider.startUpdates();
|
||||
try {
|
||||
positionProvider.startUpdates();
|
||||
} catch (SecurityException e) {
|
||||
Log.w(TAG, e);
|
||||
}
|
||||
networkManager.start();
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
networkManager.stop();
|
||||
positionProvider.stopUpdates();
|
||||
try {
|
||||
positionProvider.stopUpdates();
|
||||
} catch (SecurityException e) {
|
||||
Log.w(TAG, e);
|
||||
}
|
||||
handler.removeCallbacksAndMessages(null);
|
||||
}
|
||||
|
||||
@@ -148,7 +162,11 @@ public class TrackingController implements PositionProvider.PositionListener, Ne
|
||||
public void onComplete(boolean success, Position result) {
|
||||
if (success) {
|
||||
if (result != null) {
|
||||
send(result);
|
||||
if (result.getDeviceId().equals(preferences.getString(MainActivity.KEY_DEVICE, null))) {
|
||||
send(result);
|
||||
} else {
|
||||
delete(result);
|
||||
}
|
||||
} else {
|
||||
isWaiting = true;
|
||||
}
|
||||
|
||||
|
После Ширина: | Высота: | Размер: 3.6 KiB |
|
После Ширина: | Высота: | Размер: 2.4 KiB |
|
После Ширина: | Высота: | Размер: 4.8 KiB |
|
После Ширина: | Высота: | Размер: 7.2 KiB |
@@ -13,7 +13,7 @@
|
||||
android:layout_marginLeft="@dimen/about_margin"
|
||||
android:layout_marginStart="@dimen/about_margin"
|
||||
android:layout_marginTop="@dimen/about_margin"
|
||||
android:src="@mipmap/ic_launcher"
|
||||
android:src="@drawable/logo"
|
||||
android:contentDescription="@string/app_logo" />
|
||||
|
||||
<LinearLayout
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
|
||||
<string name="status_service_create">Servicio creado</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_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_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>
|
||||
@@ -28,6 +30,7 @@
|
||||
|
||||
<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>
|
||||
|
||||
|
До Ширина: | Высота: | Размер: 3.5 KiB После Ширина: | Высота: | Размер: 3.3 KiB |
|
До Ширина: | Высота: | Размер: 2.2 KiB После Ширина: | Высота: | Размер: 2.0 KiB |
|
До Ширина: | Высота: | Размер: 4.8 KiB После Ширина: | Высота: | Размер: 4.7 KiB |
|
До Ширина: | Высота: | Размер: 7.4 KiB После Ширина: | Высота: | Размер: 7.5 KiB |
|
До Ширина: | Высота: | Размер: 10 KiB После Ширина: | Высота: | Размер: 11 KiB |