Search in sources :

Example 21 with Condition

use of android.service.notification.Condition in project android_frameworks_base by AOSPA.

the class ZenModePanel method handleUpdateZen.

private void handleUpdateZen(int zen) {
    if (mSessionZen != -1 && mSessionZen != zen) {
        setExpanded(isShown());
        mSessionZen = zen;
    }
    mZenButtons.setSelectedValue(zen, false);
    updateWidgets();
    handleUpdateConditions();
    if (mExpanded) {
        final Condition selected = getSelectedCondition();
        if (!Objects.equals(mExitCondition, selected)) {
            select(selected);
        }
    }
}
Also used : Condition(android.service.notification.Condition)

Example 22 with Condition

use of android.service.notification.Condition in project android_frameworks_base by AOSPA.

the class ZenModePanel method handleUpdateConditions.

private void handleUpdateConditions() {
    if (mTransitionHelper.isTransitioning()) {
        return;
    }
    final int conditionCount = mConditions == null ? 0 : mConditions.length;
    if (DEBUG)
        Log.d(mTag, "handleUpdateConditions conditionCount=" + conditionCount);
    // forever
    bind(forever(), mZenRadioGroupContent.getChildAt(FOREVER_CONDITION_INDEX), FOREVER_CONDITION_INDEX);
    // countdown
    if (mCountdownConditionSupported && mTimeCondition != null) {
        bind(mTimeCondition, mZenRadioGroupContent.getChildAt(COUNTDOWN_CONDITION_INDEX), COUNTDOWN_CONDITION_INDEX);
    }
    // countdown until alarm
    if (mCountdownConditionSupported) {
        Condition nextAlarmCondition = getTimeUntilNextAlarmCondition();
        if (nextAlarmCondition != null) {
            mZenRadioGroup.getChildAt(COUNTDOWN_ALARM_CONDITION_INDEX).setVisibility(View.VISIBLE);
            mZenRadioGroupContent.getChildAt(COUNTDOWN_ALARM_CONDITION_INDEX).setVisibility(View.VISIBLE);
            bind(nextAlarmCondition, mZenRadioGroupContent.getChildAt(COUNTDOWN_ALARM_CONDITION_INDEX), COUNTDOWN_ALARM_CONDITION_INDEX);
        } else {
            mZenRadioGroup.getChildAt(COUNTDOWN_ALARM_CONDITION_INDEX).setVisibility(View.GONE);
            mZenRadioGroupContent.getChildAt(COUNTDOWN_ALARM_CONDITION_INDEX).setVisibility(View.GONE);
        }
    }
    // ensure something is selected
    if (mExpanded && isShown()) {
        ensureSelection();
    }
    mZenConditions.setVisibility(mSessionZen != Global.ZEN_MODE_OFF ? View.VISIBLE : View.GONE);
}
Also used : Condition(android.service.notification.Condition)

Example 23 with Condition

use of android.service.notification.Condition in project android_frameworks_base by AOSPA.

the class ZenModePanel method onClickTimeButton.

private void onClickTimeButton(View row, ConditionTag tag, boolean up, int rowId) {
    MetricsLogger.action(mContext, MetricsEvent.QS_DND_TIME, up);
    Condition newCondition = null;
    final int N = MINUTE_BUCKETS.length;
    if (mBucketIndex == -1) {
        // not on a known index, search for the next or prev bucket by time
        final Uri conditionId = getConditionId(tag.condition);
        final long time = ZenModeConfig.tryParseCountdownConditionId(conditionId);
        final long now = System.currentTimeMillis();
        for (int i = 0; i < N; i++) {
            int j = up ? i : N - 1 - i;
            final int bucketMinutes = MINUTE_BUCKETS[j];
            final long bucketTime = now + bucketMinutes * MINUTES_MS;
            if (up && bucketTime > time || !up && bucketTime < time) {
                mBucketIndex = j;
                newCondition = ZenModeConfig.toTimeCondition(mContext, bucketTime, bucketMinutes, ActivityManager.getCurrentUser(), false);
                break;
            }
        }
        if (newCondition == null) {
            mBucketIndex = DEFAULT_BUCKET_INDEX;
            newCondition = ZenModeConfig.toTimeCondition(mContext, MINUTE_BUCKETS[mBucketIndex], ActivityManager.getCurrentUser());
        }
    } else {
        // on a known index, simply increment or decrement
        mBucketIndex = Math.max(0, Math.min(N - 1, mBucketIndex + (up ? 1 : -1)));
        newCondition = ZenModeConfig.toTimeCondition(mContext, MINUTE_BUCKETS[mBucketIndex], ActivityManager.getCurrentUser());
    }
    mTimeCondition = newCondition;
    bind(mTimeCondition, row, rowId);
    tag.rb.setChecked(true);
    select(mTimeCondition);
    announceConditionSelection(tag);
}
Also used : Condition(android.service.notification.Condition) Uri(android.net.Uri)

Example 24 with Condition

use of android.service.notification.Condition in project android_frameworks_base by AOSPA.

the class ZenModePanel method handleUpdateManualRule.

private void handleUpdateManualRule(ZenRule rule) {
    final int zen = rule != null ? rule.zenMode : Global.ZEN_MODE_OFF;
    handleUpdateZen(zen);
    final Condition c = rule != null ? rule.condition : null;
    handleExitConditionChanged(c);
}
Also used : Condition(android.service.notification.Condition)

Example 25 with Condition

use of android.service.notification.Condition in project android_frameworks_base by AOSPA.

the class ConditionProviders method notifyConditions.

public void notifyConditions(String pkg, ManagedServiceInfo info, Condition[] conditions) {
    synchronized (mMutex) {
        if (DEBUG)
            Slog.d(TAG, "notifyConditions pkg=" + pkg + " info=" + info + " conditions=" + (conditions == null ? null : Arrays.asList(conditions)));
        conditions = removeDuplicateConditions(pkg, conditions);
        if (conditions == null || conditions.length == 0)
            return;
        final int N = conditions.length;
        for (int i = 0; i < N; i++) {
            final Condition c = conditions[i];
            final ConditionRecord r = getRecordLocked(c.id, info.component, true);
            r.info = info;
            r.condition = c;
        }
    }
    final int N = conditions.length;
    for (int i = 0; i < N; i++) {
        final Condition c = conditions[i];
        if (mCallback != null) {
            mCallback.onConditionChanged(c.id, c);
        }
    }
}
Also used : Condition(android.service.notification.Condition)

Aggregations

Condition (android.service.notification.Condition)41 Uri (android.net.Uri)20 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 AudioManager (android.media.AudioManager)1