From: TrillGates Date: Tue, 31 Aug 2021 08:29:14 +0000 (+0800) Subject: fixed notification toast cover alarm. X-Git-Url: http://git.snicker.com.cn/css/html/static/gitweb.css?a=commitdiff_plain;h=4ee845d813e466aa4eacfecfccb5b8b760d71402;p=iclooplauncher.git fixed notification toast cover alarm. --- diff --git a/app/release/ICLoopPageLauncher_V36_202108232006_release.apk b/app/release/ICLoopPageLauncher_V37_202108272032_release.apk similarity index 57% rename from app/release/ICLoopPageLauncher_V36_202108232006_release.apk rename to app/release/ICLoopPageLauncher_V37_202108272032_release.apk index e4ba618..0e14f89 100644 Binary files a/app/release/ICLoopPageLauncher_V36_202108232006_release.apk and b/app/release/ICLoopPageLauncher_V37_202108272032_release.apk differ diff --git a/app/release/output-metadata.json b/app/release/output-metadata.json index 7788ef2..8a31a50 100644 --- a/app/release/output-metadata.json +++ b/app/release/output-metadata.json @@ -12,7 +12,7 @@ "filters": [], "versionCode": 1, "versionName": "1.0", - "outputFile": "ICLoopPageLauncher_V36_202108232006_release.apk" + "outputFile": "ICLoopPageLauncher_V37_202108272032_release.apk" } ] } \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 6ed0195..5856bdc 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -41,6 +41,7 @@ + @@ -49,7 +50,7 @@ diff --git a/app/src/main/java/com/ic/launcher/NotificationActivity.java b/app/src/main/java/com/ic/launcher/NotificationActivity.java index 0319ab1..6839ccd 100644 --- a/app/src/main/java/com/ic/launcher/NotificationActivity.java +++ b/app/src/main/java/com/ic/launcher/NotificationActivity.java @@ -125,6 +125,7 @@ public class NotificationActivity extends AppCompatActivity { //删除该类型的所有通知 Intent intent = new Intent(); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + String title = notificationItem.getTitle(); switch (category) { case CATEGORY_SMS: //跳转到短信详情界面 @@ -135,6 +136,7 @@ public class NotificationActivity extends AppCompatActivity { case CATEGORY_BLOOD: //跳转到记录里的体征警告界面 intent.setAction("com.ic.action.WARNING_MSG"); + title = null; break; case CATEGORY_PHONE: //跳转到通话记录界面 @@ -142,7 +144,7 @@ public class NotificationActivity extends AppCompatActivity { break; } startActivity(intent); -// notificationPresenter.removeNotificationByCategory(category); + notificationPresenter.removeNotificationByCategory(category, title); finish(); } diff --git a/app/src/main/java/com/ic/launcher/presenter/MainPagePresenter.java b/app/src/main/java/com/ic/launcher/presenter/MainPagePresenter.java index f7f8bdc..5047a17 100644 --- a/app/src/main/java/com/ic/launcher/presenter/MainPagePresenter.java +++ b/app/src/main/java/com/ic/launcher/presenter/MainPagePresenter.java @@ -23,6 +23,7 @@ import org.threeten.bp.ZoneId; import org.threeten.bp.format.DateTimeFormatter; import java.util.ArrayList; +import java.util.List; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -74,14 +75,30 @@ public class MainPagePresenter extends BasePresenter { private final BroadcastReceiver mScreenStateReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { - //灭屏 - MainPagePresenter.getInstance(mContext).checkNotification(); + //如果顶部有闹钟,就不要显示通知UI。 + String topActivity = getTopActivity(); + if (!"com.ic.alarm.AlarmRingActivity".equals(topActivity)) { + MainPagePresenter.getInstance(mContext).checkNotification(); + } } }; + private String getTopActivity() { + String className = null; + ActivityManager mActivityManager = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE); + List list = mActivityManager.getRunningTasks(1); + if (!list.isEmpty() && list.get(0) != null && list.get(0).topActivity != null) { + className = list.get(0).topActivity.getClassName(); + } + return className; + } + + public static final String NOTIFICATION_CHECK = "com.ic.notification.action.CHECK"; + private void listenerScreenState() { IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(Intent.ACTION_SCREEN_ON); + intentFilter.addAction(NOTIFICATION_CHECK); //intentFilter.addAction(Intent.ACTION_SCREEN_OFF); mContext.registerReceiver(mScreenStateReceiver, intentFilter); } diff --git a/app/src/main/java/com/ic/launcher/presenter/NotificationPresenter.java b/app/src/main/java/com/ic/launcher/presenter/NotificationPresenter.java index 563980e..f08a3ce 100644 --- a/app/src/main/java/com/ic/launcher/presenter/NotificationPresenter.java +++ b/app/src/main/java/com/ic/launcher/presenter/NotificationPresenter.java @@ -1,9 +1,11 @@ package com.ic.launcher.presenter; import android.content.ContentResolver; +import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.net.Uri; +import android.text.TextUtils; import androidx.lifecycle.MutableLiveData; @@ -13,10 +15,15 @@ import com.ic.launcher.utils.Constants; import java.util.ArrayList; import java.util.Collections; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; +import static com.ic.launcher.NotificationActivity.CATEGORY_PHONE; +import static com.ic.launcher.NotificationActivity.CATEGORY_SMS; + public class NotificationPresenter extends BasePresenter { private final Context mContext; private final ExecutorService executorService; @@ -85,4 +92,56 @@ public class NotificationPresenter extends BasePresenter { } }); } + + public void removeNotificationByCategory(String category, String title) { + executorService.execute(() -> { + int delete; + if (TextUtils.isEmpty(title)) { + delete = contentResolver.delete(Uri.parse(Constants.NOTIFICATIONS), + "category=?", + new String[]{category}); + } else { + delete = contentResolver.delete(Uri.parse(Constants.NOTIFICATIONS), + "category=? and title=?", + new String[]{category, title}); + } + ICLogger.d("deleted == > " + delete); + }); + //根据类型修改顶部的值 + //如果是短信 + Map tempMap = new HashMap<>(); + List value = notificationListValue.getValue(); + for (int i = 0; i < value.size(); i++) { + NotificationItem notificationItem = value.get(i); + String itemCategory = notificationItem.getCategory(); + Integer integer = tempMap.get(itemCategory); + if (integer == null) { + integer = 0; + } + integer++; + tempMap.put(itemCategory, integer); + } + Integer smsCount = tempMap.get(CATEGORY_SMS); + if (smsCount == null || smsCount <= 1) { + //如果短信的个数为0,就清除顶部的通知 + //删除短信图标 + //干掉短信未读的记录 + ContentValues contentValues = new ContentValues(); + //分类是心率的包名 + contentValues.put("s_key", "sms_unread"); + //1表示有,0表示没有 + contentValues.put("s_value", 0); + contentResolver.insert(Uri.parse(Constants.SETTINGS), contentValues); + } + //删除未接电话的标记 + Integer phoneCount = tempMap.get(CATEGORY_PHONE); + if (phoneCount == null || phoneCount <= 1) { + ContentValues contentValues = new ContentValues(); + //分类是心率的包名 + contentValues.put("s_key", "has_missed_phone"); + //1表示有,0表示没有 + contentValues.put("s_value", 0); + contentResolver.insert(Uri.parse(Constants.SETTINGS), contentValues); + } + } } diff --git a/app/version_code.properties b/app/version_code.properties index 32ccda2..ebc8c89 100644 --- a/app/version_code.properties +++ b/app/version_code.properties @@ -1,2 +1,2 @@ -#Mon Aug 23 20:06:49 CST 2021 -VERSION_CODE=36 +#Fri Aug 27 20:32:00 CST 2021 +VERSION_CODE=37