Show ping in proxy alert

This commit is contained in:
NekoInverter 2020-02-05 15:32:40 +08:00
parent fd86bd9717
commit 5f845fcd09
3 changed files with 19 additions and 4 deletions

View File

@ -35,6 +35,7 @@ dependencies {
def appCenterSdkVersion = '2.5.1'
implementation "com.microsoft.appcenter:appcenter-analytics:${appCenterSdkVersion}"
implementation "com.microsoft.appcenter:appcenter-crashes:${appCenterSdkVersion}"
implementation "com.microsoft.appcenter:appcenter-push:${appCenterSdkVersion}"
}
android {

View File

@ -2733,7 +2733,7 @@ public class AndroidUtilities {
lineView.setBackgroundColor(Theme.getColor(Theme.key_divider));
linearLayout.addView(lineView, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 1));
}
for (int a = 0; a < 5; a++) {
for (int a = 0; a < 6; a++) {
String text = null;
String detail = null;
if (a == 0) {
@ -2751,6 +2751,9 @@ public class AndroidUtilities {
} else if (a == 4) {
text = password;
detail = LocaleController.getString("UseProxyPassword", R.string.UseProxyPassword);
} else if (a == 5) {
text = LocaleController.getString("Checking", R.string.Checking);
detail = LocaleController.getString("Checking", R.string.Checking);
}
if (TextUtils.isEmpty(text)) {
continue;
@ -2760,8 +2763,18 @@ public class AndroidUtilities {
cell.getTextView().setTextColor(Theme.getColor(Theme.key_dialogTextBlack));
cell.getValueTextView().setTextColor(Theme.getColor(Theme.key_dialogTextGray3));
linearLayout.addView(cell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
if (a == 2) {
break;
if (a == 5) {
ConnectionsManager.getInstance(UserConfig.selectedAccount).checkProxy(address, Utilities.parseInt(port), user, password, secret, time -> AndroidUtilities.runOnUIThread(() -> {
String colorKey;
if (time != -1) {
cell.setTextAndValue(LocaleController.getString("Available", R.string.Available), LocaleController.formatString("Ping", R.string.Ping, time), true);
colorKey = Theme.key_windowBackgroundWhiteGreenText;
} else {
cell.setTextAndValue(LocaleController.getString("Unavailable", R.string.Unavailable), LocaleController.getString("Unavailable", R.string.Unavailable), true);
colorKey = Theme.key_windowBackgroundWhiteRedText4;
}
cell.getValueTextView().setTextColor(Theme.getColor(colorKey));
}));
}
}

View File

@ -32,6 +32,7 @@ import com.google.firebase.iid.FirebaseInstanceId;
import com.microsoft.appcenter.AppCenter;
import com.microsoft.appcenter.analytics.Analytics;
import com.microsoft.appcenter.crashes.Crashes;
import com.microsoft.appcenter.push.Push;
import org.telegram.tgnet.ConnectionsManager;
import org.telegram.tgnet.TLRPC;
@ -178,7 +179,7 @@ public class ApplicationLoader extends Application {
super.onCreate();
AppCenter.start(this, "033a70ca-ea8d-4c2f-8c2c-b37f1b47f766",
Analytics.class, Crashes.class);
Analytics.class, Crashes.class, Push.class);
if (applicationContext == null) {
applicationContext = getApplicationContext();
}