Skip to content

Commit

Permalink
Merge pull request #608 from doki-theme/internalUsageFixes
Browse files Browse the repository at this point in the history
Internal API Usages Fix
  • Loading branch information
Unthrottled authored Dec 15, 2022
2 parents 0d7a09d + 73388f1 commit 6a7d18c
Show file tree
Hide file tree
Showing 28 changed files with 113 additions and 602 deletions.
7 changes: 0 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -294,13 +294,6 @@ You can hit `Apply` to test out your new settings!

![Notification Opacity](./assets/readmeAssets/notification_opacity.gif)

**Frameless Mode** is a feature only available on MacOS, and gives your IDE the frameless look and feel.
Note: Since 2022.2 JetBrains platforms natively support this feature. So this implementation will collide with the native one.

**Tohsaka Rin**

![Frameless mode](./assets/readmeAssets/frameless.png)

**Theme Change Animation** enables the neat fade-in animation effect as you change your theme.
You can see a rough example in the [quick theme switch section.](#quick-theme-switch)

Expand Down
Binary file removed assets/readmeAssets/frameless.png
Binary file not shown.
6 changes: 6 additions & 0 deletions changelog/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
Changelog
---

# 88.3-1.8.0 [SDK API Updates]

- Removed Frameless mode as it's supported by the platform now.
- Migrated away from various internal methods where replacement was available.

# 88.3-1.7.2 [Better EXP UI Support]

- Added better EXP UI support
Expand Down
6 changes: 4 additions & 2 deletions changelog/RELEASE-NOTES.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 88.3-1.7.2 [Doki Theme Icons]
# 88.3-1.8.0 [Doki Theme Icons]

<div align="center">
<img src="https://doki.assets.unthrottled.io/misc/doki_icons_logo.png" width="256" height="256" alt="Doki Theme Icons"></img>
Expand All @@ -15,4 +15,6 @@
- Added the initial experimental UI (New UI) support.
- Source code is compiled for Java 17.
- Raised lowest supported build to 2022.2 to support Java 17.
- Themed the progress indicator track bar.
- Themed the progress indicator track bar.
- Removed Frameless mode as it's supported by the platform now.
- Migrated away from various internal methods where replacement was available.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
# -> https://www.jetbrains.org/intellij/sdk/docs/reference_guide/intellij_artifacts.html

pluginGroup=io.unthrottled
pluginVersion=88.3-1.7.2
pluginVersion=88.3-1.8.0
pluginSinceBuild=222
pluginUntilBuild = 223.*

# Plugin Verifier integration -> https://github.com/JetBrains/gradle-intellij-plugin#plugin-verifier-dsl
# See https://jb.gg/intellij-platform-builds-list for available build versions.
pluginVerifierIdeVersions = 2021.3.1, 2022.1.3
pluginVerifierIdeVersions = 2022.2, 2022.3

platformType = IU
platformVersion = 2022.3
Expand Down
1 change: 0 additions & 1 deletion src/main/java/icons/DokiThemeIcons.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ public class DokiThemeIcons {
public static final Icon SHAME = IconLoader.getIcon("/icons/emojis/1f648.svg", DokiThemeIcons.class);
public static final Icon MAGIC = IconLoader.getIcon("/icons/doki/magic.svg", DokiThemeIcons.class);
public static final Icon DIFF = IconLoader.getIcon("/icons/actions/diff.svg", DokiThemeIcons.class);
public static final Icon TITLE_BAR = IconLoader.getIcon("/icons/doki/themedTitleBar.svg", DokiThemeIcons.class);
public static final Icon DOKI_LOGO = IconLoader.getIcon("/icons/doki/Doki-Doki-Logo.svg", DokiThemeIcons.class);
public static final Icon AMII_LOGO = IconLoader.getIcon("/icons/plugins/amii/plugin-tool-window.svg", DokiThemeIcons.class);
public static final Icon WALLPAPER = IconLoader.getIcon("/icons/doki/image.svg", DokiThemeIcons.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -478,14 +478,6 @@
<grid row="2" column="4" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<component id="d8006" class="javax.swing.JCheckBox" binding="framelessModeMacOSOnlyCheckBox" default-binding="true">
<constraints>
<grid row="2" 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 resource-bundle="messages/MessageBundle" key="settings.general.other.themed.titlebar"/>
</properties>
</component>
<hspacer id="e21a4">
<constraints>
<grid row="1" column="4" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ public class ThemeSettingsUI implements SearchableConfigurable, Configurable.NoS
private JCheckBox backgroundWallpaperCheckBox;
private JLabel warningLabel;
private JCheckBox nameInStatusBarCheckBox;
private JCheckBox framelessModeMacOSOnlyCheckBox;
private JButton chooseImageButton;
private JCheckBox useCustomStickerCheckBox;
private JTextPane generalLinks;
Expand Down Expand Up @@ -205,11 +204,6 @@ private void initializeAutoCreatedComponents() {
}
);

framelessModeMacOSOnlyCheckBox.setSelected(initialThemeSettingsModel.isThemedTitleBar());
framelessModeMacOSOnlyCheckBox.addActionListener(e ->
themeSettingsModel.setThemedTitleBar(framelessModeMacOSOnlyCheckBox.isSelected())
);

overrideEditorFontSizeCheckBox.setSelected(initialThemeSettingsModel.isCustomFontSize());
overrideEditorFontSizeCheckBox.addActionListener(e ->
themeSettingsModel.setCustomFontSize(overrideEditorFontSizeCheckBox.isSelected()));
Expand Down
69 changes: 34 additions & 35 deletions src/main/kotlin/io/unthrottled/doki/TheDokiTheme.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import com.intellij.openapi.application.ApplicationActivationListener
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.extensions.PluginId
import com.intellij.openapi.project.Project
import com.intellij.openapi.project.ProjectManager
import com.intellij.openapi.project.ProjectManagerListener
import com.intellij.openapi.startup.StartupManager
import com.intellij.openapi.wm.IdeFrame
import io.unthrottled.doki.config.ThemeConfig
Expand Down Expand Up @@ -40,6 +38,9 @@ class TheDokiTheme : Disposable {
const val COMMUNITY_PLUGIN_ID = "io.acari.DDLCTheme"
private const val ULTIMATE_PLUGIN_ID = "io.unthrottled.DokiTheme"

val instance: TheDokiTheme
get() = ApplicationManager.getApplication().getService(TheDokiTheme::class.java)

fun getVersion(): Optional<String> =
PluginManagerCore.getPlugin(PluginId.getId(COMMUNITY_PLUGIN_ID))
.toOptional()
Expand Down Expand Up @@ -90,44 +91,39 @@ class TheDokiTheme : Disposable {
}
}
)
}

