From fa002fbd88ba1b18f4d37e5848f638240320e8a2 Mon Sep 17 00:00:00 2001 From: Aditya Kulkarni Date: Tue, 12 Feb 2019 13:29:24 -0800 Subject: [PATCH] beta4 --- .../adityapk/zcash/zqwandroid/ConnectionManager.kt | 4 ++++ .../adityapk/zcash/zqwandroid/SettingsActivity.kt | 12 +++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/adityapk/zcash/zqwandroid/ConnectionManager.kt b/app/src/main/java/com/adityapk/zcash/zqwandroid/ConnectionManager.kt index e0ebdd1..6e56506 100644 --- a/app/src/main/java/com/adityapk/zcash/zqwandroid/ConnectionManager.kt +++ b/app/src/main/java/com/adityapk/zcash/zqwandroid/ConnectionManager.kt @@ -76,6 +76,10 @@ object ConnectionManager { } } + fun closeConnection() { + DataModel.ws?.close(1000, "Close requested") + } + fun sendRefreshSignal(finished: Boolean) { val i = Intent(DATA_SIGNAL) i.putExtra("action", "refresh") diff --git a/app/src/main/java/com/adityapk/zcash/zqwandroid/SettingsActivity.kt b/app/src/main/java/com/adityapk/zcash/zqwandroid/SettingsActivity.kt index 23a0216..72a90ff 100644 --- a/app/src/main/java/com/adityapk/zcash/zqwandroid/SettingsActivity.kt +++ b/app/src/main/java/com/adityapk/zcash/zqwandroid/SettingsActivity.kt @@ -15,17 +15,27 @@ class SettingsActivity : AppCompatActivity() { btnDisconnect.setOnClickListener { DataModel.setConnString(null, applicationContext) DataModel.clear() + ConnectionManager.closeConnection() + updateUI() } chkDisallowInternet.setOnClickListener { - DataModel.setGlobalAllowInternet(chkDisallowInternet.isChecked) + DataModel.setGlobalAllowInternet(!chkDisallowInternet.isChecked) + + if (chkDisallowInternet.isChecked) { + ConnectionManager.closeConnection() + } + + updateUI() } } fun updateUI() { txtSettingsConnString.text = DataModel.getConnString(ZQWApp.appContext!!) ?: "Not Connected" + chkDisallowInternet.isChecked = !DataModel.getGlobalAllowInternet() + lblVersionName.text = BuildConfig.VERSION_NAME lblServerVersion.text = DataModel.mainResponseData?.serverversion ?: "Not Connected" }