Сравнить коммиты
| Автор | SHA1 | Дата | |
|---|---|---|---|
|
|
1cb5326e07 | ||
|
|
28befc6180 | ||
|
|
e83ef80fa3 | ||
|
|
b26a1bd133 | ||
|
|
0bbee716a6 | ||
|
|
52e3b839ae | ||
|
|
cfe04eb0a6 | ||
|
|
c243912c55 | ||
|
|
914a157afc | ||
|
|
454ce6be21 |
@@ -1,15 +1,15 @@
|
|||||||
apply plugin: 'com.android.application'
|
apply plugin: 'com.android.application'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 29
|
compileSdkVersion 30
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId 'org.traccar.client'
|
applicationId 'org.traccar.client'
|
||||||
buildConfigField 'boolean', 'HIDDEN_APP', 'false'
|
buildConfigField 'boolean', 'HIDDEN_APP', 'false'
|
||||||
minSdkVersion 16
|
minSdkVersion 16
|
||||||
targetSdkVersion 29
|
targetSdkVersion 30
|
||||||
versionCode 65
|
versionCode 68
|
||||||
versionName '6.4'
|
versionName '6.7'
|
||||||
multiDexEnabled true
|
multiDexEnabled true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'com.google.android.material:material:1.3.0-alpha02'
|
implementation 'com.google.android.material:material:1.3.0-alpha03'
|
||||||
implementation 'androidx.multidex:multidex:2.0.1'
|
implementation 'androidx.multidex:multidex:2.0.1'
|
||||||
implementation 'androidx.preference:preference:1.1.1'
|
implementation 'androidx.preference:preference:1.1.1'
|
||||||
testImplementation 'junit:junit:4.13'
|
testImplementation 'junit:junit:4.13'
|
||||||
@@ -55,6 +55,7 @@ dependencies {
|
|||||||
googleImplementation 'com.google.firebase:firebase-crashlytics-gradle:2.3.0'
|
googleImplementation 'com.google.firebase:firebase-crashlytics-gradle:2.3.0'
|
||||||
googleImplementation 'com.google.firebase:firebase-analytics:17.5.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.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')) {
|
||||||
|
|||||||
@@ -15,16 +15,55 @@
|
|||||||
*/
|
*/
|
||||||
package org.traccar.client;
|
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;
|
import com.google.firebase.analytics.FirebaseAnalytics;
|
||||||
|
|
||||||
public class GoogleMainApplication extends MainApplication {
|
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;
|
private FirebaseAnalytics firebaseAnalytics;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
firebaseAnalytics = FirebaseAnalytics.getInstance(this);
|
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_COARSE_LOCATION" />
|
||||||
<uses-permission android:name="android.permission.ACCESS_FINE_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.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.RECEIVE_BOOT_COMPLETED" />
|
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||||
|
|||||||
@@ -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");
|
* 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.
|
||||||
@@ -24,9 +24,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
@Override
|
@Override
|
||||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
if (savedInstanceState == null) {
|
setContentView(R.layout.main);
|
||||||
getSupportFragmentManager().beginTransaction().replace(android.R.id.content, new MainFragment()).commit();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
package org.traccar.client;
|
package org.traccar.client;
|
||||||
|
|
||||||
import android.annotation.TargetApi;
|
import android.annotation.TargetApi;
|
||||||
|
import android.app.Activity;
|
||||||
import android.app.Notification;
|
import android.app.Notification;
|
||||||
import android.app.NotificationChannel;
|
import android.app.NotificationChannel;
|
||||||
import android.app.NotificationManager;
|
import android.app.NotificationManager;
|
||||||
@@ -26,6 +27,7 @@ import android.net.Uri;
|
|||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
import androidx.multidex.MultiDexApplication;
|
import androidx.multidex.MultiDexApplication;
|
||||||
|
|
||||||
public class MainApplication extends MultiDexApplication {
|
public class MainApplication extends MultiDexApplication {
|
||||||
@@ -71,4 +73,7 @@ public class MainApplication extends MultiDexApplication {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void handleRatingFlow(@NonNull Activity activity) {
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,6 +47,8 @@ import androidx.preference.PreferenceFragmentCompat;
|
|||||||
import androidx.preference.PreferenceManager;
|
import androidx.preference.PreferenceManager;
|
||||||
import androidx.preference.TwoStatePreference;
|
import androidx.preference.TwoStatePreference;
|
||||||
|
|
||||||
|
import com.google.android.material.snackbar.Snackbar;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
@@ -69,6 +71,7 @@ public class MainFragment extends PreferenceFragmentCompat implements OnSharedPr
|
|||||||
public static final String KEY_WAKELOCK = "wakelock";
|
public static final String KEY_WAKELOCK = "wakelock";
|
||||||
|
|
||||||
private static final int PERMISSIONS_REQUEST_LOCATION = 2;
|
private static final int PERMISSIONS_REQUEST_LOCATION = 2;
|
||||||
|
private static final String KEY_DISCLOSURE_SHOWN = "disclosureShown";
|
||||||
|
|
||||||
private SharedPreferences sharedPreferences;
|
private SharedPreferences sharedPreferences;
|
||||||
|
|
||||||
@@ -77,6 +80,7 @@ public class MainFragment extends PreferenceFragmentCompat implements OnSharedPr
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||||
|
|
||||||
if (BuildConfig.HIDDEN_APP && Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
|
if (BuildConfig.HIDDEN_APP && Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
|
||||||
removeLauncherIcon();
|
removeLauncherIcon();
|
||||||
}
|
}
|
||||||
@@ -191,6 +195,17 @@ public class MainFragment extends PreferenceFragmentCompat implements OnSharedPr
|
|||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
sharedPreferences.registerOnSharedPreferenceChangeListener(this);
|
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
|
@Override
|
||||||
@@ -218,6 +233,7 @@ public class MainFragment extends PreferenceFragmentCompat implements OnSharedPr
|
|||||||
} else {
|
} else {
|
||||||
stopTrackingService();
|
stopTrackingService();
|
||||||
}
|
}
|
||||||
|
((MainApplication) getActivity().getApplication()).handleRatingFlow(getActivity());
|
||||||
} 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));
|
||||||
}
|
}
|
||||||
@@ -255,10 +271,6 @@ public class MainFragment extends PreferenceFragmentCompat implements OnSharedPr
|
|||||||
if (ContextCompat.checkSelfPermission(getContext(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
if (ContextCompat.checkSelfPermission(getContext(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
||||||
requiredPermissions.add(Manifest.permission.ACCESS_FINE_LOCATION);
|
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();
|
permission = requiredPermissions.isEmpty();
|
||||||
if (!permission) {
|
if (!permission) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
|
|||||||
@@ -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");
|
* 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.
|
||||||
@@ -34,6 +34,9 @@ import android.util.Log;
|
|||||||
|
|
||||||
public class TrackingService extends Service {
|
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 String TAG = TrackingService.class.getSimpleName();
|
||||||
private static final int NOTIFICATION_ID = 1;
|
private static final int NOTIFICATION_ID = 1;
|
||||||
|
|
||||||
@@ -82,6 +85,7 @@ public class TrackingService extends Service {
|
|||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
Log.i(TAG, "service create");
|
Log.i(TAG, "service create");
|
||||||
|
sendBroadcast(new Intent(ACTION_STARTED));
|
||||||
StatusActivity.addMessage(getString(R.string.status_service_create));
|
StatusActivity.addMessage(getString(R.string.status_service_create));
|
||||||
|
|
||||||
startForeground(NOTIFICATION_ID, createNotification(this));
|
startForeground(NOTIFICATION_ID, createNotification(this));
|
||||||
@@ -120,6 +124,7 @@ public class TrackingService extends Service {
|
|||||||
@Override
|
@Override
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
Log.i(TAG, "service destroy");
|
Log.i(TAG, "service destroy");
|
||||||
|
sendBroadcast(new Intent(ACTION_STOPPED));
|
||||||
StatusActivity.addMessage(getString(R.string.status_service_destroy));
|
StatusActivity.addMessage(getString(R.string.status_service_destroy));
|
||||||
|
|
||||||
stopForeground(true);
|
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>
|
||||||
@@ -46,4 +46,5 @@
|
|||||||
<string name="hidden_app_name">Device Settings</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>
|
<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="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>
|
</resources>
|
||||||
|
|||||||
+3
-3
@@ -4,9 +4,9 @@ buildscript {
|
|||||||
jcenter()
|
jcenter()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:4.0.1'
|
classpath 'com.android.tools.build:gradle:4.2.0-beta01'
|
||||||
classpath 'com.google.gms:google-services:4.3.3'
|
classpath 'com.google.gms:google-services:4.3.4'
|
||||||
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.3.0'
|
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.4.1'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,2 +1 @@
|
|||||||
android.enableJetifier=true
|
|
||||||
android.useAndroidX=true
|
android.useAndroidX=true
|
||||||
|
|||||||
+1
-1
@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
|
|||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
|
distributionUrl=https://services.gradle.org/distributions/gradle-6.7-bin.zip
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user