diff --git a/README.md b/README.md index 2c50d4a..ae905df 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Reset Your IDE Eval Information -1. Download and install plugin from [Download Link](https://plugins.zhile.io/files/ide-eval-resetter-2.3.2-10863c.zip). +1. Download and install plugin from [Download Link](https://plugins.zhile.io/files/ide-eval-resetter-2.3.3-3d9348.zip). * Alternative installation method: * Add "Custom Plugin Repository": `https://plugins.zhile.io` manually (`Settings/Preferences` -> `Plugins`) * Search and install plugin: `IDE Eval Reset` diff --git a/build.gradle b/build.gradle index 752d865..1dccaee 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ plugins { } group 'io.zhile.research.intellij' -version '2.3.2' +version '2.3.3' sourceCompatibility = 1.7 targetCompatibility = 1.7 @@ -29,6 +29,8 @@ intellij { patchPluginXml { changeNotes = """
+Release v2.3.3 + 1. add more reset records Release v2.3.2 1. fix plugin version Release v2.3.1 diff --git a/src/main/java/io/zhile/research/intellij/ier/common/KeepCondition.java b/src/main/java/io/zhile/research/intellij/ier/common/KeepCondition.java new file mode 100644 index 0000000..bbe368d --- /dev/null +++ b/src/main/java/io/zhile/research/intellij/ier/common/KeepCondition.java @@ -0,0 +1,5 @@ +package io.zhile.research.intellij.ier.common; + +public interface KeepCondition { + boolean needKeep(); +} diff --git a/src/main/java/io/zhile/research/intellij/ier/common/PreferenceRecord.java b/src/main/java/io/zhile/research/intellij/ier/common/PreferenceRecord.java index 2674a96..bbadbda 100644 --- a/src/main/java/io/zhile/research/intellij/ier/common/PreferenceRecord.java +++ b/src/main/java/io/zhile/research/intellij/ier/common/PreferenceRecord.java @@ -11,14 +11,20 @@ public class PreferenceRecord implements EvalRecord { private final String key; private final String value; private final boolean isRaw; + private final KeepCondition keepCondition; public PreferenceRecord(String key) { - this(key, false); + this(key, false, null); } public PreferenceRecord(String key, boolean isRaw) { + this(key, isRaw, null); + } + + public PreferenceRecord(String key, boolean isRaw, KeepCondition keepCondition) { this.key = key; this.isRaw = isRaw; + this.keepCondition = keepCondition; this.value = isRaw ? Preferences.userRoot().get(key, DEFAULT_VALUE) : Prefs.get(key, DEFAULT_VALUE); } @@ -32,6 +38,10 @@ public class PreferenceRecord implements EvalRecord { @Override public void reset() throws Exception { + if (null != keepCondition && keepCondition.needKeep()) { + return; + } + if (isRaw) { Preferences.userRoot().remove(key); } else { @@ -43,6 +53,8 @@ public class PreferenceRecord implements EvalRecord { @Override public String toString() { - return type + ": " + key + " = " + (null == value ? "" : value); + String v = null == value ? "" : value; + + return type + ": " + key + " = " + v.substring(0, Math.min(36, v.length())); } } diff --git a/src/main/java/io/zhile/research/intellij/ier/common/Resetter.java b/src/main/java/io/zhile/research/intellij/ier/common/Resetter.java index 77bc26c..5d11661 100644 --- a/src/main/java/io/zhile/research/intellij/ier/common/Resetter.java +++ b/src/main/java/io/zhile/research/intellij/ier/common/Resetter.java @@ -22,10 +22,9 @@ import java.util.prefs.Preferences; public class Resetter { private static final String DEFAULT_VENDOR = "jetbrains"; private static final String OLD_MACHINE_ID_KEY = "JetBrains.UserIdOnMachine"; - private static final String NEW_MACHINE_ID_KEY = DEFAULT_VENDOR + ".user_id_on_machine"; - private static final String DEVICE_ID_KEY = DEFAULT_VENDOR + ".device_id"; private static final String EVAL_KEY = "evlsprt"; - private static final String AUTO_RESET_KEY = Constants.PLUGIN_PREFS_PREFIX + ".auto_reset." + Constants.IDE_NAME_LOWER + "." + Constants.IDE_HASH; + private static final String AUTO_RESET_KEY = Constants.PLUGIN_PREFS_PREFIX + ".auto_reset." + Constants.IDE_NAME_LOWER; + private static final String AUTO_LOGOUT_KEY = Constants.PLUGIN_PREFS_PREFIX + ".auto_logout"; private static final Method METHOD_GET_PRODUCT_CODE = ReflectionHelper.getMethod(IdeaPluginDescriptor.class, "getProductCode"); private static final Method METHOD_GET_RELEASE_DATE = ReflectionHelper.getMethod(IdeaPluginDescriptor.class, "getReleaseDate"); @@ -92,10 +91,24 @@ public class Resetter { } } + KeepCondition keepCondition = new KeepCondition() { + @Override + public boolean needKeep() { + return !isAutoLogout(); + } + }; PreferenceRecord[] prefsValue = new PreferenceRecord[]{ new PreferenceRecord(OLD_MACHINE_ID_KEY, true), - new PreferenceRecord(NEW_MACHINE_ID_KEY), - new PreferenceRecord(DEVICE_ID_KEY), + new PreferenceRecord(DEFAULT_VENDOR + ".user_id_on_machine"), + new PreferenceRecord(DEFAULT_VENDOR + ".device_id"), + new PreferenceRecord(DEFAULT_VENDOR + ".marketplacedownloads_device_id"), + new PreferenceRecord(DEFAULT_VENDOR + ".mlse_device_id"), + new PreferenceRecord(DEFAULT_VENDOR + ".auth-tokens.account_jetbrains_com"), + new PreferenceRecord(DEFAULT_VENDOR + ".feature_usage_event_log_salt"), + new PreferenceRecord(DEFAULT_VENDOR + ".mlse_feature_usage_event_log_salt"), + new PreferenceRecord(DEFAULT_VENDOR + ".jetprofile.idtoken"), + new PreferenceRecord(DEFAULT_VENDOR + ".jetprofile.userid", false, keepCondition), + new PreferenceRecord(DEFAULT_VENDOR + ".jetprofile.userlogin", false, keepCondition), }; for (PreferenceRecord record : prefsValue) { if (record.getValue() == null) { @@ -226,6 +239,15 @@ public class Resetter { syncPrefs(); } + public static boolean isAutoLogout() { + return Prefs.getBoolean(AUTO_LOGOUT_KEY, false); + } + + public static void setAutoLogout(boolean isAutoClear) { + Prefs.putBoolean(AUTO_LOGOUT_KEY, isAutoClear); + syncPrefs(); + } + public static void syncPrefs() { try { Preferences.userRoot().sync(); diff --git a/src/main/java/io/zhile/research/intellij/ier/listener/PluginListener.java b/src/main/java/io/zhile/research/intellij/ier/listener/PluginListener.java index 4e65c68..c9139e5 100644 --- a/src/main/java/io/zhile/research/intellij/ier/listener/PluginListener.java +++ b/src/main/java/io/zhile/research/intellij/ier/listener/PluginListener.java @@ -48,7 +48,12 @@ public class PluginListener implements DynamicPluginListener, PluginStateListene } ActionManager.getInstance().getAction(Constants.RESET_ACTION_ID); - NotificationHelper.showInfo(null, "Plugin installed successfully! Now enjoy it~
For more information, visit here."); + + String link = "https://zhile.io/2020/11/18/jetbrains-eval-reset-da33a93d.html"; + String autoResetTip = "Auto reset switch state: " + (Resetter.isAutoReset() ? "on" : "off"); + String autoLogoutTip = "Auto logout switch state: " + (Resetter.isAutoLogout() ? "on" : "off"); + String content = String.format("Plugin installed successfully!
For more information, visit this link.
%s
%s", link, autoResetTip, autoLogoutTip); + NotificationHelper.showInfo(null, content); } @Override diff --git a/src/main/java/io/zhile/research/intellij/ier/ui/form/MainForm.form b/src/main/java/io/zhile/research/intellij/ier/ui/form/MainForm.form index c04ddaa..4543f70 100644 --- a/src/main/java/io/zhile/research/intellij/ier/ui/form/MainForm.form +++ b/src/main/java/io/zhile/research/intellij/ier/ui/form/MainForm.form @@ -2,7 +2,7 @@