1
1
package com.github.dinbtechit.vscodetheme.startup
2
2
3
- import com.github.dinbtechit.vscodetheme.VSCodeTheme
4
3
import com.github.dinbtechit.vscodetheme.VSCodeThemeManager
5
- import com.github.dinbtechit.vscodetheme.actions.AlwaysApplyThemeAction
4
+
6
5
import com.github.dinbtechit.vscodetheme.actions.DonateAction
7
6
import com.github.dinbtechit.vscodetheme.actions.StarGithubRepoAction
8
7
import com.github.dinbtechit.vscodetheme.actions.WhatsNewAction
@@ -13,23 +12,17 @@ import com.intellij.ide.plugins.PluginManagerCore
13
12
import com.intellij.notification.Notification
14
13
import com.intellij.notification.NotificationGroupManager
15
14
import com.intellij.notification.NotificationType
16
- import com.intellij.openapi.actionSystem.DefaultActionGroup
17
15
import com.intellij.openapi.extensions.PluginId
18
16
import com.intellij.openapi.project.Project
19
- import com.intellij.openapi.startup.StartupActivity
17
+ import com.intellij.openapi.startup.ProjectActivity
18
+
20
19
21
- /* enum class DisplayActionType {
22
- DONATION_ONLY,
23
- SHOW_ALL_THEMES_FOR_DEFAULT,
24
- SHOW_NEW_DARK_MODERN_THEME
25
- }*/
26
20
object DisplayActionType {
27
21
const val DONATION_ONLY = " DONATION_ONLY"
28
22
const val SHOW_ALL_THEMES_FOR_DEFAULT = " SHOW_ALL_THEMES_FOR_DEFAULT"
29
- const val SHOW_NEW_DARK_MODERN_THEME = " SHOW_NEW_DARK_MODERN_THEME"
30
23
}
31
24
32
- class VSCodeStartupNotifyActivity : StartupActivity {
25
+ class VSCodeStartupNotifyActivity : ProjectActivity {
33
26
34
27
35
28
private val updateContent: String by lazy {
@@ -43,16 +36,7 @@ class VSCodeStartupNotifyActivity : StartupActivity {
43
36
private val switchThemeQuestion: String by lazy {
44
37
// language=HTML
45
38
"""
46
- Set one of the <b>VSCode Theme(s)</b> as a default theme.
47
- <br/>
48
- $updateContent
49
- """ .trimIndent()
50
- }
51
-
52
- private val tryNewDarkModernThemeQuestion: String by lazy {
53
- // language=HTML
54
- """
55
- Would you like to set the <b>VSCode Dark Modern</b> as a default theme?
39
+ Select <b>VSCode Theme(s)</b> from themes.
56
40
<br/>
57
41
$updateContent
58
42
""" .trimIndent()
@@ -67,23 +51,15 @@ class VSCodeStartupNotifyActivity : StartupActivity {
67
51
const val pluginId = " com.github.dinbtechit.vscodetheme"
68
52
}
69
53
70
- override fun runActivity (project : Project ) {
54
+ override suspend fun execute (project : Project ) {
71
55
val settings = VSCodeThemeSettingsStore .instance
72
56
val isReady = VSCodeThemeManager .getInstance().isVSCodeThemeReady()
73
57
if (isReady && getPlugin()?.version != VSCodeThemeSettingsStore .instance.version) {
74
58
settings.version = getPlugin()!! .version
75
- if (settings.alwaysApply) {
76
- if (settings.themeName != VSCodeTheme .UNKNOWN ) {
77
- VSCodeThemeManager .getInstance().switchToVSCodeTheme(selectedVSCodeTheme = settings.themeName)
78
- }
79
- showNotificationPopup(project)
80
- } else if (settings.showNotificationOnUpdate) {
81
- showNotificationPopup(project)
82
- }
59
+ showNotificationPopup(project)
83
60
}
84
61
// Uncomment for Testing popup
85
62
// showNotificationPopup(project)
86
-
87
63
}
88
64
89
65
private fun updateMsg (): String {
@@ -105,17 +81,8 @@ class VSCodeStartupNotifyActivity : StartupActivity {
105
81
}
106
82
107
83
private fun notificationContent (): String {
108
- if (! VSCodeThemeManager .getInstance().isVSCodeThemeSelected() && ! VSCodeThemeManager .getInstance()
109
- .isVSCodeDarkModernThemeSelected()
110
- ) {
111
- Util .displayActionType = DisplayActionType .SHOW_ALL_THEMES_FOR_DEFAULT
112
- return switchThemeQuestion
113
- } else if (VSCodeThemeManager .getInstance().isVSCodeThemeSelected()) {
114
- Util .displayActionType = DisplayActionType .SHOW_NEW_DARK_MODERN_THEME
115
- return tryNewDarkModernThemeQuestion
116
- }
117
- Util .displayActionType = DisplayActionType .DONATION_ONLY
118
- return updateContent
84
+ Util .displayActionType = DisplayActionType .SHOW_ALL_THEMES_FOR_DEFAULT
85
+ return switchThemeQuestion
119
86
}
120
87
121
88
private fun getPlugin (): IdeaPluginDescriptor ? = PluginManagerCore .getPlugin(PluginId .getId(pluginId))
@@ -127,21 +94,7 @@ class VSCodeStartupNotifyActivity : StartupActivity {
127
94
.getNotificationGroup(" VSCode Theme Notification Group" )
128
95
.createNotification(content, type)
129
96
.setTitle(title)
130
- .setIcon(VSCodeIcons .Logo ).apply {
131
- if (Util .displayActionType == DisplayActionType .SHOW_ALL_THEMES_FOR_DEFAULT ) {
132
- addAction(DefaultActionGroup (" Show All" , false ).apply {
133
- add(
134
- AlwaysApplyThemeAction (
135
- text = VSCodeTheme .DARK_MODERN ,
136
- vscodeTheme = VSCodeTheme .DARK_MODERN
137
- )
138
- )
139
- add(AlwaysApplyThemeAction (text = VSCodeTheme .DARK , vscodeTheme = VSCodeTheme .DARK ))
140
- })
141
- } else if (Util .displayActionType == DisplayActionType .SHOW_NEW_DARK_MODERN_THEME ) {
142
- addAction(AlwaysApplyThemeAction (text = " Switch Now" , vscodeTheme = VSCodeTheme .DARK_MODERN ))
143
- }
144
- }
97
+ .setIcon(VSCodeIcons .Logo )
145
98
.addAction(DonateAction ())
146
99
.addAction(StarGithubRepoAction ())
147
100
.addAction(WhatsNewAction ())
0 commit comments