From ab19944383ddab99c1c0768d012e15bde3cc7c51 Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Sat, 19 Mar 2016 21:53:35 +0100 Subject: [PATCH] Change constants from repo/node to folder/device. --- .../activities/SettingsActivity.java | 18 ++++++++---------- .../fragments/DeviceFragment.java | 6 +++--- .../fragments/DeviceListFragment.java | 7 +++---- .../fragments/DrawerFragment.java | 2 +- .../fragments/FolderFragment.java | 18 +++++++++--------- .../fragments/FolderListFragment.java | 6 +++--- .../syncthing/EventProcessor.java | 9 ++++----- .../syncthing/SyncthingService.java | 2 +- 8 files changed, 32 insertions(+), 36 deletions(-) diff --git a/src/main/java/com/nutomic/syncthingandroid/activities/SettingsActivity.java b/src/main/java/com/nutomic/syncthingandroid/activities/SettingsActivity.java index 918bc542..8037fcbe 100644 --- a/src/main/java/com/nutomic/syncthingandroid/activities/SettingsActivity.java +++ b/src/main/java/com/nutomic/syncthingandroid/activities/SettingsActivity.java @@ -14,15 +14,13 @@ import com.nutomic.syncthingandroid.fragments.SettingsFragment; */ public class SettingsActivity extends SyncthingActivity { - public static final String ACTION_APP_SETTINGS_FRAGMENT = "app_settings_fragment"; - - public static final String ACTION_NODE_SETTINGS_FRAGMENT = "device_settings_fragment"; - - public static final String ACTION_REPO_SETTINGS_FRAGMENT = "folder_settings_fragment"; + public static final String ACTION_APP_SETTINGS = "app_settings_fragment"; + public static final String ACTION_DEVICE_SETTINGS = "device_settings_fragment"; + public static final String ACTION_FOLDER_SETTINGS = "folder_settings_fragment"; /** - * Must be set for {@link #ACTION_NODE_SETTINGS_FRAGMENT} and - * {@link #ACTION_REPO_SETTINGS_FRAGMENT} to determine if an existing folder/device should be + * Must be set for {@link #ACTION_DEVICE_SETTINGS} and + * {@link #ACTION_FOLDER_SETTINGS} to determine if an existing folder/device should be * edited or a new one created. */ public static final String EXTRA_IS_CREATE = "create"; @@ -41,17 +39,17 @@ public class SettingsActivity extends SyncthingActivity { savedInstanceState.getString("fragment_name")); } else if (getIntent().getAction() != null) { switch (getIntent().getAction()) { - case ACTION_APP_SETTINGS_FRAGMENT: + case ACTION_APP_SETTINGS: setTitle(R.string.settings_title); mFragment = new SettingsFragment(); break; - case ACTION_NODE_SETTINGS_FRAGMENT: + case ACTION_DEVICE_SETTINGS: mFragment = new DeviceFragment(); if (!getIntent().hasExtra(EXTRA_IS_CREATE)) { throw new IllegalArgumentException("EXTRA_IS_CREATE must be set"); } break; - case ACTION_REPO_SETTINGS_FRAGMENT: + case ACTION_FOLDER_SETTINGS: mFragment = new FolderFragment(); if (!getIntent().hasExtra(EXTRA_IS_CREATE)) { throw new IllegalArgumentException("EXTRA_IS_CREATE must be set"); diff --git a/src/main/java/com/nutomic/syncthingandroid/fragments/DeviceFragment.java b/src/main/java/com/nutomic/syncthingandroid/fragments/DeviceFragment.java index 72c7ff3e..c1481458 100644 --- a/src/main/java/com/nutomic/syncthingandroid/fragments/DeviceFragment.java +++ b/src/main/java/com/nutomic/syncthingandroid/fragments/DeviceFragment.java @@ -54,7 +54,7 @@ public class DeviceFragment extends Fragment implements SyncthingService.OnApiChangeListener, RestApi.OnDeviceIdNormalizedListener, View.OnClickListener { - public static final String EXTRA_NODE_ID = "device_id"; + public static final String EXTRA_DEVICE_ID = "device_id"; private static final String TAG = "DeviceSettingsFragment"; @@ -269,7 +269,7 @@ public class DeviceFragment extends Fragment implements mDevice = null; for (int i = 0; i < devices.size(); i++) { if (devices.get(i).deviceID.equals( - getActivity().getIntent().getStringExtra(EXTRA_NODE_ID))) { + getActivity().getIntent().getStringExtra(EXTRA_DEVICE_ID))) { mDevice = devices.get(i); break; } @@ -375,7 +375,7 @@ public class DeviceFragment extends Fragment implements private void initDevice() { mDevice = new RestApi.Device(); mDevice.name = ""; - mDevice.deviceID = getActivity().getIntent().getStringExtra(EXTRA_NODE_ID); + mDevice.deviceID = getActivity().getIntent().getStringExtra(EXTRA_DEVICE_ID); mDevice.addresses = DYNAMIC_ADDRESS; mDevice.compression = METADATA.getValue(getActivity()); mDevice.introducer = false; diff --git a/src/main/java/com/nutomic/syncthingandroid/fragments/DeviceListFragment.java b/src/main/java/com/nutomic/syncthingandroid/fragments/DeviceListFragment.java index 301eeb40..b9b454ad 100644 --- a/src/main/java/com/nutomic/syncthingandroid/fragments/DeviceListFragment.java +++ b/src/main/java/com/nutomic/syncthingandroid/fragments/DeviceListFragment.java @@ -11,7 +11,6 @@ import android.widget.AdapterView; import android.widget.ListView; import com.nutomic.syncthingandroid.R; -import com.nutomic.syncthingandroid.activities.MainActivity; import com.nutomic.syncthingandroid.activities.SettingsActivity; import com.nutomic.syncthingandroid.activities.SyncthingActivity; import com.nutomic.syncthingandroid.syncthing.SyncthingService; @@ -103,9 +102,9 @@ public class DeviceListFragment extends ListFragment implements SyncthingService @Override public void onItemClick(AdapterView adapterView, View view, int i, long l) { Intent intent = new Intent(getActivity(), SettingsActivity.class); - intent.setAction(SettingsActivity.ACTION_NODE_SETTINGS_FRAGMENT); + intent.setAction(SettingsActivity.ACTION_DEVICE_SETTINGS); intent.putExtra(SettingsActivity.EXTRA_IS_CREATE, false); - intent.putExtra(DeviceFragment.EXTRA_NODE_ID, mAdapter.getItem(i).deviceID); + intent.putExtra(DeviceFragment.EXTRA_DEVICE_ID, mAdapter.getItem(i).deviceID); startActivity(intent); } @@ -119,7 +118,7 @@ public class DeviceListFragment extends ListFragment implements SyncthingService switch (item.getItemId()) { case R.id.add_device: Intent intent = new Intent(getActivity(), SettingsActivity.class) - .setAction(SettingsActivity.ACTION_NODE_SETTINGS_FRAGMENT) + .setAction(SettingsActivity.ACTION_DEVICE_SETTINGS) .putExtra(SettingsActivity.EXTRA_IS_CREATE, true); startActivity(intent); return true; diff --git a/src/main/java/com/nutomic/syncthingandroid/fragments/DrawerFragment.java b/src/main/java/com/nutomic/syncthingandroid/fragments/DrawerFragment.java index ca9a0036..990d0218 100644 --- a/src/main/java/com/nutomic/syncthingandroid/fragments/DrawerFragment.java +++ b/src/main/java/com/nutomic/syncthingandroid/fragments/DrawerFragment.java @@ -202,7 +202,7 @@ public class DrawerFragment extends Fragment implements RestApi.OnReceiveSystemI break; case R.id.drawerActionSettings: startActivity(new Intent(mActivity, SettingsActivity.class) - .setAction(SettingsActivity.ACTION_APP_SETTINGS_FRAGMENT)); + .setAction(SettingsActivity.ACTION_APP_SETTINGS)); mActivity.closeDrawer(); break; case R.id.drawerActionRestart: diff --git a/src/main/java/com/nutomic/syncthingandroid/fragments/FolderFragment.java b/src/main/java/com/nutomic/syncthingandroid/fragments/FolderFragment.java index edc69705..ffff1c30 100644 --- a/src/main/java/com/nutomic/syncthingandroid/fragments/FolderFragment.java +++ b/src/main/java/com/nutomic/syncthingandroid/fragments/FolderFragment.java @@ -52,7 +52,7 @@ import static java.lang.String.valueOf; public class FolderFragment extends Fragment implements SyncthingActivity.OnServiceConnectedListener, SyncthingService.OnApiChangeListener { - public static final String EXTRA_REPO_ID = "folder_id"; + public static final String EXTRA_FOLDER_ID = "folder_id"; public static final String EXTRA_DEVICE_ID = "device_id"; @@ -84,7 +84,7 @@ public class FolderFragment extends Fragment @Override public void afterTextChanged(Editable s) { mFolder.id = s.toString(); - updateRepo(); + updateFolder(); } }; @@ -99,7 +99,7 @@ public class FolderFragment extends Fragment @Override public void onCheckedChanged(CompoundButton view, boolean isChecked) { mFolder.readOnly = isChecked; - updateRepo(); + updateFolder(); } }; @@ -112,7 +112,7 @@ public class FolderFragment extends Fragment } else { mFolder.deviceIds.remove(device.deviceID); } - updateRepo(); + updateFolder(); } }; @@ -127,7 +127,7 @@ public class FolderFragment extends Fragment ((SimpleVersioning) mFolder.versioning).setParams(intValue); mVersioningKeepView.setText(valueOf(intValue)); } - updateRepo(); + updateFolder(); } }; @@ -231,7 +231,7 @@ public class FolderFragment extends Fragment if (!mIsCreateMode) { List folders = mSyncthingService.getApi().getFolders(); - String passedId = getActivity().getIntent().getStringExtra(EXTRA_REPO_ID); + String passedId = getActivity().getIntent().getStringExtra(EXTRA_FOLDER_ID); mFolder = null; for (RestApi.Folder currentFolder : folders) { if (currentFolder.id.equals(passedId)) { @@ -341,13 +341,13 @@ public class FolderFragment extends Fragment if (resultCode == Activity.RESULT_OK && requestCode == DIRECTORY_REQUEST_CODE) { mFolder.path = data.getStringExtra(FolderPickerActivity.EXTRA_RESULT_DIRECTORY); mPathView.setText(mFolder.path); - updateRepo(); + updateFolder(); } } private void initFolder() { mFolder = new RestApi.Folder(); - mFolder.id = getActivity().getIntent().getStringExtra(EXTRA_REPO_ID); + mFolder.id = getActivity().getIntent().getStringExtra(EXTRA_FOLDER_ID); mFolder.path = ""; mFolder.rescanIntervalS = 259200; // Scan every 3 days (in case inotify dropped some changes) mFolder.deviceIds = new ArrayList<>(); @@ -385,7 +385,7 @@ public class FolderFragment extends Fragment deviceView.setOnCheckedChangeListener(mOnShareChangeListener); } - private void updateRepo() { + private void updateFolder() { if (!mIsCreateMode) { mSyncthingService.getApi().editFolder(mFolder, false, getActivity()); } diff --git a/src/main/java/com/nutomic/syncthingandroid/fragments/FolderListFragment.java b/src/main/java/com/nutomic/syncthingandroid/fragments/FolderListFragment.java index bff57127..d157d790 100644 --- a/src/main/java/com/nutomic/syncthingandroid/fragments/FolderListFragment.java +++ b/src/main/java/com/nutomic/syncthingandroid/fragments/FolderListFragment.java @@ -103,9 +103,9 @@ public class FolderListFragment extends ListFragment implements SyncthingService @Override public void onItemClick(AdapterView adapterView, View view, int i, long l) { Intent intent = new Intent(getActivity(), SettingsActivity.class) - .setAction(SettingsActivity.ACTION_REPO_SETTINGS_FRAGMENT) + .setAction(SettingsActivity.ACTION_FOLDER_SETTINGS) .putExtra(SettingsActivity.EXTRA_IS_CREATE, false) - .putExtra(FolderFragment.EXTRA_REPO_ID, mAdapter.getItem(i).id); + .putExtra(FolderFragment.EXTRA_FOLDER_ID, mAdapter.getItem(i).id); startActivity(intent); } @@ -131,7 +131,7 @@ public class FolderListFragment extends ListFragment implements SyncthingService switch (item.getItemId()) { case R.id.add_folder: Intent intent = new Intent(getActivity(), SettingsActivity.class) - .setAction(SettingsActivity.ACTION_REPO_SETTINGS_FRAGMENT) + .setAction(SettingsActivity.ACTION_FOLDER_SETTINGS) .putExtra(SettingsActivity.EXTRA_IS_CREATE, true); startActivity(intent); return true; diff --git a/src/main/java/com/nutomic/syncthingandroid/syncthing/EventProcessor.java b/src/main/java/com/nutomic/syncthingandroid/syncthing/EventProcessor.java index 35b9e07d..b2f44910 100644 --- a/src/main/java/com/nutomic/syncthingandroid/syncthing/EventProcessor.java +++ b/src/main/java/com/nutomic/syncthingandroid/syncthing/EventProcessor.java @@ -22,7 +22,6 @@ import org.json.JSONException; import org.json.JSONObject; import java.io.File; -import java.util.Random; import java.util.concurrent.TimeUnit; /** @@ -97,9 +96,9 @@ public class EventProcessor implements SyncthingService.OnWebGuiAvailableListene Log.d(TAG, "Unknwon device " + deviceId + " wants to connect"); Intent intent = new Intent(mContext, SettingsActivity.class) - .setAction(SettingsActivity.ACTION_NODE_SETTINGS_FRAGMENT) + .setAction(SettingsActivity.ACTION_DEVICE_SETTINGS) .putExtra(SettingsActivity.EXTRA_IS_CREATE, true) - .putExtra(DeviceFragment.EXTRA_NODE_ID, deviceId); + .putExtra(DeviceFragment.EXTRA_DEVICE_ID, deviceId); PendingIntent pi = PendingIntent.getActivity(mContext, 0, intent, 0); String title = mContext.getString(R.string.device_rejected, @@ -113,10 +112,10 @@ public class EventProcessor implements SyncthingService.OnWebGuiAvailableListene Log.d(TAG, "Device " + deviceId + " wants to share folder " + folderId); intent = new Intent(mContext, SettingsActivity.class) - .setAction(SettingsActivity.ACTION_REPO_SETTINGS_FRAGMENT) + .setAction(SettingsActivity.ACTION_FOLDER_SETTINGS) .putExtra(SettingsActivity.EXTRA_IS_CREATE, true) .putExtra(FolderFragment.EXTRA_DEVICE_ID, deviceId) - .putExtra(FolderFragment.EXTRA_REPO_ID, folderId); + .putExtra(FolderFragment.EXTRA_FOLDER_ID, folderId); pi = PendingIntent.getActivity(mContext, 0, intent, 0); String deviceName = null; diff --git a/src/main/java/com/nutomic/syncthingandroid/syncthing/SyncthingService.java b/src/main/java/com/nutomic/syncthingandroid/syncthing/SyncthingService.java index 0cfd8a16..8997a3fe 100644 --- a/src/main/java/com/nutomic/syncthingandroid/syncthing/SyncthingService.java +++ b/src/main/java/com/nutomic/syncthingandroid/syncthing/SyncthingService.java @@ -557,7 +557,7 @@ public class SyncthingService extends Service implements public void onClick(DialogInterface dialogInterface, int i) { activity.finish(); Intent intent = new Intent(activity, SettingsActivity.class) - .setAction(SettingsActivity.ACTION_APP_SETTINGS_FRAGMENT); + .setAction(SettingsActivity.ACTION_APP_SETTINGS); activity.startActivity(intent); } }