From e7ea3063ca4e9c6c16368a75ae2ac443150f9706 Mon Sep 17 00:00:00 2001 From: Artem Umerov Date: Sat, 25 Mar 2023 01:41:50 +0300 Subject: [PATCH] 18 18 --- .../ragnarok/fenrir/activity/MainActivity.kt | 268 ++++++++++-------- .../fragment/SecurityPreferencesFragment.kt | 11 + .../fragment/accounts/AccountsFragment.kt | 8 + .../fragment/accounts/AccountsPresenter.kt | 10 +- .../fenrir/fragment/accounts/IAccountsView.kt | 2 + .../fenrir/settings/AccountsSettings.kt | 123 +++++--- .../dev/ragnarok/fenrir/settings/ISettings.kt | 8 +- .../dev/ragnarok/fenrir/util/ShortcutUtils.kt | 2 +- app_fenrir/src/main/res/values-be/strings.xml | 2 + app_fenrir/src/main/res/values-ru/strings.xml | 2 + app_fenrir/src/main/res/values/strings.xml | 2 + 11 files changed, 280 insertions(+), 158 deletions(-) diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/MainActivity.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/MainActivity.kt index 53d403873..048ac0482 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/MainActivity.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/MainActivity.kt @@ -791,133 +791,161 @@ open class MainActivity : AppCompatActivity(), NavigationDrawerCallbacks, OnSect if (intent == null) { return false } - if (ACTION_OPEN_WALL == intent.action) { - val owner_id = intent.extras!!.getLong(Extra.OWNER_ID) - PlaceFactory.getOwnerWallPlace(mAccountId, owner_id, null).tryOpenWith(this) - return true - } - if (ACTION_SWITH_ACCOUNT == intent.action) { - val newAccountId = intent.extras!!.getLong(Extra.ACCOUNT_ID) - if (Settings.get().accounts().current != newAccountId) { - Settings.get() - .accounts().current = newAccountId - mAccountId = newAccountId + Logger.d(TAG, "handleIntent, extras: ${intent.extras}, action: ${intent.action}") + when { + ACTION_OPEN_WALL == intent.action -> { + val owner_id = intent.extras!!.getLong(Extra.OWNER_ID) + PlaceFactory.getOwnerWallPlace(mAccountId, owner_id, null).tryOpenWith(this) + return true } - intent.action = ACTION_MAIN - } - if (ACTION_SHORTCUT_WALL == intent.action) { - val newAccountId = intent.extras!!.getLong(Extra.ACCOUNT_ID) - val ownerId = intent.extras!!.getLong(Extra.OWNER_ID) - if (Settings.get().accounts().current != newAccountId) { - Settings.get() - .accounts().current = newAccountId - mAccountId = newAccountId + + ACTION_SWITCH_ACCOUNT == intent.action -> { + val newAccountId = intent.extras!!.getLong(Extra.ACCOUNT_ID) + if (Settings.get().accounts().current != newAccountId) { + if (!Settings.get().accounts().registered.contains(newAccountId)) { + createCustomToast(this).showToastError(R.string.account_not_registered) + } else { + Settings.get() + .accounts().current = newAccountId + mAccountId = newAccountId + } + } + intent.action = ACTION_MAIN } - clearBackStack() - openPlace(PlaceFactory.getOwnerWallPlace(newAccountId, ownerId, null)) - return true - } - val extras = intent.extras - val action = intent.action - Logger.d(TAG, "handleIntent, extras: $extras, action: $action") - if (Intent.ACTION_SEND_MULTIPLE == action) { - val mime = intent.type - if (getMainActivityTransform() == MainActivityTransforms.MAIN && extras != null && mime.nonNullNoEmpty() && isMimeAudio( - mime - ) && extras.containsKey(Intent.EXTRA_STREAM) - ) { - val uris = intent.getParcelableArrayListExtraCompat(Intent.EXTRA_STREAM) - if (uris.nonNullNoEmpty()) { - val playlist = ArrayList