mirror of
https://github.com/NekoX-Dev/NekoX.git
synced 2024-11-26 20:49:12 +01:00
Added white color to color picker, decelerating scrolling in photo viewer
This commit is contained in:
parent
458517e4a4
commit
b85b6c1068
@ -81,7 +81,7 @@ android {
|
||||
defaultConfig {
|
||||
minSdkVersion 8
|
||||
targetSdkVersion 19
|
||||
versionCode 264
|
||||
versionCode 265
|
||||
versionName "1.5.7"
|
||||
}
|
||||
}
|
||||
|
@ -527,12 +527,34 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
Utilities.stageQueue.postRunnable(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Datacenter datacenter = datacenterWithId(currentDatacenterId);
|
||||
datacenter.recreateSessions();
|
||||
while (requestQueue.size() != 0) {
|
||||
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);
|
||||
clearRequestsForRequestClass(RPCRequest.RPCRequestClassDownloadMedia, datacenter);
|
||||
clearRequestsForRequestClass(RPCRequest.RPCRequestClassUploadMedia, datacenter);
|
||||
for (Datacenter datacenter : datacenters.values()) {
|
||||
datacenter.recreateSessions();
|
||||
datacenter.authorized = false;
|
||||
}
|
||||
|
||||
sessionsToDestroy.clear();
|
||||
saveSession();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -383,6 +383,11 @@ public class FileLoadOperation {
|
||||
if (httpUrl != null) {
|
||||
startDownloadHTTPRequest();
|
||||
} else {
|
||||
if (totalBytesCount >= 1024 * 1024) {
|
||||
downloadChunkSize = 1024 * 256;
|
||||
} else {
|
||||
downloadChunkSize = 1024 * 32;
|
||||
}
|
||||
startDownloadRequest();
|
||||
}
|
||||
}
|
||||
|
@ -3068,7 +3068,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
|
||||
@Override
|
||||
public void run(TLObject response, TLRPC.TL_error error) {
|
||||
|
||||
ConnectionsManager.getInstance().cleanUp();
|
||||
}
|
||||
}, null, true, RPCRequest.RPCRequestClassGeneric);
|
||||
}
|
||||
|
@ -152,7 +152,6 @@ public class LoginActivityRegisterView extends SlideView {
|
||||
UserConfig.clearConfig();
|
||||
MessagesStorage.getInstance().cleanUp();
|
||||
MessagesController.getInstance().cleanUp();
|
||||
ConnectionsManager.getInstance().cleanUp();
|
||||
UserConfig.setCurrentUser(user);
|
||||
UserConfig.saveConfig(true);
|
||||
ArrayList<TLRPC.User> users = new ArrayList<TLRPC.User>();
|
||||
|
@ -221,7 +221,6 @@ public class LoginActivitySmsView extends SlideView implements NotificationCente
|
||||
UserConfig.clearConfig();
|
||||
MessagesStorage.getInstance().cleanUp();
|
||||
MessagesController.getInstance().cleanUp();
|
||||
ConnectionsManager.getInstance().cleanUp();
|
||||
UserConfig.setCurrentUser(res.user);
|
||||
UserConfig.saveConfig(true);
|
||||
ArrayList<TLRPC.User> users = new ArrayList<TLRPC.User>();
|
||||
|
@ -42,6 +42,7 @@ import android.widget.Button;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.Scroller;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.telegram.messenger.ConnectionsManager;
|
||||
@ -160,6 +161,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
private boolean zoomAnimation = false;
|
||||
private int switchImageAfterAnimation = 0;
|
||||
private VelocityTracker velocityTracker = null;
|
||||
private Scroller scroller = null;
|
||||
|
||||
private ArrayList<MessageObject> imagesArrTemp = new ArrayList<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) {
|
||||
parentActivity = activity;
|
||||
|
||||
scroller = new Scroller(activity);
|
||||
|
||||
windowView = new FrameLayoutTouchListener(activity);
|
||||
windowView.setBackgroundDrawable(backgroundDrawable);
|
||||
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 (!scroller.isFinished()) {
|
||||
scroller.abortAnimation();
|
||||
}
|
||||
if (!draggingDown && !changingPage) {
|
||||
if (canZoom && ev.getPointerCount() == 2) {
|
||||
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()) {
|
||||
moveDx /= 3.0f;
|
||||
}
|
||||
if (translationY < minY || translationY > maxY) {
|
||||
moveDy /= 3.0f;
|
||||
if (maxY == 0 && minY == 0) {
|
||||
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;
|
||||
@ -1922,6 +1939,10 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
}
|
||||
|
||||
if (ai != -1) {
|
||||
if (!scroller.isFinished()) {
|
||||
scroller.abortAnimation();
|
||||
}
|
||||
|
||||
float ts = scale + (animateToScale - scale) * ai;
|
||||
float tx = translationX + (animateToX - translationX) * ai;
|
||||
float ty = translationY + (animateToY - translationY) * ai;
|
||||
@ -1944,6 +1965,17 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
Utilities.unlockOrientation(parentActivity);
|
||||
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 == 1) {
|
||||
setImageIndex(currentIndex + 1, false);
|
||||
@ -2119,6 +2151,11 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
|
||||
@Override
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ public class ColorPickerView extends View {
|
||||
private static final String STATE_OLD_COLOR = "color";
|
||||
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 mPointerHaloPaint;
|
||||
|
Loading…
Reference in New Issue
Block a user