1
0
mirror of https://github.com/NekoX-Dev/NekoX.git synced 2024-11-27 04:29:44 +01:00
(cherry picked from commit 7cd71a8c0c)
This commit is contained in:
世界 2020-06-28 10:05:29 +00:00
parent abba7ef236
commit 2b22dbdb25
No known key found for this signature in database
GPG Key ID: CD109927C34A63C4
20 changed files with 160 additions and 122 deletions

View File

@ -203,7 +203,7 @@ public class ConnectionsManager extends BaseController {
int timezoneOffset = (TimeZone.getDefault().getRawOffset() + TimeZone.getDefault().getDSTSavings()) / 1000;
int layer = MessagesController.getMainSettings(currentAccount).getInt("layer",TLRPC.LAYER);
int layer = MessagesController.getMainSettings(currentAccount).getInt("layer", TLRPC.LAYER);
if (layer != TLRPC.LAYER) {
@ -486,11 +486,15 @@ public class ConnectionsManager extends BaseController {
}
public static void onConnectionStateChanged(final int state, final int currentAccount) {
AndroidUtilities.runOnUIThread(() -> {
getInstance(currentAccount).connectionState = state;
AccountInstance.getInstance(currentAccount).getNotificationCenter().postNotificationName(NotificationCenter.didUpdateConnectionState);
});
ProxySwitcher.didReceivedNotification(state);
try {
AndroidUtilities.runOnUIThread(() -> {
getInstance(currentAccount).connectionState = state;
ProxySwitcher.didReceivedNotification(state);
AccountInstance.getInstance(currentAccount).getNotificationCenter().postNotificationName(NotificationCenter.didUpdateConnectionState);
});
} catch (Exception e) {
FileLog.e(e);
}
}
public static void onLogout(final int currentAccount) {
@ -551,7 +555,9 @@ public class ConnectionsManager extends BaseController {
}
public static void onProxyError() {
NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.needShowAlert, 3);
AndroidUtilities.runOnUIThread(() -> {
NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.needShowAlert, 3);
});
}
public static void getHostByName(String hostName, long address) {
@ -661,10 +667,13 @@ public class ConnectionsManager extends BaseController {
public static native void native_applyDatacenterAddress(int currentAccount, int datacenterId, String ipAddress, int port);
public static native void native_setDatacenterAddress(int currentAccount, int datacenterId, String ipv4Address,String ipv6Address, int port);
public static native void native_setDatacenterAddress(int currentAccount, int datacenterId, String ipv4Address, String ipv6Address, int port);
public static native void native_setDatacenterPublicKey(int currentAccount, int datacenterId, String publicKey, long fingerprint);
public static native void native_saveDatacenters(int currentAccount);
public static native void native_setLayer(int currentAccount,int layer);
public static native void native_setLayer(int currentAccount, int layer);
public static native int native_getConnectionState(int currentAccount);

View File

@ -32,7 +32,6 @@ public class HeaderCell extends LinearLayout {
private TextView textView;
private TextView textView2;
private int height = 40;
public HeaderCell(Context context) {
this(context, Theme.key_windowBackgroundWhiteBlueHeader, 21, 15, false);
@ -48,7 +47,7 @@ public class HeaderCell extends LinearLayout {
}
public HeaderCell(Context context, String textColorKey, int padding, int topMargin, boolean text2,boolean bigTitle) {
public HeaderCell(Context context, String textColorKey, int padding, int topMargin, boolean text2, boolean bigTitle) {
super(context);
setOrientation(LinearLayout.VERTICAL);
@ -61,7 +60,6 @@ public class HeaderCell extends LinearLayout {
}
textView.setEllipsize(TextUtils.TruncateAt.END);
textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL);
textView.setMinHeight(AndroidUtilities.dp(height - topMargin));
textView.setTextColor(Theme.getColor(textColorKey));
textView.setTag(textColorKey);
addView(textView, LayoutHelper.createLinear(-1, -2));
@ -83,7 +81,7 @@ public class HeaderCell extends LinearLayout {
}
public void setHeight(int value) {
textView.setMinHeight(AndroidUtilities.dp(height = value) - ((LayoutParams) textView.getLayoutParams()).topMargin);
textView.setMinHeight(AndroidUtilities.dp(value) - ((LayoutParams) textView.getLayoutParams()).topMargin);
}
public void setEnabled(boolean value, ArrayList<Animator> animators) {
@ -108,6 +106,7 @@ public class HeaderCell extends LinearLayout {
public TextView getTextView() {
return textView;
}
public TextView getTextView2() {
return textView2;
}

View File

@ -292,7 +292,7 @@ public class TextCheckCell extends FrameLayout {
canvas.drawCircle(cx, cy, animatedRad, animationPaint);
}
if (needDivider) {
canvas.drawLine(LocaleController.isRTL ? 0 : AndroidUtilities.dp(20), getMeasuredHeight() - 3, getMeasuredWidth() - (LocaleController.isRTL ? AndroidUtilities.dp(20) : 0), getMeasuredHeight() - 3, Theme.dividerPaint);
canvas.drawLine(0, getMeasuredHeight() - 3, getMeasuredWidth(), getMeasuredHeight() - 3, Theme.dividerPaint);
}
}

View File

@ -63,6 +63,9 @@ public class TextDetailSettingsCell extends FrameLayout {
imageView.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_windowBackgroundWhiteGrayIcon), PorterDuff.Mode.SRC_IN));
imageView.setVisibility(GONE);
addView(imageView, LayoutHelper.createFrame(52, 52, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 8, 6, 8, 0));
setMultilineDetail(true);
}
@Override

View File

@ -479,7 +479,7 @@ public class ChannelCreateActivity extends BaseFragment implements NotificationC
}
};
avatarEditor.setScaleType(ImageView.ScaleType.CENTER);
avatarEditor.setImageResource(R.drawable.deproko_baseline_camera_26);
avatarEditor.setImageResource(R.drawable.baseline_camera_alt_24);
avatarEditor.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_actionBarDefaultIcon), PorterDuff.Mode.SRC_IN));
avatarEditor.setEnabled(false);

