use of com.android.tools.idea.gradle.project.ProxySettingsDialog in project android by JetBrains.
the class HttpProxySettingsCleanUpTask method doCleanUp.
@Override
void doCleanUp(@NotNull Project project) {
HttpConfigurable ideHttpProxySettings = HttpConfigurable.getInstance();
if (!ideHttpProxySettings.USE_HTTP_PROXY || isEmpty(ideHttpProxySettings.PROXY_HOST)) {
return;
}
GradleProperties properties;
try {
properties = new GradleProperties(project);
} catch (IOException e) {
getLogger().info("Failed to read gradle.properties file", e);
// Let sync continue, even though it may fail.
return;
}
ProxySettings gradleProxySettings = properties.getHttpProxySettings();
ProxySettings ideProxySettings = new ProxySettings(ideHttpProxySettings);
if (!ideProxySettings.equals(gradleProxySettings)) {
ProxySettingsDialog dialog = new ProxySettingsDialog(project, ideProxySettings);
if (dialog.showAndGet()) {
dialog.applyProxySettings(properties.getProperties());
try {
properties.save();
} catch (IOException e) {
Throwable root = getRootCause(e);
String cause = root.getMessage();
String errMsg = "Failed to save HTTP proxy settings to gradle.properties file.";
if (isNotEmpty(cause)) {
if (!cause.endsWith(".")) {
cause += ".";
}
errMsg += String.format("\nCause: %1$s", cause);
}
AndroidGradleNotification notification = AndroidGradleNotification.getInstance(project);
notification.showBalloon("Proxy Settings", errMsg, ERROR);
getLogger().info("Failed to save changes to gradle.properties file", root);
}
}
}
}
Aggregations