mirror of
https://github.com/syncthing/syncthing-android.git
synced 2024-12-23 03:11:30 +00:00
Refactor "repository" to "repo" in class/variable names.
This commit is contained in:
parent
c21315b907
commit
139a6e9b03
8 changed files with 48 additions and 52 deletions
|
@ -28,7 +28,7 @@ import com.nutomic.syncthingandroid.syncthing.SyncthingService;
|
|||
import com.nutomic.syncthingandroid.syncthing.SyncthingServiceBinder;
|
||||
|
||||
/**
|
||||
* Shows {@link RepositoriesFragment} and {@link NodesFragment} in different tabs, and
|
||||
* Shows {@link ReposFragment} and {@link NodesFragment} in different tabs, and
|
||||
* {@link LocalNodeInfoFragment} in the navigation drawer.
|
||||
*/
|
||||
public class MainActivity extends ActionBarActivity
|
||||
|
@ -82,7 +82,7 @@ public class MainActivity extends ActionBarActivity
|
|||
|
||||
};
|
||||
|
||||
private RepositoriesFragment mRepositoriesFragment;
|
||||
private ReposFragment mRepositoriesFragment;
|
||||
|
||||
private NodesFragment mNodesFragment;
|
||||
|
||||
|
@ -137,8 +137,8 @@ public class MainActivity extends ActionBarActivity
|
|||
|
||||
if (savedInstanceState != null) {
|
||||
FragmentManager fm = getSupportFragmentManager();
|
||||
mRepositoriesFragment = (RepositoriesFragment) fm.getFragment(
|
||||
savedInstanceState, RepositoriesFragment.class.getName());
|
||||
mRepositoriesFragment = (ReposFragment) fm.getFragment(
|
||||
savedInstanceState, ReposFragment.class.getName());
|
||||
mNodesFragment = (NodesFragment) fm.getFragment(
|
||||
savedInstanceState, NodesFragment.class.getName());
|
||||
mLocalNodeInfoFragment = (LocalNodeInfoFragment) fm.getFragment(
|
||||
|
@ -146,7 +146,7 @@ public class MainActivity extends ActionBarActivity
|
|||
mViewPager.setCurrentItem(savedInstanceState.getInt("currentTab"));
|
||||
}
|
||||
else {
|
||||
mRepositoriesFragment = new RepositoriesFragment();
|
||||
mRepositoriesFragment = new ReposFragment();
|
||||
mNodesFragment = new NodesFragment();
|
||||
mLocalNodeInfoFragment = new LocalNodeInfoFragment();
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ public class MainActivity extends ActionBarActivity
|
|||
// Avoid crash if called during startup.
|
||||
if (mRepositoriesFragment != null && mNodesFragment != null) {
|
||||
FragmentManager fm = getSupportFragmentManager();
|
||||
fm.putFragment(outState, RepositoriesFragment.class.getName(), mRepositoriesFragment);
|
||||
fm.putFragment(outState, ReposFragment.class.getName(), mRepositoriesFragment);
|
||||
fm.putFragment(outState, NodesFragment.class.getName(), mNodesFragment);
|
||||
fm.putFragment(outState, LocalNodeInfoFragment.class.getName(), mLocalNodeInfoFragment);
|
||||
outState.putInt("currentTab", mViewPager.getCurrentItem());
|
||||
|
|
|
@ -20,7 +20,6 @@ import com.nutomic.syncthingandroid.syncthing.RestApi;
|
|||
import com.nutomic.syncthingandroid.syncthing.SyncthingService;
|
||||
import com.nutomic.syncthingandroid.syncthing.SyncthingServiceBinder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
|
|
@ -5,10 +5,10 @@ import android.view.View;
|
|||
import android.widget.AdapterView;
|
||||
import android.widget.ListView;
|
||||
|
||||
import com.nutomic.syncthingandroid.util.NodeAdapter;
|
||||
import com.nutomic.syncthingandroid.R;
|
||||
import com.nutomic.syncthingandroid.syncthing.RestApi;
|
||||
import com.nutomic.syncthingandroid.syncthing.SyncthingService;
|
||||
import com.nutomic.syncthingandroid.util.NodeAdapter;
|
||||
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
|
|
@ -17,11 +17,11 @@ import android.view.Menu;
|
|||
import android.view.MenuItem;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.nutomic.syncthingandroid.util.ExtendedCheckBoxPreference;
|
||||
import com.nutomic.syncthingandroid.R;
|
||||
import com.nutomic.syncthingandroid.syncthing.RestApi;
|
||||
import com.nutomic.syncthingandroid.syncthing.SyncthingService;
|
||||
import com.nutomic.syncthingandroid.syncthing.SyncthingServiceBinder;
|
||||
import com.nutomic.syncthingandroid.util.ExtendedCheckBoxPreference;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -37,7 +37,7 @@ public class RepoSettingsActivity extends PreferenceActivity
|
|||
|
||||
public static final String ACTION_EDIT = "edit";
|
||||
|
||||
public static final String KEY_REPOSITORY_ID = "repository_id";
|
||||
public static final String KEY_REPO_ID = "repository_id";
|
||||
|
||||
private static final String KEY_NODE_SHARED = "node_shared";
|
||||
|
||||
|
@ -57,7 +57,7 @@ public class RepoSettingsActivity extends PreferenceActivity
|
|||
}
|
||||
};
|
||||
|
||||
private RestApi.Repository mRepository;
|
||||
private RestApi.Repository mRepo;
|
||||
|
||||
private EditTextPreference mRepositoryId;
|
||||
|
||||
|
@ -101,11 +101,11 @@ public class RepoSettingsActivity extends PreferenceActivity
|
|||
public void onApiAvailable() {
|
||||
if (getIntent().getAction().equals(ACTION_CREATE)) {
|
||||
setTitle(R.string.create_repo);
|
||||
mRepository = new RestApi.Repository();
|
||||
mRepository.ID = "";
|
||||
mRepository.Directory = "";
|
||||
mRepository.Nodes = new ArrayList<RestApi.Node>();
|
||||
mRepository.Versioning = new RestApi.Versioning();
|
||||
mRepo = new RestApi.Repository();
|
||||
mRepo.ID = "";
|
||||
mRepo.Directory = "";
|
||||
mRepo.Nodes = new ArrayList<RestApi.Node>();
|
||||
mRepo.Versioning = new RestApi.Versioning();
|
||||
getPreferenceScreen().removePreference(mDelete);
|
||||
}
|
||||
else if (getIntent().getAction().equals(ACTION_EDIT)) {
|
||||
|
@ -113,18 +113,18 @@ public class RepoSettingsActivity extends PreferenceActivity
|
|||
mRepositoryId.setEnabled(false);
|
||||
List<RestApi.Repository> repos = mSyncthingService.getApi().getRepositories();
|
||||
for (int i = 0; i < repos.size(); i++) {
|
||||
if (repos.get(i).ID.equals(getIntent().getStringExtra(KEY_REPOSITORY_ID))) {
|
||||
mRepository = repos.get(i);
|
||||
if (repos.get(i).ID.equals(getIntent().getStringExtra(KEY_REPO_ID))) {
|
||||
mRepo = repos.get(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mRepositoryId.setText(mRepository.ID);
|
||||
mRepositoryId.setSummary(mRepository.ID);
|
||||
mDirectory.setText(mRepository.Directory);
|
||||
mDirectory.setSummary(mRepository.Directory);
|
||||
mRepositoryMaster.setChecked(mRepository.ReadOnly);
|
||||
mRepositoryId.setText(mRepo.ID);
|
||||
mRepositoryId.setSummary(mRepo.ID);
|
||||
mDirectory.setText(mRepo.Directory);
|
||||
mDirectory.setSummary(mRepo.Directory);
|
||||
mRepositoryMaster.setChecked(mRepo.ReadOnly);
|
||||
List<RestApi.Node> nodesList = mSyncthingService.getApi().getNodes();
|
||||
for (RestApi.Node n : nodesList) {
|
||||
ExtendedCheckBoxPreference cbp =
|
||||
|
@ -133,17 +133,17 @@ public class RepoSettingsActivity extends PreferenceActivity
|
|||
cbp.setKey(KEY_NODE_SHARED);
|
||||
cbp.setOnPreferenceChangeListener(RepoSettingsActivity.this);
|
||||
cbp.setChecked(false);
|
||||
for (RestApi.Node n2 : mRepository.Nodes) {
|
||||
for (RestApi.Node n2 : mRepo.Nodes) {
|
||||
if (n2.NodeID.equals(n.NodeID)) {
|
||||
cbp.setChecked(true);
|
||||
}
|
||||
}
|
||||
mNodes.addPreference(cbp);
|
||||
}
|
||||
mVersioning.setChecked(mRepository.Versioning instanceof RestApi.SimpleVersioning);
|
||||
mVersioning.setChecked(mRepo.Versioning instanceof RestApi.SimpleVersioning);
|
||||
if (mVersioning.isChecked()) {
|
||||
mVersioningKeep.setText(mRepository.Versioning.getParams().get("keep"));
|
||||
mVersioningKeep.setSummary(mRepository.Versioning.getParams().get("keep"));
|
||||
mVersioningKeep.setText(mRepo.Versioning.getParams().get("keep"));
|
||||
mVersioningKeep.setSummary(mRepo.Versioning.getParams().get("keep"));
|
||||
mVersioningKeep.setEnabled(true);
|
||||
}
|
||||
else {
|
||||
|
@ -167,15 +167,15 @@ public class RepoSettingsActivity extends PreferenceActivity
|
|||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.create:
|
||||
if (mRepository.ID.equals("")) {
|
||||
if (mRepo.ID.equals("")) {
|
||||
Toast.makeText(this, R.string.repo_id_required, Toast.LENGTH_LONG).show();
|
||||
return true;
|
||||
}
|
||||
if (mRepository.Directory.equals("")) {
|
||||
if (mRepo.Directory.equals("")) {
|
||||
Toast.makeText(this, R.string.repo_path_required, Toast.LENGTH_LONG).show();
|
||||
return true;
|
||||
}
|
||||
mSyncthingService.getApi().editRepository(mRepository, true);
|
||||
mSyncthingService.getApi().editRepository(mRepo, true);
|
||||
finish();
|
||||
return true;
|
||||
}
|
||||
|
@ -196,17 +196,17 @@ public class RepoSettingsActivity extends PreferenceActivity
|
|||
}
|
||||
|
||||
if (preference.equals(mRepositoryId)) {
|
||||
mRepository.ID = (String) o;
|
||||
mRepo.ID = (String) o;
|
||||
repositoryUpdated();
|
||||
return true;
|
||||
}
|
||||
else if (preference.equals(mDirectory)) {
|
||||
mRepository.Directory = (String) o;
|
||||
mRepo.Directory = (String) o;
|
||||
repositoryUpdated();
|
||||
return true;
|
||||
}
|
||||
else if (preference.equals(mRepositoryMaster)) {
|
||||
mRepository.ReadOnly = (Boolean) o;
|
||||
mRepo.ReadOnly = (Boolean) o;
|
||||
repositoryUpdated();
|
||||
return true;
|
||||
}
|
||||
|
@ -214,12 +214,12 @@ public class RepoSettingsActivity extends PreferenceActivity
|
|||
ExtendedCheckBoxPreference pref = (ExtendedCheckBoxPreference) preference;
|
||||
RestApi.Node node = (RestApi.Node) pref.getObject();
|
||||
if ((Boolean) o) {
|
||||
mRepository.Nodes.add(node);
|
||||
mRepo.Nodes.add(node);
|
||||
}
|
||||
else {
|
||||
for (RestApi.Node n : mRepository.Nodes) {
|
||||
for (RestApi.Node n : mRepo.Nodes) {
|
||||
if (n.NodeID.equals(node.NodeID)) {
|
||||
mRepository.Nodes.remove(n);
|
||||
mRepo.Nodes.remove(n);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -230,19 +230,19 @@ public class RepoSettingsActivity extends PreferenceActivity
|
|||
mVersioningKeep.setEnabled((Boolean) o);
|
||||
if ((Boolean) o) {
|
||||
RestApi.SimpleVersioning v = new RestApi.SimpleVersioning();
|
||||
mRepository.Versioning = v;
|
||||
mRepo.Versioning = v;
|
||||
v.setParams(5);
|
||||
mVersioningKeep.setText("5");
|
||||
mVersioningKeep.setSummary("5");
|
||||
}
|
||||
else {
|
||||
mRepository.Versioning = new RestApi.Versioning();
|
||||
mRepo.Versioning = new RestApi.Versioning();
|
||||
}
|
||||
repositoryUpdated();
|
||||
return true;
|
||||
}
|
||||
else if (preference.equals(mVersioningKeep)) {
|
||||
((RestApi.SimpleVersioning) mRepository.Versioning)
|
||||
((RestApi.SimpleVersioning) mRepo.Versioning)
|
||||
.setParams(Integer.parseInt((String) o));
|
||||
repositoryUpdated();
|
||||
return true;
|
||||
|
@ -259,7 +259,7 @@ public class RepoSettingsActivity extends PreferenceActivity
|
|||
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
mSyncthingService.getApi().deleteRepository(mRepository);
|
||||
mSyncthingService.getApi().deleteRepository(mRepo);
|
||||
finish();
|
||||
}
|
||||
})
|
||||
|
@ -272,7 +272,7 @@ public class RepoSettingsActivity extends PreferenceActivity
|
|||
|
||||
private void repositoryUpdated() {
|
||||
if (getIntent().getAction().equals(ACTION_EDIT)) {
|
||||
mSyncthingService.getApi().editRepository(mRepository, false);
|
||||
mSyncthingService.getApi().editRepository(mRepo, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,9 +5,9 @@ import android.view.View;
|
|||
import android.widget.AdapterView;
|
||||
|
||||
import com.nutomic.syncthingandroid.R;
|
||||
import com.nutomic.syncthingandroid.util.RepositoryAdapter;
|
||||
import com.nutomic.syncthingandroid.syncthing.RestApi;
|
||||
import com.nutomic.syncthingandroid.syncthing.SyncthingService;
|
||||
import com.nutomic.syncthingandroid.util.ReposAdapter;
|
||||
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
@ -15,10 +15,10 @@ import java.util.TimerTask;
|
|||
/**
|
||||
* Displays a list of all existing repositories.
|
||||
*/
|
||||
public class RepositoriesFragment extends LoadingListFragment implements
|
||||
public class ReposFragment extends LoadingListFragment implements
|
||||
RestApi.OnApiAvailableListener, AdapterView.OnItemClickListener {
|
||||
|
||||
private RepositoryAdapter mAdapter;
|
||||
private ReposAdapter mAdapter;
|
||||
|
||||
private Timer mTimer;
|
||||
|
||||
|
@ -26,7 +26,7 @@ public class RepositoriesFragment extends LoadingListFragment implements
|
|||
|
||||
@Override
|
||||
public void onInitAdapter(MainActivity activity) {
|
||||
mAdapter = new RepositoryAdapter(activity);
|
||||
mAdapter = new ReposAdapter(activity);
|
||||
mAdapter.add(activity.getApi().getRepositories());
|
||||
setListAdapter(mAdapter, R.string.repositories_list_empty);
|
||||
mInitialized = true;
|
||||
|
@ -66,7 +66,7 @@ public class RepositoriesFragment extends LoadingListFragment implements
|
|||
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
||||
Intent intent = new Intent(getActivity(), RepoSettingsActivity.class);
|
||||
intent.setAction(RepoSettingsActivity.ACTION_EDIT);
|
||||
intent.putExtra(RepoSettingsActivity.KEY_REPOSITORY_ID, mAdapter.getItem(i).ID);
|
||||
intent.putExtra(RepoSettingsActivity.KEY_REPO_ID, mAdapter.getItem(i).ID);
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
|
@ -5,12 +5,9 @@ import android.app.NotificationManager;
|
|||
import android.app.PendingIntent;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
import android.util.Log;
|
||||
|
||||
import com.nutomic.syncthingandroid.BuildConfig;
|
||||
import com.nutomic.syncthingandroid.R;
|
||||
|
||||
import org.json.JSONArray;
|
||||
|
|
|
@ -17,12 +17,12 @@ import java.util.List;
|
|||
/**
|
||||
* Generates item views for repository items.
|
||||
*/
|
||||
public class RepositoryAdapter extends ArrayAdapter<RestApi.Repository>
|
||||
public class ReposAdapter extends ArrayAdapter<RestApi.Repository>
|
||||
implements RestApi.OnReceiveModelListener {
|
||||
|
||||
private HashMap<String, RestApi.Model> mModels = new HashMap<String, RestApi.Model>();
|
||||
|
||||
public RepositoryAdapter(Context context) {
|
||||
public ReposAdapter(Context context) {
|
||||
super(context, R.layout.node_list_item);
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ public class RepositoryAdapter extends ArrayAdapter<RestApi.Repository>
|
|||
if (convertView == null) {
|
||||
LayoutInflater inflater = (LayoutInflater) getContext()
|
||||
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
convertView = inflater.inflate(R.layout.repository_list_item, parent, false);
|
||||
convertView = inflater.inflate(R.layout.repo_list_item, parent, false);
|
||||
}
|
||||
|
||||
TextView id = (TextView) convertView.findViewById(R.id.id);
|
Loading…
Reference in a new issue