use objects instead of class

This commit is contained in:
Bnyro 2022-06-26 12:26:19 +02:00
parent ecacd13ceb
commit b477e1a202
7 changed files with 10 additions and 10 deletions

View File

@ -57,8 +57,8 @@ class MainActivity : AppCompatActivity() {
RetrofitInstance.url =
PreferenceHelper.getString(this, "selectInstance", "https://pipedapi.kavin.rocks/")!!
ThemeHelper().updateTheme(this)
LocaleHelper().updateLanguage(this)
ThemeHelper.updateTheme(this)
LocaleHelper.updateLanguage(this)
// show noInternet Activity if no internet available on app startup
if (!isNetworkAvailable(this)) {

View File

@ -21,7 +21,7 @@ class RouterActivity : AppCompatActivity() {
handleSendText(uri!!)
} else {
// start app as normal if URI not in host list
ThemeHelper().restartMainActivity(this)
ThemeHelper.restartMainActivity(this)
}
}

View File

@ -19,7 +19,7 @@ class SettingsActivity : AppCompatActivity() {
val TAG = "SettingsActivity"
override fun onCreate(savedInstanceState: Bundle?) {
DynamicColors.applyToActivityIfAvailable(this)
ThemeHelper().updateTheme(this)
ThemeHelper.updateTheme(this)
// makes the preference dialogs use material dialogs
setTheme(R.style.MaterialAlertDialog)
@ -54,7 +54,7 @@ class SettingsActivity : AppCompatActivity() {
val nManager =
this.getSystemService(NOTIFICATION_SERVICE) as NotificationManager
nManager.cancelAll()
ThemeHelper().restartMainActivity(this)
ThemeHelper.restartMainActivity(this)
ActivityCompat.finishAffinity(this)
} else {
super.onBackPressed()

View File

@ -21,7 +21,7 @@ class AppearanceSettings : PreferenceFragmentCompat() {
val themeToggle = findPreference<ListPreference>("theme_togglee")
themeToggle?.setOnPreferenceChangeListener { _, _ ->
requireMainActivityRestart = true
ThemeHelper().restartMainActivity(requireContext())
ThemeHelper.restartMainActivity(requireContext())
true
}
@ -34,7 +34,7 @@ class AppearanceSettings : PreferenceFragmentCompat() {
val iconChange = findPreference<ListPreference>("icon_change")
iconChange?.setOnPreferenceChangeListener { _, newValue ->
ThemeHelper().changeIcon(requireContext(), newValue.toString())
ThemeHelper.changeIcon(requireContext(), newValue.toString())
true
}

View File

@ -31,7 +31,7 @@ class MainSettings : PreferenceFragmentCompat() {
val language = findPreference<ListPreference>("language")
language?.setOnPreferenceChangeListener { _, _ ->
ThemeHelper().restartMainActivity(requireContext())
ThemeHelper.restartMainActivity(requireContext())
true
}

View File

@ -4,7 +4,7 @@ import android.content.Context
import android.os.Build
import java.util.*
class LocaleHelper {
object LocaleHelper {
fun updateLanguage(context: Context) {
val languageName = PreferenceHelper.getString(context, "language", "en")

View File

@ -9,7 +9,7 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.app.AppCompatDelegate
import com.github.libretube.R
class ThemeHelper {
object ThemeHelper {
fun updateTheme(context: Context) {
updateAccentColor(context)