Merge branch 'check_profiles_remotely' into develop
This commit is contained in:
commit
aa4aefe9dc
|
@ -115,6 +115,7 @@ 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
|
||||
|
@ -141,10 +142,12 @@ public class ProfileActivity extends BaseActivity {
|
|||
ActionBar actionBar = getSupportActionBar();
|
||||
Bundle b = getIntent().getExtras();
|
||||
binding.accountFollow.setEnabled(false);
|
||||
checkRemotely = false;
|
||||
if (b != null) {
|
||||
account = (Account) b.getSerializable(Helper.ARG_ACCOUNT);
|
||||
account_id = b.getString(Helper.ARG_USER_ID, null);
|
||||
mention_str = b.getString(Helper.ARG_MENTION, null);
|
||||
checkRemotely = b.getBoolean(Helper.ARG_CHECK_REMOTELY, false);
|
||||
}
|
||||
postponeEnterTransition();
|
||||
|
||||
|
@ -239,7 +242,7 @@ public class ProfileActivity extends BaseActivity {
|
|||
binding.accountTabLayout.clearOnTabSelectedListeners();
|
||||
binding.accountTabLayout.removeAllTabs();
|
||||
//Tablayout for timelines/following/followers
|
||||
FedilabProfileTLPageAdapter fedilabProfileTLPageAdapter = new FedilabProfileTLPageAdapter(getSupportFragmentManager(), account);
|
||||
FedilabProfileTLPageAdapter fedilabProfileTLPageAdapter = new FedilabProfileTLPageAdapter(getSupportFragmentManager(), account, checkRemotely);
|
||||
binding.accountTabLayout.addTab(binding.accountTabLayout.newTab().setText(getString(R.string.status_cnt, Helper.withSuffix(account.statuses_count))));
|
||||
binding.accountTabLayout.addTab(binding.accountTabLayout.newTab().setText(getString(R.string.following_cnt, Helper.withSuffix(account.following_count))));
|
||||
binding.accountTabLayout.addTab(binding.accountTabLayout.newTab().setText(getString(R.string.followers_cnt, Helper.withSuffix(account.followers_count))));
|
||||
|
@ -339,11 +342,25 @@ public class ProfileActivity extends BaseActivity {
|
|||
binding.accountMoved.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
}
|
||||
if (account.acct != null && account.acct.contains("@"))
|
||||
binding.warningMessage.setVisibility(View.VISIBLE);
|
||||
binding.warningContainer.setVisibility(View.VISIBLE);
|
||||
else
|
||||
binding.warningMessage.setVisibility(View.GONE);
|
||||
|
||||
binding.warningContainer.setVisibility(View.GONE);
|
||||
|
||||
binding.openRemoteProfile.setBackgroundTintList(ThemeHelper.getButtonActionColorStateList(ProfileActivity.this));
|
||||
if (checkRemotely) {
|
||||
binding.openRemoteProfile.setVisibility(View.GONE);
|
||||
}
|
||||
binding.openRemoteProfile.setOnClickListener(v -> {
|
||||
Intent intent = new Intent(ProfileActivity.this, ProfileActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
b.putSerializable(Helper.ARG_ACCOUNT, account);
|
||||
b.putSerializable(Helper.ARG_CHECK_REMOTELY, true);
|
||||
intent.putExtras(b);
|
||||
ActivityOptionsCompat options = ActivityOptionsCompat
|
||||
.makeSceneTransitionAnimation(ProfileActivity.this, binding.profilePicture, getString(R.string.activity_porfile_pp));
|
||||
startActivity(intent, options.toBundle());
|
||||
finish();
|
||||
});
|
||||
//Fields for profile
|
||||
List<Field> fields = account.fields;
|
||||
if (fields != null && fields.size() > 0) {
|
||||
|
|
|
@ -439,6 +439,42 @@ public class CrossActionHelper {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fetch and federate the remote status
|
||||
*/
|
||||
public static void fetchAccountInRemoteInstance(@NonNull Context context, String acct, String instance, Callback callback) {
|
||||
|
||||
MastodonSearchService mastodonSearchService = init(context, instance);
|
||||
new Thread(() -> {
|
||||
Call<Results> resultsCall = mastodonSearchService.search(null, acct, null, "accounts", null, null, null, null, null, null, 1);
|
||||
Results results = null;
|
||||
if (resultsCall != null) {
|
||||
try {
|
||||
Response<Results> resultsResponse = resultsCall.execute();
|
||||
if (resultsResponse.isSuccessful()) {
|
||||
results = resultsResponse.body();
|
||||
if (results != null) {
|
||||
if (results.accounts == null) {
|
||||
results.accounts = new ArrayList<>();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||
Results finalResults = results;
|
||||
Runnable myRunnable = () -> {
|
||||
if (finalResults != null && finalResults.accounts != null && finalResults.accounts.size() > 0) {
|
||||
callback.federatedAccount(finalResults.accounts.get(0));
|
||||
}
|
||||
};
|
||||
mainHandler.post(myRunnable);
|
||||
|
||||
}).start();
|
||||
}
|
||||
|
||||
public enum TypeOfCrossAction {
|
||||
FOLLOW_ACTION,
|
||||
UNFOLLOW_ACTION,
|
||||
|
|
|
@ -272,6 +272,7 @@ public class Helper {
|
|||
public static final String ARG_SHOW_PINNED = "ARG_SHOW_PINNED";
|
||||
public static final String ARG_SHOW_MEDIA_ONY = "ARG_SHOW_MEDIA_ONY";
|
||||
public static final String ARG_MENTION = "ARG_MENTION";
|
||||
public static final String ARG_CHECK_REMOTELY = "ARG_CHECK_REMOTELY";
|
||||
public static final String ARG_USER_ID = "ARG_USER_ID";
|
||||
public static final String ARG_MEDIA_ARRAY = "ARG_MEDIA_ARRAY";
|
||||
public static final String ARG_VISIBILITY = "ARG_VISIBILITY";
|
||||
|
|
|
@ -259,7 +259,7 @@ public class NotificationAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|||
if (notification.status != null) {
|
||||
notification.status.cached = notification.cached;
|
||||
}
|
||||
statusManagement(context, statusesVM, searchVM, holderStatus, this, null, notification.status, Timeline.TimeLineEnum.NOTIFICATION, false, true, null);
|
||||
statusManagement(context, statusesVM, searchVM, holderStatus, this, null, notification.status, Timeline.TimeLineEnum.NOTIFICATION, false, true, false, null);
|
||||
holderStatus.bindingNotification.status.dateShort.setText(Helper.dateDiff(context, notification.created_at));
|
||||
holderStatus.bindingNotification.containerTransparent.setAlpha(.3f);
|
||||
if (getItemViewType(position) == TYPE_MENTION || getItemViewType(position) == TYPE_STATUS || getItemViewType(position) == TYPE_REACTION) {
|
||||
|
|
|
@ -153,14 +153,16 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
private final boolean minified;
|
||||
private final Timeline.TimeLineEnum timelineType;
|
||||
private final boolean canBeFederated;
|
||||
private final boolean checkRemotely;
|
||||
public FetchMoreCallBack fetchMoreCallBack;
|
||||
private Context context;
|
||||
|
||||
public StatusAdapter(List<Status> statuses, Timeline.TimeLineEnum timelineType, boolean minified, boolean canBeFederated) {
|
||||
public StatusAdapter(List<Status> statuses, Timeline.TimeLineEnum timelineType, boolean minified, boolean canBeFederated, boolean checkRemotely) {
|
||||
this.statusList = statuses;
|
||||
this.timelineType = timelineType;
|
||||
this.minified = minified;
|
||||
this.canBeFederated = canBeFederated;
|
||||
this.checkRemotely = checkRemotely;
|
||||
}
|
||||
|
||||
|
||||
|
@ -349,14 +351,14 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
List<Status> statusList,
|
||||
Status status,
|
||||
Timeline.TimeLineEnum timelineType,
|
||||
boolean minified, boolean canBeFederated,
|
||||
boolean minified, boolean canBeFederated, boolean checkRemotely,
|
||||
FetchMoreCallBack fetchMoreCallBack) {
|
||||
if (status == null) {
|
||||
return;
|
||||
}
|
||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
|
||||
boolean remote = timelineType == Timeline.TimeLineEnum.REMOTE;
|
||||
boolean remote = timelineType == Timeline.TimeLineEnum.REMOTE || checkRemotely;
|
||||
|
||||
Status statusToDeal = status.reblog != null ? status.reblog : status;
|
||||
|
||||
|
@ -2161,7 +2163,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
StatusViewHolder holder = (StatusViewHolder) viewHolder;
|
||||
StatusesVM statusesVM = new ViewModelProvider((ViewModelStoreOwner) context).get(StatusesVM.class);
|
||||
SearchVM searchVM = new ViewModelProvider((ViewModelStoreOwner) context).get(SearchVM.class);
|
||||
statusManagement(context, statusesVM, searchVM, holder, this, statusList, status, timelineType, minified, canBeFederated, fetchMoreCallBack);
|
||||
statusManagement(context, statusesVM, searchVM, holder, this, statusList, status, timelineType, minified, canBeFederated, checkRemotely, fetchMoreCallBack);
|
||||
} else if (viewHolder.getItemViewType() == STATUS_FILTERED) {
|
||||
StatusViewHolder holder = (StatusViewHolder) viewHolder;
|
||||
holder.bindingFiltered.filteredText.setText(context.getString(R.string.filtered_by, status.filteredByApp.title));
|
||||
|
|
|
@ -30,15 +30,18 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import app.fedilab.android.BaseMainActivity;
|
||||
import app.fedilab.android.R;
|
||||
import app.fedilab.android.client.entities.api.Account;
|
||||
import app.fedilab.android.client.entities.api.Attachment;
|
||||
import app.fedilab.android.client.entities.api.Status;
|
||||
import app.fedilab.android.client.entities.api.Statuses;
|
||||
import app.fedilab.android.databinding.FragmentPaginationBinding;
|
||||
import app.fedilab.android.helper.CrossActionHelper;
|
||||
import app.fedilab.android.helper.Helper;
|
||||
import app.fedilab.android.helper.MastodonHelper;
|
||||
import app.fedilab.android.ui.drawer.ImageAdapter;
|
||||
import app.fedilab.android.viewmodel.mastodon.AccountsVM;
|
||||
import es.dmoral.toasty.Toasty;
|
||||
|
||||
|
||||
public class FragmentMediaProfile extends Fragment {
|
||||
|
@ -50,6 +53,10 @@ public class FragmentMediaProfile extends Fragment {
|
|||
private List<Status> mediaStatuses;
|
||||
private String max_id;
|
||||
private ImageAdapter imageAdapter;
|
||||
String tempToken;
|
||||
String tempInstance;
|
||||
private boolean checkRemotely;
|
||||
private String accountId;
|
||||
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
|
@ -58,6 +65,7 @@ public class FragmentMediaProfile extends Fragment {
|
|||
Bundle bundle = this.getArguments();
|
||||
if (bundle != null) {
|
||||
accountTimeline = (Account) getArguments().getSerializable(Helper.ARG_ACCOUNT);
|
||||
checkRemotely = getArguments().getBoolean(Helper.ARG_CHECK_REMOTELY, false);
|
||||
}
|
||||
return binding.getRoot();
|
||||
}
|
||||
|
@ -68,8 +76,37 @@ public class FragmentMediaProfile extends Fragment {
|
|||
flagLoading = false;
|
||||
accountsVM = new ViewModelProvider(FragmentMediaProfile.this).get(AccountsVM.class);
|
||||
mediaStatuses = new ArrayList<>();
|
||||
accountsVM.getAccountStatuses(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, accountTimeline.id, null, null, null, null, null, true, false, MastodonHelper.statusesPerCall(requireActivity()))
|
||||
.observe(getViewLifecycleOwner(), this::initializeStatusesCommonView);
|
||||
|
||||
if (checkRemotely) {
|
||||
tempToken = null;
|
||||
String[] acctArray = accountTimeline.acct.split("@");
|
||||
if (acctArray.length > 1) {
|
||||
tempInstance = acctArray[1];
|
||||
}
|
||||
CrossActionHelper.fetchAccountInRemoteInstance(requireActivity(), accountTimeline.acct, tempInstance, new CrossActionHelper.Callback() {
|
||||
@Override
|
||||
public void federatedStatus(Status status) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void federatedAccount(Account account) {
|
||||
if (account != null) {
|
||||
accountId = account.id;
|
||||
accountsVM.getAccountStatuses(tempInstance, null, accountId, null, null, null, null, null, true, false, MastodonHelper.statusesPerCall(requireActivity()))
|
||||
.observe(getViewLifecycleOwner(), statuses -> initializeStatusesCommonView(statuses));
|
||||
} else {
|
||||
Toasty.error(requireActivity(), getString(R.string.toast_fetch_error), Toasty.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
tempToken = BaseMainActivity.currentToken;
|
||||
tempInstance = BaseMainActivity.currentInstance;
|
||||
accountId = accountTimeline.id;
|
||||
accountsVM.getAccountStatuses(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, accountTimeline.id, null, null, null, null, null, true, false, MastodonHelper.statusesPerCall(requireActivity()))
|
||||
.observe(getViewLifecycleOwner(), this::initializeStatusesCommonView);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -133,7 +170,7 @@ public class FragmentMediaProfile extends Fragment {
|
|||
if (!flagLoading) {
|
||||
flagLoading = true;
|
||||
binding.loadingNextElements.setVisibility(View.VISIBLE);
|
||||
accountsVM.getAccountStatuses(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, accountTimeline.id, max_id, null, null, null, null, true, false, MastodonHelper.statusesPerCall(requireActivity()))
|
||||
accountsVM.getAccountStatuses(tempInstance, tempToken, accountId, max_id, null, null, null, null, true, false, MastodonHelper.statusesPerCall(requireActivity()))
|
||||
.observe(getViewLifecycleOwner(), newStatuses -> dealWithPagination(newStatuses));
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -162,7 +162,7 @@ public class FragmentMastodonContext extends Fragment {
|
|||
this.statuses = new ArrayList<>();
|
||||
focusedStatus.isFocused = true;
|
||||
this.statuses.add(focusedStatus);
|
||||
statusAdapter = new StatusAdapter(this.statuses, Timeline.TimeLineEnum.UNKNOWN, false, true);
|
||||
statusAdapter = new StatusAdapter(this.statuses, Timeline.TimeLineEnum.UNKNOWN, false, true, false);
|
||||
binding.swipeContainer.setRefreshing(false);
|
||||
LinearLayoutManager mLayoutManager = new LinearLayoutManager(requireActivity());
|
||||
binding.recyclerView.setLayoutManager(mLayoutManager);
|
||||
|
|
|
@ -45,6 +45,7 @@ import java.util.List;
|
|||
|
||||
import app.fedilab.android.BaseMainActivity;
|
||||
import app.fedilab.android.R;
|
||||
import app.fedilab.android.activities.MainActivity;
|
||||
import app.fedilab.android.client.entities.api.Account;
|
||||
import app.fedilab.android.client.entities.api.Attachment;
|
||||
import app.fedilab.android.client.entities.api.Pagination;
|
||||
|
@ -57,6 +58,7 @@ import app.fedilab.android.client.entities.app.TagTimeline;
|
|||
import app.fedilab.android.client.entities.app.Timeline;
|
||||
import app.fedilab.android.databinding.FragmentPaginationBinding;
|
||||
import app.fedilab.android.exception.DBException;
|
||||
import app.fedilab.android.helper.CrossActionHelper;
|
||||
import app.fedilab.android.helper.Helper;
|
||||
import app.fedilab.android.helper.MastodonHelper;
|
||||
import app.fedilab.android.helper.ThemeHelper;
|
||||
|
@ -81,6 +83,9 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
|||
private StatusAdapter statusAdapter;
|
||||
private Timeline.TimeLineEnum timelineType;
|
||||
private List<Status> timelineStatuses;
|
||||
private boolean checkRemotely;
|
||||
private String accountIDInRemoteInstance;
|
||||
|
||||
//Handle actions that can be done in other fragments
|
||||
private final BroadcastReceiver receive_action = new BroadcastReceiver() {
|
||||
@Override
|
||||
|
@ -307,6 +312,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
|||
tagTimeline = (TagTimeline) getArguments().getSerializable(Helper.ARG_TAG_TIMELINE);
|
||||
accountTimeline = (Account) getArguments().getSerializable(Helper.ARG_ACCOUNT);
|
||||
exclude_replies = !getArguments().getBoolean(Helper.ARG_SHOW_REPLIES, true);
|
||||
checkRemotely = getArguments().getBoolean(Helper.ARG_CHECK_REMOTELY, false);
|
||||
show_pinned = getArguments().getBoolean(Helper.ARG_SHOW_PINNED, false);
|
||||
exclude_reblogs = !getArguments().getBoolean(Helper.ARG_SHOW_REBLOGS, true);
|
||||
media_only = getArguments().getBoolean(Helper.ARG_SHOW_MEDIA_ONY, false);
|
||||
|
@ -314,6 +320,13 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
|||
minified = getArguments().getBoolean(Helper.ARG_MINIFIED, false);
|
||||
statusReport = (Status) getArguments().getSerializable(Helper.ARG_STATUS_REPORT);
|
||||
}
|
||||
//When visiting a profile without being authenticated
|
||||
if (checkRemotely) {
|
||||
String[] acctArray = accountTimeline.acct.split("@");
|
||||
if (acctArray.length > 1) {
|
||||
remoteInstance = acctArray[1];
|
||||
}
|
||||
}
|
||||
if (tagTimeline != null) {
|
||||
ident = "@T@" + tagTimeline.name;
|
||||
if (tagTimeline.isART) {
|
||||
|
@ -321,7 +334,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
|||
}
|
||||
} else if (list_id != null) {
|
||||
ident = "@l@" + list_id;
|
||||
} else if (remoteInstance != null) {
|
||||
} else if (remoteInstance != null && !checkRemotely) {
|
||||
if (pinnedTimeline.remoteInstance.type == RemoteInstance.InstanceType.NITTER) {
|
||||
ident = "@R@" + pinnedTimeline.remoteInstance.host;
|
||||
} else {
|
||||
|
@ -517,7 +530,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
|||
if (min_id == null || (statuses.pagination.min_id != null && Helper.compareTo(statuses.pagination.min_id, min_id) > 0)) {
|
||||
min_id = statuses.pagination.min_id;
|
||||
}
|
||||
statusAdapter = new StatusAdapter(timelineStatuses, timelineType, minified, canBeFederated);
|
||||
statusAdapter = new StatusAdapter(timelineStatuses, timelineType, minified, canBeFederated, checkRemotely);
|
||||
statusAdapter.fetchMoreCallBack = this;
|
||||
if (statusReport != null) {
|
||||
scrollToTop();
|
||||
|
@ -915,10 +928,56 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
|||
} else if (timelineType == Timeline.TimeLineEnum.TAG || timelineType == Timeline.TimeLineEnum.ART) { //TAG TIMELINE
|
||||
routeCommon(direction, fetchingMissing, statusToUpdate);
|
||||
} else if (timelineType == Timeline.TimeLineEnum.ACCOUNT_TIMELINE) { //PROFILE TIMELINES
|
||||
if (direction == null) {
|
||||
String tempToken;
|
||||
String tempInstance;
|
||||
String accountId;
|
||||
if (checkRemotely) {
|
||||
tempToken = null;
|
||||
tempInstance = remoteInstance;
|
||||
accountId = accountIDInRemoteInstance;
|
||||
if (accountIDInRemoteInstance == null) {
|
||||
CrossActionHelper.fetchAccountInRemoteInstance(requireActivity(), accountTimeline.acct, tempInstance, new CrossActionHelper.Callback() {
|
||||
@Override
|
||||
public void federatedStatus(Status status) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void federatedAccount(Account account) {
|
||||
if (account != null) {
|
||||
accountIDInRemoteInstance = account.id;
|
||||
accountsVM.getAccountStatuses(tempInstance, null, accountIDInRemoteInstance, null, null, null, null, null, false, true, MastodonHelper.statusesPerCall(requireActivity()))
|
||||
.observe(getViewLifecycleOwner(), pinnedStatuses -> accountsVM.getAccountStatuses(tempInstance, null, accountIDInRemoteInstance, null, null, null, exclude_replies, exclude_reblogs, media_only, false, MastodonHelper.statusesPerCall(requireActivity()))
|
||||
.observe(getViewLifecycleOwner(), otherStatuses -> {
|
||||
if (otherStatuses != null && otherStatuses.statuses != null) {
|
||||
if (pinnedStatuses != null && pinnedStatuses.statuses != null) {
|
||||
for (Status status : pinnedStatuses.statuses) {
|
||||
status.pinned = true;
|
||||
}
|
||||
otherStatuses.statuses.addAll(0, pinnedStatuses.statuses);
|
||||
}
|
||||
}
|
||||
initializeStatusesCommonView(otherStatuses);
|
||||
}));
|
||||
} else {
|
||||
Toasty.error(requireActivity(), getString(R.string.toast_fetch_error), Toasty.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
accountId = accountIDInRemoteInstance;
|
||||
}
|
||||
} else {
|
||||
tempToken = MainActivity.currentToken;
|
||||
tempInstance = currentInstance;
|
||||
accountId = accountTimeline.id;
|
||||
}
|
||||
if (accountId == null) {
|
||||
accountId = accountTimeline.id;
|
||||
}
|
||||
if (direction == null && !checkRemotely) {
|
||||
if (show_pinned) {
|
||||
//Fetch pinned statuses to display them at the top
|
||||
accountsVM.getAccountStatuses(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, accountTimeline.id, null, null, null, null, null, false, true, MastodonHelper.statusesPerCall(requireActivity()))
|
||||
accountsVM.getAccountStatuses(currentInstance, MainActivity.currentToken, accountId, null, null, null, null, null, false, true, MastodonHelper.statusesPerCall(requireActivity()))
|
||||
.observe(getViewLifecycleOwner(), pinnedStatuses -> accountsVM.getAccountStatuses(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, accountTimeline.id, null, null, null, exclude_replies, exclude_reblogs, media_only, false, MastodonHelper.statusesPerCall(requireActivity()))
|
||||
.observe(getViewLifecycleOwner(), otherStatuses -> {
|
||||
if (otherStatuses != null && otherStatuses.statuses != null && pinnedStatuses != null && pinnedStatuses.statuses != null) {
|
||||
|
@ -930,11 +989,11 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
|||
}
|
||||
}));
|
||||
} else {
|
||||
accountsVM.getAccountStatuses(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, accountTimeline.id, null, null, null, exclude_replies, exclude_reblogs, media_only, false, MastodonHelper.statusesPerCall(requireActivity()))
|
||||
accountsVM.getAccountStatuses(tempInstance, tempToken, accountId, null, null, null, exclude_replies, exclude_reblogs, media_only, false, MastodonHelper.statusesPerCall(requireActivity()))
|
||||
.observe(getViewLifecycleOwner(), this::initializeStatusesCommonView);
|
||||
}
|
||||
} else if (direction == DIRECTION.BOTTOM) {
|
||||
accountsVM.getAccountStatuses(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, accountTimeline.id, max_id, null, null, exclude_replies, exclude_reblogs, media_only, false, MastodonHelper.statusesPerCall(requireActivity()))
|
||||
accountsVM.getAccountStatuses(tempInstance, tempToken, accountId, max_id, null, null, exclude_replies, exclude_reblogs, media_only, false, MastodonHelper.statusesPerCall(requireActivity()))
|
||||
.observe(getViewLifecycleOwner(), statusesBottom -> dealWithPagination(statusesBottom, DIRECTION.BOTTOM, false));
|
||||
} else {
|
||||
flagLoading = false;
|
||||
|
|
|
@ -37,12 +37,13 @@ public class FragmentProfileTimeline extends Fragment {
|
|||
|
||||
private Account account;
|
||||
private FragmentProfileTimelinesBinding binding;
|
||||
|
||||
private boolean checkRemotely;
|
||||
public View onCreateView(@NonNull LayoutInflater inflater,
|
||||
ViewGroup container, Bundle savedInstanceState) {
|
||||
|
||||
if (getArguments() != null) {
|
||||
account = (Account) getArguments().getSerializable(Helper.ARG_ACCOUNT);
|
||||
checkRemotely = getArguments().getBoolean(Helper.ARG_CHECK_REMOTELY, false);
|
||||
}
|
||||
binding = FragmentProfileTimelinesBinding.inflate(inflater, container, false);
|
||||
return binding.getRoot();
|
||||
|
@ -57,7 +58,7 @@ public class FragmentProfileTimeline extends Fragment {
|
|||
binding.tabLayout.addTab(binding.tabLayout.newTab().setText(getString(R.string.media)));
|
||||
binding.tabLayout.setTabTextColors(ThemeHelper.getAttColor(requireActivity(), R.attr.mTextColor), ContextCompat.getColor(requireActivity(), R.color.cyanea_accent_dark_reference));
|
||||
binding.tabLayout.setTabIconTint(ThemeHelper.getColorStateList(requireActivity()));
|
||||
binding.viewpager.setAdapter(new FedilabProfilePageAdapter(getChildFragmentManager(), account));
|
||||
binding.viewpager.setAdapter(new FedilabProfilePageAdapter(getChildFragmentManager(), account, checkRemotely));
|
||||
binding.viewpager.setOffscreenPageLimit(3);
|
||||
binding.viewpager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(binding.tabLayout));
|
||||
binding.tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
|
||||
|
|
|
@ -31,10 +31,12 @@ import app.fedilab.android.ui.fragment.timeline.FragmentMastodonTimeline;
|
|||
public class FedilabProfilePageAdapter extends FragmentStatePagerAdapter {
|
||||
private final Account account;
|
||||
private Fragment mCurrentFragment;
|
||||
private final boolean checkRemotely;
|
||||
|
||||
public FedilabProfilePageAdapter(FragmentManager fm, Account account) {
|
||||
public FedilabProfilePageAdapter(FragmentManager fm, Account account, boolean remotely) {
|
||||
super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);
|
||||
this.account = account;
|
||||
this.checkRemotely = remotely;
|
||||
}
|
||||
|
||||
public Fragment getCurrentFragment() {
|
||||
|
@ -62,6 +64,7 @@ public class FedilabProfilePageAdapter extends FragmentStatePagerAdapter {
|
|||
bundle.putBoolean(Helper.ARG_SHOW_PINNED, true);
|
||||
bundle.putBoolean(Helper.ARG_SHOW_REPLIES, false);
|
||||
bundle.putBoolean(Helper.ARG_SHOW_REBLOGS, true);
|
||||
bundle.putBoolean(Helper.ARG_CHECK_REMOTELY, checkRemotely);
|
||||
fragmentProfileTimeline.setArguments(bundle);
|
||||
return fragmentProfileTimeline;
|
||||
case 1:
|
||||
|
@ -71,11 +74,13 @@ public class FedilabProfilePageAdapter extends FragmentStatePagerAdapter {
|
|||
bundle.putBoolean(Helper.ARG_SHOW_PINNED, false);
|
||||
bundle.putBoolean(Helper.ARG_SHOW_REPLIES, true);
|
||||
bundle.putBoolean(Helper.ARG_SHOW_REBLOGS, false);
|
||||
bundle.putBoolean(Helper.ARG_CHECK_REMOTELY, checkRemotely);
|
||||
fragmentProfileTimeline.setArguments(bundle);
|
||||
return fragmentProfileTimeline;
|
||||
case 2:
|
||||
FragmentMediaProfile fragmentMediaProfile = new FragmentMediaProfile();
|
||||
bundle.putSerializable(Helper.ARG_ACCOUNT, account);
|
||||
bundle.putBoolean(Helper.ARG_CHECK_REMOTELY, checkRemotely);
|
||||
fragmentMediaProfile.setArguments(bundle);
|
||||
return fragmentMediaProfile;
|
||||
default:
|
||||
|
|
|
@ -31,10 +31,12 @@ import app.fedilab.android.ui.fragment.timeline.FragmentProfileTimeline;
|
|||
public class FedilabProfileTLPageAdapter extends FragmentStatePagerAdapter {
|
||||
private final Account account;
|
||||
private Fragment mCurrentFragment;
|
||||
private final boolean checkRemotely;
|
||||
|
||||
public FedilabProfileTLPageAdapter(FragmentManager fm, Account account) {
|
||||
public FedilabProfileTLPageAdapter(FragmentManager fm, Account account, boolean remotely) {
|
||||
super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);
|
||||
this.account = account;
|
||||
this.checkRemotely = remotely;
|
||||
}
|
||||
|
||||
public Fragment getCurrentFragment() {
|
||||
|
@ -57,6 +59,7 @@ public class FedilabProfileTLPageAdapter extends FragmentStatePagerAdapter {
|
|||
FragmentProfileTimeline fragmentProfileTimeline = new FragmentProfileTimeline();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putSerializable(Helper.ARG_ACCOUNT, account);
|
||||
bundle.putSerializable(Helper.ARG_CHECK_REMOTELY, checkRemotely);
|
||||
fragmentProfileTimeline.setArguments(bundle);
|
||||
return fragmentProfileTimeline;
|
||||
case 1:
|
||||
|
@ -64,6 +67,7 @@ public class FedilabProfileTLPageAdapter extends FragmentStatePagerAdapter {
|
|||
FragmentMastodonAccount fragmentMastodonAccount = new FragmentMastodonAccount();
|
||||
bundle = new Bundle();
|
||||
bundle.putSerializable(Helper.ARG_ACCOUNT, account);
|
||||
bundle.putSerializable(Helper.ARG_CHECK_REMOTELY, checkRemotely);
|
||||
bundle.putString(Helper.ARG_VIEW_MODEL_KEY, "FEDILAB_" + position);
|
||||
bundle.putSerializable(Helper.ARG_FOLLOW_TYPE, position == 1 ? follow_type.FOLLOWING : follow_type.FOLLOWERS);
|
||||
fragmentMastodonAccount.setArguments(bundle);
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:autoMirrored="true"
|
||||
android:tint="#FFFFFF"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M7,9H2V7h5V9zM7,12H2v2h5V12zM20.59,19l-3.83,-3.83C15.96,15.69 15.02,16 14,16c-2.76,0 -5,-2.24 -5,-5s2.24,-5 5,-5s5,2.24 5,5c0,1.02 -0.31,1.96 -0.83,2.75L22,17.59L20.59,19zM17,11c0,-1.65 -1.35,-3 -3,-3s-3,1.35 -3,3s1.35,3 3,3S17,12.65 17,11zM2,19h10v-2H2V19z" />
|
||||
</vector>
|
|
@ -325,18 +325,39 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/info" />
|
||||
<!-- End Fields container -->
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/warning_message"
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:id="@+id/warning_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center"
|
||||
android:text="@string/disclaimer_full"
|
||||
android:textColor="@color/dark_text"
|
||||
android:orientation="horizontal"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/fields_container" />
|
||||
app:layout_constraintTop_toBottomOf="@+id/fields_container"
|
||||
tools:visibility="visible">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/warning_message"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:text="@string/disclaimer_full"
|
||||
android:textColor="@color/dark_text" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageButton
|
||||
android:id="@+id/open_remote_profile"
|
||||
style="@style/Widget.AppCompat.Button.Colored"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_marginStart="6dp"
|
||||
android:layout_marginTop="6dp"
|
||||
android:contentDescription="@string/display_remote_profile"
|
||||
android:scaleType="fitCenter"
|
||||
android:src="@drawable/ic_baseline_manage_search_24" />
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
|
|
|
@ -1899,4 +1899,6 @@
|
|||
<string name="show_anyway">Show anyway</string>
|
||||
<string name="filtered_by">Filtered: %1$s</string>
|
||||
<string name="toast_error_add_to_list">The app failed to add the account into the list!</string>
|
||||
<string name="display_remote_profile">Display remote profile</string>
|
||||
<string name="toast_fetch_error">The app cannot find remote data!</string>
|
||||
</resources>
|
Loading…
Reference in New Issue