diff options
Diffstat (limited to 'app/src/main/java/app/fedilab/android/mastodon/activities/EditProfileActivity.java')
-rw-r--r-- | app/src/main/java/app/fedilab/android/mastodon/activities/EditProfileActivity.java | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/app/src/main/java/app/fedilab/android/mastodon/activities/EditProfileActivity.java b/app/src/main/java/app/fedilab/android/mastodon/activities/EditProfileActivity.java index 8d5a49f53..e180f8752 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/activities/EditProfileActivity.java +++ b/app/src/main/java/app/fedilab/android/mastodon/activities/EditProfileActivity.java @@ -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(); |