diff --git a/TMessagesProj/jni/tgnet/ConnectionsManager.cpp b/TMessagesProj/jni/tgnet/ConnectionsManager.cpp index 6f2ad2937..3d4e9ad9f 100644 --- a/TMessagesProj/jni/tgnet/ConnectionsManager.cpp +++ b/TMessagesProj/jni/tgnet/ConnectionsManager.cpp @@ -1860,14 +1860,14 @@ void ConnectionsManager::setUserId(int32_t userId) { } void ConnectionsManager::switchBackend() { - scheduleTask([&] { + //scheduleTask([&] { currentDatacenterId = 1; testBackend = !testBackend; datacenters.clear(); initDatacenters(); saveConfig(); - exit(1); - }); + //exit(1); + //}); } void ConnectionsManager::removeRequestFromGuid(int32_t requestToken) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LoginActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/LoginActivity.java index e9ecf0592..340ed73e7 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/LoginActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/LoginActivity.java @@ -1230,6 +1230,7 @@ public class LoginActivity extends BaseFragment { private TextView textView; private TextView textView2; private CheckBoxCell checkBoxCell; + private CheckBoxCell testBackendCell; private int countryState = 0; @@ -1541,6 +1542,39 @@ public class LoginActivity extends BaseFragment { }); } + testBackendCell = new CheckBoxCell(context, 2); + testBackendCell.setText(LocaleController.getString("TestBackend", R.string.TestBackend), "", (ConnectionsManager.native_isTestBackend(currentAccount) != 0), false); + addView(testBackendCell, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.LEFT | Gravity.TOP, 0, 0, 0, 0)); + testBackendCell.setOnClickListener(new OnClickListener() { + + private Toast visibleToast; + + @Override + public void onClick(View v) { + if (getParentActivity() == null) { + return; + } + CheckBoxCell cell = (CheckBoxCell) v; + ConnectionsManager.native_switchBackend(currentAccount); + boolean isTestBackend = ConnectionsManager.native_isTestBackend(currentAccount) != 0; + cell.setChecked(isTestBackend, true); + try { + if (visibleToast != null) { + visibleToast.cancel(); + } + } catch (Exception e) { + FileLog.e(e); + } + if (isTestBackend) { + visibleToast = Toast.makeText(getParentActivity(), LocaleController.getString("TestBackendOn", R.string.TestBackendOn), Toast.LENGTH_SHORT); + visibleToast.show(); + } else { + visibleToast = Toast.makeText(getParentActivity(), LocaleController.getString("TestBackendOff", R.string.TestBackendOff), Toast.LENGTH_SHORT); + visibleToast.show(); + } + } + }); + HashMap languageMap = new HashMap<>(); try { BufferedReader reader = new BufferedReader(new InputStreamReader(getResources().getAssets().open("countries.txt"))); @@ -1729,7 +1763,7 @@ public class LoginActivity extends BaseFragment { continue; } String userPhone = userConfig.getCurrentUser().phone; - if (PhoneNumberUtils.compare(phone, userPhone)) { + if (PhoneNumberUtils.compare(phone, userPhone) && ConnectionsManager.native_isTestBackend(currentAccount) == ConnectionsManager.native_isTestBackend(a)) { final int num = a; AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); builder.setTitle(LocaleController.getString("NekogramWithEmoji", R.string.NekogramWithEmoji)); diff --git a/TMessagesProj/src/main/res/values-it/strings_neko.xml b/TMessagesProj/src/main/res/values-it/strings_neko.xml index 5e0bf86e8..4823793b4 100644 --- a/TMessagesProj/src/main/res/values-it/strings_neko.xml +++ b/TMessagesProj/src/main/res/values-it/strings_neko.xml @@ -46,4 +46,7 @@ Mostra fuochi d\'artificio* Le opzioni con * potrebbero avere bisogno di un riavvio per avere effetto. Elimina il file scaricato + Test Backend + Questo account si connetterà al server di test. + Questo account si connetterà al server principale. diff --git a/TMessagesProj/src/main/res/values-ja/strings_neko.xml b/TMessagesProj/src/main/res/values-ja/strings_neko.xml index 0678c3768..610285c72 100644 --- a/TMessagesProj/src/main/res/values-ja/strings_neko.xml +++ b/TMessagesProj/src/main/res/values-ja/strings_neko.xml @@ -46,4 +46,7 @@ 花火を見ましょう* 注 * オプションを有効にするには、再起動が必要な場合があります。 キャッシュを削除 + 異世界 + このアカウントは、テストバックエンドに接続します。 + このアカウントは、本番バックエンドに接続します。 \ No newline at end of file diff --git a/TMessagesProj/src/main/res/values-zh-rCN/strings_neko.xml b/TMessagesProj/src/main/res/values-zh-rCN/strings_neko.xml index 2b478ea07..935956f96 100644 --- a/TMessagesProj/src/main/res/values-zh-rCN/strings_neko.xml +++ b/TMessagesProj/src/main/res/values-zh-rCN/strings_neko.xml @@ -46,4 +46,7 @@ 一起去看烟花吧* 注 * 的选项可能需要重启才能生效。 删除缓存的文件 + 异世界 + 此账户将连接至测试后端服务器。 + 此账户将连接至生产后端服务器。 \ No newline at end of file diff --git a/TMessagesProj/src/main/res/values-zh-rTW/strings_neko.xml b/TMessagesProj/src/main/res/values-zh-rTW/strings_neko.xml index c798cd2de..3f5c5daa9 100644 --- a/TMessagesProj/src/main/res/values-zh-rTW/strings_neko.xml +++ b/TMessagesProj/src/main/res/values-zh-rTW/strings_neko.xml @@ -46,4 +46,7 @@ 一起去看煙花吧* 注 * 的選項可能需要重啟才能生效。 刪除緩存的文件 + 異世界 + 此賬戶將連接至測試後端伺服器。 + 此賬戶將連接至生產後端伺服器。 \ No newline at end of file diff --git a/TMessagesProj/src/main/res/values/strings_neko.xml b/TMessagesProj/src/main/res/values/strings_neko.xml index 32c12e56a..67081a1c1 100644 --- a/TMessagesProj/src/main/res/values/strings_neko.xml +++ b/TMessagesProj/src/main/res/values/strings_neko.xml @@ -51,4 +51,7 @@ Show fireworks* Options with * may need restart to take effect. Delete downloaded file + Test Backend + This account will connect to the test backend. + This account will connect to the production backend. \ No newline at end of file