From 272bbd820681305ee6f872e8c09653b4dd866970 Mon Sep 17 00:00:00 2001 From: PaulStets Date: Thu, 21 Dec 2017 16:22:53 +0200 Subject: [PATCH 1/3] Added total sum to reports --- OsmAnd/res/layout/fragment_reports.xml | 55 +++++++++++++++++++ OsmAnd/res/values/strings.xml | 1 + .../plus/liveupdates/ReportsFragment.java | 30 +++++++++- 3 files changed, 84 insertions(+), 2 deletions(-) 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..1e7ff0d3bd 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,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); } From fce7cb05e737deee5be38f30507629fc96c1adc3 Mon Sep 17 00:00:00 2001 From: PaulStets Date: Thu, 21 Dec 2017 16:32:43 +0200 Subject: [PATCH 2/3] Refactoring --- OsmAnd/src/net/osmand/plus/liveupdates/ReportsFragment.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/liveupdates/ReportsFragment.java b/OsmAnd/src/net/osmand/plus/liveupdates/ReportsFragment.java index 1e7ff0d3bd..e6838776ed 100644 --- a/OsmAnd/src/net/osmand/plus/liveupdates/ReportsFragment.java +++ b/OsmAnd/src/net/osmand/plus/liveupdates/ReportsFragment.java @@ -270,8 +270,7 @@ public class ReportsFragment extends BaseOsmAndFragment implements CountrySelect } if (donationsTotalLayout != null && donationsTotalTextView != null) { - boolean world = regionUrlString.isEmpty(); - donationsTotalLayout.setVisibility(world ? View.VISIBLE : View.GONE); + donationsTotalLayout.setVisibility(regionUrlString.isEmpty() ? View.VISIBLE : View.GONE); donationsTotalTextView.setText(String.format("%.3f", response.btc*1000f) + " mBTC"); } } From 6a9523f7b67516cbbd27167427ec005a62d31e3b Mon Sep 17 00:00:00 2001 From: PaulStets Date: Thu, 21 Dec 2017 18:18:25 +0200 Subject: [PATCH 3/3] Refactoring --- .../plus/liveupdates/ReportsFragment.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/liveupdates/ReportsFragment.java b/OsmAnd/src/net/osmand/plus/liveupdates/ReportsFragment.java index e6838776ed..ffb7762a7b 100644 --- a/OsmAnd/src/net/osmand/plus/liveupdates/ReportsFragment.java +++ b/OsmAnd/src/net/osmand/plus/liveupdates/ReportsFragment.java @@ -278,20 +278,20 @@ public class ReportsFragment extends BaseOsmAndFragment implements CountrySelect } }; recChangesByMontAsyncTask.setOnResponseListener(recResponseListener); + clearTextViewResult(recipientsTextView); + clearTextViewResult(donationsTextView); + clearTextViewResult(donationsTotalTextView); - if (recipientsTextView != null) { - recipientsTextView.setText("-"); - } - 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); } + private void clearTextViewResult(TextView textView) { + if (textView != null) { + textView.setText("-"); + } + } + @Override public void onSearchResult(CountryItem item) { selectedCountryItem = item;