Compose Updated, Dialog and Windows Exe Not working fix, Icons Added.

This commit is contained in:
shabinder 2021-09-26 03:26:04 +05:30
parent 45ff63a8bf
commit d4076be165
10 changed files with 123 additions and 82 deletions

View File

@ -22,9 +22,9 @@ import org.gradle.kotlin.dsl.accessors.runtime.addDependencyTo
object Versions { object Versions {
// App's Version (To be bumped at each update) // App's Version (To be bumped at each update)
const val versionName = "3.3.0" const val versionName = "3.3.1"
const val versionCode = 24 const val versionCode = 25
// Kotlin // Kotlin
const val kotlinVersion = "1.5.21" const val kotlinVersion = "1.5.21"
@ -122,7 +122,7 @@ object JetBrains {
object Compose { object Compose {
// __LATEST_COMPOSE_RELEASE_VERSION__ // __LATEST_COMPOSE_RELEASE_VERSION__
private const val VERSION = "1.0.0-alpha2" private const val VERSION = "1.0.0-alpha3"
const val gradlePlugin = "org.jetbrains.compose:compose-gradle-plugin:$VERSION" const val gradlePlugin = "org.jetbrains.compose:compose-gradle-plugin:$VERSION"
} }
} }

View File

@ -16,8 +16,6 @@
package com.shabinder.common.uikit.utils package com.shabinder.common.uikit.utils
import android.util.Log
import androidx.compose.animation.core.TweenSpec
import androidx.compose.animation.core.animateFloatAsState import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.animation.core.tween import androidx.compose.animation.core.tween
import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue
@ -26,7 +24,6 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.composed import androidx.compose.ui.composed
import androidx.compose.ui.draw.alpha
import androidx.compose.ui.draw.drawBehind import androidx.compose.ui.draw.drawBehind
import androidx.compose.ui.graphics.Brush import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Color
@ -70,10 +67,10 @@ fun Modifier.verticalGradientScrim(
} }
var height by remember { mutableStateOf(fixedHeight ?: 1f) } var height by remember { mutableStateOf(fixedHeight ?: 1f) }
val scrimHeight by animateFloatAsState( val scrimHeight by animateFloatAsState(
// Whenever the target value changes, new animation // Whenever the target value changes, new animation
// will start to the new target value // will start to the new target value
targetValue = height, targetValue = height,
animationSpec = tween(durationMillis = 1500) animationSpec = tween(durationMillis = 1500)
) )
val brush = remember(color, numStops, startYPercentage, endYPercentage, scrimHeight) { val brush = remember(color, numStops, startYPercentage, endYPercentage, scrimHeight) {
Brush.verticalGradient( Brush.verticalGradient(

View File

@ -3,6 +3,9 @@ package com.shabinder.common.uikit
import androidx.compose.animation.AnimatedVisibility import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.ExperimentalAnimationApi import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.painter.BitmapPainter
import androidx.compose.ui.res.loadImageBitmap
import androidx.compose.ui.res.useResource
@OptIn(ExperimentalAnimationApi::class) @OptIn(ExperimentalAnimationApi::class)
@Composable @Composable
@ -12,7 +15,11 @@ actual fun Dialog(
content: @Composable () -> Unit content: @Composable () -> Unit
) { ) {
AnimatedVisibility(isVisible) { AnimatedVisibility(isVisible) {
androidx.compose.ui.window.Dialog(onDismiss) { androidx.compose.ui.window.Dialog(
onDismiss,
title = "SpotiFlyer",
icon = BitmapPainter(useResource("drawable/spotiflyer.png", ::loadImageBitmap))
) {
content() content()
} }
} }

View File

@ -54,7 +54,10 @@ interface FileManager {
fun createDirectory(dirPath: String) fun createDirectory(dirPath: String)
suspend fun cacheImage(image: Any, path: String) // in Android = ImageBitmap, Desktop = BufferedImage suspend fun cacheImage(
image: Any,
path: String
) // in Android = ImageBitmap, Desktop = BufferedImage
suspend fun loadImage(url: String, reqWidth: Int = 150, reqHeight: Int = 150): Picture suspend fun loadImage(url: String, reqWidth: Int = 150, reqHeight: Int = 150): Picture
@ -74,13 +77,15 @@ interface FileManager {
* */ * */
fun FileManager.createDirectories() { fun FileManager.createDirectories() {
try { try {
createDirectory(defaultDir()) if (defaultDir() != "null") {
createDirectory(imageCacheDir()) createDirectory(defaultDir())
createDirectory(defaultDir() + "Tracks/") createDirectory(imageCacheDir())
createDirectory(defaultDir() + "Albums/") createDirectory(defaultDir() + "Tracks/")
createDirectory(defaultDir() + "Playlists/") createDirectory(defaultDir() + "Albums/")
createDirectory(defaultDir() + "YT_Downloads/") createDirectory(defaultDir() + "Playlists/")
} catch (ignored: Exception) {} createDirectory(defaultDir() + "YT_Downloads/")
}
} catch (ignored: Exception) { }
} }
fun FileManager.finalOutputDir( fun FileManager.finalOutputDir(
@ -98,7 +103,8 @@ fun FileManager.finalOutputDir(
/*DIR Specific Operation End*/ /*DIR Specific Operation End*/
fun getNameURL(url: String): String { fun getNameURL(url: String): String {
return url.substring(url.lastIndexOf('/', url.lastIndexOf('/') - 1) + 1, url.length).replace('/', '_') return url.substring(url.lastIndexOf('/', url.lastIndexOf('/') - 1) + 1, url.length)
.replace('/', '_')
} }
suspend fun downloadFile(url: String): Flow<DownloadResult> { suspend fun downloadFile(url: String): Flow<DownloadResult> {

View File

@ -22,7 +22,7 @@ internal class DesktopAnalyticsManager(
val config: Config = Config(COUNTLY_CONFIG.SERVER_URL, COUNTLY_CONFIG.APP_KEY).apply { val config: Config = Config(COUNTLY_CONFIG.SERVER_URL, COUNTLY_CONFIG.APP_KEY).apply {
eventsBufferSize = 2 eventsBufferSize = 2
loggingLevel = LoggingLevel.DEBUG loggingLevel = LoggingLevel.ERROR
setDeviceIdStrategy(DeviceIdStrategy.UUID) setDeviceIdStrategy(DeviceIdStrategy.UUID)
enableFeatures(*featuresSet) enableFeatures(*featuresSet)
setRequiresConsent(true) setRequiresConsent(true)

View File

@ -83,7 +83,7 @@ compose.desktop {
iconFile.set(iconsRoot.resolve("spotiflyer.ico")) iconFile.set(iconsRoot.resolve("spotiflyer.ico"))
// Wondering what the heck is this? See : https://wixtoolset.org/documentation/manual/v3/howtos/general/generate_guids.html // Wondering what the heck is this? See : https://wixtoolset.org/documentation/manual/v3/howtos/general/generate_guids.html
// https://www.guidgen.com/ // https://www.guidgen.com/
upgradeUuid = "9f9e966b-7eef-42c7-a49c-5194b17fabd0" upgradeUuid = "3c4caf0c-ae83-457e-85cc-f8e535fb58e2"
menuGroup = packageName menuGroup = packageName
} }
linux { linux {

View File

@ -20,10 +20,11 @@ import androidx.compose.material.Surface
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.awt.ComposeWindow import androidx.compose.ui.awt.ComposeWindow
import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.painter.BitmapPainter
import androidx.compose.ui.res.loadImageBitmap
import androidx.compose.ui.res.useResource
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Window import androidx.compose.ui.window.*
import androidx.compose.ui.window.application
import androidx.compose.ui.window.rememberWindowState
import com.arkivanov.decompose.ComponentContext import com.arkivanov.decompose.ComponentContext
import com.arkivanov.decompose.DefaultComponentContext import com.arkivanov.decompose.DefaultComponentContext
import com.arkivanov.decompose.ExperimentalDecomposeApi import com.arkivanov.decompose.ExperimentalDecomposeApi
@ -44,6 +45,7 @@ import com.shabinder.common.models.Actions
import com.shabinder.common.providers.FetchPlatformQueryResult import com.shabinder.common.providers.FetchPlatformQueryResult
import com.shabinder.common.root.SpotiFlyerRoot import com.shabinder.common.root.SpotiFlyerRoot
import com.shabinder.common.translations.Strings import com.shabinder.common.translations.Strings
import com.shabinder.common.uikit.SpotiFlyerLogo
import com.shabinder.common.uikit.configurations.SpotiFlyerColors import com.shabinder.common.uikit.configurations.SpotiFlyerColors
import com.shabinder.common.uikit.configurations.SpotiFlyerShapes import com.shabinder.common.uikit.configurations.SpotiFlyerShapes
import com.shabinder.common.uikit.configurations.SpotiFlyerTypography import com.shabinder.common.uikit.configurations.SpotiFlyerTypography
@ -65,40 +67,34 @@ private lateinit var appWindow: ComposeWindow
@OptIn(ExperimentalDecomposeApi::class) @OptIn(ExperimentalDecomposeApi::class)
fun main() { fun main() {
val lifecycle = LifecycleRegistry() val lifecycle = LifecycleRegistry()
val rootComponent = spotiFlyerRoot(DefaultComponentContext(lifecycle)) val rootComponent = spotiFlyerRoot(DefaultComponentContext(lifecycle))
val windowState = WindowState(size = WindowSize(450.dp, 800.dp))
application { singleWindowApplication(
val windowState = rememberWindowState(width = 450.dp, height = 800.dp) title = "SpotiFlyer",
state = windowState,
icon = BitmapPainter(useResource("drawable/spotiflyer.png", ::loadImageBitmap))
) {
LifecycleController(lifecycle, windowState) LifecycleController(lifecycle, windowState)
Window( Surface(
title = "SpotiFlyer", modifier = Modifier.fillMaxSize(),
state = windowState, color = Color.Black,
onCloseRequest = ::exitApplication contentColor = colorOffWhite
) { ) {
appWindow = window DesktopMaterialTheme(
Surface( colors = SpotiFlyerColors,
modifier = Modifier.fillMaxSize(), typography = SpotiFlyerTypography,
color = Color.Black, shapes = SpotiFlyerShapes
contentColor = colorOffWhite
) { ) {
DesktopMaterialTheme( val root: SpotiFlyerRoot = SpotiFlyerRootContent(rootComponent)
colors = SpotiFlyerColors, showToast = root.callBacks::showToast
typography = SpotiFlyerTypography,
shapes = SpotiFlyerShapes
) {
val root: SpotiFlyerRoot = SpotiFlyerRootContent(rootComponent)
showToast = root.callBacks::showToast
// FFmpeg WARNING // FFmpeg WARNING
try { try {
FFmpeg.atPath().addArgument("-version").execute() FFmpeg.atPath().addArgument("-version").execute()
} catch (e: Exception) { } catch (e: Exception) {
if (e is JaffreeException) Actions.instance.showPopUpMessage("WARNING!\nFFmpeg not found at path") if (e is JaffreeException) Actions.instance.showPopUpMessage("WARNING!\nFFmpeg not found at path")
}
} }
} }
} }

View File

@ -14,34 +14,63 @@
~ along with this program. If not, see <https://www.gnu.org/licenses/>. ~ along with this program. If not, see <https://www.gnu.org/licenses/>.
--> -->
<vector android:height="150dp" android:viewportHeight="512" <vector xmlns:android="http://schemas.android.com/apk/res/android"
android:viewportWidth="512" android:width="150dp" xmlns:aapt="http://schemas.android.com/aapt"
xmlns:aapt="http://schemas.android.com/aapt" xmlns:android="http://schemas.android.com/apk/res/android"> android:width="108dp"
<path android:pathData="M256,256m-256,0a256,256 0,1 1,512 0a256,256 0,1 1,-512 0"> android:height="108dp"
<aapt:attr name="android:fillColor"> android:gravity="center"
<gradient android:endX="437.019" android:endY="74.981" android:viewportWidth="108"
android:startX="74.981" android:startY="437.019" android:type="linear"> android:viewportHeight="108">
<item android:color="#FF736BFD" android:offset="0"/> <group android:scaleX="0.10546875"
<item android:color="#FFF54187" android:offset="1"/> android:scaleY="0.10546875"
</gradient> android:translateX="27"
</aapt:attr> android:translateY="27">
</path> <path
<path android:fillColor="#FF000000" android:pathData="M377,356.7c-68.9,-45.4 -155.6,-56.4 -257.6,-32.7c-20.5,4.8 -13.6,35.8 7.3,31.2C290.7,317 351.6,386 368.2,386C384,386 390.2,365.4 377,356.7z"/> android:pathData="M256,256m-256,0a256,256 0,1 1,512 0a256,256 0,1 1,-512 0">
<path android:fillColor="#FF000000" android:pathData="M112.1,275.1C203.9,253.4 308.1,266 384,308c18.5,10.2 34,-17.8 15.5,-28c-82.7,-45.7 -195.6,-59.5 -294.7,-36C84.2,248.8 91.5,280 112.1,275.1L112.1,275.1z"/> <aapt:attr name="android:fillColor">
<path android:fillColor="#FF000000" android:pathData="M100,191.9c96.6,-29.6 232.2,-13.4 308.7,36.9c17.6,11.5 35.3,-15.1 17.6,-26.7c-84.9,-55.8 -229.2,-73.3 -335.6,-40.8C70.4,167.5 79.9,198.1 100,191.9L100,191.9z"/> <gradient
<path android:pathData="M507.8,438.2c-1.6,97.2 -141.9,97.1 -143.5,0C365.9,341 506.2,341 507.8,438.2z"> android:startY="437.0193"
<aapt:attr name="android:fillColor"> android:startX="74.9807"
<gradient android:endX="384.197" android:endY="490.009" android:endY="74.9807"
android:startX="487.832" android:startY="386.374" android:type="linear"> android:endX="437.0193"
<item android:color="#FF736BFD" android:offset="0"/> android:type="linear">
<item android:color="#FFF54187" android:offset="1"/> <item android:offset="0" android:color="#FF736BFD"/>
</gradient> <item android:offset="1" android:color="#FFF54187"/>
</aapt:attr> </gradient>
</path> </aapt:attr>
<path android:fillColor="#FF000000" </path>
android:pathData="M486.8,456.8c-0.6,-2.4 -6.9,-1 -8.5,-1.4c11.5,-82 -82.4,-86.7 -87.1,-22.2c0.3,1.8 -1,6.7 2.2,6.6c0,0 8.6,0 8.6,0c3.1,0.1 2,-4.7 2.2,-6.6c0.1,-23.3 35,-23.3 35.2,0c0,0 0,6.9 0,6.9c-0.1,2.8 4.4,2.8 4.3,0c5,-35.2 -43.8,-40.1 -43.8,-4.7h-4.3c-1.6,-53.7 77.2,-55.9 78.4,-2.2c0,0 0,24.4 0,24.4c-0.1,2.9 3.8,2.1 5.6,2.2l-20.7,21l-20.7,-21c1.8,-0.1 5.6,0.7 5.6,-2.2c0,0 0,-8.8 0,-8.8c0,-2.8 -4.4,-2.8 -4.3,0c0,0 0,6.6 0,6.6c-2.2,0.2 -11.3,-1.3 -8,3.7c0,0 25.9,26.3 25.9,26.3c0.8,0.9 2.2,0.9 3.1,0C460.6,484.4 489.4,458.3 486.8,456.8z" <path
android:strokeColor="#000" android:strokeWidth=".75"/> android:fillColor="#FF000000"
<path android:fillColor="#00000000" android:pathData="M377,356.7c-68.9,-45.4 -155.6,-56.4 -257.6,-32.7c-20.5,4.8 -13.6,35.8 7.3,31.2C290.7,317 351.6,386 368.2,386C384,386 390.2,365.4 377,356.7z"/>
android:pathData="M510,437.5c-1.7,96.2 -142.1,96.2 -143.8,0C367.9,341.3 508.4,341.3 510,437.5z" <path
android:strokeColor="#000" android:strokeWidth="6"/> android:fillColor="#FF000000"
android:pathData="M112.1,275.1C203.9,253.4 308.1,266 384,308c18.5,10.2 34,-17.8 15.5,-28c-82.7,-45.7 -195.6,-59.5 -294.7,-36C84.2,248.8 91.5,280 112.1,275.1L112.1,275.1z"/>
<path
android:fillColor="#FF000000"
android:pathData="M100,191.9c96.6,-29.6 232.2,-13.4 308.7,36.9c17.6,11.5 35.3,-15.1 17.6,-26.7c-84.9,-55.8 -229.2,-73.3 -335.6,-40.8C70.4,167.5 79.9,198.1 100,191.9L100,191.9z"/>
<path
android:pathData="M507.8,438.2c-1.6,97.2 -141.9,97.1 -143.5,0C365.9,341 506.2,341 507.8,438.2z">
<aapt:attr name="android:fillColor">
<gradient
android:startY="386.3741"
android:startX="487.8323"
android:endY="490.009"
android:endX="384.1974"
android:type="linear">
<item android:offset="0" android:color="#FF736BFD"/>
<item android:offset="1" android:color="#FFF54187"/>
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FF000000"
android:pathData="M486.8,456.8c-0.6,-2.4 -6.9,-1 -8.5,-1.4c11.5,-82 -82.4,-86.7 -87.1,-22.2c0.3,1.8 -1,6.7 2.2,6.6c0,0 8.6,0 8.6,0c3.1,0.1 2,-4.7 2.2,-6.6c0.1,-23.3 35,-23.3 35.2,0c0,0 0,6.9 0,6.9c-0.1,2.8 4.4,2.8 4.3,0c5,-35.2 -43.8,-40.1 -43.8,-4.7h-4.3c-1.6,-53.7 77.2,-55.9 78.4,-2.2c0,0 0,24.4 0,24.4c-0.1,2.9 3.8,2.1 5.6,2.2l-20.7,21l-20.7,-21c1.8,-0.1 5.6,0.7 5.6,-2.2c0,0 0,-8.8 0,-8.8c0,-2.8 -4.4,-2.8 -4.3,0c0,0 0,6.6 0,6.6c-2.2,0.2 -11.3,-1.3 -8,3.7c0,0 25.9,26.3 25.9,26.3c0.8,0.9 2.2,0.9 3.1,0C460.6,484.4 489.4,458.3 486.8,456.8z"
android:strokeWidth="0.75"
android:strokeColor="#000000"/>
<path
android:pathData="M510,437.5c-1.7,96.2 -142.1,96.2 -143.8,0C367.9,341.3 508.4,341.3 510,437.5z"
android:strokeWidth="6"
android:fillColor="#00000000"
android:strokeColor="#000000"/>
</group>
</vector> </vector>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 63 KiB

After

Width:  |  Height:  |  Size: 63 KiB

View File

@ -0,0 +1,6 @@
- File size less than 100 KB,
- Crash Fixes when App Went in Background
- Offloaded Many CPU Intensive tasks from Main Thread
- Notification Handling Improved, Now Exits Gracefully
- Some translations Added.
- ImageVectors Caching Implemented Expect some performance gain