From 10e268fbb9e3c10a5dd51e3335bfaebcef909b2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Fri, 17 Apr 2020 11:29:46 +0800 Subject: [PATCH] =?UTF-8?q?=E5=96=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TMessagesProj/build.gradle | 8 +- .../messenger/MessagesController.java | 3 +- .../telegram/ui/ActionBar/AlertDialog.java | 6 +- .../telegram/ui/ActionBar/BottomSheet.java | 4 +- .../org/telegram/ui/Cells/TextCheckCell.java | 60 ++++++--- .../telegram/ui/ChatRightsEditActivity.java | 2 +- .../java/org/telegram/ui/LoginActivity.java | 122 ++++++++---------- .../org/telegram/ui/ProxyListActivity.java | 3 +- .../org/telegram/ui/StickersActivity.java | 6 +- .../tw/nekomimi/nekogram/BottomBuilder.kt | 82 ++++++++---- .../tw/nekomimi/nekogram/NekoXConfig.java | 16 --- .../nekogram/NekoXSettingActivity.java | 33 +---- .../transtale/source/LingoTranslator.kt | 2 +- .../nekomimi/nekogram/utils/StickersUtil.kt | 48 ++++++- .../src/main/res/values/strings_nekox.xml | 7 +- 15 files changed, 230 insertions(+), 172 deletions(-) diff --git a/TMessagesProj/build.gradle b/TMessagesProj/build.gradle index da84d3402..5ffb7faad 100644 --- a/TMessagesProj/build.gradle +++ b/TMessagesProj/build.gradle @@ -41,10 +41,10 @@ dependencies { implementation files('libs/ssr-libev-release.aar') compileOnly 'com.google.firebase:firebase-messaging:20.1.5' - compileOnly 'com.google.firebase:firebase-crashlytics:17.0.0-beta03' + compileOnly 'com.google.firebase:firebase-crashlytics:17.0.0-beta04' releaseImplementation 'com.google.firebase:firebase-messaging:20.1.5' - releaseImplementation 'com.google.firebase:firebase-crashlytics:17.0.0-beta03' + releaseImplementation 'com.google.firebase:firebase-crashlytics:17.0.0-beta04' } @@ -59,8 +59,8 @@ android { minSdkVersion 16 targetSdkVersion 28 - versionName "6.0.1.15" - versionCode = 20 + versionName "6.0.1.16" + versionCode = 21 vectorDrawables.generatedDensities = ['mdpi', 'hdpi', 'xhdpi', 'xxhdpi'] diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java index 1fc4e05c3..98982e463 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java @@ -4073,7 +4073,8 @@ public class MessagesController extends BaseController implements NotificationCe checkDeletingTask(false); checkReadTasks(); - if (getUserConfig().isClientActivated()) { + if (getUserConfig().isClientActivated() && !getUserConfig().isBot) { + if (getConnectionsManager().getPauseTime() == 0 && ApplicationLoader.isScreenOn && !ApplicationLoader.mainInterfacePausedStageQueue) { if (ApplicationLoader.mainInterfacePausedStageQueueTime != 0 && Math.abs(ApplicationLoader.mainInterfacePausedStageQueueTime - System.currentTimeMillis()) > 1000) { if (statusSettingState != 1 && (lastStatusUpdateTime == 0 || Math.abs(System.currentTimeMillis() - lastStatusUpdateTime) >= 55000 || offlineSent)) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/AlertDialog.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/AlertDialog.java index 3bddee52e..782f7dc9d 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/AlertDialog.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/AlertDialog.java @@ -200,7 +200,7 @@ public class AlertDialog extends Dialog implements Drawable.Callback { @Override public boolean onTouchEvent(MotionEvent event) { - if (progressViewStyle == 3) { + if (progressViewStyle > 0) { showCancelAlert(); return false; } @@ -474,6 +474,8 @@ public class AlertDialog extends Dialog implements Drawable.Callback { } messageTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP); if (progressViewStyle == 1) { + setCanceledOnTouchOutside(false); + setCancelable(false); progressViewContainer = new FrameLayout(getContext()); containerView.addView(progressViewContainer, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 44, Gravity.LEFT | Gravity.TOP, 23, title == null ? 24 : 0, 23, 24)); @@ -485,6 +487,8 @@ public class AlertDialog extends Dialog implements Drawable.Callback { messageTextView.setEllipsize(TextUtils.TruncateAt.END); progressViewContainer.addView(messageTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL, (LocaleController.isRTL ? 0 : 62), 0, (LocaleController.isRTL ? 62 : 0), 0)); } else if (progressViewStyle == 2) { + setCanceledOnTouchOutside(false); + setCancelable(false); containerView.addView(messageTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 24, title == null ? 19 : 0, 24, 20)); lineProgressView = new LineProgressView(getContext()); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/BottomSheet.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/BottomSheet.java index 1499c6b8f..3c0f89934 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/BottomSheet.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/BottomSheet.java @@ -497,7 +497,7 @@ public class BottomSheet extends Dialog { setBackground(Theme.getSelectorDrawable(false)); - super.setGravity(Gravity.CENTER); + super.setGravity(Gravity.CENTER_VERTICAL | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT)); imageView = new ImageView(context); imageView.setScaleType(ImageView.ScaleType.CENTER); @@ -508,11 +508,11 @@ public class BottomSheet extends Dialog { textView.setLines(1); textView.setSingleLine(true); textView.setEllipsize(TextUtils.TruncateAt.END); - textView.setPadding(AndroidUtilities.dp(16),0,0,0); if (type == 0) { textView.setTextColor(Theme.getColor(Theme.key_dialogTextBlack)); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); textView.setGravity(Gravity.CENTER_VERTICAL); + textView.setPadding(AndroidUtilities.dp(16),0,0,0); } else if (type == 1) { textView.setTextColor(Theme.getColor(Theme.key_dialogTextBlack)); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextCheckCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextCheckCell.java index 68554b301..89474ead0 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextCheckCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextCheckCell.java @@ -33,9 +33,11 @@ import org.telegram.messenger.LocaleController; import org.telegram.messenger.R; import org.telegram.ui.ActionBar.Theme; import org.telegram.ui.Components.AnimationProperties; +import org.telegram.ui.Components.CheckBoxSquare; import org.telegram.ui.Components.CubicBezierInterpolator; import org.telegram.ui.Components.LayoutHelper; import org.telegram.ui.Components.Switch; +import org.telegram.ui.Components.ViewHelper; import java.util.ArrayList; @@ -44,6 +46,7 @@ public class TextCheckCell extends FrameLayout { private TextView textView; private TextView valueTextView; private Switch checkBox; + private CheckBoxSquare checkBoxSquare; private boolean needDivider; private boolean isMultiline; private int height = 50; @@ -95,9 +98,18 @@ public class TextCheckCell extends FrameLayout { valueTextView.setEllipsize(TextUtils.TruncateAt.END); addView(valueTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 64 : padding, 36, LocaleController.isRTL ? padding : 64, 0)); - checkBox = new Switch(context); - checkBox.setColors(Theme.key_switchTrack, Theme.key_switchTrackChecked, Theme.key_windowBackgroundWhite, Theme.key_windowBackgroundWhite); - addView(checkBox, LayoutHelper.createFrame(37, 20, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL, 22, 0, 22, 0)); + if (!dialog) { + + checkBox = new Switch(context); + checkBox.setColors(Theme.key_switchTrack, Theme.key_switchTrackChecked, Theme.key_windowBackgroundWhite, Theme.key_windowBackgroundWhite); + addView(checkBox, LayoutHelper.createFrame(37, 20, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL, 22, 0, 22, 0)); + + } else { + + checkBoxSquare = new CheckBoxSquare(context,true); + addView(checkBoxSquare, LayoutHelper.createFrame(18, 18, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL, 22, 0, 22, 0)); + + } setClipChildren(false); } @@ -107,7 +119,7 @@ public class TextCheckCell extends FrameLayout { if (isMultiline) { super.onMeasure(MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)); } else { - super.onMeasure(MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(valueTextView.getVisibility() == VISIBLE ? 64 : height) + (needDivider ? 1 : 0), MeasureSpec.EXACTLY)); + super.onMeasure(MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(valueTextView.getVisibility() == VISIBLE ? 64 : height) + (needDivider ? 3 : 0), MeasureSpec.EXACTLY)); } } @@ -120,7 +132,11 @@ public class TextCheckCell extends FrameLayout { public void setTextAndCheck(String text, boolean checked, boolean divider) { textView.setText(text); isMultiline = false; - checkBox.setChecked(checked, false); + if (checkBox != null) { + checkBox.setChecked(checked, false); + } else { + checkBoxSquare.setChecked(checked,false); + } needDivider = divider; valueTextView.setVisibility(GONE); LayoutParams layoutParams = (LayoutParams) textView.getLayoutParams(); @@ -150,7 +166,7 @@ public class TextCheckCell extends FrameLayout { @Override public void setPressed(boolean pressed) { - if (drawCheckRipple) { + if (drawCheckRipple && checkBox != null) { checkBox.setDrawRipple(pressed); } super.setPressed(pressed); @@ -159,7 +175,11 @@ public class TextCheckCell extends FrameLayout { public void setTextAndValueAndCheck(String text, String value, boolean checked, boolean multiline, boolean divider) { textView.setText(text); valueTextView.setText(value); - checkBox.setChecked(checked, false); + if (checkBox != null) { + checkBox.setChecked(checked, false); + } else { + checkBoxSquare.setChecked(checked,false); + } needDivider = divider; valueTextView.setVisibility(VISIBLE); isMultiline = multiline; @@ -187,13 +207,17 @@ public class TextCheckCell extends FrameLayout { super.setEnabled(value); if (animators != null) { animators.add(ObjectAnimator.ofFloat(textView, "alpha", value ? 1.0f : 0.5f)); - animators.add(ObjectAnimator.ofFloat(checkBox, "alpha", value ? 1.0f : 0.5f)); + if (checkBox != null) { + animators.add(ObjectAnimator.ofFloat(checkBox, "alpha", value ? 1.0f : 0.5f)); + } else { + animators.add(ObjectAnimator.ofFloat(checkBoxSquare, "alpha", value ? 1.0f : 0.5f)); + } if (valueTextView.getVisibility() == VISIBLE) { animators.add(ObjectAnimator.ofFloat(valueTextView, "alpha", value ? 1.0f : 0.5f)); } } else { textView.setAlpha(value ? 1.0f : 0.5f); - checkBox.setAlpha(value ? 1.0f : 0.5f); + (checkBox != null ? checkBox : checkBoxSquare).setAlpha(value ? 1.0f : 0.5f); if (valueTextView.getVisibility() == VISIBLE) { valueTextView.setAlpha(value ? 1.0f : 0.5f); } @@ -201,11 +225,15 @@ public class TextCheckCell extends FrameLayout { } public void setChecked(boolean checked) { - checkBox.setChecked(checked, true); + if (checkBox != null) { + checkBox.setChecked(checked, true); + } else { + checkBoxSquare.setChecked(checked,true); + } } public boolean isChecked() { - return checkBox.isChecked(); + return checkBox != null ? checkBox.isChecked() : checkBoxSquare.isChecked(); } @Override @@ -226,7 +254,9 @@ public class TextCheckCell extends FrameLayout { if (animationPaint == null) { animationPaint = new Paint(Paint.ANTI_ALIAS_FLAG); } - checkBox.setOverrideColor(checked ? 1 : 2); + if (checkBox != null) { + checkBox.setOverrideColor(checked ? 1 : 2); + } animatedColorBackground = color; animationPaint.setColor(animatedColorBackground); animationProgress = 0.0f; @@ -262,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() - 1, getMeasuredWidth() - (LocaleController.isRTL ? AndroidUtilities.dp(20) : 0), getMeasuredHeight() - 1, Theme.dividerPaint); + canvas.drawLine(LocaleController.isRTL ? 0 : AndroidUtilities.dp(20), getMeasuredHeight() - 3, getMeasuredWidth() - (LocaleController.isRTL ? AndroidUtilities.dp(20) : 0), getMeasuredHeight() - 3, Theme.dividerPaint); } } @@ -271,7 +301,7 @@ public class TextCheckCell extends FrameLayout { super.onInitializeAccessibilityNodeInfo(info); info.setClassName("android.widget.Switch"); info.setCheckable(true); - info.setChecked(checkBox.isChecked()); - info.setContentDescription(checkBox.isChecked() ? LocaleController.getString("NotificationsOn", R.string.NotificationsOn) : LocaleController.getString("NotificationsOff", R.string.NotificationsOff)); + info.setChecked(isChecked()); + info.setContentDescription(isChecked() ? LocaleController.getString("NotificationsOn", R.string.NotificationsOn) : LocaleController.getString("NotificationsOff", R.string.NotificationsOff)); } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChatRightsEditActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChatRightsEditActivity.java index 8d8210307..bc64c9f71 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChatRightsEditActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChatRightsEditActivity.java @@ -392,7 +392,7 @@ public class ChatRightsEditActivity extends BaseFragment { break; } buttons[a].setTextAndIcon(text, 0); - linearLayoutInviteContainer.addView(buttons[a], LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); + linearLayoutInviteContainer.addView(buttons[a], LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 48)); buttons[a].setOnClickListener(v2 -> { Integer tag = (Integer) v2.getTag(); switch (tag) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LoginActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/LoginActivity.java index 35344b668..7e816e64c 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/LoginActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/LoginActivity.java @@ -120,10 +120,9 @@ import java.util.Set; import java.util.Timer; import java.util.TimerTask; +import tw.nekomimi.nekogram.BottomBuilder; import tw.nekomimi.nekogram.EditTextAutoFill; -import tw.nekomimi.nekogram.NekoConfig; import tw.nekomimi.nekogram.NekoXConfig; -import tw.nekomimi.nekogram.utils.AlertUtil; @SuppressLint("HardwareIds") public class LoginActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate { @@ -140,7 +139,7 @@ public class LoginActivity extends BaseFragment implements NotificationCenter.No private boolean checkPermissions = true; private boolean checkShowPermissions = true; private boolean newAccount; - private boolean syncContacts = false; + private boolean syncContacts = !"cn".equals(Locale.getDefault().getCountry().toLowerCase()); private int scrollHeight; @@ -164,9 +163,6 @@ public class LoginActivity extends BaseFragment implements NotificationCenter.No private ActionBarMenuItem proxyItem; private ProxyDrawable proxyDrawable; - @SuppressWarnings("ConstantConditions") - private boolean useOfficalId = !"release".equals(BuildConfig.BUILD_TYPE); - private class ProgressView extends View { private final Path path = new Path(); @@ -265,6 +261,12 @@ public class LoginActivity extends BaseFragment implements NotificationCenter.No } + private int menu_other = 5; + private int menu_custom_api = 6; + + private int customAppId; + private String customAppHash = null; + @Override public View createView(Context context) { actionBar.setTitle(LocaleController.getString("NekogramWithEmoji", R.string.NekogramWithEmoji)); @@ -319,8 +321,8 @@ public class LoginActivity extends BaseFragment implements NotificationCenter.No ConnectionsManager.getInstance(currentAccount).cleanup(false); final TLRPC.TL_auth_importBotAuthorization req = new TLRPC.TL_auth_importBotAuthorization(); - req.api_hash = useOfficalId ? BuildVars.OFFICAL_APP_HASH : BuildConfig.APP_HASH; - req.api_id = useOfficalId ? BuildVars.OFFICAL_APP_ID : BuildConfig.APP_ID; + req.api_hash = customAppId != 0 ? customAppHash : BuildConfig.APP_HASH; + req.api_id = customAppId != 0 ? customAppId : BuildConfig.APP_ID; req.bot_auth_token = token; req.flags = 0; int reqId = ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> { @@ -374,6 +376,15 @@ public class LoginActivity extends BaseFragment implements NotificationCenter.No editText.setLayoutParams(layoutParams); } } + } else if (id == menu_custom_api) { + + BottomBuilder builder = new BottomBuilder(getParentActivity()); + + builder.addTitle(LocaleController.getString("CustomApi", R.string.CustomApi), + true, + LocaleController.getString("UseCustomApiNotice", R.string.UseCustomApiNotice)); + + } } }); @@ -391,12 +402,16 @@ public class LoginActivity extends BaseFragment implements NotificationCenter.No menu.addItem(3, R.drawable.ic_translate); - if (NekoXConfig.showBotLogin) { + ActionBarMenuItem otherItem = menu.addItem(menu_other, R.drawable.ic_ab_other); - menu.addItem(4, R.drawable.list_bot); + if (NekoXConfig.developerMode) { + + 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)); + actionBar.setAllowOverlayTitle(true); doneItem = menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56)); doneProgressView = new ContextProgressView(context, 1); @@ -1210,7 +1225,7 @@ public class LoginActivity extends BaseFragment implements NotificationCenter.No if (getParentActivity() instanceof LaunchActivity) { if (newAccount) { newAccount = false; - ((LaunchActivity) getParentActivity()).switchToAccount(currentAccount, false,true); + ((LaunchActivity) getParentActivity()).switchToAccount(currentAccount, false, true); finishFragment(); } else { final Bundle args = new Bundle(); @@ -1291,7 +1306,6 @@ public class LoginActivity extends BaseFragment implements NotificationCenter.No private TextView textView2; private CheckBoxCell checkBoxCell; private CheckBoxCell testBackendCell; - private CheckBoxCell useOfficalIdCell; private int countryState = 0; @@ -1569,41 +1583,39 @@ public class LoginActivity extends BaseFragment implements NotificationCenter.No textView2.setLineSpacing(AndroidUtilities.dp(2), 1.0f); addView(textView2, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT, 0, 28, 0, 10)); - if (true) { - checkBoxCell = new CheckBoxCell(context, 2); - checkBoxCell.setText(LocaleController.getString("SyncContacts", R.string.SyncContacts), "", syncContacts, false); - addView(checkBoxCell, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.LEFT | Gravity.TOP, 0, 0, 0, 0)); - checkBoxCell.setOnClickListener(new OnClickListener() { + checkBoxCell = new CheckBoxCell(context, 2); + checkBoxCell.setText(LocaleController.getString("SyncContacts", R.string.SyncContacts), "", syncContacts, false); + addView(checkBoxCell, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.LEFT | Gravity.TOP, 0, 0, 0, 0)); + checkBoxCell.setOnClickListener(new OnClickListener() { - private Toast visibleToast; + private Toast visibleToast; - @Override - public void onClick(View v) { - if (getParentActivity() == null) { - return; - } - CheckBoxCell cell = (CheckBoxCell) v; - syncContacts = !syncContacts; - cell.setChecked(syncContacts, true); - try { - if (visibleToast != null) { - visibleToast.cancel(); - } - } catch (Exception e) { - FileLog.e(e); - } - if (syncContacts) { - visibleToast = Toast.makeText(getParentActivity(), LocaleController.getString("SyncContactsOn", R.string.SyncContactsOn), Toast.LENGTH_SHORT); - visibleToast.show(); - } else { - visibleToast = Toast.makeText(getParentActivity(), LocaleController.getString("SyncContactsOff", R.string.SyncContactsOff), Toast.LENGTH_SHORT); - visibleToast.show(); - } + @Override + public void onClick(View v) { + if (getParentActivity() == null) { + return; } - }); - } + CheckBoxCell cell = (CheckBoxCell) v; + syncContacts = !syncContacts; + cell.setChecked(syncContacts, true); + try { + if (visibleToast != null) { + visibleToast.cancel(); + } + } catch (Exception e) { + FileLog.e(e); + } + if (syncContacts) { + visibleToast = Toast.makeText(getParentActivity(), LocaleController.getString("SyncContactsOn", R.string.SyncContactsOn), Toast.LENGTH_SHORT); + visibleToast.show(); + } else { + visibleToast = Toast.makeText(getParentActivity(), LocaleController.getString("SyncContactsOff", R.string.SyncContactsOff), Toast.LENGTH_SHORT); + visibleToast.show(); + } + } + }); - if (NekoXConfig.showTestBackend) { + if (NekoXConfig.developerMode) { testBackendCell = new CheckBoxCell(context, 2); testBackendCell.setText(LocaleController.getString("TestBackend", R.string.TestBackend), "", ConnectionsManager.native_isTestBackend(currentAccount) != 0, true); addView(testBackendCell, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.LEFT | Gravity.TOP, 0, 0, 0, 0)); @@ -1638,26 +1650,6 @@ public class LoginActivity extends BaseFragment implements NotificationCenter.No }); } - useOfficalIdCell = new CheckBoxCell(context, 2); - useOfficalIdCell.setText(LocaleController.getString("UseOfficalId", R.string.UseOfficalId), "", useOfficalId, false); - addView(useOfficalIdCell, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.LEFT | Gravity.TOP, 0, 0, 0, 0)); - useOfficalIdCell.setOnClickListener(new OnClickListener() { - - private Toast visibleToast; - - @Override - public void onClick(View v) { - if (getParentActivity() == null) { - return; - } - CheckBoxCell cell = (CheckBoxCell) v; - cell.setChecked(useOfficalId = !useOfficalId, true); - if (useOfficalId) { - AlertUtil.showSimpleAlert(getParentActivity(), LocaleController.getString("UseOfficalIdNotice", R.string.UseOfficalIdNotice)); - } - } - }); - HashMap languageMap = new HashMap<>(); try { BufferedReader reader = new BufferedReader(new InputStreamReader(getResources().getAssets().open("countries.txt"))); @@ -1866,8 +1858,8 @@ public class LoginActivity extends BaseFragment implements NotificationCenter.No ConnectionsManager.getInstance(currentAccount).cleanup(false); final TLRPC.TL_auth_sendCode req = new TLRPC.TL_auth_sendCode(); - req.api_hash = useOfficalId ? BuildVars.OFFICAL_APP_HASH : BuildConfig.APP_HASH; - req.api_id = useOfficalId ? BuildVars.OFFICAL_APP_ID : BuildConfig.APP_ID; + req.api_hash = customAppId != 0 ? customAppHash : BuildConfig.APP_HASH; + req.api_id = customAppId != 0 ? customAppId : BuildConfig.APP_ID; req.phone_number = phone; req.settings = new TLRPC.TL_codeSettings(); req.settings.allow_flashcall = simcardAvailable && allowCall && allowCancelCall && allowReadCallLog; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ProxyListActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ProxyListActivity.java index b9c37552b..c33a294f1 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ProxyListActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ProxyListActivity.java @@ -1085,7 +1085,8 @@ public class ProxyListActivity extends BaseFragment implements NotificationCente private void checkSingleProxy(SharedConfig.ProxyInfo proxyInfo, int repeat, Runnable callback) { proxyInfo.checking = true; - NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.proxyCheckDone, proxyInfo); + + UIUtil.runOnUIThread(() -> NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.proxyCheckDone, proxyInfo)); if (proxyInfo instanceof SharedConfig.ExternalSocks5Proxy && !((SharedConfig.ExternalSocks5Proxy) proxyInfo).isStarted()) { ((SharedConfig.ExternalSocks5Proxy) proxyInfo).start(); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/StickersActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/StickersActivity.java index bd87ba1af..90468217e 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/StickersActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/StickersActivity.java @@ -443,7 +443,7 @@ public class StickersActivity extends BaseFragment implements NotificationCenter AtomicBoolean exportSets = new AtomicBoolean(true); AtomicBoolean exportArchived = new AtomicBoolean(true); - final AtomicReference exportButton = new AtomicReference<>(); + final AtomicReference exportButton = new AtomicReference<>(); builder.setCheckItems(new String[]{ LocaleController.getString("StickerSets", R.string.StickerSets), @@ -472,7 +472,7 @@ public class StickersActivity extends BaseFragment implements NotificationCenter } - check.setChecked(export, true); + check.setChecked(export); if (!exportSets.get() && !exportArchived.get()) { @@ -486,7 +486,7 @@ public class StickersActivity extends BaseFragment implements NotificationCenter }); - builder.addButton(LocaleController.getString("Cancel", R.string.Cancel), null); + builder.addButton(LocaleController.getString("Cancel", R.string.Cancel),false,true, null); exportButton.set(builder.addButton(LocaleController.getString("Export", R.string.ExportStickers), (it) -> { diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/BottomBuilder.kt b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/BottomBuilder.kt index 51d40ddfa..027fca301 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/BottomBuilder.kt +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/BottomBuilder.kt @@ -1,15 +1,20 @@ package tw.nekomimi.nekogram import android.content.Context +import android.text.TextUtils +import android.util.TypedValue import android.view.Gravity import android.view.View +import android.widget.FrameLayout import android.widget.LinearLayout +import android.widget.TextView import org.telegram.messenger.AndroidUtilities -import org.telegram.messenger.LocaleController import org.telegram.ui.ActionBar.BottomSheet import org.telegram.ui.ActionBar.Theme import org.telegram.ui.Cells.CheckBoxCell import org.telegram.ui.Cells.HeaderCell +import org.telegram.ui.Cells.ShadowSectionCell +import org.telegram.ui.Cells.TextCheckCell import org.telegram.ui.Components.LayoutHelper class BottomBuilder(val ctx: Context) { @@ -26,39 +31,65 @@ class BottomBuilder(val ctx: Context) { private val buttonsView by lazy { + FrameLayout(ctx).apply { + + setBackgroundColor(Theme.getColor(Theme.key_dialogBackground)) + + this@BottomBuilder.rootView.addView(this, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 50, Gravity.LEFT or Gravity.BOTTOM)) + + addView(rightButtonsView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.TOP or Gravity.RIGHT)); + + } + + } + + private val rightButtonsView by lazy { + LinearLayout(ctx).apply { orientation = LinearLayout.HORIZONTAL - gravity = Gravity.CENTER_VERTICAL or if (LocaleController.isRTL) Gravity.LEFT else Gravity.RIGHT - - minimumHeight = AndroidUtilities.dp(48F) - - this@BottomBuilder.rootView.addView(this, LinearLayout.LayoutParams(-1, -2)) + weightSum = 1F } } @JvmOverloads - fun addTitle(title: String, bigTitle: Boolean = true) { + fun addTitle(title: String, bigTitle: Boolean = true, subTitle: String? = null) { val headerCell = if (bigTitle) HeaderCell(ctx, Theme.key_dialogTextBlue2, 21, 15, false) else HeaderCell(ctx) headerCell.setText(title) - rootView.addView(headerCell, LayoutHelper.createLinear(-1, -2)) + subTitle?.also { headerCell.setText2(it) } + + rootView.addView(headerCell, LayoutHelper.createLinear(-1, -2).apply { + + bottomMargin = AndroidUtilities.dp(16F) + + }) + + rootView.addView(ShadowSectionCell(ctx,3)) } @JvmOverloads fun addCheckBox(text: String, value: Boolean, valueText: String? = null, listener: View.OnClickListener) { - val checkBoxCell = CheckBoxCell(ctx, 1, 21) + val checkBoxCell = TextCheckCell(ctx, 21,true) checkBoxCell.setBackgroundDrawable(Theme.getSelectorDrawable(false)) checkBoxCell.minimumHeight = AndroidUtilities.dp(50F) rootView.addView(checkBoxCell, LayoutHelper.createLinear(-1, -2)) - checkBoxCell.setText(text, valueText, value, true) + + if (valueText == null) { + + checkBoxCell.setTextAndCheck(text, value, true) + + } else { + + checkBoxCell.setTextAndValueAndCheck(text,valueText,value,true,true) + } checkBoxCell.setOnClickListener(listener) @@ -67,7 +98,7 @@ class BottomBuilder(val ctx: Context) { @FunctionalInterface interface IndexedListener { - fun onClick(index: Int, view: CheckBoxCell) + fun onClick(index: Int, view: TextCheckCell) } @@ -78,7 +109,7 @@ class BottomBuilder(val ctx: Context) { addCheckBox(textI, value(index), valueText?.invoke(index), View.OnClickListener { - listener.onClick(index, it as CheckBoxCell) + listener.onClick(index, it as TextCheckCell) }) @@ -87,22 +118,21 @@ class BottomBuilder(val ctx: Context) { } @JvmOverloads - fun addButton(text: String, icon: Int = 0, red: Boolean = false, listener: View.OnClickListener?): BottomSheet.BottomSheetCell { + fun addButton(text: String, red: Boolean = false,left : Boolean = false, listener: View.OnClickListener?): TextView { - return BottomSheet.BottomSheetCell(ctx, 1).apply { + return TextView(ctx).apply { - setBackgroundDrawable(Theme.getSelectorDrawable(false)) - setTextAndIcon(text, icon) - setTextColor(Theme.getColor(if (red) Theme.key_windowBackgroundWhiteRedText else Theme.key_dialogTextBlue2)) - setOnClickListener { v -> - if (listener != null) { - listener.onClick(v) - } else { - dismiss() - } - } - - buttonsView.addView(this, LinearLayout.LayoutParams(-2, -1)) + setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14f) + setTextColor(Theme.getColor(Theme.key_dialogTextBlue4)) + gravity = Gravity.CENTER + isSingleLine = true + ellipsize = TextUtils.TruncateAt.END + setBackgroundDrawable(Theme.createSelectorDrawable(Theme.getColor(Theme.key_dialogButtonSelector), 0)) + setPadding(AndroidUtilities.dp(18f), 0, AndroidUtilities.dp(18f), 0) + setText(text) + typeface = AndroidUtilities.getTypeface("fonts/rmedium.ttf") + (if (left) buttonsView else rightButtonsView).addView(this, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.TOP or Gravity.LEFT)) + setOnClickListener(listener ?: View.OnClickListener { dismiss() }) } diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/NekoXConfig.java b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/NekoXConfig.java index f1f5c2a8c..b44268a10 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/NekoXConfig.java +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/NekoXConfig.java @@ -25,9 +25,6 @@ public class NekoXConfig { public static boolean disableFlagSecure = preferences.getBoolean("disable_flag_secure", false); public static boolean disableScreenshotDetection = preferences.getBoolean("disable_screenshot_detection", false); - public static boolean showTestBackend = preferences.getBoolean("show_test_backend", false); - public static boolean showBotLogin = preferences.getBoolean("show_bot_login", false); - public static void toggleDeveloperMode() { preferences.edit().putBoolean("developer_mode", developerMode = !developerMode).apply(); @@ -46,17 +43,4 @@ public class NekoXConfig { } - public static void toggleShowTestBackend() { - - preferences.edit().putBoolean("show_test_backend", showTestBackend = !showTestBackend).apply(); - - } - - public static void toggleShowBotLogin() { - - preferences.edit().putBoolean("show_bot_login", showBotLogin = !showBotLogin).apply(); - - } - - } \ No newline at end of file diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/NekoXSettingActivity.java b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/NekoXSettingActivity.java index d4dd72cff..9c9a89f06 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/NekoXSettingActivity.java +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/NekoXSettingActivity.java @@ -52,10 +52,6 @@ public class NekoXSettingActivity extends BaseFragment { private int disableFlagSecureRow; private int disableScreenshotDetectionRow; - private int loginSettingsRow; - private int showTestBackendRow; - private int showBotLoginRow; - @Override public boolean onFragmentCreate() { super.onFragmentCreate(); @@ -118,16 +114,6 @@ public class NekoXSettingActivity extends BaseFragment { if (view instanceof TextCheckCell) { ((TextCheckCell) view).setChecked(NekoXConfig.disableScreenshotDetection); } - } else if (position == showTestBackendRow) { - NekoXConfig.toggleShowTestBackend(); - if (view instanceof TextCheckCell) { - ((TextCheckCell) view).setChecked(NekoXConfig.showTestBackend); - } - } else if (position == showBotLoginRow) { - NekoXConfig.toggleShowBotLogin(); - if (view instanceof TextCheckCell) { - ((TextCheckCell) view).setChecked(NekoXConfig.showBotLogin); - } } }); @@ -153,10 +139,6 @@ public class NekoXSettingActivity extends BaseFragment { disableFlagSecureRow = rowCount++; disableScreenshotDetectionRow = rowCount++; - loginSettingsRow = rowCount++; - showTestBackendRow = rowCount++; - showBotLoginRow = rowCount++; - if (listAdapter != null) { listAdapter.notifyDataSetChanged(); } @@ -264,8 +246,6 @@ public class NekoXSettingActivity extends BaseFragment { HeaderCell headerCell = (HeaderCell) holder.itemView; if (position == developerSettingsRow) { headerCell.setText(LocaleController.getString("DeveloperSettings", R.string.DeveloperSettings)); - } else if (position == loginSettingsRow) { - headerCell.setText(LocaleController.getString("LoginSettings", R.string.LoginSettings)); } break; } @@ -277,10 +257,6 @@ public class NekoXSettingActivity extends BaseFragment { textCell.setTextAndCheck("Disable Flag Secure", NekoXConfig.disableFlagSecure, true); } else if (position == disableScreenshotDetectionRow) { textCell.setTextAndCheck("Disable Screenshot Detection", NekoXConfig.disableScreenshotDetection, false); - } else if (position == showTestBackendRow) { - textCell.setTextAndCheck("Show Test Backend", NekoXConfig.showTestBackend, true); - } else if (position == showBotLoginRow) { - textCell.setTextAndCheck("Show Bot Login", NekoXConfig.showBotLogin, false); } break; } @@ -301,9 +277,7 @@ public class NekoXSettingActivity extends BaseFragment { int position = holder.getAdapterPosition(); return position == fetchAndExportLangRow || position == disableFlagSecureRow || - position == disableScreenshotDetectionRow || - position == showTestBackendRow || - position == showBotLoginRow; + position == disableScreenshotDetectionRow; } @Override @@ -344,10 +318,9 @@ public class NekoXSettingActivity extends BaseFragment { @Override public int getItemViewType(int position) { - if (position == developerSettingsRow || position == loginSettingsRow) { + if (position == developerSettingsRow) { return 4; - } else if (position == disableFlagSecureRow || position == disableScreenshotDetectionRow || - position == showTestBackendRow || position == showBotLoginRow) { + } else if (position == disableFlagSecureRow || position == disableScreenshotDetectionRow) { return 3; } else if (position == fetchAndExportLangRow) { return 2; diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/transtale/source/LingoTranslator.kt b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/transtale/source/LingoTranslator.kt index 3442844b9..55a0a20d5 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/transtale/source/LingoTranslator.kt +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/transtale/source/LingoTranslator.kt @@ -22,7 +22,7 @@ object LingoTranslator : Translator { val response = HttpUtil.okHttpClient.newCall(Request.Builder() .url("https://api.interpreter.caiyunai.com/v1/translator") .header("Content-Type", "application/json; charset=UTF-8") - .header("X- ", "token 9sdftiq37bnv410eon2l") // 白嫖 + .header("X-Authorization", "token 9sdftiq37bnv410eon2l") // 白嫖 .applyUserAgent() .post(JSONObject().apply { diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/utils/StickersUtil.kt b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/utils/StickersUtil.kt index 095347b32..5cb8bea6a 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/utils/StickersUtil.kt +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/utils/StickersUtil.kt @@ -1,7 +1,5 @@ package tw.nekomimi.nekogram.utils -import com.google.gson.Gson -import com.google.gson.JsonArray import com.google.gson.JsonObject import kotlinx.coroutines.delay import kotlinx.coroutines.runBlocking @@ -30,6 +28,42 @@ object StickersUtil { } + val installed = f.mediaDataController.getStickerSets(MediaDataController.TYPE_IMAGE) + + val finishLoad = AtomicBoolean() + val archivedSets = LinkedList() + + fun loadStickers() { + + val req = TL_messages_getArchivedStickers() + req.offset_id = if (archivedSets.isEmpty()) 0 else archivedSets[archivedSets.size - 1].set.id + req.limit = 100 + req.masks = false + + f.connectionsManager.sendRequest(req) { response, _ -> + + if (response is TL_messages_archivedStickers) { + + archivedSets.addAll(response.sets) + + if (response.sets.size < 100) { + + finishLoad.set(true) + + } else { + + loadStickers() + + } + + } + + } + + } + + loadStickers() + stickerObj.getAsJsonObject("stickerSets")?.also { val stickerSets = LinkedList(it.entrySet().map { @@ -45,10 +79,13 @@ object StickersUtil { val waitLock = AtomicBoolean() - for (stickerSetObj in stickerSets) { + install@for (stickerSetObj in stickerSets) { if (cancel.get()) return@runBlocking + for (s in installed) if (s.set.short_name == stickerSetObj.value) continue@install + for (s in archivedSets) if (s.set.short_name == stickerSetObj.value) continue@install + waitLock.set(false) f.connectionsManager.sendRequest(TL_messages_installStickerSet().apply { @@ -110,12 +147,15 @@ object StickersUtil { val waitLock = AtomicBoolean() - for (stickerSetObj in stickerSets) { + install@ for (stickerSetObj in stickerSets) { if (cancel.get()) return@runBlocking waitLock.set(false) + for (s in installed) if (s.set.short_name == stickerSetObj.value) continue@install + for (s in archivedSets) if (s.set.short_name == stickerSetObj.value) continue@install + f.connectionsManager.sendRequest(TL_messages_installStickerSet().apply { stickerset = TL_inputStickerSetShortName().apply { diff --git a/TMessagesProj/src/main/res/values/strings_nekox.xml b/TMessagesProj/src/main/res/values/strings_nekox.xml index 1e4d0fd79..bd5f6be62 100644 --- a/TMessagesProj/src/main/res/values/strings_nekox.xml +++ b/TMessagesProj/src/main/res/values/strings_nekox.xml @@ -3,8 +3,11 @@ Nekogram X - Disguised as official app - Log in using the official App Id, if you are unable to register or log in, this may help.\n\nNote: fcm will not work if you are using the release version. + Custom Api + Log in using the custom api, if you are unable to register or log in, this may help.\n\nNote: fcm will not work if you are using the release version. + Telegram Android + Telegram X + Manual input Change Provider