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 ->
variant.outputs.all { output ->
@ -319,7 +319,7 @@ android {
defaultConfig {
minSdkVersion 16
targetSdkVersion 30
versionName "8.5.2"
versionName "8.5.3"
vectorDrawables.generatedDensities = ['mdpi', 'hdpi', 'xhdpi', 'xxhdpi']

View file

@ -31,6 +31,7 @@ import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.graphics.ColorMatrix;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Point;
@ -697,6 +698,17 @@ public class AndroidUtilities {
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) {
if (activity == null || isTablet()) {
return;
@ -2278,7 +2290,7 @@ public class AndroidUtilities {
}
public static void appCenterLog(Throwable e) {
}
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 CHECK_UPDATES = true;
public static boolean NO_SCOPED_STORAGE = Build.VERSION.SDK_INT <= 29;
public static int BUILD_VERSION = 2563;
public static String BUILD_VERSION_STRING = "8.5.2";
public static int BUILD_VERSION = 2565;
public static String BUILD_VERSION_STRING = "8.5.3";
public static int APP_ID = 4;
public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103";

View file

@ -388,6 +388,7 @@ public class MediaDataController extends BaseController {
getMessagesStorage().getStorageQueue().postRunnable(() -> {
try {
if (reactionsFinal != null) {
getMessagesStorage().getDatabase().executeFast("DELETE FROM reactions").stepThis().dispose();
SQLitePreparedStatement state = getMessagesStorage().getDatabase().executeFast("REPLACE INTO reactions VALUES(?, ?, ?)");
state.requery();
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.R;
import org.telegram.messenger.SharedConfig;
import org.telegram.ui.Components.BackButtonMenu;
import org.telegram.ui.Components.Bulletin;
import org.telegram.ui.Components.CubicBezierInterpolator;
import org.telegram.ui.Components.GroupCallPip;
@ -323,6 +324,7 @@ public class ActionBarLayout extends FrameLayout {
protected Activity parentActivity;
public ArrayList<BaseFragment> fragmentsStack;
public ArrayList<BackButtonMenu.PulledDialog> pulledDialogs;
private Rect rect = new Rect();
private boolean delayedAnimationResumed;

View file

@ -55,6 +55,7 @@ import android.os.SystemClock;
import android.text.TextPaint;
import android.text.TextUtils;
import android.util.Base64;
import android.util.Log;
import android.util.LongSparseArray;
import android.util.SparseArray;
import android.util.StateSet;
@ -1520,56 +1521,57 @@ public class Theme {
}
if (!isDarkTheme) {
int outBubble;
if (isDarkTheme) {
outBubble = averageColor(currentColors, key_chat_outBubbleGradient1, key_chat_outBubbleGradient2, key_chat_outBubbleGradient3);
} else if (currentColors.containsKey(key_chat_outBubble)) {
outBubble = currentColors.get(key_chat_outBubble);
} else {
outBubble = getColor(key_chat_outBubble);
}
int inBubbleSelected;
if (currentColors.containsKey(key_chat_inBubbleSelected)) {
inBubbleSelected = currentColors.get(key_chat_inBubbleSelected);
} else {
inBubbleSelected = getColor(key_chat_inBubbleSelected);
}
int gradientAverageColor = 0;
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);
}
int selectedBackground = currentColors.containsKey(key_chat_selectedBackground) ? currentColors.get(key_chat_selectedBackground) : getColor(key_chat_selectedBackground);
selectedBackground = applyHue(selectedBackground, gradientAverageColor);
selectedBackground = darkenColor(selectedBackground, .1f);
selectedBackground = Color.argb((int) (Color.alpha(selectedBackground) * 0.8f), Color.red(selectedBackground), Color.green(selectedBackground), Color.blue(selectedBackground));
currentColors.put(key_chat_selectedBackground, selectedBackground);
int outBubbleOverlay = bubbleSelectedOverlay(outBubble);
currentColors.put(key_chat_outBubbleGradientSelectedOverlay, outBubbleOverlay);
inBubbleSelected = applyHue(inBubbleSelected, gradientAverageColor);
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,
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);
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));
currentColors.put(key_chat_outTimeSelectedText, shiftHSV(outTimeSelected, .02f, .01f, contrast < 1.9d ? -.1f : 0f));
// currentColors.put(key_chat_outTimeSelectedText, applyHue(outTimeSelected, gradientAverageColor));
currentColors.remove(key_chat_selectedBackground);
// int outBubble;
// if (isDarkTheme) {
// outBubble = averageColor(currentColors, key_chat_outBubbleGradient1, key_chat_outBubbleGradient2, key_chat_outBubbleGradient3);
// } else if (currentColors.containsKey(key_chat_outBubble)) {
// outBubble = currentColors.get(key_chat_outBubble);
// } else {
// outBubble = getColor(key_chat_outBubble);
// }
// int inBubbleSelected;
// if (currentColors.containsKey(key_chat_inBubbleSelected)) {
// inBubbleSelected = currentColors.get(key_chat_inBubbleSelected);
// } else {
// inBubbleSelected = getColor(key_chat_inBubbleSelected);
// }
// int gradientAverageColor = 0;
// 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);
// }
// int selectedBackground = currentColors.containsKey(key_chat_selectedBackground) ? currentColors.get(key_chat_selectedBackground) : getColor(key_chat_selectedBackground);
// selectedBackground = applyHue(selectedBackground, gradientAverageColor);
// selectedBackground = darkenColor(selectedBackground, .1f);
// selectedBackground = Color.argb((int) (Color.alpha(selectedBackground) * 0.8f), Color.red(selectedBackground), Color.green(selectedBackground), Color.blue(selectedBackground));
// currentColors.put(key_chat_selectedBackground, selectedBackground);
// int outBubbleOverlay = bubbleSelectedOverlay(outBubble);
// currentColors.put(key_chat_outBubbleGradientSelectedOverlay, outBubbleOverlay);
//
// inBubbleSelected = applyHue(inBubbleSelected, gradientAverageColor);
// 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,
// 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);
// 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));
// currentColors.put(key_chat_outTimeSelectedText, shiftHSV(outTimeSelected, .02f, .01f, contrast < 1.9d ? -.1f : 0f));
//// currentColors.put(key_chat_outTimeSelectedText, applyHue(outTimeSelected, gradientAverageColor));
}
return !isMyMessagesGradientColorsNear;
@ -3864,6 +3866,7 @@ public class Theme {
public static final String key_paint_chatActionBackground = "paintChatActionBackground";
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_chatBotButton = "paintChatBotButton";
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)) {
chat_actionBackgroundPaint.setShader(serviceBitmapShader);
chat_actionBackgroundSelectedPaint.setShader(serviceBitmapShader);
ColorMatrix colorMatrix = new ColorMatrix();
colorMatrix.setSaturation(((MotionBackgroundDrawable) drawable).getIntensity() >= 0 ? 1.8f : 0.5f);
chat_actionBackgroundPaint.setColorFilter(new ColorMatrixColorFilter(colorMatrix));
chat_actionBackgroundPaint.setAlpha(127);
chat_actionBackgroundSelectedPaint.setShader(serviceBitmapShader);
chat_actionBackgroundSelectedPaint.setColorFilter(new ColorMatrixColorFilter(colorMatrix));
chat_actionBackgroundSelectedPaint.setAlpha(200);
} else {

View file

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

View file

@ -557,6 +557,9 @@ public class CacheControlActivity extends BaseFragment {
SQLiteDatabase database = MessagesStorage.getInstance(currentAccount).getDatabase();
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");
StringBuilder ids = new StringBuilder();
while (cursor.next()) {

View file

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

View file

@ -27,6 +27,7 @@ import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.Color;
@ -61,6 +62,7 @@ import android.text.TextUtils;
import android.text.style.CharacterStyle;
import android.text.style.ForegroundColorSpan;
import android.text.style.URLSpan;
import android.util.Log;
import android.util.Property;
import android.util.SparseArray;
import android.util.SparseIntArray;
@ -257,7 +259,9 @@ import org.telegram.ui.Delegates.ChatActivityMemberRequestsDelegate;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.InputStream;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.Arrays;
@ -2070,8 +2074,10 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
pinchToZoomHelper.clear();
}
chatThemeBottomSheet = null;
ActionBarLayout parentLayout = getParentLayout();
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;
}
@ -4504,76 +4510,94 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
} else if (child instanceof ChatMessageCell) {
ChatMessageCell cell = (ChatMessageCell) child;
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()) {
canvas.save();
canvas.translate(cell.getX(), cell.getY());
if (cell.getScaleX() != 1f) {
canvas.scale(
cell.getScaleX(), cell.getScaleY(),
cell.getPivotX(), (cell.getHeight() >> 1)
cell.getScaleX(), cell.getScaleY(),
cell.getPivotX(), (cell.getHeight() >> 1)
);
}
cell.drawBackgroundInternal(canvas, true);
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) {
ChatActionCell cell = (ChatActionCell) child;
if (cell.hasGradientService()) {
@ -8679,12 +8703,18 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
private void addToPulledDialogsMyself() {
if (getParentLayout() == null) {
return;
}
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) {
if (getParentLayout() == null) {
return;
}
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) {
@ -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);
entry.caption = caption;
cameraPhoto.add(entry);
PhotoViewer.getInstance().openPhotoForSelect(cameraPhoto, 0, 2, false, new PhotoViewer.EmptyPhotoViewerProvider() {
PhotoViewer.getInstance().openPhotoForSelect(cameraPhoto, 0, 0, false, new PhotoViewer.EmptyPhotoViewerProvider() {
@Override
public ImageReceiver.BitmapHolder getThumbForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation, int index) {
return new ImageReceiver.BitmapHolder(thumb, null, 0);
@ -13679,6 +13709,23 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
path = photoInfo.path;
} else if (photoInfo.uri != null) {
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 {
continue;
}
@ -13700,57 +13747,56 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
} catch (Exception 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) {
entry.caption = caption;
}
entries.add(entry);
}
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 {
if (entries.isEmpty()) {
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) {
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, () -> {
hideActionMode();
updatePinnedMessageView(true);
}, () -> dimBehindView(false), themeDelegate);
}, null, themeDelegate);
}
private void hideActionMode() {
@ -27142,6 +27188,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
startServiceBitmap = ((MotionBackgroundDrawable) backgroundDrawable).getBitmap();
}
startServiceColor = currentServiceColor;
startSelectedBackgroundColor = currentSelectedBackgroundColor;
startServiceTextColor = drawServiceGradient ? 0xffffffff : getCurrentColorOrDefault(Theme.key_chat_serviceText, true);
startServiceLinkColor = 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 startServiceIconColor;
int startServiceColor;
int startSelectedBackgroundColor;
Bitmap startServiceBitmap;
int currentServiceColor;
int currentSelectedBackgroundColor;
boolean drawServiceGradient;
private void initServiceMessageColors(Drawable backgroundDrawable) {
@ -27384,11 +27433,16 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
int currentServiceMessageColor = result[0];
Integer serviceColor = getCurrentColor(Theme.key_chat_serviceBackground);
Integer selectedBackgroundColor = getCurrentColor(Theme.key_chat_selectedBackground);
Integer serviceColor2 = serviceColor;
if (serviceColor == null) {
serviceColor = currentServiceMessageColor;
}
if (selectedBackgroundColor == null) {
selectedBackgroundColor = currentServiceMessageColor;
}
currentServiceColor = serviceColor;
currentSelectedBackgroundColor = selectedBackgroundColor;
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 actionBackgroundSelectedPaint = getPaint(Theme.key_paint_chatActionBackgroundSelected);
Paint msgBackgroundSelectedPaint = getPaint(Theme.key_paint_chatMessageBackgroundSelected);
if (actionBackgroundPaint != null) {
if (drawServiceGradient) {
ColorMatrix colorMatrix = new ColorMatrix();
colorMatrix.setSaturation(((MotionBackgroundDrawable) backgroundDrawable).getIntensity() >= 0 ? 1.8f : 0.5f);
actionBackgroundPaint.setAlpha(127);
actionBackgroundPaint.setColorFilter(new ColorMatrixColorFilter(colorMatrix));
actionBackgroundPaint.setShader(serviceShaderSource);
actionBackgroundSelectedPaint.setAlpha(127);
actionBackgroundSelectedPaint.setColorFilter(new ColorMatrixColorFilter(colorMatrix));
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 {
actionBackgroundPaint.setColorFilter(null);
actionBackgroundPaint.setShader(null);
actionBackgroundSelectedPaint.setColorFilter(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 actionBackgroundSelectedPaint = getPaint(Theme.key_paint_chatActionBackgroundSelected);
Paint msgBackgroundSelectedPaint = getPaint(Theme.key_paint_chatMessageBackgroundSelected);
int serviceColor = currentServiceColor;
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);
actionBackgroundSelectedPaint.setShader(serviceShader);
}
if (msgBackgroundSelectedPaint != null) {
msgBackgroundSelectedPaint.setShader(serviceShader);
}
} else {
useSourceShader = true;
serviceCanvas.drawBitmap(serviceBitmapSource, 0, 0, null);
@ -27491,7 +27567,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
actionBackgroundPaint.setShader(serviceShaderSource);
actionBackgroundSelectedPaint.setShader(serviceShaderSource);
}
if (msgBackgroundSelectedPaint != null) {
msgBackgroundSelectedPaint.setShader(serviceShaderSource);
}
}
}
}

View file

@ -41,22 +41,25 @@ public class BackButtonMenu {
int folderId;
int filterId;
}
private static HashMap<Integer, ArrayList<PulledDialog>> pulledDialogs;
public static ActionBarPopupWindow show(BaseFragment fragment, View backButton, long currentDialogId) {
if (fragment == null) {
public static ActionBarPopupWindow show(BaseFragment thisFragment, View backButton, long currentDialogId) {
if (thisFragment == null) {
return null;
}
final ActionBarLayout parentLayout = fragment.getParentLayout();
ArrayList<PulledDialog> dialogs = getStackedHistoryDialogs(fragment.getCurrentAccount(), parentLayout == null ? null : parentLayout.fragmentsStack, currentDialogId);
final ActionBarLayout parentLayout = thisFragment.getParentLayout();
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) {
return null;
}
Context context = fragment.getParentActivity();
ActionBarPopupWindow.ActionBarPopupWindowLayout layout = new ActionBarPopupWindow.ActionBarPopupWindowLayout(context);
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);
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));
}
@ -163,21 +166,18 @@ public class BackButtonMenu {
scrimPopupWindow.getContentView().setFocusableInTouchMode(true);
layout.setFitItems(true);
View fragmentView = fragment.getFragmentView();
if (fragmentView != null) {
int popupX = AndroidUtilities.dp(8) - backgroundPaddings.left;
if (AndroidUtilities.isTablet()) {
int[] location = new int[2];
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 popupX = AndroidUtilities.dp(8) - backgroundPaddings.left;
if (AndroidUtilities.isTablet()) {
int[] location = new int[2];
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) {}
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<>();
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) {
final int count = fragmentsStack.size();
for (int i = 0; i < count; ++i) {
@ -263,46 +270,42 @@ public class BackButtonMenu {
}
}
if (pulledDialogs != null) {
ArrayList<PulledDialog> pulledDialogsAccount = pulledDialogs.get(account);
if (pulledDialogsAccount != null) {
for (PulledDialog pulledDialog : pulledDialogsAccount) {
if (pulledDialog.dialogId == ignoreDialogId) {
continue;
}
boolean alreadyAddedDialog = false;
for (int d = 0; d < dialogs.size(); ++d) {
if (dialogs.get(d).dialogId == pulledDialog.dialogId) {
alreadyAddedDialog = true;
break;
}
}
if (!alreadyAddedDialog) {
dialogs.add(pulledDialog);
for (PulledDialog pulledDialog : pulledDialogs) {
if (pulledDialog.dialogId == ignoreDialogId) {
continue;
}
boolean alreadyAddedDialog = false;
for (int d = 0; d < dialogs.size(); ++d) {
if (dialogs.get(d).dialogId == pulledDialog.dialogId) {
alreadyAddedDialog = true;
break;
}
}
if (!alreadyAddedDialog) {
dialogs.add(pulledDialog);
}
}
}
Collections.sort(dialogs, (d1, d2) -> d2.stackIndex - d1.stackIndex);
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) {
return;
}
if (pulledDialogs == null) {
pulledDialogs = new HashMap<>();
if (thisFragment == null) {
return;
}
ArrayList<PulledDialog> dialogs = null;
if (pulledDialogs.containsKey(account)) {
dialogs = pulledDialogs.get(account);
final ActionBarLayout parentLayout = thisFragment.getParentLayout();
if (parentLayout == null) {
return;
}
if (dialogs == null) {
pulledDialogs.put(account, dialogs = new ArrayList<>());
if (parentLayout.pulledDialogs == null) {
parentLayout.pulledDialogs = new ArrayList<>();
}
boolean alreadyAdded = false;
for (PulledDialog d : dialogs) {
for (PulledDialog d : parentLayout.pulledDialogs) {
if (d.dialogId == dialogId) {
alreadyAdded = true;
break;
@ -318,18 +321,22 @@ public class BackButtonMenu {
d.folderId = folderId;
d.chat = chat;
d.user = user;
dialogs.add(d);
parentLayout.pulledDialogs.add(d);
}
}
public static void clearPulledDialogs(int account, int fromIndex) {
if (pulledDialogs != null && pulledDialogs.containsKey(account)) {
ArrayList<PulledDialog> dialogs = pulledDialogs.get(account);
if (dialogs != null) {
for (int i = 0; i < dialogs.size(); ++i) {
if (dialogs.get(i).stackIndex > fromIndex) {
dialogs.remove(i);
i--;
}
public static void clearPulledDialogs(BaseFragment thisFragment, int fromIndex) {
if (thisFragment == null) {
return;
}
final ActionBarLayout parentLayout = thisFragment.getParentLayout();
if (parentLayout == null) {
return;
}
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 {
private Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
private Paint customPaint = null;
private long lastAnimationTime;
private float currentAnimationProgress;
private boolean isSelected;
@ -33,6 +34,10 @@ public class MessageBackgroundDrawable extends Drawable {
paint.setColor(color);
}
public void setCustomPaint(Paint paint) {
this.customPaint = paint;
}
public void setSelected(boolean selected, boolean animated) {
if (isSelected == selected) {
if (animationInProgress != animated && !animated) {
@ -125,7 +130,7 @@ public class MessageBackgroundDrawable extends Drawable {
@Override
public void draw(Canvas canvas) {
if (currentAnimationProgress == 1.0f) {
canvas.drawRect(getBounds(), paint);
canvas.drawRect(getBounds(), customPaint != null ? customPaint : paint);
} else if (currentAnimationProgress != 0.0f) {
float interpolatedProgress;
if (isSelected) {
@ -150,7 +155,7 @@ public class MessageBackgroundDrawable extends Drawable {
}
x1 = centerX + (1.0f - interpolatedProgress) * (x1 - centerX);
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) {
long newTime = SystemClock.elapsedRealtime();

View file

@ -43,6 +43,7 @@ import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Vibrator;
import android.text.TextPaint;
import android.text.TextUtils;
import android.util.Property;
import android.util.StateSet;
@ -59,9 +60,11 @@ import android.view.ViewOutlineProvider;
import android.view.ViewParent;
import android.view.ViewTreeObserver;
import android.view.WindowManager;
import android.view.accessibility.AccessibilityNodeInfo;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.Interpolator;
import android.widget.Button;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.ImageView;
@ -289,8 +292,15 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
private RecyclerView sideMenu;
private ChatActivityEnterView commentView;
private ImageView[] writeButton;
private FrameLayout writeButtonContainer;
private View selectedCountView;
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 fragmentContextView;
@ -347,6 +357,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
private DialogsActivityDelegate delegate;
private ArrayList<Long> selectedDialogs = new ArrayList<>();
public boolean notify = true;
private int canReadCount;
private int canPinCount;
@ -3218,6 +3229,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
commentView.setAllowStickersAndGifs(false, false);
commentView.setForceShowSendButton(true, false);
commentView.setVisibility(View.GONE);
commentView.getSendButton().setAlpha(0);
contentView.addView(commentView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.BOTTOM));
commentView.setDelegate(new ChatActivityEnterView.ChatActivityEnterViewDelegate() {
@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) {
@ -6211,6 +6316,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
doneItemAnimator.start();
}
private boolean isNextButton = false;
private void updateSelectedCount() {
if (commentView != null) {
if (selectedDialogs.isEmpty()) {
@ -6223,13 +6329,22 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
commentView.hidePopup(false);
commentView.closeKeyboard();
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.setInterpolator(new DecelerateInterpolator());
animatorSet.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
commentView.setVisibility(View.GONE);
writeButtonContainer.setVisibility(View.GONE);
}
});
animatorSet.start();
@ -6237,11 +6352,21 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
fragmentView.requestLayout();
}
} else {
selectedCountView.invalidate();
if (commentView.getTag() == null) {
commentView.setFieldText("");
commentView.setVisibility(View.VISIBLE);
writeButtonContainer.setVisibility(View.VISIBLE);
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.setInterpolator(new DecelerateInterpolator());
animatorSet.addListener(new AnimatorListenerAdapter() {
@ -6259,6 +6384,10 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
} else if (initialDialogsType == 10) {
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)
@ -6888,6 +7017,9 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
public void setDelegate(DialogsActivityDelegate dialogsActivityDelegate) {
delegate = dialogsActivityDelegate;
}
public boolean shouldShowNextButton(DialogsActivity fragment, ArrayList<Long> dids, CharSequence message, boolean param) {
return false;
}
public void setSearchString(String string) {
searchString = string;
@ -7052,6 +7184,87 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
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
public ArrayList<ThemeDescription> getThemeDescriptions() {
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_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_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));

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("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);
boolean removeLast;
if (AndroidUtilities.isTablet()) {
@ -3836,6 +3856,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
}
} else {
boolean notify = dialogsFragment == null || dialogsFragment.notify;
final ChatActivity fragment;
if (dids.size() <= 1) {
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()) {
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) {
actionBarLayout.presentFragment(fragment, true, false, true, false);
}
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);
@ -3906,7 +3927,8 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
AccountInstance accountInstance = AccountInstance.getInstance(UserConfig.selectedAccount);
boolean photosEditorOpened = false;
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) {
fragment.openVideoEditor(videoPath, sendingText);
sendingText = null;
@ -3924,7 +3946,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
}
ArrayList<String> arrayList = new ArrayList<>();
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) {
@ -3932,14 +3954,14 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
photoPathsArray.get(0).caption = sendingText;
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 (sendingText != null && sendingText.length() <= 1024 && ((documentsPathsArray != null ? documentsPathsArray.size() : 0) + (documentsUrisArray != null ? documentsUrisArray.size() : 0)) == 1) {
captionToSend = sendingText;
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) {
SendMessagesHelper.prepareSendingText(accountInstance, sendingText, did, true, 0);
@ -3947,11 +3969,11 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
if (contactsToSend != null && !contactsToSend.isEmpty()) {
for (int a = 0; a < contactsToSend.size(); 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)) {
SendMessagesHelper.prepareSendingText(accountInstance, message.toString(), did, true, 0);
SendMessagesHelper.prepareSendingText(accountInstance, message.toString(), did, notify, 0);
}
}
}