Fix cross actions
This commit is contained in:
parent
e4affdc9d7
commit
8103bf4a16
@ -426,7 +426,7 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
|
|||||||
headerMainBinding.ownerAccounts.setImageResource(R.drawable.ic_baseline_arrow_drop_up_24);
|
headerMainBinding.ownerAccounts.setImageResource(R.drawable.ic_baseline_arrow_drop_up_24);
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
List<BaseAccount> accounts = new Account(activity).getCrossAccounts();
|
List<BaseAccount> accounts = new Account(activity).getOtherAccounts();
|
||||||
Handler mainHandler = new Handler(Looper.getMainLooper());
|
Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||||
Runnable myRunnable = () -> {
|
Runnable myRunnable = () -> {
|
||||||
navigationView.getMenu().clear();
|
navigationView.getMenu().clear();
|
||||||
|
@ -358,7 +358,7 @@ public class Account extends BaseAccount implements Serializable {
|
|||||||
*
|
*
|
||||||
* @return BaseAccount List<{@link BaseAccount}>
|
* @return BaseAccount List<{@link BaseAccount}>
|
||||||
*/
|
*/
|
||||||
public List<BaseAccount> getCrossAccounts() throws DBException {
|
public List<BaseAccount> getOtherAccounts() throws DBException {
|
||||||
if (db == null) {
|
if (db == null) {
|
||||||
throw new DBException("db is null. Wrong initialization.");
|
throw new DBException("db is null. Wrong initialization.");
|
||||||
}
|
}
|
||||||
@ -370,6 +370,23 @@ public class Account extends BaseAccount implements Serializable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns all accounts that allows cross-account actions
|
||||||
|
*
|
||||||
|
* @return BaseAccount List<{@link BaseAccount}>
|
||||||
|
*/
|
||||||
|
public List<BaseAccount> getCrossAccounts() throws DBException {
|
||||||
|
if (db == null) {
|
||||||
|
throw new DBException("db is null. Wrong initialization.");
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
Cursor c = db.query(Sqlite.TABLE_USER_ACCOUNT, null, null, null, null, null, null, null);
|
||||||
|
return cursorToListMastodonUser(c);
|
||||||
|
} catch (Exception e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns all accounts
|
* Returns all accounts
|
||||||
*
|
*
|
||||||
@ -455,6 +472,27 @@ public class Account extends BaseAccount implements Serializable {
|
|||||||
return accountList;
|
return accountList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private List<BaseAccount> cursorToListMastodonUser(Cursor c) {
|
||||||
|
//No element found
|
||||||
|
if (c.getCount() == 0) {
|
||||||
|
c.close();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
List<BaseAccount> accountList = new ArrayList<>();
|
||||||
|
while (c.moveToNext()) {
|
||||||
|
BaseAccount account = convertCursorToAccount(c);
|
||||||
|
//We don't add in the list the current connected account
|
||||||
|
if (account.mastodon_account != null) {
|
||||||
|
accountList.add(account);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Close the cursor
|
||||||
|
c.close();
|
||||||
|
return accountList;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private List<BaseAccount> cursorToListUserWithOwner(Cursor c) {
|
private List<BaseAccount> cursorToListUserWithOwner(Cursor c) {
|
||||||
//No element found
|
//No element found
|
||||||
if (c.getCount() == 0) {
|
if (c.getCount() == 0) {
|
||||||
|
@ -401,7 +401,7 @@ public class CrossActionHelper {
|
|||||||
public static void doCrossShare(final Context context, final Bundle bundle) {
|
public static void doCrossShare(final Context context, final Bundle bundle) {
|
||||||
List<BaseAccount> accounts;
|
List<BaseAccount> accounts;
|
||||||
try {
|
try {
|
||||||
accounts = new Account(context).getAll();
|
accounts = new Account(context).getCrossAccounts();
|
||||||
List<app.fedilab.android.mastodon.client.entities.api.Account> accountList = new ArrayList<>();
|
List<app.fedilab.android.mastodon.client.entities.api.Account> accountList = new ArrayList<>();
|
||||||
for (BaseAccount account : accounts) {
|
for (BaseAccount account : accounts) {
|
||||||
account.mastodon_account.acct += "@" + account.instance;
|
account.mastodon_account.acct += "@" + account.instance;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user