diff --git a/OsmAnd/res/layout/fragment_reports.xml b/OsmAnd/res/layout/fragment_reports.xml index b900f162e6..84e6564ccb 100644 --- a/OsmAnd/res/layout/fragment_reports.xml +++ b/OsmAnd/res/layout/fragment_reports.xml @@ -274,6 +274,61 @@ android:layout_marginLeft="56dp" android:background="?attr/dashboard_divider"/> + + + + + + + + + + + + + + + + + + + Move Point Add to a GPX track OSM Recipients + Total Donations diff --git a/OsmAnd/src/net/osmand/plus/liveupdates/ReportsFragment.java b/OsmAnd/src/net/osmand/plus/liveupdates/ReportsFragment.java index 904f2b3833..ffb7762a7b 100644 --- a/OsmAnd/src/net/osmand/plus/liveupdates/ReportsFragment.java +++ b/OsmAnd/src/net/osmand/plus/liveupdates/ReportsFragment.java @@ -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 onResponseListener = new GetJsonAsyncTask.OnResponseListener() { @Override @@ -255,24 +266,32 @@ 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) { + donationsTotalLayout.setVisibility(regionUrlString.isEmpty() ? View.VISIBLE : View.GONE); + donationsTotalTextView.setText(String.format("%.3f", response.btc*1000f) + " mBTC"); } } disableProgress(); } }; recChangesByMontAsyncTask.setOnResponseListener(recResponseListener); + clearTextViewResult(recipientsTextView); + clearTextViewResult(donationsTextView); + clearTextViewResult(donationsTotalTextView); - if (recipientsTextView != null) { - recipientsTextView.setText("-"); - } - if (donationsTextView != null) { - donationsTextView.setText("-"); - } String recfinalUrl = String.format(RECIPIENTS_BY_MONTH, monthUrlString, regionUrlString); recChangesByMontAsyncTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, recfinalUrl); } + private void clearTextViewResult(TextView textView) { + if (textView != null) { + textView.setText("-"); + } + } + @Override public void onSearchResult(CountryItem item) { selectedCountryItem = item; @@ -368,16 +387,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 +409,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); }