Preference to disable multiple-login usernames (#2718)
* Preference to disable multiple-login usernames (with problems) * Fix problem where 'show self username disambiguation' does not take effect immediately because MainActivity needed to be restarted * Make 'show username in toolbars' a 3-option selector, default when multiple accounts logged in * Move SHOW_SELF_USERNAME higher in preference fragment
This commit is contained in:
parent
05f9a17e7a
commit
85a6b2d96b
9 changed files with 48 additions and 3 deletions
|
|
@ -15,9 +15,12 @@
|
|||
|
||||
package com.keylesspalace.tusky.db
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import androidx.preference.PreferenceManager
|
||||
import com.keylesspalace.tusky.entity.Account
|
||||
import com.keylesspalace.tusky.entity.Status
|
||||
import com.keylesspalace.tusky.settings.PrefKeys
|
||||
import java.util.Locale
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
|
@ -225,4 +228,18 @@ class AccountManager @Inject constructor(db: AppDatabase) {
|
|||
identifier == it.identifier
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if the name of the currently-selected account should be displayed in UIs
|
||||
*/
|
||||
fun shouldDisplaySelfUsername(context: Context): Boolean {
|
||||
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
|
||||
val showUsernamePreference = sharedPreferences.getString(PrefKeys.SHOW_SELF_USERNAME, "disambiguate")
|
||||
if (showUsernamePreference == "always")
|
||||
return true
|
||||
if (showUsernamePreference == "never")
|
||||
return false
|
||||
|
||||
return accounts.size > 1 // "disambiguate"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue