diff --git a/app/src/main/java/org/hydev/wearsync/ActivitySettings.kt b/app/src/main/java/org/hydev/wearsync/ActivitySettings.kt index acfb9f9..491f85a 100644 --- a/app/src/main/java/org/hydev/wearsync/ActivitySettings.kt +++ b/app/src/main/java/org/hydev/wearsync/ActivitySettings.kt @@ -1,18 +1,18 @@ package org.hydev.wearsync +import android.os.Build.MODEL import android.os.Bundle import androidx.appcompat.app.AppCompatActivity import androidx.preference.Preference import androidx.preference.PreferenceFragmentCompat +import com.influxdb.client.domain.WritePrecision import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.SupervisorJob import kotlinx.coroutines.launch - class ActivitySettings : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -48,7 +48,23 @@ class ActivitySettings : AppCompatActivity() view?.snack("Error: ${e.message}") } } - println("Clicked") + true + } + + findPreference("infTest2Button")!!.setOnPreferenceClickListener { + scope.launch { + try { + with(act.prefs.createInflux()) { + getWriteKotlinApi().writeRecord("ping host=\"$MODEL\"", WritePrecision.MS) + } + println("Success!") + view?.snack("Success!") + } + catch (e: Exception) { + e.printStackTrace() + view?.snack("Error: ${e.message}") + } + } true } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c12b414..605ffa7 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -9,6 +9,8 @@ Organization Bucket Token - Test connection - Click here to test your connection to the influxdb server. + Test Connection + Test your connection to the influxdb server. + Test Authentication + Test if your token has permissions. \ No newline at end of file diff --git a/app/src/main/res/xml/root_preferences.xml b/app/src/main/res/xml/root_preferences.xml index 33bce52..e062356 100644 --- a/app/src/main/res/xml/root_preferences.xml +++ b/app/src/main/res/xml/root_preferences.xml @@ -32,6 +32,11 @@ app:title="@string/pref_influx_test" app:summary="@string/pref_influx_test_sub" /> + + \ No newline at end of file