Skip to content
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

Bump jvm from 1.8.10 to 1.9.22 #743

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ plugins {
// Custom plugin for building all the themes
id("doki-theme-plugin")
// Kotlin support
kotlin("jvm") version "1.8.10"
kotlin("jvm") version "1.9.22"
// gradle-intellij-plugin - read more: https://github.com/JetBrains/gradle-intellij-plugin
id("org.jetbrains.intellij") version "1.16.1"
// detekt linter - read more: https://detekt.github.io/detekt/gradle.html
Expand Down Expand Up @@ -57,7 +57,7 @@ intellij {
plugins.set(
properties("platformPlugins").split(',')
.map(String::trim)
.filter(String::isNotEmpty)
.filter(String::isNotEmpty),
)
}

Expand Down
2 changes: 1 addition & 1 deletion buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
kotlin("jvm") version "1.8.10"
kotlin("jvm") version "1.9.22"
`kotlin-dsl`
}

Expand Down
2 changes: 1 addition & 1 deletion detekt-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ formatting:
active: false
autoCorrect: false
Indentation:
active: true
active: false
autoCorrect: false
indentSize: 2
ParameterListWrapping:
Expand Down
8 changes: 4 additions & 4 deletions src/main/kotlin/io/unthrottled/doki/TheDokiTheme.kt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class TheDokiTheme : Disposable {
.map { it.toOptional() }
.orElseGet {
PluginManagerCore.getPlugin(
PluginId.getId(ULTIMATE_PLUGIN_ID)
PluginId.getId(ULTIMATE_PLUGIN_ID),
).toOptional()
}
.map { it.version }
Expand All @@ -73,7 +73,7 @@ class TheDokiTheme : Disposable {
setSVGColorPatcher(it)
}
}
}
},
)

connection.subscribe(
Expand All @@ -89,7 +89,7 @@ class TheDokiTheme : Disposable {
IconPathReplacementComponent.removePatchers()
LookAndFeelInstaller.removeIcons()
}
}
},
)
}

