more work on v2 account-settings ui

This commit is contained in:
Eric 2022-11-29 15:47:07 -08:00
parent d75c469baa
commit 3b08ca39f6
No known key found for this signature in database
GPG Key ID: 89C93F0F8D6D5A98
4 changed files with 90 additions and 39 deletions

View File

@ -420,7 +420,7 @@
"assets/build/ba_data/audio/zoeOw.ogg": "https://files.ballistica.net/cache/ba1/60/ad/38269b7f1c7dc20cb9a506cd0681",
"assets/build/ba_data/audio/zoePickup01.ogg": "https://files.ballistica.net/cache/ba1/72/85/d6fc4d16b7081d91fba2850b5b10",
"assets/build/ba_data/audio/zoeScream01.ogg": "https://files.ballistica.net/cache/ba1/e9/ae/1d674d0c086eaa0bd1c3b1db0505",
"assets/build/ba_data/data/langdata.json": "https://files.ballistica.net/cache/ba1/b1/c3/2d8b079670d84bde0558f6454f1f",
"assets/build/ba_data/data/langdata.json": "https://files.ballistica.net/cache/ba1/c1/58/545feb14ab42361ee0eacce7a1e7",
"assets/build/ba_data/data/languages/arabic.json": "https://files.ballistica.net/cache/ba1/b0/05/e530acaba539f040ce61e22561dc",
"assets/build/ba_data/data/languages/belarussian.json": "https://files.ballistica.net/cache/ba1/61/03/89070ca765e06da3a419a579f503",
"assets/build/ba_data/data/languages/chinese.json": "https://files.ballistica.net/cache/ba1/05/87/d3e03edbc59eb7e7da7ef8b17134",
@ -429,16 +429,16 @@
"assets/build/ba_data/data/languages/czech.json": "https://files.ballistica.net/cache/ba1/cb/df/f2d54d3146a159c678a47d3ff01b",
"assets/build/ba_data/data/languages/danish.json": "https://files.ballistica.net/cache/ba1/6a/fa/fcf4a804beaff927b0f12c179eaa",
"assets/build/ba_data/data/languages/dutch.json": "https://files.ballistica.net/cache/ba1/68/93/da8e9874f41a786edf52ba4ccaad",
"assets/build/ba_data/data/languages/english.json": "https://files.ballistica.net/cache/ba1/74/1d/04985b013519340632a0f5eb6d81",
"assets/build/ba_data/data/languages/english.json": "https://files.ballistica.net/cache/ba1/52/2a/3e6272799aba12af878dfd2eea15",
"assets/build/ba_data/data/languages/esperanto.json": "https://files.ballistica.net/cache/ba1/ac/f5/c0922a99e40dfc9f5e026d43b533",
"assets/build/ba_data/data/languages/filipino.json": "https://files.ballistica.net/cache/ba1/86/26/060476f46994c035ae0d52640657",
"assets/build/ba_data/data/languages/french.json": "https://files.ballistica.net/cache/ba1/c7/cf/35a6ebc876c7476b72547a914d07",
"assets/build/ba_data/data/languages/german.json": "https://files.ballistica.net/cache/ba1/06/58/071d6f7bbb5e93a3e074dbd323ae",
"assets/build/ba_data/data/languages/gibberish.json": "https://files.ballistica.net/cache/ba1/a3/f7/b12c68a8c1ecabbf7b8c41452986",
"assets/build/ba_data/data/languages/gibberish.json": "https://files.ballistica.net/cache/ba1/e7/f2/9cf56bec9e4312c7b547e42477ea",
"assets/build/ba_data/data/languages/greek.json": "https://files.ballistica.net/cache/ba1/ae/89/47486b987d14f58b6cf2d665ce4b",
"assets/build/ba_data/data/languages/hindi.json": "https://files.ballistica.net/cache/ba1/9f/df/469e166c6a0d42bca4baae3a6cb6",
"assets/build/ba_data/data/languages/hungarian.json": "https://files.ballistica.net/cache/ba1/b2/81/53c8cd7617d649403e539c3a6171",
"assets/build/ba_data/data/languages/indonesian.json": "https://files.ballistica.net/cache/ba1/26/57/b9443fccbc90602a5ace74935365",
"assets/build/ba_data/data/languages/indonesian.json": "https://files.ballistica.net/cache/ba1/ae/64/97ed10eed5f31b33864d90368330",
"assets/build/ba_data/data/languages/italian.json": "https://files.ballistica.net/cache/ba1/5f/b2/b9301d67bef699a092a4c04dd522",
"assets/build/ba_data/data/languages/korean.json": "https://files.ballistica.net/cache/ba1/7c/38/d4a44c481757d355836f292ede48",
"assets/build/ba_data/data/languages/persian.json": "https://files.ballistica.net/cache/ba1/cd/ed/4d6d0778d256ccc0ff2e27b970c6",

View File

