Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2017-12-22 10:03:51 +01:00
commit 9cc58ff77c
29 changed files with 249 additions and 79 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View file

@ -275,6 +275,64 @@
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"
android:clickable="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
@ -289,7 +347,6 @@
android:src="@drawable/ic_group"/>
<LinearLayout
android:id="@+id/numberOfRecipientsLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="16dp"

View file

@ -9,8 +9,9 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_selected_item_title_height"
android:background="?attr/selectableItemBackground">
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:minHeight="@dimen/bottom_sheet_selected_item_title_height">
<CheckBox
android:id="@+id/check_box"
@ -34,11 +35,12 @@
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginEnd="@dimen/content_padding"
android:layout_marginRight="@dimen/content_padding"
android:layout_weight="1"
android:minHeight="@dimen/bottom_sheet_selected_item_title_height"
android:orientation="vertical">
<TextView
@ -56,9 +58,9 @@
android:id="@+id/description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:layout_marginTop="@dimen/map_widget_icon_margin"
android:ellipsize="end"
android:maxLines="3"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_desc_text_size"
tools:text="Oct 13, 2017 * 3 MB * 01:14"/>

View file

@ -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"/>
<LinearLayout
android:layout_width="wrap_content"

View file

@ -1,5 +1,7 @@
<?xml version='1.0' encoding='UTF-8'?>
<resources>
<string name="av_locations_selected_desc">Файл GPX с координатами и данными выбранных заметок.</string>
<string name="av_locations_all_desc">Файл GPX с координатами и данными всех заметок.</string>
<string name="favorite_empty_place_name">Место</string>
<string name="private_access_routing_req">Ваш пункт назначения находится на частной территории. Вы хотите разрешить доступ к частным дорогам для этой поездки?</string>
<string name="restart_search">Искать снова</string>
@ -432,7 +434,7 @@
<string name="amenity_type_user_defined">Пользовательские</string>
<string name="fav_export_confirmation">Файл с избранными уже существует. Вы хотите его заменить?</string>
<string name="profile_settings">Настройка профиля</string>
<string name="settings_preset">Профиль</string>
<string name="settings_preset">Профиль по умолчанию</string>
<string name="settings_preset_descr">Выберите профиль работы приложения (в каждом профиле настройки хранятся отдельно).</string>
<string name="global_settings">Общие настройки</string>
<string name="global_app_settings">Общие настройки приложения</string>

View file

@ -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
-->
<string name="av_locations_selected_desc">GPX file with coordinates and data of the selected notes.</string>
<string name="av_locations_all_desc">GPX file with coordinates and data of all notes.</string>
<string name="release_3_0">
\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 @@
<string name="donations">Donations</string>
<string name="number_of_recipients">Number of recipients</string>
<string name="osm_user_stat">Edits %1$s, rank %2$s, total edits %3$s</string>
<string name="osm_recipient_stat">Edits %1$s, sum %2$s mBTC</string>
<string name="osm_editors_ranking">OSM Editors ranking</string>
<string name="osm_live_subscription">OsmAnd Live subscription</string>
<string name="osm_live_subscribe_btn">Subscribe</string>
@ -2819,4 +2822,6 @@
<string name="import_track_desc">File %1$s does not contain waypoints, import it as a track?</string>
<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

@ -3,6 +3,9 @@
<cache-path
name="share"
path="share" />
path="share"/>
<external-files-path
name="files"
path="/"/>
</paths>

View file

@ -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));

View file

@ -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) {

View file

@ -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<Recording> selected) {
ArrayList<Uri> files = new ArrayList<>();
ArrayList<Uri> 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<Recording> selected) {
File externalCacheDir = getActivity().getExternalCacheDir();
if (externalCacheDir == null) {
return null;
private Set<Recording> getRecordingsForGpx(Set<Recording> 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<Recording> 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);
}
}

View file

@ -205,7 +205,7 @@ public class NotesAdapter extends ArrayAdapter<Object> {
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<Object> {
});
}
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));

View file

@ -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 {
@ -49,4 +52,12 @@ public final class Protocol {
public int changes;
}
public static class Recipient {
String osmid;
int changes;
String btcaddress;
int rank;
int weight;
float btc;
}
}

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;
@ -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<Protocol.TotalChangesByMonthResponse> onResponseListener =
new GetJsonAsyncTask.OnResponseListener<Protocol.TotalChangesByMonthResponse>() {
@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);
}

View file

@ -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,11 +30,12 @@ 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<UserRankingByMonth> adapter = new ListAdapter(getListItemIcon());
final ArrayAdapter<Object> 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);
if (getTag().equals(ReportsFragment.EDITS_FRAGMENT)) {
((TextView) view.findViewById(R.id.titleTextView)).setText(R.string.osm_editors_ranking);
GetJsonAsyncTask<RankingUserByMonthResponse> task = new GetJsonAsyncTask<>(RankingUserByMonthResponse.class);
task.setOnResponseListener(new OnResponseListener<Protocol.RankingUserByMonthResponse>() {
@ -44,15 +43,35 @@ public class UsersReportFragment extends BaseOsmAndDialogFragment {
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);
}
});
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, url);
listView.setAdapter(adapter);
} else if (getTag().equals(ReportsFragment.RECIPIENTS_FRAGMENT)) {
((TextView)view.findViewById(R.id.titleTextView)).setText(R.string.osm_recipients_label);
GetJsonAsyncTask<Protocol.RecipientsByMonth> task = new GetJsonAsyncTask<>(Protocol.RecipientsByMonth.class);
task.setOnResponseListener(new OnResponseListener<Protocol.RecipientsByMonth>() {
@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<UserRankingByMonth> {
private class ListAdapter extends ArrayAdapter<Object> {
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;
}
}

View file

@ -201,9 +201,11 @@ public class AdvancedEditPoiFragment extends BaseOsmAndFragment
if (!hasFocus) {
if (!editPoiData.isInEdit()) {
String s = tagEditText.getText().toString();
if (!previousTag[0].equals(s)) {
editPoiData.removeTag(previousTag[0]);
editPoiData.putTag(s.toString(), valueEditText.getText().toString());
previousTag[0] = s.toString();
editPoiData.putTag(s, valueEditText.getText().toString());
previousTag[0] = s;
}
}
} else {
tagAdapter.getFilter().filter(tagEditText.getText());

View file

@ -37,7 +37,7 @@ public class EditPoiData {
category = app.getPoiTypes().getOtherPoiCategory();
entity = node;
initTags(node);
updateTypeTag(getPoiTypeString());
updateTypeTag(getPoiTypeString(), false);
}
public Map<String, PoiType> getAllTranslatedSubTypes() {
@ -116,8 +116,11 @@ public class EditPoiData {
try {
isInEdit = true;
tagValues.remove(REMOVE_TAG_PREFIX+tag);
tagValues.put(tag, value);
String oldValue = tagValues.get(tag);
if (oldValue == null || !oldValue.equals(value)) {
changedTags.add(tag);
}
tagValues.put(tag, value);
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);
if (userChanges) {
changedTags.add(POI_TYPE_TAG);
}
retrieveType();
PoiType pt = getPoiTypeDefined();
if(pt != null) {

View file

@ -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) {

View file

@ -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<String, String> 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<String, String> 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) {