diff --git a/app/app.iml b/app/app.iml
index 2911acff..7f125a00 100644
--- a/app/app.iml
+++ b/app/app.iml
@@ -73,7 +73,7 @@
-
+
diff --git a/app/src/main/java/com/stevenschoen/putionew/PutioFileLayout.java b/app/src/main/java/com/stevenschoen/putionew/PutioFileLayout.java
index f32c2596..0b7ffed7 100644
--- a/app/src/main/java/com/stevenschoen/putionew/PutioFileLayout.java
+++ b/app/src/main/java/com/stevenschoen/putionew/PutioFileLayout.java
@@ -1,21 +1,27 @@
package com.stevenschoen.putionew;
+import android.content.Context;
+import android.content.res.Resources;
import android.os.Parcel;
import android.os.Parcelable;
+import com.stevenschoen.putionew.model.files.PutioFileData;
+
public class PutioFileLayout implements Parcelable {
public String name;
public String description;
public int iconRes;
public String iconUrl;
- public PutioFileLayout(String name, String description, int iconRes, String iconUrl) {
- super();
- this.name = name;
- this.description = description;
- this.iconRes = iconRes;
- this.iconUrl = iconUrl;
- }
+ public PutioFileLayout(Resources resources, PutioFileData data) {
+ name = data.name;
+ description = resources.getString(R.string.size_is, PutioUtils.humanReadableByteCount(
+ data.size, false));
+ Integer iconResource = PutioFileData.contentTypes.get(data.contentType);
+ if (iconResource == null) iconResource = R.drawable.ic_putio_file;
+ iconRes = iconResource;
+ iconUrl = data.icon;
+ }
@Override
public int describeContents() {
diff --git a/app/src/main/java/com/stevenschoen/putionew/PutioTransferLayout.java b/app/src/main/java/com/stevenschoen/putionew/PutioTransferLayout.java
index ab584927..5dfd759d 100644
--- a/app/src/main/java/com/stevenschoen/putionew/PutioTransferLayout.java
+++ b/app/src/main/java/com/stevenschoen/putionew/PutioTransferLayout.java
@@ -3,25 +3,24 @@
import android.os.Parcel;
import android.os.Parcelable;
+import com.stevenschoen.putionew.model.transfers.PutioTransferData;
+
public class PutioTransferLayout implements Parcelable {
public String name;
public long downSpeed;
public long upSpeed;
+ public String ratio;
public int percentDone;
public String status;
- public PutioTransferLayout() {
- super();
- }
-
- public PutioTransferLayout(String name, long downSpeed, long upSpeed, int percentDone, String status) {
- super();
- this.name = name;
- this.downSpeed = downSpeed;
- this.upSpeed = upSpeed;
- this.percentDone = percentDone;
- this.status = status;
- }
+ public PutioTransferLayout(PutioTransferData data) {
+ name = data.name;
+ downSpeed = data.downSpeed;
+ upSpeed = data.upSpeed;
+ ratio = data.currentRatio;
+ percentDone = data.percentDone;
+ status = data.status;
+ }
@Override
public int describeContents() {
@@ -33,12 +32,10 @@ public PutioTransferLayout(Parcel in) {
}
private void readFromParcel(Parcel in) {
- // We just need to read back each
- // field in the order that it was
- // written to the parcel
this.name = in.readString();
this.downSpeed = in.readLong();
this.upSpeed = in.readLong();
+ this.ratio = in.readString();
this.percentDone = in.readInt();
this.status = in.readString();
}
@@ -48,6 +45,7 @@ public void writeToParcel(Parcel out, int flags) {
out.writeString(this.name);
out.writeLong(this.downSpeed);
out.writeLong(this.upSpeed);
+ out.writeString(this.ratio);
out.writeInt(this.percentDone);
out.writeString(this.status);
}
diff --git a/app/src/main/java/com/stevenschoen/putionew/TransfersAdapter.java b/app/src/main/java/com/stevenschoen/putionew/TransfersAdapter.java
index d451d2de..a78a7c3a 100644
--- a/app/src/main/java/com/stevenschoen/putionew/TransfersAdapter.java
+++ b/app/src/main/java/com/stevenschoen/putionew/TransfersAdapter.java
@@ -42,13 +42,16 @@ public View getView(int position, View convertView, ViewGroup parent) {
holder.textDownUnit = (TextView) row.findViewById(R.id.text_transfer_downUnit);
holder.textUpValue = (TextView) row.findViewById(R.id.text_transfer_upValue);
holder.textUpUnit = (TextView) row.findViewById(R.id.text_transfer_upUnit);
+ holder.textRatio = (TextView) row.findViewById(R.id.text_transfer_ratio);
holder.textPercent = (TextView) row.findViewById(R.id.text_transfer_percent);
holder.imgStatusIcon = (ImageView) row.findViewById(R.id.img_transfer_icon);
holder.statusLoading = (ProgressBar) row.findViewById(R.id.transfer_statusLoading);
holder.greenBar = row.findViewById(R.id.transfer_greenbar);
holder.textMessage = (TextView) row.findViewById(R.id.text_transfer_message);
- holder.speedHolder = row.findViewById(R.id.transfer_speedHolder);
+ holder.downHolder = row.findViewById(R.id.holder_transfer_down);
+ holder.upHolder = row.findViewById(R.id.holder_transfer_up);
+ holder.ratioHolder = row.findViewById(R.id.holder_transfer_ratio);
row.setTag(holder);
} else {
@@ -59,61 +62,65 @@ public View getView(int position, View convertView, ViewGroup parent) {
holder.textName.setText(transfer.name);
- String[] downStrings = PutioUtils.humanReadableByteCountArray(data.get(position).downSpeed, false);
+ String[] downStrings = PutioUtils.humanReadableByteCountArray(transfer.downSpeed, false);
holder.textDownValue.setText(downStrings[0]);
holder.textDownUnit.setText(downStrings[1] + "/sec");
- String[] upStrings = PutioUtils.humanReadableByteCountArray(data.get(position).upSpeed, false);
+ String[] upStrings = PutioUtils.humanReadableByteCountArray(transfer.upSpeed, false);
holder.textUpValue.setText(upStrings[0]);
holder.textUpUnit.setText(upStrings[1] + "/sec");
- int percentInt = data.get(position).percentDone;
+ int percentInt = transfer.percentDone;
String percentString = Integer.toString(percentInt);
- if (data.get(position).status.equals("COMPLETED")) {
- holder.imgStatusIcon.setImageResource(R.drawable.ic_transfer_done);
- holder.imgStatusIcon.setVisibility(View.VISIBLE);
- holder.statusLoading.setVisibility(View.INVISIBLE);
- holder.textMessage.setVisibility(View.GONE);
- holder.speedHolder.setVisibility(View.VISIBLE);
- holder.textPercent.setText(percentString + "%");
- holder.greenBar.setBackgroundColor(Color.parseColor("#2000FF00"));
- holder.greenBar.setPivotX(0);
- holder.greenBar.setScaleX(1f);
- holder.textPercent.setTextColor(context.getResources().getColor(R.color.putio_green));
- } else if (data.get(position).status.equals("SEEDING")) {
- holder.imgStatusIcon.setImageResource(R.drawable.ic_transfer_done);
- holder.imgStatusIcon.setVisibility(View.VISIBLE);
- holder.statusLoading.setVisibility(View.INVISIBLE);
- holder.textMessage.setVisibility(View.GONE);
- holder.speedHolder.setVisibility(View.VISIBLE);
- holder.textPercent.setText(percentString + "%");
- holder.greenBar.setBackgroundColor(Color.parseColor("#2000FF00"));
- holder.greenBar.setPivotX(0);
- holder.greenBar.setScaleX(1f);
- holder.textPercent.setTextColor(context.getResources().getColor(R.color.putio_green));
- } else if (data.get(position).status.equals("ERROR")) {
- holder.imgStatusIcon.setImageResource(R.drawable.ic_transfer_failed);
- holder.imgStatusIcon.setVisibility(View.VISIBLE);
- holder.statusLoading.setVisibility(View.INVISIBLE);
- holder.textMessage.setText(context.getString(R.string.transferfailed));
- holder.textMessage.setVisibility(View.VISIBLE);
- holder.speedHolder.setVisibility(View.GONE);
- holder.textPercent.setText(":(");
- holder.greenBar.setBackgroundColor(context.getResources().getColor(R.color.putio_error));
- holder.greenBar.setPivotX(0);
- holder.greenBar.setScaleX(1f);
- holder.textPercent.setTextColor(Color.RED);
- } else {
- holder.imgStatusIcon.setVisibility(View.INVISIBLE);
- holder.statusLoading.setVisibility(View.VISIBLE);
- holder.textMessage.setVisibility(View.GONE);
- holder.speedHolder.setVisibility(View.VISIBLE);
- holder.textPercent.setText(percentString + "%");
- holder.greenBar.setBackgroundColor(Color.parseColor("#2000FF00"));
- holder.greenBar.setPivotX(0);
- holder.greenBar.setScaleX((float) data.get(position).percentDone / 100);
- holder.textPercent.setTextColor(Color.BLACK);
- }
+ switch (transfer.status) {
+ case "COMPLETED":
+ case "SEEDING":
+ holder.imgStatusIcon.setImageResource(R.drawable.ic_transfer_done);
+ holder.imgStatusIcon.setVisibility(View.VISIBLE);
+ holder.statusLoading.setVisibility(View.INVISIBLE);
+ holder.textMessage.setVisibility(View.GONE);
+ holder.downHolder.setVisibility(View.GONE);
+ holder.upHolder.setVisibility(View.VISIBLE);
+ if (Float.valueOf(transfer.ratio) != 0) {
+ holder.textRatio.setText(getContext().getString(R.string.ratio_is, transfer.ratio));
+ holder.ratioHolder.setVisibility(View.VISIBLE);
+ } else {
+ holder.ratioHolder.setVisibility(View.GONE);
+ }
+ holder.textPercent.setText(percentString + "%");
+ holder.greenBar.setBackgroundColor(Color.parseColor("#2000FF00"));
+ holder.greenBar.setPivotX(0);
+ holder.greenBar.setScaleX(1f);
+ holder.textPercent.setTextColor(context.getResources().getColor(R.color.putio_green));
+ break;
+ case "ERROR":
+ holder.imgStatusIcon.setImageResource(R.drawable.ic_transfer_failed);
+ holder.imgStatusIcon.setVisibility(View.VISIBLE);
+ holder.statusLoading.setVisibility(View.INVISIBLE);
+ holder.textMessage.setText(context.getString(R.string.transferfailed));
+ holder.textMessage.setVisibility(View.VISIBLE);
+ holder.downHolder.setVisibility(View.GONE);
+ holder.upHolder.setVisibility(View.GONE);
+ holder.ratioHolder.setVisibility(View.GONE);
+ holder.textPercent.setText(":(");
+ holder.greenBar.setBackgroundColor(context.getResources().getColor(R.color.putio_error));
+ holder.greenBar.setPivotX(0);
+ holder.greenBar.setScaleX(1f);
+ holder.textPercent.setTextColor(Color.RED);
+ break;
+ default:
+ holder.imgStatusIcon.setVisibility(View.INVISIBLE);
+ holder.statusLoading.setVisibility(View.VISIBLE);
+ holder.textMessage.setVisibility(View.GONE);
+ holder.downHolder.setVisibility(View.VISIBLE);
+ holder.upHolder.setVisibility(View.VISIBLE);
+ holder.ratioHolder.setVisibility(View.GONE);
+ holder.textPercent.setText(percentString + "%");
+ holder.greenBar.setBackgroundColor(Color.parseColor("#2000FF00"));
+ holder.greenBar.setPivotX(0);
+ holder.greenBar.setScaleX((float) data.get(position).percentDone / 100);
+ holder.textPercent.setTextColor(Color.BLACK);
+ }
return row;
}
@@ -124,12 +131,15 @@ static class TransferHolder {
TextView textDownUnit;
TextView textUpValue;
TextView textUpUnit;
+ TextView textRatio;
TextView textPercent;
ImageView imgStatusIcon;
ProgressBar statusLoading;
View greenBar;
TextView textMessage;
- View speedHolder;
+ View downHolder;
+ View upHolder;
+ View ratioHolder;
}
}
\ No newline at end of file
diff --git a/app/src/main/java/com/stevenschoen/putionew/fragments/Files.java b/app/src/main/java/com/stevenschoen/putionew/fragments/Files.java
index e82e8b82..4357917a 100644
--- a/app/src/main/java/com/stevenschoen/putionew/fragments/Files.java
+++ b/app/src/main/java/com/stevenschoen/putionew/fragments/Files.java
@@ -475,15 +475,7 @@ private void populateList(final List files, int newId, int parent
fileLayouts.clear();
if (isAdded()) {
for (PutioFileData file : files) {
- Integer iconResource = PutioFileData.contentTypes.get(file.contentType);
- if (iconResource == null) iconResource = R.drawable.ic_putio_file;
- fileLayouts.add(new PutioFileLayout(
- file.name,
- getString(R.string.size_is, PutioUtils.humanReadableByteCount(
- file.size, false)),
- iconResource,
- file.icon
- ));
+ fileLayouts.add(new PutioFileLayout(getResources(), file));
}
}
adapter.notifyDataSetChanged();
diff --git a/app/src/main/java/com/stevenschoen/putionew/fragments/Transfers.java b/app/src/main/java/com/stevenschoen/putionew/fragments/Transfers.java
index 610a40bb..b01a3447 100644
--- a/app/src/main/java/com/stevenschoen/putionew/fragments/Transfers.java
+++ b/app/src/main/java/com/stevenschoen/putionew/fragments/Transfers.java
@@ -240,48 +240,12 @@ public void updateTransfers(List transfers) {
setViewMode(VIEWMODE_LIST);
}
-// final ArrayList transferLayoutsTemp = new ArrayList();
-// for (int i = 0; i < transfers.length; i++) {
-// if (isAdded()) {
-// transferLayoutsTemp.add(new PutioTransferLayout(
-// transfers[i].name,
-// transfers[i].downSpeed,
-// transfers[i].upSpeed,
-// transfers[i].percentDone,
-// transfers[i].status));
-// }
-// }
-//
-// int index = listview.getFirstVisiblePosition();
-// View v = listview.getChildAt(0);
-// int top = (v == null) ? 0 : v.getTop();
-//
-// listview.setSelectionFromTop(index, top);
-//
-// while (transferLayouts.size() > transferLayoutsTemp.size()) {
-// transferLayouts.remove(transferLayouts.size() - 1);
-// }
-//
-// for (int i = 0; i < transferLayoutsTemp.size(); i++) {
-// if (transferLayouts.size() <= i) {
-// transferLayouts.add(transferLayoutsTemp.get(i));
-// } else {
-// transferLayouts.set(i, transferLayoutsTemp.get(i));
-// }
-// adapter.notifyDataSetChanged();
-// }
-
transfersData = transfers;
if (isAdded()) {
transferLayouts.clear();
for (PutioTransferData transfer : transfers) {
- transferLayouts.add(new PutioTransferLayout(
- transfer.name,
- transfer.downSpeed,
- transfer.upSpeed,
- transfer.percentDone,
- transfer.status));
+ transferLayouts.add(new PutioTransferLayout(transfer));
}
adapter.notifyDataSetChanged();
}
diff --git a/app/src/main/java/com/stevenschoen/putionew/model/transfers/PutioTransferData.java b/app/src/main/java/com/stevenschoen/putionew/model/transfers/PutioTransferData.java
index 54eb9c17..0ec9facf 100644
--- a/app/src/main/java/com/stevenschoen/putionew/model/transfers/PutioTransferData.java
+++ b/app/src/main/java/com/stevenschoen/putionew/model/transfers/PutioTransferData.java
@@ -11,6 +11,7 @@ public class PutioTransferData implements Parcelable {
public String estimatedTime;
public String createdTime;
public boolean extract;
+ public String currentRatio;
public long downSpeed;
public long upSpeed;
public int percentDone;
@@ -18,27 +19,7 @@ public class PutioTransferData implements Parcelable {
public String statusMessage;
public int saveParentId;
- public PutioTransferData(int id, int fileId, long size, String name,
- String estimatedTime, String createdTime, boolean extract,
- long downSpeed, long upSpeed, int percentDone, String status,
- String statusMessage, int saveParentId) {
- super();
- this.id = id;
- this.fileId = fileId;
- this.size = size;
- this.name = name;
- this.estimatedTime = estimatedTime;
- this.createdTime = createdTime;
- this.extract = extract;
- this.downSpeed = downSpeed;
- this.upSpeed = upSpeed;
- this.percentDone = percentDone;
- this.status = status;
- this.statusMessage = statusMessage;
- this.saveParentId = saveParentId;
- }
-
- @Override
+ @Override
public int describeContents() {
return 0;
}
@@ -48,9 +29,6 @@ public PutioTransferData(Parcel in) {
}
private void readFromParcel(Parcel in) {
- // We just need to read back each
- // field in the order that it was
- // written to the parcel
this.id = in.readInt();
this.fileId = in.readInt();
this.size = in.readLong();
@@ -58,6 +36,7 @@ private void readFromParcel(Parcel in) {
this.estimatedTime = in.readString();
this.createdTime = in.readString();
this.extract = (Boolean) in.readValue(ClassLoader.getSystemClassLoader());
+ this.currentRatio = in.readString();
this.downSpeed = in.readLong();
this.upSpeed = in.readLong();
this.percentDone = in.readInt();
@@ -75,6 +54,7 @@ public void writeToParcel(Parcel out, int flags) {
out.writeString(this.estimatedTime);
out.writeString(this.createdTime);
out.writeValue(this.extract);
+ out.writeString(this.currentRatio);
out.writeLong(this.downSpeed);
out.writeLong(this.upSpeed);
out.writeInt(this.percentDone);
diff --git a/app/src/main/res/layout/transfer.xml b/app/src/main/res/layout/transfer.xml
index 4d994a60..49d3487d 100644
--- a/app/src/main/res/layout/transfer.xml
+++ b/app/src/main/res/layout/transfer.xml
@@ -71,62 +71,93 @@
android:visibility="gone" />
+ android:layout_marginLeft="4dp"
+ android:orientation="horizontal">
-
-
-
+ android:layout_marginEnd="8dp"
+ android:layout_marginRight="8dp"
+ android:orientation="horizontal">
-
+
-
+
+
+
+
+
-
-
-
-
+
+
+
+
+
+
+
+
+
+ android:layout_height="match_parent"
+ android:orientation="horizontal">
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index e2d4b968..89a2d21c 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -93,6 +93,7 @@
No files were found.
File deleted!
Transfer removed!
+ Ratio: %s
Hey!
The download link is ready to be pasted.
Choose a file