mirror of
https://github.com/syncthing/syncthing-android.git
synced 2024-12-23 03:11:30 +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 stateChanged;
|
||||
public long version;
|
||||
public String error;
|
||||
public String watchError;
|
||||
}
|
||||
|
|
|
@ -97,9 +97,6 @@ public class FoldersAdapter extends ArrayAdapter<Folder> {
|
|||
return;
|
||||
}
|
||||
|
||||
int percentage = (folderStatus.globalBytes != 0)
|
||||
? Math.round(100 * folderStatus.inSyncBytes / folderStatus.globalBytes)
|
||||
: 100;
|
||||
long neededItems = folderStatus.needFiles + folderStatus.needDirectories + folderStatus.needSymlinks + folderStatus.needDeletes;
|
||||
boolean outOfSync = folderStatus.state.equals("idle") && neededItems > 0;
|
||||
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.setTextColor(ContextCompat.getColor(mContext, R.color.text_black));
|
||||
} else {
|
||||
binding.state.setText(getLocalizedState(mContext, folderStatus.state, percentage));
|
||||
binding.state.setText(getLocalizedState(mContext, folderStatus));
|
||||
switch(folderStatus.state) {
|
||||
case "idle":
|
||||
binding.state.setTextColor(ContextCompat.getColor(mContext, R.color.text_green));
|
||||
|
@ -121,6 +118,7 @@ public class FoldersAdapter extends ArrayAdapter<Folder> {
|
|||
case "syncing":
|
||||
binding.state.setTextColor(ContextCompat.getColor(mContext, R.color.text_blue));
|
||||
break;
|
||||
case "error":
|
||||
default:
|
||||
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.
|
||||
*/
|
||||
private static String getLocalizedState(Context c, String state, int percentage) {
|
||||
switch (state) {
|
||||
case "idle": return c.getString(R.string.state_idle);
|
||||
case "scanning": return c.getString(R.string.state_scanning);
|
||||
case "syncing": return c.getString(R.string.state_syncing, percentage);
|
||||
case "error": return c.getString(R.string.state_error);
|
||||
case "unknown": return c.getString(R.string.state_unknown);
|
||||
default: return state;
|
||||
private static String getLocalizedState(Context c, FolderStatus folderStatus) {
|
||||
switch (folderStatus.state) {
|
||||
case "idle":
|
||||
return c.getString(R.string.state_idle);
|
||||
case "scanning":
|
||||
return c.getString(R.string.state_scanning);
|
||||
case "syncing":
|
||||
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