Update to 6.1.1 (1946)

This commit is contained in:
DrKLO 2020-05-01 10:08:26 +08:00 committed by 世界
parent b360cde732
commit dcbdc1d828
No known key found for this signature in database
GPG Key ID: CD109927C34A63C4
14 changed files with 252 additions and 95 deletions

View File

@ -314,7 +314,14 @@ public class AndroidUtilities {
if (links.size() == 0) {
return false;
}
for (LinkSpec link : links) {
for (int a = 0, N = links.size(); a < N; a++) {
LinkSpec link = links.get(a);
URLSpan[] oldSpans = text.getSpans(link.start, link.end, URLSpan.class);
if (oldSpans != null && oldSpans.length > 0) {
for (int b = 0; b < oldSpans.length; b++) {
text.removeSpan(oldSpans[b]);
}
}
text.setSpan(new URLSpan(link.url), link.start, link.end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
return true;
@ -3611,7 +3618,7 @@ public class AndroidUtilities {
if (ch == '.' || ch == '-' || ch == '/' || ch == '+' || ch >= '0' && ch <= '9') {
continue;
}
if (ch >= 'a' && ch < 'z' || ch >= 'A' && ch <= 'Z') {
if (ch >= 'a' && ch <= 'z' || ch >= 'A' && ch <= 'Z') {
hasLatin = true;
} else {
hasNonLatin = true;

View File

@ -3931,14 +3931,14 @@ public class MediaDataController extends BaseController {
Collections.sort(entities, entityComparator);
}
private static boolean checkInclusion(int index, ArrayList<TLRPC.MessageEntity> entities) {
private static boolean checkInclusion(int index, ArrayList<TLRPC.MessageEntity> entities, boolean end) {
if (entities == null || entities.isEmpty()) {
return false;
}
int count = entities.size();
for (int a = 0; a < count; a++) {
TLRPC.MessageEntity entity = entities.get(a);
if (entity.offset <= index && entity.offset + entity.length > index) {
if ((end ? entity.offset < index : entity.offset <= index) && entity.offset + entity.length > index) {
return true;
}
}
@ -4266,7 +4266,7 @@ public class MediaDataController extends BaseController {
TextStyleSpan span = spans[a];
int spanStart = spannable.getSpanStart(span);
int spanEnd = spannable.getSpanEnd(span);
if (checkInclusion(spanStart, entities) || checkInclusion(spanEnd, entities) || checkIntersection(spanStart, spanEnd, entities)) {
if (checkInclusion(spanStart, entities, false) || checkInclusion(spanEnd, entities, true) || checkIntersection(spanStart, spanEnd, entities)) {
continue;
}
if (entities == null) {
@ -4370,7 +4370,7 @@ public class MediaDataController extends BaseController {
while ((index = TextUtils.indexOf(message[0], checkString, lastIndex)) != -1) {
if (start == -1) {
char prevChar = index == 0 ? ' ' : message[0].charAt(index - 1);
if (!checkInclusion(index, entities) && (prevChar == ' ' || prevChar == '\n')) {
if (!checkInclusion(index, entities, false) && (prevChar == ' ' || prevChar == '\n')) {
start = index;
}
lastIndex = index + 2;
@ -4383,7 +4383,7 @@ public class MediaDataController extends BaseController {
}
}
lastIndex = index + 2;
if (checkInclusion(index, entities) || checkIntersection(start, index, entities)) {
if (checkInclusion(index, entities, false) || checkIntersection(start, index, entities)) {
start = -1;
continue;
}

View File

@ -1014,7 +1014,8 @@ public class MessageObject {
messageText = replaceWithLink(LocaleController.getString("EventLogAdded", R.string.EventLogAdded), "un2", whoUser);
messageText = replaceWithLink(messageText, "un1", fromUser);
}
} else if (event.action instanceof TLRPC.TL_channelAdminLogEventActionParticipantToggleAdmin) {
} else if (event.action instanceof TLRPC.TL_channelAdminLogEventActionParticipantToggleAdmin ||
event.action instanceof TLRPC.TL_channelAdminLogEventActionParticipantToggleBan && event.action.prev_participant instanceof TLRPC.TL_channelParticipantAdmin && event.action.new_participant instanceof TLRPC.TL_channelParticipant) {
messageOwner = new TLRPC.TL_message();
TLRPC.User whoUser = MessagesController.getInstance(currentAccount).getUser(event.action.prev_participant.user_id);
StringBuilder rights;

View File

@ -9683,18 +9683,22 @@ public class MessagesStorage extends BaseController {
for (int a = 0; a < dialogs.dialogs.size(); a++) {
TLRPC.Dialog dialog = dialogs.dialogs.get(a);
boolean exists = false;
DialogObject.initDialog(dialog);
if (check == 1) {
SQLiteCursor cursor = database.queryFinalized("SELECT did FROM dialogs WHERE did = " + dialog.id);
boolean exists = cursor.next();
exists = cursor.next();
cursor.dispose();
if (exists) {
continue;
}
} else if (dialog.pinned && check == 2) {
} else if (check == 2) {
SQLiteCursor cursor = database.queryFinalized("SELECT pinned FROM dialogs WHERE did = " + dialog.id);
if (cursor.next()) {
dialog.pinnedNum = cursor.intValue(0);
exists = true;
if (dialog.pinned) {
dialog.pinnedNum = cursor.intValue(0);
}
}
cursor.dispose();
}
@ -9753,7 +9757,12 @@ public class MessagesStorage extends BaseController {
state_polls.step();
}
createFirstHoles(dialog.id, state_holes, state_media_holes, message.id);
if (exists) {
closeHolesInTable("messages_holes", dialog.id, message.id, message.id);
closeHolesInMedia(dialog.id, message.id, message.id, -1);
} else {
createFirstHoles(dialog.id, state_holes, state_media_holes, message.id);
}
}
long topMessage = dialog.top_message;

View File

@ -3101,6 +3101,7 @@ public class SendMessagesHelper extends BaseController implements NotificationCe
}
if (poll.results != null && !TextUtils.isEmpty(poll.results.solution)) {
inputMediaPoll.solution = poll.results.solution;
inputMediaPoll.solution_entities = poll.results.solution_entities;
inputMediaPoll.flags |= 2;
}
inputMedia = inputMediaPoll;

View File

@ -5353,6 +5353,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
if (!animated) {
psaButtonProgress = show ? 1.0f : 0.0f;
} else {
setInvalidatesParent(true);
invalidate();
}
}
@ -5380,6 +5381,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
if (invalidatesParent && getParent() != null) {
View parent = (View) getParent();
if (parent.getParent() != null) {
parent.invalidate();
parent = (View) parent.getParent();
parent.invalidate();
}
@ -8853,6 +8855,35 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
setDrawableBounds(currentBackgroundShadowDrawable, backgroundDrawableLeft, backgroundTop, backgroundDrawableRight, layoutHeight - offsetBottom + additionalBottom);
}
if (hasPsaHint) {
int x;
if (currentPosition == null || (currentPosition.flags & MessageObject.POSITION_FLAG_RIGHT) != 0) {
x = currentBackgroundDrawable.getBounds().right;
} else {
x = 0;
int dWidth = getGroupPhotosWidth();
for (int a = 0; a < currentMessagesGroup.posArray.size(); a++) {
MessageObject.GroupedMessagePosition position = currentMessagesGroup.posArray.get(a);
if (position.minY == 0) {
x += Math.ceil((position.pw + position.leftSpanOffset) / 1000.0f * dWidth);
} else {
break;
}
}
}
Drawable drawable = Theme.chat_psaHelpDrawable[currentMessageObject.isOutOwner() ? 1 : 0];
int y;
if (currentMessageObject.type == MessageObject.TYPE_ROUND_VIDEO) {
y = AndroidUtilities.dp(12);
} else {
y = AndroidUtilities.dp(10 + (drawNameLayout ? 19 : 0));
}
psaHelpX = x - drawable.getIntrinsicWidth() - AndroidUtilities.dp(currentMessageObject.isOutOwner() ? 20 : 14);
psaHelpY = y + AndroidUtilities.dp(4);
}
if (checkBoxVisible || checkBoxAnimationInProgress) {
if (checkBoxVisible && checkBoxAnimationProgress == 1.0f || !checkBoxVisible && checkBoxAnimationProgress == 0.0f) {
checkBoxAnimationInProgress = false;
@ -9167,13 +9198,6 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
if (hasPsaHint) {
if (psaButtonVisible || psaButtonProgress > 0) {
Drawable drawable = Theme.chat_psaHelpDrawable[currentMessageObject.isOutOwner() ? 1 : 0];
if (pollVoteInProgress) {
drawable.setAlpha((int) (255 * pollAnimationProgress));
} else {
drawable.setAlpha(255);
}
psaHelpX = currentBackgroundDrawable.getBounds().right - drawable.getIntrinsicWidth() - AndroidUtilities.dp(currentMessageObject.isOutOwner() ? 20 : 14);
psaHelpY = forwardNameY + AndroidUtilities.dp(4);
int cx = psaHelpX + drawable.getIntrinsicWidth() / 2;
int cy = psaHelpY + drawable.getIntrinsicHeight() / 2;
float scale = psaButtonVisible && psaButtonProgress < 1 ? AnimationProperties.overshootInterpolator.getInterpolation(psaButtonProgress) : psaButtonProgress;
@ -9191,16 +9215,18 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
}
if (psaButtonVisible && psaButtonProgress < 1.0f) {
psaButtonProgress += dt / 180.0f;
invalidate();
if (psaButtonProgress > 1.0f) {
psaButtonProgress = 1.0f;
setInvalidatesParent(false);
}
invalidate();
} else if (!psaButtonVisible && psaButtonProgress > 0.0f) {
psaButtonProgress -= dt / 180.0f;
invalidate();
if (psaButtonProgress < 0.0f) {
psaButtonProgress = 0.0f;
setInvalidatesParent(false);
}
invalidate();
}
}
}

View File

@ -18,6 +18,7 @@ import android.graphics.PorterDuffColorFilter;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.util.TypedValue;
import android.view.ActionMode;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View;
@ -33,6 +34,7 @@ import org.telegram.ui.ActionBar.SimpleTextView;
import org.telegram.ui.ActionBar.Theme;
import org.telegram.ui.Components.CheckBox2;
import org.telegram.ui.Components.EditTextBoldCursor;
import org.telegram.ui.Components.EditTextCaption;
import org.telegram.ui.Components.LayoutHelper;
import java.util.ArrayList;
@ -50,36 +52,84 @@ public class PollEditTextCell extends FrameLayout {
private boolean alwaysShowText2;
public PollEditTextCell(Context context, OnClickListener onDelete) {
this(context, false, onDelete);
}
public PollEditTextCell(Context context, boolean caption, OnClickListener onDelete) {
super(context);
textView = new EditTextBoldCursor(context) {
@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
InputConnection conn = super.onCreateInputConnection(outAttrs);
if (showNextButton) {
outAttrs.imeOptions &= ~EditorInfo.IME_FLAG_NO_ENTER_ACTION;
if (caption) {
textView = new EditTextCaption(context) {
@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
InputConnection conn = super.onCreateInputConnection(outAttrs);
if (showNextButton) {
outAttrs.imeOptions &= ~EditorInfo.IME_FLAG_NO_ENTER_ACTION;
}
return conn;
}
return conn;
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
onEditTextDraw(this, canvas);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
onEditTextDraw(this, canvas);
}
@Override
public boolean onTouchEvent(MotionEvent event) {
if (!isEnabled()) {
return false;
@Override
public boolean onTouchEvent(MotionEvent event) {
if (!isEnabled()) {
return false;
}
if (event.getAction() == MotionEvent.ACTION_UP) {
onFieldTouchUp(this);
}
return super.onTouchEvent(event);
}
if (event.getAction() == MotionEvent.ACTION_UP) {
onFieldTouchUp(this);
@Override
public ActionMode startActionMode(ActionMode.Callback callback, int type) {
ActionMode actionMode = super.startActionMode(callback, type);
onActionModeStart(this, actionMode);
return actionMode;
}
return super.onTouchEvent(event);
}
};
@Override
public ActionMode startActionMode(ActionMode.Callback callback) {
ActionMode actionMode = super.startActionMode(callback);
onActionModeStart(this, actionMode);
return actionMode;
}
};
((EditTextCaption) textView).setAllowTextEntitiesIntersection(true);
} else {
textView = new EditTextBoldCursor(context) {
@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
InputConnection conn = super.onCreateInputConnection(outAttrs);
if (showNextButton) {
outAttrs.imeOptions &= ~EditorInfo.IME_FLAG_NO_ENTER_ACTION;
}
return conn;
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
onEditTextDraw(this, canvas);
}
@Override
public boolean onTouchEvent(MotionEvent event) {
if (!isEnabled()) {
return false;
}
if (event.getAction() == MotionEvent.ACTION_UP) {
onFieldTouchUp(this);
}
return super.onTouchEvent(event);
}
};
}
textView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
textView.setHintTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteHintText));
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
@ -188,6 +238,10 @@ public class PollEditTextCell extends FrameLayout {
return false;
}
protected void onActionModeStart(EditTextBoldCursor editText, ActionMode actionMode) {
}
public void callOnDelete() {
if (deleteImageView == null) {
return;

View File

@ -12562,6 +12562,14 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
return true;
}
}
fillActionModeMenu(menu);
return true;
}
public void fillActionModeMenu(Menu menu) {
if (menu.findItem(R.id.menu_bold) != null) {
return;
}
if (Build.VERSION.SDK_INT >= 23) {
menu.removeItem(android.R.id.shareText);
}
@ -16608,6 +16616,30 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
SpannableStringBuilder stringBuilder = new SpannableStringBuilder(text);
MessageObject.addLinks(false, stringBuilder);
MessageObject.GroupedMessages group = cell.getCurrentMessagesGroup();
if (group != null) {
for (int a = 0, N = group.posArray.size(); a < N; a++) {
MessageObject.GroupedMessagePosition pos = group.posArray.get(a);
if ((pos.flags & MessageObject.POSITION_FLAG_LEFT) != 0) {
MessageObject m = group.messages.get(a);
if (m != messageObject) {
messageObject = m;
int count = chatListView.getChildCount();
for (int b = 0; b < count; b++) {
View view = chatListView.getChildAt(b);
if (!(view instanceof ChatMessageCell)) {
continue;
}
ChatMessageCell c = (ChatMessageCell) view;
if (messageObject.equals(c.getMessageObject())) {
cell = c;
}
}
}
break;
}
}
}
showInfoHint(messageObject, stringBuilder, 1);
}
cell.showHintButton(false, true, type);

View File

@ -409,6 +409,7 @@ public class ChatAttachAlertDocumentLayout extends ChatAttachAlert.AttachAlertLa
} catch (Exception e) {
FileLog.e(e);
}
parentAlert.actionBar.closeSearchField();
ActionBarMenu menu = parentAlert.actionBar.createMenu();
menu.removeView(sortItem);
menu.removeView(searchItem);

View File

@ -986,6 +986,7 @@ public class ChatAttachAlertLocationLayout extends ChatAttachAlert.AttachAlertLa
if (searchAdapter != null) {
searchAdapter.destroy();
}
parentAlert.actionBar.closeSearchField();
ActionBarMenu menu = parentAlert.actionBar.createMenu();
menu.removeView(searchItem);
}

View File

@ -10,8 +10,10 @@ import android.graphics.drawable.Drawable;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.ActionMode;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
@ -19,6 +21,7 @@ import android.view.inputmethod.EditorInfo;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.ChatObject;
import org.telegram.messenger.LocaleController;
import org.telegram.messenger.MediaDataController;
import org.telegram.messenger.R;
import org.telegram.messenger.Utilities;
import org.telegram.tgnet.SerializedData;
@ -59,7 +62,7 @@ public class ChatAttachAlertPollLayout extends ChatAttachAlert.AttachAlertLayout
private boolean[] answersChecks = new boolean[10];
private int answersCount = 1;
private String questionString;
private String solutionString;
private CharSequence solutionString;
private boolean anonymousPoll = true;
private boolean multipleChoise;
private boolean quizPoll;
@ -329,6 +332,9 @@ public class ChatAttachAlertPollLayout extends ChatAttachAlert.AttachAlertLayout
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
parentAlert.updateLayout(ChatAttachAlertPollLayout.this, true);
if (dy != 0 && hintView != null) {
hintView.hide();
}
}
@Override
@ -393,14 +399,14 @@ public class ChatAttachAlertPollLayout extends ChatAttachAlert.AttachAlertLayout
poll.poll.multiple_choice = multipleChoise;
poll.poll.quiz = quizPoll;
poll.poll.public_voters = !anonymousPoll;
poll.poll.question = getFixedString(questionString);
poll.poll.question = getFixedString(questionString).toString();
SerializedData serializedData = new SerializedData(10);
for (int a = 0; a < answers.length; a++) {
if (TextUtils.isEmpty(getFixedString(answers[a]))) {
continue;
}
TLRPC.TL_pollAnswer answer = new TLRPC.TL_pollAnswer();
answer.text = getFixedString(answers[a]);
answer.text = getFixedString(answers[a]).toString();
answer.option = new byte[1];
answer.option[0] = (byte) (48 + poll.poll.answers.size());
poll.poll.answers.add(answer);
@ -411,7 +417,13 @@ public class ChatAttachAlertPollLayout extends ChatAttachAlert.AttachAlertLayout
HashMap<String, String> params = new HashMap<>();
params.put("answers", Utilities.bytesToHex(serializedData.toByteArray()));
poll.results = new TLRPC.TL_pollResults();
poll.results.solution = getFixedString(solutionString);
CharSequence solution = getFixedString(solutionString);
poll.results.solution = solution.toString();
CharSequence[] message = new CharSequence[]{solution};
ArrayList<TLRPC.MessageEntity> entities = MediaDataController.getInstance(parentAlert.currentAccount).getEntities(message, true);
if (entities != null && !entities.isEmpty()) {
poll.results.solution_entities = entities;
}
if (!TextUtils.isEmpty(poll.results.solution)) {
poll.results.flags |= 16;
}
@ -507,16 +519,16 @@ public class ChatAttachAlertPollLayout extends ChatAttachAlert.AttachAlertLayout
listView.smoothScrollToPosition(1);
}
private String getFixedString(String text) {
public static CharSequence getFixedString(CharSequence text) {
if (TextUtils.isEmpty(text)) {
return text;
}
text = AndroidUtilities.getTrimmedString(text).toString();
while (text.contains("\n\n\n")) {
text = text.replace("\n\n\n", "\n\n");
text = AndroidUtilities.getTrimmedString(text);
while (TextUtils.indexOf(text, "\n\n\n") >= 0) {
text = TextUtils.replace(text, new String[]{"\n\n\n"}, new CharSequence[]{"\n\n"});
}
while (text.startsWith("\n\n\n")) {
text = text.replace("\n\n\n", "\n\n");
while (TextUtils.indexOf(text, "\n\n\n") == 0) {
text = TextUtils.replace(text, new String[]{"\n\n\n"}, new CharSequence[]{"\n\n"});
}
return text;
}
@ -909,11 +921,22 @@ public class ChatAttachAlertPollLayout extends ChatAttachAlert.AttachAlertLayout
view = new TextCheckCell(mContext);
break;
case 7: {
PollEditTextCell cell = new PollEditTextCell(mContext, null) {
PollEditTextCell cell = new PollEditTextCell(mContext, true, null) {
@Override
protected void onFieldTouchUp(EditTextBoldCursor editText) {
parentAlert.makeFocusable(editText);
}
@Override
protected void onActionModeStart(EditTextBoldCursor editText, ActionMode actionMode) {
if (editText.isFocused() && editText.hasSelection()) {
Menu menu = actionMode.getMenu();
if (menu.findItem(android.R.id.copy) == null) {
return;
}
((ChatActivity) parentAlert.baseFragment).fillActionModeMenu(menu);
}
}
};
cell.createErrorTextView();
cell.addTextWatcher(new TextWatcher() {
@ -932,7 +955,7 @@ public class ChatAttachAlertPollLayout extends ChatAttachAlert.AttachAlertLayout
if (cell.getTag() != null) {
return;
}
solutionString = s.toString();
solutionString = s;
RecyclerView.ViewHolder holder = listView.findViewHolderForAdapterPosition(solutionRow);
if (holder != null) {
setTextLeft(holder.itemView, solutionRow);

View File

@ -928,7 +928,7 @@ public class SharedMediaLayout extends FrameLayout implements NotificationCenter
commonGroupsAdapter = new CommonGroupsAdapter(context);
chatUsersAdapter = new ChatUsersAdapter(context);
chatUsersAdapter.sortedUsers = sortedUsers;
chatUsersAdapter.chatInfo = chatInfo;
chatUsersAdapter.chatInfo = membersFirst ? chatInfo : null;
linksAdapter = new SharedLinksAdapter(context);
setWillNotDraw(false);

View File

@ -4138,7 +4138,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
}
} else if (action == delete || action == clear) {
if (count == 1) {
if (canDeletePsaSelected) {
if (action == delete && canDeletePsaSelected) {
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setTitle(LocaleController.getString("PsaHideChatAlertTitle", R.string.PsaHideChatAlertTitle));
builder.setMessage(LocaleController.getString("PsaHideChatAlertText", R.string.PsaHideChatAlertText));

View File

@ -9,8 +9,10 @@ import android.graphics.drawable.Drawable;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.ActionMode;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
@ -50,7 +52,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.DefaultItemAnimator;
import androidx.recyclerview.widget.ItemTouchHelper;
import androidx.recyclerview.widget.LinearLayoutManager;
@ -68,7 +69,7 @@ public class PollCreateActivity extends BaseFragment {
private boolean[] answersChecks = new boolean[10];
private int answersCount = 1;
private String questionString;
private String solutionString;
private CharSequence solutionString;
private boolean anonymousPoll = true;
private boolean multipleChoise;
private boolean quizPoll;
@ -196,7 +197,7 @@ public class PollCreateActivity extends BaseFragment {
if (quizPoll && doneItem.getAlpha() != 1.0f) {
int checksCount = 0;
for (int a = 0; a < answersChecks.length; a++) {
if (!TextUtils.isEmpty(getFixedString(answers[a])) && answersChecks[a]) {
if (!TextUtils.isEmpty(ChatAttachAlertPollLayout.getFixedString(answers[a])) && answersChecks[a]) {
checksCount++;
}
}
@ -210,18 +211,14 @@ public class PollCreateActivity extends BaseFragment {
poll.poll.multiple_choice = multipleChoise;
poll.poll.quiz = quizPoll;
poll.poll.public_voters = !anonymousPoll;
poll.poll.question = getFixedString(questionString);
/*poll.poll.close_period = 20;
poll.poll.close_date = getConnectionsManager().getCurrentTime() + 20;
poll.poll.flags |= 16;
poll.poll.flags |= 32;*/
poll.poll.question = ChatAttachAlertPollLayout.getFixedString(questionString).toString();
SerializedData serializedData = new SerializedData(10);
for (int a = 0; a < answers.length; a++) {
if (TextUtils.isEmpty(getFixedString(answers[a]))) {
if (TextUtils.isEmpty(ChatAttachAlertPollLayout.getFixedString(answers[a]))) {
continue;
}
TLRPC.TL_pollAnswer answer = new TLRPC.TL_pollAnswer();
answer.text = getFixedString(answers[a]);
answer.text = ChatAttachAlertPollLayout.getFixedString(answers[a]).toString();
answer.option = new byte[1];
answer.option[0] = (byte) (48 + poll.poll.answers.size());
poll.poll.answers.add(answer);
@ -232,7 +229,13 @@ public class PollCreateActivity extends BaseFragment {
HashMap<String, String> params = new HashMap<>();
params.put("answers", Utilities.bytesToHex(serializedData.toByteArray()));
poll.results = new TLRPC.TL_pollResults();
poll.results.solution = getFixedString(solutionString);
CharSequence solution = ChatAttachAlertPollLayout.getFixedString(solutionString);
poll.results.solution = solution.toString();
CharSequence[] message = new CharSequence[]{solution};
ArrayList<TLRPC.MessageEntity> entities = getMediaDataController().getEntities(message, true);
if (entities != null && !entities.isEmpty()) {
poll.results.solution_entities = entities;
}
if (!TextUtils.isEmpty(poll.results.solution)) {
poll.results.flags |= 16;
}
@ -358,13 +361,15 @@ public class PollCreateActivity extends BaseFragment {
});
listView.setOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
}
@Override
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
if (dy != 0 && hintView != null) {
hintView.hide();
}
}
});
@ -388,20 +393,6 @@ public class PollCreateActivity extends BaseFragment {
AndroidUtilities.requestAdjustResize(getParentActivity(), classGuid, true);
}
private String getFixedString(String text) {
if (TextUtils.isEmpty(text)) {
return text;
}
text = AndroidUtilities.getTrimmedString(text).toString();
while (text.contains("\n\n\n")) {
text = text.replace("\n\n\n", "\n\n");
}
while (text.startsWith("\n\n\n")) {
text = text.replace("\n\n\n", "\n\n");
}
return text;
}
private void showQuizHint() {
int count = listView.getChildCount();
for (int a = answerStartRow; a < answerStartRow + answersCount; a++) {
@ -421,19 +412,19 @@ public class PollCreateActivity extends BaseFragment {
int checksCount = 0;
if (quizPoll) {
for (int a = 0; a < answersChecks.length; a++) {
if (!TextUtils.isEmpty(getFixedString(answers[a])) && answersChecks[a]) {
if (!TextUtils.isEmpty(ChatAttachAlertPollLayout.getFixedString(answers[a])) && answersChecks[a]) {
checksCount++;
}
}
}
if (!TextUtils.isEmpty(getFixedString(solutionString)) && solutionString.length() > ChatAttachAlertPollLayout.MAX_SOLUTION_LENGTH) {
if (!TextUtils.isEmpty(ChatAttachAlertPollLayout.getFixedString(solutionString)) && solutionString.length() > ChatAttachAlertPollLayout.MAX_SOLUTION_LENGTH) {
enabled = false;
} else if (TextUtils.isEmpty(getFixedString(questionString)) || questionString.length() > ChatAttachAlertPollLayout.MAX_QUESTION_LENGTH) {
} else if (TextUtils.isEmpty(ChatAttachAlertPollLayout.getFixedString(questionString)) || questionString.length() > ChatAttachAlertPollLayout.MAX_QUESTION_LENGTH) {
enabled = false;
} else {
int count = 0;
for (int a = 0; a < answers.length; a++) {
if (!TextUtils.isEmpty(getFixedString(answers[a]))) {
if (!TextUtils.isEmpty(ChatAttachAlertPollLayout.getFixedString(answers[a]))) {
if (answers[a].length() > ChatAttachAlertPollLayout.MAX_ANSWER_LENGTH) {
count = 0;
break;
@ -500,10 +491,10 @@ public class PollCreateActivity extends BaseFragment {
}
private boolean checkDiscard() {
boolean allowDiscard = TextUtils.isEmpty(getFixedString(questionString));
boolean allowDiscard = TextUtils.isEmpty(ChatAttachAlertPollLayout.getFixedString(questionString));
if (allowDiscard) {
for (int a = 0; a < answersCount; a++) {
allowDiscard = TextUtils.isEmpty(getFixedString(answers[a]));
allowDiscard = TextUtils.isEmpty(ChatAttachAlertPollLayout.getFixedString(answers[a]));
if (!allowDiscard) {
break;
}
@ -749,7 +740,18 @@ public class PollCreateActivity extends BaseFragment {
view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
break;
case 7: {
PollEditTextCell cell = new PollEditTextCell(mContext, null);
PollEditTextCell cell = new PollEditTextCell(mContext, true, null) {
@Override
protected void onActionModeStart(EditTextBoldCursor editText, ActionMode actionMode) {
if (editText.isFocused() && editText.hasSelection()) {
Menu menu = actionMode.getMenu();
if (menu.findItem(android.R.id.copy) == null) {
return;
}
parentFragment.fillActionModeMenu(menu);
}
}
};
cell.createErrorTextView();
cell.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
cell.addTextWatcher(new TextWatcher() {
@ -768,7 +770,7 @@ public class PollCreateActivity extends BaseFragment {
if (cell.getTag() != null) {
return;
}
solutionString = s.toString();
solutionString = s;
RecyclerView.ViewHolder holder = listView.findViewHolderForAdapterPosition(solutionRow);
if (holder != null) {
setTextLeft(holder.itemView, solutionRow);