Remove unnecessary shared pref

This commit is contained in:
Andrew 2024-04-09 08:21:41 +09:30
parent 7d7d2b89bd
commit ac97529c73
5 changed files with 7 additions and 15 deletions

View File

@ -154,6 +154,8 @@ public class ApplicationContext extends Application implements DefaultLifecycleO
private volatile boolean isAppVisible;
public boolean newAccount = false;
@Override
public Object getSystemService(String name) {
if (MessagingModuleConfiguration.MESSAGING_MODULE_SERVICE.equals(name)) {
@ -213,8 +215,6 @@ public class ApplicationContext extends Application implements DefaultLifecycleO
MessagingModuleConfiguration.configure(this);
super.onCreate();
textSecurePreferences.setNewAccount(false);
messagingModuleConfiguration = new MessagingModuleConfiguration(
this,
storage,

View File

@ -225,7 +225,7 @@ class HomeActivity : PassphraseRequiredActionBarActivity(),
}
// Set up empty state view
binding.emptyStateContainer.setContent { EmptyView(textSecurePreferences.isNewAccount()) }
binding.emptyStateContainer.setContent { EmptyView(ApplicationContext.getInstance(this).newAccount) }
IP2Country.configureIfNeeded(this@HomeActivity)
startObservingUpdates()

View File

@ -25,6 +25,7 @@ import kotlinx.coroutines.launch
import network.loki.messenger.R
import org.session.libsession.utilities.AppTextSecurePreferences
import org.session.libsession.utilities.TextSecurePreferences
import org.thoughtcrime.securesms.ApplicationContext
import org.thoughtcrime.securesms.BaseActionBarActivity
import org.thoughtcrime.securesms.dependencies.ConfigFactory
import org.thoughtcrime.securesms.onboarding.messagenotifications.startPNModeActivity
@ -67,7 +68,7 @@ class LoadingActivity: BaseActionBarActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
prefs.setNewAccount(false)
ApplicationContext.getInstance(this).newAccount = false
ComposeView(this)
.apply { setContent { LoadingScreen() } }

View File

@ -32,6 +32,7 @@ import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.launch
import network.loki.messenger.R
import org.session.libsession.utilities.AppTextSecurePreferences
import org.thoughtcrime.securesms.ApplicationContext
import org.thoughtcrime.securesms.BaseActionBarActivity
import org.thoughtcrime.securesms.onboarding.messagenotifications.startPNModeActivity
import org.thoughtcrime.securesms.ui.AppTheme
@ -138,7 +139,7 @@ class PickDisplayNameActivity : BaseActionBarActivity() {
}
fun Context.startPickDisplayNameActivity(failedToLoad: Boolean = false, flags: Int = 0) {
AppTextSecurePreferences(this).setNewAccount(!failedToLoad)
ApplicationContext.getInstance(this).newAccount = !failedToLoad
Intent(this, PickDisplayNameActivity::class.java)
.apply { putExtra(EXTRA_PICK_NEW_NAME, failedToLoad) }

View File

@ -19,7 +19,6 @@ import org.session.libsession.utilities.TextSecurePreferences.Companion.CLASSIC_
import org.session.libsession.utilities.TextSecurePreferences.Companion.CLASSIC_LIGHT
import org.session.libsession.utilities.TextSecurePreferences.Companion.FOLLOW_SYSTEM_SETTINGS
import org.session.libsession.utilities.TextSecurePreferences.Companion.HIDE_PASSWORD
import org.session.libsession.utilities.TextSecurePreferences.Companion.NEW_ACCOUNT
import org.session.libsession.utilities.TextSecurePreferences.Companion.LAST_VACUUM_TIME
import org.session.libsession.utilities.TextSecurePreferences.Companion.LEGACY_PREF_KEY_SELECTED_UI_MODE
import org.session.libsession.utilities.TextSecurePreferences.Companion.OCEAN_DARK
@ -187,8 +186,6 @@ interface TextSecurePreferences {
fun clearAll()
fun getHidePassword(): Boolean
fun setHidePassword(value: Boolean)
fun isNewAccount(): Boolean
fun setNewAccount(value: Boolean)
companion object {
val TAG = TextSecurePreferences::class.simpleName
@ -291,7 +288,6 @@ interface TextSecurePreferences {
const val SELECTED_STYLE = "pref_selected_style" // classic_dark/light, ocean_dark/light
const val FOLLOW_SYSTEM_SETTINGS = "pref_follow_system" // follow system day/night
const val HIDE_PASSWORD = "pref_hide_password"
const val NEW_ACCOUNT = "new_account"
const val LEGACY_PREF_KEY_SELECTED_UI_MODE = "SELECTED_UI_MODE" // this will be cleared upon launching app, for users migrating to theming build
const val CLASSIC_DARK = "classic.dark"
@ -1726,10 +1722,4 @@ class AppTextSecurePreferences @Inject constructor(
override fun setHidePassword(value: Boolean) {
setBooleanPreference(HIDE_PASSWORD, value)
}
override fun isNewAccount(): Boolean = getBooleanPreference(NEW_ACCOUNT, false)
override fun setNewAccount(value: Boolean) {
setBooleanPreference(NEW_ACCOUNT, value)
}
}