diff --git a/src/main/java/com/nutomic/syncthingandroid/gui/MainActivity.java b/src/main/java/com/nutomic/syncthingandroid/gui/MainActivity.java index 0a9dfa6a..86597da5 100644 --- a/src/main/java/com/nutomic/syncthingandroid/gui/MainActivity.java +++ b/src/main/java/com/nutomic/syncthingandroid/gui/MainActivity.java @@ -266,7 +266,7 @@ public class MainActivity extends ActionBarActivity } switch (item.getItemId()) { - case R.id.add_repository: + case R.id.add_repo: Intent intent = new Intent(this, RepoSettingsActivity.class); intent.setAction(RepoSettingsActivity.ACTION_CREATE); startActivity(intent); diff --git a/src/main/java/com/nutomic/syncthingandroid/gui/RepoSettingsActivity.java b/src/main/java/com/nutomic/syncthingandroid/gui/RepoSettingsActivity.java index 74ad493c..37a4723f 100644 --- a/src/main/java/com/nutomic/syncthingandroid/gui/RepoSettingsActivity.java +++ b/src/main/java/com/nutomic/syncthingandroid/gui/RepoSettingsActivity.java @@ -37,7 +37,7 @@ public class RepoSettingsActivity extends PreferenceActivity public static final String ACTION_EDIT = "edit"; - public static final String KEY_REPO_ID = "repository_id"; + public static final String KEY_REPO_ID = "repo_id"; private static final String KEY_NODE_SHARED = "node_shared"; @@ -56,13 +56,13 @@ public class RepoSettingsActivity extends PreferenceActivity } }; - private RestApi.Repository mRepo; + private RestApi.Repo mRepo; - private EditTextPreference mRepositoryId; + private EditTextPreference mRepoId; private EditTextPreference mDirectory; - private CheckBoxPreference mRepositoryMaster; + private CheckBoxPreference mRepoMaster; private PreferenceScreen mNodes; @@ -83,12 +83,12 @@ public class RepoSettingsActivity extends PreferenceActivity addPreferencesFromResource(R.xml.repo_settings_edit); } - mRepositoryId = (EditTextPreference) findPreference("repository_id"); - mRepositoryId.setOnPreferenceChangeListener(this); + mRepoId = (EditTextPreference) findPreference("repo_id"); + mRepoId.setOnPreferenceChangeListener(this); mDirectory = (EditTextPreference) findPreference("directory"); mDirectory.setOnPreferenceChangeListener(this); - mRepositoryMaster = (CheckBoxPreference) findPreference("repository_master"); - mRepositoryMaster.setOnPreferenceChangeListener(this); + mRepoMaster = (CheckBoxPreference) findPreference("repo_master"); + mRepoMaster.setOnPreferenceChangeListener(this); mNodes = (PreferenceScreen) findPreference("nodes"); mVersioning = (CheckBoxPreference) findPreference("versioning"); mVersioning.setOnPreferenceChangeListener(this); @@ -112,7 +112,7 @@ public class RepoSettingsActivity extends PreferenceActivity if (getIntent().getAction().equals(ACTION_CREATE)) { setTitle(R.string.create_repo); - mRepo = new RestApi.Repository(); + mRepo = new RestApi.Repo(); mRepo.ID = ""; mRepo.Directory = ""; mRepo.Nodes = new ArrayList(); @@ -120,7 +120,7 @@ public class RepoSettingsActivity extends PreferenceActivity } else if (getIntent().getAction().equals(ACTION_EDIT)) { setTitle(R.string.edit_repo); - List repos = mSyncthingService.getApi().getRepos(); + List repos = mSyncthingService.getApi().getRepos(); for (int i = 0; i < repos.size(); i++) { if (repos.get(i).ID.equals(getIntent().getStringExtra(KEY_REPO_ID))) { mRepo = repos.get(i); @@ -129,11 +129,11 @@ public class RepoSettingsActivity extends PreferenceActivity } } - mRepositoryId.setText(mRepo.ID); - mRepositoryId.setSummary(mRepo.ID); + mRepoId.setText(mRepo.ID); + mRepoId.setSummary(mRepo.ID); mDirectory.setText(mRepo.Directory); mDirectory.setSummary(mRepo.Directory); - mRepositoryMaster.setChecked(mRepo.ReadOnly); + mRepoMaster.setChecked(mRepo.ReadOnly); List nodesList = mSyncthingService.getApi().getNodes(); for (RestApi.Node n : nodesList) { ExtendedCheckBoxPreference cbp = @@ -204,19 +204,19 @@ public class RepoSettingsActivity extends PreferenceActivity pref.setSummary((String) o); } - if (preference.equals(mRepositoryId)) { + if (preference.equals(mRepoId)) { mRepo.ID = (String) o; - repositoryUpdated(); + repoUpdated(); return true; } else if (preference.equals(mDirectory)) { mRepo.Directory = (String) o; - repositoryUpdated(); + repoUpdated(); return true; } - else if (preference.equals(mRepositoryMaster)) { + else if (preference.equals(mRepoMaster)) { mRepo.ReadOnly = (Boolean) o; - repositoryUpdated(); + repoUpdated(); return true; } else if (preference.getKey().equals(KEY_NODE_SHARED)) { @@ -232,7 +232,7 @@ public class RepoSettingsActivity extends PreferenceActivity } } } - repositoryUpdated(); + repoUpdated(); return true; } else if (preference.equals(mVersioning)) { @@ -247,13 +247,13 @@ public class RepoSettingsActivity extends PreferenceActivity else { mRepo.Versioning = new RestApi.Versioning(); } - repositoryUpdated(); + repoUpdated(); return true; } else if (preference.equals(mVersioningKeep)) { ((RestApi.SimpleVersioning) mRepo.Versioning) .setParams(Integer.parseInt((String) o)); - repositoryUpdated(); + repoUpdated(); return true; } @@ -279,7 +279,7 @@ public class RepoSettingsActivity extends PreferenceActivity return false; } - private void repositoryUpdated() { + private void repoUpdated() { if (getIntent().getAction().equals(ACTION_EDIT)) { mSyncthingService.getApi().editRepo(mRepo, false); } diff --git a/src/main/java/com/nutomic/syncthingandroid/syncthing/RestApi.java b/src/main/java/com/nutomic/syncthingandroid/syncthing/RestApi.java index 18038eb1..f0d71155 100644 --- a/src/main/java/com/nutomic/syncthingandroid/syncthing/RestApi.java +++ b/src/main/java/com/nutomic/syncthingandroid/syncthing/RestApi.java @@ -59,7 +59,7 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener { public long sys; } - public static class Repository { + public static class Repo { public String Directory; public String ID; public String Invalid; @@ -384,17 +384,17 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener { /** * Returns a list of all existing repositores. */ - public List getRepos() { + public List getRepos() { if (mConfig == null) - return new ArrayList(); + return new ArrayList(); - List ret = null; + List ret = null; try { JSONArray repos = mConfig.getJSONArray("Repositories"); - ret = new ArrayList(repos.length()); + ret = new ArrayList(repos.length()); for (int i = 0; i < repos.length(); i++) { JSONObject json = repos.getJSONObject(i); - Repository r = new Repository(); + Repo r = new Repo(); r.Directory = json.getString("Directory"); r.ID = json.getString("ID"); r.Invalid = json.getString("Invalid"); @@ -608,7 +608,7 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener { /** * Updates or creates the given node. */ - public void editRepo(Repository repo, boolean create) { + public void editRepo(Repo repo, boolean create) { try { JSONArray repos = mConfig.getJSONArray("Repositories"); JSONObject r = null; @@ -656,7 +656,7 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener { /** * Deletes the given repository from syncthing. */ - public void deleteRepo(Repository repo) { + public void deleteRepo(Repo repo) { try { JSONArray repos = mConfig.getJSONArray("Repositories"); diff --git a/src/main/java/com/nutomic/syncthingandroid/util/ReposAdapter.java b/src/main/java/com/nutomic/syncthingandroid/util/ReposAdapter.java index 0b5b8ed2..d580597d 100644 --- a/src/main/java/com/nutomic/syncthingandroid/util/ReposAdapter.java +++ b/src/main/java/com/nutomic/syncthingandroid/util/ReposAdapter.java @@ -17,7 +17,7 @@ import java.util.List; /** * Generates item views for repository items. */ -public class ReposAdapter extends ArrayAdapter +public class ReposAdapter extends ArrayAdapter implements RestApi.OnReceiveModelListener { private HashMap mModels = new HashMap(); @@ -67,8 +67,8 @@ public class ReposAdapter extends ArrayAdapter /** * Replacement for addAll, which is not implemented on lower API levels. */ - public void add(List nodes) { - for (RestApi.Repository r : nodes) { + public void add(List nodes) { + for (RestApi.Repo r : nodes) { add(r); } } diff --git a/src/main/res/menu/main_menu.xml b/src/main/res/menu/main_menu.xml index 0f8e4697..454528ae 100644 --- a/src/main/res/menu/main_menu.xml +++ b/src/main/res/menu/main_menu.xml @@ -10,7 +10,7 @@ app:showAsAction="ifRoom" /> diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 6575696a..916143e2 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -98,6 +98,8 @@ Keep Versions + Delete Repository + Create Repository diff --git a/src/main/res/xml/repo_settings_create.xml b/src/main/res/xml/repo_settings_create.xml index a1c05d47..0eb64ce9 100644 --- a/src/main/res/xml/repo_settings_create.xml +++ b/src/main/res/xml/repo_settings_create.xml @@ -3,7 +3,7 @@ android:persistent="false" > + android:title="@string/directory" /> + android:key="repo_master" + android:title="@string/repo_master" /> + android:title="@string/nodes" /> + android:title="@string/delete_repo" /> \ No newline at end of file