Java Code Examples for android.service.notification.NotificationListenerService#INTERRUPTION_FILTER_PRIORITY
The following examples show how to use
android.service.notification.NotificationListenerService#INTERRUPTION_FILTER_PRIORITY .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RingerModeLoader.java From Easer with GNU General Public License v3.0 | 6 votes |
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) private boolean setDoNotDisturbForLollipop(RingerMode mode) { int mode_num; if (mode == RingerMode.dnd_all) { mode_num = NotificationListenerService.INTERRUPTION_FILTER_ALL; } else if (mode == RingerMode.dnd_priority) { mode_num = NotificationListenerService.INTERRUPTION_FILTER_PRIORITY; } else if (mode == RingerMode.dnd_none) { mode_num = NotificationListenerService.INTERRUPTION_FILTER_NONE; } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && mode == RingerMode.dnd_alarms) { mode_num = NotificationListenerService.INTERRUPTION_FILTER_ALARMS; } else { throw new IllegalStateException("DoNotDisturb mode run out of cases???"); } InterruptionFilterSwitcherService.setInterruptionFilter(context, mode_num); return true; }
Example 2
Source File: Constants.java From Noyze with Apache License 2.0 | 5 votes |
public int getZenModeListenerInterruptionFilter(int mZenMode) { switch (mZenMode) { case ZEN_MODE_OFF: return NotificationListenerService.INTERRUPTION_FILTER_ALL; case ZEN_MODE_IMPORTANT_INTERRUPTIONS: return NotificationListenerService.INTERRUPTION_FILTER_PRIORITY; case ZEN_MODE_NO_INTERRUPTIONS: return NotificationListenerService.INTERRUPTION_FILTER_NONE; default: return NotificationListenerService.INTERRUPTION_FILTER_NONE; } }
Example 3
Source File: Constants.java From Noyze with Apache License 2.0 | 5 votes |
private static int zenModeFromListenerInterruptionFilter(int listenerInterruptionFilter) { switch (listenerInterruptionFilter) { case NotificationListenerService.INTERRUPTION_FILTER_ALL: return ZEN_MODE_OFF; case NotificationListenerService.INTERRUPTION_FILTER_PRIORITY: return ZEN_MODE_IMPORTANT_INTERRUPTIONS; case NotificationListenerService.INTERRUPTION_FILTER_NONE: return ZEN_MODE_NO_INTERRUPTIONS; default: return ZEN_MODE_OFF; } }
Example 4
Source File: PPNotificationListenerService.java From PhoneProfilesPlus with Apache License 2.0 | 5 votes |
/** Convenience method for sending an {@link android.content.Intent} with {@link #ACTION_REQUEST_INTERRUPTION_FILTER}. */ @SuppressLint("InlinedApi") public static void requestInterruptionFilter(final Context context, final int zenMode) { boolean a60 = (android.os.Build.VERSION.SDK_INT == 23) && Build.VERSION.RELEASE.equals("6.0"); if (/*((android.os.Build.VERSION.SDK_INT >= 21) && (android.os.Build.VERSION.SDK_INT < 23)) ||*/ a60) { if (isNotificationListenerServiceEnabled(context)) { int interruptionFilter = NotificationListenerService.INTERRUPTION_FILTER_ALL; switch (zenMode) { case ActivateProfileHelper.ZENMODE_ALL: interruptionFilter = NotificationListenerService.INTERRUPTION_FILTER_ALL; break; case ActivateProfileHelper.ZENMODE_PRIORITY: interruptionFilter = NotificationListenerService.INTERRUPTION_FILTER_PRIORITY; break; case ActivateProfileHelper.ZENMODE_NONE: interruptionFilter = NotificationListenerService.INTERRUPTION_FILTER_NONE; break; case ActivateProfileHelper.ZENMODE_ALARMS: interruptionFilter = NotificationListenerService.INTERRUPTION_FILTER_ALARMS; break; } //Intent request = getInterruptionFilterRequestIntent(interruptionFilter, context); Intent request = new Intent(PPNotificationListenerService.ACTION_REQUEST_INTERRUPTION_FILTER); request.putExtra(EXTRA_FILTER, interruptionFilter); request.setPackage(context.getPackageName()); context.sendBroadcast(request); } } }
Example 5
Source File: Constants.java From Noyze with Apache License 2.0 | 5 votes |
public int getZenModeListenerInterruptionFilter(int mZenMode) { switch (mZenMode) { case ZEN_MODE_OFF: return NotificationListenerService.INTERRUPTION_FILTER_ALL; case ZEN_MODE_IMPORTANT_INTERRUPTIONS: return NotificationListenerService.INTERRUPTION_FILTER_PRIORITY; case ZEN_MODE_NO_INTERRUPTIONS: return NotificationListenerService.INTERRUPTION_FILTER_NONE; default: return NotificationListenerService.INTERRUPTION_FILTER_NONE; } }
Example 6
Source File: Constants.java From Noyze with Apache License 2.0 | 5 votes |
private static int zenModeFromListenerInterruptionFilter(int listenerInterruptionFilter) { switch (listenerInterruptionFilter) { case NotificationListenerService.INTERRUPTION_FILTER_ALL: return ZEN_MODE_OFF; case NotificationListenerService.INTERRUPTION_FILTER_PRIORITY: return ZEN_MODE_IMPORTANT_INTERRUPTIONS; case NotificationListenerService.INTERRUPTION_FILTER_NONE: return ZEN_MODE_NO_INTERRUPTIONS; default: return ZEN_MODE_OFF; } }
Example 7
Source File: PPNotificationListenerService.java From PhoneProfilesPlus with Apache License 2.0 | 4 votes |
@Override public void onInterruptionFilterChanged(int interruptionFilter) { super.onInterruptionFilterChanged(interruptionFilter); //CallsCounter.logCounter(getApplicationContext(), "PPNotificationListenerService.onInterruptionFilterChanged", "PPNotificationListenerService_onInterruptionFilterChanged"); boolean a60 = (android.os.Build.VERSION.SDK_INT == 23) && Build.VERSION.RELEASE.equals("6.0"); if (/*((android.os.Build.VERSION.SDK_INT >= 21) &&*/ /*(android.os.Build.VERSION.SDK_INT < 23)) ||*/ a60) { /*if (PPApplication.logEnabled()) { PPApplication.logE(TAG, "onInterruptionFilterChanged(interruptionFilter=" + interruptionFilter + ')'); PPApplication.logE(TAG, "onInterruptionFilterChanged(internalChange=" + RingerModeChangeReceiver.internalChange + ")"); }*/ if (!RingerModeChangeReceiver.internalChange) { final AudioManager audioManager = (AudioManager) getApplicationContext().getSystemService(Context.AUDIO_SERVICE); int ringerMode = AudioManager.RINGER_MODE_NORMAL; if (audioManager != null) ringerMode = audioManager.getRingerMode(); // convert to profile zenMode int zenMode = 0; switch (interruptionFilter) { case NotificationListenerService.INTERRUPTION_FILTER_ALL: //if (ActivateProfileHelper.vibrationIsOn(/*getApplicationContext(), */audioManager, true)) if (ringerMode == AudioManager.RINGER_MODE_VIBRATE) zenMode = 4; else zenMode = 1; break; case NotificationListenerService.INTERRUPTION_FILTER_PRIORITY: //if (ActivateProfileHelper.vibrationIsOn(/*getApplicationContext(), */audioManager, true)) if (ringerMode == AudioManager.RINGER_MODE_VIBRATE) zenMode = 5; else zenMode = 2; break; case NotificationListenerService.INTERRUPTION_FILTER_NONE: zenMode = 3; break; case NotificationListenerService.INTERRUPTION_FILTER_ALARMS: // new filter - Alarm only - Android M zenMode = 6; break; } //PPApplication.logE(TAG, "onInterruptionFilterChanged(zenMode=" + zenMode + ')'); if (zenMode != 0) { RingerModeChangeReceiver.notUnlinkVolumes = true; ActivateProfileHelper.saveRingerMode(getApplicationContext(), 5); ActivateProfileHelper.saveZenMode(getApplicationContext(), zenMode); } } //RingerModeChangeReceiver.setAlarmForDisableInternalChange(getApplicationContext()); } }