update the logic of auto reset option

master
pengzhile 3 years ago
parent ab68a58532
commit f5d61c4b99

@ -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.3-3d9348.zip).
1. Download and install plugin from [Download Link](https://plugins.zhile.io/files/ide-eval-resetter-2.3.4-62e7c8.zip).
* Alternative installation method:
* Add "Custom Plugin Repository": `https://plugins.zhile.io` manually (`Settings/Preferences` -> `Plugins`)
* Search and install plugin: `IDE Eval Reset`

@ -4,7 +4,7 @@ plugins {
}
group 'io.zhile.research.intellij'
version '2.3.3'
version '2.3.4'
sourceCompatibility = 1.7
targetCompatibility = 1.7
@ -29,6 +29,8 @@ intellij {
patchPluginXml {
changeNotes = """<pre>
Release v2.3.4
1. update the logic of auto reset option
Release v2.3.3
1. add more reset records
Release v2.3.2

@ -179,7 +179,7 @@ public class Resetter {
evalDir.mkdirs();
}
LICENSE_FILES.add(String.format("%s%s.evaluation.key", AppHelper.getProductCode(), AppHelper.getBuildNumber().getBaselineVersion()));
LICENSE_FILES.add(String.format("%s%s.evaluation.key", AppHelper.getProductName(), Constants.IDE_BASELINE_VERSION));
for (IdeaPluginDescriptor descriptor : PluginManager.getPlugins()) {
addPluginLicense(descriptor);

@ -14,14 +14,14 @@ public class AppHelper {
});
}
public static String getProductCode() {
String productCode = Constants.IDE_NAME;
public static String getProductName() {
String productName = Constants.IDE_NAME;
if ("IDEA".equals(productCode)) {
return productCode.toLowerCase();
if ("IDEA".equals(productName)) {
return productName.toLowerCase();
}
return productCode;
return productName;
}
public static BuildNumber getBuildNumber() {

@ -10,6 +10,7 @@ public class Constants {
public static final String IDE_NAME = ApplicationNamesInfo.getInstance().getProductName();
public static final String IDE_NAME_LOWER = IDE_NAME.toLowerCase();
public static final String IDE_HASH = Integer.toHexString(FileUtil.pathHashCode(PathManager.getHomePath()));
public static final int IDE_BASELINE_VERSION = AppHelper.getBuildNumber().getBaselineVersion();
public static final String PLUGIN_PREFS_PREFIX = "Ide-Eval-Reset";
public static final String RESET_ACTION_ID = "io.zhile.research.intellij.ier.action.ResetAction";
public static final String RESTART_ACTION_ID = "io.zhile.research.intellij.ier.action.RestartAction";

@ -5,7 +5,7 @@ import io.zhile.research.intellij.ier.common.Resetter;
public class ResetTimeHelper {
public static final long RESET_PERIOD = 2160000000L; // 25 days
private static final String RESET_KEY = Constants.PLUGIN_PREFS_PREFIX + "." + Constants.IDE_NAME_LOWER + "." + Constants.IDE_HASH;
private static final String RESET_KEY = Constants.PLUGIN_PREFS_PREFIX + ".reset_time." + Constants.IDE_NAME + Constants.IDE_BASELINE_VERSION;
public static long getLastResetTime() {
return Prefs.getLong(RESET_KEY, 0L);

@ -12,6 +12,7 @@ import io.zhile.research.intellij.ier.common.Resetter;
import io.zhile.research.intellij.ier.helper.Constants;
import io.zhile.research.intellij.ier.helper.NotificationHelper;
import io.zhile.research.intellij.ier.helper.PluginHelper;
import io.zhile.research.intellij.ier.helper.ResetTimeHelper;
import io.zhile.research.intellij.ier.tw.MainToolWindowFactory;
import org.jetbrains.annotations.NotNull;
@ -42,23 +43,25 @@ public class PluginListener implements DynamicPluginListener, PluginStateListene
}
@Override
public void pluginLoaded(@NotNull IdeaPluginDescriptor pluginDescriptor) {
if (!PluginHelper.myself(pluginDescriptor)) {
public void pluginLoaded(@NotNull IdeaPluginDescriptor descriptor) {
if (!PluginHelper.myself(descriptor)) {
return;
}
ActionManager.getInstance().getAction(Constants.RESET_ACTION_ID);
String link = "https://zhile.io/2020/11/18/jetbrains-eval-reset-da33a93d.html";
String autoResetTip = "Auto reset switch state: " + (Resetter.isAutoReset() ? "<b>on</b>" : "<b>off<b>");
String autoLogoutTip = "Auto logout switch state: " + (Resetter.isAutoLogout() ? "<b>on</b>" : "<b>off<b>");
String content = String.format("Plugin installed successfully!<br>For more information, visit <a href='%s'>this link</a>.<br><br>%s<br>%s", link, autoResetTip, autoLogoutTip);
String versionTip = "Plugin version: <b>v" + descriptor.getVersion() + "</b>";
String autoResetTip = "Auto reset option state: " + (Resetter.isAutoReset() ? "<b>on</b>" : "<b>off</b>");
String autoLogoutTip = "Auto logout option state: " + (Resetter.isAutoLogout() ? "<b>on</b>" : "<b>off</b>");
String lastResetTime = "Last reset time: <b>" + ResetTimeHelper.getLastResetTimeStr() + "</b>";
String content = String.format("Plugin installed successfully!<br>For more information, <a href='%s'>visit here</a>.<br><br>%s<br>%s<br>%s<br>%s", link, versionTip, autoResetTip, autoLogoutTip, lastResetTime);
NotificationHelper.showInfo(null, content);
}
@Override
public void beforePluginUnload(@NotNull IdeaPluginDescriptor pluginDescriptor, boolean isUpdate) {
if (!PluginHelper.myself(pluginDescriptor)) {
public void beforePluginUnload(@NotNull IdeaPluginDescriptor descriptor, boolean isUpdate) {
if (!PluginHelper.myself(descriptor)) {
return;
}

Loading…
Cancel
Save