|
|
@@ -3,6 +3,7 @@ package com.usai.redant.apexdrivers;
|
|
|
|
|
|
import android.Manifest;
|
|
|
import android.app.AlertDialog;
|
|
|
+import android.app.NotificationManager;
|
|
|
import android.app.ProgressDialog;
|
|
|
import android.content.Context;
|
|
|
import android.content.DialogInterface;
|
|
|
@@ -14,12 +15,14 @@ import android.os.Build;
|
|
|
import android.os.Bundle;
|
|
|
import android.os.PowerManager;
|
|
|
import android.provider.Settings;
|
|
|
+import android.service.notification.StatusBarNotification;
|
|
|
import android.support.v4.app.ActivityCompat;
|
|
|
import android.support.v4.app.Fragment;
|
|
|
import android.support.v4.app.FragmentManager;
|
|
|
import android.support.v4.app.FragmentTransaction;
|
|
|
import android.support.v4.app.NotificationManagerCompat;
|
|
|
import android.text.TextUtils;
|
|
|
+import android.util.Log;
|
|
|
import android.view.Menu;
|
|
|
import android.view.MenuItem;
|
|
|
import android.widget.RelativeLayout;
|
|
|
@@ -47,7 +50,6 @@ public class MainActivity extends BasicActivity implements LoginFragment.LoginCa
|
|
|
private RelativeLayout mRootContainer;
|
|
|
private final static String FragmentTag = "ContentFragmentTag";
|
|
|
|
|
|
- private JSONObject mAps;
|
|
|
private static WeakReference<MainActivity> weakSelf = null;
|
|
|
|
|
|
public static MainActivity currentMainActivity() {
|
|
|
@@ -57,10 +59,6 @@ public class MainActivity extends BasicActivity implements LoginFragment.LoginCa
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- public void setAPS(JSONObject mAps) {
|
|
|
- this.mAps = mAps;
|
|
|
- }
|
|
|
-
|
|
|
void Test()
|
|
|
{
|
|
|
dbgUtil.fileLog(this,"lib import successful");
|
|
|
@@ -162,6 +160,13 @@ public class MainActivity extends BasicActivity implements LoginFragment.LoginCa
|
|
|
checkNotification();
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ protected void onNewIntent(Intent intent) {
|
|
|
+ super.onNewIntent(intent);
|
|
|
+
|
|
|
+ setIntent(intent);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
protected void onResume() {
|
|
|
super.onResume();
|
|
|
@@ -177,42 +182,82 @@ public class MainActivity extends BasicActivity implements LoginFragment.LoginCa
|
|
|
if (ApexDriverApplication.sharedApplication().isLogin()) {
|
|
|
|
|
|
Intent intent = getIntent();
|
|
|
+ String apsStr = null;
|
|
|
+
|
|
|
+ // 从Intent获取aps
|
|
|
if (intent != null) {
|
|
|
|
|
|
-// boolean is_notification=intent.getBooleanExtra("is_notification",false);
|
|
|
-// if(!is_notification)
|
|
|
-// {
|
|
|
-// mAps=null;
|
|
|
-// return;
|
|
|
-// }
|
|
|
- String apsStr = intent.getStringExtra("aps");
|
|
|
+ apsStr = intent.getStringExtra("aps");
|
|
|
|
|
|
- try {
|
|
|
- JSONObject aps = mAps;
|
|
|
+ }
|
|
|
|
|
|
- if (aps == null && !TextUtils.isEmpty(apsStr)) {
|
|
|
- aps = new JSONObject(apsStr);
|
|
|
- }
|
|
|
+ // 若aps不为空,则程序是从点击通知进入的
|
|
|
+ if (!TextUtils.isEmpty(apsStr)) {
|
|
|
|
|
|
- if (aps != null) {
|
|
|
- final String orderID = aps.optString("order-id");
|
|
|
- final int orderType = aps.optInt("order-type");
|
|
|
- final String orderType2 = aps.optString("order-type2");
|
|
|
- final String statusNo = aps.optString("status-no");
|
|
|
+ intent.removeExtra("aps");
|
|
|
|
|
|
- Intent detailIntent = DetailActivity.build(getApplicationContext(),orderID,orderType,orderType2,statusNo);
|
|
|
- this.setIntent(null);
|
|
|
- startActivity(detailIntent);
|
|
|
- }
|
|
|
+ try {
|
|
|
+
|
|
|
+ JSONObject aps = new JSONObject(apsStr);
|
|
|
+ showDetailByNotification(aps);
|
|
|
|
|
|
} catch (JSONException e) {
|
|
|
e.printStackTrace();
|
|
|
- } finally {
|
|
|
- mAps = null;
|
|
|
}
|
|
|
+
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 如果aps为空,则点击appicon进入程序
|
|
|
+// aps = getLastNotification();
|
|
|
+// removeLastNotification();
|
|
|
+// showDetailByAsk(aps);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void showDetailByNotification(JSONObject aps) {
|
|
|
+
|
|
|
+ if (aps != null) {
|
|
|
+ final String orderID = aps.optString("order-id");
|
|
|
+ final int orderType = aps.optInt("order-type");
|
|
|
+ final String orderType2 = aps.optString("order-type2");
|
|
|
+ final String statusNo = aps.optString("status-no");
|
|
|
+
|
|
|
+ Intent detailIntent = DetailActivity.build(getApplicationContext(),orderID,orderType,orderType2,statusNo);
|
|
|
+
|
|
|
+ startActivity(detailIntent);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void showDetailByAsk(final JSONObject aps) {
|
|
|
+
|
|
|
+ if (aps != null) {
|
|
|
+
|
|
|
+ final String orderID = aps.optString("order-id");
|
|
|
+ int required = aps.optInt("required");
|
|
|
+ String msg = aps.optString("message");
|
|
|
+ if (TextUtils.isEmpty(msg)) {
|
|
|
+ msg = orderID + " status changed,view detail?";
|
|
|
+ }
|
|
|
+
|
|
|
+ android.support.v7.app.AlertDialog.Builder builder = new android.support.v7.app.AlertDialog.Builder(this);
|
|
|
+ builder.setTitle("Message");
|
|
|
+ builder.setMessage(msg);
|
|
|
+ if (required == 0) {
|
|
|
+ builder.setNegativeButton("Cancel",null);
|
|
|
}
|
|
|
+ builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(DialogInterface dialog, int which) {
|
|
|
+ showDetailByNotification(aps);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ builder.show();
|
|
|
+
|
|
|
}
|
|
|
- mAps = null;
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
void checkPowerManagement()
|