<commit_before>package jp.toastkid.yobidashi.browser

import android.content.Context
import android.graphics.drawable.BitmapDrawable
import android.support.v7.app.AlertDialog
import android.webkit.WebView

import jp.toastkid.yobidashi.R

/**
 * Method object of displaying page information dialog.

 * @author toastkidjp
 */
internal class PageInformationDialog(private val webView: WebView) {

    private val context: Context

    init {
        this.context = webView.context
    }

    fun show() {
        val builder = AlertDialog.Builder(context)
                .setTitle(R.string.title_menu_page_information)
                .setMessage("Title: " + webView.title
                        + System.getProperty("line.separator")
                        + "URL: " + webView.url
                        + System.getProperty("line.separator")
                )
                .setCancelable(true)
                .setPositiveButton(R.string.close) { d, i -> d.dismiss() }
        if (webView.favicon != null) {
            builder.setIcon(BitmapDrawable(context.resources, webView.favicon))
        }
        builder.show()
    }
}<commit_msg>Implement copy URL to page information dialog.<commit_after>package jp.toastkid.yobidashi.browser

import android.content.Context
import android.content.DialogInterface
import android.graphics.drawable.BitmapDrawable
import android.support.v7.app.AlertDialog
import android.webkit.WebView

import jp.toastkid.yobidashi.R
import jp.toastkid.yobidashi.libs.Toaster
import jp.toastkid.yobidashi.libs.clip.Clipboard
import jp.toastkid.yobidashi.libs.preference.PreferenceApplier

/**
 * Method object of displaying page information dialog.
 *
 * @param webView
 * @author toastkidjp
 */
internal class PageInformationDialog(private val webView: WebView) {

    /**
     * Context.
     */
    private val context: Context = webView.context

    /**
     * Show dialog.
     */
    fun show() {
        val builder = AlertDialog.Builder(context)
                .setTitle(R.string.title_menu_page_information)
                .setMessage(makeMessage())
                .setCancelable(true)
                .setNeutralButton("Clip URL") { d, _ -> clipUrl(d) }
                .setPositiveButton(R.string.close) { d, _ -> d.dismiss() }
        if (webView.favicon != null) {
            builder.setIcon(BitmapDrawable(context.resources, webView.favicon))
        }
        builder.show()
    }

    /**
     * Copy URL to Clipboard.
     *
     * @param d
     */
    private fun clipUrl(d: DialogInterface) {
        Clipboard.clip(context, webView.url)
        Toaster.snackShort(
                webView,
                "It has copied URL to clipboard.${lineSeparator}${webView.url}",
                PreferenceApplier(context).colorPair()
        )
        d.dismiss()
    }

    /**
     * Make message.
     */
    private fun makeMessage(): String =
            "Title: ${webView.title}${lineSeparator}URL: ${webView.url}${lineSeparator}"

    companion object {

        /**
         * Line separator.
         */
        private val lineSeparator = System.getProperty("line.separator")

    }
}
{'fraction_non_alphanumeric': 0.10750636132315522, 'fraction_numerical': 0.0006361323155216285, 'mean_word_length': 2.265835929387331, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '7152244', 'n_tokens_mistral': 943, 'n_tokens_neox': 890, 'n_words': 168}