Added total sum to reports

This commit is contained in:
PaulStets 2017-12-21 16:22:53 +02:00
parent cc1df51e88
commit 272bbd8206
3 changed files with 84 additions and 2 deletions

View file

@ -274,6 +274,61 @@
android:layout_marginLeft="56dp"
android:background="?attr/dashboard_divider"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/donationsTotal"
android:visibility="gone"
android:minHeight="60dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:minHeight="60dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/donationsTotalIcon"
android:layout_width="56dp"
android:layout_height="56dp"
android:scaleType="center"
android:src="@drawable/ic_action_bitcoin"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="16dp"
android:orientation="vertical">
<TextView
android:id="@+id/donationsTotalTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/total_donations"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_sub_text_size"/>
<TextView
android:id="@+id/donationsTotalTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="-"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size"/>
</LinearLayout>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginLeft="56dp"
android:background="?attr/dashboard_divider"/>
</LinearLayout>
<LinearLayout
android:id="@+id/numberOfRecipientsLayout"
android:background="?attr/selectableItemBackground"

View file

@ -2823,4 +2823,5 @@
<string name="move_point">Move Point</string>
<string name="add_segment_to_the_track">Add to a GPX track</string>
<string name="osm_recipients_label">OSM Recipients</string>
<string name="total_donations">Total Donations</string>
</resources>

View file