connection.subscribe(
ProjectManager.TOPIC,
object : ProjectManagerListener {
override fun projectOpened(project: Project) {
EXPUIBastardizer.bastardizeExperimentalUI()
ThemeManager.instance.currentTheme
.ifPresent {
EditorBackgroundWallpaperService.instance.checkForUpdates(it)
EmptyFrameWallpaperService.instance.checkForUpdates(it)
StickerPaneService.instance.checkForUpdates(it)
}

val isNewUser = ThemeConfig.instance.userId.isEmpty()
getVersion()
.ifPresent { version ->
if (version != ThemeConfig.instance.version) {
LegacyMigration.newVersionMigration(project)
ThemeConfig.instance.version = version
ThemeManager.instance.currentTheme.ifPresent {
StartupManager.getInstance(project).runWhenProjectIsInitialized {
UpdateNotification.display(
project,
version,
isNewUser,
)
}
}
}
fun projectOpened(project: Project) {
EXPUIBastardizer.bastardizeExperimentalUI()
ThemeManager.instance.currentTheme
.ifPresent {
EditorBackgroundWallpaperService.instance.checkForUpdates(it)
EmptyFrameWallpaperService.instance.checkForUpdates(it)
StickerPaneService.instance.checkForUpdates(it)
}

StartupManager.getInstance(project).runWhenProjectIsInitialized {
PromotionManager.registerPromotion(version)
}
val isNewUser = ThemeConfig.instance.userId.isEmpty()
getVersion()
.ifPresent { version ->
if (version != ThemeConfig.instance.version) {
LegacyMigration.newVersionMigration(project)
ThemeConfig.instance.version = version
ThemeManager.instance.currentTheme.ifPresent {
StartupManager.getInstance(project).runAfterOpened {
UpdateNotification.display(
project,
version,
isNewUser,
)
}
registerUser()
}
}

StartupManager.getInstance(project).runAfterOpened {
PromotionManager.registerPromotion(version)
}
}
)
registerUser()
}

private fun userOnBoarding() {
Expand All @@ -151,4 +147,7 @@ class TheDokiTheme : Disposable {
connection.dispose()
UpdateNotificationUpdater.dispose()
}

fun init() {
}
}

This file was deleted.

1 change: 0 additions & 1 deletion src/main/kotlin/io/unthrottled/doki/config/ThemeConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class ThemeConfig : PersistentStateComponent<ThemeConfig>, Cloneable {
var isFirstTime: Boolean = true
var isDokiBackground: Boolean = false
var isEmptyFrameBackground: Boolean = true
var isThemedTitleBar: Boolean = true
var showThemeStatusBar: Boolean = true
var allowPromotions: Boolean = true
var currentStickerName: String = CurrentSticker.DEFAULT.name
Expand Down
68 changes: 3 additions & 65 deletions src/main/kotlin/io/unthrottled/doki/hax/HackComponent.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,12 @@ import com.intellij.ui.CaptionPanel
import com.intellij.ui.Gray
import com.intellij.ui.JBColor
import com.intellij.ui.SimpleTextAttributes
import com.intellij.ui.messages.JBMacMessages
import com.intellij.ui.popup.util.MasterDetailPopupBuilder
import com.intellij.util.ui.UIUtil
import com.intellij.xdebugger.impl.ui.XDebuggerUIConstants
import com.intellij.xdebugger.memory.ui.ClassesTable
import io.unthrottled.doki.hax.FieldHacker.setFinalStatic
import io.unthrottled.doki.stickers.DOKI_BACKGROUND_PROP
import io.unthrottled.doki.ui.TitlePaneUI.Companion.LOL_NOPE
import io.unthrottled.doki.util.runSafely
import javassist.CannotCompileException
import javassist.ClassClassPath
Expand All @@ -45,7 +43,6 @@ import javassist.expr.ExprEditor
import javassist.expr.MethodCall
import javassist.expr.NewExpr
import java.awt.Color
import javax.swing.JDialog

@Suppress("TooManyFunctions", "LargeClass")
object HackComponent : Disposable {
Expand All @@ -60,11 +57,13 @@ object HackComponent : Disposable {
enableAccentConsistency()
enableBackgroundConsistency()
enableSelectionConsistency()
enableTitlePaneConsistency()
enableHoverConsistency()
enableHintConsistency()
}

fun init() {
}

private fun enableHintConsistency() {
hackReformatHintInfoForeground()
}
Expand Down Expand Up @@ -92,10 +91,6 @@ object HackComponent : Disposable {
}
}

private fun enableTitlePaneConsistency() {
hackSheetMessage()
}

private fun enableSelectionConsistency() {
hackWelcomeScreen()
hackSearchHighlight()
Expand All @@ -120,7 +115,6 @@ object HackComponent : Disposable {

private fun enableBackgroundConsistency() {
hackParameterInfoBackground()
hackSheetWindow()
hackToolWindowDecorator()
hackLivePreview()
hackEmptyTextPanel()
Expand Down Expand Up @@ -251,62 +245,6 @@ object HackComponent : Disposable {
}
}

private fun hackSheetMessage() {
runSafely({
val cp = ClassPool(true)
cp.insertClassPath(ClassClassPath(JBMacMessages::class.java))
val ctClass = cp.get("com.intellij.ui.messages.SheetMessage")
ctClass.declaredConstructors
.forEach { constructorDude ->
constructorDude.instrument(
object : ExprEditor() {
override fun edit(e: NewExpr?) {
if (e?.className == JDialog::class.java.name) {
e?.replace("{ \$2 = \"$LOL_NOPE\"; \$_ = \$proceed(\$\$); }")
}
}
}
)
}
ctClass.toClass()
}) {
log.warn("Unable to hackSheetMessage for reasons.")
}
}

private fun hackSheetWindow() {
runSafely({
val cp = ClassPool(true)
cp.insertClassPath(ClassClassPath(JBMacMessages::class.java))
val ctClass = cp.get("com.intellij.ui.messages.SheetController")
ctClass.declaredClasses
.filter { it.declaredMethods.any { m -> m.name == "paintComponent" } }
.forEach { classDude ->
classDude.getDeclaredMethods("paintComponent").forEach {
it.instrument(
object : ExprEditor() {
override fun edit(e: NewExpr?) {
if (e?.className == JBColor::class.java.name) {
e?.replace("{ \$_ = com.intellij.util.ui.UIUtil.getPanelBackground(); }")
}
}

override fun edit(e: MethodCall?) {
if (e?.methodName == "isUnderDarcula") {
e.replace("{ \$_ = true; }")
}
}
}
)
}
classDude.toClass()
}
ctClass.toClass()
}) {
log.warn("Unable to hackSheetWindow for reasons.")
}
}

private fun hackParameterInfoBackground() {
runSafely({
val cp = ClassPool(true)
Expand Down
Loading

0 comments on commit 6a7d18c

Please sign in to comment.