change currentAccount with a getter

This commit is contained in:
Thomas 2024-01-29 15:02:56 +01:00
parent 1274d83ee1
commit 1ad956e965
65 changed files with 349 additions and 398 deletions

View file

@ -213,7 +213,6 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
public static boolean filterFetched;
public static boolean show_boosts, show_replies, show_dms, show_art_nsfw, show_self_boosts, show_self_replies, show_my_messages;
public static String regex_home, regex_local, regex_public;
public static BaseAccount currentAccount;
public static iconLauncher mLauncher = iconLauncher.BUBBLES;
public static boolean headerMenuOpen;
public static int currentNightMode;
@ -226,7 +225,7 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
Bundle args = intent.getExtras();
if (args != null) {
long bundleId = args.getLong(Helper.ARG_INTENT_ID, -1);
new CachedBundle(BaseMainActivity.this).getBundle(bundleId, currentAccount, bundle -> {
new CachedBundle(BaseMainActivity.this).getBundle(bundleId, Helper.getCurrentAccount(BaseMainActivity.this), bundle -> {
if (bundle.getBoolean(Helper.RECEIVE_COMPOSE_ERROR_MESSAGE, false)) {
String errorMessage = bundle.getString(Helper.RECEIVE_ERROR_MESSAGE);
StatusDraft statusDraft = (StatusDraft) bundle.getSerializable(Helper.ARG_STATUS_DRAFT);
@ -239,7 +238,7 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
Intent intentCompose = new Intent(context, ComposeActivity.class);
Bundle args2 = new Bundle();
args2.putSerializable(Helper.ARG_STATUS_DRAFT, statusDraft);
new CachedBundle(BaseMainActivity.this).insertBundle(args2, currentAccount, bundleId2 -> {
new CachedBundle(BaseMainActivity.this).insertBundle(args2, Helper.getCurrentAccount(BaseMainActivity.this), bundleId2 -> {
Bundle bundle2 = new Bundle();
bundle2.putLong(Helper.ARG_INTENT_ID, bundleId2);
intentCompose.putExtras(bundle2);
@ -262,13 +261,13 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
Bundle args = intent.getExtras();
if (args != null) {
long bundleId = args.getLong(Helper.ARG_INTENT_ID, -1);
new CachedBundle(BaseMainActivity.this).getBundle(bundleId, currentAccount, bundle -> {
new CachedBundle(BaseMainActivity.this).getBundle(bundleId, Helper.getCurrentAccount(BaseMainActivity.this), bundle -> {
if (bundle.getBoolean(Helper.RECEIVE_REDRAW_TOPBAR, false)) {
List<MastodonList> mastodonLists = (List<MastodonList>) bundle.getSerializable(Helper.RECEIVE_MASTODON_LIST);
redrawPinned(mastodonLists);
}
if (bundle.getBoolean(Helper.RECEIVE_REDRAW_BOTTOM, false)) {
bottomMenu = new BottomMenu(BaseMainActivity.this).hydrate(currentAccount, binding.bottomNavView);
bottomMenu = new BottomMenu(BaseMainActivity.this).hydrate(Helper.getCurrentAccount(BaseMainActivity.this), binding.bottomNavView);
if (bottomMenu != null) {
//ManageClick on bottom menu items
if (binding.bottomNavView.findViewById(R.id.nav_home) != null) {
@ -321,7 +320,7 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
Intent intentContext = new Intent(BaseMainActivity.this, ContextActivity.class);
Bundle args2 = new Bundle();
args2.putSerializable(Helper.ARG_STATUS, statusSent);
new CachedBundle(BaseMainActivity.this).insertBundle(args2, currentAccount, bundleId2 -> {
new CachedBundle(BaseMainActivity.this).insertBundle(args2, Helper.getCurrentAccount(BaseMainActivity.this), bundleId2 -> {
Bundle bundle2 = new Bundle();
bundle2.putLong(Helper.ARG_INTENT_ID, bundleId2);
intentContext.putExtras(bundle2);
@ -360,18 +359,18 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
//Fetch some db values to initialize data
new Thread(() -> {
try {
if (currentAccount == null) {
if (Helper.getCurrentAccount(activity) == null) {
if (currentToken == null || currentToken.trim().isEmpty()) {
currentToken = sharedpreferences.getString(Helper.PREF_USER_TOKEN, null);
}
try {
currentAccount = new Account(activity).getConnectedAccount();
Helper.setCurrentAccount(new Account(activity).getConnectedAccount());
} catch (DBException e) {
e.printStackTrace();
}
}
if (currentAccount != null) {
MutedAccounts mutedAccounts = new MutedAccounts(activity).getMutedAccount(currentAccount);
if (Helper.getCurrentAccount(activity) != null) {
MutedAccounts mutedAccounts = new MutedAccounts(activity).getMutedAccount(Helper.getCurrentAccount(activity));
if (mutedAccounts != null && mutedAccounts.accounts != null) {
filteredAccounts = mutedAccounts.accounts;
}
@ -620,9 +619,9 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
}).start();
} else {
navigationView.getMenu().clear();
if (MainActivity.currentAccount.mastodon_account != null) {
if (Helper.getCurrentAccount(activity).mastodon_account != null) {
navigationView.inflateMenu(R.menu.activity_main_drawer);
} else if (MainActivity.currentAccount.peertube_account != null) {
} else if (Helper.getCurrentAccount(activity).peertube_account != null) {
navigationView.inflateMenu(R.menu.activity_main_drawer_peertube);
}
headerMainBinding.ownerAccounts.setImageResource(R.drawable.ic_baseline_arrow_drop_down_24);
@ -640,10 +639,10 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
if (itemId == R.id.action_logout_account) {
AlertDialog.Builder alt_bld = new MaterialAlertDialogBuilder(activity);
alt_bld.setTitle(R.string.action_logout);
if (currentAccount.mastodon_account != null && currentAccount.instance != null) {
alt_bld.setMessage(activity.getString(R.string.logout_account_confirmation, currentAccount.mastodon_account.username, currentAccount.instance));
} else if (currentAccount.peertube_account != null && currentAccount.instance != null) {
alt_bld.setMessage(activity.getString(R.string.logout_account_confirmation, currentAccount.peertube_account.getUsername(), currentAccount.instance));
if (Helper.getCurrentAccount(activity).mastodon_account != null && Helper.getCurrentAccount(activity).instance != null) {
alt_bld.setMessage(activity.getString(R.string.logout_account_confirmation, Helper.getCurrentAccount(activity).mastodon_account.username, Helper.getCurrentAccount(activity).instance));
} else if (Helper.getCurrentAccount(activity).peertube_account != null && Helper.getCurrentAccount(activity).instance != null) {
alt_bld.setMessage(activity.getString(R.string.logout_account_confirmation, Helper.getCurrentAccount(activity).peertube_account.getUsername(), Helper.getCurrentAccount(activity).instance));
} else {
alt_bld.setMessage(activity.getString(R.string.logout_account_confirmation, "", ""));
}
@ -677,14 +676,14 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
if (intent != null && intent.getExtras() != null) {
Bundle args = intent.getExtras();
long bundleId = args.getLong(Helper.ARG_INTENT_ID, -1);
new CachedBundle(activity).getBundle(bundleId, currentAccount, bundle -> {
new CachedBundle(activity).getBundle(bundleId, Helper.getCurrentAccount(activity), bundle -> {
app.fedilab.android.mastodon.client.entities.api.Account account = (app.fedilab.android.mastodon.client.entities.api.Account) bundle.getSerializable(Helper.INTENT_TARGETED_ACCOUNT);
Status status = (Status) bundle.getSerializable(Helper.INTENT_TARGETED_STATUS);
if (account != null) {
Intent intentAccount = new Intent(activity, ProfileActivity.class);
Bundle args2 = new Bundle();
args2.putSerializable(Helper.ARG_ACCOUNT, account);
new CachedBundle(activity).insertBundle(args2, currentAccount, bundleId2 -> {
new CachedBundle(activity).insertBundle(args2, Helper.getCurrentAccount(activity), bundleId2 -> {
Bundle bundleCached = new Bundle();
bundleCached.putLong(Helper.ARG_INTENT_ID, bundleId2);
intentAccount.putExtras(bundleCached);
@ -695,7 +694,7 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
Intent intentContext = new Intent(activity, ContextActivity.class);
Bundle args2 = new Bundle();
args2.putSerializable(Helper.ARG_STATUS, status);
new CachedBundle(activity).insertBundle(args2, currentAccount, bundleId2 -> {
new CachedBundle(activity).insertBundle(args2, Helper.getCurrentAccount(activity), bundleId2 -> {
Bundle bundleCached = new Bundle();
bundleCached.putLong(Helper.ARG_INTENT_ID, bundleId2);
intentContext.putExtras(bundleCached);
@ -731,7 +730,7 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
args.putBoolean(ARG_REFRESH_NOTFICATION, true);
Intent intentBC = new Intent(Helper.RECEIVE_STATUS_ACTION);
intentBC.setPackage(BuildConfig.APPLICATION_ID);
new CachedBundle(activity).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(activity).insertBundle(args, Helper.getCurrentAccount(activity), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intentBC.putExtras(bundle);
@ -808,14 +807,14 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
} else if (extras.getInt(Helper.INTENT_ACTION) == Helper.OPEN_NOTIFICATION) {
openNotifications(activity, intent);
} else if (extras.getInt(Helper.INTENT_ACTION) == Helper.OPEN_WITH_ANOTHER_ACCOUNT) {
CrossActionHelper.fetchRemoteStatus(activity, MainActivity.currentAccount, urlOfMessage, new CrossActionHelper.Callback() {
CrossActionHelper.fetchRemoteStatus(activity, Helper.getCurrentAccount(activity), urlOfMessage, new CrossActionHelper.Callback() {
@Override
public void federatedStatus(Status status) {
if (status != null) {
Intent intent = new Intent(activity, ContextActivity.class);
Bundle args = new Bundle();
args.putSerializable(Helper.ARG_STATUS, status);
new CachedBundle(activity).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(activity).insertBundle(args, Helper.getCurrentAccount(activity), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intent.putExtras(bundle);
@ -1041,26 +1040,26 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
Matcher matcherLink;
matcherLink = link.matcher(url);
if (matcherLink.find()) {
if (currentAccount == null) {
if (Helper.getCurrentAccount(activity) == null) {
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(activity);
if (currentToken == null || currentToken.trim().isEmpty()) {
currentToken = sharedpreferences.getString(Helper.PREF_USER_TOKEN, null);
}
try {
currentAccount = new Account(activity).getConnectedAccount();
Helper.setCurrentAccount(new Account(activity).getConnectedAccount());
} catch (DBException e) {
e.printStackTrace();
}
}
if (matcherLink.group(3) != null && Objects.requireNonNull(matcherLink.group(3)).length() > 0) { //It's a toot
CrossActionHelper.fetchRemoteStatus(activity, currentAccount, url, new CrossActionHelper.Callback() {
CrossActionHelper.fetchRemoteStatus(activity, Helper.getCurrentAccount(activity), url, new CrossActionHelper.Callback() {
@Override
public void federatedStatus(Status status) {
if (status != null) {
Intent intent = new Intent(activity, ContextActivity.class);
Bundle args = new Bundle();
args.putSerializable(Helper.ARG_STATUS, status);
new CachedBundle(activity).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(activity).insertBundle(args, Helper.getCurrentAccount(activity), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intent.putExtras(bundle);
@ -1077,7 +1076,7 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
}
});
} else {//It's an account
CrossActionHelper.fetchRemoteAccount(activity, currentAccount, matcherLink.group(2) + "@" + matcherLink.group(1), new CrossActionHelper.Callback() {
CrossActionHelper.fetchRemoteAccount(activity, Helper.getCurrentAccount(activity), matcherLink.group(2) + "@" + matcherLink.group(1), new CrossActionHelper.Callback() {
@Override
public void federatedStatus(Status status) {
}
@ -1088,7 +1087,7 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
Intent intent = new Intent(activity, ProfileActivity.class);
Bundle args = new Bundle();
args.putSerializable(Helper.ARG_ACCOUNT, account);
new CachedBundle(activity).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(activity).insertBundle(args, Helper.getCurrentAccount(activity), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intent.putExtras(bundle);
@ -1148,27 +1147,26 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
permissionLauncher.launch(Manifest.permission.POST_NOTIFICATIONS);
}
NavHeaderMainBinding headerMainBinding = NavHeaderMainBinding.inflate(getLayoutInflater());
currentAccount = null;
//Update account details
new Thread(() -> {
try {
if (currentToken == null) {
currentToken = sharedpreferences.getString(PREF_USER_TOKEN, null);
}
currentAccount = new Account(BaseMainActivity.this).getConnectedAccount();
Helper.setCurrentAccount(new Account(BaseMainActivity.this).getConnectedAccount());
} catch (DBException e) {
e.printStackTrace();
}
//Apply the custom theme
if (currentAccount != null && currentInstance == null) {
currentInstance = currentAccount.instance;
currentUserID = currentAccount.user_id;
if (Helper.getCurrentAccount(BaseMainActivity.this) != null && currentInstance == null) {
currentInstance = Helper.getCurrentAccount(BaseMainActivity.this).instance;
currentUserID = Helper.getCurrentAccount(BaseMainActivity.this).user_id;
Handler mainHandler = new Handler(Looper.getMainLooper());
Runnable myRunnable = this::recreate;
mainHandler.post(myRunnable);
}
if (currentAccount != null && currentAccount.peertube_account != null) {
if (Helper.getCurrentAccount(BaseMainActivity.this) != null && Helper.getCurrentAccount(BaseMainActivity.this).peertube_account != null) {
//It is a peertube user
Intent intent = getIntent();
Intent myIntent = new Intent(this, PeertubeMainActivity.class);
@ -1189,7 +1187,7 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
return;
}
//If the attached account is null, the app will fetch remote instance to get up-to-date values
if (currentAccount != null && currentAccount.mastodon_account == null) {
if (Helper.getCurrentAccount(BaseMainActivity.this) != null && Helper.getCurrentAccount(BaseMainActivity.this).mastodon_account == null) {
OkHttpClient okHttpClient = Helper.myOkHttpClient(getApplication().getApplicationContext());
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://" + (MainActivity.currentInstance != null ? IDN.toASCII(MainActivity.currentInstance, IDN.ALLOW_UNASSIGNED) : null) + "/api/v1/")
@ -1202,7 +1200,7 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
try {
retrofit2.Response<app.fedilab.android.mastodon.client.entities.api.Account> accountResponse = accountCall.execute();
if (accountResponse.isSuccessful()) {
currentAccount.mastodon_account = accountResponse.body();
Helper.getCurrentAccount(BaseMainActivity.this).mastodon_account = accountResponse.body();
}
} catch (Exception e) {
e.printStackTrace();
@ -1211,9 +1209,9 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
}
Handler mainHandler = new Handler(Looper.getMainLooper());
Runnable myRunnable = () -> {
if (currentAccount == null || (currentAccount.mastodon_account == null && currentAccount.peertube_account == null)) {
if (Helper.getCurrentAccount(BaseMainActivity.this) == null || (Helper.getCurrentAccount(BaseMainActivity.this).mastodon_account == null && Helper.getCurrentAccount(BaseMainActivity.this).peertube_account == null)) {
//It is not, the user is redirected to the login page
if (currentAccount != null) {
if (Helper.getCurrentAccount(BaseMainActivity.this) != null) {
try {
Helper.removeAccount(BaseMainActivity.this);
} catch (DBException e) {
@ -1229,11 +1227,11 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
}
return;
}
bottomMenu = new BottomMenu(BaseMainActivity.this).hydrate(currentAccount, binding.bottomNavView);
if (currentAccount.mastodon_account.locked) {
bottomMenu = new BottomMenu(BaseMainActivity.this).hydrate(Helper.getCurrentAccount(BaseMainActivity.this), binding.bottomNavView);
if (Helper.getCurrentAccount(BaseMainActivity.this).mastodon_account.locked) {
binding.navView.getMenu().findItem(R.id.nav_follow_requests).setVisible(true);
}
if (currentAccount.admin) {
if (Helper.getCurrentAccount(BaseMainActivity.this).admin) {
binding.navView.getMenu().findItem(R.id.nav_administration).setVisible(true);
}
if (bottomMenu != null) {
@ -1280,8 +1278,8 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
});
}
currentInstance = currentAccount.instance;
currentUserID = currentAccount.user_id;
currentInstance = Helper.getCurrentAccount(BaseMainActivity.this).instance;
currentUserID = Helper.getCurrentAccount(BaseMainActivity.this).user_id;
show_boosts = sharedpreferences.getBoolean(getString(R.string.SET_SHOW_BOOSTS) + currentUserID + currentInstance, true);
show_my_messages = sharedpreferences.getBoolean(getString(R.string.SET_SHOW_MY_MESSAGES) + currentUserID + currentInstance, true);
@ -1295,22 +1293,22 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
show_art_nsfw = sharedpreferences.getBoolean(getString(R.string.SET_ART_WITH_NSFW) + currentUserID + currentInstance, false);
binding.profilePicture.setOnClickListener(v -> binding.drawerLayout.openDrawer(GravityCompat.START));
Helper.loadPP(BaseMainActivity.this, binding.profilePicture, currentAccount);
headerMainBinding.accountAcc.setText(String.format("%s@%s", currentAccount.mastodon_account.username, currentAccount.instance));
if (currentAccount.mastodon_account.display_name == null || currentAccount.mastodon_account.display_name.isEmpty()) {
currentAccount.mastodon_account.display_name = currentAccount.mastodon_account.acct;
Helper.loadPP(BaseMainActivity.this, binding.profilePicture, Helper.getCurrentAccount(BaseMainActivity.this));
headerMainBinding.accountAcc.setText(String.format("%s@%s", Helper.getCurrentAccount(BaseMainActivity.this).mastodon_account.username, Helper.getCurrentAccount(BaseMainActivity.this).instance));
if (Helper.getCurrentAccount(BaseMainActivity.this).mastodon_account.display_name == null || Helper.getCurrentAccount(BaseMainActivity.this).mastodon_account.display_name.isEmpty()) {
Helper.getCurrentAccount(BaseMainActivity.this).mastodon_account.display_name = Helper.getCurrentAccount(BaseMainActivity.this).mastodon_account.acct;
}
if (!isFinishing()) {
headerMainBinding.accountName.setText(
currentAccount.mastodon_account.getSpanDisplayNameEmoji(BaseMainActivity.this,
Helper.getCurrentAccount(BaseMainActivity.this).mastodon_account.getSpanDisplayNameEmoji(BaseMainActivity.this,
new WeakReference<>(headerMainBinding.accountName)),
TextView.BufferType.SPANNABLE);
}
float scale = sharedpreferences.getFloat(getString(R.string.SET_FONT_SCALE), 1.1f);
headerMainBinding.accountName.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18 * 1.1f / scale);
headerMainBinding.accountAcc.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18 * 1.1f / scale);
Helper.loadPP(BaseMainActivity.this, headerMainBinding.accountProfilePicture, currentAccount, false);
MastodonHelper.loadProfileMediaMastodon(BaseMainActivity.this, headerMainBinding.backgroundImage, currentAccount.mastodon_account, MastodonHelper.MediaAccountType.HEADER);
Helper.loadPP(BaseMainActivity.this, headerMainBinding.accountProfilePicture, Helper.getCurrentAccount(BaseMainActivity.this), false);
MastodonHelper.loadProfileMediaMastodon(BaseMainActivity.this, headerMainBinding.backgroundImage, Helper.getCurrentAccount(BaseMainActivity.this).mastodon_account, MastodonHelper.MediaAccountType.HEADER);
headerMainBinding.backgroundImage.setAlpha(0.5f);
/*
* Some general data are loaded when the app starts such;
@ -1351,13 +1349,13 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
new ViewModelProvider(BaseMainActivity.this).get(AccountsVM.class).getConnectedAccount(currentInstance, currentToken)
.observe(BaseMainActivity.this, mastodonAccount -> {
//Initialize static var
if (mastodonAccount != null && currentAccount != null) {
currentAccount.mastodon_account = mastodonAccount;
if (mastodonAccount != null && Helper.getCurrentAccount(BaseMainActivity.this) != null) {
Helper.setCurrentAccountMastodonAccount(BaseMainActivity.this, mastodonAccount);
displayReleaseNotesIfNeeded(BaseMainActivity.this, false);
new Thread(() -> {
try {
//Update account in db
new Account(BaseMainActivity.this).insertOrUpdate(currentAccount);
new Account(BaseMainActivity.this).insertOrUpdate(Helper.getCurrentAccount(BaseMainActivity.this));
} catch (DBException e) {
e.printStackTrace();
}
@ -1475,8 +1473,8 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
headerMainBinding.accountProfilePicture.setOnClickListener(v -> {
Intent intent = new Intent(BaseMainActivity.this, ProfileActivity.class);
Bundle args = new Bundle();
args.putSerializable(Helper.ARG_ACCOUNT, currentAccount.mastodon_account);
new CachedBundle(BaseMainActivity.this).insertBundle(args, currentAccount, bundleId -> {
args.putSerializable(Helper.ARG_ACCOUNT, Helper.getCurrentAccount(BaseMainActivity.this).mastodon_account);
new CachedBundle(BaseMainActivity.this).insertBundle(args, Helper.getCurrentAccount(BaseMainActivity.this), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intent.putExtras(bundle);

View file

@ -15,8 +15,6 @@ package app.fedilab.android.activities;
* see <http://www.gnu.org/licenses>. */
import static app.fedilab.android.BaseMainActivity.currentAccount;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
@ -123,7 +121,7 @@ public class AboutActivity extends BaseBarActivity {
Intent intent = new Intent(AboutActivity.this, ProfileActivity.class);
Bundle args = new Bundle();
args.putSerializable(Helper.ARG_ACCOUNT, account);
new CachedBundle(AboutActivity.this).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(AboutActivity.this).insertBundle(args, Helper.getCurrentAccount(AboutActivity.this), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intent.putExtras(bundle);

View file

@ -15,8 +15,6 @@ package app.fedilab.android.mastodon.activities;
* see <http://www.gnu.org/licenses>. */
import static app.fedilab.android.BaseMainActivity.currentAccount;
import android.app.Activity;
import android.graphics.PorterDuff;
import android.os.Bundle;
@ -69,7 +67,7 @@ public class AccountReportActivity extends BaseBarActivity {
Bundle args = getIntent().getExtras();
if (args != null) {
long bundleId = args.getLong(Helper.ARG_INTENT_ID, -1);
new CachedBundle(AccountReportActivity.this).getBundle(bundleId, currentAccount, this::initializeAfterBundle);
new CachedBundle(AccountReportActivity.this).getBundle(bundleId, Helper.getCurrentAccount(AccountReportActivity.this), this::initializeAfterBundle);
} else {
initializeAfterBundle(null);
}

View file

@ -54,12 +54,12 @@ import java.util.List;
import java.util.Locale;
import app.fedilab.android.R;
import app.fedilab.android.activities.MainActivity;
import app.fedilab.android.databinding.ActivityCheckHomeCachetBinding;
import app.fedilab.android.mastodon.client.entities.api.Status;
import app.fedilab.android.mastodon.client.entities.app.StatusCache;
import app.fedilab.android.mastodon.client.entities.app.TimelineCacheLogs;
import app.fedilab.android.mastodon.exception.DBException;
import app.fedilab.android.mastodon.helper.Helper;
import app.fedilab.android.mastodon.helper.ThemeHelper;
import es.dmoral.toasty.Toasty;
@ -88,7 +88,7 @@ public class CheckHomeCacheActivity extends BaseBarActivity {
if (getSupportActionBar() != null) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
if (MainActivity.currentAccount == null || MainActivity.currentAccount.mastodon_account == null) {
if (Helper.getCurrentAccount(CheckHomeCacheActivity.this) == null || Helper.getCurrentAccount(CheckHomeCacheActivity.this).mastodon_account == null) {
finish();
return;
}
@ -107,7 +107,7 @@ public class CheckHomeCacheActivity extends BaseBarActivity {
try {
if (myRange == range.ALL) {
if (statuses == null) {
statuses = new StatusCache(this).getHome(MainActivity.currentAccount);
statuses = new StatusCache(this).getHome(Helper.getCurrentAccount(CheckHomeCacheActivity.this));
sortAsc(statuses);
}
} else if (myRange == range.DAY) {
@ -247,7 +247,7 @@ public class CheckHomeCacheActivity extends BaseBarActivity {
try {
if (myRange == range.ALL) {
if (timelineCacheLogsList == null) {
timelineCacheLogsList = new TimelineCacheLogs(this).getHome(MainActivity.currentAccount);
timelineCacheLogsList = new TimelineCacheLogs(this).getHome(Helper.getCurrentAccount(CheckHomeCacheActivity.this));
}
} else if (myRange == range.DAY) {
if (timelineCacheLogsDayList == null && timelineCacheLogsList != null) {

View file

@ -15,7 +15,6 @@ package app.fedilab.android.mastodon.activities;
* see <http://www.gnu.org/licenses>. */
import static app.fedilab.android.BaseMainActivity.currentAccount;
import static app.fedilab.android.BaseMainActivity.currentInstance;
import static app.fedilab.android.BaseMainActivity.emojis;
@ -123,7 +122,7 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana
Bundle args = intent.getExtras();
if (args != null) {
long bundleId = args.getLong(Helper.ARG_INTENT_ID, -1);
new CachedBundle(ComposeActivity.this).getBundle(bundleId, currentAccount, bundle -> {
new CachedBundle(ComposeActivity.this).getBundle(bundleId, Helper.getCurrentAccount(ComposeActivity.this), bundle -> {
String imgpath = bundle.getString("imgpath");
float focusX = bundle.getFloat("focusX", -2);
float focusY = bundle.getFloat("focusY", -2);
@ -492,7 +491,7 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana
if (b != null) {
long bundleId = b.getLong(Helper.ARG_INTENT_ID, -1);
if (bundleId != -1) {
new CachedBundle(ComposeActivity.this).getBundle(bundleId, currentAccount, this::initializeAfterBundle);
new CachedBundle(ComposeActivity.this).getBundle(bundleId, Helper.getCurrentAccount(ComposeActivity.this), this::initializeAfterBundle);
} else {
initializeAfterBundle(b);
}
@ -513,7 +512,7 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana
statusMention = (Status) b.getSerializable(Helper.ARG_STATUS_MENTION);
account = (BaseAccount) b.getSerializable(Helper.ARG_ACCOUNT);
if (account == null) {
account = currentAccount;
account = Helper.getCurrentAccount(ComposeActivity.this);
}
editMessageId = b.getString(Helper.ARG_EDIT_STATUS_ID, null);
instance = b.getString(Helper.ARG_INSTANCE, null);
@ -521,8 +520,8 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana
visibility = b.getString(Helper.ARG_VISIBILITY, null);
if (visibility == null && statusReply != null) {
visibility = getVisibility(account, statusReply.visibility);
} else if (visibility == null && currentAccount != null && currentAccount.mastodon_account != null && currentAccount.mastodon_account.source != null) {
visibility = currentAccount.mastodon_account.source.privacy;
} else if (visibility == null && Helper.getCurrentAccount(ComposeActivity.this) != null && Helper.getCurrentAccount(ComposeActivity.this).mastodon_account != null && Helper.getCurrentAccount(ComposeActivity.this).mastodon_account.source != null) {
visibility = Helper.getCurrentAccount(ComposeActivity.this).mastodon_account.source.privacy;
}
mentionBooster = (Account) b.getSerializable(Helper.ARG_MENTION_BOOSTER);
accountMention = (Account) b.getSerializable(Helper.ARG_ACCOUNT_MENTION);
@ -569,7 +568,7 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana
statusDraft.statusDraftList = statuses;
}
if (account == null) {
account = currentAccount;
account = Helper.getCurrentAccount(ComposeActivity.this);
}
if (account == null) {
Toasty.error(ComposeActivity.this, getString(R.string.toast_error), Toasty.LENGTH_SHORT).show();

View file

@ -15,7 +15,6 @@ package app.fedilab.android.mastodon.activities;
* see <http://www.gnu.org/licenses>. */
import static app.fedilab.android.BaseMainActivity.currentAccount;
import static app.fedilab.android.BaseMainActivity.currentInstance;
import android.content.Intent;
@ -99,7 +98,7 @@ public class ContextActivity extends BaseActivity implements FragmentMastodonCon
Bundle args = getIntent().getExtras();
if (args != null) {
long bundleId = args.getLong(Helper.ARG_INTENT_ID, -1);
new CachedBundle(ContextActivity.this).getBundle(bundleId, currentAccount, this::initializeAfterBundle);
new CachedBundle(ContextActivity.this).getBundle(bundleId, Helper.getCurrentAccount(ContextActivity.this), this::initializeAfterBundle);
} else {
initializeAfterBundle(null);
}
@ -111,7 +110,7 @@ public class ContextActivity extends BaseActivity implements FragmentMastodonCon
remote_instance = bundle.getString(Helper.ARG_REMOTE_INSTANCE, null);
focusedStatusURI = bundle.getString(Helper.ARG_FOCUSED_STATUS_URI, null);
}
if (focusedStatus == null || currentAccount == null || currentAccount.mastodon_account == null) {
if (focusedStatus == null || Helper.getCurrentAccount(ContextActivity.this) == null || Helper.getCurrentAccount(ContextActivity.this).mastodon_account == null) {
finish();
return;
}
@ -127,8 +126,8 @@ public class ContextActivity extends BaseActivity implements FragmentMastodonCon
loadRemotelyConversation(true);
invalidateOptionsMenu();
}
if (currentAccount != null) {
MastodonHelper.loadPPMastodon(binding.profilePicture, currentAccount.mastodon_account);
if (Helper.getCurrentAccount(ContextActivity.this) != null) {
MastodonHelper.loadPPMastodon(binding.profilePicture, Helper.getCurrentAccount(ContextActivity.this).mastodon_account);
}
}
@ -159,7 +158,7 @@ public class ContextActivity extends BaseActivity implements FragmentMastodonCon
Bundle args = new Bundle();
args.putSerializable(Helper.ARG_STATUS, focusedStatus);
args.putString(Helper.ARG_REMOTE_INSTANCE, remote_instance);
new CachedBundle(ContextActivity.this).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(ContextActivity.this).insertBundle(args, Helper.getCurrentAccount(ContextActivity.this), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
FragmentMastodonContext fragmentMastodonContext = new FragmentMastodonContext();
@ -289,7 +288,7 @@ public class ContextActivity extends BaseActivity implements FragmentMastodonCon
args.putSerializable(Helper.ARG_STATUS, status);
args.putString(Helper.ARG_REMOTE_INSTANCE, finalInstance);
args.putString(Helper.ARG_FOCUSED_STATUS_URI, focusedStatusURI);
new CachedBundle(ContextActivity.this).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(ContextActivity.this).insertBundle(args, Helper.getCurrentAccount(ContextActivity.this), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
FragmentMastodonContext fragmentMastodonContext = new FragmentMastodonContext();
@ -341,7 +340,7 @@ public class ContextActivity extends BaseActivity implements FragmentMastodonCon
args.putSerializable(Helper.ARG_STATUS, status);
args.putString(Helper.ARG_FOCUSED_STATUS_URI, focusedStatusURI);
args.putString(Helper.ARG_REMOTE_INSTANCE, finalInstance);
new CachedBundle(ContextActivity.this).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(ContextActivity.this).insertBundle(args, Helper.getCurrentAccount(ContextActivity.this), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intentContext.putExtras(bundle);

View file

@ -14,7 +14,6 @@ package app.fedilab.android.mastodon.activities;
* You should have received a copy of the GNU General Public License along with Fedilab; if not,
* see <http://www.gnu.org/licenses>. */
import static app.fedilab.android.BaseMainActivity.currentAccount;
import android.content.SharedPreferences;
import android.net.Uri;
@ -77,7 +76,7 @@ public class CustomSharingActivity extends BaseBarActivity implements OnCustomSh
status = null;
if (args != null) {
long bundleId = args.getLong(Helper.ARG_INTENT_ID, -1);
new CachedBundle(CustomSharingActivity.this).getBundle(bundleId, currentAccount, this::initializeAfterBundle);
new CachedBundle(CustomSharingActivity.this).getBundle(bundleId, Helper.getCurrentAccount(CustomSharingActivity.this), this::initializeAfterBundle);
} else {
initializeAfterBundle(null);
}
@ -110,7 +109,7 @@ public class CustomSharingActivity extends BaseBarActivity implements OnCustomSh
bundle_thumbnailurl = status.account.avatar;
}
if (!bundle_creator.contains("@")) {
bundle_creator = bundle_creator + "@" + currentAccount.instance;
bundle_creator = bundle_creator + "@" + Helper.getCurrentAccount(CustomSharingActivity.this).instance;
}
binding.setCustomSharingTitle.setEllipsize(TextUtils.TruncateAt.END);

View file

@ -15,7 +15,6 @@ package app.fedilab.android.mastodon.activities;
* see <http://www.gnu.org/licenses>. */
import static app.fedilab.android.BaseMainActivity.currentAccount;
import static app.fedilab.android.mastodon.activities.ComposeActivity.PICK_MEDIA;
import android.content.ClipData;
@ -72,7 +71,7 @@ public class DirectMessageActivity extends BaseActivity implements FragmentMasto
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(this);
float scale = sharedpreferences.getFloat(getString(R.string.SET_FONT_SCALE), 1.1f);
binding.title.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18 * 1.1f / scale);
MastodonHelper.loadPPMastodon(binding.profilePicture, currentAccount.mastodon_account);
MastodonHelper.loadPPMastodon(binding.profilePicture, Helper.getCurrentAccount(DirectMessageActivity.this).mastodon_account);
if (getSupportActionBar() != null) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
@ -82,7 +81,7 @@ public class DirectMessageActivity extends BaseActivity implements FragmentMasto
if (args != null) {
long bundleId = args.getLong(Helper.ARG_INTENT_ID, -1);
new CachedBundle(DirectMessageActivity.this).getBundle(bundleId, currentAccount, this::initializeAfterBundle);
new CachedBundle(DirectMessageActivity.this).getBundle(bundleId, Helper.getCurrentAccount(DirectMessageActivity.this), this::initializeAfterBundle);
} else {
initializeAfterBundle(null);
}
@ -97,7 +96,7 @@ public class DirectMessageActivity extends BaseActivity implements FragmentMasto
remote_instance = bundle.getString(Helper.ARG_REMOTE_INSTANCE, null);
}
if (focusedStatus == null || currentAccount == null || currentAccount.mastodon_account == null) {
if (focusedStatus == null || Helper.getCurrentAccount(DirectMessageActivity.this) == null || Helper.getCurrentAccount(DirectMessageActivity.this).mastodon_account == null) {
finish();
return;
}
@ -106,7 +105,7 @@ public class DirectMessageActivity extends BaseActivity implements FragmentMasto
args.putSerializable(Helper.ARG_STATUS, focusedStatus);
args.putString(Helper.ARG_REMOTE_INSTANCE, remote_instance);
Status finalFocusedStatus = focusedStatus;
new CachedBundle(DirectMessageActivity.this).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(DirectMessageActivity.this).insertBundle(args, Helper.getCurrentAccount(DirectMessageActivity.this), bundleId -> {
Bundle args2 = new Bundle();
args2.putLong(Helper.ARG_INTENT_ID, bundleId);
FragmentMastodonDirectMessage FragmentMastodonDirectMessage = new FragmentMastodonDirectMessage();

View file

@ -14,7 +14,6 @@ package app.fedilab.android.mastodon.activities;
* You should have received a copy of the GNU General Public License along with Fedilab; if not,
* see <http://www.gnu.org/licenses>. */
import static app.fedilab.android.BaseMainActivity.currentAccount;
import android.content.SharedPreferences;
import android.os.Bundle;
@ -45,6 +44,7 @@ import app.fedilab.android.mastodon.client.entities.api.Attachment;
import app.fedilab.android.mastodon.client.entities.api.Status;
import app.fedilab.android.mastodon.client.entities.app.StatusDraft;
import app.fedilab.android.mastodon.exception.DBException;
import app.fedilab.android.mastodon.helper.Helper;
import app.fedilab.android.mastodon.ui.drawer.StatusDraftAdapter;
import app.fedilab.android.mastodon.viewmodel.mastodon.TimelinesVM;
@ -82,7 +82,7 @@ public class DraftActivity extends BaseActivity implements StatusDraftAdapter.Dr
getSupportActionBar().setDisplayShowHomeEnabled(true);
}
timelinesVM = new ViewModelProvider(DraftActivity.this).get(TimelinesVM.class);
timelinesVM.getDrafts(currentAccount)
timelinesVM.getDrafts(Helper.getCurrentAccount(DraftActivity.this))
.observe(DraftActivity.this, this::initializeDraftView);
}
@ -178,7 +178,7 @@ public class DraftActivity extends BaseActivity implements StatusDraftAdapter.Dr
super.onResume();
//We need to check if drafts changed (ie when coming back from the compose activity)
if (statusDrafts != null && timelinesVM != null) {
timelinesVM.getDrafts(currentAccount)
timelinesVM.getDrafts(Helper.getCurrentAccount(DraftActivity.this))
.observe(DraftActivity.this, this::updateDrafts);
}
}

View file

@ -14,7 +14,7 @@ package app.fedilab.android.mastodon.activities;
* You should have received a copy of the GNU General Public License along with Fedilab; if not,
* see <http://www.gnu.org/licenses>. */
import static app.fedilab.android.BaseMainActivity.currentAccount;
import static app.fedilab.android.BaseMainActivity.instanceInfo;
import android.annotation.SuppressLint;
@ -91,7 +91,7 @@ public class EditProfileActivity extends BaseBarActivity {
new ViewModelProvider(EditProfileActivity.this).get(AccountsVM.class).getConnectedAccount(BaseMainActivity.currentInstance, BaseMainActivity.currentToken)
.observe(EditProfileActivity.this, account -> {
if (account != null) {
currentAccount.mastodon_account = account;
Helper.setCurrentAccountMastodonAccount(EditProfileActivity.this, account);
initializeView();
} else {
Helper.sendToastMessage(getApplication(), Helper.RECEIVE_TOAST_TYPE_ERROR, getString(R.string.toast_error));
@ -103,19 +103,19 @@ public class EditProfileActivity extends BaseBarActivity {
@SuppressWarnings("deprecation")
private void initializeView() {
//Hydrate values
MastodonHelper.loadProfileMediaMastodon(EditProfileActivity.this, binding.bannerPp, currentAccount.mastodon_account, MastodonHelper.MediaAccountType.HEADER);
MastodonHelper.loadPPMastodon(binding.accountPp, currentAccount.mastodon_account);
binding.displayName.setText(currentAccount.mastodon_account.display_name);
binding.acct.setText(String.format(Locale.getDefault(), "%s@%s", currentAccount.mastodon_account.acct, BaseMainActivity.currentInstance));
MastodonHelper.loadProfileMediaMastodon(EditProfileActivity.this, binding.bannerPp, Helper.getCurrentAccount(EditProfileActivity.this).mastodon_account, MastodonHelper.MediaAccountType.HEADER);
MastodonHelper.loadPPMastodon(binding.accountPp, Helper.getCurrentAccount(EditProfileActivity.this).mastodon_account);
binding.displayName.setText(Helper.getCurrentAccount(EditProfileActivity.this).mastodon_account.display_name);
binding.acct.setText(String.format(Locale.getDefault(), "%s@%s", Helper.getCurrentAccount(EditProfileActivity.this).mastodon_account.acct, BaseMainActivity.currentInstance));
String bio;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
bio = Html.fromHtml(currentAccount.mastodon_account.note, Html.FROM_HTML_MODE_LEGACY).toString();
bio = Html.fromHtml(Helper.getCurrentAccount(EditProfileActivity.this).mastodon_account.note, Html.FROM_HTML_MODE_LEGACY).toString();
else
bio = Html.fromHtml(currentAccount.mastodon_account.note).toString();
bio = Html.fromHtml(Helper.getCurrentAccount(EditProfileActivity.this).mastodon_account.note).toString();
binding.bio.setText(bio);
if (currentAccount.mastodon_account.source != null) {
binding.sensitive.setChecked(currentAccount.mastodon_account.source.sensitive);
switch (currentAccount.mastodon_account.source.privacy) {
if (Helper.getCurrentAccount(EditProfileActivity.this).mastodon_account.source != null) {
binding.sensitive.setChecked(Helper.getCurrentAccount(EditProfileActivity.this).mastodon_account.source.sensitive);
switch (Helper.getCurrentAccount(EditProfileActivity.this).mastodon_account.source.privacy) {
case "public" -> binding.visibilityPublic.setChecked(true);
case "unlisted" -> binding.visibilityUnlisted.setChecked(true);
case "private" -> binding.visibilityPrivate.setChecked(true);
@ -126,15 +126,15 @@ public class EditProfileActivity extends BaseBarActivity {
binding.visibilityGroup.setVisibility(View.GONE);
}
binding.bot.setChecked(currentAccount.mastodon_account.bot);
binding.discoverable.setChecked(currentAccount.mastodon_account.discoverable);
binding.bot.setChecked(Helper.getCurrentAccount(EditProfileActivity.this).mastodon_account.bot);
binding.discoverable.setChecked(Helper.getCurrentAccount(EditProfileActivity.this).mastodon_account.discoverable);
if (currentAccount.mastodon_account.locked) {
if (Helper.getCurrentAccount(EditProfileActivity.this).mastodon_account.locked) {
binding.locked.setChecked(true);
} else {
binding.unlocked.setChecked(true);
}
List<Field> fields = currentAccount.mastodon_account.fields;
List<Field> fields = Helper.getCurrentAccount(EditProfileActivity.this).mastodon_account.fields;
if (fields != null && fields.size() > 0) {
for (Field field : fields) {
AccountFieldItemBinding fieldItemBinding = AccountFieldItemBinding.inflate(getLayoutInflater());
@ -214,11 +214,11 @@ public class EditProfileActivity extends BaseBarActivity {
if (account != null) {
sendBroadCast(account);
binding.avatarProgress.setVisibility(View.GONE);
currentAccount.mastodon_account = account;
Helper.setCurrentAccountMastodonAccount(EditProfileActivity.this, account);
Helper.recreateMainActivity(EditProfileActivity.this);
new Thread(() -> {
try {
new app.fedilab.android.mastodon.client.entities.app.Account(EditProfileActivity.this).insertOrUpdate(currentAccount);
new app.fedilab.android.mastodon.client.entities.app.Account(EditProfileActivity.this).insertOrUpdate(Helper.getCurrentAccount(EditProfileActivity.this));
} catch (DBException e) {
e.printStackTrace();
}
@ -242,10 +242,10 @@ public class EditProfileActivity extends BaseBarActivity {
if (account != null) {
sendBroadCast(account);
binding.headerProgress.setVisibility(View.GONE);
currentAccount.mastodon_account = account;
Helper.setCurrentAccountMastodonAccount(EditProfileActivity.this, account);
new Thread(() -> {
try {
new app.fedilab.android.mastodon.client.entities.app.Account(EditProfileActivity.this).insertOrUpdate(currentAccount);
new app.fedilab.android.mastodon.client.entities.app.Account(EditProfileActivity.this).insertOrUpdate(Helper.getCurrentAccount(EditProfileActivity.this));
} catch (DBException e) {
e.printStackTrace();
}
@ -262,7 +262,7 @@ public class EditProfileActivity extends BaseBarActivity {
Bundle args = new Bundle();
args.putBoolean(Helper.RECEIVE_REDRAW_PROFILE, true);
args.putSerializable(Helper.ARG_ACCOUNT, account);
new CachedBundle(EditProfileActivity.this).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(EditProfileActivity.this).insertBundle(args, Helper.getCurrentAccount(EditProfileActivity.this), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
Intent intentBD = new Intent(Helper.BROADCAST_DATA);
@ -342,10 +342,10 @@ public class EditProfileActivity extends BaseBarActivity {
)
.observe(EditProfileActivity.this, account -> {
if (account != null) {
currentAccount.mastodon_account = account;
Helper.setCurrentAccountMastodonAccount(EditProfileActivity.this, account);
new Thread(() -> {
try {
new app.fedilab.android.mastodon.client.entities.app.Account(EditProfileActivity.this).insertOrUpdate(currentAccount);
new app.fedilab.android.mastodon.client.entities.app.Account(EditProfileActivity.this).insertOrUpdate(Helper.getCurrentAccount(EditProfileActivity.this));
sendBroadCast(account);
} catch (DBException e) {
e.printStackTrace();

View file

@ -15,8 +15,6 @@ package app.fedilab.android.mastodon.activities;
* see <http://www.gnu.org/licenses>. */
import static app.fedilab.android.BaseMainActivity.currentAccount;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
@ -81,7 +79,7 @@ public class HashTagActivity extends BaseActivity {
Bundle args = getIntent().getExtras();
if (args != null) {
long bundleId = args.getLong(Helper.ARG_INTENT_ID, -1);
new CachedBundle(HashTagActivity.this).getBundle(bundleId, currentAccount, this::initializeAfterBundle);
new CachedBundle(HashTagActivity.this).getBundle(bundleId, Helper.getCurrentAccount(HashTagActivity.this), this::initializeAfterBundle);
} else {
initializeAfterBundle(null);
}
@ -172,7 +170,7 @@ public class HashTagActivity extends BaseActivity {
statusDraft.statusDraftList = statuses;
Bundle args = new Bundle();
args.putSerializable(Helper.ARG_STATUS_DRAFT, statusDraft);
new CachedBundle(HashTagActivity.this).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(HashTagActivity.this).insertBundle(args, Helper.getCurrentAccount(HashTagActivity.this), bundleId -> {
Bundle bundleCached = new Bundle();
bundleCached.putLong(Helper.ARG_INTENT_ID, bundleId);
intentToot.putExtras(bundleCached);
@ -207,7 +205,7 @@ public class HashTagActivity extends BaseActivity {
Bundle args = new Bundle();
args.putBoolean(Helper.RECEIVE_REDRAW_TOPBAR, true);
Intent intentBD = new Intent(Helper.BROADCAST_DATA);
new CachedBundle(HashTagActivity.this).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(HashTagActivity.this).insertBundle(args, Helper.getCurrentAccount(HashTagActivity.this), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intentBD.putExtras(bundle);
@ -221,7 +219,7 @@ public class HashTagActivity extends BaseActivity {
} else {
new Thread(() -> {
try {
Pinned pinned = new Pinned(HashTagActivity.this).getPinned(currentAccount);
Pinned pinned = new Pinned(HashTagActivity.this).getPinned(Helper.getCurrentAccount(HashTagActivity.this));
boolean canBeAdded = true;
boolean update = true;
if (pinned == null) {
@ -267,7 +265,7 @@ public class HashTagActivity extends BaseActivity {
Bundle args = new Bundle();
args.putBoolean(Helper.RECEIVE_REDRAW_TOPBAR, true);
Intent intentBD = new Intent(Helper.BROADCAST_DATA);
new CachedBundle(HashTagActivity.this).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(HashTagActivity.this).insertBundle(args, Helper.getCurrentAccount(HashTagActivity.this), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intentBD.putExtras(bundle);

View file

@ -15,8 +15,6 @@ package app.fedilab.android.mastodon.activities;
* see <http://www.gnu.org/licenses>. */
import static app.fedilab.android.BaseMainActivity.currentAccount;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
@ -177,7 +175,7 @@ public class MastodonListActivity extends BaseBarActivity implements MastodonLis
timelinesVM.getAccountsInList(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, mastodonList.id, null, null, 0)
.observe(MastodonListActivity.this, accounts -> {
if (accounts != null && accounts.size() > 0) {
accountsVM.muteAccountsHome(currentAccount, accounts);
accountsVM.muteAccountsHome(Helper.getCurrentAccount(MastodonListActivity.this), accounts);
}
});
dialog.dismiss();
@ -313,7 +311,7 @@ public class MastodonListActivity extends BaseBarActivity implements MastodonLis
args.putBoolean(Helper.RECEIVE_REDRAW_TOPBAR, true);
Intent intentBD = new Intent(Helper.BROADCAST_DATA);
args.putSerializable(Helper.RECEIVE_MASTODON_LIST, mastodonListList);
new CachedBundle(MastodonListActivity.this).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(MastodonListActivity.this).insertBundle(args, Helper.getCurrentAccount(MastodonListActivity.this), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intentBD.putExtras(bundle);
@ -353,7 +351,7 @@ public class MastodonListActivity extends BaseBarActivity implements MastodonLis
args.putBoolean(Helper.RECEIVE_REDRAW_TOPBAR, true);
Intent intentBD = new Intent(Helper.BROADCAST_DATA);
args.putSerializable(Helper.RECEIVE_MASTODON_LIST, mastodonListList);
new CachedBundle(MastodonListActivity.this).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(MastodonListActivity.this).insertBundle(args, Helper.getCurrentAccount(MastodonListActivity.this), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intentBD.putExtras(bundle);
@ -405,7 +403,7 @@ public class MastodonListActivity extends BaseBarActivity implements MastodonLis
Bundle args = new Bundle();
args.putBoolean(Helper.RECEIVE_REDRAW_TOPBAR, true);
Intent intentBD = new Intent(Helper.BROADCAST_DATA);
new CachedBundle(MastodonListActivity.this).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(MastodonListActivity.this).insertBundle(args, Helper.getCurrentAccount(MastodonListActivity.this), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intentBD.putExtras(bundle);

View file

@ -15,7 +15,6 @@ package app.fedilab.android.mastodon.activities;
* see <http://www.gnu.org/licenses>. */
import static android.util.Patterns.WEB_URL;
import static app.fedilab.android.BaseMainActivity.currentAccount;
import android.Manifest;
import android.app.DownloadManager;
@ -129,7 +128,7 @@ public class MediaActivity extends BaseTransparentActivity implements OnDownload
Bundle args = getIntent().getExtras();
if (args != null) {
long bundleId = args.getLong(Helper.ARG_INTENT_ID, -1);
new CachedBundle(MediaActivity.this).getBundle(bundleId, currentAccount, this::initializeAfterBundle);
new CachedBundle(MediaActivity.this).getBundle(bundleId, Helper.getCurrentAccount(MediaActivity.this), this::initializeAfterBundle);
} else {
initializeAfterBundle(null);
}
@ -173,7 +172,7 @@ public class MediaActivity extends BaseTransparentActivity implements OnDownload
Intent intentContext = new Intent(MediaActivity.this, ContextActivity.class);
Bundle args = new Bundle();
args.putSerializable(Helper.ARG_STATUS, attachments.get(mediaPosition - 1).status);
new CachedBundle(MediaActivity.this).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(MediaActivity.this).insertBundle(args, Helper.getCurrentAccount(MediaActivity.this), bundleId -> {
Bundle bundleCached = new Bundle();
bundleCached.putLong(Helper.ARG_INTENT_ID, bundleId);
intentContext.putExtras(bundleCached);

View file

@ -15,8 +15,6 @@ package app.fedilab.android.mastodon.activities;
* see <http://www.gnu.org/licenses>. */
import static app.fedilab.android.BaseMainActivity.currentAccount;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
@ -82,7 +80,7 @@ public class PartnerShipActivity extends BaseBarActivity {
Intent intent = new Intent(PartnerShipActivity.this, ProfileActivity.class);
Bundle args = new Bundle();
args.putSerializable(Helper.ARG_ACCOUNT, account);
new CachedBundle(PartnerShipActivity.this).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(PartnerShipActivity.this).insertBundle(args, Helper.getCurrentAccount(PartnerShipActivity.this), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intent.putExtras(bundle);

View file

@ -15,8 +15,6 @@ package app.fedilab.android.mastodon.activities;
* see <http://www.gnu.org/licenses>. */
import static app.fedilab.android.BaseMainActivity.currentAccount;
import android.content.BroadcastReceiver;
import android.content.ClipData;
import android.content.ClipboardManager;
@ -135,7 +133,7 @@ public class ProfileActivity extends BaseActivity {
Bundle args = intent.getExtras();
if (args != null) {
long bundleId = args.getLong(Helper.ARG_INTENT_ID, -1);
new CachedBundle(ProfileActivity.this).getBundle(bundleId, currentAccount, bundle -> {
new CachedBundle(ProfileActivity.this).getBundle(bundleId, Helper.getCurrentAccount(ProfileActivity.this), bundle -> {
Account accountReceived = (Account) bundle.getSerializable(Helper.ARG_ACCOUNT);
if (bundle.getBoolean(Helper.RECEIVE_REDRAW_PROFILE, false) && accountReceived != null) {
if (account != null && accountReceived.id != null && account.id != null && accountReceived.id.equalsIgnoreCase(account.id)) {
@ -180,7 +178,7 @@ public class ProfileActivity extends BaseActivity {
homeMuted = false;
if (args != null) {
long bundleId = args.getLong(Helper.ARG_INTENT_ID, -1);
new CachedBundle(ProfileActivity.this).getBundle(bundleId, currentAccount, this::initializeAfterBundle);
new CachedBundle(ProfileActivity.this).getBundle(bundleId, Helper.getCurrentAccount(ProfileActivity.this), this::initializeAfterBundle);
} else {
initializeAfterBundle(null);
}
@ -215,7 +213,7 @@ public class ProfileActivity extends BaseActivity {
finish();
}
//Check if account is homeMuted
accountsVM.isMuted(currentAccount, account).observe(this, result -> homeMuted = result != null && result);
accountsVM.isMuted(Helper.getCurrentAccount(ProfileActivity.this), account).observe(this, result -> homeMuted = result != null && result);
ContextCompat.registerReceiver(ProfileActivity.this, broadcast_data, new IntentFilter(Helper.BROADCAST_DATA), ContextCompat.RECEIVER_NOT_EXPORTED);
@ -458,7 +456,7 @@ public class ProfileActivity extends BaseActivity {
Bundle args = new Bundle();
args.putSerializable(Helper.ARG_ACCOUNT, account);
args.putSerializable(Helper.ARG_CHECK_REMOTELY, true);
new CachedBundle(ProfileActivity.this).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(ProfileActivity.this).insertBundle(args, Helper.getCurrentAccount(ProfileActivity.this), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intent.putExtras(bundle);
@ -511,7 +509,7 @@ public class ProfileActivity extends BaseActivity {
attachments.add(attachment);
args.putSerializable(Helper.ARG_MEDIA_ARRAY, attachments);
args.putInt(Helper.ARG_MEDIA_POSITION, 1);
new CachedBundle(ProfileActivity.this).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(ProfileActivity.this).insertBundle(args, Helper.getCurrentAccount(ProfileActivity.this), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intent.putExtras(bundle);
@ -535,7 +533,7 @@ public class ProfileActivity extends BaseActivity {
attachments.add(attachment);
args.putSerializable(Helper.ARG_MEDIA_ARRAY, attachments);
args.putInt(Helper.ARG_MEDIA_POSITION, 1);
new CachedBundle(ProfileActivity.this).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(ProfileActivity.this).insertBundle(args, Helper.getCurrentAccount(ProfileActivity.this), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intent.putExtras(bundle);
@ -636,7 +634,7 @@ public class ProfileActivity extends BaseActivity {
* This methode is called to update the view once an action has been performed
*/
private void updateAccount() {
if (currentAccount == null || account == null) {
if (Helper.getCurrentAccount(ProfileActivity.this) == null || account == null) {
return;
}
@ -673,7 +671,7 @@ public class ProfileActivity extends BaseActivity {
Intent intent = new Intent(ProfileActivity.this, ProfileActivity.class);
Bundle args = new Bundle();
args.putSerializable(Helper.ARG_ACCOUNT, account);
new CachedBundle(ProfileActivity.this).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(ProfileActivity.this).insertBundle(args, Helper.getCurrentAccount(ProfileActivity.this), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intent.putExtras(bundle);
@ -736,7 +734,7 @@ public class ProfileActivity extends BaseActivity {
//The value for account is from same server so id can be used
if (account.id.equals(currentAccount.user_id)) {
if (account.id.equals(Helper.getCurrentAccount(ProfileActivity.this).user_id)) {
binding.accountFollow.setVisibility(View.GONE);
binding.headerEditProfile.setVisibility(View.VISIBLE);
binding.headerEditProfile.bringToFront();
@ -948,7 +946,7 @@ public class ProfileActivity extends BaseActivity {
Bundle args = new Bundle();
args.putBoolean(Helper.RECEIVE_REDRAW_TOPBAR, true);
Intent intentBD = new Intent(Helper.BROADCAST_DATA);
new CachedBundle(ProfileActivity.this).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(ProfileActivity.this).insertBundle(args, Helper.getCurrentAccount(ProfileActivity.this), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intentBD.putExtras(bundle);
@ -1077,7 +1075,7 @@ public class ProfileActivity extends BaseActivity {
Bundle args = new Bundle();
args.putSerializable(Helper.ARG_ACCOUNT_MENTION, account);
args.putString(Helper.ARG_VISIBILITY, "direct");
new CachedBundle(ProfileActivity.this).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(ProfileActivity.this).insertBundle(args, Helper.getCurrentAccount(ProfileActivity.this), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intent.putExtras(bundle);
@ -1168,7 +1166,7 @@ public class ProfileActivity extends BaseActivity {
intent = new Intent(ProfileActivity.this, ComposeActivity.class);
Bundle args = new Bundle();
args.putSerializable(Helper.ARG_ACCOUNT_MENTION, account);
new CachedBundle(ProfileActivity.this).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(ProfileActivity.this).insertBundle(args, Helper.getCurrentAccount(ProfileActivity.this), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intent.putExtras(bundle);
@ -1217,7 +1215,7 @@ public class ProfileActivity extends BaseActivity {
builderInner.setNeutralButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
if (homeMuted) {
builderInner.setTitle(R.string.unmute_home);
builderInner.setPositiveButton(R.string.action_unmute, (dialog, which) -> accountsVM.unmuteHome(currentAccount, account)
builderInner.setPositiveButton(R.string.action_unmute, (dialog, which) -> accountsVM.unmuteHome(Helper.getCurrentAccount(ProfileActivity.this), account)
.observe(ProfileActivity.this, account -> {
homeMuted = false;
invalidateOptionsMenu();
@ -1225,7 +1223,7 @@ public class ProfileActivity extends BaseActivity {
}));
} else {
builderInner.setTitle(R.string.mute_home);
builderInner.setPositiveButton(R.string.action_mute, (dialog, which) -> accountsVM.muteHome(currentAccount, account)
builderInner.setPositiveButton(R.string.action_mute, (dialog, which) -> accountsVM.muteHome(Helper.getCurrentAccount(ProfileActivity.this), account)
.observe(ProfileActivity.this, account -> {
homeMuted = true;
invalidateOptionsMenu();

View file

@ -15,8 +15,6 @@ package app.fedilab.android.mastodon.activities;
* see <http://www.gnu.org/licenses>. */
import static app.fedilab.android.BaseMainActivity.currentAccount;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
@ -290,7 +288,7 @@ public class ReorderTimelinesActivity extends BaseBarActivity implements OnStart
Bundle args = new Bundle();
args.putBoolean(Helper.RECEIVE_REDRAW_TOPBAR, true);
Intent intentBD = new Intent(Helper.BROADCAST_DATA);
new CachedBundle(ReorderTimelinesActivity.this).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(ReorderTimelinesActivity.this).insertBundle(args, Helper.getCurrentAccount(ReorderTimelinesActivity.this), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intentBD.putExtras(bundle);
@ -383,7 +381,7 @@ public class ReorderTimelinesActivity extends BaseBarActivity implements OnStart
Bundle args = new Bundle();
args.putBoolean(Helper.RECEIVE_REDRAW_TOPBAR, true);
Intent intentBD = new Intent(Helper.BROADCAST_DATA);
new CachedBundle(ReorderTimelinesActivity.this).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(ReorderTimelinesActivity.this).insertBundle(args, Helper.getCurrentAccount(ReorderTimelinesActivity.this), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intentBD.putExtras(bundle);
@ -396,7 +394,7 @@ public class ReorderTimelinesActivity extends BaseBarActivity implements OnStart
Bundle args = new Bundle();
args.putBoolean(Helper.RECEIVE_REDRAW_BOTTOM, true);
Intent intentBD = new Intent(Helper.BROADCAST_DATA);
new CachedBundle(ReorderTimelinesActivity.this).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(ReorderTimelinesActivity.this).insertBundle(args, Helper.getCurrentAccount(ReorderTimelinesActivity.this), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intentBD.putExtras(bundle);

View file

@ -14,7 +14,6 @@ package app.fedilab.android.mastodon.activities;
* You should have received a copy of the GNU General Public License along with Fedilab; if not,
* see <http://www.gnu.org/licenses>. */
import static app.fedilab.android.BaseMainActivity.currentAccount;
import android.os.Bundle;
import android.view.MenuItem;
@ -77,7 +76,7 @@ public class ReportActivity extends BaseBarActivity {
if (args != null) {
long bundleId = args.getLong(Helper.ARG_INTENT_ID, -1);
if (bundleId != -1) {
new CachedBundle(ReportActivity.this).getBundle(bundleId, currentAccount, this::initializeAfterBundle);
new CachedBundle(ReportActivity.this).getBundle(bundleId, Helper.getCurrentAccount(ReportActivity.this), this::initializeAfterBundle);
} else {
initializeAfterBundle(args);
}
@ -243,7 +242,7 @@ public class ReportActivity extends BaseBarActivity {
status.isChecked = true;
args.putSerializable(Helper.ARG_STATUS_REPORT, status);
}
new CachedBundle(ReportActivity.this).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(ReportActivity.this).insertBundle(args, Helper.getCurrentAccount(ReportActivity.this), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
fragment.setArguments(bundle);
@ -273,7 +272,7 @@ public class ReportActivity extends BaseBarActivity {
status.isChecked = true;
args.putSerializable(Helper.ARG_STATUS_REPORT, status);
}
new CachedBundle(ReportActivity.this).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(ReportActivity.this).insertBundle(args, Helper.getCurrentAccount(ReportActivity.this), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
fragment.setArguments(bundle);

View file

@ -14,7 +14,6 @@ package app.fedilab.android.mastodon.activities;
* You should have received a copy of the GNU General Public License along with Fedilab; if not,
* see <http://www.gnu.org/licenses>. */
import static app.fedilab.android.BaseMainActivity.currentAccount;
import android.content.SharedPreferences;
import android.os.Bundle;
@ -29,6 +28,7 @@ import com.google.android.material.tabs.TabLayout;
import app.fedilab.android.R;
import app.fedilab.android.databinding.ActivityScheduledBinding;
import app.fedilab.android.mastodon.helper.Helper;
import app.fedilab.android.mastodon.helper.MastodonHelper;
import app.fedilab.android.mastodon.ui.pageadapter.FedilabScheduledPageAdapter;
@ -55,7 +55,7 @@ public class ScheduledActivity extends BaseActivity {
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(this);
float scale = sharedpreferences.getFloat(getString(R.string.SET_FONT_SCALE), 1.1f);
binding.title.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18 * 1.1f / scale);
MastodonHelper.loadPPMastodon(binding.profilePicture, currentAccount.mastodon_account);
MastodonHelper.loadPPMastodon(binding.profilePicture, Helper.getCurrentAccount(ScheduledActivity.this).mastodon_account);
binding.title.setText(R.string.scheduled);
binding.scheduleTablayout.addTab(binding.scheduleTablayout.newTab().setText(getString(R.string.toots_server)));
binding.scheduleTablayout.addTab(binding.scheduleTablayout.newTab().setText(getString(R.string.toots_client)));

View file

@ -15,7 +15,6 @@ package app.fedilab.android.mastodon.activities;
* see <http://www.gnu.org/licenses>. */
import static app.fedilab.android.BaseMainActivity.currentAccount;
import static app.fedilab.android.BaseMainActivity.currentInstance;
import static app.fedilab.android.BaseMainActivity.currentToken;
@ -75,7 +74,7 @@ public class StatusInfoActivity extends BaseActivity {
Bundle args = getIntent().getExtras();
if (args != null) {
long bundleId = args.getLong(Helper.ARG_INTENT_ID, -1);
new CachedBundle(StatusInfoActivity.this).getBundle(bundleId, currentAccount, this::initializeAfterBundle);
new CachedBundle(StatusInfoActivity.this).getBundle(bundleId, Helper.getCurrentAccount(StatusInfoActivity.this), this::initializeAfterBundle);
} else {
initializeAfterBundle(null);
}

View file

@ -14,7 +14,6 @@ package app.fedilab.android.mastodon.activities;
* You should have received a copy of the GNU General Public License along with Fedilab; if not,
* see <http://www.gnu.org/licenses>. */
import static app.fedilab.android.BaseMainActivity.currentAccount;
import android.os.Bundle;
import android.view.MenuItem;
@ -48,7 +47,7 @@ public class TimelineActivity extends BaseBarActivity {
Bundle args = getIntent().getExtras();
if (args != null) {
long bundleId = args.getLong(Helper.ARG_INTENT_ID, -1);
new CachedBundle(TimelineActivity.this).getBundle(bundleId, currentAccount, this::initializeAfterBundle);
new CachedBundle(TimelineActivity.this).getBundle(bundleId, Helper.getCurrentAccount(TimelineActivity.this), this::initializeAfterBundle);
} else {
initializeAfterBundle(null);
}
@ -76,7 +75,7 @@ public class TimelineActivity extends BaseBarActivity {
if (status != null) {
args.putSerializable(Helper.ARG_STATUS, status);
}
new CachedBundle(TimelineActivity.this).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(TimelineActivity.this).insertBundle(args, Helper.getCurrentAccount(TimelineActivity.this), bundleId -> {
Bundle bundle1 = new Bundle();
bundle1.putLong(Helper.ARG_INTENT_ID, bundleId);
fragmentMastodonTimeline.setArguments(bundle1);

View file

@ -15,8 +15,6 @@ package app.fedilab.android.mastodon.activities.admin;
* see <http://www.gnu.org/licenses>. */
import static app.fedilab.android.BaseMainActivity.currentAccount;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Intent;
@ -101,7 +99,7 @@ public class AdminAccountActivity extends BaseActivity {
if (args != null) {
long bundleId = args.getLong(Helper.ARG_INTENT_ID, -1);
new CachedBundle(AdminAccountActivity.this).getBundle(bundleId, currentAccount, this::initializeAfterBundle);
new CachedBundle(AdminAccountActivity.this).getBundle(bundleId, Helper.getCurrentAccount(AdminAccountActivity.this), this::initializeAfterBundle);
} else {
initializeAfterBundle(null);
}
@ -355,7 +353,7 @@ public class AdminAccountActivity extends BaseActivity {
attachments.add(attachment);
args.putSerializable(Helper.ARG_MEDIA_ARRAY, attachments);
args.putInt(Helper.ARG_MEDIA_POSITION, 1);
new CachedBundle(AdminAccountActivity.this).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(AdminAccountActivity.this).insertBundle(args, Helper.getCurrentAccount(AdminAccountActivity.this), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intent.putExtras(bundle);

View file

@ -14,7 +14,7 @@ package app.fedilab.android.mastodon.activities.admin;
* You should have received a copy of the GNU General Public License along with Fedilab; if not,
* see <http://www.gnu.org/licenses>. */
import static app.fedilab.android.BaseMainActivity.currentAccount;
import static app.fedilab.android.mastodon.activities.admin.AdminActionActivity.AdminEnum.ACCOUNT;
import static app.fedilab.android.mastodon.activities.admin.AdminActionActivity.AdminEnum.DOMAIN;
import static app.fedilab.android.mastodon.activities.admin.AdminActionActivity.AdminEnum.REPORT;
@ -68,7 +68,7 @@ public class AdminActionActivity extends BaseBarActivity {
Bundle args = intent.getExtras();
if (args != null) {
long bundleId = args.getLong(Helper.ARG_INTENT_ID, -1);
new CachedBundle(AdminActionActivity.this).getBundle(bundleId, currentAccount, bundle -> {
new CachedBundle(AdminActionActivity.this).getBundle(bundleId, Helper.getCurrentAccount(AdminActionActivity.this), bundle -> {
AdminDomainBlock adminDomainBlock = (AdminDomainBlock) bundle.getSerializable(Helper.ARG_ADMIN_DOMAINBLOCK);
AdminDomainBlock adminDomainBlockDelete = (AdminDomainBlock) bundle.getSerializable(Helper.ARG_ADMIN_DOMAINBLOCK_DELETE);
if (adminDomainBlock != null && adminDomainBlock.domain != null && fragmentAdminDomain != null) {

View file

@ -15,8 +15,6 @@ package app.fedilab.android.mastodon.activities.admin;
* see <http://www.gnu.org/licenses>. */
import static app.fedilab.android.BaseMainActivity.currentAccount;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
@ -115,7 +113,7 @@ public class AdminDomainBlockActivity extends BaseBarActivity {
Intent intent = new Intent(Helper.BROADCAST_DATA);
Bundle args = new Bundle();
args.putSerializable(Helper.ARG_ADMIN_DOMAINBLOCK, adminDomainBlockResult);
new CachedBundle(AdminDomainBlockActivity.this).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(AdminDomainBlockActivity.this).insertBundle(args, Helper.getCurrentAccount(AdminDomainBlockActivity.this), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intent.putExtras(bundle);
@ -151,7 +149,7 @@ public class AdminDomainBlockActivity extends BaseBarActivity {
Intent intent = new Intent(Helper.BROADCAST_DATA);
Bundle args = new Bundle();
args.putSerializable(Helper.ARG_ADMIN_DOMAINBLOCK_DELETE, adminDomainBlock);
new CachedBundle(AdminDomainBlockActivity.this).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(AdminDomainBlockActivity.this).insertBundle(args, Helper.getCurrentAccount(AdminDomainBlockActivity.this), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intent.putExtras(bundle);

View file

@ -15,8 +15,6 @@ package app.fedilab.android.mastodon.activities.admin;
* see <http://www.gnu.org/licenses>. */
import static app.fedilab.android.BaseMainActivity.currentAccount;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Intent;
@ -106,7 +104,7 @@ public class AdminReportActivity extends BaseBarActivity {
if (args != null) {
long bundleId = args.getLong(Helper.ARG_INTENT_ID, -1);
new CachedBundle(AdminReportActivity.this).getBundle(bundleId, currentAccount, this::initializeAfterBundle);
new CachedBundle(AdminReportActivity.this).getBundle(bundleId, Helper.getCurrentAccount(AdminReportActivity.this), this::initializeAfterBundle);
} else {
initializeAfterBundle(null);
}
@ -368,7 +366,7 @@ public class AdminReportActivity extends BaseBarActivity {
attachments.add(attachment);
args.putSerializable(Helper.ARG_MEDIA_ARRAY, attachments);
args.putInt(Helper.ARG_MEDIA_POSITION, 1);
new CachedBundle(AdminReportActivity.this).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(AdminReportActivity.this).insertBundle(args, Helper.getCurrentAccount(AdminReportActivity.this), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intent.putExtras(bundle);

View file

@ -41,7 +41,6 @@ import java.util.Date;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
import app.fedilab.android.MainApplication;
import app.fedilab.android.mastodon.client.entities.api.Account;
import app.fedilab.android.mastodon.client.entities.api.Status;
import app.fedilab.android.mastodon.exception.DBException;

View file

@ -14,7 +14,6 @@ package app.fedilab.android.mastodon.helper;
* You should have received a copy of the GNU General Public License along with Fedilab; if not,
* see <http://www.gnu.org/licenses>. */
import static app.fedilab.android.BaseMainActivity.currentAccount;
import android.content.Context;
import android.content.Intent;
@ -251,7 +250,7 @@ public class CrossActionHelper {
Bundle args = new Bundle();
args.putSerializable(Helper.ARG_STATUS_REPLY, targetedStatus);
args.putSerializable(Helper.ARG_ACCOUNT, ownerAccount);
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(context).insertBundle(args, Helper.getCurrentAccount(context), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intent.putExtras(bundle);
@ -262,7 +261,7 @@ public class CrossActionHelper {
Intent intentCompose = new Intent(context, ComposeActivity.class);
Bundle args = new Bundle();
args.putSerializable(Helper.ARG_ACCOUNT, ownerAccount);
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(context).insertBundle(args, Helper.getCurrentAccount(context), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intentCompose.putExtras(bundle);
@ -445,7 +444,7 @@ public class CrossActionHelper {
final BaseAccount account = accountArray[which];
Intent intentToot = new Intent(context, ComposeActivity.class);
bundle.putSerializable(Helper.ARG_ACCOUNT, account);
new CachedBundle(context).insertBundle(bundle, currentAccount, bundleId -> {
new CachedBundle(context).insertBundle(bundle, Helper.getCurrentAccount(context), bundleId -> {
Bundle bundleCached = new Bundle();
bundleCached.putLong(Helper.ARG_INTENT_ID, bundleId);
intentToot.putExtras(bundleCached);

View file

@ -15,7 +15,6 @@ package app.fedilab.android.mastodon.helper;
* see <http://www.gnu.org/licenses>. */
import static android.content.Context.DOWNLOAD_SERVICE;
import static app.fedilab.android.BaseMainActivity.currentAccount;
import static app.fedilab.android.mastodon.activities.BaseActivity.currentThemeId;
import static app.fedilab.android.mastodon.helper.LogoHelper.getNotificationIcon;
import static app.fedilab.android.mastodon.helper.ThemeHelper.fetchAccentColor;
@ -165,6 +164,7 @@ import app.fedilab.android.mastodon.viewmodel.mastodon.AccountsVM;
import app.fedilab.android.mastodon.viewmodel.mastodon.OauthVM;
import app.fedilab.android.mastodon.watermark.androidwm.WatermarkBuilder;
import app.fedilab.android.mastodon.watermark.androidwm.bean.WatermarkText;
import app.fedilab.android.peertube.client.data.AccountData;
import es.dmoral.toasty.Toasty;
import okhttp3.MediaType;
import okhttp3.MultipartBody;
@ -423,6 +423,7 @@ public class Helper {
private static int notificationId = 1;
//Allow to store in shared preference first visible fragment when the app starts
private static String slugOfFirstFragment;
private static BaseAccount baseAccount;
static {
LinkedHashMap<PatternType, Pattern> aMap = new LinkedHashMap<>();
@ -433,7 +434,6 @@ public class Helper {
patternHashMap = Collections.unmodifiableMap(aMap);
}
/**
* Manage downloads with URLs
*
@ -477,7 +477,6 @@ public class Helper {
}
}
/***
* Check if the user is connected to Internet
* @return boolean
@ -876,7 +875,7 @@ public class Helper {
args.putString(RECEIVE_TOAST_TYPE, type);
args.putString(RECEIVE_TOAST_CONTENT, content);
intentBC.setAction(Helper.RECEIVE_TOAST_MESSAGE);
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(context).insertBundle(args, Helper.getCurrentAccount(context), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intentBC.putExtras(bundle);
@ -918,7 +917,6 @@ public class Helper {
return fragment;
}
/**
* Load a media into a view
*
@ -961,11 +959,11 @@ public class Helper {
OauthVM oauthVM = new ViewModelProvider((ViewModelStoreOwner) activity).get(OauthVM.class);
if (currentAccount != null) {
if (Helper.getCurrentAccount(activity) != null) {
//Revoke the token
oauthVM.revokeToken(currentAccount.instance, currentAccount.token, currentAccount.client_id, currentAccount.client_secret);
oauthVM.revokeToken(Helper.getCurrentAccount(activity).instance, Helper.getCurrentAccount(activity).token, Helper.getCurrentAccount(activity).client_id, Helper.getCurrentAccount(activity).client_secret);
//Log out the current user
accountDB.removeUser(currentAccount);
accountDB.removeUser(Helper.getCurrentAccount(activity));
}
BaseAccount newAccount = accountDB.getLastUsedAccount();
SharedPreferences.Editor editor = sharedpreferences.edit();
@ -979,7 +977,7 @@ public class Helper {
activity.startActivity(loginActivity);
activity.finish();
} else {
currentAccount = newAccount;
Helper.setCurrentAccount(newAccount);
editor.putString(PREF_USER_TOKEN, newAccount.token);
editor.putString(PREF_USER_SOFTWARE, newAccount.software);
editor.putString(PREF_USER_INSTANCE, newAccount.instance);
@ -1367,7 +1365,6 @@ public class Helper {
}).start();
}
public static void createFileFromUri(Context context, Uri uri, OnFileCopied callBack) {
new Thread(() -> {
InputStream selectedFileInputStream;
@ -1526,7 +1523,7 @@ public class Helper {
Bundle args = new Bundle();
args.putBoolean(Helper.RECEIVE_RECREATE_ACTIVITY, true);
Intent intentBD = new Intent(Helper.BROADCAST_DATA);
new CachedBundle(activity).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(activity).insertBundle(args, Helper.getCurrentAccount(activity), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intentBD.putExtras(bundle);
@ -1693,7 +1690,6 @@ public class Helper {
}
}
public static String dateDiffFull(Date dateToot) {
SimpleDateFormat df = (SimpleDateFormat) DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.MEDIUM, Locale.getDefault());
try {
@ -1703,7 +1699,6 @@ public class Helper {
}
}
public static String dateDiffFullShort(Date dateToot) {
SimpleDateFormat df = (SimpleDateFormat) DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, Locale.getDefault());
try {
@ -1934,7 +1929,7 @@ public class Helper {
Intent intent = new Intent(activity, ProfileActivity.class);
Bundle args = new Bundle();
args.putSerializable(Helper.ARG_ACCOUNT, account);
new CachedBundle(activity).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(activity).insertBundle(args, Helper.getCurrentAccount(activity), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intent.putExtras(bundle);
@ -2022,7 +2017,6 @@ public class Helper {
Runtime.getRuntime().exit(0);
}
public static void forwardToBrowser(Activity activity, Intent i) {
Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_VIEW);
@ -2047,7 +2041,6 @@ public class Helper {
}
}
public static int dialogStyle() {
if (R.style.AppThemeBar == currentThemeId || R.style.AppTheme == currentThemeId) {
return R.style.AppThemeAlertDialog;
@ -2076,6 +2069,33 @@ public class Helper {
}
}
public static BaseAccount getCurrentAccount(Context context) {
if (baseAccount == null && context != null) {
baseAccount = new BaseAccount();
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
baseAccount.user_id = sharedpreferences.getString(PREF_USER_ID, null);
baseAccount.instance = sharedpreferences.getString(PREF_USER_INSTANCE, null);
baseAccount.token = sharedpreferences.getString(PREF_USER_TOKEN, null);
}
return baseAccount;
}
public static void setCurrentAccount(BaseAccount newBaseAccount) {
baseAccount = newBaseAccount;
}
public static void setCurrentAccountMastodonAccount(Context context, app.fedilab.android.mastodon.client.entities.api.Account newAccount) {
BaseAccount tempBaseAccount = getCurrentAccount(context);
tempBaseAccount.mastodon_account = newAccount;
setCurrentAccount(tempBaseAccount);
}
public static void setCurrentAccountPeertubeAccount(Context context, AccountData.PeertubeAccount newAccount) {
BaseAccount tempBaseAccount = getCurrentAccount(context);
tempBaseAccount.peertube_account = newAccount;
setCurrentAccount(tempBaseAccount);
}
public static boolean isNumeric(String str) {
try {
Double.parseDouble(str);

View file

@ -15,7 +15,6 @@ package app.fedilab.android.mastodon.helper;
* see <http://www.gnu.org/licenses>. */
import static android.content.Context.DOWNLOAD_SERVICE;
import static app.fedilab.android.BaseMainActivity.currentAccount;
import static app.fedilab.android.mastodon.helper.LogoHelper.getMainLogo;
import android.app.Activity;
@ -172,7 +171,7 @@ public class MediaHelper {
intent.setDataAndType(uri, mime);
MediaScannerConnection.scanFile(context, new String[]{backupFile.getAbsolutePath()}, null, null);
if (!share) {
Helper.notify_user(context, currentAccount, intent, BitmapFactory.decodeResource(context.getResources(),
Helper.notify_user(context, Helper.getCurrentAccount(context), intent, BitmapFactory.decodeResource(context.getResources(),
getMainLogo(context)), Helper.NotifType.STORE, context.getString(R.string.save_over), context.getString(R.string.download_from, fileName));
Toasty.success(context, context.getString(R.string.save_over), Toasty.LENGTH_LONG).show();
} else {

View file

@ -15,7 +15,6 @@ package app.fedilab.android.mastodon.helper;
* see <http://www.gnu.org/licenses>. */
import static app.fedilab.android.BaseMainActivity.currentAccount;
import static app.fedilab.android.BaseMainActivity.currentInstance;
import static app.fedilab.android.BaseMainActivity.currentUserID;
import static app.fedilab.android.BaseMainActivity.show_boosts;
@ -186,7 +185,7 @@ public class PinnedTimelineHelper {
}
if (extraFeatures) {
try {
Pinned pinnedAll = new Pinned(activity).getAllPinned(currentAccount);
Pinned pinnedAll = new Pinned(activity).getAllPinned(Helper.getCurrentAccount(activity));
if (pinnedAll == null) {
pinnedAll = new Pinned();
pinnedAll.user_id = currentUserID;
@ -262,7 +261,7 @@ public class PinnedTimelineHelper {
for (MastodonList mastodonList : mastodonLists) {
boolean present = false;
try {
Pinned pinnedAll = new Pinned(activity).getAllPinned(currentAccount);
Pinned pinnedAll = new Pinned(activity).getAllPinned(Helper.getCurrentAccount(activity));
if (pinnedAll == null) {
pinnedAll = pinned;
}
@ -793,7 +792,7 @@ public class PinnedTimelineHelper {
int toRemove = 0;
try {
//If some menu items have been hidden we should not create tab for them
bottomMenuDb = new BottomMenu(activity).getAllBottomMenu(currentAccount);
bottomMenuDb = new BottomMenu(activity).getAllBottomMenu(Helper.getCurrentAccount(activity));
if (bottomMenuDb != null) {
List<BottomMenu.MenuItem> menuItemList = bottomMenuDb.bottom_menu;
if (menuItemList != null) {

View file

@ -15,7 +15,6 @@ package app.fedilab.android.mastodon.helper;
* see <http://www.gnu.org/licenses>. */
import static app.fedilab.android.BaseMainActivity.currentAccount;
import static app.fedilab.android.BaseMainActivity.currentNightMode;
import android.app.Activity;
@ -290,7 +289,7 @@ public class SpannableHelper {
intent = new Intent(context, HashTagActivity.class);
args = new Bundle();
args.putString(Helper.ARG_SEARCH_KEYWORD, word.trim());
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(context).insertBundle(args, Helper.getCurrentAccount(context), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intent.putExtras(bundle);
@ -322,7 +321,7 @@ public class SpannableHelper {
} else {
args.putString(Helper.ARG_MENTION, word);
}
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(context).insertBundle(args, Helper.getCurrentAccount(context), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intent.putExtras(bundle);
@ -646,13 +645,13 @@ public class SpannableHelper {
Matcher matcherUserWithoutAt = userWithoutAt.matcher(finalUrl);
if (matcherLink.find() && !finalUrl.contains("medium.com")) {
if (matcherLink.group(3) != null && Objects.requireNonNull(matcherLink.group(3)).length() > 0) { //It's a toot
CrossActionHelper.fetchRemoteStatus(context, currentAccount, finalUrl, new CrossActionHelper.Callback() {
CrossActionHelper.fetchRemoteStatus(context, Helper.getCurrentAccount(context), finalUrl, new CrossActionHelper.Callback() {
@Override
public void federatedStatus(Status status) {
Intent intent = new Intent(context, ContextActivity.class);
Bundle args = new Bundle();
args.putSerializable(Helper.ARG_STATUS, status);
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(context).insertBundle(args, Helper.getCurrentAccount(context), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intent.putExtras(bundle);
@ -666,7 +665,7 @@ public class SpannableHelper {
}
});
} else {//It's an account
CrossActionHelper.fetchRemoteAccount(context, currentAccount, matcherLink.group(2) + "@" + matcherLink.group(1), new CrossActionHelper.Callback() {
CrossActionHelper.fetchRemoteAccount(context, Helper.getCurrentAccount(context), matcherLink.group(2) + "@" + matcherLink.group(1), new CrossActionHelper.Callback() {
@Override
public void federatedStatus(Status status) {
}
@ -676,7 +675,7 @@ public class SpannableHelper {
Intent intent = new Intent(context, ProfileActivity.class);
Bundle args = new Bundle();
args.putSerializable(Helper.ARG_ACCOUNT, account);
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(context).insertBundle(args, Helper.getCurrentAccount(context), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intent.putExtras(bundle);
@ -688,13 +687,13 @@ public class SpannableHelper {
}
} else if (matcherLinkLong.find() && !finalUrl.contains("medium.com")) {
if (matcherLinkLong.group(3) != null && Objects.requireNonNull(matcherLinkLong.group(3)).length() > 0) { //It's a toot
CrossActionHelper.fetchRemoteStatus(context, currentAccount, finalUrl, new CrossActionHelper.Callback() {
CrossActionHelper.fetchRemoteStatus(context, Helper.getCurrentAccount(context), finalUrl, new CrossActionHelper.Callback() {
@Override
public void federatedStatus(Status status) {
Intent intent = new Intent(context, ContextActivity.class);
Bundle args = new Bundle();
args.putSerializable(Helper.ARG_STATUS, status);
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(context).insertBundle(args, Helper.getCurrentAccount(context), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intent.putExtras(bundle);
@ -708,7 +707,7 @@ public class SpannableHelper {
}
});
} else if (matcherLinkLong.group(2) != null) {//It's an account
CrossActionHelper.fetchRemoteAccount(context, currentAccount, matcherLinkLong.group(2), new CrossActionHelper.Callback() {
CrossActionHelper.fetchRemoteAccount(context, Helper.getCurrentAccount(context), matcherLinkLong.group(2), new CrossActionHelper.Callback() {
@Override
public void federatedStatus(Status status) {
}
@ -718,7 +717,7 @@ public class SpannableHelper {
Intent intent = new Intent(context, ProfileActivity.class);
Bundle args = new Bundle();
args.putSerializable(Helper.ARG_ACCOUNT, account);
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(context).insertBundle(args, Helper.getCurrentAccount(context), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intent.putExtras(bundle);
@ -730,13 +729,13 @@ public class SpannableHelper {
}
} else if (matcherUserWithoutAt.find() && !finalUrl.contains("medium.com")) {
if (matcherUserWithoutAt.group(4) != null && Objects.requireNonNull(matcherUserWithoutAt.group(4)).length() > 0) { //It's a toot
CrossActionHelper.fetchRemoteStatus(context, currentAccount, finalUrl, new CrossActionHelper.Callback() {
CrossActionHelper.fetchRemoteStatus(context, Helper.getCurrentAccount(context), finalUrl, new CrossActionHelper.Callback() {
@Override
public void federatedStatus(Status status) {
Intent intent = new Intent(context, ContextActivity.class);
Bundle args = new Bundle();
args.putSerializable(Helper.ARG_STATUS, status);
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(context).insertBundle(args, Helper.getCurrentAccount(context), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intent.putExtras(bundle);
@ -750,7 +749,7 @@ public class SpannableHelper {
}
});
} else {//It's an account
CrossActionHelper.fetchRemoteAccount(context, currentAccount, matcherUserWithoutAt.group(3) + "@" + matcherUserWithoutAt.group(1), new CrossActionHelper.Callback() {
CrossActionHelper.fetchRemoteAccount(context, Helper.getCurrentAccount(context), matcherUserWithoutAt.group(3) + "@" + matcherUserWithoutAt.group(1), new CrossActionHelper.Callback() {
@Override
public void federatedStatus(Status status) {
}
@ -760,7 +759,7 @@ public class SpannableHelper {
Intent intent = new Intent(context, ProfileActivity.class);
Bundle args = new Bundle();
args.putSerializable(Helper.ARG_ACCOUNT, account);
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(context).insertBundle(args, Helper.getCurrentAccount(context), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intent.putExtras(bundle);
@ -946,7 +945,7 @@ public class SpannableHelper {
Intent intent = new Intent(context, ProfileActivity.class);
Bundle args = new Bundle();
args.putSerializable(Helper.ARG_ACCOUNT, account.moved);
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(context).insertBundle(args, Helper.getCurrentAccount(context), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intent.putExtras(bundle);

View file

@ -15,7 +15,6 @@ package app.fedilab.android.mastodon.helper;
* see <http://www.gnu.org/licenses>. */
import static app.fedilab.android.BaseMainActivity.currentAccount;
import static app.fedilab.android.mastodon.helper.LogoHelper.getMainLogo;
import static app.fedilab.android.sqlite.Sqlite.DB_NAME;
import static app.fedilab.android.sqlite.Sqlite.db;
@ -111,7 +110,7 @@ public class ZipHelper {
Uri uri = Uri.parse("file://" + zipFile);
intentOpen.setDataAndType(uri, "application/zip");
String title = context.getString(R.string.data_export_settings);
Helper.notify_user(context, currentAccount, intentOpen, BitmapFactory.decodeResource(context.getResources(),
Helper.notify_user(context, Helper.getCurrentAccount(context), intentOpen, BitmapFactory.decodeResource(context.getResources(),
getMainLogo(context)), Helper.NotifType.BACKUP, title, message);
}
}

View file

@ -1,8 +1,6 @@
package app.fedilab.android.mastodon.imageeditor;
import static app.fedilab.android.BaseMainActivity.currentAccount;
import android.Manifest;
import android.content.Intent;
import android.content.pm.PackageManager;
@ -330,7 +328,7 @@ public class EditImageActivity extends BaseActivity implements OnPhotoEditorList
args.putFloat("focusX", focusX);
args.putFloat("focusY", focusY);
}
new CachedBundle(EditImageActivity.this).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(EditImageActivity.this).insertBundle(args, Helper.getCurrentAccount(EditImageActivity.this), bundleId -> {
intentImage.putExtras(args);
intentImage.setPackage(BuildConfig.APPLICATION_ID);
sendBroadcast(intentImage);

View file

@ -15,8 +15,6 @@ package app.fedilab.android.mastodon.ui.drawer;
* see <http://www.gnu.org/licenses>. */
import static app.fedilab.android.BaseMainActivity.currentAccount;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
@ -95,9 +93,9 @@ public class AccountAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
accountViewHolder.binding.muteHome.setChecked(muted);
accountViewHolder.binding.muteHome.setOnClickListener(v -> {
if (muted) {
accountsVM.unmuteHome(currentAccount, account).observe((LifecycleOwner) context, account1 -> adapter.notifyItemChanged(accountViewHolder.getLayoutPosition()));
accountsVM.unmuteHome(Helper.getCurrentAccount(context), account).observe((LifecycleOwner) context, account1 -> adapter.notifyItemChanged(accountViewHolder.getLayoutPosition()));
} else {
accountsVM.muteHome(currentAccount, account).observe((LifecycleOwner) context, account1 -> adapter.notifyItemChanged(accountViewHolder.getLayoutPosition()));
accountsVM.muteHome(Helper.getCurrentAccount(context), account).observe((LifecycleOwner) context, account1 -> adapter.notifyItemChanged(accountViewHolder.getLayoutPosition()));
}
});
} else {
@ -114,7 +112,7 @@ public class AccountAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
Intent intent = new Intent(context, ProfileActivity.class);
Bundle args = new Bundle();
args.putSerializable(Helper.ARG_ACCOUNT, account);
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(context).insertBundle(args, Helper.getCurrentAccount(context), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intent.putExtras(bundle);
@ -130,7 +128,7 @@ public class AccountAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
Intent intent = new Intent(context, ProfileActivity.class);
Bundle args = new Bundle();
args.putSerializable(Helper.ARG_ACCOUNT, accountSearch);
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(context).insertBundle(args, Helper.getCurrentAccount(context), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intent.putExtras(bundle);

View file

@ -14,7 +14,6 @@ package app.fedilab.android.mastodon.ui.drawer;
* You should have received a copy of the GNU General Public License along with Fedilab; if not,
* see <http://www.gnu.org/licenses>. */
import static app.fedilab.android.BaseMainActivity.currentAccount;
import android.content.Context;
import android.content.Intent;
@ -106,7 +105,7 @@ public class AccountFollowRequestAdapter extends RecyclerView.Adapter<RecyclerVi
Intent intent = new Intent(context, ProfileActivity.class);
Bundle args = new Bundle();
args.putSerializable(Helper.ARG_ACCOUNT, account);
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(context).insertBundle(args, Helper.getCurrentAccount(context), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intent.putExtras(bundle);

View file

@ -118,13 +118,13 @@ public class AccountsSearchAdapter extends ArrayAdapter<Account> implements Filt
holder.binding.accountDn.setText(account.display_name);
holder.binding.accountDn.setVisibility(View.VISIBLE);
account.pronouns = null;
for(Field field: account.fields) {
if(field.name.trim().equalsIgnoreCase("pronouns")) {
for (Field field : account.fields) {
if (field.name.trim().equalsIgnoreCase("pronouns")) {
account.pronouns = field.value;
break;
}
}
if(account.pronouns != null) {
if (account.pronouns != null) {
holder.binding.pronouns.setText(account.pronouns);
holder.binding.pronouns.setVisibility(View.VISIBLE);
} else {

View file

@ -14,7 +14,6 @@ package app.fedilab.android.mastodon.ui.drawer;
* You should have received a copy of the GNU General Public License along with Fedilab; if not,
* see <http://www.gnu.org/licenses>. */
import static app.fedilab.android.BaseMainActivity.currentAccount;
import android.content.Context;
import android.content.Intent;
@ -67,7 +66,7 @@ public class AccountsSearchTopBarAdapter extends SimpleCursorAdapter {
Intent intent = new Intent(context, ProfileActivity.class);
Bundle args = new Bundle();
args.putSerializable(Helper.ARG_ACCOUNT, accountList.get(position));
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(context).insertBundle(args, Helper.getCurrentAccount(context), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intent.putExtras(bundle);

View file

@ -16,7 +16,6 @@ package app.fedilab.android.mastodon.ui.drawer;
import static android.content.Context.INPUT_METHOD_SERVICE;
import static app.fedilab.android.BaseMainActivity.currentAccount;
import static app.fedilab.android.BaseMainActivity.emojis;
import static app.fedilab.android.BaseMainActivity.instanceInfo;
import static app.fedilab.android.mastodon.activities.ComposeActivity.MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE;
@ -1136,9 +1135,9 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
if (attachmentList != null && attachmentList.size() > 0) {
holder.binding.sensitiveMedia.setVisibility(View.VISIBLE);
if (!statusList.get(position).sensitive) {
if (currentAccount != null && currentAccount.mastodon_account != null && currentAccount.mastodon_account.source != null) {
holder.binding.sensitiveMedia.setChecked(currentAccount.mastodon_account.source.sensitive);
statusList.get(position).sensitive = currentAccount.mastodon_account.source.sensitive;
if (Helper.getCurrentAccount(context) != null && Helper.getCurrentAccount(context).mastodon_account != null && Helper.getCurrentAccount(context).mastodon_account.source != null) {
holder.binding.sensitiveMedia.setChecked(Helper.getCurrentAccount(context).mastodon_account.source.sensitive);
statusList.get(position).sensitive = Helper.getCurrentAccount(context).mastodon_account.source.sensitive;
} else {
statusList.get(position).sensitive = false;
}
@ -1380,7 +1379,7 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
ArrayList<Attachment> attachments = new ArrayList<>();
attachments.add(attachment);
args.putSerializable(Helper.ARG_MEDIA_ARRAY, attachments);
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(context).insertBundle(args, Helper.getCurrentAccount(context), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
mediaIntent.putExtras(bundle);
@ -1423,13 +1422,13 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
} else if (getItemViewType(position) == TYPE_COMPOSE) {
Status statusDraft = statusList.get(position);
if(position > 0 && getItemViewType(position -1 ) == TYPE_NORMAL) {
Status statusFromUser = statusList.get(position-1);
if (position > 0 && getItemViewType(position - 1) == TYPE_NORMAL) {
Status statusFromUser = statusList.get(position - 1);
Account accountFromUser = statusFromUser.account;
statusFromUser.pronouns = null;
if(accountFromUser.fields != null && accountFromUser.fields.size() > 0) {
for(Field field: accountFromUser.fields) {
if(field.name.toLowerCase().startsWith("pronoun")) {
if (accountFromUser.fields != null && accountFromUser.fields.size() > 0) {
for (Field field : accountFromUser.fields) {
if (field.name.toLowerCase().startsWith("pronoun")) {
statusList.get(position).pronouns = field.value;
break;
}
@ -1441,7 +1440,7 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
boolean mathsComposer = sharedpreferences.getBoolean(context.getString(R.string.SET_MATHS_COMPOSER), true);
boolean forwardTag = sharedpreferences.getBoolean(context.getString(R.string.SET_FORWARD_TAGS_IN_REPLY), false);
if(statusDraft.pronouns != null) {
if (statusDraft.pronouns != null) {
holder.binding.genders.setVisibility(View.VISIBLE);
holder.binding.pronouns.setText(statusDraft.pronouns);
} else {
@ -1604,8 +1603,8 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
if (statusDraft.visibility == null) {
if (position > 0) {
statusDraft.visibility = statusList.get(position - 1).visibility;
} else if (currentAccount.mastodon_account != null && currentAccount.mastodon_account.source != null) {
statusDraft.visibility = currentAccount.mastodon_account.source.privacy;
} else if (Helper.getCurrentAccount(context).mastodon_account != null && Helper.getCurrentAccount(context).mastodon_account.source != null) {
statusDraft.visibility = Helper.getCurrentAccount(context).mastodon_account.source.privacy;
} else {
statusDraft.visibility = "public";
}

View file

@ -15,7 +15,6 @@ package app.fedilab.android.mastodon.ui.drawer;
* see <http://www.gnu.org/licenses>. */
import static app.fedilab.android.BaseMainActivity.currentAccount;
import static app.fedilab.android.BaseMainActivity.currentNightMode;
import android.annotation.SuppressLint;
@ -225,7 +224,7 @@ public class ConversationAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
}
Bundle args = new Bundle();
args.putSerializable(Helper.ARG_STATUS, conversation.last_status);
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(context).insertBundle(args, Helper.getCurrentAccount(context), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intent.putExtras(bundle);
@ -243,7 +242,7 @@ public class ConversationAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
}
Bundle args = new Bundle();
args.putSerializable(Helper.ARG_STATUS, conversation.last_status);
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(context).insertBundle(args, Helper.getCurrentAccount(context), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intent.putExtras(bundle);

View file

@ -14,7 +14,6 @@ package app.fedilab.android.mastodon.ui.drawer;
* You should have received a copy of the GNU General Public License along with Fedilab; if not,
* see <http://www.gnu.org/licenses>. */
import static app.fedilab.android.BaseMainActivity.currentAccount;
import android.app.Activity;
import android.content.Context;
@ -79,7 +78,7 @@ public class ImageAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
args.putInt(Helper.ARG_MEDIA_POSITION, position + 1);
args.putBoolean(Helper.ARG_MEDIA_ARRAY_PROFILE, true);
if (attachment != null) {
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(context).insertBundle(args, Helper.getCurrentAccount(context), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
mediaIntent.putExtras(bundle);
@ -99,7 +98,7 @@ public class ImageAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
} else {
return false;
}
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(context).insertBundle(args, Helper.getCurrentAccount(context), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intentContext.putExtras(bundle);

View file

@ -15,7 +15,6 @@ package app.fedilab.android.mastodon.ui.drawer;
* see <http://www.gnu.org/licenses>. */
import static app.fedilab.android.BaseMainActivity.currentAccount;
import static app.fedilab.android.BaseMainActivity.currentNightMode;
import static app.fedilab.android.mastodon.ui.drawer.StatusAdapter.statusManagement;
@ -274,7 +273,7 @@ public class NotificationAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
Intent intent = new Intent(context, ProfileActivity.class);
Bundle args = new Bundle();
args.putSerializable(Helper.ARG_ACCOUNT, notification.account);
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(context).insertBundle(args, Helper.getCurrentAccount(context), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intent.putExtras(bundle);
@ -387,7 +386,7 @@ public class NotificationAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
Intent intent = new Intent(context, ProfileActivity.class);
Bundle args = new Bundle();
args.putSerializable(Helper.ARG_ACCOUNT, notification.account);
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(context).insertBundle(args, Helper.getCurrentAccount(context), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intent.putExtras(bundle);
@ -437,7 +436,7 @@ public class NotificationAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
Intent intent = new Intent(context, ProfileActivity.class);
Bundle args = new Bundle();
args.putSerializable(Helper.ARG_ACCOUNT, relativeNotif.account);
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(context).insertBundle(args, Helper.getCurrentAccount(context), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intent.putExtras(bundle);
@ -454,7 +453,7 @@ public class NotificationAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
Intent intent = new Intent(context, ProfileActivity.class);
Bundle args = new Bundle();
args.putSerializable(Helper.ARG_ACCOUNT, notification.account);
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(context).insertBundle(args, Helper.getCurrentAccount(context), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intent.putExtras(bundle);
@ -465,7 +464,7 @@ public class NotificationAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
Intent intent = new Intent(context, ProfileActivity.class);
Bundle args = new Bundle();
args.putSerializable(Helper.ARG_ACCOUNT, notification.account);
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(context).insertBundle(args, Helper.getCurrentAccount(context), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intent.putExtras(bundle);

View file

@ -14,7 +14,6 @@ package app.fedilab.android.mastodon.ui.drawer;
* You should have received a copy of the GNU General Public License along with Fedilab; if not,
* see <http://www.gnu.org/licenses>. */
import static app.fedilab.android.BaseMainActivity.currentAccount;
import android.app.Activity;
import android.content.Context;
@ -108,7 +107,7 @@ public class SliderAdapter extends SliderViewAdapter<SliderAdapter.SliderAdapter
Bundle args = new Bundle();
args.putInt(Helper.ARG_MEDIA_POSITION, position + 1);
args.putSerializable(Helper.ARG_MEDIA_ARRAY, new ArrayList<>(status.media_attachments));
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(context).insertBundle(args, Helper.getCurrentAccount(context), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
mediaIntent.putExtras(bundle);

View file

@ -16,7 +16,6 @@ package app.fedilab.android.mastodon.ui.drawer;
import static android.content.Context.INPUT_METHOD_SERVICE;
import static app.fedilab.android.BaseMainActivity.currentAccount;
import static app.fedilab.android.BaseMainActivity.currentNightMode;
import static app.fedilab.android.BaseMainActivity.currentUserID;
import static app.fedilab.android.BaseMainActivity.emojis;
@ -482,18 +481,18 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
}
String loadMediaType = sharedpreferences.getString(context.getString(R.string.SET_LOAD_MEDIA_TYPE), "ALWAYS");
if(statusToDeal.pronouns == null && statusToDeal.account.fields != null && statusToDeal.account.fields.size() > 0) {
for(Field field: statusToDeal.account.fields) {
if(field.name.toLowerCase().startsWith("pronoun")) {
if (statusToDeal.pronouns == null && statusToDeal.account.fields != null && statusToDeal.account.fields.size() > 0) {
for (Field field : statusToDeal.account.fields) {
if (field.name.toLowerCase().startsWith("pronoun")) {
statusToDeal.pronouns = field.value;
break;
}
}
if(statusToDeal.pronouns == null) {
if (statusToDeal.pronouns == null) {
statusToDeal.pronouns = "none";
}
}
if(statusToDeal.pronouns != null && !statusToDeal.pronouns.equalsIgnoreCase("none")) {
if (statusToDeal.pronouns != null && !statusToDeal.pronouns.equalsIgnoreCase("none")) {
holder.binding.pronouns.setVisibility(View.VISIBLE);
holder.binding.pronouns.setText(statusToDeal.pronouns);
} else {
@ -523,7 +522,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
Intent intent = new Intent(context, ContextActivity.class);
Bundle args = new Bundle();
args.putSerializable(Helper.ARG_STATUS, statusToDeal.quote);
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(context).insertBundle(args, Helper.getCurrentAccount(context), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intent.putExtras(bundle);
@ -559,7 +558,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
holder.binding.quotedMessage.cardviewContainer.setVisibility(View.GONE);
}
if (currentAccount != null && currentAccount.api == Account.API.PLEROMA || status.reactions != null) {
if (Helper.getCurrentAccount(context) != null && Helper.getCurrentAccount(context).api == Account.API.PLEROMA || status.reactions != null) {
if (status.pleroma != null && status.pleroma.emoji_reactions != null && status.pleroma.emoji_reactions.size() > 0) {
holder.binding.layoutReactions.getRoot().setVisibility(View.VISIBLE);
ReactionAdapter reactionAdapter = new ReactionAdapter(status.id, status.pleroma.emoji_reactions, true);
@ -958,7 +957,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
Intent intent = new Intent(context, ProfileActivity.class);
Bundle args = new Bundle();
args.putSerializable(Helper.ARG_ACCOUNT, fetchedStatus.reblog != null ? fetchedStatus.reblog.account : fetchedStatus.account);
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(context).insertBundle(args, Helper.getCurrentAccount(context), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intent.putExtras(bundle);
@ -972,7 +971,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
Intent intent = new Intent(context, ProfileActivity.class);
Bundle args = new Bundle();
args.putSerializable(Helper.ARG_ACCOUNT, status.reblog != null ? status.reblog.account : status.account);
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(context).insertBundle(args, Helper.getCurrentAccount(context), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intent.putExtras(bundle);
@ -990,7 +989,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
Intent intent = new Intent(context, ProfileActivity.class);
Bundle args = new Bundle();
args.putSerializable(Helper.ARG_ACCOUNT, fetchedStatus.account);
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(context).insertBundle(args, Helper.getCurrentAccount(context), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intent.putExtras(bundle);
@ -1004,7 +1003,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
Intent intent = new Intent(context, ProfileActivity.class);
Bundle args = new Bundle();
args.putSerializable(Helper.ARG_ACCOUNT, status.account);
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(context).insertBundle(args, Helper.getCurrentAccount(context), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intent.putExtras(bundle);
@ -1697,7 +1696,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
Bundle args = new Bundle();
args.putInt(Helper.ARG_MEDIA_POSITION, finalMediaPosition);
args.putSerializable(Helper.ARG_MEDIA_ARRAY, new ArrayList<>(statusToDeal.media_attachments));
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(context).insertBundle(args, Helper.getCurrentAccount(context), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
mediaIntent.putExtras(bundle);
@ -1768,7 +1767,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
Bundle args = new Bundle();
args.putInt(Helper.ARG_MEDIA_POSITION, finalMediaPosition);
args.putSerializable(Helper.ARG_MEDIA_ARRAY, new ArrayList<>(statusToDeal.media_attachments));
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(context).insertBundle(args, Helper.getCurrentAccount(context), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
mediaIntent.putExtras(bundle);
@ -1809,7 +1808,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
args.putSerializable(Helper.ARG_STATUS, statusToDeal);
args.putSerializable(Helper.ARG_TYPE_OF_INFO, StatusInfoActivity.typeOfInfo.BOOSTED_BY);
args.putBoolean(Helper.ARG_CHECK_REMOTELY, remote);
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(context).insertBundle(args, Helper.getCurrentAccount(context), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intent.putExtras(bundle);
@ -1825,7 +1824,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
args.putSerializable(Helper.ARG_STATUS, statusToDeal);
args.putSerializable(Helper.ARG_TYPE_OF_INFO, StatusInfoActivity.typeOfInfo.LIKED_BY);
args.putBoolean(Helper.ARG_CHECK_REMOTELY, remote);
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(context).insertBundle(args, Helper.getCurrentAccount(context), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intent.putExtras(bundle);
@ -2048,7 +2047,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
if (context instanceof ContextActivity && !remote) {
Bundle args = new Bundle();
args.putSerializable(Helper.ARG_STATUS, statusToDeal);
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(context).insertBundle(args, Helper.getCurrentAccount(context), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
Fragment fragment = Helper.addFragment(((AppCompatActivity) context).getSupportFragmentManager(), R.id.nav_host_fragment_content_main, new FragmentMastodonContext(), bundle, null, FragmentMastodonContext.class.getName());
@ -2064,7 +2063,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
args.putString(Helper.ARG_LEMMY_POST_ID, status.lemmy_post_id);
args.putSerializable(Helper.ARG_STATUS, status);
Intent intent = new Intent(context, TimelineActivity.class);
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(context).insertBundle(args, Helper.getCurrentAccount(context), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intent.putExtras(bundle);
@ -2081,7 +2080,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
Intent intent = new Intent(context, ContextActivity.class);
Bundle args = new Bundle();
args.putSerializable(Helper.ARG_STATUS, fetchedStatus);
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(context).insertBundle(args, Helper.getCurrentAccount(context), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intent.putExtras(bundle);
@ -2108,7 +2107,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
Intent intent = new Intent(context, ContextActivity.class);
Bundle args = new Bundle();
args.putSerializable(Helper.ARG_STATUS, statusToDeal);
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(context).insertBundle(args, Helper.getCurrentAccount(context), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intent.putExtras(bundle);
@ -2169,7 +2168,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
popup.getMenu().findItem(R.id.action_block_domain).setVisible(false);
stringArrayConf = context.getResources().getStringArray(R.array.more_action_confirm);
}
popup.getMenu().findItem(R.id.action_admin).setVisible(currentAccount.admin);
popup.getMenu().findItem(R.id.action_admin).setVisible(Helper.getCurrentAccount(context).admin);
boolean custom_sharing = sharedpreferences.getBoolean(context.getString(R.string.SET_CUSTOM_SHARING), false);
if (custom_sharing && statusToDeal.visibility.equals("public"))
@ -2200,7 +2199,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
Bundle args = new Bundle();
args.putSerializable(Helper.ARG_STATUS_DRAFT, statusDraft);
args.putSerializable(Helper.ARG_STATUS_REPLY_ID, statusDeleted.in_reply_to_id);
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(context).insertBundle(args, Helper.getCurrentAccount(context), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intent.putExtras(bundle);
@ -2230,7 +2229,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
args.putSerializable(Helper.ARG_STATUS_DRAFT, statusDraft);
args.putString(Helper.ARG_EDIT_STATUS_ID, statusToDeal.id);
args.putString(Helper.ARG_STATUS_REPLY_ID, statusToDeal.in_reply_to_id);
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(context).insertBundle(args, Helper.getCurrentAccount(context), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intent.putExtras(bundle);
@ -2246,7 +2245,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
Intent intent = new Intent(context, AdminAccountActivity.class);
Bundle args = new Bundle();
args.putString(Helper.ARG_ACCOUNT_ID, statusToDeal.account.id);
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(context).insertBundle(args, Helper.getCurrentAccount(context), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intent.putExtras(bundle);
@ -2303,7 +2302,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
builderInner.setTitle(R.string.mute_home);
builderInner.setMessage(statusToDeal.account.acct);
builderInner.setNeutralButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
builderInner.setPositiveButton(R.string.action_mute, (dialog, which) -> accountsVM.muteHome(currentAccount, statusToDeal.account)
builderInner.setPositiveButton(R.string.action_mute, (dialog, which) -> accountsVM.muteHome(Helper.getCurrentAccount(context), statusToDeal.account)
.observe((LifecycleOwner) context, account -> Toasty.info(context, context.getString(R.string.toast_mute), Toasty.LENGTH_LONG).show()));
builderInner.show();
} else if (itemId == R.id.action_mute_conversation) {
@ -2347,7 +2346,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
Intent intent = new Intent(context, ReportActivity.class);
Bundle args = new Bundle();
args.putSerializable(Helper.ARG_STATUS, statusToDeal);
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(context).insertBundle(args, Helper.getCurrentAccount(context), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intent.putExtras(bundle);
@ -2408,7 +2407,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
Intent intent = new Intent(context, CustomSharingActivity.class);
Bundle args = new Bundle();
args.putSerializable(Helper.ARG_STATUS, statusToDeal);
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(context).insertBundle(args, Helper.getCurrentAccount(context), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intent.putExtras(bundle);
@ -2418,7 +2417,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
Intent intent = new Intent(context, ComposeActivity.class);
Bundle args = new Bundle();
args.putSerializable(Helper.ARG_STATUS_MENTION, statusToDeal);
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(context).insertBundle(args, Helper.getCurrentAccount(context), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intent.putExtras(bundle);
@ -2453,7 +2452,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
BaseMainActivity.currentToken = account.token;
BaseMainActivity.currentUserID = account.user_id;
BaseMainActivity.currentInstance = account.instance;
currentAccount = account;
Helper.setCurrentAccount(account);
SharedPreferences.Editor editor = sharedpreferences.edit();
editor.putString(PREF_USER_TOKEN, account.token);
editor.putString(PREF_USER_SOFTWARE, account.software);
@ -2479,7 +2478,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
BaseMainActivity.currentToken = account.token;
BaseMainActivity.currentUserID = account.user_id;
BaseMainActivity.currentInstance = account.instance;
currentAccount = account;
Helper.setCurrentAccount(account);
SharedPreferences.Editor editor = sharedpreferences.edit();
editor.putString(PREF_USER_TOKEN, account.token);
editor.putString(PREF_USER_SOFTWARE, account.software);
@ -2514,7 +2513,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
Intent intent = new Intent(context, ComposeActivity.class);
Bundle args = new Bundle();
args.putSerializable(Helper.ARG_QUOTED_MESSAGE, statusToDeal);
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(context).insertBundle(args, Helper.getCurrentAccount(context), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intent.putExtras(bundle);
@ -2531,7 +2530,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
Intent intent = new Intent(context, ComposeActivity.class);
Bundle args = new Bundle();
args.putSerializable(Helper.ARG_STATUS_REPLY, fetchedStatus);
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(context).insertBundle(args, Helper.getCurrentAccount(context), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intent.putExtras(bundle);
@ -2548,7 +2547,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
if (status.reblog != null) {
args.putSerializable(Helper.ARG_MENTION_BOOSTER, status.account);
}
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(context).insertBundle(args, Helper.getCurrentAccount(context), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intent.putExtras(bundle);
@ -2823,7 +2822,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
Bundle args = new Bundle();
args.putInt(Helper.ARG_MEDIA_POSITION, mediaPosition);
args.putSerializable(Helper.ARG_MEDIA_ARRAY, new ArrayList<>(statusToDeal.media_attachments));
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(context).insertBundle(args, Helper.getCurrentAccount(context), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
mediaIntent.putExtras(bundle);
@ -2891,7 +2890,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
args.putBoolean(ARG_TIMELINE_REFRESH_ALL, true);
}
Intent intentBC = new Intent(Helper.RECEIVE_STATUS_ACTION);
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(context).insertBundle(args, Helper.getCurrentAccount(context), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intentBC.putExtras(bundle);
@ -3282,7 +3281,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
Intent intent = new Intent(context, ProfileActivity.class);
Bundle args = new Bundle();
args.putSerializable(Helper.ARG_ACCOUNT, status.account);
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(context).insertBundle(args, Helper.getCurrentAccount(context), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intent.putExtras(bundle);
@ -3297,7 +3296,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
ArrayList<Attachment> attachments = new ArrayList<>();
attachments.add(status.art_attachment);
args.putSerializable(Helper.ARG_MEDIA_ARRAY, attachments);
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(context).insertBundle(args, Helper.getCurrentAccount(context), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
mediaIntent.putExtras(bundle);
@ -3313,7 +3312,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
Intent intent = new Intent(context, ContextActivity.class);
Bundle args = new Bundle();
args.putSerializable(Helper.ARG_STATUS, status);
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(context).insertBundle(args, Helper.getCurrentAccount(context), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intent.putExtras(bundle);
@ -3348,7 +3347,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
Intent intent = new Intent(context, ProfileActivity.class);
Bundle args = new Bundle();
args.putSerializable(Helper.ARG_ACCOUNT, statusToDeal.account);
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(context).insertBundle(args, Helper.getCurrentAccount(context), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intent.putExtras(bundle);
@ -3359,7 +3358,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
Intent intent = new Intent(context, ContextActivity.class);
Bundle args = new Bundle();
args.putSerializable(Helper.ARG_STATUS, statusToDeal);
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(context).insertBundle(args, Helper.getCurrentAccount(context), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intent.putExtras(bundle);

View file

@ -15,7 +15,6 @@ package app.fedilab.android.mastodon.ui.drawer;
* see <http://www.gnu.org/licenses>. */
import static app.fedilab.android.BaseMainActivity.currentAccount;
import static app.fedilab.android.mastodon.ui.drawer.StatusAdapter.prepareRequestBuilder;
import android.app.Activity;
@ -196,7 +195,7 @@ public class StatusDirectMessageAdapter extends RecyclerView.Adapter<RecyclerVie
Bundle args = new Bundle();
args.putInt(Helper.ARG_MEDIA_POSITION, mediaPosition);
args.putSerializable(Helper.ARG_MEDIA_ARRAY, new ArrayList<>(status.media_attachments));
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(context).insertBundle(args, Helper.getCurrentAccount(context), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
mediaIntent.putExtras(bundle);
@ -675,7 +674,7 @@ public class StatusDirectMessageAdapter extends RecyclerView.Adapter<RecyclerVie
Bundle args = new Bundle();
args.putInt(Helper.ARG_MEDIA_POSITION, finalMediaPosition);
args.putSerializable(Helper.ARG_MEDIA_ARRAY, new ArrayList<>(status.media_attachments));
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(context).insertBundle(args, Helper.getCurrentAccount(context), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
mediaIntent.putExtras(bundle);

View file

@ -15,8 +15,6 @@ package app.fedilab.android.mastodon.ui.drawer;
* see <http://www.gnu.org/licenses>. */
import static app.fedilab.android.BaseMainActivity.currentAccount;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
@ -106,7 +104,7 @@ public class StatusDraftAdapter extends RecyclerView.Adapter<StatusDraftAdapter.
Intent intent = new Intent(context, ComposeActivity.class);
Bundle args = new Bundle();
args.putSerializable(Helper.ARG_STATUS_DRAFT, statusDraft);
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(context).insertBundle(args, Helper.getCurrentAccount(context), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intent.putExtras(bundle);

View file

@ -16,7 +16,6 @@ package app.fedilab.android.mastodon.ui.drawer;
import static androidx.core.text.HtmlCompat.FROM_HTML_MODE_LEGACY;
import static app.fedilab.android.BaseMainActivity.currentAccount;
import android.content.Context;
import android.content.Intent;
@ -131,7 +130,7 @@ public class StatusScheduledAdapter extends RecyclerView.Adapter<StatusScheduled
Intent intent = new Intent(context, ComposeActivity.class);
Bundle args = new Bundle();
args.putSerializable(Helper.ARG_STATUS_DRAFT, statusDraft);
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(context).insertBundle(args, Helper.getCurrentAccount(context), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intent.putExtras(bundle);

View file

@ -15,8 +15,6 @@ package app.fedilab.android.mastodon.ui.drawer;
* see <http://www.gnu.org/licenses>. */
import static app.fedilab.android.BaseMainActivity.currentAccount;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
@ -90,7 +88,7 @@ public class SuggestionAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
Intent intent = new Intent(context, ProfileActivity.class);
Bundle args = new Bundle();
args.putSerializable(Helper.ARG_ACCOUNT, account);
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(context).insertBundle(args, Helper.getCurrentAccount(context), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intent.putExtras(bundle);

View file

@ -14,7 +14,6 @@ package app.fedilab.android.mastodon.ui.drawer;
* You should have received a copy of the GNU General Public License along with Fedilab; if not,
* see <http://www.gnu.org/licenses>. */
import static app.fedilab.android.BaseMainActivity.currentAccount;
import android.content.Context;
import android.content.Intent;
@ -105,7 +104,7 @@ public class TagAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
Intent intent = new Intent(context, HashTagActivity.class);
Bundle args = new Bundle();
args.putString(Helper.ARG_SEARCH_KEYWORD, tag.name.trim());
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(context).insertBundle(args, Helper.getCurrentAccount(context), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intent.putExtras(bundle);

View file

@ -15,8 +15,6 @@ package app.fedilab.android.mastodon.ui.drawer.admin;
* see <http://www.gnu.org/licenses>. */
import static app.fedilab.android.BaseMainActivity.currentAccount;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
@ -82,7 +80,7 @@ public class AdminAccountAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
Intent intent = new Intent(context, AdminAccountActivity.class);
Bundle args = new Bundle();
args.putSerializable(Helper.ARG_ACCOUNT, adminAccount);
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(context).insertBundle(args, Helper.getCurrentAccount(context), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intent.putExtras(bundle);

View file

@ -14,7 +14,6 @@ package app.fedilab.android.mastodon.ui.fragment.media;
* You should have received a copy of the GNU General Public License along with Fedilab; if not,
* see <http://www.gnu.org/licenses>. */
import static app.fedilab.android.BaseMainActivity.currentAccount;
import android.content.SharedPreferences;
import android.os.Bundle;
@ -84,11 +83,11 @@ public class FragmentMediaProfile extends Fragment {
if (arguments != null) {
long bundleId = arguments.getLong(Helper.ARG_INTENT_ID, -1);
if (bundleId != -1) {
new CachedBundle(requireActivity()).getBundle(bundleId, currentAccount, this::initializeAfterBundle);
new CachedBundle(requireActivity()).getBundle(bundleId, Helper.getCurrentAccount(requireActivity()), this::initializeAfterBundle);
} else {
if (arguments.containsKey(Helper.ARG_CACHED_ACCOUNT_ID)) {
try {
accountTimeline = new CachedBundle(requireActivity()).getCachedAccount(currentAccount, arguments.getString(Helper.ARG_CACHED_ACCOUNT_ID));
accountTimeline = new CachedBundle(requireActivity()).getCachedAccount(Helper.getCurrentAccount(requireActivity()), arguments.getString(Helper.ARG_CACHED_ACCOUNT_ID));
} catch (DBException e) {
e.printStackTrace();
}

View file

@ -133,7 +133,7 @@ public class FragmentHomeCacheSettings extends PreferenceFragmentCompat implemen
editor.putBoolean(getString(R.string.SET_FETCH_HOME) + MainActivity.currentUserID + MainActivity.currentInstance, SET_FETCH_HOME.isChecked());
editor.commit();
if (SET_FETCH_HOME.isChecked()) {
FetchHomeWorker.setRepeatHome(requireActivity(), MainActivity.currentAccount, inputData);
FetchHomeWorker.setRepeatHome(requireActivity(), Helper.getCurrentAccount(requireActivity()), inputData);
} else {
WorkManager.getInstance(requireActivity()).cancelAllWorkByTag(Helper.WORKER_REFRESH_HOME + MainActivity.currentUserID + MainActivity.currentInstance);
}
@ -145,7 +145,7 @@ public class FragmentHomeCacheSettings extends PreferenceFragmentCompat implemen
SharedPreferences.Editor editor = sharedpreferences.edit();
editor.putString(getString(R.string.SET_FETCH_HOME_DELAY_VALUE) + MainActivity.currentUserID + MainActivity.currentInstance, SET_FETCH_HOME_DELAY_VALUE.getValue());
editor.commit();
FetchHomeWorker.setRepeatHome(requireActivity(), MainActivity.currentAccount, inputData);
FetchHomeWorker.setRepeatHome(requireActivity(), Helper.getCurrentAccount(requireActivity()), inputData);
}
}
}

View file

@ -15,7 +15,6 @@ package app.fedilab.android.mastodon.ui.fragment.timeline;
* see <http://www.gnu.org/licenses>. */
import static app.fedilab.android.BaseMainActivity.currentAccount;
import static app.fedilab.android.BaseMainActivity.currentInstance;
import static app.fedilab.android.BaseMainActivity.currentToken;
import static app.fedilab.android.mastodon.helper.MastodonHelper.ACCOUNTS_PER_CALL;
@ -137,11 +136,11 @@ public class FragmentMastodonAccount extends Fragment {
if (arguments != null) {
long bundleId = arguments.getLong(Helper.ARG_INTENT_ID, -1);
if (bundleId != -1) {
new CachedBundle(requireActivity()).getBundle(bundleId, currentAccount, this::initializeAfterBundle);
new CachedBundle(requireActivity()).getBundle(bundleId, Helper.getCurrentAccount(requireActivity()), this::initializeAfterBundle);
} else {
if (arguments.containsKey(Helper.ARG_CACHED_ACCOUNT_ID)) {
try {
accountTimeline = new CachedBundle(requireActivity()).getCachedAccount(currentAccount, arguments.getString(Helper.ARG_CACHED_ACCOUNT_ID));
accountTimeline = new CachedBundle(requireActivity()).getCachedAccount(Helper.getCurrentAccount(requireActivity()), arguments.getString(Helper.ARG_CACHED_ACCOUNT_ID));
} catch (DBException e) {
e.printStackTrace();
}
@ -233,7 +232,7 @@ public class FragmentMastodonAccount extends Fragment {
}
} else if (timelineType == Timeline.TimeLineEnum.MUTED_TIMELINE_HOME) {
if (firstLoad) {
accountsVM.getMutedHome(currentAccount)
accountsVM.getMutedHome(Helper.getCurrentAccount(requireActivity()))
.observe(getViewLifecycleOwner(), this::initializeAccountCommonView);
}
} else if (timelineType == Timeline.TimeLineEnum.BLOCKED_TIMELINE) {

View file

@ -14,7 +14,7 @@ package app.fedilab.android.mastodon.ui.fragment.timeline;
* You should have received a copy of the GNU General Public License along with Fedilab; if not,
* see <http://www.gnu.org/licenses>. */
import static app.fedilab.android.BaseMainActivity.currentAccount;
import static app.fedilab.android.mastodon.activities.ContextActivity.displayCW;
import static app.fedilab.android.mastodon.activities.ContextActivity.expand;
@ -67,7 +67,7 @@ public class FragmentMastodonContext extends Fragment {
Bundle args = intent.getExtras();
if (args != null) {
long bundleId = args.getLong(Helper.ARG_INTENT_ID, -1);
new CachedBundle(requireActivity()).getBundle(bundleId, currentAccount, bundle -> {
new CachedBundle(requireActivity()).getBundle(bundleId, Helper.getCurrentAccount(requireActivity()), bundle -> {
Status receivedStatus = (Status) bundle.getSerializable(Helper.ARG_STATUS_ACTION);
String delete_statuses_for_user = bundle.getString(Helper.ARG_STATUS_ACCOUNT_ID_DELETED);
Status status_to_delete = (Status) bundle.getSerializable(Helper.ARG_STATUS_DELETED);
@ -176,7 +176,7 @@ public class FragmentMastodonContext extends Fragment {
super.onViewCreated(view, savedInstanceState);
if (arguments != null) {
long bundleId = arguments.getLong(Helper.ARG_INTENT_ID, -1);
new CachedBundle(requireActivity()).getBundle(bundleId, currentAccount, this::initializeAfterBundle);
new CachedBundle(requireActivity()).getBundle(bundleId, Helper.getCurrentAccount(requireActivity()), this::initializeAfterBundle);
} else {
initializeAfterBundle(null);
}

View file

@ -15,8 +15,6 @@ package app.fedilab.android.mastodon.ui.fragment.timeline;
* see <http://www.gnu.org/licenses>. */
import static app.fedilab.android.BaseMainActivity.currentAccount;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;
@ -358,14 +356,14 @@ public class FragmentMastodonConversation extends Fragment implements Conversati
@Override
public void onDestroyView() {
if (isAdded()) {
storeMarker(currentAccount);
storeMarker(Helper.getCurrentAccount(requireActivity()));
}
super.onDestroyView();
}
@Override
public void onPause() {
storeMarker(currentAccount);
storeMarker(Helper.getCurrentAccount(requireActivity()));
super.onPause();
}

View file

@ -14,7 +14,7 @@ package app.fedilab.android.mastodon.ui.fragment.timeline;
* You should have received a copy of the GNU General Public License along with Fedilab; if not,
* see <http://www.gnu.org/licenses>. */
import static app.fedilab.android.BaseMainActivity.currentAccount;
import static app.fedilab.android.BaseMainActivity.currentInstance;
import static app.fedilab.android.BaseMainActivity.currentToken;
import static app.fedilab.android.BaseMainActivity.currentUserID;
@ -115,7 +115,7 @@ public class FragmentMastodonDirectMessage extends Fragment {
Bundle args = intent.getExtras();
if (args != null) {
long bundleId = args.getLong(Helper.ARG_INTENT_ID, -1);
new CachedBundle(requireActivity()).getBundle(bundleId, currentAccount, bundle -> {
new CachedBundle(requireActivity()).getBundle(bundleId, Helper.getCurrentAccount(requireActivity()), bundle -> {
if (bundle.getBoolean(Helper.RECEIVE_NEW_MESSAGE, false)) {
Status statusReceived = (Status) bundle.getSerializable(Helper.RECEIVE_STATUS_ACTION);
if (statusReceived != null) {
@ -137,7 +137,7 @@ public class FragmentMastodonDirectMessage extends Fragment {
binding = FragmentDirectMessageBinding.inflate(inflater, container, false);
if (getArguments() != null) {
long bundleId = getArguments().getLong(Helper.ARG_INTENT_ID, -1);
new CachedBundle(requireActivity()).getBundle(bundleId, currentAccount, this::initializeAfterBundle);
new CachedBundle(requireActivity()).getBundle(bundleId, Helper.getCurrentAccount(requireActivity()), this::initializeAfterBundle);
} else {
initializeAfterBundle(null);
}
@ -569,7 +569,7 @@ public class FragmentMastodonDirectMessage extends Fragment {
statusCompose.in_reply_to_id = lastStatus.id;
statusCompose.visibility = "direct";
statusCompose.mentions = new ArrayList<>();
if (lastStatus.account.acct != null && currentAccount.mastodon_account != null && !lastStatus.account.acct.equalsIgnoreCase(currentAccount.mastodon_account.acct)) {
if (lastStatus.account.acct != null && Helper.getCurrentAccount(requireActivity()).mastodon_account != null && !lastStatus.account.acct.equalsIgnoreCase(Helper.getCurrentAccount(requireActivity()).mastodon_account.acct)) {
Mention mention = new Mention();
mention.acct = "@" + lastStatus.account.acct;
mention.url = lastStatus.account.url;
@ -579,7 +579,7 @@ public class FragmentMastodonDirectMessage extends Fragment {
//There are other mentions to
if (lastStatus.mentions != null && lastStatus.mentions.size() > 0) {
for (Mention mentionTmp : lastStatus.mentions) {
if (currentAccount.mastodon_account != null && !mentionTmp.acct.equalsIgnoreCase(currentAccount.mastodon_account.acct)) {
if (Helper.getCurrentAccount(requireActivity()).mastodon_account != null && !mentionTmp.acct.equalsIgnoreCase(Helper.getCurrentAccount(requireActivity()).mastodon_account.acct)) {
statusCompose.mentions.add(mentionTmp);
}
}

View file

@ -14,7 +14,6 @@ package app.fedilab.android.mastodon.ui.fragment.timeline;
* You should have received a copy of the GNU General Public License along with Fedilab; if not,
* see <http://www.gnu.org/licenses>. */
import static app.fedilab.android.BaseMainActivity.currentAccount;
import android.content.BroadcastReceiver;
import android.content.Context;
@ -78,7 +77,7 @@ public class FragmentMastodonNotification extends Fragment implements Notificati
Bundle args = intent.getExtras();
if (args != null) {
long bundleId = args.getLong(Helper.ARG_INTENT_ID, -1);
new CachedBundle(requireActivity()).getBundle(bundleId, currentAccount, bundle -> {
new CachedBundle(requireActivity()).getBundle(bundleId, Helper.getCurrentAccount(requireActivity()), bundle -> {
Status receivedStatus = (Status) bundle.getSerializable(Helper.ARG_STATUS_ACTION);
String delete_all_for_account_id = bundle.getString(Helper.ARG_DELETE_ALL_FOR_ACCOUNT_ID);
boolean refreshNotifications = bundle.getBoolean(Helper.ARG_REFRESH_NOTFICATION, false);
@ -691,14 +690,14 @@ public class FragmentMastodonNotification extends Fragment implements Notificati
e.printStackTrace();
}
if (isAdded()) {
storeMarker(currentAccount);
storeMarker(Helper.getCurrentAccount(requireActivity()));
}
super.onDestroyView();
}
@Override
public void onPause() {
storeMarker(currentAccount);
storeMarker(Helper.getCurrentAccount(requireActivity()));
super.onPause();
}

View file

@ -15,7 +15,6 @@ package app.fedilab.android.mastodon.ui.fragment.timeline;
* see <http://www.gnu.org/licenses>. */
import static app.fedilab.android.BaseMainActivity.currentAccount;
import static app.fedilab.android.BaseMainActivity.currentInstance;
import static app.fedilab.android.BaseMainActivity.networkAvailable;
@ -98,7 +97,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
Bundle args = intent.getExtras();
if (args != null) {
long bundleId = args.getLong(Helper.ARG_INTENT_ID, -1);
new CachedBundle(requireActivity()).getBundle(bundleId, currentAccount, bundle -> {
new CachedBundle(requireActivity()).getBundle(bundleId, Helper.getCurrentAccount(requireActivity()), bundle -> {
Status receivedStatus = (Status) bundle.getSerializable(Helper.ARG_STATUS_ACTION);
String delete_statuses_for_user = bundle.getString(Helper.ARG_STATUS_ACCOUNT_ID_DELETED);
String delete_all_for_account_id = bundle.getString(Helper.ARG_DELETE_ALL_FOR_ACCOUNT_ID);
@ -378,11 +377,11 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
if (arguments != null) {
long bundleId = arguments.getLong(Helper.ARG_INTENT_ID, -1);
if (bundleId != -1) {
new CachedBundle(requireActivity()).getBundle(bundleId, currentAccount, this::initializeAfterBundle);
new CachedBundle(requireActivity()).getBundle(bundleId, Helper.getCurrentAccount(requireActivity()), this::initializeAfterBundle);
} else {
if (arguments.containsKey(Helper.ARG_CACHED_ACCOUNT_ID)) {
try {
accountTimeline = new CachedBundle(requireActivity()).getCachedAccount(currentAccount, arguments.getString(Helper.ARG_CACHED_ACCOUNT_ID));
accountTimeline = new CachedBundle(requireActivity()).getCachedAccount(Helper.getCurrentAccount(requireActivity()), arguments.getString(Helper.ARG_CACHED_ACCOUNT_ID));
} catch (DBException e) {
e.printStackTrace();
}
@ -855,7 +854,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
@Override
public void onPause() {
storeMarker(currentAccount);
storeMarker(Helper.getCurrentAccount(requireActivity()));
super.onPause();
}
@ -863,7 +862,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
public void onDestroyView() {
//Update last read id for home timeline
if (isAdded()) {
storeMarker(currentAccount);
storeMarker(Helper.getCurrentAccount(requireActivity()));
}
try {
requireActivity().unregisterReceiver(receive_action);
@ -1143,7 +1142,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
}
initializeStatusesCommonView(otherStatuses);
}));
} else if(accountTimeline != null){
} else if (accountTimeline != null) {
tempToken[0] = MainActivity.currentToken;
tempInstance[0] = currentInstance;
accountId[0] = accountTimeline.id;
@ -1154,7 +1153,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
} else {
accountId[0] = accountIDInRemoteInstance;
}
} else if(accountTimeline != null){
} else if (accountTimeline != null) {
tempToken[0] = MainActivity.currentToken;
tempInstance[0] = currentInstance;
accountId[0] = accountTimeline.id;

View file

@ -42,6 +42,7 @@ import app.fedilab.android.BaseMainActivity;
import app.fedilab.android.R;
import app.fedilab.android.databinding.FragmentNotificationContainerBinding;
import app.fedilab.android.databinding.PopupNotificationSettingsBinding;
import app.fedilab.android.mastodon.helper.Helper;
import app.fedilab.android.mastodon.ui.pageadapter.FedilabNotificationPageAdapter;
import app.fedilab.android.mastodon.viewmodel.mastodon.NotificationsVM;
import es.dmoral.toasty.Toasty;
@ -258,9 +259,9 @@ public class FragmentNotificationContainer extends Fragment {
public void onResume() {
super.onResume();
NotificationManager mNotificationManager = (NotificationManager) requireActivity().getSystemService(Context.NOTIFICATION_SERVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && BaseMainActivity.currentAccount != null && BaseMainActivity.currentAccount.mastodon_account != null) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && Helper.getCurrentAccount(requireActivity()) != null && Helper.getCurrentAccount(requireActivity()).mastodon_account != null) {
for (StatusBarNotification statusBarNotification : mNotificationManager.getActiveNotifications()) {
if (statusBarNotification.getGroupKey().contains(BaseMainActivity.currentAccount.mastodon_account.acct + "@" + BaseMainActivity.currentAccount.instance)) {
if (statusBarNotification.getGroupKey().contains(Helper.getCurrentAccount(requireActivity()).mastodon_account.acct + "@" + Helper.getCurrentAccount(requireActivity()).instance)) {
mNotificationManager.cancel(statusBarNotification.getId());
}
}

View file

@ -14,7 +14,6 @@ package app.fedilab.android.mastodon.ui.fragment.timeline;
* You should have received a copy of the GNU General Public License along with Fedilab; if not,
* see <http://www.gnu.org/licenses>. */
import static app.fedilab.android.BaseMainActivity.currentAccount;
import android.os.Bundle;
import android.view.LayoutInflater;
@ -62,7 +61,7 @@ public class FragmentProfileTimeline extends Fragment {
if (arguments != null) {
String cached_account_id = arguments.getString(Helper.ARG_CACHED_ACCOUNT_ID);
try {
account = new CachedBundle(requireActivity()).getCachedAccount(currentAccount, cached_account_id);
account = new CachedBundle(requireActivity()).getCachedAccount(Helper.getCurrentAccount(requireActivity()), cached_account_id);
} catch (DBException e) {
e.printStackTrace();
}
@ -126,7 +125,7 @@ public class FragmentProfileTimeline extends Fragment {
args.putBoolean(Helper.ARG_CHECK_REMOTELY, checkRemotely);
args.putBoolean(Helper.ARG_SHOW_REBLOGS, show_boosts);
args.putBoolean(Helper.ARG_SHOW_REPLIES, show_replies);
new CachedBundle(requireActivity()).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(requireActivity()).insertBundle(args, Helper.getCurrentAccount(requireActivity()), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
fragmentMastodonTimeline.setArguments(bundle);

View file

@ -14,7 +14,6 @@ package app.fedilab.android.mastodon.ui.fragment.timeline;
* You should have received a copy of the GNU General Public License along with Fedilab; if not,
* see <http://www.gnu.org/licenses>. */
import static app.fedilab.android.BaseMainActivity.currentAccount;
import android.os.Bundle;
import android.os.Handler;
@ -82,7 +81,7 @@ public class FragmentScheduled extends Fragment implements StatusScheduledAdapte
} else if (type == Timeline.TimeLineEnum.SCHEDULED_TOOT_CLIENT) {
new Thread(() -> {
try {
List<StatusDraft> scheduledDrafts = new StatusDraft(requireActivity()).geStatusDraftScheduledList(currentAccount);
List<StatusDraft> scheduledDrafts = new StatusDraft(requireActivity()).geStatusDraftScheduledList(Helper.getCurrentAccount(requireActivity()));
Handler mainHandler = new Handler(Looper.getMainLooper());
Runnable myRunnable = () -> {
binding.loader.setVisibility(View.GONE);
@ -107,7 +106,7 @@ public class FragmentScheduled extends Fragment implements StatusScheduledAdapte
} else if (type == Timeline.TimeLineEnum.SCHEDULED_BOOST) {
new Thread(() -> {
try {
List<ScheduledBoost> scheduledBoosts = new ScheduledBoost(requireActivity()).getScheduled(currentAccount);
List<ScheduledBoost> scheduledBoosts = new ScheduledBoost(requireActivity()).getScheduled(Helper.getCurrentAccount(requireActivity()));
Handler mainHandler = new Handler(Looper.getMainLooper());
Runnable myRunnable = () -> {
binding.loader.setVisibility(View.GONE);

View file

@ -14,7 +14,6 @@ package app.fedilab.android.mastodon.viewmodel.mastodon;
* You should have received a copy of the GNU General Public License along with Fedilab; if not,
* see <http://www.gnu.org/licenses>. */
import static app.fedilab.android.BaseMainActivity.currentAccount;
import android.app.Application;
import android.net.Uri;
@ -345,7 +344,7 @@ public class AccountsVM extends AndroidViewModel {
Response<Account> accountResponse = accountCall.execute();
if (accountResponse.isSuccessful()) {
account = accountResponse.body();
new CachedBundle(getApplication().getApplicationContext()).insertAccountBundle(account, currentAccount);
new CachedBundle(getApplication().getApplicationContext()).insertAccountBundle(account, Helper.getCurrentAccount(getApplication().getApplicationContext()));
}
} catch (Exception e) {
e.printStackTrace();
@ -1078,7 +1077,7 @@ public class AccountsVM extends AndroidViewModel {
if (searchResponse.isSuccessful()) {
accountList = searchResponse.body();
if (accountList != null && accountList.size() > 0) {
new CachedBundle(getApplication().getApplicationContext()).insertAccountBundle(accountList.get(0), currentAccount);
new CachedBundle(getApplication().getApplicationContext()).insertAccountBundle(accountList.get(0), Helper.getCurrentAccount(getApplication().getApplicationContext()));
}
}
} catch (Exception e) {

View file

@ -14,7 +14,6 @@ package app.fedilab.android.mastodon.viewmodel.mastodon;
* You should have received a copy of the GNU General Public License along with Fedilab; if not,
* see <http://www.gnu.org/licenses>. */
import static app.fedilab.android.BaseMainActivity.currentAccount;
import android.app.Application;
import android.content.SharedPreferences;
@ -70,7 +69,7 @@ public class ReorderVM extends AndroidViewModel {
new Thread(() -> {
Pinned pinned = null;
try {
pinned = new Pinned(getApplication().getApplicationContext()).getAllPinned(currentAccount);
pinned = new Pinned(getApplication().getApplicationContext()).getAllPinned(Helper.getCurrentAccount(getApplication().getApplicationContext()));
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(getApplication().getApplicationContext());
boolean singleBar = sharedpreferences.getBoolean(getApplication().getApplicationContext().getString(R.string.SET_USE_SINGLE_TOPBAR), false);
List<PinnedTimeline> pinnedTimelinesToRemove = new ArrayList<>();
@ -111,7 +110,7 @@ public class ReorderVM extends AndroidViewModel {
new Thread(() -> {
Pinned pinned = null;
try {
pinned = new Pinned(getApplication().getApplicationContext()).getAllPinned(currentAccount);
pinned = new Pinned(getApplication().getApplicationContext()).getAllPinned(Helper.getCurrentAccount(getApplication().getApplicationContext()));
} catch (DBException e) {
e.printStackTrace();
@ -130,7 +129,7 @@ public class ReorderVM extends AndroidViewModel {
new Thread(() -> {
BottomMenu bottomMenu = null;
try {
bottomMenu = new BottomMenu(getApplication().getApplicationContext()).getAllBottomMenu(currentAccount);
bottomMenu = new BottomMenu(getApplication().getApplicationContext()).getAllBottomMenu(Helper.getCurrentAccount(getApplication().getApplicationContext()));
} catch (DBException e) {
e.printStackTrace();
}

View file

@ -14,7 +14,6 @@ package app.fedilab.android.mastodon.viewmodel.mastodon;
* You should have received a copy of the GNU General Public License along with Fedilab; if not,
* see <http://www.gnu.org/licenses>. */
import static app.fedilab.android.BaseMainActivity.currentAccount;
import android.app.Application;
import android.os.Handler;
@ -27,6 +26,7 @@ import androidx.lifecycle.MutableLiveData;
import app.fedilab.android.mastodon.client.entities.app.Pinned;
import app.fedilab.android.mastodon.exception.DBException;
import app.fedilab.android.mastodon.helper.Helper;
public class TopBarVM extends AndroidViewModel {
@ -44,7 +44,7 @@ public class TopBarVM extends AndroidViewModel {
Handler mainHandler = new Handler(Looper.getMainLooper());
Pinned pinnedTimeline = null;
try {
pinnedTimeline = pinned.getPinned(currentAccount);
pinnedTimeline = pinned.getPinned(Helper.getCurrentAccount(getApplication().getApplicationContext()));
} catch (DBException e) {
e.printStackTrace();
}

View file

@ -16,7 +16,6 @@ package app.fedilab.android.peertube.activities;
import static androidx.media3.common.Player.MEDIA_ITEM_TRANSITION_REASON_AUTO;
import static app.fedilab.android.BaseMainActivity.currentAccount;
import static app.fedilab.android.BaseMainActivity.currentInstance;
import static app.fedilab.android.BaseMainActivity.currentToken;
import static app.fedilab.android.mastodon.helper.Helper.PREF_USER_TOKEN;
@ -289,8 +288,8 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis
sepiaSearch = b.getBoolean("sepia_search", false);
peertube = (VideoData.Video) b.getSerializable("video");
}
if (currentAccount != null && currentAccount.peertube_account != null) {
binding.myAcct.setText(String.format("@%s@%s", currentAccount.peertube_account.getUsername(), currentAccount.instance));
if (app.fedilab.android.mastodon.helper.Helper.getCurrentAccount(PeertubeActivity.this) != null && app.fedilab.android.mastodon.helper.Helper.getCurrentAccount(PeertubeActivity.this).peertube_account != null) {
binding.myAcct.setText(String.format("@%s@%s", app.fedilab.android.mastodon.helper.Helper.getCurrentAccount(PeertubeActivity.this).peertube_account.getUsername(), app.fedilab.android.mastodon.helper.Helper.getCurrentAccount(PeertubeActivity.this).instance));
}
//If the activity was called from a URL
willPlayFromIntent = manageIntentUrl(intent);

View file

@ -14,7 +14,7 @@ package app.fedilab.android.peertube.activities;
* You should have received a copy of the GNU General Public License along with Fedilab; if not,
* see <http://www.gnu.org/licenses>. */
import static app.fedilab.android.BaseMainActivity.currentAccount;
import static app.fedilab.android.BaseMainActivity.currentInstance;
import static app.fedilab.android.BaseMainActivity.currentToken;
import static app.fedilab.android.BaseMainActivity.currentUserID;
@ -275,7 +275,7 @@ public class PeertubeMainActivity extends PeertubeBaseMainActivity {
mostLikedFragment.setArguments(bundle);
currentAccount = null;
app.fedilab.android.mastodon.helper.Helper.setCurrentAccount(null);
if (Helper.isLoggedIn()) {
NavHeaderMainBinding headerMainBinding = NavHeaderMainBinding.inflate(getLayoutInflater());
new Thread(() -> {
@ -283,20 +283,20 @@ public class PeertubeMainActivity extends PeertubeBaseMainActivity {
if (currentToken == null) {
currentToken = sharedpreferences.getString(app.fedilab.android.mastodon.helper.Helper.PREF_USER_TOKEN, null);
}
currentAccount = new Account(PeertubeMainActivity.this).getConnectedAccount();
if (currentAccount == null) {
app.fedilab.android.mastodon.helper.Helper.setCurrentAccount(new Account(PeertubeMainActivity.this).getConnectedAccount());
if (app.fedilab.android.mastodon.helper.Helper.getCurrentAccount(PeertubeMainActivity.this) == null) {
if (currentUserID == null) {
currentUserID = sharedpreferences.getString(PREF_USER_ID, null);
}
if (currentInstance == null) {
currentInstance = sharedpreferences.getString(PREF_USER_INSTANCE, null);
}
currentAccount = new Account(PeertubeMainActivity.this).getUniqAccount(currentUserID, currentInstance);
app.fedilab.android.mastodon.helper.Helper.setCurrentAccount(new Account(PeertubeMainActivity.this).getUniqAccount(currentUserID, currentInstance));
}
} catch (DBException e) {
e.printStackTrace();
}
if (currentAccount != null && currentAccount.mastodon_account != null && typeOfConnection != TypeOfConnection.REMOTE_ACCOUNT) {
if (app.fedilab.android.mastodon.helper.Helper.getCurrentAccount(PeertubeMainActivity.this) != null && app.fedilab.android.mastodon.helper.Helper.getCurrentAccount(PeertubeMainActivity.this).mastodon_account != null && typeOfConnection != TypeOfConnection.REMOTE_ACCOUNT) {
//It is a Mastodon User
Intent myIntent = new Intent(PeertubeMainActivity.this, MainActivity.class);
startActivity(myIntent);
@ -304,10 +304,10 @@ public class PeertubeMainActivity extends PeertubeBaseMainActivity {
return;
}
//If the attached account is null, the app will fetch remote instance to get up-to-date values
if (currentAccount != null && currentAccount.peertube_account == null) {
if (app.fedilab.android.mastodon.helper.Helper.getCurrentAccount(PeertubeMainActivity.this) != null && app.fedilab.android.mastodon.helper.Helper.getCurrentAccount(PeertubeMainActivity.this).peertube_account == null) {
try {
userMe = new RetrofitPeertubeAPI(PeertubeMainActivity.this, currentInstance, currentToken).verifyCredentials();
currentAccount.peertube_account = userMe.getAccount();
app.fedilab.android.mastodon.helper.Helper.setCurrentAccountPeertubeAccount(PeertubeMainActivity.this, userMe.getAccount());
} catch (Error e) {
e.printStackTrace();
}
@ -315,15 +315,15 @@ public class PeertubeMainActivity extends PeertubeBaseMainActivity {
Handler mainHandler = new Handler(Looper.getMainLooper());
Runnable myRunnable = () -> {
if (typeOfConnection == TypeOfConnection.REMOTE_ACCOUNT) {
headerMainBinding.accountAcc.setText(String.format("%s@%s", currentAccount.mastodon_account.username, currentAccount.instance));
if (currentAccount.mastodon_account.display_name == null || currentAccount.mastodon_account.display_name.isEmpty()) {
currentAccount.mastodon_account.display_name = currentAccount.mastodon_account.acct;
headerMainBinding.accountAcc.setText(String.format("%s@%s", app.fedilab.android.mastodon.helper.Helper.getCurrentAccount(PeertubeMainActivity.this).mastodon_account.username, app.fedilab.android.mastodon.helper.Helper.getCurrentAccount(PeertubeMainActivity.this).instance));
if (app.fedilab.android.mastodon.helper.Helper.getCurrentAccount(PeertubeMainActivity.this).mastodon_account.display_name == null || app.fedilab.android.mastodon.helper.Helper.getCurrentAccount(PeertubeMainActivity.this).mastodon_account.display_name.isEmpty()) {
app.fedilab.android.mastodon.helper.Helper.getCurrentAccount(PeertubeMainActivity.this).mastodon_account.display_name = app.fedilab.android.mastodon.helper.Helper.getCurrentAccount(PeertubeMainActivity.this).mastodon_account.acct;
}
headerMainBinding.accountName.setText(currentAccount.mastodon_account.display_name);
headerMainBinding.accountName.setText(app.fedilab.android.mastodon.helper.Helper.getCurrentAccount(PeertubeMainActivity.this).mastodon_account.display_name);
float scale = sharedpreferences.getFloat(getString(R.string.SET_FONT_SCALE), 1.1f);
headerMainBinding.accountName.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18 * 1.1f / scale);
headerMainBinding.accountAcc.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18 * 1.1f / scale);
app.fedilab.android.mastodon.helper.Helper.loadPP(PeertubeMainActivity.this, headerMainBinding.accountProfilePicture, currentAccount, false);
app.fedilab.android.mastodon.helper.Helper.loadPP(PeertubeMainActivity.this, headerMainBinding.accountProfilePicture, app.fedilab.android.mastodon.helper.Helper.getCurrentAccount(PeertubeMainActivity.this), false);
headerMainBinding.backgroundImage.setAlpha(0.5f);
headerMainBinding.accountAcc.setOnClickListener(v -> headerMainBinding.changeAccount.callOnClick());
headerMainBinding.changeAccount.setOnClickListener(v -> {
@ -332,15 +332,15 @@ public class PeertubeMainActivity extends PeertubeBaseMainActivity {
manageDrawerMenu(PeertubeMainActivity.this, binding.drawerNavView, headerMainBinding);
});
} else {
headerMainBinding.accountAcc.setText(String.format("%s@%s", currentAccount.peertube_account.getUsername(), currentAccount.instance));
if (currentAccount.peertube_account.getDisplayName() == null || currentAccount.peertube_account.getDisplayName().isEmpty()) {
currentAccount.peertube_account.setDisplayName(currentAccount.peertube_account.getAcct());
headerMainBinding.accountAcc.setText(String.format("%s@%s", app.fedilab.android.mastodon.helper.Helper.getCurrentAccount(PeertubeMainActivity.this).peertube_account.getUsername(), app.fedilab.android.mastodon.helper.Helper.getCurrentAccount(PeertubeMainActivity.this).instance));
if (app.fedilab.android.mastodon.helper.Helper.getCurrentAccount(PeertubeMainActivity.this).peertube_account.getDisplayName() == null || app.fedilab.android.mastodon.helper.Helper.getCurrentAccount(PeertubeMainActivity.this).peertube_account.getDisplayName().isEmpty()) {
app.fedilab.android.mastodon.helper.Helper.getCurrentAccount(PeertubeMainActivity.this).peertube_account.setDisplayName(app.fedilab.android.mastodon.helper.Helper.getCurrentAccount(PeertubeMainActivity.this).peertube_account.getAcct());
}
headerMainBinding.accountName.setText(currentAccount.peertube_account.getDisplayName());
headerMainBinding.accountName.setText(app.fedilab.android.mastodon.helper.Helper.getCurrentAccount(PeertubeMainActivity.this).peertube_account.getDisplayName());
float scale = sharedpreferences.getFloat(getString(R.string.SET_FONT_SCALE), 1.1f);
headerMainBinding.accountName.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18 * 1.1f / scale);
headerMainBinding.accountAcc.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18 * 1.1f / scale);
app.fedilab.android.mastodon.helper.Helper.loadPP(PeertubeMainActivity.this, headerMainBinding.accountProfilePicture, currentAccount, false);
app.fedilab.android.mastodon.helper.Helper.loadPP(PeertubeMainActivity.this, headerMainBinding.accountProfilePicture, app.fedilab.android.mastodon.helper.Helper.getCurrentAccount(PeertubeMainActivity.this), false);
headerMainBinding.backgroundImage.setAlpha(0.5f);
headerMainBinding.accountAcc.setOnClickListener(v -> headerMainBinding.changeAccount.callOnClick());
headerMainBinding.changeAccount.setOnClickListener(v -> {
@ -419,7 +419,7 @@ public class PeertubeMainActivity extends PeertubeBaseMainActivity {
currentToken = sharedpreferences.getString(app.fedilab.android.mastodon.helper.Helper.PREF_USER_TOKEN, null);
}
try {
currentAccount = new Account(PeertubeMainActivity.this).getConnectedAccount();
app.fedilab.android.mastodon.helper.Helper.setCurrentAccount(new Account(PeertubeMainActivity.this).getConnectedAccount());
} catch (DBException e) {
e.printStackTrace();
}
@ -427,7 +427,7 @@ public class PeertubeMainActivity extends PeertubeBaseMainActivity {
Runnable myRunnable = () -> {
binding.navView.inflateMenu(R.menu.bottom_nav_menu_peertube);
binding.drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
app.fedilab.android.mastodon.helper.Helper.loadPP(this, binding.profilePicture, currentAccount);
app.fedilab.android.mastodon.helper.Helper.loadPP(this, binding.profilePicture, app.fedilab.android.mastodon.helper.Helper.getCurrentAccount(PeertubeMainActivity.this));
};
mainHandler.post(myRunnable);
}).start();

View file

@ -15,8 +15,6 @@ package app.fedilab.android.ui.fragment;
* see <http://www.gnu.org/licenses>. */
import static app.fedilab.android.BaseMainActivity.currentAccount;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
@ -148,7 +146,7 @@ public class FragmentLoginPickInstanceMastodon extends Fragment implements Insta
Bundle args = new Bundle();
args.putSerializable(Helper.ARG_REMOTE_INSTANCE_STRING, clickedInstance.domain);
args.putSerializable(Helper.ARG_TIMELINE_TYPE, Timeline.TimeLineEnum.TREND_MESSAGE_PUBLIC);
new CachedBundle(requireActivity()).insertBundle(args, currentAccount, bundleId -> {
new CachedBundle(requireActivity()).insertBundle(args, Helper.getCurrentAccount(requireActivity()), bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
Helper.addFragment(