mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
Add preference to skip account selection at startup (refs #740)
This commit is contained in:
parent
01ce02372e
commit
f35ac51f4e
4 changed files with 24 additions and 1 deletions
|
@ -6,6 +6,7 @@ import android.os.Bundle
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.lifecycle.ViewModelProvider
|
import androidx.lifecycle.ViewModelProvider
|
||||||
import androidx.recyclerview.widget.GridLayoutManager
|
import androidx.recyclerview.widget.GridLayoutManager
|
||||||
|
import com.lagradost.cloudstream3.AcraApplication.Companion.getKey
|
||||||
import com.lagradost.cloudstream3.CommonActivity
|
import com.lagradost.cloudstream3.CommonActivity
|
||||||
import com.lagradost.cloudstream3.CommonActivity.loadThemes
|
import com.lagradost.cloudstream3.CommonActivity.loadThemes
|
||||||
import com.lagradost.cloudstream3.MainActivity
|
import com.lagradost.cloudstream3.MainActivity
|
||||||
|
@ -35,9 +36,14 @@ class AccountSelectActivity : AppCompatActivity() {
|
||||||
|
|
||||||
val accounts = getAccounts(this@AccountSelectActivity)
|
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
|
// Don't show account selection if there is only
|
||||||
// one account that exists
|
// one account that exists
|
||||||
if (!isEditingFromMainActivity && accounts.count() <= 1) {
|
if (!isEditingFromMainActivity && skipStartup) {
|
||||||
navigateToMainActivity()
|
navigateToMainActivity()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -335,6 +335,15 @@ class SettingsGeneral : PreferenceFragmentCompat() {
|
||||||
return@setOnPreferenceChangeListener true
|
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 {
|
getPref(R.string.download_path_key)?.setOnPreferenceClickListener {
|
||||||
val dirs = getDownloadDirs()
|
val dirs = getDownloadDirs()
|
||||||
|
|
||||||
|
|
|
@ -65,6 +65,7 @@
|
||||||
<string name="filter_sub_lang_key" translatable="false">filter_sub_lang_key</string>
|
<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="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="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>
|
<string name="enable_skip_op_from_database" translatable="false">enable_skip_op_from_database</string>
|
||||||
<!-- FORMAT MIGHT TRANSLATE, WILL CAUSE CRASH IF APPLIED WRONG -->
|
<!-- FORMAT MIGHT TRANSLATE, WILL CAUSE CRASH IF APPLIED WRONG -->
|
||||||
<string name="extra_info_format" formatted="true" translatable="false">%d %s | %s</string>
|
<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="manage_accounts">Manage Accounts</string>
|
||||||
<string name="edit_account">Edit account</string>
|
<string name="edit_account">Edit account</string>
|
||||||
<string name="logged_account" formatted="true">Logged in as %s</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>
|
</resources>
|
||||||
|
|
|
@ -11,6 +11,12 @@
|
||||||
android:title="@string/download_path_pref"
|
android:title="@string/download_path_pref"
|
||||||
android:icon="@drawable/netflix_download" />
|
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
|
<Preference
|
||||||
android:key="@string/legal_notice_key"
|
android:key="@string/legal_notice_key"
|
||||||
android:title="@string/legal_notice"
|
android:title="@string/legal_notice"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue