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
No related branches found
No related tags found
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() {
override fun onOptionsItemSelected(item: MenuItem?) = when (item?.itemId) {
R.id.action_save -> {
onSave()
if (onSave()) activity?.finish()
true
}
else -> super.onOptionsItemSelected(item)
}
abstract fun onSave()
abstract fun onSave(): Boolean
}
\ No newline at end of file
......@@ -80,8 +80,7 @@ class NetworkConfigFragment : SettingsFragment() {
}
override fun onSave() {
networkConfig?.let {
override fun onSave() = networkConfig?.let {
val config = it.copy()
config.setPingTimeoutEnabled(pingTimeoutEnabled.isChecked)
......@@ -96,6 +95,7 @@ class NetworkConfigFragment : SettingsFragment() {
val properties = config.toVariantMap()
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