<commit_before>package io.envoyproxy.envoymobile.helloenvoykotlin

import android.app.Activity
import android.os.Bundle
import android.os.Handler
import android.os.HandlerThread
import android.util.Log
import androidx.recyclerview.widget.DividerItemDecoration
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import io.envoyproxy.envoymobile.AndroidEngineBuilder
import io.envoyproxy.envoymobile.Element
import io.envoyproxy.envoymobile.Engine
import io.envoyproxy.envoymobile.LogLevel
import io.envoyproxy.envoymobile.RequestHeadersBuilder
import io.envoyproxy.envoymobile.RequestMethod
import io.envoyproxy.envoymobile.UpstreamHttpProtocol
import io.envoyproxy.envoymobile.shared.Failure
import io.envoyproxy.envoymobile.shared.ResponseRecyclerViewAdapter
import io.envoyproxy.envoymobile.shared.Success
import java.io.IOException
import java.util.concurrent.Executors
import java.util.concurrent.TimeUnit

private const val REQUEST_HANDLER_THREAD_NAME = "hello_envoy_kt"
private const val REQUEST_AUTHORITY = "api.lyft.com"
private const val REQUEST_PATH = "/ping"
private const val REQUEST_SCHEME = "https"
private val FILTERED_HEADERS = setOf(
  "server",
  "filter-demo",
  "buffer-filter-demo",
  "async-filter-demo",
  "x-envoy-upstream-service-time"
)

/**
 * The main activity of the app.
 */
class MainActivity : Activity() {
  private val thread = HandlerThread(REQUEST_HANDLER_THREAD_NAME)
  private lateinit var recyclerView: RecyclerView
  private lateinit var viewAdapter: ResponseRecyclerViewAdapter
  private lateinit var engine: Engine

  @Suppress("MaxLineLength")
  override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main)

    engine = AndroidEngineBuilder(application)
      .addLogLevel(LogLevel.DEBUG)
      .enableInterfaceBinding(true)
      .addPlatformFilter(::DemoFilter)
      .addPlatformFilter(::BufferDemoFilter)
      .addPlatformFilter(::AsyncDemoFilter)
      .addNativeFilter("envoy.filters.http.buffer", "{\"@type\":\"type.googleapis.com/envoy.extensions.filters.http.buffer.v3.Buffer\",\"max_request_bytes\":5242880}")
      .addStringAccessor("demo-accessor", { "PlatformString" })
      .setOnEngineRunning { Log.d("MainActivity", "Envoy async internal setup completed") }
      .setEventTracker({
        for (entry in it.entries) {
          Log.d("MainActivity", "Event emitted: ${entry.key}, ${entry.value}")
        }
      })
      .setLogger {
        Log.d("MainActivity", it)
      }<commit_msg>example apps: disable interface binding (#2456)<commit_after>package io.envoyproxy.envoymobile.helloenvoykotlin

import android.app.Activity
import android.os.Bundle
import android.os.Handler
import android.os.HandlerThread
import android.util.Log
import androidx.recyclerview.widget.DividerItemDecoration
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import io.envoyproxy.envoymobile.AndroidEngineBuilder
import io.envoyproxy.envoymobile.Element
import io.envoyproxy.envoymobile.Engine
import io.envoyproxy.envoymobile.LogLevel
import io.envoyproxy.envoymobile.RequestHeadersBuilder
import io.envoyproxy.envoymobile.RequestMethod
import io.envoyproxy.envoymobile.UpstreamHttpProtocol
import io.envoyproxy.envoymobile.shared.Failure
import io.envoyproxy.envoymobile.shared.ResponseRecyclerViewAdapter
import io.envoyproxy.envoymobile.shared.Success
import java.io.IOException
import java.util.concurrent.Executors
import java.util.concurrent.TimeUnit

private const val REQUEST_HANDLER_THREAD_NAME = "hello_envoy_kt"
private const val REQUEST_AUTHORITY = "api.lyft.com"
private const val REQUEST_PATH = "/ping"
private const val REQUEST_SCHEME = "https"
private val FILTERED_HEADERS = setOf(
  "server",
  "filter-demo",
  "buffer-filter-demo",
  "async-filter-demo",
  "x-envoy-upstream-service-time"
)

/**
 * The main activity of the app.
 */
class MainActivity : Activity() {
  private val thread = HandlerThread(REQUEST_HANDLER_THREAD_NAME)
  private lateinit var recyclerView: RecyclerView
  private lateinit var viewAdapter: ResponseRecyclerViewAdapter
  private lateinit var engine: Engine

  @Suppress("MaxLineLength")
  override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main)

    engine = AndroidEngineBuilder(application)
      .addLogLevel(LogLevel.DEBUG)
      .addPlatformFilter(::DemoFilter)
      .addPlatformFilter(::BufferDemoFilter)
      .addPlatformFilter(::AsyncDemoFilter)
      .addNativeFilter("envoy.filters.http.buffer", "{\"@type\":\"type.googleapis.com/envoy.extensions.filters.http.buffer.v3.Buffer\",\"max_request_bytes\":5242880}")
      .addStringAccessor("demo-accessor", { "PlatformString" })
      .setOnEngineRunning { Log.d("MainActivity", "Envoy async internal setup completed") }
      .setEventTracker({
        for (entry in it.entries) {
          Log.d("MainActivity", "Event emitted: ${entry.key}, ${entry.value}")
        }
      })
      .setLogger {
        Log.d("MainActivity", it)
      }
{'fraction_non_alphanumeric': 0.10217138425746414, 'fraction_numerical': 0.0038774718883288098, 'mean_word_length': 5.08372641509434, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, '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': '4253264', 'n_tokens_mistral': 1588, 'n_tokens_neox': 1534, 'n_words': 282}