@ -11,6 +11,7 @@
- Added 'raw' bool arg to `ba.pushcall()`. Passing True for it disables context save/restore and thread checks.
- Added `ba.internal.dump_tracebacks()` which can be used to dump the stack state of all Python threads after some delay. Useful for debugging deadlock; just call right before said deadlock occurs. Results will be logged on the next app launch if they cannot be immediately.
- Fixed a low level event-loop issue that in some cases was preventing the Android version from properly pausing/resuming the app or managing connections while in the background. If you look at the devices section on ballistica.net you should now see your device disappear when you background the app and reappear when you foreground it. Please holler if not.
- Device accounts are now marked as deprecated, and signing in with one now brings up an 'upgrade' UI which allows converting it to a V2 account. It is my hope to push the entire client ecosystem to V2 accounts as quickly as possible since trying to support both independent V1 accounts and V2 accounts is a substantial technical burden.
### 1.7.13 (build 20919, api 7, 2022-11-03)
- Android target-sdk has been updated to 33 (Android 13). Please holler if anything seems broken or is behaving differently than before on Android.

View File

@ -9,12 +9,12 @@ import logging
from typing import TYPE_CHECKING
from efro.call import tpartial
from bacommon.login import LoginType
import _ba
if TYPE_CHECKING:
from typing import Any
from bacommon.login import LoginType
from ba._login import LoginAdapter
@ -30,7 +30,6 @@ class AccountV2Subsystem:
"""
def __init__(self) -> None:
from bacommon.login import LoginType
# Whether or not everything related to an initial login
# (or lack thereof) has completed. This includes things like
@ -179,6 +178,8 @@ class AccountV2Subsystem:
types even if the default implicit one can't be explicitly
logged out or otherwise controlled.
"""
from ba._language import Lstr
assert _ba.in_logic_thread()
cfg = _ba.app.config
@ -202,19 +203,26 @@ class AccountV2Subsystem:
# this implicit login, we may want to let them know that the
# 'Welcome back FOO' they likely just saw is not actually
# accurate.
if bool(False):
if (
self.primary is not None
and not self.login_adapters[login_type].is_back_end_active()
):
if (
self.primary is not None
and not self.login_adapters[login_type].is_back_end_active()
):
if login_type is LoginType.GPGS:
service_str = Lstr(resource='googlePlayText')
else:
service_str = None
if service_str is not None:
_ba.timer(
2.0,
tpartial(
_ba.screenmessage,
'Warning: Ignoring your'
' Google Play Games account.\n'
'If you want to use it,'
' sign out of your current account.',
Lstr(
resource='notUsingAccountText',
subs=[
('${ACCOUNT}', state.display_name),
('${SERVICE}', service_str),
],
),
(1, 0.5, 0),
),
)
@ -328,11 +336,11 @@ class AccountV2Subsystem:
del adapter # Unused.
# Make some noise on errors.
# (May want to make this more descriptive).
# Make some noise on errors since the user knows a sign-in
# attempt is happening in this case.
if isinstance(result, Exception):
logging.warning(
'Error on explicit sign in attempt.', exc_info=result
'Error on explicit accountv2 sign in attempt.', exc_info=result
)
with _ba.Context('ui'):
_ba.screenmessage(
@ -354,8 +362,12 @@ class AccountV2Subsystem:
del adapter # Unused.
# Silently ignore errors.
# Log errors but don't inform the user; they're not aware of this
# attempt and ignorance is bliss.
if isinstance(result, Exception):
logging.warning(
'Error on implicit accountv2 sign in attempt.', exc_info=result
)
return
# If we're still connected and still not signed in,

View File

@ -17,6 +17,12 @@ import ba.internal
if TYPE_CHECKING:
from ba.internal import LoginAdapter
# We only show v1 linking controls when directly signed in with
# V1 accounts. Generally V2 accounts should use the web ui for linking.
# However we have an escape-hatch here if someone needs to access
# V1 linking for the V1 portion of their V2 account.
FORCE_ENABLE_V1_LINKING = False
class AccountSettingsWindow(ba.Window):
"""Window for account related functionality."""
@ -275,6 +281,7 @@ class AccountSettingsWindow(ba.Window):
and 'Device' in self._show_sign_in_buttons
)
sign_in_button_space = 70.0
deprecated_space = 60
show_game_service_button = self._signed_in and v1_account_type in [
'Game Center'
@ -283,12 +290,7 @@ class AccountSettingsWindow(ba.Window):
show_what_is_v2 = self._signed_in and v1_account_type == 'V2'
show_linked_accounts_text = (
self._signed_in
and ba.internal.get_v1_account_misc_read_val(
'allowAccountLinking2', False
)
)
show_linked_accounts_text = self._signed_in
linked_accounts_text_space = 60.0
show_achievements_button = self._signed_in and v1_account_type in (
@ -325,17 +327,17 @@ class AccountSettingsWindow(ba.Window):
70.0 if show_manage_v2_account_button else 100.0
)
show_link_accounts_button = (
self._signed_in
and ba.internal.get_v1_account_misc_read_val(
'allowAccountLinking2', False
)
show_link_accounts_button = self._signed_in and (
primary_v2_account is None or FORCE_ENABLE_V1_LINKING
)
link_accounts_button_space = 70.0
show_unlink_accounts_button = show_link_accounts_button
unlink_accounts_button_space = 90.0
show_v2_link_info = self._signed_in and not show_link_accounts_button
v2_link_info_space = 70.0
show_sign_out_button = self._signed_in and v1_account_type in [
'Local',
'Google Play',
@ -361,10 +363,10 @@ class AccountSettingsWindow(ba.Window):
self._sub_height += signing_in_text_space
if show_google_play_sign_in_button:
self._sub_height += sign_in_button_space
if show_device_sign_in_button:
self._sub_height += sign_in_button_space
if show_v2_proxy_sign_in_button:
self._sub_height += sign_in_button_space
if show_device_sign_in_button:
self._sub_height += sign_in_button_space + deprecated_space
if show_game_service_button:
self._sub_height += game_service_button_space
if show_linked_accounts_text:
@ -391,6 +393,8 @@ class AccountSettingsWindow(ba.Window):
self._sub_height += link_accounts_button_space
if show_unlink_accounts_button:
self._sub_height += unlink_accounts_button_space
if show_v2_link_info:
self._sub_height += v2_link_info_space
if show_sign_out_button:
self._sub_height += sign_out_button_space
if show_cancel_sign_in_button:
@ -625,7 +629,7 @@ class AccountSettingsWindow(ba.Window):
if show_device_sign_in_button:
button_width = 350
v -= sign_in_button_space
v -= sign_in_button_space + deprecated_space
self._sign_in_device_button = btn = ba.buttonwidget(
parent=self._subcontainer,
position=((self._sub_width - button_width) * 0.5, v - 20),
@ -634,6 +638,18 @@ class AccountSettingsWindow(ba.Window):
label='',
on_activate_call=lambda: self._sign_in_press('Local'),
)
ba.textwidget(
parent=self._subcontainer,
h_align='center',
v_align='center',
size=(0, 0),
position=(self._sub_width * 0.5, v + 60),
text=ba.Lstr(resource='deprecatedText'),
scale=0.8,
maxwidth=300,
color=(0.6, 0.55, 0.45),
)
ba.textwidget(
parent=self._subcontainer,
draw_controller=btn,
@ -926,6 +942,7 @@ class AccountSettingsWindow(ba.Window):
scale=0.9,
color=(0.75, 0.7, 0.8),
maxwidth=self._sub_width * 0.95,
text=ba.Lstr(resource=self._r + '.linkedAccountsText'),
h_align='center',
v_align='center',
)
@ -934,6 +951,8 @@ class AccountSettingsWindow(ba.Window):
else:
self._linked_accounts_text = None
# Show link/unlink buttons only for V1 accounts.
if show_link_accounts_button:
v -= link_accounts_button_space
self._link_accounts_button = btn = ba.buttonwidget(
@ -1013,6 +1032,21 @@ class AccountSettingsWindow(ba.Window):
else:
self._unlink_accounts_button = None
if show_v2_link_info:
v -= v2_link_info_space
ba.textwidget(
parent=self._subcontainer,
h_align='center',
v_align='center',
size=(0, 0),
position=(self._sub_width * 0.5, v + v2_link_info_space - 20),
text=ba.Lstr(resource='v2AccountLinkingInfoText'),
flatness=1.0,
scale=0.8,
maxwidth=450,
color=(0.5, 0.45, 0.55),
)
if show_sign_out_button:
v -= sign_out_button_space
self._sign_out_button = btn = ba.buttonwidget(
@ -1144,6 +1178,14 @@ class AccountSettingsWindow(ba.Window):
if self._linked_accounts_text is None:
return
# Disable this by default when signed in to a V2 account
# (since this shows V1 links which we should no longer care about).
if (
ba.app.accounts_v2.primary is not None
and not FORCE_ENABLE_V1_LINKING
):
return
# if this is not present, we haven't had contact from the server so
# let's not proceed..
if ba.internal.get_public_login_id() is None:
@ -1153,13 +1195,9 @@ class AccountSettingsWindow(ba.Window):
accounts = ba.internal.get_v1_account_misc_read_val_2(
'linkedAccounts', []
)
# our_account = _bs.get_v1_account_display_string()
# accounts = [a for a in accounts if a != our_account]
# accounts_str = u', '.join(accounts) if accounts else
# ba.Lstr(translate=('settingNames', 'None'))
# UPDATE - we now just print the number here; not the actual
# accounts
# (they can see that in the unlink section if they're curious)
# accounts (they can see that in the unlink section if they're
# curious)
accounts_str = str(max(0, len(accounts) - 1))
ba.textwidget(
edit=self._linked_accounts_text,