|
@@ -14,7 +14,6 @@ import android.view.View;
|
|
|
import android.view.View.OnClickListener;
|
|
import android.view.View.OnClickListener;
|
|
|
import android.widget.EditText;
|
|
import android.widget.EditText;
|
|
|
import android.widget.ImageButton;
|
|
import android.widget.ImageButton;
|
|
|
-import android.widget.RadioGroup;
|
|
|
|
|
import android.widget.Toast;
|
|
import android.widget.Toast;
|
|
|
|
|
|
|
|
public class ServerSettingActivity extends Activity
|
|
public class ServerSettingActivity extends Activity
|
|
@@ -58,23 +57,23 @@ public class ServerSettingActivity extends Activity
|
|
|
SharedPreferences pref = RedAntApplication.getInstance()
|
|
SharedPreferences pref = RedAntApplication.getInstance()
|
|
|
.getSharedPreferences("RA Image", 0);
|
|
.getSharedPreferences("RA Image", 0);
|
|
|
|
|
|
|
|
- String ia = pref.getString("ia", null);
|
|
|
|
|
- String ea = pref.getString("ea", null);
|
|
|
|
|
|
|
+// String ia = pref.getString("ia", null);
|
|
|
|
|
+// String ea = pref.getString("ea", null);
|
|
|
String aa = pref.getString("aa", null);
|
|
String aa = pref.getString("aa", null);
|
|
|
String station_name = pref.getString("station name", null);
|
|
String station_name = pref.getString("station name", null);
|
|
|
- RadioGroup rg = (RadioGroup) findViewById(R.id.radioGroup1);
|
|
|
|
|
|
|
+// RadioGroup rg = (RadioGroup) findViewById(R.id.radioGroup1);
|
|
|
|
|
|
|
|
- if (!TextUtils.isEmpty(aa) && aa.equals(ia))
|
|
|
|
|
- rg.check(R.id.radio0);
|
|
|
|
|
|
|
+// if (!TextUtils.isEmpty(aa) && aa.equals(ia))
|
|
|
|
|
+// rg.check(R.id.radio0);
|
|
|
|
|
|
|
|
- if (!TextUtils.isEmpty(aa) && aa.equals(ea))
|
|
|
|
|
- rg.check(R.id.radio1);
|
|
|
|
|
|
|
+// if (!TextUtils.isEmpty(aa) && aa.equals(ea))
|
|
|
|
|
+// rg.check(R.id.radio1);
|
|
|
|
|
|
|
|
EditText et_ia = (EditText) findViewById(R.id.et_ia);
|
|
EditText et_ia = (EditText) findViewById(R.id.et_ia);
|
|
|
- EditText et_ea = (EditText) findViewById(R.id.et_ea);
|
|
|
|
|
|
|
+// EditText et_ea = (EditText) findViewById(R.id.et_ea);
|
|
|
EditText et_name = (EditText) findViewById(R.id.et_name);
|
|
EditText et_name = (EditText) findViewById(R.id.et_name);
|
|
|
- et_ea.setText(ea);
|
|
|
|
|
- et_ia.setText(ia);
|
|
|
|
|
|
|
+// et_ea.setText(ea);
|
|
|
|
|
+ et_ia.setText(aa);
|
|
|
et_name.setText(station_name);
|
|
et_name.setText(station_name);
|
|
|
|
|
|
|
|
ImageButton ibtn = (ImageButton) findViewById(R.id.ibtn_scan);
|
|
ImageButton ibtn = (ImageButton) findViewById(R.id.ibtn_scan);
|
|
@@ -126,17 +125,27 @@ public class ServerSettingActivity extends Activity
|
|
|
return ;//Network.RESULT_NET_ERROR;
|
|
return ;//Network.RESULT_NET_ERROR;
|
|
|
}
|
|
}
|
|
|
String address[]=jstr.split(";");
|
|
String address[]=jstr.split(";");
|
|
|
- if (address.length<3)
|
|
|
|
|
|
|
+ EditText et_ia = (EditText) findViewById(R.id.et_ia);
|
|
|
|
|
+// EditText et_ea = (EditText) findViewById(R.id.et_ea);
|
|
|
|
|
+ EditText et_name = (EditText) findViewById(R.id.et_name);
|
|
|
|
|
+ if (address.length==3)
|
|
|
|
|
+ {
|
|
|
|
|
+ et_ia.setText(address[2].trim());
|
|
|
|
|
+ et_name.setText(address[0].trim());
|
|
|
|
|
+ }
|
|
|
|
|
+ else if(address.length==2)
|
|
|
|
|
+ {
|
|
|
|
|
+ et_ia.setText(address[1].trim());
|
|
|
|
|
+ et_name.setText(address[0].trim());
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
{
|
|
{
|
|
|
toast();
|
|
toast();
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- EditText et_ia = (EditText) findViewById(R.id.et_ia);
|
|
|
|
|
- EditText et_ea = (EditText) findViewById(R.id.et_ea);
|
|
|
|
|
- EditText et_name = (EditText) findViewById(R.id.et_name);
|
|
|
|
|
- et_ea.setText(address[2].trim());
|
|
|
|
|
- et_ia.setText(address[1].trim());
|
|
|
|
|
- et_name.setText(address[0].trim());
|
|
|
|
|
|
|
+
|
|
|
|
|
+// et_ea.setText(address[2].trim());
|
|
|
|
|
+
|
|
|
// JSONObject jsobj;
|
|
// JSONObject jsobj;
|
|
|
// try
|
|
// try
|
|
|
// {
|
|
// {
|
|
@@ -191,20 +200,24 @@ public class ServerSettingActivity extends Activity
|
|
|
if (id == R.id.action_save)
|
|
if (id == R.id.action_save)
|
|
|
{
|
|
{
|
|
|
EditText et_ia = (EditText) findViewById(R.id.et_ia);
|
|
EditText et_ia = (EditText) findViewById(R.id.et_ia);
|
|
|
- EditText et_ea = (EditText) findViewById(R.id.et_ea);
|
|
|
|
|
|
|
+// EditText et_ea = (EditText) findViewById(R.id.et_ea);
|
|
|
EditText et_name = (EditText) findViewById(R.id.et_name);
|
|
EditText et_name = (EditText) findViewById(R.id.et_name);
|
|
|
String ia = et_ia.getText().toString();
|
|
String ia = et_ia.getText().toString();
|
|
|
- String ea = et_ea.getText().toString();
|
|
|
|
|
|
|
+// String ea = et_ea.getText().toString();
|
|
|
String name = et_name.getText().toString();
|
|
String name = et_name.getText().toString();
|
|
|
- if (TextUtils.isEmpty(ia) && TextUtils.isEmpty(ea))
|
|
|
|
|
|
|
+ if (TextUtils.isEmpty(ia) )
|
|
|
{
|
|
{
|
|
|
- showdialog("Active server address can not be empty!");
|
|
|
|
|
|
|
+ showdialog("Server address can not be empty!");
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
SharedPreferences pref = RedAntApplication.getInstance()
|
|
SharedPreferences pref = RedAntApplication.getInstance()
|
|
|
.getSharedPreferences("RA Image", 0);
|
|
.getSharedPreferences("RA Image", 0);
|
|
|
SharedPreferences.Editor editor = pref.edit();
|
|
SharedPreferences.Editor editor = pref.edit();
|
|
|
|
|
+
|
|
|
|
|
+ editor.putString("aa", ia);
|
|
|
|
|
+ RedAntApplication.active_address = ia;
|
|
|
|
|
+
|
|
|
if (TextUtils.isEmpty(name))
|
|
if (TextUtils.isEmpty(name))
|
|
|
{
|
|
{
|
|
|
showdialog("Station name can not be empty!");
|
|
showdialog("Station name can not be empty!");
|
|
@@ -214,46 +227,47 @@ public class ServerSettingActivity extends Activity
|
|
|
|
|
|
|
|
editor.putString("station name", name);
|
|
editor.putString("station name", name);
|
|
|
}
|
|
}
|
|
|
- if (!TextUtils.isEmpty(ia))
|
|
|
|
|
- {
|
|
|
|
|
|
|
+// if (!TextUtils.isEmpty(ia))
|
|
|
|
|
+// {
|
|
|
|
|
+//
|
|
|
|
|
+// if (!ia.substring(ia.length() - 1).equals("/"))
|
|
|
|
|
+// ia = ia + "/";
|
|
|
|
|
+// editor.putString("ia", ia);
|
|
|
|
|
+// }
|
|
|
|
|
+// if (!TextUtils.isEmpty(ea))
|
|
|
|
|
+// {
|
|
|
|
|
+// if (!ea.substring(ea.length() - 1).equals("/"))
|
|
|
|
|
+// ea = ea + "/";
|
|
|
|
|
+// editor.putString("ea", ea);
|
|
|
|
|
+// }
|
|
|
|
|
+// RadioGroup rg = (RadioGroup) findViewById(R.id.radioGroup1);
|
|
|
|
|
+// if (rg.getCheckedRadioButtonId() == R.id.radio0)
|
|
|
|
|
+// {
|
|
|
|
|
+// if (!TextUtils.isEmpty(ia))
|
|
|
|
|
+// {
|
|
|
|
|
+// editor.putString("aa", ia);
|
|
|
|
|
+// RedAntApplication.active_address = ia;
|
|
|
|
|
+// }
|
|
|
|
|
+// else
|
|
|
|
|
+// {
|
|
|
|
|
+// showdialog("Active server address can not be empty!");
|
|
|
|
|
+// return true;
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
+// else
|
|
|
|
|
+// {
|
|
|
|
|
+// if (!TextUtils.isEmpty(ea))
|
|
|
|
|
+// {
|
|
|
|
|
+// editor.putString("aa", ea);
|
|
|
|
|
+// RedAntApplication.active_address = ea;
|
|
|
|
|
+// }
|
|
|
|
|
+// else
|
|
|
|
|
+// {
|
|
|
|
|
+// showdialog("Active server address can not be empty!");
|
|
|
|
|
+// return true;
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
|
|
|
- if (!ia.substring(ia.length() - 1).equals("/"))
|
|
|
|
|
- ia = ia + "/";
|
|
|
|
|
- editor.putString("ia", ia);
|
|
|
|
|
- }
|
|
|
|
|
- if (!TextUtils.isEmpty(ea))
|
|
|
|
|
- {
|
|
|
|
|
- if (!ea.substring(ea.length() - 1).equals("/"))
|
|
|
|
|
- ea = ea + "/";
|
|
|
|
|
- editor.putString("ea", ea);
|
|
|
|
|
- }
|
|
|
|
|
- RadioGroup rg = (RadioGroup) findViewById(R.id.radioGroup1);
|
|
|
|
|
- if (rg.getCheckedRadioButtonId() == R.id.radio0)
|
|
|
|
|
- {
|
|
|
|
|
- if (!TextUtils.isEmpty(ia))
|
|
|
|
|
- {
|
|
|
|
|
- editor.putString("aa", ia);
|
|
|
|
|
- RedAntApplication.active_address = ia;
|
|
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
- showdialog("Active server address can not be empty!");
|
|
|
|
|
- return true;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
- if (!TextUtils.isEmpty(ea))
|
|
|
|
|
- {
|
|
|
|
|
- editor.putString("aa", ea);
|
|
|
|
|
- RedAntApplication.active_address = ea;
|
|
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
- showdialog("Active server address can not be empty!");
|
|
|
|
|
- return true;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
RedAntApplication.station_name = name;
|
|
RedAntApplication.station_name = name;
|
|
|
|
|
|
|
|
editor.remove("Lat");
|
|
editor.remove("Lat");
|