mirror of
https://github.com/wrwrabbit/Partisan-Telegram-Android.git
synced 2026-06-01 23:00:05 +00:00
show connection is disabled dialog after migration
This commit is contained in:
parent
10297251e8
commit
dac7035dfd
8 changed files with 36 additions and 8 deletions
|
|
@ -225,6 +225,11 @@ public class AppMigrator {
|
|||
}
|
||||
}
|
||||
|
||||
public static boolean isConnectionDisabled() {
|
||||
return SharedConfig.isProxyEnabled()
|
||||
&& isProxyForDisablingConnection(SharedConfig.currentProxy);
|
||||
}
|
||||
|
||||
public static void enableConnection() {
|
||||
for (SharedConfig.ProxyInfo proxyInfo : SharedConfig.proxyList) {
|
||||
if (isProxyForDisablingConnection(proxyInfo)) {
|
||||
|
|
@ -234,11 +239,11 @@ public class AppMigrator {
|
|||
}
|
||||
|
||||
private static boolean isProxyForDisablingConnection(SharedConfig.ProxyInfo proxyInfo) {
|
||||
return "127.0.0.1".equals(proxyInfo.address) && proxyInfo.port == 1080;
|
||||
return "127.0.0.1".equals(proxyInfo.address) && proxyInfo.port == -1;
|
||||
}
|
||||
|
||||
public static void disableConnection() {
|
||||
SharedConfig.ProxyInfo proxyInfo = new SharedConfig.ProxyInfo("127.0.0.1", 1080, "", "", "");
|
||||
SharedConfig.ProxyInfo proxyInfo = new SharedConfig.ProxyInfo("127.0.0.1", -1, "", "", "");
|
||||
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
SharedConfig.addProxy(proxyInfo);
|
||||
|
|
|
|||
|
|
@ -95,6 +95,7 @@ import org.telegram.messenger.Utilities;
|
|||
import org.telegram.messenger.browser.Browser;
|
||||
import org.telegram.messenger.fakepasscode.FakePasscodeUtils;
|
||||
import org.telegram.messenger.partisan.SpoofedLinkChecker;
|
||||
import org.telegram.messenger.partisan.appmigration.AppMigrator;
|
||||
import org.telegram.tgnet.ConnectionsManager;
|
||||
import org.telegram.tgnet.SerializedData;
|
||||
import org.telegram.tgnet.TLObject;
|
||||
|
|
@ -7251,6 +7252,19 @@ public class AlertsCreator {
|
|||
}
|
||||
}
|
||||
|
||||
public static void showConnectionDisabledDialogIfNeed(BaseFragment fragment, Runnable onAccepted) {
|
||||
if (AppMigrator.isConnectionDisabled() && !FakePasscodeUtils.isFakePasscodeActivated() && fragment != null) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(fragment.getContext());
|
||||
builder.setTitle(LocaleController.getString(R.string.ConnectionDisabledTitle));
|
||||
builder.setMessage(LocaleController.getString(R.string.ConnectionDisabledMessage));
|
||||
builder.setPositiveButton(LocaleController.getString(R.string.Continue), (dialog2, which) -> onAccepted.run());
|
||||
builder.setNegativeButton(LocaleController.getString(R.string.Cancel), null);
|
||||
fragment.showDialog(builder.create());
|
||||
} else if (onAccepted != null) {
|
||||
onAccepted.run();
|
||||
}
|
||||
}
|
||||
|
||||
public interface SoundFrequencyDelegate {
|
||||
void didSelectValues(int time, int minute);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -544,7 +544,9 @@ public class DataSettingsActivity extends BaseFragment {
|
|||
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
||||
showDialog(builder.create());
|
||||
} else if (position == proxyRow) {
|
||||
presentFragment(new ProxyListActivity());
|
||||
AlertsCreator.showConnectionDisabledDialogIfNeed(this, () -> {
|
||||
presentFragment(new ProxyListActivity());
|
||||
});
|
||||
} else if (position == enableStreamRow) {
|
||||
SharedConfig.toggleStreamMedia();
|
||||
TextCheckCell textCheckCell = (TextCheckCell) view;
|
||||
|
|
|
|||
|
|
@ -6703,7 +6703,9 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
|
|||
getNotificationsController().showNotifications();
|
||||
updatePasscodeButton();
|
||||
} else if (id == 2) {
|
||||
presentFragment(new ProxyListActivity());
|
||||
AlertsCreator.showConnectionDisabledDialogIfNeed(DialogsActivity.this, () -> {
|
||||
presentFragment(new ProxyListActivity());
|
||||
});
|
||||
} else if (id == 3) {
|
||||
showSearch(true, true, true);
|
||||
actionBar.openSearchField(true);
|
||||
|
|
|
|||
|
|
@ -7486,7 +7486,9 @@ public class LaunchActivity extends BasePermissionsActivity implements INavigati
|
|||
if (lastFragment instanceof ProxyListActivity || lastFragment instanceof ProxySettingsActivity) {
|
||||
return;
|
||||
}
|
||||
presentFragment(new ProxyListActivity());
|
||||
AlertsCreator.showConnectionDisabledDialogIfNeed(getLastFragment(), () -> {
|
||||
presentFragment(new ProxyListActivity());
|
||||
});
|
||||
};
|
||||
}
|
||||
actionBarLayout.setTitleOverlayText(title, titleId, action);
|
||||
|
|
|
|||
|
|
@ -807,7 +807,7 @@ public class LoginActivity extends BaseFragment implements NotificationCenter.No
|
|||
|
||||
proxyButtonView = new ImageView(context);
|
||||
proxyButtonView.setImageDrawable(proxyDrawable = new ProxyDrawable(context));
|
||||
proxyButtonView.setOnClickListener(v -> presentFragment(new ProxyListActivity()));
|
||||
proxyButtonView.setOnClickListener(v -> AlertsCreator.showConnectionDisabledDialogIfNeed(this, () -> presentFragment(new ProxyListActivity())));
|
||||
proxyButtonView.setAlpha(0f);
|
||||
proxyButtonView.setVisibility(View.GONE);
|
||||
sizeNotifierFrameLayout.addView(proxyButtonView, LayoutHelper.createFrame(32, 32, Gravity.RIGHT | Gravity.TOP, 16, 16, 16, 16));
|
||||
|
|
|
|||
|
|
@ -12077,8 +12077,8 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
|||
new SearchResult(217, LocaleController.getString("Calls", R.string.Calls), "callsSectionRow", LocaleController.getString("DataSettings", R.string.DataSettings), R.drawable.msg2_data, () -> presentFragment(new DataSettingsActivity())),
|
||||
new SearchResult(218, LocaleController.getString("VoipUseLessData", R.string.VoipUseLessData), "useLessDataForCallsRow", LocaleController.getString("DataSettings", R.string.DataSettings), R.drawable.msg2_data, () -> presentFragment(new DataSettingsActivity())),
|
||||
new SearchResult(219, LocaleController.getString("VoipQuickReplies", R.string.VoipQuickReplies), "quickRepliesRow", LocaleController.getString("DataSettings", R.string.DataSettings), R.drawable.msg2_data, () -> presentFragment(new DataSettingsActivity())),
|
||||
new SearchResult(220, LocaleController.getString("ProxySettings", R.string.ProxySettings), LocaleController.getString("DataSettings", R.string.DataSettings), R.drawable.msg2_data, () -> presentFragment(new ProxyListActivity())),
|
||||
new SearchResult(221, LocaleController.getString("UseProxyForCalls", R.string.UseProxyForCalls), "callsRow", LocaleController.getString("DataSettings", R.string.DataSettings), LocaleController.getString("ProxySettings", R.string.ProxySettings), R.drawable.msg2_data, () -> presentFragment(new ProxyListActivity())),
|
||||
new SearchResult(220, LocaleController.getString("ProxySettings", R.string.ProxySettings), LocaleController.getString("DataSettings", R.string.DataSettings), R.drawable.msg2_data, () -> AlertsCreator.showConnectionDisabledDialogIfNeed(ProfileActivity.this, () -> presentFragment(new ProxyListActivity()))),
|
||||
new SearchResult(221, LocaleController.getString("UseProxyForCalls", R.string.UseProxyForCalls), "callsRow", LocaleController.getString("DataSettings", R.string.DataSettings), LocaleController.getString("ProxySettings", R.string.ProxySettings), R.drawable.msg2_data, () -> AlertsCreator.showConnectionDisabledDialogIfNeed(ProfileActivity.this, () -> presentFragment(new ProxyListActivity()))),
|
||||
new SearchResult(111, LocaleController.getString("PrivacyDeleteCloudDrafts", R.string.PrivacyDeleteCloudDrafts), "clearDraftsRow", LocaleController.getString("DataSettings", R.string.DataSettings), R.drawable.msg2_data, () -> presentFragment(new DataSettingsActivity())),
|
||||
new SearchResult(222, LocaleController.getString(R.string.SaveToGallery), "saveToGallerySectionRow", LocaleController.getString(R.string.DataSettings), R.drawable.msg2_data, () -> presentFragment(new DataSettingsActivity())),
|
||||
new SearchResult(223, LocaleController.getString(R.string.SaveToGalleryPrivate), "saveToGalleryPeerRow", LocaleController.getString(R.string.DataSettings), LocaleController.getString(R.string.SaveToGallery), R.drawable.msg2_data, () -> presentFragment(new DataSettingsActivity())),
|
||||
|
|
|
|||
|
|
@ -9232,4 +9232,7 @@
|
|||
<string name="Step4">Step 4</string>
|
||||
<string name="UninstallSelfDescription">Telegram updated to version 3.0. Make sure that all data has been transferred to the new application. Then uninstall the old app.</string>
|
||||
<string name="UninstallSelf">Uninstall Old PTelegram</string>
|
||||
|
||||
<string name="ConnectionDisabledTitle">Connection is Disabled</string>
|
||||
<string name="ConnectionDisabledMessage">Your data has been transferred to another app and connection in current app is disabled. Turn it on only if there are problems with the new version of the app.</string>
|
||||
</resources>
|
||||
Loading…
Add table
Add a link
Reference in a new issue