Code Conventions und auf Englisch übersetzt

This commit is contained in:
m_broelemann 2021-01-06 21:22:32 +01:00
parent 4073adce47
commit 20c18ce389
5 changed files with 30 additions and 37 deletions

View File

@ -46,7 +46,7 @@ public class MainActivity extends AppCompatActivity {
/** zur Verwendung von xml anstatt der direkten Einbindung.*/ /** zur Verwendung von xml anstatt der direkten Einbindung.*/
public IXML xml; public IXML xml;
/** zur Verwendung von uebergabe anstatt der direkten Einbindung.*/ /** zur Verwendung von uebergabe anstatt der direkten Einbindung.*/
public Communicator uebergabe; public Communicator delivery;
/** Handler for the custom user configurations. **/ /** Handler for the custom user configurations. **/
public ConfigurationHandler configurationHandler; public ConfigurationHandler configurationHandler;
/** zur Verwendung von favorite anstatt der direkten Einbindung.*/ /** zur Verwendung von favorite anstatt der direkten Einbindung.*/
@ -61,9 +61,9 @@ public class MainActivity extends AppCompatActivity {
ensurePermissions(); ensurePermissions();
setupConfigs(); setupConfigs();
favorite = configurationHandler; favorite = configurationHandler;
uebergabe = new Communicator(configurationHandler.getAddress(), delivery = new Communicator(configurationHandler.getAddress(),
configurationHandler.getPort(), this); configurationHandler.getPort(), this);
uebergabe.downloadXML(); delivery.downloadXML();
setContentView(R.layout.activity_main); setContentView(R.layout.activity_main);
Toolbar toolbar = findViewById(R.id.toolbar); Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
@ -105,7 +105,7 @@ public class MainActivity extends AppCompatActivity {
MaterialAlertDialogBuilder(MainActivity.this); MaterialAlertDialogBuilder(MainActivity.this);
//alert.setTitle(R.string.action_set_connection); //alert.setTitle(R.string.action_set_connection);
View view2 = LayoutInflater.from(MainActivity.this).inflate(R. View view2 = LayoutInflater.from(MainActivity.this).inflate(R.
layout.alert_dialog_ip_pot_eingabe, null); layout.alert_dialog_ip_pot, null);
EditText ipAdress = (EditText) view2.findViewById(R.id. EditText ipAdress = (EditText) view2.findViewById(R.id.
editTextIp); editTextIp);
ipAdress.setText(configurationHandler.getAddress()); ipAdress.setText(configurationHandler.getAddress());
@ -127,7 +127,7 @@ public class MainActivity extends AppCompatActivity {
+ ":" + configurationHandler. + ":" + configurationHandler.
getPort() + " is set", getPort() + " is set",
Toast.LENGTH_SHORT).show(); Toast.LENGTH_SHORT).show();
uebergabe = new Communicator( delivery = new Communicator(
configurationHandler.getAddress(), configurationHandler.getAddress(),
configurationHandler.getPort(), configurationHandler.getPort(),
MainActivity.this); MainActivity.this);
@ -172,13 +172,15 @@ public class MainActivity extends AppCompatActivity {
break; break;
case R.id.action_download_xml: case R.id.action_download_xml:
uebergabe.downloadXML(); delivery.downloadXML();
Toast.makeText(this, "Downloaded .xml", Toast.makeText(this, "Downloaded .xml",
Toast.LENGTH_SHORT).show(); Toast.LENGTH_SHORT).show();
break; break;
case R.id.action_upload_xml: case R.id.action_upload_xml:
try { try {
uebergabe.uploadXML(); delivery.uploadXML();
Toast.makeText(this, "Upload .xml executed",
Toast.LENGTH_SHORT).show();
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
e.printStackTrace(); e.printStackTrace();
Toast.makeText(this, "Upload .xml failed", Toast.makeText(this, "Upload .xml failed",

View File

@ -19,19 +19,19 @@ public class MainListViewAdapter extends BaseAdapter {
*/ */
private MainActivity mainActivity; private MainActivity mainActivity;
/** /**
* Welche ansicht gewählt wurde 0 für all IOs, 1 r favorite IOs. * Which view was selected, 0 for all IOs, 1 for favorite IOs.
*/ */
private int favoriteMode; private int favoriteMode;
/** /**
* Name des devices für den aktuellen durchlauf. * Name of the device for the current run.
*/ */
private String deviceName; private String deviceName;
/** /**
* Bild für Favorit oder nicht. * Image for favorite or not.
*/ */
private int favoriteImage; private int favoriteImage;
/** /**
* Liste der beim öffnen der Favoritenansicht bestehenden Favoriten. * List of favorites existing when opening the favorites view.
*/ */
private List<String> favoritenList; private List<String> favoritenList;
@ -46,9 +46,8 @@ public class MainListViewAdapter extends BaseAdapter {
this.favoriteMode = pFavoriteMode; this.favoriteMode = pFavoriteMode;
} }
/** /**
* @return Anzahl der Anzeigen * @return devices number
*/ */
@Override @Override
public int getCount() { public int getCount() {
@ -117,7 +116,6 @@ public class MainListViewAdapter extends BaseAdapter {
if (favoriteMode == 0) { if (favoriteMode == 0) {
deviceName = mainActivity.xml.getDeviceNames().get(i); deviceName = mainActivity.xml.getDeviceNames().get(i);
} else { } else {
List<String> test = favoritenList;
deviceName = favoritenList.get(i); deviceName = favoritenList.get(i);
} }
if (mainActivity.favorite.getFavorites().contains(deviceName)) { if (mainActivity.favorite.getFavorites().contains(deviceName)) {

View File

@ -18,26 +18,21 @@ import java.util.List;
public class PinView { public class PinView {
/** /**
* Einbinden der MainActivity. * Include the MainActivity.
*/ */
private MainActivity mainActivity; private MainActivity mainActivity;
/** /**
* Statusbild für den atuellen durchlauf. * Image for state.
*/ */
private int image; private int image;
/** /**
* Werte der Pins. * Values of the pins.
*/ */
private List<String> pinValues = new ArrayList<>(); private List<String> pinValues = new ArrayList<>();
/** /**
* Gerätenamen. * Device name.
*/ */
private String deviceName; private String deviceName;
/**
* DutyCycle.
*/
private String dutyValue;
/** /**
* @param pMainActivity * @param pMainActivity
@ -53,13 +48,12 @@ public class PinView {
* @return view * @return view
*/ */
public View getView(final int i) { public View getView(final int i) {
dutyValue = "";
View view = mainActivity.getLayoutInflater().inflate(R.layout. View view = mainActivity.getLayoutInflater().inflate(R.layout.
pin_listview_layout, null); pin_listview_layout, null);
TextView textViewPin = (TextView) view.findViewById(R.id.textPin); TextView textViewPin = (TextView) view.findViewById(R.id.textPin);
textViewPin.setText(((List<String>) (mainActivity.xml.getPort( textViewPin.setText(((List<String>) (mainActivity.xml.getPort(
deviceName)).get("pins")).get(i)); deviceName)).get("pins")).get(i));
mainActivity.uebergabe.read(deviceName, new Response. mainActivity.delivery.read(deviceName, new Response.
Listener<JSONObject>() { Listener<JSONObject>() {
@Override @Override
public void onResponse(final JSONObject response) { public void onResponse(final JSONObject response) {
@ -92,7 +86,7 @@ public class PinView {
(mainActivity.xml.getPort( (mainActivity.xml.getPort(
deviceName)).get("pins")). deviceName)).get("pins")).
get(i) + "\":" + setState + "}}"); get(i) + "\":" + setState + "}}");
mainActivity.uebergabe.write(deviceName, jsonObject, mainActivity.delivery.write(deviceName, jsonObject,
new Response.Listener<JSONObject>() { new Response.Listener<JSONObject>() {
@Override @Override
public void onResponse(final JSONObject response public void onResponse(final JSONObject response
@ -108,11 +102,12 @@ public class PinView {
MaterialAlertDialogBuilder alert = MaterialAlertDialogBuilder alert =
new MaterialAlertDialogBuilder(mainActivity); new MaterialAlertDialogBuilder(mainActivity);
View viewAlert = mainActivity.getLayoutInflater(). View viewAlert = mainActivity.getLayoutInflater().
inflate(R.layout.alert_dialog_pwm, null); inflate(R.layout.alert_dialog_duty, null);
RangeSlider readDuty = (RangeSlider) viewAlert. RangeSlider readDuty = (RangeSlider) viewAlert.
findViewById(R.id.range_slider_duty); findViewById(R.id.range_slider_duty);
readDuty.setValues((float) Float.valueOf(pinValues. readDuty.setValues((float) Float.valueOf(pinValues.
get(i))); get(i).equals("None") ? "0" : pinValues.get(i))
);
alert.setView(viewAlert); alert.setView(viewAlert);
alert.setPositiveButton("set", alert.setPositiveButton("set",
new DialogInterface.OnClickListener() { new DialogInterface.OnClickListener() {
@ -123,15 +118,13 @@ public class PinView {
intValue(); intValue();
try { try {
JSONObject jsonObject = JSONObject jsonObject =
new JSONObject( new JSONObject("{\"output\":{\""
"{\"output\":{\"" + ((List<String>) (
+ ((List<String>) mainActivity.xml.getPort(
(mainActivity.xml. deviceName)).get("pins")
getPort(deviceName)). ).get(i) + "\":\""
get("pins")).get(i) + value + "\"}}");
+ "\":\"" + value mainActivity.delivery.write(
+ "\"}}");
mainActivity.uebergabe.write(
deviceName, jsonObject, deviceName, jsonObject,
new Response. new Response.
Listener<JSONObject>() { Listener<JSONObject>() {