📄 settingform.java
字号:
package Hiisi;import javax.microedition.lcdui.ChoiceGroup;import javax.microedition.lcdui.Command;import javax.microedition.lcdui.CommandListener;import javax.microedition.lcdui.Display;import javax.microedition.lcdui.Displayable;import javax.microedition.lcdui.Form;import javax.microedition.lcdui.List;import javax.microedition.lcdui.TextField;import java.util.Vector;public class SettingForm extends Form implements CommandListener{ private Command[] command = new Command[2]; private ChoiceGroup modeSetting; private ChoiceGroup checkConnection; private ChoiceGroup logSetting; private ChoiceGroup uaSetting; private ChoiceGroup filtering; private TextField filteringURL; final int BLUETOOTH_MODE = 0; final int WAP_MODE = 1; private int gatewayMode = BLUETOOTH_MODE; private boolean logEnable = false; private int uaId = 0; private boolean filter = false; private String filterURL = HiisiMIDlet.hiisiMIDlet.getAppProperty("Filter"); private String defaultUrl = null; int getGatewayMode() { return gatewayMode; } int setGatewayMode(int mode) { gatewayMode = mode; modeSetting.setSelectedIndex(gatewayMode, true); return gatewayMode; } String getGatewayModeString() { if(gatewayMode == BLUETOOTH_MODE) return "[Bluetooth Mode]"; else return "[W-CDMA / GSM Mode]"; } void uncheckCheckConnection() { checkConnection.setSelectedIndex(0, false); } boolean isLogEnable() { return logEnable; } boolean setLogEnable(boolean log) { logEnable = log; if(logEnable) logSetting.setSelectedIndex(0, true); else logSetting.setSelectedIndex(1, true); return logEnable; } int getUaId() { return uaId; } int setUaId(int ua) { uaId = ua; uaSetting.setSelectedIndex(uaId, true); return uaId; } boolean isFilter() { return filter; } boolean setFilter(boolean filt) { filter = filt; filtering.setSelectedIndex(0, filter); return filter; } String getFilterURL() { return filterURL; } String setFilterURL(String url) { filterURL = url; return filterURL; } String getDefaultUrl() { return defaultUrl; } String setDefaultUrl(String addr) { defaultUrl = "btspp://" + addr + ":1;authenticate=false;encrypt=false;master=false"; return defaultUrl; } SettingForm() { super(HiisiMIDlet.hiisiMIDlet.proxyName); if(!HiisiMIDlet.hiisiMIDlet.getAppProperty("Default-Device").equals("000000000000")) { setDefaultUrl(HiisiMIDlet.hiisiMIDlet.getAppProperty("Default-Device")); } command[0] = new Command("Cancel", Command.EXIT, 1); command[1] = new Command("OK", Command.SCREEN, 2); addCommand(command[0]); addCommand(command[1]); setCommandListener(this); modeSetting = new ChoiceGroup("Mode", ChoiceGroup.EXCLUSIVE); append(modeSetting); modeSetting.append("Bluetooth", null); modeSetting.append("W-CDMA / GSM", null); setGatewayMode(gatewayMode); checkConnection = new ChoiceGroup("Bluetooth Connection", ChoiceGroup.MULTIPLE); append(checkConnection); checkConnection.append("Check now", null); checkConnection.setSelectedIndex(0, false); logSetting = new ChoiceGroup("Log", ChoiceGroup.EXCLUSIVE); append(logSetting); logSetting.append("Enable", null); logSetting.append("Recent 5 only", null); setLogEnable(logEnable); uaSetting = new ChoiceGroup("User Agent", ChoiceGroup.EXCLUSIVE); append(uaSetting); uaSetting.append(HiisiMIDlet.hiisiMIDlet.getAppProperty("User-Agent"), null); uaSetting.append(HiisiMIDlet.hiisiMIDlet.getAppProperty("User-Agent2"), null); uaSetting.append(HiisiMIDlet.hiisiMIDlet.getAppProperty("User-Agent3"), null); setUaId(uaId); filtering = new ChoiceGroup("Filtering", ChoiceGroup.MULTIPLE); append(filtering); filtering.append("Enable", null); setFilter(filter); filteringURL = new TextField("Filter's URL", filterURL, 100, TextField.URL); append(filteringURL); } private void makeReinquireGUI() { final List choice = new List("Select a device", List.IMPLICIT); if(HiisiMIDlet.hiisiMIDlet.bluetoothConnection.getSelectedDevice() != null && HiisiMIDlet.hiisiMIDlet.bluetoothConnection.getUrl() != null) { choice.append(HiisiMIDlet.hiisiMIDlet.bluetoothConnection.getSelectedDevice(), null); } choice.append("Inquire new device", null); if(HiisiMIDlet.settingForm.getDefaultUrl() != null) { choice.append("Use default device", null); } choice.setCommandListener( new CommandListener() { public void commandAction(Command c, Displayable d) { Display.getDisplay(HiisiMIDlet.hiisiMIDlet).setCurrent(HiisiMIDlet.mainForm); if(choice.getString(choice.getSelectedIndex()).equals("Inquire new device")) HiisiMIDlet.bluetoothConnection.startDeviceInquiry(); if(choice.getString(choice.getSelectedIndex()).equals("Use default device")) HiisiMIDlet.bluetoothConnection.setUrl(HiisiMIDlet.settingForm.getDefaultUrl()); } } ); Display.getDisplay(HiisiMIDlet.hiisiMIDlet).setCurrent(choice); } public void commandAction(Command c,Displayable d) { if(c == command[0]) { Display.getDisplay(HiisiMIDlet.hiisiMIDlet).setCurrent(HiisiMIDlet.mainForm); } if(c == command[1]) { Display.getDisplay(HiisiMIDlet.hiisiMIDlet).setCurrent(HiisiMIDlet.mainForm); if(logSetting.getSelectedIndex() == 0) setLogEnable(true); else setLogEnable(false); setUaId(uaSetting.getSelectedIndex()); if(filtering.isSelected(0) && modeSetting.getSelectedIndex() == 0) setFilter(true); else setFilter(false); setFilterURL(filteringURL.getString()); if(gatewayMode == BLUETOOTH_MODE && modeSetting.getSelectedIndex() == BLUETOOTH_MODE) { setGatewayMode(modeSetting.getSelectedIndex()); if(checkConnection.isSelected(0)) { HiisiMIDlet.gateway.checkConnection(); } else { HiisiMIDlet.mainForm.log("Hiisi Proxy " + getGatewayModeString() + " is idling..."); } } else if(gatewayMode == WAP_MODE && modeSetting.getSelectedIndex() == BLUETOOTH_MODE) { setGatewayMode(modeSetting.getSelectedIndex()); if(checkConnection.isSelected(0)) { HiisiMIDlet.mainForm.log("Cannnot check bluetooth connection.\nHiisi Proxy " + getGatewayModeString() + " is idling..."); } else { HiisiMIDlet.mainForm.log("Hiisi Proxy " + getGatewayModeString() + " is idling..."); } makeReinquireGUI(); } else { setGatewayMode(modeSetting.getSelectedIndex()); if(checkConnection.isSelected(0)) { HiisiMIDlet.mainForm.log("Cannnot check bluetooth connection.\nHiisi Proxy " + getGatewayModeString() + " is idling..."); } else { HiisiMIDlet.mainForm.log("Hiisi Proxy " + getGatewayModeString() + " is idling..."); } } } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -