|
|
|
@ -4,6 +4,7 @@ import androidx.appcompat.app.AppCompatActivity;
|
|
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
|
import android.os.Bundle;
|
|
|
|
|
import android.text.TextUtils;
|
|
|
|
|
import android.view.MenuItem;
|
|
|
|
|
import android.view.View;
|
|
|
|
|
import android.view.inputmethod.InputMethodManager;
|
|
|
|
@ -103,21 +104,45 @@ public class ChannelActivity extends AppCompatActivity {
|
|
|
|
|
InputStreamReader inputStreamReader = null;
|
|
|
|
|
BufferedReader bufferedReader = null;
|
|
|
|
|
try {
|
|
|
|
|
inputStreamReader = new InputStreamReader(new FileInputStream(new File(appPath + "data/channels/" + String.valueOf(channel) + ".json")), "UTF-8");
|
|
|
|
|
bufferedReader = new BufferedReader(inputStreamReader);
|
|
|
|
|
String line;
|
|
|
|
|
StringBuilder stringBuilder = new StringBuilder();
|
|
|
|
|
while ((line = bufferedReader.readLine()) != null) {
|
|
|
|
|
stringBuilder.append(line);
|
|
|
|
|
File channelFile = new File(appPath + "data/channels/" + String.valueOf(channel) + ".json");
|
|
|
|
|
StringBuilder stringBuilder = null;
|
|
|
|
|
if (channelFile.exists()) {
|
|
|
|
|
|
|
|
|
|
inputStreamReader = new InputStreamReader(new FileInputStream(channelFile), "UTF-8");
|
|
|
|
|
bufferedReader = new BufferedReader(inputStreamReader);
|
|
|
|
|
String line;
|
|
|
|
|
stringBuilder = new StringBuilder();
|
|
|
|
|
while ((line = bufferedReader.readLine()) != null) {
|
|
|
|
|
stringBuilder.append(line);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JSONObject jsonObject = new JSONObject(stringBuilder.toString());
|
|
|
|
|
JSONObject jsonObject = stringBuilder != null ? (new JSONObject(stringBuilder.toString())) : new JSONObject();
|
|
|
|
|
binding.btnAutoExplosure.setChecked(jsonObject.optInt("autoExposure", 1) == 1);
|
|
|
|
|
binding.btnAutoFocus.setChecked(jsonObject.optInt("autoFocus", 1) == 1);
|
|
|
|
|
binding.btnHdrMode.setChecked(jsonObject.optInt("hdr", 1) == 1);
|
|
|
|
|
binding.exposuretime.setText(Integer.toString(jsonObject.optInt("exposureTime", 0)));
|
|
|
|
|
binding.sensitivity.setText(Integer.toString(jsonObject.optInt("sensibility", 0)));
|
|
|
|
|
binding.orientations.setSelection(jsonObject.optInt("orientation", 0));
|
|
|
|
|
binding.recognization.setSelection(jsonObject.optInt("recognization", 0));
|
|
|
|
|
if (jsonObject.has("cameraId")) {
|
|
|
|
|
binding.cameraId.setText(Integer.toString(jsonObject.optInt("cameraId", channel - 1)));
|
|
|
|
|
} else {
|
|
|
|
|
binding.cameraId.setText("");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JSONObject osdJsonObj = jsonObject.optJSONObject("osd");
|
|
|
|
|
if (osdJsonObj != null) {
|
|
|
|
|
binding.osdLeftTop.setText(osdJsonObj.optString("leftTop", ""));
|
|
|
|
|
binding.osdRightTop.setText(osdJsonObj.optString("rightTop", ""));
|
|
|
|
|
binding.osdRightBottom.setText(osdJsonObj.optString("rightBottom", ""));
|
|
|
|
|
binding.osdLeftBottom.setText(osdJsonObj.optString("leftBottom", ""));
|
|
|
|
|
} else {
|
|
|
|
|
binding.osdLeftTop.setText("");
|
|
|
|
|
binding.osdRightTop.setText("");
|
|
|
|
|
binding.osdRightBottom.setText("");
|
|
|
|
|
binding.osdLeftBottom.setText("");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} catch (UnsupportedEncodingException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
@ -196,9 +221,25 @@ public class ChannelActivity extends AppCompatActivity {
|
|
|
|
|
jsonObject.put("exposureTime", Integer.parseInt(binding.exposuretime.getText().toString()));
|
|
|
|
|
jsonObject.put("sensibility", Integer.parseInt(binding.sensitivity.getText().toString()));
|
|
|
|
|
jsonObject.put("orientation", binding.orientations.getSelectedItemPosition());
|
|
|
|
|
jsonObject.put("recognization", binding.recognization.getSelectedItemPosition());
|
|
|
|
|
// binding.cameraId.setText(jsonObject.optString("cameraId", ""));
|
|
|
|
|
if (!TextUtils.isEmpty(binding.cameraId.getText().toString())) {
|
|
|
|
|
jsonObject.put("cameraId", Integer.parseInt(binding.cameraId.getText().toString()));
|
|
|
|
|
} else {
|
|
|
|
|
jsonObject.remove("cameraId");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} catch (JSONException ex) {
|
|
|
|
|
JSONObject osdJsonObj = jsonObject.optJSONObject("osd");
|
|
|
|
|
if (osdJsonObj == null) {
|
|
|
|
|
osdJsonObj = jsonObject.put("osd", new JSONObject());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
osdJsonObj.put("leftTop", binding.osdLeftTop.getText().toString());
|
|
|
|
|
osdJsonObj.put("rightTop", binding.osdRightTop.getText().toString());
|
|
|
|
|
osdJsonObj.put("rightBottom", binding.osdRightBottom.getText().toString());
|
|
|
|
|
osdJsonObj.put("leftBottom", binding.osdLeftBottom.getText().toString());
|
|
|
|
|
|
|
|
|
|
} catch (JSONException ex) {
|
|
|
|
|
}
|
|
|
|
|
OutputStreamWriter outputStreamWriter = null;
|
|
|
|
|
try {
|
|
|
|
|