diff --git a/OsmAnd/no_translate.xml b/OsmAnd/no_translate.xml
index 7471ced1a9..702dd1adfc 100644
--- a/OsmAnd/no_translate.xml
+++ b/OsmAnd/no_translate.xml
@@ -27,27 +27,6 @@
Tag
Value
- OSM Live subscription
- Subscribe
- €1,49
- We need it to provide you information about contributions
- Public Name
- Don\'t show my name in reports
- Support region
- Month cost
- Monthly payment
- Active
- Inactive
- Please enter valid E-mail address
- Please enter Public Name
- Thank you for subscribing to live updates!
- Part your donation will be sent to OSM users who submit changes to the map in that region
- Subscription settings
- Please purchase OSM Live subscription first
-
- This subscription enables hourly updates for all maps around the world.
- Major part of the income goes back to OSM community and is paid out per each OSM contribution.
- In case you love OsmAnd and OSM and want to support it, this is a perfect way to do it.
-
+ €1,49
diff --git a/OsmAnd/res/layout/fragment_reports.xml b/OsmAnd/res/layout/fragment_reports.xml
index 12f99f4ac2..a16fd36929 100644
--- a/OsmAnd/res/layout/fragment_reports.xml
+++ b/OsmAnd/res/layout/fragment_reports.xml
@@ -1,150 +1,250 @@
-
+ tools:context="net.osmand.plus.liveupdates.ReportsFragment" >
-
+
-
+ android:layout_height="wrap_content"
+ android:background="?attr/bg_color"
+ android:columnCount="2" >
-
+ android:orientation="horizontal"
+ android:gravity="center_vertical">
+ android:textColor="?android:textColorPrimary" />
+
+
+
-
+
-
+
-
-
+
-
+
-
+
-
+
+
+ android:text="@string/reports_for"
+ android:textColor="?android:textColorSecondary"
+ android:textSize="@dimen/default_sub_text_size" />
-
+
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ android:layout_columnSpan="2" />
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/layout/fragment_simple_list.xml b/OsmAnd/res/layout/fragment_simple_list.xml
new file mode 100644
index 0000000000..95e228a960
--- /dev/null
+++ b/OsmAnd/res/layout/fragment_simple_list.xml
@@ -0,0 +1,56 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml
index a57f609348..4b1a4851b4 100644
--- a/OsmAnd/res/values/strings.xml
+++ b/OsmAnd/res/values/strings.xml
@@ -9,6 +9,31 @@
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
-->
+ Donations
+ Number of recipients
+ Changes %1$s, rank %2$s, total changes %3$s
+ OSM Editors ranking
+ OSM Live subscription
+ Subscribe
+ We need it to provide you information about contributions
+ Public Name
+ Don\'t show my name in reports
+ Support region
+ Month cost
+ Monthly payment
+ Active
+ Inactive
+ Please enter valid E-mail address
+ Please enter Public Name
+ Thank you for subscribing to live updates!
+ Part your donation will be sent to OSM users who submit changes to the map in that region
+ Subscription settings
+ Please purchase OSM Live subscription first
+
+ This subscription enables hourly updates for all maps around the world.
+ Major part of the income goes back to OSM community and is paid out per each OSM contribution.
+ In case you love OsmAnd and OSM and want to support it, this is a perfect way to do it.
+
Select Map marker
Other markers
Upload anonymously
diff --git a/OsmAnd/src/net/osmand/plus/liveupdates/Protocol.java b/OsmAnd/src/net/osmand/plus/liveupdates/Protocol.java
index 1f81ea471f..f7e41e3f62 100644
--- a/OsmAnd/src/net/osmand/plus/liveupdates/Protocol.java
+++ b/OsmAnd/src/net/osmand/plus/liveupdates/Protocol.java
@@ -10,6 +10,28 @@ public final class Protocol {
public String month;
public RankingByMonth[] rows;
}
+
+ public static class RankingUserByMonthResponse {
+ public String month;
+ public UserRankingByMonth[] rows;
+ }
+
+ public static class RecipientsByMonth {
+ public String month;
+ public String message;
+ public float regionBtc;
+ public int regionCount;
+ public float regionPercentage;
+ public float btc;
+ }
+
+ public static class UserRankingByMonth {
+ public String user ;
+ public int changes;
+ public int globalchanges;
+ public int rank;
+ public int grank;
+ }
// {"rank":"8","countUsers":"713","minChanges":"14","maxChanges":"18","avgChanges":"15.9845722300140252"}
public static class RankingByMonth {
@@ -26,4 +48,5 @@ public final class Protocol {
public int users;
public int changes;
}
+
}
diff --git a/OsmAnd/src/net/osmand/plus/liveupdates/ReportsFragment.java b/OsmAnd/src/net/osmand/plus/liveupdates/ReportsFragment.java
index 380f3a4fdc..4639c1b2db 100644
--- a/OsmAnd/src/net/osmand/plus/liveupdates/ReportsFragment.java
+++ b/OsmAnd/src/net/osmand/plus/liveupdates/ReportsFragment.java
@@ -1,8 +1,23 @@
package net.osmand.plus.liveupdates;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Locale;
+
+import net.osmand.PlatformUtil;
+import net.osmand.osm.io.NetworkUtils;
+import net.osmand.plus.R;
+import net.osmand.plus.base.BaseOsmAndFragment;
+import net.osmand.plus.liveupdates.CountrySelectionFragment.CountryItem;
+
+import org.apache.commons.logging.Log;
+
import android.annotation.SuppressLint;
import android.content.Context;
+import android.content.Intent;
import android.content.res.Resources;
+import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.annotation.AttrRes;
@@ -10,6 +25,7 @@ import android.support.annotation.ColorInt;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
+import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
@@ -21,44 +37,48 @@ import android.widget.TextView;
import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
-import net.osmand.PlatformUtil;
-import net.osmand.osm.io.NetworkUtils;
-import net.osmand.plus.R;
-import net.osmand.plus.base.BaseOsmAndFragment;
-import net.osmand.plus.liveupdates.CountrySelectionFragment.CountryItem;
-
-import org.apache.commons.logging.Log;
-
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Locale;
-
public class ReportsFragment extends BaseOsmAndFragment implements CountrySelectionFragment.OnFragmentInteractionListener {
public static final String TITLE = "Report";
- public static final String TOTAL_CHANGES_BY_MONTH_URL_PATTERN = "http://download.osmand.net/" +
+ public static final String DOMAIN = "http://download.osmand.net/";
+ public static final String TOTAL_CHANGES_BY_MONTH_URL_PATTERN = DOMAIN +
"reports/query_report.php?report=total_changes_by_month&month=%s®ion=%s";
+ public static final String USERS_RANKING_BY_MONTH = DOMAIN +
+ "reports/query_report.php?report=ranking_users_by_month&month=%s®ion=%s";
+ public static final String RECIPIENTS_BY_MONTH = DOMAIN +
+ "reports/query_report.php?report=recipients_by_month&month=%s®ion=%s";
+
+
private static final Log LOG = PlatformUtil.getLog(ReportsFragment.class);
private TextView contributorsTextView;
private TextView editsTextView;
+ private TextView donationsTextView;
+ private TextView recipientsTextView;
private Spinner montReportsSpinner;
private MonthsForReportsAdapter monthsForReportsAdapter;
private CountrySelectionFragment countrySelectionFragment = new CountrySelectionFragment();
+ private UsersReportFragment userReportFragment = new UsersReportFragment();
private TextView countryNameTextView;
private CountryItem selectedCountryItem;
private ImageView numberOfContributorsIcon;
private ImageView numberOfEditsIcon;
+ private ImageView donationsIcon;
+ private ImageView numberOfRecipientsIcon;
private TextView numberOfContributorsTitle;
private TextView numberOfEditsTitle;
+ private TextView numberOfRecipientsTitle;
+ private TextView donationsTitle;
private ProgressBar progressBar;
private int inactiveColor;
private int textColorPrimary;
private int textColorSecondary;
+
+
+
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
@@ -67,6 +87,15 @@ public class ReportsFragment extends BaseOsmAndFragment implements CountrySelect
montReportsSpinner = (Spinner) view.findViewById(R.id.montReportsSpinner);
monthsForReportsAdapter = new MonthsForReportsAdapter(getActivity());
montReportsSpinner.setAdapter(monthsForReportsAdapter);
+
+ view.findViewById(R.id.show_all).setOnClickListener(new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://osmand.net/osm_live"));
+ startActivity(intent);
+ }
+ });
View regionReportsButton = view.findViewById(R.id.reportsButton);
regionReportsButton.setOnClickListener(new View.OnClickListener() {
@@ -75,25 +104,55 @@ public class ReportsFragment extends BaseOsmAndFragment implements CountrySelect
countrySelectionFragment.show(getChildFragmentManager(), "CountriesSearchSelectionFragment");
}
});
+ OnClickListener listener = new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ int monthItemPosition = montReportsSpinner.getSelectedItemPosition();
+ String monthUrlString = monthsForReportsAdapter.getQueryString(monthItemPosition);
+ String countryUrlString = selectedCountryItem.getDownloadName();
+ if (countryUrlString.length() > 0) {
+ Bundle bl = new Bundle();
+ bl.putString(UsersReportFragment.URL_REQUEST,
+ String.format(USERS_RANKING_BY_MONTH, monthUrlString, countryUrlString));
+ userReportFragment.setArguments(bl);
+ userReportFragment.show(getChildFragmentManager(), "NumberOfEditsFramgnet");
+ }
+ }
+ };
+ view.findViewById(R.id.numberOfContributorsLayout).setOnClickListener(listener);
+ view.findViewById(R.id.numberOfEditsLayout).setOnClickListener(listener);;
countrySelectionFragment.initCountries(getMyApplication());
selectedCountryItem = countrySelectionFragment.getCountryItems().get(0);
+
countryNameTextView = (TextView) regionReportsButton.findViewById(android.R.id.text1);
countryNameTextView.setText(selectedCountryItem.getLocalName());
setThemedDrawable(view, R.id.calendarImageView, R.drawable.ic_action_data);
setThemedDrawable(view, R.id.regionIconImageView, R.drawable.ic_world_globe_dark);
+
numberOfContributorsIcon = (ImageView) view.findViewById(R.id.numberOfContributorsIcon);
- setThemedDrawable(numberOfContributorsIcon, R.drawable.ic_group);
numberOfEditsIcon = (ImageView) view.findViewById(R.id.numberOfEditsIcon);
+ numberOfRecipientsIcon = (ImageView) view.findViewById(R.id.numberOfRecipientsIcon);
+ donationsIcon = (ImageView) view.findViewById(R.id.donationsIcon);
+ setThemedDrawable(numberOfContributorsIcon, R.drawable.ic_group);
+ setThemedDrawable(numberOfRecipientsIcon, R.drawable.ic_group);
+ setThemedDrawable(donationsIcon, R.drawable.ic_action_message);
setThemedDrawable(numberOfEditsIcon, R.drawable.ic_map);
+
+
numberOfContributorsTitle = (TextView) view.findViewById(R.id.numberOfContributorsTitle);
numberOfEditsTitle = (TextView) view.findViewById(R.id.numberOfEditsTitle);
+ donationsTitle = (TextView) view.findViewById(R.id.donationsTitle);
+ numberOfRecipientsTitle = (TextView) view.findViewById(R.id.numberOfRecipientsTitle);
+
progressBar = (ProgressBar) view.findViewById(R.id.progress);
contributorsTextView = (TextView) view.findViewById(R.id.contributorsTextView);
editsTextView = (TextView) view.findViewById(R.id.editsTextView);
+ donationsTextView = (TextView) view.findViewById(R.id.donationsTextView);
+ recipientsTextView = (TextView) view.findViewById(R.id.recipientsTextView);
requestAndUpdateUi();
@@ -161,6 +220,34 @@ public class ReportsFragment extends BaseOsmAndFragment implements CountrySelect
totalChangesByMontAsyncTask.setOnErrorListener(onErrorListener);
String finalUrl = String.format(TOTAL_CHANGES_BY_MONTH_URL_PATTERN, monthUrlString, regionUrlString);
totalChangesByMontAsyncTask.execute(finalUrl);
+
+ GetJsonAsyncTask recChangesByMontAsyncTask =
+ new GetJsonAsyncTask<>(Protocol.RecipientsByMonth.class);
+ GetJsonAsyncTask.OnResponseListener recResponseListener =
+ new GetJsonAsyncTask.OnResponseListener() {
+ @Override
+ public void onResponse(Protocol.RecipientsByMonth response) {
+ if (response != null) {
+ if (recipientsTextView != null) {
+ recipientsTextView.setText(String.valueOf(response.regionCount));
+ }
+ if (donationsTextView != null) {
+ donationsTextView.setText(String.format("%.3f", response.regionBtc*1000.0) + " mBTC");
+ }
+ }
+ disableProgress();
+ }
+ };
+ recChangesByMontAsyncTask.setOnResponseListener(recResponseListener);
+
+ if (recipientsTextView != null) {
+ recipientsTextView.setText("-");
+ }
+ if (donationsTextView != null) {
+ donationsTextView.setText("-");
+ }
+ String recfinalUrl = String.format(RECIPIENTS_BY_MONTH, monthUrlString, regionUrlString);
+ recChangesByMontAsyncTask.execute(recfinalUrl);
}
@Override
@@ -228,8 +315,10 @@ public class ReportsFragment extends BaseOsmAndFragment implements CountrySelect
@Override
protected void onPostExecute(P protocol) {
if (protocol != null) {
- onResponseListener.onResponse(protocol);
- } else {
+ if(onResponseListener != null) {
+ onResponseListener.onResponse(protocol);
+ }
+ } else if (onErrorListener != null) {
onErrorListener.onError(error);
}
}
@@ -254,21 +343,39 @@ public class ReportsFragment extends BaseOsmAndFragment implements CountrySelect
private void enableProgress() {
numberOfContributorsIcon.setImageDrawable(getPaintedContentIcon(R.drawable.ic_group, inactiveColor));
numberOfEditsIcon.setImageDrawable(getPaintedContentIcon(R.drawable.ic_map, inactiveColor));
+ numberOfRecipientsIcon.setImageDrawable(getPaintedContentIcon(R.drawable.ic_group, inactiveColor));
+ donationsIcon.setImageDrawable(getPaintedContentIcon(R.drawable.ic_action_message, inactiveColor));
+
numberOfContributorsTitle.setTextColor(inactiveColor);
numberOfEditsTitle.setTextColor(inactiveColor);
+ numberOfRecipientsTitle.setTextColor(inactiveColor);
+ donationsTitle.setTextColor(inactiveColor);
+
progressBar.setVisibility(View.VISIBLE);
+
contributorsTextView.setTextColor(inactiveColor);
+ donationsTextView.setTextColor(inactiveColor);
+ recipientsTextView.setTextColor(inactiveColor);
editsTextView.setTextColor(inactiveColor);
}
private void disableProgress() {
numberOfContributorsIcon.setImageDrawable(getContentIcon(R.drawable.ic_group));
numberOfEditsIcon.setImageDrawable(getContentIcon(R.drawable.ic_map));
+ numberOfRecipientsIcon.setImageDrawable(getContentIcon(R.drawable.ic_group));
+ donationsIcon.setImageDrawable(getContentIcon(R.drawable.ic_action_message));
+
numberOfContributorsTitle.setTextColor(textColorSecondary);
numberOfEditsTitle.setTextColor(textColorSecondary);
+ numberOfRecipientsTitle.setTextColor(textColorSecondary);
+ donationsTitle.setTextColor(textColorSecondary);
+
progressBar.setVisibility(View.INVISIBLE);
+
contributorsTextView.setTextColor(textColorPrimary);
editsTextView.setTextColor(textColorPrimary);
+ donationsTextView.setTextColor(textColorPrimary);
+ recipientsTextView.setTextColor(textColorPrimary);
}
@ColorInt
diff --git a/OsmAnd/src/net/osmand/plus/liveupdates/UsersReportFragment.java b/OsmAnd/src/net/osmand/plus/liveupdates/UsersReportFragment.java
new file mode 100644
index 0000000000..6b0c5549dd
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/liveupdates/UsersReportFragment.java
@@ -0,0 +1,110 @@
+package net.osmand.plus.liveupdates;
+
+import java.util.Arrays;
+
+import net.osmand.plus.R;
+import net.osmand.plus.base.BaseOsmAndDialogFragment;
+import net.osmand.plus.liveupdates.Protocol.RankingUserByMonthResponse;
+import net.osmand.plus.liveupdates.Protocol.UserRankingByMonth;
+import net.osmand.plus.liveupdates.ReportsFragment.GetJsonAsyncTask;
+import net.osmand.plus.liveupdates.ReportsFragment.GetJsonAsyncTask.OnResponseListener;
+import android.content.res.Resources;
+import android.graphics.drawable.Drawable;
+import android.os.Bundle;
+import android.support.annotation.ColorInt;
+import android.support.annotation.DrawableRes;
+import android.util.TypedValue;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
+import android.widget.ImageButton;
+import android.widget.ListView;
+import android.widget.TextView;
+
+public class UsersReportFragment extends BaseOsmAndDialogFragment {
+
+ public static final String URL_REQUEST = "URL_REQUEST";
+ public static final String REGION_NAME = "REGION_NAME";
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+ final View view = inflater.inflate(R.layout.fragment_simple_list, container, false);
+ ListView listView = (ListView) view.findViewById(android.R.id.list);
+ final ArrayAdapter adapter = new ListAdapter(getListItemIcon());
+ String url = getArguments().getString(URL_REQUEST);
+ //String reg = getArguments().getString(REGION_NAME);
+ view.findViewById(R.id.progress).setVisibility(View.VISIBLE);
+ ((TextView)view.findViewById(R.id.titleTextView)).setText(R.string.osm_editors_ranking);
+ GetJsonAsyncTask task = new GetJsonAsyncTask<>(RankingUserByMonthResponse.class);
+ task.setOnResponseListener(new OnResponseListener() {
+
+ @Override
+ public void onResponse(RankingUserByMonthResponse response) {
+ adapter.addAll(Arrays.asList(response.rows));
+ view.findViewById(R.id.progress).setVisibility(View.GONE);
+ }
+ });
+ task.execute(url);
+ listView.setAdapter(adapter);
+
+ ImageButton clearButton = (ImageButton) view.findViewById(R.id.closeButton);
+ //setThemedDrawable(clearButton, R.drawable.ic_action_remove_dark);
+ clearButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ dismiss();
+ }
+ });
+ return view;
+ }
+
+ @DrawableRes
+ protected int getListItemIcon() {
+ return R.drawable.ic_person;
+ }
+
+ @Override
+ public void onDetach() {
+ super.onDetach();
+ }
+
+ private class ListAdapter extends ArrayAdapter {
+ private final Drawable drawableLeft;
+ @ColorInt
+ private final int textColor;
+ private final int textSecondaryColor;
+
+ public ListAdapter(@DrawableRes int drawableLeftId) {
+ super(getMyActivity(), android.R.layout.simple_list_item_2);
+ this.drawableLeft = drawableLeftId == -1 ? null : getContentIcon(drawableLeftId);
+ TypedValue typedValue = new TypedValue();
+ Resources.Theme theme = getActivity().getTheme();
+ theme.resolveAttribute(android.R.attr.textColorPrimary, typedValue, true);
+ textColor = typedValue.data;
+ theme.resolveAttribute(android.R.attr.textColorSecondary, typedValue, true);
+ textSecondaryColor = typedValue.data;
+
+ }
+
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ UserRankingByMonth item = getItem(position);
+ View v = convertView;
+ if (v == null) {
+ LayoutInflater inflater = getActivity().getLayoutInflater();
+ v = inflater.inflate(android.R.layout.simple_list_item_2, parent, false);
+ }
+ TextView text1 = (TextView) v.findViewById(android.R.id.text1);
+ TextView text2 = (TextView) v.findViewById(android.R.id.text2);
+ text1.setText(item.user);
+ text2.setText(getString(R.string.osm_user_stat,
+ String.valueOf(item.changes), String.valueOf(item.rank), String.valueOf(item.globalchanges)));
+ text1.setTextColor(textColor);
+ text2.setTextColor(textSecondaryColor);
+ text1.setCompoundDrawablesWithIntrinsicBounds(drawableLeft, null, null, null);
+ text1.setCompoundDrawablePadding(getResources().getDimensionPixelSize(R.dimen.list_content_padding));
+ return v;
+ }
+ }
+}