|
@@ -1,49 +1,46 @@
|
|
|
package com.usai.redant.apexdrivers;
|
|
package com.usai.redant.apexdrivers;
|
|
|
|
|
|
|
|
|
|
+import android.app.Activity;
|
|
|
import android.app.Application;
|
|
import android.app.Application;
|
|
|
|
|
+import android.content.BroadcastReceiver;
|
|
|
import android.content.ComponentName;
|
|
import android.content.ComponentName;
|
|
|
import android.content.Context;
|
|
import android.content.Context;
|
|
|
import android.content.DialogInterface;
|
|
import android.content.DialogInterface;
|
|
|
import android.content.Intent;
|
|
import android.content.Intent;
|
|
|
|
|
+import android.content.IntentFilter;
|
|
|
import android.content.ServiceConnection;
|
|
import android.content.ServiceConnection;
|
|
|
import android.content.SharedPreferences;
|
|
import android.content.SharedPreferences;
|
|
|
-import android.graphics.Bitmap;
|
|
|
|
|
-import android.graphics.BitmapFactory;
|
|
|
|
|
-import android.graphics.drawable.BitmapDrawable;
|
|
|
|
|
-import android.graphics.drawable.Drawable;
|
|
|
|
|
import android.location.Location;
|
|
import android.location.Location;
|
|
|
import android.os.Build;
|
|
import android.os.Build;
|
|
|
|
|
+import android.os.Bundle;
|
|
|
import android.os.IBinder;
|
|
import android.os.IBinder;
|
|
|
import android.support.v7.app.AlertDialog;
|
|
import android.support.v7.app.AlertDialog;
|
|
|
import android.text.TextUtils;
|
|
import android.text.TextUtils;
|
|
|
import android.util.Log;
|
|
import android.util.Log;
|
|
|
-import android.widget.Switch;
|
|
|
|
|
|
|
|
|
|
import com.usai.redant.apexdrivers.network.Network;
|
|
import com.usai.redant.apexdrivers.network.Network;
|
|
|
import com.usai.redant.apexdrivers.receiver.ApexDriverAlarmReceiver;
|
|
import com.usai.redant.apexdrivers.receiver.ApexDriverAlarmReceiver;
|
|
|
import com.usai.redant.apexdrivers.utils.OperationQueue;
|
|
import com.usai.redant.apexdrivers.utils.OperationQueue;
|
|
|
import com.usai.redant.rautils.receiver.RABroadcast;
|
|
import com.usai.redant.rautils.receiver.RABroadcast;
|
|
|
import com.usai.redant.rautils.utils.AESUtil;
|
|
import com.usai.redant.rautils.utils.AESUtil;
|
|
|
-import com.usai.redant.rautils.utils.FileManager;
|
|
|
|
|
-import com.usai.redant.rautils.utils.ImageUtil;
|
|
|
|
|
import com.usai.redant.rautils.utils.RAUtil;
|
|
import com.usai.redant.rautils.utils.RAUtil;
|
|
|
|
|
|
|
|
-import java.io.File;
|
|
|
|
|
-import java.io.FileOutputStream;
|
|
|
|
|
-import java.io.InputStream;
|
|
|
|
|
-import java.io.OutputStream;
|
|
|
|
|
import java.lang.reflect.Field;
|
|
import java.lang.reflect.Field;
|
|
|
|
|
|
|
|
public class ApexDriverApplication extends Application {
|
|
public class ApexDriverApplication extends Application {
|
|
|
|
|
|
|
|
public final static String secretKey = "usai";
|
|
public final static String secretKey = "usai";
|
|
|
public final static String preferencesKey = "Apex";
|
|
public final static String preferencesKey = "Apex";
|
|
|
|
|
+ public static final String CHANNEL_ID = "Apex & Drivers";
|
|
|
|
|
+ public static final String CHANNEL_NAME = "Apex & Drivers";
|
|
|
|
|
+
|
|
|
private static ApexDriverApplication mApp;
|
|
private static ApexDriverApplication mApp;
|
|
|
|
|
|
|
|
public String user;
|
|
public String user;
|
|
|
public String password;
|
|
public String password;
|
|
|
private volatile long notificationID;
|
|
private volatile long notificationID;
|
|
|
|
|
|
|
|
|
|
+ public boolean isbackground=true;
|
|
|
|
|
|
|
|
public final static int BackgroundReportTypeNone = 0;
|
|
public final static int BackgroundReportTypeNone = 0;
|
|
|
public final static int BackgroundReportTypeReject = 1;
|
|
public final static int BackgroundReportTypeReject = 1;
|
|
@@ -57,13 +54,85 @@ public class ApexDriverApplication extends Application {
|
|
|
private ApexDriversBackgroundService mService;
|
|
private ApexDriversBackgroundService mService;
|
|
|
private boolean mRequiredLocation = false;
|
|
private boolean mRequiredLocation = false;
|
|
|
|
|
|
|
|
|
|
+
|
|
|
private OperationQueue networkQueue;
|
|
private OperationQueue networkQueue;
|
|
|
|
|
|
|
|
|
|
+ private BroadcastReceiver screen_event_receiver = new BroadcastReceiver() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onReceive(Context context, Intent intent) {
|
|
|
|
|
+// if (isbackground) {
|
|
|
|
|
+ isbackground = true;
|
|
|
|
|
+
|
|
|
|
|
+// }
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ private ActivityLifecycleCallbacks activitylcCallbacks =new ActivityLifecycleCallbacks() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onActivityCreated(Activity activity, Bundle bundle) {
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onActivityStarted(Activity activity) {
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onActivityResumed(Activity activity) {
|
|
|
|
|
+
|
|
|
|
|
+ if(isbackground==true)
|
|
|
|
|
+ {
|
|
|
|
|
+ isbackground = false;
|
|
|
|
|
+ //notification
|
|
|
|
|
+ Log.d("ApexDriverApplication", "onCreate: SEND" + RABroadcast.ACTION_REDANT_INIT_ALARM);
|
|
|
|
|
+ Intent bintent = new Intent(RABroadcast.ACTION_REDANT_INIT_ALARM);
|
|
|
|
|
+ bintent.setClass(ApexDriverApplication.this, ApexDriverAlarmReceiver.class);
|
|
|
|
|
+// bintent.putExtra("msg", msg.toString());
|
|
|
|
|
+ sendBroadcast(bintent);
|
|
|
|
|
+ }
|
|
|
|
|
+// isbackground = false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onActivityPaused(Activity activity) {
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onActivityStopped(Activity activity) {
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onActivitySaveInstanceState(Activity activity, Bundle bundle) {
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onActivityDestroyed(Activity activity) {
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onTrimMemory(int level)
|
|
|
|
|
+ {
|
|
|
|
|
+ super.onTrimMemory(level);
|
|
|
|
|
+ if (level == TRIM_MEMORY_UI_HIDDEN) {
|
|
|
|
|
+ isbackground = true;
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
@Override
|
|
@Override
|
|
|
public void onCreate() {
|
|
public void onCreate() {
|
|
|
Log.d("ApexDriverApplication", "onCreate");
|
|
Log.d("ApexDriverApplication", "onCreate");
|
|
|
super.onCreate();
|
|
super.onCreate();
|
|
|
|
|
|
|
|
|
|
+ IntentFilter screenOffFilter = new IntentFilter(Intent.ACTION_SCREEN_OFF);
|
|
|
|
|
+ registerReceiver(screen_event_receiver, screenOffFilter);
|
|
|
|
|
+
|
|
|
|
|
+ registerActivityLifecycleCallbacks(activitylcCallbacks);
|
|
|
mApp = this;
|
|
mApp = this;
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
@@ -137,6 +206,7 @@ public class ApexDriverApplication extends Application {
|
|
|
public void onTerminate() {
|
|
public void onTerminate() {
|
|
|
super.onTerminate();
|
|
super.onTerminate();
|
|
|
|
|
|
|
|
|
|
+ unregisterActivityLifecycleCallbacks(activitylcCallbacks);
|
|
|
unbindService(mServiceConnection);
|
|
unbindService(mServiceConnection);
|
|
|
}
|
|
}
|
|
|
|
|
|