diff options
Diffstat (limited to 'src/com/android/launcher3/dot/FolderDotInfo.java')
-rw-r--r-- | src/com/android/launcher3/dot/FolderDotInfo.java | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/src/com/android/launcher3/dot/FolderDotInfo.java b/src/com/android/launcher3/dot/FolderDotInfo.java new file mode 100644 index 000000000..b5eb8cd58 --- /dev/null +++ b/src/com/android/launcher3/dot/FolderDotInfo.java @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.launcher3.dot; + +import android.view.ViewDebug; + +import com.android.launcher3.Utilities; + +/** + * Subclass of DotInfo that only contains the dot count, which is + * the sum of all the Folder's items' notifications (each counts as 1). + */ +public class FolderDotInfo extends DotInfo { + + private static final int MIN_COUNT = 0; + + private int mNumNotifications; + + public FolderDotInfo() { + super(null); + } + + public void addDotInfo(DotInfo dotToAdd) { + if (dotToAdd == null) { + return; + } + mNumNotifications += dotToAdd.getNotificationKeys().size(); + mNumNotifications = Utilities.boundToRange( + mNumNotifications, MIN_COUNT, DotInfo.MAX_COUNT); + } + + public void subtractDotInfo(DotInfo dotToSubtract) { + if (dotToSubtract == null) { + return; + } + mNumNotifications -= dotToSubtract.getNotificationKeys().size(); + mNumNotifications = Utilities.boundToRange( + mNumNotifications, MIN_COUNT, DotInfo.MAX_COUNT); + } + + @Override + public int getNotificationCount() { + return mNumNotifications; + } + + @ViewDebug.ExportedProperty(category = "launcher") + public boolean hasDot() { + return mNumNotifications > 0; + } +} |