added backbutton for settings

This commit is contained in:
LagradOst 2022-06-04 02:11:32 +02:00
parent 2d6b46fbcd
commit 622fdcff0f
16 changed files with 109 additions and 19 deletions

View file

@ -2,6 +2,7 @@ package com.lagradost.cloudstream3.ui.settings
import android.content.Context
import android.os.Bundle
import android.view.View
import android.widget.ImageView
import android.widget.TextView
import androidx.appcompat.app.AlertDialog
@ -14,11 +15,16 @@ import com.lagradost.cloudstream3.syncproviders.AccountManager
import com.lagradost.cloudstream3.syncproviders.OAuth2API
import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.beneneCount
import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.getPref
import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.setUpToolbar
import com.lagradost.cloudstream3.utils.UIHelper.dismissSafe
import com.lagradost.cloudstream3.utils.UIHelper.hideKeyboard
import com.lagradost.cloudstream3.utils.UIHelper.setImage
class SettingsAccount : PreferenceFragmentCompat() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
setUpToolbar(R.string.category_credits)
}
private fun showLoginInfo(api: AccountManager, info: OAuth2API.LoginInfo) {
val builder =
AlertDialog.Builder(context ?: return, R.style.AlertDialogCustom)

View file

@ -8,6 +8,7 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.annotation.StringRes
import androidx.core.view.isVisible
import androidx.fragment.app.Fragment
import androidx.preference.Preference
@ -17,9 +18,11 @@ import com.lagradost.cloudstream3.R
import com.lagradost.cloudstream3.mvvm.logError
import com.lagradost.cloudstream3.syncproviders.OAuth2API
import com.lagradost.cloudstream3.ui.home.HomeFragment
import com.lagradost.cloudstream3.utils.UIHelper.fixPaddingStatusbar
import com.lagradost.cloudstream3.utils.UIHelper.navigate
import com.lagradost.cloudstream3.utils.UIHelper.setImage
import kotlinx.android.synthetic.main.main_settings.*
import kotlinx.android.synthetic.main.settings_title_top.*
import java.io.File
class SettingsFragment : Fragment() {
@ -37,6 +40,18 @@ class SettingsFragment : Fragment() {
}
}
fun PreferenceFragmentCompat?.setUpToolbar(@StringRes title : Int) {
if (this == null) return
settings_toolbar?.apply {
setTitle(title)
setNavigationIcon(R.drawable.ic_baseline_arrow_back_24)
setNavigationOnClickListener {
activity?.onBackPressed()
}
}
context.fixPaddingStatusbar(settings_toolbar)
}
fun getFolderSize(dir: File): Long {
var size: Long = 0
dir.listFiles()?.let {

View file

@ -1,6 +1,7 @@
package com.lagradost.cloudstream3.ui.settings
import android.os.Bundle
import android.view.View
import androidx.preference.PreferenceFragmentCompat
import androidx.preference.PreferenceManager
import com.lagradost.cloudstream3.*
@ -10,6 +11,7 @@ import com.lagradost.cloudstream3.mvvm.logError
import com.lagradost.cloudstream3.network.initClient
import com.lagradost.cloudstream3.ui.APIRepository
import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.getPref
import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.setUpToolbar
import com.lagradost.cloudstream3.utils.HOMEPAGE_API
import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showBottomDialog
import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showDialog
@ -54,6 +56,11 @@ class SettingsLang : PreferenceFragmentCompat() {
return conf?.locale?.language ?: "en"
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
setUpToolbar(R.string.category_preferred_media_and_lang)
}
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
hideKeyboard()
setPreferencesFromResource(R.xml.settings_media_lang, rootKey)

View file

@ -1,19 +1,20 @@
package com.lagradost.cloudstream3.ui.settings
import android.os.Bundle
import android.view.View
import androidx.preference.PreferenceFragmentCompat
import androidx.preference.PreferenceManager
import com.lagradost.cloudstream3.AcraApplication
import com.lagradost.cloudstream3.R
import com.lagradost.cloudstream3.app
import com.lagradost.cloudstream3.network.initClient
import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.getPref
import com.lagradost.cloudstream3.utils.HOMEPAGE_API
import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showBottomDialog
import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.setUpToolbar
import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showNginxTextInputDialog
import com.lagradost.cloudstream3.utils.UIHelper.hideKeyboard
class SettingsNginx : PreferenceFragmentCompat() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
setUpToolbar(R.string.category_nginx)
}
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
hideKeyboard()
setPreferencesFromResource(R.xml.settings_nginx, rootKey)

View file

@ -5,6 +5,7 @@ import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.os.Environment
import android.view.View
import androidx.activity.result.contract.ActivityResultContracts
import androidx.preference.PreferenceFragmentCompat
import androidx.preference.PreferenceManager
@ -17,6 +18,7 @@ import com.lagradost.cloudstream3.mvvm.normalSafeApiCall
import com.lagradost.cloudstream3.network.initClient
import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.getFolderSize
import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.getPref
import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.setUpToolbar
import com.lagradost.cloudstream3.ui.subtitles.ChromecastSubtitlesFragment
import com.lagradost.cloudstream3.ui.subtitles.SubtitlesFragment
import com.lagradost.cloudstream3.utils.Qualities
@ -28,6 +30,10 @@ import com.lagradost.cloudstream3.utils.VideoDownloadManager.getBasePath
import java.io.File
class SettingsPlayer : PreferenceFragmentCompat() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
setUpToolbar(R.string.category_player)
}
// Open file picker
private val pathPicker =
registerForActivityResult(ActivityResultContracts.OpenDocumentTree()) { uri ->

View file

@ -1,18 +1,24 @@
package com.lagradost.cloudstream3.ui.settings
import android.os.Bundle
import android.view.View
import androidx.preference.PreferenceFragmentCompat
import androidx.preference.PreferenceManager
import com.lagradost.cloudstream3.R
import com.lagradost.cloudstream3.mvvm.logError
import com.lagradost.cloudstream3.ui.search.SearchResultBuilder
import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.getPref
import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.setUpToolbar
import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showBottomDialog
import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showDialog
import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showMultiDialog
import com.lagradost.cloudstream3.utils.UIHelper.hideKeyboard
class SettingsUI : PreferenceFragmentCompat() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
setUpToolbar(R.string.category_ui)
}
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
hideKeyboard()
setPreferencesFromResource(R.xml.settins_ui, rootKey)

View file

@ -4,14 +4,15 @@ import android.content.ClipData
import android.content.ClipboardManager
import android.content.Context
import android.os.Bundle
import android.view.View
import android.widget.Toast
import androidx.appcompat.app.AlertDialog
import androidx.preference.PreferenceFragmentCompat
import androidx.preference.PreferenceManager
import com.lagradost.cloudstream3.CommonActivity
import com.lagradost.cloudstream3.R
import com.lagradost.cloudstream3.mvvm.logError
import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.getPref
import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.setUpToolbar
import com.lagradost.cloudstream3.utils.BackupUtils.backup
import com.lagradost.cloudstream3.utils.BackupUtils.restorePrompt
import com.lagradost.cloudstream3.utils.InAppUpdater.Companion.runAutoUpdate
@ -26,11 +27,14 @@ import java.io.OutputStream
import kotlin.concurrent.thread
class SettingsUpdates : PreferenceFragmentCompat() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
setUpToolbar(R.string.category_updates)
}
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
hideKeyboard()
setPreferencesFromResource(R.xml.settings_updates, rootKey)
val settingsManager = PreferenceManager.getDefaultSharedPreferences(requireContext())
//val settingsManager = PreferenceManager.getDefaultSharedPreferences(requireContext())
getPref(R.string.backup_key)?.setOnPreferenceClickListener {
activity?.backup()

View file

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:background="?attr/primaryGrayBackground"
android:id="@+id/settings_top_root"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.appbar.AppBarLayout
android:background="@android:color/transparent"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/settings_toolbar"
android:paddingTop="@dimen/navbar_height"
tools:title="Overlord"
android:background="?attr/primaryGrayBackground"
app:navigationIconTint="?attr/iconColor"
app:titleTextColor="?attr/textColor"
app:layout_scrollFlags="scroll|enterAlways"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</com.google.android.material.appbar.AppBarLayout>
<!-- Required ViewGroup for PreferenceFragmentCompat -->
<FrameLayout
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:background="?attr/primaryBlackBackground"
android:id="@android:id/list_container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View file

@ -88,6 +88,7 @@
<fragment
android:id="@+id/navigation_settings_player"
android:label="@string/title_settings"
android:name="com.lagradost.cloudstream3.ui.settings.SettingsPlayer"
app:enterAnim="@anim/enter_anim"
app:exitAnim="@anim/exit_anim"
@ -111,6 +112,7 @@
<fragment
android:id="@+id/navigation_settings_ui"
android:label="@string/title_settings"
android:name="com.lagradost.cloudstream3.ui.settings.SettingsUI"
app:enterAnim="@anim/enter_anim"
app:exitAnim="@anim/exit_anim"
@ -119,6 +121,7 @@
<fragment
android:id="@+id/navigation_settings_lang"
android:label="@string/title_settings"
android:name="com.lagradost.cloudstream3.ui.settings.SettingsLang"
app:enterAnim="@anim/enter_anim"
app:exitAnim="@anim/exit_anim"
@ -127,6 +130,7 @@
<fragment
android:id="@+id/navigation_settings_nginx"
android:label="@string/title_settings"
android:name="com.lagradost.cloudstream3.ui.settings.SettingsNginx"
app:enterAnim="@anim/enter_anim"
app:exitAnim="@anim/exit_anim"
@ -135,6 +139,7 @@
<fragment
android:id="@+id/navigation_settings_updates"
android:label="@string/title_settings"
android:name="com.lagradost.cloudstream3.ui.settings.SettingsUpdates"
app:enterAnim="@anim/enter_anim"
app:exitAnim="@anim/exit_anim"
@ -143,6 +148,7 @@
<fragment
android:id="@+id/navigation_settings_account"
android:label="@string/title_settings"
android:name="com.lagradost.cloudstream3.ui.settings.SettingsAccount"
app:enterAnim="@anim/enter_anim"
app:exitAnim="@anim/exit_anim"
@ -252,6 +258,7 @@
android:id="@+id/navigation_settings"
android:layout_height="match_parent"
android:name="com.lagradost.cloudstream3.ui.settings.SettingsFragment"
tools:layout="@layout/main_settings"
android:label="@string/title_settings"
app:enterAnim="@anim/enter_anim"
app:exitAnim="@anim/exit_anim"
@ -305,6 +312,7 @@
android:id="@+id/navigation_subtitles"
android:layout_height="match_parent"
android:name="com.lagradost.cloudstream3.ui.subtitles.SubtitlesFragment"
tools:layout="@layout/subtitle_settings"
android:label="@string/subtitles_settings"
app:enterAnim="@anim/enter_anim"
app:exitAnim="@anim/exit_anim"
@ -315,6 +323,7 @@
android:id="@+id/navigation_chrome_subtitles"
android:layout_height="match_parent"
android:name="com.lagradost.cloudstream3.ui.subtitles.ChromecastSubtitlesFragment"
tools:layout="@layout/chromecast_subtitle_settings"
android:label="@string/chromecast_subtitles_settings"
app:enterAnim="@anim/enter_anim"
app:exitAnim="@anim/exit_anim"
@ -325,6 +334,7 @@
android:id="@+id/navigation_quick_search"
android:layout_height="match_parent"
android:name="com.lagradost.cloudstream3.ui.quicksearch.QuickSearchFragment"
tools:layout="@layout/quick_search"
app:enterAnim="@anim/enter_anim"
app:exitAnim="@anim/exit_anim"
app:popEnterAnim="@anim/enter_anim"
@ -335,6 +345,7 @@
android:id="@+id/navigation_download_child"
android:layout_height="match_parent"
android:name="com.lagradost.cloudstream3.ui.download.DownloadChildFragment"
tools:layout="@layout/fragment_child_downloads"
app:enterAnim="@anim/enter_anim"
app:exitAnim="@anim/exit_anim"
app:popEnterAnim="@anim/enter_anim"
@ -352,6 +363,7 @@
android:id="@+id/navigation_results"
android:layout_height="match_parent"
android:name="com.lagradost.cloudstream3.ui.result.ResultFragment"
tools:layout="@layout/fragment_result_swipe"
app:enterAnim="@anim/enter_anim"
app:exitAnim="@anim/exit_anim"
app:popEnterAnim="@anim/enter_anim"
@ -373,6 +385,7 @@
</fragment>
<fragment
tools:layout="@layout/fragment_player"
android:id="@+id/navigation_player"
android:layout_height="match_parent"
android:name="com.lagradost.cloudstream3.ui.player.GeneratorPlayer"

View file

@ -61,6 +61,8 @@
<item name="boxItemBackground">@color/boxItemBackground</item>
<item name="iconColor">@color/iconColor</item>
<item name="white">#FFF</item>
<item name="preferenceTheme">@style/CustomPreferenceThemeOverlay</item>
</style>
<style name="ListViewStyle" parent="Widget.AppCompat.ListView">
@ -367,6 +369,10 @@
<item name="android:backgroundTint">?attr/primaryBlackBackground</item>
</style>
<style name="CustomPreferenceThemeOverlay" parent="@style/PreferenceThemeOverlay">
<item name="android:layout">@layout/settings_title_top</item>
</style>
<style name="SettingsItem">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">50sp</item>

View file

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<PreferenceCategory app:icon="@color/transparent" />
<Preference
android:key="@string/mal_key"
android:icon="@drawable/mal_logo" />

View file

@ -1,8 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<PreferenceCategory app:icon="@color/transparent" />
<Preference
android:key="@string/locale_key"
android:title="@string/app_language"

View file

@ -1,8 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<PreferenceCategory app:icon="@color/transparent" />
<Preference
android:key="@string/nginx_url_key"
android:title="@string/nginx_url_pref"

View file

@ -1,8 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<PreferenceCategory app:icon="@color/transparent" />
<Preference
android:key="@string/subtitle_settings_key"
android:title="@string/player_subtitles_settings"

View file

@ -1,8 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<PreferenceCategory app:icon="@color/transparent" />
<Preference
android:title="@string/check_for_update"
app:summary="@string/app_version"

View file

@ -1,8 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<PreferenceCategory app:icon="@color/transparent" />
<Preference
android:icon="@drawable/ic_baseline_color_lens_24"
android:key="@string/primary_color_key"