mirror of
https://github.com/syncthing/syncthing-android.git
synced 2024-11-30 08:11:17 +00:00
Change constants from repo/node to folder/device.
This commit is contained in:
parent
f9c8a7dc8c
commit
ab19944383
8 changed files with 32 additions and 36 deletions
|
@ -14,15 +14,13 @@ import com.nutomic.syncthingandroid.fragments.SettingsFragment;
|
||||||
*/
|
*/
|
||||||
public class SettingsActivity extends SyncthingActivity {
|
public class SettingsActivity extends SyncthingActivity {
|
||||||
|
|
||||||
public static final String ACTION_APP_SETTINGS_FRAGMENT = "app_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_NODE_SETTINGS_FRAGMENT = "device_settings_fragment";
|
public static final String ACTION_FOLDER_SETTINGS = "folder_settings_fragment";
|
||||||
|
|
||||||
public static final String ACTION_REPO_SETTINGS_FRAGMENT = "folder_settings_fragment";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Must be set for {@link #ACTION_NODE_SETTINGS_FRAGMENT} and
|
* Must be set for {@link #ACTION_DEVICE_SETTINGS} and
|
||||||
* {@link #ACTION_REPO_SETTINGS_FRAGMENT} to determine if an existing folder/device should be
|
* {@link #ACTION_FOLDER_SETTINGS} to determine if an existing folder/device should be
|
||||||
* edited or a new one created.
|
* edited or a new one created.
|
||||||
*/
|
*/
|
||||||
public static final String EXTRA_IS_CREATE = "create";
|
public static final String EXTRA_IS_CREATE = "create";
|
||||||
|
@ -41,17 +39,17 @@ public class SettingsActivity extends SyncthingActivity {
|
||||||
savedInstanceState.getString("fragment_name"));
|
savedInstanceState.getString("fragment_name"));
|
||||||
} else if (getIntent().getAction() != null) {
|
} else if (getIntent().getAction() != null) {
|
||||||
switch (getIntent().getAction()) {
|
switch (getIntent().getAction()) {
|
||||||
case ACTION_APP_SETTINGS_FRAGMENT:
|
case ACTION_APP_SETTINGS:
|
||||||
setTitle(R.string.settings_title);
|
setTitle(R.string.settings_title);
|
||||||
mFragment = new SettingsFragment();
|
mFragment = new SettingsFragment();
|
||||||
break;
|
break;
|
||||||
case ACTION_NODE_SETTINGS_FRAGMENT:
|
case ACTION_DEVICE_SETTINGS:
|
||||||
mFragment = new DeviceFragment();
|
mFragment = new DeviceFragment();
|
||||||
if (!getIntent().hasExtra(EXTRA_IS_CREATE)) {
|
if (!getIntent().hasExtra(EXTRA_IS_CREATE)) {
|
||||||
throw new IllegalArgumentException("EXTRA_IS_CREATE must be set");
|
throw new IllegalArgumentException("EXTRA_IS_CREATE must be set");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ACTION_REPO_SETTINGS_FRAGMENT:
|
case ACTION_FOLDER_SETTINGS:
|
||||||
mFragment = new FolderFragment();
|
mFragment = new FolderFragment();
|
||||||
if (!getIntent().hasExtra(EXTRA_IS_CREATE)) {
|
if (!getIntent().hasExtra(EXTRA_IS_CREATE)) {
|
||||||
throw new IllegalArgumentException("EXTRA_IS_CREATE must be set");
|
throw new IllegalArgumentException("EXTRA_IS_CREATE must be set");
|
||||||
|
|
|
@ -54,7 +54,7 @@ public class DeviceFragment extends Fragment implements
|
||||||
SyncthingService.OnApiChangeListener, RestApi.OnDeviceIdNormalizedListener,
|
SyncthingService.OnApiChangeListener, RestApi.OnDeviceIdNormalizedListener,
|
||||||
View.OnClickListener {
|
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";
|
private static final String TAG = "DeviceSettingsFragment";
|
||||||
|
|
||||||
|
@ -269,7 +269,7 @@ public class DeviceFragment extends Fragment implements
|
||||||
mDevice = null;
|
mDevice = null;
|
||||||
for (int i = 0; i < devices.size(); i++) {
|
for (int i = 0; i < devices.size(); i++) {
|
||||||
if (devices.get(i).deviceID.equals(
|
if (devices.get(i).deviceID.equals(
|
||||||
getActivity().getIntent().getStringExtra(EXTRA_NODE_ID))) {
|
getActivity().getIntent().getStringExtra(EXTRA_DEVICE_ID))) {
|
||||||
mDevice = devices.get(i);
|
mDevice = devices.get(i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -375,7 +375,7 @@ public class DeviceFragment extends Fragment implements
|
||||||
private void initDevice() {
|
private void initDevice() {
|
||||||
mDevice = new RestApi.Device();
|
mDevice = new RestApi.Device();
|
||||||
mDevice.name = "";
|
mDevice.name = "";
|
||||||
mDevice.deviceID = getActivity().getIntent().getStringExtra(EXTRA_NODE_ID);
|
mDevice.deviceID = getActivity().getIntent().getStringExtra(EXTRA_DEVICE_ID);
|
||||||
mDevice.addresses = DYNAMIC_ADDRESS;
|
mDevice.addresses = DYNAMIC_ADDRESS;
|
||||||
mDevice.compression = METADATA.getValue(getActivity());
|
mDevice.compression = METADATA.getValue(getActivity());
|
||||||
mDevice.introducer = false;
|
mDevice.introducer = false;
|
||||||
|
|
|
@ -11,7 +11,6 @@ import android.widget.AdapterView;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
|
|
||||||
import com.nutomic.syncthingandroid.R;
|
import com.nutomic.syncthingandroid.R;
|
||||||
import com.nutomic.syncthingandroid.activities.MainActivity;
|
|
||||||
import com.nutomic.syncthingandroid.activities.SettingsActivity;
|
import com.nutomic.syncthingandroid.activities.SettingsActivity;
|
||||||
import com.nutomic.syncthingandroid.activities.SyncthingActivity;
|
import com.nutomic.syncthingandroid.activities.SyncthingActivity;
|
||||||
import com.nutomic.syncthingandroid.syncthing.SyncthingService;
|
import com.nutomic.syncthingandroid.syncthing.SyncthingService;
|
||||||
|
@ -103,9 +102,9 @@ public class DeviceListFragment extends ListFragment implements SyncthingService
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
||||||
Intent intent = new Intent(getActivity(), SettingsActivity.class);
|
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(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);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,7 +118,7 @@ public class DeviceListFragment extends ListFragment implements SyncthingService
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
case R.id.add_device:
|
case R.id.add_device:
|
||||||
Intent intent = new Intent(getActivity(), SettingsActivity.class)
|
Intent intent = new Intent(getActivity(), SettingsActivity.class)
|
||||||
.setAction(SettingsActivity.ACTION_NODE_SETTINGS_FRAGMENT)
|
.setAction(SettingsActivity.ACTION_DEVICE_SETTINGS)
|
||||||
.putExtra(SettingsActivity.EXTRA_IS_CREATE, true);
|
.putExtra(SettingsActivity.EXTRA_IS_CREATE, true);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -202,7 +202,7 @@ public class DrawerFragment extends Fragment implements RestApi.OnReceiveSystemI
|
||||||
break;
|
break;
|
||||||
case R.id.drawerActionSettings:
|
case R.id.drawerActionSettings:
|
||||||
startActivity(new Intent(mActivity, SettingsActivity.class)
|
startActivity(new Intent(mActivity, SettingsActivity.class)
|
||||||
.setAction(SettingsActivity.ACTION_APP_SETTINGS_FRAGMENT));
|
.setAction(SettingsActivity.ACTION_APP_SETTINGS));
|
||||||
mActivity.closeDrawer();
|
mActivity.closeDrawer();
|
||||||
break;
|
break;
|
||||||
case R.id.drawerActionRestart:
|
case R.id.drawerActionRestart:
|
||||||
|
|
|
@ -52,7 +52,7 @@ import static java.lang.String.valueOf;
|
||||||
public class FolderFragment extends Fragment
|
public class FolderFragment extends Fragment
|
||||||
implements SyncthingActivity.OnServiceConnectedListener, SyncthingService.OnApiChangeListener {
|
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";
|
public static final String EXTRA_DEVICE_ID = "device_id";
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ public class FolderFragment extends Fragment
|
||||||
@Override
|
@Override
|
||||||
public void afterTextChanged(Editable s) {
|
public void afterTextChanged(Editable s) {
|
||||||
mFolder.id = s.toString();
|
mFolder.id = s.toString();
|
||||||
updateRepo();
|
updateFolder();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ public class FolderFragment extends Fragment
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton view, boolean isChecked) {
|
public void onCheckedChanged(CompoundButton view, boolean isChecked) {
|
||||||
mFolder.readOnly = isChecked;
|
mFolder.readOnly = isChecked;
|
||||||
updateRepo();
|
updateFolder();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ public class FolderFragment extends Fragment
|
||||||
} else {
|
} else {
|
||||||
mFolder.deviceIds.remove(device.deviceID);
|
mFolder.deviceIds.remove(device.deviceID);
|
||||||
}
|
}
|
||||||
updateRepo();
|
updateFolder();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ public class FolderFragment extends Fragment
|
||||||
((SimpleVersioning) mFolder.versioning).setParams(intValue);
|
((SimpleVersioning) mFolder.versioning).setParams(intValue);
|
||||||
mVersioningKeepView.setText(valueOf(intValue));
|
mVersioningKeepView.setText(valueOf(intValue));
|
||||||
}
|
}
|
||||||
updateRepo();
|
updateFolder();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -231,7 +231,7 @@ public class FolderFragment extends Fragment
|
||||||
|
|
||||||
if (!mIsCreateMode) {
|
if (!mIsCreateMode) {
|
||||||
List<RestApi.Folder> folders = mSyncthingService.getApi().getFolders();
|
List<RestApi.Folder> folders = mSyncthingService.getApi().getFolders();
|
||||||
String passedId = getActivity().getIntent().getStringExtra(EXTRA_REPO_ID);
|
String passedId = getActivity().getIntent().getStringExtra(EXTRA_FOLDER_ID);
|
||||||
mFolder = null;
|
mFolder = null;
|
||||||
for (RestApi.Folder currentFolder : folders) {
|
for (RestApi.Folder currentFolder : folders) {
|
||||||
if (currentFolder.id.equals(passedId)) {
|
if (currentFolder.id.equals(passedId)) {
|
||||||
|
@ -341,13 +341,13 @@ public class FolderFragment extends Fragment
|
||||||
if (resultCode == Activity.RESULT_OK && requestCode == DIRECTORY_REQUEST_CODE) {
|
if (resultCode == Activity.RESULT_OK && requestCode == DIRECTORY_REQUEST_CODE) {
|
||||||
mFolder.path = data.getStringExtra(FolderPickerActivity.EXTRA_RESULT_DIRECTORY);
|
mFolder.path = data.getStringExtra(FolderPickerActivity.EXTRA_RESULT_DIRECTORY);
|
||||||
mPathView.setText(mFolder.path);
|
mPathView.setText(mFolder.path);
|
||||||
updateRepo();
|
updateFolder();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initFolder() {
|
private void initFolder() {
|
||||||
mFolder = new RestApi.Folder();
|
mFolder = new RestApi.Folder();
|
||||||
mFolder.id = getActivity().getIntent().getStringExtra(EXTRA_REPO_ID);
|
mFolder.id = getActivity().getIntent().getStringExtra(EXTRA_FOLDER_ID);
|
||||||
mFolder.path = "";
|
mFolder.path = "";
|
||||||
mFolder.rescanIntervalS = 259200; // Scan every 3 days (in case inotify dropped some changes)
|
mFolder.rescanIntervalS = 259200; // Scan every 3 days (in case inotify dropped some changes)
|
||||||
mFolder.deviceIds = new ArrayList<>();
|
mFolder.deviceIds = new ArrayList<>();
|
||||||
|
@ -385,7 +385,7 @@ public class FolderFragment extends Fragment
|
||||||
deviceView.setOnCheckedChangeListener(mOnShareChangeListener);
|
deviceView.setOnCheckedChangeListener(mOnShareChangeListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateRepo() {
|
private void updateFolder() {
|
||||||
if (!mIsCreateMode) {
|
if (!mIsCreateMode) {
|
||||||
mSyncthingService.getApi().editFolder(mFolder, false, getActivity());
|
mSyncthingService.getApi().editFolder(mFolder, false, getActivity());
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,9 +103,9 @@ public class FolderListFragment extends ListFragment implements SyncthingService
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
||||||
Intent intent = new Intent(getActivity(), SettingsActivity.class)
|
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(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);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ public class FolderListFragment extends ListFragment implements SyncthingService
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
case R.id.add_folder:
|
case R.id.add_folder:
|
||||||
Intent intent = new Intent(getActivity(), SettingsActivity.class)
|
Intent intent = new Intent(getActivity(), SettingsActivity.class)
|
||||||
.setAction(SettingsActivity.ACTION_REPO_SETTINGS_FRAGMENT)
|
.setAction(SettingsActivity.ACTION_FOLDER_SETTINGS)
|
||||||
.putExtra(SettingsActivity.EXTRA_IS_CREATE, true);
|
.putExtra(SettingsActivity.EXTRA_IS_CREATE, true);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -22,7 +22,6 @@ import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Random;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -97,9 +96,9 @@ public class EventProcessor implements SyncthingService.OnWebGuiAvailableListene
|
||||||
Log.d(TAG, "Unknwon device " + deviceId + " wants to connect");
|
Log.d(TAG, "Unknwon device " + deviceId + " wants to connect");
|
||||||
|
|
||||||
Intent intent = new Intent(mContext, SettingsActivity.class)
|
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(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);
|
PendingIntent pi = PendingIntent.getActivity(mContext, 0, intent, 0);
|
||||||
|
|
||||||
String title = mContext.getString(R.string.device_rejected,
|
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);
|
Log.d(TAG, "Device " + deviceId + " wants to share folder " + folderId);
|
||||||
|
|
||||||
intent = new Intent(mContext, SettingsActivity.class)
|
intent = new Intent(mContext, SettingsActivity.class)
|
||||||
.setAction(SettingsActivity.ACTION_REPO_SETTINGS_FRAGMENT)
|
.setAction(SettingsActivity.ACTION_FOLDER_SETTINGS)
|
||||||
.putExtra(SettingsActivity.EXTRA_IS_CREATE, true)
|
.putExtra(SettingsActivity.EXTRA_IS_CREATE, true)
|
||||||
.putExtra(FolderFragment.EXTRA_DEVICE_ID, deviceId)
|
.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);
|
pi = PendingIntent.getActivity(mContext, 0, intent, 0);
|
||||||
|
|
||||||
String deviceName = null;
|
String deviceName = null;
|
||||||
|
|
|
@ -557,7 +557,7 @@ public class SyncthingService extends Service implements
|
||||||
public void onClick(DialogInterface dialogInterface, int i) {
|
public void onClick(DialogInterface dialogInterface, int i) {
|
||||||
activity.finish();
|
activity.finish();
|
||||||
Intent intent = new Intent(activity, SettingsActivity.class)
|
Intent intent = new Intent(activity, SettingsActivity.class)
|
||||||
.setAction(SettingsActivity.ACTION_APP_SETTINGS_FRAGMENT);
|
.setAction(SettingsActivity.ACTION_APP_SETTINGS);
|
||||||
activity.startActivity(intent);
|
activity.startActivity(intent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue