<commit_before>/*
 * Copyright (c) 2019 toastkidjp.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompany this distribution.
 * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html.
 */
package jp.toastkid.yobidashi.notification.morning

import android.annotation.TargetApi
import android.app.Notification
import android.app.NotificationChannel
import android.app.NotificationManager
import android.content.Context
import android.os.Build
import android.widget.RemoteViews
import androidx.core.app.NotificationCompat
import jp.toastkid.yobidashi.R

/**
 * @author toastkidjp
 */
class DailyNotification {

    fun show(context: Context) {
        val notificationManager =
                context.getSystemService(Context.NOTIFICATION_SERVICE) as? NotificationManager
                        ?: return
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            val name = context.getString(R.string.title_show_daily_notification)
            notificationManager.createNotificationChannel(makeNotificationChannel(name))
        }
        notificationManager.notify(2, makeNotification(context, RemoteViewsFactory().invoke(context)))
    }

    @TargetApi(Build.VERSION_CODES.O)
    private fun makeNotificationChannel(name: String) =
            NotificationChannel(
                    "daily",
                    name,
                    NotificationManager.IMPORTANCE_HIGH
            )

    /**
     * Make notification widget.
     *
     * @param context
     */
    private fun makeNotification(context: Context, contentView: RemoteViews): Notification {
        return NotificationCompat.Builder(context, "daily")
                .setSmallIcon(R.drawable.ic_search_white)
                .setCustomContentView(contentView)
                .setAutoCancel(false)
                .setPriority(NotificationCompat.PRIORITY_HIGH)
                .build()
    }
}<commit_msg>refactor #504 Extract channel ID to constant.<commit_after>/*
 * Copyright (c) 2019 toastkidjp.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompany this distribution.
 * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html.
 */
package jp.toastkid.yobidashi.notification.morning

import android.annotation.TargetApi
import android.app.Notification
import android.app.NotificationChannel
import android.app.NotificationManager
import android.content.Context
import android.os.Build
import android.widget.RemoteViews
import androidx.core.app.NotificationCompat
import jp.toastkid.yobidashi.R

/**
 * @author toastkidjp
 */
class DailyNotification {

    fun show(context: Context) {
        val notificationManager =
                context.getSystemService(Context.NOTIFICATION_SERVICE) as? NotificationManager
                        ?: return
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            val name = context.getString(R.string.title_show_daily_notification)
            notificationManager.createNotificationChannel(makeNotificationChannel(name))
        }
        notificationManager.notify(2, makeNotification(context, RemoteViewsFactory().invoke(context)))
    }

    @TargetApi(Build.VERSION_CODES.O)
    private fun makeNotificationChannel(name: String) =
            NotificationChannel(
                    CHANNEL_ID,
                    name,
                    NotificationManager.IMPORTANCE_HIGH
            )

    /**
     * Make notification widget.
     *
     * @param context
     */
    private fun makeNotification(context: Context, contentView: RemoteViews): Notification {
        return NotificationCompat.Builder(context, CHANNEL_ID)
                .setSmallIcon(R.drawable.ic_search_white)
                .setCustomContentView(contentView)
                .setAutoCancel(false)
                .setPriority(NotificationCompat.PRIORITY_HIGH)
                .build()
    }

    companion object {
        private const val CHANNEL_ID = "daily"
    }
}
{'fraction_non_alphanumeric': 0.07976047904191617, 'fraction_numerical': 0.005029940119760479, 'mean_word_length': 2.786038077969175, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1222834', 'n_tokens_mistral': 1106, 'n_tokens_neox': 1034, 'n_words': 233}