Add preference to skip account selection at startup (refs #740)

This commit is contained in:
Luna712 2023-11-04 20:37:15 -06:00
parent 01ce02372e
commit f35ac51f4e
4 changed files with 24 additions and 1 deletions

View file

@ -6,6 +6,7 @@ import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.ViewModelProvider
import androidx.recyclerview.widget.GridLayoutManager
import com.lagradost.cloudstream3.AcraApplication.Companion.getKey
import com.lagradost.cloudstream3.CommonActivity
import com.lagradost.cloudstream3.CommonActivity.loadThemes
import com.lagradost.cloudstream3.MainActivity
@ -35,9 +36,14 @@ class AccountSelectActivity : AppCompatActivity() {
val accounts = getAccounts(this@AccountSelectActivity)
val skipStartup = getKey(
getString(R.string.skip_startup_account_select_key),
false
) ?: false || accounts.count() <= 1
// Don't show account selection if there is only
// one account that exists
if (!isEditingFromMainActivity && accounts.count() <= 1) {
if (!isEditingFromMainActivity && skipStartup) {
navigateToMainActivity()
return
}

View file

@ -335,6 +335,15 @@ class SettingsGeneral : PreferenceFragmentCompat() {
return@setOnPreferenceChangeListener true
}
settingsManager.edit().putBoolean(
getString(R.string.skip_startup_account_select_key),
getKey(getString(R.string.skip_startup_account_select_key), false) ?: false
).apply()
getPref(R.string.skip_startup_account_select_key)?.setOnPreferenceChangeListener { _, newValue ->
setKey(getString(R.string.skip_startup_account_select_key), newValue)
return@setOnPreferenceChangeListener true
}
getPref(R.string.download_path_key)?.setOnPreferenceClickListener {
val dirs = getDownloadDirs()

View file

@ -65,6 +65,7 @@
<string name="filter_sub_lang_key" translatable="false">filter_sub_lang_key</string>
<string name="pref_filter_search_quality_key" translatable="false">pref_filter_search_quality_key</string>
<string name="enable_nsfw_on_providers_key" translatable="false">enable_nsfw_on_providers_key</string>
<string name="skip_startup_account_select_key" translatable="false">skip_startup_account_select_key</string>
<string name="enable_skip_op_from_database" translatable="false">enable_skip_op_from_database</string>
<!-- FORMAT MIGHT TRANSLATE, WILL CAUSE CRASH IF APPLIED WRONG -->
<string name="extra_info_format" formatted="true" translatable="false">%d %s | %s</string>
@ -729,4 +730,5 @@
<string name="manage_accounts">Manage Accounts</string>
<string name="edit_account">Edit account</string>
<string name="logged_account" formatted="true">Logged in as %s</string>
<string name="skip_startup_account_select_pref">Skip account selection at startup</string>
</resources>

View file

@ -11,6 +11,12 @@
android:title="@string/download_path_pref"
android:icon="@drawable/netflix_download" />
<SwitchPreference
android:defaultValue="false"
android:icon="@drawable/ic_outline_account_circle_24"
android:key="@string/skip_startup_account_select_key"
android:title="@string/skip_startup_account_select_pref" />
<Preference
android:key="@string/legal_notice_key"
android:title="@string/legal_notice"