From f57051cbb36d4fbef224c02520b5a31704c0a2e8 Mon Sep 17 00:00:00 2001 From: mkljczk Date: Fri, 6 Dec 2024 17:00:03 +0100 Subject: [PATCH 1/2] Fetch custom emojis with auth token Signed-off-by: mkljczk --- .../android/api/session/AccountSession.java | 2 +- .../api/session/AccountSessionManager.java | 32 +++++++++---------- .../android/fragments/ComposeFragment.java | 4 +-- .../onboarding/AccountActivationFragment.java | 2 +- .../report/ReportReasonChoiceFragment.java | 4 ++- .../report/ReportRuleChoiceFragment.java | 4 ++- .../settings/SettingsServerAboutFragment.java | 4 ++- .../settings/SettingsServerRulesFragment.java | 4 ++- 8 files changed, 32 insertions(+), 24 deletions(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/api/session/AccountSession.java b/mastodon/src/main/java/org/joinmastodon/android/api/session/AccountSession.java index 00eca9a4..87fb24f1 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/api/session/AccountSession.java +++ b/mastodon/src/main/java/org/joinmastodon/android/api/session/AccountSession.java @@ -371,6 +371,6 @@ public class AccountSession{ } public Instance getInstanceInfo(){ - return AccountSessionManager.getInstance().getInstanceInfo(domain); + return AccountSessionManager.getInstance().getInstanceInfo(domain, token); } } diff --git a/mastodon/src/main/java/org/joinmastodon/android/api/session/AccountSessionManager.java b/mastodon/src/main/java/org/joinmastodon/android/api/session/AccountSessionManager.java index 729276d7..2f357c53 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/api/session/AccountSessionManager.java +++ b/mastodon/src/main/java/org/joinmastodon/android/api/session/AccountSessionManager.java @@ -107,13 +107,13 @@ public class AccountSessionManager{ private AccountSessionManager(){ prefs=MastodonApp.context.getSharedPreferences("account_manager", Context.MODE_PRIVATE); runWithDatabase(db->{ - HashSet domains=new HashSet<>(); + HashMap domains=new HashMap<>(); try(Cursor cursor=db.query("accounts", null, null, null, null, null, null)){ ContentValues values=new ContentValues(); while(cursor.moveToNext()){ DatabaseUtils.cursorRowToContentValues(cursor, values); AccountSession session=new AccountSession(values); - domains.add(session.domain.toLowerCase()); + domains.put(session.domain.toLowerCase(), session.token); sessions.put(session.getID(), session); } } @@ -135,7 +135,7 @@ public class AccountSessionManager{ session.toContentValues(values); db.insertWithOnConflict("accounts", null, values, SQLiteDatabase.CONFLICT_REPLACE); }); - updateInstanceEmojis(instance, instance.getDomain()); + updateInstanceEmojis(instance, instance.getDomain(), token); if(PushSubscriptionManager.arePushNotificationsAvailable()){ session.getPushSubscriptionManager().registerAccountForPush(null); } @@ -272,9 +272,9 @@ public class AccountSessionManager{ public void maybeUpdateLocalInfo(){ long now=System.currentTimeMillis(); - HashSet domains=new HashSet<>(); + HashMap domains=new HashMap<>(); for(AccountSession session:sessions.values()){ - domains.add(session.domain.toLowerCase()); + domains.put(session.domain.toLowerCase(), session.token); if(now-session.infoLastUpdated>24L*3600_000L){ updateSessionLocalInfo(session); } @@ -287,12 +287,12 @@ public class AccountSessionManager{ } } - private void maybeUpdateInstanceInfo(Set domains){ + private void maybeUpdateInstanceInfo(HashMap domains){ long now=System.currentTimeMillis(); - for(String domain:domains){ + for(String domain:domains.keySet()){ Long lastUpdated=instancesLastUpdated.get(domain); if(lastUpdated==null || now-lastUpdated>24L*3600_000L){ - updateInstanceInfo(domain); + updateInstanceInfo(domain, domains.get(domain)); } } } @@ -346,13 +346,13 @@ public class AccountSessionManager{ .exec(session.getID()); } - public void updateInstanceInfo(String domain){ + public void updateInstanceInfo(String domain, Token token){ loadInstanceInfo(domain, new Callback<>(){ @Override public void onSuccess(Instance instance){ instances.put(domain, instance); runOnDbThread(db->insertInstanceIntoDatabase(db, domain, instance, null, 0)); - updateInstanceEmojis(instance, domain); + updateInstanceEmojis(instance, domain, token); } @Override @@ -362,7 +362,7 @@ public class AccountSessionManager{ }); } - private void updateInstanceEmojis(Instance instance, String domain){ + private void updateInstanceEmojis(Instance instance, String domain, Token token){ new GetCustomEmojis() .setCallback(new Callback<>(){ @Override @@ -379,11 +379,11 @@ public class AccountSessionManager{ } }) - .execNoAuth(domain); + .exec(domain, token); } - private void readInstanceInfo(SQLiteDatabase db, Set domains){ - for(String domain : domains){ + private void readInstanceInfo(SQLiteDatabase db, HashMap domains){ + for(String domain : domains.keySet()){ final int maxEmojiLength=500000; try(Cursor cursor=db.rawQuery("SELECT domain, instance_obj, substr(emojis,1,?) AS emojis, length(emojis) AS emoji_length, last_updated, version FROM instances WHERE `domain` = ?", new String[]{String.valueOf(maxEmojiLength) , domain})) { @@ -446,7 +446,7 @@ public class AccountSessionManager{ return r==null ? Collections.emptyList() : r; } - public Instance getInstanceInfo(String domain){ + public Instance getInstanceInfo(String domain, Token token){ Instance i=instances.get(domain); if(i!=null) return i; @@ -456,7 +456,7 @@ public class AccountSessionManager{ InstanceV1 fake=new InstanceV1(); fake.uri=fake.title=domain; fake.description=fake.version=fake.email=""; - updateInstanceInfo(domain); + updateInstanceInfo(domain, token); return fake; } diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java index ce5eb9b6..1b778407 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java @@ -191,7 +191,7 @@ public class ComposeFragment extends MastodonToolbarFragment implements ComposeE self=session.self; instanceDomain=session.domain; customEmojis=AccountSessionManager.getInstance().getCustomEmojis(instanceDomain); - instance=AccountSessionManager.getInstance().getInstanceInfo(instanceDomain); + instance=AccountSessionManager.getInstance().getInstanceInfo(instanceDomain, session.token); if(getArguments().containsKey("editStatus")){ editingStatus=Parcels.unwrap(getArguments().getParcelable("editStatus")); } @@ -200,7 +200,7 @@ public class ComposeFragment extends MastodonToolbarFragment implements ComposeE return; } if(customEmojis.isEmpty()){ - AccountSessionManager.getInstance().updateInstanceInfo(instanceDomain); + AccountSessionManager.getInstance().updateInstanceInfo(instanceDomain, session.token); } if(instance.maxTootChars>0) diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/onboarding/AccountActivationFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/onboarding/AccountActivationFragment.java index d8e819b0..d899a156 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/onboarding/AccountActivationFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/onboarding/AccountActivationFragment.java @@ -176,7 +176,7 @@ public class AccountActivationFragment extends ToolbarFragment{ currentRequest=null; AccountSessionManager mgr=AccountSessionManager.getInstance(); AccountSession session=mgr.getAccount(accountID); - Instance instance=mgr.getInstanceInfo(session.domain); + Instance instance=mgr.getInstanceInfo(session.domain, session.token); mgr.removeAccount(accountID); mgr.addAccount(instance, session.token, result, session.app, null); String newID=mgr.getLastActiveAccountID(); diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/report/ReportReasonChoiceFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/report/ReportReasonChoiceFragment.java index 661e5330..40c6b4c2 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/report/ReportReasonChoiceFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/report/ReportReasonChoiceFragment.java @@ -17,6 +17,7 @@ import com.squareup.otto.Subscribe; import org.joinmastodon.android.E; import org.joinmastodon.android.R; +import org.joinmastodon.android.api.session.AccountSession; import org.joinmastodon.android.api.session.AccountSessionManager; import org.joinmastodon.android.events.FinishReportFragmentsEvent; import org.joinmastodon.android.fragments.StatusListFragment; @@ -94,7 +95,8 @@ public class ReportReasonChoiceFragment extends StatusListFragment{ items.add(new ChoiceItem(getString(R.string.report_reason_personal), getString(R.string.report_reason_personal_subtitle), ReportReason.PERSONAL.name())); items.add(new ChoiceItem(getString(R.string.report_reason_spam), getString(R.string.report_reason_spam_subtitle), ReportReason.SPAM.name())); - Instance inst=AccountSessionManager.getInstance().getInstanceInfo(AccountSessionManager.getInstance().getAccount(accountID).domain); + AccountSession session=AccountSessionManager.getInstance().getAccount(accountID); + Instance inst=AccountSessionManager.getInstance().getInstanceInfo(session.domain, session.token); if(inst!=null && inst.rules!=null && !inst.rules.isEmpty()){ items.add(new ChoiceItem(getString(R.string.report_reason_violation), getString(R.string.report_reason_violation_subtitle), ReportReason.VIOLATION.name())); } diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/report/ReportRuleChoiceFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/report/ReportRuleChoiceFragment.java index f88e4fb2..0f8c89bc 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/report/ReportRuleChoiceFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/report/ReportRuleChoiceFragment.java @@ -6,6 +6,7 @@ import android.view.View; import com.squareup.otto.Subscribe; import org.joinmastodon.android.R; +import org.joinmastodon.android.api.session.AccountSession; import org.joinmastodon.android.api.session.AccountSessionManager; import org.joinmastodon.android.events.FinishReportFragmentsEvent; import org.joinmastodon.android.model.Instance; @@ -22,7 +23,8 @@ public class ReportRuleChoiceFragment extends BaseReportChoiceFragment{ @Override protected void populateItems(){ isMultipleChoice=true; - Instance inst=AccountSessionManager.getInstance().getInstanceInfo(AccountSessionManager.getInstance().getAccount(accountID).domain); + AccountSession session=AccountSessionManager.getInstance().getAccount(accountID); + Instance inst=AccountSessionManager.getInstance().getInstanceInfo(session.domain, session.token); if(inst!=null && inst.rules!=null){ for(Instance.Rule rule:inst.rules){ items.add(new ChoiceItem(rule.text, null, rule.id)); diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsServerAboutFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsServerAboutFragment.java index 58887ca7..c14b5825 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsServerAboutFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsServerAboutFragment.java @@ -24,6 +24,7 @@ import android.widget.Toast; import org.joinmastodon.android.R; import org.joinmastodon.android.api.MastodonAPIController; import org.joinmastodon.android.api.requests.instance.GetInstanceExtendedDescription; +import org.joinmastodon.android.api.session.AccountSession; import org.joinmastodon.android.api.session.AccountSessionManager; import org.joinmastodon.android.model.Instance; import org.joinmastodon.android.model.viewmodel.AccountViewModel; @@ -60,7 +61,8 @@ public class SettingsServerAboutFragment extends LoaderFragment{ public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); accountID=getArguments().getString("account"); - instance=AccountSessionManager.getInstance().getInstanceInfo(AccountSessionManager.get(accountID).domain); + AccountSession session=AccountSessionManager.get(accountID); + instance=AccountSessionManager.getInstance().getInstanceInfo(session.domain, session.token); loadData(); } diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsServerRulesFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsServerRulesFragment.java index 198fca6a..6a4a573e 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsServerRulesFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsServerRulesFragment.java @@ -5,6 +5,7 @@ import android.view.LayoutInflater; import android.view.View; import org.joinmastodon.android.R; +import org.joinmastodon.android.api.session.AccountSession; import org.joinmastodon.android.api.session.AccountSessionManager; import org.joinmastodon.android.fragments.MastodonRecyclerFragment; import org.joinmastodon.android.model.Instance; @@ -23,7 +24,8 @@ public class SettingsServerRulesFragment extends MastodonRecyclerFragment Date: Sat, 7 Dec 2024 00:03:27 +0100 Subject: [PATCH 2/2] Pick token from updateInstanceEmojis Signed-off-by: mkljczk --- .../android/api/session/AccountSession.java | 2 +- .../api/session/AccountSessionManager.java | 40 ++++++++++--------- .../android/fragments/ComposeFragment.java | 4 +- .../onboarding/AccountActivationFragment.java | 2 +- .../report/ReportReasonChoiceFragment.java | 4 +- .../report/ReportRuleChoiceFragment.java | 4 +- .../settings/SettingsServerAboutFragment.java | 4 +- .../settings/SettingsServerRulesFragment.java | 4 +- 8 files changed, 30 insertions(+), 34 deletions(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/api/session/AccountSession.java b/mastodon/src/main/java/org/joinmastodon/android/api/session/AccountSession.java index 87fb24f1..00eca9a4 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/api/session/AccountSession.java +++ b/mastodon/src/main/java/org/joinmastodon/android/api/session/AccountSession.java @@ -371,6 +371,6 @@ public class AccountSession{ } public Instance getInstanceInfo(){ - return AccountSessionManager.getInstance().getInstanceInfo(domain, token); + return AccountSessionManager.getInstance().getInstanceInfo(domain); } } diff --git a/mastodon/src/main/java/org/joinmastodon/android/api/session/AccountSessionManager.java b/mastodon/src/main/java/org/joinmastodon/android/api/session/AccountSessionManager.java index 2f357c53..092fa6f8 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/api/session/AccountSessionManager.java +++ b/mastodon/src/main/java/org/joinmastodon/android/api/session/AccountSessionManager.java @@ -107,13 +107,13 @@ public class AccountSessionManager{ private AccountSessionManager(){ prefs=MastodonApp.context.getSharedPreferences("account_manager", Context.MODE_PRIVATE); runWithDatabase(db->{ - HashMap domains=new HashMap<>(); + HashSet domains=new HashSet<>(); try(Cursor cursor=db.query("accounts", null, null, null, null, null, null)){ ContentValues values=new ContentValues(); while(cursor.moveToNext()){ DatabaseUtils.cursorRowToContentValues(cursor, values); AccountSession session=new AccountSession(values); - domains.put(session.domain.toLowerCase(), session.token); + domains.add(session.domain.toLowerCase()); sessions.put(session.getID(), session); } } @@ -135,7 +135,7 @@ public class AccountSessionManager{ session.toContentValues(values); db.insertWithOnConflict("accounts", null, values, SQLiteDatabase.CONFLICT_REPLACE); }); - updateInstanceEmojis(instance, instance.getDomain(), token); + updateInstanceEmojis(instance, instance.getDomain()); if(PushSubscriptionManager.arePushNotificationsAvailable()){ session.getPushSubscriptionManager().registerAccountForPush(null); } @@ -272,9 +272,9 @@ public class AccountSessionManager{ public void maybeUpdateLocalInfo(){ long now=System.currentTimeMillis(); - HashMap domains=new HashMap<>(); + HashSet domains=new HashSet<>(); for(AccountSession session:sessions.values()){ - domains.put(session.domain.toLowerCase(), session.token); + domains.add(session.domain.toLowerCase()); if(now-session.infoLastUpdated>24L*3600_000L){ updateSessionLocalInfo(session); } @@ -287,12 +287,12 @@ public class AccountSessionManager{ } } - private void maybeUpdateInstanceInfo(HashMap domains){ + private void maybeUpdateInstanceInfo(Set domains){ long now=System.currentTimeMillis(); - for(String domain:domains.keySet()){ + for(String domain:domains){ Long lastUpdated=instancesLastUpdated.get(domain); if(lastUpdated==null || now-lastUpdated>24L*3600_000L){ - updateInstanceInfo(domain, domains.get(domain)); + updateInstanceInfo(domain); } } } @@ -346,13 +346,13 @@ public class AccountSessionManager{ .exec(session.getID()); } - public void updateInstanceInfo(String domain, Token token){ + public void updateInstanceInfo(String domain){ loadInstanceInfo(domain, new Callback<>(){ @Override public void onSuccess(Instance instance){ instances.put(domain, instance); runOnDbThread(db->insertInstanceIntoDatabase(db, domain, instance, null, 0)); - updateInstanceEmojis(instance, domain, token); + updateInstanceEmojis(instance, domain); } @Override @@ -362,8 +362,8 @@ public class AccountSessionManager{ }); } - private void updateInstanceEmojis(Instance instance, String domain, Token token){ - new GetCustomEmojis() + private void updateInstanceEmojis(Instance instance, String domain){ + GetCustomEmojis getCustomEmojisRequest=(GetCustomEmojis)new GetCustomEmojis() .setCallback(new Callback<>(){ @Override public void onSuccess(List result){ @@ -378,12 +378,16 @@ public class AccountSessionManager{ public void onError(ErrorResponse error){ } - }) - .exec(domain, token); + }); + + sessions.values().stream().filter(session->session.domain.equals(domain)).findFirst().ifPresentOrElse( + (session)->getCustomEmojisRequest.exec(domain, session.token), + ()->getCustomEmojisRequest.execNoAuth(domain) + ); } - private void readInstanceInfo(SQLiteDatabase db, HashMap domains){ - for(String domain : domains.keySet()){ + private void readInstanceInfo(SQLiteDatabase db, Set domains){ + for(String domain : domains){ final int maxEmojiLength=500000; try(Cursor cursor=db.rawQuery("SELECT domain, instance_obj, substr(emojis,1,?) AS emojis, length(emojis) AS emoji_length, last_updated, version FROM instances WHERE `domain` = ?", new String[]{String.valueOf(maxEmojiLength) , domain})) { @@ -446,7 +450,7 @@ public class AccountSessionManager{ return r==null ? Collections.emptyList() : r; } - public Instance getInstanceInfo(String domain, Token token){ + public Instance getInstanceInfo(String domain){ Instance i=instances.get(domain); if(i!=null) return i; @@ -456,7 +460,7 @@ public class AccountSessionManager{ InstanceV1 fake=new InstanceV1(); fake.uri=fake.title=domain; fake.description=fake.version=fake.email=""; - updateInstanceInfo(domain, token); + updateInstanceInfo(domain); return fake; } diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java index 1b778407..ce5eb9b6 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java @@ -191,7 +191,7 @@ public class ComposeFragment extends MastodonToolbarFragment implements ComposeE self=session.self; instanceDomain=session.domain; customEmojis=AccountSessionManager.getInstance().getCustomEmojis(instanceDomain); - instance=AccountSessionManager.getInstance().getInstanceInfo(instanceDomain, session.token); + instance=AccountSessionManager.getInstance().getInstanceInfo(instanceDomain); if(getArguments().containsKey("editStatus")){ editingStatus=Parcels.unwrap(getArguments().getParcelable("editStatus")); } @@ -200,7 +200,7 @@ public class ComposeFragment extends MastodonToolbarFragment implements ComposeE return; } if(customEmojis.isEmpty()){ - AccountSessionManager.getInstance().updateInstanceInfo(instanceDomain, session.token); + AccountSessionManager.getInstance().updateInstanceInfo(instanceDomain); } if(instance.maxTootChars>0) diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/onboarding/AccountActivationFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/onboarding/AccountActivationFragment.java index d899a156..d8e819b0 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/onboarding/AccountActivationFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/onboarding/AccountActivationFragment.java @@ -176,7 +176,7 @@ public class AccountActivationFragment extends ToolbarFragment{ currentRequest=null; AccountSessionManager mgr=AccountSessionManager.getInstance(); AccountSession session=mgr.getAccount(accountID); - Instance instance=mgr.getInstanceInfo(session.domain, session.token); + Instance instance=mgr.getInstanceInfo(session.domain); mgr.removeAccount(accountID); mgr.addAccount(instance, session.token, result, session.app, null); String newID=mgr.getLastActiveAccountID(); diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/report/ReportReasonChoiceFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/report/ReportReasonChoiceFragment.java index 40c6b4c2..661e5330 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/report/ReportReasonChoiceFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/report/ReportReasonChoiceFragment.java @@ -17,7 +17,6 @@ import com.squareup.otto.Subscribe; import org.joinmastodon.android.E; import org.joinmastodon.android.R; -import org.joinmastodon.android.api.session.AccountSession; import org.joinmastodon.android.api.session.AccountSessionManager; import org.joinmastodon.android.events.FinishReportFragmentsEvent; import org.joinmastodon.android.fragments.StatusListFragment; @@ -95,8 +94,7 @@ public class ReportReasonChoiceFragment extends StatusListFragment{ items.add(new ChoiceItem(getString(R.string.report_reason_personal), getString(R.string.report_reason_personal_subtitle), ReportReason.PERSONAL.name())); items.add(new ChoiceItem(getString(R.string.report_reason_spam), getString(R.string.report_reason_spam_subtitle), ReportReason.SPAM.name())); - AccountSession session=AccountSessionManager.getInstance().getAccount(accountID); - Instance inst=AccountSessionManager.getInstance().getInstanceInfo(session.domain, session.token); + Instance inst=AccountSessionManager.getInstance().getInstanceInfo(AccountSessionManager.getInstance().getAccount(accountID).domain); if(inst!=null && inst.rules!=null && !inst.rules.isEmpty()){ items.add(new ChoiceItem(getString(R.string.report_reason_violation), getString(R.string.report_reason_violation_subtitle), ReportReason.VIOLATION.name())); } diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/report/ReportRuleChoiceFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/report/ReportRuleChoiceFragment.java index 0f8c89bc..f88e4fb2 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/report/ReportRuleChoiceFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/report/ReportRuleChoiceFragment.java @@ -6,7 +6,6 @@ import android.view.View; import com.squareup.otto.Subscribe; import org.joinmastodon.android.R; -import org.joinmastodon.android.api.session.AccountSession; import org.joinmastodon.android.api.session.AccountSessionManager; import org.joinmastodon.android.events.FinishReportFragmentsEvent; import org.joinmastodon.android.model.Instance; @@ -23,8 +22,7 @@ public class ReportRuleChoiceFragment extends BaseReportChoiceFragment{ @Override protected void populateItems(){ isMultipleChoice=true; - AccountSession session=AccountSessionManager.getInstance().getAccount(accountID); - Instance inst=AccountSessionManager.getInstance().getInstanceInfo(session.domain, session.token); + Instance inst=AccountSessionManager.getInstance().getInstanceInfo(AccountSessionManager.getInstance().getAccount(accountID).domain); if(inst!=null && inst.rules!=null){ for(Instance.Rule rule:inst.rules){ items.add(new ChoiceItem(rule.text, null, rule.id)); diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsServerAboutFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsServerAboutFragment.java index c14b5825..58887ca7 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsServerAboutFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsServerAboutFragment.java @@ -24,7 +24,6 @@ import android.widget.Toast; import org.joinmastodon.android.R; import org.joinmastodon.android.api.MastodonAPIController; import org.joinmastodon.android.api.requests.instance.GetInstanceExtendedDescription; -import org.joinmastodon.android.api.session.AccountSession; import org.joinmastodon.android.api.session.AccountSessionManager; import org.joinmastodon.android.model.Instance; import org.joinmastodon.android.model.viewmodel.AccountViewModel; @@ -61,8 +60,7 @@ public class SettingsServerAboutFragment extends LoaderFragment{ public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); accountID=getArguments().getString("account"); - AccountSession session=AccountSessionManager.get(accountID); - instance=AccountSessionManager.getInstance().getInstanceInfo(session.domain, session.token); + instance=AccountSessionManager.getInstance().getInstanceInfo(AccountSessionManager.get(accountID).domain); loadData(); } diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsServerRulesFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsServerRulesFragment.java index 6a4a573e..198fca6a 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsServerRulesFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsServerRulesFragment.java @@ -5,7 +5,6 @@ import android.view.LayoutInflater; import android.view.View; import org.joinmastodon.android.R; -import org.joinmastodon.android.api.session.AccountSession; import org.joinmastodon.android.api.session.AccountSessionManager; import org.joinmastodon.android.fragments.MastodonRecyclerFragment; import org.joinmastodon.android.model.Instance; @@ -24,8 +23,7 @@ public class SettingsServerRulesFragment extends MastodonRecyclerFragment