Fix issue #831 - Filter messages in profiles

custom_theming
Thomas 2 years ago
parent 2f9addb788
commit 7743de24d2

@ -125,6 +125,8 @@ public class ProfileActivity extends BaseActivity {
private String account_id;
private String mention_str;
private WellKnownNodeinfo.NodeInfo nodeInfo;
private boolean checkRemotely;
private final BroadcastReceiver broadcast_data = new BroadcastReceiver() {
@Override
@ -225,6 +227,7 @@ public class ProfileActivity extends BaseActivity {
followerTab.setText(getString(R.string.followers_cnt, Helper.withSuffix(account.followers_count)));
}
}
}
}

@ -334,6 +334,12 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
}
}
public void goTop() {
if (binding != null && search == null) {
binding.recyclerView.scrollToPosition(0);
}
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
@ -404,6 +410,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
statusReport = (Status) getArguments().getSerializable(Helper.ARG_STATUS_REPORT);
}
//When visiting a profile without being authenticated
if (checkRemotely) {
String[] acctArray = accountTimeline.acct.split("@");

@ -16,18 +16,24 @@ package app.fedilab.android.mastodon.ui.fragment.timeline;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.PopupMenu;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentTransaction;
import com.google.android.material.tabs.TabLayout;
import app.fedilab.android.R;
import app.fedilab.android.databinding.FragmentProfileTimelinesBinding;
import app.fedilab.android.mastodon.client.entities.api.Account;
import app.fedilab.android.mastodon.client.entities.app.Timeline;
import app.fedilab.android.mastodon.helper.Helper;
import app.fedilab.android.mastodon.ui.pageadapter.FedilabProfilePageAdapter;
@ -36,6 +42,7 @@ public class FragmentProfileTimeline extends Fragment {
private Account account;
private FragmentProfileTimelinesBinding binding;
private boolean checkRemotely;
private boolean show_boosts = true, show_replies = true;
public View onCreateView(@NonNull LayoutInflater inflater,
ViewGroup container, Bundle savedInstanceState) {
@ -71,9 +78,84 @@ public class FragmentProfileTimeline extends Fragment {
@Override
public void onTabReselected(TabLayout.Tab tab) {
if (binding.viewpager.getAdapter() != null && binding.viewpager
.getAdapter()
.instantiateItem(binding.viewpager, binding.viewpager.getCurrentItem()) instanceof FragmentMastodonTimeline) {
FragmentMastodonTimeline fragmentMastodonTimeline = (FragmentMastodonTimeline) binding.viewpager
.getAdapter()
.instantiateItem(binding.viewpager, binding.viewpager.getCurrentItem());
fragmentMastodonTimeline.goTop();
}
}
});
final LinearLayout tabStrip = (LinearLayout) binding.tabLayout.getChildAt(0);
tabStrip.getChildAt(0).setOnLongClickListener(v -> {
PopupMenu popup = new PopupMenu(requireActivity(), binding.tabLayout.getChildAt(0));
popup.getMenuInflater()
.inflate(R.menu.option_filter_toots_account, popup.getMenu());
Menu menu = popup.getMenu();
final MenuItem itemShowBoosts = menu.findItem(R.id.action_show_boosts);
final MenuItem itemShowReplies = menu.findItem(R.id.action_show_replies);
itemShowBoosts.setChecked(show_boosts);
itemShowReplies.setChecked(show_replies);
popup.setOnDismissListener(menu1 -> {
if (binding.viewpager.getAdapter() != null && binding.viewpager
.getAdapter()
.instantiateItem(binding.viewpager, binding.viewpager.getCurrentItem()) instanceof FragmentMastodonTimeline) {
FragmentMastodonTimeline fragmentMastodonTimeline = (FragmentMastodonTimeline) binding.viewpager
.getAdapter()
.instantiateItem(binding.viewpager, binding.viewpager.getCurrentItem());
FragmentTransaction fragTransaction = getChildFragmentManager().beginTransaction();
fragTransaction.detach(fragmentMastodonTimeline).commit();
Bundle bundle = new Bundle();
bundle.putSerializable(Helper.ARG_TIMELINE_TYPE, Timeline.TimeLineEnum.ACCOUNT_TIMELINE);
bundle.putSerializable(Helper.ARG_ACCOUNT, account);
bundle.putBoolean(Helper.ARG_SHOW_PINNED, true);
bundle.putBoolean(Helper.ARG_CHECK_REMOTELY, checkRemotely);
bundle.putBoolean(Helper.ARG_SHOW_REBLOGS, show_boosts);
bundle.putBoolean(Helper.ARG_SHOW_REPLIES, show_replies);
fragmentMastodonTimeline.setArguments(bundle);
FragmentTransaction fragTransaction2 = getChildFragmentManager().beginTransaction();
fragTransaction2.attach(fragmentMastodonTimeline);
fragTransaction2.commit();
fragmentMastodonTimeline.recreate();
}
});
popup.setOnMenuItemClickListener(item -> {
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
item.setActionView(new View(requireActivity()));
item.setOnActionExpandListener(new MenuItem.OnActionExpandListener() {
@Override
public boolean onMenuItemActionExpand(MenuItem item) {
return false;
}
@Override
public boolean onMenuItemActionCollapse(MenuItem item) {
return false;
}
});
int itemId = item.getItemId();
if (itemId == R.id.action_show_boosts) {
show_boosts = !show_boosts;
} else if (itemId == R.id.action_show_replies) {
show_replies = !show_replies;
}
if (binding.tabLayout.getTabAt(0) != null)
binding.tabLayout.getTabAt(0).select();
itemShowReplies.setChecked(show_replies);
itemShowBoosts.setChecked(show_boosts);
return true;
});
popup.show();
return true;
});
}

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<item
android:id="@+id/action_show_boosts"
android:checkable="true"
android:title="@string/show_boosts"
app:actionViewClass="android.widget.CheckBox"
app:showAsAction="always"
tools:ignore="AlwaysShowAction" />
<item
android:id="@+id/action_show_replies"
android:checkable="true"
android:title="@string/show_replies"
app:actionViewClass="android.widget.CheckBox"
app:showAsAction="always" />
</menu>

@ -1,5 +1,5 @@
Added:
- Filter messages in profiles (hide/show boosts or replies) via a long press on the tab
Changed:
- Some layout improvements for Peertube

Loading…
Cancel
Save