changed the XML up and download to the IO interface as it involves communicating with the raspberry

This commit is contained in:
paul-loedige 2020-12-28 18:38:37 +01:00
parent ce240ef176
commit d03b7906f7
7 changed files with 32 additions and 34 deletions

1
APED/.idea/vcs.xml generated
View File

@ -2,5 +2,6 @@
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
<mapping directory="$PROJECT_DIR$/app/src/main/assets/XML" vcs="Git" />
</component>
</project>

View File

@ -106,13 +106,13 @@ public class MainActivity extends AppCompatActivity {
break;
case R.id.action_download_xml:
if (xml.download() == 0) {
Toast.makeText(this, "Download .xml",
if (uebergabe.downloadXML() == 0) {
Toast.makeText(this, "Downloaded .xml",
Toast.LENGTH_SHORT).show();
}
break;
case R.id.action_upload_xml:
if (xml.upload() == 0) {
if (uebergabe.uploadXML(new File("")) == 0) {
Toast.makeText(this, "Upload .xml",
Toast.LENGTH_SHORT).show();
}

View File

@ -1,5 +1,7 @@
package com.example.aped.communication;
import java.io.File;
public interface IIO
{
/**
@ -16,4 +18,17 @@ public interface IIO
* @return the value written
*/
String write(String deviceName, String value);
/**
* uploads the config.xml to the raspberry
* @param xmlFile the config.xml
* @return 0 if everything worked
*/
int uploadXML(File xmlFile);
/**
* downloads the current config.xml from the raspberry
* @return 0 if everything worked
*/
int downloadXML();
}

View File

@ -4,6 +4,8 @@ import android.widget.Toast;
import com.example.aped.R;
import java.io.File;
public class TestIO implements IIO {
@Override
@ -27,4 +29,15 @@ public class TestIO implements IIO {
public String write(String deviceName, String value) {
return "TRUE";//Wenn erfolgreich gesendet
}
@Override
public int uploadXML(File xmlFile) {
return 0;
}
@Override
public int downloadXML() {
return 0;
}
}

View File

@ -4,17 +4,6 @@ import java.util.Dictionary;
import java.util.List;
public interface IXML {
/**
* downloads the XML from the raspberry to the local folder
* @return 0 for no errors
*/
int download();
/**
* uploads the local XML to the raspberry
* @return 0 for no errors
*/
int upload();
/**
* reads the list of available devices from the XML

View File

@ -7,16 +7,6 @@ import java.util.Hashtable;
import java.util.List;
public class TestXML implements IXML {
/** Test Klasse.*/
@Override
public int download() {
return 0;
}
/** Test Klasse.*/
@Override
public int upload() {
return 0;
}
@Override
public List<String> getDeviceNames() {

View File

@ -46,16 +46,6 @@ public class XMLHandler implements IXML {
root = builder.parse(xmlFile);
}
@Override
public int download() {
throw new NotImplementedError();
}
@Override
public int upload() {
throw new NotImplementedError();
}
/**
* reads the device names from the XML file.
* @return the device names as a list of strings