mirror of
https://github.com/DrKLO/Telegram.git
synced 2024-12-22 14:35:03 +01:00
Added white color to color picker, decelerating scrolling in photo viewer
This commit is contained in:
parent
458517e4a4
commit
b85b6c1068
8 changed files with 74 additions and 12 deletions
|
@ -81,7 +81,7 @@ android {
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdkVersion 8
|
minSdkVersion 8
|
||||||
targetSdkVersion 19
|
targetSdkVersion 19
|
||||||
versionCode 264
|
versionCode 265
|
||||||
versionName "1.5.7"
|
versionName "1.5.7"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -527,12 +527,34 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||||
Utilities.stageQueue.postRunnable(new Runnable() {
|
Utilities.stageQueue.postRunnable(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
Datacenter datacenter = datacenterWithId(currentDatacenterId);
|
while (requestQueue.size() != 0) {
|
||||||
datacenter.recreateSessions();
|
RPCRequest request = requestQueue.get(0);
|
||||||
|
requestQueue.remove(0);
|
||||||
|
if (request.completionBlock != null) {
|
||||||
|
TLRPC.TL_error implicitError = new TLRPC.TL_error();
|
||||||
|
implicitError.code = -1000;
|
||||||
|
request.completionBlock.run(null, implicitError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (runningRequests.size() != 0) {
|
||||||
|
RPCRequest request = runningRequests.get(0);
|
||||||
|
runningRequests.remove(0);
|
||||||
|
if (request.completionBlock != null) {
|
||||||
|
TLRPC.TL_error implicitError = new TLRPC.TL_error();
|
||||||
|
implicitError.code = -1000;
|
||||||
|
request.completionBlock.run(null, implicitError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pingIdToDate.clear();
|
||||||
|
quickAckIdToRequestIds.clear();
|
||||||
|
|
||||||
clearRequestsForRequestClass(RPCRequest.RPCRequestClassGeneric, datacenter);
|
for (Datacenter datacenter : datacenters.values()) {
|
||||||
clearRequestsForRequestClass(RPCRequest.RPCRequestClassDownloadMedia, datacenter);
|
datacenter.recreateSessions();
|
||||||
clearRequestsForRequestClass(RPCRequest.RPCRequestClassUploadMedia, datacenter);
|
datacenter.authorized = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
sessionsToDestroy.clear();
|
||||||
|
saveSession();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -383,6 +383,11 @@ public class FileLoadOperation {
|
||||||
if (httpUrl != null) {
|
if (httpUrl != null) {
|
||||||
startDownloadHTTPRequest();
|
startDownloadHTTPRequest();
|
||||||
} else {
|
} else {
|
||||||
|
if (totalBytesCount >= 1024 * 1024) {
|
||||||
|
downloadChunkSize = 1024 * 256;
|
||||||
|
} else {
|
||||||
|
downloadChunkSize = 1024 * 32;
|
||||||
|
}
|
||||||
startDownloadRequest();
|
startDownloadRequest();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3068,7 +3068,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||||
ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
|
ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
|
||||||
@Override
|
@Override
|
||||||
public void run(TLObject response, TLRPC.TL_error error) {
|
public void run(TLObject response, TLRPC.TL_error error) {
|
||||||
|
ConnectionsManager.getInstance().cleanUp();
|
||||||
}
|
}
|
||||||
}, null, true, RPCRequest.RPCRequestClassGeneric);
|
}, null, true, RPCRequest.RPCRequestClassGeneric);
|
||||||
}
|
}
|
||||||
|
|
|
@ -152,7 +152,6 @@ public class LoginActivityRegisterView extends SlideView {
|
||||||
UserConfig.clearConfig();
|
UserConfig.clearConfig();
|
||||||
MessagesStorage.getInstance().cleanUp();
|
MessagesStorage.getInstance().cleanUp();
|
||||||
MessagesController.getInstance().cleanUp();
|
MessagesController.getInstance().cleanUp();
|
||||||
ConnectionsManager.getInstance().cleanUp();
|
|
||||||
UserConfig.setCurrentUser(user);
|
UserConfig.setCurrentUser(user);
|
||||||
UserConfig.saveConfig(true);
|
UserConfig.saveConfig(true);
|
||||||
ArrayList<TLRPC.User> users = new ArrayList<TLRPC.User>();
|
ArrayList<TLRPC.User> users = new ArrayList<TLRPC.User>();
|
||||||
|
|
|
@ -221,7 +221,6 @@ public class LoginActivitySmsView extends SlideView implements NotificationCente
|
||||||
UserConfig.clearConfig();
|
UserConfig.clearConfig();
|
||||||
MessagesStorage.getInstance().cleanUp();
|
MessagesStorage.getInstance().cleanUp();
|
||||||
MessagesController.getInstance().cleanUp();
|
MessagesController.getInstance().cleanUp();
|
||||||
ConnectionsManager.getInstance().cleanUp();
|
|
||||||
UserConfig.setCurrentUser(res.user);
|
UserConfig.setCurrentUser(res.user);
|
||||||
UserConfig.saveConfig(true);
|
UserConfig.saveConfig(true);
|
||||||
ArrayList<TLRPC.User> users = new ArrayList<TLRPC.User>();
|
ArrayList<TLRPC.User> users = new ArrayList<TLRPC.User>();
|
||||||
|
|
|
@ -42,6 +42,7 @@ import android.widget.Button;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
|
import android.widget.Scroller;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import org.telegram.messenger.ConnectionsManager;
|
import org.telegram.messenger.ConnectionsManager;
|
||||||
|
@ -160,6 +161,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||||
private boolean zoomAnimation = false;
|
private boolean zoomAnimation = false;
|
||||||
private int switchImageAfterAnimation = 0;
|
private int switchImageAfterAnimation = 0;
|
||||||
private VelocityTracker velocityTracker = null;
|
private VelocityTracker velocityTracker = null;
|
||||||
|
private Scroller scroller = null;
|
||||||
|
|
||||||
private ArrayList<MessageObject> imagesArrTemp = new ArrayList<MessageObject>();
|
private ArrayList<MessageObject> imagesArrTemp = new ArrayList<MessageObject>();
|
||||||
private HashMap<Integer, MessageObject> imagesByIdsTemp = new HashMap<Integer, MessageObject>();
|
private HashMap<Integer, MessageObject> imagesByIdsTemp = new HashMap<Integer, MessageObject>();
|
||||||
|
@ -432,6 +434,8 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||||
public void setParentActivity(Activity activity) {
|
public void setParentActivity(Activity activity) {
|
||||||
parentActivity = activity;
|
parentActivity = activity;
|
||||||
|
|
||||||
|
scroller = new Scroller(activity);
|
||||||
|
|
||||||
windowView = new FrameLayoutTouchListener(activity);
|
windowView = new FrameLayoutTouchListener(activity);
|
||||||
windowView.setBackgroundDrawable(backgroundDrawable);
|
windowView.setBackgroundDrawable(backgroundDrawable);
|
||||||
windowView.setFocusable(false);
|
windowView.setFocusable(false);
|
||||||
|
@ -1688,6 +1692,9 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ev.getActionMasked() == MotionEvent.ACTION_DOWN || ev.getActionMasked() == MotionEvent.ACTION_POINTER_DOWN) {
|
if (ev.getActionMasked() == MotionEvent.ACTION_DOWN || ev.getActionMasked() == MotionEvent.ACTION_POINTER_DOWN) {
|
||||||
|
if (!scroller.isFinished()) {
|
||||||
|
scroller.abortAnimation();
|
||||||
|
}
|
||||||
if (!draggingDown && !changingPage) {
|
if (!draggingDown && !changingPage) {
|
||||||
if (canZoom && ev.getPointerCount() == 2) {
|
if (canZoom && ev.getPointerCount() == 2) {
|
||||||
pinchStartDistance = (float) Math.hypot(ev.getX(1) - ev.getX(0), ev.getY(1) - ev.getY(0));
|
pinchStartDistance = (float) Math.hypot(ev.getX(1) - ev.getX(0), ev.getY(1) - ev.getY(0));
|
||||||
|
@ -1756,8 +1763,18 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||||
if (translationX < minX && !rightImage.hasImage() || translationX > maxX && !leftImage.hasImage()) {
|
if (translationX < minX && !rightImage.hasImage() || translationX > maxX && !leftImage.hasImage()) {
|
||||||
moveDx /= 3.0f;
|
moveDx /= 3.0f;
|
||||||
}
|
}
|
||||||
if (translationY < minY || translationY > maxY) {
|
if (maxY == 0 && minY == 0) {
|
||||||
moveDy /= 3.0f;
|
if (translationY - moveDy < minY) {
|
||||||
|
translationY = minY;
|
||||||
|
moveDy = 0;
|
||||||
|
} else if (translationY - moveDy > maxY) {
|
||||||
|
translationY = maxY;
|
||||||
|
moveDy = 0;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (translationY < minY || translationY > maxY) {
|
||||||
|
moveDy /= 3.0f;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
translationX -= moveDx;
|
translationX -= moveDx;
|
||||||
|
@ -1922,6 +1939,10 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ai != -1) {
|
if (ai != -1) {
|
||||||
|
if (!scroller.isFinished()) {
|
||||||
|
scroller.abortAnimation();
|
||||||
|
}
|
||||||
|
|
||||||
float ts = scale + (animateToScale - scale) * ai;
|
float ts = scale + (animateToScale - scale) * ai;
|
||||||
float tx = translationX + (animateToX - translationX) * ai;
|
float tx = translationX + (animateToX - translationX) * ai;
|
||||||
float ty = translationY + (animateToY - translationY) * ai;
|
float ty = translationY + (animateToY - translationY) * ai;
|
||||||
|
@ -1944,6 +1965,17 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||||
Utilities.unlockOrientation(parentActivity);
|
Utilities.unlockOrientation(parentActivity);
|
||||||
zoomAnimation = false;
|
zoomAnimation = false;
|
||||||
}
|
}
|
||||||
|
if (!scroller.isFinished()) {
|
||||||
|
if (scroller.computeScrollOffset()) {
|
||||||
|
if (scroller.getStartX() < maxX && scroller.getStartX() > minX) {
|
||||||
|
translationX = scroller.getCurrX();
|
||||||
|
}
|
||||||
|
if (scroller.getStartY() < maxY && scroller.getStartY() > minY) {
|
||||||
|
translationY = scroller.getCurrY();
|
||||||
|
}
|
||||||
|
containerView.invalidate();
|
||||||
|
}
|
||||||
|
}
|
||||||
if (switchImageAfterAnimation != 0) {
|
if (switchImageAfterAnimation != 0) {
|
||||||
if (switchImageAfterAnimation == 1) {
|
if (switchImageAfterAnimation == 1) {
|
||||||
setImageIndex(currentIndex + 1, false);
|
setImageIndex(currentIndex + 1, false);
|
||||||
|
@ -2119,6 +2151,11 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
|
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
|
||||||
|
if (scale != 1) {
|
||||||
|
scroller.abortAnimation();
|
||||||
|
scroller.fling(Math.round(translationX), Math.round(translationY), Math.round(velocityX), Math.round(velocityY), (int) minX, (int) maxX, (int) minY, (int) maxY);
|
||||||
|
containerView.postInvalidate();
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ public class ColorPickerView extends View {
|
||||||
private static final String STATE_OLD_COLOR = "color";
|
private static final String STATE_OLD_COLOR = "color";
|
||||||
private static final String STATE_SHOW_OLD_COLOR = "showColor";
|
private static final String STATE_SHOW_OLD_COLOR = "showColor";
|
||||||
|
|
||||||
private static final int[] COLORS = new int[] { 0xFFFF0000, 0xFFFF00FF, 0xFF0000FF, 0xFF00FFFF, 0xFF00FF00, 0xFFFFFF00, 0xFFFF0000 };
|
private static final int[] COLORS = new int[] { 0xFFFF0000, 0xFFFF00FF, 0xFF0000FF, 0xFF00FFFF, 0xFF00FF00, 0xFFFFFFFF, 0xFFFFFF00, 0xFFFF0000 };
|
||||||
|
|
||||||
private Paint mColorWheelPaint;
|
private Paint mColorWheelPaint;
|
||||||
private Paint mPointerHaloPaint;
|
private Paint mPointerHaloPaint;
|
||||||
|
|
Loading…
Reference in a new issue