Skip to content

fix TimerStatusBarWidge;fix color format #448

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;

/**
* @author shuzijun
Expand Down Expand Up @@ -191,7 +192,7 @@ private String getStyle(boolean isTag) {
sb.append("}");
sb.append("::-webkit-scrollbar-track {background-color:").append(toHexColor(defaultBackground)).append(";}");
sb.append("::-webkit-scrollbar-thumb {background-color:").append(toHexColor(scrollbarThumbColor)).append(";}");
sb.append(".vditor-reset {font-size:").append(editorColorsScheme.getEditorFontSize()).append(";");
sb.append(".vditor-reset {font-size:").append(editorColorsScheme.getEditorFontSize()).append("px;");
sb.append(fontFamily);
if (text != null) {
sb.append("color:").append(toHexColor(text)).append(";");
Expand All @@ -207,6 +208,9 @@ private String getStyle(boolean isTag) {

private String toHexColor(Color color) {
DecimalFormat df = new DecimalFormat("0.00");
DecimalFormatSymbols dfs = new DecimalFormatSymbols();
dfs.setDecimalSeparator('.');
df.setDecimalFormatSymbols(dfs);
return String.format("rgba(%s,%s,%s,%s)", color.getRed(), color.getGreen(), color.getBlue(), df.format(color.getAlpha() / (float) 255));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.shuzijun.leetcode.plugin.timer;

import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.wm.StatusBar;
import com.intellij.openapi.wm.StatusBarWidget;
import com.intellij.openapi.wm.StatusBarWidgetFactory;
Expand All @@ -16,7 +15,6 @@
*/
public class TimerStatusBarWidgetProvider implements StatusBarWidgetFactory {

private TimerBarWidget timerBarWidget;

@Override
public @NonNls @NotNull String getId() {
Expand All @@ -35,21 +33,15 @@ public boolean isAvailable(@NotNull Project project) {

@Override
public @NotNull StatusBarWidget createWidget(@NotNull Project project) {
if (timerBarWidget == null) {
timerBarWidget = new TimerBarWidget(project);
}
return timerBarWidget;
return new TimerBarWidget(project);
}

@Override
public void disposeWidget(@NotNull StatusBarWidget widget) {
if (timerBarWidget != null) {
Disposer.dispose(timerBarWidget);
}
}

@Override
public boolean canBeEnabledOn(@NotNull StatusBar statusBar) {
return false;
return true;
}
}