mirror of
https://codeberg.org/tom79/Fedilab.git
synced 2024-12-22 08:40:03 +02:00
Some fixes for #2
This commit is contained in:
parent
207d8d9994
commit
713b5307e2
16 changed files with 129 additions and 72 deletions
|
@ -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();
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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<PatternType, Pattern> 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();
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -107,11 +107,15 @@ public class TimelineHelper {
|
|||
//A security to make sure filters have been fetched before displaying messages
|
||||
List<Notification> 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) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -102,9 +102,12 @@ public class AccountAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
|||
doAction = ProfileActivity.action.UNFOLLOW;
|
||||
accountViewHolder.binding.followAction.setIconResource(R.drawable.ic_baseline_person_remove_24);
|
||||
} else if (account.relationShip.requested) {
|
||||
accountViewHolder.binding.followAction.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(context, R.color.red_1)));
|
||||
doAction = ProfileActivity.action.NOTHING;
|
||||
accountViewHolder.binding.followAction.setEnabled(false);
|
||||
accountViewHolder.binding.followAction.setIconResource(R.drawable.ic_baseline_hourglass_full_24);
|
||||
} else {
|
||||
accountViewHolder.binding.followAction.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(context, R.color.cyanea_accent_dark_reference)));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -184,6 +184,9 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (statusDraft.text == null) {
|
||||
statusDraft.text = "";
|
||||
}
|
||||
//Put other accounts mentioned at the bottom
|
||||
boolean capitalize = sharedpreferences.getBoolean(context.getString(R.string.SET_CAPITALIZE), true);
|
||||
if (inReplyToUser != null) {
|
||||
|
@ -562,20 +565,22 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
|||
*/
|
||||
private void buttonState(ComposeViewHolder holder) {
|
||||
if (BaseMainActivity.software == null || BaseMainActivity.software.toUpperCase().compareTo("MASTODON") == 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);
|
||||
if (holder.getAdapterPosition() > 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<RecyclerView.ViewHolder
|
|||
AccountsVM accountsVM = new ViewModelProvider((ViewModelStoreOwner) context).get(AccountsVM.class);
|
||||
SearchVM searchVM = new ViewModelProvider((ViewModelStoreOwner) context).get(SearchVM.class);
|
||||
textw = 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) {
|
||||
|
||||
if (count > 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<RecyclerView.ViewHolder
|
|||
|
||||
if (s.toString().contains(fedilabHugsTrigger)) {
|
||||
newContent[0] = s.toString().replaceAll(fedilabHugsTrigger, "");
|
||||
int currentLength = MastodonHelper.countLength(holder);
|
||||
|
||||
int toFill = 500 - currentLength;
|
||||
if (toFill <= 0) {
|
||||
return;
|
||||
|
@ -720,8 +737,10 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
|||
searchLength[0] = Math.min(currentCursorPosition[0], searchDeep);
|
||||
|
||||
|
||||
if (currentCursorPosition[0] - (searchLength[0] - 1) < 0 || currentCursorPosition[0] == 0 || currentCursorPosition[0] > 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<RecyclerView.ViewHolder
|
|||
}
|
||||
String[] searchInArray = (s.toString().substring(currentCursorPosition[0] - searchLength[0], currentCursorPosition[0])).split("\\s");
|
||||
if (searchInArray.length < 1) {
|
||||
updateCharacterCount(holder);
|
||||
return;
|
||||
}
|
||||
String searchIn = searchInArray[searchInArray.length - 1];
|
||||
|
@ -1099,16 +1119,30 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
|||
holder.binding.buttonPoll.setOnClickListener(v -> 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<RecyclerView.ViewHolder
|
|||
} else {
|
||||
composePollBinding.buttonAddOption.setVisibility(View.VISIBLE);
|
||||
}
|
||||
int childCount = composePollBinding.optionsListContainer.getChildCount();
|
||||
if (childCount > 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<RecyclerView.ViewHolder
|
|||
} else {
|
||||
|
||||
ComposePollItemBinding composePollItemBinding = ComposePollItemBinding.inflate(LayoutInflater.from(context), new LinearLayout(context), false);
|
||||
|
||||
composePollItemBinding.text.setFilters(fArray);
|
||||
composePollItemBinding.text.setHint(context.getString(R.string.poll_choice_s, (pollCountItem[0] + 1)));
|
||||
composePollItemBinding.text.setText(pollItem.title);
|
||||
composePollBinding.optionsList.addView(composePollItemBinding.getRoot());
|
||||
composePollItemBinding.buttonRemove.setOnClickListener(view -> {
|
||||
composePollBinding.optionsList.removeView(view);
|
||||
|
@ -1335,21 +1368,12 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
|||
statusDraft.poll.expire_in = expire;
|
||||
|
||||
List<Poll.PollItem> 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<String> options = new ArrayList<>();
|
||||
boolean doubleTitle = false;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -86,6 +86,7 @@ public class OauthVM extends AndroidViewModel {
|
|||
if (tokenCall != null) {
|
||||
try {
|
||||
Response<Token> tokenResponse = tokenCall.execute();
|
||||
|
||||
if (tokenResponse.isSuccessful()) {
|
||||
token = tokenResponse.body();
|
||||
}
|
||||
|
|
|
@ -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" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatSpinner
|
||||
|
@ -92,7 +92,7 @@
|
|||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="Poll duration:"
|
||||
android:text="@string/poll_duration"
|
||||
android:textAlignment="viewEnd" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatSpinner
|
||||
|
|
|
@ -1585,6 +1585,8 @@
|
|||
<string name="types_of_notifications_to_display">Types of notifications to display</string>
|
||||
<string name="set_unfollow_validation_title">Confirm unfollows</string>
|
||||
<string name="message_has_been_sent">Message has been sent!</string>
|
||||
<string name="poll_type">Poll type:</string>
|
||||
<string name="poll_duration">Poll duration:</string>
|
||||
|
||||
|
||||
</resources>
|
||||
|
|
Loading…
Reference in a new issue