From 4dc909bd467b0beb2320fff6ab530d9ecc32f5c4 Mon Sep 17 00:00:00 2001 From: xtaodada Date: Thu, 15 Aug 2024 22:08:37 +0800 Subject: [PATCH] feat: can only save proxy when use url --- .../org/telegram/messenger/AndroidUtilities.java | 16 ++++++++++++++++ .../ui/Components/PickerBottomLayout.java | 4 ++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/AndroidUtilities.java b/TMessagesProj/src/main/java/org/telegram/messenger/AndroidUtilities.java index e8bf65ccfb..71a3b2cee3 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/AndroidUtilities.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/AndroidUtilities.java @@ -4385,6 +4385,22 @@ protected void onDetachedFromWindow() { } dismissRunnable.run(); }); + + pickerBottomLayout.middleButtonTextView.setText(LocaleController.getString("Save", R.string.Save).toUpperCase()); + pickerBottomLayout.middleButton.setVisibility(View.VISIBLE); + pickerBottomLayout.middleButton.setOnClickListener((it) -> { + int p = Utilities.parseInt(port); + SharedConfig.ProxyInfo info; + if (TextUtils.isEmpty(secret)) { + info = new SharedConfig.ProxyInfo(address, p, user, password, ""); + } else { + info = new SharedConfig.ProxyInfo(address, p, "", "", secret); + } + SharedConfig.addProxy(info); + NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.proxySettingsChanged); + dismissRunnable.run(); + }); + builder.show(); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/PickerBottomLayout.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/PickerBottomLayout.java index ca700bef3b..1be85ab6ec 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/PickerBottomLayout.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/PickerBottomLayout.java @@ -63,14 +63,14 @@ public PickerBottomLayout(Context context, boolean darkTheme, Theme.ResourcesPro middleButton = new LinearLayout(context); middleButton.setOrientation(LinearLayout.HORIZONTAL); - middleButton.setBackgroundDrawable(Theme.createSelectorDrawable(0x0f000000, 0)); + middleButton.setBackground(Theme.createSelectorDrawable(Theme.getColor(Theme.key_picker_enabledButton, resourcesProvider) & 0x0fffffff, 0)); middleButton.setPadding(AndroidUtilities.dp(33), 0, AndroidUtilities.dp(33), 0); middleButton.setVisibility(GONE); rightLayout.addView(middleButton); middleButtonTextView = new TextView(context); middleButtonTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); - middleButtonTextView.setTextColor(Theme.getColor(Theme.key_picker_enabledButton)); + middleButtonTextView.setTextColor(Theme.getColor(Theme.key_picker_enabledButton, resourcesProvider)); middleButtonTextView.setGravity(Gravity.CENTER); middleButtonTextView.setCompoundDrawablePadding(AndroidUtilities.dp(8)); middleButtonTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));