diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/ProfileFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/ProfileFragment.java index aca6699c1..5e3f3f2fb 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/ProfileFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/ProfileFragment.java @@ -1,7 +1,5 @@ package org.joinmastodon.android.fragments; -import static org.joinmastodon.android.fragments.ProfileAboutFragment.MAX_FIELDS; - import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorSet; @@ -175,6 +173,8 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList private MenuItem editSaveMenuItem; private boolean savingEdits; + private int maxFields = ProfileAboutFragment.MAX_FIELDS; + // from ProfileAboutFragment public UsableRecyclerView list; private AboutAdapter adapter; @@ -200,6 +200,9 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList loaded=true; if(!isOwnProfile) loadRelationship(); + else if (isInstanceAkkoma()) { + maxFields = getInstance().get().pleroma.metadata.fieldsLimits.maxFields; + } }else{ profileAccountID=getArguments().getString("profileAccountID"); if(!getArguments().getBoolean("noAutoLoad", false)) @@ -1385,7 +1388,7 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList public int getItemCount(){ if(isInEditMode){ int size=fields.size(); - if(size{ if(searchActive) exitSearch(); else openSearch(); }); - if(searchActive){ - searchBack.setImageResource(R.drawable.ic_fluent_arrow_left_24_regular); + if(searchActive) searchBack.setImageResource(R.drawable.ic_fluent_arrow_left_24_regular); + else searchBack.setEnabled(false); + if(searchActive || disableDiscover){ pager.setVisibility(View.GONE); tabLayout.setVisibility(View.GONE); searchView.setVisibility(View.VISIBLE); @@ -232,15 +236,18 @@ public class DiscoverFragment extends AppKitFragment implements ScrollableToTop, if(!searchActive) return; searchActive=false; - pager.setVisibility(View.VISIBLE); - tabLayout.setVisibility(View.VISIBLE); - searchView.setVisibility(View.GONE); searchText.setText(R.string.sk_search_fediverse); searchBack.setImageResource(R.drawable.ic_fluent_search_24_regular); searchBack.setEnabled(false); searchBack.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO); - tabsDivider.setVisibility(View.VISIBLE); currentQuery=null; + searchFragment.clear(); + + if(disableDiscover) return; + pager.setVisibility(View.VISIBLE); + tabLayout.setVisibility(View.VISIBLE); + searchView.setVisibility(View.GONE); + tabsDivider.setVisibility(View.VISIBLE); } private Fragment getFragmentForPage(int page){ diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/discover/SearchFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/discover/SearchFragment.java index a21f58f5b..fc7644649 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/discover/SearchFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/discover/SearchFragment.java @@ -54,7 +54,7 @@ public class SearchFragment extends BaseStatusListFragment{ super.onCreate(savedInstanceState); if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.N) setRetainInstance(true); - setEmptyText(R.string.no_search_results); + setEmptyText(R.string.sk_recent_searches_placeholder); loadData(); } @@ -173,13 +173,16 @@ public class SearchFragment extends BaseStatusListFragment{ } public void setQuery(String q, SearchResult.Type filter){ - if(q.isBlank()) + if(q.isBlank()) { + setEmptyText(R.string.sk_recent_searches_placeholder); return; + } if(currentRequest!=null){ currentRequest.cancel(); currentRequest=null; } currentQuery=q; + setEmptyText(R.string.no_search_results); if(filter==null) currentFilter=EnumSet.allOf(SearchResult.Type.class); else @@ -221,6 +224,13 @@ public class SearchFragment extends BaseStatusListFragment{ } } + public void clear() { + data.clear(); + preloadedData.clear(); + adapter.notifyDataSetChanged(); + V.setVisibilityAnimated(content, View.GONE); + } + @Override public Uri getWebUri(Uri.Builder base) { Uri.Builder searchUri = base.path("/search"); diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsMainFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsMainFragment.java index 0ee47d41d..844b44a18 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsMainFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsMainFragment.java @@ -16,6 +16,7 @@ import org.joinmastodon.android.R; import org.joinmastodon.android.api.session.AccountSession; import org.joinmastodon.android.api.session.AccountSessionManager; import org.joinmastodon.android.events.SelfUpdateStateChangedEvent; +import org.joinmastodon.android.model.Instance; import org.joinmastodon.android.model.viewmodel.ListItem; import org.joinmastodon.android.ui.M3AlertDialogBuilder; import org.joinmastodon.android.ui.utils.HideableSingleViewRecyclerAdapter; @@ -29,6 +30,7 @@ import me.grishka.appkit.Nav; import me.grishka.appkit.utils.MergeRecyclerAdapter; public class SettingsMainFragment extends BaseSettingsFragment{ + private AccountSession account; private boolean loggedOut; private HideableSingleViewRecyclerAdapter bannerAdapter; private Button updateButton1, updateButton2; @@ -47,23 +49,27 @@ public class SettingsMainFragment extends BaseSettingsFragment{ @Override public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); + account = AccountSessionManager.get(accountID); setTitle(R.string.settings); - setSubtitle(AccountSessionManager.get(accountID).getFullUsername()); + setSubtitle(account.getFullUsername()); onDataLoaded(List.of( new ListItem<>(R.string.settings_behavior, 0, R.drawable.ic_fluent_settings_24_regular, this::onBehaviorClick), new ListItem<>(R.string.settings_display, 0, R.drawable.ic_fluent_color_24_regular, this::onDisplayClick), - new ListItem<>(R.string.settings_filters, 0, R.drawable.ic_fluent_filter_24_regular, this::onFiltersClick), new ListItem<>(R.string.settings_notifications, 0, R.drawable.ic_fluent_alert_24_regular, this::onNotificationsClick), new ListItem<>(R.string.sk_settings_instance, 0, R.drawable.ic_fluent_server_24_regular, this::onInstanceClick), new ListItem<>(getString(R.string.about_app, getString(R.string.sk_app_name)), null, R.drawable.ic_fluent_info_24_regular, this::onAboutClick, null, 0, true), new ListItem<>(R.string.log_out, 0, R.drawable.ic_fluent_sign_out_24_regular, this::onLogOutClick, R.attr.colorM3Error, false) )); + Instance instance = AccountSessionManager.getInstance().getInstanceInfo(account.domain); + if (!instance.isAkkoma()) + data.add(2, new ListItem<>(R.string.settings_filters, 0, R.drawable.ic_fluent_filter_24_regular, this::onFiltersClick)); + if(BuildConfig.DEBUG || BuildConfig.BUILD_TYPE.equals("appcenterPrivateBeta")){ data.add(0, new ListItem<>("Debug settings", null, R.drawable.ic_fluent_wrench_screwdriver_24_regular, ()->Nav.go(getActivity(), SettingsDebugFragment.class, makeFragmentArgs()), null, 0, true)); } - AccountSessionManager.get(accountID).reloadPreferences(null); + account.reloadPreferences(null); E.register(this); } @@ -80,7 +86,7 @@ public class SettingsMainFragment extends BaseSettingsFragment{ protected void onHidden(){ super.onHidden(); if(!loggedOut) - AccountSessionManager.get(accountID).savePreferencesIfPending(); + account.savePreferencesIfPending(); } @Override @@ -147,7 +153,7 @@ public class SettingsMainFragment extends BaseSettingsFragment{ AccountSession session=AccountSessionManager.getInstance().getAccount(accountID); new M3AlertDialogBuilder(getActivity()) .setMessage(getString(R.string.confirm_log_out, session.getFullUsername())) - .setPositiveButton(R.string.log_out, (dialog, which)->AccountSessionManager.get(accountID).logOut(getActivity(), ()->{ + .setPositiveButton(R.string.log_out, (dialog, which)->account.logOut(getActivity(), ()->{ loggedOut=true; getActivity().finish(); Intent intent=new Intent(getActivity(), MainActivity.class); diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/StatusDisplayItem.java b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/StatusDisplayItem.java index a1c0fa803..cf5f6ba5c 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/StatusDisplayItem.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/StatusDisplayItem.java @@ -3,6 +3,7 @@ package org.joinmastodon.android.ui.displayitems; import android.app.Activity; import android.app.Fragment; import android.content.Context; +import android.graphics.drawable.ColorDrawable; import android.os.Bundle; import android.text.SpannableStringBuilder; import android.text.TextUtils; @@ -30,6 +31,7 @@ import org.joinmastodon.android.model.ScheduledStatus; import org.joinmastodon.android.model.Status; import org.joinmastodon.android.ui.PhotoLayoutHelper; import org.joinmastodon.android.ui.text.HtmlParser; +import org.joinmastodon.android.ui.utils.UiUtils; import org.joinmastodon.android.ui.viewholders.AccountViewHolder; import org.joinmastodon.android.utils.StatusFilterPredicate; import org.parceler.Parcels; @@ -253,6 +255,12 @@ public abstract class StatusDisplayItem{ List imageAttachments=statusForContent.mediaAttachments.stream().filter(att->att.type.isImage()).collect(Collectors.toList()); if(!imageAttachments.isEmpty()){ + int color = UiUtils.getThemeColor(fragment.getContext(), R.attr.colorM3SurfaceVariant); + for (Attachment att : imageAttachments) { + if (att.blurhashPlaceholder == null) { + att.blurhashPlaceholder = new ColorDrawable(color); + } + } PhotoLayoutHelper.TiledLayoutResult layout=PhotoLayoutHelper.processThumbs(imageAttachments); MediaGridStatusDisplayItem mediaGrid=new MediaGridStatusDisplayItem(parentID, fragment, layout, imageAttachments, statusForContent); if((flags & FLAG_MEDIA_FORCE_HIDDEN)!=0) diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/viewcontrollers/ComposePollViewController.java b/mastodon/src/main/java/org/joinmastodon/android/ui/viewcontrollers/ComposePollViewController.java index f8e6f92f9..52aa0a88f 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/viewcontrollers/ComposePollViewController.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/viewcontrollers/ComposePollViewController.java @@ -74,10 +74,17 @@ public class ComposePollViewController{ pollWrap=view.findViewById(R.id.poll_wrap); Instance instance=fragment.instance; - if(instance.configuration!=null && instance.configuration.polls!=null && instance.configuration.polls.maxOptions>0) - maxPollOptions=instance.configuration.polls.maxOptions; - if(instance.configuration!=null && instance.configuration.polls!=null && instance.configuration.polls.maxCharactersPerOption>0) - maxPollOptionLength=instance.configuration.polls.maxCharactersPerOption; + if (!instance.isAkkoma()) { + if(instance.configuration!=null && instance.configuration.polls!=null && instance.configuration.polls.maxOptions>0) + maxPollOptions=instance.configuration.polls.maxOptions; + if(instance.configuration!=null && instance.configuration.polls!=null && instance.configuration.polls.maxCharactersPerOption>0) + maxPollOptionLength=instance.configuration.polls.maxCharactersPerOption; + } else { + if (instance.pollLimits!=null && instance.pollLimits.maxOptions>0) + maxPollOptions=instance.pollLimits.maxOptions; + if(instance.pollLimits!=null && instance.pollLimits.maxOptionChars>0) + maxPollOptionLength=instance.pollLimits.maxOptionChars; + } pollOptionsView=pollWrap.findViewById(R.id.poll_options); addPollOptionBtn=pollWrap.findViewById(R.id.add_poll_option);