Skip to content

Commit

Permalink
fix: NPE in toggle proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
omg-xtao committed Feb 16, 2024
1 parent ca41952 commit 5644bac
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1429,19 +1429,25 @@ public static void setDistanceSystemType(int type) {
public static boolean proxyEnabled;

public static void setProxyEnable(boolean enable) {
if (enable && currentProxy == null) {
enable = false;
}

proxyEnabled = enable;

SharedPreferences preferences = MessagesController.getGlobalMainSettings();

preferences.edit().putBoolean("proxy_enabled", enable).commit();
preferences.edit().putBoolean("proxy_enabled", enable).apply();

ProxyInfo finalInfo = currentProxy;

UIUtil.runOnIoDispatcher(() -> {

ConnectionsManager.setProxySettings(enable, finalInfo.address, finalInfo.port, finalInfo.username, finalInfo.password, finalInfo.secret);

if (proxyEnabled) {
ConnectionsManager.setProxySettings(true, finalInfo.address, finalInfo.port, finalInfo.username, finalInfo.password, finalInfo.secret);
} else {
ConnectionsManager.setProxySettings(false, "", 0, "", "", "");
}
UIUtil.runOnUIThread(() -> NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.proxySettingsChanged));

});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public class NekoExperimentalSettingsActivity extends BaseNekoXSettingsActivity
// private final AbstractConfigCell smoothKeyboardRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.smoothKeyboard));
private final AbstractConfigCell enhancedFileLoaderRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.enhancedFileLoader));
private final AbstractConfigCell mediaPreviewRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.mediaPreview));
private final AbstractConfigCell proxyAutoSwitchRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.proxyAutoSwitch));
// private final AbstractConfigCell proxyAutoSwitchRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.proxyAutoSwitch));
private final AbstractConfigCell disableFilteringRow = cellGroup.appendCell(new ConfigCellCustom("DisableFiltering", CellGroup.ITEM_TYPE_TEXT_CHECK, true));
// private final NekomuraTGCell ignoreContentRestrictionsRow = addNekomuraTGCell(nkmrCells.new NekomuraTGTextCheck(NekoConfig.ignoreContentRestrictions, LocaleController.getString("IgnoreContentRestrictionsNotice")));
private final AbstractConfigCell unlimitedFavedStickersRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.unlimitedFavedStickers, LocaleController.getString("UnlimitedFavoredStickersAbout")));
Expand Down

0 comments on commit 5644bac

Please sign in to comment.