mirror of
https://github.com/DrKLO/Telegram.git
synced 2024-12-22 06:25:14 +01:00
Update to 6.1.1 (1946)
This commit is contained in:
parent
dbf81a34af
commit
5a2a813dc0
16 changed files with 254 additions and 98 deletions
|
@ -286,7 +286,7 @@ android {
|
|||
}
|
||||
}
|
||||
|
||||
defaultConfig.versionCode = 1945
|
||||
defaultConfig.versionCode = 1946
|
||||
|
||||
def tgVoipDexFileName = "libtgvoip.dex"
|
||||
def tgVoipDexClasses = ["AudioRecordJNI", "AudioTrackJNI", "NativeTgVoipDelegate", "NativeTgVoipInstance", "TgVoipNativeLoader", "Resampler", "VLog"]
|
||||
|
|
|
@ -308,7 +308,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;
|
||||
|
@ -3307,7 +3314,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;
|
||||
|
|
|
@ -19,7 +19,7 @@ public class BuildVars {
|
|||
public static boolean USE_CLOUD_STRINGS = true;
|
||||
public static boolean CHECK_UPDATES = true;
|
||||
public static boolean TON_WALLET_STANDALONE = false;
|
||||
public static int BUILD_VERSION = 1945;
|
||||
public static int BUILD_VERSION = 1946;
|
||||
public static String BUILD_VERSION_STRING = "6.1.0";
|
||||
public static int APP_ID = 4;
|
||||
public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103";
|
||||
|
|
|
@ -3923,14 +3923,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;
|
||||
}
|
||||
}
|
||||
|
@ -4258,7 +4258,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) {
|
||||
|
@ -4362,7 +4362,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;
|
||||
|
@ -4375,7 +4375,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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -9675,18 +9675,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();
|
||||
}
|
||||
|
@ -9745,7 +9749,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;
|
||||
|
|
|
@ -3110,6 +3110,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;
|
||||
|
|
|
@ -5281,6 +5281,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
if (!animated) {
|
||||
psaButtonProgress = show ? 1.0f : 0.0f;
|
||||
} else {
|
||||
setInvalidatesParent(true);
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
|
@ -5308,6 +5309,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();
|
||||
}
|
||||
|
@ -8779,6 +8781,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;
|
||||
|
@ -9093,13 +9124,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;
|
||||
|
@ -9117,16 +9141,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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -12408,6 +12408,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);
|
||||
}
|
||||
|
@ -12434,7 +12442,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
}
|
||||
menu.add(R.id.menu_groupbolditalic, R.id.menu_link, 11, LocaleController.getString("CreateLink", R.string.CreateLink));
|
||||
menu.add(R.id.menu_groupbolditalic, R.id.menu_regular, 12, LocaleController.getString("Regular", R.string.Regular));
|
||||
return true;
|
||||
}
|
||||
|
||||
private void updateScheduledInterface(boolean animated) {
|
||||
|
@ -16015,6 +16022,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);
|
||||
|
|
|
@ -403,6 +403,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);
|
||||
|
|
|
@ -968,6 +968,7 @@ public class ChatAttachAlertLocationLayout extends ChatAttachAlert.AttachAlertLa
|
|||
if (searchAdapter != null) {
|
||||
searchAdapter.destroy();
|
||||
}
|
||||
parentAlert.actionBar.closeSearchField();
|
||||
ActionBarMenu menu = parentAlert.actionBar.createMenu();
|
||||
menu.removeView(searchItem);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -4090,7 +4090,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));
|
||||
|
|
|
@ -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;
|
||||
|
@ -49,7 +51,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;
|
||||
|
@ -67,7 +68,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;
|
||||
|
@ -195,7 +196,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++;
|
||||
}
|
||||
}
|
||||
|
@ -209,18 +210,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);
|
||||
|
@ -231,7 +228,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;
|
||||
}
|
||||
|
@ -357,13 +360,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();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -387,20 +392,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++) {
|
||||
|
@ -420,19 +411,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;
|
||||
|
@ -499,10 +490,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;
|
||||
}
|
||||
|
@ -748,7 +739,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() {
|
||||
|
@ -767,7 +769,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);
|
||||
|
|
Loading…
Reference in a new issue