Skip to content

Commit bf162f7

Browse files
committed
Apply PR comment
1 parent 3fcdb70 commit bf162f7

File tree

3 files changed

+14
-15
lines changed

3 files changed

+14
-15
lines changed

app/src/main/kotlin/io/homeassistant/companion/android/settings/ConnectionSecurityLevelFragment.kt

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,21 @@ import io.homeassistant.companion.android.onboarding.locationforsecureconnection
4747
* This fragment is temporary and should be removed once the app fully migrates to Compose Navigation.
4848
*/
4949
@AndroidEntryPoint
50-
class ConnectionSecurityLevelFragment : Fragment() {
50+
class ConnectionSecurityLevelFragment private constructor() : Fragment() {
5151

5252
companion object {
5353
const val RESULT_KEY = "connection_security_level_result"
54-
const val EXTRA_SERVER = "server_id"
55-
const val EXTRA_HANDLE_ALL_INSETS = "handle_all_insets"
54+
private const val EXTRA_SERVER = "server_id"
55+
private const val EXTRA_HANDLE_ALL_INSETS = "handle_all_insets"
56+
57+
fun newInstance(serverId: Int, handleAllInsets: Boolean = false): ConnectionSecurityLevelFragment {
58+
return ConnectionSecurityLevelFragment().apply {
59+
arguments = bundleOf(
60+
EXTRA_SERVER to serverId,
61+
EXTRA_HANDLE_ALL_INSETS to handleAllInsets,
62+
)
63+
}
64+
}
5665
}
5766

5867
private val viewModel: LocationForSecureConnectionViewModel by createViewModelLazy(

app/src/main/kotlin/io/homeassistant/companion/android/settings/server/ServerSettingsFragment.kt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,7 @@ class ServerSettingsFragment :
182182
findPreference<Preference>("connection_security_level")?.let {
183183
it.setOnPreferenceClickListener {
184184
parentFragmentManager.commit {
185-
replace(
186-
R.id.content_full_screen,
187-
ConnectionSecurityLevelFragment::class.java,
188-
Bundle().apply { putInt(ConnectionSecurityLevelFragment.EXTRA_SERVER, serverId) },
189-
)
185+
replace(R.id.content_full_screen, ConnectionSecurityLevelFragment.newInstance(serverId))
190186
addToBackStack(null)
191187
}
192188
return@setOnPreferenceClickListener true

app/src/main/kotlin/io/homeassistant/companion/android/webview/WebViewActivity.kt

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1424,14 +1424,8 @@ class WebViewActivity :
14241424
}
14251425
}
14261426

1427-
val fragment = ConnectionSecurityLevelFragment().apply {
1428-
arguments = Bundle().apply {
1429-
putInt(ConnectionSecurityLevelFragment.EXTRA_SERVER, serverId)
1430-
putBoolean(ConnectionSecurityLevelFragment.EXTRA_HANDLE_ALL_INSETS, true)
1431-
}
1432-
}
14331427
supportFragmentManager.beginTransaction()
1434-
.replace(android.R.id.content, fragment)
1428+
.replace(android.R.id.content, ConnectionSecurityLevelFragment.newInstance(serverId, true))
14351429
.addToBackStack(null)
14361430
.commit()
14371431
}

0 commit comments

Comments
 (0)