Skip to content

Commit

Permalink
Chores - Deprecated APIs and dart highlighting fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
dinbtechit committed Dec 17, 2023
1 parent d6dff47 commit 8c739fa
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 38 deletions.
1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,26 +1,15 @@
package com.github.dinbtechit.vscodetheme

import com.github.dinbtechit.vscodetheme.settings.VSCodeThemeSettingsStore
import com.intellij.ide.DataManager
import com.intellij.ide.actions.SettingsEntryPointAction
import com.intellij.ide.plugins.IdeaPluginDescriptor
import com.intellij.ide.plugins.PluginManagerCore
import com.intellij.ide.ui.*
import com.intellij.ide.ui.laf.UIThemeLookAndFeelInfoImpl
import com.intellij.ide.ui.laf.UiThemeProviderListManager
import com.intellij.openapi.actionSystem.ActionManager
import com.intellij.openapi.actionSystem.ActionPlaces
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.ide.ui.LafManager
import com.intellij.ide.ui.LafManagerListener

Check warning on line 7 in src/main/kotlin/com/github/dinbtechit/vscodetheme/VSCodeThemeManager.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unused import directive

Unused import directive
import com.intellij.ide.ui.ThemeListProvider

Check warning on line 8 in src/main/kotlin/com/github/dinbtechit/vscodetheme/VSCodeThemeManager.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unused import directive

Unused import directive
import com.intellij.openapi.application.ApplicationManager

Check warning on line 9 in src/main/kotlin/com/github/dinbtechit/vscodetheme/VSCodeThemeManager.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unused import directive

Unused import directive
import com.intellij.openapi.extensions.PluginId
import com.intellij.openapi.options.Configurable
import com.intellij.openapi.options.SearchableConfigurable
import com.intellij.openapi.options.ShowSettingsUtil
import com.intellij.openapi.project.ProjectManager
import java.util.*
import javax.swing.UIDefaults

import javax.swing.UIManager
import com.intellij.util.ui.JBUI

Check warning on line 11 in src/main/kotlin/com/github/dinbtechit/vscodetheme/VSCodeThemeManager.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unused import directive

Unused import directive
import com.jetbrains.rd.util.string.printToString

Check warning on line 12 in src/main/kotlin/com/github/dinbtechit/vscodetheme/VSCodeThemeManager.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unused import directive

Unused import directive

