1
0
mirror of https://github.com/MGislv/NekoX.git synced 2024-07-02 10:33:36 +00:00

Update to 8.5.3

This commit is contained in:
xaxtix 2022-02-15 23:18:49 +03:00
parent 3b4919a542
commit b5694a1ca6
14 changed files with 587 additions and 239 deletions

View File

@ -300,7 +300,7 @@ android {
} }
} }
defaultConfig.versionCode = 2563 defaultConfig.versionCode = 2565
applicationVariants.all { variant -> applicationVariants.all { variant ->
variant.outputs.all { output -> variant.outputs.all { output ->
@ -319,7 +319,7 @@ android {
defaultConfig { defaultConfig {
minSdkVersion 16 minSdkVersion 16
targetSdkVersion 30 targetSdkVersion 30
versionName "8.5.2" versionName "8.5.3"
vectorDrawables.generatedDensities = ['mdpi', 'hdpi', 'xhdpi', 'xxhdpi'] vectorDrawables.generatedDensities = ['mdpi', 'hdpi', 'xhdpi', 'xxhdpi']

View File

@ -31,6 +31,7 @@ import android.database.Cursor;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.BitmapFactory; import android.graphics.BitmapFactory;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.ColorMatrix;
import android.graphics.Matrix; import android.graphics.Matrix;
import android.graphics.Paint; import android.graphics.Paint;
import android.graphics.Point; import android.graphics.Point;
@ -697,6 +698,17 @@ public class AndroidUtilities {
return new int[]{(int) (r * 255), (int) (g * 255), (int) (b * 255)}; return new int[]{(int) (r * 255), (int) (g * 255), (int) (b * 255)};
} }
public static void lightColorMatrix(ColorMatrix colorMatrix, float addLightness) {
if (colorMatrix == null) {
return;
}
float[] matrix = colorMatrix.getArray();
matrix[4] += addLightness;
matrix[9] += addLightness;
matrix[14] += addLightness;
colorMatrix.set(matrix);
}
public static void requestAdjustResize(Activity activity, int classGuid) { public static void requestAdjustResize(Activity activity, int classGuid) {
if (activity == null || isTablet()) { if (activity == null || isTablet()) {
return; return;
@ -2278,7 +2290,7 @@ public class AndroidUtilities {
} }
public static void appCenterLog(Throwable e) { public static void appCenterLog(Throwable e) {
} }
public static void addToClipboard(CharSequence str) { public static void addToClipboard(CharSequence str) {

View File

@ -20,8 +20,8 @@ public class BuildVars {
public static boolean USE_CLOUD_STRINGS = true; public static boolean USE_CLOUD_STRINGS = true;
public static boolean CHECK_UPDATES = true; public static boolean CHECK_UPDATES = true;
public static boolean NO_SCOPED_STORAGE = Build.VERSION.SDK_INT <= 29; public static boolean NO_SCOPED_STORAGE = Build.VERSION.SDK_INT <= 29;
public static int BUILD_VERSION = 2563; public static int BUILD_VERSION = 2565;
public static String BUILD_VERSION_STRING = "8.5.2"; public static String BUILD_VERSION_STRING = "8.5.3";
public static int APP_ID = 4; public static int APP_ID = 4;
public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103"; public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103";

View File

@ -388,6 +388,7 @@ public class MediaDataController extends BaseController {
getMessagesStorage().getStorageQueue().postRunnable(() -> { getMessagesStorage().getStorageQueue().postRunnable(() -> {
try { try {
if (reactionsFinal != null) { if (reactionsFinal != null) {
getMessagesStorage().getDatabase().executeFast("DELETE FROM reactions").stepThis().dispose();
SQLitePreparedStatement state = getMessagesStorage().getDatabase().executeFast("REPLACE INTO reactions VALUES(?, ?, ?)"); SQLitePreparedStatement state = getMessagesStorage().getDatabase().executeFast("REPLACE INTO reactions VALUES(?, ?, ?)");
state.requery(); state.requery();
int size = 4; // Integer.BYTES int size = 4; // Integer.BYTES

View File

@ -46,6 +46,7 @@ import org.telegram.messenger.FileLog;
import org.telegram.messenger.MessagesController; import org.telegram.messenger.MessagesController;
import org.telegram.messenger.R; import org.telegram.messenger.R;
import org.telegram.messenger.SharedConfig; import org.telegram.messenger.SharedConfig;
import org.telegram.ui.Components.BackButtonMenu;
import org.telegram.ui.Components.Bulletin; import org.telegram.ui.Components.Bulletin;
import org.telegram.ui.Components.CubicBezierInterpolator; import org.telegram.ui.Components.CubicBezierInterpolator;
import org.telegram.ui.Components.GroupCallPip; import org.telegram.ui.Components.GroupCallPip;
@ -323,6 +324,7 @@ public class ActionBarLayout extends FrameLayout {
protected Activity parentActivity; protected Activity parentActivity;
public ArrayList<BaseFragment> fragmentsStack; public ArrayList<BaseFragment> fragmentsStack;
public ArrayList<BackButtonMenu.PulledDialog> pulledDialogs;
private Rect rect = new Rect(); private Rect rect = new Rect();
private boolean delayedAnimationResumed; private boolean delayedAnimationResumed;

View File

@ -55,6 +55,7 @@ import android.os.SystemClock;
import android.text.TextPaint; import android.text.TextPaint;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Base64; import android.util.Base64;
import android.util.Log;
import android.util.LongSparseArray; import android.util.LongSparseArray;
import android.util.SparseArray; import android.util.SparseArray;
import android.util.StateSet; import android.util.StateSet;
@ -1520,56 +1521,57 @@ public class Theme {
} }
if (!isDarkTheme) { if (!isDarkTheme) {
int outBubble; currentColors.remove(key_chat_selectedBackground);
if (isDarkTheme) { // int outBubble;
outBubble = averageColor(currentColors, key_chat_outBubbleGradient1, key_chat_outBubbleGradient2, key_chat_outBubbleGradient3); // if (isDarkTheme) {
} else if (currentColors.containsKey(key_chat_outBubble)) { // outBubble = averageColor(currentColors, key_chat_outBubbleGradient1, key_chat_outBubbleGradient2, key_chat_outBubbleGradient3);
outBubble = currentColors.get(key_chat_outBubble); // } else if (currentColors.containsKey(key_chat_outBubble)) {
} else { // outBubble = currentColors.get(key_chat_outBubble);
outBubble = getColor(key_chat_outBubble); // } else {
} // outBubble = getColor(key_chat_outBubble);
int inBubbleSelected; // }
if (currentColors.containsKey(key_chat_inBubbleSelected)) { // int inBubbleSelected;
inBubbleSelected = currentColors.get(key_chat_inBubbleSelected); // if (currentColors.containsKey(key_chat_inBubbleSelected)) {
} else { // inBubbleSelected = currentColors.get(key_chat_inBubbleSelected);
inBubbleSelected = getColor(key_chat_inBubbleSelected); // } else {
} // inBubbleSelected = getColor(key_chat_inBubbleSelected);
int gradientAverageColor = 0; // }
if (isDarkTheme) { // int gradientAverageColor = 0;
gradientAverageColor = outBubble; // if (isDarkTheme) {
} // gradientAverageColor = outBubble;
if (gradientAverageColor == 0) { // }
gradientAverageColor = averageColor(currentColors, key_chat_wallpaper_gradient_to1, key_chat_wallpaper_gradient_to2, key_chat_wallpaper_gradient_to3); // if (gradientAverageColor == 0) {
} // gradientAverageColor = averageColor(currentColors, key_chat_wallpaper_gradient_to1, key_chat_wallpaper_gradient_to2, key_chat_wallpaper_gradient_to3);
if (gradientAverageColor == 0) { // }
gradientAverageColor = averageColor(currentColors, key_chat_wallpaper); // if (gradientAverageColor == 0) {
} // gradientAverageColor = averageColor(currentColors, key_chat_wallpaper);
int selectedBackground = currentColors.containsKey(key_chat_selectedBackground) ? currentColors.get(key_chat_selectedBackground) : getColor(key_chat_selectedBackground); // }
selectedBackground = applyHue(selectedBackground, gradientAverageColor); // int selectedBackground = currentColors.containsKey(key_chat_selectedBackground) ? currentColors.get(key_chat_selectedBackground) : getColor(key_chat_selectedBackground);
selectedBackground = darkenColor(selectedBackground, .1f); // selectedBackground = applyHue(selectedBackground, gradientAverageColor);
selectedBackground = Color.argb((int) (Color.alpha(selectedBackground) * 0.8f), Color.red(selectedBackground), Color.green(selectedBackground), Color.blue(selectedBackground)); // selectedBackground = darkenColor(selectedBackground, .1f);
currentColors.put(key_chat_selectedBackground, selectedBackground); // selectedBackground = Color.argb((int) (Color.alpha(selectedBackground) * 0.8f), Color.red(selectedBackground), Color.green(selectedBackground), Color.blue(selectedBackground));
int outBubbleOverlay = bubbleSelectedOverlay(outBubble); // currentColors.put(key_chat_selectedBackground, selectedBackground);
currentColors.put(key_chat_outBubbleGradientSelectedOverlay, outBubbleOverlay); // int outBubbleOverlay = bubbleSelectedOverlay(outBubble);
// currentColors.put(key_chat_outBubbleGradientSelectedOverlay, outBubbleOverlay);
inBubbleSelected = applyHue(inBubbleSelected, gradientAverageColor); //
inBubbleSelected = shiftHSV(inBubbleSelected, 0, .04f, 0); // inBubbleSelected = applyHue(inBubbleSelected, gradientAverageColor);
currentColors.put(key_chat_inBubbleSelected, inBubbleSelected); // inBubbleSelected = shiftHSV(inBubbleSelected, 0, .04f, 0);
// currentColors.put(key_chat_inBubbleSelected, inBubbleSelected);
final String[] inTextSelectedKeys = new String[] { //
key_chat_inTimeSelectedText, key_chat_inAdminSelectedText, key_chat_inAudioDurationSelectedText, // final String[] inTextSelectedKeys = new String[] {
key_chat_inAudioPerformerSelectedText, key_chat_inFileInfoSelectedText, key_chat_inContactPhoneSelectedText, // key_chat_inTimeSelectedText, key_chat_inAdminSelectedText, key_chat_inAudioDurationSelectedText,
key_chat_inPreviewInstantSelectedText, key_chat_inVenueInfoSelectedText, key_chat_inReplyMediaMessageSelectedText // key_chat_inAudioPerformerSelectedText, key_chat_inFileInfoSelectedText, key_chat_inContactPhoneSelectedText,
}; // key_chat_inPreviewInstantSelectedText, key_chat_inVenueInfoSelectedText, key_chat_inReplyMediaMessageSelectedText
for (String inTextSelectedKey : inTextSelectedKeys) { // };
int color = currentColors.containsKey(inTextSelectedKey) ? currentColors.get(inTextSelectedKey) : getColor(inTextSelectedKey); // for (String inTextSelectedKey : inTextSelectedKeys) {
currentColors.put(inTextSelectedKey, applyHue(color, gradientAverageColor)); // int color = currentColors.containsKey(inTextSelectedKey) ? currentColors.get(inTextSelectedKey) : getColor(inTextSelectedKey);
} // currentColors.put(inTextSelectedKey, applyHue(color, gradientAverageColor));
// }
int outTimeSelected = currentColors.containsKey(key_chat_outTimeSelectedText) ? currentColors.get(key_chat_outTimeSelectedText) : getColor(key_chat_outTimeSelectedText); //
double contrast = ColorUtils.calculateContrast(outTimeSelected, mix(outBubble, outBubbleOverlay)); // int outTimeSelected = currentColors.containsKey(key_chat_outTimeSelectedText) ? currentColors.get(key_chat_outTimeSelectedText) : getColor(key_chat_outTimeSelectedText);
currentColors.put(key_chat_outTimeSelectedText, shiftHSV(outTimeSelected, .02f, .01f, contrast < 1.9d ? -.1f : 0f)); // double contrast = ColorUtils.calculateContrast(outTimeSelected, mix(outBubble, outBubbleOverlay));
// currentColors.put(key_chat_outTimeSelectedText, applyHue(outTimeSelected, gradientAverageColor)); // currentColors.put(key_chat_outTimeSelectedText, shiftHSV(outTimeSelected, .02f, .01f, contrast < 1.9d ? -.1f : 0f));
//// currentColors.put(key_chat_outTimeSelectedText, applyHue(outTimeSelected, gradientAverageColor));
} }
return !isMyMessagesGradientColorsNear; return !isMyMessagesGradientColorsNear;
@ -3864,6 +3866,7 @@ public class Theme {
public static final String key_paint_chatActionBackground = "paintChatActionBackground"; public static final String key_paint_chatActionBackground = "paintChatActionBackground";
public static final String key_paint_chatActionBackgroundSelected = "paintChatActionBackgroundSelected"; public static final String key_paint_chatActionBackgroundSelected = "paintChatActionBackgroundSelected";
public static final String key_paint_chatMessageBackgroundSelected = "paintChatMessageBackgroundSelected";
public static final String key_paint_chatActionText = "paintChatActionText"; public static final String key_paint_chatActionText = "paintChatActionText";
public static final String key_paint_chatBotButton = "paintChatBotButton"; public static final String key_paint_chatBotButton = "paintChatBotButton";
public static final String key_paint_chatComposeBackground = "paintChatComposeBackground"; public static final String key_paint_chatComposeBackground = "paintChatComposeBackground";
@ -9136,12 +9139,12 @@ public class Theme {
if (serviceBitmapShader != null && (currentColors.get(key_chat_serviceBackground) == null || drawable instanceof MotionBackgroundDrawable)) { if (serviceBitmapShader != null && (currentColors.get(key_chat_serviceBackground) == null || drawable instanceof MotionBackgroundDrawable)) {
chat_actionBackgroundPaint.setShader(serviceBitmapShader); chat_actionBackgroundPaint.setShader(serviceBitmapShader);
chat_actionBackgroundSelectedPaint.setShader(serviceBitmapShader);
ColorMatrix colorMatrix = new ColorMatrix(); ColorMatrix colorMatrix = new ColorMatrix();
colorMatrix.setSaturation(((MotionBackgroundDrawable) drawable).getIntensity() >= 0 ? 1.8f : 0.5f); colorMatrix.setSaturation(((MotionBackgroundDrawable) drawable).getIntensity() >= 0 ? 1.8f : 0.5f);
chat_actionBackgroundPaint.setColorFilter(new ColorMatrixColorFilter(colorMatrix)); chat_actionBackgroundPaint.setColorFilter(new ColorMatrixColorFilter(colorMatrix));
chat_actionBackgroundPaint.setAlpha(127); chat_actionBackgroundPaint.setAlpha(127);
chat_actionBackgroundSelectedPaint.setShader(serviceBitmapShader);
chat_actionBackgroundSelectedPaint.setColorFilter(new ColorMatrixColorFilter(colorMatrix)); chat_actionBackgroundSelectedPaint.setColorFilter(new ColorMatrixColorFilter(colorMatrix));
chat_actionBackgroundSelectedPaint.setAlpha(200); chat_actionBackgroundSelectedPaint.setAlpha(200);
} else { } else {

View File

@ -271,6 +271,7 @@ public class ThemeDescription {
Drawable background = viewToInvalidate.getBackground(); Drawable background = viewToInvalidate.getBackground();
if (background instanceof MessageBackgroundDrawable) { if (background instanceof MessageBackgroundDrawable) {
((MessageBackgroundDrawable) background).setColor(color); ((MessageBackgroundDrawable) background).setColor(color);
((MessageBackgroundDrawable) background).setCustomPaint(null);
} else { } else {
viewToInvalidate.setBackgroundColor(color); viewToInvalidate.setBackgroundColor(color);
} }
@ -589,6 +590,7 @@ public class ThemeDescription {
Drawable background = view.getBackground(); Drawable background = view.getBackground();
if (background instanceof MessageBackgroundDrawable) { if (background instanceof MessageBackgroundDrawable) {
((MessageBackgroundDrawable) background).setColor(color); ((MessageBackgroundDrawable) background).setColor(color);
((MessageBackgroundDrawable) background).setCustomPaint(null);
} else { } else {
view.setBackgroundColor(color); view.setBackgroundColor(color);
} }

View File

@ -557,6 +557,9 @@ public class CacheControlActivity extends BaseFragment {
SQLiteDatabase database = MessagesStorage.getInstance(currentAccount).getDatabase(); SQLiteDatabase database = MessagesStorage.getInstance(currentAccount).getDatabase();
ArrayList<Long> dialogsToCleanup = new ArrayList<>(); ArrayList<Long> dialogsToCleanup = new ArrayList<>();
database.executeFast("DELETE FROM reaction_mentions").stepThis().dispose();
database.executeFast("DELETE FROM reaction_mentions").stepThis().dispose();
SQLiteCursor cursor = database.queryFinalized("SELECT did FROM dialogs WHERE 1"); SQLiteCursor cursor = database.queryFinalized("SELECT did FROM dialogs WHERE 1");
StringBuilder ids = new StringBuilder(); StringBuilder ids = new StringBuilder();
while (cursor.next()) { while (cursor.next()) {

View File

@ -892,7 +892,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
private int lastRepliesCount; private int lastRepliesCount;
private float selectedBackgroundProgress; private float selectedBackgroundProgress;
private float viewTop; public float viewTop;
private int backgroundHeight; private int backgroundHeight;
private boolean scheduledInvalidate; private boolean scheduledInvalidate;

View File

@ -27,6 +27,7 @@ import android.content.SharedPreferences;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.BitmapShader; import android.graphics.BitmapShader;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Color; import android.graphics.Color;
@ -61,6 +62,7 @@ import android.text.TextUtils;
import android.text.style.CharacterStyle; import android.text.style.CharacterStyle;
import android.text.style.ForegroundColorSpan; import android.text.style.ForegroundColorSpan;
import android.text.style.URLSpan; import android.text.style.URLSpan;
import android.util.Log;
import android.util.Property; import android.util.Property;
import android.util.SparseArray; import android.util.SparseArray;
import android.util.SparseIntArray; import android.util.SparseIntArray;
@ -257,7 +259,9 @@ import org.telegram.ui.Delegates.ChatActivityMemberRequestsDelegate;
import java.io.BufferedWriter; import java.io.BufferedWriter;
import java.io.File; import java.io.File;
import java.io.FileOutputStream;
import java.io.FileWriter; import java.io.FileWriter;
import java.io.InputStream;
import java.net.URLDecoder; import java.net.URLDecoder;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -2070,8 +2074,10 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
pinchToZoomHelper.clear(); pinchToZoomHelper.clear();
} }
chatThemeBottomSheet = null; chatThemeBottomSheet = null;
ActionBarLayout parentLayout = getParentLayout();
if (parentLayout != null && parentLayout.fragmentsStack != null) { if (parentLayout != null && parentLayout.fragmentsStack != null) {
BackButtonMenu.clearPulledDialogs(currentAccount, parentLayout.fragmentsStack.indexOf(this) - (replacingChatActivity ? 0 : 1)); BackButtonMenu.clearPulledDialogs(this, parentLayout.fragmentsStack.indexOf(this) - (replacingChatActivity ? 0 : 1));
} }
replacingChatActivity = false; replacingChatActivity = false;
} }
@ -4504,76 +4510,94 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
} else if (child instanceof ChatMessageCell) { } else if (child instanceof ChatMessageCell) {
ChatMessageCell cell = (ChatMessageCell) child; ChatMessageCell cell = (ChatMessageCell) child;
MessageObject.GroupedMessages group = cell.getCurrentMessagesGroup(); MessageObject.GroupedMessages group = cell.getCurrentMessagesGroup();
if (group == null || group != lastDrawnGroup) {
lastDrawnGroup = group;
MessageObject.GroupedMessagePosition position = cell.getCurrentPosition();
MessageBackgroundDrawable backgroundDrawable = cell.getBackgroundDrawable();
if ((backgroundDrawable.isAnimationInProgress() || cell.isDrawingSelectionBackground()) && (position == null || (position.flags & MessageObject.POSITION_FLAG_RIGHT) != 0)) {
if (cell.isHighlighted() || cell.isHighlightedAnimated()) {
if (position == null) {
Paint backgroundPaint = getThemedPaint(Theme.key_paint_chatMessageBackgroundSelected);
if (themeDelegate.isDark || backgroundPaint == null) {
backgroundPaint = Theme.chat_replyLinePaint;
backgroundPaint.setColor(getThemedColor(Theme.key_chat_selectedBackground));
}
canvas.save();
canvas.translate(0, cell.getTranslationY());
int wasAlpha = backgroundPaint.getAlpha();
backgroundPaint.setAlpha((int) (wasAlpha * cell.getHightlightAlpha() * cell.getAlpha()));
if (themeDelegate != null) {
themeDelegate.applyServiceShaderMatrix(getMeasuredWidth(), cell.getHeight(), 0, cell.getTop());
} else {
Theme.applyServiceShaderMatrix(getMeasuredWidth(), cell.getHeight(), 0, cell.getTop());
}
canvas.drawRect(0, cell.getTop(), getMeasuredWidth(), cell.getBottom(), backgroundPaint);
backgroundPaint.setAlpha(wasAlpha);
canvas.restore();
}
} else {
int y = (int) cell.getY();
int height;
canvas.save();
if (position == null) {
height = cell.getMeasuredHeight();
} else {
height = y + cell.getMeasuredHeight();
long time = 0;
float touchX = 0;
float touchY = 0;
for (int i = 0; i < count; i++) {
View inner = getChildAt(i);
if (inner instanceof ChatMessageCell) {
ChatMessageCell innerCell = (ChatMessageCell) inner;
MessageObject.GroupedMessages innerGroup = innerCell.getCurrentMessagesGroup();
if (innerGroup == group) {
MessageBackgroundDrawable drawable = innerCell.getBackgroundDrawable();
y = Math.min(y, (int) innerCell.getY());
height = Math.max(height, (int) innerCell.getY() + innerCell.getMeasuredHeight());
long touchTime = drawable.getLastTouchTime();
if (touchTime > time) {
touchX = drawable.getTouchX() + innerCell.getX();
touchY = drawable.getTouchY() + innerCell.getY();
time = touchTime;
}
}
}
}
backgroundDrawable.setTouchCoordsOverride(touchX, touchY - y);
height -= y;
}
canvas.clipRect(0, y, getMeasuredWidth(), y + height);
Paint selectedBackgroundPaint = getThemedPaint(Theme.key_paint_chatMessageBackgroundSelected);
if (!themeDelegate.isDark && selectedBackgroundPaint != null) {
backgroundDrawable.setCustomPaint(selectedBackgroundPaint);
if (themeDelegate != null) {
themeDelegate.applyServiceShaderMatrix(getMeasuredWidth(), height, 0, 0);
} else {
Theme.applyServiceShaderMatrix(getMeasuredWidth(), height, 0, 0);
}
} else {
backgroundDrawable.setCustomPaint(null);
backgroundDrawable.setColor(getThemedColor(Theme.key_chat_selectedBackground));
}
backgroundDrawable.setBounds(0, y, getMeasuredWidth(), y + height);
backgroundDrawable.draw(canvas);
canvas.restore();
}
}
}
if (scrimView != cell && group == null && cell.drawBackgroundInParent()) { if (scrimView != cell && group == null && cell.drawBackgroundInParent()) {
canvas.save(); canvas.save();
canvas.translate(cell.getX(), cell.getY()); canvas.translate(cell.getX(), cell.getY());
if (cell.getScaleX() != 1f) { if (cell.getScaleX() != 1f) {
canvas.scale( canvas.scale(
cell.getScaleX(), cell.getScaleY(), cell.getScaleX(), cell.getScaleY(),
cell.getPivotX(), (cell.getHeight() >> 1) cell.getPivotX(), (cell.getHeight() >> 1)
); );
} }
cell.drawBackgroundInternal(canvas, true); cell.drawBackgroundInternal(canvas, true);
canvas.restore(); canvas.restore();
} }
if (group != null && group == lastDrawnGroup) {
continue;
}
lastDrawnGroup = group;
MessageObject.GroupedMessagePosition position = cell.getCurrentPosition();
MessageBackgroundDrawable backgroundDrawable = cell.getBackgroundDrawable();
if ((backgroundDrawable.isAnimationInProgress() || cell.isDrawingSelectionBackground()) && (position == null || (position.flags & MessageObject.POSITION_FLAG_RIGHT) != 0)) {
if (cell.isHighlighted() || cell.isHighlightedAnimated()) {
if (position == null) {
int color = getThemedColor(Theme.key_chat_selectedBackground);
int alpha = Color.alpha(color);
canvas.save();
canvas.translate(0, cell.getTranslationY());
Theme.chat_replyLinePaint.setColor(getThemedColor(Theme.key_chat_selectedBackground));
Theme.chat_replyLinePaint.setAlpha((int) (alpha * cell.getHightlightAlpha() * cell.getAlpha()));
canvas.drawRect(0, cell.getTop(), getMeasuredWidth(), cell.getBottom(), Theme.chat_replyLinePaint);
canvas.restore();
}
} else {
backgroundDrawable.setColor(getThemedColor(Theme.key_chat_selectedBackground));
int y = (int) cell.getY();
int height;
canvas.save();
if (position == null) {
height = cell.getMeasuredHeight();
} else {
height = y + cell.getMeasuredHeight();
long time = 0;
float touchX = 0;
float touchY = 0;
for (int i = 0; i < count; i++) {
View inner = getChildAt(i);
if (inner instanceof ChatMessageCell) {
ChatMessageCell innerCell = (ChatMessageCell) inner;
MessageObject.GroupedMessages innerGroup = innerCell.getCurrentMessagesGroup();
if (innerGroup == group) {
MessageBackgroundDrawable drawable = innerCell.getBackgroundDrawable();
y = Math.min(y, (int) innerCell.getY());
height = Math.max(height, (int) innerCell.getY() + innerCell.getMeasuredHeight());
long touchTime = drawable.getLastTouchTime();
if (touchTime > time) {
touchX = drawable.getTouchX() + innerCell.getX();
touchY = drawable.getTouchY() + innerCell.getY();
time = touchTime;
}
}
}
}
backgroundDrawable.setTouchCoordsOverride(touchX, touchY - y);
height -= y;
}
canvas.clipRect(0, y, getMeasuredWidth(), y + height);
canvas.translate(0, y);
backgroundDrawable.setBounds(0, 0, getMeasuredWidth(), height);
backgroundDrawable.draw(canvas);
canvas.restore();
}
}
} else if (child instanceof ChatActionCell) { } else if (child instanceof ChatActionCell) {
ChatActionCell cell = (ChatActionCell) child; ChatActionCell cell = (ChatActionCell) child;
if (cell.hasGradientService()) { if (cell.hasGradientService()) {
@ -8679,12 +8703,18 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
} }
private void addToPulledDialogsMyself() { private void addToPulledDialogsMyself() {
if (getParentLayout() == null) {
return;
}
int stackIndex = getParentLayout().fragmentsStack.indexOf(this); int stackIndex = getParentLayout().fragmentsStack.indexOf(this);
BackButtonMenu.addToPulledDialogs(currentAccount, stackIndex, currentChat, currentUser, dialog_id, dialogFilterId, dialogFolderId); BackButtonMenu.addToPulledDialogs(this, stackIndex, currentChat, currentUser, dialog_id, dialogFilterId, dialogFolderId);
} }
private void addToPulledDialogs(TLRPC.Chat chat, long dialogId, int folderId, int filterId) { private void addToPulledDialogs(TLRPC.Chat chat, long dialogId, int folderId, int filterId) {
if (getParentLayout() == null) {
return;
}
int stackIndex = getParentLayout().fragmentsStack.indexOf(this); int stackIndex = getParentLayout().fragmentsStack.indexOf(this);
BackButtonMenu.addToPulledDialogs(currentAccount, stackIndex, chat, null, dialogId, folderId, filterId); BackButtonMenu.addToPulledDialogs(this, stackIndex, chat, null, dialogId, folderId, filterId);
} }
private void setPullingDownTransition(boolean fromPullingDownTransition) { private void setPullingDownTransition(boolean fromPullingDownTransition) {
@ -13647,7 +13677,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
MediaController.PhotoEntry entry = new MediaController.PhotoEntry(0, 0, 0, videoPath, 0, true, 0, 0, 0); MediaController.PhotoEntry entry = new MediaController.PhotoEntry(0, 0, 0, videoPath, 0, true, 0, 0, 0);
entry.caption = caption; entry.caption = caption;
cameraPhoto.add(entry); cameraPhoto.add(entry);
PhotoViewer.getInstance().openPhotoForSelect(cameraPhoto, 0, 2, false, new PhotoViewer.EmptyPhotoViewerProvider() { PhotoViewer.getInstance().openPhotoForSelect(cameraPhoto, 0, 0, false, new PhotoViewer.EmptyPhotoViewerProvider() {
@Override @Override
public ImageReceiver.BitmapHolder getThumbForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation, int index) { public ImageReceiver.BitmapHolder getThumbForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation, int index) {
return new ImageReceiver.BitmapHolder(thumb, null, 0); return new ImageReceiver.BitmapHolder(thumb, null, 0);
@ -13679,6 +13709,23 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
path = photoInfo.path; path = photoInfo.path;
} else if (photoInfo.uri != null) { } else if (photoInfo.uri != null) {
path = AndroidUtilities.getPath(photoInfo.uri); path = AndroidUtilities.getPath(photoInfo.uri);
if (path == null) {
try {
BitmapFactory.Options bmOptions = new BitmapFactory.Options();
InputStream inputStream = ApplicationLoader.applicationContext.getContentResolver().openInputStream(photoInfo.uri);
Bitmap b = BitmapFactory.decodeStream(inputStream, null, bmOptions);
String fileName = Integer.MIN_VALUE + "_" + SharedConfig.getLastLocalId() + ".webp";
File fileDir = FileLoader.getDirectory(FileLoader.MEDIA_DIR_CACHE);
final File cacheFile = new File(fileDir, fileName);
FileOutputStream stream = new FileOutputStream(cacheFile);
b.compress(Bitmap.CompressFormat.WEBP, 100, stream);
SharedConfig.saveConfig();
path = cacheFile.getPath();
// path = Uri.fromFile(cacheFile);
} catch (Exception e) {
continue;
}
}
} else { } else {
continue; continue;
} }
@ -13700,57 +13747,56 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
} catch (Exception e) { } catch (Exception e) {
FileLog.e(e); FileLog.e(e);
} }
MediaController.PhotoEntry entry = new MediaController.PhotoEntry(0, 0, 0, path, orientation, false, 0, 0, 0); MediaController.PhotoEntry entry = new MediaController.PhotoEntry(0, 0, 0, path, orientation, photoInfo.isVideo, 0, 0, 0);
if (a == photoPathes.size() - 1 && caption != null) { if (a == photoPathes.size() - 1 && caption != null) {
entry.caption = caption; entry.caption = caption;
} }
entries.add(entry); entries.add(entry);
} }
if (!entries.isEmpty()) { if (entries.isEmpty()) {
if (getParentActivity() != null) {
final boolean[] checked = new boolean[entries.size()];
Arrays.fill(checked, true);
PhotoViewer.getInstance().setParentActivity(getParentActivity(), themeDelegate);
PhotoViewer.getInstance().openPhotoForSelect(new ArrayList<>(entries), entries.size() - 1, 0, false, new PhotoViewer.EmptyPhotoViewerProvider() {
@Override
public ImageReceiver.BitmapHolder getThumbForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation, int index) {
return null;
}
@Override
public void sendButtonPressed(int index, VideoEditedInfo videoEditedInfo, boolean notify, int scheduleDate, boolean forceDocument) {
for (int i = entries.size() - 1; i >= 0; --i) {
if (!checked[i]) {
entries.remove(i);
}
}
sendPhotosGroup(entries, notify, scheduleDate, forceDocument);
}
@Override
public int setPhotoChecked(int index, VideoEditedInfo videoEditedInfo) {
return index;
}
@Override
public boolean isPhotoChecked(int index) {
return checked[index];
}
@Override
public boolean canScrollAway() {
return false;
}
}, this);
} else {
fillEditingMediaWithCaption(caption, null);
sendPhotosGroup(entries, false, 0, false);
afterMessageSend();
}
return true;
} else {
return false; return false;
} }
if (getParentActivity() != null) {
final boolean[] checked = new boolean[entries.size()];
Arrays.fill(checked, true);
PhotoViewer.getInstance().setParentActivity(getParentActivity(), themeDelegate);
PhotoViewer.getInstance().openPhotoForSelect(new ArrayList<>(entries), entries.size() - 1, 2, false, new PhotoViewer.EmptyPhotoViewerProvider() {
@Override
public ImageReceiver.BitmapHolder getThumbForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation, int index) {
return null;
}
@Override
public void sendButtonPressed(int index, VideoEditedInfo videoEditedInfo, boolean notify, int scheduleDate, boolean forceDocument) {
for (int i = entries.size() - 1; i >= 0; --i) {
if (!checked[i]) {
entries.remove(i);
}
}
sendPhotosGroup(entries, notify, scheduleDate, forceDocument);
}
@Override
public int setPhotoChecked(int index, VideoEditedInfo videoEditedInfo) {
return index;
}
@Override
public boolean isPhotoChecked(int index) {
return checked[index];
}
@Override
public boolean canScrollAway() {
return false;
}
}, this);
} else {
fillEditingMediaWithCaption(caption, null);
sendPhotosGroup(entries, false, 0, false);
afterMessageSend();
}
return true;
} }
private void sendPhotosGroup(ArrayList<MediaController.PhotoEntry> entries, boolean notify, int scheduleDate, boolean forceDocument) { private void sendPhotosGroup(ArrayList<MediaController.PhotoEntry> entries, boolean notify, int scheduleDate, boolean forceDocument) {
if (!entries.isEmpty()) { if (!entries.isEmpty()) {
@ -20545,7 +20591,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
AlertsCreator.createDeleteMessagesAlert(this, currentUser, currentChat, currentEncryptedChat, chatInfo, mergeDialogId, finalSelectedObject, selectedMessagesIds, finalSelectedGroup, chatMode == MODE_SCHEDULED, loadParticipant, () -> { AlertsCreator.createDeleteMessagesAlert(this, currentUser, currentChat, currentEncryptedChat, chatInfo, mergeDialogId, finalSelectedObject, selectedMessagesIds, finalSelectedGroup, chatMode == MODE_SCHEDULED, loadParticipant, () -> {
hideActionMode(); hideActionMode();
updatePinnedMessageView(true); updatePinnedMessageView(true);
}, () -> dimBehindView(false), themeDelegate); }, null, themeDelegate);
} }
private void hideActionMode() { private void hideActionMode() {
@ -27142,6 +27188,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
startServiceBitmap = ((MotionBackgroundDrawable) backgroundDrawable).getBitmap(); startServiceBitmap = ((MotionBackgroundDrawable) backgroundDrawable).getBitmap();
} }
startServiceColor = currentServiceColor; startServiceColor = currentServiceColor;
startSelectedBackgroundColor = currentSelectedBackgroundColor;
startServiceTextColor = drawServiceGradient ? 0xffffffff : getCurrentColorOrDefault(Theme.key_chat_serviceText, true); startServiceTextColor = drawServiceGradient ? 0xffffffff : getCurrentColorOrDefault(Theme.key_chat_serviceText, true);
startServiceLinkColor = drawServiceGradient ? 0xffffffff : getCurrentColorOrDefault(Theme.key_chat_serviceLink, true); startServiceLinkColor = drawServiceGradient ? 0xffffffff : getCurrentColorOrDefault(Theme.key_chat_serviceLink, true);
startServiceButtonColor = drawServiceGradient ? 0xffffffff : getCurrentColorOrDefault(Theme.key_chat_serviceLink, true); startServiceButtonColor = drawServiceGradient ? 0xffffffff : getCurrentColorOrDefault(Theme.key_chat_serviceLink, true);
@ -27374,9 +27421,11 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
int startServiceButtonColor; int startServiceButtonColor;
int startServiceIconColor; int startServiceIconColor;
int startServiceColor; int startServiceColor;
int startSelectedBackgroundColor;
Bitmap startServiceBitmap; Bitmap startServiceBitmap;
int currentServiceColor; int currentServiceColor;
int currentSelectedBackgroundColor;
boolean drawServiceGradient; boolean drawServiceGradient;
private void initServiceMessageColors(Drawable backgroundDrawable) { private void initServiceMessageColors(Drawable backgroundDrawable) {
@ -27384,11 +27433,16 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
int currentServiceMessageColor = result[0]; int currentServiceMessageColor = result[0];
Integer serviceColor = getCurrentColor(Theme.key_chat_serviceBackground); Integer serviceColor = getCurrentColor(Theme.key_chat_serviceBackground);
Integer selectedBackgroundColor = getCurrentColor(Theme.key_chat_selectedBackground);
Integer serviceColor2 = serviceColor; Integer serviceColor2 = serviceColor;
if (serviceColor == null) { if (serviceColor == null) {
serviceColor = currentServiceMessageColor; serviceColor = currentServiceMessageColor;
} }
if (selectedBackgroundColor == null) {
selectedBackgroundColor = currentServiceMessageColor;
}
currentServiceColor = serviceColor; currentServiceColor = serviceColor;
currentSelectedBackgroundColor = selectedBackgroundColor;
drawServiceGradient = backgroundDrawable instanceof MotionBackgroundDrawable && SharedConfig.getDevicePerformanceClass() != SharedConfig.PERFORMANCE_CLASS_LOW; drawServiceGradient = backgroundDrawable instanceof MotionBackgroundDrawable && SharedConfig.getDevicePerformanceClass() != SharedConfig.PERFORMANCE_CLASS_LOW;
@ -27407,22 +27461,40 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
Paint actionBackgroundPaint = getPaint(Theme.key_paint_chatActionBackground); Paint actionBackgroundPaint = getPaint(Theme.key_paint_chatActionBackground);
Paint actionBackgroundSelectedPaint = getPaint(Theme.key_paint_chatActionBackgroundSelected); Paint actionBackgroundSelectedPaint = getPaint(Theme.key_paint_chatActionBackgroundSelected);
Paint msgBackgroundSelectedPaint = getPaint(Theme.key_paint_chatMessageBackgroundSelected);
if (actionBackgroundPaint != null) { if (actionBackgroundPaint != null) {
if (drawServiceGradient) { if (drawServiceGradient) {
ColorMatrix colorMatrix = new ColorMatrix(); ColorMatrix colorMatrix = new ColorMatrix();
colorMatrix.setSaturation(((MotionBackgroundDrawable) backgroundDrawable).getIntensity() >= 0 ? 1.8f : 0.5f); colorMatrix.setSaturation(((MotionBackgroundDrawable) backgroundDrawable).getIntensity() >= 0 ? 1.8f : 0.5f);
actionBackgroundPaint.setAlpha(127); actionBackgroundPaint.setAlpha(127);
actionBackgroundPaint.setColorFilter(new ColorMatrixColorFilter(colorMatrix)); actionBackgroundPaint.setColorFilter(new ColorMatrixColorFilter(colorMatrix));
actionBackgroundPaint.setShader(serviceShaderSource); actionBackgroundPaint.setShader(serviceShaderSource);
actionBackgroundSelectedPaint.setAlpha(127); actionBackgroundSelectedPaint.setAlpha(127);
actionBackgroundSelectedPaint.setColorFilter(new ColorMatrixColorFilter(colorMatrix)); actionBackgroundSelectedPaint.setColorFilter(new ColorMatrixColorFilter(colorMatrix));
actionBackgroundSelectedPaint.setShader(serviceShaderSource); actionBackgroundSelectedPaint.setShader(serviceShaderSource);
if (msgBackgroundSelectedPaint == null) {
msgBackgroundSelectedPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
currentPaints.put(Theme.key_paint_chatMessageBackgroundSelected, msgBackgroundSelectedPaint);
}
ColorMatrix colorMatrix2 = new ColorMatrix();
colorMatrix2.setSaturation(0.98f);
AndroidUtilities.lightColorMatrix(colorMatrix2, -60);
msgBackgroundSelectedPaint.setAlpha(90);
msgBackgroundSelectedPaint.setColorFilter(new ColorMatrixColorFilter(colorMatrix2));
msgBackgroundSelectedPaint.setShader(serviceShaderSource);
} else { } else {
actionBackgroundPaint.setColorFilter(null); actionBackgroundPaint.setColorFilter(null);
actionBackgroundPaint.setShader(null); actionBackgroundPaint.setShader(null);
actionBackgroundSelectedPaint.setColorFilter(null); actionBackgroundSelectedPaint.setColorFilter(null);
actionBackgroundSelectedPaint.setShader(null); actionBackgroundSelectedPaint.setShader(null);
if (msgBackgroundSelectedPaint != null) {
msgBackgroundSelectedPaint.setColorFilter(null);
msgBackgroundSelectedPaint.setShader(null);
}
} }
} }
} }
@ -27433,6 +27505,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
} }
Paint actionBackgroundPaint = getPaint(Theme.key_paint_chatActionBackground); Paint actionBackgroundPaint = getPaint(Theme.key_paint_chatActionBackground);
Paint actionBackgroundSelectedPaint = getPaint(Theme.key_paint_chatActionBackgroundSelected); Paint actionBackgroundSelectedPaint = getPaint(Theme.key_paint_chatActionBackgroundSelected);
Paint msgBackgroundSelectedPaint = getPaint(Theme.key_paint_chatMessageBackgroundSelected);
int serviceColor = currentServiceColor; int serviceColor = currentServiceColor;
int serviceTextColor = drawServiceGradient ? 0xffffffff : getCurrentColorOrDefault(Theme.key_chat_serviceText, true); int serviceTextColor = drawServiceGradient ? 0xffffffff : getCurrentColorOrDefault(Theme.key_chat_serviceText, true);
@ -27484,6 +27557,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
actionBackgroundPaint.setShader(serviceShader); actionBackgroundPaint.setShader(serviceShader);
actionBackgroundSelectedPaint.setShader(serviceShader); actionBackgroundSelectedPaint.setShader(serviceShader);
} }
if (msgBackgroundSelectedPaint != null) {
msgBackgroundSelectedPaint.setShader(serviceShader);
}
} else { } else {
useSourceShader = true; useSourceShader = true;
serviceCanvas.drawBitmap(serviceBitmapSource, 0, 0, null); serviceCanvas.drawBitmap(serviceBitmapSource, 0, 0, null);
@ -27491,7 +27567,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
actionBackgroundPaint.setShader(serviceShaderSource); actionBackgroundPaint.setShader(serviceShaderSource);
actionBackgroundSelectedPaint.setShader(serviceShaderSource); actionBackgroundSelectedPaint.setShader(serviceShaderSource);
} }
if (msgBackgroundSelectedPaint != null) {
msgBackgroundSelectedPaint.setShader(serviceShaderSource);
}
} }
} }
} }

View File

@ -41,22 +41,25 @@ public class BackButtonMenu {
int folderId; int folderId;
int filterId; int filterId;
} }
private static HashMap<Integer, ArrayList<PulledDialog>> pulledDialogs;
public static ActionBarPopupWindow show(BaseFragment fragment, View backButton, long currentDialogId) { public static ActionBarPopupWindow show(BaseFragment thisFragment, View backButton, long currentDialogId) {
if (fragment == null) { if (thisFragment == null) {
return null; return null;
} }
final ActionBarLayout parentLayout = fragment.getParentLayout(); final ActionBarLayout parentLayout = thisFragment.getParentLayout();
ArrayList<PulledDialog> dialogs = getStackedHistoryDialogs(fragment.getCurrentAccount(), parentLayout == null ? null : parentLayout.fragmentsStack, currentDialogId); final Context context = thisFragment.getParentActivity();
final View fragmentView = thisFragment.getFragmentView();
if (parentLayout == null || context == null || fragmentView == null) {
return null;
}
ArrayList<PulledDialog> dialogs = getStackedHistoryDialogs(thisFragment, currentDialogId);
if (dialogs.size() <= 0) { if (dialogs.size() <= 0) {
return null; return null;
} }
Context context = fragment.getParentActivity();
ActionBarPopupWindow.ActionBarPopupWindowLayout layout = new ActionBarPopupWindow.ActionBarPopupWindowLayout(context); ActionBarPopupWindow.ActionBarPopupWindowLayout layout = new ActionBarPopupWindow.ActionBarPopupWindowLayout(context);
android.graphics.Rect backgroundPaddings = new Rect(); android.graphics.Rect backgroundPaddings = new Rect();
Drawable shadowDrawable = fragment.getParentActivity().getResources().getDrawable(R.drawable.popup_fixed_alert).mutate(); Drawable shadowDrawable = thisFragment.getParentActivity().getResources().getDrawable(R.drawable.popup_fixed_alert).mutate();
shadowDrawable.getPadding(backgroundPaddings); shadowDrawable.getPadding(backgroundPaddings);
layout.setBackgroundColor(Theme.getColor(Theme.key_actionBarDefaultSubmenuBackground)); layout.setBackgroundColor(Theme.getColor(Theme.key_actionBarDefaultSubmenuBackground));
@ -144,7 +147,7 @@ public class BackButtonMenu {
} }
} }
} }
goToPulledDialog(fragment, pDialog); goToPulledDialog(thisFragment, pDialog);
}); });
layout.addView(cell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 48)); layout.addView(cell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 48));
} }
@ -163,21 +166,18 @@ public class BackButtonMenu {
scrimPopupWindow.getContentView().setFocusableInTouchMode(true); scrimPopupWindow.getContentView().setFocusableInTouchMode(true);
layout.setFitItems(true); layout.setFitItems(true);
View fragmentView = fragment.getFragmentView(); int popupX = AndroidUtilities.dp(8) - backgroundPaddings.left;
if (fragmentView != null) { if (AndroidUtilities.isTablet()) {
int popupX = AndroidUtilities.dp(8) - backgroundPaddings.left; int[] location = new int[2];
if (AndroidUtilities.isTablet()) { fragmentView.getLocationInWindow(location);
int[] location = new int[2]; popupX += location[0];
fragmentView.getLocationInWindow(location);
popupX += location[0];
}
int popupY = (int) (backButton.getBottom() - backgroundPaddings.top - AndroidUtilities.dp(8));
scrimPopupWindow.showAtLocation(fragmentView, Gravity.LEFT | Gravity.TOP, popupX, popupY);
try {
fragmentView.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
} catch (Exception ignore) {}
} }
int popupY = (int) (backButton.getBottom() - backgroundPaddings.top - AndroidUtilities.dp(8));
scrimPopupWindow.showAtLocation(fragmentView, Gravity.LEFT | Gravity.TOP, popupX, popupY);
try {
fragmentView.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
} catch (Exception ignore) {}
return scrimPopupWindow; return scrimPopupWindow;
} }
@ -203,8 +203,15 @@ public class BackButtonMenu {
} }
} }
public static ArrayList<PulledDialog> getStackedHistoryDialogs(int account, ArrayList<BaseFragment> fragmentsStack, long ignoreDialogId) { public static ArrayList<PulledDialog> getStackedHistoryDialogs(BaseFragment thisFragment, long ignoreDialogId) {
ArrayList<PulledDialog> dialogs = new ArrayList<>(); ArrayList<PulledDialog> dialogs = new ArrayList<>();
if (thisFragment == null)
return dialogs;
final ActionBarLayout parentLayout = thisFragment.getParentLayout();
if (parentLayout == null)
return dialogs;
ArrayList<BaseFragment> fragmentsStack = parentLayout.fragmentsStack;
ArrayList<PulledDialog> pulledDialogs = parentLayout.pulledDialogs;
if (fragmentsStack != null) { if (fragmentsStack != null) {
final int count = fragmentsStack.size(); final int count = fragmentsStack.size();
for (int i = 0; i < count; ++i) { for (int i = 0; i < count; ++i) {
@ -263,46 +270,42 @@ public class BackButtonMenu {
} }
} }
if (pulledDialogs != null) { if (pulledDialogs != null) {
ArrayList<PulledDialog> pulledDialogsAccount = pulledDialogs.get(account); for (PulledDialog pulledDialog : pulledDialogs) {
if (pulledDialogsAccount != null) { if (pulledDialog.dialogId == ignoreDialogId) {
for (PulledDialog pulledDialog : pulledDialogsAccount) { continue;
if (pulledDialog.dialogId == ignoreDialogId) { }
continue; boolean alreadyAddedDialog = false;
} for (int d = 0; d < dialogs.size(); ++d) {
boolean alreadyAddedDialog = false; if (dialogs.get(d).dialogId == pulledDialog.dialogId) {
for (int d = 0; d < dialogs.size(); ++d) { alreadyAddedDialog = true;
if (dialogs.get(d).dialogId == pulledDialog.dialogId) { break;
alreadyAddedDialog = true;
break;
}
}
if (!alreadyAddedDialog) {
dialogs.add(pulledDialog);
} }
} }
if (!alreadyAddedDialog) {
dialogs.add(pulledDialog);
}
} }
} }
Collections.sort(dialogs, (d1, d2) -> d2.stackIndex - d1.stackIndex); Collections.sort(dialogs, (d1, d2) -> d2.stackIndex - d1.stackIndex);
return dialogs; return dialogs;
} }
public static void addToPulledDialogs(int account, int stackIndex, TLRPC.Chat chat, TLRPC.User user, long dialogId, int folderId, int filterId) { public static void addToPulledDialogs(BaseFragment thisFragment, int stackIndex, TLRPC.Chat chat, TLRPC.User user, long dialogId, int folderId, int filterId) {
if (chat == null && user == null) { if (chat == null && user == null) {
return; return;
} }
if (pulledDialogs == null) { if (thisFragment == null) {
pulledDialogs = new HashMap<>(); return;
} }
ArrayList<PulledDialog> dialogs = null; final ActionBarLayout parentLayout = thisFragment.getParentLayout();
if (pulledDialogs.containsKey(account)) { if (parentLayout == null) {
dialogs = pulledDialogs.get(account); return;
} }
if (dialogs == null) { if (parentLayout.pulledDialogs == null) {
pulledDialogs.put(account, dialogs = new ArrayList<>()); parentLayout.pulledDialogs = new ArrayList<>();
} }
boolean alreadyAdded = false; boolean alreadyAdded = false;
for (PulledDialog d : dialogs) { for (PulledDialog d : parentLayout.pulledDialogs) {
if (d.dialogId == dialogId) { if (d.dialogId == dialogId) {
alreadyAdded = true; alreadyAdded = true;
break; break;
@ -318,18 +321,22 @@ public class BackButtonMenu {
d.folderId = folderId; d.folderId = folderId;
d.chat = chat; d.chat = chat;
d.user = user; d.user = user;
dialogs.add(d); parentLayout.pulledDialogs.add(d);
} }
} }
public static void clearPulledDialogs(int account, int fromIndex) { public static void clearPulledDialogs(BaseFragment thisFragment, int fromIndex) {
if (pulledDialogs != null && pulledDialogs.containsKey(account)) { if (thisFragment == null) {
ArrayList<PulledDialog> dialogs = pulledDialogs.get(account); return;
if (dialogs != null) { }
for (int i = 0; i < dialogs.size(); ++i) { final ActionBarLayout parentLayout = thisFragment.getParentLayout();
if (dialogs.get(i).stackIndex > fromIndex) { if (parentLayout == null) {
dialogs.remove(i); return;
i--; }
} if (parentLayout.pulledDialogs != null) {
for (int i = 0; i < parentLayout.pulledDialogs.size(); ++i) {
if (parentLayout.pulledDialogs.get(i).stackIndex > fromIndex) {
parentLayout.pulledDialogs.remove(i);
i--;
} }
} }
} }

View File

@ -13,6 +13,7 @@ import android.view.ViewGroup;
public class MessageBackgroundDrawable extends Drawable { public class MessageBackgroundDrawable extends Drawable {
private Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); private Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
private Paint customPaint = null;
private long lastAnimationTime; private long lastAnimationTime;
private float currentAnimationProgress; private float currentAnimationProgress;
private boolean isSelected; private boolean isSelected;
@ -33,6 +34,10 @@ public class MessageBackgroundDrawable extends Drawable {
paint.setColor(color); paint.setColor(color);
} }
public void setCustomPaint(Paint paint) {
this.customPaint = paint;
}
public void setSelected(boolean selected, boolean animated) { public void setSelected(boolean selected, boolean animated) {
if (isSelected == selected) { if (isSelected == selected) {
if (animationInProgress != animated && !animated) { if (animationInProgress != animated && !animated) {
@ -125,7 +130,7 @@ public class MessageBackgroundDrawable extends Drawable {
@Override @Override
public void draw(Canvas canvas) { public void draw(Canvas canvas) {
if (currentAnimationProgress == 1.0f) { if (currentAnimationProgress == 1.0f) {
canvas.drawRect(getBounds(), paint); canvas.drawRect(getBounds(), customPaint != null ? customPaint : paint);
} else if (currentAnimationProgress != 0.0f) { } else if (currentAnimationProgress != 0.0f) {
float interpolatedProgress; float interpolatedProgress;
if (isSelected) { if (isSelected) {
@ -150,7 +155,7 @@ public class MessageBackgroundDrawable extends Drawable {
} }
x1 = centerX + (1.0f - interpolatedProgress) * (x1 - centerX); x1 = centerX + (1.0f - interpolatedProgress) * (x1 - centerX);
y1 = centerY + (1.0f - interpolatedProgress) * (y1 - centerY); y1 = centerY + (1.0f - interpolatedProgress) * (y1 - centerY);
canvas.drawCircle(x1, y1, finalRadius * interpolatedProgress, paint); canvas.drawCircle(x1, y1, finalRadius * interpolatedProgress, customPaint != null ? customPaint : paint);
} }
if (animationInProgress) { if (animationInProgress) {
long newTime = SystemClock.elapsedRealtime(); long newTime = SystemClock.elapsedRealtime();

View File

@ -43,6 +43,7 @@ import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.Vibrator; import android.os.Vibrator;
import android.text.TextPaint;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Property; import android.util.Property;
import android.util.StateSet; import android.util.StateSet;
@ -59,9 +60,11 @@ import android.view.ViewOutlineProvider;
import android.view.ViewParent; import android.view.ViewParent;
import android.view.ViewTreeObserver; import android.view.ViewTreeObserver;
import android.view.WindowManager; import android.view.WindowManager;
import android.view.accessibility.AccessibilityNodeInfo;
import android.view.animation.AccelerateDecelerateInterpolator; import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.animation.DecelerateInterpolator; import android.view.animation.DecelerateInterpolator;
import android.view.animation.Interpolator; import android.view.animation.Interpolator;
import android.widget.Button;
import android.widget.EditText; import android.widget.EditText;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.ImageView; import android.widget.ImageView;
@ -289,8 +292,15 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
private RecyclerView sideMenu; private RecyclerView sideMenu;
private ChatActivityEnterView commentView; private ChatActivityEnterView commentView;
private ImageView[] writeButton;
private FrameLayout writeButtonContainer;
private View selectedCountView;
private ActionBarMenuItem switchItem; private ActionBarMenuItem switchItem;
private RectF rect = new RectF();
private Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
private TextPaint textPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
private FragmentContextView fragmentLocationContextView; private FragmentContextView fragmentLocationContextView;
private FragmentContextView fragmentContextView; private FragmentContextView fragmentContextView;
@ -347,6 +357,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
private DialogsActivityDelegate delegate; private DialogsActivityDelegate delegate;
private ArrayList<Long> selectedDialogs = new ArrayList<>(); private ArrayList<Long> selectedDialogs = new ArrayList<>();
public boolean notify = true;
private int canReadCount; private int canReadCount;
private int canPinCount; private int canPinCount;
@ -3218,6 +3229,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
commentView.setAllowStickersAndGifs(false, false); commentView.setAllowStickersAndGifs(false, false);
commentView.setForceShowSendButton(true, false); commentView.setForceShowSendButton(true, false);
commentView.setVisibility(View.GONE); commentView.setVisibility(View.GONE);
commentView.getSendButton().setAlpha(0);
contentView.addView(commentView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.BOTTOM)); contentView.addView(commentView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.BOTTOM));
commentView.setDelegate(new ChatActivityEnterView.ChatActivityEnterViewDelegate() { commentView.setDelegate(new ChatActivityEnterView.ChatActivityEnterViewDelegate() {
@Override @Override
@ -3328,6 +3340,99 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
} }
}); });
writeButtonContainer = new FrameLayout(context) {
@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
super.onInitializeAccessibilityNodeInfo(info);
info.setText(LocaleController.formatPluralString("AccDescrShareInChats", selectedDialogs.size()));
info.setClassName(Button.class.getName());
info.setLongClickable(true);
info.setClickable(true);
}
};
writeButtonContainer.setFocusable(true);
writeButtonContainer.setFocusableInTouchMode(true);
writeButtonContainer.setVisibility(View.INVISIBLE);
writeButtonContainer.setScaleX(0.2f);
writeButtonContainer.setScaleY(0.2f);
writeButtonContainer.setAlpha(0.0f);
contentView.addView(writeButtonContainer, LayoutHelper.createFrame(60, 60, Gravity.RIGHT | Gravity.BOTTOM, 0, 0, 6, 10));
textPaint.setTextSize(AndroidUtilities.dp(12));
textPaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
selectedCountView = new View(context) {
@Override
protected void onDraw(Canvas canvas) {
String text = String.format("%d", Math.max(1, selectedDialogs.size()));
int textSize = (int) Math.ceil(textPaint.measureText(text));
int size = Math.max(AndroidUtilities.dp(16) + textSize, AndroidUtilities.dp(24));
int cx = getMeasuredWidth() / 2;
int cy = getMeasuredHeight() / 2;
textPaint.setColor(getThemedColor(Theme.key_dialogRoundCheckBoxCheck));
paint.setColor(getThemedColor(Theme.isCurrentThemeDark() ? Theme.key_voipgroup_inviteMembersBackground : Theme.key_dialogBackground));
rect.set(cx - size / 2, 0, cx + size / 2, getMeasuredHeight());
canvas.drawRoundRect(rect, AndroidUtilities.dp(12), AndroidUtilities.dp(12), paint);
paint.setColor(getThemedColor(Theme.key_dialogRoundCheckBox));
rect.set(cx - size / 2 + AndroidUtilities.dp(2), AndroidUtilities.dp(2), cx + size / 2 - AndroidUtilities.dp(2), getMeasuredHeight() - AndroidUtilities.dp(2));
canvas.drawRoundRect(rect, AndroidUtilities.dp(10), AndroidUtilities.dp(10), paint);
canvas.drawText(text, cx - textSize / 2, AndroidUtilities.dp(16.2f), textPaint);
}
};
selectedCountView.setAlpha(0.0f);
selectedCountView.setScaleX(0.2f);
selectedCountView.setScaleY(0.2f);
contentView.addView(selectedCountView, LayoutHelper.createFrame(42, 24, Gravity.RIGHT | Gravity.BOTTOM, 0, 0, -8, 9));
FrameLayout writeButtonBackground = new FrameLayout(context);
Drawable writeButtonDrawable = Theme.createSimpleSelectorCircleDrawable(AndroidUtilities.dp(56), getThemedColor(Theme.key_dialogFloatingButton), getThemedColor(Build.VERSION.SDK_INT >= 21 ? Theme.key_dialogFloatingButtonPressed : Theme.key_dialogFloatingButton));
if (Build.VERSION.SDK_INT < 21) {
Drawable shadowDrawable = context.getResources().getDrawable(R.drawable.floating_shadow_profile).mutate();
shadowDrawable.setColorFilter(new PorterDuffColorFilter(0xff000000, PorterDuff.Mode.MULTIPLY));
CombinedDrawable combinedDrawable = new CombinedDrawable(shadowDrawable, drawable, 0, 0);
combinedDrawable.setIconSize(AndroidUtilities.dp(56), AndroidUtilities.dp(56));
writeButtonDrawable = combinedDrawable;
}
writeButtonBackground.setBackgroundDrawable(writeButtonDrawable);
writeButtonBackground.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
writeButtonBackground.setOutlineProvider(new ViewOutlineProvider() {
@SuppressLint("NewApi")
@Override
public void getOutline(View view, Outline outline) {
outline.setOval(0, 0, AndroidUtilities.dp(56), AndroidUtilities.dp(56));
}
});
}
writeButtonBackground.setOnClickListener(v -> {
if (delegate == null || selectedDialogs.isEmpty()) {
return;
}
delegate.didSelectDialogs(DialogsActivity.this, selectedDialogs, commentView.getFieldText(), false);
});
writeButtonBackground.setOnLongClickListener(v -> {
if (isNextButton) {
return false;
}
onSendLongClick(writeButtonBackground);
return true;
});
writeButton = new ImageView[2];
for (int a = 0; a < 2; ++a) {
writeButton[a] = new ImageView(context);
writeButton[a].setImageResource(a == 1 ? R.drawable.actionbtn_next : R.drawable.attach_send);
writeButton[a].setColorFilter(new PorterDuffColorFilter(getThemedColor(Theme.key_dialogFloatingIcon), PorterDuff.Mode.MULTIPLY));
writeButton[a].setScaleType(ImageView.ScaleType.CENTER);
writeButtonBackground.addView(writeButton[a], LayoutHelper.createFrame(Build.VERSION.SDK_INT >= 21 ? 56 : 60, Build.VERSION.SDK_INT >= 21 ? 56 : 60, Gravity.CENTER));
}
AndroidUtilities.updateViewVisibilityAnimated(writeButton[0], true, 0.5f, false);
AndroidUtilities.updateViewVisibilityAnimated(writeButton[1], false, 0.5f, false);
writeButtonContainer.addView(writeButtonBackground, LayoutHelper.createFrame(Build.VERSION.SDK_INT >= 21 ? 56 : 60, Build.VERSION.SDK_INT >= 21 ? 56 : 60, Gravity.LEFT | Gravity.TOP, Build.VERSION.SDK_INT >= 21 ? 2 : 0, 0, 0, 0));
} }
if (filterTabsView != null) { if (filterTabsView != null) {
@ -6211,6 +6316,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
doneItemAnimator.start(); doneItemAnimator.start();
} }
private boolean isNextButton = false;
private void updateSelectedCount() { private void updateSelectedCount() {
if (commentView != null) { if (commentView != null) {
if (selectedDialogs.isEmpty()) { if (selectedDialogs.isEmpty()) {
@ -6223,13 +6329,22 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
commentView.hidePopup(false); commentView.hidePopup(false);
commentView.closeKeyboard(); commentView.closeKeyboard();
AnimatorSet animatorSet = new AnimatorSet(); AnimatorSet animatorSet = new AnimatorSet();
animatorSet.playTogether(ObjectAnimator.ofFloat(commentView, View.TRANSLATION_Y, 0, commentView.getMeasuredHeight())); animatorSet.playTogether(
ObjectAnimator.ofFloat(commentView, View.TRANSLATION_Y, 0, commentView.getMeasuredHeight()),
ObjectAnimator.ofFloat(writeButtonContainer, View.SCALE_X, .2f),
ObjectAnimator.ofFloat(writeButtonContainer, View.SCALE_Y, .2f),
ObjectAnimator.ofFloat(writeButtonContainer, View.ALPHA, 0),
ObjectAnimator.ofFloat(selectedCountView, View.SCALE_X, 0.2f),
ObjectAnimator.ofFloat(selectedCountView, View.SCALE_Y, 0.2f),
ObjectAnimator.ofFloat(selectedCountView, View.ALPHA, 0.0f)
);
animatorSet.setDuration(180); animatorSet.setDuration(180);
animatorSet.setInterpolator(new DecelerateInterpolator()); animatorSet.setInterpolator(new DecelerateInterpolator());
animatorSet.addListener(new AnimatorListenerAdapter() { animatorSet.addListener(new AnimatorListenerAdapter() {
@Override @Override
public void onAnimationEnd(Animator animation) { public void onAnimationEnd(Animator animation) {
commentView.setVisibility(View.GONE); commentView.setVisibility(View.GONE);
writeButtonContainer.setVisibility(View.GONE);
} }
}); });
animatorSet.start(); animatorSet.start();
@ -6237,11 +6352,21 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
fragmentView.requestLayout(); fragmentView.requestLayout();
} }
} else { } else {
selectedCountView.invalidate();
if (commentView.getTag() == null) { if (commentView.getTag() == null) {
commentView.setFieldText(""); commentView.setFieldText("");
commentView.setVisibility(View.VISIBLE); commentView.setVisibility(View.VISIBLE);
writeButtonContainer.setVisibility(View.VISIBLE);
AnimatorSet animatorSet = new AnimatorSet(); AnimatorSet animatorSet = new AnimatorSet();
animatorSet.playTogether(ObjectAnimator.ofFloat(commentView, View.TRANSLATION_Y, commentView.getMeasuredHeight(), 0)); animatorSet.playTogether(
ObjectAnimator.ofFloat(commentView, View.TRANSLATION_Y, commentView.getMeasuredHeight(), 0),
ObjectAnimator.ofFloat(writeButtonContainer, View.SCALE_X, 1f),
ObjectAnimator.ofFloat(writeButtonContainer, View.SCALE_Y, 1f),
ObjectAnimator.ofFloat(writeButtonContainer, View.ALPHA, 1f),
ObjectAnimator.ofFloat(selectedCountView, View.SCALE_X, 1f),
ObjectAnimator.ofFloat(selectedCountView, View.SCALE_Y, 1f),
ObjectAnimator.ofFloat(selectedCountView, View.ALPHA, 1f)
);
animatorSet.setDuration(180); animatorSet.setDuration(180);
animatorSet.setInterpolator(new DecelerateInterpolator()); animatorSet.setInterpolator(new DecelerateInterpolator());
animatorSet.addListener(new AnimatorListenerAdapter() { animatorSet.addListener(new AnimatorListenerAdapter() {
@ -6259,6 +6384,10 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
} else if (initialDialogsType == 10) { } else if (initialDialogsType == 10) {
hideFloatingButton(selectedDialogs.isEmpty()); hideFloatingButton(selectedDialogs.isEmpty());
} }
isNextButton = shouldShowNextButton(this, selectedDialogs, commentView.getFieldText(), false);
AndroidUtilities.updateViewVisibilityAnimated(writeButton[0], !isNextButton, 0.5f, true);
AndroidUtilities.updateViewVisibilityAnimated(writeButton[1], isNextButton, 0.5f, true);
} }
@TargetApi(Build.VERSION_CODES.M) @TargetApi(Build.VERSION_CODES.M)
@ -6888,6 +7017,9 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
public void setDelegate(DialogsActivityDelegate dialogsActivityDelegate) { public void setDelegate(DialogsActivityDelegate dialogsActivityDelegate) {
delegate = dialogsActivityDelegate; delegate = dialogsActivityDelegate;
} }
public boolean shouldShowNextButton(DialogsActivity fragment, ArrayList<Long> dids, CharSequence message, boolean param) {
return false;
}
public void setSearchString(String string) { public void setSearchString(String string) {
searchString = string; searchString = string;
@ -7052,6 +7184,87 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
return floatingButton; return floatingButton;
} }
private ActionBarPopupWindow sendPopupWindow;
private boolean onSendLongClick(View view) {
final Activity parentActivity = getParentActivity();
final Theme.ResourcesProvider resourcesProvider = getResourceProvider();
if (parentActivity == null) {
return false;
}
LinearLayout layout = new LinearLayout(parentActivity);
layout.setOrientation(LinearLayout.VERTICAL);
ActionBarPopupWindow.ActionBarPopupWindowLayout sendPopupLayout2 = new ActionBarPopupWindow.ActionBarPopupWindowLayout(parentActivity, resourcesProvider);
sendPopupLayout2.setAnimationEnabled(false);
sendPopupLayout2.setOnTouchListener(new View.OnTouchListener() {
private android.graphics.Rect popupRect = new android.graphics.Rect();
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
if (sendPopupWindow != null && sendPopupWindow.isShowing()) {
v.getHitRect(popupRect);
if (!popupRect.contains((int) event.getX(), (int) event.getY())) {
sendPopupWindow.dismiss();
}
}
}
return false;
}
});
sendPopupLayout2.setDispatchKeyEventListener(keyEvent -> {
if (keyEvent.getKeyCode() == KeyEvent.KEYCODE_BACK && keyEvent.getRepeatCount() == 0 && sendPopupWindow != null && sendPopupWindow.isShowing()) {
sendPopupWindow.dismiss();
}
});
sendPopupLayout2.setShownFromBotton(false);
sendPopupLayout2.setupRadialSelectors(getThemedColor(Theme.key_dialogButtonSelector));
ActionBarMenuSubItem sendWithoutSound = new ActionBarMenuSubItem(parentActivity, true, true, resourcesProvider);
sendWithoutSound.setTextAndIcon(LocaleController.getString("SendWithoutSound", R.string.SendWithoutSound), R.drawable.input_notify_off);
sendWithoutSound.setMinimumWidth(AndroidUtilities.dp(196));
sendPopupLayout2.addView(sendWithoutSound, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 48));
sendWithoutSound.setOnClickListener(v -> {
if (sendPopupWindow != null && sendPopupWindow.isShowing()) {
sendPopupWindow.dismiss();
}
this.notify = false;
if (delegate == null || selectedDialogs.isEmpty()) {
return;
}
delegate.didSelectDialogs(DialogsActivity.this, selectedDialogs, commentView.getFieldText(), false);
});
layout.addView(sendPopupLayout2, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
sendPopupWindow = new ActionBarPopupWindow(layout, LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT);
sendPopupWindow.setAnimationEnabled(false);
sendPopupWindow.setAnimationStyle(R.style.PopupContextAnimation2);
sendPopupWindow.setOutsideTouchable(true);
sendPopupWindow.setClippingEnabled(true);
sendPopupWindow.setInputMethodMode(ActionBarPopupWindow.INPUT_METHOD_NOT_NEEDED);
sendPopupWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED);
sendPopupWindow.getContentView().setFocusableInTouchMode(true);
SharedConfig.removeScheduledOrNoSuoundHint();
layout.measure(View.MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(1000), View.MeasureSpec.AT_MOST), View.MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(1000), View.MeasureSpec.AT_MOST));
sendPopupWindow.setFocusable(true);
int[] location = new int[2];
view.getLocationInWindow(location);
int y;
// if (keyboardVisible && parentFragment.contentView.getMeasuredHeight() > AndroidUtilities.dp(58)) {
// y = location[1] + view.getMeasuredHeight();
// } else {
y = location[1] - layout.getMeasuredHeight() - AndroidUtilities.dp(2);
// }
sendPopupWindow.showAtLocation(view, Gravity.LEFT | Gravity.TOP, location[0] + view.getMeasuredWidth() - layout.getMeasuredWidth() + AndroidUtilities.dp(8), y);
sendPopupWindow.dimBehind();
view.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
return false;
}
@Override @Override
public ArrayList<ThemeDescription> getThemeDescriptions() { public ArrayList<ThemeDescription> getThemeDescriptions() {
ThemeDescription.ThemeDescriptionDelegate cellDelegate = () -> { ThemeDescription.ThemeDescriptionDelegate cellDelegate = () -> {
@ -7521,7 +7734,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
arrayList.add(new ThemeDescription(commentView, ThemeDescription.FLAG_TEXTCOLOR, new Class[]{ChatActivityEnterView.class}, new String[]{"messageEditText"}, null, null, null, Theme.key_chat_messagePanelText)); arrayList.add(new ThemeDescription(commentView, ThemeDescription.FLAG_TEXTCOLOR, new Class[]{ChatActivityEnterView.class}, new String[]{"messageEditText"}, null, null, null, Theme.key_chat_messagePanelText));
arrayList.add(new ThemeDescription(commentView, ThemeDescription.FLAG_CURSORCOLOR, new Class[]{ChatActivityEnterView.class}, new String[]{"messageEditText"}, null, null, null, Theme.key_chat_messagePanelCursor)); arrayList.add(new ThemeDescription(commentView, ThemeDescription.FLAG_CURSORCOLOR, new Class[]{ChatActivityEnterView.class}, new String[]{"messageEditText"}, null, null, null, Theme.key_chat_messagePanelCursor));
arrayList.add(new ThemeDescription(commentView, ThemeDescription.FLAG_HINTTEXTCOLOR, new Class[]{ChatActivityEnterView.class}, new String[]{"messageEditText"}, null, null, null, Theme.key_chat_messagePanelHint)); arrayList.add(new ThemeDescription(commentView, ThemeDescription.FLAG_HINTTEXTCOLOR, new Class[]{ChatActivityEnterView.class}, new String[]{"messageEditText"}, null, null, null, Theme.key_chat_messagePanelHint));
arrayList.add(new ThemeDescription(commentView, ThemeDescription.FLAG_IMAGECOLOR, new Class[]{ChatActivityEnterView.class}, new String[]{"sendButton"}, null, null, null, Theme.key_chat_messagePanelSend)); // arrayList.add(new ThemeDescription(commentView, ThemeDescription.FLAG_IMAGECOLOR, new Class[]{ChatActivityEnterView.class}, new String[]{"sendButton"}, null, null, null, Theme.key_chat_messagePanelSend));
} }
arrayList.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_actionBarTipBackground)); arrayList.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_actionBarTipBackground));

View File

@ -2520,7 +2520,27 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
args.putString("selectAlertString", LocaleController.getString("SendMessagesToText", R.string.SendMessagesToText)); args.putString("selectAlertString", LocaleController.getString("SendMessagesToText", R.string.SendMessagesToText));
args.putString("selectAlertStringGroup", LocaleController.getString("SendMessagesToGroupText", R.string.SendMessagesToGroupText)); args.putString("selectAlertStringGroup", LocaleController.getString("SendMessagesToGroupText", R.string.SendMessagesToGroupText));
} }
DialogsActivity fragment = new DialogsActivity(args); DialogsActivity fragment = new DialogsActivity(args) {
@Override
public boolean shouldShowNextButton(DialogsActivity dialogsFragment, ArrayList<Long> dids, CharSequence message, boolean param) {
if (exportingChatUri != null) {
return false;
} else {
if (contactsToSend != null && contactsToSend.size() == 1 && !mainFragmentsStack.isEmpty()) {
return true;
} else {
if (dids.size() <= 1) {
if (videoPath != null) {
return true;
} else if (photoPathsArray != null && photoPathsArray.size() > 0) {
return true;
}
}
}
}
return false;
}
};
fragment.setDelegate(this); fragment.setDelegate(this);
boolean removeLast; boolean removeLast;
if (AndroidUtilities.isTablet()) { if (AndroidUtilities.isTablet()) {
@ -3836,6 +3856,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
} }
} else { } else {
boolean notify = dialogsFragment == null || dialogsFragment.notify;
final ChatActivity fragment; final ChatActivity fragment;
if (dids.size() <= 1) { if (dids.size() <= 1) {
final long did = dids.get(0); final long did = dids.get(0);
@ -3889,12 +3910,12 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
if (contactsToSend != null && contactsToSend.size() == 1 && !mainFragmentsStack.isEmpty()) { if (contactsToSend != null && contactsToSend.size() == 1 && !mainFragmentsStack.isEmpty()) {
PhonebookShareAlert alert = new PhonebookShareAlert(mainFragmentsStack.get(mainFragmentsStack.size() - 1), null, null, contactsToSendUri, null, null, null); PhonebookShareAlert alert = new PhonebookShareAlert(mainFragmentsStack.get(mainFragmentsStack.size() - 1), null, null, contactsToSendUri, null, null, null);
alert.setDelegate((user, notify, scheduleDate) -> { alert.setDelegate((user, notify2, scheduleDate) -> {
if (fragment != null) { if (fragment != null) {
actionBarLayout.presentFragment(fragment, true, false, true, false); actionBarLayout.presentFragment(fragment, true, false, true, false);
} }
for (int i = 0; i < dids.size(); i++) { for (int i = 0; i < dids.size(); i++) {
SendMessagesHelper.getInstance(account).sendMessage(user, dids.get(i), null, null, null, null, notify, scheduleDate); SendMessagesHelper.getInstance(account).sendMessage(user, dids.get(i), null, null, null, null, notify2, scheduleDate);
} }
}); });
mainFragmentsStack.get(mainFragmentsStack.size() - 1).showDialog(alert); mainFragmentsStack.get(mainFragmentsStack.size() - 1).showDialog(alert);
@ -3906,7 +3927,8 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
AccountInstance accountInstance = AccountInstance.getInstance(UserConfig.selectedAccount); AccountInstance accountInstance = AccountInstance.getInstance(UserConfig.selectedAccount);
boolean photosEditorOpened = false; boolean photosEditorOpened = false;
if (fragment != null) { if (fragment != null) {
actionBarLayout.presentFragment(fragment, dialogsFragment != null, dialogsFragment == null, true, false); boolean withoutAnimation = dialogsFragment == null || (videoPath != null || (photoPathsArray != null && photoPathsArray.size() > 0));
actionBarLayout.presentFragment(fragment, dialogsFragment != null, withoutAnimation, true, false);
if (videoPath != null) { if (videoPath != null) {
fragment.openVideoEditor(videoPath, sendingText); fragment.openVideoEditor(videoPath, sendingText);
sendingText = null; sendingText = null;
@ -3924,7 +3946,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
} }
ArrayList<String> arrayList = new ArrayList<>(); ArrayList<String> arrayList = new ArrayList<>();
arrayList.add(videoPath); arrayList.add(videoPath);
SendMessagesHelper.prepareSendingDocuments(accountInstance, arrayList, arrayList, null, captionToSend, null, did, null, null, null, null, true, 0); SendMessagesHelper.prepareSendingDocuments(accountInstance, arrayList, arrayList, null, captionToSend, null, did, null, null, null, null, notify, 0);
} }
} }
if (photoPathsArray != null && !photosEditorOpened) { if (photoPathsArray != null && !photosEditorOpened) {
@ -3932,14 +3954,14 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
photoPathsArray.get(0).caption = sendingText; photoPathsArray.get(0).caption = sendingText;
sendingText = null; sendingText = null;
} }
SendMessagesHelper.prepareSendingMedia(accountInstance, photoPathsArray, did, null, null, null, false, false, null, true, 0); SendMessagesHelper.prepareSendingMedia(accountInstance, photoPathsArray, did, null, null, null, false, false, null, notify, 0);
} }
if (documentsPathsArray != null || documentsUrisArray != null) { if (documentsPathsArray != null || documentsUrisArray != null) {
if (sendingText != null && sendingText.length() <= 1024 && ((documentsPathsArray != null ? documentsPathsArray.size() : 0) + (documentsUrisArray != null ? documentsUrisArray.size() : 0)) == 1) { if (sendingText != null && sendingText.length() <= 1024 && ((documentsPathsArray != null ? documentsPathsArray.size() : 0) + (documentsUrisArray != null ? documentsUrisArray.size() : 0)) == 1) {
captionToSend = sendingText; captionToSend = sendingText;
sendingText = null; sendingText = null;
} }
SendMessagesHelper.prepareSendingDocuments(accountInstance, documentsPathsArray, documentsOriginalPathsArray, documentsUrisArray, captionToSend, documentsMimeType, did, null, null, null, null, true, 0); SendMessagesHelper.prepareSendingDocuments(accountInstance, documentsPathsArray, documentsOriginalPathsArray, documentsUrisArray, captionToSend, documentsMimeType, did, null, null, null, null, notify, 0);
} }
if (sendingText != null) { if (sendingText != null) {
SendMessagesHelper.prepareSendingText(accountInstance, sendingText, did, true, 0); SendMessagesHelper.prepareSendingText(accountInstance, sendingText, did, true, 0);
@ -3947,11 +3969,11 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
if (contactsToSend != null && !contactsToSend.isEmpty()) { if (contactsToSend != null && !contactsToSend.isEmpty()) {
for (int a = 0; a < contactsToSend.size(); a++) { for (int a = 0; a < contactsToSend.size(); a++) {
TLRPC.User user = contactsToSend.get(a); TLRPC.User user = contactsToSend.get(a);
SendMessagesHelper.getInstance(account).sendMessage(user, did, null, null, null, null, true, 0); SendMessagesHelper.getInstance(account).sendMessage(user, did, null, null, null, null, notify, 0);
} }
} }
if (!TextUtils.isEmpty(message)) { if (!TextUtils.isEmpty(message)) {
SendMessagesHelper.prepareSendingText(accountInstance, message.toString(), did, true, 0); SendMessagesHelper.prepareSendingText(accountInstance, message.toString(), did, notify, 0);
} }
} }
} }