Add background location disclosure
Этот коммит содержится в:
@@ -1,11 +1,12 @@
|
|||||||
apply plugin: 'com.android.application'
|
apply plugin: 'com.android.application'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
|
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 30
|
|
||||||
versionCode 66
|
versionCode 66
|
||||||
versionName '6.5'
|
versionName '6.5'
|
||||||
multiDexEnabled true
|
multiDexEnabled true
|
||||||
|
|||||||
@@ -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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user