Behebung diverser Design Fehler
This commit is contained in:
parent
3e65d83ede
commit
ff777de343
@ -58,14 +58,18 @@ public class MainActivity extends AppCompatActivity {
|
||||
/** zur Verwendung von favorite anstatt der direkten Einbindung.*/
|
||||
public IFAVORITES favorite = new TestFavorites();
|
||||
/** allgemeines.*/
|
||||
String ip = "192.168.1.220";
|
||||
private String ip = "192.168.1.220";
|
||||
/**
|
||||
*
|
||||
* @param savedInstanceState
|
||||
*/
|
||||
@Override
|
||||
protected void onCreate(final Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
//checks that the permission to read and write the xml is granted
|
||||
ensurePermissions();
|
||||
setXML();
|
||||
uebergabe = new Communicator(ip,8080,this);
|
||||
uebergabe = new Communicator(ip, 8080, this);
|
||||
setContentView(R.layout.activity_main);
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
@ -104,11 +108,11 @@ public class MainActivity extends AppCompatActivity {
|
||||
public boolean onOptionsItemSelected(final @NonNull MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.action_set_IP:
|
||||
Toast.makeText(this, "set IP",
|
||||
Toast.LENGTH_SHORT).show();
|
||||
MaterialAlertDialogBuilder alert = new MaterialAlertDialogBuilder(MainActivity.this);
|
||||
MaterialAlertDialogBuilder alert = new
|
||||
MaterialAlertDialogBuilder(MainActivity.this);
|
||||
alert.setTitle(R.string.action_set_IP);
|
||||
alert.setMessage("Please enter the ip address of the device to be connected");
|
||||
alert.setMessage("Please enter the ip address of the "
|
||||
+ "device to be connected");
|
||||
final EditText input = new EditText(MainActivity.this);
|
||||
input.setText(ip);
|
||||
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
|
||||
@ -118,18 +122,25 @@ public class MainActivity extends AppCompatActivity {
|
||||
alert.setView(input);
|
||||
alert.setPositiveButton("connect",
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog,int which) {
|
||||
public void onClick(final DialogInterface dialog,
|
||||
final int which) {
|
||||
// Write your code here to execute after dialog
|
||||
ip = input.getText().toString();
|
||||
Toast.makeText(getApplicationContext(),ip +" IP connect", Toast.LENGTH_SHORT).show();
|
||||
uebergabe = new Communicator(ip,8080,MainActivity.this);
|
||||
Toast.makeText(getApplicationContext(),
|
||||
ip + " IP connect",
|
||||
Toast.LENGTH_SHORT).show();
|
||||
uebergabe = new Communicator(ip, 8080,
|
||||
MainActivity.this);
|
||||
}
|
||||
});
|
||||
alert.setNegativeButton("exit",
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
public void onClick(final DialogInterface dialog,
|
||||
final int which) {
|
||||
// Write your code here to execute after dialog
|
||||
Toast.makeText(getApplicationContext(),"exit clicked", Toast.LENGTH_SHORT).show();
|
||||
Toast.makeText(getApplicationContext(),
|
||||
"exit clicked",
|
||||
Toast.LENGTH_SHORT).show();
|
||||
dialog.cancel();
|
||||
}
|
||||
});
|
||||
@ -227,16 +238,18 @@ public class MainActivity extends AppCompatActivity {
|
||||
}
|
||||
}
|
||||
|
||||
private void setXML(){
|
||||
private void setXML() {
|
||||
try {
|
||||
String xmlPath = ExternalStorageHandler.getExternalPrivateStorageDir(MainActivity.this);
|
||||
File xmlFile = new File(xmlPath,"config.xml");
|
||||
String xmlPath = ExternalStorageHandler.
|
||||
getExternalPrivateStorageDir(MainActivity.this);
|
||||
File xmlFile = new File(xmlPath, "config.xml");
|
||||
|
||||
//create the default XML config by using the default.xml from the assets folder
|
||||
if (xmlFile.exists()){
|
||||
if (xmlFile.exists()) {
|
||||
xmlFile.delete();
|
||||
}
|
||||
InputStream inputStream = getAssets().open("XML/default.xml");
|
||||
InputStream inputStream = getAssets().open(
|
||||
"XML/default.xml");
|
||||
byte[] buffer = new byte[inputStream.available()];
|
||||
inputStream.read(buffer);
|
||||
inputStream.close();
|
||||
@ -246,9 +259,11 @@ public class MainActivity extends AppCompatActivity {
|
||||
|
||||
xml = new XMLHandler(xmlFile);
|
||||
} catch (FileNotFoundException e) {
|
||||
Log.e("Main Activity","Exception while reading the external private storage dir: " + e.getMessage());
|
||||
} catch (ParserConfigurationException | IOException | SAXException e){
|
||||
Log.e("Main Activity","XMLHandler failed to initialise: " + e.getMessage());
|
||||
Log.e("Main Activity", "Exception while reading the "
|
||||
+ "external private storage dir: " + e.getMessage());
|
||||
} catch (ParserConfigurationException | IOException | SAXException e) {
|
||||
Log.e("Main Activity", "XMLHandler failed to initialise: "
|
||||
+ e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user