diff --git a/app/src/main/java/com/github/libretube/DownloadService.kt b/app/src/main/java/com/github/libretube/DownloadService.kt index be3534646..356bca423 100644 --- a/app/src/main/java/com/github/libretube/DownloadService.kt +++ b/app/src/main/java/com/github/libretube/DownloadService.kt @@ -5,6 +5,7 @@ import android.app.PendingIntent import android.app.Service import android.content.BroadcastReceiver import android.content.Context +import android.content.Context.DOWNLOAD_SERVICE import android.content.Intent import android.content.IntentFilter import android.net.Uri @@ -15,6 +16,10 @@ import android.os.IBinder import android.util.Log import androidx.core.app.NotificationCompat import androidx.core.app.NotificationManagerCompat +import androidx.core.content.ContentProviderCompat.requireContext +import androidx.core.net.toFile +import androidx.core.net.toUri +import androidx.preference.PreferenceManager import com.arthenica.ffmpegkit.FFmpegKit import java.io.File @@ -44,8 +49,9 @@ class DownloadService : Service() { videoId = intent?.getStringExtra("videoId")!! videoUrl = intent.getStringExtra("videoUrl")!! audioUrl = intent.getStringExtra("audioUrl")!! - extension = intent.getStringExtra("extension")!! duration = intent.getIntExtra("duration", 1) + val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this) + extension = sharedPreferences.getString("video_format", ".mp4")!! downloadType = if (audioUrl != "" && videoUrl != "") "mux" else if (audioUrl != "") "audio" else if (videoUrl != "") "video" @@ -81,11 +87,22 @@ class DownloadService : Service() { } // create LibreTube folder in Downloads + /* + val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this) + val downloadsDirectory = sharedPreferences.getString("download_directory_path", "") + Log.i(TAG, downloadsDirectory!!) + libretubeDir = if (downloadsDirectory == "") File( + Environment.getExternalStoragePublicDirectory(DIRECTORY_DOWNLOADS), + "LibreTube" + ) + else File(downloadsDirectory) + */ libretubeDir = File( Environment.getExternalStoragePublicDirectory(DIRECTORY_DOWNLOADS), "LibreTube" ) if (!libretubeDir.exists()) libretubeDir.mkdirs() + Log.i(TAG, libretubeDir.toString()) // start download try { diff --git a/app/src/main/java/com/github/libretube/SettingsActivity.kt b/app/src/main/java/com/github/libretube/SettingsActivity.kt index fff1872f1..f4ebb83c8 100644 --- a/app/src/main/java/com/github/libretube/SettingsActivity.kt +++ b/app/src/main/java/com/github/libretube/SettingsActivity.kt @@ -6,7 +6,7 @@ import android.os.Bundle import android.view.View import androidx.appcompat.app.AppCompatActivity import androidx.core.app.ActivityCompat -import com.github.libretube.preferences.SettingsFragment +import com.github.libretube.preferences.MainSettings import com.github.libretube.util.ThemeHelper import com.google.android.material.color.DynamicColors @@ -14,7 +14,7 @@ var isCurrentViewMainSettings = true var requireMainActivityRestart = false class SettingsActivity : AppCompatActivity() { - + val TAG = "SettingsActivity" override fun onCreate(savedInstanceState: Bundle?) { DynamicColors.applyToActivityIfAvailable(this) ThemeHelper().updateTheme(this) @@ -31,7 +31,7 @@ class SettingsActivity : AppCompatActivity() { if (savedInstanceState == null) { supportFragmentManager .beginTransaction() - .replace(R.id.settings, SettingsFragment()) + .replace(R.id.settings, MainSettings()) .commit() } } @@ -54,7 +54,7 @@ class SettingsActivity : AppCompatActivity() { isCurrentViewMainSettings = true supportFragmentManager .beginTransaction() - .replace(R.id.settings, SettingsFragment()) + .replace(R.id.settings, MainSettings()) .commit() } } diff --git a/app/src/main/java/com/github/libretube/dialogs/DownloadDialog.kt b/app/src/main/java/com/github/libretube/dialogs/DownloadDialog.kt index 769b2e93c..d01b2ff1b 100644 --- a/app/src/main/java/com/github/libretube/dialogs/DownloadDialog.kt +++ b/app/src/main/java/com/github/libretube/dialogs/DownloadDialog.kt @@ -13,8 +13,6 @@ import android.view.View import android.widget.AdapterView import android.widget.ArrayAdapter import android.widget.Button -import android.widget.RadioButton -import android.widget.RadioGroup import android.widget.Spinner import android.widget.TextView import androidx.core.app.ActivityCompat @@ -29,13 +27,8 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder class DownloadDialog : DialogFragment() { private val TAG = "DownloadDialog" var streams: Streams = Streams() - var vidName = arrayListOf() - var vidUrl = arrayListOf() - var audioName = arrayListOf() - var audioUrl = arrayListOf() var selectedVideo = 0 var selectedAudio = 0 - var extension = ".mp4" var duration = 0 private lateinit var videoId: String override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { @@ -142,19 +135,13 @@ class DownloadDialog : DialogFragment() { override fun onNothingSelected(parent: AdapterView<*>?) {} } - val radioGroup = view.findViewById(R.id.radioGp) - radioGroup.setOnCheckedChangeListener { group, checkedId -> - val radio: RadioButton = view.findViewById(checkedId) - extension = radio.text.toString() - Log.d(TAG, extension) - } + view.findViewById