Merge pull request #1235 from Bnyro/master

fix errors
This commit is contained in:
Bnyro 2022-09-08 18:56:04 +02:00 committed by GitHub
commit 52ce834003
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,6 @@
package com.github.libretube package com.github.libretube
import android.annotation.SuppressLint
import android.app.Application import android.app.Application
import android.app.NotificationChannel import android.app.NotificationChannel
import android.app.NotificationManager import android.app.NotificationManager
@ -13,6 +14,10 @@ import com.fasterxml.jackson.core.type.TypeReference
import com.fasterxml.jackson.databind.ObjectMapper import com.fasterxml.jackson.databind.ObjectMapper
import com.github.libretube.api.CronetHelper import com.github.libretube.api.CronetHelper
import com.github.libretube.api.RetrofitInstance import com.github.libretube.api.RetrofitInstance
import com.github.libretube.constants.BACKGROUND_CHANNEL_ID
import com.github.libretube.constants.DOWNLOAD_CHANNEL_ID
import com.github.libretube.constants.PIPED_API_URL
import com.github.libretube.constants.PUSH_CHANNEL_ID
import com.github.libretube.constants.PreferenceKeys import com.github.libretube.constants.PreferenceKeys
import com.github.libretube.db.DatabaseHolder import com.github.libretube.db.DatabaseHolder
import com.github.libretube.db.obj.WatchHistoryItem import com.github.libretube.db.obj.WatchHistoryItem
@ -100,6 +105,7 @@ class MyApp : Application() {
/** /**
* Initializes the required [NotificationChannel]s for the app. * Initializes the required [NotificationChannel]s for the app.
*/ */
@SuppressLint("InlinedApi")
private fun initializeNotificationChannels() { private fun initializeNotificationChannels() {
createNotificationChannel( createNotificationChannel(
DOWNLOAD_CHANNEL_ID, DOWNLOAD_CHANNEL_ID,
@ -149,13 +155,13 @@ class MyApp : Application() {
val username = legacyUserPrefs.getString("username", "")!! val username = legacyUserPrefs.getString("username", "")!!
if (username != "") { if (username != "") {
PreferenceHelper.setUsername(username) PreferenceHelper.setUsername(username)
legacyUserPrefs.edit().putString("username", "") legacyUserPrefs.edit().putString("username", "").apply()
} }
val legacyTokenPrefs = getSharedPreferences("token", Context.MODE_PRIVATE) val legacyTokenPrefs = getSharedPreferences("token", Context.MODE_PRIVATE)
val token = legacyUserPrefs.getString("token", "")!! val token = legacyUserPrefs.getString("token", "")!!
if (token != "") { if (token != "") {
PreferenceHelper.setToken(token) PreferenceHelper.setToken(token)
legacyTokenPrefs.edit().putString("token", "") legacyTokenPrefs.edit().putString("token", "").apply()
} }
} }
@ -177,7 +183,7 @@ class MyApp : Application() {
) )
} catch (e: Exception) { } catch (e: Exception) {
} }
prefs.edit().putString("watch_history", "").commit() prefs.edit().putString("watch_history", "").apply()
} }
val legacyWatchPositions = prefs.getString("watch_positions", "") val legacyWatchPositions = prefs.getString("watch_positions", "")
if (legacyWatchPositions != "") { if (legacyWatchPositions != "") {
@ -189,12 +195,12 @@ class MyApp : Application() {
) )
} catch (e: Exception) { } catch (e: Exception) {
} }
prefs.edit().remove("watch_positions").commit() prefs.edit().remove("watch_positions").apply()
} }
prefs.edit() prefs.edit()
.remove("custom_instances") .remove("custom_instances")
.remove("local_subscriptions") .remove("local_subscriptions")
.commit() .apply()
}.start() }.start()
} }
} }