@ -18,6 +18,7 @@ import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.Spinner;
import android.widget.TextView;
@ -72,11 +73,15 @@ public class ReportsFragment extends BaseOsmAndFragment implements CountrySelect
private ImageView numberOfEditsIcon;
private ImageView donationsIcon;
private ImageView numberOfRecipientsIcon;
private ImageView donationsTotalIcon;
private TextView donationsTotalTitle;
private TextView donationsTotalTextView;
private TextView numberOfContributorsTitle;
private TextView numberOfEditsTitle;
private TextView numberOfRecipientsTitle;
private TextView donationsTitle;
private ProgressBar progressBar;
private LinearLayout donationsTotalLayout;
private int inactiveColor;
private int textColorPrimary;
@ -159,9 +164,11 @@ public class ReportsFragment extends BaseOsmAndFragment implements CountrySelect
numberOfEditsIcon = (ImageView) view.findViewById(R.id.numberOfEditsIcon);
numberOfRecipientsIcon = (ImageView) view.findViewById(R.id.numberOfRecipientsIcon);
donationsIcon = (ImageView) view.findViewById(R.id.donationsIcon);
donationsTotalIcon = (ImageView) view.findViewById(R.id.donationsTotalIcon);
setThemedDrawable(numberOfContributorsIcon, R.drawable.ic_action_group2);
setThemedDrawable(numberOfRecipientsIcon, R.drawable.ic_group);
setThemedDrawable(donationsIcon, R.drawable.ic_action_bitcoin);
setThemedDrawable(donationsTotalIcon, R.drawable.ic_action_bitcoin);
setThemedDrawable(numberOfEditsIcon, R.drawable.ic_map);
@ -169,6 +176,10 @@ public class ReportsFragment extends BaseOsmAndFragment implements CountrySelect
numberOfEditsTitle = (TextView) view.findViewById(R.id.numberOfEditsTitle);
donationsTitle = (TextView) view.findViewById(R.id.donationsTitle);
numberOfRecipientsTitle = (TextView) view.findViewById(R.id.numberOfRecipientsTitle);
donationsTotalLayout = (LinearLayout) view.findViewById(R.id.donationsTotal);
donationsTotalTitle = (TextView) view.findViewById(R.id.donationsTotalTitle);
donationsTotalTextView = (TextView) view.findViewById(R.id.donationsTotalTextView);
progressBar = (ProgressBar) view.findViewById(R.id.progress);
@ -207,7 +218,7 @@ public class ReportsFragment extends BaseOsmAndFragment implements CountrySelect
tryUpdateData(monthUrlString, countryUrlString);
}
private void tryUpdateData(String monthUrlString, String regionUrlString) {
private void tryUpdateData(String monthUrlString, final String regionUrlString) {
GetJsonAsyncTask.OnResponseListener<Protocol.TotalChangesByMonthResponse> onResponseListener =
new GetJsonAsyncTask.OnResponseListener<Protocol.TotalChangesByMonthResponse>() {
@Override
@ -255,7 +266,13 @@ public class ReportsFragment extends BaseOsmAndFragment implements CountrySelect
recipientsTextView.setText(String.valueOf(response.regionCount));
}
if (donationsTextView != null) {
donationsTextView.setText(String.format("%.3f", response.regionBtc*1000.0) + " mBTC");
donationsTextView.setText(String.format("%.3f", response.regionBtc*1000f) + " mBTC");
}
if (donationsTotalLayout != null &&
donationsTotalTextView != null) {
boolean world = regionUrlString.isEmpty();
donationsTotalLayout.setVisibility(world ? View.VISIBLE : View.GONE);
donationsTotalTextView.setText(String.format("%.3f", response.btc*1000f) + " mBTC");
}
}
disableProgress();
@ -269,6 +286,9 @@ public class ReportsFragment extends BaseOsmAndFragment implements CountrySelect
if (donationsTextView != null) {
donationsTextView.setText("-");
}
if (donationsTotalTextView != null) {
donationsTotalTextView.setText("-");
}
String recfinalUrl = String.format(RECIPIENTS_BY_MONTH, monthUrlString, regionUrlString);
recChangesByMontAsyncTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, recfinalUrl);
}
@ -368,16 +388,19 @@ public class ReportsFragment extends BaseOsmAndFragment implements CountrySelect
numberOfEditsIcon.setImageDrawable(getPaintedContentIcon(R.drawable.ic_map, inactiveColor));
numberOfRecipientsIcon.setImageDrawable(getPaintedContentIcon(R.drawable.ic_group, inactiveColor));
donationsIcon.setImageDrawable(getPaintedContentIcon(R.drawable.ic_action_bitcoin, inactiveColor));
donationsTotalIcon.setImageDrawable(getPaintedContentIcon(R.drawable.ic_action_bitcoin, inactiveColor));
numberOfContributorsTitle.setTextColor(inactiveColor);
numberOfEditsTitle.setTextColor(inactiveColor);
numberOfRecipientsTitle.setTextColor(inactiveColor);
donationsTitle.setTextColor(inactiveColor);
donationsTotalTitle.setTextColor(inactiveColor);
progressBar.setVisibility(View.VISIBLE);
contributorsTextView.setTextColor(inactiveColor);
donationsTextView.setTextColor(inactiveColor);
donationsTotalTextView.setTextColor(inactiveColor);
recipientsTextView.setTextColor(inactiveColor);
editsTextView.setTextColor(inactiveColor);
}
@ -387,17 +410,20 @@ public class ReportsFragment extends BaseOsmAndFragment implements CountrySelect
numberOfEditsIcon.setImageDrawable(getContentIcon(R.drawable.ic_map));
numberOfRecipientsIcon.setImageDrawable(getContentIcon(R.drawable.ic_group));
donationsIcon.setImageDrawable(getContentIcon(R.drawable.ic_action_bitcoin));
donationsTotalIcon.setImageDrawable(getContentIcon(R.drawable.ic_action_bitcoin));
numberOfContributorsTitle.setTextColor(textColorSecondary);
numberOfEditsTitle.setTextColor(textColorSecondary);
numberOfRecipientsTitle.setTextColor(textColorSecondary);
donationsTitle.setTextColor(textColorSecondary);
donationsTotalTitle.setTextColor(textColorSecondary);
progressBar.setVisibility(View.INVISIBLE);
contributorsTextView.setTextColor(textColorPrimary);
editsTextView.setTextColor(textColorPrimary);
donationsTextView.setTextColor(textColorPrimary);
donationsTotalTextView.setTextColor(textColorPrimary);
recipientsTextView.setTextColor(textColorPrimary);
}