From 40eb1a83cdcde7c0178428ecb0ad880a363a97a3 Mon Sep 17 00:00:00 2001 From: Arne Schwabe Date: Tue, 11 Jul 2023 16:59:30 +0200 Subject: Fix some ANRs --- .../openvpn/fragments/OpenVpnPreferencesFragment.java | 1 - .../ui/java/de/blinkt/openvpn/fragments/Settings_IP.kt | 15 ++++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) (limited to 'main/src/ui/java') diff --git a/main/src/ui/java/de/blinkt/openvpn/fragments/OpenVpnPreferencesFragment.java b/main/src/ui/java/de/blinkt/openvpn/fragments/OpenVpnPreferencesFragment.java index a3c19955..802e0b49 100644 --- a/main/src/ui/java/de/blinkt/openvpn/fragments/OpenVpnPreferencesFragment.java +++ b/main/src/ui/java/de/blinkt/openvpn/fragments/OpenVpnPreferencesFragment.java @@ -46,7 +46,6 @@ public abstract class OpenVpnPreferencesFragment extends PreferenceFragmentCompa String profileUUID = savedInstanceState.getString(VpnProfile.EXTRA_PROFILEUUID); mProfile = ProfileManager.get(getActivity(), profileUUID); loadSettings(); - } } diff --git a/main/src/ui/java/de/blinkt/openvpn/fragments/Settings_IP.kt b/main/src/ui/java/de/blinkt/openvpn/fragments/Settings_IP.kt index 27e6854f..fa7e6f55 100644 --- a/main/src/ui/java/de/blinkt/openvpn/fragments/Settings_IP.kt +++ b/main/src/ui/java/de/blinkt/openvpn/fragments/Settings_IP.kt @@ -5,6 +5,7 @@ package de.blinkt.openvpn.fragments import android.os.Bundle +import android.view.View import androidx.preference.* import de.blinkt.openvpn.R import de.blinkt.openvpn.fragments.OpenVpnPreferencesFragment @@ -33,6 +34,19 @@ class Settings_IP : OpenVpnPreferencesFragment(), Preference.OnPreferenceChangeL // Load the preferences from an XML resource addPreferencesFromResource(R.xml.vpn_ipsettings) + bindPreferences() + loadSettings() + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + /* Bind the preferences early to avoid loadingSetting which is called + * from the superclass to access an uninitialised earlyinit property + */ + bindPreferences() + super.onViewCreated(view, savedInstanceState) + } + + private fun bindPreferences() { mIPv4 = findPreference("ipv4_address")!! mIPv6 = findPreference("ipv6_address")!! mUsePull = findPreference("usePull")!! @@ -45,7 +59,6 @@ class Settings_IP : OpenVpnPreferencesFragment(), Preference.OnPreferenceChangeL mNobind = findPreference("nobind")!! mUsePull.onPreferenceChangeListener = this mOverrideDNS.onPreferenceChangeListener = this - loadSettings() } -- cgit v1.2.3