From 1bb8a10633e4b085e4ba24fcdb5fe393e4c2d4a0 Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Thu, 26 May 2022 05:44:27 +0530 Subject: ui: remove unnecessary boolean check This check was added in 3c31c340d86f when the kernel module loader was introduced into the app lifecycle, to avoid attempting to start a root shell twice. When the module loader was removed in a03ad51622d338d1c, this flag was accidentally left in when it should have been deleted. Signed-off-by: Harsh Shandilya --- ui/src/main/java/com/wireguard/android/Application.kt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'ui/src/main/java') diff --git a/ui/src/main/java/com/wireguard/android/Application.kt b/ui/src/main/java/com/wireguard/android/Application.kt index d9dcb637..f26ca926 100644 --- a/ui/src/main/java/com/wireguard/android/Application.kt +++ b/ui/src/main/java/com/wireguard/android/Application.kt @@ -64,11 +64,9 @@ class Application : android.app.Application() { private suspend fun determineBackend(): Backend { var backend: Backend? = null - var didStartRootShell = false if (UserKnobs.enableKernelModule.first() && WgQuickBackend.hasKernelSupport()) { try { - if (!didStartRootShell) - rootShell.start() + rootShell.start() val wgQuickBackend = WgQuickBackend(applicationContext, rootShell, toolsInstaller) wgQuickBackend.setMultipleTunnels(UserKnobs.multipleTunnels.first()) backend = wgQuickBackend -- cgit v1.2.3 From 5d14caf3b26abaf8dcffdaa83e104e512df4d65b Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Thu, 26 May 2022 06:00:29 +0530 Subject: ui: move default style to Material3 with Dynamic Colors The TV theme has been kept as-is since Material You guidance around this is a bit scarce at the moment. Signed-off-by: Harsh Shandilya --- ui/src/main/java/com/wireguard/android/Application.kt | 2 ++ .../android/fragment/AppListDialogFragment.kt | 3 ++- .../android/fragment/ConfigNamingDialogFragment.kt | 3 ++- ui/src/main/res/values/styles.xml | 19 +------------------ ui/src/main/res/values/tv_styles.xml | 18 ++++++++++++++++-- 5 files changed, 23 insertions(+), 22 deletions(-) (limited to 'ui/src/main/java') diff --git a/ui/src/main/java/com/wireguard/android/Application.kt b/ui/src/main/java/com/wireguard/android/Application.kt index f26ca926..7573bdad 100644 --- a/ui/src/main/java/com/wireguard/android/Application.kt +++ b/ui/src/main/java/com/wireguard/android/Application.kt @@ -16,6 +16,7 @@ import androidx.datastore.core.DataStore import androidx.datastore.preferences.core.PreferenceDataStoreFactory import androidx.datastore.preferences.core.Preferences import androidx.datastore.preferences.preferencesDataStoreFile +import com.google.android.material.color.DynamicColors import com.wireguard.android.backend.Backend import com.wireguard.android.backend.GoBackend import com.wireguard.android.backend.WgQuickBackend @@ -86,6 +87,7 @@ class Application : android.app.Application() { override fun onCreate() { Log.i(TAG, USER_AGENT) super.onCreate() + DynamicColors.applyToActivitiesIfAvailable(this) rootShell = RootShell(applicationContext) toolsInstaller = ToolsInstaller(applicationContext, rootShell) preferencesDataStore = PreferenceDataStoreFactory.create { applicationContext.preferencesDataStoreFile("settings") } diff --git a/ui/src/main/java/com/wireguard/android/fragment/AppListDialogFragment.kt b/ui/src/main/java/com/wireguard/android/fragment/AppListDialogFragment.kt index f6f57ddb..1a40a1cd 100644 --- a/ui/src/main/java/com/wireguard/android/fragment/AppListDialogFragment.kt +++ b/ui/src/main/java/com/wireguard/android/fragment/AppListDialogFragment.kt @@ -15,6 +15,7 @@ import androidx.databinding.Observable import androidx.fragment.app.DialogFragment import androidx.fragment.app.setFragmentResult import androidx.lifecycle.lifecycleScope +import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.tabs.TabLayout import com.wireguard.android.BR import com.wireguard.android.R @@ -88,7 +89,7 @@ class AppListDialogFragment : DialogFragment() { } override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { - val alertDialogBuilder = AlertDialog.Builder(requireActivity()) + val alertDialogBuilder = MaterialAlertDialogBuilder(requireActivity()) val binding = AppListDialogFragmentBinding.inflate(requireActivity().layoutInflater, null, false) binding.executePendingBindings() alertDialogBuilder.setView(binding.root) diff --git a/ui/src/main/java/com/wireguard/android/fragment/ConfigNamingDialogFragment.kt b/ui/src/main/java/com/wireguard/android/fragment/ConfigNamingDialogFragment.kt index d20f21c6..0c4e9d20 100644 --- a/ui/src/main/java/com/wireguard/android/fragment/ConfigNamingDialogFragment.kt +++ b/ui/src/main/java/com/wireguard/android/fragment/ConfigNamingDialogFragment.kt @@ -12,6 +12,7 @@ import androidx.appcompat.app.AlertDialog import androidx.core.content.getSystemService import androidx.fragment.app.DialogFragment import androidx.lifecycle.lifecycleScope +import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.textfield.TextInputEditText import com.wireguard.android.Application import com.wireguard.android.R @@ -64,7 +65,7 @@ class ConfigNamingDialogFragment : DialogFragment() { override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { val activity = requireActivity() imm = activity.getSystemService() - val alertDialogBuilder = AlertDialog.Builder(activity) + val alertDialogBuilder = MaterialAlertDialogBuilder(activity) alertDialogBuilder.setTitle(R.string.import_from_qr_code) binding = ConfigNamingDialogFragmentBinding.inflate(activity.layoutInflater, null, false) binding?.apply { diff --git a/ui/src/main/res/values/styles.xml b/ui/src/main/res/values/styles.xml index b90f111f..396f156c 100644 --- a/ui/src/main/res/values/styles.xml +++ b/ui/src/main/res/values/styles.xml @@ -1,7 +1,7 @@ - @@ -32,12 +29,6 @@ ?attr/elevationOverlayColor - - - - diff --git a/ui/src/main/res/values/tv_styles.xml b/ui/src/main/res/values/tv_styles.xml index c5477f6a..536ca752 100644 --- a/ui/src/main/res/values/tv_styles.xml +++ b/ui/src/main/res/values/tv_styles.xml @@ -16,12 +16,26 @@ false @color/tv_primary_color @color/tv_primary_color - @style/AppTheme.Dialog - @style/AppTheme.Dialog + @style/TvTheme.Dialog + @style/TvTheme.Dialog @style/TextInputLayoutBase @style/TvTheme.MaterialCardView + + + +