Search in sources :

Example 1 with Condition

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

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 2 with Condition

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

the class ConditionProviders method removeDuplicateConditions.

private Condition[] removeDuplicateConditions(String pkg, Condition[] conditions) {
    if (conditions == null || conditions.length == 0)
        return null;
    final int N = conditions.length;
    final ArrayMap<Uri, Condition> valid = new ArrayMap<Uri, Condition>(N);
    for (int i = 0; i < N; i++) {
        final Uri id = conditions[i].id;
        if (valid.containsKey(id)) {
            Slog.w(TAG, "Ignoring condition from " + pkg + " for duplicate id: " + id);
            continue;
        }
        valid.put(id, conditions[i]);
    }
    if (valid.size() == 0)
        return null;
    if (valid.size() == N)
        return conditions;
    final Condition[] rt = new Condition[valid.size()];
    for (int i = 0; i < rt.length; i++) {
        rt[i] = valid.valueAt(i);
    }
    return rt;
}
Also used : Condition(android.service.notification.Condition) ArrayMap(android.util.ArrayMap) Uri(android.net.Uri)

Example 3 with Condition

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

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)

Example 4 with Condition

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

the class ConditionProviders method removeDuplicateConditions.

private Condition[] removeDuplicateConditions(String pkg, Condition[] conditions) {
    if (conditions == null || conditions.length == 0)
        return null;
    final int N = conditions.length;
    final ArrayMap<Uri, Condition> valid = new ArrayMap<Uri, Condition>(N);
    for (int i = 0; i < N; i++) {
        final Uri id = conditions[i].id;
        if (valid.containsKey(id)) {
            Slog.w(TAG, "Ignoring condition from " + pkg + " for duplicate id: " + id);
            continue;
        }
        valid.put(id, conditions[i]);
    }
    if (valid.size() == 0)
        return null;
    if (valid.size() == N)
        return conditions;
    final Condition[] rt = new Condition[valid.size()];
    for (int i = 0; i < rt.length; i++) {
        rt[i] = valid.valueAt(i);
    }
    return rt;
}
Also used : Condition(android.service.notification.Condition) ArrayMap(android.util.ArrayMap) Uri(android.net.Uri)

Example 5 with Condition

use of android.service.notification.Condition in project platform_frameworks_base by android.

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)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