1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2024-12-23 03:11:30 +00:00

Set proper default name for local device

This commit is contained in:
Felix Ableitner 2016-12-22 15:14:54 +09:00
parent 1df103cb0f
commit 0539d0b5a0

View file

@ -72,6 +72,7 @@ public class ConfigXml {
}
if (isFirstStart) {
changeLocalDeviceName();
changeDefaultFolder();
generateLoginInfo();
}
@ -174,6 +175,23 @@ public class ConfigXml {
.getElementsByTagName("gui").item(0);
}
/**
* Set model name as device name for Syncthing.
*
* We need to iterate through XML nodes manually, as mConfig.getDocumentElement() will also
* return nested elements inside folder element.
*/
private void changeLocalDeviceName() {
NodeList childNodes = mConfig.getDocumentElement().getChildNodes();
for (int i = 0; i < childNodes.getLength(); i++) {
Node node = childNodes.item(i);
if (node.getNodeName().equals("device")) {
((Element) node).setAttribute("name", Build.MODEL);
}
}
saveChanges();
}
/**
* Change default folder id to camera and path to camera folder path.
*/