From 713b5307e2f3a6e7f7f778d3b5870a6343d6cd10 Mon Sep 17 00:00:00 2001 From: Thomas Date: Fri, 29 Apr 2022 17:12:03 +0200 Subject: [PATCH] Some fixes for #2 --- .../android/activities/HashTagActivity.java | 6 +- .../android/activities/LoginActivity.java | 8 +- .../android/activities/ProfileActivity.java | 2 +- .../activities/WebviewConnectActivity.java | 14 +-- .../helper/CommentDecorationHelper.java | 2 +- .../app/fedilab/android/helper/Helper.java | 15 +++ .../android/helper/MastodonHelper.java | 13 +-- .../android/helper/TimelineHelper.java | 14 ++- .../android/services/PostMessageService.java | 4 +- .../android/ui/drawer/AccountAdapter.java | 3 + .../android/ui/drawer/ComposeAdapter.java | 98 ++++++++++++------- .../timeline/FragmentMastodonTimeline.java | 11 ++- .../FedilabProfilePageAdapter.java | 4 + .../android/viewmodel/mastodon/OauthVM.java | 1 + app/src/main/res/layout/compose_poll.xml | 4 +- app/src/main/res/values/strings.xml | 2 + 16 files changed, 129 insertions(+), 72 deletions(-) diff --git a/app/src/main/java/app/fedilab/android/activities/HashTagActivity.java b/app/src/main/java/app/fedilab/android/activities/HashTagActivity.java index 585f0bca..060f0b4a 100644 --- a/app/src/main/java/app/fedilab/android/activities/HashTagActivity.java +++ b/app/src/main/java/app/fedilab/android/activities/HashTagActivity.java @@ -17,6 +17,8 @@ package app.fedilab.android.activities; import android.content.Intent; import android.os.Bundle; +import android.os.Handler; +import android.os.Looper; import android.view.Menu; import android.view.MenuItem; @@ -120,7 +122,9 @@ public class HashTagActivity extends BaseActivity { } } if (!canBeAdded) { - Toasty.warning(HashTagActivity.this, getString(R.string.tags_already_stored), Toasty.LENGTH_SHORT).show(); + Handler mainHandler = new Handler(Looper.getMainLooper()); + Runnable myRunnable = () -> Toasty.warning(HashTagActivity.this, getString(R.string.tags_already_stored), Toasty.LENGTH_SHORT).show(); + mainHandler.post(myRunnable); return; } PinnedTimeline pinnedTimeline = new PinnedTimeline(); diff --git a/app/src/main/java/app/fedilab/android/activities/LoginActivity.java b/app/src/main/java/app/fedilab/android/activities/LoginActivity.java index 0d1af166..3241a41c 100644 --- a/app/src/main/java/app/fedilab/android/activities/LoginActivity.java +++ b/app/src/main/java/app/fedilab/android/activities/LoginActivity.java @@ -39,6 +39,8 @@ import androidx.preference.PreferenceManager; import org.jetbrains.annotations.NotNull; +import java.util.regex.Matcher; + import app.fedilab.android.BaseMainActivity; import app.fedilab.android.R; import app.fedilab.android.client.entities.Account; @@ -81,12 +83,12 @@ public class LoginActivity extends BaseActivity { //That happens when the user wants to use an external browser if (getIntent() != null && getIntent().getData() != null && getIntent().getData().toString().contains(REDIRECT_CONTENT_WEB + "?code=")) { String url = getIntent().getData().toString(); - String[] val = url.split("code="); - if (val.length < 2) { + Matcher matcher = Helper.codePattern.matcher(url); + if (!matcher.find()) { Toasty.error(LoginActivity.this, getString(R.string.toast_code_error), Toast.LENGTH_LONG).show(); return; } - String code = val[1]; + String code = matcher.group(1); OauthVM oauthVM = new ViewModelProvider(LoginActivity.this).get(OauthVM.class); //We are dealing with a Mastodon API if (api == Account.API.MASTODON) { diff --git a/app/src/main/java/app/fedilab/android/activities/ProfileActivity.java b/app/src/main/java/app/fedilab/android/activities/ProfileActivity.java index cf98a999..b66a98c7 100644 --- a/app/src/main/java/app/fedilab/android/activities/ProfileActivity.java +++ b/app/src/main/java/app/fedilab/android/activities/ProfileActivity.java @@ -656,7 +656,7 @@ public class ProfileActivity extends BaseActivity { public boolean onCreateOptionsMenu(@NonNull Menu menu) { getMenuInflater().inflate(R.menu.activity_profile, menu); if (account != null) { - final boolean isOwner = account.id.compareToIgnoreCase(BaseMainActivity.currentUserID) == 0; + final boolean isOwner = account.id != null && account.id.compareToIgnoreCase(BaseMainActivity.currentUserID) == 0; String[] splitAcct = account.acct.split("@"); //check if user is from the same instance if (splitAcct.length <= 1) { //If yes, these entries must be hidden diff --git a/app/src/main/java/app/fedilab/android/activities/WebviewConnectActivity.java b/app/src/main/java/app/fedilab/android/activities/WebviewConnectActivity.java index 1b322026..829e2e20 100644 --- a/app/src/main/java/app/fedilab/android/activities/WebviewConnectActivity.java +++ b/app/src/main/java/app/fedilab/android/activities/WebviewConnectActivity.java @@ -42,7 +42,6 @@ import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.ProgressBar; import android.widget.TextView; -import android.widget.Toast; import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.AlertDialog; @@ -50,6 +49,8 @@ import androidx.core.content.ContextCompat; import androidx.lifecycle.ViewModelProvider; import androidx.preference.PreferenceManager; +import java.util.regex.Matcher; + import app.fedilab.android.BaseMainActivity; import app.fedilab.android.R; import app.fedilab.android.client.entities.Account; @@ -59,7 +60,6 @@ import app.fedilab.android.helper.Helper; import app.fedilab.android.helper.ThemeHelper; import app.fedilab.android.viewmodel.mastodon.AccountsVM; import app.fedilab.android.viewmodel.mastodon.OauthVM; -import es.dmoral.toasty.Toasty; public class WebviewConnectActivity extends BaseActivity { @@ -183,15 +183,11 @@ public class WebviewConnectActivity extends BaseActivity { public boolean shouldOverrideUrlLoading(WebView view, String url) { super.shouldOverrideUrlLoading(view, url); if (url.contains(Helper.REDIRECT_CONTENT_WEB)) { - String[] val = url.split("code="); - if (val.length < 2) { - Toasty.error(WebviewConnectActivity.this, getString(R.string.toast_code_error), Toast.LENGTH_LONG).show(); - Intent myIntent = new Intent(WebviewConnectActivity.this, LoginActivity.class); - startActivity(myIntent); - finish(); + Matcher matcher = Helper.codePattern.matcher(url); + if (!matcher.find()) { return false; } - String code = val[1]; + String code = matcher.group(1); OauthVM oauthVM = new ViewModelProvider(WebviewConnectActivity.this).get(OauthVM.class); //API call to get the user token oauthVM.createToken(currentInstance, "authorization_code", BaseMainActivity.client_id, BaseMainActivity.client_secret, Helper.REDIRECT_CONTENT_WEB, Helper.OAUTH_SCOPES, code) diff --git a/app/src/main/java/app/fedilab/android/helper/CommentDecorationHelper.java b/app/src/main/java/app/fedilab/android/helper/CommentDecorationHelper.java index 0dc2086f..11c9a38b 100644 --- a/app/src/main/java/app/fedilab/android/helper/CommentDecorationHelper.java +++ b/app/src/main/java/app/fedilab/android/helper/CommentDecorationHelper.java @@ -53,7 +53,7 @@ public class CommentDecorationHelper { } String targetedComment = null; for (Status status : statuses) { - if (replyToCommentId.compareTo(status.id) == 0) { + if (status != null && status.id != null && replyToCommentId.compareTo(status.id) == 0) { targetedComment = status.in_reply_to_id; break; } diff --git a/app/src/main/java/app/fedilab/android/helper/Helper.java b/app/src/main/java/app/fedilab/android/helper/Helper.java index c8f7251c..9cff1e14 100644 --- a/app/src/main/java/app/fedilab/android/helper/Helper.java +++ b/app/src/main/java/app/fedilab/android/helper/Helper.java @@ -51,6 +51,7 @@ import android.provider.MediaStore; import android.provider.OpenableColumns; import android.text.TextUtils; import android.util.DisplayMetrics; +import android.util.Log; import android.util.TypedValue; import android.view.LayoutInflater; import android.view.Menu; @@ -187,6 +188,8 @@ public class Helper { public static final String ARG_MEDIA_POSITION = "ARG_MEDIA_POSITION"; public static final String ARG_MEDIA_ATTACHMENT = "ARG_MEDIA_ATTACHMENT"; public static final String ARG_SHOW_REPLIES = "ARG_SHOW_REPLIES"; + public static final String ARG_SHOW_REBLOGS = "ARG_SHOW_REBLOGS"; + 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"; @@ -251,6 +254,8 @@ public class Helper { public static final Pattern xmppPattern = Pattern.compile("xmpp:[-a-zA-Z0-9+$&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]"); public static final Pattern mediumPattern = Pattern.compile("([\\w@-]*)?\\.?medium.com/@?([/\\w-]+)"); public static final Pattern wikipediaPattern = Pattern.compile("([\\w_-]+)\\.wikipedia.org/(((?!([\"'<])).)*)"); + public static final Pattern codePattern = Pattern.compile("code=([\\w-]+)"); + // --- Static Map of patterns used in spannable status content public static final Map patternHashMap; public static int counter = 1; @@ -1184,8 +1189,18 @@ public class Helper { attachment.size = Helper.getRealSizeFromUri(context, uri); ContentResolver cR = context.getApplicationContext().getContentResolver(); attachment.mimeType = cR.getType(uri); + Log.v(Helper.TAG, "uri: " + uri); + Log.v(Helper.TAG, "attachment.mimeType: " + attachment.mimeType); + MimeTypeMap mime = MimeTypeMap.getSingleton(); String extension = mime.getExtensionFromMimeType(cR.getType(uri)); + + Log.v(Helper.TAG, "mime: " + attachment.mimeType); + Log.v(Helper.TAG, "extension: " + attachment.mimeType); + if (uri.toString().endsWith("fedilab_recorded_audio.wav")) { + extension = "wav"; + attachment.mimeType = "audio/x-wav"; + } SimpleDateFormat formatter = new SimpleDateFormat("yyyy_MM_dd_HH_mm_ss_" + counter, Locale.getDefault()); counter++; Date now = new Date(); diff --git a/app/src/main/java/app/fedilab/android/helper/MastodonHelper.java b/app/src/main/java/app/fedilab/android/helper/MastodonHelper.java index fe454e4a..546a485a 100644 --- a/app/src/main/java/app/fedilab/android/helper/MastodonHelper.java +++ b/app/src/main/java/app/fedilab/android/helper/MastodonHelper.java @@ -159,7 +159,7 @@ public class MastodonHelper { return pagination; } pagination.max_id = statusList.get(0).id; - pagination.min_id = String.valueOf(Long.parseLong(statusList.get(statusList.size() - 1).id) - 1); + pagination.min_id = statusList.get(statusList.size() - 1).id; return pagination; } @@ -169,7 +169,7 @@ public class MastodonHelper { return pagination; } pagination.max_id = accountList.get(0).id; - pagination.min_id = String.valueOf(Long.parseLong(accountList.get(accountList.size() - 1).id) - 1); + pagination.min_id = accountList.get(accountList.size() - 1).id; return pagination; } @@ -179,7 +179,7 @@ public class MastodonHelper { return pagination; } pagination.max_id = scheduledStatusList.get(0).id; - pagination.min_id = String.valueOf(Long.parseLong(scheduledStatusList.get(scheduledStatusList.size() - 1).id) - 1); + pagination.min_id = scheduledStatusList.get(scheduledStatusList.size() - 1).id; return pagination; } @@ -189,7 +189,7 @@ public class MastodonHelper { return pagination; } pagination.max_id = conversationList.get(0).id; - pagination.min_id = String.valueOf(Long.parseLong(conversationList.get(conversationList.size() - 1).id) - 1); + pagination.min_id = conversationList.get(conversationList.size() - 1).id; return pagination; } @@ -276,8 +276,9 @@ public class MastodonHelper { Matcher matcherALink = Patterns.WEB_URL.matcher(contentCount); while (matcherALink.find()) { final String url = matcherALink.group(1); - assert url != null; - contentCount = contentCount.replace(url, "abcdefghijklmnopkrstuvw"); + if (url != null) { + contentCount = contentCount.replace(url, "abcdefghijklmnopkrstuvw"); + } } int contentLength = contentCount.length() - countWithEmoji(content); int cwLength = cwContent.length() - countWithEmoji(cwContent); diff --git a/app/src/main/java/app/fedilab/android/helper/TimelineHelper.java b/app/src/main/java/app/fedilab/android/helper/TimelineHelper.java index 7e8a73bf..a47a6e90 100644 --- a/app/src/main/java/app/fedilab/android/helper/TimelineHelper.java +++ b/app/src/main/java/app/fedilab/android/helper/TimelineHelper.java @@ -107,11 +107,15 @@ public class TimelineHelper { //A security to make sure filters have been fetched before displaying messages List notificationToRemove = new ArrayList<>(); if (!BaseMainActivity.filterFetched) { - AccountsVM accountsVM = new ViewModelProvider((ViewModelStoreOwner) context).get(AccountsVM.class); - accountsVM.getFilters(BaseMainActivity.currentInstance, BaseMainActivity.currentToken).observe((LifecycleOwner) context, filters -> { - BaseMainActivity.filterFetched = true; - BaseMainActivity.mainFilters = filters; - }); + try { + AccountsVM accountsVM = new ViewModelProvider((ViewModelStoreOwner) context).get(AccountsVM.class); + accountsVM.getFilters(BaseMainActivity.currentInstance, BaseMainActivity.currentToken).observe((LifecycleOwner) context, filters -> { + BaseMainActivity.filterFetched = true; + BaseMainActivity.mainFilters = filters; + }); + } catch (Exception e) { + return notifications; + } } //If there are filters: if (BaseMainActivity.mainFilters != null && BaseMainActivity.mainFilters.size() > 0) { diff --git a/app/src/main/java/app/fedilab/android/services/PostMessageService.java b/app/src/main/java/app/fedilab/android/services/PostMessageService.java index a80ea37e..0af6234d 100644 --- a/app/src/main/java/app/fedilab/android/services/PostMessageService.java +++ b/app/src/main/java/app/fedilab/android/services/PostMessageService.java @@ -300,8 +300,8 @@ public class PostMessageService extends IntentService { } } - if (scheduledDate == null && token != null) { - Account account = null; + if (scheduledDate == null && token != null && firstSendMessage != null) { + Account account; try { account = new Account(PostMessageService.this).getAccountByToken(token); final Intent pendingIntent = new Intent(PostMessageService.this, ContextActivity.class); diff --git a/app/src/main/java/app/fedilab/android/ui/drawer/AccountAdapter.java b/app/src/main/java/app/fedilab/android/ui/drawer/AccountAdapter.java index cb079e57..dc525e82 100644 --- a/app/src/main/java/app/fedilab/android/ui/drawer/AccountAdapter.java +++ b/app/src/main/java/app/fedilab/android/ui/drawer/AccountAdapter.java @@ -102,9 +102,12 @@ public class AccountAdapter extends RecyclerView.Adapter 0) { + Status statusDraft = statusList.get(holder.getAdapterPosition()); + if (statusDraft.poll == null) { + holder.binding.buttonAttachImage.setEnabled(true); + holder.binding.buttonAttachVideo.setEnabled(true); + holder.binding.buttonAttachAudio.setEnabled(true); + holder.binding.buttonAttachManual.setEnabled(true); + } else { + holder.binding.buttonAttachImage.setEnabled(false); + holder.binding.buttonAttachVideo.setEnabled(false); + holder.binding.buttonAttachAudio.setEnabled(false); + holder.binding.buttonAttachManual.setEnabled(false); + holder.binding.buttonPoll.setEnabled(true); + } + holder.binding.buttonPoll.setEnabled(statusDraft.media_attachments == null || statusDraft.media_attachments.size() <= 0); } - holder.binding.buttonPoll.setEnabled(statusDraft.media_attachments == null || statusDraft.media_attachments.size() <= 0); } } @@ -612,17 +617,29 @@ public class ComposeAdapter extends RecyclerView.Adapter 2) { + holder.binding.addRemoveStatus.setVisibility(View.VISIBLE); + } + position = start; } @Override public void afterTextChanged(Editable s) { + int currentLength = MastodonHelper.countLength(holder); + //Copy/past + if (currentLength > instanceInfo.configuration.statusesConf.max_characters + 1) { + holder.binding.content.setText(s.delete(instanceInfo.configuration.statusesConf.max_characters - holder.binding.contentSpoiler.getText().length(), (currentLength - holder.binding.contentSpoiler.getText().length()))); + } else if (currentLength > instanceInfo.configuration.statusesConf.max_characters) { + holder.binding.content.setText(s.delete(position, position + 1)); + } statusList.get(holder.getAdapterPosition()).text = s.toString(); if (s.toString().trim().length() < 2) { buttonVisibility(holder); @@ -639,7 +656,7 @@ public class ComposeAdapter extends RecyclerView.Adapter s.toString().length()) + if (currentCursorPosition[0] - (searchLength[0] - 1) < 0 || currentCursorPosition[0] == 0 || currentCursorPosition[0] > s.toString().length()) { + updateCharacterCount(holder); return; + } String patternh = "^(.|\\s)*(:fedilab_hugs:)$"; final Pattern hPattern = Pattern.compile(patternh); @@ -741,6 +760,7 @@ public class ComposeAdapter extends RecyclerView.Adapter displayPollPopup(holder, statusDraft, position)); holder.binding.characterProgress.setMax(instanceInfo.configuration.statusesConf.max_characters); holder.binding.contentSpoiler.addTextChangedListener(new TextWatcher() { + private int position; + @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { + position = start; + if (count > 2) { + holder.binding.addRemoveStatus.setVisibility(View.VISIBLE); + } } @Override public void afterTextChanged(Editable s) { + int currentLength = MastodonHelper.countLength(holder); + if (currentLength > instanceInfo.configuration.statusesConf.max_characters + 1) { + holder.binding.contentSpoiler.setText(s.delete(instanceInfo.configuration.statusesConf.max_characters - holder.binding.content.getText().length(), (currentLength - holder.binding.content.getText().length()))); + buttonVisibility(holder); + } else if (currentLength > instanceInfo.configuration.statusesConf.max_characters) { + buttonVisibility(holder); + holder.binding.contentSpoiler.setText(s.delete(position, position + 1)); + } statusList.get(holder.getAdapterPosition()).spoiler_text = s.toString(); if (s.toString().trim().length() < 2) { buttonVisibility(holder); @@ -1199,11 +1233,10 @@ public class ComposeAdapter extends RecyclerView.Adapter 2) { - for (int i = 2; i < childCount; i++) { - ((AppCompatEditText) composePollBinding.optionsListContainer.getChildAt(i)).setHint(context.getString(R.string.poll_choice_s, i + 1)); - } + int childCount = composePollBinding.optionsList.getChildCount(); + for (int i = 0; i < childCount; i++) { + AppCompatEditText title = (composePollBinding.optionsList.getChildAt(i)).findViewById(R.id.text); + title.setHint(context.getString(R.string.poll_choice_s, i + 1)); } }); @@ -1238,9 +1271,9 @@ public class ComposeAdapter extends RecyclerView.Adapter { composePollBinding.optionsList.removeView(view); @@ -1335,21 +1368,12 @@ public class ComposeAdapter extends RecyclerView.Adapter pollItems = new ArrayList<>(); - Poll.PollItem pollOption1 = new Poll.PollItem(); - pollOption1.title = choice1; - pollItems.add(pollOption1); - - Poll.PollItem pollOption2 = new Poll.PollItem(); - pollOption2.title = choice2; - pollItems.add(pollOption2); - - int childCount = composePollBinding.optionsListContainer.getChildCount(); - if (childCount > 2) { - for (int i = 2; i < childCount; i++) { - Poll.PollItem pollItem = new Poll.PollItem(); - pollItem.title = ((AppCompatEditText) composePollBinding.optionsListContainer.getChildAt(i)).getText().toString(); - pollItems.add(pollItem); - } + int childCount = composePollBinding.optionsList.getChildCount(); + for (int i = 0; i < childCount; i++) { + Poll.PollItem pollItem = new Poll.PollItem(); + AppCompatEditText title = (composePollBinding.optionsList.getChildAt(i)).findViewById(R.id.text); + pollItem.title = title.getText().toString(); + pollItems.add(pollItem); } List options = new ArrayList<>(); boolean doubleTitle = false; diff --git a/app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentMastodonTimeline.java b/app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentMastodonTimeline.java index 9650d7d4..1ed2e949 100644 --- a/app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentMastodonTimeline.java +++ b/app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentMastodonTimeline.java @@ -70,7 +70,7 @@ public class FragmentMastodonTimeline extends Fragment { private TagTimeline tagTimeline; private LinearLayoutManager mLayoutManager; private Account accountTimeline; - private boolean show_replies, show_pinned, media_only, minified; + private boolean exclude_replies, exclude_reblogs, show_pinned, media_only, minified; private String viewModelKey; public View onCreateView(@NonNull LayoutInflater inflater, @@ -85,8 +85,9 @@ public class FragmentMastodonTimeline extends Fragment { searchCache = getArguments().getString(Helper.ARG_SEARCH_KEYWORD_CACHE, null); tagTimeline = (TagTimeline) getArguments().getSerializable(Helper.ARG_TAG_TIMELINE); accountTimeline = (Account) getArguments().getSerializable(Helper.ARG_ACCOUNT); - show_replies = getArguments().getBoolean(Helper.ARG_SHOW_REPLIES, false); + exclude_replies = !getArguments().getBoolean(Helper.ARG_SHOW_REPLIES, true); 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); viewModelKey = getArguments().getString(Helper.ARG_VIEW_MODEL_KEY, ""); minified = getArguments().getBoolean(Helper.ARG_MINIFIED, false); @@ -367,17 +368,17 @@ public class FragmentMastodonTimeline extends Fragment { 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())) - .observe(getViewLifecycleOwner(), pinnedStatuses -> accountsVM.getAccountStatuses(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, accountTimeline.id, null, null, null, show_replies, !show_replies, false, false, 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 -> { otherStatuses.statuses.addAll(0, pinnedStatuses.statuses); initializeStatusesCommonView(otherStatuses); })); } else { - accountsVM.getAccountStatuses(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, accountTimeline.id, null, null, null, show_replies, !show_replies, media_only, false, MastodonHelper.statusesPerCall(requireActivity())) + accountsVM.getAccountStatuses(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, accountTimeline.id, 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, show_replies, !show_replies, media_only, false, MastodonHelper.statusesPerCall(requireActivity())) + accountsVM.getAccountStatuses(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, accountTimeline.id, max_id, null, null, exclude_replies, exclude_reblogs, media_only, false, MastodonHelper.statusesPerCall(requireActivity())) .observe(getViewLifecycleOwner(), statusesBottom -> dealWithPagination(statusesBottom, DIRECTION.BOTTOM)); } else { flagLoading = false; diff --git a/app/src/main/java/app/fedilab/android/ui/pageadapter/FedilabProfilePageAdapter.java b/app/src/main/java/app/fedilab/android/ui/pageadapter/FedilabProfilePageAdapter.java index f3610552..73c29528 100644 --- a/app/src/main/java/app/fedilab/android/ui/pageadapter/FedilabProfilePageAdapter.java +++ b/app/src/main/java/app/fedilab/android/ui/pageadapter/FedilabProfilePageAdapter.java @@ -60,13 +60,17 @@ public class FedilabProfilePageAdapter extends FragmentStatePagerAdapter { 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_SHOW_REPLIES, false); + bundle.putBoolean(Helper.ARG_SHOW_REBLOGS, true); fragmentProfileTimeline.setArguments(bundle); return fragmentProfileTimeline; case 1: fragmentProfileTimeline = new FragmentMastodonTimeline(); bundle.putSerializable(Helper.ARG_TIMELINE_TYPE, Timeline.TimeLineEnum.ACCOUNT_TIMELINE); bundle.putSerializable(Helper.ARG_ACCOUNT, account); + bundle.putBoolean(Helper.ARG_SHOW_PINNED, false); bundle.putBoolean(Helper.ARG_SHOW_REPLIES, true); + bundle.putBoolean(Helper.ARG_SHOW_REBLOGS, false); fragmentProfileTimeline.setArguments(bundle); return fragmentProfileTimeline; case 2: diff --git a/app/src/main/java/app/fedilab/android/viewmodel/mastodon/OauthVM.java b/app/src/main/java/app/fedilab/android/viewmodel/mastodon/OauthVM.java index 3814e837..ea99eec0 100644 --- a/app/src/main/java/app/fedilab/android/viewmodel/mastodon/OauthVM.java +++ b/app/src/main/java/app/fedilab/android/viewmodel/mastodon/OauthVM.java @@ -86,6 +86,7 @@ public class OauthVM extends AndroidViewModel { if (tokenCall != null) { try { Response tokenResponse = tokenCall.execute(); + if (tokenResponse.isSuccessful()) { token = tokenResponse.body(); } diff --git a/app/src/main/res/layout/compose_poll.xml b/app/src/main/res/layout/compose_poll.xml index 32decc30..6cc1a04e 100644 --- a/app/src/main/res/layout/compose_poll.xml +++ b/app/src/main/res/layout/compose_poll.xml @@ -71,7 +71,7 @@ android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" - android:text="Poll type:" + android:text="@string/poll_type" android:textAlignment="viewEnd" /> Types of notifications to display Confirm unfollows Message has been sent! + Poll type: + Poll duration: