mirror of
https://github.com/syncthing/syncthing-android.git
synced 2024-12-23 11:21:29 +00:00
parent
b8511cfd41
commit
765bc4a984
2 changed files with 23 additions and 12 deletions
|
@ -25,5 +25,6 @@ public class FolderStatus {
|
||||||
public String state;
|
public String state;
|
||||||
public String stateChanged;
|
public String stateChanged;
|
||||||
public long version;
|
public long version;
|
||||||
|
public String error;
|
||||||
public String watchError;
|
public String watchError;
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,9 +97,6 @@ public class FoldersAdapter extends ArrayAdapter<Folder> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int percentage = (folderStatus.globalBytes != 0)
|
|
||||||
? Math.round(100 * folderStatus.inSyncBytes / folderStatus.globalBytes)
|
|
||||||
: 100;
|
|
||||||
long neededItems = folderStatus.needFiles + folderStatus.needDirectories + folderStatus.needSymlinks + folderStatus.needDeletes;
|
long neededItems = folderStatus.needFiles + folderStatus.needDirectories + folderStatus.needSymlinks + folderStatus.needDeletes;
|
||||||
boolean outOfSync = folderStatus.state.equals("idle") && neededItems > 0;
|
boolean outOfSync = folderStatus.state.equals("idle") && neededItems > 0;
|
||||||
boolean overrideButtonVisible = (folder.type == Constants.FOLDER_TYPE_SEND_ONLY) && outOfSync;
|
boolean overrideButtonVisible = (folder.type == Constants.FOLDER_TYPE_SEND_ONLY) && outOfSync;
|
||||||
|
@ -112,7 +109,7 @@ public class FoldersAdapter extends ArrayAdapter<Folder> {
|
||||||
binding.state.setText(mContext.getString(R.string.state_paused));
|
binding.state.setText(mContext.getString(R.string.state_paused));
|
||||||
binding.state.setTextColor(ContextCompat.getColor(mContext, R.color.text_black));
|
binding.state.setTextColor(ContextCompat.getColor(mContext, R.color.text_black));
|
||||||
} else {
|
} else {
|
||||||
binding.state.setText(getLocalizedState(mContext, folderStatus.state, percentage));
|
binding.state.setText(getLocalizedState(mContext, folderStatus));
|
||||||
switch(folderStatus.state) {
|
switch(folderStatus.state) {
|
||||||
case "idle":
|
case "idle":
|
||||||
binding.state.setTextColor(ContextCompat.getColor(mContext, R.color.text_green));
|
binding.state.setTextColor(ContextCompat.getColor(mContext, R.color.text_green));
|
||||||
|
@ -121,6 +118,7 @@ public class FoldersAdapter extends ArrayAdapter<Folder> {
|
||||||
case "syncing":
|
case "syncing":
|
||||||
binding.state.setTextColor(ContextCompat.getColor(mContext, R.color.text_blue));
|
binding.state.setTextColor(ContextCompat.getColor(mContext, R.color.text_blue));
|
||||||
break;
|
break;
|
||||||
|
case "error":
|
||||||
default:
|
default:
|
||||||
binding.state.setTextColor(ContextCompat.getColor(mContext, R.color.text_red));
|
binding.state.setTextColor(ContextCompat.getColor(mContext, R.color.text_red));
|
||||||
}
|
}
|
||||||
|
@ -139,14 +137,26 @@ public class FoldersAdapter extends ArrayAdapter<Folder> {
|
||||||
/**
|
/**
|
||||||
* Returns the folder's state as a localized string.
|
* Returns the folder's state as a localized string.
|
||||||
*/
|
*/
|
||||||
private static String getLocalizedState(Context c, String state, int percentage) {
|
private static String getLocalizedState(Context c, FolderStatus folderStatus) {
|
||||||
switch (state) {
|
switch (folderStatus.state) {
|
||||||
case "idle": return c.getString(R.string.state_idle);
|
case "idle":
|
||||||
case "scanning": return c.getString(R.string.state_scanning);
|
return c.getString(R.string.state_idle);
|
||||||
case "syncing": return c.getString(R.string.state_syncing, percentage);
|
case "scanning":
|
||||||
case "error": return c.getString(R.string.state_error);
|
return c.getString(R.string.state_scanning);
|
||||||
case "unknown": return c.getString(R.string.state_unknown);
|
case "syncing":
|
||||||
default: return state;
|
int percentage = (folderStatus.globalBytes != 0)
|
||||||
|
? Math.round(100 * folderStatus.inSyncBytes / folderStatus.globalBytes)
|
||||||
|
: 100;
|
||||||
|
return c.getString(R.string.state_syncing, percentage);
|
||||||
|
case "error":
|
||||||
|
if (TextUtils.isEmpty(folderStatus.error)) {
|
||||||
|
return c.getString(R.string.state_error);
|
||||||
|
}
|
||||||
|
return c.getString(R.string.state_error) + " (" + folderStatus.error + ")";
|
||||||
|
case "unknown":
|
||||||
|
return c.getString(R.string.state_unknown);
|
||||||
|
default:
|
||||||
|
return folderStatus.state;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue