From 0668043a87e2f18fe4058812af4a20c5441be71a Mon Sep 17 00:00:00 2001 From: Matthew Gharrity Date: Thu, 5 May 2022 21:27:31 -0400 Subject: Ask for confirmation when switching to Kotlin EAPs When the user goes to Tools > Kotlin > Configure Kotlin Plugin Updates and changes the update channel to Early Access Preview, a new dialog is shown to confirm the choice and warn that EAP builds are downloaded directly from JetBrains. Bug: 231644880 Test: manual Change-Id: I84cba8ddd54530cd019d939c9166362fcb62803e --- .../configuration/KotlinLanguageConfiguration.kt | 25 ++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/configuration/KotlinLanguageConfiguration.kt b/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/configuration/KotlinLanguageConfiguration.kt index 8ef39c401120..6ace4b13e1c3 100644 --- a/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/configuration/KotlinLanguageConfiguration.kt +++ b/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/configuration/KotlinLanguageConfiguration.kt @@ -5,6 +5,7 @@ package org.jetbrains.kotlin.idea.configuration import com.intellij.ide.IdeBundle import com.intellij.openapi.options.Configurable import com.intellij.openapi.options.SearchableConfigurable +import com.intellij.openapi.ui.MessageDialogBuilder import com.intellij.openapi.updateSettings.impl.UpdateSettings import com.intellij.openapi.util.NlsSafe import org.jetbrains.annotations.Nls @@ -126,10 +127,26 @@ class KotlinLanguageConfiguration : SearchableConfigurable, Configurable.NoScrol form.channelCombo.selectedIndex = savedChannel form.channelCombo.addActionListener { - val newChannel = form.channelCombo.selectedIndex - if (newChannel != savedChannel) { - savedChannel = newChannel - checkForUpdates() + val selectedIndex = form.channelCombo.selectedIndex + if (selectedIndex != savedChannel) { + if (selectedIndex == UpdateChannel.EAP.ordinal) { + // Android Studio: if switching to the EAP channel, we require explicit confirmation from + // the user that they want to download Kotlin builds from JetBrains. This is putatively + // temporary until we have a broader solution for third-party plugins in general. + val legalese = "EAP Kotlin builds are provided by JetBrains and receive no support from Google. " + + "EAP builds are experimental and can potentially break Android Studio, requiring reinstallation. " + + "Would you like to continue?" + val confirmation = MessageDialogBuilder.okCancel("Switching to EAP Builds From JetBrains", legalese) + if (confirmation.ask(parentComponent = form.mainPanel)) { + savedChannel = selectedIndex + checkForUpdates() + } else { + form.channelCombo.selectedIndex = savedChannel + } + } else { + savedChannel = selectedIndex + checkForUpdates() + } } } -- cgit v1.2.3