1
0
mirror of https://github.com/NekoX-Dev/NekoX.git synced 2024-11-26 16:59:21 +01:00

fix merge: v9.3.3

This commit is contained in:
James Clef 2023-01-21 15:05:51 +08:00 committed by luvletter2333
parent 69c6fce26b
commit 8f4e6d9428
No known key found for this signature in database
GPG Key ID: A26A8880836E1978
43 changed files with 856 additions and 819 deletions

View File

@ -35,8 +35,8 @@ import com.google.zxing.qrcode.encoder.ByteMatrix;
import com.google.zxing.qrcode.encoder.Encoder;
import com.google.zxing.qrcode.encoder.QRCode;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.R;
import org.telegram.messenger.SvgHelper;
import org.telegram.ui.Components.RLottieDrawable;
@ -52,26 +52,25 @@ import java.util.function.Function;
*/
public final class QRCodeWriter {
private static final int QUIET_ZONE_SIZE = 4;
private ByteMatrix input;
private float[] radii = new float[8];
private int imageBloks;
private int imageBlockX;
public boolean includeSideQuads = true;
private int sideQuadSize;
private static final int QUIET_ZONE_SIZE = 4;
private ByteMatrix input;
private float[] radii = new float[8];
private int imageBloks;
private int imageBlockX;
private int sideQuadSize;
private int imageSize;
private int imageSize;
public Bitmap encode(String contents, BarcodeFormat format, int width, int height, Map<EncodeHintType, ?> hints, Bitmap bitmap, Context context) throws WriterException {
return encode(contents, format, width, height, hints, bitmap, context, null);
}
public Bitmap encode(String contents, BarcodeFormat format, int width, int height, Map<EncodeHintType, ?> hints, Bitmap bitmap, Context context, Function<Integer, Bitmap> iconF) throws WriterException {
if (contents.isEmpty()) {
throw new IllegalArgumentException("Found empty contents");
public Bitmap encode(String contents, BarcodeFormat format, int width, int height, Map<EncodeHintType, ?> hints, Bitmap bitmap, Context context) throws WriterException {
return encode(contents, format, width, height, hints, bitmap, context, null);
}
public Bitmap encode(String contents, BarcodeFormat format, int width, int height, Map<EncodeHintType, ?> hints, Bitmap bitmap, Context context, Function<Integer, Bitmap> iconF) throws WriterException {
if (contents.isEmpty()) {
throw new IllegalArgumentException("Found empty contents");
}
if (width < 0 || height < 0) {
throw new IllegalArgumentException("Requested dimensions are too small: " + width + 'x' + height);
}
@ -130,8 +129,8 @@ public final class QRCodeWriter {
if (imageBloks % 2 != inputWidth % 2) {
imageBloks++;
}
imageBlockX = (inputWidth - imageBloks) / 2;
imageSize = imageBloks * multiple - 24;
imageBlockX = (inputWidth - imageBloks) / 2;
imageSize = imageBloks * multiple - 24;
int imageX = (size - imageSize) / 2;
for (int a = 0; a < 3; a++) {
@ -240,15 +239,15 @@ public final class QRCodeWriter {
private boolean has(int x, int y) {
if (x >= imageBlockX && x < imageBlockX + imageBloks && y >= imageBlockX && y < imageBlockX + imageBloks) {
return false;
return false;
}
if ((x < sideQuadSize || x >= input.getWidth() - sideQuadSize) && y < sideQuadSize) {
return false;
}
if (x < sideQuadSize && y >= input.getHeight() - sideQuadSize) {
return false;
}
return x >= 0 && y >= 0 && x < input.getWidth() && y < input.getHeight() && input.get(x, y) == 1;
if ((x < sideQuadSize || x >= input.getWidth() - sideQuadSize) && y < sideQuadSize) {
return false;
}
if (x < sideQuadSize && y >= input.getHeight() - sideQuadSize) {
return false;
}
return x >= 0 && y >= 0 && x < input.getWidth() && y < input.getHeight() && input.get(x, y) == 1;
}
public Bitmap encode(String contents, int width, int height, Map<EncodeHintType, ?> hints, Bitmap bitmap) throws WriterException {
@ -323,12 +322,56 @@ public final class QRCodeWriter {
imageSize = imageBloks * multiple - 24;
int imageX = (size - imageSize) / 2;
if (includeSideQuads) {
blackPaint.setColor(color);
drawSideQuadsGradient(canvas, blackPaint, rect, sideQuadSize, multiple, padding, size, radiusFactor, radii, backgroundColor,color);
boolean isTransparentBackground = Color.alpha(backgroundColor) == 0;
Path clipPath = new Path();
RectF rectF = new RectF();
for (int a = 0; a < 3; a++) {
int x, y;
if (a == 0) {
x = padding;
y = padding;
} else if (a == 1) {
x = size - sideQuadSize * multiple - padding;
y = padding;
} else {
x = padding;
y = size - sideQuadSize * multiple - padding;
}
boolean isTransparentBackground = Color.alpha(backgroundColor) == 0;
float r;
if (isTransparentBackground) {
rectF.set(x + multiple, y + multiple, x + (sideQuadSize - 1) * multiple, y + (sideQuadSize - 1) * multiple);
r = (sideQuadSize * multiple) / 4.0f * radiusFactor;
clipPath.reset();
clipPath.addRoundRect(rectF, r, r, Path.Direction.CW);
clipPath.close();
canvas.save();
canvas.clipPath(clipPath, Region.Op.DIFFERENCE);
}
r = (sideQuadSize * multiple) / 3.0f * radiusFactor;
Arrays.fill(radii, r);
rect.setColor(color);
rect.setBounds(x, y, x + sideQuadSize * multiple, y + sideQuadSize * multiple);
rect.draw(canvas);
canvas.drawRect(x + multiple, y + multiple, x + (sideQuadSize - 1) * multiple, y + (sideQuadSize - 1) * multiple, blackPaint);
if (isTransparentBackground) {
canvas.restore();
}
if (!isTransparentBackground) {
r = (sideQuadSize * multiple) / 4.0f * radiusFactor;
Arrays.fill(radii, r);
rect.setColor(backgroundColor);
rect.setBounds(x + multiple, y + multiple, x + (sideQuadSize - 1) * multiple, y + (sideQuadSize - 1) * multiple);
rect.draw(canvas);
}
r = ((sideQuadSize - 2) * multiple) / 4.0f * radiusFactor;
Arrays.fill(radii, r);
rect.setColor(color);
rect.setBounds(x + multiple * 2, y + multiple * 2, x + (sideQuadSize - 2) * multiple, y + (sideQuadSize - 2) * multiple);
rect.draw(canvas);
}
float r = multiple / 2.0f * radiusFactor;
for (int y = 0, outputY = padding; y < inputHeight; y++, outputY += multiple) {
@ -393,120 +436,49 @@ public final class QRCodeWriter {
return bitmap;
}
public static void drawSideQuadsGradient(Canvas canvas, Paint blackPaint, GradientDrawable rect, float sideQuadSize, float multiple, int padding, float size, float radiusFactor, float[] radii, int backgroundColor, int color) {
boolean isTransparentBackground = Color.alpha(backgroundColor) == 0;
rect.setShape(GradientDrawable.RECTANGLE);
rect.setCornerRadii(radii);
Path clipPath = new Path();
RectF rectF = new RectF();
for (int a = 0; a < 3; a++) {
float x, y;
if (a == 0) {
x = padding;
y = padding;
} else if (a == 1) {
x = size - sideQuadSize * multiple - padding;
y = padding;
} else {
x = padding;
y = size - sideQuadSize * multiple - padding;
}
public static void drawSideQuads(Canvas canvas, float xOffset, float yOffset, Paint blackPaint, float sideQuadSize, float multiple, int padding, float size, float radiusFactor, float[] radii, boolean isTransparentBackground) {
Path clipPath = new Path();
for (int a = 0; a < 3; a++) {
float x, y;
if (a == 0) {
x = padding;
y = padding;
} else if (a == 1) {
x = size - sideQuadSize * multiple - padding;
y = padding;
} else {
x = padding;
y = size - sideQuadSize * multiple - padding;
}
float r;
if (isTransparentBackground) {
rectF.set(x + multiple, y + multiple, x + (sideQuadSize - 1) * multiple, y + (sideQuadSize - 1) * multiple);
r = (sideQuadSize * multiple) / 4.0f * radiusFactor;
clipPath.reset();
clipPath.addRoundRect(rectF, r, r, Path.Direction.CW);
clipPath.close();
canvas.save();
canvas.clipPath(clipPath, Region.Op.DIFFERENCE);
}
r = (sideQuadSize * multiple) / 3.0f * radiusFactor;
Arrays.fill(radii, r);
rect.setColor(color);
rect.setBounds((int) x, (int) y, (int) (x + sideQuadSize * multiple), (int) (y + sideQuadSize * multiple));
rect.draw(canvas);
canvas.drawRect(x + multiple, y + multiple, x + (sideQuadSize - 1) * multiple, y + (sideQuadSize - 1) * multiple, blackPaint);
if (isTransparentBackground) {
canvas.restore();
}
x += xOffset;
y += yOffset;
if (!isTransparentBackground) {
r = (sideQuadSize * multiple) / 4.0f * radiusFactor;
Arrays.fill(radii, r);
rect.setColor(backgroundColor);
rect.setBounds((int) (x + multiple), (int) (y + multiple), (int) (x + (sideQuadSize - 1) * multiple), (int) (y + (sideQuadSize - 1) * multiple));
rect.draw(canvas);
}
float r;
if (isTransparentBackground) {
AndroidUtilities.rectTmp.set(x + multiple, y + multiple, x + (sideQuadSize - 1) * multiple, y + (sideQuadSize - 1) * multiple);
r = (sideQuadSize * multiple) / 4.0f * radiusFactor;
clipPath.reset();
clipPath.addRoundRect(AndroidUtilities.rectTmp, r, r, Path.Direction.CW);
clipPath.close();
canvas.save();
canvas.clipPath(clipPath, Region.Op.DIFFERENCE);
}
r = (sideQuadSize * multiple) / 3.0f * radiusFactor;
AndroidUtilities.rectTmp.set(x, y, x + sideQuadSize * multiple, y + sideQuadSize * multiple);
canvas.drawRoundRect(AndroidUtilities.rectTmp, r, r, blackPaint);
if (isTransparentBackground) {
canvas.restore();
}
r = ((sideQuadSize - 2) * multiple) / 4.0f * radiusFactor;
Arrays.fill(radii, r);
rect.setColor(color);
rect.setBounds((int) (x + multiple * 2), (int) (y + multiple * 2), (int) (x + (sideQuadSize - 2) * multiple), (int) (y + (sideQuadSize - 2) * multiple));
rect.draw(canvas);
r = ((sideQuadSize - 2) * multiple) / 4.0f * radiusFactor;
AndroidUtilities.rectTmp.set(x + multiple * 2, y + multiple * 2, x + (sideQuadSize - 2) * multiple, y + (sideQuadSize - 2) * multiple);
canvas.drawRoundRect(AndroidUtilities.rectTmp, r, r, blackPaint);
}
}
}
public static void drawSideQuads(Canvas canvas, float xOffset, float yOffset, Paint blackPaint, float sideQuadSize, float multiple, int padding, float size, float radiusFactor, float[] radii, boolean isTransparentBackground) {
Path clipPath = new Path();
for (int a = 0; a < 3; a++) {
float x, y;
if (a == 0) {
x = padding;
y = padding;
} else if (a == 1) {
x = size - sideQuadSize * multiple - padding;
y = padding;
} else {
x = padding;
y = size - sideQuadSize * multiple - padding;
}
x += xOffset;
y += yOffset;
float r;
if (isTransparentBackground) {
AndroidUtilities.rectTmp.set(x + multiple, y + multiple, x + (sideQuadSize - 1) * multiple, y + (sideQuadSize - 1) * multiple);
r = (sideQuadSize * multiple) / 4.0f * radiusFactor;
clipPath.reset();
clipPath.addRoundRect(AndroidUtilities.rectTmp, r, r, Path.Direction.CW);
clipPath.close();
canvas.save();
canvas.clipPath(clipPath, Region.Op.DIFFERENCE);
}
r = (sideQuadSize * multiple) / 3.0f * radiusFactor;
AndroidUtilities.rectTmp.set(x, y, x + sideQuadSize * multiple, y + sideQuadSize * multiple);
canvas.drawRoundRect(AndroidUtilities.rectTmp, r, r, blackPaint);
if (isTransparentBackground) {
canvas.restore();
}
r = ((sideQuadSize - 2) * multiple) / 4.0f * radiusFactor;
AndroidUtilities.rectTmp.set(x + multiple * 2, y + multiple * 2, x + (sideQuadSize - 2) * multiple, y + (sideQuadSize - 2) * multiple);
canvas.drawRoundRect(AndroidUtilities.rectTmp, r, r, blackPaint);
}
}
private boolean has(int x, int y) {
if (x >= imageBlockX && x < imageBlockX + imageBloks && y >= imageBlockX && y < imageBlockX + imageBloks) {
return false;
}
if ((x < sideQuadSize || x >= input.getWidth() - sideQuadSize) && y < sideQuadSize) {
return false;
}
if (x < sideQuadSize && y >= input.getHeight() - sideQuadSize) {
return false;
}
return x >= 0 && y >= 0 && x < input.getWidth() && y < input.getHeight() && input.get(x, y) == 1;
}
public int getImageSize() {
return imageSize;
}
public int getSideSize() {
return sideQuadSize;
}
return imageSize;
}
}

View File

@ -3824,7 +3824,17 @@ public class AndroidUtilities {
SharedConfig.setCurrentProxy(SharedConfig.addProxy(info));
NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.proxySettingsChanged);
if (activity instanceof LaunchActivity) {
INavigationLayout layout = ((LaunchActivity) activity).getActionBarLayout();
BaseFragment fragment = layout.getLastFragment();
if (fragment instanceof ChatActivity) {
((ChatActivity) fragment).getUndoView().showWithAction(0, UndoView.ACTION_PROXY_ADDED, null);
} else {
NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.showBulletin, Bulletin.TYPE_SUCCESS, LocaleController.getString(R.string.ProxyAddedSuccess));
}
} else {
NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.showBulletin, Bulletin.TYPE_SUCCESS, LocaleController.getString(R.string.ProxyAddedSuccess));
}
dismissRunnable.run();
});
@ -4919,6 +4929,9 @@ public class AndroidUtilities {
}
public static boolean shouldShowUrlInAlert(String url) {
if (NekoConfig.skipOpenLinkConfirm.Bool()) {
return false;
}
try {
Uri uri = Uri.parse(url);
url = uri.getHost();

View File

@ -374,8 +374,7 @@ public class Emoji {
this.end = end;
this.code = code;
}
public int start;
public int start;
public int end;
public CharSequence code;
}
@ -544,8 +543,8 @@ public class Emoji {
}
public static CharSequence replaceEmoji(CharSequence cs, Paint.FontMetricsInt fontMetrics, boolean createNew, int[] emojiOnly, int alignment) {
if (cs == null || cs.length() == 0) {
return Spannable.Factory.getInstance().newSpannable(cs.toString());
if (NekoConfig.useSystemEmoji.Bool() || cs == null || cs.length() == 0) {
return cs;
}
Spannable s;
if (!createNew && cs instanceof Spannable) {

View File

@ -210,7 +210,7 @@ public class FileLoadOperation {
}
private void updateParams() {
if (MessagesController.getInstance(currentAccount).getfileExperimentalParams && !forceSmallChunk || NekoConfig.enhancedFileLoader.Bool()) {
if ((MessagesController.getInstance(currentAccount).getfileExperimentalParams || NekoConfig.enhancedFileLoader.Bool() && !forceSmallChunk)) {
downloadChunkSizeBig = 1024 * 512;
maxDownloadRequests = 8;
maxDownloadRequestsBig = 8;

View File

@ -28,6 +28,8 @@ import java.util.concurrent.CountDownLatch;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.function.Function;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class FileLoader extends BaseController {

View File

@ -2439,7 +2439,7 @@ public class LocaleController {
req.lang_pack = "";
return ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> {
if (response != null) {
saveRemoteLocaleStrings(localeInfo, (TLRPC.TL_langPackDifference) response, currentAccount, onDone);
AndroidUtilities.runOnUIThread(() -> saveRemoteLocaleStrings(localeInfo, (TLRPC.TL_langPackDifference) response, currentAccount, onDone));
}
}, ConnectionsManager.RequestFlagWithoutLogin);
}
@ -2448,7 +2448,7 @@ public class LocaleController {
req.lang_code = localeInfo.getBaseLangCode();
return ConnectionsManager.getInstance(currentAccount).sendRequest(req, (TLObject response, TLRPC.TL_error error) -> {
if (response != null) {
saveRemoteLocaleStrings(localeInfo, (TLRPC.TL_langPackDifference) response, currentAccount, onDone);
AndroidUtilities.runOnUIThread(() -> saveRemoteLocaleStrings(localeInfo, (TLRPC.TL_langPackDifference) response, currentAccount, onDone));
}
}, ConnectionsManager.RequestFlagWithoutLogin);
}
@ -2461,7 +2461,7 @@ public class LocaleController {
req.lang_pack = "";
return ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> {
if (response != null) {
saveRemoteLocaleStrings(localeInfo, (TLRPC.TL_langPackDifference) response, currentAccount, onDone);
AndroidUtilities.runOnUIThread(() -> saveRemoteLocaleStrings(localeInfo, (TLRPC.TL_langPackDifference) response, currentAccount, onDone));
}
}, ConnectionsManager.RequestFlagWithoutLogin);
} else {
@ -2470,7 +2470,7 @@ public class LocaleController {
req.lang_code = localeInfo.getLangCode();
return ConnectionsManager.getInstance(currentAccount).sendRequest(req, (TLObject response, TLRPC.TL_error error) -> {
if (response != null) {
saveRemoteLocaleStrings(localeInfo, (TLRPC.TL_langPackDifference) response, currentAccount, onDone);
AndroidUtilities.runOnUIThread(() -> saveRemoteLocaleStrings(localeInfo, (TLRPC.TL_langPackDifference) response, currentAccount, onDone));
}
}, ConnectionsManager.RequestFlagWithoutLogin);
}

View File

@ -3796,6 +3796,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
private final int notificationId;
public MediaLoader(Context context, AccountInstance accountInstance, ArrayList<MessageObject> messages, MessagesStorage.IntCallback onFinish) {
notificationId = SaveToDownloadReceiver.createNotificationId();
currentAccount = accountInstance;
messageObjects = messages;
onFinishRunnable = onFinish;
@ -3808,7 +3809,6 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
progressDialog.setCanceledOnTouchOutside(false);
progressDialog.setCancelable(true);
progressDialog.setOnCancelListener(d -> cancelled = true);
notificationId = SaveToDownloadReceiver.createNotificationId();
}
public void start(Context context) {

View File

@ -1242,7 +1242,7 @@ public class MessagesController extends BaseController implements NotificationCe
telegramAntispamUserId = mainPreferences.getLong("telegramAntispamUserId", -1);
telegramAntispamGroupSizeMin = mainPreferences.getInt("telegramAntispamGroupSizeMin", 100);
hiddenMembersGroupSizeMin = mainPreferences.getInt("hiddenMembersGroupSizeMin", 100);
// BuildVars.GOOGLE_AUTH_CLIENT_ID = mainPreferences.getString("googleAuthClientId", BuildVars.GOOGLE_AUTH_CLIENT_ID);
// BuildVars.GOOGLE_AUTH_CLIENT_ID = mainPreferences.getString("googleAuthClientId", BuildVars.GOOGLE_AUTH_CLIENT_ID);
Set<String> currencySet = mainPreferences.getStringSet("directPaymentsCurrency", null);
if (currencySet != null) {
@ -10465,10 +10465,6 @@ public class MessagesController extends BaseController implements NotificationCe
if (type == ChatObject.CHAT_TYPE_CHAT && !forImport) {
TLRPC.TL_messages_createChat req = new TLRPC.TL_messages_createChat();
req.title = title;
if (ttlPeriod > 0) {
req.ttl_period = ttlPeriod;
req.flags |= 1;
}
TLObject nekoxBot = null;
if (selectedContacts.isEmpty()) {
String username = "NekoXBot";
@ -10484,7 +10480,7 @@ public class MessagesController extends BaseController implements NotificationCe
putUsers(res.users, false);
putChats(res.chats, false);
getMessagesStorage().putUsersAndChats(res.users, res.chats, false, true);
createChat(title, selectedContacts, about, type, forImport, location, locationAddress, fragment);
createChat(title, selectedContacts, about, type, forImport, location, locationAddress, 0, fragment);
} else {
AndroidUtilities.runOnUIThread(() -> {
AlertsCreator.processError(currentAccount, error, fragment, req);

View File

@ -93,6 +93,7 @@ public class MessagesStorage extends BaseController {
private static SparseArray<MessagesStorage> Instance = new SparseArray();
private static final Object lockObject = new Object();
private final static int LAST_DB_VERSION = 111;
private boolean databaseMigrationInProgress;
public boolean showClearDatabaseAlert;

View File

@ -68,7 +68,7 @@ public class SecretChatHelper extends BaseController {
}
}
public static final int CURRENT_SECRET_CHAT_LAYER = 151;
public static int CURRENT_SECRET_CHAT_LAYER = 151;
private ArrayList<Integer> sendingNotifyLayer = new ArrayList<>();
private SparseArray<ArrayList<TL_decryptedMessageHolder>> secretHolesQueue = new SparseArray<>();

View File

@ -47,6 +47,8 @@ import java.io.RandomAccessFile;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.util.Arrays;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.io.UnsupportedEncodingException;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@ -290,60 +292,72 @@ public class SharedConfig {
}
}
public String getLink() {
StringBuilder url = new StringBuilder(!TextUtils.isEmpty(secret) ? "https://t.me/proxy?" : "https://t.me/socks?");
try {
url.append("server=").append(URLEncoder.encode(address, "UTF-8")).append("&").append("port=").append(port);
if (!TextUtils.isEmpty(username)) {
url.append("&user=").append(URLEncoder.encode(username, "UTF-8"));
}
if (!TextUtils.isEmpty(password)) {
url.append("&pass=").append(URLEncoder.encode(password, "UTF-8"));
}
if (!TextUtils.isEmpty(secret)) {
url.append("&secret=").append(URLEncoder.encode(secret, "UTF-8"));
}
} catch (UnsupportedEncodingException ignored) {}
return url.toString();
}
public String getAddress() {
return address + ":" + port;
}
public String getType() {
if (!StrUtil.isBlank(secret)) {
return "MTProto";
} else {
return "Socks5";
}
}
public String getTitle() {
StringBuilder builder = new StringBuilder();
builder.append("[ ");
if (subId != 0L) {
try {
builder.append(SubManager.getSubList().find(ObjectFilters.eq("id", subId)).firstOrDefault().displayName());
} catch (Exception e) {
builder.append("Unknown");
}
} else {
builder.append(getType());
}
builder.append(" ] ");
if (StrUtil.isBlank(getRemarks())) {
builder.append(getAddress());
} else {
builder.append(getRemarks());
}
return builder.toString();
}
private String remarks;
public String getRemarks() {
return remarks;
}
public void setRemarks(String remarks) {
@ -354,38 +368,59 @@ public class SharedConfig {
}
public String toUrl() {
HttpUrl.Builder builder = HttpUrl.parse(StrUtil.isBlank(secret) ?
"https://t.me/socks" : "https://t.me/proxy").newBuilder()
.addQueryParameter("server", address)
.addQueryParameter("port", port + "");
if (!StrUtil.isBlank(secret)) {
builder.addQueryParameter("secret", secret);
} else {
builder.addQueryParameter("user", username)
.addQueryParameter("pass", password);
}
if (!StrUtil.isBlank(remarks)) {
builder.fragment(Utils.INSTANCE.urlEncode(remarks));
}
return builder.toString();
}
public static ProxyInfo fromUrl(String url) {
Uri lnk = Uri.parse(url);
if (lnk == null) throw new IllegalArgumentException(url);
ProxyInfo info = new ProxyInfo(lnk.getQueryParameter("server"),
Utilities.parseInt(lnk.getQueryParameter("port")),
lnk.getQueryParameter("user"),
lnk.getQueryParameter("pass"),
lnk.getQueryParameter("secret"));
if (StrUtil.isNotBlank(lnk.getFragment())) {
info.setRemarks(lnk.getFragment());
}
return info;
}
public JSONObject toJsonInternal() throws JSONException {
JSONObject obj = new JSONObject();
if (!StrUtil.isBlank(remarks)) {
obj.put("remarks", remarks);
}
@ -410,12 +445,17 @@ public class SharedConfig {
}
return obj;
}
public static ProxyInfo fromJson(JSONObject obj) {
ProxyInfo info;
switch (obj.optString("type", "null")) {
case "socks5": {
info = new ProxyInfo();
info.group = obj.optInt("group", 0);
@ -423,55 +463,84 @@ public class SharedConfig {
info.port = obj.optInt("port", 443);
info.username = obj.optString("username", "");
info.password = obj.optString("password", "");
info.remarks = obj.optString("remarks");
if (StrUtil.isBlank(info.remarks)) info.remarks = null;
info.group = obj.optInt("group", 0);
break;
}
case "mtproto": {
info = new ProxyInfo();
info.address = obj.optString("address", "");
info.port = obj.optInt("port", 443);
info.secret = obj.optString("secret", "");
info.remarks = obj.optString("remarks");
if (StrUtil.isBlank(info.remarks)) info.remarks = null;
info.group = obj.optInt("group", 0);
break;
}
case "vmess": {
info = new VmessProxy(obj.optString("link"));
break;
}
case "shadowsocks": {
info = new ShadowsocksProxy(obj.optString("link"));
break;
}
case "shadowsocksr": {
info = new ShadowsocksRProxy(obj.optString("link"));
break;
}
case "ws": {
info = new WsProxy(obj.optString("link"));
break;
}
default: {
throw new IllegalStateException("invalid proxy type " + obj.optString("type", "null"));
}
}
return info;
}
@Override
public int hashCode() {
return (address + port + username + password + secret).hashCode();
}
@Override
@ -480,7 +549,7 @@ public class SharedConfig {
}
}
public abstract static class ExternalSocks5Proxy extends SharedConfig.ProxyInfo {
public abstract static class ExternalSocks5Proxy extends ProxyInfo {
public ExternalSocks5Proxy() {

View File

@ -1899,4 +1899,11 @@ public class ActionBar extends FrameLayout {
backButtonImageView.setUnread(count);
}
}
public void setDrawBackButton(boolean b) {
this.drawBackButton = b;
if (backButtonImageView != null) {
backButtonImageView.invalidate();
}
}
}

View File

@ -278,7 +278,7 @@ public class AlertDialog extends Dialog implements Drawable.Callback, Notificati
shadowDrawable = context.getResources().getDrawable(R.drawable.popup_fixed_alert3).mutate();
backgroundColor = getThemedColor(Theme.key_dialogBackground);
blurOpacity = progressStyle == ALERT_TYPE_SPINNER ? 0.55f : (AndroidUtilities.computePerceivedBrightness(backgroundColor) < 0.721f ? 0.80f : 0.92f);
shadowDrawable.setColorFilter(new PorterDuffColorFilter(backgroundColor, PorterDuff.Mode.SRC_IN));
shadowDrawable.setColorFilter(new PorterDuffColorFilter(backgroundColor, PorterDuff.Mode.MULTIPLY));
shadowDrawable.getPadding(backgroundPaddings);
}

View File

@ -14,6 +14,8 @@ import android.animation.ValueAnimator;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.DialogInterface;
import android.content.pm.PackageManager;
import android.graphics.Canvas;
import android.graphics.Paint;
@ -35,6 +37,14 @@ import android.text.style.RelativeSizeSpan;
import android.util.LongSparseArray;
import android.util.SparseArray;
import android.util.TypedValue;
import android.text.SpannableString;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.TextUtils;
import android.text.style.RelativeSizeSpan;
import android.util.LongSparseArray;
import android.util.SparseArray;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View;
@ -45,6 +55,12 @@ import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.core.widget.NestedScrollView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.core.graphics.ColorUtils;
import androidx.recyclerview.widget.DefaultItemAnimator;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.core.graphics.ColorUtils;
@ -66,6 +82,12 @@ import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.DialogObject;
import org.telegram.messenger.FileLoader;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.BotWebViewVibrationEffect;
import org.telegram.messenger.CacheByChatsController;
import org.telegram.messenger.Emoji;
import org.telegram.messenger.FileLoader;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.FilePathDatabase;
import org.telegram.messenger.FilePathDatabase;
import org.telegram.messenger.ImageLoader;
import org.telegram.messenger.LocaleController;
@ -103,6 +125,12 @@ import org.telegram.ui.Components.AnimatedFloat;
import org.telegram.ui.Components.BackupImageView;
import org.telegram.ui.Components.CacheChart;
import org.telegram.ui.Components.CheckBox2;
import org.telegram.ui.Components.AlertsCreator;
import org.telegram.ui.Components.AnimatedFloat;
import org.telegram.ui.Components.AnimatedTextView;
import org.telegram.ui.Components.BackupImageView;
import org.telegram.ui.Components.CacheChart;
import org.telegram.ui.Components.CheckBox2;
import org.telegram.ui.Components.CubicBezierInterpolator;
import org.telegram.ui.Components.FlickerLoadingView;
import org.telegram.ui.Components.HideViewAfterAnimation;
@ -165,18 +193,6 @@ public class CacheControlActivity extends BaseFragment implements NotificationCe
private LinearLayoutManager layoutManager;
AlertDialog progressDialog;
private int databaseRow;
private int databaseInfoRow;
private int keepMediaHeaderRow;
private int keepMediaInfoRow;
private int cacheInfoRow;
private int deviseStorageHeaderRow;
private int storageUsageRow;
private int keepMediaChooserRow;
private int rowCount;
private int resetDataRow;
private boolean[] selected = new boolean[] { true, true, true, true, true, true, true, true, true };
private long databaseSize = -1;
private long cacheSize = -1, cacheEmojiSize = -1, cacheTempSize = -1;
@ -256,9 +272,6 @@ public class CacheControlActivity extends BaseFragment implements NotificationCe
}
cacheTempSize = getDirectorySize(FileLoader.checkDirectory(FileLoader.MEDIA_DIR_CACHE), 4);
cacheSize += getDirectorySize(new File(ApplicationLoader.getDataDirFixed(), "cache"), 0);
cacheSize += getDirectorySize(ApplicationLoader.applicationContext.getExternalFilesDir("logs"), 0);
if (canceled) {
return;
}
@ -669,11 +682,6 @@ public class CacheControlActivity extends BaseFragment implements NotificationCe
sectionsEndRow = itemInners.size();
itemInners.add(new ItemInner(VIEW_TYPE_CLEAR_CACHE_BUTTON, null, null));
itemInners.add(ItemInner.asInfo(LocaleController.getString("StorageUsageInfo", R.string.StorageUsageInfo)));
resetDataRow = rowCount++;
// if (hasOldFolder) {
// migrateOldFolderRow = rowCount++;
// }
} else {
sectionsEndRow = -1;
}
@ -811,7 +819,7 @@ public class CacheControlActivity extends BaseFragment implements NotificationCe
file = FileLoader.checkDirectory(type);
}
if (file != null) {
Utilities.clearDir(file.getAbsolutePath(), documentsMusicType, Long.MAX_VALUE, true);
Utilities.clearDir(file.getAbsolutePath(), documentsMusicType, Long.MAX_VALUE, false);
}
if (type == 100) {
file = FileLoader.checkDirectory(FileLoader.MEDIA_DIR_CACHE);
@ -829,7 +837,7 @@ public class CacheControlActivity extends BaseFragment implements NotificationCe
file = FileLoader.checkDirectory(publicDirectoryType);
if (file != null) {
Utilities.clearDir(file.getAbsolutePath(), documentsMusicType, Long.MAX_VALUE, false);
Utilities.clearDir(file.getAbsolutePath(), documentsMusicType, Long.MAX_VALUE, true);
}
}
if (type == FileLoader.MEDIA_DIR_DOCUMENT) {
@ -842,40 +850,31 @@ public class CacheControlActivity extends BaseFragment implements NotificationCe
if (type == FileLoader.MEDIA_DIR_CACHE) {
cacheSize = getDirectorySize(FileLoader.checkDirectory(FileLoader.MEDIA_DIR_CACHE), 5);
cacheTempSize = getDirectorySize(FileLoader.checkDirectory(FileLoader.MEDIA_DIR_CACHE), 4);
imagesCleared = true;
try {
FileUtil.delete(new File(ApplicationLoader.getDataDirFixed(), "cache"));
} catch (Exception ignored) {
}
try {
FileUtil.delete(new File(EnvUtil.getTelegramPath(), "logs"));
} catch (Exception ignored) {
}
} else if (type == FileLoader.MEDIA_DIR_AUDIO) {
audioSize = getDirectorySize(FileLoader.checkDirectory(FileLoader.MEDIA_DIR_AUDIO), documentsMusicType);
} else if (type == FileLoader.MEDIA_DIR_DOCUMENT) {
if (documentsMusicType == 1) {
documentsSize = getDirectorySize(FileLoader.checkDirectory(FileLoader.MEDIA_DIR_DOCUMENT), documentsMusicType);
documentsSize += getDirectorySize(FileLoader.checkDirectory(FileLoader.MEDIA_DIR_FILES), documentsMusicType);
} else {
musicSize = getDirectorySize(FileLoader.checkDirectory(FileLoader.MEDIA_DIR_DOCUMENT), documentsMusicType);
musicSize += getDirectorySize(FileLoader.checkDirectory(FileLoader.MEDIA_DIR_FILES), documentsMusicType);
}
} else if (type == FileLoader.MEDIA_DIR_IMAGE) {
imagesCleared = true;
photoSize = getDirectorySize(FileLoader.checkDirectory(FileLoader.MEDIA_DIR_IMAGE), documentsMusicType);
photoSize += getDirectorySize(FileLoader.checkDirectory(FileLoader.MEDIA_DIR_IMAGE_PUBLIC), documentsMusicType);
} else if (type == FileLoader.MEDIA_DIR_VIDEO) {
videoSize = getDirectorySize(FileLoader.checkDirectory(FileLoader.MEDIA_DIR_VIDEO), documentsMusicType);
videoSize += getDirectorySize(FileLoader.checkDirectory(FileLoader.MEDIA_DIR_VIDEO_PUBLIC), documentsMusicType);
} else if (type == 100) {
imagesCleared = true;
stickersCacheSize = getDirectorySize(new File(FileLoader.checkDirectory(FileLoader.MEDIA_DIR_CACHE), "acache"), documentsMusicType);
imagesCleared = true;
} else if (type == FileLoader.MEDIA_DIR_AUDIO) {
audioSize = getDirectorySize(FileLoader.checkDirectory(FileLoader.MEDIA_DIR_AUDIO), documentsMusicType);
} else if (type == FileLoader.MEDIA_DIR_DOCUMENT) {
if (documentsMusicType == 1) {
documentsSize = getDirectorySize(FileLoader.checkDirectory(FileLoader.MEDIA_DIR_DOCUMENT), documentsMusicType);
documentsSize += getDirectorySize(FileLoader.checkDirectory(FileLoader.MEDIA_DIR_FILES), documentsMusicType);
} else {
musicSize = getDirectorySize(FileLoader.checkDirectory(FileLoader.MEDIA_DIR_DOCUMENT), documentsMusicType);
musicSize += getDirectorySize(FileLoader.checkDirectory(FileLoader.MEDIA_DIR_FILES), documentsMusicType);
}
} else if (type == FileLoader.MEDIA_DIR_IMAGE) {
imagesCleared = true;
photoSize = getDirectorySize(FileLoader.checkDirectory(FileLoader.MEDIA_DIR_IMAGE), documentsMusicType);
photoSize += getDirectorySize(FileLoader.checkDirectory(FileLoader.MEDIA_DIR_IMAGE_PUBLIC), documentsMusicType);
} else if (type == FileLoader.MEDIA_DIR_VIDEO) {
videoSize = getDirectorySize(FileLoader.checkDirectory(FileLoader.MEDIA_DIR_VIDEO), documentsMusicType);
videoSize += getDirectorySize(FileLoader.checkDirectory(FileLoader.MEDIA_DIR_VIDEO_PUBLIC), documentsMusicType);
} else if (type == 100) {
imagesCleared = true;
stickersCacheSize = getDirectorySize(new File(FileLoader.checkDirectory(FileLoader.MEDIA_DIR_CACHE), "acache"), documentsMusicType);
cacheEmojiSize = getDirectorySize(FileLoader.checkDirectory(FileLoader.MEDIA_DIR_CACHE), 3);
stickersCacheSize += cacheEmojiSize;
}
cacheEmojiSize = getDirectorySize(FileLoader.checkDirectory(FileLoader.MEDIA_DIR_CACHE), 3);
stickersCacheSize += cacheEmojiSize;}
}
final boolean imagesClearedFinal = imagesCleared;
totalSize = cacheSize + cacheTempSize + videoSize + audioSize + photoSize + documentsSize + musicSize + stickersCacheSize;
@ -1330,39 +1329,6 @@ public class CacheControlActivity extends BaseFragment implements NotificationCe
});
}
private void resetData() {
BottomBuilder builder = new BottomBuilder(getParentActivity());
builder.addTitle(LocaleController.getString("StorageResetInfo", R.string.StorageResetInfo));
builder.addItem(LocaleController.getString("CacheClear", R.string.CacheClear), R.drawable.baseline_delete_sweep_24, true, (i) -> {
if (getParentActivity() == null) {
return Unit.INSTANCE;
}
final AlertDialog progressDialog = new AlertDialog(getParentActivity(), 3);
progressDialog.setCanCancel(false);
progressDialog.show();
ConnectionsManager.reseting = true;
UIUtil.runOnIoDispatcher(() -> {
FileUtil.delete(EnvUtil.getTelegramPath());
for (int a : SharedConfig.activeAccounts) {
AccountInstance instance = AccountInstance.getInstance(a);
if (instance.getUserConfig().isClientActivated()) {
TLRPC.TL_auth_logOut req = new TLRPC.TL_auth_logOut();
instance.getConnectionsManager().sendRequest(req, (response, error) -> {
});
}
}
FileUtil.delete(getParentActivity().getFilesDir().getParentFile());
AndroidUtilities.runOnUIThread(() -> {
progressDialog.dismiss();
ProcessPhoenix.triggerRebirth(getParentActivity(), new Intent(getParentActivity(), LaunchActivity.class));
}, 2000L);
});
return Unit.INSTANCE;
});
builder.addCancelItem();
builder.show();
}
private void clearDatabase() {
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setTitle(LocaleController.getString("LocalDatabaseClearTextTitle", R.string.LocalDatabaseClearTextTitle));
@ -1390,6 +1356,7 @@ public class CacheControlActivity extends BaseFragment implements NotificationCe
}
}
@Override
public void onResume() {
super.onResume();
@ -1913,7 +1880,6 @@ public class CacheControlActivity extends BaseFragment implements NotificationCe
@Override
public boolean isEnabled(RecyclerView.ViewHolder holder) {
int position = holder.getAdapterPosition();
//
return position == migrateOldFolderRow || (holder.getItemViewType() == VIEW_TYPE_STORAGE && (totalSize > 0) && !calculating) || holder.getItemViewType() == VIEW_TYPE_CHAT || holder.getItemViewType() == VIEW_TYPE_KEEP_MEDIA_CELL || holder.getItemViewType() == VIEW_TYPE_SECTION;
}
@ -1944,30 +1910,23 @@ public class CacheControlActivity extends BaseFragment implements NotificationCe
view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
slideChooseView.setCallback(index -> {
if (index == 0) {
SharedConfig.setKeepMedia(4);
} else if (index == 1) {
SharedConfig.setKeepMedia(3);
} else if (index == 2) {
} else if (index == 1) {
SharedConfig.setKeepMedia(0);
} else if (index == 3) {
} else if (index == 2) {
SharedConfig.setKeepMedia(1);
} else if (index == 4) {
} else if (index == 3) {
SharedConfig.setKeepMedia(2);
}
});
int keepMedia = SharedConfig.keepMedia;
int index;
if (keepMedia == 3) {
index = 1;
} else if (keepMedia == 4) {
index = 0;
} else {
index = keepMedia + 2;
index = keepMedia + 1;
}
slideChooseView.setOptions(index, LocaleController.formatPluralString("Days", 1), LocaleController.formatPluralString("Days", 3), LocaleController.formatPluralString("Weeks", 1), LocaleController.formatPluralString("Months", 1), LocaleController.getString("KeepMediaForever", R.string.KeepMediaForever));
break;
case 5:
view = new ShadowSectionCell(mContext);
slideChooseView.setOptions(index, LocaleController.formatPluralString("Days", 3), LocaleController.formatPluralString("Weeks", 1), LocaleController.formatPluralString("Months", 1), LocaleController.getString("KeepMediaForever", R.string.KeepMediaForever));
break;
case VIEW_TYPE_CHAT:
UserCell userCell = new UserCell(getContext(), getResourceProvider());
@ -1991,16 +1950,16 @@ public class CacheControlActivity extends BaseFragment implements NotificationCe
view = cacheChart = new CacheChart(mContext) {
@Override
protected void onSectionClick(int index) {
// if (index == 8) {
// index = -1;
// }
// for (int i = 0; i < itemInners.size(); ++i) {
// ItemInner item = itemInners.get(i);
// if (item != null && item.index == index) {
// toggleSection(item, null);
// return;
// }
// }
// if (index == 8) {
// index = -1;
// }
// for (int i = 0; i < itemInners.size(); ++i) {
// ItemInner item = itemInners.get(i);
// if (item != null && item.index == index) {
// toggleSection(item, null);
// return;
// }
// }
}
@Override
@ -2124,9 +2083,9 @@ public class CacheControlActivity extends BaseFragment implements NotificationCe
float totalSizeInGb = (int) (totalDeviceSize / 1024L / 1024L) / 1000.0f;
ArrayList<Integer> options = new ArrayList<>();
// if (BuildVars.DEBUG_PRIVATE_VERSION) {
// options.add(1);
// }
// if (BuildVars.DEBUG_PRIVATE_VERSION) {
// options.add(1);
// }
if (totalSizeInGb <= 17) {
options.add(2);
}
@ -2230,9 +2189,8 @@ public class CacheControlActivity extends BaseFragment implements NotificationCe
// textCell.setTextAndValue(LocaleController.getString("ClearLocalDatabase", R.string.ClearLocalDatabase), AndroidUtilities.formatFileSize(databaseSize), updateDatabaseSize, false);
// updateDatabaseSize = false;
// } else
if (position == resetDataRow) {
textCell.setText(LocaleController.getString("StorageReset", R.string.StorageReset), false);
textCell.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteRedText));
if (position == migrateOldFolderRow) {
textCell.setTextAndValue(LocaleController.getString("MigrateOldFolder", R.string.MigrateOldFolder), null, false);
}
break;
case VIEW_TYPE_INFO:

View File

@ -35,6 +35,7 @@ import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.TextUtils;
import android.text.style.ClickableSpan;
import android.util.Log;
import android.util.SparseArray;
import android.util.TypedValue;
import android.view.Gravity;
@ -162,12 +163,74 @@ public class CameraScanActivity extends BaseFragment {
}
// Official Signature
public static BottomSheet showAsSheet(BaseFragment parentFragment, boolean gallery, int type, CameraScanActivityDelegate cameraDelegate) {
return showAsSheet(parentFragment.getParentActivity(), gallery, type, cameraDelegate, false);
public static INavigationLayout[] showAsSheet(BaseFragment parentFragment, boolean gallery, int type, CameraScanActivityDelegate cameraDelegate) {
return showAsSheet(parentFragment, gallery, type, cameraDelegate, false);
}
// Add the any parameter
public static BottomSheet showAsSheet(Activity parentActivity, boolean gallery, int type, CameraScanActivityDelegate cameraDelegate, boolean any) {
public static INavigationLayout[] showAsSheet(BaseFragment parentFragment, boolean gallery, int type, CameraScanActivityDelegate cameraDelegate, boolean any) {
if (parentFragment == null || parentFragment.getParentActivity() == null) {
return null;
}
INavigationLayout[] actionBarLayout = new INavigationLayout[]{INavigationLayout.newLayout(parentFragment.getParentActivity())};
BottomSheet bottomSheet = new BottomSheet(parentFragment.getParentActivity(), false) {
CameraScanActivity fragment;
{
actionBarLayout[0].setFragmentStack(new ArrayList<>());
fragment = new CameraScanActivity(type) {
@Override
public void finishFragment() {
dismiss();
}
@Override
public void removeSelfFromStack() {
dismiss();
}
};
fragment.shownAsBottomSheet = true;
fragment.needGalleryButton = gallery;
fragment.any = any;
actionBarLayout[0].addFragmentToStack(fragment);
actionBarLayout[0].showLastFragment();
actionBarLayout[0].getView().setPadding(backgroundPaddingLeft, 0, backgroundPaddingLeft, 0);
fragment.setDelegate(cameraDelegate);
containerView = actionBarLayout[0].getView();
setApplyBottomPadding(false);
setApplyBottomPadding(false);
setOnDismissListener(dialog -> fragment.onFragmentDestroy());
}
@Override
protected boolean canDismissWithSwipe() {
return false;
}
@Override
public void onBackPressed() {
if (actionBarLayout[0] == null || actionBarLayout[0].getFragmentStack().size() <= 1) {
super.onBackPressed();
} else {
actionBarLayout[0].onBackPressed();
}
}
@Override
public void dismiss() {
super.dismiss();
actionBarLayout[0] = null;
}
};
bottomSheet.setUseLightStatusBar(false);
AndroidUtilities.setLightNavigationBar(bottomSheet.getWindow(), false);
AndroidUtilities.setNavigationBarColor(bottomSheet.getWindow(), 0xff000000, false);
bottomSheet.setUseLightStatusBar(false);
bottomSheet.getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
bottomSheet.show();
return actionBarLayout;
}
public static BottomSheet showAsSheet(Activity parentActivity, boolean gallery, int type, CameraScanActivityDelegate cameraDelegate) {
if (parentActivity == null) {
return null;
}
@ -190,7 +253,6 @@ public class CameraScanActivity extends BaseFragment {
};
fragment.shownAsBottomSheet = true;
fragment.needGalleryButton = gallery;
fragment.any = any;
actionBarLayout[0].addFragmentToStack(fragment);
actionBarLayout[0].showLastFragment();
actionBarLayout[0].getView().setPadding(backgroundPaddingLeft, 0, backgroundPaddingLeft, 0);
@ -395,14 +457,14 @@ public class CameraScanActivity extends BaseFragment {
if (isQr() && child == cameraView) {
RectF bounds = getBounds();
int sizex = (int) (child.getWidth() * bounds.width()),
sizey = (int) (child.getHeight() * bounds.height()),
cx = (int) (child.getWidth() * bounds.centerX()),
cy = (int) (child.getHeight() * bounds.centerY());
sizey = (int) (child.getHeight() * bounds.height()),
cx = (int) (child.getWidth() * bounds.centerX()),
cy = (int) (child.getHeight() * bounds.centerY());
sizex *= (.5f + qrAppearingValue * .5f);
sizey *= (.5f + qrAppearingValue * .5f);
int x = cx - sizex / 2,
y = cy - sizey / 2;
y = cy - sizey / 2;
paint.setAlpha((int) (255 * (1f - (1f - backShadowAlpha) * Math.min(1, qrAppearingValue))));
canvas.drawRect(0, 0, child.getMeasuredWidth(), y, paint);
@ -413,7 +475,7 @@ public class CameraScanActivity extends BaseFragment {
canvas.drawRect(x, y, x + sizex, y + sizey, paint);
final int lineWidth = AndroidUtilities.lerp(0, AndroidUtilities.dp(4), Math.min(1, qrAppearingValue * 20f)),
halfLineWidth = lineWidth / 2;
halfLineWidth = lineWidth / 2;
final int lineLength = AndroidUtilities.lerp(Math.min(sizex, sizey), AndroidUtilities.dp(20), Math.min(1.2f, (float) Math.pow(qrAppearingValue, 1.8f)));
cornerPaint.setAlpha((int) (255 * Math.min(1, qrAppearingValue)));
@ -601,8 +663,8 @@ public class CameraScanActivity extends BaseFragment {
SpannableStringBuilder spanned = new SpannableStringBuilder(text);
String[] links = new String[] {
LocaleController.getString("AuthAnotherClientDownloadClientUrl", R.string.AuthAnotherClientDownloadClientUrl),
LocaleController.getString("AuthAnotherWebClientUrl", R.string.AuthAnotherWebClientUrl)
LocaleController.getString("AuthAnotherClientDownloadClientUrl", R.string.AuthAnotherClientDownloadClientUrl),
LocaleController.getString("AuthAnotherWebClientUrl", R.string.AuthAnotherWebClientUrl)
};
for (int i = 0; i < links.length; ++i) {
text = spanned.toString();
@ -750,20 +812,13 @@ public class CameraScanActivity extends BaseFragment {
private ValueAnimator recognizedAnimator;
private float recognizedT = 0;
private float newRecognizedT = 0;
private SpringAnimation useRecognizedBoundsAnimator;
private float useRecognizedBounds = 0;
private void updateRecognized() {
float wasNewRecognizedT = recognizedT;
newRecognizedT = recognized ? 1f : 0f;
if (wasNewRecognizedT != newRecognizedT) {
if (recognizedAnimator != null) {
recognizedAnimator.cancel();
}
} else {
return;
if (recognizedAnimator != null) {
recognizedAnimator.cancel();
}
float newRecognizedT = recognized ? 1f : 0f;
recognizedAnimator = ValueAnimator.ofFloat(recognizedT, newRecognizedT);
recognizedAnimator.addUpdateListener(a -> {
recognizedT = (float) a.getAnimatedValue();
@ -878,13 +933,13 @@ public class CameraScanActivity extends BaseFragment {
normalBounds = new RectF();
}
int width = Math.max(AndroidUtilities.displaySize.x, fragmentView.getWidth()),
height = Math.max(AndroidUtilities.displaySize.y, fragmentView.getHeight()),
side = (int) (Math.min(width, height) / 1.5f);
height = Math.max(AndroidUtilities.displaySize.y, fragmentView.getHeight()),
side = (int) (Math.min(width, height) / 1.5f);
normalBounds.set(
(width - side) / 2f / (float) width,
(height - side) / 2f / (float) height,
(width + side) / 2f / (float) width,
(height + side) / 2f / (float) height
(width - side) / 2f / (float) width,
(height - side) / 2f / (float) height,
(width + side) / 2f / (float) width,
(height + side) / 2f / (float) height
);
}
private RectF getBounds() {
@ -1028,9 +1083,9 @@ public class CameraScanActivity extends BaseFragment {
}
if (( // finish because...
(recognizeIndex == 0 && res != null && res.bounds == null && !qrLoading) || // first recognition doesn't have bounds
(SystemClock.elapsedRealtime() - recognizedStart > 1000 && !qrLoading) // got more than 1 second and nothing is loading
) && recognizedText != null) {
(recognizeIndex == 0 && res != null && res.bounds == null && !qrLoading) || // first recognition doesn't have bounds
(SystemClock.elapsedRealtime() - recognizedStart > 1000 && !qrLoading) // got more than 1 second and nothing is loading
) && recognizedText != null) {
if (cameraView != null && cameraView.getCameraSession() != null && currentType != TYPE_QR_WEB_BOT) {
CameraController.getInstance().stopPreview(cameraView.getCameraSession());
}
@ -1091,10 +1146,10 @@ public class CameraScanActivity extends BaseFragment {
matrixGrayscale.setSaturation(0);
ColorMatrix matrixInvert = new ColorMatrix();
matrixInvert.set(new float[] {
-1.0f, 0.0f, 0.0f, 0.0f, 255.0f,
0.0f, -1.0f, 0.0f, 0.0f, 255.0f,
0.0f, 0.0f, -1.0f, 0.0f, 255.0f,
0.0f, 0.0f, 0.0f, 1.0f, 0.0f
-1.0f, 0.0f, 0.0f, 0.0f, 255.0f,
0.0f, -1.0f, 0.0f, 0.0f, 255.0f,
0.0f, 0.0f, -1.0f, 0.0f, 255.0f,
0.0f, 0.0f, 0.0f, 1.0f, 0.0f
});
matrixInvert.preConcat(matrixGrayscale);
paint.setColorFilter(new ColorMatrixColorFilter(matrixInvert));
@ -1117,10 +1172,10 @@ public class CameraScanActivity extends BaseFragment {
}
public static ColorMatrix createThresholdMatrix(int threshold) {
ColorMatrix matrix = new ColorMatrix(new float[] {
85.f, 85.f, 85.f, 0.f, -255.f * threshold,
85.f, 85.f, 85.f, 0.f, -255.f * threshold,
85.f, 85.f, 85.f, 0.f, -255.f * threshold,
0f, 0f, 0f, 1f, 0f
85.f, 85.f, 85.f, 0.f, -255.f * threshold,
85.f, 85.f, 85.f, 0.f, -255.f * threshold,
85.f, 85.f, 85.f, 0.f, -255.f * threshold,
0f, 0f, 0f, 1f, 0f
});
return matrix;
}
@ -1257,9 +1312,9 @@ public class CameraScanActivity extends BaseFragment {
bounds = null;
} else {
float minX = Float.MAX_VALUE,
maxX = Float.MIN_VALUE,
minY = Float.MAX_VALUE,
maxY = Float.MIN_VALUE;
maxX = Float.MIN_VALUE,
minY = Float.MAX_VALUE,
maxY = Float.MIN_VALUE;
for (ResultPoint point : result.getResultPoints()) {
minX = Math.min(minX, point.getX());
maxX = Math.max(maxX, point.getX());
@ -1288,11 +1343,11 @@ public class CameraScanActivity extends BaseFragment {
QrResult qrResult = new QrResult();
if (bounds != null) {
int paddingx = AndroidUtilities.dp(25),
paddingy = AndroidUtilities.dp(15);
paddingy = AndroidUtilities.dp(15);
bounds.set(bounds.left - paddingx, bounds.top - paddingy, bounds.right + paddingx, bounds.bottom + paddingy);
bounds.set(
bounds.left / (float) width, bounds.top / (float) height,
bounds.right / (float) width, bounds.bottom / (float) height
bounds.left / (float) width, bounds.top / (float) height,
bounds.right / (float) width, bounds.bottom / (float) height
);
}
qrResult.bounds = bounds;

View File

@ -12607,8 +12607,6 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
} else if (messageObject.customReplyName != null) {
name = messageObject.customReplyName;
} else {
// NekoX: never draw forwardede name
drawForwardedName = false;
if (drawForwardedName) {
name = messageObject.replyMessageObject.getForwardedName();
}

View File

@ -55,7 +55,7 @@ public class MentionCell extends LinearLayout {
imageView.setRoundRadius(AndroidUtilities.dp(14));
addView(imageView, LayoutHelper.createLinear(28, 28, 12, 4, 0, 0));
nameTextView = new EmojiTextView(context) {
nameTextView = new TextView(context) {
@Override
public void setText(CharSequence text, BufferType type) {
text = Emoji.replaceEmoji(text, getPaint().getFontMetricsInt(), false);

View File

@ -93,9 +93,7 @@ public class SharedLinkCell extends FrameLayout {
public void run() {
if (checkingForLongPress && getParent() != null && currentPressCount == pressCount) {
checkingForLongPress = false;
if (!NekoConfig.disableVibration.Bool()) {
performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
}
performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
if (pressedLinkIndex >= 0) {
delegate.onLinkPress(links.get(pressedLinkIndex).toString(), true);
}

View File

@ -1603,8 +1603,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
int migrated_to = arguments.getInt("migrated_to", 0);
scrollToTopOnResume = arguments.getBoolean("scrollToTopOnResume", false);
needRemovePreviousSameChatActivity = arguments.getBoolean("need_remove_previous_same_chat_activity", true);
justCreatedChat = arguments.getBoolean("just_created_chat", false);
noForwardQuote = arguments.getBoolean("forward_noquote", false);
justCreatedChat = arguments.getBoolean("just_created_chat", false);
if (chatId != 0) {
currentChat = getMessagesController().getChat(chatId);
@ -9467,11 +9467,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (createUnreadMessageAfterId != 0) {
scrollToMessageId(createUnreadMessageAfterId, 0, false, returnToLoadIndex, true, 0, inCaseLoading);
} else if (returnToMessageId > 0) {
if (NekoConfig.rememberAllBackMessages.Bool() && !returnToMessageIdsStack.empty())
returnToMessageId = returnToMessageIdsStack.pop();
scrollToMessageId(returnToMessageId, 0, true, returnToLoadIndex, true, 0, inCaseLoading);
} else {
scrollToLastMessage(true, true, inCaseLoading);
scrollToLastMessage(false, true, inCaseLoading);
if (!pinnedMessageIds.isEmpty()) {
forceScrollToFirst = true;
forceNextPinnedMessageId = pinnedMessageIds.get(0);
@ -11275,7 +11273,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
private void showVoiceHint(boolean hide, boolean video) {
if (getParentActivity() == null || fragmentView == null || hide && voiceHintTextView == null || chatMode != 0 || chatActivityEnterView == null || chatActivityEnterView.getAudioVideoButtonContainer() == null || chatActivityEnterView.getAudioVideoButtonContainer().getVisibility() != View.VISIBLE || isInPreviewMode()) {
if (getParentActivity() == null || fragmentView == null || hide && voiceHintTextView == null || chatMode != 0 || chatActivityEnterView == null || chatActivityEnterView.getAudioVideoButtonContainer() == null || chatActivityEnterView.getAudioVideoButtonContainer().getVisibility() != View.VISIBLE || isInPreviewMode()) {
return;
}
if (NekoConfig.useChatAttachMediaMenu.Bool()) return;
@ -12157,7 +12155,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
SendMessagesHelper.getInstance(currentAccount).sendMessage(caption, dialog_id, null, null, null, true, null, null, null, true, 0, null, false);
caption = null;
}
getSendMessagesHelper().sendMessage(fmessages, dialog_id, noForwardQuote, false, true, 0);
getSendMessagesHelper().sendMessage(fmessages, dialog_id, false, false, true, 0);
SendMessagesHelper.prepareSendingDocuments(getAccountInstance(), files, files, null, caption, null, dialog_id, replyingMessageObject, getThreadMessage(), null, editingMessageObject, notify, scheduleDate);
afterMessageSend();
}
@ -18724,10 +18722,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
avatarContainer.updateSubtitle();
}
}
} else if (id == NotificationCenter.dialogsUnreadCounterChanged) {
if (actionBar != null) { // NekoX
actionBar.unreadBadgeSetCount(getMessagesStorage().getMainUnreadCount());
}
}
}
@ -27121,7 +27115,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (username != null) {
username = username.toLowerCase();
if (ChatObject.hasPublicLink(currentChat, username) || UserObject.hasPublicUsername(currentUser, username)) {
if (avatarContainer != null) {
if (avatarContainer != null) {
avatarContainer.openProfile(false);
} else {
shakeContent();
@ -27145,10 +27139,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
presentFragment(fragment);
}
} else {
// if (qr) {
// ProxyUtil.showQrDialog(getParentActivity(), str);
// return;
// }
processExternalUrl(0, str, url, cell, false);
}
}
@ -27248,11 +27238,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
} else if (type == 1) {
Browser.openUrl(getParentActivity(), Uri.parse(url), inlineReturn == 0, false, makeProgressForLink(cell, span));
} else if (type == 2) {
// NekoX: Fix skipOpenLinkConfirm broken in 7.6.0, since processExternalUrl is imported in 7.6.0
if (NekoConfig.skipOpenLinkConfirm.Bool())
Browser.openUrl(getParentActivity(), Uri.parse(url), inlineReturn == 0, true, makeProgressForLink(cell, span));
else
AlertsCreator.showOpenUrlAlert(ChatActivity.this, url, true, true, true);
Browser.openUrl(getParentActivity(), Uri.parse(url), inlineReturn == 0, true, makeProgressForLink(cell, span));
}
}
}
@ -27397,63 +27383,54 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
} else {
final String urlFinal = ((URLSpan) url).getURL();
if (longPress) {
BottomBuilder builder = new BottomBuilder(getParentActivity());
final ChatMessageCell finalCell = cell;
BottomSheet.Builder builder = new BottomSheet.Builder(getParentActivity(), false, themeDelegate);
String formattedUrl = urlFinal;
try {
formattedUrl = URLDecoder.decode(urlFinal.replaceAll("\\+", "%2b"), "UTF-8");
} catch (Exception e) {
FileLog.e(e);
}
builder.addTitle(formattedUrl);
builder.addItems(
new String[]{
LocaleController.getString("Open", R.string.Open),
LocaleController.getString("Copy", R.string.Copy),
LocaleController.getString("ShareQRCode", R.string.ShareQRCode),
LocaleController.getString("ShareMessages", R.string.ShareMessages)
},
new int[]{
R.drawable.baseline_open_in_browser_24,
R.drawable.baseline_content_copy_24,
R.drawable.wallet_qr,
R.drawable.baseline_share_24
},
(which, text, __) -> {
if (which == 0) {
processExternalUrl(1, urlFinal, url, finalCell, false);
} else if (which == 1) {
String url1 = urlFinal;
boolean tel = false;
boolean mail = false;
if (url1.startsWith("mailto:")) {
url1 = url1.substring(7);
mail = true;
} else if (url1.startsWith("tel:")) {
url1 = url1.substring(4);
tel = true;
}
AndroidUtilities.addToClipboard(url1);
if (mail) {
undoView.showWithAction(0, UndoView.ACTION_EMAIL_COPIED, null);
} else if (tel) {
undoView.showWithAction(0, UndoView.ACTION_PHONE_COPIED, null);
} else {
undoView.showWithAction(0, UndoView.ACTION_LINK_COPIED, null);
}
} else if (which == 2) {
ProxyUtil.showQrDialog(getParentActivity(), urlFinal);
} else if (which == 3) {
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, urlFinal);
try {
getParentActivity().startActivity(intent);
} catch (Exception e) {
AlertUtil.showToast(e);
}
builder.setTitle(formattedUrl);
builder.setTitleMultipleLines(true);
builder.setItems(new CharSequence[]{LocaleController.getString("Open", R.string.Open), LocaleController.getString("ShareFile", R.string.ShareFile), LocaleController.getString("Copy", R.string.Copy)}, (dialog, which) -> {
if (which == 0) {
processExternalUrl(1, urlFinal, url, finalCell, false);
} else if (which == 1 || which == 2) {
String url1 = urlFinal;
boolean tel = false;
boolean mail = false;
if (url1.startsWith("mailto:")) {
url1 = url1.substring(7);
mail = true;
} else if (url1.startsWith("tel:")) {
url1 = url1.substring(4);
tel = true;
}
if (which == 2) {
AndroidUtilities.addToClipboard(url1);
if (mail) {
undoView.showWithAction(0, UndoView.ACTION_EMAIL_COPIED, null);
} else if (tel) {
undoView.showWithAction(0, UndoView.ACTION_PHONE_COPIED, null);
} else {
undoView.showWithAction(0, UndoView.ACTION_LINK_COPIED, null);
}
return Unit.INSTANCE;
});
} else {
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("text/plain");
shareIntent.putExtra(Intent.EXTRA_TEXT, url1);
Intent chooserIntent = Intent.createChooser(shareIntent, LocaleController.getString("ShareFile", R.string.ShareFile));
chooserIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
ApplicationLoader.applicationContext.startActivity(chooserIntent);
}
}
});
builder.setOnPreDismissListener(di -> {
if (finalCell != null) {
finalCell.resetPressedLink(-1);
}
});
showDialog(builder.create());
} else {
boolean forceAlert = url instanceof URLSpanReplacement;

View File

@ -268,9 +268,9 @@ public class AdminLogFilterAlert extends BottomSheet {
if (currentFilter == null) {
currentFilter = new TLRPC.TL_channelAdminLogEventsFilter();
currentFilter.join = currentFilter.leave = currentFilter.invite = currentFilter.ban =
currentFilter.unban = currentFilter.kick = currentFilter.unkick = currentFilter.promote =
currentFilter.demote = currentFilter.info = currentFilter.settings = currentFilter.pinned =
currentFilter.edit = currentFilter.delete = currentFilter.group_call = currentFilter.invites = true;
currentFilter.unban = currentFilter.kick = currentFilter.unkick = currentFilter.promote =
currentFilter.demote = currentFilter.info = currentFilter.settings = currentFilter.pinned =
currentFilter.edit = currentFilter.delete = currentFilter.group_call = currentFilter.invites = true;
}
if (position == restrictionsRow) {
currentFilter.kick = currentFilter.ban = currentFilter.unkick = currentFilter.unban = !currentFilter.kick;

View File

@ -607,9 +607,6 @@ public class AlertsCreator {
localeInfo.pathToFile = "unofficial";
}
}
if (callback != null) {
callback.run();
}
LocaleController.getInstance().applyLanguage(localeInfo, true, false, false, true, UserConfig.selectedAccount, null);
activity.rebuildAllFragments(true);
return Unit.INSTANCE;
@ -1115,7 +1112,7 @@ public class AlertsCreator {
return;
}
long inlineReturn = (fragment instanceof ChatActivity) ? ((ChatActivity) fragment).getInlineReturn() : 0;
if (Browser.isInternalUrl(url, null) || !ask || NekoConfig.skipOpenLinkConfirm.Bool()) {
if (Browser.isInternalUrl(url, null) || !ask) {
Browser.openUrl(fragment.getParentActivity(), Uri.parse(url), inlineReturn == 0, tryTelegraph, progress);
} else {
String urlFinal = url;
@ -3889,6 +3886,44 @@ public class AlertsCreator {
return builder.create();
}
public static BottomSheet createMuteAlert(BaseFragment fragment, ArrayList<Long> dialog_ids, int topicId, Theme.ResourcesProvider resourcesProvider) {
if (fragment == null || fragment.getParentActivity() == null) {
return null;
}
BottomSheet.Builder builder = new BottomSheet.Builder(fragment.getParentActivity(), false, resourcesProvider);
builder.setTitle(LocaleController.getString("Notifications", R.string.Notifications), true);
CharSequence[] items = new CharSequence[]{
LocaleController.formatString("MuteFor", R.string.MuteFor, LocaleController.formatPluralString("Hours", 1)),
LocaleController.formatString("MuteFor", R.string.MuteFor, LocaleController.formatPluralString("Hours", 8)),
LocaleController.formatString("MuteFor", R.string.MuteFor, LocaleController.formatPluralString("Days", 2)),
LocaleController.getString("MuteDisable", R.string.MuteDisable)
};
builder.setItems(items, (dialogInterface, i) -> {
int setting;
if (i == 0) {
setting = NotificationsController.SETTING_MUTE_HOUR;
} else if (i == 1) {
setting = NotificationsController.SETTING_MUTE_8_HOURS;
} else if (i == 2) {
setting = NotificationsController.SETTING_MUTE_2_DAYS;
} else {
setting = NotificationsController.SETTING_MUTE_FOREVER;
}
if (dialog_ids != null) {
for (int j = 0; j < dialog_ids.size(); ++j) {
long dialog_id = dialog_ids.get(j);
NotificationsController.getInstance(UserConfig.selectedAccount).setDialogNotificationsSettings(dialog_id, topicId, setting);
}
}
if (BulletinFactory.canShowBulletin(fragment)) {
BulletinFactory.createMuteBulletin(fragment, setting, 0, resourcesProvider).show();
}
}
);
return builder.create();
}
public static void sendReport(TLRPC.InputPeer peer, int type, String message, ArrayList<Integer> messages) {
TLRPC.TL_messages_report request = new TLRPC.TL_messages_report();
request.peer = peer;

View File

@ -44,6 +44,7 @@ public class AvatarDrawable extends Drawable {
private float textHeight;
private float textLeft;
private boolean isProfile;
private boolean smallSize;
private boolean drawDeleted;
private int avatarType;
private float archivedAvatarProgress;
@ -260,6 +261,10 @@ public class AvatarDrawable extends Drawable {
needApplyColorAccent = false;
}
public void setSmallSize(boolean value) {
smallSize = value;
}
public void setTextSize(int size) {
namePaint.setTextSize(size);
}
@ -436,6 +441,10 @@ public class AvatarDrawable extends Drawable {
if (drawable != null) {
int w = (int) (drawable.getIntrinsicWidth() * scaleSize);
int h = (int) (drawable.getIntrinsicHeight() * scaleSize);
if (smallSize) {
w *= 0.8f;
h *= 0.8f;
}
int x = (size - w) / 2;
int y = (size - h) / 2;
drawable.setBounds(x, y, x + w, y + h);

View File

@ -4395,15 +4395,12 @@ public class ChatActivityEnterView extends BlurredFrameLayout implements Notific
}
preferences.edit().putBoolean(isChannel ? "currentModeVideoChannel" : "currentModeVideo", visible).apply();
}
if (!NekoConfig.useChatAttachMediaMenu.Bool()) {
if (!NekoConfig.useChatAttachMediaMenu.Bool())
audioVideoSendButton.setState(isInVideoMode() ? ChatActivityEnterViewAnimatedIconView.State.VIDEO : ChatActivityEnterViewAnimatedIconView.State.VOICE, animated);
audioVideoSendButton.setContentDescription(LocaleController.getString(isInVideoMode() ? R.string.AccDescrVideoMessage : R.string.AccDescrVoiceMessage));
audioVideoButtonContainer.setContentDescription(LocaleController.getString(isInVideoMode() ? R.string.AccDescrVideoMessage : R.string.AccDescrVoiceMessage));
} else {
else
audioVideoSendButton.setState(ChatActivityEnterViewAnimatedIconView.State.MENU, animated);
audioVideoSendButton.setContentDescription(LocaleController.getString(R.string.Other));
// audioVideoButtonContainer.setContentDescription();
}
audioVideoSendButton.setContentDescription(LocaleController.getString(isInVideoMode() ? R.string.AccDescrVideoMessage : R.string.AccDescrVoiceMessage));
audioVideoButtonContainer.setContentDescription(LocaleController.getString(isInVideoMode() ? R.string.AccDescrVideoMessage : R.string.AccDescrVoiceMessage));
audioVideoSendButton.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED);
}

View File

@ -587,7 +587,7 @@ public class ChatAttachAlertPhotoLayout extends ChatAttachAlert.AttachAlertLayou
compressItem = parentAlert.selectedMenuItem.addSubItem(compress, R.drawable.msg_filehq, LocaleController.getString("SendWithoutCompression", R.string.SendWithoutCompression));
parentAlert.selectedMenuItem.addSubItem(group, R.drawable.msg_ungroup, LocaleController.getString("SendWithoutGrouping", R.string.SendWithoutGrouping));
spoilerItem = parentAlert.selectedMenuItem.addSubItem(spoiler, R.drawable.msg_spoiler, LocaleController.getString("EnablePhotoSpoiler", R.string.EnablePhotoSpoiler));
parentAlert.selectedMenuItem.addSubItem(open_in, R.drawable.baseline_open_in_browser_24, LocaleController.getString("OpenInExternalApp", R.string.OpenInExternalApp));
parentAlert.selectedMenuItem.addSubItem(open_in, R.drawable.msg_openin, LocaleController.getString("OpenInExternalApp", R.string.OpenInExternalApp));
View gap = parentAlert.selectedMenuItem.addGap(preview_gap);
gap.setBackgroundColor(Theme.getColor(Theme.key_actionBarDefaultSubmenuSeparator, resourcesProvider));
previewItem = parentAlert.selectedMenuItem.addSubItem(preview, R.drawable.msg_view_file, LocaleController.getString("AttachMediaPreviewButton", R.string.AttachMediaPreviewButton));

View File

@ -18,7 +18,6 @@ import org.telegram.ui.ActionBar.Theme;
public class ColoredImageSpan extends ReplacementSpan {
int drawableColor;
// boolean override;
Drawable drawable;
boolean usePaintColor = true;
@ -52,14 +51,6 @@ public class ColoredImageSpan extends ReplacementSpan {
this.verticalAlignment = verticalAlignment;
}
public ColoredImageSpan(@NonNull Drawable drawable, int drawableColor) {
this.drawable = drawable;
this.drawableColor = drawableColor;
this.usePaintColor = true;
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
drawable.setColorFilter(new PorterDuffColorFilter(drawableColor, PorterDuff.Mode.SRC_IN));
}
public void setSize(int size) {
this.size = size;
drawable.setBounds(0, 0, size, size);
@ -74,7 +65,6 @@ public class ColoredImageSpan extends ReplacementSpan {
public void draw(@NonNull Canvas canvas, CharSequence text, int start, int end, float x, int top, int y, int bottom, @NonNull Paint paint) {
int color;
if (usePaintColor) {
// override
color = paint.getColor();
} else {
color = Theme.getColor(colorKey);

View File

@ -166,11 +166,8 @@ public class EditTextEffects extends EditText {
Layout layout = getLayout();
if (text instanceof Spannable && layout != null) {
int line = layout.getLineForOffset(start);
// NekoX: Fix official bug: Mention crash
if (start > layout.getText().length())
return;
int x = (int) layout.getPrimaryHorizontal(start);
int y = (int) ((layout.getLineTop(line) + layout.getLineBottom(line)) / 2f);
int x = (int) layout.getPrimaryHorizontal(start);
int y = (int) ((layout.getLineTop(line) + layout.getLineBottom(line)) / 2f);
for (SpoilerEffect eff : spoilers) {
if (eff.getBounds().contains(x, y)) {

View File

@ -227,7 +227,7 @@ public class ImageUpdater implements NotificationCenter.NotificationCenterDelega
openAttachMenu(onDismiss);
return;
}
BottomBuilder builder = new BottomBuilder(parentFragment.getParentActivity());
BottomSheet.Builder builder = new BottomSheet.Builder(parentFragment.getParentActivity());
if (type == TYPE_SET_PHOTO_FOR_USER) {
builder.setTitle(LocaleController.formatString("SetPhotoFor", R.string.SetPhotoFor, user.first_name), true);
@ -237,6 +237,80 @@ public class ImageUpdater implements NotificationCenter.NotificationCenterDelega
builder.setTitle(LocaleController.getString("ChoosePhoto", R.string.ChoosePhoto), true);
}
ArrayList<CharSequence> items = new ArrayList<>();
ArrayList<Integer> icons = new ArrayList<>();
ArrayList<Integer> ids = new ArrayList<>();
items.add(LocaleController.getString("ChooseTakePhoto", R.string.ChooseTakePhoto));
icons.add(R.drawable.msg_camera);
ids.add(ID_TAKE_PHOTO);
if (canSelectVideo) {
items.add(LocaleController.getString("ChooseRecordVideo", R.string.ChooseRecordVideo));
icons.add(R.drawable.msg_video);
ids.add(ID_RECORD_VIDEO);
}
items.add(LocaleController.getString("ChooseFromGallery", R.string.ChooseFromGallery));
icons.add(R.drawable.msg_photos);
ids.add(ID_UPLOAD_FROM_GALLERY);
if (searchAvailable) {
items.add(LocaleController.getString("ChooseFromSearch", R.string.ChooseFromSearch));
icons.add(R.drawable.msg_search);
ids.add(ID_SEARCH_WEB);
}
if (hasAvatar) {
items.add(LocaleController.getString("DeletePhoto", R.string.DeletePhoto));
icons.add(R.drawable.msg_delete);
ids.add(ID_REMOVE_PHOTO);
}
int[] iconsRes = new int[icons.size()];
for (int i = 0, N = icons.size(); i < N; i++) {
iconsRes[i] = icons.get(i);
}
builder.setItems(items.toArray(new CharSequence[0]), iconsRes, (dialogInterface, i) -> {
int id = ids.get(i);
switch (id) {
case ID_TAKE_PHOTO:
openCamera();
break;
case ID_UPLOAD_FROM_GALLERY:
openGallery();
break;
case ID_SEARCH_WEB:
openSearch();
break;
case ID_REMOVE_PHOTO:
onDeleteAvatar.run();
break;
case ID_RECORD_VIDEO:
openVideoCamera();
break;
}
});
BottomSheet sheet = builder.create();
sheet.setOnHideListener(onDismiss);
parentFragment.showDialog(sheet);
if (hasAvatar) {
sheet.setItemColor(items.size() - 1, Theme.getColor(Theme.key_dialogTextRed2), Theme.getColor(Theme.key_dialogRedIcon));
}
}
public void openMenu(boolean hasAvatar, Runnable onDeleteAvatar, DialogInterface.OnDismissListener onDismiss) {
if (parentFragment == null || parentFragment.getParentActivity() == null) {
return;
}
if (useAttachMenu) {
openAttachMenu(onDismiss);
return;
}
BottomBuilder builder = new BottomBuilder(parentFragment.getParentActivity());
if (hasAvatar && parentFragment instanceof ProfileActivity) {
builder.addItem(LocaleController.getString("Open", R.string.Open), R.drawable.baseline_visibility_24, __ -> {

View File

@ -4,6 +4,7 @@ import android.content.Context;
import android.content.SharedPreferences;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.SharedConfig;
import org.telegram.messenger.UserConfig;
import org.telegram.ui.Components.Paint.Views.PaintTextOptionsView;
@ -32,7 +33,7 @@ public class PersistColorPalette {
);
private final static Integer DEFAULT_MARKER_COLOR = 0xff0a84ff;
private static PersistColorPalette[] instances = new PersistColorPalette[UserConfig.MAX_ACCOUNT_COUNT];
private static PersistColorPalette[] instances = new PersistColorPalette[32];
private SharedPreferences mConfig;
private List<Integer> colors = new ArrayList<>(COLORS_COUNT);

View File

@ -106,10 +106,6 @@ public class PremiumPreviewBottomSheet extends BottomSheetWithRecyclerListView i
FrameLayout bulletinContainer;
public PremiumPreviewBottomSheet(BaseFragment fragment, int currentAccount, TLRPC.User user, Theme.ResourcesProvider resourcesProvider) {
this(fragment, currentAccount, user, null, resourcesProvider);
}
public PremiumPreviewBottomSheet(BaseFragment fragment, int currentAccount, TLRPC.User user, Void gift, Theme.ResourcesProvider resourcesProvider) {
super(fragment, false, false, false, resourcesProvider);
fixNavigationBar();
this.fragment = fragment;

View File

@ -998,11 +998,6 @@ public class ProfileGalleryView extends CircularViewPager implements Notificatio
item.imageView.setRoundRadius(roundTopRadius, roundTopRadius, roundBottomRadius, roundBottomRadius);
item.imageView.setTag(realPosition);
item.imageView.setOnClickListener(__ -> {
callback.onClick();;
});
return item;
}

View File

@ -1971,6 +1971,9 @@ public class ShareAlert extends BottomSheet implements NotificationCenter.Notifi
// send fwd message first.
result = SendMessagesHelper.getInstance(currentAccount).sendMessage(sendingMessageObjects, key, !showSendersName,false, withSound, 0);
}
if (replyTopMsg != null) {
replyTopMsg.isTopicMainMessage = true;
}
if (frameLayout2.getTag() != null && commentTextView.length() > 0) {
SendMessagesHelper.getInstance(currentAccount).sendMessage(text[0] == null ? null : text[0].toString(), key, replyTopMsg, replyTopMsg, null, true, entities, null, null, withSound, 0, null, false);
}

View File

@ -330,7 +330,7 @@ public class UndoView extends FrameLayout {
}
private boolean isTooltipAction() {
return currentAction == ACTION_NEED_RESATRT || currentAction == ACTION_ARCHIVE_HIDDEN || currentAction == ACTION_ARCHIVE_HINT || currentAction == ACTION_ARCHIVE_FEW_HINT ||
return currentAction == ACTION_ARCHIVE_HIDDEN || currentAction == ACTION_ARCHIVE_HINT || currentAction == ACTION_ARCHIVE_FEW_HINT ||
currentAction == ACTION_ARCHIVE_PINNED || currentAction == ACTION_CONTACT_ADDED || currentAction == ACTION_PROXY_ADDED || currentAction == ACTION_OWNER_TRANSFERED_CHANNEL ||
currentAction == ACTION_OWNER_TRANSFERED_GROUP || currentAction == ACTION_QUIZ_CORRECT || currentAction == ACTION_QUIZ_INCORRECT || currentAction == ACTION_CACHE_WAS_CLEARED ||
currentAction == ACTION_ADDED_TO_FOLDER || currentAction == ACTION_REMOVED_FROM_FOLDER || currentAction == ACTION_PROFILE_PHOTO_CHANGED ||

View File

@ -12,7 +12,6 @@ import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
@ -513,9 +512,10 @@ public class DataSettingsActivity extends BaseFragment {
updateVoipUseLessData = false;
} else if (position == dataUsageRow) {
textCell.setIcon(R.drawable.msg_data_usage);
textCell.setText(LocaleController.getString("NetworkUsage", R.string.NetworkUsage), true);
textCell.setText(LocaleController.getString("NetworkUsage", R.string.NetworkUsage), storageNumRow != -1);
} else if (position == storageNumRow) {
textCell.setTextAndValue(LocaleController.getString("StoragePath", R.string.StoragePath), NekoConfig.cachePath.String(), false);
textCell.setIcon(R.drawable.msg_storage_path);
textCell.setText(LocaleController.getString("StoragePath", R.string.StoragePath), false);
} else if (position == proxyRow) {
textCell.setIcon(0);
textCell.setText(LocaleController.getString("ProxySettings", R.string.ProxySettings), false);
@ -524,7 +524,7 @@ public class DataSettingsActivity extends BaseFragment {
textCell.setCanDisable(true);
textCell.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteRedText));
textCell.setText(LocaleController.getString("ResetAutomaticMediaDownload", R.string.ResetAutomaticMediaDownload), false);
} else if (position == quickRepliesRow) {
} else if (position == quickRepliesRow){
textCell.setIcon(0);
textCell.setText(LocaleController.getString("VoipQuickReplies", R.string.VoipQuickReplies), false);
} else if (position == clearDraftsRow) {

View File

@ -1692,7 +1692,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
firstLayout = false;
}
super.onMeasure(widthSpec, heightSpec);
if ((initialDialogsType == 3 && NekoConfig.showTabsOnForward.Bool()) || !onlySelect) {
if (!onlySelect) {
if (appliedPaddingTop != t && viewPages != null && viewPages.length > 1 && !startedTracking && (tabsAnimation == null || !tabsAnimation.isRunning()) && !tabsAnimationInProgress && (filterTabsView == null || !filterTabsView.isAnimatingIndicator())) {
viewPages[1].setTranslationX(viewPages[0].getMeasuredWidth());
}
@ -2538,11 +2538,6 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
updatePasscodeButton();
updateProxyButton(false, false);
}
scanItem = menu.addItem(nekox_scanqr, R.drawable.wallet_qr);
scanItem.setContentDescription(LocaleController.getString("ScanQRCode", R.string.ScanQRCode));
scanItem.setVisibility(View.GONE);
searchItem = menu.addItem(0, R.drawable.ic_ab_search).setIsSearchField(true, false).setActionBarMenuItemSearchListener(new ActionBarMenuItem.ActionBarMenuItemSearchListener() {
boolean isSpeedItemCreated = false;
@ -4582,15 +4577,6 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
};
rightSlidingDialogContainer.setOpenProgress(0f);
contentView.addView(rightSlidingDialogContainer, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
if (new Random().nextInt(100) < 50)
PrivacyUtil.postCheckAll(getParentActivity(), currentAccount);
else if (new Random().nextInt(100) < 20)
UpdateUtil.postCheckFollowChannel(getParentActivity(), currentAccount);
if (NekoXConfig.developerMode && !NekoXConfig.isDeveloper())
NekoXConfig.toggleDeveloperMode();
return fragmentView;
}

View File

@ -51,14 +51,6 @@ 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.messenger.MessagesController;
import org.telegram.messenger.MessagesStorage;
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.ActionBarPopupWindow;
import org.telegram.ui.ActionBar.BaseFragment;
import org.telegram.ui.ActionBar.Theme;
@ -76,6 +68,12 @@ import org.telegram.ui.Components.CombinedDrawable;
import org.telegram.ui.Components.ContextProgressView;
import org.telegram.ui.Components.EditTextEmoji;
import org.telegram.ui.Components.ImageUpdater;
import org.telegram.ui.Components.LayoutHelper;
import org.telegram.ui.Components.ListView.AdapterWithDiffUtils;
import org.telegram.ui.Components.RLottieDrawable;
import org.telegram.ui.Components.RLottieImageView;
import org.telegram.ui.Components.VerticalPositionAutoAnimator;
import org.telegram.ui.Components.ImageUpdater;
import org.telegram.ui.Components.BackupImageView;
import org.telegram.ui.Components.CombinedDrawable;
import org.telegram.ui.Components.ContextProgressView;
@ -83,9 +81,6 @@ import org.telegram.ui.Components.EditTextEmoji;
import org.telegram.ui.Components.GroupCreateDividerItemDecoration;
import org.telegram.ui.Components.ImageUpdater;
import org.telegram.ui.Components.LayoutHelper;
import org.telegram.ui.Components.ListView.AdapterWithDiffUtils;
import org.telegram.ui.Components.RLottieDrawable;
import org.telegram.ui.Components.RLottieImageView;
import org.telegram.ui.Components.RadialProgressView;
import org.telegram.ui.Components.RecyclerListView;
import org.telegram.ui.Components.SizeNotifierFrameLayout;

View File

@ -15,14 +15,12 @@ import android.content.Context;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.graphics.Canvas;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityNodeInfo;
import android.widget.EditText;
import android.widget.FrameLayout;
import androidx.recyclerview.widget.DefaultItemAnimator;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
@ -33,11 +31,9 @@ import org.telegram.messenger.R;
import org.telegram.messenger.Utilities;
import org.telegram.ui.ActionBar.Theme;
import org.telegram.ui.ActionBar.ThemeDescription;
import org.telegram.ui.Cells.HeaderCell;
import org.telegram.ui.Cells.LanguageCell;
import org.telegram.tgnet.ConnectionsManager;
import org.telegram.tgnet.TLRPC;
import org.telegram.tgnet.ConnectionsManager;
import org.telegram.ui.ActionBar.ActionBar;
import org.telegram.ui.ActionBar.ActionBarMenu;
import org.telegram.ui.ActionBar.ActionBarMenuItem;
@ -74,9 +70,6 @@ public class LanguageSelectActivity extends BaseFragment implements Notification
private ArrayList<LocaleController.LocaleInfo> sortedLanguages;
private ArrayList<LocaleController.LocaleInfo> unofficialLanguages;
private ActionBarMenuItem searchItem;
private int translateSettingsBackgroundHeight;
@Override
public boolean onFragmentCreate() {
fillLanguages();
@ -110,7 +103,7 @@ public class LanguageSelectActivity extends BaseFragment implements Notification
});
ActionBarMenu menu = actionBar.createMenu();
searchItem = menu.addItem(0, R.drawable.ic_ab_search).setIsSearchField(true).setActionBarMenuItemSearchListener(new ActionBarMenuItem.ActionBarMenuItemSearchListener() {
ActionBarMenuItem item = menu.addItem(0, R.drawable.ic_ab_search).setIsSearchField(true).setActionBarMenuItemSearchListener(new ActionBarMenuItem.ActionBarMenuItemSearchListener() {
@Override
public void onSearchExpand() {
searching = true;
@ -146,7 +139,7 @@ public class LanguageSelectActivity extends BaseFragment implements Notification
}
}
});
searchItem.setSearchFieldHint(LocaleController.getString("Search", R.string.Search));
item.setSearchFieldHint(LocaleController.getString("Search", R.string.Search));
listAdapter = new ListAdapter(context, false);
searchListViewAdapter = new ListAdapter(context, true);
@ -161,92 +154,30 @@ public class LanguageSelectActivity extends BaseFragment implements Notification
emptyView.setShowAtCenter(true);
frameLayout.addView(emptyView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
listView = new RecyclerListView(context) {
@Override
protected void dispatchDraw(Canvas canvas) {
if (getAdapter() == listAdapter && getItemAnimator() != null && getItemAnimator().isRunning()) {
int backgroundColor = Theme.getColor(Theme.key_windowBackgroundWhite, resourcesProvider);
drawItemBackground(canvas, 0, translateSettingsBackgroundHeight, backgroundColor);
// drawItemBackground(canvas, 1, Theme.getColor(Theme.key_windowBackgroundWhite, resourcesProvider));
drawSectionBackground(canvas, 1, 2, backgroundColor);
}
super.dispatchDraw(canvas);
}
};
listView = new RecyclerListView(context);
listView.setEmptyView(emptyView);
listView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false));
listView.setVerticalScrollBarEnabled(false);
listView.setAdapter(listAdapter);
DefaultItemAnimator itemAnimator = new DefaultItemAnimator() {
@Override
protected void onMoveAnimationUpdate(RecyclerView.ViewHolder holder) {
listView.invalidate();
listView.updateSelector();
}
};
itemAnimator.setDurations(400);
itemAnimator.setInterpolator(CubicBezierInterpolator.EASE_OUT_QUINT);
listView.setItemAnimator(itemAnimator);
frameLayout.addView(listView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
listView.setOnItemClickListener((view, position) -> {
try {
if (getParentActivity() == null || parentLayout == null || !(view instanceof TextRadioCell)) {
if (getParentActivity() == null || parentLayout == null || !(view instanceof LanguageCell)) {
return;
}
LanguageCell cell = (LanguageCell) view;
LocaleController.LocaleInfo localeInfo = cell.getCurrentLocale();
if (localeInfo != null) {
if (localeInfo.toInstall) {
AlertsCreator.createLanguageAlert((LaunchActivity) getParentActivity(),localeInfo.pack,() -> {
finishFragment();
}).show();
return;
}
boolean search = listView.getAdapter() == searchListViewAdapter;
if (!search) {
position -= 2;
}
LocaleController.LocaleInfo localeInfo;
if (search) {
localeInfo = searchResult.get(position);
} else if (!unofficialLanguages.isEmpty() && position >= 0 && position < unofficialLanguages.size()) {
localeInfo = unofficialLanguages.get(position);
} else {
if (!unofficialLanguages.isEmpty()) {
position -= unofficialLanguages.size() + 1;
}
localeInfo = sortedLanguages.get(position);
}
if (localeInfo != null) {
LocaleController.LocaleInfo prevLocale = LocaleController.getInstance().getCurrentLocaleInfo();
boolean sameLang = prevLocale == localeInfo;
final AlertDialog progressDialog = new AlertDialog(getContext(), AlertDialog.ALERT_TYPE_SPINNER);
int reqId = LocaleController.getInstance().applyLanguage(localeInfo, true, false, false, true, currentAccount, () -> {
progressDialog.dismiss();
if (!sameLang) {
actionBar.closeSearchField();
updateLanguage();
}
});
if (reqId != 0) {
progressDialog.setOnCancelListener(di -> {
ConnectionsManager.getInstance(currentAccount).cancelRequest(reqId, true);
});
}
String langCode = localeInfo.pluralLangCode,
prevLangCode = prevLocale.pluralLangCode;
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
HashSet<String> selectedLanguages = RestrictedLanguagesSelectActivity.getRestrictedLanguages();
HashSet<String> newSelectedLanguages = new HashSet<String>(selectedLanguages);
if (selectedLanguages.contains(langCode)) {
newSelectedLanguages.removeIf(s -> s != null && s.equals(langCode));
if (!selectedLanguages.contains(prevLangCode))
newSelectedLanguages.add(prevLangCode);
}
preferences.edit().putStringSet("translate_button_restricted_languages", newSelectedLanguages).apply();
if (!sameLang) {
progressDialog.showDelayed(500);
}
}
} catch (Exception e) {
FileLog.e(e);
LocaleController.getInstance().applyLanguage(localeInfo, true, false, false, true, currentAccount,()->{});
parentLayout.rebuildAllFragmentViews(false, false);
}
finishFragment();
});
// NekoX: Merge 8.4.1, Remove offcial changes
@ -379,42 +310,26 @@ public class LanguageSelectActivity extends BaseFragment implements Notification
listView.setAdapter(listAdapter);
}
} else {
// try {
// if (searchTimer != null) {
// searchTimer.cancel();
// }
// } catch (Exception e) {
// FileLog.e(e);
// }
// searchTimer = new Timer();
// searchTimer.schedule(new TimerTask() {
// @Override
// public void run() {
// try {
// searchTimer.cancel();
// searchTimer = null;
// } catch (Exception e) {
// FileLog.e(e);
// }
processSearch(query);
// }
// }, 100, 300);
}
}
private void updateLanguage() {
if (actionBar != null) {
actionBar.setTitleAnimated(LocaleController.getString("Language", R.string.Language), true, 350, CubicBezierInterpolator.EASE_OUT_QUINT);
}
if (listView != null) {
for (int i = 0; i < listView.getChildCount(); ++i) {
View child = listView.getChildAt(i);
if (child instanceof TranslateSettings || child instanceof HeaderCell) {
listAdapter.notifyItemChanged(listView.getChildAdapterPosition(child));
} else {
listAdapter.onBindViewHolder(listView.getChildViewHolder(child), listView.getChildAdapterPosition(child));
}
}
// try {
// if (searchTimer != null) {
// searchTimer.cancel();
// }
// } catch (Exception e) {
// FileLog.e(e);
// }
// searchTimer = new Timer();
// searchTimer.schedule(new TimerTask() {
// @Override
// public void run() {
// try {
// searchTimer.cancel();
// searchTimer = null;
// } catch (Exception e) {
// FileLog.e(e);
// }
processSearch(query);
// }
// }, 100, 300);
}
}
@ -539,19 +454,20 @@ public class LanguageSelectActivity extends BaseFragment implements Notification
switch (viewType) {
case 0: {
view = new LanguageCell(mContext);
// view = new TextRadioCell(mContext);
// view = new TextRadioCell(mContext);
view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
break;
}
// case 2:
// TranslateSettings translateSettings = new TranslateSettings(mContext);
// view = translateSettings;
// break;
// case 3:
// HeaderCell header = new HeaderCell(mContext);
// header.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
// view = header;
// break;
// case 2:
// TranslateSettings translateSettings = new TranslateSettings(mContext);
// view = translateSettings;
// break;
// case 3:
// HeaderCell header = new HeaderCell(mContext);
// header.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
// header.setText(LocaleController.getString("Language", R.string.Language));
// view = header;
// break;
case 1:
default: {
view = new ShadowSectionCell(mContext);
@ -565,16 +481,12 @@ public class LanguageSelectActivity extends BaseFragment implements Notification
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
switch (holder.getItemViewType()) {
case 0: {
if (!search) {
position -= 2;
}
LanguageCell textSettingsCell = (LanguageCell) holder.itemView;
LocaleController.LocaleInfo localeInfo = null;
// TextRadioCell textSettingsCell = (TextRadioCell) holder.itemView;
LocaleController.LocaleInfo localeInfo;
boolean last;
if (search) {
if (position >= 0 && position < searchResult.size()) {
localeInfo = searchResult.get(position);
}
localeInfo = searchResult.get(position);
last = position == searchResult.size() - 1;
} else if (!unofficialLanguages.isEmpty() && position >= 0 && position < unofficialLanguages.size()) {
localeInfo = unofficialLanguages.get(position);
@ -583,17 +495,13 @@ public class LanguageSelectActivity extends BaseFragment implements Notification
if (!unofficialLanguages.isEmpty()) {
position -= unofficialLanguages.size() + 1;
}
if (position >= 0 && position < sortedLanguages.size()) {
localeInfo = sortedLanguages.get(position);
}
localeInfo = sortedLanguages.get(position);
last = position == sortedLanguages.size() - 1;
}
if (localeInfo != null) {
if (localeInfo.isLocal()) {
textSettingsCell.setLanguage(LanguageSelectActivity.this, localeInfo, String.format("%1$s (%2$s)", localeInfo.name, LocaleController.getString("LanguageCustom", R.string.LanguageCustom)), !last);
} else {
textSettingsCell.setLanguage(LanguageSelectActivity.this, localeInfo, null, !last);
}
if (localeInfo.isLocal()) {
textSettingsCell.setLanguage(LanguageSelectActivity.this, localeInfo, String.format("%1$s (%2$s)", localeInfo.name, LocaleController.getString("LanguageCustom", R.string.LanguageCustom)), !last);
} else {
textSettingsCell.setLanguage(LanguageSelectActivity.this, localeInfo, null, !last);
}
textSettingsCell.setLanguageSelected(localeInfo == LocaleController.getInstance().getCurrentLocaleInfo(), true);
break;
@ -607,17 +515,6 @@ public class LanguageSelectActivity extends BaseFragment implements Notification
}
break;
}
case 2: {
// TranslateSettings translateSettings = (TranslateSettings) holder.itemView;
// translateSettings.setVisibility(searching ? View.GONE : View.VISIBLE);
// translateSettings.updateHeight();
break;
}
case 3: {
HeaderCell header = (HeaderCell) holder.itemView;
header.setText(LocaleController.getString("Language", R.string.Language));
break;
}
}
}

View File

@ -126,8 +126,8 @@ import org.telegram.ui.ActionBar.INavigationLayout;
import org.telegram.ui.ActionBar.SimpleTextView;
import org.telegram.ui.ActionBar.Theme;
import org.telegram.ui.Adapters.DrawerLayoutAdapter;
import org.telegram.ui.Cells.CheckBoxCell;
import org.telegram.ui.Cells.DrawerActionCheckCell;
import org.telegram.ui.Cells.CheckBoxCell;
import org.telegram.ui.Cells.DrawerActionCell;
import org.telegram.ui.Cells.DrawerAddCell;
import org.telegram.ui.Cells.DrawerProfileCell;
@ -2166,8 +2166,6 @@ public class LaunchActivity extends BasePermissionsActivity implements INavigati
messageId = Utilities.parseInt(segments.get(3));
}
}
} else if (path.startsWith("contact/")) {
contactToken = path.substring(8);
} else if (path.startsWith("@id")) {
try {
long userId = Utilities.parseLong(StringsKt.substringAfter(path, "@id", "0"));
@ -2177,6 +2175,8 @@ public class LaunchActivity extends BasePermissionsActivity implements INavigati
} catch (Exception e) {
FileLog.e(e);
}
} else if (path.startsWith("contact/")) {
contactToken = path.substring(8);
} else if (path.length() >= 1) {
ArrayList<String> segments = new ArrayList<>(data.getPathSegments());
if (segments.size() > 0 && segments.get(0).equals("s")) {
@ -2628,7 +2628,7 @@ public class LaunchActivity extends BasePermissionsActivity implements INavigati
if (message != null && message.startsWith("@")) {
message = " " + message;
}
runLinkRequest(intentAccount[0], username, group, sticker, emoji, botUser, botChat, botChannel, botChatAdminParams, message, contactToken, hasUrl, messageId, channelId, threadId, commentId, game, auth, lang, unsupportedUrl, code, login, wallPaper, inputInvoiceSlug, theme, voicechat, livestream, internal ? 3 : 0, videoTimestamp, setAsAttachBot, attachMenuBotToOpen, attachMenuBotChoose, progress);
runLinkRequest(intentAccount[0], username, group, sticker, emoji, botUser, botChat, botChannel, botChatAdminParams, message, contactToken, hasUrl, messageId, channelId, threadId, commentId, game, auth, lang, unsupportedUrl, code, login, wallPaper, inputInvoiceSlug, theme, voicechat, livestream, 0, videoTimestamp, setAsAttachBot, attachMenuBotToOpen, attachMenuBotChoose, progress);
} else {
try (Cursor cursor = getContentResolver().query(intent.getData(), null, null, null, null)) {
if (cursor != null) {
@ -3412,12 +3412,12 @@ public class LaunchActivity extends BasePermissionsActivity implements INavigati
progress.onCancel(() -> AndroidUtilities.cancelRunOnUIThread(runnable));
AndroidUtilities.runOnUIThread(runnable, 7500);
return;
} else if (state == 0 && UserConfig.getActivatedAccountsCount() >= 2) {
} else if (state == 0 && UserConfig.getActivatedAccountsCount() >= 2 && auth != null) {
AlertsCreator.createAccountSelectDialog(this, account -> {
if (account != intentAccount) {
switchToAccount(account, true);
}
runLinkRequest(account, username, group, sticker, emoji, botUser, botChat, botChannel, botChatAdminParams, message, contactToken, hasUrl, messageId, channelId, threadId, commentId, game, auth, lang, unsupportedUrl, code, loginToken, wallPaper, inputInvoiceSlug, theme, voicechat, livestream, 3, videoTimestamp, setAsAttachBot, attachMenuBotToOpen, attachMenuBotChoose, progress);
runLinkRequest(account, username, group, sticker, emoji, botUser, botChat, botChannel, botChatAdminParams, message, contactToken, hasUrl, messageId, channelId, threadId, commentId, game, auth, lang, unsupportedUrl, code, loginToken, wallPaper, inputInvoiceSlug, theme, voicechat, livestream, 1, videoTimestamp, setAsAttachBot, attachMenuBotToOpen, attachMenuBotChoose, progress);
}).show();
return;
} else if (code != null) {

View File

@ -42,7 +42,6 @@ import android.os.Build;
import android.os.Bundle;
import android.telephony.PhoneNumberUtils;
//import android.telephony.TelephonyManager;
import android.telephony.TelephonyManager;
import android.text.Editable;
import android.text.InputType;
import android.text.Spannable;
@ -2309,90 +2308,90 @@ public class LoginActivity extends BaseFragment implements NotificationCenter.No
req.lang_code = "";
getConnectionsManager().sendRequest(req, (response, error) -> {
AndroidUtilities.runOnUIThread(() -> {
if (error == null) {
countriesArray.clear();
codesMap.clear();
phoneFormatMap.clear();
AndroidUtilities.runOnUIThread(() -> {
if (error == null) {
countriesArray.clear();
codesMap.clear();
phoneFormatMap.clear();
TLRPC.TL_help_countriesList help_countriesList = (TLRPC.TL_help_countriesList) response;
for (int i = 0; i < help_countriesList.countries.size(); i++) {
TLRPC.TL_help_country c = help_countriesList.countries.get(i);
for (int k = 0; k < c.country_codes.size(); k++) {
TLRPC.TL_help_countryCode countryCode = c.country_codes.get(k);
if (countryCode != null) {
CountrySelectActivity.Country countryWithCode = new CountrySelectActivity.Country();
countryWithCode.name = c.default_name;
countryWithCode.code = countryCode.country_code;
countryWithCode.shortname = c.iso2;
TLRPC.TL_help_countriesList help_countriesList = (TLRPC.TL_help_countriesList) response;
for (int i = 0; i < help_countriesList.countries.size(); i++) {
TLRPC.TL_help_country c = help_countriesList.countries.get(i);
for (int k = 0; k < c.country_codes.size(); k++) {
TLRPC.TL_help_countryCode countryCode = c.country_codes.get(k);
if (countryCode != null) {
CountrySelectActivity.Country countryWithCode = new CountrySelectActivity.Country();
countryWithCode.name = c.default_name;
countryWithCode.code = countryCode.country_code;
countryWithCode.shortname = c.iso2;
countriesArray.add(countryWithCode);
List<CountrySelectActivity.Country> countryList = codesMap.get(countryCode.country_code);
if (countryList == null) {
codesMap.put(countryCode.country_code, countryList = new ArrayList<>());
}
countryList.add(countryWithCode);
if (countryCode.patterns.size() > 0) {
phoneFormatMap.put(countryCode.country_code, countryCode.patterns);
countriesArray.add(countryWithCode);
List<CountrySelectActivity.Country> countryList = codesMap.get(countryCode.country_code);
if (countryList == null) {
codesMap.put(countryCode.country_code, countryList = new ArrayList<>());
}
countryList.add(countryWithCode);
if (countryCode.patterns.size() > 0) {
phoneFormatMap.put(countryCode.country_code, countryCode.patterns);
}
}
}
}
}
CountrySelectActivity.Country countryWithCode = new CountrySelectActivity.Country();
String test_code = "999";
countryWithCode.name = "Test Number";
countryWithCode.code = test_code;
countryWithCode.shortname = "YL";
countriesArray.add(countryWithCode);
codesMap.put(test_code, countryWithCode);
List<String> testCodeStr = new ArrayList<>();
testCodeStr.add("XX X XXXX");
phoneFormatMap.put(test_code, testCodeStr);
if (activityMode == MODE_CHANGE_PHONE_NUMBER) {
String number = PhoneFormat.stripExceptNumbers(UserConfig.getInstance(currentAccount).getClientPhone());
boolean ok = false;
if (!TextUtils.isEmpty(number)) {
if (number.length() > 4) {
for (int a = 4; a >= 1; a--) {
String sub = number.substring(0, a);
if (activityMode == MODE_CHANGE_PHONE_NUMBER) {
String number = PhoneFormat.stripExceptNumbers(UserConfig.getInstance(currentAccount).getClientPhone());
boolean ok = false;
if (!TextUtils.isEmpty(number)) {
if (number.length() > 4) {
for (int a = 4; a >= 1; a--) {
String sub = number.substring(0, a);
CountrySelectActivity.Country country2;
List<CountrySelectActivity.Country> list = codesMap.get(sub);
if (list == null) {
country2 = null;
} else if (list.size() > 1) {
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
String lastMatched = preferences.getString("phone_code_last_matched_" + sub, null);
CountrySelectActivity.Country country2;
List<CountrySelectActivity.Country> list = codesMap.get(sub);
if (list == null) {
country2 = null;
} else if (list.size() > 1) {
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
String lastMatched = preferences.getString("phone_code_last_matched_" + sub, null);
if (lastMatched != null) {
country2 = list.get(list.size() - 1);
for (CountrySelectActivity.Country c : countriesArray) {
if (Objects.equals(c.shortname, lastMatched)) {
country2 = c;
break;
if (lastMatched != null) {
country2 = list.get(list.size() - 1);
for (CountrySelectActivity.Country c : countriesArray) {
if (Objects.equals(c.shortname, lastMatched)) {
country2 = c;
break;
}
}
} else {
country2 = list.get(list.size() - 1);
}
} else {
country2 = list.get(list.size() - 1);
country2 = list.get(0);
}
} else {
country2 = list.get(0);
}
if (country2 != null) {
ok = true;
codeField.setText(sub);
break;
if (country2 != null) {
ok = true;
codeField.setText(sub);
break;
}
}
if (!ok) {
codeField.setText(number.substring(0, 1));
}
}
if (!ok) {
codeField.setText(number.substring(0, 1));
}
}
}
CountrySelectActivity.Country countryWithCode = new CountrySelectActivity.Country();
String test_code = "999";
countryWithCode.name = "Test Number";
countryWithCode.code = test_code;
countryWithCode.shortname = "YL";
countriesArray.add(countryWithCode);
codesMap.put(test_code, new ArrayList<>(Collections.singletonList(countryWithCode)));
phoneFormatMap.put(test_code, Collections.singletonList("XX X XXXX"));
}
}
});
});
}, ConnectionsManager.RequestFlagWithoutLogin | ConnectionsManager.RequestFlagFailOnServerErrors);
}
@ -2808,68 +2807,61 @@ public class LoginActivity extends BaseFragment implements NotificationCenter.No
}
}
TLRPC.TL_codeSettings settings = new TLRPC.TL_codeSettings();
settings.allow_flashcall = simcardAvailable && allowCall && allowCancelCall && allowReadCallLog;
settings.allow_missed_call = simcardAvailable && allowCall;
settings.allow_app_hash = PushListenerController.getProvider().hasServices();
ConnectionsManager.getInstance(currentAccount).cleanup(false);
final TLRPC.TL_auth_sendCode req = new TLRPC.TL_auth_sendCode();
req.api_hash = NekoXConfig.currentAppHash();
req.api_id = NekoXConfig.currentAppId();
req.phone_number = phone;
req.settings = new TLRPC.TL_codeSettings();
req.settings.allow_flashcall = simcardAvailable && allowCall && allowCancelCall && allowReadCallLog;
req.settings.allow_missed_call = simcardAvailable && allowCall;
req.settings.allow_app_hash = PushListenerController.getProvider().hasServices();
ArrayList<TLRPC.TL_auth_loggedOut> tokens = MessagesController.getSavedLogOutTokens();
if (tokens != null) {
for (int i = 0; i < tokens.size(); i++) {
if (settings.logout_tokens == null) {
settings.logout_tokens = new ArrayList<>();
if (req.settings.logout_tokens == null) {
req.settings.logout_tokens = new ArrayList<>();
}
settings.logout_tokens.add(tokens.get(i).future_auth_token);
req.settings.logout_tokens.add(tokens.get(i).future_auth_token);
}
MessagesController.saveLogOutTokens(tokens);
}
if (settings.logout_tokens != null) {
settings.flags |= 64;
if (req.settings.logout_tokens != null) {
req.settings.flags |= 64;
}
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
preferences.edit().remove("sms_hash_code").apply();
if (settings.allow_app_hash) {
preferences.edit().putString("sms_hash", BuildVars.SMS_HASH).apply();
} else {
preferences.edit().remove("sms_hash").apply();
}
if (settings.allow_flashcall) {
req.settings.allow_app_hash = PushListenerController.getProvider().hasServices();
if (req.settings.allow_flashcall) {
try {
String number = tm.getLine1Number();
String number = "";
if (!TextUtils.isEmpty(number)) {
settings.current_number = PhoneNumberUtils.compare(phone, number);
if (!settings.current_number) {
settings.allow_flashcall = false;
req.settings.current_number = PhoneNumberUtils.compare(phone, number);
if (!req.settings.current_number) {
req.settings.allow_flashcall = false;
}
} else {
if (UserConfig.getActivatedAccountsCount() > 0) {
settings.allow_flashcall = false;
req.settings.allow_flashcall = false;
} else {
settings.current_number = false;
req.settings.current_number = false;
}
}
} catch (Exception e) {
settings.allow_flashcall = false;
req.settings.allow_flashcall = false;
FileLog.e(e);
}
}
TLObject req;
TLObject reqFinal;
if (activityMode == MODE_CHANGE_PHONE_NUMBER) {
TLRPC.TL_account_sendChangePhoneCode changePhoneCode = new TLRPC.TL_account_sendChangePhoneCode();
changePhoneCode.phone_number = phone;
changePhoneCode.settings = settings;
req = changePhoneCode;
changePhoneCode.settings = req.settings;
reqFinal = changePhoneCode;
} else {
ConnectionsManager.getInstance(currentAccount).cleanup(false);
TLRPC.TL_auth_sendCode sendCode = new TLRPC.TL_auth_sendCode();
sendCode.api_hash = NekoXConfig.currentAppHash();
sendCode.api_id = NekoXConfig.currentAppId();
sendCode.phone_number = phone;
sendCode.settings = settings;
req = sendCode;
reqFinal = req;
}
Bundle params = new Bundle();
@ -2937,7 +2929,7 @@ public class LoginActivity extends BaseFragment implements NotificationCenter.No
bundle.putString("phoneFormated", phone);
bundle.putString("phoneHash", phoneHash);
bundle.putString("code", reqI.phone_code);
setPage(6, true, bundle, false);
setPage(LoginActivity.VIEW_PASSWORD, true, bundle, false);
} else {
needShowAlert(LocaleController.getString("NekoX", R.string.NekoX), error1.text);
}
@ -3019,7 +3011,7 @@ public class LoginActivity extends BaseFragment implements NotificationCenter.No
return;
}
try {
TelephonyManager tm = (TelephonyManager) ApplicationLoader.applicationContext.getSystemService(Context.TELEPHONY_SERVICE);
// TelephonyManager tm = (TelephonyManager) ApplicationLoader.applicationContext.getSystemService(Context.TELEPHONY_SERVICE);
if (AndroidUtilities.isSimAvailable()) {
boolean allowCall = true;
boolean allowReadPhoneNumbers = true;
@ -3568,7 +3560,7 @@ public class LoginActivity extends BaseFragment implements NotificationCenter.No
mailer.putExtra(Intent.EXTRA_TEXT, "Phone: " + requestPhone + "\nApp version: " + version + "\nOS version: SDK " + Build.VERSION.SDK_INT + "\nDevice Name: " + Build.MANUFACTURER + Build.MODEL + "\nLocale: " + Locale.getDefault() + "\nError: " + lastError);
getContext().startActivity(Intent.createChooser(mailer, "Send email..."));
} catch (Exception e) {
needShowAlert(LocaleController.getString(R.string.NekoX), LocaleController.getString("NoMailInstalled", R.string.NoMailInstalled));
needShowAlert(LocaleController.getString(R.string.AppName), LocaleController.getString("NoMailInstalled", R.string.NoMailInstalled));
}
})
.setPositiveButton(LocaleController.getString(R.string.Close), null)

View File

@ -195,14 +195,12 @@ import org.telegram.ui.Components.CombinedDrawable;
import org.telegram.ui.Components.Crop.CropTransform;
import org.telegram.ui.Components.Crop.CropView;
import org.telegram.ui.Components.CubicBezierInterpolator;
import org.telegram.ui.Components.EmojiPacksAlert;
import org.telegram.ui.Components.FadingTextViewLayout;
import org.telegram.ui.Components.FilterShaders;
import org.telegram.ui.Components.FloatSeekBarAccessibilityDelegate;
import org.telegram.ui.Components.GestureDetector2;
import org.telegram.ui.Components.GroupedPhotosListView;
import org.telegram.ui.Components.HideViewAfterAnimation;
import org.telegram.ui.Components.IPhotoPaintView;
import org.telegram.ui.Components.ImageUpdater;
import org.telegram.ui.Components.LayoutHelper;
import org.telegram.ui.Components.LinkPath;
@ -210,10 +208,10 @@ import org.telegram.ui.Components.LinkSpanDrawable;
import org.telegram.ui.Components.MediaActivity;
import org.telegram.ui.Components.NumberPicker;
import org.telegram.ui.Components.OtherDocumentPlaceholderDrawable;
import org.telegram.ui.Components.Paint.Views.LPhotoPaintView;
import org.telegram.ui.Components.PaintingOverlay;
import org.telegram.ui.Components.PhotoCropView;
import org.telegram.ui.Components.PhotoFilterView;
import org.telegram.ui.Components.PhotoPaintView;
import org.telegram.ui.Components.PhotoViewerCaptionEnterView;
import org.telegram.ui.Components.PhotoViewerWebView;
import org.telegram.ui.Components.PickerBottomLayoutViewer;
@ -254,15 +252,14 @@ import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicBoolean;
import kotlin.Unit;
import tw.nekomimi.nekogram.NekoConfig;
import tw.nekomimi.nekogram.NekoXConfig;
import tw.nekomimi.nekogram.transtale.TranslateDb;
import tw.nekomimi.nekogram.transtale.Translator;
import tw.nekomimi.nekogram.transtale.TranslatorKt;
import tw.nekomimi.nekogram.ui.BottomBuilder;
import tw.nekomimi.nekogram.utils.AlertUtil;
import tw.nekomimi.nekogram.utils.ProxyUtil;
@ -394,7 +391,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
private MediaController.CropState leftCropState;
private MediaController.CropState rightCropState;
private PhotoFilterView photoFilterView;
private IPhotoPaintView photoPaintView;
private PhotoPaintView photoPaintView;
private AlertDialog visibleDialog;
private CaptionTextViewSwitcher captionTextViewSwitcher;
private CaptionScrollView captionScrollView;
@ -5741,8 +5738,6 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
} else if (a == 3) {
sendPressed(true, 0);
} else if (a == 4) {
translateComment(TranslateDb.getChatLanguage(chatId, TranslatorKt.getCode2Locale(NekoConfig.translateInputLang.String())));
} else if (a == 5) {
sendPressed(true, 0, false, true, false);
}
});
@ -10370,7 +10365,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
} else {
state = editState.cropState;
}
photoPaintView = new LPhotoPaintView(parentActivity, currentAccount, bitmap, isCurrentVideo ? null : centerImage.getBitmap(), centerImage.getOrientation(), editState.mediaEntities, state, () -> paintingOverlay.hideBitmap(), resourcesProvider) {
photoPaintView = new PhotoPaintView(parentActivity, bitmap, isCurrentVideo ? null : centerImage.getBitmap(), centerImage.getOrientation(), editState.mediaEntities, state, () -> paintingOverlay.hideBitmap(), resourcesProvider) {
@Override
protected void onOpenCloseStickersAlert(boolean open) {
if (videoPlayer == null) {
@ -10396,7 +10391,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
@Override
protected void onTextAdd() {
if (!windowView.isFocusable()) {
// makeFocusable();
makeFocusable();
}
}
};
@ -11570,7 +11565,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
MessagesController.getInstance(currentAccount).loadDialogPhotos(avatarsDialogId, 80, 0, true, classGuid);
}
}
if (currentMessageObject != null && currentMessageObject.isVideo() || (NekoConfig.takeGIFasVideo.Bool() && currentMessageObject != null && currentMessageObject.isGif()) || currentBotInlineResult != null && (currentBotInlineResult.type.equals("video") || MessageObject.isVideoDocument(currentBotInlineResult.document)) || (pageBlocksAdapter != null && pageBlocksAdapter.isVideo(index)) || (sendPhotoType == SELECT_TYPE_NO_SELECT && ((MediaController.PhotoEntry)imagesArrLocals.get(index)).isVideo)) {
if (currentMessageObject != null && currentMessageObject.isVideo() || currentBotInlineResult != null && (currentBotInlineResult.type.equals("video") || MessageObject.isVideoDocument(currentBotInlineResult.document)) || (pageBlocksAdapter != null && pageBlocksAdapter.isVideo(index)) || (sendPhotoType == SELECT_TYPE_NO_SELECT && ((MediaController.PhotoEntry)imagesArrLocals.get(index)).isVideo)) {
playerAutoStarted = true;
onActionClick(false);
} else if (!imagesArrLocals.isEmpty()) {
@ -13518,9 +13513,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
return openPhoto(null, null, null, null, null, null, null, index, provider, null, 0, 0, 0, true, pageBlocksAdapter, null);
}
public boolean openPhotoForSelect(final ArrayList<Object> photos, final int index,
int type, boolean documentsPicker, final PhotoViewerProvider provider, ChatActivity
chatActivity) {
public boolean openPhotoForSelect(final ArrayList<Object> photos, final int index, int type, boolean documentsPicker, final PhotoViewerProvider provider, ChatActivity chatActivity) {
return openPhotoForSelect(null, null, photos, index, type, documentsPicker, provider, chatActivity);
}
@ -15480,7 +15473,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
zoomAnimation = false;
containerView.invalidate();
}
public void zoomOut() {
animateTo(1f, 0, 0, false);
}
@ -17356,8 +17349,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
return new ByteArrayInputStream(output, 0, outPos);
}
private void processOpenVideo(final String videoPath, boolean muted, float start,
float end, int compressQality) {
private void processOpenVideo(final String videoPath, boolean muted, float start, float end, int compressQality) {
if (currentLoadingVideoRunnable != null) {
Utilities.globalQueue.cancelRunnable(currentLoadingVideoRunnable);
currentLoadingVideoRunnable = null;

View File

@ -192,6 +192,7 @@ import org.telegram.ui.Components.Premium.PremiumGradient;
import org.telegram.ui.Components.Premium.PremiumPreviewBottomSheet;
import org.telegram.ui.Components.Premium.ProfilePremiumCell;
import org.telegram.ui.Components.ProfileGalleryView;
import org.telegram.ui.Components.RLottieDrawable;
import org.telegram.ui.Components.RLottieImageView;
import org.telegram.ui.Components.RadialProgressView;
import org.telegram.ui.Components.Reactions.ReactionsLayoutInBubble;
@ -272,8 +273,8 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
private boolean sharedMediaLayoutAttached;
private SharedMediaLayout.SharedMediaPreloader sharedMediaPreloader;
// private RLottieDrawable cameraDrawable;
// private RLottieDrawable cellCameraDrawable;
private RLottieDrawable cameraDrawable;
private RLottieDrawable cellCameraDrawable;
private HintView fwdRestrictedHint;
private FrameLayout avatarContainer;
@ -4248,6 +4249,9 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
writeButton.setBackground(combinedDrawable);
if (userId != 0) {
if (imageUpdater != null) {
cameraDrawable = new RLottieDrawable(R.raw.camera_outline, String.valueOf(R.raw.camera_outline), AndroidUtilities.dp(56), AndroidUtilities.dp(56), false, null);
cellCameraDrawable = new RLottieDrawable(R.raw.camera_outline, R.raw.camera_outline + "_cell", AndroidUtilities.dp(42), AndroidUtilities.dp(42), false, null);
writeButton.setImageResource(R.drawable.baseline_edit_24);
writeButton.setContentDescription(LocaleController.getString("AccDescrChangeProfilePicture", R.string.AccDescrChangeProfilePicture));
writeButton.setPadding(AndroidUtilities.dp(2), 0, 0, AndroidUtilities.dp(2));
@ -4441,13 +4445,14 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
searchItem.setScaleY(1.0f - value);
searchItem.setVisibility(View.VISIBLE);
searchItem.setClickable(searchItem.getAlpha() > .5f);
if (qrItem != null) {
float translation = AndroidUtilities.dp(48) * value;
// if (searchItem.getVisibility() == View.VISIBLE)
// translation += AndroidUtilities.dp(48);
qrItem.setTranslationX(translation);
avatarsViewPagerIndicatorView.setTranslationX(translation - AndroidUtilities.dp(48));
}
// NekoX: Move official qrItem into bottom menu when click id
// if (qrItem != null) {
// float translation = AndroidUtilities.dp(48) * value;
// if (searchItem.getVisibility() == View.VISIBLE)
// translation += AndroidUtilities.dp(48);
// qrItem.setTranslationX(translation);
// avatarsViewPagerIndicatorView.setTranslationX(translation - AndroidUtilities.dp(48));
// }
}
if (extraHeight > AndroidUtilities.dp(88f) && expandProgress < 0.33f) {
@ -4488,10 +4493,19 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
final float onlineTextViewX = (1 - value) * (1 - value) * onlineX + 2 * (1 - value) * value * onlineTextViewCx + value * value * onlineTextViewXEnd;
final float onlineTextViewY = (1 - value) * (1 - value) * onlineY + 2 * (1 - value) * value * onlineTextViewCy + value * value * onlineTextViewYEnd;
final float idTextViewXEnd = AndroidUtilities.dpf2(16f) - idTextView.getLeft();
final float idTextViewYEnd = newTop + extraHeight - AndroidUtilities.dpf2(3f) - idTextView.getBottom();
final float idTextViewCx = k + idX + (idTextViewXEnd - idX) / 2f;
final float idTextViewCy = k + idY + (idTextViewYEnd - idY) / 2f;
final float idTextViewX = (1 - value) * (1 - value) * idX + 2 * (1 - value) * value * idTextViewCx + value * value * idTextViewXEnd;
final float idTextViewY = (1 - value) * (1 - value) * idY + 2 * (1 - value) * value * idTextViewCy + value * value * idTextViewYEnd;
nameTextView[1].setTranslationX(nameTextViewX);
nameTextView[1].setTranslationY(nameTextViewY);
onlineTextView[1].setTranslationX(onlineTextViewX + customPhotoOffset);
onlineTextView[1].setTranslationX(onlineTextViewX);
onlineTextView[1].setTranslationY(onlineTextViewY);
idTextView.setTranslationX(idTextViewX);
idTextView.setTranslationY(idTextViewY);
mediaCounterTextView.setTranslationX(onlineTextViewX);
mediaCounterTextView.setTranslationY(onlineTextViewY);
final Object onlineTextViewTag = onlineTextView[1].getTag();
@ -5962,7 +5976,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
scamDrawable.setColor(ColorUtils.blendARGB(getThemedColor(Theme.key_avatar_subtitleInProfileBlue), Color.argb(179, 255, 255, 255), avatarAnimationProgress));
}
if (lockIconDrawable != null) {
lockIconDrawable.setColorFilter(ColorUtils.blendARGB(getThemedColor(Theme.key_chat_lockIcon), Color.WHITE, avatarAnimationProgress), PorterDuff.Mode.SRC_IN);
lockIconDrawable.setColorFilter(ColorUtils.blendARGB(getThemedColor(Theme.key_chat_lockIcon), Color.WHITE, avatarAnimationProgress), PorterDuff.Mode.MULTIPLY);
}
if (verifiedCrossfadeDrawable != null) {
verifiedCrossfadeDrawable.setProgress(avatarAnimationProgress);
@ -7522,10 +7536,9 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
TLRPC.TL_forumTopic topic = null;
boolean shortStatus;
long id = 0;
hasFallbackPhoto = false;
hasCustomPhoto = false;
long id = 0;
if (userId != 0) {
TLRPC.User user = getMessagesController().getUser(userId);
if (user == null) {
@ -8062,10 +8075,9 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
createAutoDeleteItem(context);
}
if (isBot) {
otherItem.addSubItem(share, R.drawable.msg_share, LocaleController.getString("BotShare", R.string.BotShare));
if (!user.bot_nochats) {
otherItem.addSubItem(invite_to_group, R.drawable.baseline_group_add_24, LocaleController.getString("BotInvite", R.string.BotInvite));
}
// if (!user.bot_nochats) {
// otherItem.addSubItem(invite_to_group, R.drawable.baseline_group_add_24, LocaleController.getString("BotInvite", R.string.BotInvite));
// }
otherItem.addSubItem(share, R.drawable.baseline_forward_24, LocaleController.getString("BotShare", R.string.BotShare));
} else {
otherItem.addSubItem(add_contact, R.drawable.baseline_person_add_24, LocaleController.getString("AddContact", R.string.AddContact));
@ -8141,7 +8153,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
if (chat.megagroup) {
if (chatInfo == null || !chatInfo.participants_hidden || ChatObject.hasAdminRights(chat)) {
canSearchMembers = true;
otherItem.addSubItem(search_members, R.drawable.baseline_search_24, LocaleController.getString("SearchMembers", R.string.SearchMembers));
otherItem.addSubItem(search_members, R.drawable.msg_search, LocaleController.getString("SearchMembers", R.string.SearchMembers));
}
if (!chat.creator && !chat.left && !chat.kicked && !isTopic) {
otherItem.addSubItem(leave_group, R.drawable.baseline_exit_to_app_24, LocaleController.getString("LeaveMegaMenu", R.string.LeaveMegaMenu));
@ -8178,7 +8190,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
if (!ChatObject.isKickedFromChat(chat) && !ChatObject.isLeftFromChat(chat)) {
if (chatInfo == null || !chatInfo.participants_hidden || ChatObject.hasAdminRights(chat)) {
canSearchMembers = true;
otherItem.addSubItem(search_members, R.drawable.baseline_search_24, LocaleController.getString("SearchMembers", R.string.SearchMembers));
otherItem.addSubItem(search_members, R.drawable.msg_search, LocaleController.getString("SearchMembers", R.string.SearchMembers));
}
}
otherItem.addSubItem(leave_group, R.drawable.baseline_exit_to_app_24, LocaleController.getString("DeleteAndExit", R.string.DeleteAndExit));
@ -8615,9 +8627,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
}
@Override
public void didUploadPhoto(final TLRPC.InputFile photo, final TLRPC.InputFile video,
double videoStartTimestamp, String videoPath, TLRPC.PhotoSize bigSize,
final TLRPC.PhotoSize smallSize, boolean isVideo) {
public void didUploadPhoto(final TLRPC.InputFile photo, final TLRPC.InputFile video, double videoStartTimestamp, String videoPath, TLRPC.PhotoSize bigSize, final TLRPC.PhotoSize smallSize, boolean isVideo) {
AndroidUtilities.runOnUIThread(() -> {
if (photo != null || video != null) {
TLRPC.TL_photos_uploadProfilePhoto req = new TLRPC.TL_photos_uploadProfilePhoto();
@ -8769,7 +8779,6 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
AlertUtil.showToast(e);
}
}
private class ListAdapter extends RecyclerListView.SelectionAdapter {
@ -9003,15 +9012,13 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
case VIEW_TYPE_TEXT_DETAIL_MULTILINE:
case VIEW_TYPE_TEXT_DETAIL:
TextDetailCell detailCell = (TextDetailCell) holder.itemView;
if (position == usernameRow) {
Drawable drawable = ContextCompat.getDrawable(detailCell.getContext(), R.drawable.msg_qr_mini);
drawable.setColorFilter(new PorterDuffColorFilter(getThemedColor(Theme.key_switch2TrackChecked), PorterDuff.Mode.MULTIPLY));
detailCell.setImage(drawable, LocaleController.getString("GetQRCode", R.string.GetQRCode));
detailCell.setImageClickListener(ProfileActivity.this::onTextDetailCellImageClicked);
} else {
detailCell.setImage(null);
detailCell.setImageClickListener(null);
}
// if (position == usernameRow) {
// Drawable drawable = ContextCompat.getDrawable(detailCell.getContext(), R.drawable.msg_qr_mini);
// drawable.setColorFilter(new PorterDuffColorFilter(getThemedColor(Theme.key_switch2TrackChecked), PorterDuff.Mode.MULTIPLY));
// detailCell.setImage(drawable, LocaleController.getString("GetQRCode", R.string.GetQRCode));
// } else {
// detailCell.setImage(null);
// }
if (position == phoneRow) {
String text;
TLRPC.User user = getMessagesController().getUser(userId);

View File

@ -400,14 +400,41 @@ public class SessionsActivity extends BaseFragment implements NotificationCenter
});
builder.setCustomViewOffset(16);
builder.setView(frameLayout1);
}
builder.setPositiveButton(buttonText, (dialogInterface, option) -> {
if (getParentActivity() == null) {
return;
}
final AlertDialog progressDialog = new AlertDialog(getParentActivity(), AlertDialog.ALERT_TYPE_SPINNER);
progressDialog.setCanCancel(false);
progressDialog.show();
builder.setPositiveButton(buttonText, (dialogInterface, option) -> {
if (getParentActivity() == null) {
return;
if (currentType == 0) {
final TLRPC.TL_authorization authorization;
if (position >= otherSessionsStartRow && position < otherSessionsEndRow) {
authorization = (TLRPC.TL_authorization) sessions.get(position - otherSessionsStartRow);
} else {
authorization = (TLRPC.TL_authorization) passwordSessions.get(position - passwordSessionsStartRow);
}
final AlertDialog progressDialog = new AlertDialog(getParentActivity(), AlertDialog.ALERT_TYPE_SPINNER);
progressDialog.setCanCancel(false);
progressDialog.show();
TLRPC.TL_account_resetAuthorization req = new TLRPC.TL_account_resetAuthorization();
req.hash = authorization.hash;
ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
try {
progressDialog.dismiss();
} catch (Exception e) {
FileLog.e(e);
}
if (error == null) {
sessions.remove(authorization);
passwordSessions.remove(authorization);
updateRows();
if (listAdapter != null) {
listAdapter.notifyDataSetChanged();
}
}
}));
} else {
final TLRPC.TL_webAuthorization authorization = (TLRPC.TL_webAuthorization) sessions.get(position - otherSessionsStartRow);
TLRPC.TL_account_resetWebAuthorization req = new TLRPC.TL_account_resetWebAuthorization();
req.hash = authorization.hash;
ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
@ -427,15 +454,14 @@ public class SessionsActivity extends BaseFragment implements NotificationCenter
if (param[0]) {
MessagesController.getInstance(currentAccount).blockPeer(authorization.bot_id);
}
});
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));
}
});
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));
}
}
});

View File

@ -1093,7 +1093,7 @@ public class UsersSelectActivity extends BaseFragment implements NotificationCen
continue;
}
spansContainer.addSpan(span, true);
span.setOnClickListener(FilterUsersActivity.this);
span.setOnClickListener(UsersSelectActivity.this);
}
}
}