From 69f76be119638643ad9f0b9f9d0b84b9e762b554 Mon Sep 17 00:00:00 2001 From: kostas214pro Date: Fri, 31 Mar 2023 22:16:16 +0300 Subject: [PATCH] Changes and improvements-mMove inialization stuff to a coroutine to speed up app load times, added material 3 dynamic colors, and changed the color shceme for the base app --- .idea/deploymentTargetDropDown.xml | 17 ------------- app/src/main/AndroidManifest.xml | 3 ++- .../example/spotifydownloader/Application.kt | 13 ++++++++++ .../example/spotifydownloader/MainActivity.kt | 25 ++++++++++++------- app/src/main/res/values-night/themes.xml | 2 +- app/src/main/res/values/colors.xml | 3 ++- app/src/main/res/values/themes.xml | 6 ++--- 7 files changed, 37 insertions(+), 32 deletions(-) delete mode 100644 .idea/deploymentTargetDropDown.xml create mode 100644 app/src/main/java/com/example/spotifydownloader/Application.kt diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml deleted file mode 100644 index 5275e60..0000000 --- a/.idea/deploymentTargetDropDown.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index d811f8b..c62d250 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -18,7 +18,8 @@ android:supportsRtl="true" android:theme="@style/Theme.SpotifyDownloader" android:extractNativeLibs="true" - tools:targetApi="33"> + tools:targetApi="33" + android:name=".SpotifyDownloaderApplication"> diff --git a/app/src/main/java/com/example/spotifydownloader/Application.kt b/app/src/main/java/com/example/spotifydownloader/Application.kt new file mode 100644 index 0000000..63e0cbe --- /dev/null +++ b/app/src/main/java/com/example/spotifydownloader/Application.kt @@ -0,0 +1,13 @@ +package com.example.spotifydownloader + +import android.app.Application +import com.google.android.material.color.DynamicColors + +class SpotifyDownloaderApplication : Application(){ + + override fun onCreate() { + super.onCreate() + DynamicColors.applyToActivitiesIfAvailable(this) + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/example/spotifydownloader/MainActivity.kt b/app/src/main/java/com/example/spotifydownloader/MainActivity.kt index c7ecbd9..4842569 100644 --- a/app/src/main/java/com/example/spotifydownloader/MainActivity.kt +++ b/app/src/main/java/com/example/spotifydownloader/MainActivity.kt @@ -1,17 +1,20 @@ package com.example.spotifydownloader +import android.app.Activity import android.os.Bundle import android.util.Log import android.view.MenuItem import androidx.appcompat.app.ActionBarDrawerToggle import androidx.appcompat.app.AppCompatActivity import androidx.core.view.GravityCompat +import androidx.lifecycle.lifecycleScope import com.chaquo.python.Python import com.chaquo.python.android.AndroidPlatform import com.example.spotifydownloader.databinding.ActivityMainBinding import com.yausername.ffmpeg.FFmpeg import com.yausername.youtubedl_android.YoutubeDL import com.yausername.youtubedl_android.YoutubeDLException +import kotlinx.coroutines.launch class MainActivity : AppCompatActivity() { @@ -36,6 +39,7 @@ class MainActivity : AppCompatActivity() { ) binding.drawerLayout.addDrawerListener(toggle) toggle.syncState() + supportActionBar?.setDisplayHomeAsUpEnabled(true) @@ -113,18 +117,21 @@ class MainActivity : AppCompatActivity() { //Init youtubedl-android + lifecycleScope.launch{ + try { + YoutubeDL.getInstance().init(applicationContext ) + FFmpeg.getInstance().init(applicationContext) + } catch (e: YoutubeDLException) { + Log.e("error", "failed to initialize youtubedl-android", e) - try { - YoutubeDL.getInstance().init(this) - FFmpeg.getInstance().init(this) - } catch (e: YoutubeDLException) { - Log.e("error", "failed to initialize youtubedl-android", e) + + } + //Init chaquopy + if (!Python.isStarted()) { + Python.start(AndroidPlatform(applicationContext)) + } - } - //Init chaquopy - if (!Python.isStarted()) { - Python.start(AndroidPlatform(this)) } diff --git a/app/src/main/res/values-night/themes.xml b/app/src/main/res/values-night/themes.xml index 6cbe25d..b74985e 100644 --- a/app/src/main/res/values-night/themes.xml +++ b/app/src/main/res/values-night/themes.xml @@ -10,7 +10,7 @@ @color/teal_200 @color/black - ?attr/colorPrimaryVariant + @color/teal_700 \ No newline at end of file diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index f8c6127..6a1f442 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -3,8 +3,9 @@ #FFBB86FC #FF6200EE #FF3700B3 - #FF03DAC5 + #00838F #FF018786 #FF000000 #FFFFFFFF + \ No newline at end of file diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index 83fded6..4509aee 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -2,15 +2,15 @@