View File

@ -2069,10 +2069,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
actionModeViews.add(actionMode.addItemWithWidth(translate, R.drawable.ic_translate, AndroidUtilities.dp(54), LocaleController.getString("Delete", R.string.Translate)));
actionModeViews.add(actionMode.addItemWithWidth(delete, R.drawable.baseline_delete_24, AndroidUtilities.dp(54), LocaleController.getString("Delete", R.string.Delete)));
actionMode.getItem(edit).setVisibility(canEditMessagesCount == 1 && selectedMessagesIds[0].size() + selectedMessagesIds[1].size() == 1 ? View.VISIBLE : View.GONE);
actionMode.getItem(edit).setVisibility(View.GONE);
actionMode.getItem(copy).setVisibility(selectedMessagesCanCopyIds[0].size() + selectedMessagesCanCopyIds[1].size() != 0 ? View.VISIBLE : View.GONE);
actionMode.getItem(star).setVisibility(selectedMessagesCanStarIds[0].size() + selectedMessagesCanStarIds[1].size() != 0 ? View.VISIBLE : View.GONE);
actionMode.getItem(translate).setVisibility(canEditMessagesCount == 1 && selectedMessagesIds[0].size() + selectedMessagesIds[1].size() == 1 ? View.GONE : View.VISIBLE);
actionMode.getItem(star).setVisibility(View.GONE);
actionMode.getItem(delete).setVisibility(cantDeleteMessagesCount == 0 ? View.VISIBLE : View.GONE);
checkActionBarMenu();
@ -13247,13 +13246,21 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
public void fillActionModeMenu(Menu menu) {
if (menu.findItem(R.id.menu_bold) != null) {
return;
}
if (Build.VERSION.SDK_INT >= 23) {
menu.removeItem(android.R.id.shareText);
}
menu.clear();
menu.add(android.R.id.cut, android.R.id.cut,0,android.R.string.cut);
menu.add(android.R.id.copy, android.R.id.copy,1,android.R.string.copy);
menu.add(android.R.id.paste, android.R.id.paste, 2,android.R.string.paste);
menu.add(R.id.menu_translate, R.id.menu_translate, 5, LocaleController.getString("Translate", R.string.Translate));
SpannableStringBuilder stringBuilder = new SpannableStringBuilder(LocaleController.getString("Bold", R.string.Bold));

View File

@ -435,7 +435,7 @@ public class ChatEditActivity extends BaseFragment implements ImageUpdater.Image
}
};
avatarEditor.setScaleType(ImageView.ScaleType.CENTER);
avatarEditor.setImageResource(R.drawable.deproko_baseline_camera_26);
avatarEditor.setImageResource(R.drawable.baseline_camera_alt_24);
avatarEditor.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_actionBarDefaultIcon), PorterDuff.Mode.SRC_IN));
avatarEditor.setEnabled(false);
avatarEditor.setClickable(false);
@ -684,7 +684,7 @@ public class ChatEditActivity extends BaseFragment implements ImageUpdater.Image
if (ChatObject.isChannel(currentChat) && ChatObject.hasAdminRights(currentChat)) {
logCell = new TextCell(context);
logCell.setTextAndIcon(LocaleController.getString("EventLog", R.string.EventLog), R.drawable.baseline_content_paste_18, false);
logCell.setText(LocaleController.getString("EventLog", R.string.EventLog), false);
logCell.setBackgroundDrawable(Theme.getSelectorDrawable(false));
logCell.setOnClickListener(v -> presentFragment(new ChannelAdminLogActivity(currentChat)));
}
@ -900,7 +900,7 @@ public class ChatEditActivity extends BaseFragment implements ImageUpdater.Image
int reqId = getConnectionsManager().sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
TLRPC.TL_channels_channelParticipants res = (TLRPC.TL_channels_channelParticipants) response;
realAdminCount = res.count;
adminCell.setTextAndValueAndIcon(LocaleController.getString("ChannelAdministrators", R.string.ChannelAdministrators), String.format("%d", res.count), R.drawable.baseline_stars_18, true);
adminCell.setTextAndValue(LocaleController.getString("ChannelAdministrators", R.string.ChannelAdministrators), String.format("%d", res.count), true);
}));
getConnectionsManager().bindRequestToGuid(reqId, classGuid);
}
@ -1174,13 +1174,13 @@ public class ChatEditActivity extends BaseFragment implements ImageUpdater.Image
if (membersCell != null) {
if (info != null) {
if (isChannel) {
membersCell.setTextAndValueAndIcon(LocaleController.getString("ChannelSubscribers", R.string.ChannelSubscribers), String.format("%d", info.participants_count), R.drawable.baseline_group_24, true);
blockCell.setTextAndValueAndIcon(LocaleController.getString("ChannelBlacklist", R.string.ChannelBlacklist), String.format("%d", Math.max(info.banned_count, info.kicked_count)), R.drawable.actions_removed, logCell != null && logCell.getVisibility() == View.VISIBLE);
membersCell.setTextAndValue(LocaleController.getString("ChannelSubscribers", R.string.ChannelSubscribers), String.format("%d", info.participants_count), true);
blockCell.setTextAndValue(LocaleController.getString("ChannelBlacklist", R.string.ChannelBlacklist), String.format("%d", Math.max(info.banned_count, info.kicked_count)), logCell != null && logCell.getVisibility() == View.VISIBLE);
} else {
if (ChatObject.isChannel(currentChat)) {
membersCell.setTextAndValueAndIcon(LocaleController.getString("ChannelMembers", R.string.ChannelMembers), String.format("%d", info.participants_count), R.drawable.baseline_group_24, logCell != null && logCell.getVisibility() == View.VISIBLE);
membersCell.setTextAndValue(LocaleController.getString("ChannelMembers", R.string.ChannelMembers), String.format("%d", info.participants_count), logCell != null && logCell.getVisibility() == View.VISIBLE);
} else {
membersCell.setTextAndValueAndIcon(LocaleController.getString("ChannelMembers", R.string.ChannelMembers), String.format("%d", info.participants.participants.size()), R.drawable.baseline_group_24, logCell != null && logCell.getVisibility() == View.VISIBLE);
membersCell.setTextAndValue(LocaleController.getString("ChannelMembers", R.string.ChannelMembers), String.format("%d", info.participants.participants.size()), logCell != null && logCell.getVisibility() == View.VISIBLE);
}
int count = 0;
if (currentChat.default_banned_rights != null) {
@ -1214,13 +1214,13 @@ public class ChatEditActivity extends BaseFragment implements ImageUpdater.Image
} else {
count = 9;
}
blockCell.setTextAndValueAndIcon(LocaleController.getString("ChannelPermissions", R.string.ChannelPermissions), count + " / 9", R.drawable.baseline_block_24, true);
blockCell.setTextAndValue(LocaleController.getString("ChannelPermissions", R.string.ChannelPermissions), count + " / 9", true);
}
if (info.participants != null) {
if (ChatObject.isChannel(currentChat) && !ChatObject.hasAdminRights(currentChat) && info.participants.participants.size() != info.participants_count && realAdminCount == 0) {
adminCell.setTextAndIcon(LocaleController.getString("ChannelAdministrators", R.string.ChannelAdministrators), R.drawable.baseline_stars_18, true);
adminCell.setText(LocaleController.getString("ChannelAdministrators", R.string.ChannelAdministrators), true);
} else {
adminCell.setTextAndValueAndIcon(LocaleController.getString("ChannelAdministrators", R.string.ChannelAdministrators), String.format("%d", ChatObject.isChannel(currentChat) ? ChatObject.hasAdminRights(currentChat) ? info.admins_count : realAdminCount == 0 ? getChannelAdminCount() : realAdminCount : getAdminCount()), R.drawable.baseline_stars_18, true);
adminCell.setTextAndValue(LocaleController.getString("ChannelAdministrators", R.string.ChannelAdministrators), String.format("%d", ChatObject.isChannel(currentChat) ? ChatObject.hasAdminRights(currentChat) ? info.admins_count : realAdminCount == 0 ? getChannelAdminCount() : realAdminCount : getAdminCount()), true);
}
if (ChatObject.isChannel(currentChat) && !ChatObject.hasAdminRights(currentChat) && info.participants.participants.size() != info.participants_count) {
getRealChannelAdminCount();
@ -1228,13 +1228,13 @@ public class ChatEditActivity extends BaseFragment implements ImageUpdater.Image
}
} else {
if (isChannel) {
membersCell.setTextAndIcon(LocaleController.getString("ChannelSubscribers", R.string.ChannelSubscribers), R.drawable.baseline_group_24, true);
blockCell.setTextAndIcon(LocaleController.getString("ChannelBlacklist", R.string.ChannelBlacklist), R.drawable.actions_removed, logCell != null && logCell.getVisibility() == View.VISIBLE);
membersCell.setText(LocaleController.getString("ChannelSubscribers", R.string.ChannelSubscribers), true);
blockCell.setText(LocaleController.getString("ChannelBlacklist", R.string.ChannelBlacklist), logCell != null && logCell.getVisibility() == View.VISIBLE);
} else {
membersCell.setTextAndIcon(LocaleController.getString("ChannelMembers", R.string.ChannelMembers), R.drawable.baseline_group_24, logCell != null && logCell.getVisibility() == View.VISIBLE);
blockCell.setTextAndIcon(LocaleController.getString("ChannelPermissions", R.string.ChannelPermissions), R.drawable.baseline_block_24, true);
membersCell.setText(LocaleController.getString("ChannelMembers", R.string.ChannelMembers), logCell != null && logCell.getVisibility() == View.VISIBLE);
blockCell.setText(LocaleController.getString("ChannelPermissions", R.string.ChannelPermissions), true);
}
adminCell.setTextAndIcon(LocaleController.getString("ChannelAdministrators", R.string.ChannelAdministrators), R.drawable.baseline_stars_18, true);
adminCell.setText(LocaleController.getString("ChannelAdministrators", R.string.ChannelAdministrators), true);
}
}

View File

@ -16,43 +16,49 @@ import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import androidx.exifinterface.media.ExifInterface;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.provider.MediaStore;
import androidx.core.content.FileProvider;
import androidx.exifinterface.media.ExifInterface;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.BuildConfig;
import org.telegram.messenger.FileLoader;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.ImageLoader;
import org.telegram.messenger.ImageLocation;
import org.telegram.messenger.ImageReceiver;
import org.telegram.messenger.LocaleController;
import org.telegram.messenger.MediaController;
import org.telegram.messenger.MessagesController;
import org.telegram.messenger.NotificationCenter;
import org.telegram.messenger.R;
import org.telegram.messenger.SendMessagesHelper;
import org.telegram.messenger.UserConfig;
import org.telegram.messenger.Utilities;
import org.telegram.messenger.VideoEditedInfo;
import org.telegram.tgnet.ConnectionsManager;
import org.telegram.tgnet.TLRPC;
import org.telegram.messenger.FileLoader;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.NotificationCenter;
import org.telegram.messenger.UserConfig;
import org.telegram.ui.ActionBar.BaseFragment;
import org.telegram.ui.ActionBar.BottomSheet;
import org.telegram.ui.ActionBar.Theme;
import org.telegram.ui.LaunchActivity;
import org.telegram.ui.PhotoAlbumPickerActivity;
import org.telegram.ui.PhotoCropActivity;
import org.telegram.ui.ActionBar.BaseFragment;
import org.telegram.ui.PhotoPickerActivity;
import org.telegram.ui.PhotoViewer;
import org.telegram.ui.SettingsActivity;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import kotlin.Unit;
import tw.nekomimi.nekogram.BottomBuilder;
public class ImageUpdater implements NotificationCenter.NotificationCenterDelegate, PhotoCropActivity.PhotoEditActivityDelegate {
public BaseFragment parentFragment;
@ -96,41 +102,58 @@ public class ImageUpdater implements NotificationCenter.NotificationCenterDelega
if (parentFragment == null || parentFragment.getParentActivity() == null) {
return;
}
BottomSheet.Builder builder = new BottomSheet.Builder(parentFragment.getParentActivity());
builder.setTitle(LocaleController.getString("ChoosePhoto", R.string.ChoosePhoto), true);
BottomBuilder builder = new BottomBuilder(parentFragment.getParentActivity());
CharSequence[] items;
int[] icons;
if (hasAvatar && parentFragment instanceof SettingsActivity) {
builder.addItem(LocaleController.getString("Open", R.string.Open), R.drawable.baseline_visibility_24, __ -> {
TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(UserConfig.getInstance(currentAccount).getClientUserId());
if (user != null && user.photo != null && user.photo.photo_big != null) {
PhotoViewer.getInstance().setParentActivity(parentFragment.getParentActivity());
if (user.photo.dc_id != 0) {
user.photo.photo_big.dc_id = user.photo.dc_id;
}
PhotoViewer.getInstance().openPhoto(user.photo.photo_big, ((SettingsActivity) parentFragment).provider);
}
return Unit.INSTANCE;
});
if (searchAvailable) {
if (hasAvatar) {
items = new CharSequence[]{LocaleController.getString("ChooseTakePhoto", R.string.ChooseTakePhoto), LocaleController.getString("ChooseFromGallery", R.string.ChooseFromGallery), LocaleController.getString("ChooseFromSearch", R.string.ChooseFromSearch), LocaleController.getString("DeletePhoto", R.string.DeletePhoto)};
icons = new int[]{R.drawable.deproko_baseline_camera_26, R.drawable.baseline_image_24, R.drawable.baseline_search_24, R.drawable.baseline_delete_24};
} else {
items = new CharSequence[]{LocaleController.getString("ChooseTakePhoto", R.string.ChooseTakePhoto), LocaleController.getString("ChooseFromGallery", R.string.ChooseFromGallery), LocaleController.getString("ChooseFromSearch", R.string.ChooseFromSearch)};
icons = new int[]{R.drawable.deproko_baseline_camera_26, R.drawable.baseline_image_24, R.drawable.baseline_search_24};
}
} else {
if (hasAvatar) {
items = new CharSequence[]{LocaleController.getString("ChooseTakePhoto", R.string.ChooseTakePhoto), LocaleController.getString("ChooseFromGallery", R.string.ChooseFromGallery), LocaleController.getString("DeletePhoto", R.string.DeletePhoto)};
icons = new int[]{R.drawable.deproko_baseline_camera_26, R.drawable.baseline_image_24, R.drawable.baseline_delete_24};
} else {
items = new CharSequence[]{LocaleController.getString("ChooseTakePhoto", R.string.ChooseTakePhoto), LocaleController.getString("ChooseFromGallery", R.string.ChooseFromGallery)};
icons = new int[]{R.drawable.deproko_baseline_camera_26, R.drawable.baseline_image_24};
}
}
builder.setItems(items, icons, (dialogInterface, i) -> {
if (i == 0) {
openCamera();
} else if (i == 1) {
openGallery();
} else if (searchAvailable && i == 2) {
openSearch();
} else if (searchAvailable && i == 3 || i == 2) {
onDeleteAvatar.run();
}
builder.addItem(LocaleController.getString("ChooseTakePhoto", R.string.ChooseTakePhoto), R.drawable.baseline_camera_alt_24, __ -> {
openCamera();
;
return Unit.INSTANCE;
});
builder.addItem(LocaleController.getString("ChooseFromGallery", R.string.ChooseFromGallery), R.drawable.baseline_image_24, __ -> {
openGallery();
;
return Unit.INSTANCE;
});
if (searchAvailable) {
builder.addItem(LocaleController.getString("ChooseFromSearch", R.string.ChooseFromSearch), R.drawable.baseline_search_24, __ -> {
openSearch();
;
return Unit.INSTANCE;
});
}
if (hasAvatar) {
builder.addItem(LocaleController.getString("DeletePhoto", R.string.DeletePhoto), R.drawable.baseline_delete_24, true, __ -> {
onDeleteAvatar.run();
return Unit.INSTANCE;
});
}
BottomSheet sheet = builder.create();
parentFragment.showDialog(sheet);
sheet.setItemColor(searchAvailable ? 3 : 2, Theme.getColor(Theme.key_dialogTextRed2), Theme.getColor(Theme.key_dialogRedIcon));

View File

@ -67,7 +67,7 @@ public class WallpaperUpdater {
icons = null;
} else {
items = new CharSequence[]{LocaleController.getString("ChooseTakePhoto", R.string.ChooseTakePhoto), LocaleController.getString("SelectFromGallery", R.string.SelectFromGallery)};
icons = new int[]{R.drawable.deproko_baseline_camera_26, R.drawable.baseline_image_24};
icons = new int[]{R.drawable.baseline_camera_alt_24, R.drawable.baseline_image_24};
}
builder.setItems(items, icons, (dialogInterface, i) -> {

View File

@ -357,7 +357,7 @@ public class FiltersSetupActivity extends BaseFragment implements NotificationCe
@Override
protected void onDraw(Canvas canvas) {
if (needDivider) {
canvas.drawLine(LocaleController.isRTL ? 0 : AndroidUtilities.dp(62), getMeasuredHeight() - 1, getMeasuredWidth() - (LocaleController.isRTL ? AndroidUtilities.dp(62) : 0), getMeasuredHeight() - 1, Theme.dividerPaint);
canvas.drawLine(0, getMeasuredHeight() - 1, getMeasuredWidth(), getMeasuredHeight() - 1, Theme.dividerPaint);
}
}

View File

@ -357,7 +357,7 @@ public class LoginActivity extends BaseFragment implements NotificationCenter.No
needFinishActivity(false);
} else {
if (error.code == 401) {
ConnectionsManager.native_cleanUp(currentAccount,true);
ConnectionsManager.native_cleanUp(currentAccount, true);
}
if (error.text != null) {
if (error.text.contains("ACCESS_TOKEN_INVALID")) {
@ -552,11 +552,11 @@ public class LoginActivity extends BaseFragment implements NotificationCenter.No
int dcType;
if (ConnectionsManager.native_isTestBackend(currentAccount) != 0) {
if (ConnectionsManager.native_isTestBackend(currentAccount) != 0) {
dcType = 1;
} else if (MessagesController.getMainSettings(currentAccount).getBoolean("custom_dc", false)) {
dcType = 2;
} else {
dcType = 2;
} else {
dcType = 0;
}
@ -920,14 +920,17 @@ public class LoginActivity extends BaseFragment implements NotificationCenter.No
Locale current = ConfigurationCompat.getLocales(getParentActivity().getResources().getConfiguration()).get(0);
if (NekoXConfig.developerMode || !"cn".equals(current.getCountry().toLowerCase())) {
boolean disableAdvOptions = !NekoXConfig.developerMode && "cn".equals(current.getCountry().toLowerCase());
if (!disableAdvOptions) {
otherItem.addSubItem(4, R.drawable.list_bot, LocaleController.getString("BotLogin", R.string.BotLogin));
}
otherItem.addSubItem(menu_custom_api, R.drawable.baseline_vpn_key_24, LocaleController.getString("CustomApi", R.string.CustomApi));
otherItem.addSubItem(menu_custom_dc, R.drawable.baseline_sync_24,LocaleController.getString("CustomBackend", R.string.CustomBackend));
if (!disableAdvOptions) {
otherItem.addSubItem(menu_custom_dc, R.drawable.baseline_sync_24, LocaleController.getString("CustomBackend", R.string.CustomBackend));
}
actionBar.setAllowOverlayTitle(true);
doneItem = menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));

View File

@ -3494,7 +3494,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
menuItem.addSubItem(gallery_menu_save, R.drawable.baseline_image_24, LocaleController.getString("SaveToGallery", R.string.SaveToGallery)).setColors(0xfffafafa, 0xfffafafa);
menuItem.addSubItem(gallery_menu_scan, R.drawable.wallet_qr, LocaleController.getString("ScanQRCode", R.string.ScanQRCode)).setColors(0xfffafafa, 0xfffafafa);
menuItem.addSubItem(gallery_menu_setascurrent, R.drawable.deproko_baseline_camera_26, LocaleController.getString("SetAsCurrent", R.string.SetAsCurrent)).setColors(0xfffafafa, 0xfffafafa);
menuItem.addSubItem(gallery_menu_setascurrent, R.drawable.baseline_camera_alt_24, LocaleController.getString("SetAsCurrent", R.string.SetAsCurrent)).setColors(0xfffafafa, 0xfffafafa);
menuItem.addSubItem(gallery_menu_delete, R.drawable.baseline_delete_24, LocaleController.getString("Delete", R.string.Delete)).setColors(0xfffafafa, 0xfffafafa);
menuItem.addSubItem(gallery_menu_cancel_loading, R.drawable.baseline_cancel_24, LocaleController.getString("StopDownload", R.string.StopDownload)).setColors(0xfffafafa, 0xfffafafa);

View File

@ -113,7 +113,6 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.Locale;
import java.util.Set;
import cn.hutool.core.util.RuntimeUtil;
@ -247,7 +246,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
}
}
private PhotoViewer.PhotoViewerProvider provider = new PhotoViewer.EmptyPhotoViewerProvider() {
public PhotoViewer.PhotoViewerProvider provider = new PhotoViewer.EmptyPhotoViewerProvider() {
@Override
public PhotoViewer.PlaceProviderObject getPlaceForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation, int index, boolean needPreview) {
@ -371,8 +370,8 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
otherItem = menu.addItem(0, R.drawable.ic_ab_other);
otherItem.setContentDescription(LocaleController.getString("AccDescrMoreOptions", R.string.AccDescrMoreOptions));
otherItem.addSubItem(edit_name, R.drawable.baseline_edit_24, LocaleController.getString("EditName", R.string.EditName));
otherItem.addSubItem(logout, R.drawable.baseline_exit_to_app_24, LocaleController.getString("LogOut", R.string.LogOut));
// otherItem.addSubItem(edit_name, R.drawable.baseline_edit_24, LocaleController.getString("EditName", R.string.EditName));
otherItem.addSubItem(logout, LocaleController.getString("LogOut", R.string.LogOut));
int scrollTo;
int scrollToPosition = 0;
@ -525,7 +524,8 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
if (!BuildVars.isMini) {
message += "\n" + Libv2ray.checkVersionX();
}
} catch (Exception ignored) {}
} catch (Exception ignored) {
}
builder.addTitle(message);
String finalMessage = message;
builder.addItem(LocaleController.getString("Copy", R.string.Copy), R.drawable.baseline_content_copy_24, (it) -> {
@ -726,17 +726,14 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
avatarContainer.setPivotY(0);
frameLayout.addView(avatarContainer, LayoutHelper.createFrame(42, 42, Gravity.TOP | Gravity.LEFT, 64, 0, 0, 0));
avatarContainer.setOnClickListener(v -> {
if (avatar != null) {
TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(UserConfig.getInstance(currentAccount).getClientUserId());
if (user == null) {
user = UserConfig.getInstance(currentAccount).getCurrentUser();
}
if (user == null) {
return;
}
TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(UserConfig.getInstance(currentAccount).getClientUserId());
if (user != null && user.photo != null && user.photo.photo_big != null) {
PhotoViewer.getInstance().setParentActivity(getParentActivity());
if (user.photo.dc_id != 0) {
user.photo.photo_big.dc_id = user.photo.dc_id;
}
PhotoViewer.getInstance().openPhoto(user.photo.photo_big, provider);
}
imageUpdater.openMenu(user.photo != null && user.photo.photo_big != null && !(user.photo instanceof TLRPC.TL_userProfilePhotoEmpty), () -> MessagesController.getInstance(currentAccount).deleteUserPhoto(null));
});
avatarImage = new BackupImageView(context);
@ -817,7 +814,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
}
writeButton.setBackgroundDrawable(drawable);
writeButton.setImageResource(R.drawable.baseline_edit_24);
writeButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_actionBarDefaultSubmenuItemIcon), PorterDuff.Mode.SRC_IN));
writeButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_profile_actionIcon), PorterDuff.Mode.SRC_IN));
writeButton.setScaleType(ImageView.ScaleType.CENTER);
if (Build.VERSION.SDK_INT >= 21) {
StateListAnimator animator = new StateListAnimator();
@ -834,16 +831,8 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
}
frameLayout.addView(writeButton, LayoutHelper.createFrame(Build.VERSION.SDK_INT >= 21 ? 56 : 60, Build.VERSION.SDK_INT >= 21 ? 56 : 60, Gravity.RIGHT | Gravity.TOP, 0, 0, 16, 0));
writeButton.setOnClickListener(v -> {
TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(UserConfig.getInstance(currentAccount).getClientUserId());
if (user == null) {
user = UserConfig.getInstance(currentAccount).getCurrentUser();
}
if (user == null) {
return;
}
imageUpdater.openMenu(user.photo != null && user.photo.photo_big != null && !(user.photo instanceof TLRPC.TL_userProfilePhotoEmpty), () -> MessagesController.getInstance(currentAccount).deleteUserPhoto(null));
presentFragment(new ChangeNameActivity());
});
writeButton.setContentDescription(LocaleController.getString("AccDescrChangeProfilePicture", R.string.AccDescrChangeProfilePicture));
if (scrollTo != -1) {
layoutManager.scrollToPositionWithOffset(scrollTo, scrollToPosition);

View File

@ -472,7 +472,7 @@ public class StickersActivity extends BaseFragment implements NotificationCenter
BottomBuilder builder = new BottomBuilder(getParentActivity());
builder.addTitle(LocaleController.getString("", R.string.ExportStickers), true);
builder.addTitle(LocaleController.getString("ExportStickers", R.string.ExportStickers), true);
AtomicBoolean exportSets = new AtomicBoolean(true);
AtomicBoolean exportArchived = new AtomicBoolean(true);

View File

@ -10,7 +10,10 @@ import org.telegram.messenger.LocaleController
import org.telegram.messenger.R
import org.telegram.ui.ActionBar.BottomSheet
import org.telegram.ui.ActionBar.Theme
import org.telegram.ui.Cells.*
import org.telegram.ui.Cells.HeaderCell
import org.telegram.ui.Cells.RadioButtonCell
import org.telegram.ui.Cells.TextCell
import org.telegram.ui.Cells.TextCheckCell
import org.telegram.ui.Components.LayoutHelper
import java.util.*
@ -80,7 +83,11 @@ class BottomBuilder(val ctx: Context) {
fun addTitle(title: CharSequence, bigTitle: Boolean, subTitle: CharSequence?): HeaderCell {
val headerCell = HeaderCell(ctx)
val headerCell = if (bigTitle) {
HeaderCell(ctx, Theme.key_dialogTextBlue2, 23, 15, false, true)
} else {
HeaderCell(ctx, Theme.key_dialogTextGray2, 16, 12, false)
}
headerCell.setText(if (title is String) AndroidUtilities.replaceTags(title) else title)
@ -92,12 +99,10 @@ class BottomBuilder(val ctx: Context) {
rootView.addView(headerCell, LayoutHelper.createLinear(-1, -2).apply {
bottomMargin = AndroidUtilities.dp(12F)
bottomMargin = AndroidUtilities.dp(8F)
})
rootView.addView(ShadowSectionCell(ctx, 3))
return headerCell
}
@ -282,7 +287,7 @@ class BottomBuilder(val ctx: Context) {
background = Theme.getSelectorDrawable(false)
setTextAndIcon(text, icon, true)
setTextAndIcon(text, icon, false)
setOnClickListener {

View File

@ -122,7 +122,7 @@ public class ExternalGcm {
BottomBuilder builder = new BottomBuilder(ctx);
builder.addTitle(LocaleController.getString("UpdateDownloaded", R.string.UpdateDownloaded), false);
builder.addTitle(LocaleController.getString("UpdateDownloaded", R.string.UpdateDownloaded));
builder.addItem(LocaleController.getString("UpdateUpdate", R.string.UpdateUpdate), R.drawable.baseline_system_update_24, false, (it) -> {

View File

@ -1,5 +1,6 @@
package tw.nekomimi.nekogram.parts
import org.telegram.messenger.AndroidUtilities
import org.telegram.messenger.SharedConfig
import org.telegram.tgnet.ConnectionsManager
import tw.nekomimi.nekogram.NekoConfig
@ -12,7 +13,6 @@ object ProxySwitcher {
val switchTimer by lazy { Timer("Proxy Switch Timer") }
var currentTask: SwitchTask? = null
fun cancel() {
currentTask = null
@ -23,14 +23,14 @@ object ProxySwitcher {
fun reschedule() {
cancel()
switchTimer.schedule(SwitchTask().also { currentTask = it }, 3000L)
switchTimer.schedule(SwitchTask().also { currentTask = it }, 3333L)
}
@JvmStatic
fun didReceivedNotification(connectionState: Int) = UIUtil.runOnIoDispatcher run@{
fun didReceivedNotification(connectionState: Int) {
if (!NekoConfig.proxyAutoSwitch) return@run
if (!NekoConfig.proxyAutoSwitch) return
currentConnectionState = connectionState

View File

@ -112,7 +112,7 @@ fun Activity.checkUpdate(force: Boolean = false) {
val builder = BottomBuilder(this)
builder.addTitle(LocaleController.getString("UpdateDownloaded", R.string.UpdateDownloaded), false)
builder.addTitle(LocaleController.getString("UpdateDownloaded", R.string.UpdateDownloaded))
builder.addItem(LocaleController.getString("UpdateUpdate", R.string.UpdateUpdate), R.drawable.baseline_system_update_24, false) {

View File

@ -711,7 +711,7 @@ public class NekoGeneralSettingsActivity extends BaseFragment {
}
textCell.setTextAndValue(LocaleController.getString("ActionBarDecoration", R.string.ActionBarDecoration), value, false);
} else if (position == sortMenuRow) {
textCell.setText(LocaleController.getString("SortMenu", R.string.SortMenu), true);
textCell.setText(LocaleController.getString("SortMenu", R.string.SortMenu), false);
} else if (position == translateToLangRow) {
textCell.setTextAndValue(LocaleController.getString("TransToLang", R.string.TransToLang), NekoConfig.formatLang(NekoConfig.translateToLang), true);
} else if (position == translateInputToLangRow) {
@ -734,14 +734,14 @@ public class NekoGeneralSettingsActivity extends BaseFragment {
default:
value = "Unknown";
}
textCell.setTextAndValue(LocaleController.getString("TranslationProvider", R.string.TranslationProvider), value, true);
textCell.setTextAndValue(LocaleController.getString("TranslationProvider", R.string.TranslationProvider), value, false);
}
break;
}
case 6: {
TextDetailSettingsCell textCell = (TextDetailSettingsCell) holder.itemView;
if (position == googleCloudTranslateKeyRow) {
textCell.setTextAndValue(LocaleController.getString("GoogleCloudTransKey", R.string.GoogleCloudTransKey), StrUtil.isNotBlank(NekoConfig.googleCloudTranslateKey) ? NekoConfig.googleCloudTranslateKey : LocaleController.getString("GoogleCloudTransKeyNotice", R.string.GoogleCloudTransKeyNotice), true);
textCell.setTextAndValue(LocaleController.getString("GoogleCloudTransKey", R.string.GoogleCloudTransKey), StrUtil.isNotBlank(NekoConfig.googleCloudTranslateKey) ? NekoConfig.googleCloudTranslateKey : LocaleController.getString("GoogleCloudTransKeyNotice", R.string.GoogleCloudTransKeyNotice), false);
} else if (position == cachePathRow) {
textCell.setTextAndValue(LocaleController.getString("CachePath", R.string.CachePath), NekoConfig.cachePath, true);
}
@ -781,7 +781,7 @@ public class NekoGeneralSettingsActivity extends BaseFragment {
} else if (position == openArchiveOnPullRow) {
textCell.setTextAndCheck(LocaleController.getString("OpenArchiveOnPull", R.string.OpenArchiveOnPull), NekoConfig.openArchiveOnPull, true);
} else if (position == disableSystemAccountRow) {
textCell.setTextAndCheck(LocaleController.getString("DisableSystemAccount", R.string.DisableSystemAccount), NekoConfig.disableSystemAccount, true);
textCell.setTextAndCheck(LocaleController.getString("DisableSystemAccount", R.string.DisableSystemAccount), NekoConfig.disableSystemAccount, false);
} else if (position == avatarAsDrawerBackgroundRow) {
textCell.setTextAndCheck(LocaleController.getString("UseAvatarAsDrawerBackground", R.string.UseAvatarAsDrawerBackground), NekoConfig.avatarAsDrawerBackground, true);
} else if (position == removeTitleEmojiRow) {

View File

@ -187,7 +187,7 @@ object ProxyUtil {
} else {
val url = link.toHttpUrlOrNull()!!
val url = link.replace("tg://","https://t.me/").toHttpUrlOrNull()!!
AndroidUtilities.showProxyAlert(ctx,
url.queryParameter("server"),
@ -204,7 +204,7 @@ object ProxyUtil {
}.onFailure {
FileLog.w("$it")
FileLog.e(it)
AlertUtil.showToast("${LocaleController.getString("BrokenLink", R.string.BrokenLink)}: ${it.message}")