Сравнить коммиты

...
13 Коммитов
Автор SHA1 Сообщение Дата
Anton Tananaev c243912c55 Update app version 2020-10-08 22:33:09 -07:00
Anton Tananaev 914a157afc Implement rating flow 2020-10-08 22:32:43 -07:00
Anton Tananaev 454ce6be21 Disable jetifier 2020-09-28 21:36:25 -07:00
Anton Tananaev e8a1e015d4 Enable multidex 2020-09-28 21:21:16 -07:00
Anton Tananaev ceb15c1378 Update version number 2020-09-28 21:07:42 -07:00
Anton Tananaev d25c745013 Update crashlytics 2020-09-28 21:07:17 -07:00
Anton Tananaev c24df5b246 Update notification priority 2020-09-20 11:16:41 -07:00
Anton Tananaev 283d0467b4 Add option to disable wakelock 2020-09-20 11:08:10 -07:00
Anton Tananaev 83bf1daa84 Use different method 2020-09-20 11:01:03 -07:00
Anton Tananaev 96d61c4c66 Update libraries 2020-09-20 10:50:21 -07:00
Anton Tananaev 3978a3d8d6 Update path 2020-09-06 15:05:41 -07:00
Anton Tananaev 78018c3038 Update templates 2020-07-05 11:05:41 -07:00
Anton Tananaev 19b7c4da21 Minor project file update 2020-06-19 22:28:02 -07:00
15 изменённых файлов: 206 добавлений и 29 удалений
+1
Просмотреть файл
@@ -0,0 +1 @@
custom: https://www.traccar.org/donate/
-7
Просмотреть файл
@@ -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/
-->
+38
Просмотреть файл
@@ -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.
+20
Просмотреть файл
@@ -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.
+21 -9
Просмотреть файл
@@ -8,8 +8,18 @@ android {
buildConfigField 'boolean', 'HIDDEN_APP', 'false'
minSdkVersion 16
targetSdkVersion 29
versionCode 64
versionName '6.3'
versionCode 66
versionName '6.5'
multiDexEnabled true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
}
lintOptions {
@@ -19,7 +29,7 @@ android {
flavorDimensions 'default'
productFlavors {
regular {
isDefault.set(true)
isDefault = true
}
google
hidden {
@@ -36,14 +46,16 @@ android {
}
dependencies {
implementation 'com.google.android.material:material:1.3.0-alpha01'
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.4.3'
googleImplementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
googleImplementation 'com.google.firebase:firebase-analytics:17.4.3'
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')) {
@@ -51,7 +63,7 @@ if (getGradle().getStartParameter().getTaskRequests().toString().contains('Googl
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')
+39
Просмотреть файл
@@ -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();
});
}
});
}
}
}
+49
Просмотреть файл
@@ -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();
}
}
+10 -4
Просмотреть файл
@@ -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) {
}
}
+4 -1
Просмотреть файл
@@ -66,6 +66,7 @@ public class MainFragment extends PreferenceFragmentCompat implements OnSharedPr
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;
@@ -83,7 +84,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() {
@@ -206,6 +207,7 @@ public class MainFragment extends PreferenceFragmentCompat implements OnSharedPr
findPreference(KEY_ANGLE).setEnabled(enabled);
findPreference(KEY_ACCURACY).setEnabled(enabled);
findPreference(KEY_BUFFER).setEnabled(enabled);
findPreference(KEY_WAKELOCK).setEnabled(enabled);
}
@Override
@@ -216,6 +218,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));
}
-1
Просмотреть файл
@@ -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;
+9 -1
Просмотреть файл
@@ -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);
+3
Просмотреть файл
@@ -23,6 +23,9 @@
<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>
+7
Просмотреть файл
@@ -56,4 +56,11 @@
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 -2
Просмотреть файл
@@ -4,9 +4,9 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.0'
classpath 'com.android.tools.build:gradle:4.0.2'
classpath 'com.google.gms:google-services:4.3.3'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.1.1'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.3.0'
}
}
-1
Просмотреть файл
@@ -1,2 +1 @@
android.enableJetifier=true
android.useAndroidX=true