summaryrefslogtreecommitdiff
path: root/android
diff options
context:
space:
mode:
authorAlon Albert <aalbert@google.com>2022-03-10 15:40:15 -0800
committerAlon Albert <aalbert@google.com>2022-03-21 20:20:37 +0000
commit078c2e09829660b79ba5a0c106d3086c5ad6394d (patch)
treebfb730a5fa26ff4ce7a701cdea80ec75e37868be /android
parenta8f7486dd34baeae162f022205b197d59a92479a (diff)
downloadidea-078c2e09829660b79ba5a0c106d3086c5ad6394d.tar.gz
Replace StudioFlag With a User Visible Experimental option
Bug: 191880898 Test: Updated Change-Id: If6a72997575162c02560406d477054b75a15d7a8
Diffstat (limited to 'android')
-rw-r--r--android/resources/messages/AndroidBundle.properties2
-rw-r--r--android/src/META-INF/android-plugin.xml2
-rw-r--r--android/src/com/android/tools/idea/flags/ExperimentalSettingsConfigurable.form26
-rw-r--r--android/src/com/android/tools/idea/flags/ExperimentalSettingsConfigurable.java30
-rw-r--r--android/src/com/android/tools/idea/logcat/AndroidLogcatToolWindowFactory.java5
-rw-r--r--android/src/com/android/tools/idea/logcat/LogcatExperimentalSettings.kt42
6 files changed, 101 insertions, 6 deletions
diff --git a/android/resources/messages/AndroidBundle.properties b/android/resources/messages/AndroidBundle.properties
index 7f90fe53f6b..959f55e1f44 100644
--- a/android/resources/messages/AndroidBundle.properties
+++ b/android/resources/messages/AndroidBundle.properties
@@ -55,6 +55,8 @@ provider.slots.empty.error=No Complication slots added.
android.logcat.error.title=Android logcat error
android.logcat.error.clearLogcat=Failed to clear Logcat, got an exception executing "adb logcat -c". See idea.log for details.
android.logcat.color.page.name=Android Logcat
+android.logcat.enable.v2.restart.needed=Switching to the new Logcat requires an IDE restart. Restart now?
+android.logcat.enable.v2.restart.no=Not Now
warning.level.title=Warning
verbose.level.title=Verbose
info.level.title=Info
diff --git a/android/src/META-INF/android-plugin.xml b/android/src/META-INF/android-plugin.xml
index 0028457145e..e3e6f7ec504 100644
--- a/android/src/META-INF/android-plugin.xml
+++ b/android/src/META-INF/android-plugin.xml
@@ -364,6 +364,8 @@
<applicationService serviceInterface="com.android.tools.idea.run.NonGradleAndroidArtifactResolver"
serviceImplementation="com.android.tools.idea.run.JpsAndroidArtifactResolver"/>
+ <applicationService serviceImplementation="com.android.tools.idea.logcat.LogcatExperimentalSettings"/>
+
<fileType name="Android 9-Patch"
implementationClass="com.android.tools.idea.fileTypes.AndroidNinePatchFileType"
fieldName="INSTANCE"
diff --git a/android/src/com/android/tools/idea/flags/ExperimentalSettingsConfigurable.form b/android/src/com/android/tools/idea/flags/ExperimentalSettingsConfigurable.form
index 4151fd958fa..e087df3ea05 100644
--- a/android/src/com/android/tools/idea/flags/ExperimentalSettingsConfigurable.form
+++ b/android/src/com/android/tools/idea/flags/ExperimentalSettingsConfigurable.form
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.android.tools.idea.flags.ExperimentalSettingsConfigurable">
- <grid id="27dc6" binding="myPanel" layout-manager="GridLayoutManager" row-count="16" column-count="8" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
+ <grid id="27dc6" binding="myPanel" layout-manager="GridLayoutManager" row-count="18" column-count="8" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="919" height="551"/>
@@ -120,7 +120,7 @@
</component>
<vspacer id="dea89">
<constraints>
- <grid row="15" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
+ <grid row="17" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<component id="7c5c3" class="javax.swing.JCheckBox" binding="myPreviewPickerCheckBox">
@@ -161,6 +161,28 @@
<text value="Builds the preview on save to allow for faster preview refresh"/>
</properties>
</component>
+ <component id="41cf9" class="com.intellij.ui.TitledSeparator">
+ <constraints>
+ <grid row="15" column="0" row-span="1" col-span="8" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
+ </constraints>
+ <properties>
+ <text value="Logcat"/>
+ </properties>
+ </component>
+ <component id="67236" class="javax.swing.JCheckBox" binding="myEnableNewLogcatToolCheckBox" default-binding="true">
+ <constraints>
+ <grid row="16" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
+ </constraints>
+ <properties>
+ <text value="Enable new Logcat tool window"/>
+ </properties>
+ </component>
+ <component id="e0a5f" class="com.intellij.ui.components.BrowserLink" binding="myLogcatLearnMoreBrowserLink" custom-create="true">
+ <constraints>
+ <grid row="16" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
+ </constraints>
+ <properties/>
+ </component>
</children>
</grid>
</form>
diff --git a/android/src/com/android/tools/idea/flags/ExperimentalSettingsConfigurable.java b/android/src/com/android/tools/idea/flags/ExperimentalSettingsConfigurable.java
index a809359ecf4..1a171b53ee4 100644
--- a/android/src/com/android/tools/idea/flags/ExperimentalSettingsConfigurable.java
+++ b/android/src/com/android/tools/idea/flags/ExperimentalSettingsConfigurable.java
@@ -22,10 +22,13 @@ import static com.intellij.openapi.fileChooser.FileChooserDescriptorFactory.crea
import com.android.tools.idea.compose.ComposeExperimentalConfiguration;
import com.android.tools.idea.gradle.project.GradleExperimentalSettings;
import com.android.tools.idea.gradle.project.sync.idea.TraceSyncUtil;
+import com.android.tools.idea.logcat.LogcatExperimentalSettings;
import com.android.tools.idea.rendering.RenderSettings;
import com.google.common.annotations.VisibleForTesting;
+import com.intellij.ide.IdeBundle;
import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.application.ex.ApplicationEx;
import com.intellij.openapi.externalSystem.util.ExternalSystemUiUtil;
import com.intellij.openapi.options.Configurable;
import com.intellij.openapi.options.ConfigurationException;
@@ -34,6 +37,7 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.MessageType;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
+import com.intellij.ui.components.BrowserLink;
import java.io.File;
import java.util.Hashtable;
import javax.swing.JCheckBox;
@@ -42,6 +46,7 @@ import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSlider;
+import org.jetbrains.android.util.AndroidBundle;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -63,6 +68,8 @@ public class ExperimentalSettingsConfigurable implements SearchableConfigurable,
private JCheckBox myBuildOnSaveCheckBox;
private JLabel myBuildOnSaveLabel;
private JLabel myPreviewPickerLabel;
+ private JCheckBox myEnableNewLogcatToolCheckBox;
+ private BrowserLink myLogcatLearnMoreBrowserLink;
private Runnable myRestartCallback;
@@ -129,7 +136,8 @@ public class ExperimentalSettingsConfigurable implements SearchableConfigurable,
(int)(myRenderSettings.getQuality() * 100) != getQualitySetting() ||
myAnimationPreviewCheckBox.isSelected() != ComposeExperimentalConfiguration.getInstance().isAnimationPreviewEnabled() ||
myPreviewPickerCheckBox.isSelected() != ComposeExperimentalConfiguration.getInstance().isPreviewPickerEnabled() ||
- myBuildOnSaveCheckBox.isSelected() != ComposeExperimentalConfiguration.getInstance().isBuildOnSaveEnabled();
+ myBuildOnSaveCheckBox.isSelected() != ComposeExperimentalConfiguration.getInstance().isBuildOnSaveEnabled() ||
+ myEnableNewLogcatToolCheckBox.isSelected() != LogcatExperimentalSettings.getInstance().getLogcatV2Enabled();
}
private int getQualitySetting() {
@@ -147,6 +155,21 @@ public class ExperimentalSettingsConfigurable implements SearchableConfigurable,
ComposeExperimentalConfiguration.getInstance().setAnimationPreviewEnabled(myAnimationPreviewCheckBox.isSelected());
ComposeExperimentalConfiguration.getInstance().setPreviewPickerEnabled(myPreviewPickerCheckBox.isSelected());
ComposeExperimentalConfiguration.getInstance().setBuildOnSaveEnabled(myBuildOnSaveCheckBox.isSelected());
+
+ LogcatExperimentalSettings logcatSettings = LogcatExperimentalSettings.getInstance();
+ if (myEnableNewLogcatToolCheckBox.isSelected() != logcatSettings.getLogcatV2Enabled()) {
+ logcatSettings.setLogcatV2Enabled(myEnableNewLogcatToolCheckBox.isSelected());
+
+ int result = Messages.showYesNoDialog(
+ AndroidBundle.message("android.logcat.enable.v2.restart.needed"),
+ IdeBundle.message("dialog.title.restart.ide"),
+ IdeBundle.message("dialog.action.restart.yes"),
+ AndroidBundle.message("android.logcat.enable.v2.restart.no"),
+ Messages.getWarningIcon());
+ if (result == Messages.YES) {
+ ((ApplicationEx)ApplicationManager.getApplication()).restart(true);
+ }
+ }
}
@Override
@@ -294,6 +317,11 @@ public class ExperimentalSettingsConfigurable implements SearchableConfigurable,
myAnimationPreviewCheckBox.setSelected(ComposeExperimentalConfiguration.getInstance().isAnimationPreviewEnabled());
myPreviewPickerCheckBox.setSelected(ComposeExperimentalConfiguration.getInstance().isPreviewPickerEnabled());
myBuildOnSaveCheckBox.setSelected(ComposeExperimentalConfiguration.getInstance().isBuildOnSaveEnabled());
+ myEnableNewLogcatToolCheckBox.setSelected(LogcatExperimentalSettings.getInstance().getLogcatV2Enabled());
+ }
+
+ private void createUIComponents() {
+ myLogcatLearnMoreBrowserLink = new BrowserLink("Learn more", "https://d.android.com/r/studio-ui/logcat/help");
}
public enum TraceProfileItem {
diff --git a/android/src/com/android/tools/idea/logcat/AndroidLogcatToolWindowFactory.java b/android/src/com/android/tools/idea/logcat/AndroidLogcatToolWindowFactory.java
index 41b13f8ace9..85df7ee9d4e 100644
--- a/android/src/com/android/tools/idea/logcat/AndroidLogcatToolWindowFactory.java
+++ b/android/src/com/android/tools/idea/logcat/AndroidLogcatToolWindowFactory.java
@@ -21,7 +21,6 @@ import com.android.ddmlib.IDevice;
import com.android.tools.idea.AndroidEnvironmentUtils;
import com.android.tools.idea.adb.AdbService;
import com.android.tools.idea.ddms.DevicePanel;
-import com.android.tools.idea.flags.StudioFlags;
import com.android.tools.idea.run.ShowLogcatListener;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
@@ -64,7 +63,7 @@ public class AndroidLogcatToolWindowFactory implements ToolWindowFactory, DumbAw
public static final Key<DevicePanel> DEVICES_PANEL_KEY = Key.create("DevicePanel");
public AndroidLogcatToolWindowFactory() {
- if (!StudioFlags.LOGCAT_V2_ENABLE.get()) {
+ if (!LogcatExperimentalSettings.getInstance().getLogcatV2Enabled()) {
ColorSettingsPages.getInstance().registerPage(new AndroidLogcatColorPage());
}
}
@@ -78,7 +77,7 @@ public class AndroidLogcatToolWindowFactory implements ToolWindowFactory, DumbAw
@Override
public boolean isApplicable(@NotNull Project project) {
- return !StudioFlags.LOGCAT_V2_ENABLE.get() && AndroidEnvironmentUtils.isAndroidEnvironment(project);
+ return !LogcatExperimentalSettings.getInstance().getLogcatV2Enabled() && AndroidEnvironmentUtils.isAndroidEnvironment(project);
}
@Override
diff --git a/android/src/com/android/tools/idea/logcat/LogcatExperimentalSettings.kt b/android/src/com/android/tools/idea/logcat/LogcatExperimentalSettings.kt
new file mode 100644
index 00000000000..05b8b35570b
--- /dev/null
+++ b/android/src/com/android/tools/idea/logcat/LogcatExperimentalSettings.kt
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.tools.idea.logcat
+
+import com.intellij.openapi.application.ApplicationManager
+import com.intellij.openapi.components.PersistentStateComponent
+import com.intellij.openapi.components.State
+import com.intellij.openapi.components.Storage
+import com.intellij.util.xmlb.XmlSerializerUtil
+
+/**
+ * Experimental Logcat settings
+ */
+@State(name = "LogcatExperimentalSettings", storages = [(Storage("logcat.experimental.xml"))])
+data class LogcatExperimentalSettings(var logcatV2Enabled: Boolean = true)
+ : PersistentStateComponent<LogcatExperimentalSettings> {
+ override fun getState(): LogcatExperimentalSettings = this
+
+ override fun loadState(state: LogcatExperimentalSettings) {
+ XmlSerializerUtil.copyBean(state, this)
+ }
+
+ companion object {
+ @JvmStatic
+ fun getInstance(): LogcatExperimentalSettings {
+ return ApplicationManager.getApplication().getService(LogcatExperimentalSettings::class.java)
+ }
+ }
+} \ No newline at end of file