/*enum class VSCodeTheme(val theme: String) {
UNKNOWN("UNKNOWN"),
Expand Down Expand Up @@ -51,7 +40,7 @@ class VSCodeThemeManager {
try {
if (getPlugin()?.isEnabled != null) {
val vscodeTheme =
LafManager.getInstance().installedThemes.firstOrNull { (it as UIThemeLookAndFeelInfoImpl).theme.name == VSCodeTheme.DARK }
LafManager.getInstance().installedThemes.firstOrNull { it.toString().contains(VSCodeTheme.DARK) }

Check warning on line 43 in src/main/kotlin/com/github/dinbtechit/vscodetheme/VSCodeThemeManager.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unstable API Usage

'getInstalledThemes()' is marked unstable with @ApiStatus.Experimental
return vscodeTheme != null
}
return false
Expand All @@ -60,13 +49,12 @@ class VSCodeThemeManager {
}
}


fun switchToVSCodeTheme(always: Boolean = false, selectedVSCodeTheme: String = VSCodeTheme.DARK) {
try {
if (isVSCodeThemeReady()) {
val convertedSelectedVSCodeTheme = convertOldToNewTheme(selectedVSCodeTheme)
val vscodeTheme =
LafManager.getInstance().installedThemes.firstOrNull { it.name == convertedSelectedVSCodeTheme }
LafManager.getInstance().installedThemes.firstOrNull { it.toString().contains(convertedSelectedVSCodeTheme) }

Check warning on line 57 in src/main/kotlin/com/github/dinbtechit/vscodetheme/VSCodeThemeManager.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unstable API Usage

'getInstalledThemes()' is marked unstable with @ApiStatus.Experimental

if (vscodeTheme != null) {
LafManager.getInstance().currentUIThemeLookAndFeel = vscodeTheme

Check warning on line 60 in src/main/kotlin/com/github/dinbtechit/vscodetheme/VSCodeThemeManager.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unstable API Usage

'setCurrentUIThemeLookAndFeel([email protected] UIThemeLookAndFeelInfo)' is unstable because its signature references unstable 'com.intellij.ide.ui.laf.UIThemeLookAndFeelInfo' marked with @ApiStatus.Internal
Expand All @@ -82,6 +70,19 @@ class VSCodeThemeManager {
}
}

fun isVSCodeThemeSelected(): Boolean {
val theme = LafManager.getInstance().currentUIThemeLookAndFeel

Check warning on line 74 in src/main/kotlin/com/github/dinbtechit/vscodetheme/VSCodeThemeManager.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unstable API Usage

'getCurrentUIThemeLookAndFeel()' is unstable because its signature references unstable 'com.intellij.ide.ui.laf.UIThemeLookAndFeelInfo' marked with @ApiStatus.Internal
if (theme != null) {
return theme.toString().contains(VSCodeTheme.DARK) && !theme.toString().contains("Modern")
}
return false
}

fun isVSCodeDarkModernThemeSelected(): Boolean {
val theme = LafManager.getInstance().currentUIThemeLookAndFeel

Check warning on line 82 in src/main/kotlin/com/github/dinbtechit/vscodetheme/VSCodeThemeManager.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unstable API Usage

'getCurrentUIThemeLookAndFeel()' is unstable because its signature references unstable 'com.intellij.ide.ui.laf.UIThemeLookAndFeelInfo' marked with @ApiStatus.Internal
return theme?.toString()?.contains(VSCodeTheme.DARK_MODERN) ?: false
}

private fun convertOldToNewTheme(theme: String): String {
return when (theme) {
"DARK_MODERN" -> "VSCode Dark Modern"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,13 @@ import com.github.dinbtechit.vscodetheme.icons.VSCodeIcons
import com.github.dinbtechit.vscodetheme.settings.VSCodeThemeSettingsStore
import com.intellij.ide.plugins.IdeaPluginDescriptor
import com.intellij.ide.plugins.PluginManagerCore
import com.intellij.ide.ui.LafManager
import com.intellij.ide.ui.laf.UIThemeLookAndFeelInfoImpl
import com.intellij.notification.Notification
import com.intellij.notification.NotificationGroupManager
import com.intellij.notification.NotificationType
import com.intellij.openapi.actionSystem.DefaultActionGroup
import com.intellij.openapi.extensions.PluginId
import com.intellij.openapi.project.Project
import com.intellij.openapi.startup.StartupActivity
import com.intellij.openapi.application.ApplicationInfo

/*enum class DisplayActionType {
DONATION_ONLY,
Expand Down Expand Up @@ -98,20 +95,6 @@ class VSCodeStartupNotifyActivity : StartupActivity {
}
}

private fun isVSCodeThemeSelected(): Boolean {
val currentIDEVersion = ApplicationInfo.getInstance().build
val targetIDEVersion = com.intellij.openapi.util.BuildNumber.fromString("2023.3")
print(currentIDEVersion)
print(targetIDEVersion)
/* if (currentIDEVersion.compareTo(targetIDEVersion) <= 0) {
return LafManager.getInstance().currentUIThemeLookAndFeel.name == VSCodeTheme.DARK
}*/
return (LafManager.getInstance().currentUIThemeLookAndFeel as UIThemeLookAndFeelInfoImpl).theme.name == VSCodeTheme.DARK
}

private fun isVSCodeDarkModernThemeSelected() =
(LafManager.getInstance().currentUIThemeLookAndFeel as UIThemeLookAndFeelInfoImpl).theme.name == VSCodeTheme.DARK_MODERN

private fun showNotificationPopup(project: Project) {
Util.notification = createNotification(
updateMsg(),
Expand All @@ -122,10 +105,12 @@ class VSCodeStartupNotifyActivity : StartupActivity {
}

private fun notificationContent(): String {
if (!isVSCodeThemeSelected() && !isVSCodeDarkModernThemeSelected()) {
if (!VSCodeThemeManager.getInstance().isVSCodeThemeSelected() && !VSCodeThemeManager.getInstance()
.isVSCodeDarkModernThemeSelected()
) {
Util.displayActionType = DisplayActionType.SHOW_ALL_THEMES_FOR_DEFAULT
return switchThemeQuestion
} else if (isVSCodeThemeSelected()) {
} else if (VSCodeThemeManager.getInstance().isVSCodeThemeSelected()) {
Util.displayActionType = DisplayActionType.SHOW_NEW_DARK_MODERN_THEME
return tryNewDarkModernThemeQuestion
}
Expand Down

0 comments on commit 8c739fa

Please sign in to comment.