mirror of
https://codeberg.org/tom79/Fedilab.git
synced 2025-07-20 10:30:31 +03:00
Add content description to account switching buttons in navigation drawer header
This commit is contained in:
parent
505a43628d
commit
e0a79e9fe3
2 changed files with 21 additions and 14 deletions
|
@ -396,17 +396,20 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
|
||||||
Runnable myRunnable = () -> {
|
Runnable myRunnable = () -> {
|
||||||
if (accounts != null && accounts.size() > 0) {
|
if (accounts != null && accounts.size() > 0) {
|
||||||
Helper.loadPP(activity, headerMainBinding.otherAccount1, accounts.get(0));
|
Helper.loadPP(activity, headerMainBinding.otherAccount1, accounts.get(0));
|
||||||
|
String account1;
|
||||||
|
if (accounts.get(0).mastodon_account != null) {
|
||||||
|
account1 = "@" + accounts.get(0).mastodon_account.acct + "@" + accounts.get(0).instance;
|
||||||
|
} else if (accounts.get(0).peertube_account != null) {
|
||||||
|
account1 = "@" + accounts.get(0).peertube_account.getAcct() + "@" + accounts.get(0).instance;
|
||||||
|
} else {
|
||||||
|
account1 = "";
|
||||||
|
}
|
||||||
|
headerMainBinding.otherAccount1.setContentDescription(activity.getString(R.string.cd_switch_account, account1));
|
||||||
headerMainBinding.otherAccount1.setVisibility(View.VISIBLE);
|
headerMainBinding.otherAccount1.setVisibility(View.VISIBLE);
|
||||||
headerMainBinding.otherAccount1.setOnClickListener(v -> {
|
headerMainBinding.otherAccount1.setOnClickListener(v -> {
|
||||||
headerMenuOpen = false;
|
headerMenuOpen = false;
|
||||||
String account = "";
|
|
||||||
if (accounts.get(0).mastodon_account != null) {
|
|
||||||
account = "@" + accounts.get(0).mastodon_account.acct + "@" + accounts.get(0).instance;
|
|
||||||
} else if (accounts.get(0).peertube_account != null) {
|
|
||||||
account = "@" + accounts.get(0).peertube_account.getAcct() + "@" + accounts.get(0).instance;
|
|
||||||
}
|
|
||||||
typeOfConnection = PeertubeMainActivity.TypeOfConnection.NORMAL;
|
typeOfConnection = PeertubeMainActivity.TypeOfConnection.NORMAL;
|
||||||
Toasty.info(activity, activity.getString(R.string.toast_account_changed, account), Toasty.LENGTH_LONG).show();
|
Toasty.info(activity, activity.getString(R.string.toast_account_changed, account1), Toasty.LENGTH_LONG).show();
|
||||||
BaseMainActivity.currentToken = accounts.get(0).token;
|
BaseMainActivity.currentToken = accounts.get(0).token;
|
||||||
BaseMainActivity.currentUserID = accounts.get(0).user_id;
|
BaseMainActivity.currentUserID = accounts.get(0).user_id;
|
||||||
BaseMainActivity.currentInstance = accounts.get(0).instance;
|
BaseMainActivity.currentInstance = accounts.get(0).instance;
|
||||||
|
@ -425,16 +428,19 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
|
||||||
});
|
});
|
||||||
if (accounts.size() > 1) {
|
if (accounts.size() > 1) {
|
||||||
Helper.loadPP(activity, headerMainBinding.otherAccount2, accounts.get(1));
|
Helper.loadPP(activity, headerMainBinding.otherAccount2, accounts.get(1));
|
||||||
|
String account2;
|
||||||
|
if (accounts.get(1).mastodon_account != null) {
|
||||||
|
account2 = "@" + accounts.get(1).mastodon_account.acct + "@" + accounts.get(1).instance;
|
||||||
|
} else if (accounts.get(1).peertube_account != null) {
|
||||||
|
account2 = "@" + accounts.get(1).peertube_account.getAcct() + "@" + accounts.get(1).instance;
|
||||||
|
} else {
|
||||||
|
account2 = "";
|
||||||
|
}
|
||||||
|
headerMainBinding.otherAccount2.setContentDescription(activity.getString(R.string.cd_switch_account, account2));
|
||||||
headerMainBinding.otherAccount2.setVisibility(View.VISIBLE);
|
headerMainBinding.otherAccount2.setVisibility(View.VISIBLE);
|
||||||
headerMainBinding.otherAccount2.setOnClickListener(v -> {
|
headerMainBinding.otherAccount2.setOnClickListener(v -> {
|
||||||
headerMenuOpen = false;
|
headerMenuOpen = false;
|
||||||
String account = "";
|
Toasty.info(activity, activity.getString(R.string.toast_account_changed, account2), Toasty.LENGTH_LONG).show();
|
||||||
if (accounts.get(1).mastodon_account != null) {
|
|
||||||
account = "@" + accounts.get(1).mastodon_account.acct + "@" + accounts.get(1).instance;
|
|
||||||
} else if (accounts.get(1).peertube_account != null) {
|
|
||||||
account = "@" + accounts.get(1).peertube_account.getAcct() + "@" + accounts.get(1).instance;
|
|
||||||
}
|
|
||||||
Toasty.info(activity, activity.getString(R.string.toast_account_changed, account), Toasty.LENGTH_LONG).show();
|
|
||||||
BaseMainActivity.currentToken = accounts.get(1).token;
|
BaseMainActivity.currentToken = accounts.get(1).token;
|
||||||
BaseMainActivity.currentUserID = accounts.get(1).user_id;
|
BaseMainActivity.currentUserID = accounts.get(1).user_id;
|
||||||
BaseMainActivity.currentInstance = accounts.get(1).instance;
|
BaseMainActivity.currentInstance = accounts.get(1).instance;
|
||||||
|
|
|
@ -76,6 +76,7 @@
|
||||||
<string name="logout_account_confirmation">Are you sure you want to logout @%1$s@%2$s?</string>
|
<string name="logout_account_confirmation">Are you sure you want to logout @%1$s@%2$s?</string>
|
||||||
|
|
||||||
<string name="cd_open_profile">Open profile page</string>
|
<string name="cd_open_profile">Open profile page</string>
|
||||||
|
<string name="cd_switch_account">Switch to %s</string>
|
||||||
|
|
||||||
<!-- Status -->
|
<!-- Status -->
|
||||||
<string name="no_status">No message to display</string>
|
<string name="no_status">No message to display</string>
|
||||||
|
|
Loading…
Reference in a new issue