use isInstanceAkkoma()

This commit is contained in:
sk
2023-06-01 19:22:01 +02:00
parent 0702703d78
commit f241092277
10 changed files with 16 additions and 21 deletions

View File

@@ -159,7 +159,7 @@ public class CacheController{
} }
} }
Instance instance=AccountSessionManager.getInstance().getInstanceInfo(accountSession.domain); Instance instance=AccountSessionManager.getInstance().getInstanceInfo(accountSession.domain);
new GetNotifications(maxID, count, onlyPosts ? EnumSet.of(Notification.Type.STATUS) : onlyMentions ? EnumSet.of(Notification.Type.MENTION): EnumSet.allOf(Notification.Type.class), instance.isPleroma()) new GetNotifications(maxID, count, onlyPosts ? EnumSet.of(Notification.Type.STATUS) : onlyMentions ? EnumSet.of(Notification.Type.MENTION): EnumSet.allOf(Notification.Type.class), instance.isAkkoma())
.setCallback(new Callback<>(){ .setCallback(new Callback<>(){
@Override @Override
public void onSuccess(List<Notification> result){ public void onSuccess(List<Notification> result){

View File

@@ -1084,7 +1084,7 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
} }
req.status=text; req.status=text;
req.localOnly=localOnly; req.localOnly=localOnly;
req.visibility=localOnly && instance.isPleroma() ? StatusPrivacy.LOCAL : statusVisibility; req.visibility=localOnly && instance.isAkkoma() ? StatusPrivacy.LOCAL : statusVisibility;
req.sensitive=sensitive; req.sensitive=sensitive;
req.language=language; req.language=language;
req.contentType=contentType; req.contentType=contentType;
@@ -1899,7 +1899,7 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
Menu m=visibilityPopup.getMenu(); Menu m=visibilityPopup.getMenu();
MenuItem localOnlyItem = visibilityPopup.getMenu().findItem(R.id.local_only); MenuItem localOnlyItem = visibilityPopup.getMenu().findItem(R.id.local_only);
boolean prefsSaysSupported = GlobalUserPreferences.accountsWithLocalOnlySupport.contains(accountID); boolean prefsSaysSupported = GlobalUserPreferences.accountsWithLocalOnlySupport.contains(accountID);
if (instance.isPleroma()) { if (instance.isAkkoma()) {
m.findItem(R.id.vis_local).setVisible(true); m.findItem(R.id.vis_local).setVisible(true);
} else if (localOnly || prefsSaysSupported) { } else if (localOnly || prefsSaysSupported) {
localOnlyItem.setVisible(true); localOnlyItem.setVisible(true);

View File

@@ -14,7 +14,7 @@ public interface HasAccountID {
} }
default boolean isInstanceAkkoma() { default boolean isInstanceAkkoma() {
return getInstance().map(Instance::isPleroma).orElse(false); return getInstance().map(Instance::isAkkoma).orElse(false);
} }
default Optional<Instance> getInstance() { default Optional<Instance> getInstance() {

View File

@@ -78,7 +78,7 @@ public class HomeFragment extends AppKitFragment implements OnBackPressedListene
accountID=getArguments().getString("account"); accountID=getArguments().getString("account");
setTitle(R.string.sk_app_name); setTitle(R.string.sk_app_name);
isPleroma = AccountSessionManager.getInstance().getAccount(accountID).getInstance() isPleroma = AccountSessionManager.getInstance().getAccount(accountID).getInstance()
.map(Instance::isPleroma) .map(Instance::isAkkoma)
.orElse(false); .orElse(false);
if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.N) if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.N)
@@ -310,7 +310,7 @@ public class HomeFragment extends AppKitFragment implements OnBackPressedListene
Optional<Instance> instance = session.getInstance(); Optional<Instance> instance = session.getInstance();
if (instance.isEmpty()) return; // avoiding incompatibility with akkoma if (instance.isEmpty()) return; // avoiding incompatibility with akkoma
new GetNotifications(null, 1, EnumSet.allOf(Notification.Type.class), instance.get().isPleroma()) new GetNotifications(null, 1, EnumSet.allOf(Notification.Type.class), instance.get().isAkkoma())
.setCallback(new Callback<>() { .setCallback(new Callback<>() {
@Override @Override
public void onSuccess(List<Notification> notifications) { public void onSuccess(List<Notification> notifications) {

View File

@@ -163,10 +163,11 @@ public class NotificationsListFragment extends BaseStatusListFragment<Notificati
.notifications.lastReadId = result.items.get(0).id; .notifications.lastReadId = result.items.get(0).id;
AccountSessionManager.getInstance().writeAccountsFile(); AccountSessionManager.getInstance().writeAccountsFile();
if (AccountSessionManager.getInstance().getAccount(accountID).getInstance().map(Instance::isPleroma).orElse(false)) if (isInstanceAkkoma()) {
new PleromaMarkNotificationsRead(result.items.get(0).id).exec(accountID); new PleromaMarkNotificationsRead(result.items.get(0).id).exec(accountID);
} }
} }
}
}); });
} }

View File

@@ -184,12 +184,8 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
loaded=true; loaded=true;
if(!isOwnProfile) if(!isOwnProfile)
loadRelationship(); loadRelationship();
else { else if (isInstanceAkkoma() && getInstance().isPresent())
Instance instance = AccountSessionManager.getInstance().getInstanceInfo(domain); maxFields = getInstance().get().pleroma.metadata.fieldsLimits.maxFields;
if (instance != null && instance.isPleroma()) {
maxFields = instance.pleroma.metadata.fieldsLimits.maxFields;
}
}
}else{ }else{
profileAccountID=getArguments().getString("profileAccountID"); profileAccountID=getArguments().getString("profileAccountID");
if(!getArguments().getBoolean("noAutoLoad", false)) if(!getArguments().getBoolean("noAutoLoad", false))

View File

@@ -225,7 +225,7 @@ public class SettingsFragment extends MastodonToolbarFragment implements Provide
GlobalUserPreferences.showReplies=i.checked; GlobalUserPreferences.showReplies=i.checked;
GlobalUserPreferences.save(); GlobalUserPreferences.save();
})); }));
if (instance.map(Instance::isPleroma).orElse(false)) { if (isInstanceAkkoma()) {
items.add(new ButtonItem(R.string.sk_settings_reply_visibility, R.drawable.ic_fluent_chat_24_regular, b->{ items.add(new ButtonItem(R.string.sk_settings_reply_visibility, R.drawable.ic_fluent_chat_24_regular, b->{
PopupMenu popupMenu=new PopupMenu(getActivity(), b, Gravity.CENTER_HORIZONTAL); PopupMenu popupMenu=new PopupMenu(getActivity(), b, Gravity.CENTER_HORIZONTAL);
popupMenu.inflate(R.menu.reply_visibility); popupMenu.inflate(R.menu.reply_visibility);
@@ -374,7 +374,7 @@ public class SettingsFragment extends MastodonToolbarFragment implements Provide
glitchModeItem.enabled = i.checked; glitchModeItem.enabled = i.checked;
if (i.checked) { if (i.checked) {
GlobalUserPreferences.accountsWithLocalOnlySupport.add(accountID); GlobalUserPreferences.accountsWithLocalOnlySupport.add(accountID);
if (!instance.map(Instance::isPleroma).orElse(false)) { if (!isInstanceAkkoma()) {
GlobalUserPreferences.accountsInGlitchMode.add(accountID); GlobalUserPreferences.accountsInGlitchMode.add(accountID);
} }
} else { } else {

View File

@@ -74,9 +74,7 @@ public class ThreadFragment extends StatusListFragment implements ProvidesAssist
data.add(mainStatus); data.add(mainStatus);
onAppendItems(Collections.singletonList(mainStatus)); onAppendItems(Collections.singletonList(mainStatus));
} }
AccountSession account=AccountSessionManager.getInstance().getAccount(accountID); if(isInstanceAkkoma()){
Instance instance=AccountSessionManager.getInstance().getInstanceInfo(account.domain);
if(instance.isPleroma()){
List<String> threadIds=new ArrayList<>(); List<String> threadIds=new ArrayList<>();
threadIds.add(mainStatus.id); threadIds.add(mainStatus.id);
for(Status s:result.descendants){ for(Status s:result.descendants){

View File

@@ -143,7 +143,7 @@ public class Instance extends BaseModel{
return ci; return ci;
} }
public boolean isPleroma() { public boolean isAkkoma() {
return pleroma != null; return pleroma != null;
} }

View File

@@ -259,13 +259,13 @@ public class TimelineDefinition {
public boolean isCompatible(AccountSession session) { public boolean isCompatible(AccountSession session) {
// still enabling the bubble timeline for all pleroma/akkoma instances since i know of // still enabling the bubble timeline for all pleroma/akkoma instances since i know of
// at least one instance that supports it, but doesn't list "bubble_timeline" // at least one instance that supports it, but doesn't list "bubble_timeline"
return session.getInstance().map(Instance::isPleroma).orElse(false); return session.getInstance().map(Instance::isAkkoma).orElse(false);
} }
@Override @Override
public boolean wantsDefault(AccountSession session) { public boolean wantsDefault(AccountSession session) {
return session.getInstance() return session.getInstance()
.map(i -> i.isPleroma() && i.pleroma.metadata.features.contains("bubble_timeline")) .map(i -> i.isAkkoma() && i.pleroma.metadata.features.contains("bubble_timeline"))
.orElse(false); .orElse(false);
} }
}; };