Update to 5.15.0 (1864)

This commit is contained in:
DrKLO 2020-02-13 21:26:53 +03:00
parent 7d6fa267c1
commit 2eafc07314
145 changed files with 9119 additions and 2468 deletions

View file

@ -22,7 +22,7 @@ dependencies {
compileOnly 'org.checkerframework:checker-qual:2.5.2'
compileOnly 'org.checkerframework:checker-compat-qual:2.5.0'
implementation 'com.google.firebase:firebase-messaging:20.1.0'
implementation 'com.google.firebase:firebase-config:19.1.0'
implementation 'com.google.firebase:firebase-config:19.1.1'
implementation 'com.google.android.gms:play-services-maps:17.0.0'
implementation 'com.google.android.gms:play-services-auth:17.0.0'
implementation 'com.google.android.gms:play-services-vision:16.2.0'
@ -283,7 +283,7 @@ android {
}
}
defaultConfig.versionCode = 1851
defaultConfig.versionCode = 1864
applicationVariants.all { variant ->
variant.outputs.all { output ->
@ -318,7 +318,7 @@ android {
defaultConfig {
minSdkVersion 16
targetSdkVersion 28
versionName "5.14.0"
versionName "5.15.0"
vectorDrawables.generatedDensities = ['mdpi', 'hdpi', 'xhdpi', 'xxhdpi']

View file

@ -3301,18 +3301,29 @@ void ConnectionsManager::setSystemLangCode(std::string langCode) {
void ConnectionsManager::resumeNetwork(bool partial) {
scheduleTask([&, partial] {
if (lastMonotonicPauseTime != 0) {
int64_t diff = (getCurrentTimeMonotonicMillis() - lastMonotonicPauseTime) / 1000;
int64_t systemDiff = getCurrentTime() - lastSystemPauseTime;
if (systemDiff < 0 || abs(systemDiff - diff) > 2) {
timeDifference -= (systemDiff - diff);
}
}
if (partial) {
if (networkPaused) {
lastPauseTime = getCurrentTimeMonotonicMillis();
lastMonotonicPauseTime = lastPauseTime = getCurrentTimeMonotonicMillis();
lastSystemPauseTime = getCurrentTime();
networkPaused = false;
if (LOGS_ENABLED) DEBUG_D("wakeup network in background account%u", instanceNum);
} else if (lastPauseTime != 0) {
lastPauseTime = getCurrentTimeMonotonicMillis();
lastMonotonicPauseTime = lastPauseTime = getCurrentTimeMonotonicMillis();
lastSystemPauseTime = getCurrentTime();
networkPaused = false;
if (LOGS_ENABLED) DEBUG_D("reset sleep timeout account%u", instanceNum);
}
} else {
lastPauseTime = 0;
lastMonotonicPauseTime = 0;
lastSystemPauseTime = 0;
networkPaused = false;
if (LOGS_ENABLED) DEBUG_D("wakeup network account%u", instanceNum);
}
@ -3332,7 +3343,8 @@ void ConnectionsManager::pauseNetwork() {
if (lastPauseTime != 0) {
return;
}
lastPauseTime = getCurrentTimeMonotonicMillis();
lastMonotonicPauseTime = lastPauseTime = getCurrentTimeMonotonicMillis();
lastSystemPauseTime = getCurrentTime();
}
void ConnectionsManager::setNetworkAvailable(bool value, int32_t type, bool slow) {

View file

@ -161,6 +161,8 @@ private:
bool networkPaused = false;
int32_t nextSleepTimeout = CONNECTION_BACKGROUND_KEEP_TIME;
int64_t lastPauseTime = 0;
int64_t lastMonotonicPauseTime = 0;
int32_t lastSystemPauseTime = 0;
ConnectionState connectionState = ConnectionStateConnecting;
std::unique_ptr<ByteArray> movingAuthorization;
std::vector<int64_t> sessionsToDestroy;

View file

@ -15,7 +15,9 @@ import android.view.View;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.LinearInterpolator;
public class LinearSmoothScrollerMiddle extends RecyclerView.SmoothScroller {
import org.telegram.messenger.AndroidUtilities;
public class LinearSmoothScrollerCustom extends RecyclerView.SmoothScroller {
private static final float MILLISECONDS_PER_INCH = 25f;
@ -32,9 +34,14 @@ public class LinearSmoothScrollerMiddle extends RecyclerView.SmoothScroller {
private final float MILLISECONDS_PER_PX;
protected int mInterimTargetDx = 0, mInterimTargetDy = 0;
private int scrollPosition;
public LinearSmoothScrollerMiddle(Context context) {
public static final int POSITION_MIDDLE = 0;
public static final int POSITION_END = 1;
public LinearSmoothScrollerCustom(Context context, int position) {
MILLISECONDS_PER_PX = MILLISECONDS_PER_INCH / context.getResources().getDisplayMetrics().densityDpi;
scrollPosition = position;
}
@Override
@ -80,7 +87,6 @@ public class LinearSmoothScrollerMiddle extends RecyclerView.SmoothScroller {
}
protected void updateActionForInterimTarget(Action action) {
// find an interim target position
PointF scrollVector = computeScrollVectorForPosition(getTargetPosition());
if (scrollVector == null || (scrollVector.x == 0 && scrollVector.y == 0)) {
final int target = getTargetPosition();
@ -94,12 +100,7 @@ public class LinearSmoothScrollerMiddle extends RecyclerView.SmoothScroller {
mInterimTargetDx = (int) (TARGET_SEEK_SCROLL_DISTANCE_PX * scrollVector.x);
mInterimTargetDy = (int) (TARGET_SEEK_SCROLL_DISTANCE_PX * scrollVector.y);
final int time = calculateTimeForScrolling(TARGET_SEEK_SCROLL_DISTANCE_PX);
// To avoid UI hiccups, trigger a smooth scroll to a distance little further than the
// interim target. Since we track the distance travelled in onSeekTargetStep callback, it
// won't actually scroll more than what we need.
action.update((int) (mInterimTargetDx * TARGET_SEEK_EXTRA_SCROLL_RATIO)
, (int) (mInterimTargetDy * TARGET_SEEK_EXTRA_SCROLL_RATIO)
, (int) (time * TARGET_SEEK_EXTRA_SCROLL_RATIO), mLinearInterpolator);
action.update((int) (mInterimTargetDx * TARGET_SEEK_EXTRA_SCROLL_RATIO), (int) (mInterimTargetDy * TARGET_SEEK_EXTRA_SCROLL_RATIO), (int) (time * TARGET_SEEK_EXTRA_SCROLL_RATIO), mLinearInterpolator);
}
private int clampApplyScroll(int tmpDt, int dt) {
@ -126,8 +127,10 @@ public class LinearSmoothScrollerMiddle extends RecyclerView.SmoothScroller {
int viewSize = bottom - top;
if (viewSize > boxSize) {
start = 0;
} else {
} else if (scrollPosition == POSITION_MIDDLE) {
start = (boxSize - viewSize) / 2;
} else {
start = (layoutManager.getPaddingTop() - AndroidUtilities.dp(88));
}
end = start + viewSize;
final int dtStart = start - top;

View file

@ -575,7 +575,7 @@ public class RecyclerView extends ViewGroup implements ScrollingView,
private int topGlowOffset = 0;
private int bottomGlowOffset = 0;
private int glowColor = 0;
private Integer glowColor = null;
public void setTopGlowOffset(int offset) {
topGlowOffset = offset;
@ -620,7 +620,7 @@ public class RecyclerView extends ViewGroup implements ScrollingView,
}
void applyEdgeEffectColor(EdgeEffect edgeEffect) {
if (edgeEffect != null && Build.VERSION.SDK_INT >= 21 && glowColor != 0) {
if (edgeEffect != null && Build.VERSION.SDK_INT >= 21 && glowColor != null) {
edgeEffect.setColor(glowColor);
}
}
@ -4362,42 +4362,44 @@ public class RecyclerView extends ViewGroup implements ScrollingView,
// TODO If padding is not 0 and clipChildrenToPadding is false, to draw glows properly, we
// need find children closest to edges. Not sure if it is worth the effort.
boolean needsInvalidate = false;
if (mLeftGlow != null && !mLeftGlow.isFinished()) {
final int restore = c.save();
final int padding = mClipToPadding ? getPaddingBottom() : 0;
c.rotate(270);
c.translate(-getHeight() + padding, 0);
needsInvalidate = mLeftGlow != null && mLeftGlow.draw(c);
c.restoreToCount(restore);
}
if (mTopGlow != null && !mTopGlow.isFinished()) {
final int restore = c.save();
if (mClipToPadding) {
c.translate(getPaddingLeft(), getPaddingTop());
if (glowColor == null || glowColor != 0) {
if (mLeftGlow != null && !mLeftGlow.isFinished()) {
final int restore = c.save();
final int padding = mClipToPadding ? getPaddingBottom() : 0;
c.rotate(270);
c.translate(-getHeight() + padding, 0);
needsInvalidate = mLeftGlow != null && mLeftGlow.draw(c);
c.restoreToCount(restore);
}
c.translate(0, topGlowOffset);
needsInvalidate |= mTopGlow != null && mTopGlow.draw(c);
c.restoreToCount(restore);
}
if (mRightGlow != null && !mRightGlow.isFinished()) {
final int restore = c.save();
final int width = getWidth();
final int padding = mClipToPadding ? getPaddingTop() : 0;
c.rotate(90);
c.translate(-padding, -width);
needsInvalidate |= mRightGlow != null && mRightGlow.draw(c);
c.restoreToCount(restore);
}
if (mBottomGlow != null && !mBottomGlow.isFinished()) {
final int restore = c.save();
c.rotate(180);
if (mClipToPadding) {
c.translate(-getWidth() + getPaddingRight(), -getHeight() + getPaddingBottom());
} else {
c.translate(-getWidth(), -getHeight() + bottomGlowOffset);
if (mTopGlow != null && !mTopGlow.isFinished()) {
final int restore = c.save();
if (mClipToPadding) {
c.translate(getPaddingLeft(), getPaddingTop());
}
c.translate(0, topGlowOffset);
needsInvalidate |= mTopGlow != null && mTopGlow.draw(c);
c.restoreToCount(restore);
}
if (mRightGlow != null && !mRightGlow.isFinished()) {
final int restore = c.save();
final int width = getWidth();
final int padding = mClipToPadding ? getPaddingTop() : 0;
c.rotate(90);
c.translate(-padding, -width);
needsInvalidate |= mRightGlow != null && mRightGlow.draw(c);
c.restoreToCount(restore);
}
if (mBottomGlow != null && !mBottomGlow.isFinished()) {
final int restore = c.save();
c.rotate(180);
if (mClipToPadding) {
c.translate(-getWidth() + getPaddingRight(), -getHeight() + getPaddingBottom());
} else {
c.translate(-getWidth(), -getHeight() + bottomGlowOffset);
}
needsInvalidate |= mBottomGlow != null && mBottomGlow.draw(c);
c.restoreToCount(restore);
}
needsInvalidate |= mBottomGlow != null && mBottomGlow.draw(c);
c.restoreToCount(restore);
}
// If some views are animating, ItemDecorators are likely to move/change with them.

View file

@ -395,21 +395,29 @@ public class AndroidUtilities {
return media ? documentMediaIcons[0] : documentIcons[0];
}
public static int calcBitmapColor(Bitmap bitmap) {
try {
Bitmap b = Bitmaps.createScaledBitmap(bitmap, 1, 1, true);
if (b != null) {
int bitmapColor = b.getPixel(0, 0);
if (bitmap != b) {
b.recycle();
}
return bitmapColor;
}
} catch (Exception e) {
FileLog.e(e);
}
return 0;
}
public static int[] calcDrawableColor(Drawable drawable) {
int bitmapColor = 0xff000000;
int[] result = new int[4];
try {
if (drawable instanceof BitmapDrawable) {
Bitmap bitmap = ((BitmapDrawable) drawable).getBitmap();
if (bitmap != null) {
Bitmap b = Bitmaps.createScaledBitmap(bitmap, 1, 1, true);
if (b != null) {
bitmapColor = b.getPixel(0, 0);
if (bitmap != b) {
b.recycle();
}
}
}
bitmapColor = calcBitmapColor(bitmap);
} else if (drawable instanceof ColorDrawable) {
bitmapColor = ((ColorDrawable) drawable).getColor();
} else if (drawable instanceof BackgroundGradientDrawable) {
@ -516,7 +524,7 @@ public class AndroidUtilities {
}
public static void requestAdjustResize(Activity activity, int classGuid) {
if (activity == null || isTablet()) {
if (activity == null || isTablet() || SharedConfig.smoothKeyboard) {
return;
}
activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
@ -533,7 +541,7 @@ public class AndroidUtilities {
}
public static void removeAdjustResize(Activity activity, int classGuid) {
if (activity == null || isTablet()) {
if (activity == null || isTablet() || SharedConfig.smoothKeyboard) {
return;
}
if (adjustOwnerClassGuid == classGuid) {

View file

@ -19,8 +19,8 @@ public class BuildVars {
public static boolean USE_CLOUD_STRINGS = true;
public static boolean CHECK_UPDATES = true;
public static boolean TON_WALLET_STANDALONE = false;
public static int BUILD_VERSION = 1851;
public static String BUILD_VERSION_STRING = "5.14.0";
public static int BUILD_VERSION = 1864;
public static String BUILD_VERSION_STRING = "5.15.0";
public static int APP_ID = 4;
public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103";
public static String HOCKEY_APP_HASH = "a5b5c4f551dadedc9918d9766a22ca7c";

View file

@ -793,6 +793,10 @@ public class EmojiData {
public static final HashSet<String> emojiBigColoredMap = new HashSet<>(emojiBigColored.length);
public static final HashMap<CharSequence, CharSequence> emojiAliasMap = new HashMap<>(aliasNew.length);
public static boolean isHeartEmoji(String emoji) {
return "".equals(emoji) || "🧡".equals(emoji) || "💛".equals(emoji) || "💚".equals(emoji) || "💙".equals(emoji) || "💜".equals(emoji) || "🖤".equals(emoji) || "🤍".equals(emoji) || "🤎".equals(emoji);
}
static {
for (int a = 0; a < emojiToFE0F.length; a++) {
emojiToFE0FMap.put(emojiToFE0F[a], true);

View file

@ -2661,7 +2661,7 @@ public class LocaleController {
public int quantityForNumber(int count) {
if (count == 0) {
return QUANTITY_ZERO;
} else if (count > 0 && count < 2) {
} else if (count == 1) {
return QUANTITY_ONE;
} else {
return QUANTITY_OTHER;

View file

@ -64,6 +64,7 @@ public class LocationController extends BaseController implements NotificationCe
private SparseIntArray requests = new SparseIntArray();
private LongSparseArray<Boolean> cacheRequests = new LongSparseArray<>();
private long locationEndWatchTime;
private boolean shareMyCurrentLocation;
private boolean lookingForPeopleNearby;
@ -316,7 +317,7 @@ public class LocationController extends BaseController implements NotificationCe
if (!permissionsGranted) {
playServicesAvailable = false;
}
if (lookingForPeopleNearby || !sharingLocations.isEmpty()) {
if (shareMyCurrentLocation || lookingForPeopleNearby || !sharingLocations.isEmpty()) {
if (permissionsGranted) {
try {
setLastKnownLocation(LocationServices.FusedLocationApi.getLastLocation(googleApiClient));
@ -369,69 +370,86 @@ public class LocationController extends BaseController implements NotificationCe
}
requests.clear();
}
int date = getConnectionsManager().getCurrentTime();
float[] result = new float[1];
for (int a = 0; a < sharingLocations.size(); a++) {
final SharingLocationInfo info = sharingLocations.get(a);
if (info.messageObject.messageOwner.media != null && info.messageObject.messageOwner.media.geo != null) {
int messageDate = info.messageObject.messageOwner.edit_date != 0 ? info.messageObject.messageOwner.edit_date : info.messageObject.messageOwner.date;
TLRPC.GeoPoint point = info.messageObject.messageOwner.media.geo;
if (Math.abs(date - messageDate) < 10) {
Location.distanceBetween(point.lat, point._long, lastKnownLocation.getLatitude(), lastKnownLocation.getLongitude(), result);
if (result[0] < 1.0f) {
continue;
if (!sharingLocations.isEmpty()) {
int date = getConnectionsManager().getCurrentTime();
float[] result = new float[1];
for (int a = 0; a < sharingLocations.size(); a++) {
final SharingLocationInfo info = sharingLocations.get(a);
if (info.messageObject.messageOwner.media != null && info.messageObject.messageOwner.media.geo != null) {
int messageDate = info.messageObject.messageOwner.edit_date != 0 ? info.messageObject.messageOwner.edit_date : info.messageObject.messageOwner.date;
TLRPC.GeoPoint point = info.messageObject.messageOwner.media.geo;
if (Math.abs(date - messageDate) < 10) {
Location.distanceBetween(point.lat, point._long, lastKnownLocation.getLatitude(), lastKnownLocation.getLongitude(), result);
if (result[0] < 1.0f) {
continue;
}
}
}
TLRPC.TL_messages_editMessage req = new TLRPC.TL_messages_editMessage();
req.peer = getMessagesController().getInputPeer((int) info.did);
req.id = info.mid;
req.flags |= 16384;
req.media = new TLRPC.TL_inputMediaGeoLive();
req.media.stopped = false;
req.media.geo_point = new TLRPC.TL_inputGeoPoint();
req.media.geo_point.lat = AndroidUtilities.fixLocationCoord(lastKnownLocation.getLatitude());
req.media.geo_point._long = AndroidUtilities.fixLocationCoord(lastKnownLocation.getLongitude());
final int[] reqId = new int[1];
reqId[0] = getConnectionsManager().sendRequest(req, (response, error) -> {
if (error != null) {
if (error.text.equals("MESSAGE_ID_INVALID")) {
sharingLocations.remove(info);
sharingLocationsMap.remove(info.did);
saveSharingLocation(info, 1);
requests.delete(reqId[0]);
AndroidUtilities.runOnUIThread(() -> {
sharingLocationsUI.remove(info);
sharingLocationsMapUI.remove(info.did);
if (sharingLocationsUI.isEmpty()) {
stopService();
}
NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.liveLocationsChanged);
});
}
return;
}
TLRPC.Updates updates = (TLRPC.Updates) response;
boolean updated = false;
for (int a1 = 0; a1 < updates.updates.size(); a1++) {
TLRPC.Update update = updates.updates.get(a1);
if (update instanceof TLRPC.TL_updateEditMessage) {
updated = true;
info.messageObject.messageOwner = ((TLRPC.TL_updateEditMessage) update).message;
} else if (update instanceof TLRPC.TL_updateEditChannelMessage) {
updated = true;
info.messageObject.messageOwner = ((TLRPC.TL_updateEditChannelMessage) update).message;
}
}
if (updated) {
saveSharingLocation(info, 0);
}
getMessagesController().processUpdates(updates, false);
});
requests.put(reqId[0], 0);
}
TLRPC.TL_messages_editMessage req = new TLRPC.TL_messages_editMessage();
req.peer = getMessagesController().getInputPeer((int) info.did);
req.id = info.mid;
req.flags |= 16384;
req.media = new TLRPC.TL_inputMediaGeoLive();
req.media.stopped = false;
req.media.geo_point = new TLRPC.TL_inputGeoPoint();
req.media.geo_point.lat = AndroidUtilities.fixLocationCoord(lastKnownLocation.getLatitude());
req.media.geo_point._long = AndroidUtilities.fixLocationCoord(lastKnownLocation.getLongitude());
final int[] reqId = new int[1];
reqId[0] = getConnectionsManager().sendRequest(req, (response, error) -> {
if (error != null) {
if (error.text.equals("MESSAGE_ID_INVALID")) {
sharingLocations.remove(info);
sharingLocationsMap.remove(info.did);
saveSharingLocation(info, 1);
requests.delete(reqId[0]);
AndroidUtilities.runOnUIThread(() -> {
sharingLocationsUI.remove(info);
sharingLocationsMapUI.remove(info.did);
if (sharingLocationsUI.isEmpty()) {
stopService();
}
NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.liveLocationsChanged);
});
}
return;
}
TLRPC.Updates updates = (TLRPC.Updates) response;
boolean updated = false;
for (int a1 = 0; a1 < updates.updates.size(); a1++) {
TLRPC.Update update = updates.updates.get(a1);
if (update instanceof TLRPC.TL_updateEditMessage) {
updated = true;
info.messageObject.messageOwner = ((TLRPC.TL_updateEditMessage) update).message;
} else if (update instanceof TLRPC.TL_updateEditChannelMessage) {
updated = true;
info.messageObject.messageOwner = ((TLRPC.TL_updateEditChannelMessage) update).message;
}
}
if (updated) {
saveSharingLocation(info, 0);
}
getMessagesController().processUpdates(updates, false);
}
if (shareMyCurrentLocation) {
UserConfig userConfig = getUserConfig();
userConfig.lastMyLocationShareTime = (int) (System.currentTimeMillis() / 1000);
userConfig.saveConfig(false);
TLRPC.TL_contacts_getLocated req = new TLRPC.TL_contacts_getLocated();
req.geo_point = new TLRPC.TL_inputGeoPoint();
req.geo_point.lat = lastKnownLocation.getLatitude();
req.geo_point._long = lastKnownLocation.getLongitude();
req.background = true;
getConnectionsManager().sendRequest(req, (response, error) -> {
});
requests.put(reqId[0], 0);
}
getConnectionsManager().resumeNetworkMaybe();
if (shouldStopGps()) {
if (shouldStopGps() || shareMyCurrentLocation) {
shareMyCurrentLocation = false;
stop(false);
}
}
@ -449,25 +467,28 @@ public class LocationController extends BaseController implements NotificationCe
}
protected void update() {
if (sharingLocations.isEmpty()) {
return;
UserConfig userConfig = getUserConfig();
if (ApplicationLoader.isScreenOn && !ApplicationLoader.mainInterfacePaused && !shareMyCurrentLocation && userConfig.sharingMyLocationUntil != 0 && Math.abs(System.currentTimeMillis() / 1000 - userConfig.lastMyLocationShareTime) >= 60 * 60) {
shareMyCurrentLocation = true;
}
for (int a = 0; a < sharingLocations.size(); a++) {
final SharingLocationInfo info = sharingLocations.get(a);
int currentTime = getConnectionsManager().getCurrentTime();
if (info.stopTime <= currentTime) {
sharingLocations.remove(a);
sharingLocationsMap.remove(info.did);
saveSharingLocation(info, 1);
AndroidUtilities.runOnUIThread(() -> {
sharingLocationsUI.remove(info);
sharingLocationsMapUI.remove(info.did);
if (sharingLocationsUI.isEmpty()) {
stopService();
}
NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.liveLocationsChanged);
});
a--;
if (!sharingLocations.isEmpty()) {
for (int a = 0; a < sharingLocations.size(); a++) {
final SharingLocationInfo info = sharingLocations.get(a);
int currentTime = getConnectionsManager().getCurrentTime();
if (info.stopTime <= currentTime) {
sharingLocations.remove(a);
sharingLocationsMap.remove(info.did);
saveSharingLocation(info, 1);
AndroidUtilities.runOnUIThread(() -> {
sharingLocationsUI.remove(info);
sharingLocationsMapUI.remove(info.did);
if (sharingLocationsUI.isEmpty()) {
stopService();
}
NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.liveLocationsChanged);
});
a--;
}
}
}
if (started) {
@ -480,8 +501,8 @@ public class LocationController extends BaseController implements NotificationCe
lastLocationSendTime = SystemClock.elapsedRealtime();
broadcastLastKnownLocation(cancelAll);
}
} else {
if (Math.abs(lastLocationSendTime - SystemClock.elapsedRealtime()) > BACKGROUD_UPDATE_TIME) {
} else if (!sharingLocations.isEmpty() || shareMyCurrentLocation) {
if (shareMyCurrentLocation || Math.abs(lastLocationSendTime - SystemClock.elapsedRealtime()) > BACKGROUD_UPDATE_TIME) {
lastLocationStartTime = SystemClock.elapsedRealtime();
start();
}
@ -826,7 +847,7 @@ public class LocationController extends BaseController implements NotificationCe
}
private void stop(boolean empty) {
if (lookingForPeopleNearby) {
if (lookingForPeopleNearby || shareMyCurrentLocation) {
return;
}
started = false;

View file

@ -2836,20 +2836,9 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
recordReplyingMessageObject = reply_to_msg;
}
private boolean shouldRequestRecordAudioFocus() {
try {
if (/*NotificationsController.audioManager.isWiredHeadsetOn() || */NotificationsController.audioManager.isBluetoothA2dpOn()) {
return false;
}
} catch (Throwable ignore) {
}
return true;
}
public void requestAudioFocus(boolean request) {
if (request) {
if (!hasRecordAudioFocus && shouldRequestRecordAudioFocus()) {
if (!hasRecordAudioFocus && SharedConfig.pauseMusicOnRecord) {
int result = NotificationsController.audioManager.requestAudioFocus(audioRecordFocusChangedListener, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN_TRANSIENT);
if (result == AudioManager.AUDIOFOCUS_REQUEST_GRANTED) {
hasRecordAudioFocus = true;

View file

@ -3564,6 +3564,9 @@ public class MessageObject {
} else {
spannable.setSpan(new URLSpanBrowser(url, run), run.start, run.end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
} else if (run.urlEntity instanceof TLRPC.TL_messageEntityBankCard) {
hasUrls = true;
spannable.setSpan(new URLSpanNoUnderline("card:" + url, run), run.start, run.end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
} else if (run.urlEntity instanceof TLRPC.TL_messageEntityPhone) {
hasUrls = true;
String tel = PhoneFormat.stripExceptNumbers(url);

View file

@ -3043,12 +3043,18 @@ public class MessagesController extends BaseController implements NotificationCe
if (first) {
boolean isProxyDialog = false;
boolean emptyMax = max_id_delete == 0;
if (emptyMax) {
int max = getMessagesStorage().getDialogMaxMessageId(did);
if (max > 0) {
max_id_delete = Math.max(max, max_id_delete);
}
}
getMessagesStorage().deleteDialog(did, onlyHistory);
TLRPC.Dialog dialog = dialogs_dict.get(did);
if (onlyHistory == 0 || onlyHistory == 3) {
getNotificationsController().deleteNotificationChannel(did);
}
boolean emptyMax = max_id_delete == 0;
if (dialog != null) {
if (emptyMax) {
max_id_delete = Math.max(0, dialog.top_message);
@ -7211,10 +7217,12 @@ public class MessagesController extends BaseController implements NotificationCe
getContactsController().deleteUnknownAppAccounts();
}
private boolean gettingAppChangelog;
public void generateUpdateMessage() {
if (BuildVars.DEBUG_VERSION || SharedConfig.lastUpdateVersion == null || SharedConfig.lastUpdateVersion.equals(BuildVars.BUILD_VERSION_STRING)) {
if (gettingAppChangelog || BuildVars.DEBUG_VERSION || SharedConfig.lastUpdateVersion == null || SharedConfig.lastUpdateVersion.equals(BuildVars.BUILD_VERSION_STRING)) {
return;
}
gettingAppChangelog = true;
TLRPC.TL_help_getAppChangelog req = new TLRPC.TL_help_getAppChangelog();
req.prev_app_version = SharedConfig.lastUpdateVersion;
getConnectionsManager().sendRequest(req, (response, error) -> {

View file

@ -2046,7 +2046,7 @@ public class MessagesStorage extends BaseController {
}
public void putDialogPhotos(final int did, final TLRPC.photos_Photos photos) {
if (photos == null || photos.photos.isEmpty()) {
if (photos == null) {
return;
}
storageQueue.postRunnable(() -> {
@ -8148,6 +8148,33 @@ public class MessagesStorage extends BaseController {
});
}
public int getDialogMaxMessageId(final long dialog_id) {
final CountDownLatch countDownLatch = new CountDownLatch(1);
final Integer[] max = new Integer[]{0};
storageQueue.postRunnable(() -> {
SQLiteCursor cursor = null;
try {
cursor = database.queryFinalized("SELECT MAX(mid) FROM messages WHERE uid = " + dialog_id);
if (cursor.next()) {
max[0] = cursor.intValue(0);
}
} catch (Exception e) {
FileLog.e(e);
} finally {
if (cursor != null) {
cursor.dispose();
}
}
countDownLatch.countDown();
});
try {
countDownLatch.await();
} catch (Exception e) {
FileLog.e(e);
}
return max[0];
}
public int getDialogReadMax(final boolean outbox, final long dialog_id) {
final CountDownLatch countDownLatch = new CountDownLatch(1);
final Integer[] max = new Integer[]{0};

View file

@ -84,6 +84,8 @@ public class SharedConfig {
public static boolean streamAllVideo = false;
public static boolean streamMkv = false;
public static boolean saveStreamMedia = true;
public static boolean smoothKeyboard = false;
public static boolean pauseMusicOnRecord = true;
public static boolean sortContactsByName;
public static boolean sortFilesByName;
public static boolean shuffleMusic;
@ -249,6 +251,8 @@ public class SharedConfig {
useSystemEmoji = preferences.getBoolean("useSystemEmoji", false);
streamMedia = preferences.getBoolean("streamMedia", true);
saveStreamMedia = preferences.getBoolean("saveStreamMedia", true);
smoothKeyboard = preferences.getBoolean("smoothKeyboard", false);
pauseMusicOnRecord = preferences.getBoolean("pauseMusicOnRecord", true);
streamAllVideo = preferences.getBoolean("streamAllVideo", BuildVars.DEBUG_VERSION);
streamMkv = preferences.getBoolean("streamMkv", false);
suggestStickers = preferences.getInt("suggestStickers", 0);
@ -671,6 +675,22 @@ public class SharedConfig {
editor.commit();
}
public static void toggleSmoothKeyboard() {
smoothKeyboard = !smoothKeyboard;
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean("smoothKeyboard", smoothKeyboard);
editor.commit();
}
public static void togglePauseMusicOnRecord() {
pauseMusicOnRecord = !pauseMusicOnRecord;
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean("pauseMusicOnRecord", pauseMusicOnRecord);
editor.commit();
}
public static void toggleInappCamera() {
inappCamera = !inappCamera;
SharedPreferences preferences = MessagesController.getGlobalMainSettings();

View file

@ -48,6 +48,9 @@ public class UserConfig extends BaseController {
public int migrateOffsetChannelId = -1;
public long migrateOffsetAccess = -1;
public int sharingMyLocationUntil;
public int lastMyLocationShareTime;
public boolean notificationsSettingsLoaded;
public boolean notificationsSignUpSettingsLoaded;
public boolean syncContacts = true;
@ -142,6 +145,8 @@ public class UserConfig extends BaseController {
editor.putBoolean("notificationsSignUpSettingsLoaded", notificationsSignUpSettingsLoaded);
editor.putLong("autoDownloadConfigLoadTime", autoDownloadConfigLoadTime);
editor.putBoolean("hasValidDialogLoadIds", hasValidDialogLoadIds);
editor.putInt("sharingMyLocationUntil", sharingMyLocationUntil);
editor.putInt("lastMyLocationShareTime", lastMyLocationShareTime);
if (tonEncryptedData != null) {
editor.putString("tonEncryptedData", tonEncryptedData);
editor.putString("tonPublicKey", tonPublicKey);
@ -296,6 +301,8 @@ public class UserConfig extends BaseController {
tonPublicKey = preferences.getString("tonPublicKey", null);
tonKeyName = preferences.getString("tonKeyName", "walletKey" + currentAccount);
tonCreationFinished = preferences.getBoolean("tonCreationFinished", true);
sharingMyLocationUntil = preferences.getInt("sharingMyLocationUntil", 0);
lastMyLocationShareTime = preferences.getInt("lastMyLocationShareTime", 0);
String salt = preferences.getString("tonPasscodeSalt", null);
if (salt != null) {
try {
@ -443,6 +450,8 @@ public class UserConfig extends BaseController {
getPreferences().edit().clear().commit();
clearTonConfig();
sharingMyLocationUntil = 0;
lastMyLocationShareTime = 0;
currentUser = null;
clientUserId = 0;
registeredForPush = false;

View file

@ -61,7 +61,7 @@ public class TLRPC {
public static final int MESSAGE_FLAG_EDITED = 0x00008000;
public static final int MESSAGE_FLAG_MEGAGROUP = 0x80000000;
public static final int LAYER = 109;
public static final int LAYER = 110;
public static class TL_chatBannedRights extends TLObject {
public static int constructor = 0x9f120418;
@ -12837,6 +12837,86 @@ public class TLRPC {
}
}
public static class TL_dialogFilter extends TLObject {
public static int constructor = 0x14f9162c;
public int flags;
public boolean pm;
public boolean secret_chats;
public boolean private_groups;
public boolean public_groups;
public boolean broadcasts;
public boolean bots;
public boolean exclude_muted;
public boolean exclude_read;
public int id;
public String title;
public ArrayList<InputPeer> include_peers = new ArrayList<>();
public static TL_dialogFilter TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) {
if (TL_dialogFilter.constructor != constructor) {
if (exception) {
throw new RuntimeException(String.format("can't parse magic %x in TL_dialogFilter", constructor));
} else {
return null;
}
}
TL_dialogFilter result = new TL_dialogFilter();
result.readParams(stream, exception);
return result;
}
public void readParams(AbstractSerializedData stream, boolean exception) {
flags = stream.readInt32(exception);
pm = (flags & 1) != 0;
secret_chats = (flags & 2) != 0;
private_groups = (flags & 4) != 0;
public_groups = (flags & 8) != 0;
broadcasts = (flags & 16) != 0;
bots = (flags & 32) != 0;
exclude_muted = (flags & 2048) != 0;
exclude_read = (flags & 4096) != 0;
id = stream.readInt32(exception);
title = stream.readString(exception);
int magic = stream.readInt32(exception);
if (magic != 0x1cb5c415) {
if (exception) {
throw new RuntimeException(String.format("wrong Vector magic, got %x", magic));
}
return;
}
int count = stream.readInt32(exception);
for (int a = 0; a < count; a++) {
InputPeer object = InputPeer.TLdeserialize(stream, stream.readInt32(exception), exception);
if (object == null) {
return;
}
include_peers.add(object);
}
}
public void serializeToStream(AbstractSerializedData stream) {
stream.writeInt32(constructor);
flags = pm ? (flags | 1) : (flags &~ 1);
flags = secret_chats ? (flags | 2) : (flags &~ 2);
flags = private_groups ? (flags | 4) : (flags &~ 4);
flags = public_groups ? (flags | 8) : (flags &~ 8);
flags = broadcasts ? (flags | 16) : (flags &~ 16);
flags = bots ? (flags | 32) : (flags &~ 32);
flags = exclude_muted ? (flags | 2048) : (flags &~ 2048);
flags = exclude_read ? (flags | 4096) : (flags &~ 4096);
stream.writeInt32(flags);
stream.writeInt32(id);
stream.writeString(title);
stream.writeInt32(0x1cb5c415);
int count = include_peers.size();
stream.writeInt32(count);
for (int a = 0; a < count; a++) {
include_peers.get(a).serializeToStream(stream);
}
}
}
public static class TL_auth_passwordRecovery extends TLObject {
public static int constructor = 0x137948a5;
@ -14415,6 +14495,56 @@ public class TLRPC {
}
}
public static class TL_payments_bankCardData extends TLObject {
public static int constructor = 0x3e24e573;
public String title;
public ArrayList<TL_bankCardOpenUrl> open_urls = new ArrayList<>();
public static TL_payments_bankCardData TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) {
if (TL_payments_bankCardData.constructor != constructor) {
if (exception) {
throw new RuntimeException(String.format("can't parse magic %x in TL_payments_bankCardData", constructor));
} else {
return null;
}
}
TL_payments_bankCardData result = new TL_payments_bankCardData();
result.readParams(stream, exception);
return result;
}
public void readParams(AbstractSerializedData stream, boolean exception) {
title = stream.readString(exception);
int magic = stream.readInt32(exception);
if (magic != 0x1cb5c415) {
if (exception) {
throw new RuntimeException(String.format("wrong Vector magic, got %x", magic));
}
return;
}
int count = stream.readInt32(exception);
for (int a = 0; a < count; a++) {
TL_bankCardOpenUrl object = TL_bankCardOpenUrl.TLdeserialize(stream, stream.readInt32(exception), exception);
if (object == null) {
return;
}
open_urls.add(object);
}
}
public void serializeToStream(AbstractSerializedData stream) {
stream.writeInt32(constructor);
stream.writeString(title);
stream.writeInt32(0x1cb5c415);
int count = open_urls.size();
stream.writeInt32(count);
for (int a = 0; a < count; a++) {
open_urls.get(a).serializeToStream(stream);
}
}
}
public static class TL_messages_highScores extends TLObject {
public static int constructor = 0x9a3bfd99;
@ -20008,6 +20138,9 @@ public class TLRPC {
case 0x154798c3:
result = new TL_updateMessageReactions();
break;
case 0x26ffde7d:
result = new TL_updateDialogFilter();
break;
case 0xfa0f3ca2:
result = new TL_updatePinnedDialogs();
break;
@ -20017,6 +20150,9 @@ public class TLRPC {
case 0x9c974fdf:
result = new TL_updateReadHistoryInbox();
break;
case 0xa5d72105:
result = new TL_updateDialogFilterOrder();
break;
case 0x9375341e:
result = new TL_updateSavedGifs();
break;
@ -20038,6 +20174,9 @@ public class TLRPC {
case 0x95313b0c:
result = new TL_updateUserPhoto();
break;
case 0x3504914f:
result = new TL_updateDialogFilters();
break;
case 0x8e5e9873:
result = new TL_updateDcOptions();
break;
@ -20600,7 +20739,7 @@ public class TLRPC {
public static class TL_updatePeerLocated extends Update {
public static int constructor = 0xb4afcfb0;
public ArrayList<TL_peerLocated> peers = new ArrayList<>();
public ArrayList<PeerLocated> peers = new ArrayList<>();
public void readParams(AbstractSerializedData stream, boolean exception) {
int magic = stream.readInt32(exception);
@ -20612,7 +20751,7 @@ public class TLRPC {
}
int count = stream.readInt32(exception);
for (int a = 0; a < count; a++) {
TL_peerLocated object = TL_peerLocated.TLdeserialize(stream, stream.readInt32(exception), exception);
PeerLocated object = PeerLocated.TLdeserialize(stream, stream.readInt32(exception), exception);
if (object == null) {
return;
}
@ -21101,6 +21240,31 @@ public class TLRPC {
}
}
public static class TL_updateDialogFilter extends Update {
public static int constructor = 0x26ffde7d;
public int flags;
public int id;
public TL_dialogFilter filter;
public void readParams(AbstractSerializedData stream, boolean exception) {
flags = stream.readInt32(exception);
id = stream.readInt32(exception);
if ((flags & 1) != 0) {
filter = TL_dialogFilter.TLdeserialize(stream, stream.readInt32(exception), exception);
}
}
public void serializeToStream(AbstractSerializedData stream) {
stream.writeInt32(constructor);
stream.writeInt32(flags);
stream.writeInt32(id);
if ((flags & 1) != 0) {
filter.serializeToStream(stream);
}
}
}
public static class TL_updatePinnedDialogs extends Update {
public static int constructor = 0xfa0f3ca2;
@ -21195,6 +21359,36 @@ public class TLRPC {
}
}
public static class TL_updateDialogFilterOrder extends Update {
public static int constructor = 0xa5d72105;
public ArrayList<Integer> order = new ArrayList<>();
public void readParams(AbstractSerializedData stream, boolean exception) {
int magic = stream.readInt32(exception);
if (magic != 0x1cb5c415) {
if (exception) {
throw new RuntimeException(String.format("wrong Vector magic, got %x", magic));
}
return;
}
int count = stream.readInt32(exception);
for (int a = 0; a < count; a++) {
order.add(stream.readInt32(exception));
}
}
public void serializeToStream(AbstractSerializedData stream) {
stream.writeInt32(constructor);
stream.writeInt32(0x1cb5c415);
int count = order.size();
stream.writeInt32(count);
for (int a = 0; a < count; a++) {
stream.writeInt32(order.get(a));
}
}
}
public static class TL_updateSavedGifs extends Update {
public static int constructor = 0x9375341e;
@ -21348,6 +21542,15 @@ public class TLRPC {
}
}
public static class TL_updateDialogFilters extends Update {
public static int constructor = 0x3504914f;
public void serializeToStream(AbstractSerializedData stream) {
stream.writeInt32(constructor);
}
}
public static class TL_updateDcOptions extends Update {
public static int constructor = 0x8e5e9873;
@ -22407,6 +22610,9 @@ public class TLRPC {
break;
case 0x9c4e7e8b:
result = new TL_messageEntityUnderline();
break;
case 0x761e6af4:
result = new TL_messageEntityBankCard();
break;
case 0x9b69e34b:
result = new TL_messageEntityPhone();
@ -22691,6 +22897,22 @@ public class TLRPC {
public static int constructor = 0x9c4e7e8b;
public void readParams(AbstractSerializedData stream, boolean exception) {
offset = stream.readInt32(exception);
length = stream.readInt32(exception);
}
public void serializeToStream(AbstractSerializedData stream) {
stream.writeInt32(constructor);
stream.writeInt32(offset);
stream.writeInt32(length);
}
}
public static class TL_messageEntityBankCard extends MessageEntity {
public static int constructor = 0x761e6af4;
public void readParams(AbstractSerializedData stream, boolean exception) {
offset = stream.readInt32(exception);
length = stream.readInt32(exception);
@ -25184,6 +25406,37 @@ public class TLRPC {
}
}
public static class TL_bankCardOpenUrl extends TLObject {
public static int constructor = 0xf568028a;
public String url;
public String name;
public static TL_bankCardOpenUrl TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) {
if (TL_bankCardOpenUrl.constructor != constructor) {
if (exception) {
throw new RuntimeException(String.format("can't parse magic %x in TL_bankCardOpenUrl", constructor));
} else {
return null;
}
}
TL_bankCardOpenUrl result = new TL_bankCardOpenUrl();
result.readParams(stream, exception);
return result;
}
public void readParams(AbstractSerializedData stream, boolean exception) {
url = stream.readString(exception);
name = stream.readString(exception);
}
public void serializeToStream(AbstractSerializedData stream) {
stream.writeInt32(constructor);
stream.writeString(url);
stream.writeString(name);
}
}
public static class TL_contacts_resolvedPeer extends TLObject {
public static int constructor = 0x7f077ad9;
@ -27713,26 +27966,50 @@ public class TLRPC {
}
}
public static class TL_peerLocated extends TLObject {
public static abstract class PeerLocated extends TLObject {
public static PeerLocated TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) {
PeerLocated result = null;
switch (constructor) {
case 0xf8ec284b:
result = new TL_peerSelfLocated();
break;
case 0xca461b5d:
result = new TL_peerLocated();
break;
}
if (result == null && exception) {
throw new RuntimeException(String.format("can't parse magic %x in PeerLocated", constructor));
}
if (result != null) {
result.readParams(stream, exception);
}
return result;
}
}
public static class TL_peerSelfLocated extends PeerLocated {
public static int constructor = 0xf8ec284b;
public int expires;
public void readParams(AbstractSerializedData stream, boolean exception) {
expires = stream.readInt32(exception);
}
public void serializeToStream(AbstractSerializedData stream) {
stream.writeInt32(constructor);
stream.writeInt32(expires);
}
}
public static class TL_peerLocated extends PeerLocated {
public static int constructor = 0xca461b5d;
public Peer peer;
public int expires;
public int distance;
public static TL_peerLocated TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) {
if (TL_peerLocated.constructor != constructor) {
if (exception) {
throw new RuntimeException(String.format("can't parse magic %x in TL_peerLocated", constructor));
} else {
return null;
}
}
TL_peerLocated result = new TL_peerLocated();
result.readParams(stream, exception);
return result;
}
public void readParams(AbstractSerializedData stream, boolean exception) {
peer = Peer.TLdeserialize(stream, stream.readInt32(exception), exception);
expires = stream.readInt32(exception);
@ -33740,9 +34017,12 @@ public class TLRPC {
}
public static class TL_contacts_getLocated extends TLObject {
public static int constructor = 0xa356056;
public static int constructor = 0xd348bc44;
public int flags;
public boolean background;
public InputGeoPoint geo_point;
public int self_expires;
public TLObject deserializeResponse(AbstractSerializedData stream, int constructor, boolean exception) {
return Updates.TLdeserialize(stream, constructor, exception);
@ -33750,7 +34030,12 @@ public class TLRPC {
public void serializeToStream(AbstractSerializedData stream) {
stream.writeInt32(constructor);
flags = background ? (flags | 2) : (flags &~ 2);
stream.writeInt32(flags);
geo_point.serializeToStream(stream);
if ((flags & 1) != 0) {
stream.writeInt32(self_expires);
}
}
}
@ -37637,6 +37922,69 @@ public class TLRPC {
}
}
public static class TL_messages_getDialogFilters extends TLObject {
public static int constructor = 0xf19ed96d;
public TLObject deserializeResponse(AbstractSerializedData stream, int constructor, boolean exception) {
Vector vector = new Vector();
int size = stream.readInt32(exception);
for (int a = 0; a < size; a++) {
TL_dialogFilter object = TL_dialogFilter.TLdeserialize(stream, stream.readInt32(exception), exception);
if (object == null) {
return vector;
}
vector.objects.add(object);
}
return vector;
}
public void serializeToStream(AbstractSerializedData stream) {
stream.writeInt32(constructor);
}
}
public static class TL_messages_updateDialogFilter extends TLObject {
public static int constructor = 0x1ad4a04a;
public int flags;
public int id;
public TL_dialogFilter filter;
public TLObject deserializeResponse(AbstractSerializedData stream, int constructor, boolean exception) {
return Bool.TLdeserialize(stream, constructor, exception);
}
public void serializeToStream(AbstractSerializedData stream) {
stream.writeInt32(constructor);
stream.writeInt32(flags);
stream.writeInt32(id);
if ((flags & 1) != 0) {
filter.serializeToStream(stream);
}
}
}
public static class TL_messages_updateDialogFiltersOrder extends TLObject {
public static int constructor = 0xc563c1e4;
public ArrayList<Integer> order = new ArrayList<>();
public TLObject deserializeResponse(AbstractSerializedData stream, int constructor, boolean exception) {
return Bool.TLdeserialize(stream, constructor, exception);
}
public void serializeToStream(AbstractSerializedData stream) {
stream.writeInt32(constructor);
stream.writeInt32(0x1cb5c415);
int count = order.size();
stream.writeInt32(count);
for (int a = 0; a < count; a++) {
stream.writeInt32(order.get(a));
}
}
}
public static class TL_help_getAppChangelog extends TLObject {
public static int constructor = 0x9010ef6f;
@ -39017,6 +39365,21 @@ public class TLRPC {
}
}
public static class TL_payments_getBankCardData extends TLObject {
public static int constructor = 0x2e79d779;
public String number;
public TLObject deserializeResponse(AbstractSerializedData stream, int constructor, boolean exception) {
return TL_payments_bankCardData.TLdeserialize(stream, constructor, exception);
}
public void serializeToStream(AbstractSerializedData stream) {
stream.writeInt32(constructor);
stream.writeString(number);
}
}
public static class TL_langpack_getLangPack extends TLObject {
public static int constructor = 0x9ab5c58e;

View file

@ -253,7 +253,7 @@ public class ActionBar extends FrameLayout {
addToContainer = value;
}
public boolean getAddToContainer() {
public boolean shouldAddToContainer() {
return addToContainer;
}

View file

@ -37,7 +37,6 @@ import android.view.ViewOutlineProvider;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.animation.DecelerateInterpolator;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.FileLog;
@ -58,14 +57,13 @@ public class ActionBarLayout extends FrameLayout {
void onRebuildAllFragments(ActionBarLayout layout, boolean last);
}
public class LinearLayoutContainer extends LinearLayout {
public class LayoutContainer extends AdjustPanFrameLayout {
private Rect rect = new Rect();
private boolean isKeyboardVisible;
public LinearLayoutContainer(Context context) {
public LayoutContainer(Context context) {
super(context);
setOrientation(VERTICAL);
}
@Override
@ -74,6 +72,7 @@ public class ActionBarLayout extends FrameLayout {
return super.drawChild(canvas, child, drawingTime);
} else {
int actionBarHeight = 0;
int actionBarY = 0;
int childCount = getChildCount();
for (int a = 0; a < childCount; a++) {
View view = getChildAt(a);
@ -83,13 +82,14 @@ public class ActionBarLayout extends FrameLayout {
if (view instanceof ActionBar && view.getVisibility() == VISIBLE) {
if (((ActionBar) view).getCastShadows()) {
actionBarHeight = view.getMeasuredHeight();
actionBarY = (int) view.getY();
}
break;
}
}
boolean result = super.drawChild(canvas, child, drawingTime);
if (actionBarHeight != 0 && headerShadowDrawable != null) {
headerShadowDrawable.setBounds(0, actionBarHeight, getMeasuredWidth(), actionBarHeight + headerShadowDrawable.getIntrinsicHeight());
headerShadowDrawable.setBounds(0, actionBarY + actionBarHeight, getMeasuredWidth(), actionBarY + actionBarHeight + headerShadowDrawable.getIntrinsicHeight());
headerShadowDrawable.draw(canvas);
}
return result;
@ -104,9 +104,48 @@ public class ActionBarLayout extends FrameLayout {
return false;
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int width = MeasureSpec.getSize(widthMeasureSpec);
int height = MeasureSpec.getSize(heightMeasureSpec);
int count = getChildCount();
int actionBarHeight = 0;
for (int a = 0; a < count; a++) {
View child = getChildAt(a);
if (child instanceof ActionBar) {
child.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height, MeasureSpec.UNSPECIFIED));
actionBarHeight = child.getMeasuredHeight();
break;
}
}
for (int a = 0; a < count; a++) {
View child = getChildAt(a);
if (!(child instanceof ActionBar)) {
measureChildWithMargins(child, widthMeasureSpec, 0, heightMeasureSpec, actionBarHeight);
}
}
setMeasuredDimension(width, height);
}
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
super.onLayout(changed, l, t, r, b);
int count = getChildCount();
int actionBarHeight = 0;
for (int a = 0; a < count; a++) {
View child = getChildAt(a);
if (child instanceof ActionBar) {
actionBarHeight = child.getMeasuredHeight();
child.layout(0, 0, child.getMeasuredWidth(), actionBarHeight);
break;
}
}
for (int a = 0; a < count; a++) {
View child = getChildAt(a);
if (!(child instanceof ActionBar)) {
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) child.getLayoutParams();
child.layout(layoutParams.leftMargin, layoutParams.topMargin + actionBarHeight, layoutParams.leftMargin + child.getMeasuredWidth(), layoutParams.topMargin + actionBarHeight + child.getMeasuredHeight());
}
}
View rootView = getRootView();
getWindowVisibleDisplayFrame(rect);
@ -132,6 +171,40 @@ public class ActionBarLayout extends FrameLayout {
}
return false;
}
@Override
protected void onPanTranslationUpdate(int y) {
currentPanTranslationY = y;
int count = getChildCount();
for (int a = 0; a < count; a++) {
View child = getChildAt(a);
if (child instanceof ActionBar) {
child.setTranslationY(y);
} else {
if (this == layoutToIgnore) {
child.setTranslationY(y);
} else {
child.setTranslationY(0);
}
}
}
if (layoutToIgnore == null && !fragmentsStack.isEmpty()) {
fragmentsStack.get(fragmentsStack.size() - 1).onPanTranslationUpdate(y);
}
}
@Override
protected void onTransitionStart() {
fragmentsStack.get(fragmentsStack.size() - 1).onPanTransitionStart();
}
@Override
protected void onTransitionEnd() {
fragmentsStack.get(fragmentsStack.size() - 1).onPanTransitionEnd();
if (layoutToIgnore != null && !transitionAnimationInProgress && !startedTracking) {
layoutToIgnore = null;
}
}
}
private static Drawable headerShadowDrawable;
@ -142,10 +215,11 @@ public class ActionBarLayout extends FrameLayout {
private Runnable delayedOpenAnimationRunnable;
private boolean inPreviewMode;
private boolean previewOpenAnimationInProgress;
private ColorDrawable previewBackgroundDrawable;
private LinearLayoutContainer containerView;
private LinearLayoutContainer containerViewBack;
private LayoutContainer containerView;
private LayoutContainer containerViewBack;
private DrawerLayoutContainer drawerLayoutContainer;
private ActionBar currentActionBar;
@ -155,12 +229,15 @@ public class ActionBarLayout extends FrameLayout {
public float innerTranslationX;
private int currentPanTranslationY;
private boolean maybeStartTracking;
protected boolean startedTracking;
private int startedTrackingX;
private int startedTrackingY;
protected boolean animationInProgress;
private VelocityTracker velocityTracker;
private View layoutToIgnore;
private boolean beginTrackingSent;
private boolean transitionAnimationInProgress;
private boolean transitionAnimationPreviewMode;
@ -213,7 +290,7 @@ public class ActionBarLayout extends FrameLayout {
public void init(ArrayList<BaseFragment> stack) {
fragmentsStack = stack;
containerViewBack = new LinearLayoutContainer(parentActivity);
containerViewBack = new LayoutContainer(parentActivity);
addView(containerViewBack);
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) containerViewBack.getLayoutParams();
layoutParams.width = LayoutHelper.MATCH_PARENT;
@ -221,7 +298,7 @@ public class ActionBarLayout extends FrameLayout {
layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
containerViewBack.setLayoutParams(layoutParams);
containerView = new LinearLayoutContainer(parentActivity);
containerView = new LayoutContainer(parentActivity);
addView(containerView);
layoutParams = (FrameLayout.LayoutParams) containerView.getLayoutParams();
layoutParams.width = LayoutHelper.MATCH_PARENT;
@ -249,7 +326,12 @@ public class ActionBarLayout extends FrameLayout {
}
public void drawHeaderShadow(Canvas canvas, int y) {
drawHeaderShadow(canvas, 255, y);
}
public void drawHeaderShadow(Canvas canvas, int alpha, int y) {
if (headerShadowDrawable != null) {
headerShadowDrawable.setAlpha(alpha);
headerShadowDrawable.setBounds(0, y, getMeasuredWidth(), y + headerShadowDrawable.getIntrinsicHeight());
headerShadowDrawable.draw(canvas);
}
@ -273,6 +355,10 @@ public class ActionBarLayout extends FrameLayout {
}
}
public int getCurrentPanTranslationY() {
return currentPanTranslationY;
}
public void onResume() {
if (transitionAnimationInProgress) {
if (currentAnimation != null) {
@ -382,7 +468,7 @@ public class ActionBarLayout extends FrameLayout {
lastFragment.setParentLayout(null);
fragmentsStack.remove(fragmentsStack.size() - 1);
LinearLayoutContainer temp = containerView;
LayoutContainer temp = containerView;
containerView = containerViewBack;
containerViewBack = temp;
bringChildToFront(containerView);
@ -391,6 +477,8 @@ public class ActionBarLayout extends FrameLayout {
currentActionBar = lastFragment.actionBar;
lastFragment.onResume();
lastFragment.onBecomeFullyVisible();
layoutToIgnore = containerView;
} else {
if (fragmentsStack.size() >= 2) {
BaseFragment lastFragment = fragmentsStack.get(fragmentsStack.size() - 2);
@ -402,13 +490,14 @@ public class ActionBarLayout extends FrameLayout {
parent.removeViewInLayout(lastFragment.fragmentView);
}
}
if (lastFragment.actionBar != null && lastFragment.actionBar.getAddToContainer()) {
if (lastFragment.actionBar != null && lastFragment.actionBar.shouldAddToContainer()) {
ViewGroup parent = (ViewGroup) lastFragment.actionBar.getParent();
if (parent != null) {
parent.removeViewInLayout(lastFragment.actionBar);
}
}
}
layoutToIgnore = null;
}
containerViewBack.setVisibility(View.INVISIBLE);
startedTracking = false;
@ -421,6 +510,7 @@ public class ActionBarLayout extends FrameLayout {
private void prepareForMoving(MotionEvent ev) {
maybeStartTracking = false;
startedTracking = true;
layoutToIgnore = containerViewBack;
startedTrackingX = (int) ev.getX();
containerViewBack.setVisibility(View.VISIBLE);
beginTrackingSent = false;
@ -435,7 +525,13 @@ public class ActionBarLayout extends FrameLayout {
lastFragment.onRemoveFromParent();
parent.removeView(fragmentView);
}
if (lastFragment.actionBar != null && lastFragment.actionBar.getAddToContainer()) {
containerViewBack.addView(fragmentView);
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) fragmentView.getLayoutParams();
layoutParams.width = LayoutHelper.MATCH_PARENT;
layoutParams.height = LayoutHelper.MATCH_PARENT;
layoutParams.topMargin = layoutParams.bottomMargin = layoutParams.rightMargin = layoutParams.leftMargin = 0;
fragmentView.setLayoutParams(layoutParams);
if (lastFragment.actionBar != null && lastFragment.actionBar.shouldAddToContainer()) {
parent = (ViewGroup) lastFragment.actionBar.getParent();
if (parent != null) {
parent.removeView(lastFragment.actionBar);
@ -446,12 +542,6 @@ public class ActionBarLayout extends FrameLayout {
containerViewBack.addView(lastFragment.actionBar);
lastFragment.actionBar.setTitleOverlayText(titleOverlayText, titleOverlayTextId, overlayAction);
}
containerViewBack.addView(fragmentView);
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) fragmentView.getLayoutParams();
layoutParams.width = LayoutHelper.MATCH_PARENT;
layoutParams.height = LayoutHelper.MATCH_PARENT;
layoutParams.topMargin = layoutParams.bottomMargin = layoutParams.rightMargin = layoutParams.leftMargin = 0;
fragmentView.setLayoutParams(layoutParams);
if (!lastFragment.hasOwnBackground && fragmentView.getBackground() == null) {
fragmentView.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
}
@ -466,7 +556,7 @@ public class ActionBarLayout extends FrameLayout {
if (fragmentsStack.size() > 1) {
if (ev != null && ev.getAction() == MotionEvent.ACTION_DOWN && !startedTracking && !maybeStartTracking) {
BaseFragment currentFragment = fragmentsStack.get(fragmentsStack.size() - 1);
if (!currentFragment.swipeBackEnabled) {
if (!currentFragment.isSwipeBackEnabled(ev)) {
return false;
}
startedTrackingPointerId = ev.getPointerId(0);
@ -508,7 +598,7 @@ public class ActionBarLayout extends FrameLayout {
}
velocityTracker.computeCurrentVelocity(1000);
BaseFragment currentFragment = fragmentsStack.get(fragmentsStack.size() - 1);
if (!inPreviewMode && !transitionAnimationPreviewMode && !startedTracking && currentFragment.swipeBackEnabled) {
if (!inPreviewMode && !transitionAnimationPreviewMode && !startedTracking && currentFragment.isSwipeBackEnabled(ev)) {
float velX = velocityTracker.getXVelocity();
float velY = velocityTracker.getYVelocity();
if (velX >= 3500 && velX > Math.abs(velY) && currentFragment.canBeginSlide()) {
@ -551,9 +641,11 @@ public class ActionBarLayout extends FrameLayout {
});
animatorSet.start();
animationInProgress = true;
layoutToIgnore = containerViewBack;
} else {
maybeStartTracking = false;
startedTracking = false;
layoutToIgnore = null;
}
if (velocityTracker != null) {
velocityTracker.recycle();
@ -562,6 +654,7 @@ public class ActionBarLayout extends FrameLayout {
} else if (ev == null) {
maybeStartTracking = false;
startedTracking = false;
layoutToIgnore = null;
if (velocityTracker != null) {
velocityTracker.recycle();
velocityTracker = null;
@ -638,6 +731,10 @@ public class ActionBarLayout extends FrameLayout {
return transitionAnimationInProgress;
}
public boolean isPreviewOpenAnimationInProgress() {
return previewOpenAnimationInProgress;
}
private void presentFragmentInternalRemoveOld(boolean removeLast, final BaseFragment fragment) {
if (fragment == null) {
return;
@ -656,7 +753,7 @@ public class ActionBarLayout extends FrameLayout {
parent.removeViewInLayout(fragment.fragmentView);
}
}
if (fragment.actionBar != null && fragment.actionBar.getAddToContainer()) {
if (fragment.actionBar != null && fragment.actionBar.shouldAddToContainer()) {
ViewGroup parent = (ViewGroup) fragment.actionBar.getParent();
if (parent != null) {
parent.removeViewInLayout(fragment.actionBar);
@ -774,20 +871,8 @@ public class ActionBarLayout extends FrameLayout {
parent.removeView(fragmentView);
}
}
if (fragment.actionBar != null && fragment.actionBar.getAddToContainer()) {
if (removeActionBarExtraHeight) {
fragment.actionBar.setOccupyStatusBar(false);
}
ViewGroup parent = (ViewGroup) fragment.actionBar.getParent();
if (parent != null) {
parent.removeView(fragment.actionBar);
}
containerViewBack.addView(fragment.actionBar);
fragment.actionBar.setTitleOverlayText(titleOverlayText, titleOverlayTextId, overlayAction);
}
containerViewBack.addView(fragmentView);
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) fragmentView.getLayoutParams();
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) fragmentView.getLayoutParams();
layoutParams.width = LayoutHelper.MATCH_PARENT;
layoutParams.height = LayoutHelper.MATCH_PARENT;
if (preview) {
@ -798,6 +883,17 @@ public class ActionBarLayout extends FrameLayout {
layoutParams.topMargin = layoutParams.bottomMargin = layoutParams.rightMargin = layoutParams.leftMargin = 0;
}
fragmentView.setLayoutParams(layoutParams);
if (fragment.actionBar != null && fragment.actionBar.shouldAddToContainer()) {
if (removeActionBarExtraHeight) {
fragment.actionBar.setOccupyStatusBar(false);
}
ViewGroup parent = (ViewGroup) fragment.actionBar.getParent();
if (parent != null) {
parent.removeView(fragment.actionBar);
}
containerViewBack.addView(fragment.actionBar);
fragment.actionBar.setTitleOverlayText(titleOverlayText, titleOverlayTextId, overlayAction);
}
fragmentsStack.add(fragment);
fragment.onResume();
currentActionBar = fragment.actionBar;
@ -805,7 +901,7 @@ public class ActionBarLayout extends FrameLayout {
fragmentView.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
}
LinearLayoutContainer temp = containerView;
LayoutContainer temp = containerView;
containerView = containerViewBack;
containerViewBack = temp;
containerView.setVisibility(View.VISIBLE);
@ -849,6 +945,7 @@ public class ActionBarLayout extends FrameLayout {
transitionAnimationStartTime = System.currentTimeMillis();
transitionAnimationInProgress = true;
layoutToIgnore = containerView;
onOpenAnimationEndRunnable = () -> {
if (currentFragment != null) {
currentFragment.onTransitionAnimationEnd(false, false);
@ -857,10 +954,10 @@ public class ActionBarLayout extends FrameLayout {
fragment.onBecomeFullyVisible();
};
ArrayList<Animator> animators = new ArrayList<>();
animators.add(ObjectAnimator.ofFloat(this, "alpha", 0.0f, 1.0f));
animators.add(ObjectAnimator.ofFloat(this, View.ALPHA, 0.0f, 1.0f));
if (backgroundView != null) {
backgroundView.setVisibility(VISIBLE);
animators.add(ObjectAnimator.ofFloat(backgroundView, "alpha", 0.0f, 1.0f));
animators.add(ObjectAnimator.ofFloat(backgroundView, View.ALPHA, 0.0f, 1.0f));
}
if (currentFragment != null) {
currentFragment.onTransitionAnimationStart(false, false);
@ -881,6 +978,7 @@ public class ActionBarLayout extends FrameLayout {
transitionAnimationPreviewMode = preview;
transitionAnimationStartTime = System.currentTimeMillis();
transitionAnimationInProgress = true;
layoutToIgnore = containerView;
onOpenAnimationEndRunnable = () -> {
if (preview) {
inPreviewMode = true;
@ -978,7 +1076,7 @@ public class ActionBarLayout extends FrameLayout {
if (!fragmentsStack.isEmpty()) {
BaseFragment previousFragment = fragmentsStack.get(fragmentsStack.size() - 1);
previousFragment.onPause();
if (previousFragment.actionBar != null && previousFragment.actionBar.getAddToContainer()) {
if (previousFragment.actionBar != null && previousFragment.actionBar.shouldAddToContainer()) {
ViewGroup parent = (ViewGroup) previousFragment.actionBar.getParent();
if (parent != null) {
parent.removeView(previousFragment.actionBar);
@ -1017,6 +1115,7 @@ public class ActionBarLayout extends FrameLayout {
if (nextTranslation > 0) {
nextTranslation = 0;
} else if (nextTranslation < -AndroidUtilities.dp(60)) {
previewOpenAnimationInProgress = true;
inPreviewMode = false;
nextTranslation = 0;
@ -1027,7 +1126,7 @@ public class ActionBarLayout extends FrameLayout {
fragment.fragmentView.setOutlineProvider(null);
fragment.fragmentView.setClipToOutline(false);
}
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) fragment.fragmentView.getLayoutParams();
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) fragment.fragmentView.getLayoutParams();
layoutParams.topMargin = layoutParams.bottomMargin = layoutParams.rightMargin = layoutParams.leftMargin = 0;
fragment.fragmentView.setLayoutParams(layoutParams);
@ -1035,11 +1134,16 @@ public class ActionBarLayout extends FrameLayout {
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.playTogether(
ObjectAnimator.ofFloat(fragment.fragmentView, "scaleX", 1.0f, 1.05f, 1.0f),
ObjectAnimator.ofFloat(fragment.fragmentView, "scaleY", 1.0f, 1.05f, 1.0f));
ObjectAnimator.ofFloat(fragment.fragmentView, View.SCALE_X, 1.0f, 1.05f, 1.0f),
ObjectAnimator.ofFloat(fragment.fragmentView, View.SCALE_Y, 1.0f, 1.05f, 1.0f));
animatorSet.setDuration(200);
animatorSet.setInterpolator(new CubicBezierInterpolator(0.42, 0.0, 0.58, 1.0));
animatorSet.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
previewOpenAnimationInProgress = false;
}
});
animatorSet.start();
performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP);
@ -1055,6 +1159,10 @@ public class ActionBarLayout extends FrameLayout {
if (!inPreviewMode && !transitionAnimationPreviewMode) {
return;
}
if (delayedOpenAnimationRunnable != null) {
AndroidUtilities.cancelRunOnUIThread(delayedOpenAnimationRunnable);
delayedOpenAnimationRunnable = null;
}
closeLastFragment(true);
}
@ -1074,7 +1182,7 @@ public class ActionBarLayout extends FrameLayout {
}
if (previousFragment != null) {
LinearLayoutContainer temp = containerView;
LayoutContainer temp = containerView;
containerView = containerViewBack;
containerViewBack = temp;
@ -1086,17 +1194,6 @@ public class ActionBarLayout extends FrameLayout {
if (!inPreviewMode) {
containerView.setVisibility(View.VISIBLE);
if (previousFragment.actionBar != null && previousFragment.actionBar.getAddToContainer()) {
if (removeActionBarExtraHeight) {
previousFragment.actionBar.setOccupyStatusBar(false);
}
ViewGroup parent = (ViewGroup) previousFragment.actionBar.getParent();
if (parent != null) {
parent.removeView(previousFragment.actionBar);
}
containerView.addView(previousFragment.actionBar);
previousFragment.actionBar.setTitleOverlayText(titleOverlayText, titleOverlayTextId, overlayAction);
}
ViewGroup parent = (ViewGroup) fragmentView.getParent();
if (parent != null) {
previousFragment.onRemoveFromParent();
@ -1107,11 +1204,22 @@ public class ActionBarLayout extends FrameLayout {
}
}
containerView.addView(fragmentView);
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) fragmentView.getLayoutParams();
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) fragmentView.getLayoutParams();
layoutParams.width = LayoutHelper.MATCH_PARENT;
layoutParams.height = LayoutHelper.MATCH_PARENT;
layoutParams.topMargin = layoutParams.bottomMargin = layoutParams.rightMargin = layoutParams.leftMargin = 0;
fragmentView.setLayoutParams(layoutParams);
if (previousFragment.actionBar != null && previousFragment.actionBar.shouldAddToContainer()) {
if (removeActionBarExtraHeight) {
previousFragment.actionBar.setOccupyStatusBar(false);
}
parent = (ViewGroup) previousFragment.actionBar.getParent();
if (parent != null) {
parent.removeView(previousFragment.actionBar);
}
containerView.addView(previousFragment.actionBar);
previousFragment.actionBar.setTitleOverlayText(titleOverlayText, titleOverlayTextId, overlayAction);
}
}
previousFragment.onTransitionAnimationStart(true, true);
@ -1132,6 +1240,7 @@ public class ActionBarLayout extends FrameLayout {
if (needAnimation) {
transitionAnimationStartTime = System.currentTimeMillis();
transitionAnimationInProgress = true;
layoutToIgnore = containerView;
final BaseFragment previousFragmentFinal = previousFragment;
onCloseAnimationEndRunnable = () -> {
if (inPreviewMode || transitionAnimationPreviewMode) {
@ -1179,6 +1288,7 @@ public class ActionBarLayout extends FrameLayout {
if (useAlphaAnimations) {
transitionAnimationStartTime = System.currentTimeMillis();
transitionAnimationInProgress = true;
layoutToIgnore = containerView;
onCloseAnimationEndRunnable = () -> {
removeFragmentFromStackInternal(currentFragment);
@ -1192,9 +1302,9 @@ public class ActionBarLayout extends FrameLayout {
};
ArrayList<Animator> animators = new ArrayList<>();
animators.add(ObjectAnimator.ofFloat(this, "alpha", 1.0f, 0.0f));
animators.add(ObjectAnimator.ofFloat(this, View.ALPHA, 1.0f, 0.0f));
if (backgroundView != null) {
animators.add(ObjectAnimator.ofFloat(backgroundView, "alpha", 1.0f, 0.0f));
animators.add(ObjectAnimator.ofFloat(backgroundView, View.ALPHA, 1.0f, 0.0f));
}
currentAnimation = new AnimatorSet();
@ -1229,7 +1339,7 @@ public class ActionBarLayout extends FrameLayout {
}
for (int a = 0; a < fragmentsStack.size() - 1; a++) {
BaseFragment previousFragment = fragmentsStack.get(a);
if (previousFragment.actionBar != null && previousFragment.actionBar.getAddToContainer()) {
if (previousFragment.actionBar != null && previousFragment.actionBar.shouldAddToContainer()) {
ViewGroup parent = (ViewGroup) previousFragment.actionBar.getParent();
if (parent != null) {
parent.removeView(previousFragment.actionBar);
@ -1256,7 +1366,8 @@ public class ActionBarLayout extends FrameLayout {
parent.removeView(fragmentView);
}
}
if (previousFragment.actionBar != null && previousFragment.actionBar.getAddToContainer()) {
containerView.addView(fragmentView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
if (previousFragment.actionBar != null && previousFragment.actionBar.shouldAddToContainer()) {
if (removeActionBarExtraHeight) {
previousFragment.actionBar.setOccupyStatusBar(false);
}
@ -1267,7 +1378,6 @@ public class ActionBarLayout extends FrameLayout {
containerView.addView(previousFragment.actionBar);
previousFragment.actionBar.setTitleOverlayText(titleOverlayText, titleOverlayTextId, overlayAction);
}
containerView.addView(fragmentView, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
previousFragment.onResume();
currentActionBar = previousFragment.actionBar;
if (!previousFragment.hasOwnBackground && fragmentView.getBackground() == null) {
@ -1528,6 +1638,9 @@ public class ActionBarLayout extends FrameLayout {
private void onCloseAnimationEnd() {
if (transitionAnimationInProgress && onCloseAnimationEndRunnable != null) {
transitionAnimationInProgress = false;
if (currentPanTranslationY == 0) {
layoutToIgnore = null;
}
transitionAnimationPreviewMode = false;
transitionAnimationStartTime = 0;
onCloseAnimationEndRunnable.run();
@ -1550,6 +1663,9 @@ public class ActionBarLayout extends FrameLayout {
private void onOpenAnimationEnd() {
if (transitionAnimationInProgress && onOpenAnimationEndRunnable != null) {
transitionAnimationInProgress = false;
if (currentPanTranslationY == 0) {
layoutToIgnore = null;
}
transitionAnimationPreviewMode = false;
transitionAnimationStartTime = 0;
onOpenAnimationEndRunnable.run();

View file

@ -39,6 +39,7 @@ import android.widget.TextView;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.LocaleController;
import org.telegram.messenger.R;
import org.telegram.messenger.SharedConfig;
import org.telegram.ui.Components.CloseProgressDrawable2;
import org.telegram.ui.Components.EditTextBoldCursor;
import org.telegram.ui.Components.LayoutHelper;
@ -73,6 +74,10 @@ public class ActionBarMenuItem extends FrameLayout {
public Animator getCustomToggleTransition() {
return null;
}
public void onLayout(int l, int t, int r, int b) {
}
}
public interface ActionBarSumMenuItemDelegate {
@ -111,7 +116,7 @@ public class ActionBarMenuItem extends FrameLayout {
private CloseProgressDrawable2 progressDrawable;
private int additionalYOffset;
private int additionalXOffset;
private boolean longClickEnabled = true;
private boolean longClickEnabled;
private boolean animateClear = true;
private boolean clearsTextOnSearchCollapse = true;
private boolean measurePopup = true;
@ -564,6 +569,10 @@ public class ActionBarMenuItem extends FrameLayout {
iconView.setImageDrawable(drawable);
}
public ImageView getIconView() {
return iconView;
}
public void setIcon(int resId) {
if (iconView == null) {
return;
@ -898,6 +907,9 @@ public class ActionBarMenuItem extends FrameLayout {
if (popupWindow != null && popupWindow.isShowing()) {
updateOrShowPopup(false, true);
}
if (listener != null) {
listener.onLayout(left, top, right, bottom);
}
}
public void setAdditionalYOffset(int value) {
@ -912,7 +924,7 @@ public class ActionBarMenuItem extends FrameLayout {
int offsetY;
if (parentMenu != null) {
offsetY = -parentMenu.parentActionBar.getMeasuredHeight() + parentMenu.getTop() + parentMenu.getPaddingTop();
offsetY = -parentMenu.parentActionBar.getMeasuredHeight() + parentMenu.getTop() + parentMenu.getPaddingTop() - (int) parentMenu.parentActionBar.getTranslationY();
} else {
float scaleY = getScaleY();
offsetY = -(int) (getMeasuredHeight() * scaleY - (subMenuOpenSide != 2 ? getTranslationY() : 0) / scaleY) + additionalYOffset;
@ -926,11 +938,21 @@ public class ActionBarMenuItem extends FrameLayout {
if (parentMenu != null) {
View parent = parentMenu.parentActionBar;
if (subMenuOpenSide == 0) {
if (show) {
popupWindow.showAsDropDown(parent, getLeft() + parentMenu.getLeft() + getMeasuredWidth() - popupLayout.getMeasuredWidth() + (int) getTranslationX(), offsetY);
}
if (update) {
popupWindow.update(parent, getLeft() + parentMenu.getLeft() + getMeasuredWidth() - popupLayout.getMeasuredWidth() + (int) getTranslationX(), offsetY, -1, -1);
if (SharedConfig.smoothKeyboard) {
getLocationOnScreen(location);
if (show) {
popupWindow.showAtLocation(parent, Gravity.LEFT | Gravity.TOP, location[0] + getMeasuredWidth() - popupLayout.getMeasuredWidth() + (int) getTranslationX(), offsetY);
}
if (update) {
popupWindow.update(location[0] + getMeasuredWidth() - popupLayout.getMeasuredWidth() + (int) getTranslationX(), offsetY, -1, -1);
}
} else {
if (show) {
popupWindow.showAsDropDown(parent, getLeft() + parentMenu.getLeft() + getMeasuredWidth() - popupLayout.getMeasuredWidth() + (int) getTranslationX(), offsetY);
}
if (update) {
popupWindow.update(parent, getLeft() + parentMenu.getLeft() + getMeasuredWidth() - popupLayout.getMeasuredWidth() + (int) getTranslationX(), offsetY, -1, -1);
}
}
} else {
if (show) {

View file

@ -0,0 +1,48 @@
package org.telegram.ui.ActionBar;
import android.content.Context;
import android.graphics.Canvas;
import android.widget.FrameLayout;
public class AdjustPanFrameLayout extends FrameLayout {
private AdjustPanLayoutHelper adjustPanLayoutHelper;
public AdjustPanFrameLayout(Context context) {
super(context);
adjustPanLayoutHelper = new AdjustPanLayoutHelper(this) {
@Override
protected void onPanTranslationUpdate(int y) {
AdjustPanFrameLayout.this.onPanTranslationUpdate(y);
}
@Override
protected void onTransitionStart() {
AdjustPanFrameLayout.this.onTransitionStart();
}
@Override
protected void onTransitionEnd() {
AdjustPanFrameLayout.this.onTransitionEnd();
}
};
}
@Override
protected void dispatchDraw(Canvas canvas) {
adjustPanLayoutHelper.update();
super.dispatchDraw(canvas);
}
protected void onPanTranslationUpdate(int y) {
}
protected void onTransitionStart() {
}
protected void onTransitionEnd() {
}
}

View file

@ -0,0 +1,79 @@
package org.telegram.ui.ActionBar;
import android.os.Build;
import android.view.View;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.SharedConfig;
public class AdjustPanLayoutHelper {
private int[] loc = new int[2];
private final static int FRAMES_WITHOUT_MOVE_LIMIT = 5;
private View parentView;
private int framesWithoutMovement;
private int prevMovement;
private boolean wasMovement;
public AdjustPanLayoutHelper(View parent) {
parentView = parent;
parentView.getViewTreeObserver().addOnGlobalLayoutListener(this::onUpdate);
parentView.getViewTreeObserver().addOnScrollChangedListener(this::onUpdate);
parentView.getViewTreeObserver().addOnGlobalFocusChangeListener((oldFocus, newFocus) -> onUpdate());
}
private void onUpdate() {
if (!SharedConfig.smoothKeyboard) {
return;
}
//prevMovement = Integer.MAX_VALUE;
framesWithoutMovement = 0;
wasMovement = false;
parentView.invalidate();
}
public void update() {
if (parentView.getVisibility() != View.VISIBLE || parentView.getParent() == null) {
return;
}
if (!AndroidUtilities.usingHardwareInput && SharedConfig.smoothKeyboard) {
parentView.getLocationInWindow(loc);
if (loc[1] <= 0) {
loc[1] -= parentView.getTranslationY();
if (Build.VERSION.SDK_INT < 21) {
loc[1] -= AndroidUtilities.statusBarHeight;
}
} else {
loc[1] = 0;
}
if (loc[1] != prevMovement) {
if (!wasMovement) {
onTransitionStart();
}
wasMovement = true;
onPanTranslationUpdate(-loc[1]);
framesWithoutMovement = 0;
prevMovement = loc[1];
} else {
framesWithoutMovement++;
}
if (framesWithoutMovement < FRAMES_WITHOUT_MOVE_LIMIT) {
parentView.invalidate();
} else if (wasMovement) {
onTransitionEnd();
}
}
}
protected void onPanTranslationUpdate(int y) {
}
protected void onTransitionStart() {
}
protected void onTransitionEnd() {
}
}

View file

@ -0,0 +1,30 @@
package org.telegram.ui.ActionBar;
import android.content.Context;
import android.graphics.Canvas;
import android.widget.LinearLayout;
public class AdjustPanLinearLayout extends LinearLayout {
private AdjustPanLayoutHelper adjustPanLayoutHelper;
public AdjustPanLinearLayout(Context context) {
super(context);
adjustPanLayoutHelper = new AdjustPanLayoutHelper(this) {
@Override
protected void onPanTranslationUpdate(int y) {
AdjustPanLinearLayout.this.onPanTranslationUpdate(y);
}
};
}
@Override
protected void dispatchDraw(Canvas canvas) {
adjustPanLayoutHelper.update();
super.dispatchDraw(canvas);
}
protected void onPanTranslationUpdate(int y) {
}
}

View file

@ -18,6 +18,7 @@ import android.os.Build;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.Menu;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityManager;
@ -53,7 +54,6 @@ public class BaseFragment {
protected boolean inPreviewMode;
protected int classGuid;
protected Bundle arguments;
protected boolean swipeBackEnabled = true;
protected boolean hasOwnBackground = false;
protected boolean isPaused = true;
@ -97,6 +97,10 @@ public class BaseFragment {
return classGuid;
}
public boolean isSwipeBackEnabled(MotionEvent event) {
return true;
}
protected void setInPreviewMode(boolean value) {
inPreviewMode = value;
if (actionBar != null) {
@ -163,7 +167,7 @@ public class BaseFragment {
}
if (actionBar != null) {
boolean differentParent = parentLayout != null && parentLayout.getContext() != actionBar.getContext();
if (actionBar.getAddToContainer() || differentParent) {
if (actionBar.shouldAddToContainer() || differentParent) {
ViewGroup parent = (ViewGroup) actionBar.getParent();
if (parent != null) {
try {
@ -445,6 +449,22 @@ public class BaseFragment {
}
protected void onPanTranslationUpdate(int y) {
}
protected void onPanTransitionStart() {
}
protected void onPanTransitionEnd() {
}
public int getCurrentPanTranslationY() {
return parentLayout != null ? parentLayout.getCurrentPanTranslationY() : 0;
}
public Dialog getVisibleDialog() {
return visibleDialog;
}
@ -473,7 +493,7 @@ public class BaseFragment {
return getAccountInstance().getContactsController();
}
protected MediaDataController getMediaDataController() {
public MediaDataController getMediaDataController() {
return getAccountInstance().getMediaDataController();
}
@ -493,11 +513,11 @@ public class BaseFragment {
return getAccountInstance().getMessagesStorage();
}
protected SendMessagesHelper getSendMessagesHelper() {
public SendMessagesHelper getSendMessagesHelper() {
return getAccountInstance().getSendMessagesHelper();
}
protected FileLoader getFileLoader() {
public FileLoader getFileLoader() {
return getAccountInstance().getFileLoader();
}

View file

@ -61,6 +61,8 @@ public class BottomSheet extends Dialog {
protected ContainerView container;
private WindowInsets lastInsets;
protected boolean useSmoothKeyboard;
protected Runnable startAnimationRunnable;
private int layoutCount;
@ -695,7 +697,7 @@ public class BottomSheet extends Dialog {
params.dimAmount = 0;
params.flags &= ~WindowManager.LayoutParams.FLAG_DIM_BEHIND;
if (focusable) {
params.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE;
params.softInputMode = useSmoothKeyboard ? WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN : WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE;
} else {
params.flags |= WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM;
}
@ -727,7 +729,7 @@ public class BottomSheet extends Dialog {
Window window = getWindow();
WindowManager.LayoutParams params = window.getAttributes();
if (focusable) {
params.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE;
params.softInputMode = (useSmoothKeyboard ? WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN : WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
params.flags &=~ WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM;
} else {
params.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING;
@ -748,7 +750,7 @@ public class BottomSheet extends Dialog {
public void show() {
super.show();
if (focusable) {
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
getWindow().setSoftInputMode(useSmoothKeyboard ? WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN : WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
}
dismissed = false;
cancelSheetAnimation();

View file

@ -37,6 +37,7 @@ import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.BuildVars;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.R;
import org.telegram.messenger.SharedConfig;
public class DrawerLayoutContainer extends FrameLayout {
@ -76,9 +77,13 @@ public class DrawerLayoutContainer extends FrameLayout {
private boolean drawerOpened;
private boolean allowDrawContent = true;
private AdjustPanLayoutHelper adjustPanLayoutHelper;
public DrawerLayoutContainer(Context context) {
super(context);
adjustPanLayoutHelper = new AdjustPanLayoutHelper(this);
minDrawerMargin = (int) (MIN_DRAWER_MARGIN * AndroidUtilities.density + 0.5f);
setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);
setFocusableInTouchMode(true);
@ -488,6 +493,12 @@ public class DrawerLayoutContainer extends FrameLayout {
invalidate();
}
@Override
protected void dispatchDraw(Canvas canvas) {
adjustPanLayoutHelper.update();
super.dispatchDraw(canvas);
}
@Override
protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
if (!allowDrawContent) {
@ -543,10 +554,12 @@ public class DrawerLayoutContainer extends FrameLayout {
if (Build.VERSION.SDK_INT >= 21 && lastInsets != null) {
WindowInsets insets = (WindowInsets) lastInsets;
int bottomInset = insets.getSystemWindowInsetBottom();
if (bottomInset > 0) {
backgroundPaint.setColor(behindKeyboardColor);
canvas.drawRect(0, getMeasuredHeight() - bottomInset, getMeasuredWidth(), getMeasuredHeight(), backgroundPaint);
if (!SharedConfig.smoothKeyboard) {
int bottomInset = insets.getSystemWindowInsetBottom();
if (bottomInset > 0) {
backgroundPaint.setColor(behindKeyboardColor);
canvas.drawRect(0, getMeasuredHeight() - bottomInset, getMeasuredWidth(), getMeasuredHeight(), backgroundPaint);
}
}
if (hasCutout) {

View file

@ -10,12 +10,13 @@ package org.telegram.ui.ActionBar;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.LinearGradient;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.PorterDuffXfermode;
import android.graphics.Shader;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.os.SystemClock;
import android.text.Layout;
import android.text.SpannableStringBuilder;
@ -49,8 +50,8 @@ public class SimpleTextView extends View implements Drawable.Callback {
private float scrollingOffset;
private long lastUpdateTime;
private int currentScrollDelay;
private GradientDrawable fadeDrawable;
private GradientDrawable fadeDrawableBack;
private Paint fadePaint;
private Paint fadePaintBack;
private int lastWidth;
private int offsetX;
@ -107,8 +108,15 @@ public class SimpleTextView extends View implements Drawable.Callback {
}
scrollNonFitText = value;
if (scrollNonFitText) {
fadeDrawable = new GradientDrawable(GradientDrawable.Orientation.LEFT_RIGHT, new int[]{0xffffffff, 0});
fadeDrawableBack = new GradientDrawable(GradientDrawable.Orientation.LEFT_RIGHT, new int[]{0, 0xffffffff});
fadePaint = new Paint();
LinearGradient gradient = new LinearGradient(0, 0, AndroidUtilities.dp(6), 0, new int[]{0xffffffff, 0}, new float[]{0f, 1f}, Shader.TileMode.CLAMP);
fadePaint.setShader(gradient);
fadePaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_OUT));
fadePaintBack = new Paint();
gradient = new LinearGradient(0, 0, AndroidUtilities.dp(6), 0, new int[]{0, 0xffffffff}, new float[]{0f, 1f}, Shader.TileMode.CLAMP);
fadePaintBack.setShader(gradient);
fadePaintBack.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_OUT));
}
requestLayout();
}
@ -383,6 +391,12 @@ public class SimpleTextView extends View implements Drawable.Callback {
@Override
protected void onDraw(Canvas canvas) {
int textOffsetX = 0;
boolean fade = scrollNonFitText && (textDoesNotFit || scrollingOffset != 0);
if (fade) {
canvas.saveLayerAlpha(0, 0, getMeasuredWidth(), getMeasuredHeight(), 255, Canvas.ALL_SAVE_FLAG);
}
totalWidth = textWidth;
if (leftDrawable != null) {
int x = (int) -scrollingOffset;
@ -456,37 +470,25 @@ public class SimpleTextView extends View implements Drawable.Callback {
if (offsetX + textOffsetX != 0 || offsetY != 0 || scrollingOffset != 0) {
canvas.restore();
}
if (scrollNonFitText && (textDoesNotFit || scrollingOffset != 0)) {
if (fade) {
if (scrollingOffset < AndroidUtilities.dp(10)) {
fadeDrawable.setAlpha((int) (255 * (scrollingOffset / AndroidUtilities.dp(10))));
fadePaint.setAlpha((int) (255 * (scrollingOffset / AndroidUtilities.dp(10))));
} else if (scrollingOffset > totalWidth + AndroidUtilities.dp(DIST_BETWEEN_SCROLLING_TEXT) - AndroidUtilities.dp(10)) {
float dist = scrollingOffset - (totalWidth + AndroidUtilities.dp(DIST_BETWEEN_SCROLLING_TEXT) - AndroidUtilities.dp(10));
fadeDrawable.setAlpha((int) (255 * (1.0f - dist / AndroidUtilities.dp(10))));
fadePaint.setAlpha((int) (255 * (1.0f - dist / AndroidUtilities.dp(10))));
} else {
fadeDrawable.setAlpha(255);
fadePaint.setAlpha(255);
}
fadeDrawable.setBounds(0, 0, AndroidUtilities.dp(6), getMeasuredHeight());
fadeDrawable.draw(canvas);
fadeDrawableBack.setBounds(getMeasuredWidth() - AndroidUtilities.dp(6), 0, getMeasuredWidth(), getMeasuredHeight());
fadeDrawableBack.draw(canvas);
canvas.drawRect(0, 0, AndroidUtilities.dp(6), getMeasuredHeight(), fadePaint);
canvas.save();
canvas.translate(getMeasuredWidth() - AndroidUtilities.dp(6), 0);
canvas.drawRect(0, 0, AndroidUtilities.dp(6), getMeasuredHeight(), fadePaintBack);
canvas.restore();
}
updateScrollAnimation();
}
}
@Override
public void setBackgroundColor(int color) {
if (scrollNonFitText) {
if (fadeDrawable != null) {
fadeDrawable.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.MULTIPLY));
fadeDrawableBack.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.MULTIPLY));
}
} else {
super.setBackgroundColor(color);
}
}
private void updateScrollAnimation() {
if (!scrollNonFitText || !textDoesNotFit && scrollingOffset == 0) {
return;

View file

@ -125,15 +125,25 @@ public class Theme {
private boolean isSelected;
private Path path;
private Rect backupRect = new Rect();
private boolean isOut;
private int topY;
private boolean isTopNear;
private boolean isBottomNear;
private int[] currentShadowDrawableRadius = new int[4];
private int[] currentShadowDrawableRadius = new int[]{-1, -1, -1, -1};
private Drawable[] shadowDrawable = new Drawable[4];
private int shadowDrawableColor = 0xffffffff;
private int[] shadowDrawableColor = new int[]{0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff};
private int[][] currentBackgroundDrawableRadius = new int[][]{
{-1, -1, -1, -1},
{-1, -1, -1, -1}};
private Drawable[][] backgroundDrawable = new Drawable[2][4];
private int[][] backgroundDrawableColor = new int[][]{
{0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff},
{0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff}};
public static final int TYPE_TEXT = 0;
public static final int TYPE_MEDIA = 1;
@ -216,6 +226,55 @@ public class Theme {
return paint;
}
public Drawable[] getShadowDrawables() {
return shadowDrawable;
}
public Drawable getBackgroundDrawable() {
int newRad = AndroidUtilities.dp(SharedConfig.bubbleRadius);
int idx;
if (isTopNear && isBottomNear) {
idx = 3;
} else if (isTopNear) {
idx = 2;
} else if (isBottomNear) {
idx = 1;
} else {
idx = 0;
}
int idx2 = isSelected ? 1 : 0;
if (currentBackgroundDrawableRadius[idx2][idx] != newRad) {
currentBackgroundDrawableRadius[idx2][idx] = newRad;
try {
Bitmap bitmap = Bitmap.createBitmap(dp(50), dp(40), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
Paint shadowPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
shadowPaint.setColor(0xffffffff);
backupRect.set(getBounds());
setBounds(0, 0, bitmap.getWidth(), bitmap.getHeight());
draw(canvas, shadowPaint);
backgroundDrawable[idx2][idx] = new NinePatchDrawable(bitmap, getByteBuffer(bitmap.getWidth() / 2 - 1, bitmap.getWidth() / 2 + 1, bitmap.getHeight() / 2 - 1, bitmap.getHeight() / 2 + 1).array(), new Rect(), null);
backgroundDrawableColor[idx2][idx] = 0;
setBounds(backupRect);
} catch (Throwable ignore) {
}
}
int color;
if (isSelected) {
color = getColor(isOut ? key_chat_outBubbleSelected : key_chat_inBubbleSelected);
} else {
color = getColor(isOut ? key_chat_outBubble : key_chat_inBubble);
}
if (backgroundDrawable[idx2][idx] != null && backgroundDrawableColor[idx2][idx] != color) {
backgroundDrawable[idx2][idx].setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.MULTIPLY));
backgroundDrawableColor[idx2][idx] = color;
}
return backgroundDrawable[idx2][idx];
}
public Drawable getShadowDrawable() {
int newRad = AndroidUtilities.dp(SharedConfig.bubbleRadius);
int idx;
@ -235,7 +294,10 @@ public class Theme {
Canvas canvas = new Canvas(bitmap);
Paint shadowPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
shadowPaint.setColor(0x155F6569);
LinearGradient gradientShader = new LinearGradient(0, 0, 0, dp(40), new int[]{0x155F6569, 0x295F6569}, null, Shader.TileMode.CLAMP);
shadowPaint.setShader(gradientShader);
shadowPaint.setShadowLayer(2, 0, 1, 0xffffffff);
if (AndroidUtilities.density > 1) {
setBounds(-1, -1, bitmap.getWidth() + 1, bitmap.getHeight() + 1);
@ -253,15 +315,15 @@ public class Theme {
}
shadowDrawable[idx] = new NinePatchDrawable(bitmap, getByteBuffer(bitmap.getWidth() / 2 - 1, bitmap.getWidth() / 2 + 1, bitmap.getHeight() / 2 - 1, bitmap.getHeight() / 2 + 1).array(), new Rect(), null);
shadowDrawableColor = 0;
shadowDrawableColor[idx] = 0;
} catch (Throwable ignore) {
}
}
int color = getColor(isOut ? key_chat_outBubbleShadow : key_chat_inBubbleShadow);
if (shadowDrawable[idx] != null && shadowDrawableColor != color) {
if (shadowDrawable[idx] != null && shadowDrawableColor[idx] != color) {
shadowDrawable[idx].setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.MULTIPLY));
shadowDrawableColor = color;
shadowDrawableColor[idx] = color;
}
return shadowDrawable[idx];
}
@ -309,6 +371,14 @@ public class Theme {
public void draw(Canvas canvas, Paint paintToUse) {
Rect bounds = getBounds();
if (paintToUse == null && gradientShader == null) {
Drawable background = getBackgroundDrawable();
if (background != null) {
background.setBounds(bounds);
background.draw(canvas);
return;
}
}
int padding = dp(2);
int rad;
int nearRad;
@ -1825,7 +1895,7 @@ public class Theme {
public static int serviceSelectedMessageColorBackup;
private static int serviceMessage2Color;
private static int serviceSelectedMessage2Color;
private static int currentColor;
public static int currentColor;
private static int currentSelectedColor;
private static Drawable wallpaper;
private static Drawable themedWallpaper;
@ -2602,6 +2672,11 @@ public class Theme {
public static final String key_profile_verifiedCheck = "profile_verifiedCheck";
public static final String key_profile_status = "profile_status";
public static final String key_profile_tabText = "profile_tabText";
public static final String key_profile_tabSelectedText = "profile_tabSelectedText";
public static final String key_profile_tabSelectedLine = "profile_tabSelectedLine";
public static final String key_profile_tabSelector = "profile_tabSelector";
public static final String key_sharedMedia_startStopLoadIcon = "sharedMedia_startStopLoadIcon";
public static final String key_sharedMedia_linkPlaceholder = "sharedMedia_linkPlaceholder";
public static final String key_sharedMedia_linkPlaceholderText = "sharedMedia_linkPlaceholderText";
@ -3271,6 +3346,11 @@ public class Theme {
defaultColors.put(key_profile_title, 0xffffffff);
defaultColors.put(key_profile_status, 0xffd7eafa);
defaultColors.put(key_profile_tabText, 0xff878c90);
defaultColors.put(key_profile_tabSelectedText, 0xff3a95d5);
defaultColors.put(key_profile_tabSelectedLine, 0xff4fa6e9);
defaultColors.put(key_profile_tabSelector, 0x0f000000);
defaultColors.put(key_player_actionBar, 0xffffffff);
defaultColors.put(key_player_actionBarSelector, 0x0f000000);
defaultColors.put(key_player_actionBarTitle, 0xff2f3438);
@ -3517,6 +3597,11 @@ public class Theme {
fallbackKeys.put(key_chat_inPollWrongAnswer, key_chat_attachAudioBackground);
fallbackKeys.put(key_chat_outPollWrongAnswer, key_chat_attachAudioBackground);
fallbackKeys.put(key_profile_tabText, key_windowBackgroundWhiteGrayText);
fallbackKeys.put(key_profile_tabSelectedText, key_windowBackgroundWhiteBlueHeader);
fallbackKeys.put(key_profile_tabSelectedLine, key_windowBackgroundWhiteBlueHeader);
fallbackKeys.put(key_profile_tabSelector, key_listSelector);
themeAccentExclusionKeys.addAll(Arrays.asList(keys_avatar_background));
themeAccentExclusionKeys.addAll(Arrays.asList(keys_avatar_nameInMessage));
themeAccentExclusionKeys.add(key_chat_attachFileBackground);
@ -4124,6 +4209,8 @@ public class Theme {
int eventType = -1;
if (monthOfYear == 11 && dayOfMonth >= 24 && dayOfMonth <= 31 || monthOfYear == 0 && dayOfMonth == 1) {
eventType = 0;
} else if (monthOfYear == 1 && dayOfMonth == 14) {
eventType = 1;
}
return eventType;
}

View file

@ -237,7 +237,9 @@ public class ThemeDescription {
if (drawablesToUpdate[a] == null) {
continue;
}
if (drawablesToUpdate[a] instanceof ScamDrawable) {
if (drawablesToUpdate[a] instanceof BackDrawable) {
((BackDrawable) drawablesToUpdate[a]).setColor(color);
} else if (drawablesToUpdate[a] instanceof ScamDrawable) {
((ScamDrawable) drawablesToUpdate[a]).setColor(color);
} else if (drawablesToUpdate[a] instanceof RLottieDrawable) {
if (lottieLayerName != null) {
@ -699,6 +701,7 @@ public class ThemeDescription {
((RadialProgressView) object).setProgressColor(color);
} else if (object instanceof Paint) {
((Paint) object).setColor(color);
child.invalidate();
} else if (object instanceof SeekBarView) {
if ((changeFlags & FLAG_PROGRESSBAR) != 0) {
((SeekBarView) object).setOuterColor(color);

View file

@ -249,20 +249,29 @@ public class ActionIntroActivity extends BaseFragment implements LocationControl
int y = (height - imageView.getMeasuredHeight()) / 2;
imageView.layout(0, y, imageView.getMeasuredWidth(), y + imageView.getMeasuredHeight());
int x = (int) (width * 0.4f);
y = (int) (height * 0.22f);
y = (int) (height * 0.08f);
titleTextView.layout(x, y, x + titleTextView.getMeasuredWidth(), y + titleTextView.getMeasuredHeight());
x = (int) (width * 0.4f + (width * 0.6f - descriptionLayout.getMeasuredWidth()) / 2);
y = (int) (height * 0.39f);
y = (int) (height * 0.25f);
descriptionLayout.layout(x, y, x + descriptionLayout.getMeasuredWidth(), y + descriptionLayout.getMeasuredHeight());
x = (int) (width * 0.4f + (width * 0.6f - buttonTextView.getMeasuredWidth()) / 2);
y = (int) (height * 0.74f);
y = (int) (height * 0.78f);
buttonTextView.layout(x, y, x + buttonTextView.getMeasuredWidth(), y + buttonTextView.getMeasuredHeight());
} else {
int y = (int) (height * 0.148f);
imageView.layout(0, y, imageView.getMeasuredWidth(), y + imageView.getMeasuredHeight());
y = (int) (height * 0.551f);
titleTextView.layout(0, y, titleTextView.getMeasuredWidth(), y + titleTextView.getMeasuredHeight());
y = (int) (height * 0.631f);
int y;
if (AndroidUtilities.displaySize.y < 1800) {
y = (int) (height * 0.06f);
imageView.layout(0, y, imageView.getMeasuredWidth(), y + imageView.getMeasuredHeight());
y = (int) (height * 0.463f);
titleTextView.layout(0, y, titleTextView.getMeasuredWidth(), y + titleTextView.getMeasuredHeight());
y = (int) (height * 0.543f);
} else {
y = (int) (height * 0.148f);
imageView.layout(0, y, imageView.getMeasuredWidth(), y + imageView.getMeasuredHeight());
y = (int) (height * 0.551f);
titleTextView.layout(0, y, titleTextView.getMeasuredWidth(), y + titleTextView.getMeasuredHeight());
y = (int) (height * 0.631f);
}
int x = (getMeasuredWidth() - descriptionLayout.getMeasuredWidth()) / 2;
descriptionLayout.layout(x, y, x + descriptionLayout.getMeasuredWidth(), y + descriptionLayout.getMeasuredHeight());
x = (width - buttonTextView.getMeasuredWidth()) / 2;

View file

@ -221,6 +221,17 @@ public class DrawerLayoutAdapter extends RecyclerListView.SelectionAdapter {
items.add(null); // divider
items.add(new Item(7, LocaleController.getString("InviteFriends", R.string.InviteFriends), R.drawable.menu_invite_ny));
items.add(new Item(9, LocaleController.getString("TelegramFAQ", R.string.TelegramFAQ), R.drawable.menu_help_ny));
} else if (eventType == 1) {
items.add(new Item(2, LocaleController.getString("NewGroup", R.string.NewGroup), R.drawable.menu_groups_14));
items.add(new Item(3, LocaleController.getString("NewSecretChat", R.string.NewSecretChat), R.drawable.menu_secret_14));
items.add(new Item(4, LocaleController.getString("NewChannel", R.string.NewChannel), R.drawable.menu_broadcast_14));
items.add(new Item(6, LocaleController.getString("Contacts", R.string.Contacts), R.drawable.menu_contacts_14));
items.add(new Item(10, LocaleController.getString("Calls", R.string.Calls), R.drawable.menu_calls_14));
items.add(new Item(11, LocaleController.getString("SavedMessages", R.string.SavedMessages), R.drawable.menu_bookmarks_14));
items.add(new Item(8, LocaleController.getString("Settings", R.string.Settings), R.drawable.menu_settings_14));
items.add(null); // divider
items.add(new Item(7, LocaleController.getString("InviteFriends", R.string.InviteFriends), R.drawable.menu_secret_ny));
items.add(new Item(9, LocaleController.getString("TelegramFAQ", R.string.TelegramFAQ), R.drawable.menu_help));
} else {
items.add(new Item(2, LocaleController.getString("NewGroup", R.string.NewGroup), R.drawable.menu_groups));
items.add(new Item(3, LocaleController.getString("NewSecretChat", R.string.NewSecretChat), R.drawable.menu_secret));

View file

@ -3761,7 +3761,7 @@ public class ArticleViewer implements NotificationCenter.NotificationCenterDeleg
windowLayoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
windowLayoutParams.gravity = Gravity.TOP | Gravity.LEFT;
windowLayoutParams.type = WindowManager.LayoutParams.LAST_APPLICATION_WINDOW;
windowLayoutParams.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE;
windowLayoutParams.softInputMode = SharedConfig.smoothKeyboard ? WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN : WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE;
windowLayoutParams.flags = WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM;
if (Build.VERSION.SDK_INT >= 21) {
windowLayoutParams.flags |= WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN |

View file

@ -55,6 +55,7 @@ import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.FileLoader;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.R;
import org.telegram.messenger.SharedConfig;
import org.telegram.messenger.UserObject;
import org.telegram.tgnet.TLRPC;
import org.telegram.messenger.UserConfig;
@ -212,7 +213,7 @@ public class AudioSelectActivity extends BaseFragment implements NotificationCen
editText.setCursorColor(Theme.getColor(Theme.key_dialogTextBlack));
editText.setHintTextColor(Theme.getColor(Theme.key_chat_messagePanelHint));
sizeNotifierFrameLayout = new SizeNotifierFrameLayout(context) {
sizeNotifierFrameLayout = new SizeNotifierFrameLayout(context, SharedConfig.smoothKeyboard) {
private int lastNotifyWidth;
private boolean ignoreLayout;
@ -225,18 +226,27 @@ public class AudioSelectActivity extends BaseFragment implements NotificationCen
setMeasuredDimension(widthSize, heightSize);
int keyboardSize = getKeyboardHeight();
int kbHeight = getKeyboardHeight();
int keyboardSize = SharedConfig.smoothKeyboard ? 0 : kbHeight;
if (keyboardSize <= AndroidUtilities.dp(20)) {
if (!AndroidUtilities.isInMultiwindow && commentTextView != null && frameLayout2.getParent() == this) {
heightSize -= commentTextView.getEmojiPadding();
heightMeasureSpec = MeasureSpec.makeMeasureSpec(heightSize, MeasureSpec.EXACTLY);
}
} else if (commentTextView != null) {
}
if (kbHeight > AndroidUtilities.dp(20) && commentTextView != null) {
ignoreLayout = true;
commentTextView.hideEmojiView();
ignoreLayout = false;
}
if (SharedConfig.smoothKeyboard && commentTextView != null && commentTextView.isPopupShowing()) {
fragmentView.setTranslationY(getCurrentPanTranslationY());
listView.setTranslationY(0);
emptyView.setTranslationY(0);
}
int childCount = getChildCount();
for (int i = 0; i < childCount; i++) {
View child = getChildAt(i);
@ -269,7 +279,8 @@ public class AudioSelectActivity extends BaseFragment implements NotificationCen
}
final int count = getChildCount();
int paddingBottom = commentTextView != null && frameLayout2.getParent() == this && getKeyboardHeight() <= AndroidUtilities.dp(20) && !AndroidUtilities.isInMultiwindow && !AndroidUtilities.isTablet() ? commentTextView.getEmojiPadding() : 0;
int keyboardSize = SharedConfig.smoothKeyboard ? 0 : getKeyboardHeight();
int paddingBottom = commentTextView != null && frameLayout2.getParent() == this && keyboardSize <= AndroidUtilities.dp(20) && !AndroidUtilities.isInMultiwindow && !AndroidUtilities.isTablet() ? commentTextView.getEmojiPadding() : 0;
setBottomClip(paddingBottom);
for (int i = 0; i < count; i++) {
@ -323,7 +334,7 @@ public class AudioSelectActivity extends BaseFragment implements NotificationCen
if (AndroidUtilities.isTablet()) {
childTop = getMeasuredHeight() - child.getMeasuredHeight();
} else {
childTop = getMeasuredHeight() + getKeyboardHeight() - child.getMeasuredHeight();
childTop = getMeasuredHeight() + keyboardSize - child.getMeasuredHeight();
}
}
child.layout(childLeft, childTop, childLeft + width, childTop + height);
@ -390,7 +401,7 @@ public class AudioSelectActivity extends BaseFragment implements NotificationCen
listView.setOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
if (newState == RecyclerView.SCROLL_STATE_DRAGGING && searching && searchWas) {
if (newState == RecyclerView.SCROLL_STATE_DRAGGING) {
AndroidUtilities.hideKeyboard(getParentActivity().getCurrentFocus());
}
}
@ -583,6 +594,21 @@ public class AudioSelectActivity extends BaseFragment implements NotificationCen
return fragmentView;
}
@Override
protected void onPanTranslationUpdate(int y) {
if (listView == null) {
return;
}
if (commentTextView.isPopupShowing()) {
fragmentView.setTranslationY(y);
listView.setTranslationY(0);
emptyView.setTranslationY(0);
} else {
listView.setTranslationY(y);
emptyView.setTranslationY(y);
}
}
private void updateEmptyView() {
if (loadingAudio) {
listView.setEmptyView(progressView);

View file

@ -11,6 +11,9 @@ package org.telegram.ui.Cells;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.text.Layout;
import android.text.Spannable;
import android.text.StaticLayout;
@ -78,6 +81,11 @@ public class ChatActionCell extends BaseCell {
private int customDate;
private CharSequence customText;
private String overrideBackground;
private String overrideText;
private ColorFilter overrideColorFilter;
private int overrideColor;
private ChatActionCellDelegate delegate;
public ChatActionCell(Context context) {
@ -125,6 +133,11 @@ public class ChatActionCell extends BaseCell {
}
}
public void setOverrideColor(String background, String text) {
overrideBackground = background;
overrideText = text;
}
public void setMessageObject(MessageObject messageObject) {
if (currentMessageObject == messageObject && (hasReplyMessage || messageObject.replyMessageObject == null)) {
return;
@ -407,197 +420,222 @@ public class ChatActionCell extends BaseCell {
imageReceiver.draw(canvas);
}
if (textLayout != null) {
final int count = textLayout.getLineCount();
final int corner = AndroidUtilities.dp(11);
final int cornerOffset = AndroidUtilities.dp(6);
final int cornerRest = corner - cornerOffset;
final int cornerIn = AndroidUtilities.dp(8);
int y = AndroidUtilities.dp(7);
int previousLineBottom = 0;
int previousLineHeight = 0;
int dx;
int dx2;
int dy;
for (int a = 0; a < count; a++) {
int width = findMaxWidthAroundLine(a);
int x = (getMeasuredWidth() - width - cornerRest) / 2;
width += cornerRest;
int lineBottom = textLayout.getLineBottom(a);
int height = lineBottom - previousLineBottom;
int additionalHeight = 0;
previousLineBottom = lineBottom;
if (textLayout == null) {
return;
}
boolean drawBottomCorners = a == count - 1;
boolean drawTopCorners = a == 0;
if (overrideBackground != null) {
int color = Theme.getColor(overrideBackground);
if (color != overrideColor) {
overrideColor = color;
overrideColorFilter = new PorterDuffColorFilter(overrideColor, PorterDuff.Mode.MULTIPLY);
}
for (int a = 0; a < 4; a++) {
Theme.chat_cornerOuter[a].setColorFilter(overrideColorFilter);
Theme.chat_cornerInner[a].setColorFilter(overrideColorFilter);
}
Theme.chat_actionBackgroundPaint.setColor(overrideColor);
Theme.chat_actionTextPaint.setColor(Theme.getColor(overrideText));
}
if (drawTopCorners) {
y -= AndroidUtilities.dp(3);
height += AndroidUtilities.dp(3);
}
if (drawBottomCorners) {
height += AndroidUtilities.dp(3);
}
final int count = textLayout.getLineCount();
final int corner = AndroidUtilities.dp(11);
final int cornerOffset = AndroidUtilities.dp(6);
final int cornerRest = corner - cornerOffset;
final int cornerIn = AndroidUtilities.dp(8);
int y = AndroidUtilities.dp(7);
int previousLineBottom = 0;
int previousLineHeight = 0;
int dx;
int dx2;
int dy;
for (int a = 0; a < count; a++) {
int width = findMaxWidthAroundLine(a);
int x = (getMeasuredWidth() - width - cornerRest) / 2;
width += cornerRest;
int lineBottom = textLayout.getLineBottom(a);
int height = lineBottom - previousLineBottom;
int additionalHeight = 0;
previousLineBottom = lineBottom;
int yOld = y;
int hOld = height;
boolean drawBottomCorners = a == count - 1;
boolean drawTopCorners = a == 0;
int drawInnerBottom = 0;
int drawInnerTop = 0;
int nextLineWidth = 0;
int prevLineWidth = 0;
if (!drawBottomCorners && a + 1 < count) {
nextLineWidth = findMaxWidthAroundLine(a + 1) + cornerRest;
if (nextLineWidth + cornerRest * 2 < width) {
drawInnerBottom = 1;
drawBottomCorners = true;
} else if (width + cornerRest * 2 < nextLineWidth) {
drawInnerBottom = 2;
} else {
drawInnerBottom = 3;
}
}
if (!drawTopCorners && a > 0) {
prevLineWidth = findMaxWidthAroundLine(a - 1) + cornerRest;
if (prevLineWidth + cornerRest * 2 < width) {
drawInnerTop = 1;
drawTopCorners = true;
} else if (width + cornerRest * 2 < prevLineWidth) {
drawInnerTop = 2;
} else {
drawInnerTop = 3;
}
}
if (drawInnerBottom != 0) {
if (drawInnerBottom == 1) {
int nextX = (getMeasuredWidth() - nextLineWidth) / 2;
additionalHeight = AndroidUtilities.dp(3);
if (isLineBottom(nextLineWidth, width, a + 1, count, cornerRest)) {
canvas.drawRect(x + cornerOffset, y + height, nextX - cornerRest, y + height + AndroidUtilities.dp(3), Theme.chat_actionBackgroundPaint);
canvas.drawRect(nextX + nextLineWidth + cornerRest, y + height, x + width - cornerOffset, y + height + AndroidUtilities.dp(3), Theme.chat_actionBackgroundPaint);
} else {
canvas.drawRect(x + cornerOffset, y + height, nextX, y + height + AndroidUtilities.dp(3), Theme.chat_actionBackgroundPaint);
canvas.drawRect(nextX + nextLineWidth, y + height, x + width - cornerOffset, y + height + AndroidUtilities.dp(3), Theme.chat_actionBackgroundPaint);
}
} else if (drawInnerBottom == 2) {
additionalHeight = AndroidUtilities.dp(3);
dy = y + height - AndroidUtilities.dp(11);
dx = x - cornerIn;
if (drawInnerTop != 2 && drawInnerTop != 3) {
dx -= cornerRest;
}
if (drawTopCorners || drawBottomCorners) {
canvas.drawRect(dx + cornerIn, dy + AndroidUtilities.dp(3), dx + cornerIn + corner, dy + corner, Theme.chat_actionBackgroundPaint);
}
Theme.chat_cornerInner[2].setBounds(dx, dy, dx + cornerIn, dy + cornerIn);
Theme.chat_cornerInner[2].draw(canvas);
dx = x + width;
if (drawInnerTop != 2 && drawInnerTop != 3) {
dx += cornerRest;
}
if (drawTopCorners || drawBottomCorners) {
canvas.drawRect(dx - corner, dy + AndroidUtilities.dp(3), dx, dy + corner, Theme.chat_actionBackgroundPaint);
}
Theme.chat_cornerInner[3].setBounds(dx, dy, dx + cornerIn, dy + cornerIn);
Theme.chat_cornerInner[3].draw(canvas);
} else {
additionalHeight = AndroidUtilities.dp(6);
}
}
if (drawInnerTop != 0) {
if (drawInnerTop == 1) {
int prevX = (getMeasuredWidth() - prevLineWidth) / 2;
y -= AndroidUtilities.dp(3);
height += AndroidUtilities.dp(3);
if (isLineTop(prevLineWidth, width, a - 1, count, cornerRest)) {
canvas.drawRect(x + cornerOffset, y, prevX - cornerRest, y + AndroidUtilities.dp(3), Theme.chat_actionBackgroundPaint);
canvas.drawRect(prevX + prevLineWidth + cornerRest, y, x + width - cornerOffset, y + AndroidUtilities.dp(3), Theme.chat_actionBackgroundPaint);
} else {
canvas.drawRect(x + cornerOffset, y, prevX, y + AndroidUtilities.dp(3), Theme.chat_actionBackgroundPaint);
canvas.drawRect(prevX + prevLineWidth, y, x + width - cornerOffset, y + AndroidUtilities.dp(3), Theme.chat_actionBackgroundPaint);
}
} else if (drawInnerTop == 2) {
y -= AndroidUtilities.dp(3);
height += AndroidUtilities.dp(3);
dy = previousLineHeight;
dx = x - cornerIn;
if (drawInnerBottom != 2 && drawInnerBottom != 3) {
dx -= cornerRest;
}
if (drawTopCorners || drawBottomCorners) {
canvas.drawRect(dx + cornerIn, y + AndroidUtilities.dp(3), dx + cornerIn + corner, y + AndroidUtilities.dp(11), Theme.chat_actionBackgroundPaint);
}
Theme.chat_cornerInner[0].setBounds(dx, dy, dx + cornerIn, dy + cornerIn);
Theme.chat_cornerInner[0].draw(canvas);
dx = x + width;
if (drawInnerBottom != 2 && drawInnerBottom != 3) {
dx += cornerRest;
}
if (drawTopCorners || drawBottomCorners) {
canvas.drawRect(dx - corner, y + AndroidUtilities.dp(3), dx, y + AndroidUtilities.dp(11), Theme.chat_actionBackgroundPaint);
}
Theme.chat_cornerInner[1].setBounds(dx, dy, dx + cornerIn, dy + cornerIn);
Theme.chat_cornerInner[1].draw(canvas);
} else {
y -= AndroidUtilities.dp(6);
height += AndroidUtilities.dp(6);
}
}
if (drawTopCorners || drawBottomCorners) {
canvas.drawRect(x + cornerOffset, yOld, x + width - cornerOffset, yOld + hOld, Theme.chat_actionBackgroundPaint);
} else {
canvas.drawRect(x, yOld, x + width, yOld + hOld, Theme.chat_actionBackgroundPaint);
}
dx = x - cornerRest;
dx2 = x + width - cornerOffset;
if (drawTopCorners && !drawBottomCorners && drawInnerBottom != 2) {
canvas.drawRect(dx, y + corner, dx + corner, y + height + additionalHeight - AndroidUtilities.dp(6), Theme.chat_actionBackgroundPaint);
canvas.drawRect(dx2, y + corner, dx2 + corner, y + height + additionalHeight - AndroidUtilities.dp(6), Theme.chat_actionBackgroundPaint);
} else if (drawBottomCorners && !drawTopCorners && drawInnerTop != 2) {
canvas.drawRect(dx, y + corner - AndroidUtilities.dp(5), dx + corner, y + height + additionalHeight - corner, Theme.chat_actionBackgroundPaint);
canvas.drawRect(dx2, y + corner - AndroidUtilities.dp(5), dx2 + corner, y + height + additionalHeight - corner, Theme.chat_actionBackgroundPaint);
} else if (drawTopCorners || drawBottomCorners) {
canvas.drawRect(dx, y + corner, dx + corner, y + height + additionalHeight - corner, Theme.chat_actionBackgroundPaint);
canvas.drawRect(dx2, y + corner, dx2 + corner, y + height + additionalHeight - corner, Theme.chat_actionBackgroundPaint);
}
if (drawTopCorners) {
Theme.chat_cornerOuter[0].setBounds(dx, y, dx + corner, y + corner);
Theme.chat_cornerOuter[0].draw(canvas);
Theme.chat_cornerOuter[1].setBounds(dx2, y, dx2 + corner, y + corner);
Theme.chat_cornerOuter[1].draw(canvas);
}
if (drawBottomCorners) {
dy = y + height + additionalHeight - corner;
Theme.chat_cornerOuter[2].setBounds(dx2, dy, dx2 + corner, dy + corner);
Theme.chat_cornerOuter[2].draw(canvas);
Theme.chat_cornerOuter[3].setBounds(dx, dy, dx + corner, dy + corner);
Theme.chat_cornerOuter[3].draw(canvas);
}
y += height;
previousLineHeight = y + additionalHeight;
if (drawTopCorners) {
y -= AndroidUtilities.dp(3);
height += AndroidUtilities.dp(3);
}
if (drawBottomCorners) {
height += AndroidUtilities.dp(3);
}
canvas.save();
canvas.translate(textXLeft, textY);
textLayout.draw(canvas);
canvas.restore();
int yOld = y;
int hOld = height;
int drawInnerBottom = 0;
int drawInnerTop = 0;
int nextLineWidth = 0;
int prevLineWidth = 0;
if (!drawBottomCorners && a + 1 < count) {
nextLineWidth = findMaxWidthAroundLine(a + 1) + cornerRest;
if (nextLineWidth + cornerRest * 2 < width) {
drawInnerBottom = 1;
drawBottomCorners = true;
} else if (width + cornerRest * 2 < nextLineWidth) {
drawInnerBottom = 2;
} else {
drawInnerBottom = 3;
}
}
if (!drawTopCorners && a > 0) {
prevLineWidth = findMaxWidthAroundLine(a - 1) + cornerRest;
if (prevLineWidth + cornerRest * 2 < width) {
drawInnerTop = 1;
drawTopCorners = true;
} else if (width + cornerRest * 2 < prevLineWidth) {
drawInnerTop = 2;
} else {
drawInnerTop = 3;
}
}
if (drawInnerBottom != 0) {
if (drawInnerBottom == 1) {
int nextX = (getMeasuredWidth() - nextLineWidth) / 2;
additionalHeight = AndroidUtilities.dp(3);
if (isLineBottom(nextLineWidth, width, a + 1, count, cornerRest)) {
canvas.drawRect(x + cornerOffset, y + height, nextX - cornerRest, y + height + AndroidUtilities.dp(3), Theme.chat_actionBackgroundPaint);
canvas.drawRect(nextX + nextLineWidth + cornerRest, y + height, x + width - cornerOffset, y + height + AndroidUtilities.dp(3), Theme.chat_actionBackgroundPaint);
} else {
canvas.drawRect(x + cornerOffset, y + height, nextX, y + height + AndroidUtilities.dp(3), Theme.chat_actionBackgroundPaint);
canvas.drawRect(nextX + nextLineWidth, y + height, x + width - cornerOffset, y + height + AndroidUtilities.dp(3), Theme.chat_actionBackgroundPaint);
}
} else if (drawInnerBottom == 2) {
additionalHeight = AndroidUtilities.dp(3);
dy = y + height - AndroidUtilities.dp(11);
dx = x - cornerIn;
if (drawInnerTop != 2 && drawInnerTop != 3) {
dx -= cornerRest;
}
if (drawTopCorners || drawBottomCorners) {
canvas.drawRect(dx + cornerIn, dy + AndroidUtilities.dp(3), dx + cornerIn + corner, dy + corner, Theme.chat_actionBackgroundPaint);
}
Theme.chat_cornerInner[2].setBounds(dx, dy, dx + cornerIn, dy + cornerIn);
Theme.chat_cornerInner[2].draw(canvas);
dx = x + width;
if (drawInnerTop != 2 && drawInnerTop != 3) {
dx += cornerRest;
}
if (drawTopCorners || drawBottomCorners) {
canvas.drawRect(dx - corner, dy + AndroidUtilities.dp(3), dx, dy + corner, Theme.chat_actionBackgroundPaint);
}
Theme.chat_cornerInner[3].setBounds(dx, dy, dx + cornerIn, dy + cornerIn);
Theme.chat_cornerInner[3].draw(canvas);
} else {
additionalHeight = AndroidUtilities.dp(6);
}
}
if (drawInnerTop != 0) {
if (drawInnerTop == 1) {
int prevX = (getMeasuredWidth() - prevLineWidth) / 2;
y -= AndroidUtilities.dp(3);
height += AndroidUtilities.dp(3);
if (isLineTop(prevLineWidth, width, a - 1, count, cornerRest)) {
canvas.drawRect(x + cornerOffset, y, prevX - cornerRest, y + AndroidUtilities.dp(3), Theme.chat_actionBackgroundPaint);
canvas.drawRect(prevX + prevLineWidth + cornerRest, y, x + width - cornerOffset, y + AndroidUtilities.dp(3), Theme.chat_actionBackgroundPaint);
} else {
canvas.drawRect(x + cornerOffset, y, prevX, y + AndroidUtilities.dp(3), Theme.chat_actionBackgroundPaint);
canvas.drawRect(prevX + prevLineWidth, y, x + width - cornerOffset, y + AndroidUtilities.dp(3), Theme.chat_actionBackgroundPaint);
}
} else if (drawInnerTop == 2) {
y -= AndroidUtilities.dp(3);
height += AndroidUtilities.dp(3);
dy = previousLineHeight;
dx = x - cornerIn;
if (drawInnerBottom != 2 && drawInnerBottom != 3) {
dx -= cornerRest;
}
if (drawTopCorners || drawBottomCorners) {
canvas.drawRect(dx + cornerIn, y + AndroidUtilities.dp(3), dx + cornerIn + corner, y + AndroidUtilities.dp(11), Theme.chat_actionBackgroundPaint);
}
Theme.chat_cornerInner[0].setBounds(dx, dy, dx + cornerIn, dy + cornerIn);
Theme.chat_cornerInner[0].draw(canvas);
dx = x + width;
if (drawInnerBottom != 2 && drawInnerBottom != 3) {
dx += cornerRest;
}
if (drawTopCorners || drawBottomCorners) {
canvas.drawRect(dx - corner, y + AndroidUtilities.dp(3), dx, y + AndroidUtilities.dp(11), Theme.chat_actionBackgroundPaint);
}
Theme.chat_cornerInner[1].setBounds(dx, dy, dx + cornerIn, dy + cornerIn);
Theme.chat_cornerInner[1].draw(canvas);
} else {
y -= AndroidUtilities.dp(6);
height += AndroidUtilities.dp(6);
}
}
if (drawTopCorners || drawBottomCorners) {
canvas.drawRect(x + cornerOffset, yOld, x + width - cornerOffset, yOld + hOld, Theme.chat_actionBackgroundPaint);
} else {
canvas.drawRect(x, yOld, x + width, yOld + hOld, Theme.chat_actionBackgroundPaint);
}
dx = x - cornerRest;
dx2 = x + width - cornerOffset;
if (drawTopCorners && !drawBottomCorners && drawInnerBottom != 2) {
canvas.drawRect(dx, y + corner, dx + corner, y + height + additionalHeight - AndroidUtilities.dp(6), Theme.chat_actionBackgroundPaint);
canvas.drawRect(dx2, y + corner, dx2 + corner, y + height + additionalHeight - AndroidUtilities.dp(6), Theme.chat_actionBackgroundPaint);
} else if (drawBottomCorners && !drawTopCorners && drawInnerTop != 2) {
canvas.drawRect(dx, y + corner - AndroidUtilities.dp(5), dx + corner, y + height + additionalHeight - corner, Theme.chat_actionBackgroundPaint);
canvas.drawRect(dx2, y + corner - AndroidUtilities.dp(5), dx2 + corner, y + height + additionalHeight - corner, Theme.chat_actionBackgroundPaint);
} else if (drawTopCorners || drawBottomCorners) {
canvas.drawRect(dx, y + corner, dx + corner, y + height + additionalHeight - corner, Theme.chat_actionBackgroundPaint);
canvas.drawRect(dx2, y + corner, dx2 + corner, y + height + additionalHeight - corner, Theme.chat_actionBackgroundPaint);
}
if (drawTopCorners) {
Theme.chat_cornerOuter[0].setBounds(dx, y, dx + corner, y + corner);
Theme.chat_cornerOuter[0].draw(canvas);
Theme.chat_cornerOuter[1].setBounds(dx2, y, dx2 + corner, y + corner);
Theme.chat_cornerOuter[1].draw(canvas);
}
if (drawBottomCorners) {
dy = y + height + additionalHeight - corner;
Theme.chat_cornerOuter[2].setBounds(dx2, dy, dx2 + corner, dy + corner);
Theme.chat_cornerOuter[2].draw(canvas);
Theme.chat_cornerOuter[3].setBounds(dx, dy, dx + corner, dy + corner);
Theme.chat_cornerOuter[3].draw(canvas);
}
y += height;
previousLineHeight = y + additionalHeight;
}
canvas.save();
canvas.translate(textXLeft, textY);
textLayout.draw(canvas);
canvas.restore();
if (overrideColorFilter != null) {
for (int a = 0; a < 4; a++) {
Theme.chat_cornerOuter[a].setColorFilter(Theme.colorFilter);
Theme.chat_cornerInner[a].setColorFilter(Theme.colorFilter);
}
Theme.chat_actionBackgroundPaint.setColor(Theme.currentColor);
Theme.chat_actionTextPaint.setColor(Theme.getColor(Theme.key_chat_serviceText));
}
}

View file

@ -4187,6 +4187,8 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
currentPhotoObjectThumb = FileLoader.getClosestPhotoSizeWithSize(messageObject.photoThumbs, 40);
photoParentObject = messageObject.photoThumbsObject;
photoImage.setRoundRadius(0);
canChangeRadius = false;
if (messageObject.attachPathExists) {
photoImage.setImage(ImageLocation.getForPath(messageObject.messageOwner.attachPath), filter,
ImageLocation.getForObject(currentPhotoObjectThumb, photoParentObject), "b1",
@ -4365,9 +4367,6 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
} else {
w = h = (int) (Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) * 0.5f);
}
} else if (messageObject.isAnyKindOfSticker()) {
photoImage.setRoundRadius(0);
canChangeRadius = false;
}
int widthForCaption = 0;
@ -5753,7 +5752,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
timeX += AndroidUtilities.dp(4);
}
}
if (SharedConfig.bubbleRadius >= 10 && captionLayout == null) {
if (SharedConfig.bubbleRadius >= 10 && captionLayout == null && documentAttachType != DOCUMENT_ATTACH_TYPE_ROUND && documentAttachType != DOCUMENT_ATTACH_TYPE_STICKER) {
timeX -= AndroidUtilities.dp(2);
}
} else {
@ -7934,7 +7933,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
viaWidth = (int) Math.ceil(Theme.chat_replyNamePaint.measureText(viaString, 0, viaString.length()));
}
boolean authorName = !pinnedTop && drawName && isChat && !currentMessageObject.isOutOwner();
boolean authorName = (!pinnedTop || ChatObject.isChannel(currentChat) && !currentChat.megagroup) && drawName && isChat && !currentMessageObject.isOutOwner();
boolean viaBot = (messageObject.messageOwner.fwd_from == null || messageObject.type == 14) && viaUsername != null;
if (authorName || viaBot) {
drawNameLayout = true;
@ -8945,6 +8944,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
if (drawPinnedBottom) {
canvas.translate(0, AndroidUtilities.dp(2));
}
boolean bigRadius = false;
if (mediaBackground && captionLayout == null) {
Paint paint;
if (currentMessageObject.shouldDrawWithoutBackground()) {
@ -8955,16 +8955,19 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
int oldAlpha = paint.getAlpha();
paint.setAlpha((int) (oldAlpha * timeAlpha));
Theme.chat_timePaint.setAlpha((int) (255 * timeAlpha));
int x1 = timeX - AndroidUtilities.dp(SharedConfig.bubbleRadius >= 10 ? 6 : 4);
int y1 = layoutHeight - AndroidUtilities.dp(28);
rect.set(x1, y1, x1 + timeWidth + AndroidUtilities.dp((SharedConfig.bubbleRadius >= 10 ? 12 : 8) + (currentMessageObject.isOutOwner() ? 20 : 0)), y1 + AndroidUtilities.dp(17));
int r;
if (documentAttachType != DOCUMENT_ATTACH_TYPE_ROUND) {
if (documentAttachType != DOCUMENT_ATTACH_TYPE_ROUND && documentAttachType != DOCUMENT_ATTACH_TYPE_STICKER) {
int[] rad = photoImage.getRoundRadius();
r = Math.min(AndroidUtilities.dp(8), Math.max(rad[2], rad[3]));
bigRadius = SharedConfig.bubbleRadius >= 10;
} else {
r = AndroidUtilities.dp(4);
}
int x1 = timeX - AndroidUtilities.dp(bigRadius ? 6 : 4);
int y1 = layoutHeight - AndroidUtilities.dp(28);
rect.set(x1, y1, x1 + timeWidth + AndroidUtilities.dp((bigRadius ? 12 : 8) + (currentMessageObject.isOutOwner() ? 20 : 0)), y1 + AndroidUtilities.dp(17));
canvas.drawRoundRect(rect, r, r, paint);
paint.setAlpha(oldAlpha);
@ -9088,11 +9091,11 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
if (mediaBackground && captionLayout == null) {
if (currentMessageObject.shouldDrawWithoutBackground()) {
Theme.chat_msgStickerClockDrawable.setAlpha((int) (255 * timeAlpha));
setDrawableBounds(Theme.chat_msgStickerClockDrawable, layoutWidth - AndroidUtilities.dp(22.0f) - Theme.chat_msgStickerClockDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(13.5f) - Theme.chat_msgStickerClockDrawable.getIntrinsicHeight());
setDrawableBounds(Theme.chat_msgStickerClockDrawable, layoutWidth - AndroidUtilities.dp(bigRadius ? 24 : 22) - Theme.chat_msgStickerClockDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(13.5f) - Theme.chat_msgStickerClockDrawable.getIntrinsicHeight());
Theme.chat_msgStickerClockDrawable.draw(canvas);
Theme.chat_msgStickerClockDrawable.setAlpha(255);
} else {
setDrawableBounds(Theme.chat_msgMediaClockDrawable, layoutWidth - AndroidUtilities.dp(22.0f) - Theme.chat_msgMediaClockDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(13.5f) - Theme.chat_msgMediaClockDrawable.getIntrinsicHeight());
setDrawableBounds(Theme.chat_msgMediaClockDrawable, layoutWidth - AndroidUtilities.dp(bigRadius ? 24 : 22) - Theme.chat_msgMediaClockDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(13.5f) - Theme.chat_msgMediaClockDrawable.getIntrinsicHeight());
Theme.chat_msgMediaClockDrawable.draw(canvas);
}
} else {
@ -9104,7 +9107,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
if (isBroadcast) {
if (drawCheck1 || drawCheck2) {
if (mediaBackground && captionLayout == null) {
setDrawableBounds(Theme.chat_msgBroadcastMediaDrawable, layoutWidth - AndroidUtilities.dp(24.0f) - Theme.chat_msgBroadcastMediaDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(14.0f) - Theme.chat_msgBroadcastMediaDrawable.getIntrinsicHeight());
setDrawableBounds(Theme.chat_msgBroadcastMediaDrawable, layoutWidth - AndroidUtilities.dp(bigRadius ? 26 : 24) - Theme.chat_msgBroadcastMediaDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(14.0f) - Theme.chat_msgBroadcastMediaDrawable.getIntrinsicHeight());
Theme.chat_msgBroadcastMediaDrawable.draw(canvas);
} else {
setDrawableBounds(Theme.chat_msgBroadcastDrawable, layoutWidth - AndroidUtilities.dp(20.5f) - Theme.chat_msgBroadcastDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(8.0f) - Theme.chat_msgBroadcastDrawable.getIntrinsicHeight());
@ -9116,16 +9119,16 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
if (mediaBackground && captionLayout == null) {
if (currentMessageObject.shouldDrawWithoutBackground()) {
if (drawCheck1) {
setDrawableBounds(Theme.chat_msgStickerCheckDrawable, layoutWidth - AndroidUtilities.dp(26.3f) - Theme.chat_msgStickerCheckDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(13.5f) - Theme.chat_msgStickerCheckDrawable.getIntrinsicHeight());
setDrawableBounds(Theme.chat_msgStickerCheckDrawable, layoutWidth - AndroidUtilities.dp(bigRadius ? 28.3f : 26.3f) - Theme.chat_msgStickerCheckDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(13.5f) - Theme.chat_msgStickerCheckDrawable.getIntrinsicHeight());
} else {
setDrawableBounds(Theme.chat_msgStickerCheckDrawable, layoutWidth - AndroidUtilities.dp(21.5f) - Theme.chat_msgStickerCheckDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(13.5f) - Theme.chat_msgStickerCheckDrawable.getIntrinsicHeight());
setDrawableBounds(Theme.chat_msgStickerCheckDrawable, layoutWidth - AndroidUtilities.dp(bigRadius ? 23.5f : 21.5f) - Theme.chat_msgStickerCheckDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(13.5f) - Theme.chat_msgStickerCheckDrawable.getIntrinsicHeight());
}
Theme.chat_msgStickerCheckDrawable.draw(canvas);
} else {
if (drawCheck1) {
setDrawableBounds(Theme.chat_msgMediaCheckDrawable, layoutWidth - AndroidUtilities.dp(26.3f) - Theme.chat_msgMediaCheckDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(13.5f) - Theme.chat_msgMediaCheckDrawable.getIntrinsicHeight());
setDrawableBounds(Theme.chat_msgMediaCheckDrawable, layoutWidth - AndroidUtilities.dp(bigRadius ? 28.3f : 26.3f) - Theme.chat_msgMediaCheckDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(13.5f) - Theme.chat_msgMediaCheckDrawable.getIntrinsicHeight());
} else {
setDrawableBounds(Theme.chat_msgMediaCheckDrawable, layoutWidth - AndroidUtilities.dp(21.5f) - Theme.chat_msgMediaCheckDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(13.5f) - Theme.chat_msgMediaCheckDrawable.getIntrinsicHeight());
setDrawableBounds(Theme.chat_msgMediaCheckDrawable, layoutWidth - AndroidUtilities.dp(bigRadius ? 23.5f : 21.5f) - Theme.chat_msgMediaCheckDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(13.5f) - Theme.chat_msgMediaCheckDrawable.getIntrinsicHeight());
}
Theme.chat_msgMediaCheckDrawable.setAlpha((int) (255 * timeAlpha));
Theme.chat_msgMediaCheckDrawable.draw(canvas);
@ -9135,10 +9138,10 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
Drawable drawable;
if (drawCheck1) {
drawable = isDrawSelectionBackground() ? Theme.chat_msgOutCheckReadSelectedDrawable : Theme.chat_msgOutCheckReadDrawable;
setDrawableBounds(drawable, layoutWidth - AndroidUtilities.dp(22.5f) - drawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(8.0f) - drawable.getIntrinsicHeight());
setDrawableBounds(drawable, layoutWidth - AndroidUtilities.dp(22.5f) - drawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(pinnedBottom || pinnedTop ? 9 : 8) - drawable.getIntrinsicHeight());
} else {
drawable = isDrawSelectionBackground() ? Theme.chat_msgOutCheckSelectedDrawable : Theme.chat_msgOutCheckDrawable;
setDrawableBounds(drawable, layoutWidth - AndroidUtilities.dp(18.5f) - drawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(8.0f) - drawable.getIntrinsicHeight());
setDrawableBounds(drawable, layoutWidth - AndroidUtilities.dp(18.5f) - drawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(pinnedBottom || pinnedTop ? 9 : 8) - drawable.getIntrinsicHeight());
}
drawable.draw(canvas);
}
@ -9146,17 +9149,17 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
if (drawCheck1) {
if (mediaBackground && captionLayout == null) {
if (currentMessageObject.shouldDrawWithoutBackground()) {
setDrawableBounds(Theme.chat_msgStickerHalfCheckDrawable, layoutWidth - AndroidUtilities.dp(21.5f) - Theme.chat_msgStickerHalfCheckDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(13.5f) - Theme.chat_msgStickerHalfCheckDrawable.getIntrinsicHeight());
setDrawableBounds(Theme.chat_msgStickerHalfCheckDrawable, layoutWidth - AndroidUtilities.dp(bigRadius ? 23.5f : 21.5f) - Theme.chat_msgStickerHalfCheckDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(13.5f) - Theme.chat_msgStickerHalfCheckDrawable.getIntrinsicHeight());
Theme.chat_msgStickerHalfCheckDrawable.draw(canvas);
} else {
setDrawableBounds(Theme.chat_msgMediaHalfCheckDrawable, layoutWidth - AndroidUtilities.dp(21.5f) - Theme.chat_msgMediaHalfCheckDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(13.5f) - Theme.chat_msgMediaHalfCheckDrawable.getIntrinsicHeight());
setDrawableBounds(Theme.chat_msgMediaHalfCheckDrawable, layoutWidth - AndroidUtilities.dp(bigRadius ? 23.5f : 21.5f) - Theme.chat_msgMediaHalfCheckDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(13.5f) - Theme.chat_msgMediaHalfCheckDrawable.getIntrinsicHeight());
Theme.chat_msgMediaHalfCheckDrawable.setAlpha((int) (255 * timeAlpha));
Theme.chat_msgMediaHalfCheckDrawable.draw(canvas);
Theme.chat_msgMediaHalfCheckDrawable.setAlpha(255);
}
} else {
Drawable drawable = isDrawSelectionBackground() ? Theme.chat_msgOutHalfCheckSelectedDrawable : Theme.chat_msgOutHalfCheckDrawable;
setDrawableBounds(drawable, layoutWidth - AndroidUtilities.dp(18) - drawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(8.0f) - drawable.getIntrinsicHeight());
setDrawableBounds(drawable, layoutWidth - AndroidUtilities.dp(18) - drawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(pinnedBottom || pinnedTop ? 9 : 8) - drawable.getIntrinsicHeight());
drawable.draw(canvas);
}
}
@ -9169,7 +9172,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
y = layoutHeight - AndroidUtilities.dp(26.5f);
} else {
x = layoutWidth - AndroidUtilities.dp(32);
y = layoutHeight - AndroidUtilities.dp(21);
y = layoutHeight - AndroidUtilities.dp(pinnedBottom || pinnedTop ? 22 : 21);
}
rect.set(x, y, x + AndroidUtilities.dp(14), y + AndroidUtilities.dp(14));
canvas.drawRoundRect(rect, AndroidUtilities.dp(1), AndroidUtilities.dp(1), Theme.chat_msgErrorPaint);

View file

@ -134,6 +134,13 @@ public class ManageChatUserCell extends FrameLayout {
super.onMeasure(MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(64) + (needDivider ? 1 : 0), MeasureSpec.EXACTLY));
}
public int getUserId() {
if (currentObject instanceof TLRPC.User) {
return ((TLRPC.User) currentObject).id;
}
return 0;
}
public void setStatusColors(int color, int onlineColor) {
statusColor = color;
statusOnlineColor = onlineColor;
@ -143,6 +150,10 @@ public class ManageChatUserCell extends FrameLayout {
isAdmin = value;
}
public boolean hasAvatarSet() {
return avatarImageView.getImageReceiver().hasNotThumb();
}
public void update(int mask) {
if (currentObject == null) {
return;

View file

@ -204,6 +204,14 @@ public class ProfileSearchCell extends BaseCell {
}
}
public TLRPC.User getUser() {
return user;
}
public TLRPC.Chat getChat() {
return chat;
}
public void setSublabelOffset(int x, int y) {
sublabelOffsetX = x;
sublabelOffsetY = y;

View file

@ -271,6 +271,24 @@ public class SharedPhotoVideoCell extends FrameLayout {
}
}
@Override
public void invalidate() {
for (int a = 0; a < 6; a++) {
photoVideoViews[a].invalidate();
}
super.invalidate();
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
}
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
}
public void setDelegate(SharedPhotoVideoCellDelegate delegate) {
this.delegate = delegate;
}

View file

@ -838,7 +838,6 @@ public class ChangePhoneActivity extends BaseFragment {
private Timer timeTimer;
private Timer codeTimer;
private int openTime;
private final Object timerSync = new Object();
private int time = 60000;
private int codeTime = 15000;
@ -1100,7 +1099,6 @@ public class ChangePhoneActivity extends BaseFragment {
requestPhone = params.getString("phoneFormated");
phoneHash = params.getString("phoneHash");
timeout = time = params.getInt("timeout");
openTime = (int) (System.currentTimeMillis() / 1000);
nextType = params.getInt("nextType");
pattern = params.getString("pattern");
length = params.getInt("length");

View file

@ -32,7 +32,7 @@ import android.os.Build;
import android.os.Bundle;
import androidx.core.content.FileProvider;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.LinearSmoothScrollerMiddle;
import androidx.recyclerview.widget.LinearSmoothScrollerCustom;
import androidx.recyclerview.widget.RecyclerView;
import android.text.TextUtils;
@ -73,6 +73,7 @@ import org.telegram.messenger.MessageObject;
import org.telegram.messenger.MessagesController;
import org.telegram.messenger.NotificationCenter;
import org.telegram.messenger.R;
import org.telegram.messenger.SharedConfig;
import org.telegram.messenger.UserConfig;
import org.telegram.messenger.Utilities;
import org.telegram.messenger.browser.Browser;
@ -556,7 +557,7 @@ public class ChannelAdminLogActivity extends BaseFragment implements Notificatio
avatarContainer.setSubtitle(LocaleController.getString("EventLogAllEvents", R.string.EventLogAllEvents));
avatarContainer.setChatAvatar(currentChat);
fragmentView = new SizeNotifierFrameLayout(context) {
fragmentView = new SizeNotifierFrameLayout(context, SharedConfig.smoothKeyboard) {
@Override
protected void onAttachedToWindow() {
@ -596,8 +597,6 @@ public class ChannelAdminLogActivity extends BaseFragment implements Notificatio
heightSize -= actionBarHeight;
}
int keyboardSize = getKeyboardHeight();
int childCount = getChildCount();
for (int i = 0; i < childCount; i++) {
@ -773,7 +772,7 @@ public class ChannelAdminLogActivity extends BaseFragment implements Notificatio
@Override
public void smoothScrollToPosition(RecyclerView recyclerView, RecyclerView.State state, int position) {
LinearSmoothScrollerMiddle linearSmoothScroller = new LinearSmoothScrollerMiddle(recyclerView.getContext());
LinearSmoothScrollerCustom linearSmoothScroller = new LinearSmoothScrollerCustom(recyclerView.getContext(), LinearSmoothScrollerCustom.POSITION_MIDDLE);
linearSmoothScroller.setTargetPosition(position);
startSmoothScroll(linearSmoothScroller);
}
@ -1958,7 +1957,7 @@ public class ChannelAdminLogActivity extends BaseFragment implements Notificatio
args.putInt("user_id", user.id);
addCanBanUser(args, user.id);
ProfileActivity fragment = new ProfileActivity(args);
fragment.setPlayProfileAnimation(false);
fragment.setPlayProfileAnimation(0);
presentFragment(fragment);
}
}
@ -2188,7 +2187,7 @@ public class ChannelAdminLogActivity extends BaseFragment implements Notificatio
args.putInt("user_id", uid);
addCanBanUser(args, uid);
ProfileActivity fragment = new ProfileActivity(args);
fragment.setPlayProfileAnimation(false);
fragment.setPlayProfileAnimation(0);
presentFragment(fragment);
}
}
@ -2429,11 +2428,13 @@ public class ChannelAdminLogActivity extends BaseFragment implements Notificatio
new ThemeDescription(chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_avatar_nameInMessagePink),
new ThemeDescription(chatListView, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{Theme.chat_msgInDrawable, Theme.chat_msgInMediaDrawable}, null, Theme.key_chat_inBubble),
new ThemeDescription(chatListView, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{Theme.chat_msgInSelectedDrawable, Theme.chat_msgInMediaSelectedDrawable}, null, Theme.key_chat_inBubbleSelected),
new ThemeDescription(chatListView, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{Theme.chat_msgInDrawable.getShadowDrawable(), Theme.chat_msgInMediaDrawable.getShadowDrawable()}, null, Theme.key_chat_inBubbleShadow),
new ThemeDescription(chatListView, 0, new Class[]{ChatMessageCell.class}, null, Theme.chat_msgInDrawable.getShadowDrawables(), null, Theme.key_chat_inBubbleShadow),
new ThemeDescription(chatListView, 0, new Class[]{ChatMessageCell.class}, null, Theme.chat_msgInMediaDrawable.getShadowDrawables(), null, Theme.key_chat_inBubbleShadow),
new ThemeDescription(chatListView, 0, new Class[]{ChatMessageCell.class}, null, Theme.chat_msgOutDrawable.getShadowDrawables(), null, Theme.key_chat_outBubbleShadow),
new ThemeDescription(chatListView, 0, new Class[]{ChatMessageCell.class}, null, Theme.chat_msgOutMediaDrawable.getShadowDrawables(), null, Theme.key_chat_outBubbleShadow),
new ThemeDescription(chatListView, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{Theme.chat_msgOutDrawable, Theme.chat_msgOutMediaDrawable}, null, Theme.key_chat_outBubble),
new ThemeDescription(chatListView, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{Theme.chat_msgOutDrawable, Theme.chat_msgOutMediaDrawable}, null, Theme.key_chat_outBubbleGradient),
new ThemeDescription(chatListView, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{Theme.chat_msgOutSelectedDrawable, Theme.chat_msgOutMediaSelectedDrawable}, null, Theme.key_chat_outBubbleSelected),
new ThemeDescription(chatListView, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{Theme.chat_msgOutDrawable.getShadowDrawable(), Theme.chat_msgOutMediaDrawable.getShadowDrawable()}, null, Theme.key_chat_outBubbleShadow),
new ThemeDescription(chatListView, ThemeDescription.FLAG_TEXTCOLOR, new Class[]{ChatActionCell.class}, Theme.chat_actionTextPaint, null, null, Theme.key_chat_serviceText),
new ThemeDescription(chatListView, ThemeDescription.FLAG_LINKCOLOR, new Class[]{ChatActionCell.class}, Theme.chat_actionTextPaint, null, null, Theme.key_chat_serviceLink),

View file

@ -44,6 +44,7 @@ import org.telegram.messenger.LocaleController;
import org.telegram.messenger.MessagesController;
import org.telegram.messenger.NotificationCenter;
import org.telegram.messenger.R;
import org.telegram.messenger.SharedConfig;
import org.telegram.tgnet.ConnectionsManager;
import org.telegram.tgnet.TLRPC;
import org.telegram.ui.ActionBar.ActionBar;
@ -286,7 +287,7 @@ public class ChannelCreateActivity extends BaseFragment implements NotificationC
if (currentStep == 0) {
actionBar.setTitle(LocaleController.getString("NewChannel", R.string.NewChannel));
SizeNotifierFrameLayout sizeNotifierFrameLayout = new SizeNotifierFrameLayout(context) {
SizeNotifierFrameLayout sizeNotifierFrameLayout = new SizeNotifierFrameLayout(context, SharedConfig.smoothKeyboard) {
private boolean ignoreLayout;
@ -300,7 +301,7 @@ public class ChannelCreateActivity extends BaseFragment implements NotificationC
measureChildWithMargins(actionBar, widthMeasureSpec, 0, heightMeasureSpec, 0);
int keyboardSize = getKeyboardHeight();
int keyboardSize = SharedConfig.smoothKeyboard ? 0 : getKeyboardHeight();
if (keyboardSize > AndroidUtilities.dp(20)) {
ignoreLayout = true;
nameTextView.hideEmojiView();
@ -333,7 +334,8 @@ public class ChannelCreateActivity extends BaseFragment implements NotificationC
protected void onLayout(boolean changed, int l, int t, int r, int b) {
final int count = getChildCount();
int paddingBottom = getKeyboardHeight() <= AndroidUtilities.dp(20) && !AndroidUtilities.isInMultiwindow && !AndroidUtilities.isTablet() ? nameTextView.getEmojiPadding() : 0;
int keyboardSize = SharedConfig.smoothKeyboard ? 0 : getKeyboardHeight();
int paddingBottom = keyboardSize <= AndroidUtilities.dp(20) && !AndroidUtilities.isInMultiwindow && !AndroidUtilities.isTablet() ? nameTextView.getEmojiPadding() : 0;
setBottomClip(paddingBottom);
for (int i = 0; i < count; i++) {
@ -387,7 +389,7 @@ public class ChannelCreateActivity extends BaseFragment implements NotificationC
if (AndroidUtilities.isTablet()) {
childTop = getMeasuredHeight() - child.getMeasuredHeight();
} else {
childTop = getMeasuredHeight() + getKeyboardHeight() - child.getMeasuredHeight();
childTop = getMeasuredHeight() + keyboardSize - child.getMeasuredHeight();
}
}
child.layout(childLeft, childTop, childLeft + width, childTop + height);

View file

@ -48,7 +48,7 @@ import android.provider.MediaStore;
import androidx.core.content.FileProvider;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.LinearSmoothScrollerMiddle;
import androidx.recyclerview.widget.LinearSmoothScrollerCustom;
import androidx.recyclerview.widget.RecyclerView;
import android.text.Layout;
@ -97,6 +97,7 @@ import org.telegram.PhoneFormat.PhoneFormat;
import org.telegram.messenger.BuildConfig;
import org.telegram.messenger.BuildVars;
import org.telegram.messenger.ChatObject;
import org.telegram.messenger.EmojiData;
import org.telegram.messenger.MediaDataController;
import org.telegram.messenger.Emoji;
import org.telegram.messenger.ImageLocation;
@ -286,6 +287,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
private TextView reportSpamButton;
private ImageView closeReportSpam;
private FragmentContextView fragmentContextView;
private FragmentContextView fragmentLocationContextView;
private View replyLineView;
private TextView emptyView;
private TextView gifHintTextView;
@ -537,6 +539,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
private FireworksOverlay fireworksOverlay;
private boolean swipeBackEnabled = true;
public static Pattern publicMsgUrlPattern;
public static Pattern privateMsgUrlPattern;
@ -660,7 +664,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
object.viewX = coords[0];
object.viewY = coords[1] - (Build.VERSION.SDK_INT >= 21 ? 0 : AndroidUtilities.statusBarHeight);
object.parentView = chatListView;
object.animatingImageView = pagedownButton != null && pagedownButton.getTag() != null ? animatingImageView : null;
object.animatingImageView = !SharedConfig.smoothKeyboard && pagedownButton != null && pagedownButton.getTag() != null ? animatingImageView : null;
object.imageReceiver = imageReceiver;
if (needPreview) {
object.thumb = imageReceiver.getBitmapSafe();
@ -672,7 +676,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (pinnedMessageView != null && pinnedMessageView.getTag() == null || topChatPanelView != null && topChatPanelView.getTag() == null) {
object.clipTopAddition = AndroidUtilities.dp(48);
}
object.clipTopAddition += chatListViewClipTop;
object.clipTopAddition += chatListViewClipTop + getCurrentPanTranslationY();
return object;
}
}
@ -1099,6 +1103,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (chatActivityEnterView != null) {
chatActivityEnterView.onDestroy();
}
if (avatarContainer != null) {
avatarContainer.onDestroy();
}
if (mentionsAdapter != null) {
mentionsAdapter.onDestroy();
}
@ -1468,6 +1475,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
});
if (avatarContainer != null) {
avatarContainer.onDestroy();
}
avatarContainer = new ChatAvatarContainer(context, this, currentEncryptedChat != null);
if (inPreviewMode) {
avatarContainer.setOccupyStatusBar(false);
@ -1741,7 +1751,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
};
fragmentView = new SizeNotifierFrameLayout(context, parentLayout) {
fragmentView = new SizeNotifierFrameLayout(context, SharedConfig.smoothKeyboard, parentLayout) {
int inputFieldHeight = 0;
@ -1838,7 +1848,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
}
if (child == actionBar && parentLayout != null) {
parentLayout.drawHeaderShadow(canvas, actionBar.getVisibility() == VISIBLE ? actionBar.getMeasuredHeight() + (inPreviewMode && Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0) : 0);
parentLayout.drawHeaderShadow(canvas, actionBar.getVisibility() == VISIBLE ? (int) actionBar.getTranslationY() + actionBar.getMeasuredHeight() + (inPreviewMode && Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0) : 0);
}
return result;
}
@ -1869,7 +1879,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
canvas.drawRect(0, 0, getMeasuredWidth(), getMeasuredHeight(), scrimPaint);
int chatListViewTop = (int) chatListView.getY();
int chatListViewBottom = chatListViewTop + chatListView.getMeasuredHeight();
int listTop = chatListView.getTop() + chatListView.getPaddingTop() - AndroidUtilities.dp(4) + (chatActivityEnterView.getMeasuredHeight() - AndroidUtilities.dp(51));
int listTop = chatListView.getTop() + chatListView.getPaddingTop() - AndroidUtilities.dp(4) + (chatActivityEnterView.getMeasuredHeight() - AndroidUtilities.dp(51)) + getCurrentPanTranslationY();
MessageObject.GroupedMessages scrimGroup;
if (scrimView instanceof ChatMessageCell) {
scrimGroup = ((ChatMessageCell) scrimView).getCurrentMessagesGroup();
@ -2003,13 +2013,17 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
setMeasuredDimension(widthSize, heightSize);
heightSize -= getPaddingTop();
if (SharedConfig.smoothKeyboard && chatActivityEnterView.isPopupShowing()) {
setNonNoveTranslation(getCurrentPanTranslationY());
}
measureChildWithMargins(actionBar, widthMeasureSpec, 0, heightMeasureSpec, 0);
int actionBarHeight = actionBar.getMeasuredHeight();
if (actionBar.getVisibility() == VISIBLE) {
heightSize -= actionBarHeight;
}
int keyboardSize = getKeyboardHeight();
int keyboardSize = SharedConfig.smoothKeyboard ? 0 : getKeyboardHeight();
if (keyboardSize <= AndroidUtilities.dp(20)) {
if (!AndroidUtilities.isInMultiwindow) {
@ -2160,7 +2174,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
final int count = getChildCount();
int paddingBottom = getKeyboardHeight() <= AndroidUtilities.dp(20) && !AndroidUtilities.isInMultiwindow ? chatActivityEnterView.getEmojiPadding() : 0;
int keyboardSize = SharedConfig.smoothKeyboard ? 0 : getKeyboardHeight();
int paddingBottom = keyboardSize <= AndroidUtilities.dp(20) && !AndroidUtilities.isInMultiwindow ? chatActivityEnterView.getEmojiPadding() : 0;
setBottomClip(paddingBottom);
for (int i = 0; i < count; i++) {
@ -2266,6 +2281,45 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
notifyHeightChanged();
}
private void setNonNoveTranslation(int y) {
contentView.setTranslationY(y);
actionBar.setTranslationY(0);
contentView.setBackgroundTranslation(0);
if (pinnedMessageView != null) {
pinnedMessageView.setTranslationY(0);
}
if (fragmentContextView != null) {
fragmentContextView.setTranslationY(0);
}
if (fragmentLocationContextView != null) {
fragmentLocationContextView.setTranslationY(0);
}
topChatPanelView.setTranslationY(0);
}
@Override
protected void onPanTranslationUpdate(int y) {
if (getParentLayout() != null && getParentLayout().isPreviewOpenAnimationInProgress()) {
return;
}
if (chatAttachAlert != null && chatAttachAlert.isShowing() || chatActivityEnterView.isPopupShowing()) {
setNonNoveTranslation(y);
} else {
actionBar.setTranslationY(y);
contentView.setBackgroundTranslation(y);
if (pinnedMessageView != null) {
pinnedMessageView.setTranslationY(y);
}
if (fragmentContextView != null) {
fragmentContextView.setTranslationY(y);
}
if (fragmentLocationContextView != null) {
fragmentLocationContextView.setTranslationY(y);
}
topChatPanelView.setTranslationY(y);
}
}
};
contentView = (SizeNotifierFrameLayout) fragmentView;
@ -3041,7 +3095,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
@Override
public void smoothScrollToPosition(RecyclerView recyclerView, RecyclerView.State state, int position) {
LinearSmoothScrollerMiddle linearSmoothScroller = new LinearSmoothScrollerMiddle(recyclerView.getContext());
LinearSmoothScrollerCustom linearSmoothScroller = new LinearSmoothScrollerCustom(recyclerView.getContext(), LinearSmoothScrollerCustom.POSITION_MIDDLE);
linearSmoothScroller.setTargetPosition(position);
startSmoothScroll(linearSmoothScroller);
}
@ -4132,8 +4186,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
mentiondownButton.setContentDescription(LocaleController.getString("AccDescrMentionDown", R.string.AccDescrMentionDown));
if (!AndroidUtilities.isTablet() || AndroidUtilities.isSmallTablet()) {
FragmentContextView fragmentLocationContextView = new FragmentContextView(context, this, true);
contentView.addView(fragmentLocationContextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 39, Gravity.TOP | Gravity.LEFT, 0, -36, 0, 0));
contentView.addView(fragmentLocationContextView = new FragmentContextView(context, this, true), LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 39, Gravity.TOP | Gravity.LEFT, 0, -36, 0, 0));
contentView.addView(fragmentContextView = new FragmentContextView(context, this, false), LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 39, Gravity.TOP | Gravity.LEFT, 0, -36, 0, 0));
fragmentContextView.setAdditionalContextView(fragmentLocationContextView);
fragmentLocationContextView.setAdditionalContextView(fragmentContextView);
@ -4147,7 +4200,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
messagesSearchListView.setVisibility(View.GONE);
messagesSearchListView.setAlpha(0.0f);
messagesSearchListView.setAdapter(messagesSearchAdapter = new MessagesSearchAdapter(context));
contentView.addView(messagesSearchListView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.LEFT | Gravity.TOP));
contentView.addView(messagesSearchListView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.LEFT | Gravity.TOP, 0, 0, 0, 48));
messagesSearchListView.setOnItemClickListener((view, position) -> {
getMediaDataController().jumpToSearchedMessage(classGuid, position);
showMessagesSearchListView(false);
@ -5590,6 +5643,10 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
return dialog_id;
}
public long getMergeDialogId() {
return mergeDialogId;
}
public boolean hasReportSpam() {
return topChatPanelView != null && topChatPanelView.getTag() == null && reportSpamButton.getVisibility() != View.GONE;
}
@ -8406,7 +8463,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
}
if (canSave) {
if (messageObject.getDocument() != null) {
if (messageObject.getDocument() != null && !messageObject.isMusic()) {
String mime = messageObject.getDocument().mime_type;
if (mime != null) {
if (messageObject.getDocumentName().toLowerCase().endsWith("attheme")) {
@ -14036,7 +14093,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
} else {
popupY = AndroidUtilities.statusBarHeight;
}
scrimPopupWindow.showAtLocation(chatListView, Gravity.LEFT | Gravity.TOP, popupX, popupY);
scrimPopupWindow.showAtLocation(chatListView, Gravity.LEFT | Gravity.TOP, popupX, popupY - getCurrentPanTranslationY());
chatListView.stopScroll();
chatLayoutManager.setCanScrollVertically(false);
scrimView = v;
@ -14188,7 +14245,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
drawable.restart();
if (message.isAnimatedEmoji()) {
String emoji = message.getStickerEmoji();
if ("".equals(emoji)) {
if (EmojiData.isHeartEmoji(emoji)) {
HashMap<Integer, Integer> pattern = new HashMap<>();
pattern.put(1, 1);
pattern.put(13, 0);
@ -15301,6 +15358,11 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
return swipeBackEnabled;
}
@Override
public boolean isSwipeBackEnabled(MotionEvent event) {
return swipeBackEnabled;
}
public class ChatActivityAdapter extends RecyclerAnimationScrollHelper.AnimatableAdapter {
private Context mContext;
@ -15487,7 +15549,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
Bundle args = new Bundle();
args.putInt("user_id", user.id);
ProfileActivity fragment = new ProfileActivity(args);
fragment.setPlayProfileAnimation(currentUser != null && currentUser.id == user.id);
fragment.setPlayProfileAnimation(currentUser != null && currentUser.id == user.id ? 1 : 0);
presentFragment(fragment);
}
}
@ -15644,6 +15706,45 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
messageObject.forceSeekTo = seekTime / (float) messageObject.getDuration();
mediaController.playMessage(messageObject);
}
} else if (str.startsWith("card:")) {
String number = str.substring(5);
final AlertDialog[] progressDialog = new AlertDialog[]{new AlertDialog(getParentActivity(), 3)};
TLRPC.TL_payments_getBankCardData req = new TLRPC.TL_payments_getBankCardData();
req.number = number;
int requestId = getConnectionsManager().sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
try {
progressDialog[0].dismiss();
} catch (Throwable ignore) {
}
progressDialog[0] = null;
if (response instanceof TLRPC.TL_payments_bankCardData) {
TLRPC.TL_payments_bankCardData data = (TLRPC.TL_payments_bankCardData) response;
BottomSheet.Builder builder = new BottomSheet.Builder(getParentActivity());
ArrayList<CharSequence> arrayList = new ArrayList<>();
for (int a = 0, N = data.open_urls.size(); a < N; a++) {
arrayList.add(data.open_urls.get(a).name);
}
arrayList.add(LocaleController.getString("CopyCardNumber", R.string.CopyCardNumber));
builder.setTitle(data.title);
builder.setItems(arrayList.toArray(new CharSequence[0]), (dialog, which) -> {
if (which < data.open_urls.size()) {
Browser.openUrl(getParentActivity(), data.open_urls.get(which).url, inlineReturn == 0, false);
} else {
AndroidUtilities.addToClipboard(number);
Toast.makeText(ApplicationLoader.applicationContext, LocaleController.getString("CardNumberCopied", R.string.CardNumberCopied), Toast.LENGTH_SHORT).show();
}
});
showDialog(builder.create());
}
}), null, null, 0, getMessagesController().webFileDatacenterId, ConnectionsManager.ConnectionTypeGeneric, true);
AndroidUtilities.runOnUIThread(() -> {
if (progressDialog[0] == null) {
return;
}
progressDialog[0].setOnCancelListener(dialog -> getConnectionsManager().cancelRequest(requestId, true));
showDialog(progressDialog[0]);
}, 500);
}
} else {
final String urlFinal = ((URLSpan) url).getURL();
@ -15706,7 +15807,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
}
ProfileActivity fragment = new ProfileActivity(args);
fragment.setPlayProfileAnimation(true);
fragment.setPlayProfileAnimation(1);
fragment.setChatInfo(chatInfo);
fragment.setUserInfo(userInfo);
presentFragment(fragment);
@ -16015,7 +16116,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
args.putLong("dialog_id", dialog_id);
}
ProfileActivity fragment = new ProfileActivity(args);
fragment.setPlayProfileAnimation(currentUser != null && currentUser.id == uid);
fragment.setPlayProfileAnimation(currentUser != null && currentUser.id == uid ? 1 : 0);
presentFragment(fragment);
}
}
@ -16440,6 +16541,16 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
@Override
public void notifyItemRangeInserted(int positionStart, int itemCount) {
updateRows();
if (positionStart == 1 && itemCount > 0) {
int lastPosition = positionStart + itemCount;
if (lastPosition >= messagesStartRow && lastPosition < messagesEndRow) {
MessageObject m1 = messages.get(lastPosition - messagesStartRow);
MessageObject m2 = messages.get(lastPosition - messagesStartRow - 1);
if (currentChat != null && m1.messageOwner.from_id == m2.messageOwner.from_id || currentUser != null && m1.isOutOwner() == m2.isOutOwner()) {
notifyItemChanged(positionStart);
}
}
}
try {
super.notifyItemRangeInserted(positionStart, itemCount);
} catch (Exception e) {
@ -16644,12 +16755,14 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
new ThemeDescription(chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_avatar_nameInMessagePink),
new ThemeDescription(chatListView, 0, new Class[]{ChatMessageCell.class, BotHelpCell.class}, null, new Drawable[]{Theme.chat_msgInDrawable, Theme.chat_msgInMediaDrawable}, null, Theme.key_chat_inBubble),
new ThemeDescription(chatListView, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{Theme.chat_msgInSelectedDrawable, Theme.chat_msgInMediaSelectedDrawable}, null, Theme.key_chat_inBubbleSelected),
new ThemeDescription(chatListView, 0, new Class[]{ChatMessageCell.class, BotHelpCell.class}, null, new Drawable[]{Theme.chat_msgInDrawable.getShadowDrawable(), Theme.chat_msgInMediaDrawable.getShadowDrawable()}, null, Theme.key_chat_inBubbleShadow),
new ThemeDescription(chatListView, 0, new Class[]{ChatMessageCell.class}, null, Theme.chat_msgInDrawable.getShadowDrawables(), null, Theme.key_chat_inBubbleShadow),
new ThemeDescription(chatListView, 0, new Class[]{ChatMessageCell.class}, null, Theme.chat_msgInMediaDrawable.getShadowDrawables(), null, Theme.key_chat_inBubbleShadow),
new ThemeDescription(chatListView, 0, new Class[]{ChatMessageCell.class}, null, Theme.chat_msgOutDrawable.getShadowDrawables(), null, Theme.key_chat_outBubbleShadow),
new ThemeDescription(chatListView, 0, new Class[]{ChatMessageCell.class}, null, Theme.chat_msgOutMediaDrawable.getShadowDrawables(), null, Theme.key_chat_outBubbleShadow),
new ThemeDescription(chatListView, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{Theme.chat_msgOutDrawable, Theme.chat_msgOutMediaDrawable}, null, Theme.key_chat_outBubble),
new ThemeDescription(chatListView, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{Theme.chat_msgOutDrawable, Theme.chat_msgOutMediaDrawable}, null, Theme.key_chat_outBubbleGradient),
new ThemeDescription(chatListView, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{Theme.chat_msgOutSelectedDrawable, Theme.chat_msgOutMediaSelectedDrawable}, null, Theme.key_chat_outBubbleSelected),
new ThemeDescription(chatListView, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{Theme.chat_msgOutSelectedDrawable, Theme.chat_msgOutSelectedDrawable}, null, Theme.key_chat_outBubbleGradientSelectedOverlay),
new ThemeDescription(chatListView, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{Theme.chat_msgOutDrawable.getShadowDrawable(), Theme.chat_msgOutMediaDrawable.getShadowDrawable()}, null, Theme.key_chat_outBubbleShadow),
new ThemeDescription(chatListView, ThemeDescription.FLAG_TEXTCOLOR, new Class[]{ChatActionCell.class}, Theme.chat_actionTextPaint, null, null, Theme.key_chat_serviceText),
new ThemeDescription(chatListView, ThemeDescription.FLAG_LINKCOLOR, new Class[]{ChatActionCell.class}, Theme.chat_actionTextPaint, null, null, Theme.key_chat_serviceLink),

View file

@ -43,6 +43,7 @@ import org.telegram.messenger.MessagesController;
import org.telegram.messenger.MessagesStorage;
import org.telegram.messenger.NotificationCenter;
import org.telegram.messenger.R;
import org.telegram.messenger.SharedConfig;
import org.telegram.messenger.UserConfig;
import org.telegram.tgnet.TLRPC;
import org.telegram.ui.ActionBar.ActionBar;
@ -229,7 +230,7 @@ public class ChatEditActivity extends BaseFragment implements ImageUpdater.Image
}
});
SizeNotifierFrameLayout sizeNotifierFrameLayout = new SizeNotifierFrameLayout(context) {
SizeNotifierFrameLayout sizeNotifierFrameLayout = new SizeNotifierFrameLayout(context, SharedConfig.smoothKeyboard) {
private boolean ignoreLayout;
@ -243,7 +244,7 @@ public class ChatEditActivity extends BaseFragment implements ImageUpdater.Image
measureChildWithMargins(actionBar, widthMeasureSpec, 0, heightMeasureSpec, 0);
int keyboardSize = getKeyboardHeight();
int keyboardSize = SharedConfig.smoothKeyboard ? 0 : getKeyboardHeight();
if (keyboardSize > AndroidUtilities.dp(20)) {
ignoreLayout = true;
nameTextView.hideEmojiView();
@ -276,7 +277,8 @@ public class ChatEditActivity extends BaseFragment implements ImageUpdater.Image
protected void onLayout(boolean changed, int l, int t, int r, int b) {
final int count = getChildCount();
int paddingBottom = getKeyboardHeight() <= AndroidUtilities.dp(20) && !AndroidUtilities.isInMultiwindow && !AndroidUtilities.isTablet() ? nameTextView.getEmojiPadding() : 0;
int keyboardSize = SharedConfig.smoothKeyboard ? 0 : getKeyboardHeight();
int paddingBottom = keyboardSize <= AndroidUtilities.dp(20) && !AndroidUtilities.isInMultiwindow && !AndroidUtilities.isTablet() ? nameTextView.getEmojiPadding() : 0;
setBottomClip(paddingBottom);
for (int i = 0; i < count; i++) {
@ -330,7 +332,7 @@ public class ChatEditActivity extends BaseFragment implements ImageUpdater.Image
if (AndroidUtilities.isTablet()) {
childTop = getMeasuredHeight() - child.getMeasuredHeight();
} else {
childTop = getMeasuredHeight() + getKeyboardHeight() - child.getMeasuredHeight();
childTop = getMeasuredHeight() + keyboardSize - child.getMeasuredHeight();
}
}
child.layout(childLeft, childTop, childLeft + width, childTop + height);

View file

@ -21,7 +21,6 @@ import android.util.TypedValue;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.Toast;

View file

@ -294,6 +294,15 @@ public class ChatRightsEditActivity extends BaseFragment {
listView.setVerticalScrollbarPosition(LocaleController.isRTL ? RecyclerListView.SCROLLBAR_POSITION_LEFT : RecyclerListView.SCROLLBAR_POSITION_RIGHT);
frameLayout.addView(listView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
listView.setOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
if (newState == RecyclerView.SCROLL_STATE_DRAGGING) {
AndroidUtilities.hideKeyboard(getParentActivity().getCurrentFocus());
}
}
});
listView.setOnItemClickListener((view, position) -> {
if (!canEdit) {
return;

View file

@ -960,6 +960,11 @@ public class ChatUsersActivity extends BaseFragment implements NotificationCente
emptyView.showTextView();
}
updateRows();
if (needOpenSearch) {
searchItem.openSearch(false);
}
return fragmentView;
}
@ -1941,7 +1946,6 @@ public class ChatUsersActivity extends BaseFragment implements NotificationCente
public void onResume() {
super.onResume();
AndroidUtilities.requestAdjustResize(getParentActivity(), classGuid);
//AndroidUtilities.removeAdjustResize(getParentActivity(), classGuid);
if (listViewAdapter != null) {
listViewAdapter.notifyDataSetChanged();
}
@ -1965,7 +1969,8 @@ public class ChatUsersActivity extends BaseFragment implements NotificationCente
@Override
protected void onTransitionAnimationEnd(boolean isOpen, boolean backward) {
if (isOpen && !backward && needOpenSearch) {
searchItem.openSearch(true);
searchItem.getSearchField().requestFocus();
AndroidUtilities.showKeyboard(searchItem.getSearchField());
}
}

View file

@ -1,291 +0,0 @@
/*
* This is the source code of Telegram for Android v. 5.x.x.
* It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE).
*
* Copyright Nikolai Kudashov, 2013-2018.
*/
package org.telegram.ui;
import android.content.Context;
import android.graphics.Paint;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.LocaleController;
import org.telegram.messenger.MessagesController;
import org.telegram.messenger.NotificationCenter;
import org.telegram.messenger.R;
import org.telegram.tgnet.ConnectionsManager;
import org.telegram.tgnet.TLRPC;
import org.telegram.ui.ActionBar.ActionBar;
import org.telegram.ui.ActionBar.BaseFragment;
import org.telegram.ui.ActionBar.Theme;
import org.telegram.ui.ActionBar.ThemeDescription;
import org.telegram.ui.Cells.LoadingCell;
import org.telegram.ui.Cells.ProfileSearchCell;
import org.telegram.ui.Cells.TextInfoPrivacyCell;
import org.telegram.ui.Components.EmptyTextProgressView;
import org.telegram.ui.Components.LayoutHelper;
import org.telegram.ui.Components.RecyclerListView;
import java.util.ArrayList;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
public class CommonGroupsActivity extends BaseFragment {
private ListAdapter listViewAdapter;
private EmptyTextProgressView emptyView;
private RecyclerListView listView;
private LinearLayoutManager layoutManager;
private ArrayList<TLRPC.Chat> chats = new ArrayList<>();
private int userId;
private boolean loading;
private boolean firstLoaded;
private boolean endReached;
public CommonGroupsActivity(int uid) {
super();
userId = uid;
}
@Override
public boolean onFragmentCreate() {
super.onFragmentCreate();
getChats(0, 50);
return true;
}
@Override
public View createView(Context context) {
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setAllowOverlayTitle(true);
actionBar.setTitle(LocaleController.getString("GroupsInCommonTitle", R.string.GroupsInCommonTitle));
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
@Override
public void onItemClick(int id) {
if (id == -1) {
finishFragment();
}
}
});
fragmentView = new FrameLayout(context);
fragmentView.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundGray));
FrameLayout frameLayout = (FrameLayout) fragmentView;
emptyView = new EmptyTextProgressView(context);
emptyView.setText(LocaleController.getString("NoGroupsInCommon", R.string.NoGroupsInCommon));
frameLayout.addView(emptyView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
listView = new RecyclerListView(context);
listView.setEmptyView(emptyView);
listView.setLayoutManager(layoutManager = new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false));
listView.setAdapter(listViewAdapter = new ListAdapter(context));
listView.setVerticalScrollbarPosition(LocaleController.isRTL ? RecyclerListView.SCROLLBAR_POSITION_LEFT : RecyclerListView.SCROLLBAR_POSITION_RIGHT);
frameLayout.addView(listView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
listView.setOnItemClickListener((view, position) -> {
if (position < 0 || position >= chats.size()) {
return;
}
TLRPC.Chat chat = chats.get(position);
Bundle args = new Bundle();
args.putInt("chat_id", chat.id);
if (!MessagesController.getInstance(currentAccount).checkCanOpenChat(args, CommonGroupsActivity.this)) {
return;
}
NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.closeChats);
presentFragment(new ChatActivity(args), true);
});
listView.setOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
int firstVisibleItem = layoutManager.findFirstVisibleItemPosition();
int visibleItemCount = firstVisibleItem == RecyclerView.NO_POSITION ? 0 : Math.abs(layoutManager.findLastVisibleItemPosition() - firstVisibleItem) + 1;
if (visibleItemCount > 0) {
int totalItemCount = listViewAdapter.getItemCount();
if (!endReached && !loading && !chats.isEmpty() && firstVisibleItem + visibleItemCount >= totalItemCount - 5) {
getChats(chats.get(chats.size() - 1).id, 100);
}
}
}
});
if (loading) {
emptyView.showProgress();
} else {
emptyView.showTextView();
}
return fragmentView;
}
private void getChats(int max_id, final int count) {
if (loading) {
return;
}
loading = true;
if (emptyView != null && !firstLoaded) {
emptyView.showProgress();
}
if (listViewAdapter != null) {
listViewAdapter.notifyDataSetChanged();
}
TLRPC.TL_messages_getCommonChats req = new TLRPC.TL_messages_getCommonChats();
req.user_id = MessagesController.getInstance(currentAccount).getInputUser(userId);
if (req.user_id instanceof TLRPC.TL_inputUserEmpty) {
return;
}
req.limit = count;
req.max_id = max_id;
int reqId = ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
if (error == null) {
TLRPC.messages_Chats res = (TLRPC.messages_Chats) response;
MessagesController.getInstance(currentAccount).putChats(res.chats, false);
endReached = res.chats.isEmpty() || res.chats.size() != count;
chats.addAll(res.chats);
} else {
endReached = true;
}
loading = false;
firstLoaded = true;
if (emptyView != null) {
emptyView.showTextView();
}
if (listViewAdapter != null) {
listViewAdapter.notifyDataSetChanged();
}
}));
ConnectionsManager.getInstance(currentAccount).bindRequestToGuid(reqId, classGuid);
}
@Override
public void onResume() {
super.onResume();
if (listViewAdapter != null) {
listViewAdapter.notifyDataSetChanged();
}
}
private class ListAdapter extends RecyclerListView.SelectionAdapter {
private Context mContext;
public ListAdapter(Context context) {
mContext = context;
}
@Override
public boolean isEnabled(RecyclerView.ViewHolder holder) {
return holder.getAdapterPosition() != chats.size();
}
@Override
public int getItemCount() {
int count = chats.size();
if (!chats.isEmpty()) {
count++;
if (!endReached) {
count++;
}
}
return count;
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view;
switch (viewType) {
case 0:
view = new ProfileSearchCell(mContext);
view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
break;
case 1:
view = new LoadingCell(mContext);
view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
break;
case 2:
default:
view = new TextInfoPrivacyCell(mContext);
view.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
break;
}
return new RecyclerListView.Holder(view);
}
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
if (holder.getItemViewType() == 0) {
ProfileSearchCell cell = (ProfileSearchCell) holder.itemView;
TLRPC.Chat chat = chats.get(position);
cell.setData(chat, null, null, null, false, false);
cell.useSeparator = position != chats.size() - 1 || !endReached;
}
}
@Override
public int getItemViewType(int i) {
if (i < chats.size()) {
return 0;
} else if (!endReached && i == chats.size()) {
return 1;
}
return 2;
}
}
@Override
public ThemeDescription[] getThemeDescriptions() {
ThemeDescription.ThemeDescriptionDelegate cellDelegate = () -> {
if (listView != null) {
int count = listView.getChildCount();
for (int a = 0; a < count; a++) {
View child = listView.getChildAt(a);
if (child instanceof ProfileSearchCell) {
((ProfileSearchCell) child).update(0);
}
}
}
};
return new ThemeDescription[]{
new ThemeDescription(listView, ThemeDescription.FLAG_CELLBACKGROUNDCOLOR, new Class[]{LoadingCell.class, ProfileSearchCell.class}, null, null, null, Theme.key_windowBackgroundWhite),
new ThemeDescription(fragmentView, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_windowBackgroundGray),
new ThemeDescription(actionBar, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_actionBarDefault),
new ThemeDescription(listView, ThemeDescription.FLAG_LISTGLOWCOLOR, null, null, null, null, Theme.key_actionBarDefault),
new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_ITEMSCOLOR, null, null, null, null, Theme.key_actionBarDefaultIcon),
new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_TITLECOLOR, null, null, null, null, Theme.key_actionBarDefaultTitle),
new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SELECTORCOLOR, null, null, null, null, Theme.key_actionBarDefaultSelector),
new ThemeDescription(listView, ThemeDescription.FLAG_SELECTOR, null, null, null, null, Theme.key_listSelector),
new ThemeDescription(listView, 0, new Class[]{View.class}, Theme.dividerPaint, null, null, Theme.key_divider),
new ThemeDescription(emptyView, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_emptyListPlaceholder),
new ThemeDescription(emptyView, ThemeDescription.FLAG_PROGRESSBAR, null, null, null, null, Theme.key_progressCircle),
new ThemeDescription(listView, ThemeDescription.FLAG_BACKGROUNDFILTER, new Class[]{TextInfoPrivacyCell.class}, null, null, null, Theme.key_windowBackgroundGrayShadow),
new ThemeDescription(listView, 0, new Class[]{TextInfoPrivacyCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteGrayText4),
new ThemeDescription(listView, 0, new Class[]{LoadingCell.class}, new String[]{"progressBar"}, null, null, null, Theme.key_progressCircle),
new ThemeDescription(listView, 0, new Class[]{ProfileSearchCell.class}, null, new Paint[]{Theme.dialogs_namePaint[0], Theme.dialogs_namePaint[1], Theme.dialogs_searchNamePaint}, null, null, Theme.key_chats_name),
new ThemeDescription(listView, 0, new Class[]{ProfileSearchCell.class}, null, new Paint[]{Theme.dialogs_nameEncryptedPaint[0], Theme.dialogs_nameEncryptedPaint[1], Theme.dialogs_searchNameEncryptedPaint}, null, null, Theme.key_chats_secretName),
new ThemeDescription(listView, 0, new Class[]{ProfileSearchCell.class}, null, new Drawable[]{Theme.avatar_savedDrawable}, null, Theme.key_avatar_text),
new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundRed),
new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundOrange),
new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundViolet),
new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundGreen),
new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundCyan),
new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundBlue),
new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundPink),
};
}
}

View file

@ -1159,6 +1159,68 @@ public class AlertsCreator {
}
}
public interface BlockDialogCallback {
void run(boolean report, boolean delete);
}
public static void createBlockDialogAlert(BaseFragment fragment, int count, boolean reportSpam, TLRPC.User user, BlockDialogCallback onProcessRunnable) {
if (fragment == null || fragment.getParentActivity() == null || count == 1 && user == null) {
return;
}
Context context = fragment.getParentActivity();
AlertDialog.Builder builder = new AlertDialog.Builder(context);
CheckBoxCell[] cell = new CheckBoxCell[2];
LinearLayout linearLayout = new LinearLayout(context);
linearLayout.setOrientation(LinearLayout.VERTICAL);
builder.setView(linearLayout);
String actionText;
if (count == 1) {
String name = ContactsController.formatName(user.first_name, user.last_name);
builder.setTitle(LocaleController.formatString("BlockUserTitle", R.string.BlockUserTitle, name));
actionText = LocaleController.getString("BlockUser", R.string.BlockUser);
builder.setMessage(AndroidUtilities.replaceTags(LocaleController.formatString("BlockUserMessage", R.string.BlockUserMessage, name)));
} else {
builder.setTitle(LocaleController.formatString("BlockUserTitle", R.string.BlockUserTitle, LocaleController.formatPluralString("UsersCountTitle", count)));
actionText = LocaleController.getString("BlockUsers", R.string.BlockUsers);
builder.setMessage(AndroidUtilities.replaceTags(LocaleController.formatString("BlockUsersMessage", R.string.BlockUsersMessage, LocaleController.formatPluralString("UsersCount", count))));
}
final boolean[] checks = new boolean[]{true, true};
for (int a = 0; a < cell.length; a++) {
if (a == 0 && !reportSpam) {
continue;
}
int num = a;
cell[a] = new CheckBoxCell(context, 1);
cell[a].setBackgroundDrawable(Theme.getSelectorDrawable(false));
if (a == 0) {
cell[a].setText(LocaleController.getString("ReportSpamTitle", R.string.ReportSpamTitle), "", true, false);
} else {
cell[a].setText(count == 1 ? LocaleController.getString("DeleteThisChat", R.string.DeleteThisChat) : LocaleController.getString("DeleteTheseChats", R.string.DeleteTheseChats), "", true, false);
}
cell[a].setPadding(LocaleController.isRTL ? AndroidUtilities.dp(16) : AndroidUtilities.dp(8), 0, LocaleController.isRTL ? AndroidUtilities.dp(8) : AndroidUtilities.dp(16), 0);
linearLayout.addView(cell[a], LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 48));
cell[a].setOnClickListener(v -> {
CheckBoxCell cell1 = (CheckBoxCell) v;
checks[num] = !checks[num];
cell1.setChecked(checks[num], true);
});
}
builder.setPositiveButton(actionText, (dialogInterface, i) -> onProcessRunnable.run(checks[0], checks[1]));
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
AlertDialog alertDialog = builder.create();
fragment.showDialog(alertDialog);
TextView button = (TextView) alertDialog.getButton(DialogInterface.BUTTON_POSITIVE);
if (button != null) {
button.setTextColor(Theme.getColor(Theme.key_dialogTextRed2));
}
}
public interface DatePickerDelegate {
void didSelectDate(int year, int month, int dayOfMonth);
}

View file

@ -715,7 +715,7 @@ public class AudioPlayerAlert extends BottomSheet implements NotificationCenter.
listView.setOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
if (newState == RecyclerView.SCROLL_STATE_DRAGGING && searching && searchWas) {
if (newState == RecyclerView.SCROLL_STATE_DRAGGING) {
AndroidUtilities.hideKeyboard(getCurrentFocus());
}
}

View file

@ -56,8 +56,12 @@ public class BackupImageView extends View {
setImage(imageLocation, imageFilter, null, null, thumb, null, null, size, parentObject);
}
public void setImage(ImageLocation imageLocation, String imageFilter, Bitmap thumb, int size, Object parentObject) {
setImage(imageLocation, imageFilter, null, null, null, thumb, null, size, parentObject);
public void setImage(ImageLocation imageLocation, String imageFilter, Bitmap thumbBitmap, int size, int cacheType, Object parentObject) {
Drawable thumb = null;
if (thumbBitmap != null) {
thumb = new BitmapDrawable(null, thumbBitmap);
}
imageReceiver.setImage(imageLocation, imageFilter, null, null, thumb, size, null, parentObject, cacheType);
}
public void setImage(ImageLocation imageLocation, String imageFilter, ImageLocation thumbLocation, String thumbFilter, int size, Object parentObject) {

View file

@ -26,6 +26,7 @@ import android.graphics.Paint;
import android.graphics.PixelFormat;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.drawable.Drawable;
import android.media.AudioManager;
@ -1015,6 +1016,12 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
parentFragment.extendActionMode(menu);
}
}
@Override
public boolean requestRectangleOnScreen(Rect rectangle) {
rectangle.bottom += AndroidUtilities.dp(1000);
return super.requestRectangleOnScreen(rectangle);
}
};
messageEditText.setDelegate(() -> {
if (delegate != null) {

View file

@ -132,6 +132,8 @@ public class ChatAttachAlert extends BottomSheet implements NotificationCenter.N
private View shadow;
private int currentPanTranslationY;
private FrameLayout frameLayout2;
private EditTextEmoji commentTextView;
private FrameLayout writeButtonContainer;
@ -610,7 +612,7 @@ public class ChatAttachAlert extends BottomSheet implements NotificationCenter.N
cameraDrawable = context.getResources().getDrawable(R.drawable.instant_camera).mutate();
sizeNotifierFrameLayout = new SizeNotifierFrameLayout(context) {
sizeNotifierFrameLayout = new SizeNotifierFrameLayout(context, false) {
private int lastNotifyWidth;
private RectF rect = new RectF();
@ -649,7 +651,7 @@ public class ChatAttachAlert extends BottomSheet implements NotificationCenter.N
ignoreLayout = false;
}
int availableHeight = totalHeight - getPaddingTop();
int keyboardSize = getKeyboardHeight();
int keyboardSize = useSmoothKeyboard ? 0 : getKeyboardHeight();
if (!AndroidUtilities.isInMultiwindow && keyboardSize <= AndroidUtilities.dp(20)) {
availableHeight -= commentTextView.getEmojiPadding();
}
@ -710,7 +712,7 @@ public class ChatAttachAlert extends BottomSheet implements NotificationCenter.N
setMeasuredDimension(widthSize, heightSize);
widthSize -= backgroundPaddingLeft * 2;
int keyboardSize = getKeyboardHeight();
int keyboardSize = useSmoothKeyboard ? 0 : getKeyboardHeight();
if (keyboardSize <= AndroidUtilities.dp(20)) {
if (!AndroidUtilities.isInMultiwindow) {
heightSize -= commentTextView.getEmojiPadding();
@ -757,7 +759,8 @@ public class ChatAttachAlert extends BottomSheet implements NotificationCenter.N
}
final int count = getChildCount();
int paddingBottom = getKeyboardHeight() <= AndroidUtilities.dp(20) && !AndroidUtilities.isInMultiwindow && !AndroidUtilities.isTablet() ? commentTextView.getEmojiPadding() : 0;
int keyboardSize = useSmoothKeyboard ? 0 : getKeyboardHeight();
int paddingBottom = keyboardSize <= AndroidUtilities.dp(20) && !AndroidUtilities.isInMultiwindow && !AndroidUtilities.isTablet() ? commentTextView.getEmojiPadding() : 0;
setBottomClip(paddingBottom);
for (int i = 0; i < count; i++) {
@ -811,7 +814,7 @@ public class ChatAttachAlert extends BottomSheet implements NotificationCenter.N
if (AndroidUtilities.isTablet()) {
childTop = getMeasuredHeight() - child.getMeasuredHeight();
} else {
childTop = getMeasuredHeight() + getKeyboardHeight() - child.getMeasuredHeight();
childTop = getMeasuredHeight() + keyboardSize - child.getMeasuredHeight();
}
}
child.layout(childLeft, childTop, childLeft + width, childTop + height);
@ -917,6 +920,17 @@ public class ChatAttachAlert extends BottomSheet implements NotificationCenter.N
super.setTranslationY(translationY);
checkCameraViewPosition();
}
@Override
protected void onPanTranslationUpdate(int y) {
currentPanTranslationY = y;
if (commentTextView.isPopupShowing()) {
containerView.setTranslationY(y);
actionBar.setTranslationY(0);
} else {
actionBar.setTranslationY(y);
}
}
};
containerView = sizeNotifierFrameLayout;
containerView.setWillNotDraw(false);
@ -2996,7 +3010,7 @@ public class ChatAttachAlert extends BottomSheet implements NotificationCenter.N
cameraViewOffsetY = 0;
}
int containerHeight = containerView.getMeasuredHeight();
int keyboardSize = sizeNotifierFrameLayout.getKeyboardHeight();
int keyboardSize = useSmoothKeyboard ? 0 : sizeNotifierFrameLayout.getKeyboardHeight();
if (!AndroidUtilities.isInMultiwindow && keyboardSize <= AndroidUtilities.dp(20)) {
containerHeight -= commentTextView.getEmojiPadding();
}

View file

@ -22,6 +22,7 @@ import org.telegram.messenger.ChatObject;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.ImageLocation;
import org.telegram.messenger.LocaleController;
import org.telegram.messenger.MediaDataController;
import org.telegram.messenger.MessagesController;
import org.telegram.messenger.NotificationCenter;
import org.telegram.messenger.R;
@ -56,13 +57,22 @@ public class ChatAvatarContainer extends FrameLayout implements NotificationCent
private CharSequence lastSubtitle;
private String lastSubtitleColorKey;
private SharedMediaLayout.SharedMediaPreloader sharedMediaPreloader;
public ChatAvatarContainer(Context context, ChatActivity chatActivity, boolean needTime) {
super(context);
parentFragment = chatActivity;
if (parentFragment != null) {
sharedMediaPreloader = new SharedMediaLayout.SharedMediaPreloader(chatActivity);
}
avatarImageView = new BackupImageView(context);
avatarImageView.setRoundRadius(AndroidUtilities.dp(21));
addView(avatarImageView);
if (parentFragment != null && !parentFragment.isInScheduleMode()) {
avatarImageView.setOnClickListener(v -> openProfile(true));
}
titleTextView = new SimpleTextView(context);
titleTextView.setTextColor(Theme.getColor(Theme.key_actionBarDefaultTitle));
@ -90,36 +100,7 @@ public class ChatAvatarContainer extends FrameLayout implements NotificationCent
}
if (parentFragment != null && !parentFragment.isInScheduleMode()) {
setOnClickListener(v -> {
TLRPC.User user = parentFragment.getCurrentUser();
TLRPC.Chat chat = parentFragment.getCurrentChat();
if (user != null) {
Bundle args = new Bundle();
if (UserObject.isUserSelf(user)) {
args.putLong("dialog_id", parentFragment.getDialogId());
MediaActivity fragment = new MediaActivity(args, new int[]{-1, -1, -1, -1, -1});
fragment.setChatInfo(parentFragment.getCurrentChatInfo());
parentFragment.presentFragment(fragment);
} else {
args.putInt("user_id", user.id);
args.putBoolean("reportSpam", parentFragment.hasReportSpam());
if (timeItem != null) {
args.putLong("dialog_id", parentFragment.getDialogId());
}
ProfileActivity fragment = new ProfileActivity(args);
fragment.setUserInfo(parentFragment.getCurrentUserInfo());
fragment.setPlayProfileAnimation(true);
parentFragment.presentFragment(fragment);
}
} else if (chat != null) {
Bundle args = new Bundle();
args.putInt("chat_id", chat.id);
ProfileActivity fragment = new ProfileActivity(args);
fragment.setChatInfo(parentFragment.getCurrentChatInfo());
fragment.setPlayProfileAnimation(true);
parentFragment.presentFragment(fragment);
}
});
setOnClickListener(v -> openProfile(false));
TLRPC.Chat chat = parentFragment.getCurrentChat();
statusDrawables[0] = new TypingDotsDrawable();
@ -133,6 +114,42 @@ public class ChatAvatarContainer extends FrameLayout implements NotificationCent
}
}
private void openProfile(boolean byAvatar) {
if (byAvatar && (AndroidUtilities.isTablet() || AndroidUtilities.displaySize.x > AndroidUtilities.displaySize.y || !avatarImageView.getImageReceiver().hasNotThumb())) {
byAvatar = false;
}
TLRPC.User user = parentFragment.getCurrentUser();
TLRPC.Chat chat = parentFragment.getCurrentChat();
if (user != null) {
Bundle args = new Bundle();
if (UserObject.isUserSelf(user)) {
args.putLong("dialog_id", parentFragment.getDialogId());
int[] media = new int[MediaDataController.MEDIA_TYPES_COUNT];
System.arraycopy(sharedMediaPreloader.getLastMediaCount(), 0, media, 0, media.length);
MediaActivity fragment = new MediaActivity(args, media, sharedMediaPreloader.getSharedMediaData(), -1);
fragment.setChatInfo(parentFragment.getCurrentChatInfo());
parentFragment.presentFragment(fragment);
} else {
args.putInt("user_id", user.id);
args.putBoolean("reportSpam", parentFragment.hasReportSpam());
if (timeItem != null) {
args.putLong("dialog_id", parentFragment.getDialogId());
}
ProfileActivity fragment = new ProfileActivity(args, sharedMediaPreloader);
fragment.setUserInfo(parentFragment.getCurrentUserInfo());
fragment.setPlayProfileAnimation(byAvatar ? 2 : 1);
parentFragment.presentFragment(fragment);
}
} else if (chat != null) {
Bundle args = new Bundle();
args.putInt("chat_id", chat.id);
ProfileActivity fragment = new ProfileActivity(args, sharedMediaPreloader);
fragment.setChatInfo(parentFragment.getCurrentChatInfo());
fragment.setPlayProfileAnimation(byAvatar ? 2 : 1);
parentFragment.presentFragment(fragment);
}
}
public void setOccupyStatusBar(boolean value) {
occupyStatusBar = value;
}
@ -237,6 +254,12 @@ public class ChatAvatarContainer extends FrameLayout implements NotificationCent
return subtitleTextView;
}
public void onDestroy() {
if (sharedMediaPreloader != null) {
sharedMediaPreloader.onDestroy(parentFragment);
}
}
private void setTypingAnimation(boolean start) {
if (start) {
try {

View file

@ -51,6 +51,8 @@ public class ClippingImageView extends View {
private float animationProgress;
private float[][] animationValues;
private float additionalTranslationY;
public ClippingImageView(Context context) {
super(context);
paint = new Paint(Paint.FILTER_BITMAP_FLAG);
@ -68,6 +70,20 @@ public class ClippingImageView extends View {
animationValues = values;
}
public void setAdditionalTranslationY(float value) {
additionalTranslationY = value;
}
@Override
public void setTranslationY(float translationY) {
super.setTranslationY(translationY + additionalTranslationY);
}
@Override
public float getTranslationY() {
return super.getTranslationY() - additionalTranslationY;
}
@Keep
public float getAnimationProgress() {
return animationProgress;

View file

@ -3,6 +3,7 @@ package org.telegram.ui.Components;
import android.content.Context;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.Rect;
import android.os.Build;
import android.text.Editable;
import android.text.InputFilter;
@ -100,6 +101,12 @@ public class EditTextEmoji extends FrameLayout implements NotificationCenter.Not
}
return false;
}
@Override
public boolean requestRectangleOnScreen(Rect rectangle) {
rectangle.bottom += AndroidUtilities.dp(1000);
return super.requestRectangleOnScreen(rectangle);
}
};
editText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
editText.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);

View file

@ -3,28 +3,38 @@ package org.telegram.ui.Components;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.RectF;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.SystemClock;
import android.view.View;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.BuildVars;
import org.telegram.messenger.R;
import org.telegram.messenger.SharedConfig;
import org.telegram.messenger.Utilities;
import java.util.ArrayList;
import java.util.Calendar;
public class FireworksOverlay extends View {
private static Paint[] paint;
private static Paint[] heartPaint;
private RectF rect = new RectF();
private long lastUpdateTime;
private boolean started;
private boolean startedFall;
private float speedCoef = 1.0f;
private int fallingDownCount;
private static Drawable[] heartDrawable;
private static final int particlesCount = SharedConfig.getDevicePerfomanceClass() == SharedConfig.PERFORMANCE_CLASS_LOW ? 50 : 60;
private static final int fallParticlesCount = SharedConfig.getDevicePerfomanceClass() == SharedConfig.PERFORMANCE_CLASS_LOW ? 20 : 30;
private boolean isFebruary14;
private static int[] colors = new int[] {
0xff2CBCE8,
@ -35,6 +45,14 @@ public class FireworksOverlay extends View {
0xff59B86C
};
private static int[] heartColors = new int[] {
0xffE2557B,
0xff5FCDF2,
0xffFFDA69,
0xffDB6363,
0xffE376B0
};
static {
paint = new Paint[colors.length];
for (int a = 0; a < paint.length; a++) {
@ -60,12 +78,22 @@ public class FireworksOverlay extends View {
private void draw(Canvas canvas) {
if (type == 0) {
canvas.drawCircle(x, y, AndroidUtilities.dp(typeSize), paint[colorType]);
} else {
} else if (type == 1) {
rect.set(x - AndroidUtilities.dp(typeSize), y - AndroidUtilities.dp(2), x + AndroidUtilities.dp(typeSize), y + AndroidUtilities.dp(2));
canvas.save();
canvas.rotate(rotation, rect.centerX(), rect.centerY());
canvas.drawRoundRect(rect, AndroidUtilities.dp(2), AndroidUtilities.dp(2), paint[colorType]);
canvas.restore();
} else if (type == 2) {
Drawable drawable = heartDrawable[colorType];
int w = drawable.getIntrinsicWidth() / 2;
int h = drawable.getIntrinsicHeight() / 2;
drawable.setBounds((int) x - w, (int) y - h, (int) x + w, (int) y + h);
canvas.save();
canvas.rotate(rotation, x, y);
canvas.scale(typeSize / 6.0f, typeSize / 6.0f, x, y);
drawable.draw(canvas);
canvas.restore();
}
}
@ -115,7 +143,7 @@ public class FireworksOverlay extends View {
if (wasNegative && moveY > yEdge) {
fallingDownCount++;
}
if (type == 1) {
if (type == 1 || type == 2) {
rotation += moveCoef * 10;
if (rotation > 360) {
rotation -= 360;
@ -131,13 +159,29 @@ public class FireworksOverlay extends View {
super(context);
}
private void loadHeartDrawables() {
if (heartDrawable != null) {
return;
}
heartDrawable = new Drawable[heartColors.length];
for (int a = 0; a < heartDrawable.length; a++) {
heartDrawable[a] = ApplicationLoader.applicationContext.getResources().getDrawable(R.drawable.heart_confetti).mutate();
heartDrawable[a].setColorFilter(new PorterDuffColorFilter(heartColors[a], PorterDuff.Mode.MULTIPLY));
}
}
private Particle createParticle(boolean fall) {
Particle particle = new Particle();
particle.colorType = (byte) Utilities.random.nextInt(paint.length);
particle.type = (byte) Utilities.random.nextInt(2);
if (isFebruary14 && particle.type == 0) {
particle.type = 2;
particle.colorType = (byte) Utilities.random.nextInt(heartColors.length);
} else {
particle.colorType = (byte) Utilities.random.nextInt(colors.length);
}
particle.side = (byte) Utilities.random.nextInt(2);
particle.finishedStart = (byte) (1 + Utilities.random.nextInt(2));
if (particle.type == 0) {
if (particle.type == 0 || particle.type == 2) {
particle.typeSize = (byte) (4 + Utilities.random.nextFloat() * 2);
} else {
particle.typeSize = (byte) (4 + Utilities.random.nextFloat() * 4);
@ -170,6 +214,14 @@ public class FireworksOverlay extends View {
startedFall = false;
fallingDownCount = 0;
speedCoef = 1.0f;
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(System.currentTimeMillis());
int day = calendar.get(Calendar.DAY_OF_MONTH);
int month = calendar.get(Calendar.MONTH);
isFebruary14 = month == 1 && (BuildVars.DEBUG_PRIVATE_VERSION || day == 14);
if (isFebruary14) {
loadHeartDrawables();
}
for (int a = 0; a < particlesCount; a++) {
particles.add(createParticle(false));
}

View file

@ -0,0 +1,550 @@
/*
* Copyright (C) 2008 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.telegram.ui.Components;
import android.content.Context;
import android.os.Build;
import android.os.Handler;
import android.os.Message;
import android.view.MotionEvent;
import android.view.VelocityTracker;
import android.view.ViewConfiguration;
public class GestureDetector2 {
public interface OnGestureListener {
boolean onDown(MotionEvent e);
void onUp(MotionEvent e);
void onShowPress(MotionEvent e);
boolean onSingleTapUp(MotionEvent e);
boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY);
void onLongPress(MotionEvent e);
boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY);
}
/**
* The listener that is used to notify when a double-tap or a confirmed
* single-tap occur.
*/
public interface OnDoubleTapListener {
/**
* Notified when a single-tap occurs.
* <p>
* Unlike {@link OnGestureListener#onSingleTapUp(MotionEvent)}, this
* will only be called after the detector is confident that the user's
* first tap is not followed by a second tap leading to a double-tap
* gesture.
*
* @param e The down motion event of the single-tap.
* @return true if the event is consumed, else false
*/
boolean onSingleTapConfirmed(MotionEvent e);
/**
* Notified when a double-tap occurs.
*
* @param e The down motion event of the first tap of the double-tap.
* @return true if the event is consumed, else false
*/
boolean onDoubleTap(MotionEvent e);
/**
* Notified when an event within a double-tap gesture occurs, including
* the down, move, and up events.
*
* @param e The motion event that occurred during the double-tap gesture.
* @return true if the event is consumed, else false
*/
boolean onDoubleTapEvent(MotionEvent e);
}
public interface OnContextClickListener {
/**
* Notified when a context click occurs.
*
* @param e The motion event that occurred during the context click.
* @return true if the event is consumed, else false
*/
boolean onContextClick(MotionEvent e);
}
/**
* A convenience class to extend when you only want to listen for a subset
* of all the gestures. This implements all methods in the
* {@link OnGestureListener}, {@link OnDoubleTapListener}, and {@link OnContextClickListener}
* but does nothing and return {@code false} for all applicable methods.
*/
public static class SimpleOnGestureListener implements OnGestureListener, OnDoubleTapListener,
OnContextClickListener {
public boolean onSingleTapUp(MotionEvent e) {
return false;
}
public void onLongPress(MotionEvent e) {
}
public boolean onScroll(MotionEvent e1, MotionEvent e2,
float distanceX, float distanceY) {
return false;
}
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
float velocityY) {
return false;
}
public void onShowPress(MotionEvent e) {
}
public boolean onDown(MotionEvent e) {
return false;
}
public void onUp(MotionEvent e) {
}
public boolean onDoubleTap(MotionEvent e) {
return false;
}
public boolean onDoubleTapEvent(MotionEvent e) {
return false;
}
public boolean onSingleTapConfirmed(MotionEvent e) {
return false;
}
public boolean onContextClick(MotionEvent e) {
return false;
}
}
private int mTouchSlopSquare;
private int mDoubleTapTouchSlopSquare;
private int mDoubleTapSlopSquare;
private int mMinimumFlingVelocity;
private int mMaximumFlingVelocity;
private static final int LONGPRESS_TIMEOUT = ViewConfiguration.getLongPressTimeout();
private static final int TAP_TIMEOUT = ViewConfiguration.getTapTimeout();
private static final int DOUBLE_TAP_TIMEOUT = 150;
private static final int DOUBLE_TAP_MIN_TIME = 40;
private static final int SHOW_PRESS = 1;
private static final int LONG_PRESS = 2;
private static final int TAP = 3;
private final Handler mHandler;
private final OnGestureListener mListener;
private OnDoubleTapListener mDoubleTapListener;
private boolean mStillDown;
private boolean mDeferConfirmSingleTap;
private boolean mInLongPress;
private boolean mInContextClick;
private boolean mAlwaysInTapRegion;
private boolean mAlwaysInBiggerTapRegion;
private boolean mIgnoreNextUpEvent;
private MotionEvent mCurrentDownEvent;
private MotionEvent mCurrentMotionEvent;
private MotionEvent mPreviousUpEvent;
private boolean mIsDoubleTapping;
private float mLastFocusX;
private float mLastFocusY;
private float mDownFocusX;
private float mDownFocusY;
private boolean mIsLongpressEnabled;
private VelocityTracker mVelocityTracker;
private class GestureHandler extends Handler {
GestureHandler() {
super();
}
GestureHandler(Handler handler) {
super(handler.getLooper());
}
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case SHOW_PRESS:
mListener.onShowPress(mCurrentDownEvent);
break;
case LONG_PRESS:
dispatchLongPress();
break;
case TAP:
if (mDoubleTapListener != null) {
if (!mStillDown) {
mDoubleTapListener.onSingleTapConfirmed(mCurrentDownEvent);
} else {
mDeferConfirmSingleTap = true;
}
}
break;
default:
throw new RuntimeException("Unknown message " + msg); //never
}
}
}
@Deprecated
public GestureDetector2(OnGestureListener listener, Handler handler) {
this(null, listener, handler);
}
@Deprecated
public GestureDetector2(OnGestureListener listener) {
this(null, listener, null);
}
public GestureDetector2(Context context, OnGestureListener listener) {
this(context, listener, null);
}
public GestureDetector2(Context context, OnGestureListener listener, Handler handler) {
if (handler != null) {
mHandler = new GestureHandler(handler);
} else {
mHandler = new GestureHandler();
}
mListener = listener;
if (listener instanceof OnDoubleTapListener) {
setOnDoubleTapListener((OnDoubleTapListener) listener);
}
init(context);
}
public GestureDetector2(Context context, OnGestureListener listener, Handler handler, boolean unused) {
this(context, listener, handler);
}
private void init(Context context) {
if (mListener == null) {
throw new NullPointerException("OnGestureListener must not be null");
}
mIsLongpressEnabled = true;
int touchSlop, doubleTapSlop, doubleTapTouchSlop;
if (context == null) {
touchSlop = ViewConfiguration.getTouchSlop();
doubleTapTouchSlop = touchSlop;
doubleTapSlop = 100;
mMinimumFlingVelocity = ViewConfiguration.getMinimumFlingVelocity();
mMaximumFlingVelocity = ViewConfiguration.getMaximumFlingVelocity();
} else {
final ViewConfiguration configuration = ViewConfiguration.get(context);
touchSlop = configuration.getScaledTouchSlop();
doubleTapTouchSlop = configuration.getScaledTouchSlop();
doubleTapSlop = configuration.getScaledDoubleTapSlop();
mMinimumFlingVelocity = configuration.getScaledMinimumFlingVelocity();
mMaximumFlingVelocity = configuration.getScaledMaximumFlingVelocity();
}
mTouchSlopSquare = touchSlop * touchSlop;
mDoubleTapTouchSlopSquare = doubleTapTouchSlop * doubleTapTouchSlop;
mDoubleTapSlopSquare = doubleTapSlop * doubleTapSlop;
}
public void setOnDoubleTapListener(OnDoubleTapListener onDoubleTapListener) {
mDoubleTapListener = onDoubleTapListener;
}
public void setIsLongpressEnabled(boolean isLongpressEnabled) {
mIsLongpressEnabled = isLongpressEnabled;
}
public boolean isLongpressEnabled() {
return mIsLongpressEnabled;
}
public boolean onTouchEvent(MotionEvent ev) {
final int action = ev.getAction();
if (mCurrentMotionEvent != null) {
mCurrentMotionEvent.recycle();
}
mCurrentMotionEvent = MotionEvent.obtain(ev);
if (mVelocityTracker == null) {
mVelocityTracker = VelocityTracker.obtain();
}
mVelocityTracker.addMovement(ev);
final boolean pointerUp = (action & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_POINTER_UP;
final int skipIndex = pointerUp ? ev.getActionIndex() : -1;
// Determine focal point
float sumX = 0, sumY = 0;
final int count = ev.getPointerCount();
for (int i = 0; i < count; i++) {
if (skipIndex == i) continue;
sumX += ev.getX(i);
sumY += ev.getY(i);
}
final int div = pointerUp ? count - 1 : count;
final float focusX = sumX / div;
final float focusY = sumY / div;
boolean handled = false;
switch (action & MotionEvent.ACTION_MASK) {
case MotionEvent.ACTION_POINTER_DOWN:
mDownFocusX = mLastFocusX = focusX;
mDownFocusY = mLastFocusY = focusY;
// Cancel long press and taps
cancelTaps();
break;
case MotionEvent.ACTION_POINTER_UP:
mDownFocusX = mLastFocusX = focusX;
mDownFocusY = mLastFocusY = focusY;
// Check the dot product of current velocities.
// If the pointer that left was opposing another velocity vector, clear.
mVelocityTracker.computeCurrentVelocity(1000, mMaximumFlingVelocity);
final int upIndex = ev.getActionIndex();
final int id1 = ev.getPointerId(upIndex);
final float x1 = mVelocityTracker.getXVelocity(id1);
final float y1 = mVelocityTracker.getYVelocity(id1);
for (int i = 0; i < count; i++) {
if (i == upIndex) continue;
final int id2 = ev.getPointerId(i);
final float x = x1 * mVelocityTracker.getXVelocity(id2);
final float y = y1 * mVelocityTracker.getYVelocity(id2);
final float dot = x + y;
if (dot < 0) {
mVelocityTracker.clear();
break;
}
}
break;
case MotionEvent.ACTION_DOWN:
if (mDoubleTapListener != null) {
boolean hadTapMessage = mHandler.hasMessages(TAP);
if (hadTapMessage) mHandler.removeMessages(TAP);
if ((mCurrentDownEvent != null) && (mPreviousUpEvent != null)
&& hadTapMessage
&& isConsideredDoubleTap(mCurrentDownEvent, mPreviousUpEvent, ev)) {
// This is a second tap
mIsDoubleTapping = true;
// Give a callback with the first tap of the double-tap
handled |= mDoubleTapListener.onDoubleTap(mCurrentDownEvent);
// Give a callback with down event of the double-tap
handled |= mDoubleTapListener.onDoubleTapEvent(ev);
} else {
// This is a first tap
mHandler.sendEmptyMessageDelayed(TAP, DOUBLE_TAP_TIMEOUT);
}
}
mDownFocusX = mLastFocusX = focusX;
mDownFocusY = mLastFocusY = focusY;
if (mCurrentDownEvent != null) {
mCurrentDownEvent.recycle();
}
mCurrentDownEvent = MotionEvent.obtain(ev);
mAlwaysInTapRegion = true;
mAlwaysInBiggerTapRegion = true;
mStillDown = true;
mInLongPress = false;
mDeferConfirmSingleTap = false;
if (mIsLongpressEnabled) {
mHandler.removeMessages(LONG_PRESS);
mHandler.sendMessageAtTime(
mHandler.obtainMessage(LONG_PRESS, 0, 0), mCurrentDownEvent.getDownTime()
+ ViewConfiguration.getLongPressTimeout());
}
mHandler.sendEmptyMessageAtTime(SHOW_PRESS,
mCurrentDownEvent.getDownTime() + TAP_TIMEOUT);
handled |= mListener.onDown(ev);
break;
case MotionEvent.ACTION_MOVE:
if (mInLongPress || mInContextClick) {
break;
}
final int motionClassification = Build.VERSION.SDK_INT >= 29 ? ev.getClassification() : 0;
final boolean hasPendingLongPress = mHandler.hasMessages(LONG_PRESS);
final float scrollX = mLastFocusX - focusX;
final float scrollY = mLastFocusY - focusY;
if (mIsDoubleTapping) {
handled |= mDoubleTapListener.onDoubleTapEvent(ev);
} else if (mAlwaysInTapRegion) {
final int deltaX = (int) (focusX - mDownFocusX);
final int deltaY = (int) (focusY - mDownFocusY);
int distance = (deltaX * deltaX) + (deltaY * deltaY);
int slopSquare = mTouchSlopSquare;
final boolean ambiguousGesture = Build.VERSION.SDK_INT >= 29 && motionClassification == MotionEvent.CLASSIFICATION_AMBIGUOUS_GESTURE;
final boolean shouldInhibitDefaultAction = hasPendingLongPress && ambiguousGesture;
if (shouldInhibitDefaultAction) {
final float multiplier = 2f;
if (distance > slopSquare) {
mHandler.removeMessages(LONG_PRESS);
final long longPressTimeout = ViewConfiguration.getLongPressTimeout();
mHandler.sendMessageAtTime(mHandler.obtainMessage(LONG_PRESS, 0, 0), ev.getDownTime() + (long) (longPressTimeout * multiplier));
}
slopSquare *= multiplier * multiplier;
}
if (distance > slopSquare) {
handled = mListener.onScroll(mCurrentDownEvent, ev, scrollX, scrollY);
mLastFocusX = focusX;
mLastFocusY = focusY;
mAlwaysInTapRegion = false;
mHandler.removeMessages(TAP);
mHandler.removeMessages(SHOW_PRESS);
mHandler.removeMessages(LONG_PRESS);
}
int doubleTapSlopSquare = mDoubleTapTouchSlopSquare;
if (distance > doubleTapSlopSquare) {
mAlwaysInBiggerTapRegion = false;
}
} else if ((Math.abs(scrollX) >= 1) || (Math.abs(scrollY) >= 1)) {
handled = mListener.onScroll(mCurrentDownEvent, ev, scrollX, scrollY);
mLastFocusX = focusX;
mLastFocusY = focusY;
}
if (Build.VERSION.SDK_INT >= 29) {
final boolean deepPress = motionClassification == MotionEvent.CLASSIFICATION_DEEP_PRESS;
if (deepPress && hasPendingLongPress) {
mHandler.removeMessages(LONG_PRESS);
mHandler.sendMessage(mHandler.obtainMessage(LONG_PRESS, 0, 0));
}
}
break;
case MotionEvent.ACTION_UP:
mStillDown = false;
mListener.onUp(ev);
MotionEvent currentUpEvent = MotionEvent.obtain(ev);
if (mIsDoubleTapping) {
handled |= mDoubleTapListener.onDoubleTapEvent(ev);
} else if (mInLongPress) {
mHandler.removeMessages(TAP);
mInLongPress = false;
} else if (mAlwaysInTapRegion && !mIgnoreNextUpEvent) {
handled = mListener.onSingleTapUp(ev);
if (mDeferConfirmSingleTap && mDoubleTapListener != null) {
mDoubleTapListener.onSingleTapConfirmed(ev);
}
} else if (!mIgnoreNextUpEvent) {
final VelocityTracker velocityTracker = mVelocityTracker;
final int pointerId = ev.getPointerId(0);
velocityTracker.computeCurrentVelocity(1000, mMaximumFlingVelocity);
final float velocityY = velocityTracker.getYVelocity(pointerId);
final float velocityX = velocityTracker.getXVelocity(pointerId);
if ((Math.abs(velocityY) > mMinimumFlingVelocity)
|| (Math.abs(velocityX) > mMinimumFlingVelocity)) {
handled = mListener.onFling(mCurrentDownEvent, ev, velocityX, velocityY);
}
}
if (mPreviousUpEvent != null) {
mPreviousUpEvent.recycle();
}
mPreviousUpEvent = currentUpEvent;
if (mVelocityTracker != null) {
mVelocityTracker.recycle();
mVelocityTracker = null;
}
mIsDoubleTapping = false;
mDeferConfirmSingleTap = false;
mIgnoreNextUpEvent = false;
mHandler.removeMessages(SHOW_PRESS);
mHandler.removeMessages(LONG_PRESS);
break;
case MotionEvent.ACTION_CANCEL:
cancel();
break;
}
return handled;
}
private void cancel() {
mHandler.removeMessages(SHOW_PRESS);
mHandler.removeMessages(LONG_PRESS);
mHandler.removeMessages(TAP);
mVelocityTracker.recycle();
mVelocityTracker = null;
mIsDoubleTapping = false;
mStillDown = false;
mAlwaysInTapRegion = false;
mAlwaysInBiggerTapRegion = false;
mDeferConfirmSingleTap = false;
mInLongPress = false;
mInContextClick = false;
mIgnoreNextUpEvent = false;
}
private void cancelTaps() {
mHandler.removeMessages(SHOW_PRESS);
mHandler.removeMessages(LONG_PRESS);
mHandler.removeMessages(TAP);
mIsDoubleTapping = false;
mAlwaysInTapRegion = false;
mAlwaysInBiggerTapRegion = false;
mDeferConfirmSingleTap = false;
mInLongPress = false;
mInContextClick = false;
mIgnoreNextUpEvent = false;
}
private boolean isConsideredDoubleTap(MotionEvent firstDown, MotionEvent firstUp, MotionEvent secondDown) {
if (!mAlwaysInBiggerTapRegion) {
return false;
}
final long deltaTime = secondDown.getEventTime() - firstUp.getEventTime();
if (deltaTime > DOUBLE_TAP_TIMEOUT || deltaTime < DOUBLE_TAP_MIN_TIME) {
return false;
}
int deltaX = (int) firstDown.getX() - (int) secondDown.getX();
int deltaY = (int) firstDown.getY() - (int) secondDown.getY();
int slopSquare = mDoubleTapSlopSquare;
return (deltaX * deltaX + deltaY * deltaY < slopSquare);
}
private void dispatchLongPress() {
mHandler.removeMessages(TAP);
mDeferConfirmSingleTap = false;
mInLongPress = true;
mListener.onLongPress(mCurrentDownEvent);
}
}

View file

@ -12,6 +12,7 @@ import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.text.Editable;
import android.text.InputFilter;
@ -151,6 +152,12 @@ public class PhotoViewerCaptionEnterView extends FrameLayout implements Notifica
protected int getActionModeStyle() {
return FloatingToolbar.STYLE_BLACK;
}
@Override
public boolean requestRectangleOnScreen(Rect rectangle) {
rectangle.bottom += AndroidUtilities.dp(1000);
return super.requestRectangleOnScreen(rectangle);
}
};
messageEditText.setWindowView(windowView);

View file

@ -808,7 +808,7 @@ public class PollVotesAlert extends BottomSheet {
args.putInt("user_id", userCell.currentUser.id);
dismiss();
ProfileActivity fragment = new ProfileActivity(args);
fragment.setPlayProfileAnimation(currentUser != null && currentUser.id == userCell.currentUser.id);
fragment.setPlayProfileAnimation(currentUser != null && currentUser.id == userCell.currentUser.id ? 1 : 0);
parentFragment.presentFragment(fragment);
}
});

View file

@ -42,6 +42,7 @@ public class ProfileGalleryView extends CircularViewPager implements Notificatio
private final ViewPagerAdapter adapter;
private final int parentClassGuid;
private final long dialogId;
private boolean scrolledByUser;
private int currentAccount = UserConfig.selectedAccount;
@ -145,6 +146,7 @@ public class ProfileGalleryView extends CircularViewPager implements Notificatio
if (action == MotionEvent.ACTION_DOWN) {
isScrollingListView = true;
isSwipingViewPager = true;
scrolledByUser = true;
downPoint.set(ev.getX(), ev.getY());
} else if (action == MotionEvent.ACTION_MOVE) {
final float dx = ev.getX() - downPoint.x;
@ -226,7 +228,7 @@ public class ProfileGalleryView extends CircularViewPager implements Notificatio
}
public BackupImageView getCurrentItemView() {
if (adapter != null) {
if (adapter != null && !adapter.objects.isEmpty()) {
return adapter.objects.get(getCurrentItem()).imageView;
} else {
return null;
@ -237,6 +239,14 @@ public class ProfileGalleryView extends CircularViewPager implements Notificatio
setCurrentItem(adapter.getExtraCount(), false);
}
public int getRealCount() {
return adapter.getCount() - adapter.getExtraCount() * 2;
}
public int getRealPosition() {
return adapter.getRealPosition(getCurrentItem());
}
@Override
public boolean onInterceptTouchEvent(MotionEvent e) {
if (parentListView.getScrollState() != RecyclerView.SCROLL_STATE_IDLE) {
@ -318,6 +328,9 @@ public class ProfileGalleryView extends CircularViewPager implements Notificatio
}
loadNeighboringThumbs();
getAdapter().notifyDataSetChanged();
if (!scrolledByUser) {
resetCurrentItem();
}
if (fromCache) {
MessagesController.getInstance(currentAccount).loadDialogPhotos(did, 80, 0, false, parentClassGuid);
}
@ -398,9 +411,9 @@ public class ProfileGalleryView extends CircularViewPager implements Notificatio
{
final int realPosition = getRealPosition(position);
if (realPosition == 0) {
setImage(imagesLocations.get(realPosition), null, parentAvatarImageView.getImageReceiver().getBitmap(), imagesLocationsSizes.get(realPosition), null);
setImage(imagesLocations.get(realPosition), null, parentAvatarImageView.getImageReceiver().getBitmap(), imagesLocationsSizes.get(realPosition), 1, null);
} else {
setImage(imagesLocations.get(realPosition), null, thumbsLocations.get(realPosition), null, null, null, null, imagesLocationsSizes.get(realPosition), null);
setImage(imagesLocations.get(realPosition), null, thumbsLocations.get(realPosition), null, null, 0, 1, imagesLocationsSizes.get(realPosition));
radialProgress = new RadialProgress2(this);
radialProgress.setOverrideAlpha(0.0f);
radialProgress.setIcon(MediaActionDrawable.ICON_EMPTY, false, false);

View file

@ -8,8 +8,6 @@ import android.view.View;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.google.android.exoplayer2.util.Log;
import org.telegram.ui.Cells.ChatMessageCell;
import java.util.ArrayList;
@ -24,11 +22,11 @@ public class RecyclerAnimationScrollHelper {
private LinearLayoutManager layoutManager;
private int scrollDirection;
ValueAnimator animator;
private ValueAnimator animator;
ScrollListener scrollListener;
private ScrollListener scrollListener;
AnimationCallback animationCallback;
private AnimationCallback animationCallback;
public RecyclerAnimationScrollHelper(RecyclerListView recyclerView, LinearLayoutManager layoutManager) {
this.recyclerView = recyclerView;

View file

@ -32,6 +32,9 @@ public class ScrollSlidingTextTabStrip extends HorizontalScrollView {
public interface ScrollSlidingTabStripDelegate {
void onPageSelected(int page, boolean forward);
void onPageScrolled(float progress);
default void onSamePageSelected() {
}
}
private LinearLayout tabsContainer;
@ -56,6 +59,8 @@ public class ScrollSlidingTextTabStrip extends HorizontalScrollView {
private boolean animatingIndicator;
private float animationIdicatorProgress;
private int scrollingToChild = -1;
private GradientDrawable selectorDrawable;
private String tabLineColorKey = Theme.key_actionBarTabLine;
@ -115,6 +120,7 @@ public class ScrollSlidingTextTabStrip extends HorizontalScrollView {
setHorizontalScrollBarEnabled(false);
tabsContainer = new LinearLayout(context);
tabsContainer.setOrientation(LinearLayout.HORIZONTAL);
tabsContainer.setPadding(AndroidUtilities.dp(7), 0, AndroidUtilities.dp(7), 0);
tabsContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
addView(tabsContainer);
}
@ -128,6 +134,9 @@ public class ScrollSlidingTextTabStrip extends HorizontalScrollView {
}
private void setAnimationProgressInernal(TextView newTab, TextView prevTab, float value) {
if (newTab == null || prevTab == null) {
return;
}
int newColor = Theme.getColor(activeTextColorKey);
int prevColor = Theme.getColor(unactiveTextColorKey);
@ -154,6 +163,9 @@ public class ScrollSlidingTextTabStrip extends HorizontalScrollView {
TextView newTab = (TextView) tabsContainer.getChildAt(currentPosition);
TextView prevTab = (TextView) tabsContainer.getChildAt(previousPosition);
if (prevTab == null || newTab == null) {
return;
}
setAnimationProgressInernal(newTab, prevTab, value);
if (value >= 1f) {
@ -218,16 +230,21 @@ public class ScrollSlidingTextTabStrip extends HorizontalScrollView {
tab.setGravity(Gravity.CENTER);
tab.setText(text);
tab.setBackgroundDrawable(Theme.createSelectorDrawable(Theme.getColor(selectorColorKey), 3));
tab.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
tab.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
tab.setSingleLine(true);
tab.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
tab.setPadding(AndroidUtilities.dp(8), 0, AndroidUtilities.dp(8), 0);
tab.setPadding(AndroidUtilities.dp(16), 0, AndroidUtilities.dp(16), 0);
tab.setOnClickListener(v -> {
int position1 = tabsContainer.indexOfChild(v);
if (position1 < 0 || position1 == currentPosition) {
if (position1 < 0) {
return;
}
if (position1 == currentPosition && delegate != null) {
delegate.onSamePageSelected();
return;
}
boolean scrollingForward = currentPosition < position1;
scrollingToChild = -1;
previousPosition = currentPosition;
currentPosition = position1;
selectedTabId = id;
@ -254,7 +271,7 @@ public class ScrollSlidingTextTabStrip extends HorizontalScrollView {
}
scrollToChild(position1);
});
int tabWidth = (int) Math.ceil(tab.getPaint().measureText(text, 0, text.length())) + AndroidUtilities.dp(16);
int tabWidth = (int) Math.ceil(tab.getPaint().measureText(text, 0, text.length())) + tab.getPaddingLeft() + tab.getPaddingRight();
allTextWidth += tabWidth;
positionToWidth.put(position, tabWidth);
tabsContainer.addView(tab, LayoutHelper.createLinear(0, LayoutHelper.MATCH_PARENT));
@ -266,6 +283,9 @@ public class ScrollSlidingTextTabStrip extends HorizontalScrollView {
TextView tab = (TextView) tabsContainer.getChildAt(a);
tab.setTag(currentPosition == a ? activeTextColorKey : unactiveTextColorKey);
tab.setTextColor(Theme.getColor(currentPosition == a ? activeTextColorKey : unactiveTextColorKey));
if (a == 0) {
tab.getLayoutParams().width = count == 1 ? LayoutHelper.WRAP_CONTENT : 0;
}
}
}
@ -283,6 +303,14 @@ public class ScrollSlidingTextTabStrip extends HorizontalScrollView {
public void setInitialTabId(int id) {
selectedTabId = id;
int pos = idToPosition.get(id);
TextView child = (TextView) tabsContainer.getChildAt(pos);
if (child != null) {
currentPosition = pos;
prevLayoutWidth = 0;
finishAddingTabs();
requestLayout();
}
}
public int getFirstTabId() {
@ -302,7 +330,7 @@ public class ScrollSlidingTextTabStrip extends HorizontalScrollView {
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int width = MeasureSpec.getSize(widthMeasureSpec);
int width = MeasureSpec.getSize(widthMeasureSpec) - AndroidUtilities.dp(22);
int count = tabsContainer.getChildCount();
for (int a = 0; a < count; a++) {
View child = tabsContainer.getChildAt(a);
@ -314,11 +342,16 @@ public class ScrollSlidingTextTabStrip extends HorizontalScrollView {
layoutParams.weight = 1.0f / count;
layoutParams.width = 0;
} else {
layoutParams.weight = 1.0f / allTextWidth * positionToWidth.get(a);
layoutParams.width = 0;
if (a == 0 && count == 1) {
layoutParams.weight = 0.0f;
layoutParams.width = LayoutHelper.WRAP_CONTENT;
} else {
layoutParams.weight = 1.0f / allTextWidth * positionToWidth.get(a);
layoutParams.width = 0;
}
}
}
if (allTextWidth > width) {
if (count == 1 || allTextWidth > width) {
tabsContainer.setWeightSum(0.0f);
} else {
tabsContainer.setWeightSum(1.0f);
@ -328,9 +361,10 @@ public class ScrollSlidingTextTabStrip extends HorizontalScrollView {
}
private void scrollToChild(int position) {
if (tabCount == 0) {
if (tabCount == 0 || scrollingToChild == position) {
return;
}
scrollingToChild = position;
TextView child = (TextView) tabsContainer.getChildAt(position);
if (child == null) {
return;
@ -351,6 +385,7 @@ public class ScrollSlidingTextTabStrip extends HorizontalScrollView {
if (prevLayoutWidth != r - l) {
prevLayoutWidth = r - l;
scrollingToChild = -1;
if (animatingIndicator) {
AndroidUtilities.cancelRunOnUIThread(animationRunnable);
animatingIndicator = false;
@ -403,6 +438,7 @@ public class ScrollSlidingTextTabStrip extends HorizontalScrollView {
child.setTag(unactiveTextColorKey);
nextChild.setTag(activeTextColorKey);
}
scrollToChild(tabsContainer.indexOfChild(nextChild));
}
if (progress >= 1.0f) {
currentPosition = position;

View file

@ -56,6 +56,7 @@ import org.telegram.messenger.MessagesStorage;
import org.telegram.messenger.NotificationCenter;
import org.telegram.messenger.R;
import org.telegram.messenger.SendMessagesHelper;
import org.telegram.messenger.SharedConfig;
import org.telegram.messenger.UserConfig;
import org.telegram.messenger.Utilities;
import org.telegram.tgnet.ConnectionsManager;
@ -294,7 +295,7 @@ public class ShareAlert extends BottomSheet implements NotificationCenter.Notifi
}
SizeNotifierFrameLayout sizeNotifierFrameLayout = new SizeNotifierFrameLayout(context) {
SizeNotifierFrameLayout sizeNotifierFrameLayout = new SizeNotifierFrameLayout(context, false) {
private boolean ignoreLayout = false;
private RectF rect1 = new RectF();
@ -309,7 +310,7 @@ public class ShareAlert extends BottomSheet implements NotificationCenter.Notifi
ignoreLayout = false;
}
int availableHeight = totalHeight - getPaddingTop();
int keyboardSize = getKeyboardHeight();
int keyboardSize = SharedConfig.smoothKeyboard ? 0 : getKeyboardHeight();
if (!AndroidUtilities.isInMultiwindow && keyboardSize <= AndroidUtilities.dp(20)) {
availableHeight -= commentTextView.getEmojiPadding();
}
@ -333,7 +334,7 @@ public class ShareAlert extends BottomSheet implements NotificationCenter.Notifi
setMeasuredDimension(widthSize, heightSize);
widthSize -= backgroundPaddingLeft * 2;
int keyboardSize = getKeyboardHeight();
int keyboardSize = SharedConfig.smoothKeyboard ? 0 : getKeyboardHeight();
if (keyboardSize <= AndroidUtilities.dp(20)) {
if (!AndroidUtilities.isInMultiwindow) {
heightSize -= commentTextView.getEmojiPadding();
@ -382,7 +383,8 @@ public class ShareAlert extends BottomSheet implements NotificationCenter.Notifi
protected void onLayout(boolean changed, int l, int t, int r, int b) {
final int count = getChildCount();
int paddingBottom = getKeyboardHeight() <= AndroidUtilities.dp(20) && !AndroidUtilities.isInMultiwindow && !AndroidUtilities.isTablet() ? commentTextView.getEmojiPadding() : 0;
int keyboardSize = SharedConfig.smoothKeyboard ? 0 : getKeyboardHeight();
int paddingBottom = keyboardSize <= AndroidUtilities.dp(20) && !AndroidUtilities.isInMultiwindow && !AndroidUtilities.isTablet() ? commentTextView.getEmojiPadding() : 0;
setBottomClip(paddingBottom);
for (int i = 0; i < count; i++) {
@ -436,7 +438,7 @@ public class ShareAlert extends BottomSheet implements NotificationCenter.Notifi
if (AndroidUtilities.isTablet()) {
childTop = getMeasuredHeight() - child.getMeasuredHeight();
} else {
childTop = getMeasuredHeight() + getKeyboardHeight() - child.getMeasuredHeight();
childTop = getMeasuredHeight() + keyboardSize - child.getMeasuredHeight();
}
}
child.layout(childLeft, childTop, childLeft + width, childTop + height);

File diff suppressed because it is too large Load diff

View file

@ -18,14 +18,14 @@ import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.os.Build;
import android.view.View;
import android.widget.FrameLayout;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.ui.ActionBar.ActionBar;
import org.telegram.ui.ActionBar.ActionBarLayout;
import org.telegram.ui.ActionBar.AdjustPanFrameLayout;
import org.telegram.ui.ActionBar.Theme;
public class SizeNotifierFrameLayout extends FrameLayout {
public class SizeNotifierFrameLayout extends AdjustPanFrameLayout {
private Rect rect = new Rect();
private Drawable backgroundDrawable;
@ -37,21 +37,24 @@ public class SizeNotifierFrameLayout extends FrameLayout {
private float translationX;
private float translationY;
private float parallaxScale = 1.0f;
private int backgroundTranslationY;
private boolean paused = true;
private Drawable oldBackgroundDrawable;
private ActionBarLayout parentLayout;
private boolean useSmoothKeyboard;
public interface SizeNotifierFrameLayoutDelegate {
void onSizeChanged(int keyboardHeight, boolean isWidthGreater);
}
public SizeNotifierFrameLayout(Context context) {
this(context, null);
public SizeNotifierFrameLayout(Context context, boolean smoothKeyboard) {
this(context, smoothKeyboard, null);
}
public SizeNotifierFrameLayout(Context context, ActionBarLayout layout) {
public SizeNotifierFrameLayout(Context context, boolean smoothKeyboard, ActionBarLayout layout) {
super(context);
setWillNotDraw(false);
useSmoothKeyboard = smoothKeyboard;
parentLayout = layout;
}
@ -143,6 +146,10 @@ public class SizeNotifierFrameLayout extends FrameLayout {
bottomClip = value;
}
public void setBackgroundTranslation(int translation) {
backgroundTranslationY = translation;
}
public int getHeightWithKeyboard() {
return getKeyboardHeight() + getMeasuredHeight();
}
@ -153,6 +160,7 @@ public class SizeNotifierFrameLayout extends FrameLayout {
super.onDraw(canvas);
return;
}
int kbHeight = useSmoothKeyboard ? 0 : keyboardHeight;
Drawable newDrawable = Theme.getCachedWallpaperNonBlocking();
if (newDrawable != backgroundDrawable && newDrawable != null) {
if (Theme.isAnimatingColor()) {
@ -186,7 +194,7 @@ public class SizeNotifierFrameLayout extends FrameLayout {
canvas.save();
canvas.clipRect(0, 0, getMeasuredWidth(), getMeasuredHeight() - bottomClip);
}
drawable.setBounds(0, 0, getMeasuredWidth(), getMeasuredHeight() + keyboardHeight);
drawable.setBounds(0, backgroundTranslationY, getMeasuredWidth(), backgroundTranslationY + getMeasuredHeight() + kbHeight);
drawable.draw(canvas);
if (bottomClip != 0) {
canvas.restore();
@ -204,12 +212,12 @@ public class SizeNotifierFrameLayout extends FrameLayout {
int actionBarHeight = (isActionBarVisible() ? ActionBar.getCurrentActionBarHeight() : 0) + (Build.VERSION.SDK_INT >= 21 && occupyStatusBar ? AndroidUtilities.statusBarHeight : 0);
int viewHeight = getMeasuredHeight() - actionBarHeight;
float scaleX = (float) getMeasuredWidth() / (float) drawable.getIntrinsicWidth();
float scaleY = (float) (viewHeight + keyboardHeight) / (float) drawable.getIntrinsicHeight();
float scaleY = (float) (viewHeight + kbHeight) / (float) drawable.getIntrinsicHeight();
float scale = scaleX < scaleY ? scaleY : scaleX;
int width = (int) Math.ceil(drawable.getIntrinsicWidth() * scale * parallaxScale);
int height = (int) Math.ceil(drawable.getIntrinsicHeight() * scale * parallaxScale);
int x = (getMeasuredWidth() - width) / 2 + (int) translationX;
int y = (viewHeight - height + keyboardHeight) / 2 + actionBarHeight + (int) translationY;
int y = backgroundTranslationY + (viewHeight - height + kbHeight) / 2 + actionBarHeight + (int) translationY;
canvas.save();
canvas.clipRect(0, actionBarHeight, width, getMeasuredHeight() - bottomClip);
drawable.setBounds(x, y, x + width, y + height);

View file

@ -12,24 +12,26 @@ import android.content.Context;
import android.graphics.Rect;
import android.view.View;
import android.view.WindowManager;
import android.widget.FrameLayout;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.ui.ActionBar.AdjustPanFrameLayout;
public class SizeNotifierFrameLayoutPhoto extends FrameLayout {
public class SizeNotifierFrameLayoutPhoto extends AdjustPanFrameLayout {
private Rect rect = new Rect();
private int keyboardHeight;
private SizeNotifierFrameLayoutPhotoDelegate delegate;
private WindowManager windowManager;
private boolean withoutWindow;
private boolean useSmoothKeyboard;
public interface SizeNotifierFrameLayoutPhotoDelegate {
void onSizeChanged(int keyboardHeight, boolean isWidthGreater);
}
public SizeNotifierFrameLayoutPhoto(Context context) {
public SizeNotifierFrameLayoutPhoto(Context context, boolean smoothKeyboard) {
super(context);
useSmoothKeyboard = smoothKeyboard;
}
public void setDelegate(SizeNotifierFrameLayoutPhotoDelegate sizeNotifierFrameLayoutPhotoDelegate) {
@ -55,7 +57,12 @@ public class SizeNotifierFrameLayoutPhoto extends FrameLayout {
} else {
int usableViewHeight = rootView.getHeight() - AndroidUtilities.getViewInset(rootView);
int top = rect.top;
int size = AndroidUtilities.displaySize.y - top - usableViewHeight;
int size;
if (useSmoothKeyboard) {
size = Math.max(0, usableViewHeight - (rect.bottom - rect.top));
} else {
size = AndroidUtilities.displaySize.y - top - usableViewHeight;
}
if (size <= Math.max(AndroidUtilities.dp(10), AndroidUtilities.statusBarHeight)) {
size = 0;
}
@ -67,12 +74,9 @@ public class SizeNotifierFrameLayoutPhoto extends FrameLayout {
if (delegate != null) {
keyboardHeight = getKeyboardHeight();
final boolean isWidthGreater = AndroidUtilities.displaySize.x > AndroidUtilities.displaySize.y;
post(new Runnable() {
@Override
public void run() {
if (delegate != null) {
delegate.onSizeChanged(keyboardHeight, isWidthGreater);
}
post(() -> {
if (delegate != null) {
delegate.onSizeChanged(keyboardHeight, isWidthGreater);
}
});
}

View file

@ -168,7 +168,7 @@ public class CountrySelectActivity extends BaseFragment {
listView.setOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
if (newState == RecyclerView.SCROLL_STATE_DRAGGING && searching && searchWas) {
if (newState == RecyclerView.SCROLL_STATE_DRAGGING) {
AndroidUtilities.hideKeyboard(getParentActivity().getCurrentFocus());
}
}

View file

@ -79,6 +79,8 @@ public class DataUsageActivity extends BaseFragment {
return t * t * t * t * t + 1.0F;
};
private boolean swipeBackEnabled = true;
public DataUsageActivity() {
super();
}
@ -548,6 +550,11 @@ public class DataUsageActivity extends BaseFragment {
}
}
@Override
public boolean isSwipeBackEnabled(MotionEvent event) {
return swipeBackEnabled;
}
private void setScrollY(float value) {
actionBar.setTranslationY(value);
for (int a = 0; a < viewPages.length; a++) {
@ -560,9 +567,9 @@ public class DataUsageActivity extends BaseFragment {
if (scrollSlidingTextTabStrip == null) {
return;
}
scrollSlidingTextTabStrip.addTextTab(0, LocaleController.getString("NetworkUsageMobile", R.string.NetworkUsageMobile));
scrollSlidingTextTabStrip.addTextTab(1, LocaleController.getString("NetworkUsageWiFi", R.string.NetworkUsageWiFi));
scrollSlidingTextTabStrip.addTextTab(2, LocaleController.getString("NetworkUsageRoaming", R.string.NetworkUsageRoaming));
scrollSlidingTextTabStrip.addTextTab(0, LocaleController.getString("NetworkUsageMobileTab", R.string.NetworkUsageMobileTab));
scrollSlidingTextTabStrip.addTextTab(1, LocaleController.getString("NetworkUsageWiFiTab", R.string.NetworkUsageWiFiTab));
scrollSlidingTextTabStrip.addTextTab(2, LocaleController.getString("NetworkUsageRoamingTab", R.string.NetworkUsageRoamingTab));
scrollSlidingTextTabStrip.setVisibility(View.VISIBLE);
actionBar.setExtraHeight(AndroidUtilities.dp(44));
int id = scrollSlidingTextTabStrip.getCurrentTabId();

View file

@ -78,6 +78,8 @@ public class DialogOrContactPickerActivity extends BaseFragment {
return t * t * t * t * t + 1.0F;
};
private boolean swipeBackEnabled = true;
public DialogOrContactPickerActivity() {
super();
@ -582,6 +584,11 @@ public class DialogOrContactPickerActivity extends BaseFragment {
}
}
@Override
public boolean isSwipeBackEnabled(MotionEvent event) {
return swipeBackEnabled;
}
@Override
public void onFragmentDestroy() {
if (dialogsActivity != null) {

View file

@ -39,7 +39,7 @@ import android.os.Vibrator;
import androidx.recyclerview.widget.ItemTouchHelper;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.LinearSmoothScrollerMiddle;
import androidx.recyclerview.widget.LinearSmoothScrollerCustom;
import androidx.recyclerview.widget.RecyclerView;
import android.text.TextUtils;
@ -183,6 +183,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
private ActionBarMenuSubItem archiveItem;
private ActionBarMenuSubItem clearItem;
private ActionBarMenuSubItem readItem;
private ActionBarMenuSubItem blockItem;
private float additionalFloatingTranslation;
private float floatingButtonTranslation;
@ -250,6 +251,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
private int canMuteCount;
private int canUnmuteCount;
private int canClearCacheCount;
private int canReportSpamCount;
private int folderId;
@ -259,6 +261,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
private final static int clear = 103;
private final static int mute = 104;
private final static int archive = 105;
private final static int block = 106;
private final static int ARCHIVE_ITEM_STATE_PINNED = 0;
private final static int ARCHIVE_ITEM_STATE_SHOWED = 1;
@ -277,7 +280,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
private int inputFieldHeight;
public ContentView(Context context) {
super(context);
super(context, SharedConfig.smoothKeyboard);
}
@Override
@ -290,7 +293,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
measureChildWithMargins(actionBar, widthMeasureSpec, 0, heightMeasureSpec, 0);
int keyboardSize = getKeyboardHeight();
int keyboardSize = SharedConfig.smoothKeyboard ? 0 : getKeyboardHeight();
int childCount = getChildCount();
if (commentView != null) {
@ -304,6 +307,12 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
} else {
inputFieldHeight = 0;
}
if (SharedConfig.smoothKeyboard && commentView.isPopupShowing()) {
fragmentView.setTranslationY(getCurrentPanTranslationY());
listView.setTranslationY(0);
searchListView.setTranslationY(0);
}
}
for (int i = 0; i < childCount; i++) {
@ -338,8 +347,9 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
int paddingBottom;
Object tag = commentView != null ? commentView.getTag() : null;
int keyboardSize = SharedConfig.smoothKeyboard ? 0 : getKeyboardHeight();
if (tag != null && tag.equals(2)) {
paddingBottom = getKeyboardHeight() <= AndroidUtilities.dp(20) && !AndroidUtilities.isInMultiwindow ? commentView.getEmojiPadding() : 0;
paddingBottom = keyboardSize <= AndroidUtilities.dp(20) && !AndroidUtilities.isInMultiwindow ? commentView.getEmojiPadding() : 0;
} else {
paddingBottom = 0;
}
@ -1164,7 +1174,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
DialogsActivity dialogsActivity = new DialogsActivity(arguments);
dialogsActivity.setDelegate(oldDelegate);
launchActivity.presentFragment(dialogsActivity, false, true);
} else if (id == pin || id == read || id == delete || id == clear || id == mute || id == archive) {
} else if (id == pin || id == read || id == delete || id == clear || id == mute || id == archive || id == block) {
perfromSelectedDialogsAction(id, true);
}
}
@ -1192,6 +1202,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
archiveItem = otherItem.addSubItem(archive, R.drawable.msg_archive, LocaleController.getString("Archive", R.string.Archive));
readItem = otherItem.addSubItem(read, R.drawable.msg_markread, LocaleController.getString("MarkAsRead", R.string.MarkAsRead));
clearItem = otherItem.addSubItem(clear, R.drawable.msg_clear, LocaleController.getString("ClearHistory", R.string.ClearHistory));
blockItem = otherItem.addSubItem(block, R.drawable.msg_block, LocaleController.getString("BlockUser", R.string.BlockUser));
actionModeViews.add(pinItem);
actionModeViews.add(muteItem);
@ -1259,7 +1270,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
if (hasHiddenArchive() && position == 1) {
super.smoothScrollToPosition(recyclerView, state, position);
} else {
LinearSmoothScrollerMiddle linearSmoothScroller = new LinearSmoothScrollerMiddle(recyclerView.getContext());
LinearSmoothScrollerCustom linearSmoothScroller = new LinearSmoothScrollerCustom(recyclerView.getContext(), LinearSmoothScrollerCustom.POSITION_MIDDLE);
linearSmoothScroller.setTargetPosition(position);
startSmoothScroll(linearSmoothScroller);
}
@ -2001,6 +2012,21 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
return fragmentView;
}
@Override
protected void onPanTranslationUpdate(int y) {
if (listView == null) {
return;
}
if (commentView != null && commentView.isPopupShowing()) {
fragmentView.setTranslationY(y);
listView.setTranslationY(0);
searchListView.setTranslationY(0);
} else {
listView.setTranslationY(y);
searchListView.setTranslationY(y);
}
}
@Override
public void onResume() {
super.onResume();
@ -2674,42 +2700,64 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
return;
}
} else if ((action == delete || action == clear) && count > 1 && alert) {
if (alert) {
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
if (action == delete) {
builder.setTitle(LocaleController.formatString("DeleteFewChatsTitle", R.string.DeleteFewChatsTitle, LocaleController.formatPluralString("ChatsSelected", count)));
builder.setMessage(LocaleController.getString("AreYouSureDeleteFewChats", R.string.AreYouSureDeleteFewChats));
builder.setPositiveButton(LocaleController.getString("Delete", R.string.Delete), (dialog1, which) -> {
getMessagesController().setDialogsInTransaction(true);
perfromSelectedDialogsAction(action, false);
getMessagesController().setDialogsInTransaction(false);
MessagesController.getInstance(currentAccount).checkIfFolderEmpty(folderId);
if (folderId != 0 && getDialogsArray(currentAccount, dialogsType, folderId, false).size() == 0) {
listView.setEmptyView(null);
progressView.setVisibility(View.INVISIBLE);
finishFragment();
}
});
} else {
if (canClearCacheCount != 0) {
builder.setTitle(LocaleController.formatString("ClearCacheFewChatsTitle", R.string.ClearCacheFewChatsTitle, LocaleController.formatPluralString("ChatsSelectedClearCache", count)));
builder.setMessage(LocaleController.getString("AreYouSureClearHistoryCacheFewChats", R.string.AreYouSureClearHistoryCacheFewChats));
builder.setPositiveButton(LocaleController.getString("ClearHistoryCache", R.string.ClearHistoryCache), (dialog1, which) -> perfromSelectedDialogsAction(action, false));
} else {
builder.setTitle(LocaleController.formatString("ClearFewChatsTitle", R.string.ClearFewChatsTitle, LocaleController.formatPluralString("ChatsSelectedClear", count)));
builder.setMessage(LocaleController.getString("AreYouSureClearHistoryFewChats", R.string.AreYouSureClearHistoryFewChats));
builder.setPositiveButton(LocaleController.getString("ClearHistory", R.string.ClearHistory), (dialog1, which) -> perfromSelectedDialogsAction(action, false));
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
if (action == delete) {
builder.setTitle(LocaleController.formatString("DeleteFewChatsTitle", R.string.DeleteFewChatsTitle, LocaleController.formatPluralString("ChatsSelected", count)));
builder.setMessage(LocaleController.getString("AreYouSureDeleteFewChats", R.string.AreYouSureDeleteFewChats));
builder.setPositiveButton(LocaleController.getString("Delete", R.string.Delete), (dialog1, which) -> {
getMessagesController().setDialogsInTransaction(true);
perfromSelectedDialogsAction(action, false);
getMessagesController().setDialogsInTransaction(false);
MessagesController.getInstance(currentAccount).checkIfFolderEmpty(folderId);
if (folderId != 0 && getDialogsArray(currentAccount, dialogsType, folderId, false).size() == 0) {
listView.setEmptyView(null);
progressView.setVisibility(View.INVISIBLE);
finishFragment();
}
});
} else {
if (canClearCacheCount != 0) {
builder.setTitle(LocaleController.formatString("ClearCacheFewChatsTitle", R.string.ClearCacheFewChatsTitle, LocaleController.formatPluralString("ChatsSelectedClearCache", count)));
builder.setMessage(LocaleController.getString("AreYouSureClearHistoryCacheFewChats", R.string.AreYouSureClearHistoryCacheFewChats));
builder.setPositiveButton(LocaleController.getString("ClearHistoryCache", R.string.ClearHistoryCache), (dialog1, which) -> perfromSelectedDialogsAction(action, false));
} else {
builder.setTitle(LocaleController.formatString("ClearFewChatsTitle", R.string.ClearFewChatsTitle, LocaleController.formatPluralString("ChatsSelectedClear", count)));
builder.setMessage(LocaleController.getString("AreYouSureClearHistoryFewChats", R.string.AreYouSureClearHistoryFewChats));
builder.setPositiveButton(LocaleController.getString("ClearHistory", R.string.ClearHistory), (dialog1, which) -> perfromSelectedDialogsAction(action, false));
}
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
AlertDialog alertDialog = builder.create();
showDialog(alertDialog);
TextView button = (TextView) alertDialog.getButton(DialogInterface.BUTTON_POSITIVE);
if (button != null) {
button.setTextColor(Theme.getColor(Theme.key_dialogTextRed2));
}
return;
}
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
AlertDialog alertDialog = builder.create();
showDialog(alertDialog);
TextView button = (TextView) alertDialog.getButton(DialogInterface.BUTTON_POSITIVE);
if (button != null) {
button.setTextColor(Theme.getColor(Theme.key_dialogTextRed2));
}
return;
} else if (action == block && alert) {
TLRPC.User user;
if (count == 1) {
long did = selectedDialogs.get(0);
user = getMessagesController().getUser((int) did);
} else {
user = null;
}
AlertsCreator.createBlockDialogAlert(DialogsActivity.this, count, canReportSpamCount != 0, user, (report, delete) -> {
for (int a = 0, N = selectedDialogs.size(); a < N; a++) {
long did = selectedDialogs.get(a);
int lowerId = (int) did;
if (report) {
TLRPC.User u = getMessagesController().getUser(lowerId);
getMessagesController().reportSpam(did, u, null, null, false);
}
if (delete) {
getMessagesController().deleteDialog(did, 0, true);
}
getMessagesController().blockUser(lowerId);
}
hideActionMode(false);
});
return;
}
boolean scrollToTop = false;
for (int a = 0; a < count; a++) {
@ -2844,6 +2892,8 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
getNotificationsController().setDialogNotificationsSettings(selectedDialog, NotificationsController.SETTING_MUTE_FOREVER);
}
}
} else if (action == block) {
}
}
if (action == pin) {
@ -2878,11 +2928,15 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
canPinCount = 0;
canReadCount = 0;
canClearCacheCount = 0;
int cantBlockCount = 0;
canReportSpamCount = 0;
if (hide) {
return;
}
ArrayList<Long> selectedDialogs = dialogsAdapter.getSelectedDialogs();
int count = selectedDialogs.size();
int selfUserId = getUserConfig().getClientUserId();
SharedPreferences preferences = getNotificationsSettings();
for (int a = 0; a < count; a++) {
TLRPC.Dialog dialog = getMessagesController().dialogs_dict.get(selectedDialogs.get(a));
if (dialog == null) {
@ -2904,13 +2958,26 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
if (folderId == 1) {
canUnarchiveCount++;
} else if (selectedDialog != getUserConfig().getClientUserId() && selectedDialog != 777000 && !getMessagesController().isProxyDialog(selectedDialog, false)) {
} else if (selectedDialog != selfUserId && selectedDialog != 777000 && !getMessagesController().isProxyDialog(selectedDialog, false)) {
canArchiveCount++;
}
int lower_id = (int) selectedDialog;
int high_id = (int) (selectedDialog >> 32);
if (lower_id <= 0 || lower_id == selfUserId) {
cantBlockCount++;
} else {
TLRPC.User user = getMessagesController().getUser(lower_id);
if (MessagesController.isSupportUser(user)) {
cantBlockCount++;
} else {
if (lower_id == 0 || preferences.getBoolean("dialog_bar_report" + selectedDialog, true)) {
canReportSpamCount++;
}
}
}
if (DialogObject.isChannel(dialog)) {
final TLRPC.Chat chat = getMessagesController().getChat(-lower_id);
CharSequence[] items;
@ -2988,6 +3055,11 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
} else {
pinItem.setVisibility(View.VISIBLE);
}
if (cantBlockCount != 0) {
blockItem.setVisibility(View.GONE);
} else {
blockItem.setVisibility(View.VISIBLE);
}
if (canUnmuteCount != 0) {
muteItem.setIcon(R.drawable.msg_unmute);
muteItem.setContentDescription(LocaleController.getString("ChatsUnmute", R.string.ChatsUnmute));

View file

@ -309,7 +309,7 @@ public class DocumentSelectActivity extends BaseFragment {
selectedFiles.clear();
sizeNotifierFrameLayout = new SizeNotifierFrameLayout(context) {
sizeNotifierFrameLayout = new SizeNotifierFrameLayout(context, SharedConfig.smoothKeyboard) {
private int lastNotifyWidth;
private boolean ignoreLayout;
@ -322,18 +322,27 @@ public class DocumentSelectActivity extends BaseFragment {
setMeasuredDimension(widthSize, heightSize);
int keyboardSize = getKeyboardHeight();
int kbHeight = getKeyboardHeight();
int keyboardSize = SharedConfig.smoothKeyboard ? 0 : kbHeight;
if (keyboardSize <= AndroidUtilities.dp(20)) {
if (!AndroidUtilities.isInMultiwindow && commentTextView != null && frameLayout2.getParent() == this) {
heightSize -= commentTextView.getEmojiPadding();
heightMeasureSpec = MeasureSpec.makeMeasureSpec(heightSize, MeasureSpec.EXACTLY);
}
} else if (commentTextView != null) {
}
if (kbHeight > AndroidUtilities.dp(20) && commentTextView != null) {
ignoreLayout = true;
commentTextView.hideEmojiView();
ignoreLayout = false;
}
if (SharedConfig.smoothKeyboard && commentTextView != null && commentTextView.isPopupShowing()) {
fragmentView.setTranslationY(getCurrentPanTranslationY());
listView.setTranslationY(0);
emptyView.setTranslationY(0);
}
int childCount = getChildCount();
for (int i = 0; i < childCount; i++) {
View child = getChildAt(i);
@ -366,7 +375,8 @@ public class DocumentSelectActivity extends BaseFragment {
}
final int count = getChildCount();
int paddingBottom = commentTextView != null && frameLayout2.getParent() == this && getKeyboardHeight() <= AndroidUtilities.dp(20) && !AndroidUtilities.isInMultiwindow && !AndroidUtilities.isTablet() ? commentTextView.getEmojiPadding() : 0;
int keyboardSize = SharedConfig.smoothKeyboard ? 0 : getKeyboardHeight();
int paddingBottom = commentTextView != null && frameLayout2.getParent() == this && keyboardSize <= AndroidUtilities.dp(20) && !AndroidUtilities.isInMultiwindow && !AndroidUtilities.isTablet() ? commentTextView.getEmojiPadding() : 0;
setBottomClip(paddingBottom);
for (int i = 0; i < count; i++) {
@ -420,7 +430,7 @@ public class DocumentSelectActivity extends BaseFragment {
if (AndroidUtilities.isTablet()) {
childTop = getMeasuredHeight() - child.getMeasuredHeight();
} else {
childTop = getMeasuredHeight() + getKeyboardHeight() - child.getMeasuredHeight();
childTop = getMeasuredHeight() + keyboardSize - child.getMeasuredHeight();
}
}
child.layout(childLeft, childTop, childLeft + width, childTop + height);
@ -480,7 +490,7 @@ public class DocumentSelectActivity extends BaseFragment {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
scrolling = newState != RecyclerView.SCROLL_STATE_IDLE;
if (newState == RecyclerView.SCROLL_STATE_DRAGGING && searching && searchWas) {
if (newState == RecyclerView.SCROLL_STATE_DRAGGING) {
AndroidUtilities.hideKeyboard(getParentActivity().getCurrentFocus());
}
}
@ -769,6 +779,21 @@ public class DocumentSelectActivity extends BaseFragment {
return fragmentView;
}
@Override
protected void onPanTranslationUpdate(int y) {
if (listView == null) {
return;
}
if (commentTextView.isPopupShowing()) {
fragmentView.setTranslationY(y);
listView.setTranslationY(0);
emptyView.setTranslationY(0);
} else {
listView.setTranslationY(y);
emptyView.setTranslationY(y);
}
}
private boolean onItemClick(View view, ListItem item) {
if (item == null || item.file == null || item.file.isDirectory()) {
return false;

View file

@ -983,7 +983,8 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
if (selectedContacts.size() == 0) {
actionBar.setSubtitle(LocaleController.formatString("MembersCountZero", R.string.MembersCountZero, LocaleController.formatPluralString("Members", maxCount)));
} else {
actionBar.setSubtitle(LocaleController.formatString("MembersCount", R.string.MembersCount, selectedContacts.size(), maxCount));
String str = LocaleController.getPluralString("MembersCountSelected", selectedContacts.size());
actionBar.setSubtitle(String.format(str, selectedContacts.size(), maxCount));
}
}
}

View file

@ -41,6 +41,7 @@ import org.telegram.messenger.ChatObject;
import org.telegram.messenger.ImageLocation;
import org.telegram.messenger.LocaleController;
import org.telegram.messenger.MessagesStorage;
import org.telegram.messenger.SharedConfig;
import org.telegram.tgnet.ConnectionsManager;
import org.telegram.tgnet.TLRPC;
import org.telegram.messenger.FileLog;
@ -231,7 +232,7 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
}
});
SizeNotifierFrameLayout sizeNotifierFrameLayout = new SizeNotifierFrameLayout(context) {
SizeNotifierFrameLayout sizeNotifierFrameLayout = new SizeNotifierFrameLayout(context, SharedConfig.smoothKeyboard) {
private boolean ignoreLayout;
@ -245,7 +246,7 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
measureChildWithMargins(actionBar, widthMeasureSpec, 0, heightMeasureSpec, 0);
int keyboardSize = getKeyboardHeight();
int keyboardSize = SharedConfig.smoothKeyboard ? 0 : getKeyboardHeight();
if (keyboardSize > AndroidUtilities.dp(20)) {
ignoreLayout = true;
editText.hideEmojiView();
@ -278,7 +279,8 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
protected void onLayout(boolean changed, int l, int t, int r, int b) {
final int count = getChildCount();
int paddingBottom = getKeyboardHeight() <= AndroidUtilities.dp(20) && !AndroidUtilities.isInMultiwindow && !AndroidUtilities.isTablet() ? editText.getEmojiPadding() : 0;
int keyboardSize = SharedConfig.smoothKeyboard ? 0 : getKeyboardHeight();
int paddingBottom = keyboardSize <= AndroidUtilities.dp(20) && !AndroidUtilities.isInMultiwindow && !AndroidUtilities.isTablet() ? editText.getEmojiPadding() : 0;
setBottomClip(paddingBottom);
for (int i = 0; i < count; i++) {
@ -332,7 +334,7 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
if (AndroidUtilities.isTablet()) {
childTop = getMeasuredHeight() - child.getMeasuredHeight();
} else {
childTop = getMeasuredHeight() + getKeyboardHeight() - child.getMeasuredHeight();
childTop = getMeasuredHeight() + keyboardSize - child.getMeasuredHeight();
}
}
child.layout(childLeft, childTop, childLeft + width, childTop + height);

View file

@ -196,7 +196,7 @@ public class LanguageSelectActivity extends BaseFragment implements Notification
listView.setOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
if (newState == RecyclerView.SCROLL_STATE_DRAGGING && searching && searchWas) {
if (newState == RecyclerView.SCROLL_STATE_DRAGGING) {
AndroidUtilities.hideKeyboard(getParentActivity().getCurrentFocus());
}
}

View file

@ -25,6 +25,7 @@ import android.graphics.Color;
import android.graphics.Point;
import android.graphics.Shader;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.ColorDrawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
@ -231,7 +232,31 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
}
}
getWindow().setBackgroundDrawableResource(R.drawable.transparent);
getWindow().setBackgroundDrawable(new ColorDrawable(0xffffffff) {
@Override
public void setBounds(int left, int top, int right, int bottom) {
bottom += AndroidUtilities.dp(500);
super.setBounds(left, top, right, bottom);
}
@Override
public void draw(Canvas canvas) {
if (SharedConfig.smoothKeyboard) {
int color = getColor();
int newColor;
if (PhotoViewer.hasInstance() && PhotoViewer.getInstance().isVisible()) {
newColor = 0xff000000;
} else {
newColor = Theme.getColor(Theme.key_windowBackgroundWhite);
}
if (color != newColor) {
setColor(newColor);
}
super.draw(canvas);
}
}
});
if (SharedConfig.passcodeHash.length() > 0 && !SharedConfig.allowScreenCapture) {
try {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);

View file

@ -405,7 +405,6 @@ public class LocationActivity extends BaseFragment implements NotificationCenter
@Override
public boolean onFragmentCreate() {
super.onFragmentCreate();
swipeBackEnabled = false;
getNotificationCenter().addObserver(this, NotificationCenter.closeChats);
NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.locationPermissionGranted);
if (messageObject != null && messageObject.isLiveLocation()) {
@ -452,6 +451,11 @@ public class LocationActivity extends BaseFragment implements NotificationCenter
}
}
@Override
public boolean isSwipeBackEnabled(MotionEvent event) {
return false;
}
@Override
public View createView(Context context) {
searchWas = false;

View file

@ -92,6 +92,7 @@ import org.telegram.ui.Components.NumberTextView;
import org.telegram.ui.Components.RadialProgressView;
import org.telegram.ui.Components.RecyclerListView;
import org.telegram.ui.Components.ScrollSlidingTextTabStrip;
import org.telegram.ui.Components.SharedMediaLayout;
import java.util.ArrayList;
import java.util.Collections;
@ -164,8 +165,10 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
private boolean animatingForward;
private boolean backAnimation;
private boolean swipeBackEnabled;
private long dialog_id;
private int columnsCount = 4;
private int columnsCount = 3;
private static final Interpolator interpolator = t -> {
--t;
@ -265,91 +268,7 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
}
};
public static class SharedMediaData {
private ArrayList<MessageObject> messages = new ArrayList<>();
private SparseArray<MessageObject>[] messagesDict = new SparseArray[]{new SparseArray<>(), new SparseArray<>()};
private ArrayList<String> sections = new ArrayList<>();
private HashMap<String, ArrayList<MessageObject>> sectionArrays = new HashMap<>();
private int totalCount;
private boolean loading;
private boolean[] endReached = new boolean[]{false, true};
private int[] max_id = new int[]{0, 0};
public void setTotalCount(int count) {
totalCount = count;
}
public void setMaxId(int num, int value) {
max_id[num] = value;
}
public void setEndReached(int num, boolean value) {
endReached[num] = value;
}
public boolean addMessage(MessageObject messageObject, int loadIndex, boolean isNew, boolean enc) {
if (messagesDict[loadIndex].indexOfKey(messageObject.getId()) >= 0) {
return false;
}
ArrayList<MessageObject> messageObjects = sectionArrays.get(messageObject.monthKey);
if (messageObjects == null) {
messageObjects = new ArrayList<>();
sectionArrays.put(messageObject.monthKey, messageObjects);
if (isNew) {
sections.add(0, messageObject.monthKey);
} else {
sections.add(messageObject.monthKey);
}
}
if (isNew) {
messageObjects.add(0, messageObject);
messages.add(0, messageObject);
} else {
messageObjects.add(messageObject);
messages.add(messageObject);
}
messagesDict[loadIndex].put(messageObject.getId(), messageObject);
if (!enc) {
if (messageObject.getId() > 0) {
max_id[loadIndex] = Math.min(messageObject.getId(), max_id[loadIndex]);
}
} else {
max_id[loadIndex] = Math.max(messageObject.getId(), max_id[loadIndex]);
}
return true;
}
public boolean deleteMessage(int mid, int loadIndex) {
MessageObject messageObject = messagesDict[loadIndex].get(mid);
if (messageObject == null) {
return false;
}
ArrayList<MessageObject> messageObjects = sectionArrays.get(messageObject.monthKey);
if (messageObjects == null) {
return false;
}
messageObjects.remove(messageObject);
messages.remove(messageObject);
messagesDict[loadIndex].remove(messageObject.getId());
if (messageObjects.isEmpty()) {
sectionArrays.remove(messageObject.monthKey);
sections.remove(messageObject.monthKey);
}
totalCount--;
return true;
}
public void replaceMid(int oldMid, int newMid) {
MessageObject obj = messagesDict[0].get(oldMid);
if (obj != null) {
messagesDict[0].remove(oldMid);
messagesDict[0].put(newMid, obj);
obj.messageOwner.id = newMid;
}
}
}
private SharedMediaData[] sharedMediaData = new SharedMediaData[5];
private SharedMediaLayout.SharedMediaData[] sharedMediaData = new SharedMediaLayout.SharedMediaData[5];
private final static int forward = 3;
private final static int delete = 4;
@ -359,13 +278,13 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
this(args, media, null, MediaDataController.MEDIA_PHOTOVIDEO);
}
public MediaActivity(Bundle args, int[] media, SharedMediaData[] mediaData, int initTab) {
public MediaActivity(Bundle args, int[] media, SharedMediaLayout.SharedMediaData[] mediaData, int initTab) {
super(args);
hasMedia = media;
initialTab = initTab;
dialog_id = args.getLong("dialog_id", 0);
for (int a = 0; a < sharedMediaData.length; a++) {
sharedMediaData[a] = new SharedMediaData();
sharedMediaData[a] = new SharedMediaLayout.SharedMediaData();
sharedMediaData[a].max_id[0] = ((int) dialog_id) == 0 ? Integer.MIN_VALUE : Integer.MAX_VALUE;
if (mergeDialogId != 0 && info != null) {
sharedMediaData[a].max_id[1] = info.migrated_from_max_id;
@ -373,13 +292,13 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
}
if (mediaData != null) {
sharedMediaData[a].totalCount = mediaData[a].totalCount;
//sharedMediaData[a].endReached = mediaData[a].endReached;
sharedMediaData[a].messages.addAll(mediaData[a].messages);
sharedMediaData[a].sections.addAll(mediaData[a].sections);
for (HashMap.Entry<String, ArrayList<MessageObject>> entry : mediaData[a].sectionArrays.entrySet()) {
sharedMediaData[a].sectionArrays.put(entry.getKey(), new ArrayList<>(entry.getValue()));
}
for (int i = 0; i < 2; i++) {
sharedMediaData[a].endReached[i] = mediaData[a].endReached[i];
sharedMediaData[a].messagesDict[i] = mediaData[a].messagesDict[i].clone();
sharedMediaData[a].max_id[i] = mediaData[a].max_id[i];
}
@ -1181,7 +1100,7 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
if (newState == RecyclerView.SCROLL_STATE_DRAGGING && searching && searchWas) {
if (newState == RecyclerView.SCROLL_STATE_DRAGGING) {
AndroidUtilities.hideKeyboard(getParentActivity().getCurrentFocus());
}
scrolling = newState != RecyclerView.SCROLL_STATE_IDLE;
@ -1343,6 +1262,7 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
return false;
}
}
private void setScrollY(float value) {
actionBar.setTranslationY(value);
if (fragmentContextView != null) {
@ -1470,7 +1390,7 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
boolean updated = false;
for (int a = 0, N = markAsDeletedMessages.size(); a < N; a++) {
for (int b = 0; b < sharedMediaData.length; b++) {
if (sharedMediaData[b].deleteMessage(markAsDeletedMessages.get(a), loadIndex)) {
if (sharedMediaData[b].deleteMessage(markAsDeletedMessages.get(a), loadIndex) != null) {
updated = true;
}
}
@ -1554,8 +1474,8 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
}
Integer msgId = (Integer) args[0];
Integer newMsgId = (Integer) args[1];
for (SharedMediaData data : sharedMediaData) {
data.replaceMid(msgId, newMsgId);
for (int a = 0; a < sharedMediaData.length; a++) {
sharedMediaData[a].replaceMid(msgId, newMsgId);
}
} else if (id == NotificationCenter.messagePlayingDidStart || id == NotificationCenter.messagePlayingPlayStateChanged || id == NotificationCenter.messagePlayingDidReset) {
if (id == NotificationCenter.messagePlayingDidReset || id == NotificationCenter.messagePlayingPlayStateChanged) {
@ -1612,6 +1532,11 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
}
}
@Override
public boolean isSwipeBackEnabled(MotionEvent event) {
return swipeBackEnabled;
}
@Override
public void onConfigurationChanged(android.content.res.Configuration newConfig) {
super.onConfigurationChanged(newConfig);
@ -1772,23 +1697,23 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
scrollSlidingTextTabStrip.removeTabs();
if (hasMedia[0] != 0 || hasMedia[1] == 0 && hasMedia[2] == 0 && hasMedia[3] == 0 && hasMedia[4] == 0) {
if (!scrollSlidingTextTabStrip.hasTab(0)) {
scrollSlidingTextTabStrip.addTextTab(0, LocaleController.getString("SharedMediaTab", R.string.SharedMediaTab));
scrollSlidingTextTabStrip.addTextTab(0, LocaleController.getString("SharedMediaTab2", R.string.SharedMediaTab2));
}
}
if (hasMedia[1] != 0) {
if (!scrollSlidingTextTabStrip.hasTab(1)) {
scrollSlidingTextTabStrip.addTextTab(1, LocaleController.getString("SharedFilesTab", R.string.SharedFilesTab));
scrollSlidingTextTabStrip.addTextTab(1, LocaleController.getString("SharedFilesTab2", R.string.SharedFilesTab2));
}
}
if ((int) dialog_id != 0) {
if (hasMedia[3] != 0) {
if (!scrollSlidingTextTabStrip.hasTab(3)) {
scrollSlidingTextTabStrip.addTextTab(3, LocaleController.getString("SharedLinksTab", R.string.SharedLinksTab));
scrollSlidingTextTabStrip.addTextTab(3, LocaleController.getString("SharedLinksTab2", R.string.SharedLinksTab2));
}
}
if (hasMedia[4] != 0) {
if (!scrollSlidingTextTabStrip.hasTab(4)) {
scrollSlidingTextTabStrip.addTextTab(4, LocaleController.getString("SharedMusicTab", R.string.SharedMusicTab));
scrollSlidingTextTabStrip.addTextTab(4, LocaleController.getString("SharedMusicTab2", R.string.SharedMusicTab2));
}
}
} else {
@ -1796,14 +1721,14 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
if (currentEncryptedChat != null && AndroidUtilities.getPeerLayerVersion(currentEncryptedChat.layer) >= 46) {
if (hasMedia[4] != 0) {
if (!scrollSlidingTextTabStrip.hasTab(4)) {
scrollSlidingTextTabStrip.addTextTab(4, LocaleController.getString("SharedMusicTab", R.string.SharedMusicTab));
scrollSlidingTextTabStrip.addTextTab(4, LocaleController.getString("SharedMusicTab2", R.string.SharedMusicTab2));
}
}
}
}
if (hasMedia[2] != 0) {
if (!scrollSlidingTextTabStrip.hasTab(2)) {
scrollSlidingTextTabStrip.addTextTab(2, LocaleController.getString("SharedVoiceTab", R.string.SharedVoiceTab));
scrollSlidingTextTabStrip.addTextTab(2, LocaleController.getString("SharedVoiceTab2", R.string.SharedVoiceTab2));
}
}
}
@ -2177,14 +2102,14 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
}
if (AndroidUtilities.isTablet()) {
columnsCount = 4;
columnsCount = 3;
mediaPages[num].emptyTextView.setPadding(AndroidUtilities.dp(40), 0, AndroidUtilities.dp(40), AndroidUtilities.dp(128));
} else {
if (rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90) {
columnsCount = 6;
mediaPages[num].emptyTextView.setPadding(AndroidUtilities.dp(40), 0, AndroidUtilities.dp(40), 0);
} else {
columnsCount = 4;
columnsCount = 3;
mediaPages[num].emptyTextView.setPadding(AndroidUtilities.dp(40), 0, AndroidUtilities.dp(40), AndroidUtilities.dp(128));
}
}
@ -2766,14 +2691,14 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
} else {
for (int a = 0; a < mediaPages.length; a++) {
if (mediaPages[a].selectedType == currentType) {
if (getItemCount() != 0) {
mediaPages[a].listView.setEmptyView(mediaPages[a].emptyView);
mediaPages[a].progressView.setVisibility(View.GONE);
} else {
//if (getItemCount() != 0) {
mediaPages[a].listView.setEmptyView(mediaPages[a].emptyView);
mediaPages[a].progressView.setVisibility(View.GONE);
/*} else {
mediaPages[a].listView.setEmptyView(null);
mediaPages[a].emptyView.setVisibility(View.GONE);
mediaPages[a].progressView.setVisibility(View.VISIBLE);
}
}*/
}
}

View file

@ -527,7 +527,7 @@ public class NotificationsCustomSettingsActivity extends BaseFragment {
listView.setOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
if (newState == RecyclerView.SCROLL_STATE_DRAGGING && searching && searchWas) {
if (newState == RecyclerView.SCROLL_STATE_DRAGGING) {
AndroidUtilities.hideKeyboard(getParentActivity().getCurrentFocus());
}
}

View file

@ -185,6 +185,8 @@ public class PaymentFormActivity extends BaseFragment implements NotificationCen
private boolean shouldNavigateBack;
private ScrollView scrollView;
private boolean swipeBackEnabled = true;
private TextView textView;
private HeaderCell[] headerCell = new HeaderCell[3];
private ArrayList<View> dividers = new ArrayList<>();
@ -3043,13 +3045,19 @@ public class PaymentFormActivity extends BaseFragment implements NotificationCen
AndroidUtilities.runOnUIThread(() -> {
NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.paymentFinished);
setDonePressed(false);
webView.setVisibility(View.VISIBLE);
webviewLoading = true;
showEditDoneProgress(true, true);
progressView.setVisibility(View.VISIBLE);
doneItem.setEnabled(false);
doneItem.getContentView().setVisibility(View.INVISIBLE);
webView.loadUrl(webViewUrl = ((TLRPC.TL_payments_paymentVerificationNeeded) response).url);
if (progressView != null) {
progressView.setVisibility(View.VISIBLE);
}
if (doneItem != null) {
doneItem.setEnabled(false);
doneItem.getContentView().setVisibility(View.INVISIBLE);
}
if (webView != null) {
webView.setVisibility(View.VISIBLE);
webView.loadUrl(webViewUrl = ((TLRPC.TL_payments_paymentVerificationNeeded) response).url);
}
});
}
} else {
@ -3085,6 +3093,11 @@ public class PaymentFormActivity extends BaseFragment implements NotificationCen
}
}
@Override
public boolean isSwipeBackEnabled(MotionEvent event) {
return swipeBackEnabled;
}
private void checkPassword() {
if (UserConfig.getInstance(currentAccount).tmpPassword != null) {
if (UserConfig.getInstance(currentAccount).tmpPassword.valid_until < ConnectionsManager.getInstance(currentAccount).getCurrentTime() + 60) {

View file

@ -13,8 +13,11 @@ import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.drawable.Drawable;
import android.location.Location;
import android.os.Build;
import android.os.Bundle;
import android.os.SystemClock;
import android.util.TypedValue;
@ -33,6 +36,7 @@ import org.telegram.messenger.LocaleController;
import org.telegram.messenger.LocationController;
import org.telegram.messenger.NotificationCenter;
import org.telegram.messenger.R;
import org.telegram.messenger.UserConfig;
import org.telegram.tgnet.TLRPC;
import org.telegram.ui.ActionBar.ActionBar;
import org.telegram.ui.ActionBar.AlertDialog;
@ -61,6 +65,10 @@ public class PeopleNearbyActivity extends BaseFragment implements NotificationCe
private RecyclerListView listView;
private ActionIntroActivity groupCreateActivity;
private UndoView undoView;
private LinearLayoutManager layoutManager;
private View actionBarBackground;
private AnimatorSet actionBarAnimator;
private String currentGroupCreateAddress;
private String currentGroupCreateDisplayAddress;
@ -70,6 +78,8 @@ public class PeopleNearbyActivity extends BaseFragment implements NotificationCe
private boolean canCreateGroup;
private AlertDialog loadingDialog;
private boolean expanded;
private Runnable checkExpiredRunnable;
private int reqId;
@ -88,7 +98,7 @@ public class PeopleNearbyActivity extends BaseFragment implements NotificationCe
@Override
public void run() {
if (shortPollRunnable != null) {
sendRequest(true);
sendRequest(true, 0);
AndroidUtilities.cancelRunOnUIThread(shortPollRunnable);
AndroidUtilities.runOnUIThread(shortPollRunnable, SHORT_POLL_TIMEOUT);
}
@ -99,12 +109,15 @@ public class PeopleNearbyActivity extends BaseFragment implements NotificationCe
private ArrayList<TLRPC.TL_peerLocated> chats;
private int currentChatId;
private boolean showingMe;
private int helpRow;
private int helpSectionRow;
private int usersHeaderRow;
private int showMeRow;
private int usersStartRow;
private int usersEndRow;
private int usersEmptyRow;
private int showMoreRow;
private int usersSectionRow;
private int chatsHeaderRow;
private int chatsStartRow;
@ -125,19 +138,29 @@ public class PeopleNearbyActivity extends BaseFragment implements NotificationCe
rowCount = 0;
usersStartRow = -1;
usersEndRow = -1;
usersEmptyRow = -1;
showMoreRow = -1;
chatsStartRow = -1;
chatsEndRow = -1;
chatsCreateRow = -1;
showMeRow = -1;
helpRow = rowCount++;
helpSectionRow = rowCount++;
usersHeaderRow = rowCount++;
if (users.isEmpty()) {
usersEmptyRow = rowCount++;
} else {
showMeRow = rowCount++;
if (!users.isEmpty()) {
int count;
if (expanded) {
count = users.size();
} else {
count = Math.min(5, users.size());
}
usersStartRow = rowCount;
rowCount += users.size();
rowCount += count;
usersEndRow = rowCount;
if (count != users.size()) {
showMoreRow = rowCount++;
}
}
usersSectionRow = rowCount++;
@ -162,7 +185,7 @@ public class PeopleNearbyActivity extends BaseFragment implements NotificationCe
getNotificationCenter().addObserver(this, NotificationCenter.newPeopleNearbyAvailable);
getNotificationCenter().addObserver(this, NotificationCenter.needDeleteDialog);
checkCanCreateGroup();
sendRequest(false);
sendRequest(false, 0);
AndroidUtilities.runOnUIThread(shortPollRunnable, SHORT_POLL_TIMEOUT);
return true;
}
@ -193,8 +216,18 @@ public class PeopleNearbyActivity extends BaseFragment implements NotificationCe
@Override
public View createView(Context context) {
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setAllowOverlayTitle(true);
actionBar.setBackgroundDrawable(null);
actionBar.setTitleColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
actionBar.setItemsColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText), false);
actionBar.setItemsBackgroundColor(Theme.getColor(Theme.key_listSelector), false);
actionBar.setCastShadows(false);
actionBar.setAddToContainer(false);
actionBar.setOccupyStatusBar(Build.VERSION.SDK_INT >= 21 && !AndroidUtilities.isTablet());
actionBar.setTitle(LocaleController.getString("PeopleNearby", R.string.PeopleNearby));
actionBar.getTitleTextView().setAlpha(0.0f);
if (!AndroidUtilities.isTablet()) {
actionBar.showActionModeTop();
}
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
@Override
public void onItemClick(int id) {
@ -204,24 +237,45 @@ public class PeopleNearbyActivity extends BaseFragment implements NotificationCe
}
});
fragmentView = new FrameLayout(context);
fragmentView = new FrameLayout(context) {
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) actionBarBackground.getLayoutParams();
layoutParams.height = ActionBar.getCurrentActionBarHeight() + (actionBar.getOccupyStatusBar() ? AndroidUtilities.statusBarHeight : 0) + AndroidUtilities.dp(3);
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
checkScroll(false);
}
};
fragmentView.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundGray));
fragmentView.setTag(Theme.key_windowBackgroundGray);
FrameLayout frameLayout = (FrameLayout) fragmentView;
listView = new RecyclerListView(context);
listView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false));
listView.setGlowColor(0);
listView.setLayoutManager(layoutManager = new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false));
listView.setAdapter(listViewAdapter = new ListAdapter(context));
listView.setVerticalScrollbarPosition(LocaleController.isRTL ? RecyclerListView.SCROLLBAR_POSITION_LEFT : RecyclerListView.SCROLLBAR_POSITION_RIGHT);
frameLayout.addView(listView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
listView.setOnItemClickListener((view, position) -> {
if (getParentActivity() == null) {
return;
}
if (position >= usersStartRow && position < usersEndRow) {
ManageChatUserCell cell = (ManageChatUserCell) view;
TLRPC.TL_peerLocated peerLocated = users.get(position - usersStartRow);
Bundle args1 = new Bundle();
args1.putInt("user_id", peerLocated.peer.user_id);
ChatActivity chatActivity = new ChatActivity(args1);
presentFragment(chatActivity);
if (cell.hasAvatarSet()) {
args1.putBoolean("expandPhoto", true);
}
presentFragment(new ProfileActivity(args1));
} else if (position >= chatsStartRow && position < chatsEndRow) {
TLRPC.TL_peerLocated peerLocated = chats.get(position - chatsStartRow);
Bundle args1 = new Bundle();
@ -242,8 +296,54 @@ public class PeopleNearbyActivity extends BaseFragment implements NotificationCe
return;
}
openGroupCreate();
} else if (position == showMeRow) {
UserConfig userConfig = getUserConfig();
if (showingMe) {
userConfig.sharingMyLocationUntil = 0;
userConfig.saveConfig(false);
sendRequest(false, 2);
updateRows();
} else {
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setTitle(LocaleController.getString("MakeMyselfVisibleTitle", R.string.MakeMyselfVisibleTitle));
builder.setMessage(LocaleController.getString("MakeMyselfVisibleInfo", R.string.MakeMyselfVisibleInfo));
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), (dialog, which) -> {
userConfig.sharingMyLocationUntil = 0x7fffffff;
userConfig.saveConfig(false);
sendRequest(false, 1);
updateRows();
});
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
showDialog(builder.create());
}
userConfig.saveConfig(false);
} else if (position == showMoreRow) {
expanded = true;
updateRows();
}
});
listView.setOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
checkScroll(true);
}
});
actionBarBackground = new View(context) {
private Paint paint = new Paint();
@Override
protected void onDraw(Canvas canvas) {
paint.setColor(Theme.getColor(Theme.key_windowBackgroundWhite));
int h = getMeasuredHeight() - AndroidUtilities.dp(3);
canvas.drawRect(0, 0, getMeasuredWidth(), h, paint);
parentLayout.drawHeaderShadow(canvas, h);
}
};
actionBarBackground.setAlpha(0.0f);
frameLayout.addView(actionBarBackground, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
frameLayout.addView(actionBar, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
undoView = new UndoView(context);
frameLayout.addView(undoView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.BOTTOM | Gravity.LEFT, 8, 0, 8, 8));
@ -252,6 +352,52 @@ public class PeopleNearbyActivity extends BaseFragment implements NotificationCe
return fragmentView;
}
private int[] location = new int[2];
private void checkScroll(boolean animated) {
int first = layoutManager.findFirstVisibleItemPosition();
boolean show;
if (first != 0) {
show = true;
} else {
RecyclerView.ViewHolder holder = listView.findViewHolderForAdapterPosition(first);
if (holder == null) {
show = true;
} else {
HintInnerCell hintInnerCell = (HintInnerCell) holder.itemView;
hintInnerCell.titleTextView.getLocationOnScreen(location);
show = location[1] + hintInnerCell.titleTextView.getMeasuredHeight() < actionBar.getBottom();
}
}
boolean visible = actionBarBackground.getTag() == null;
if (show != visible) {
actionBarBackground.setTag(show ? null : 1);
if (actionBarAnimator != null) {
actionBarAnimator.cancel();
actionBarAnimator = null;
}
if (animated) {
actionBarAnimator = new AnimatorSet();
actionBarAnimator.playTogether(
ObjectAnimator.ofFloat(actionBarBackground, View.ALPHA, show ? 1.0f : 0.0f),
ObjectAnimator.ofFloat(actionBar.getTitleTextView(), View.ALPHA, show ? 1.0f : 0.0f)
);
actionBarAnimator.setDuration(150);
actionBarAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
if (animation.equals(actionBarAnimator)) {
actionBarAnimator = null;
}
}
});
actionBarAnimator.start();
} else {
actionBarBackground.setAlpha(show ? 1.0f : 0.0f);
actionBar.getTitleTextView().setAlpha(show ? 1.0f : 0.0f);
}
}
}
private void openGroupCreate() {
if (!canCreateGroup) {
AlertsCreator.showSimpleAlert(PeopleNearbyActivity.this, LocaleController.getString("YourLocatedChannelsTooMuch", R.string.YourLocatedChannelsTooMuch));
@ -324,7 +470,7 @@ public class PeopleNearbyActivity extends BaseFragment implements NotificationCe
showProgressAnimation.start();
}
private void sendRequest(boolean shortpoll) {
private void sendRequest(boolean shortpoll, int share) {
if (!firstLoaded) {
AndroidUtilities.runOnUIThread(showProgressRunnable = () -> {
showLoadingProgress(true);
@ -342,7 +488,7 @@ public class PeopleNearbyActivity extends BaseFragment implements NotificationCe
if (BuildVars.DEBUG_VERSION) {
FileLog.d("located distance = " + distance);
}
if ((SystemClock.elapsedRealtime() - lastLoadedLocationTime) >= 3000L && lastLoadedLocation.distanceTo(location) > 20) {
if (share != 0 || (SystemClock.elapsedRealtime() - lastLoadedLocationTime) >= 3000L && lastLoadedLocation.distanceTo(location) > 20) {
if (reqId != 0) {
getConnectionsManager().cancelRequest(reqId, true);
reqId = 0;
@ -361,6 +507,10 @@ public class PeopleNearbyActivity extends BaseFragment implements NotificationCe
req.geo_point = new TLRPC.TL_inputGeoPoint();
req.geo_point.lat = location.getLatitude();
req.geo_point._long = location.getLongitude();
if (share != 0) {
req.flags |= 1;
req.self_expires = share == 1 ? 0x7fffffff : 0;
}
reqId = getConnectionsManager().sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
reqId = 0;
if (showProgressRunnable != null) {
@ -368,26 +518,50 @@ public class PeopleNearbyActivity extends BaseFragment implements NotificationCe
showProgressRunnable = null;
}
showLoadingProgress(false);
if (response != null) {
if (response != null && share != 2) {
TLRPC.Updates updates = (TLRPC.TL_updates) response;
getMessagesController().putUsers(updates.users, false);
getMessagesController().putChats(updates.chats, false);
users.clear();
chats.clear();
boolean hasSelf = false;
UserConfig userConfig = getUserConfig();
boolean saveConfig = false;
if (userConfig.sharingMyLocationUntil != 0) {
userConfig.lastMyLocationShareTime = (int) (System.currentTimeMillis() / 1000);
saveConfig = true;
}
for (int a = 0, N = updates.updates.size(); a < N; a++) {
TLRPC.Update baseUpdate = updates.updates.get(a);
if (baseUpdate instanceof TLRPC.TL_updatePeerLocated) {
TLRPC.TL_updatePeerLocated update = (TLRPC.TL_updatePeerLocated) baseUpdate;
for (int b = 0, N2 = update.peers.size(); b < N2; b++) {
TLRPC.TL_peerLocated peerLocated = update.peers.get(b);
if (peerLocated.peer instanceof TLRPC.TL_peerUser) {
users.add(peerLocated);
} else {
chats.add(peerLocated);
TLRPC.PeerLocated object = update.peers.get(b);
if (object instanceof TLRPC.TL_peerLocated) {
TLRPC.TL_peerLocated peerLocated = (TLRPC.TL_peerLocated) object;
if (peerLocated.peer instanceof TLRPC.TL_peerUser) {
users.add(peerLocated);
} else {
chats.add(peerLocated);
}
} else if (object instanceof TLRPC.TL_peerSelfLocated) {
hasSelf = true;
TLRPC.TL_peerSelfLocated peerSelfLocated = (TLRPC.TL_peerSelfLocated) object;
if (userConfig.sharingMyLocationUntil != peerSelfLocated.expires) {
userConfig.sharingMyLocationUntil = peerSelfLocated.expires;
saveConfig = true;
}
}
}
}
}
if (!hasSelf && userConfig.sharingMyLocationUntil != 0) {
userConfig.sharingMyLocationUntil = 0;
saveConfig = true;
}
if (saveConfig) {
userConfig.saveConfig(false);
}
checkForExpiredLocations(true);
updateRows();
}
@ -453,27 +627,30 @@ public class PeopleNearbyActivity extends BaseFragment implements NotificationCe
@Override
public void didReceivedNotification(int id, int account, Object... args) {
if (id == NotificationCenter.newLocationAvailable) {
sendRequest(false);
sendRequest(false, 0);
} else if (id == NotificationCenter.newPeopleNearbyAvailable) {
TLRPC.TL_updatePeerLocated update = (TLRPC.TL_updatePeerLocated) args[0];
for (int b = 0, N2 = update.peers.size(); b < N2; b++) {
TLRPC.TL_peerLocated peerLocated = update.peers.get(b);
boolean found = false;
ArrayList<TLRPC.TL_peerLocated> arrayList;
if (peerLocated.peer instanceof TLRPC.TL_peerUser) {
arrayList = users;
} else {
arrayList = chats;
}
for (int a = 0, N = arrayList.size(); a < N; a++) {
TLRPC.TL_peerLocated old = arrayList.get(a);
if (old.peer.user_id != 0 && old.peer.user_id == peerLocated.peer.user_id || old.peer.chat_id != 0 && old.peer.chat_id == peerLocated.peer.chat_id || old.peer.channel_id != 0 && old.peer.channel_id == peerLocated.peer.channel_id) {
arrayList.set(a, peerLocated);
found = true;
TLRPC.PeerLocated object = update.peers.get(b);
if (object instanceof TLRPC.TL_peerLocated) {
TLRPC.TL_peerLocated peerLocated = (TLRPC.TL_peerLocated) object;
boolean found = false;
ArrayList<TLRPC.TL_peerLocated> arrayList;
if (peerLocated.peer instanceof TLRPC.TL_peerUser) {
arrayList = users;
} else {
arrayList = chats;
}
for (int a = 0, N = arrayList.size(); a < N; a++) {
TLRPC.TL_peerLocated old = arrayList.get(a);
if (old.peer.user_id != 0 && old.peer.user_id == peerLocated.peer.user_id || old.peer.chat_id != 0 && old.peer.chat_id == peerLocated.peer.chat_id || old.peer.channel_id != 0 && old.peer.channel_id == peerLocated.peer.channel_id) {
arrayList.set(a, peerLocated);
found = true;
}
}
if (!found) {
arrayList.add(peerLocated);
}
}
if (!found) {
arrayList.add(peerLocated);
}
}
checkForExpiredLocations(true);
@ -559,26 +736,37 @@ public class PeopleNearbyActivity extends BaseFragment implements NotificationCe
}
}
@SuppressWarnings("FieldCanBeLocal")
public class HintInnerCell extends FrameLayout {
private ImageView imageView;
private TextView titleTextView;
private TextView messageTextView;
public HintInnerCell(Context context) {
super(context);
int top = (int) ((ActionBar.getCurrentActionBarHeight() + (actionBar.getOccupyStatusBar() ? AndroidUtilities.statusBarHeight : 0)) / AndroidUtilities.density) - 44;
imageView = new ImageView(context);
imageView.setBackgroundDrawable(Theme.createCircleDrawable(AndroidUtilities.dp(74), Theme.getColor(Theme.key_chats_archiveBackground)));
imageView.setImageDrawable(new ShareLocationDrawable(context, 2));
imageView.setScaleType(ImageView.ScaleType.CENTER);
addView(imageView, LayoutHelper.createFrame(74, 74, Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, 27, 0, 0));
addView(imageView, LayoutHelper.createFrame(74, 74, Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, top + 27, 0, 0));
titleTextView = new TextView(context);
titleTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
titleTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 24);
titleTextView.setGravity(Gravity.CENTER);
titleTextView.setText(AndroidUtilities.replaceTags(LocaleController.formatString("PeopleNearby", R.string.PeopleNearby)));
addView(titleTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.LEFT, 52, top + 120, 52, 27));
messageTextView = new TextView(context);
messageTextView.setTextColor(Theme.getColor(Theme.key_chats_message));
messageTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
messageTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText));
messageTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
messageTextView.setGravity(Gravity.CENTER);
messageTextView.setText(AndroidUtilities.replaceTags(LocaleController.formatString("PeopleNearbyInfo", R.string.PeopleNearbyInfo)));
addView(messageTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.LEFT, 52, 125, 52, 27));
messageTextView.setText(AndroidUtilities.replaceTags(LocaleController.formatString("PeopleNearbyInfo2", R.string.PeopleNearbyInfo2)));
addView(messageTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.LEFT, 40, top + 161, 40, 27));
}
}
@ -610,7 +798,7 @@ public class PeopleNearbyActivity extends BaseFragment implements NotificationCe
view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
break;
case 1:
view = new ShadowSectionCell(mContext, 22);
view = new ShadowSectionCell(mContext);
break;
case 2:
view = new ManageChatTextCell(mContext);
@ -637,6 +825,7 @@ public class PeopleNearbyActivity extends BaseFragment implements NotificationCe
case 5:
default:
view = new HintInnerCell(mContext);
view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
break;
}
view.setLayoutParams(new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
@ -666,7 +855,7 @@ public class PeopleNearbyActivity extends BaseFragment implements NotificationCe
TLRPC.TL_peerLocated peerLocated = users.get(index);
TLRPC.User user = getMessagesController().getUser(peerLocated.peer.user_id);
if (user != null) {
userCell.setData(user, null, formatDistance(peerLocated), index != users.size() - 1);
userCell.setData(user, null, formatDistance(peerLocated), showMoreRow != -1 || position != usersEndRow - 1);
}
} else if (position >= chatsStartRow && position < chatsEndRow) {
int index = position - chatsStartRow;
@ -693,6 +882,8 @@ public class PeopleNearbyActivity extends BaseFragment implements NotificationCe
privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
} else if (position == chatsSectionRow) {
privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
} else if (position == helpSectionRow) {
privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
}
break;
case 2:
@ -700,6 +891,15 @@ public class PeopleNearbyActivity extends BaseFragment implements NotificationCe
actionCell.setColors(Theme.key_windowBackgroundWhiteBlueIcon, Theme.key_windowBackgroundWhiteBlueButton);
if (position == chatsCreateRow) {
actionCell.setText(LocaleController.getString("NearbyCreateGroup", R.string.NearbyCreateGroup), null, R.drawable.groups_create, chatsStartRow != -1);
} else if (position == showMeRow) {
if (showingMe = (getUserConfig().sharingMyLocationUntil > getConnectionsManager().getCurrentTime())) {
actionCell.setText(LocaleController.getString("StopShowingMe", R.string.StopShowingMe), null, R.drawable.actions_nearby_off, chatsStartRow != -1);
actionCell.setColors(Theme.key_windowBackgroundWhiteRedText5, Theme.key_windowBackgroundWhiteRedText5);
} else {
actionCell.setText(LocaleController.getString("MakeMyselfVisible", R.string.MakeMyselfVisible), null, R.drawable.actions_nearby_on, usersStartRow != -1);
}
} else if (position == showMoreRow) {
actionCell.setText(LocaleController.formatPluralString("ShowVotes", users.size() - 5), null, R.drawable.arrow_more, false);
}
break;
case 3:
@ -710,12 +910,6 @@ public class PeopleNearbyActivity extends BaseFragment implements NotificationCe
headerCell.setText(LocaleController.getString("ChatsNearbyHeader", R.string.ChatsNearbyHeader));
}
break;
case 4:
TextView textView = (TextView) holder.itemView;
if (position == usersEmptyRow) {
textView.setText(AndroidUtilities.replaceTags(LocaleController.getString("PeopleNearbyEmpty", R.string.PeopleNearbyEmpty)));
}
break;
}
}
@ -730,14 +924,12 @@ public class PeopleNearbyActivity extends BaseFragment implements NotificationCe
public int getItemViewType(int position) {
if (position == helpRow) {
return 5;
} else if (position == chatsCreateRow) {
} else if (position == chatsCreateRow || position == showMeRow || position == showMoreRow) {
return 2;
} else if (position == usersHeaderRow || position == chatsHeaderRow) {
return 3;
} else if (position == usersSectionRow || position == chatsSectionRow) {
} else if (position == usersSectionRow || position == chatsSectionRow || position == helpSectionRow) {
return 1;
} else if (position == usersEmptyRow) {
return 4;
}
return 0;
}
@ -758,15 +950,14 @@ public class PeopleNearbyActivity extends BaseFragment implements NotificationCe
};
return new ThemeDescription[]{
new ThemeDescription(listView, ThemeDescription.FLAG_CELLBACKGROUNDCOLOR, new Class[]{ManageChatUserCell.class, ManageChatTextCell.class, HeaderCell.class, TextView.class}, null, null, null, Theme.key_windowBackgroundWhite),
new ThemeDescription(listView, ThemeDescription.FLAG_CELLBACKGROUNDCOLOR, new Class[]{ManageChatUserCell.class, ManageChatTextCell.class, HeaderCell.class, TextView.class, HintInnerCell.class}, null, null, null, Theme.key_windowBackgroundWhite),
new ThemeDescription(fragmentView, ThemeDescription.FLAG_BACKGROUND | ThemeDescription.FLAG_CHECKTAG, null, null, null, null, Theme.key_windowBackgroundGray),
new ThemeDescription(fragmentView, ThemeDescription.FLAG_BACKGROUND | ThemeDescription.FLAG_CHECKTAG, null, null, null, null, Theme.key_windowBackgroundWhite),
new ThemeDescription(actionBar, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_actionBarDefault),
new ThemeDescription(listView, ThemeDescription.FLAG_LISTGLOWCOLOR, null, null, null, null, Theme.key_actionBarDefault),
new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_ITEMSCOLOR, null, null, null, null, Theme.key_actionBarDefaultIcon),
new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_TITLECOLOR, null, null, null, null, Theme.key_actionBarDefaultTitle),
new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SELECTORCOLOR, null, null, null, null, Theme.key_actionBarDefaultSelector),
new ThemeDescription(actionBarBackground, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_windowBackgroundWhite),
new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_ITEMSCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteBlackText),
new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_TITLECOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteBlackText),
new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SELECTORCOLOR, null, null, null, null, Theme.key_listSelector),
new ThemeDescription(listView, ThemeDescription.FLAG_SELECTOR, null, null, null, null, Theme.key_listSelector),
@ -796,6 +987,8 @@ public class PeopleNearbyActivity extends BaseFragment implements NotificationCe
new ThemeDescription(listView, ThemeDescription.FLAG_CHECKTAG, new Class[]{ManageChatTextCell.class}, new String[]{"imageView"}, null, null, null, Theme.key_windowBackgroundWhiteGrayIcon),
new ThemeDescription(listView, ThemeDescription.FLAG_CHECKTAG, new Class[]{ManageChatTextCell.class}, new String[]{"imageView"}, null, null, null, Theme.key_windowBackgroundWhiteBlueButton),
new ThemeDescription(listView, ThemeDescription.FLAG_CHECKTAG, new Class[]{ManageChatTextCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteBlueIcon),
new ThemeDescription(listView, ThemeDescription.FLAG_CHECKTAG, new Class[]{ManageChatTextCell.class}, new String[]{"imageView"}, null, null, null, Theme.key_windowBackgroundWhiteRedText5),
new ThemeDescription(listView, ThemeDescription.FLAG_CHECKTAG, new Class[]{ManageChatTextCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteRedText5),
new ThemeDescription(undoView, ThemeDescription.FLAG_BACKGROUNDFILTER, null, null, null, null, Theme.key_undo_background),
new ThemeDescription(undoView, 0, new Class[]{UndoView.class}, new String[]{"undoImageView"}, null, null, null, Theme.key_undo_cancelColor),

View file

@ -43,6 +43,7 @@ import org.telegram.messenger.NotificationCenter;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.R;
import org.telegram.messenger.SendMessagesHelper;
import org.telegram.messenger.SharedConfig;
import org.telegram.messenger.UserConfig;
import org.telegram.messenger.UserObject;
import org.telegram.tgnet.TLRPC;
@ -180,7 +181,7 @@ public class PhotoAlbumPickerActivity extends BaseFragment implements Notificati
menuItem.setContentDescription(LocaleController.getString("AccDescrMoreOptions", R.string.AccDescrMoreOptions));
menuItem.addSubItem(1, R.drawable.msg_openin, LocaleController.getString("OpenInExternalApp", R.string.OpenInExternalApp));
sizeNotifierFrameLayout = new SizeNotifierFrameLayout(context) {
sizeNotifierFrameLayout = new SizeNotifierFrameLayout(context, SharedConfig.smoothKeyboard) {
private int lastNotifyWidth;
private boolean ignoreLayout;
@ -192,7 +193,7 @@ public class PhotoAlbumPickerActivity extends BaseFragment implements Notificati
setMeasuredDimension(widthSize, heightSize);
int keyboardSize = getKeyboardHeight();
int keyboardSize = SharedConfig.smoothKeyboard ? 0 : getKeyboardHeight();
if (keyboardSize <= AndroidUtilities.dp(20)) {
if (!AndroidUtilities.isInMultiwindow) {
heightSize -= commentTextView.getEmojiPadding();
@ -236,7 +237,8 @@ public class PhotoAlbumPickerActivity extends BaseFragment implements Notificati
}
final int count = getChildCount();
int paddingBottom = getKeyboardHeight() <= AndroidUtilities.dp(20) && !AndroidUtilities.isInMultiwindow && !AndroidUtilities.isTablet() ? commentTextView.getEmojiPadding() : 0;
int keyboardSize = SharedConfig.smoothKeyboard ? 0 : getKeyboardHeight();
int paddingBottom = keyboardSize <= AndroidUtilities.dp(20) && !AndroidUtilities.isInMultiwindow && !AndroidUtilities.isTablet() ? commentTextView.getEmojiPadding() : 0;
setBottomClip(paddingBottom);
for (int i = 0; i < count; i++) {
@ -290,7 +292,7 @@ public class PhotoAlbumPickerActivity extends BaseFragment implements Notificati
if (AndroidUtilities.isTablet()) {
childTop = getMeasuredHeight() - child.getMeasuredHeight();
} else {
childTop = getMeasuredHeight() + getKeyboardHeight() - child.getMeasuredHeight();
childTop = getMeasuredHeight() + keyboardSize - child.getMeasuredHeight();
}
}
child.layout(childLeft, childTop, childLeft + width, childTop + height);

View file

@ -372,7 +372,6 @@ public class PhotoCropActivity extends BaseFragment {
@Override
public boolean onFragmentCreate() {
swipeBackEnabled = false;
if (imageToCrop == null) {
String photoPath = getArguments().getString("photoPath");
Uri photoUri = getArguments().getParcelable("photoUri");
@ -454,6 +453,11 @@ public class PhotoCropActivity extends BaseFragment {
return fragmentView;
}
@Override
public boolean isSwipeBackEnabled(MotionEvent event) {
return false;
}
public void setDelegate(PhotoEditActivityDelegate delegate) {
this.delegate = delegate;
}

View file

@ -55,6 +55,7 @@ import org.telegram.messenger.MediaController;
import org.telegram.messenger.MessagesController;
import org.telegram.messenger.MessagesStorage;
import org.telegram.messenger.NotificationCenter;
import org.telegram.messenger.SharedConfig;
import org.telegram.messenger.UserConfig;
import org.telegram.messenger.UserObject;
import org.telegram.messenger.VideoEditedInfo;
@ -543,7 +544,7 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen
}
}
sizeNotifierFrameLayout = new SizeNotifierFrameLayout(context) {
sizeNotifierFrameLayout = new SizeNotifierFrameLayout(context, SharedConfig.smoothKeyboard) {
private int lastNotifyWidth;
private boolean ignoreLayout;
@ -585,18 +586,26 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen
setMeasuredDimension(widthSize, heightSize);
int keyboardSize = getKeyboardHeight();
int kbHeight = getKeyboardHeight();
int keyboardSize = SharedConfig.smoothKeyboard ? 0 : kbHeight;
if (keyboardSize <= AndroidUtilities.dp(20)) {
if (!AndroidUtilities.isInMultiwindow && commentTextView != null && frameLayout2.getParent() == this) {
heightSize -= commentTextView.getEmojiPadding();
heightMeasureSpec = MeasureSpec.makeMeasureSpec(heightSize, MeasureSpec.EXACTLY);
}
} else if (commentTextView != null) {
}
if (kbHeight > AndroidUtilities.dp(20) && commentTextView != null) {
ignoreLayout = true;
commentTextView.hideEmojiView();
ignoreLayout = false;
}
if (SharedConfig.smoothKeyboard && commentTextView != null && commentTextView.isPopupShowing()) {
fragmentView.setTranslationY(getCurrentPanTranslationY());
listView.setTranslationY(0);
emptyView.setTranslationY(0);
}
int childCount = getChildCount();
for (int i = 0; i < childCount; i++) {
View child = getChildAt(i);
@ -632,7 +641,8 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen
}
final int count = getChildCount();
int paddingBottom = commentTextView != null && frameLayout2.getParent() == this && getKeyboardHeight() <= AndroidUtilities.dp(20) && !AndroidUtilities.isInMultiwindow && !AndroidUtilities.isTablet() ? commentTextView.getEmojiPadding() : 0;
int keyboardSize = SharedConfig.smoothKeyboard ? 0 : getKeyboardHeight();
int paddingBottom = commentTextView != null && frameLayout2.getParent() == this && keyboardSize <= AndroidUtilities.dp(20) && !AndroidUtilities.isInMultiwindow && !AndroidUtilities.isTablet() ? commentTextView.getEmojiPadding() : 0;
setBottomClip(paddingBottom);
for (int i = 0; i < count; i++) {
@ -686,7 +696,7 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen
if (AndroidUtilities.isTablet()) {
childTop = getMeasuredHeight() - child.getMeasuredHeight();
} else {
childTop = getMeasuredHeight() + getKeyboardHeight() - child.getMeasuredHeight();
childTop = getMeasuredHeight() + keyboardSize - child.getMeasuredHeight();
}
}
child.layout(childLeft, childTop, childLeft + width, childTop + height);
@ -866,17 +876,17 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen
}
sizeNotifierFrameLayout.addView(emptyView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.LEFT | Gravity.TOP, 0, 0, 0, selectPhotoType != 0 ? 0 : 48));
if (selectedAlbum == null) {
listView.setOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
if (newState == RecyclerView.SCROLL_STATE_DRAGGING) {
AndroidUtilities.hideKeyboard(getParentActivity().getCurrentFocus());
}
listView.setOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
if (newState == RecyclerView.SCROLL_STATE_DRAGGING) {
AndroidUtilities.hideKeyboard(getParentActivity().getCurrentFocus());
}
}
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
if (selectedAlbum == null) {
int firstVisibleItem = layoutManager.findFirstVisibleItemPosition();
int visibleItemCount = firstVisibleItem == RecyclerView.NO_POSITION ? 0 : Math.abs(layoutManager.findLastVisibleItemPosition() - firstVisibleItem) + 1;
if (visibleItemCount > 0) {
@ -888,8 +898,10 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen
}
}
}
});
}
});
if (selectedAlbum == null) {
updateSearchInterface();
}
@ -1108,6 +1120,21 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen
return fragmentView;
}
@Override
protected void onPanTranslationUpdate(int y) {
if (listView == null) {
return;
}
if (commentTextView.isPopupShowing()) {
fragmentView.setTranslationY(y);
listView.setTranslationY(0);
emptyView.setTranslationY(0);
} else {
listView.setTranslationY(y);
emptyView.setTranslationY(y);
}
}
public void setLayoutViews(FrameLayout f2, FrameLayout button, View count, View s, EditTextEmoji emoji) {
frameLayout2 = f2;
writeButtonContainer = button;
@ -1173,7 +1200,7 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen
initialSearchString = null;
processSearch(searchItem.getSearchField());
}
getParentActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
getParentActivity().getWindow().setSoftInputMode(SharedConfig.smoothKeyboard ? WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN : WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
}
}

View file

@ -23,6 +23,7 @@ import android.widget.TextView;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.LocaleController;
import org.telegram.messenger.R;
import org.telegram.messenger.SharedConfig;
import org.telegram.ui.ActionBar.ActionBar;
import org.telegram.ui.ActionBar.ActionBarMenu;
import org.telegram.ui.ActionBar.ActionBarMenuItem;
@ -66,6 +67,8 @@ public class PhotoPickerSearchActivity extends BaseFragment {
private int selectPhotoType;
private ChatActivity chatActivity;
private boolean swipeBackEnabled = true;
private final static int search_button = 0;
private Paint backgroundPaint = new Paint();
@ -193,7 +196,7 @@ public class PhotoPickerSearchActivity extends BaseFragment {
maximumVelocity = configuration.getScaledMaximumFlingVelocity();
SizeNotifierFrameLayout sizeNotifierFrameLayout;
fragmentView = sizeNotifierFrameLayout = new SizeNotifierFrameLayout(context) {
fragmentView = sizeNotifierFrameLayout = new SizeNotifierFrameLayout(context, SharedConfig.smoothKeyboard) {
private int startedTrackingPointerId;
private boolean startedTracking;
@ -239,7 +242,7 @@ public class PhotoPickerSearchActivity extends BaseFragment {
setMeasuredDimension(widthSize, heightSize);
measureChildWithMargins(actionBar, widthMeasureSpec, 0, heightMeasureSpec, 0);
int keyboardSize = getKeyboardHeight();
int keyboardSize = SharedConfig.smoothKeyboard ? 0 : getKeyboardHeight();
if (keyboardSize <= AndroidUtilities.dp(20)) {
if (!AndroidUtilities.isInMultiwindow) {
heightSize -= commentTextView.getEmojiPadding();
@ -289,7 +292,8 @@ public class PhotoPickerSearchActivity extends BaseFragment {
protected void onLayout(boolean changed, int l, int t, int r, int b) {
final int count = getChildCount();
int paddingBottom = getKeyboardHeight() <= AndroidUtilities.dp(20) && !AndroidUtilities.isInMultiwindow && !AndroidUtilities.isTablet() ? commentTextView.getEmojiPadding() : 0;
int keyboardSize = SharedConfig.smoothKeyboard ? 0 : getKeyboardHeight();
int paddingBottom = keyboardSize <= AndroidUtilities.dp(20) && !AndroidUtilities.isInMultiwindow && !AndroidUtilities.isTablet() ? commentTextView.getEmojiPadding() : 0;
setBottomClip(paddingBottom);
for (int i = 0; i < count; i++) {
@ -343,7 +347,7 @@ public class PhotoPickerSearchActivity extends BaseFragment {
if (AndroidUtilities.isTablet()) {
childTop = getMeasuredHeight() - child.getMeasuredHeight();
} else {
childTop = getMeasuredHeight() + getKeyboardHeight() - child.getMeasuredHeight();
childTop = getMeasuredHeight() + keyboardSize - child.getMeasuredHeight();
}
}
child.layout(childLeft, childTop, childLeft + width, childTop + height);
@ -661,7 +665,7 @@ public class PhotoPickerSearchActivity extends BaseFragment {
super.onResume();
if (searchItem != null) {
searchItem.openSearch(true);
getParentActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
getParentActivity().getWindow().setSoftInputMode(SharedConfig.smoothKeyboard ? WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN : WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
}
if (imagesSearch != null) {
imagesSearch.onResume();
@ -688,6 +692,11 @@ public class PhotoPickerSearchActivity extends BaseFragment {
}
}
@Override
public boolean isSwipeBackEnabled(MotionEvent event) {
return swipeBackEnabled;
}
@Override
public void onFragmentDestroy() {
if (imagesSearch != null) {
@ -762,8 +771,8 @@ public class PhotoPickerSearchActivity extends BaseFragment {
if (scrollSlidingTextTabStrip == null) {
return;
}
scrollSlidingTextTabStrip.addTextTab(0, LocaleController.getString("ImagesTab", R.string.ImagesTab));
scrollSlidingTextTabStrip.addTextTab(1, LocaleController.getString("GifsTab", R.string.GifsTab));
scrollSlidingTextTabStrip.addTextTab(0, LocaleController.getString("ImagesTab2", R.string.ImagesTab2));
scrollSlidingTextTabStrip.addTextTab(1, LocaleController.getString("GifsTab2", R.string.GifsTab2));
scrollSlidingTextTabStrip.setVisibility(View.VISIBLE);
actionBar.setExtraHeight(AndroidUtilities.dp(44));
int id = scrollSlidingTextTabStrip.getCurrentTabId();

View file

@ -36,6 +36,7 @@ import android.graphics.SurfaceTexture;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.media.MediaCodecInfo;
import android.net.Uri;
import android.os.Build;
@ -64,7 +65,6 @@ import android.util.SparseArray;
import android.util.TypedValue;
import android.view.ActionMode;
import android.view.ContextThemeWrapper;
import android.view.GestureDetector;
import android.view.Gravity;
import android.view.HapticFeedbackConstants;
import android.view.KeyEvent;
@ -147,6 +147,7 @@ import org.telegram.ui.Components.ChatAttachAlert;
import org.telegram.ui.Components.CheckBox;
import org.telegram.ui.Components.ClippingImageView;
import org.telegram.messenger.ImageReceiver;
import org.telegram.ui.Components.GestureDetector2;
import org.telegram.ui.Components.GroupedPhotosListView;
import org.telegram.ui.Components.LayoutHelper;
import org.telegram.ui.Components.NumberPicker;
@ -179,7 +180,7 @@ import java.util.HashMap;
import java.util.Locale;
@SuppressWarnings("unchecked")
public class PhotoViewer implements NotificationCenter.NotificationCenterDelegate, GestureDetector.OnGestureListener, GestureDetector.OnDoubleTapListener {
public class PhotoViewer implements NotificationCenter.NotificationCenterDelegate, GestureDetector2.OnGestureListener, GestureDetector2.OnDoubleTapListener {
private int classGuid;
private PhotoViewerProvider placeProvider;
@ -249,6 +250,12 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
private ImageReceiver sideImage;
private boolean isCurrentVideo;
private GradientDrawable[] pressedDrawable = new GradientDrawable[2];
private boolean[] drawPressedDrawable = new boolean[2];
private float[] pressedDrawableAlpha = new float[2];
private boolean useSmoothKeyboard;
private VideoForwardDrawable videoForwardDrawable;
private AnimatorSet currentListViewAnimation;
@ -330,6 +337,8 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
private boolean firstAnimationDelay;
private long lastBufferedPositionCheck;
private View playButtonAccessibilityOverlay;
private int currentPanTranslationY;
public final static int SELECT_TYPE_AVATAR = 1;
public final static int SELECT_TYPE_WALLPAPER = 3;
@ -632,7 +641,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
private long animationStartTime;
private AnimatorSet imageMoveAnimation;
private AnimatorSet changeModeAnimation;
private GestureDetector gestureDetector;
private GestureDetector2 gestureDetector;
private boolean doubleTapEnabled;
private DecelerateInterpolator interpolator = new DecelerateInterpolator(1.5f);
private float pinchStartDistance;
@ -1034,6 +1043,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
public float scale = 1.0f;
public boolean isEvent;
public ClippingImageView animatingImageView;
public int animatingImageViewYOffset;
}
public static class EmptyPhotoViewerProvider implements PhotoViewerProvider {
@ -1193,7 +1203,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
private boolean ignoreLayout;
public FrameLayoutDrawer(Context context) {
super(context);
super(context, false);
setWillNotDraw(false);
paint.setColor(0x33000000);
}
@ -1243,7 +1253,8 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
@Override
protected void onLayout(boolean changed, int _l, int t, int _r, int _b) {
final int count = getChildCount();
int paddingBottom = getKeyboardHeight() <= AndroidUtilities.dp(20) && !AndroidUtilities.isInMultiwindow ? captionEditText.getEmojiPadding() : 0;
int keyboardSize = useSmoothKeyboard ? 0 : getKeyboardHeight();
int paddingBottom = keyboardSize <= AndroidUtilities.dp(20) && !AndroidUtilities.isInMultiwindow ? captionEditText.getEmojiPadding() : 0;
for (int i = 0; i < count; i++) {
final View child = getChildAt(i);
@ -1336,7 +1347,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
if (Build.VERSION.SDK_INT >= 21 && AndroidUtilities.statusBarHeight != 0 && actionBar != null) {
paint.setAlpha((int) (255 * actionBar.getAlpha() * 0.2f));
canvas.drawRect(0, 0, getMeasuredWidth(), AndroidUtilities.statusBarHeight, paint);
canvas.drawRect(0, currentPanTranslationY, getMeasuredWidth(), currentPanTranslationY + AndroidUtilities.statusBarHeight, paint);
paint.setAlpha((int) (255 * actionBar.getAlpha() * 0.498f));
if (getPaddingRight() > 0) {
canvas.drawRect(getMeasuredWidth() - getPaddingRight(), 0, getMeasuredWidth(), getMeasuredHeight(), paint);
@ -1388,6 +1399,43 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
}
super.requestLayout();
}
@Override
protected void onPanTranslationUpdate(int y) {
currentPanTranslationY = y;
actionBar.setTranslationY(y);
if (miniProgressView != null) {
miniProgressView.setTranslationY(y);
}
if (progressView != null) {
progressView.setTranslationY(y);
}
if (checkImageView != null) {
checkImageView.setTranslationY(y);
}
if (photosCounterView != null) {
photosCounterView.setTranslationY(y);
}
if (selectedPhotosListView != null) {
selectedPhotosListView.setTranslationY(y);
}
if (aspectRatioFrameLayout != null) {
aspectRatioFrameLayout.setTranslationY(y);
}
if (textureImageView != null) {
textureImageView.setTranslationY(y);
}
if (photoCropView != null) {
photoCropView.setTranslationY(y);
}
if (photoFilterView != null) {
photoFilterView.setTranslationY(y);
}
if (photoPaintView != null) {
photoPaintView.setTranslationY(y);
}
invalidate();
}
}
@SuppressLint("StaticFieldLeak")
@ -2410,6 +2458,11 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
bottomLayout.setBackgroundColor(0x7f000000);
containerView.addView(bottomLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, Gravity.BOTTOM | Gravity.LEFT));
pressedDrawable[0] = new GradientDrawable(GradientDrawable.Orientation.LEFT_RIGHT, new int[] {0x32000000, 0});
pressedDrawable[0].setShape(GradientDrawable.RECTANGLE);
pressedDrawable[1] = new GradientDrawable(GradientDrawable.Orientation.RIGHT_LEFT, new int[] {0x32000000, 0});
pressedDrawable[1].setShape(GradientDrawable.RECTANGLE);
groupedPhotosListView = new GroupedPhotosListView(actvityContext);
containerView.addView(groupedPhotosListView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 62, Gravity.BOTTOM | Gravity.LEFT, 0, 0, 0, 48));
groupedPhotosListView.setDelegate(new GroupedPhotosListView.GroupedPhotosListViewDelegate() {
@ -3108,7 +3161,8 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
editorDoneLayout.addView(resetButton, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.CENTER));
resetButton.setOnClickListener(v -> photoCropView.reset());
gestureDetector = new GestureDetector(containerView.getContext(), this);
gestureDetector = new GestureDetector2(containerView.getContext(), this);
gestureDetector.setIsLongpressEnabled(false);
setDoubleTapEnabled(true);
ImageReceiver.ImageReceiverDelegate imageReceiverDelegate = (imageReceiver, set, thumb) -> {
@ -3279,8 +3333,9 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
}
}
});
if (Build.VERSION.SDK_INT >= 19)
if (Build.VERSION.SDK_INT >= 19) {
captionEditText.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS);
}
containerView.addView(captionEditText, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.BOTTOM | Gravity.LEFT));
mentionListView = new RecyclerListView(actvityContext) {
@ -5040,7 +5095,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
}
});
changeModeAnimation.start();
} else if (mode == 3) { // painting/text/masks
} else if (mode == 3) {
if (photoPaintView == null) {
photoPaintView = new PhotoPaintView(parentActivity, centerImage.getBitmap(), centerImage.getOrientation());
containerView.addView(photoPaintView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
@ -7154,7 +7209,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
} else {
windowLayoutParams.flags &=~ WindowManager.LayoutParams.FLAG_SECURE;
}
windowLayoutParams.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE | WindowManager.LayoutParams.SOFT_INPUT_IS_FORWARD_NAVIGATION;
windowLayoutParams.softInputMode = (useSmoothKeyboard ? WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN : WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE) | WindowManager.LayoutParams.SOFT_INPUT_IS_FORWARD_NAVIGATION;
windowView.setFocusable(false);
containerView.setFocusable(false);
wm.addView(windowView, windowLayoutParams);
@ -7399,7 +7454,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
} else {
windowLayoutParams.flags = 0;
}
windowLayoutParams.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE | WindowManager.LayoutParams.SOFT_INPUT_IS_FORWARD_NAVIGATION;
windowLayoutParams.softInputMode = (useSmoothKeyboard ? WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN : WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE) | WindowManager.LayoutParams.SOFT_INPUT_IS_FORWARD_NAVIGATION;
WindowManager wm1 = (WindowManager) parentActivity.getSystemService(Context.WINDOW_SERVICE);
wm1.updateViewLayout(windowView, windowLayoutParams);
windowView.setFocusable(true);
@ -7474,7 +7529,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
} else {
windowLayoutParams.flags = 0;
}
windowLayoutParams.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE | WindowManager.LayoutParams.SOFT_INPUT_IS_FORWARD_NAVIGATION;
windowLayoutParams.softInputMode = (useSmoothKeyboard ? WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN : WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE) | WindowManager.LayoutParams.SOFT_INPUT_IS_FORWARD_NAVIGATION;
wm.updateViewLayout(windowView, windowLayoutParams);
windowView.setFocusable(true);
containerView.setFocusable(true);
@ -7806,6 +7861,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
animatingImageViews[0] = animatingImageView;
if (hasSecondAnimatingImageView) {
animatingImageViews[1] = object.animatingImageView;
object.animatingImageView.setAdditionalTranslationY(object.animatingImageViewYOffset);
}
return animatingImageViews;
}
@ -8069,6 +8125,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
pinchStartY = translationY;
zooming = true;
moving = false;
hidePressedDrawables();
if (velocityTracker != null) {
velocityTracker.clear();
}
@ -8098,12 +8155,14 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
float dy = Math.abs(ev.getY() - dragY);
if (dx > AndroidUtilities.dp(3) || dy > AndroidUtilities.dp(3)) {
discardTap = true;
hidePressedDrawables();
if (qualityChooseView != null && qualityChooseView.getVisibility() == View.VISIBLE) {
return true;
}
}
if (placeProvider.canScrollAway() && currentEditMode == 0 && sendPhotoType != SELECT_TYPE_AVATAR && canDragDown && !draggingDown && scale == 1 && dy >= AndroidUtilities.dp(30) && dy / 2 > dx) {
draggingDown = true;
hidePressedDrawables();
moving = false;
dragY = ev.getY();
if (isActionBarVisible && containerView.getTag() != null) {
@ -8126,6 +8185,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
moveDy = 0;
moving = true;
canDragDown = false;
hidePressedDrawables();
}
moveStartX = ev.getX();
@ -8311,6 +8371,18 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
return animationValue;
}
private void switchToNextIndex(int add, boolean init) {
if (currentMessageObject != null) {
releasePlayer(false);
FileLoader.getInstance(currentAccount).cancelLoadFile(currentMessageObject.getDocument());
}
setImageIndex(currentIndex + add, init);
if (currentMessageObject != null && currentMessageObject.isVideo() && (currentMessageObject.mediaExists || currentMessageObject.attachPathExists || currentMessageObject.canStreamVideo() && SharedConfig.streamMedia) && SharedConfig.autoplayVideo) {
onActionClick(true);
checkProgress(0, false, true);
}
}
@SuppressLint({"NewApi", "DrawAllocation"})
private void onDraw(Canvas canvas) {
if (animationInProgress == 1 || animationInProgress == 3 || !isVisible && animationInProgress != 2 && !pipAnimationInProgress) {
@ -8326,6 +8398,12 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
float currentTranslationX;
float currentScale;
float aty = -1;
long newUpdateTime = System.currentTimeMillis();
long dt = newUpdateTime - videoCrossfadeAlphaLastTime;
if (dt > 20) {
dt = 17;
}
videoCrossfadeAlphaLastTime = newUpdateTime;
if (imageMoveAnimation != null) {
if (!scroller.isFinished()) {
@ -8372,9 +8450,9 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
}
}
if (switchImageAfterAnimation == 1) {
AndroidUtilities.runOnUIThread(() -> setImageIndex(currentIndex + 1, false));
AndroidUtilities.runOnUIThread(() -> switchToNextIndex(1, false));
} else if (switchImageAfterAnimation == 2) {
AndroidUtilities.runOnUIThread(() -> setImageIndex(currentIndex - 1, false));
AndroidUtilities.runOnUIThread(() -> switchToNextIndex(-1, false));
}
switchImageAfterAnimation = 0;
}
@ -8462,7 +8540,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
if (centerImage.hasBitmapImage() || drawTextureView && textureUploaded) {
canvas.save();
canvas.translate(getContainerViewWidth() / 2 + getAdditionX(), getContainerViewHeight() / 2 + getAdditionY());
canvas.translate(translateX, currentTranslationY);
canvas.translate(translateX, currentTranslationY + currentPanTranslationY);
canvas.scale(currentScale - scaleDiff, currentScale - scaleDiff);
int bitmapWidth;
@ -8500,9 +8578,6 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
videoTextureView.setAlpha(alpha * videoCrossfadeAlpha);
aspectRatioFrameLayout.draw(canvas);
if (videoCrossfadeStarted && videoCrossfadeAlpha < 1.0f) {
long newUpdateTime = System.currentTimeMillis();
long dt = newUpdateTime - videoCrossfadeAlphaLastTime;
videoCrossfadeAlphaLastTime = newUpdateTime;
videoCrossfadeAlpha += dt / (playerInjected ? 100.0f : 200.0f);
containerView.invalidate();
if (videoCrossfadeAlpha > 1.0f) {
@ -8511,6 +8586,34 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
}
}
canvas.restore();
for (int a = 0; a < pressedDrawable.length; a++) {
if (drawPressedDrawable[a] || pressedDrawableAlpha[a] != 0) {
pressedDrawable[a].setAlpha((int) (pressedDrawableAlpha[a] * 255));
if (a == 0) {
pressedDrawable[a].setBounds(0, 0, containerView.getMeasuredWidth() / 5, containerView.getMeasuredHeight());
} else {
pressedDrawable[a].setBounds(containerView.getMeasuredWidth() - containerView.getMeasuredWidth() / 5, 0, containerView.getMeasuredWidth(), containerView.getMeasuredHeight());
}
pressedDrawable[a].draw(canvas);
}
if (drawPressedDrawable[a]) {
if (pressedDrawableAlpha[a] < 1.0f) {
pressedDrawableAlpha[a] += dt / 180.0f;
if (pressedDrawableAlpha[a] > 1.0f) {
pressedDrawableAlpha[a] = 1.0f;
}
containerView.invalidate();
}
} else {
if (pressedDrawableAlpha[a] > 0.0f) {
pressedDrawableAlpha[a] -= dt / 180.0f;
if (pressedDrawableAlpha[a] < 0.0f) {
pressedDrawableAlpha[a] = 0.0f;
}
containerView.invalidate();
}
}
}
}
boolean drawProgress;
if (isCurrentVideo) {
@ -8701,9 +8804,34 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
@Override
public boolean onDown(MotionEvent e) {
if (checkImageView.getVisibility() != View.VISIBLE && !drawPressedDrawable[0] && !drawPressedDrawable[1]) {
float x = e.getX();
int side = containerView.getMeasuredWidth() / 5;
if (x < side) {
if (leftImage.hasImageSet()) {
drawPressedDrawable[0] = true;
containerView.invalidate();
}
} else if (x > containerView.getMeasuredWidth() - side) {
if (rightImage.hasImageSet()) {
drawPressedDrawable[1] = true;
containerView.invalidate();
}
}
}
return false;
}
private void hidePressedDrawables() {
drawPressedDrawable[0] = drawPressedDrawable[1] = false;
containerView.invalidate();
}
@Override
public void onUp(MotionEvent e) {
hidePressedDrawables();
}
@Override
public void onShowPress(MotionEvent e) {
@ -8742,9 +8870,23 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
if (discardTap) {
return false;
}
float x = e.getX();
if (checkImageView.getVisibility() != View.VISIBLE) {
int side = containerView.getMeasuredWidth() / 5;
if (x < side) {
if (leftImage.hasImageSet()) {
switchToNextIndex(-1, true);
return true;
}
} else if (x > containerView.getMeasuredWidth() - side) {
if (rightImage.hasImageSet()) {
switchToNextIndex(1, true);
return true;
}
}
}
if (containerView.getTag() != null) {
boolean drawTextureView = aspectRatioFrameLayout != null && aspectRatioFrameLayout.getVisibility() == View.VISIBLE;
float x = e.getX();
float y = e.getY();
if (sharedMediaType == MediaDataController.MEDIA_FILE && currentMessageObject != null) {
if (!currentMessageObject.canPreviewDocument()) {
@ -8777,7 +8919,6 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
} else if (currentBotInlineResult != null && (currentBotInlineResult.type.equals("video") || MessageObject.isVideoDocument(currentBotInlineResult.document))) {
int state = photoProgressViews[0].backgroundState;
if (state > 0 && state <= 3) {
float x = e.getX();
float y = e.getY();
if (x >= (getContainerViewWidth() - AndroidUtilities.dp(100)) / 2.0f && x <= (getContainerViewWidth() + AndroidUtilities.dp(100)) / 2.0f &&
y >= (getContainerViewHeight() - AndroidUtilities.dp(100)) / 2.0f && y <= (getContainerViewHeight() + AndroidUtilities.dp(100)) / 2.0f) {
@ -8985,8 +9126,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
int x = cx - circleSize / 2 - gapSize - lineSize;
float startPadding = a == (selectedCompression + 1) ? AndroidUtilities.dpf2(2) : 0;
float endPadding = a == selectedCompression ? AndroidUtilities.dpf2(2) : 0;
canvas.drawRect(x + startPadding, cy - AndroidUtilities.dp(1),
x + lineSize - endPadding, cy + AndroidUtilities.dp(2), paint);
canvas.drawRect(x + startPadding, cy - AndroidUtilities.dp(1), x + lineSize - endPadding, cy + AndroidUtilities.dp(2), paint);
}
}

View file

@ -177,7 +177,7 @@ public class PopupNotificationActivity extends Activity implements NotificationC
statusDrawables[3] = new PlayingGameDrawable();
statusDrawables[4] = new RoundStatusDrawable();
SizeNotifierFrameLayout contentView = new SizeNotifierFrameLayout(this) {
SizeNotifierFrameLayout contentView = new SizeNotifierFrameLayout(this, false) {
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int widthMode = MeasureSpec.getMode(widthMeasureSpec);

View file

@ -1160,11 +1160,13 @@ public class PrivacyControlActivity extends BaseFragment implements Notification
new ThemeDescription(listView, 0, null, null, new Drawable[]{Theme.chat_msgInDrawable, Theme.chat_msgInMediaDrawable}, null, Theme.key_chat_inBubble),
new ThemeDescription(listView, 0, null, null, new Drawable[]{Theme.chat_msgInSelectedDrawable, Theme.chat_msgInMediaSelectedDrawable}, null, Theme.key_chat_inBubbleSelected),
new ThemeDescription(listView, 0, null, null, new Drawable[]{Theme.chat_msgInDrawable.getShadowDrawable(), Theme.chat_msgInMediaDrawable.getShadowDrawable()}, null, Theme.key_chat_inBubbleShadow),
new ThemeDescription(listView, 0, null, null, Theme.chat_msgInDrawable.getShadowDrawables(), null, Theme.key_chat_inBubbleShadow),
new ThemeDescription(listView, 0, null, null, Theme.chat_msgInMediaDrawable.getShadowDrawables(), null, Theme.key_chat_inBubbleShadow),
new ThemeDescription(listView, 0, null, null, new Drawable[]{Theme.chat_msgOutDrawable, Theme.chat_msgOutMediaDrawable}, null, Theme.key_chat_outBubble),
new ThemeDescription(listView, 0, null, null, new Drawable[]{Theme.chat_msgOutDrawable, Theme.chat_msgOutMediaDrawable}, null, Theme.key_chat_outBubbleGradient),
new ThemeDescription(listView, 0, null, null, new Drawable[]{Theme.chat_msgOutSelectedDrawable, Theme.chat_msgOutMediaSelectedDrawable}, null, Theme.key_chat_outBubbleSelected),
new ThemeDescription(listView, 0, null, null, new Drawable[]{Theme.chat_msgOutDrawable.getShadowDrawable(), Theme.chat_msgOutMediaDrawable.getShadowDrawable()}, null, Theme.key_chat_outBubbleShadow),
new ThemeDescription(listView, 0, null, null, Theme.chat_msgOutDrawable.getShadowDrawables(), null, Theme.key_chat_outBubbleShadow),
new ThemeDescription(listView, 0, null, null, Theme.chat_msgOutMediaDrawable.getShadowDrawables(), null, Theme.key_chat_outBubbleShadow),
new ThemeDescription(listView, 0, null, null, null, null, Theme.key_chat_messageTextIn),
new ThemeDescription(listView, 0, null, null, null, null, Theme.key_chat_messageTextOut),
new ThemeDescription(listView, 0, null, null, new Drawable[]{Theme.chat_msgOutCheckDrawable}, null, Theme.key_chat_outSentCheck),

View file

@ -493,7 +493,9 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
LocaleController.getString("DebugMenuCallSettings", R.string.DebugMenuCallSettings),
null,
BuildVars.DEBUG_PRIVATE_VERSION ? "Check for app updates" : null,
LocaleController.getString("DebugMenuReadAllDialogs", R.string.DebugMenuReadAllDialogs)
LocaleController.getString("DebugMenuReadAllDialogs", R.string.DebugMenuReadAllDialogs),
SharedConfig.pauseMusicOnRecord ? LocaleController.getString("DebugMenuDisablePauseMusic", R.string.DebugMenuDisablePauseMusic) : LocaleController.getString("DebugMenuEnablePauseMusic", R.string.DebugMenuEnablePauseMusic),
BuildVars.DEBUG_VERSION && !AndroidUtilities.isTablet() ? (SharedConfig.smoothKeyboard ? LocaleController.getString("DebugMenuDisableSmoothKeyboard", R.string.DebugMenuDisableSmoothKeyboard) : LocaleController.getString("DebugMenuEnableSmoothKeyboard", R.string.DebugMenuEnableSmoothKeyboard)) : null
};
builder.setItems(items, (dialog, which) -> {
if (which == 0) {
@ -526,6 +528,13 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
((LaunchActivity) getParentActivity()).checkAppUpdate(true);
} else if (which == 10) {
MessagesStorage.getInstance(currentAccount).readAllDialogs(-1);
} else if (which == 11) {
SharedConfig.togglePauseMusicOnRecord();
} else if (which == 12) {
SharedConfig.toggleSmoothKeyboard();
if (SharedConfig.smoothKeyboard && getParentActivity() != null) {
getParentActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
}
}
});
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);

View file

@ -2053,14 +2053,15 @@ public class ThemeActivity extends BaseFragment implements NotificationCenter.No
new ThemeDescription(listView, 0, new Class[]{NotificationsCheckCell.class}, new String[]{"valueTextView"}, null, null, null, Theme.key_windowBackgroundWhiteGrayText2),
new ThemeDescription(listView, 0, new Class[]{NotificationsCheckCell.class}, new String[]{"checkBox"}, null, null, null, Theme.key_switchTrack),
new ThemeDescription(listView, 0, new Class[]{NotificationsCheckCell.class}, new String[]{"checkBox"}, null, null, null, Theme.key_switchTrackChecked),
new ThemeDescription(listView, 0, null, null, new Drawable[]{Theme.chat_msgInDrawable, Theme.chat_msgInMediaDrawable}, null, Theme.key_chat_inBubble),
new ThemeDescription(listView, 0, null, null, new Drawable[]{Theme.chat_msgInSelectedDrawable, Theme.chat_msgInMediaSelectedDrawable}, null, Theme.key_chat_inBubbleSelected),
new ThemeDescription(listView, 0, null, null, new Drawable[]{Theme.chat_msgInDrawable.getShadowDrawable(), Theme.chat_msgInMediaDrawable.getShadowDrawable()}, null, Theme.key_chat_inBubbleShadow),
new ThemeDescription(listView, 0, null, null, Theme.chat_msgInDrawable.getShadowDrawables(), null, Theme.key_chat_inBubbleShadow),
new ThemeDescription(listView, 0, null, null, Theme.chat_msgInMediaDrawable.getShadowDrawables(), null, Theme.key_chat_inBubbleShadow),
new ThemeDescription(listView, 0, null, null, new Drawable[]{Theme.chat_msgOutDrawable, Theme.chat_msgOutMediaDrawable}, null, Theme.key_chat_outBubble),
new ThemeDescription(listView, 0, null, null, new Drawable[]{Theme.chat_msgOutDrawable, Theme.chat_msgOutMediaDrawable}, null, Theme.key_chat_outBubbleGradient),
new ThemeDescription(listView, 0, null, null, new Drawable[]{Theme.chat_msgOutSelectedDrawable, Theme.chat_msgOutMediaSelectedDrawable}, null, Theme.key_chat_outBubbleSelected),
new ThemeDescription(listView, 0, null, null, new Drawable[]{Theme.chat_msgOutDrawable.getShadowDrawable(), Theme.chat_msgOutMediaDrawable.getShadowDrawable()}, null, Theme.key_chat_outBubbleShadow),
new ThemeDescription(listView, 0, null, null, Theme.chat_msgOutDrawable.getShadowDrawables(), null, Theme.key_chat_outBubbleShadow),
new ThemeDescription(listView, 0, null, null, Theme.chat_msgOutMediaDrawable.getShadowDrawables(), null, Theme.key_chat_outBubbleShadow),
new ThemeDescription(listView, 0, null, null, null, null, Theme.key_chat_messageTextIn),
new ThemeDescription(listView, 0, null, null, null, null, Theme.key_chat_messageTextOut),
new ThemeDescription(listView, 0, null, null, new Drawable[]{Theme.chat_msgOutCheckDrawable}, null, Theme.key_chat_outSentCheck),

View file

@ -257,7 +257,6 @@ public class ThemePreviewActivity extends BaseFragment implements DownloadContro
public ThemePreviewActivity(Theme.ThemeInfo themeInfo, boolean deleteFile, int screenType, boolean edit, boolean night) {
super();
this.screenType = screenType;
swipeBackEnabled = false;
nightTheme = night;
applyingTheme = themeInfo;
deleteOnCancel = deleteFile;
@ -1962,6 +1961,11 @@ public class ThemePreviewActivity extends BaseFragment implements DownloadContro
}
}
@Override
public boolean isSwipeBackEnabled(MotionEvent event) {
return false;
}
@Override
public void onFailedDownload(String fileName, boolean canceled) {
updateButtonState( true, canceled);
@ -3475,11 +3479,13 @@ public class ThemePreviewActivity extends BaseFragment implements DownloadContro
items.add(new ThemeDescription(listView2, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{Theme.chat_msgInDrawable, Theme.chat_msgInMediaDrawable}, null, Theme.key_chat_inBubble));
items.add(new ThemeDescription(listView2, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{Theme.chat_msgInSelectedDrawable, Theme.chat_msgInMediaSelectedDrawable}, null, Theme.key_chat_inBubbleSelected));
items.add(new ThemeDescription(listView2, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{Theme.chat_msgInDrawable.getShadowDrawable(), Theme.chat_msgInMediaDrawable.getShadowDrawable()}, null, Theme.key_chat_inBubbleShadow));
items.add(new ThemeDescription(listView2, 0, new Class[]{ChatMessageCell.class}, null, Theme.chat_msgInDrawable.getShadowDrawables(), null, Theme.key_chat_inBubbleShadow));
items.add(new ThemeDescription(listView2, 0, new Class[]{ChatMessageCell.class}, null, Theme.chat_msgInMediaDrawable.getShadowDrawables(), null, Theme.key_chat_inBubbleShadow));
items.add(new ThemeDescription(listView2, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{Theme.chat_msgOutDrawable, Theme.chat_msgOutMediaDrawable}, null, Theme.key_chat_outBubble));
items.add(new ThemeDescription(listView2, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{Theme.chat_msgOutDrawable, Theme.chat_msgOutMediaDrawable}, null, Theme.key_chat_outBubbleGradient));
items.add(new ThemeDescription(listView2, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{Theme.chat_msgOutSelectedDrawable, Theme.chat_msgOutMediaSelectedDrawable}, null, Theme.key_chat_outBubbleSelected));
items.add(new ThemeDescription(listView2, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{Theme.chat_msgOutDrawable.getShadowDrawable(), Theme.chat_msgOutMediaDrawable.getShadowDrawable()}, null, Theme.key_chat_outBubbleShadow));
items.add(new ThemeDescription(listView2, 0, new Class[]{ChatMessageCell.class}, null, Theme.chat_msgOutDrawable.getShadowDrawables(), null, Theme.key_chat_outBubbleShadow));
items.add(new ThemeDescription(listView2, 0, new Class[]{ChatMessageCell.class}, null, Theme.chat_msgOutMediaDrawable.getShadowDrawables(), null, Theme.key_chat_outBubbleShadow));
items.add(new ThemeDescription(listView2, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_messageTextIn));
items.add(new ThemeDescription(listView2, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_messageTextOut));
items.add(new ThemeDescription(listView2, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{Theme.chat_msgOutCheckDrawable}, null, Theme.key_chat_outSentCheck));

View file

@ -683,11 +683,13 @@ public class ThemeSetUrlActivity extends BaseFragment implements NotificationCen
new ThemeDescription(messagesCell, 0, null, null, new Drawable[]{Theme.chat_msgInDrawable, Theme.chat_msgInMediaDrawable}, null, Theme.key_chat_inBubble),
new ThemeDescription(messagesCell, 0, null, null, new Drawable[]{Theme.chat_msgInSelectedDrawable, Theme.chat_msgInMediaSelectedDrawable}, null, Theme.key_chat_inBubbleSelected),
new ThemeDescription(messagesCell, 0, null, null, new Drawable[]{Theme.chat_msgInDrawable.getShadowDrawable(), Theme.chat_msgInMediaDrawable.getShadowDrawable()}, null, Theme.key_chat_inBubbleShadow),
new ThemeDescription(messagesCell, 0, null, null, Theme.chat_msgInDrawable.getShadowDrawables(), null, Theme.key_chat_inBubbleShadow),
new ThemeDescription(messagesCell, 0, null, null, Theme.chat_msgInMediaDrawable.getShadowDrawables(), null, Theme.key_chat_inBubbleShadow),
new ThemeDescription(messagesCell, 0, null, null, new Drawable[]{Theme.chat_msgOutDrawable, Theme.chat_msgOutMediaDrawable}, null, Theme.key_chat_outBubble),
new ThemeDescription(messagesCell, 0, null, null, new Drawable[]{Theme.chat_msgOutDrawable, Theme.chat_msgOutMediaDrawable}, null, Theme.key_chat_outBubbleGradient),
new ThemeDescription(messagesCell, 0, null, null, new Drawable[]{Theme.chat_msgOutSelectedDrawable, Theme.chat_msgOutMediaSelectedDrawable}, null, Theme.key_chat_outBubbleSelected),
new ThemeDescription(messagesCell, 0, null, null, new Drawable[]{Theme.chat_msgOutDrawable.getShadowDrawable(), Theme.chat_msgOutMediaDrawable.getShadowDrawable()}, null, Theme.key_chat_outBubbleShadow),
new ThemeDescription(messagesCell, 0, null, null, Theme.chat_msgOutDrawable.getShadowDrawables(), null, Theme.key_chat_outBubbleShadow),
new ThemeDescription(messagesCell, 0, null, null, Theme.chat_msgOutMediaDrawable.getShadowDrawables(), null, Theme.key_chat_outBubbleShadow),
new ThemeDescription(messagesCell, 0, null, null, null, null, Theme.key_chat_messageTextIn),
new ThemeDescription(messagesCell, 0, null, null, null, null, Theme.key_chat_messageTextOut),
new ThemeDescription(messagesCell, 0, null, null, new Drawable[]{Theme.chat_msgOutCheckDrawable}, null, Theme.key_chat_outSentCheck),

View file

@ -21,6 +21,7 @@ import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Build;
import android.text.TextUtils;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewParent;
import android.webkit.CookieManager;
@ -154,7 +155,6 @@ public class WebviewActivity extends BaseFragment {
@SuppressLint({"SetJavaScriptEnabled", "AddJavascriptInterface"})
@Override
public View createView(Context context) {
swipeBackEnabled = false;
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setAllowOverlayTitle(true);
@ -326,6 +326,11 @@ public class WebviewActivity extends BaseFragment {
}
}
@Override
public boolean isSwipeBackEnabled(MotionEvent event) {
return false;
}
public static boolean supportWebview() {
String manufacturer = Build.MANUFACTURER;
String model = Build.MODEL;

Binary file not shown.

After

Width:  |  Height:  |  Size: 1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 406 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 911 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Some files were not shown because too many files have changed in this diff Show more