Skip to content

Commit

Permalink
BlackBerry network choice
Browse files Browse the repository at this point in the history
  • Loading branch information
shinovon committed Jun 1, 2023
1 parent d6c4279 commit 9eb7b71
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
29 changes: 27 additions & 2 deletions src/mahomaps/MahoMapsApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import javax.microedition.io.ConnectionNotFoundException;
import javax.microedition.lcdui.Alert;
import javax.microedition.lcdui.Choice;
import javax.microedition.lcdui.ChoiceGroup;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
Expand Down Expand Up @@ -35,13 +37,32 @@ public class MahoMapsApp extends MIDlet implements Runnable, CommandListener {

private static Command exit = new Command("Выход", Command.EXIT, 0);
private static Command rms = new Command("Исп. RMS", Command.OK, 0);
private static boolean bbWifi;

private static boolean bb = platform.toLowerCase().indexOf("blackberry") != -1;
private Form bbForm;
private ChoiceGroup bbChoice;

public MahoMapsApp() {
display = Display.getDisplay(this);
if (bb) {
bbForm = new Form("Выберите используемую сеть");
bbChoice = new ChoiceGroup("", Choice.EXCLUSIVE, new String[] { "Сотовая", "Wi-Fi" }, null);
bbForm.addCommand(new Command("OK", Command.OK, 2));
bbForm.setCommandListener(this);
bbForm.append(bbChoice);
}
}

protected void startApp() {
paused = false;
if (bb) {
Settings.Read();
if (!Settings.bbNetworkChoosen && display.getCurrent() != bbForm) {
BringSubScreen(bbForm);
return;
}
}
if (thread == null) {
version = getAppProperty("MIDlet-Version");
midlet = this;
Expand Down Expand Up @@ -302,14 +323,18 @@ public void commandAction(Command c, Displayable d) {
Settings.cacheMode = Settings.CACHE_RMS;
Settings.Save();
startApp();
} else if (c.getPriority() == 2) {
bbWifi = bbChoice.getSelectedIndex() == 1;
Settings.bbNetworkChoosen = true;
Settings.Save();
startApp();
}
}

public static String getConnectionParams() {
if (platform.toLowerCase().indexOf("blackberry") == -1) {
if (!bb || !bbWifi) {
return "";
}
// сделать поддержку 3г когда-нибудь
return ";deviceside=true;interface=wifi";
}
}
3 changes: 3 additions & 0 deletions src/mahomaps/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ private Settings() {
public static boolean proxyApi = false;
public static int uiSize = 0;
public static int lang = 0;
public static boolean bbNetworkChoosen;

public static String proxyServer = "http://nnp.nnchan.ru:80/mahoproxy.php?u=";

Expand Down Expand Up @@ -54,6 +55,7 @@ public static boolean Read() {
proxyApi = j.optBoolean("proxy_api");
uiSize = j.optInt("ui_size", 0);
lang = j.optInt("lang", 0);
bbNetworkChoosen = j.optBoolean("bb_network");
return true;
} catch (Throwable e) {
e.printStackTrace();
Expand Down Expand Up @@ -85,6 +87,7 @@ public static String Serialize() {
j.put("proxy_api", proxyApi);
j.put("ui_size", uiSize);
j.put("lang", lang);
j.put("bb_network", bbNetworkChoosen);
return j.toString();
}

Expand Down

0 comments on commit 9eb7b71

Please sign in to comment.