Fix a few more warnings
This commit is contained in:
parent
fa3f9b8ca5
commit
c0a486383c
@ -6,6 +6,8 @@ import android.content.Intent;
|
||||
import androidx.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Broadcast receiver class to help start or stop the traffic monitoring service when the phone's
|
||||
* battery level is low or okay.
|
||||
@ -20,7 +22,7 @@ public class BatteryReceiver extends BroadcastReceiver {
|
||||
Log.v("BatteryReceiver", "Received a battery intent");
|
||||
if (PreferenceManager.getDefaultSharedPreferences(appContext).getBoolean("enabled", true) &&
|
||||
PreferenceManager.getDefaultSharedPreferences(appContext).getBoolean("lowpower", false)) {
|
||||
if (ittIntent.getAction().equals(Intent.ACTION_BATTERY_LOW)) {
|
||||
if (Objects.equals(ittIntent.getAction(), Intent.ACTION_BATTERY_LOW)) {
|
||||
Log.i("BatteryReceiver", "Battery low. Stopping service");
|
||||
appContext.stopService(new Intent(appContext, TrafficService.class));
|
||||
} else {
|
||||
|
@ -5,6 +5,8 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Broadcast receiver class to help start the traffic monitoring service when the phone boots up only
|
||||
* if the service is enabled.
|
||||
@ -16,6 +18,11 @@ public class BootReceiver extends BroadcastReceiver {
|
||||
*/
|
||||
@Override
|
||||
public void onReceive(Context appContext, Intent bootIntent) {
|
||||
if (!(Objects.equals(bootIntent.getAction(), Intent.ACTION_BOOT_COMPLETED))
|
||||
|| Objects.equals(bootIntent.getAction(), Intent.ACTION_MY_PACKAGE_REPLACED)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (PreferenceManager.getDefaultSharedPreferences(appContext).getBoolean("enabled", true)) {
|
||||
appContext.startService(new Intent(appContext, TrafficService.class));
|
||||
}
|
||||
|
@ -1,10 +1,8 @@
|
||||
package com.mridang.speedo;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.os.PowerManager;
|
||||
import androidx.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
|
@ -115,7 +115,7 @@ public class TrafficService extends Service {
|
||||
notBuilder.setPriority(Integer.MAX_VALUE);
|
||||
notBuilder.setCategory(NotificationCompat.CATEGORY_SERVICE);
|
||||
notBuilder.setLocalOnly(true);
|
||||
setColor(settings.getInt("color", Color.TRANSPARENT));
|
||||
setColor(Color.TRANSPARENT);
|
||||
visibilityPublic(settings.getBoolean("lockscreen", true));
|
||||
|
||||
Log.d("HardwareService", "Setting up the service manager and the broadcast receiver");
|
||||
|
Loading…
Reference in New Issue
Block a user