|
|
@@ -3,15 +3,21 @@ package com.uas.appme.settings.activity;
|
|
|
import android.annotation.TargetApi;
|
|
|
import android.app.Activity;
|
|
|
import android.app.ActivityManager;
|
|
|
+import android.app.NotificationChannel;
|
|
|
+import android.app.NotificationManager;
|
|
|
import android.app.ProgressDialog;
|
|
|
import android.content.Context;
|
|
|
import android.content.DialogInterface;
|
|
|
import android.content.Intent;
|
|
|
+import android.graphics.Bitmap;
|
|
|
+import android.graphics.BitmapFactory;
|
|
|
import android.graphics.drawable.BitmapDrawable;
|
|
|
import android.net.Uri;
|
|
|
import android.os.AsyncTask;
|
|
|
import android.os.Build;
|
|
|
import android.os.Bundle;
|
|
|
+import android.support.v4.app.NotificationCompat;
|
|
|
+import android.support.v4.app.NotificationManagerCompat;
|
|
|
import android.text.TextUtils;
|
|
|
import android.util.Log;
|
|
|
import android.view.Gravity;
|
|
|
@@ -186,11 +192,11 @@ public class SettingActivity extends SupportToolBarActivity implements View.OnCl
|
|
|
|
|
|
rl_app_update.setOnClickListener(this);
|
|
|
close_push_rl.setOnClickListener(this);
|
|
|
- if (BaseConfig.isDebug()||"U0736".equals(CommonUtil.getEmcode())){
|
|
|
+ if (BaseConfig.isDebug() || "U0736".equals(CommonUtil.getEmcode())) {
|
|
|
close_push_rl.setOnLongClickListener(new View.OnLongClickListener() {
|
|
|
@Override
|
|
|
public boolean onLongClick(View view) {
|
|
|
- startActivity(new Intent(ct,SelectIpActivity.class));
|
|
|
+ startActivity(new Intent(ct, SelectIpActivity.class));
|
|
|
return false;
|
|
|
}
|
|
|
});
|
|
|
@@ -426,7 +432,7 @@ public class SettingActivity extends SupportToolBarActivity implements View.OnCl
|
|
|
startActivity(intent);
|
|
|
} else if (v.getId() == R.id.about_us_rl) {
|
|
|
startActivity(new Intent(mContext, AboutActivity.class));
|
|
|
- // startActivity(new Intent("com.modular.work.ContactsListActivity"));
|
|
|
+ // startActivity(new Intent("com.modular.work.ContactsListActivity"));
|
|
|
} else if (v.getId() == R.id.share_rl) {
|
|
|
share();
|
|
|
} else if (v.getId() == R.id.rl_app_update) {
|
|
|
@@ -494,11 +500,11 @@ public class SettingActivity extends SupportToolBarActivity implements View.OnCl
|
|
|
intent = new Intent(mContext, FlightsActivity.class);
|
|
|
startActivityForResult(intent, 0x12);
|
|
|
closePopupWindow();
|
|
|
- }else if (v.getId()==R.id.face_setting_tv){
|
|
|
+ } else if (v.getId() == R.id.face_setting_tv) {
|
|
|
intent = new Intent(mContext, FaceManageActivity.class);
|
|
|
startActivityForResult(intent, 0x13);
|
|
|
closePopupWindow();
|
|
|
- }else if (v.getId() == R.id.office_addr_setting_tv) {
|
|
|
+ } else if (v.getId() == R.id.office_addr_setting_tv) {
|
|
|
startActivityForResult(new Intent(mContext, OfficeAddressSettingsActivity.class), 0x12);
|
|
|
closePopupWindow();
|
|
|
} else if (v.getId() == R.id.my_rule_setting_tv) {
|
|
|
@@ -747,6 +753,8 @@ public class SettingActivity extends SupportToolBarActivity implements View.OnCl
|
|
|
popupWindow.showAtLocation(activity.getWindow().getDecorView(), Gravity.CENTER, 0, 0);
|
|
|
}
|
|
|
|
|
|
+ private static NotificationManager mNotificationManager;
|
|
|
+ private static NotificationCompat.Builder mNotificationBuilder;
|
|
|
|
|
|
/**
|
|
|
* @desc:百度自动更新 下载回调
|
|
|
@@ -757,7 +765,15 @@ public class SettingActivity extends SupportToolBarActivity implements View.OnCl
|
|
|
@Override
|
|
|
public void onDownloadComplete(String apkPath) {
|
|
|
try {
|
|
|
- NotifyUtil.cancelAll();
|
|
|
+ Toast.makeText(MyApplication.getInstance(), "新版本下载完成", Toast.LENGTH_LONG).show();
|
|
|
+ if (mNotificationBuilder != null) {
|
|
|
+ mNotificationBuilder.setTicker("下载完成");
|
|
|
+ if (mNotificationManager != null) {
|
|
|
+ mNotificationManager.notify(999, mNotificationBuilder.build());
|
|
|
+ mNotificationManager.cancel(999);
|
|
|
+ }
|
|
|
+ }
|
|
|
+// NotifyUtil.cancelAll();
|
|
|
BDAutoUpdateSDK.cpUpdateInstall(MyApplication.getInstance(), apkPath);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
@@ -766,13 +782,38 @@ public class SettingActivity extends SupportToolBarActivity implements View.OnCl
|
|
|
|
|
|
@Override
|
|
|
public void onStart() {
|
|
|
+ mNotificationManager = (NotificationManager) MyApplication.getInstance()
|
|
|
+ .getSystemService(Context.NOTIFICATION_SERVICE);
|
|
|
+ mNotificationBuilder = new NotificationCompat.Builder(MyApplication.getInstance(), MyApplication.getInstance().getPackageName());
|
|
|
+
|
|
|
+ //高版本需要渠道
|
|
|
+ if (Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
|
|
|
+ //只在Android O之上需要渠道
|
|
|
+ NotificationChannel notificationChannel = new NotificationChannel(MyApplication.getInstance().getPackageName(), "APK_DOWNLOAD", NotificationManager.IMPORTANCE_HIGH);
|
|
|
+ //如果这里用IMPORTANCE_NOENE就需要在系统的设置里面开启渠道,通知才能正常弹出
|
|
|
+ mNotificationManager.createNotificationChannel(notificationChannel);
|
|
|
+ }
|
|
|
|
|
|
+ mNotificationBuilder.setContentTitle("新版本下载中...")
|
|
|
+ .setPriority(NotificationCompat.PRIORITY_HIGH)
|
|
|
+ .setLargeIcon(BitmapFactory
|
|
|
+ .decodeResource(MyApplication.getInstance().getResources(), R.drawable.uuu))
|
|
|
+ .setSmallIcon(R.drawable.uuu);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onPercent(int percent, long rcvLen, long fileSize) {
|
|
|
LogUtil.d("SettingActivity", "percent:" + percent + "fileSize:" + Integer.valueOf(String.valueOf(fileSize)) + " rcvLen:" + rcvLen);
|
|
|
- NotifyUtil.buildProgress(102, R.drawable.uuu, "正在下载,共" + byteToMb(fileSize), percent, 100).show();
|
|
|
+ /*NotifyUtil.buildProgress(102,
|
|
|
+ R.drawable.uuu,
|
|
|
+ "正在下载,共" + byteToMb(fileSize),
|
|
|
+ percent,
|
|
|
+ 100,
|
|
|
+ "下载进度:%d/%d")
|
|
|
+ .show();*/
|
|
|
+ mNotificationBuilder.setProgress(100, percent, false)
|
|
|
+ .setContentText("下载进度:" + percent + "%");
|
|
|
+ mNotificationManager.notify(999, mNotificationBuilder.build());
|
|
|
}
|
|
|
|
|
|
@Override
|