diff --git a/.idea/dictionaries/shabinder.xml b/.idea/dictionaries/shabinder.xml
index 599ffd82..b5d414c9 100644
--- a/.idea/dictionaries/shabinder.xml
+++ b/.idea/dictionaries/shabinder.xml
@@ -5,6 +5,7 @@
flyer
insta
instagram
+ maxresdefault
moshi
musicforeveryone
musicplaceholder
@@ -15,6 +16,8 @@
spotify
spotifydownloader
spotifyler
+ thru
+ youtu
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 222d7c31..d3c66e7a 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,5 +1,8 @@
+
+
+
diff --git a/app/build.gradle b/app/build.gradle
index d71765eb..22d54822 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -20,7 +20,7 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: "androidx.navigation.safeargs.kotlin"
-apply plugin: 'kotlinx-serialization'
+//apply plugin: 'kotlinx-serialization'
android {
compileSdkVersion 29
@@ -34,17 +34,28 @@ android {
applicationId 'com.shabinder.spotiflyer'
minSdkVersion 22
targetSdkVersion 29
- versionCode 2
- versionName "1.1"
+ versionCode 3
+ versionName "1.2"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
-
+ packagingOptions {
+ exclude 'META-INF/DEPENDENCIES'
+ exclude 'META-INF/LICENSE'
+ exclude 'META-INF/LICENSE.txt'
+ exclude 'META-INF/license.txt'
+ exclude 'META-INF/NOTICE'
+ exclude 'META-INF/NOTICE.txt'
+ exclude 'META-INF/notice.txt'
+ exclude 'META-INF/ASL2.0'
+ exclude("META-INF/*.kotlin_module")
+ }
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
+
compileOptions {
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_1_8
@@ -65,6 +76,7 @@ dependencies {
implementation 'androidx.core:core-ktx:1.3.1'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.browser:browser:1.2.0'
+ implementation 'androidx.webkit:webkit:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0'
@@ -86,9 +98,14 @@ dependencies {
}
implementation 'androidx.recyclerview:recyclerview:1.1.0'
-
- implementation 'com.google.apis:google-api-services-youtube:v3-rev180-1.22.0'
- implementation 'com.google.oauth-client:google-oauth-client:1.22.0'
+// Authentication Way Changed!
+// implementation ('com.google.apis:google-api-services-youtube:v3-rev180-1.22.0'){
+// exclude module: 'httpclient'
+// }
+// //noinspection GradleDependency
+// implementation ('com.google.oauth-client:google-oauth-client:1.22.0'){
+// exclude module: 'httpclient'
+// }
// implementation 'com.spotify.android:auth:1.1.0'
implementation 'com.squareup.okhttp3:okhttp:4.8.0'
@@ -97,9 +114,6 @@ dependencies {
implementation "com.squareup.moshi:moshi-kotlin:1.9.3"
implementation "com.squareup.retrofit2:converter-moshi:2.9.0"
- implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" // or "kotlin-stdlib-jdk8"
- implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime:0.20.0" // JVM dependency
-
implementation 'com.mpatric:mp3agic:0.9.1'
implementation 'com.arthenica:mobile-ffmpeg-audio:4.4.LTS'
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 37f088d9..0d4c26b1 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -27,6 +27,8 @@
+
+
diff --git a/app/src/main/java/com/shabinder/spotiflyer/MainActivity.kt b/app/src/main/java/com/shabinder/spotiflyer/MainActivity.kt
index 5d1434cf..788dc826 100644
--- a/app/src/main/java/com/shabinder/spotiflyer/MainActivity.kt
+++ b/app/src/main/java/com/shabinder/spotiflyer/MainActivity.kt
@@ -18,6 +18,7 @@
package com.shabinder.spotiflyer
import android.Manifest
+import android.annotation.SuppressLint
import android.content.Context
import android.content.Intent
import android.content.SharedPreferences
@@ -25,6 +26,8 @@ import android.net.ConnectivityManager
import android.net.Uri
import android.os.Build
import android.os.Bundle
+import android.os.PowerManager
+import android.provider.Settings
import android.util.Log
import androidx.appcompat.app.AppCompatActivity
import androidx.databinding.DataBindingUtil
@@ -36,7 +39,6 @@ import com.shabinder.spotiflyer.databinding.MainActivityBinding
import com.shabinder.spotiflyer.downloadHelper.DownloadHelper
import com.shabinder.spotiflyer.utils.SpotifyService
import com.shabinder.spotiflyer.utils.SpotifyServiceToken
-import com.shabinder.spotiflyer.utils.YoutubeInterface
import com.shabinder.spotiflyer.utils.createDirectory
import com.shreyaspatil.EasyUpiPayment.EasyUpiPayment
import com.squareup.moshi.Moshi
@@ -71,6 +73,8 @@ class MainActivity : AppCompatActivity(){
binding = DataBindingUtil.setContentView(this,R.layout.main_activity)
sharedViewModel = ViewModelProvider(this).get(SharedViewModel::class.java)
sharedPref = this.getPreferences(Context.MODE_PRIVATE)
+ //starting Notification and Downloader Service!
+ DownloadHelper.startService(this)
/* if(sharedPref?.contains("token")!! && (sharedPref?.getLong("time",System.currentTimeMillis()/1000/60/60)!! < (System.currentTimeMillis()/1000/60/60)) ){
val savedToken = sharedPref?.getString("token","error")!!
@@ -88,6 +92,7 @@ class MainActivity : AppCompatActivity(){
}
requestPermission()
+ disableDozeMode()
checkIfLatestVersion()
createDir()
setUpi()
@@ -98,12 +103,42 @@ class MainActivity : AppCompatActivity(){
//Object to download From Youtube {"https://github.com/sealedtx/java-youtube-downloader"}
ytDownloader = YoutubeDownloader()
sharedViewModel.ytDownloader = ytDownloader
- //Initialing Communication with Youtube
- YoutubeInterface.youtubeConnector()
handleIntentFromExternalActivity()
}
+ @SuppressLint("BatteryLife")
+ fun disableDozeMode() {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
+ val pm =
+ this.getSystemService(Context.POWER_SERVICE) as PowerManager
+ val isIgnoringBatteryOptimizations = pm.isIgnoringBatteryOptimizations(packageName)
+ if (!isIgnoringBatteryOptimizations) {
+ val intent = Intent()
+ intent.action = Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS
+ intent.data = Uri.parse("package:$packageName")
+ startActivityForResult(intent, 1233)
+ }
+ }
+ }
+
+ override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
+ super.onActivityResult(requestCode, resultCode, data)
+ if (requestCode == 1233) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
+ val pm =
+ getSystemService(Context.POWER_SERVICE) as PowerManager
+ val isIgnoringBatteryOptimizations =
+ pm.isIgnoringBatteryOptimizations(packageName)
+ if (isIgnoringBatteryOptimizations) {
+ // Ignoring battery optimization
+ } else {
+ disableDozeMode()//Again Ask For Permission!!
+ }
+ }
+ }
+ }
+
/**
* Adding my own new Spotify Web Api Requests!
* */
@@ -253,6 +288,7 @@ class MainActivity : AppCompatActivity(){
createDirectory(DownloadHelper.defaultDir+"Tracks/")
createDirectory(DownloadHelper.defaultDir+"Albums/")
createDirectory(DownloadHelper.defaultDir+"Playlists/")
+ createDirectory(DownloadHelper.defaultDir+"YT_Downloads/")
}
private fun checkIfLatestVersion() {
diff --git a/app/src/main/java/com/shabinder/spotiflyer/downloadHelper/DownloadHelper.kt b/app/src/main/java/com/shabinder/spotiflyer/downloadHelper/DownloadHelper.kt
index 022cf581..6cc76497 100644
--- a/app/src/main/java/com/shabinder/spotiflyer/downloadHelper/DownloadHelper.kt
+++ b/app/src/main/java/com/shabinder/spotiflyer/downloadHelper/DownloadHelper.kt
@@ -17,28 +17,44 @@
package com.shabinder.spotiflyer.downloadHelper
+import android.annotation.SuppressLint
import android.content.Context
import android.content.Intent
+import android.os.Build
import android.os.Environment
import android.util.Log
+import android.view.View
+import android.view.animation.AlphaAnimation
+import android.view.animation.Animation
+import android.webkit.ValueCallback
+import android.webkit.WebView
+import android.webkit.WebViewClient
+import android.widget.TextView
import androidx.core.content.ContextCompat
import com.github.kiulian.downloader.YoutubeDownloader
import com.github.kiulian.downloader.model.formats.Format
import com.github.kiulian.downloader.model.quality.AudioQuality
+import com.shabinder.spotiflyer.SharedViewModel
import com.shabinder.spotiflyer.fragments.MainFragment
import com.shabinder.spotiflyer.models.DownloadObject
import com.shabinder.spotiflyer.models.Track
-import com.shabinder.spotiflyer.utils.YoutubeInterface
import com.shabinder.spotiflyer.worker.ForegroundService
import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import java.io.File
object DownloadHelper {
-
+ var webView:WebView? = null
var context : Context? = null
+ var statusBar:TextView? = null
val defaultDir = Environment.DIRECTORY_MUSIC + File.separator + "SpotiFlyer" + File.separator
private var downloadList = arrayListOf()
+ var sharedViewModel:SharedViewModel? = null
+ private var isBrowserLoading = false
+ private var total = 0
+ private var Processed = 0
+ var youtubeList = mutableListOf()
/**
* Function To Download All Tracks Available in a List
@@ -47,108 +63,179 @@ object DownloadHelper {
type:String,
subFolder: String?,
trackList: List