Skip to content

Commit

Permalink
Changes and improvements-mMove inialization stuff to a coroutine to s…
Browse files Browse the repository at this point in the history
…peed up app load times, added material 3 dynamic colors, and changed the color shceme for the base app
  • Loading branch information
kostas214 committed Mar 31, 2023
1 parent b030ac5 commit 69f76be
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 32 deletions.
17 changes: 0 additions & 17 deletions .idea/deploymentTargetDropDown.xml

This file was deleted.

3 changes: 2 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
android:supportsRtl="true"
android:theme="@style/Theme.SpotifyDownloader"
android:extractNativeLibs="true"
tools:targetApi="33">
tools:targetApi="33"
android:name=".SpotifyDownloaderApplication">
<activity
android:name=".MainActivity"
android:exported="true">
Expand Down
13 changes: 13 additions & 0 deletions app/src/main/java/com/example/spotifydownloader/Application.kt
Original file line number Diff line number Diff line change
@@ -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)
}

}
25 changes: 16 additions & 9 deletions app/src/main/java/com/example/spotifydownloader/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -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() {

Expand All @@ -36,6 +39,7 @@ class MainActivity : AppCompatActivity() {
)
binding.drawerLayout.addDrawerListener(toggle)
toggle.syncState()

supportActionBar?.setDisplayHomeAsUpEnabled(true)


Expand Down Expand Up @@ -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))
}


Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-night/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<item name="colorSecondaryVariant">@color/teal_200</item>
<item name="colorOnSecondary">@color/black</item>
<!-- Status bar color. -->
<item name="android:statusBarColor">?attr/colorPrimaryVariant</item>
<item name="android:statusBarColor">@color/teal_700</item>
<!-- Customize your theme here. -->
</style>
</resources>
3 changes: 2 additions & 1 deletion app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
<color name="purple_200">#FFBB86FC</color>
<color name="purple_500">#FF6200EE</color>
<color name="purple_700">#FF3700B3</color>
<color name="teal_200">#FF03DAC5</color>
<color name="teal_200">#00838F</color>
<color name="teal_700">#FF018786</color>
<color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color>

</resources>
6 changes: 3 additions & 3 deletions app/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
<!-- Base application theme. -->
<style name="Theme.SpotifyDownloader" parent="Theme.Material3.Light">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/purple_500</item>
<item name="colorPrimaryVariant">@color/purple_700</item>
<item name="colorPrimary">@color/teal_200</item>
<item name="colorPrimaryVariant">@color/teal_200</item>
<item name="colorOnPrimary">@color/white</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">@color/teal_200</item>
<item name="colorSecondaryVariant">@color/teal_700</item>
<item name="colorOnSecondary">@color/black</item>
<!-- Status bar color. -->
<item name="android:statusBarColor">?attr/colorPrimaryVariant</item>
<item name="android:statusBarColor">@color/teal_700</item>
<!-- Customize your theme here. -->

</style>
Expand Down

0 comments on commit 69f76be

Please sign in to comment.