From 0826a65d68d4fe1c0253657ef229dd655d3c37f9 Mon Sep 17 00:00:00 2001 From: vadym Date: Sat, 4 Jul 2020 13:17:04 -0700 Subject: [PATCH] 1. minor fixes --- .../chronosx88/yggdrasil/DNSListActivity.kt | 3 ++- .../chronosx88/yggdrasil/PeerListActivity.kt | 15 +++++---------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/io/github/chronosx88/yggdrasil/DNSListActivity.kt b/app/src/main/java/io/github/chronosx88/yggdrasil/DNSListActivity.kt index 3f13284..7c1b209 100644 --- a/app/src/main/java/io/github/chronosx88/yggdrasil/DNSListActivity.kt +++ b/app/src/main/java/io/github/chronosx88/yggdrasil/DNSListActivity.kt @@ -45,7 +45,7 @@ class DNSListActivity : AppCompatActivity() { super.onCreate(savedInstanceState) setContentView(R.layout.activity_dns_list) setSupportActionBar(findViewById(R.id.toolbar)) - findViewById(R.id.fab).setOnClickListener { view -> + findViewById(R.id.fab).setOnClickListener { _ -> addNewDNS() } var extras = intent.extras @@ -88,6 +88,7 @@ class DNSListActivity : AppCompatActivity() { } + @Suppress("DEPRECATION") private fun addNewDNS() { val view: View = LayoutInflater.from(this).inflate(R.layout.new_dns_dialog, null) val countryCode: String = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { diff --git a/app/src/main/java/io/github/chronosx88/yggdrasil/PeerListActivity.kt b/app/src/main/java/io/github/chronosx88/yggdrasil/PeerListActivity.kt index c359c49..4f74ab2 100644 --- a/app/src/main/java/io/github/chronosx88/yggdrasil/PeerListActivity.kt +++ b/app/src/main/java/io/github/chronosx88/yggdrasil/PeerListActivity.kt @@ -61,7 +61,7 @@ class PeerListActivity : AppCompatActivity() { super.onCreate(savedInstanceState) setContentView(R.layout.activity_peer_list) setSupportActionBar(findViewById(R.id.toolbar)) - findViewById(R.id.fab).setOnClickListener { view -> + findViewById(R.id.fab).setOnClickListener { _ -> addNewPeer() } var extras = intent.extras @@ -141,7 +141,7 @@ class PeerListActivity : AppCompatActivity() { var ipInput = view.findViewById(R.id.ipInput) ipInput.requestFocus() schemaInput.showSoftInputOnFocus = false - schemaInput.setOnFocusChangeListener { v, b -> + schemaInput.setOnFocusChangeListener { v, _ -> if(schemaInput.isFocused) { onClickSchemaList(v) } @@ -149,9 +149,8 @@ class PeerListActivity : AppCompatActivity() { schemaInput.setOnClickListener { v-> onClickSchemaList(v) } - getPopupWindow(R.layout.spinner_item, resources.getStringArray(R.array.schemas), schemaInput, getString(R.string.schema)); - var ccp = view.findViewById(R.id.ccp) - ccp.setCountryForNameCode(countryCode) + getPopupWindow(R.layout.spinner_item, resources.getStringArray(R.array.schemas), schemaInput); + view.findViewById(R.id.ccp).setCountryForNameCode(countryCode) val ab: AlertDialog.Builder = AlertDialog.Builder(this) ab.setCancelable(true).setView(view) var ad = ab.show() @@ -193,8 +192,7 @@ class PeerListActivity : AppCompatActivity() { private fun getPopupWindow( textViewResourceId: Int, objects: Array, - editText: TextView, - hint: String? + editText: TextView ): PopupWindow? { // initialize a pop up window type val popupWindow = PopupWindow(this) @@ -208,9 +206,6 @@ class PeerListActivity : AppCompatActivity() { listView.onItemClickListener = adapter // some other visual settings popupWindow.isFocusable = true - //popupWindow.setWidth(400); - val display: Display = - (this.getSystemService(Context.WINDOW_SERVICE) as WindowManager).getDefaultDisplay() popupWindow.width = 320 popupWindow.height = WindowManager.LayoutParams.WRAP_CONTENT // set the list view as pop up window content