From: TrillGates Date: Tue, 31 Aug 2021 12:38:36 +0000 (+0800) Subject: add notification trigger controler. X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=99e741ed45e30d5b21762dac24278ad1bf1bdf53;p=iclooplauncher.git add notification trigger controler. --- 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 5047a17..0cfea76 100644 --- a/app/src/main/java/com/ic/launcher/presenter/MainPagePresenter.java +++ b/app/src/main/java/com/ic/launcher/presenter/MainPagePresenter.java @@ -103,23 +103,47 @@ public class MainPagePresenter extends BasePresenter { mContext.registerReceiver(mScreenStateReceiver, intentFilter); } + public static final String KEY_NOTIFICATION_ENABLE = "key_notification_enable"; + public void checkNotification() { + //如果是关闭的,有多少删除多少 executor.execute(() -> { - Cursor query = mContext.getContentResolver().query(Uri.parse(NOTIFICATIONS), - null, null, null, null); - if (query != null) { - if (query.moveToNext()) { - //判断当前是不是拨号在前,如果是的话,就不要弹出 - boolean isInCallUiTop = checkInCallUiTop(); - if (!isInCallUiTop) { - mContext.startActivity(new Intent(mContext, NotificationActivity.class)); + String notificationValue = getValue(KEY_NOTIFICATION_ENABLE); + ICLogger.d("notificationValue ==> " + notificationValue); + if (notificationValue == null || "1".equals(notificationValue)) { + Cursor query = mContext.getContentResolver().query(Uri.parse(NOTIFICATIONS), + null, null, null, null); + if (query != null) { + if (query.moveToNext()) { + //判断当前是不是拨号在前,如果是的话,就不要弹出 + boolean isInCallUiTop = checkInCallUiTop(); + if (!isInCallUiTop) { + mContext.startActivity(new Intent(mContext, NotificationActivity.class)); + } } + query.close(); } - query.close(); + } else { + int delete = mContext.getContentResolver().delete(Uri.parse(NOTIFICATIONS), null, null); + ICLogger.d("notification delete count => " + delete); } }); } + + private String getValue(String key) { + Cursor query = mContext.getContentResolver() + .query(Uri.parse(SETTINGS), new String[]{"s_value"}, + "s_key=?", new String[]{key}, null); + if (query != null) { + if (query.moveToNext()) { + return query.getString(0); + } + query.close(); + } + return null; + } + private boolean checkInCallUiTop() { ArrayList arrayList = new ArrayList(); arrayList.add("com.android.incallui.InCallActivity");