Сравнить коммиты
| Автор | SHA1 | Дата | |
|---|---|---|---|
|
|
1cb5326e07 | ||
|
|
28befc6180 | ||
|
|
e83ef80fa3 | ||
|
|
b26a1bd133 | ||
|
|
0bbee716a6 | ||
|
|
52e3b839ae | ||
|
|
cfe04eb0a6 | ||
|
|
c243912c55 | ||
|
|
914a157afc | ||
|
|
454ce6be21 | ||
|
|
e8a1e015d4 | ||
|
|
ceb15c1378 | ||
|
|
d25c745013 | ||
|
|
c24df5b246 | ||
|
|
283d0467b4 | ||
|
|
83bf1daa84 | ||
|
|
96d61c4c66 | ||
|
|
3978a3d8d6 | ||
|
|
78018c3038 | ||
|
|
19b7c4da21 | ||
|
|
a3d43294ce | ||
|
|
330dc27f0f | ||
|
|
f052be83c3 | ||
|
|
c77d4b477b | ||
|
|
eb7de9eb98 | ||
|
|
3a786b14b7 | ||
|
|
6bad9786ec | ||
|
|
259aaf2000 |
@@ -0,0 +1 @@
|
||||
custom: https://www.traccar.org/donate/
|
||||
@@ -1,7 +0,0 @@
|
||||
<!--
|
||||
|
||||
Do you want to ask a question? Traccar official forum is the best place for getting support:
|
||||
|
||||
https://www.traccar.org/forums/
|
||||
|
||||
-->
|
||||
@@ -0,0 +1,38 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**To Reproduce**
|
||||
Steps to reproduce the behavior:
|
||||
1. Go to '...'
|
||||
2. Click on '....'
|
||||
3. Scroll down to '....'
|
||||
4. See error
|
||||
|
||||
**Expected behavior**
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
**Screenshots**
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
**Desktop (please complete the following information):**
|
||||
- OS: [e.g. iOS]
|
||||
- Browser [e.g. chrome, safari]
|
||||
- Version [e.g. 22]
|
||||
|
||||
**Smartphone (please complete the following information):**
|
||||
- Device: [e.g. iPhone6]
|
||||
- OS: [e.g. iOS8.1]
|
||||
- Browser [e.g. stock browser, safari]
|
||||
- Version [e.g. 22]
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here.
|
||||
@@ -0,0 +1,20 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
**Describe the solution you'd like**
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
**Describe alternatives you've considered**
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
**Additional context**
|
||||
Add any other context or screenshots about the feature request here.
|
||||
+34
-19
@@ -1,28 +1,40 @@
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
compileSdkVersion 29
|
||||
compileSdkVersion 30
|
||||
|
||||
defaultConfig {
|
||||
applicationId "org.traccar.client"
|
||||
buildConfigField "boolean", "HIDDEN_APP", "false"
|
||||
applicationId 'org.traccar.client'
|
||||
buildConfigField 'boolean', 'HIDDEN_APP', 'false'
|
||||
minSdkVersion 16
|
||||
targetSdkVersion 29
|
||||
versionCode 62
|
||||
versionName '6.1'
|
||||
targetSdkVersion 30
|
||||
versionCode 68
|
||||
versionName '6.7'
|
||||
multiDexEnabled true
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
packagingOptions {
|
||||
exclude 'META-INF/DEPENDENCIES'
|
||||
}
|
||||
|
||||
lintOptions {
|
||||
checkReleaseBuilds false
|
||||
}
|
||||
|
||||
flavorDimensions "default"
|
||||
flavorDimensions 'default'
|
||||
productFlavors {
|
||||
regular
|
||||
regular {
|
||||
isDefault = true
|
||||
}
|
||||
google
|
||||
hidden {
|
||||
applicationId "org.traccar.client.hidden"
|
||||
buildConfigField "boolean", "HIDDEN_APP", "true"
|
||||
applicationId 'org.traccar.client.hidden'
|
||||
buildConfigField 'boolean', 'HIDDEN_APP', 'true'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,21 +46,24 @@ android {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.google.android.material:material:1.1.0-alpha10'
|
||||
implementation 'androidx.preference:preference:1.1.0'
|
||||
testImplementation 'junit:junit:4.12'
|
||||
implementation 'com.google.android.material:material:1.3.0-alpha03'
|
||||
implementation 'androidx.multidex:multidex:2.0.1'
|
||||
implementation 'androidx.preference:preference:1.1.1'
|
||||
testImplementation 'junit:junit:4.13'
|
||||
testImplementation 'org.robolectric:robolectric:4.1'
|
||||
googleImplementation 'com.google.firebase:firebase-core:17.2.0'
|
||||
googleImplementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
|
||||
googleImplementation "com.google.android.gms:play-services-location:17.0.0"
|
||||
googleImplementation 'com.google.firebase:firebase-core:17.5.0'
|
||||
googleImplementation 'com.google.firebase:firebase-crashlytics-gradle:2.3.0'
|
||||
googleImplementation 'com.google.firebase:firebase-analytics:17.5.0'
|
||||
googleImplementation 'com.google.android.gms:play-services-location:17.1.0'
|
||||
googleImplementation 'com.google.android.play:core:1.8.2'
|
||||
}
|
||||
|
||||
if (getGradle().getStartParameter().getTaskRequests().toString().contains("Google")) {
|
||||
if (getGradle().getStartParameter().getTaskRequests().toString().contains('Google')) {
|
||||
apply plugin: 'com.google.gms.google-services'
|
||||
apply plugin: 'io.fabric'
|
||||
apply plugin: 'com.google.firebase.crashlytics'
|
||||
|
||||
task copyJson(type: Copy) {
|
||||
from '../../traccar-shared/google-services'
|
||||
from '../../environment/google-services'
|
||||
into '.'
|
||||
include 'traccar-client-android.json'
|
||||
rename('traccar-client-android.json', 'google-services.json')
|
||||
|
||||
@@ -15,16 +15,55 @@
|
||||
*/
|
||||
package org.traccar.client;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Build;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import com.google.android.play.core.review.ReviewManager;
|
||||
import com.google.android.play.core.review.ReviewManagerFactory;
|
||||
import com.google.android.play.core.tasks.Task;
|
||||
import com.google.firebase.analytics.FirebaseAnalytics;
|
||||
|
||||
public class GoogleMainApplication extends MainApplication {
|
||||
|
||||
private static final String KEY_RATING_SHOWN = "ratingShown";
|
||||
private static final long RATING_THRESHOLD = -24 * 60 * 60 * 1000L;
|
||||
|
||||
private FirebaseAnalytics firebaseAnalytics;
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
firebaseAnalytics = FirebaseAnalytics.getInstance(this);
|
||||
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.addAction(TrackingService.ACTION_STARTED);
|
||||
filter.addAction(TrackingService.ACTION_STOPPED);
|
||||
registerReceiver(new ServiceReceiver(), filter);
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP_MR1)
|
||||
@Override
|
||||
public void handleRatingFlow(@NonNull Activity activity) {
|
||||
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
boolean ratingShown = preferences.getBoolean(KEY_RATING_SHOWN, false);
|
||||
long totalDuration = preferences.getLong(ServiceReceiver.KEY_DURATION, 0);
|
||||
if (!ratingShown && totalDuration > RATING_THRESHOLD) {
|
||||
ReviewManager reviewManager = ReviewManagerFactory.create(activity);
|
||||
reviewManager.requestReviewFlow().addOnCompleteListener(infoTask -> {
|
||||
if (infoTask.isSuccessful()) {
|
||||
Task<Void> flow = reviewManager.launchReviewFlow(activity, infoTask.getResult());
|
||||
flow.addOnCompleteListener(flowTask -> {
|
||||
preferences.edit().putBoolean(KEY_RATING_SHOWN, true).apply();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright 2020 Anton Tananaev (anton@traccar.org)
|
||||
*
|
||||
* 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.SharedPreferences;
|
||||
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
public class ServiceReceiver extends BroadcastReceiver {
|
||||
|
||||
public static final String KEY_DURATION = "serviceTime";
|
||||
|
||||
private static long startTime = 0;
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (TrackingService.ACTION_STARTED.equals(intent.getAction())) {
|
||||
startTime = System.currentTimeMillis();
|
||||
} else {
|
||||
if (startTime > 0) {
|
||||
updateTime(context, System.currentTimeMillis() - startTime);
|
||||
startTime = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateTime(Context context, long duration) {
|
||||
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
long totalDuration = preferences.getLong(KEY_DURATION, 0);
|
||||
preferences.edit().putLong(KEY_DURATION, totalDuration + duration).apply();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,7 +6,6 @@
|
||||
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_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" />
|
||||
|
||||
Двоичные данные
Двоичный файл не отображается.
|
До Ширина: | Высота: | Размер: 48 KiB После Ширина: | Высота: | Размер: 26 KiB |
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2017 Anton Tananaev (anton@traccar.org)
|
||||
* Copyright 2017 - 2020 Anton Tananaev (anton@traccar.org)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -24,9 +24,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (savedInstanceState == null) {
|
||||
getSupportFragmentManager().beginTransaction().replace(android.R.id.content, new MainFragment()).commit();
|
||||
}
|
||||
setContentView(R.layout.main);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016 - 2017 Anton Tananaev (anton@traccar.org)
|
||||
* Copyright 2016 - 2020 Anton Tananaev (anton@traccar.org)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,7 +16,7 @@
|
||||
package org.traccar.client;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Application;
|
||||
import android.app.Activity;
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
@@ -27,7 +27,10 @@ import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
public class MainApplication extends Application {
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.multidex.MultiDexApplication;
|
||||
|
||||
public class MainApplication extends MultiDexApplication {
|
||||
|
||||
public static final String PRIMARY_CHANNEL = "default";
|
||||
|
||||
@@ -46,7 +49,7 @@ public class MainApplication extends Application {
|
||||
@TargetApi(Build.VERSION_CODES.O)
|
||||
private void registerChannel() {
|
||||
NotificationChannel channel = new NotificationChannel(
|
||||
PRIMARY_CHANNEL, getString(R.string.channel_default), NotificationManager.IMPORTANCE_MIN);
|
||||
PRIMARY_CHANNEL, getString(R.string.channel_default), NotificationManager.IMPORTANCE_LOW);
|
||||
channel.setLightColor(Color.GREEN);
|
||||
channel.setLockscreenVisibility(Notification.VISIBILITY_SECRET);
|
||||
((NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE)).createNotificationChannel(channel);
|
||||
@@ -70,4 +73,7 @@ public class MainApplication extends Application {
|
||||
}
|
||||
}
|
||||
|
||||
public void handleRatingFlow(@NonNull Activity activity) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012 - 2019 Anton Tananaev (anton@traccar.org)
|
||||
* Copyright 2012 - 2020 Anton Tananaev (anton@traccar.org)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -27,22 +27,29 @@ import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.text.InputType;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.webkit.URLUtil;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.preference.EditTextPreference;
|
||||
import androidx.preference.EditTextPreferenceDialogFragmentCompat;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceFragmentCompat;
|
||||
import androidx.preference.PreferenceManager;
|
||||
import androidx.preference.TwoStatePreference;
|
||||
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.webkit.URLUtil;
|
||||
import android.widget.Toast;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
@@ -60,8 +67,11 @@ public class MainFragment extends PreferenceFragmentCompat implements OnSharedPr
|
||||
public static final String KEY_ANGLE = "angle";
|
||||
public static final String KEY_ACCURACY = "accuracy";
|
||||
public static final String KEY_STATUS = "status";
|
||||
public static final String KEY_BUFFER = "buffer";
|
||||
public static final String KEY_WAKELOCK = "wakelock";
|
||||
|
||||
private static final int PERMISSIONS_REQUEST_LOCATION = 2;
|
||||
private static final String KEY_DISCLOSURE_SHOWN = "disclosureShown";
|
||||
|
||||
private SharedPreferences sharedPreferences;
|
||||
|
||||
@@ -70,6 +80,7 @@ public class MainFragment extends PreferenceFragmentCompat implements OnSharedPr
|
||||
|
||||
@Override
|
||||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||
|
||||
if (BuildConfig.HIDDEN_APP && Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
|
||||
removeLauncherIcon();
|
||||
}
|
||||
@@ -77,7 +88,7 @@ public class MainFragment extends PreferenceFragmentCompat implements OnSharedPr
|
||||
setHasOptionsMenu(true);
|
||||
|
||||
sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
addPreferencesFromResource(R.xml.preferences);
|
||||
setPreferencesFromResource(R.xml.preferences, rootKey);
|
||||
initPreferences();
|
||||
|
||||
findPreference(KEY_DEVICE).setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@@ -134,6 +145,36 @@ public class MainFragment extends PreferenceFragmentCompat implements OnSharedPr
|
||||
|
||||
}
|
||||
|
||||
public static class NumericEditTextPreferenceDialogFragment extends EditTextPreferenceDialogFragmentCompat {
|
||||
|
||||
public static NumericEditTextPreferenceDialogFragment newInstance(String key) {
|
||||
final NumericEditTextPreferenceDialogFragment fragment = new NumericEditTextPreferenceDialogFragment();
|
||||
final Bundle bundle = new Bundle();
|
||||
bundle.putString(ARG_KEY, key);
|
||||
fragment.setArguments(bundle);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onBindDialogView(View view) {
|
||||
EditText editText = view.findViewById(android.R.id.edit);
|
||||
editText.setInputType(InputType.TYPE_CLASS_NUMBER);
|
||||
super.onBindDialogView(view);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisplayPreferenceDialog(Preference preference) {
|
||||
if (Arrays.asList(KEY_INTERVAL, KEY_DISTANCE, KEY_ANGLE).contains(preference.getKey())) {
|
||||
final EditTextPreferenceDialogFragmentCompat f = NumericEditTextPreferenceDialogFragment.newInstance(preference.getKey());
|
||||
f.setTargetFragment(this, 0);
|
||||
f.show(getFragmentManager(), "androidx.preference.PreferenceFragment.DIALOG");
|
||||
} else {
|
||||
super.onDisplayPreferenceDialog(preference);
|
||||
}
|
||||
}
|
||||
|
||||
private void removeLauncherIcon() {
|
||||
String className = MainActivity.class.getCanonicalName().replace(".MainActivity", ".Launcher");
|
||||
ComponentName componentName = new ComponentName(getActivity().getPackageName(), className);
|
||||
@@ -154,6 +195,17 @@ public class MainFragment extends PreferenceFragmentCompat implements OnSharedPr
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
sharedPreferences.registerOnSharedPreferenceChangeListener(this);
|
||||
|
||||
if (!sharedPreferences.getBoolean(KEY_DISCLOSURE_SHOWN, false)) {
|
||||
Snackbar.make(getView(), R.string.disclosure_location, Snackbar.LENGTH_INDEFINITE)
|
||||
.addCallback(new Snackbar.Callback() {
|
||||
@Override
|
||||
public void onDismissed(Snackbar transientBottomBar, int event) {
|
||||
sharedPreferences.edit().putBoolean(KEY_DISCLOSURE_SHOWN, true).apply();
|
||||
}
|
||||
})
|
||||
.show();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -169,6 +221,8 @@ public class MainFragment extends PreferenceFragmentCompat implements OnSharedPr
|
||||
findPreference(KEY_DISTANCE).setEnabled(enabled);
|
||||
findPreference(KEY_ANGLE).setEnabled(enabled);
|
||||
findPreference(KEY_ACCURACY).setEnabled(enabled);
|
||||
findPreference(KEY_BUFFER).setEnabled(enabled);
|
||||
findPreference(KEY_WAKELOCK).setEnabled(enabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -179,6 +233,7 @@ public class MainFragment extends PreferenceFragmentCompat implements OnSharedPr
|
||||
} else {
|
||||
stopTrackingService();
|
||||
}
|
||||
((MainApplication) getActivity().getApplication()).handleRatingFlow(getActivity());
|
||||
} else if (key.equals(KEY_DEVICE)) {
|
||||
findPreference(KEY_DEVICE).setSummary(sharedPreferences.getString(KEY_DEVICE, null));
|
||||
}
|
||||
@@ -216,10 +271,6 @@ public class MainFragment extends PreferenceFragmentCompat implements OnSharedPr
|
||||
if (ContextCompat.checkSelfPermission(getContext(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
||||
requiredPermissions.add(Manifest.permission.ACCESS_FINE_LOCATION);
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q
|
||||
&& ContextCompat.checkSelfPermission(getContext(), Manifest.permission.ACCESS_BACKGROUND_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
||||
requiredPermissions.add(Manifest.permission.ACCESS_BACKGROUND_LOCATION);
|
||||
}
|
||||
permission = requiredPermissions.isEmpty();
|
||||
if (!permission) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
|
||||
@@ -25,7 +25,6 @@ public class TrackingController implements PositionProvider.PositionListener, Ne
|
||||
|
||||
private static final String TAG = TrackingController.class.getSimpleName();
|
||||
private static final int RETRY_DELAY = 30 * 1000;
|
||||
private static final int WAKE_LOCK_TIMEOUT = 120 * 1000;
|
||||
|
||||
private boolean isOnline;
|
||||
private boolean isWaiting;
|
||||
@@ -35,6 +34,7 @@ public class TrackingController implements PositionProvider.PositionListener, Ne
|
||||
private SharedPreferences preferences;
|
||||
|
||||
private String url;
|
||||
private boolean buffer;
|
||||
|
||||
private PositionProvider positionProvider;
|
||||
private DatabaseHelper databaseHelper;
|
||||
@@ -50,6 +50,7 @@ public class TrackingController implements PositionProvider.PositionListener, Ne
|
||||
isOnline = networkManager.isOnline();
|
||||
|
||||
url = preferences.getString(MainFragment.KEY_URL, context.getString(R.string.settings_url_default_value));
|
||||
buffer = preferences.getBoolean(MainFragment.KEY_BUFFER, true);
|
||||
}
|
||||
|
||||
public void start() {
|
||||
@@ -78,7 +79,11 @@ public class TrackingController implements PositionProvider.PositionListener, Ne
|
||||
public void onPositionUpdate(Position position) {
|
||||
StatusActivity.addMessage(context.getString(R.string.status_location_update));
|
||||
if (position != null) {
|
||||
if (buffer) {
|
||||
write(position);
|
||||
} else {
|
||||
send(position);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,12 +178,16 @@ public class TrackingController implements PositionProvider.PositionListener, Ne
|
||||
@Override
|
||||
public void onComplete(boolean success) {
|
||||
if (success) {
|
||||
if (buffer) {
|
||||
delete(position);
|
||||
}
|
||||
} else {
|
||||
StatusActivity.addMessage(context.getString(R.string.status_send_fail));
|
||||
if (buffer) {
|
||||
retry();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012 - 2019 Anton Tananaev (anton@traccar.org)
|
||||
* Copyright 2012 - 2020 Anton Tananaev (anton@traccar.org)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -29,10 +29,14 @@ import androidx.core.app.NotificationCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import android.os.PowerManager;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
|
||||
public class TrackingService extends Service {
|
||||
|
||||
public static final String ACTION_STARTED = "org.traccar.action.SERVICE_STARTED";
|
||||
public static final String ACTION_STOPPED = "org.traccar.action.SERVICE_STOPPED";
|
||||
|
||||
private static final String TAG = TrackingService.class.getSimpleName();
|
||||
private static final int NOTIFICATION_ID = 1;
|
||||
|
||||
@@ -81,15 +85,18 @@ public class TrackingService extends Service {
|
||||
@Override
|
||||
public void onCreate() {
|
||||
Log.i(TAG, "service create");
|
||||
sendBroadcast(new Intent(ACTION_STARTED));
|
||||
StatusActivity.addMessage(getString(R.string.status_service_create));
|
||||
|
||||
startForeground(NOTIFICATION_ID, createNotification(this));
|
||||
|
||||
if (ContextCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
|
||||
|
||||
if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean(MainFragment.KEY_WAKELOCK, true)) {
|
||||
PowerManager powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
|
||||
wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, getClass().getName());
|
||||
wakeLock.acquire();
|
||||
}
|
||||
|
||||
trackingController = new TrackingController(this);
|
||||
trackingController.start();
|
||||
@@ -117,6 +124,7 @@ public class TrackingService extends Service {
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
Log.i(TAG, "service destroy");
|
||||
sendBroadcast(new Intent(ACTION_STOPPED));
|
||||
StatusActivity.addMessage(getString(R.string.status_service_destroy));
|
||||
|
||||
stopForeground(true);
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/fragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:name="org.traccar.client.MainFragment" />
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
@@ -0,0 +1,46 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<resources>
|
||||
<string name="app_name">Traccar-kliënt</string>
|
||||
<string name="app_logo">Traccar</string>
|
||||
<string name="shortcut_start">Begin diens</string>
|
||||
<string name="shortcut_stop">Stop diens</string>
|
||||
<string name="shortcut_sos">Stuur SOS</string>
|
||||
<string name="channel_default">Primêre Kanaal</string>
|
||||
<string name="settings_id_title">Toestel-identifiseerder</string>
|
||||
<string name="settings_url_title">Bediener-URL</string>
|
||||
<string name="settings_url_summary">Volg bediener-URL</string>
|
||||
<string name="settings_interval_title">Frekwensie</string>
|
||||
<string name="settings_interval_summary">Rapporteer interval in sekondes</string>
|
||||
<string name="settings_distance_title">Afstand</string>
|
||||
<string name="settings_distance_summary">Rapporteer afstand in meter</string>
|
||||
<string name="settings_angle_title">Hoek</string>
|
||||
<string name="settings_angle_summary">Rapporteringshoek in grade</string>
|
||||
<string name="settings_status_title">Diensstatus</string>
|
||||
<string name="settings_status_off">Begin</string>
|
||||
<string name="settings_status_on">Stop</string>
|
||||
<string name="settings_status_off_summary">Diens gestop</string>
|
||||
<string name="settings_status_on_summary">Diens loop</string>
|
||||
<string name="settings_buffer">Vanlyn buffer</string>
|
||||
<string name="settings_buffer_off_summary">Buffer af</string>
|
||||
<string name="settings_buffer_on_summary">Buffer aan</string>
|
||||
<string name="settings_accuracy_title">Ligging akkuraatheid</string>
|
||||
<string name="settings_accuracy_summary">Verlangde ligging akkuraatheid</string>
|
||||
<string name="settings_accuracy_high">Hoog</string>
|
||||
<string name="settings_accuracy_medium">Medium</string>
|
||||
<string name="settings_accuracy_low">Laag</string>
|
||||
<string name="settings_foreground_title">Voorgrond diens</string>
|
||||
<string name="settings_foreground_summary">Verhoog diensprioriteit</string>
|
||||
<string name="menu_status">Status</string>
|
||||
<string name="menu_shortcuts">Voeg kortpaaie by</string>
|
||||
<string name="menu_clear">Skoonmaak</string>
|
||||
<string name="status_service_create">Diens het begin</string>
|
||||
<string name="status_service_destroy">Diens het gestop</string>
|
||||
<string name="status_send_success">Stuur suksesvol</string>
|
||||
<string name="status_send_fail">Stuur misluk</string>
|
||||
<string name="status_location_update">Ligging opdateer</string>
|
||||
<string name="status_network_online">Netwerk aanlyn</string>
|
||||
<string name="status_network_offline">Netwerk vanlyn</string>
|
||||
<string name="hidden_app_name">Toestelinstellings</string>
|
||||
<string name="hidden_alert">Die toep is versteek. Skakel 8722227 (TRACCAR) om dit weer oop te maak.</string>
|
||||
<string name="error_msg_invalid_url">Voer \'n geldige http: // of https: // URL in</string>
|
||||
</resources>
|
||||
@@ -20,6 +20,9 @@
|
||||
<string name="settings_status_on">Pysäytä</string>
|
||||
<string name="settings_status_off_summary">Palvelu pysäytetty</string>
|
||||
<string name="settings_status_on_summary">Palvelu käynnissä</string>
|
||||
<string name="settings_buffer">Offline-puskurointi</string>
|
||||
<string name="settings_buffer_off_summary">Puskurointi pois päältä</string>
|
||||
<string name="settings_buffer_on_summary">Puskurointi päälle</string>
|
||||
<string name="settings_accuracy_title">Sijainnin tarkkuus</string>
|
||||
<string name="settings_accuracy_summary">Haluttu sijainnin tarkkuus</string>
|
||||
<string name="settings_accuracy_high">Korkea</string>
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<resources>
|
||||
<string name="app_name"> Traccar לאנדרויד</string>
|
||||
<string name="app_logo">Traccar</string>
|
||||
<string name="shortcut_start">הפעל שירות </string>
|
||||
<string name="shortcut_stop">עצור תהליך</string>
|
||||
<string name="shortcut_sos">שלח הודעת חירום</string>
|
||||
<string name="channel_default">ערוץ ראשי</string>
|
||||
<string name="settings_id_title">מזהה מכשיר</string>
|
||||
<string name="settings_url_title">כתובת שרת</string>
|
||||
<string name="settings_url_summary">כתובת שרת איתור</string>
|
||||
<string name="settings_interval_title">תדירות</string>
|
||||
<string name="settings_interval_summary">זמן דיווח בשניות </string>
|
||||
<string name="settings_distance_title">מרחק</string>
|
||||
<string name="settings_distance_summary">דיווח מרחק במטרים</string>
|
||||
<string name="settings_angle_title">זווית</string>
|
||||
<string name="settings_angle_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_accuracy_title">דיוק מיקום</string>
|
||||
<string name="settings_accuracy_summary">דיוק מיקום מבוקש</string>
|
||||
<string name="settings_accuracy_high">מדוייק </string>
|
||||
<string name="settings_accuracy_medium">בינוני</string>
|
||||
<string name="settings_accuracy_low">נמוך - משתמש רק בGPS של המכשיר </string>
|
||||
<string name="settings_foreground_title">אפשר הפעלה ברקע</string>
|
||||
<string name="settings_foreground_summary">הגדל את עדיפות התוכנה</string>
|
||||
<string name="menu_status">סטטוס</string>
|
||||
<string name="menu_shortcuts">הוסף קיצור דרך</string>
|
||||
<string name="menu_clear">נקה</string>
|
||||
<string name="status_service_create">אפליקציה הופעלה</string>
|
||||
<string name="status_service_destroy">אפליקציה הופסקה</string>
|
||||
<string name="status_send_success">נשלח בהצלחה</string>
|
||||
<string name="status_send_fail">שליחה נכשלה</string>
|
||||
<string name="status_location_update">עדכון מיקום</string>
|
||||
<string name="status_network_online">רשת באונליין </string>
|
||||
<string name="status_network_offline">רשת מנותקת</string>
|
||||
<string name="hidden_app_name">הגדרות המכשיר</string>
|
||||
<string name="hidden_alert">האפליקציה הוסתרה. כדי לפתוח אותה שוב חייג בטלפון 8722227 (TRACCAR).</string>
|
||||
<string name="error_msg_invalid_url">הזן כתובת חוקית http:// או https:// URL</string>
|
||||
</resources>
|
||||
@@ -20,6 +20,9 @@
|
||||
<string name="settings_status_on">停止</string>
|
||||
<string name="settings_status_off_summary">サービス停止中</string>
|
||||
<string name="settings_status_on_summary">サービス実行中</string>
|
||||
<string name="settings_buffer">オフラインバッファリング</string>
|
||||
<string name="settings_buffer_off_summary">バッファリング オフ</string>
|
||||
<string name="settings_buffer_on_summary">バッファリング オン</string>
|
||||
<string name="settings_accuracy_title">位置情報の精度</string>
|
||||
<string name="settings_accuracy_summary">要求される位置情報の精度</string>
|
||||
<string name="settings_accuracy_high">高</string>
|
||||
|
||||
@@ -20,6 +20,9 @@
|
||||
<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_buffer">Frakoblet mellomlagring</string>
|
||||
<string name="settings_buffer_off_summary">Mellomlagring deaktivert</string>
|
||||
<string name="settings_buffer_on_summary">Mellomlagring på</string>
|
||||
<string name="settings_accuracy_title">Posisjonsnøyaktighet</string>
|
||||
<string name="settings_accuracy_summary">Ønsket plasseringsnøyaktighet</string>
|
||||
<string name="settings_accuracy_high">Høy</string>
|
||||
|
||||
@@ -20,6 +20,9 @@
|
||||
<string name="settings_status_on">Stopp</string>
|
||||
<string name="settings_status_off_summary">Teneste stoppa</string>
|
||||
<string name="settings_status_on_summary">Tenar køyrer</string>
|
||||
<string name="settings_buffer">Fråkopla mellomlagring</string>
|
||||
<string name="settings_buffer_off_summary">Mellomlagring deaktivert</string>
|
||||
<string name="settings_buffer_on_summary">Mellomlagring på</string>
|
||||
<string name="settings_accuracy_title">Lokasjonsnøyaktighet</string>
|
||||
<string name="settings_accuracy_summary">Ønska lokasjonsnøyaktighet</string>
|
||||
<string name="settings_accuracy_high">Høg</string>
|
||||
|
||||
@@ -20,6 +20,9 @@
|
||||
<string name="settings_status_on">Zatrzymaj</string>
|
||||
<string name="settings_status_off_summary">Usługa zatrzymana</string>
|
||||
<string name="settings_status_on_summary">Usługa uruchomiona</string>
|
||||
<string name="settings_buffer">Buforowanie offline</string>
|
||||
<string name="settings_buffer_off_summary">Buforowanie wył.</string>
|
||||
<string name="settings_buffer_on_summary"> Buforowanie wł.</string>
|
||||
<string name="settings_accuracy_title">Dokładność lokalizacji</string>
|
||||
<string name="settings_accuracy_summary">Żądana dokładność lokalizacji</string>
|
||||
<string name="settings_accuracy_high">Wysoka</string>
|
||||
|
||||
@@ -20,6 +20,9 @@
|
||||
<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_buffer">Offline buffering</string>
|
||||
<string name="settings_buffer_off_summary">Buffering off</string>
|
||||
<string name="settings_buffer_on_summary">Buffering on</string>
|
||||
<string name="settings_accuracy_title">Precisão de localização</string>
|
||||
<string name="settings_accuracy_summary">Precisão de localização desejada</string>
|
||||
<string name="settings_accuracy_high">Alto</string>
|
||||
|
||||
@@ -20,6 +20,12 @@
|
||||
<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_buffer">Offline buffering</string>
|
||||
<string name="settings_buffer_off_summary">Buffering off</string>
|
||||
<string name="settings_buffer_on_summary">Buffering on</string>
|
||||
<string name="settings_wakelock">Wake lock</string>
|
||||
<string name="settings_wakelock_off_summary">Wake lock off</string>
|
||||
<string name="settings_wakelock_on_summary">Wake lock on</string>
|
||||
<string name="settings_accuracy_title">Location accuracy</string>
|
||||
<string name="settings_accuracy_summary">Desired location accuracy</string>
|
||||
<string name="settings_accuracy_high">High</string>
|
||||
@@ -40,4 +46,5 @@
|
||||
<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>
|
||||
<string name="error_msg_invalid_url">Please enter a valid http:// or https:// URL</string>
|
||||
<string name="disclosure_location">This app collects location data to enable live tracking even when the app is closed or not in use.</string>
|
||||
</resources>
|
||||
|
||||
@@ -31,22 +31,36 @@
|
||||
<EditTextPreference
|
||||
android:defaultValue="300"
|
||||
android:key="interval"
|
||||
android:numeric="integer"
|
||||
android:inputType="number"
|
||||
android:summary="@string/settings_interval_summary"
|
||||
android:title="@string/settings_interval_title" />
|
||||
|
||||
<EditTextPreference
|
||||
android:defaultValue="0"
|
||||
android:key="distance"
|
||||
android:numeric="integer"
|
||||
android:inputType="number"
|
||||
android:summary="@string/settings_distance_summary"
|
||||
android:title="@string/settings_distance_title" />
|
||||
|
||||
<EditTextPreference
|
||||
android:defaultValue="0"
|
||||
android:key="angle"
|
||||
android:numeric="integer"
|
||||
android:inputType="number"
|
||||
android:summary="@string/settings_angle_summary"
|
||||
android:title="@string/settings_angle_title" />
|
||||
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="true"
|
||||
android:key="buffer"
|
||||
android:summaryOff="@string/settings_buffer_off_summary"
|
||||
android:summaryOn="@string/settings_buffer_on_summary"
|
||||
android:title="@string/settings_buffer" />
|
||||
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="true"
|
||||
android:key="wakelock"
|
||||
android:summaryOff="@string/settings_wakelock_off_summary"
|
||||
android:summaryOn="@string/settings_wakelock_on_summary"
|
||||
android:title="@string/settings_wakelock" />
|
||||
|
||||
</PreferenceScreen>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
package org.traccar.client;
|
||||
|
||||
import android.location.Location;
|
||||
import android.os.Build;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -14,6 +15,7 @@ import java.util.Date;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
@Config(sdk = Build.VERSION_CODES.P)
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class DatabaseHelperTest {
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
package org.traccar.client;
|
||||
|
||||
import android.location.Location;
|
||||
import android.os.Build;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -12,6 +13,7 @@ import java.util.Date;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
@Config(sdk = Build.VERSION_CODES.P)
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class ProtocolFormatterTest {
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
|
||||
package org.traccar.client;
|
||||
|
||||
import android.os.Build;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -9,10 +11,11 @@ import org.robolectric.annotation.Config;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
@Config(sdk = Build.VERSION_CODES.P)
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class RequestManagerTest {
|
||||
|
||||
@Ignore
|
||||
@Ignore("Not a real unit test")
|
||||
@Test
|
||||
public void testSendRequest() throws Exception {
|
||||
|
||||
|
||||
+3
-4
@@ -2,12 +2,11 @@ buildscript {
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
maven { url 'https://maven.fabric.io/public' }
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.5.2'
|
||||
classpath 'com.google.gms:google-services:4.3.2'
|
||||
classpath 'io.fabric.tools:gradle:1.26.1'
|
||||
classpath 'com.android.tools.build:gradle:4.2.0-beta01'
|
||||
classpath 'com.google.gms:google-services:4.3.4'
|
||||
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.4.1'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1 @@
|
||||
android.enableJetifier=true
|
||||
android.useAndroidX=true
|
||||
android.enableUnitTestBinaryResources=true
|
||||
|
||||
+1
-1
@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.0-all.zip
|
||||
distributionUrl=https://services.gradle.org/distributions/gradle-6.7-bin.zip
|
||||
|
||||
@@ -5,6 +5,7 @@ import optparse
|
||||
import urllib2
|
||||
import json
|
||||
import base64
|
||||
import shutil
|
||||
|
||||
parser = optparse.OptionParser()
|
||||
parser.add_option("-u", "--user", dest="username", help="transifex user login")
|
||||
@@ -39,3 +40,8 @@ for language in resource["available_languages"]:
|
||||
file = open(filename, "wb")
|
||||
file.write(data.read())
|
||||
file.close()
|
||||
|
||||
filename = path + "values-iw/strings.xml"
|
||||
if not os.path.exists(os.path.dirname(filename)):
|
||||
os.makedirs(os.path.dirname(filename))
|
||||
shutil.copyfile(path + "values-he/strings.xml", filename)
|
||||
|
||||
Ссылка в новой задаче
Block a user