Search in sources :

Example 46 with Condition

use of android.service.notification.Condition in project platform_packages_apps_Settings by BlissRoms.

the class ZenModeVoiceActivity method onVoiceSettingInteraction.

@Override
protected boolean onVoiceSettingInteraction(Intent intent) {
    if (intent.hasExtra(EXTRA_DO_NOT_DISTURB_MODE_ENABLED)) {
        int minutes = intent.getIntExtra(EXTRA_DO_NOT_DISTURB_MODE_MINUTES, -1);
        Condition condition = null;
        int mode = Global.ZEN_MODE_OFF;
        if (intent.getBooleanExtra(EXTRA_DO_NOT_DISTURB_MODE_ENABLED, false)) {
            if (minutes > 0) {
                condition = ZenModeConfig.toTimeCondition(this, minutes, UserHandle.myUserId());
            }
            mode = Global.ZEN_MODE_ALARMS;
        }
        setZenModeConfig(mode, condition);
        AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
        if (audioManager != null) {
            // Show the current Zen Mode setting.
            audioManager.adjustStreamVolume(AudioManager.STREAM_NOTIFICATION, AudioManager.ADJUST_SAME, AudioManager.FLAG_SHOW_UI);
        }
        notifySuccess(getChangeSummary(mode, minutes));
    } else {
        Log.v(TAG, "Missing extra android.provider.Settings.EXTRA_DO_NOT_DISTURB_MODE_ENABLED");
        finish();
    }
    return false;
}
Also used : Condition(android.service.notification.Condition) AudioManager(android.media.AudioManager)

Example 47 with Condition

use of android.service.notification.Condition in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ZenModeVoiceActivity method onVoiceSettingInteraction.

@Override
protected boolean onVoiceSettingInteraction(Intent intent) {
    if (intent.hasExtra(EXTRA_DO_NOT_DISTURB_MODE_ENABLED)) {
        int minutes = intent.getIntExtra(EXTRA_DO_NOT_DISTURB_MODE_MINUTES, -1);
        Condition condition = null;
        int mode = Global.ZEN_MODE_OFF;
        if (intent.getBooleanExtra(EXTRA_DO_NOT_DISTURB_MODE_ENABLED, false)) {
            if (minutes > 0) {
                condition = ZenModeConfig.toTimeCondition(this, minutes, UserHandle.myUserId());
            }
            mode = Global.ZEN_MODE_ALARMS;
        }
        setZenModeConfig(mode, condition);
        AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
        if (audioManager != null) {
            // Show the current Zen Mode setting.
            audioManager.adjustStreamVolume(AudioManager.STREAM_NOTIFICATION, AudioManager.ADJUST_SAME, AudioManager.FLAG_SHOW_UI);
        }
        notifySuccess(getChangeSummary(mode, minutes));
    } else {
        Log.v(TAG, "Missing extra android.provider.Settings.EXTRA_DO_NOT_DISTURB_MODE_ENABLED");
        finish();
    }
    return false;
}
Also used : Condition(android.service.notification.Condition) AudioManager(android.media.AudioManager)

Aggregations

Condition (android.service.notification.Condition)47 Uri (android.net.Uri)20 AudioManager (android.media.AudioManager)7 EventInfo (android.service.notification.ZenModeConfig.EventInfo)5 ArrayMap (android.util.ArrayMap)5 View (android.view.View)5 CompoundButton (android.widget.CompoundButton)5 OnCheckedChangeListener (android.widget.CompoundButton.OnCheckedChangeListener)5 ImageView (android.widget.ImageView)5 TextView (android.widget.TextView)5 CheckEventResult (com.android.server.notification.CalendarTracker.CheckEventResult)5 ArrayList (java.util.ArrayList)5