Expand Down Expand Up @@ -118,7 +118,7 @@ class TheDokiTheme : Disposable {
UpdateNotification.display(
project,
version,
isNewUser
isNewUser,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import io.unthrottled.doki.config.ThemeConfig
import io.unthrottled.doki.settings.actors.BackgroundActor

class BackgroundToggleAction : BaseToggleAction() {
override fun isSelected(e: AnActionEvent): Boolean =
ThemeConfig.instance.isDokiBackground
override fun isSelected(e: AnActionEvent): Boolean = ThemeConfig.instance.isDokiBackground

override fun setSelected(e: AnActionEvent, state: Boolean) {
override fun setSelected(
e: AnActionEvent,
state: Boolean,
) {
BackgroundActor.handleBackgroundUpdate(state)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ import io.unthrottled.doki.discreet.toDiscreetMode
import io.unthrottled.doki.settings.actors.DiscreetModeActor

class DiscreetModeAction : BaseToggleAction() {
override fun isSelected(e: AnActionEvent): Boolean =
ThemeConfig.instance.discreetMode
override fun isSelected(e: AnActionEvent): Boolean = ThemeConfig.instance.discreetMode

override fun setSelected(e: AnActionEvent, state: Boolean) {
override fun setSelected(
e: AnActionEvent,
state: Boolean,
) {
DiscreetModeActor.dispatchDiscreetMode(state.toDiscreetMode())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@ import io.unthrottled.doki.settings.actors.StickerHideActor
class HideOnHoverAction : BaseToggleAction(), DumbAware {
override fun isSelected(e: AnActionEvent): Boolean = ThemeConfig.instance.hideOnHover

override fun setSelected(e: AnActionEvent, state: Boolean) {
override fun setSelected(
e: AnActionEvent,
state: Boolean,
) {
StickerHideActor.setStickerHideStuff(
state,
ThemeConfig.instance.hideDelayMS
ThemeConfig.instance.hideDelayMS,
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import io.unthrottled.doki.config.ThemeConfig
import io.unthrottled.doki.settings.actors.MoveableStickerActor

class MoveableStickerToggleAction : BaseToggleAction() {
override fun isSelected(e: AnActionEvent): Boolean =
ThemeConfig.instance.isMoveableStickers
override fun isSelected(e: AnActionEvent): Boolean = ThemeConfig.instance.isMoveableStickers

override fun setSelected(e: AnActionEvent, state: Boolean) {
override fun setSelected(
e: AnActionEvent,
state: Boolean,
) {
MoveableStickerActor.moveableStickers(state)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ class ShowSettingsAction : AnAction(), DumbAware {
{
ShowSettingsUtil.getInstance().showSettingsDialog(
ProjectManager.getInstance().defaultProject,
THEME_SETTINGS_DISPLAY_NAME
THEME_SETTINGS_DISPLAY_NAME,
)
},
ModalityState.NON_MODAL
ModalityState.NON_MODAL,
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@ import io.unthrottled.doki.TheDokiTheme
import io.unthrottled.doki.notification.UpdateNotification

class ShowUpdateNotification : AnAction(), DumbAware {

override fun actionPerformed(e: AnActionEvent) {
TheDokiTheme.getVersion()
.ifPresent {
UpdateNotification.display(
e.project!!,
it,
false
false,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ import io.unthrottled.doki.settings.actors.StickerActor
import io.unthrottled.doki.stickers.StickerLevel.ON

class StickersToggleAction : BaseToggleAction() {
override fun isSelected(e: AnActionEvent): Boolean =
ThemeConfig.instance.currentStickerLevel == ON
override fun isSelected(e: AnActionEvent): Boolean = ThemeConfig.instance.currentStickerLevel == ON

override fun setSelected(e: AnActionEvent, state: Boolean) {
override fun setSelected(
e: AnActionEvent,
state: Boolean,
) {
StickerActor.enableStickers(state)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ import io.unthrottled.doki.settings.actors.StickerActor
import io.unthrottled.doki.stickers.CurrentSticker

class SwapStickerAction : BaseToggleAction() {
override fun isSelected(e: AnActionEvent): Boolean =
ThemeConfig.instance.currentSticker == CurrentSticker.SECONDARY
override fun isSelected(e: AnActionEvent): Boolean = ThemeConfig.instance.currentSticker == CurrentSticker.SECONDARY

override fun setSelected(e: AnActionEvent, state: Boolean) {
override fun setSelected(
e: AnActionEvent,
state: Boolean,
) {
StickerActor.swapStickers(if (state) CurrentSticker.SECONDARY else CurrentSticker.DEFAULT)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import io.unthrottled.doki.config.ThemeConfig
import io.unthrottled.doki.settings.actors.LafAnimationActor

class ThemeAnimationToggle : BaseToggleAction() {
override fun isSelected(e: AnActionEvent): Boolean =
ThemeConfig.instance.isLafAnimation
override fun isSelected(e: AnActionEvent): Boolean = ThemeConfig.instance.isLafAnimation

override fun setSelected(e: AnActionEvent, state: Boolean) {
override fun setSelected(
e: AnActionEvent,
state: Boolean,
) {
LafAnimationActor.enableAnimation(state)
}
}
62 changes: 37 additions & 25 deletions src/main/kotlin/io/unthrottled/doki/assets/AssetManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ import java.util.Optional
import java.util.concurrent.Callable

enum class AssetCategory(val category: String) {
STICKERS("stickers"), BACKGROUNDS("backgrounds"),
STICKERS("stickers"),
BACKGROUNDS("backgrounds"),
PROMOTION("promotion"),
MISC("misc")
MISC("misc"),
}

object HttpClientFactory {
Expand All @@ -41,7 +42,10 @@ object AssetManager {
* file:// url to the local asset. If it was not able to get the asset then it
* will return empty if the asset is not available locally.
*/
fun resolveAssetUrl(assetCategory: AssetCategory, assetPath: String): Optional<String> =
fun resolveAssetUrl(
assetCategory: AssetCategory,
assetPath: String,
): Optional<String> =
cachedResolve(assetCategory, assetPath, ASSET_SOURCE)
.map { it.toOptional() }
.orElseGet {
Expand All @@ -52,7 +56,10 @@ object AssetManager {
* Works just like <code>resolveAssetUrl</code> except that it will always
* download the remote asset.
*/
fun forceResolveAssetUrl(assetCategory: AssetCategory, assetPath: String): Optional<String> =
fun forceResolveAssetUrl(
assetCategory: AssetCategory,
assetPath: String,
): Optional<String> =
forceResolve(assetCategory, assetPath, ASSET_SOURCE)
.map { it.toOptional() }
.orElseGet {
Expand All @@ -62,7 +69,7 @@ object AssetManager {
private fun cachedResolve(
assetCategory: AssetCategory,
assetPath: String,
assetSource: String
assetSource: String,
): Optional<String> =
resolveAsset(assetCategory, assetPath, assetSource) { localAssetPath, remoteAssetUrl ->
resolveTheAssetUrl(localAssetPath, remoteAssetUrl)
Expand All @@ -71,7 +78,7 @@ object AssetManager {
private fun forceResolve(
assetCategory: AssetCategory,
assetPath: String,
assetSource: String
assetSource: String,
): Optional<String> =
resolveAsset(assetCategory, assetPath, assetSource) { localAssetPath, remoteAssetUrl ->
downloadAndGetAssetUrl(localAssetPath, remoteAssetUrl)
Expand All @@ -81,29 +88,34 @@ object AssetManager {
assetCategory: AssetCategory,
assetPath: String,
assetSource: String,
resolveAsset: (Path, String) -> Optional<String>
resolveAsset: (Path, String) -> Optional<String>,
): Optional<String> =
constructLocalAssetPath(assetCategory, assetPath)
.toOptional()
.flatMap {
val remoteAssetUrl = constructRemoteAssetUrl(
assetCategory,
assetPath,
assetSource
)
val remoteAssetUrl =
constructRemoteAssetUrl(
assetCategory,
assetPath,
assetSource,
)
resolveAsset(it, remoteAssetUrl)
}

private fun constructRemoteAssetUrl(
assetCategory: AssetCategory,
assetPath: String,
assetSource: String
): String = when (assetCategory) {
AssetCategory.STICKERS -> "$assetSource/${assetCategory.category}/jetbrains/v2$assetPath"
else -> "$assetSource/${assetCategory.category}/$assetPath"
}
assetSource: String,
): String =
when (assetCategory) {
AssetCategory.STICKERS -> "$assetSource/${assetCategory.category}/jetbrains/v2$assetPath"
else -> "$assetSource/${assetCategory.category}/$assetPath"
}

private fun resolveTheAssetUrl(localAssetPath: Path, remoteAssetUrl: String): Optional<String> =
private fun resolveTheAssetUrl(
localAssetPath: Path,
remoteAssetUrl: String,
): Optional<String> =
when {
hasAssetChanged(localAssetPath, remoteAssetUrl) ->
downloadAndGetAssetUrl(localAssetPath, remoteAssetUrl)
Expand All @@ -114,30 +126,30 @@ object AssetManager {

fun constructLocalAssetPath(
assetCategory: AssetCategory,
assetPath: String
assetPath: String,
): Path =
Paths.get(
getLocalAssetDirectory(),
assetCategory.category,
assetPath
assetPath,
).normalize().toAbsolutePath()

fun constructGlobalAssetPath(
assetCategory: AssetCategory,
assetPath: String
assetPath: String,
): Optional<Path> =
getGlobalAssetDirectory()
.map {
Paths.get(
it,
assetCategory.category,
assetPath
assetPath,
)
}

private fun downloadAndGetAssetUrl(
localAssetPath: Path,
remoteAssetUrl: String
remoteAssetUrl: String,
): Optional<String> {
createDirectories(localAssetPath)
return ApplicationManager.getApplication().executeOnPooledThread(
Expand All @@ -146,13 +158,13 @@ object AssetManager {
Files.newOutputStream(
localAssetPath,
StandardOpenOption.CREATE,
StandardOpenOption.TRUNCATE_EXISTING
StandardOpenOption.TRUNCATE_EXISTING,
).use { bufferedWriter ->
IOUtils.copy(inputStream, bufferedWriter)
}
localAssetPath.toUri().toString()
}
}
},
).get()
}
}
Loading
Loading