From e1e6933c342747046df2fe3b41cc8ad430ba4c6b Mon Sep 17 00:00:00 2001 From: Bnyro Date: Tue, 7 Jun 2022 21:22:35 +0200 Subject: [PATCH 1/2] changing topbar text in settings categories --- .../main/java/com/github/libretube/SettingsActivity.kt | 6 +++++- .../com/github/libretube/preferences/AboutFragment.kt | 3 +++ .../github/libretube/preferences/AdvancedSettings.kt | 4 ++-- .../github/libretube/preferences/AppearanceSettings.kt | 4 ++++ .../libretube/preferences/SponsorBlockSettings.kt | 5 +++++ app/src/main/res/layout/activity_settings.xml | 10 ++++++---- app/src/main/res/layout/fragment_about.xml | 2 +- 7 files changed, 26 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/com/github/libretube/SettingsActivity.kt b/app/src/main/java/com/github/libretube/SettingsActivity.kt index 23cf30bab..241b2e099 100644 --- a/app/src/main/java/com/github/libretube/SettingsActivity.kt +++ b/app/src/main/java/com/github/libretube/SettingsActivity.kt @@ -4,7 +4,9 @@ import android.app.NotificationManager import android.os.Build import android.os.Bundle import android.view.View +import android.widget.ImageButton import android.widget.ImageView +import android.widget.TextView import androidx.appcompat.app.AppCompatActivity import androidx.core.app.ActivityCompat import com.github.libretube.preferences.MainSettings @@ -32,7 +34,7 @@ class SettingsActivity : AppCompatActivity() { setContentView(R.layout.activity_settings) - val backButton = view.findViewById(R.id.back_imageView) + val backButton = view.findViewById(R.id.back_imageButton) backButton.setOnClickListener { onBackPressed() } @@ -65,6 +67,8 @@ class SettingsActivity : AppCompatActivity() { .beginTransaction() .replace(R.id.settings, MainSettings()) .commit() + val topBarTextView = findViewById(R.id.topBar_textView) + topBarTextView?.text = getString(R.string.settings) } } } diff --git a/app/src/main/java/com/github/libretube/preferences/AboutFragment.kt b/app/src/main/java/com/github/libretube/preferences/AboutFragment.kt index 33d205b51..97e95c8f1 100644 --- a/app/src/main/java/com/github/libretube/preferences/AboutFragment.kt +++ b/app/src/main/java/com/github/libretube/preferences/AboutFragment.kt @@ -27,6 +27,9 @@ class AboutFragment : Fragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) + val topBarText = activity?.findViewById(R.id.topBar_textView) + topBarText?.text = getString(R.string.about) + val appVersion = view?.findViewById(R.id.app_version) appVersion.text = BuildConfig.VERSION_NAME val website = view?.findViewById(R.id.website) diff --git a/app/src/main/java/com/github/libretube/preferences/AdvancedSettings.kt b/app/src/main/java/com/github/libretube/preferences/AdvancedSettings.kt index 75c0e31cb..12b31a597 100644 --- a/app/src/main/java/com/github/libretube/preferences/AdvancedSettings.kt +++ b/app/src/main/java/com/github/libretube/preferences/AdvancedSettings.kt @@ -16,8 +16,8 @@ class AdvancedSettings : PreferenceFragmentCompat() { override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { setPreferencesFromResource(R.xml.advanced_settings, rootKey) - val settingsTextView = view?.findViewById(R.id.settings_textView) - settingsTextView?.text = getString(R.string.advanced) + val topBarTextView = activity?.findViewById(R.id.topBar_textView) + topBarTextView?.text = getString(R.string.advanced) val clearHistory = findPreference("clear_history") clearHistory?.setOnPreferenceClickListener { diff --git a/app/src/main/java/com/github/libretube/preferences/AppearanceSettings.kt b/app/src/main/java/com/github/libretube/preferences/AppearanceSettings.kt index 9c7544420..46a9ad30a 100644 --- a/app/src/main/java/com/github/libretube/preferences/AppearanceSettings.kt +++ b/app/src/main/java/com/github/libretube/preferences/AppearanceSettings.kt @@ -1,6 +1,7 @@ package com.github.libretube.preferences import android.os.Bundle +import android.widget.TextView import androidx.preference.ListPreference import androidx.preference.Preference import androidx.preference.PreferenceFragmentCompat @@ -13,6 +14,9 @@ class AppearanceSettings : PreferenceFragmentCompat() { override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { setPreferencesFromResource(R.xml.appearance_settings, rootKey) + val topBarTextView = activity?.findViewById(R.id.topBar_textView) + topBarTextView?.text = getString(R.string.appearance) + val themeToggle = findPreference("theme_togglee") themeToggle?.setOnPreferenceChangeListener { _, _ -> activity?.recreate() diff --git a/app/src/main/java/com/github/libretube/preferences/SponsorBlockSettings.kt b/app/src/main/java/com/github/libretube/preferences/SponsorBlockSettings.kt index 142ec652d..1579feab0 100644 --- a/app/src/main/java/com/github/libretube/preferences/SponsorBlockSettings.kt +++ b/app/src/main/java/com/github/libretube/preferences/SponsorBlockSettings.kt @@ -1,6 +1,7 @@ package com.github.libretube.preferences import android.os.Bundle +import android.widget.TextView import androidx.preference.PreferenceFragmentCompat import androidx.preference.SwitchPreferenceCompat import com.github.libretube.R @@ -20,6 +21,10 @@ class SponsorBlockSettings : PreferenceFragmentCompat() { override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { setPreferencesFromResource(R.xml.sponsorblock_settings, rootKey) + + val topBarTextView = activity?.findViewById(R.id.topBar_textView) + topBarTextView?.text = getString(R.string.sponsorblock) + val sponsorBlockToggle = findPreference("sb_enabled_key") sponsorBlockToggle?.setOnPreferenceChangeListener { _, newValue -> sponsorBlockEnabled = newValue as Boolean diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index 86fd496d1..9bcbe36d3 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -7,15 +7,17 @@ android:layout_width="match_parent" android:layout_height="wrap_content"> - Date: Tue, 7 Jun 2022 21:23:25 +0200 Subject: [PATCH 2/2] ktlint --- app/src/main/java/com/github/libretube/SettingsActivity.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/app/src/main/java/com/github/libretube/SettingsActivity.kt b/app/src/main/java/com/github/libretube/SettingsActivity.kt index 241b2e099..27f6f5046 100644 --- a/app/src/main/java/com/github/libretube/SettingsActivity.kt +++ b/app/src/main/java/com/github/libretube/SettingsActivity.kt @@ -5,7 +5,6 @@ import android.os.Build import android.os.Bundle import android.view.View import android.widget.ImageButton -import android.widget.ImageView import android.widget.TextView import androidx.appcompat.app.AppCompatActivity import androidx.core.app.ActivityCompat