From cd2853fa7319e3d8a64a7a6802846e88d05f6d2d Mon Sep 17 00:00:00 2001 From: Natanel Shitrit <65548905+Natanel-Shitrit@users.noreply.github.com> Date: Sat, 28 Oct 2023 13:38:35 +0300 Subject: [PATCH] refactor: remove `cleanUpOldDownloads` (#529) * Remove `cleanUpOldDownloads` * refactor: remove `downloadsMigrated` preference --------- Co-authored-by: Jarne Demeulemeester --- .../java/dev/jdtech/jellyfin/MainActivity.kt | 29 ------------------- .../dev/jdtech/jellyfin/AppPreferences.kt | 7 ----- 2 files changed, 36 deletions(-) diff --git a/app/phone/src/main/java/dev/jdtech/jellyfin/MainActivity.kt b/app/phone/src/main/java/dev/jdtech/jellyfin/MainActivity.kt index 6df373d655..8a10177e4a 100644 --- a/app/phone/src/main/java/dev/jdtech/jellyfin/MainActivity.kt +++ b/app/phone/src/main/java/dev/jdtech/jellyfin/MainActivity.kt @@ -1,11 +1,9 @@ package dev.jdtech.jellyfin import android.os.Bundle -import android.os.Environment import android.view.View import androidx.activity.viewModels import androidx.appcompat.app.AppCompatActivity -import androidx.lifecycle.lifecycleScope import androidx.navigation.NavController import androidx.navigation.NavGraph import androidx.navigation.fragment.NavHostFragment @@ -24,7 +22,6 @@ import dev.jdtech.jellyfin.database.ServerDatabaseDao import dev.jdtech.jellyfin.databinding.ActivityMainBinding import dev.jdtech.jellyfin.viewmodels.MainViewModel import dev.jdtech.jellyfin.work.SyncWorker -import kotlinx.coroutines.launch import javax.inject.Inject import dev.jdtech.jellyfin.core.R as CoreR @@ -46,7 +43,6 @@ class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) scheduleUserDataSync() - cleanUpOldDownloads() applyTheme() setupActivity() } @@ -134,31 +130,6 @@ class MainActivity : AppCompatActivity() { } } - /** - * Temp to remove old downloads, will be removed in a future version - */ - private fun cleanUpOldDownloads() { - if (appPreferences.downloadsMigrated) { - return - } - - lifecycleScope.launch { - val oldDir = applicationContext.getExternalFilesDir(Environment.DIRECTORY_MOVIES) - if (oldDir == null) { - appPreferences.downloadsMigrated = true - return@launch - } - - try { - for (file in oldDir.listFiles()!!) { - file.delete() - } - } catch (_: Exception) {} - - appPreferences.downloadsMigrated = true - } - } - private fun scheduleUserDataSync() { val syncWorkRequest = OneTimeWorkRequestBuilder() .setConstraints( diff --git a/preferences/src/main/java/dev/jdtech/jellyfin/AppPreferences.kt b/preferences/src/main/java/dev/jdtech/jellyfin/AppPreferences.kt index 8879736d52..6a97e827fe 100644 --- a/preferences/src/main/java/dev/jdtech/jellyfin/AppPreferences.kt +++ b/preferences/src/main/java/dev/jdtech/jellyfin/AppPreferences.kt @@ -144,11 +144,4 @@ constructor( putString(Constants.PREF_SORT_ORDER, value) } } - - // Temp - var downloadsMigrated - get() = sharedPreferences.getBoolean("downloadsMigrated", false) - set(value) = sharedPreferences.edit { - putBoolean("downloadsMigrated", value) - } }