android.app.NotificationChannel#getLightColor ( )源码实例Demo

下面列出了android.app.NotificationChannel#getLightColor ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: android_9.0.0_r45   文件: RankingHelper.java
@VisibleForTesting
void lockFieldsForUpdate(NotificationChannel original, NotificationChannel update) {
    if (original.canBypassDnd() != update.canBypassDnd()) {
        update.lockFields(NotificationChannel.USER_LOCKED_PRIORITY);
    }
    if (original.getLockscreenVisibility() != update.getLockscreenVisibility()) {
        update.lockFields(NotificationChannel.USER_LOCKED_VISIBILITY);
    }
    if (original.getImportance() != update.getImportance()) {
        update.lockFields(NotificationChannel.USER_LOCKED_IMPORTANCE);
    }
    if (original.shouldShowLights() != update.shouldShowLights()
            || original.getLightColor() != update.getLightColor()) {
        update.lockFields(NotificationChannel.USER_LOCKED_LIGHTS);
    }
    if (!Objects.equals(original.getSound(), update.getSound())) {
        update.lockFields(NotificationChannel.USER_LOCKED_SOUND);
    }
    if (!Arrays.equals(original.getVibrationPattern(), update.getVibrationPattern())
            || original.shouldVibrate() != update.shouldVibrate()) {
        update.lockFields(NotificationChannel.USER_LOCKED_VIBRATION);
    }
    if (original.canShowBadge() != update.canShowBadge()) {
        update.lockFields(NotificationChannel.USER_LOCKED_SHOW_BADGE);
    }
}
 
private void loadNotificationRuleSettings() {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O ||
            mEditingRule == null || mEditingRule.settings == null ||
            mEditingRule.settings.notificationChannelId == null)
        return;
    android.app.NotificationManager mgr = (android.app.NotificationManager)
            getSystemService(NOTIFICATION_SERVICE);
    NotificationChannel channel =
            mgr.getNotificationChannel(mEditingRule.settings.notificationChannelId);

    mEditingRule.settings.soundEnabled = channel.getSound() != null;
    mEditingRule.settings.soundUri = null;
    if (channel.getSound() != null && !channel.getSound().equals(
            RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)))
        mEditingRule.settings.soundUri = channel.getSound().toString();

    mEditingRule.settings.vibrationEnabled = channel.shouldVibrate();
    if (channel.shouldVibrate())
        mEditingRule.settings.vibrationDuration = channel.getVibrationPattern() == null ||
                channel.getVibrationPattern().length != 2
                ? 0 : (int) channel.getVibrationPattern()[1];

    mEditingRule.settings.lightEnabled = channel.shouldShowLights();
    if (channel.shouldShowLights())
        mEditingRule.settings.light = channel.getLightColor();
}
 
源代码3 项目: xDrip   文件: NotificationChannels.java
@TargetApi(26)
private static int myhashcode(NotificationChannel x) {

    int result = x.getId() != null ? x.getId().hashCode() : 0;
    //result = 31 * result + (getName() != null ? getName().hashCode() : 0);
    //result = 31 * result + (getDescription() != null ? getDescription().hashCode() : 0);
    //result = 31 * result + getImportance();
    //result = 31 * result + (mBypassDnd ? 1 : 0);
    //result = 31 * result + getLockscreenVisibility();
    result = 31 * result + (x.getSound() != null ? x.getSound().hashCode() : 0);
    //result = 31 * result + (x.mLights ? 1 : 0);
    result = 31 * result + x.getLightColor();
    result = 31 * result + Arrays.hashCode(x.getVibrationPattern());
    //result = 31 * result + getUserLockedFields();
    //result = 31 * result + (mVibrationEnabled ? 1 : 0);
    //result = 31 * result + (mShowBadge ? 1 : 0);
    //result = 31 * result + (isDeleted() ? 1 : 0);
    //result = 31 * result + (getGroup() != null ? getGroup().hashCode() : 0);
    //result = 31 * result + (getAudioAttributes() != null ? getAudioAttributes().hashCode() : 0);
    //result = 31 * result + (isBlockableSystem() ? 1 : 0);
    return result;

}
 
源代码4 项目: xDrip-plus   文件: NotificationChannels.java
@TargetApi(26)
private static int myhashcode(NotificationChannel x) {

    int result = x.getId() != null ? x.getId().hashCode() : 0;
    //result = 31 * result + (getName() != null ? getName().hashCode() : 0);
    //result = 31 * result + (getDescription() != null ? getDescription().hashCode() : 0);
    //result = 31 * result + getImportance();
    //result = 31 * result + (mBypassDnd ? 1 : 0);
    //result = 31 * result + getLockscreenVisibility();
    result = 31 * result + (x.getSound() != null ? x.getSound().hashCode() : 0);
    //result = 31 * result + (x.mLights ? 1 : 0);
    result = 31 * result + x.getLightColor();
    result = 31 * result + Arrays.hashCode(x.getVibrationPattern());
    //result = 31 * result + getUserLockedFields();
    //result = 31 * result + (mVibrationEnabled ? 1 : 0);
    //result = 31 * result + (mShowBadge ? 1 : 0);
    //result = 31 * result + (isDeleted() ? 1 : 0);
    //result = 31 * result + (getGroup() != null ? getGroup().hashCode() : 0);
    //result = 31 * result + (getAudioAttributes() != null ? getAudioAttributes().hashCode() : 0);
    //result = 31 * result + (isBlockableSystem() ? 1 : 0);
    return result;

}
 
@SuppressWarnings("DoubleNegation")
private boolean hasNotificationRuleChanges() {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O ||
            mEditingRule == null || mEditingRule.settings.notificationChannelId == null)
        return false;
    android.app.NotificationManager mgr = (android.app.NotificationManager)
            getSystemService(NOTIFICATION_SERVICE);
    NotificationChannel channel =
            mgr.getNotificationChannel(mEditingRule.settings.notificationChannelId);

    Uri soundUri = mSoundEntry.getValue();
    if (channel.getSound() != soundUri &&
            (channel.getSound() == null || !channel.getSound().equals(soundUri)))
        return true;

    int vibrationDuration = mVibrationOptions[mVibrationEntry.getSelectedOption()];
    if (channel.shouldVibrate() != (vibrationDuration != 0))
        return true;
    if (channel.shouldVibrate()) {
        int channelVibrationDuration = channel.getVibrationPattern() == null ||
                channel.getVibrationPattern().length != 2
                ? -1 : (int) channel.getVibrationPattern()[1];
        if (channelVibrationDuration != vibrationDuration)
            return true;
    }

    if (channel.shouldShowLights() != (mColorEntry.getSelectedColorIndex() != 0))
        return true;
    //noinspection RedundantIfStatement
    if (channel.shouldShowLights() && channel.getLightColor() !=
            (mColorEntry.getSelectedColorIndex() == -1 ? 0 : mColorEntry.getSelectedColor()))
        return true;

    return false;
}