diff --git a/OsmAnd/res/drawable-hdpi/ic_action_type_add_16.png b/OsmAnd/res/drawable-hdpi/ic_action_type_add_16.png new file mode 100644 index 0000000000..ff4d2d7400 Binary files /dev/null and b/OsmAnd/res/drawable-hdpi/ic_action_type_add_16.png differ diff --git a/OsmAnd/res/drawable-hdpi/ic_action_type_delete_16.png b/OsmAnd/res/drawable-hdpi/ic_action_type_delete_16.png new file mode 100644 index 0000000000..1df427fe41 Binary files /dev/null and b/OsmAnd/res/drawable-hdpi/ic_action_type_delete_16.png differ diff --git a/OsmAnd/res/drawable-hdpi/ic_action_type_edit_16.png b/OsmAnd/res/drawable-hdpi/ic_action_type_edit_16.png new file mode 100644 index 0000000000..8f02b07001 Binary files /dev/null and b/OsmAnd/res/drawable-hdpi/ic_action_type_edit_16.png differ diff --git a/OsmAnd/res/drawable-mdpi/ic_action_type_add_16.png b/OsmAnd/res/drawable-mdpi/ic_action_type_add_16.png new file mode 100644 index 0000000000..db1826da8b Binary files /dev/null and b/OsmAnd/res/drawable-mdpi/ic_action_type_add_16.png differ diff --git a/OsmAnd/res/drawable-mdpi/ic_action_type_delete_16.png b/OsmAnd/res/drawable-mdpi/ic_action_type_delete_16.png new file mode 100644 index 0000000000..4cd6c72dd2 Binary files /dev/null and b/OsmAnd/res/drawable-mdpi/ic_action_type_delete_16.png differ diff --git a/OsmAnd/res/drawable-mdpi/ic_action_type_edit_16.png b/OsmAnd/res/drawable-mdpi/ic_action_type_edit_16.png new file mode 100644 index 0000000000..a33538c185 Binary files /dev/null and b/OsmAnd/res/drawable-mdpi/ic_action_type_edit_16.png differ diff --git a/OsmAnd/res/drawable-xhdpi/ic_action_type_add_16.png b/OsmAnd/res/drawable-xhdpi/ic_action_type_add_16.png new file mode 100644 index 0000000000..9713bfff68 Binary files /dev/null and b/OsmAnd/res/drawable-xhdpi/ic_action_type_add_16.png differ diff --git a/OsmAnd/res/drawable-xhdpi/ic_action_type_delete_16.png b/OsmAnd/res/drawable-xhdpi/ic_action_type_delete_16.png new file mode 100644 index 0000000000..9cc3481cb0 Binary files /dev/null and b/OsmAnd/res/drawable-xhdpi/ic_action_type_delete_16.png differ diff --git a/OsmAnd/res/drawable-xhdpi/ic_action_type_edit_16.png b/OsmAnd/res/drawable-xhdpi/ic_action_type_edit_16.png new file mode 100644 index 0000000000..f568e5b24f Binary files /dev/null and b/OsmAnd/res/drawable-xhdpi/ic_action_type_edit_16.png differ diff --git a/OsmAnd/res/drawable-xxhdpi/ic_action_type_add_16.png b/OsmAnd/res/drawable-xxhdpi/ic_action_type_add_16.png new file mode 100644 index 0000000000..aacd481d4f Binary files /dev/null and b/OsmAnd/res/drawable-xxhdpi/ic_action_type_add_16.png differ diff --git a/OsmAnd/res/drawable-xxhdpi/ic_action_type_delete_16.png b/OsmAnd/res/drawable-xxhdpi/ic_action_type_delete_16.png new file mode 100644 index 0000000000..4995ad3158 Binary files /dev/null and b/OsmAnd/res/drawable-xxhdpi/ic_action_type_delete_16.png differ diff --git a/OsmAnd/res/drawable-xxhdpi/ic_action_type_edit_16.png b/OsmAnd/res/drawable-xxhdpi/ic_action_type_edit_16.png new file mode 100644 index 0000000000..f00b70c66e Binary files /dev/null and b/OsmAnd/res/drawable-xxhdpi/ic_action_type_edit_16.png differ diff --git a/OsmAnd/res/layout/fragment_reports.xml b/OsmAnd/res/layout/fragment_reports.xml index cc94f46c20..84e6564ccb 100644 --- a/OsmAnd/res/layout/fragment_reports.xml +++ b/OsmAnd/res/layout/fragment_reports.xml @@ -275,6 +275,64 @@ android:background="?attr/dashboard_divider"/> + + + + + + + + + + + + + + + + + + + + android:layout_height="wrap_content" + android:background="?attr/selectableItemBackground" + android:minHeight="@dimen/bottom_sheet_selected_item_title_height"> diff --git a/OsmAnd/res/layout/route_info_layout.xml b/OsmAnd/res/layout/route_info_layout.xml index 08685ae667..822b7c87fd 100644 --- a/OsmAnd/res/layout/route_info_layout.xml +++ b/OsmAnd/res/layout/route_info_layout.xml @@ -107,7 +107,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" - android:src="@drawable/ic_action_polygom_dark"/> + android:src="@drawable/ic_action_route_distance"/> + Файл GPX с координатами и данными выбранных заметок. + Файл GPX с координатами и данными всех заметок. Место Ваш пункт назначения находится на частной территории. Вы хотите разрешить доступ к частным дорогам для этой поездки? Искать снова @@ -432,7 +434,7 @@ Пользовательские Файл с избранными уже существует. Вы хотите его заменить? Настройка профиля - Профиль + Профиль по умолчанию Выберите профиль работы приложения (в каждом профиле настройки хранятся отдельно). Общие настройки Общие настройки приложения diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index ddd4d52ea3..61bfe7f88c 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -9,6 +9,8 @@ 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 --> + GPX file with coordinates and data of the selected notes. + GPX file with coordinates and data of all notes. \u2022 Detection of stop signs now considers driving direction\n\n \u2022 New algorithm providing meaningful ascent/descent values for GPX tracks\n\n @@ -554,6 +556,7 @@ Donations Number of recipients Edits %1$s, rank %2$s, total edits %3$s + Edits %1$s, sum %2$s mBTC OSM Editors ranking OsmAnd Live subscription Subscribe @@ -2819,4 +2822,6 @@ File %1$s does not contain waypoints, import it as a track? Move Point Add to a GPX track + OSM Recipients + Total Donations diff --git a/OsmAnd/res/xml/paths.xml b/OsmAnd/res/xml/paths.xml index 78a4755a05..90217e4c1f 100644 --- a/OsmAnd/res/xml/paths.xml +++ b/OsmAnd/res/xml/paths.xml @@ -3,6 +3,9 @@ + path="share"/> + \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/activities/ShowRouteInfoDialogFragment.java b/OsmAnd/src/net/osmand/plus/activities/ShowRouteInfoDialogFragment.java index 42cf8163ea..599d867829 100644 --- a/OsmAnd/src/net/osmand/plus/activities/ShowRouteInfoDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/ShowRouteInfoDialogFragment.java @@ -118,7 +118,7 @@ public class ShowRouteInfoDialogFragment extends DialogFragment { }); ((ImageView) view.findViewById(R.id.distance_icon)) - .setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_action_polygom_dark)); + .setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_action_route_distance)); ((ImageView) view.findViewById(R.id.time_icon)) .setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_action_time_span)); diff --git a/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java b/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java index 379fb7339f..f811b6abc6 100644 --- a/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java +++ b/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java @@ -481,6 +481,15 @@ public class AudioVideoNotesPlugin extends OsmandPlugin { return date + " • " + sz + " • " + getDuration(ctx, false); } + public String getTypeWithDuration(Context ctx) { + StringBuilder res = new StringBuilder(getType(ctx)); + if (isAudio() || isVideo()) { + updateInternalDescription(); + res.append(", ").append(getDuration(ctx, false)); + } + return res.toString(); + } + public String getPlainDuration(boolean accessibilityEnabled) { updateInternalDescription(); if (duration > 0) { diff --git a/OsmAnd/src/net/osmand/plus/audionotes/NotesFragment.java b/OsmAnd/src/net/osmand/plus/audionotes/NotesFragment.java index c43e4fb721..b7091cba4f 100644 --- a/OsmAnd/src/net/osmand/plus/audionotes/NotesFragment.java +++ b/OsmAnd/src/net/osmand/plus/audionotes/NotesFragment.java @@ -10,6 +10,7 @@ import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; +import android.support.v4.content.FileProvider; import android.support.v7.app.AlertDialog; import android.support.v7.view.ActionMode; import android.view.LayoutInflater; @@ -453,16 +454,17 @@ public class NotesFragment extends OsmAndListFragment { } private void shareItems(Set selected) { - ArrayList files = new ArrayList<>(); + ArrayList uris = new ArrayList<>(); for (Recording rec : selected) { File file = rec == SHARE_LOCATION_FILE ? generateGPXForRecordings(selected) : rec.getFile(); if (file != null) { - files.add(Uri.parse(file.getAbsolutePath())); + uris.add(FileProvider.getUriForFile(getContext(), getActivity().getPackageName() + ".fileprovider", file)); } } + Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE); intent.setType("*/*"); - intent.putExtra(Intent.EXTRA_STREAM, files); + intent.putExtra(Intent.EXTRA_STREAM, uris); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); if (Build.VERSION.SDK_INT > 18) { intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true); @@ -470,16 +472,18 @@ public class NotesFragment extends OsmAndListFragment { startActivity(Intent.createChooser(intent, getString(R.string.share_note))); } - @Nullable - private File generateGPXForRecordings(Set selected) { - File externalCacheDir = getActivity().getExternalCacheDir(); - if (externalCacheDir == null) { - return null; + private Set getRecordingsForGpx(Set selected) { + if (selected.size() == 1 && selected.contains(SHARE_LOCATION_FILE)) { + return new HashSet<>(plugin.getAllRecordings()); } - File tmpFile = new File(externalCacheDir, "share/noteLocations.gpx"); + return selected; + } + + private File generateGPXForRecordings(Set selected) { + File tmpFile = new File(getActivity().getCacheDir(), "share/noteLocations.gpx"); tmpFile.getParentFile().mkdirs(); GPXFile file = new GPXFile(); - for (Recording r : selected) { + for (Recording r : getRecordingsForGpx(selected)) { if (r != SHARE_LOCATION_FILE) { String desc = r.getDescriptionName(r.getFileName()); if (desc == null) { @@ -492,6 +496,7 @@ public class NotesFragment extends OsmAndListFragment { wpt.link = r.getFileName(); wpt.time = r.getFile().lastModified(); wpt.category = r.getSearchHistoryType(); + wpt.desc = r.getTypeWithDuration(getContext()); getMyApplication().getSelectedGpxHelper().addPoint(wpt, file); } } diff --git a/OsmAnd/src/net/osmand/plus/audionotes/adapters/NotesAdapter.java b/OsmAnd/src/net/osmand/plus/audionotes/adapters/NotesAdapter.java index fa7f286156..1fe1548665 100644 --- a/OsmAnd/src/net/osmand/plus/audionotes/adapters/NotesAdapter.java +++ b/OsmAnd/src/net/osmand/plus/audionotes/adapters/NotesAdapter.java @@ -205,7 +205,7 @@ public class NotesAdapter extends ArrayAdapter { setupBackground(holder.view); if (recording == NotesFragment.SHARE_LOCATION_FILE) { holder.title.setText(R.string.av_locations); - holder.description.setText(R.string.av_locations_descr); + holder.description.setText(getLocationsDescId()); } else { holder.title.setText(recording.getName(app, true)); holder.description.setText(recording.getExtendedDescription(app)); @@ -255,6 +255,13 @@ public class NotesAdapter extends ArrayAdapter { }); } + private int getLocationsDescId() { + if (selected.contains(NotesFragment.SHARE_LOCATION_FILE)) { + return selected.size() == 1 ? R.string.av_locations_all_desc : R.string.av_locations_selected_desc; + } + return R.string.av_locations_descr; + } + private void setupBackground(View view) { if (!portrait) { view.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.color_transparent)); diff --git a/OsmAnd/src/net/osmand/plus/liveupdates/Protocol.java b/OsmAnd/src/net/osmand/plus/liveupdates/Protocol.java index f7e41e3f62..5be7ad064d 100644 --- a/OsmAnd/src/net/osmand/plus/liveupdates/Protocol.java +++ b/OsmAnd/src/net/osmand/plus/liveupdates/Protocol.java @@ -23,6 +23,9 @@ public final class Protocol { public int regionCount; public float regionPercentage; public float btc; + public float eur; + public float eurRate; + public Recipient[] rows; } public static class UserRankingByMonth { @@ -48,5 +51,13 @@ public final class Protocol { public int users; public int changes; } - + + public static class Recipient { + String osmid; + int changes; + String btcaddress; + int rank; + int weight; + float btc; + } } diff --git a/OsmAnd/src/net/osmand/plus/liveupdates/ReportsFragment.java b/OsmAnd/src/net/osmand/plus/liveupdates/ReportsFragment.java index 049fccb5c0..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; @@ -52,6 +53,8 @@ public class ReportsFragment extends BaseOsmAndFragment implements CountrySelect private static final Log LOG = PlatformUtil.getLog(ReportsFragment.class); public static final String OSM_LIVE_URL = "https://osmand.net/osm_live"; + public static final String EDITS_FRAGMENT = "NumberOfEditsFragment"; + public static final String RECIPIENTS_FRAGMENT = "RecipientsFragment"; private TextView contributorsTextView; private TextView editsTextView; @@ -70,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; @@ -129,15 +136,17 @@ public class ReportsFragment extends BaseOsmAndFragment implements CountrySelect String countryUrlString = selectedCountryItem.getDownloadName(); if (countryUrlString.length() > 0) { Bundle bl = new Bundle(); + boolean isRecipientsReport = v.getId() == R.id.numberOfRecipientsLayout; bl.putString(UsersReportFragment.URL_REQUEST, - String.format(USERS_RANKING_BY_MONTH, monthUrlString, countryUrlString)); + String.format(isRecipientsReport ? RECIPIENTS_BY_MONTH : USERS_RANKING_BY_MONTH, monthUrlString, countryUrlString)); userReportFragment.setArguments(bl); - userReportFragment.show(getChildFragmentManager(), "NumberOfEditsFramgnet"); + userReportFragment.show(getChildFragmentManager(), isRecipientsReport ? RECIPIENTS_FRAGMENT : EDITS_FRAGMENT); } } }; view.findViewById(R.id.numberOfContributorsLayout).setOnClickListener(listener); view.findViewById(R.id.numberOfEditsLayout).setOnClickListener(listener); + view.findViewById(R.id.numberOfRecipientsLayout).setOnClickListener(listener); countrySelectionFragment.initCountries(getMyApplication()); selectedCountryItem = countrySelectionFragment.getCountryItems().get(0); @@ -155,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); @@ -165,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); @@ -203,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 @@ -251,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; @@ -364,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); } @@ -383,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); } diff --git a/OsmAnd/src/net/osmand/plus/liveupdates/UsersReportFragment.java b/OsmAnd/src/net/osmand/plus/liveupdates/UsersReportFragment.java index b9c19676f1..9d03c3ccf8 100644 --- a/OsmAnd/src/net/osmand/plus/liveupdates/UsersReportFragment.java +++ b/OsmAnd/src/net/osmand/plus/liveupdates/UsersReportFragment.java @@ -1,7 +1,5 @@ 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; @@ -32,27 +30,48 @@ public class UsersReportFragment extends BaseOsmAndDialogFragment { 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()); + 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() { + if (getTag().equals(ReportsFragment.EDITS_FRAGMENT)) { + ((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) { - if (response != null && response.rows != null) { - for (UserRankingByMonth rankingByMonth : response.rows) { - adapter.add(rankingByMonth); + @Override + public void onResponse(RankingUserByMonthResponse response) { + if (response != null && response.rows != null) { + for (UserRankingByMonth rankingByMonth : response.rows) { + if (rankingByMonth != null) { + adapter.add(rankingByMonth); + } + } } + view.findViewById(R.id.progress).setVisibility(View.GONE); } - view.findViewById(R.id.progress).setVisibility(View.GONE); - } - }); - task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, url); + }); + task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, url); + } else if (getTag().equals(ReportsFragment.RECIPIENTS_FRAGMENT)) { + ((TextView)view.findViewById(R.id.titleTextView)).setText(R.string.osm_recipients_label); + GetJsonAsyncTask task = new GetJsonAsyncTask<>(Protocol.RecipientsByMonth.class); + task.setOnResponseListener(new OnResponseListener() { + + @Override + public void onResponse(Protocol.RecipientsByMonth response) { + if (response != null && response.rows != null) { + for (Protocol.Recipient recipient : response.rows) { + if (recipient != null) { + adapter.add(recipient); + } + } + } + view.findViewById(R.id.progress).setVisibility(View.GONE); + } + }); + task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, 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() { @@ -74,7 +93,7 @@ public class UsersReportFragment extends BaseOsmAndDialogFragment { super.onDetach(); } - private class ListAdapter extends ArrayAdapter { + private class ListAdapter extends ArrayAdapter { private final Drawable drawableLeft; @ColorInt private final int textColor; @@ -93,22 +112,28 @@ public class UsersReportFragment extends BaseOsmAndDialogFragment { } @Override - public View getView(int position, View convertView, ViewGroup parent) { - UserRankingByMonth item = getItem(position); - View v = convertView; + public View getView(int position, View v, ViewGroup parent) { if (v == null) { - LayoutInflater inflater = getActivity().getLayoutInflater(); - v = inflater.inflate(android.R.layout.simple_list_item_2, parent, false); + v = getActivity().getLayoutInflater().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)); + Object item = getItem(position); + if (item instanceof UserRankingByMonth) { + UserRankingByMonth rankingByMonth = (UserRankingByMonth) item; + text1.setText(rankingByMonth.user); + text2.setText(getString(R.string.osm_user_stat, + String.valueOf(rankingByMonth.changes), String.valueOf(rankingByMonth.rank), String.valueOf(rankingByMonth.globalchanges))); + } else if (item instanceof Protocol.Recipient){ + Protocol.Recipient recipient = (Protocol.Recipient) item; + text1.setText(recipient.osmid); + text2.setText(getString(R.string.osm_recipient_stat, + String.valueOf(recipient.changes), String.format("%.4f", (recipient.btc*1000f)))); + } return v; } } diff --git a/OsmAnd/src/net/osmand/plus/osmedit/AdvancedEditPoiFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/AdvancedEditPoiFragment.java index 990da169d1..19c62eeecd 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/AdvancedEditPoiFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/AdvancedEditPoiFragment.java @@ -201,9 +201,11 @@ public class AdvancedEditPoiFragment extends BaseOsmAndFragment if (!hasFocus) { if (!editPoiData.isInEdit()) { String s = tagEditText.getText().toString(); - editPoiData.removeTag(previousTag[0]); - editPoiData.putTag(s.toString(), valueEditText.getText().toString()); - previousTag[0] = s.toString(); + if (!previousTag[0].equals(s)) { + editPoiData.removeTag(previousTag[0]); + editPoiData.putTag(s, valueEditText.getText().toString()); + previousTag[0] = s; + } } } else { tagAdapter.getFilter().filter(tagEditText.getText()); diff --git a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiData.java b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiData.java index 146ec426f2..df1b6971b1 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiData.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiData.java @@ -37,7 +37,7 @@ public class EditPoiData { category = app.getPoiTypes().getOtherPoiCategory(); entity = node; initTags(node); - updateTypeTag(getPoiTypeString()); + updateTypeTag(getPoiTypeString(), false); } public Map getAllTranslatedSubTypes() { @@ -109,15 +109,18 @@ public class EditPoiData { public Map getTagValues() { return Collections.unmodifiableMap(tagValues); } - + public void putTag(String tag, String value) { checkNotInEdit(); - try { + try { isInEdit = true; tagValues.remove(REMOVE_TAG_PREFIX+tag); + String oldValue = tagValues.get(tag); + if (oldValue == null || !oldValue.equals(value)) { + changedTags.add(tag); + } tagValues.put(tag, value); - changedTags.add(tag); notifyDatasetChanged(tag); } finally { isInEdit = false; @@ -193,9 +196,11 @@ public class EditPoiData { return hasChangesBeenMade; } - public void updateTypeTag(String string) { + public void updateTypeTag(String string, boolean userChanges) { tagValues.put(POI_TYPE_TAG, string); - changedTags.add(POI_TYPE_TAG); + if (userChanges) { + changedTags.add(POI_TYPE_TAG); + } retrieveType(); PoiType pt = getPoiTypeDefined(); if(pt != null) { diff --git a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java index 01c5e57447..663faba576 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java @@ -258,6 +258,7 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment { poiNameEditText.setText(editPoiData.getTag(OSMSettings.OSMTagKey.NAME.getValue())); poiTypeTextInputLayout = (TextInputLayout) view.findViewById(R.id.poiTypeTextInputLayout); poiTypeEditText = (AutoCompleteTextView) view.findViewById(R.id.poiTypeEditText); + poiTypeEditText.setText(editPoiData.getPoiTypeString()); poiTypeEditText.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { @@ -270,7 +271,7 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment { @Override public void afterTextChanged(Editable s) { if (!getEditPoiData().isInEdit()) { - getEditPoiData().updateTypeTag(s.toString()); + getEditPoiData().updateTypeTag(s.toString(), true); if (!getMyApplication().isApplicationInitializing()) { poiTypeTextInputLayout.setHint(editPoiData.getPoiCategory().getTranslation()); } @@ -279,7 +280,6 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment { }); poiNameEditText.setOnEditorActionListener(mOnEditorActionListener); poiTypeEditText.setOnEditorActionListener(mOnEditorActionListener); - poiTypeEditText.setText(editPoiData.getPoiTypeString()); poiTypeEditText.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(final View v, MotionEvent event) { diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapRemoteUtil.java b/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapRemoteUtil.java index a03185e54f..fa8a086283 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapRemoteUtil.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapRemoteUtil.java @@ -37,6 +37,7 @@ import java.io.StringWriter; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.text.MessageFormat; +import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map; import java.util.Set; @@ -330,11 +331,20 @@ public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil { EntityId id = new Entity.EntityId(EntityType.NODE, nodeId); Node entity = (Node) st.getRegisteredEntities().get(id); // merge non existing tags - for (String rtag : entity.getTagKeySet()) { - if (!deletedTag(n, rtag) && (!containsTag(n, rtag) || !tagChanged(n, rtag))) { - n.putTagNoLC(rtag, entity.getTag(rtag)); + Map updatedTags = new HashMap<>(); + for (String tagKey : entity.getTagKeySet()) { + if (tagKey != null && !deletedTag(n, tagKey)) { + addIfNotNull(tagKey, entity.getTag(tagKey), updatedTags); } } + if (n.getChangedTags() != null) { + for (String tagKey : n.getChangedTags()) { + if (tagKey != null) { + addIfNotNull(tagKey, n.getTag(tagKey), updatedTags); + } + } + } + n.replaceTags(updatedTags); if(MapUtils.getDistance(n.getLatLon(), entity.getLatLon()) < 10) { // avoid shifting due to round error n.setLatitude(entity.getLatitude()); @@ -353,18 +363,16 @@ public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil { return null; } + private void addIfNotNull(String key, String value, Map tags) { + if (value != null) { + tags.put(key, value); + } + } + private boolean deletedTag(Node node, String tag) { return node.getTagKeySet().contains(EditPoiData.REMOVE_TAG_PREFIX + tag); } - private boolean containsTag(Node node, String tag) { - return node.getTagKeySet().contains(tag); - } - - private boolean tagChanged(Node node, String tag) { - return node.getChangedTags() != null && node.getChangedTags().contains(tag); - } - @Override public Node loadNode(Amenity n) { if (n.getId() % 2 == 1) {