Skip to content
Snippets Groups Projects
Commit ac39b921 authored by Janne Mareike Koschinski's avatar Janne Mareike Koschinski
Browse files

Correctly close settings after saving

parent e69ae403
Branches
Tags
No related merge requests found
package de.kuschku.quasseldroid
import android.support.test.InstrumentationRegistry
import android.support.test.runner.AndroidJUnit4
import org.junit.Assert.assertEquals
import org.junit.Test
import org.junit.runner.RunWith
/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getTargetContext()
assertEquals("de.kuschku.quasseldroid_ng", appContext.packageName)
}
}
...@@ -20,11 +20,11 @@ abstract class SettingsFragment : ServiceBoundFragment() { ...@@ -20,11 +20,11 @@ abstract class SettingsFragment : ServiceBoundFragment() {
override fun onOptionsItemSelected(item: MenuItem?) = when (item?.itemId) { override fun onOptionsItemSelected(item: MenuItem?) = when (item?.itemId) {
R.id.action_save -> { R.id.action_save -> {
onSave() if (onSave()) activity?.finish()
true true
} }
else -> super.onOptionsItemSelected(item) else -> super.onOptionsItemSelected(item)
} }
abstract fun onSave() abstract fun onSave(): Boolean
} }
\ No newline at end of file
...@@ -80,8 +80,7 @@ class NetworkConfigFragment : SettingsFragment() { ...@@ -80,8 +80,7 @@ class NetworkConfigFragment : SettingsFragment() {
} }
override fun onSave() { override fun onSave() = networkConfig?.let {
networkConfig?.let {
val config = it.copy() val config = it.copy()
config.setPingTimeoutEnabled(pingTimeoutEnabled.isChecked) config.setPingTimeoutEnabled(pingTimeoutEnabled.isChecked)
...@@ -96,6 +95,7 @@ class NetworkConfigFragment : SettingsFragment() { ...@@ -96,6 +95,7 @@ class NetworkConfigFragment : SettingsFragment() {
val properties = config.toVariantMap() val properties = config.toVariantMap()
it.requestUpdate(properties) it.requestUpdate(properties)
}
} true
} ?: false
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment