mirror of
https://github.com/chylex/IntelliJ-Rainbow-Brackets.git
synced 2025-04-14 11:15:43 +02:00
Remove post-update notification
This commit is contained in:
parent
4cab3548c3
commit
dd63c37354
src/main
kotlin/com/github/izhangzhihao/rainbow/brackets
resources/META-INF
@ -1,48 +0,0 @@
|
||||
package com.github.izhangzhihao.rainbow.brackets
|
||||
|
||||
import com.intellij.notification.*
|
||||
import com.intellij.notification.impl.NotificationsManagerImpl
|
||||
import com.intellij.openapi.Disposable
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.ui.popup.Balloon
|
||||
import com.intellij.openapi.wm.WindowManager
|
||||
import com.intellij.ui.BalloonLayoutData
|
||||
import com.intellij.ui.awt.RelativePoint
|
||||
import java.awt.Point
|
||||
|
||||
class ApplicationServicePlaceholder : Disposable {
|
||||
override fun dispose() = Unit
|
||||
|
||||
companion object {
|
||||
val INSTANCE: ApplicationServicePlaceholder = ApplicationManager.getApplication().getService(ApplicationServicePlaceholder::class.java)
|
||||
}
|
||||
}
|
||||
|
||||
fun createNotification(title: String, content: String, type: NotificationType,
|
||||
listener: NotificationListener): Notification {
|
||||
return NotificationGroupManager.getInstance().getNotificationGroup("Rainbow Brackets Notification Group")
|
||||
.createNotification(title, content, type).setListener(listener)
|
||||
}
|
||||
|
||||
fun showFullNotification(project: Project, notification: Notification) {
|
||||
val frame = WindowManager.getInstance().getIdeFrame(project)
|
||||
if (frame == null) {
|
||||
notification.notify(project)
|
||||
return
|
||||
}
|
||||
val bounds = frame.component.bounds
|
||||
val target = RelativePoint(frame.component, Point(bounds.x + bounds.width, 20))
|
||||
|
||||
try {
|
||||
val balloon = NotificationsManagerImpl.createBalloon(frame,
|
||||
notification,
|
||||
true, // showCallout
|
||||
true, // hideOnClickOutside
|
||||
BalloonLayoutData.fullContent(),
|
||||
ApplicationServicePlaceholder.INSTANCE)
|
||||
balloon.show(target, Balloon.Position.atLeft)
|
||||
} catch (e: Exception) {
|
||||
notification.notify(project)
|
||||
}
|
||||
}
|
@ -1,97 +0,0 @@
|
||||
package com.github.izhangzhihao.rainbow.brackets
|
||||
|
||||
import com.github.izhangzhihao.rainbow.brackets.settings.RainbowSettings
|
||||
import com.intellij.ide.plugins.IdeaPluginDescriptor
|
||||
import com.intellij.ide.plugins.PluginManagerCore
|
||||
import com.intellij.ide.plugins.PluginManagerCore.isPluginInstalled
|
||||
import com.intellij.ide.startup.StartupActionScriptManager
|
||||
import com.intellij.ide.startup.StartupActionScriptManager.DeleteCommand
|
||||
import com.intellij.notification.NotificationListener.UrlOpeningListener
|
||||
import com.intellij.notification.NotificationType
|
||||
import com.intellij.openapi.extensions.PluginId
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.startup.StartupActivity
|
||||
|
||||
|
||||
class RainbowUpdateNotifyActivity : StartupActivity {
|
||||
|
||||
override fun runActivity(project: Project) {
|
||||
removeIfInstalled()
|
||||
val settings = RainbowSettings.instance
|
||||
if (getPlugin()?.version != settings.version) {
|
||||
settings.version = getPlugin()!!.version
|
||||
if (settings.showNotificationOnUpdate) {
|
||||
showUpdate(project)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun removeIfInstalled() {
|
||||
val pluginId = PluginId.getId("com.github.jadepeng.rainbowfart")
|
||||
val isInstalled = isPluginInstalled(pluginId)
|
||||
if (isInstalled) {
|
||||
val pluginDescriptor = PluginManagerCore.getPlugin(pluginId)
|
||||
if (pluginDescriptor != null) {
|
||||
//disablePlugin(pluginId)
|
||||
StartupActionScriptManager.addActionCommand(DeleteCommand(pluginDescriptor.pluginPath))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val pluginId = "izhangzhihao.rainbow.brackets"
|
||||
|
||||
|
||||
private val updateContent: String by lazy {
|
||||
//language=HTML
|
||||
"""
|
||||
<br/>
|
||||
🌈Thank you for downloading <b><a href="https://github.com/izhangzhihao/intellij-rainbow-brackets">Rainbow Brackets</a></b>!<br>
|
||||
🎉Sponsored by <a href="https://codestream.com/?utm_source=jbmarket&utm_medium=banner&utm_campaign=jbrainbowbrackets">CodeStream</a>.<br>
|
||||
👍If you find this plugin helpful, <b><a href="https://github.com/izhangzhihao/intellij-rainbow-brackets#support-us">please support us!</a>.</b><br>
|
||||
<b><a href="https://github.com/izhangzhihao/intellij-rainbow-brackets#support-us">Donate</a></b> by <b><a href="https://opencollective.com/intellij-rainbow-brackets">OpenCollective</a></b> Or AliPay/WeChatPay to <b><a href="https://github.com/izhangzhihao/intellij-rainbow-brackets#sponsors">become a sponsor</a>!.</b><br>
|
||||
📝Check out <b><a href="https://izhangzhihao.github.io/rainbow-brackets-document/">the document</a></b> for all features of this plugin.<br>
|
||||
🐛If you run into any problem, <b><a href="https://github.com/izhangzhihao/intellij-rainbow-brackets/issues">feel free to raise an issue</a>.</b><br>
|
||||
🆕See <b><a href="${changelog()}">changelog</a></b> for more details about this update.<br>
|
||||
👉Want to customize your own color scheme of Rainbow Brackets? Edit it under
|
||||
<b>Settings > Editor > Color Scheme > Rainbow Brackets</b><br>
|
||||
👉Tired of the bundled colors? Try out the new color generator!
|
||||
<b>Settings > Other Settings > Rainbow Brackets > Use color generator</b><br>
|
||||
👉Other additional features under
|
||||
<b>Settings > Other Settings > Rainbow Brackets</b><br/>
|
||||
Enjoy your colorful code🌈.
|
||||
"""
|
||||
}
|
||||
|
||||
private fun changelog(): String {
|
||||
val plugin = getPlugin()
|
||||
return if (plugin == null) {
|
||||
"""https://github.com/izhangzhihao/intellij-rainbow-brackets/releases"""
|
||||
} else {
|
||||
"""https://github.com/izhangzhihao/intellij-rainbow-brackets/releases/tag/${plugin.version}"""
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun getPlugin(): IdeaPluginDescriptor? = PluginManagerCore.getPlugin(PluginId.getId(pluginId))
|
||||
|
||||
private fun updateMsg(): String {
|
||||
val plugin = getPlugin()
|
||||
return if (plugin == null) {
|
||||
"Rainbow Brackets installed."
|
||||
} else {
|
||||
"Rainbow Brackets updated to ${plugin.version}"
|
||||
}
|
||||
}
|
||||
|
||||
private fun showUpdate(project: Project) {
|
||||
val notification = createNotification(
|
||||
updateMsg(),
|
||||
updateContent,
|
||||
NotificationType.INFORMATION,
|
||||
UrlOpeningListener(false)
|
||||
)
|
||||
showFullNotification(project, notification)
|
||||
}
|
||||
}
|
||||
}
|
@ -21,7 +21,6 @@ class RainbowSettings : PersistentStateComponent<RainbowSettings> {
|
||||
var isShowRainbowIndentGuides = true
|
||||
var isDoNOTRainbowifyBracketsWithoutContent = false
|
||||
var isDoNOTRainbowifyTheFirstLevel = false
|
||||
var version = "Unknown"
|
||||
var isRainbowifyHTMLInsideJS = true
|
||||
var isRainbowifyKotlinLabel = true
|
||||
var isRainbowifyKotlinFunctionLiteralBracesAndArrow = true
|
||||
@ -36,7 +35,6 @@ class RainbowSettings : PersistentStateComponent<RainbowSettings> {
|
||||
var disableRainbowIndentsInZenMode = true
|
||||
var useColorGenerator = false
|
||||
var customColorGeneratorOption: String? = null
|
||||
var showNotificationOnUpdate = true
|
||||
var rainbowifyTagNameInXML = false
|
||||
var doNOTRainbowifyTemplateString = false
|
||||
var doNOTRainbowifyBigFiles = true
|
||||
@ -60,4 +58,4 @@ class RainbowSettings : PersistentStateComponent<RainbowSettings> {
|
||||
val instance: RainbowSettings
|
||||
get() = ApplicationManager.getApplication().getService(RainbowSettings::class.java)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -772,10 +772,8 @@
|
||||
|
||||
<additionalTextAttributes scheme="Default" file="colorSchemes/rainbow-color-default.xml"/>
|
||||
<additionalTextAttributes scheme="Darcula" file="colorSchemes/rainbow-color-default-darcula.xml"/>
|
||||
<postStartupActivity implementation="com.github.izhangzhihao.rainbow.brackets.RainbowUpdateNotifyActivity"/>
|
||||
<!--<errorHandler implementation="com.github.izhangzhihao.rainbow.brackets.util.GitHubErrorReporter"/>-->
|
||||
<highlightingPassFactory implementation="com.github.izhangzhihao.rainbow.brackets.indents.RainbowIndentsPassFactory"/>
|
||||
<applicationService serviceImplementation="com.github.izhangzhihao.rainbow.brackets.ApplicationServicePlaceholder" id="ApplicationServicePlaceholder"/>
|
||||
<editorNotificationProvider implementation="com.github.izhangzhihao.rainbow.brackets.RainbowifyBanner"/>
|
||||
<notificationGroup id="Rainbow Brackets Notification Group" displayType="STICKY_BALLOON"/>
|
||||
</extensions>
|
||||
|
Loading…
Reference in New Issue
Block a user