Merge pull request #10339 from osmandapp/master

update test branch
This commit is contained in:
Hardy 2020-12-04 19:12:15 +01:00 committed by GitHub
commit 44b9d0ce7a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 145 additions and 412 deletions

View file

@ -477,7 +477,8 @@
<color name="switch_button_active_stroke_dark">#80D28521</color> <color name="switch_button_active_stroke_dark">#80D28521</color>
<color name="empty_hint_bg">#80000000</color> <color name="empty_hint_bg">#80000000</color>
<color name="input_layout_bg_color">#4DCCCCCC</color> <color name="input_layout_bg_color">#4DCCCCCC</color>
<color name="text_input_background_light">#14000000</color> <color name="text_input_background_light">#4DCCCCCC</color>
<color name="text_input_background_dark">#0DFFFFFF</color> <color name="text_input_background_dark">#1AFFFFFF</color>
<color name="mtrl_textinput_default_box_stroke_color">#67727272</color>
</resources> </resources>

View file

@ -94,7 +94,7 @@ public class LoginBottomSheetFragment extends MenuBottomSheetDialogFragment impl
if (!(getActivity() instanceof MapActivity) && fragment instanceof OsmAuthorizationListener) { if (!(getActivity() instanceof MapActivity) && fragment instanceof OsmAuthorizationListener) {
osmOAuthHelper.addListener((OsmAuthorizationListener) fragment); osmOAuthHelper.addListener((OsmAuthorizationListener) fragment);
} }
osmOAuthHelper.startOAuth((ViewGroup) view); osmOAuthHelper.startOAuth((ViewGroup) view, nightMode);
} }
} }

View file

@ -1,7 +1,6 @@
package net.osmand.plus.osmedit; package net.osmand.plus.osmedit;
import android.app.ProgressDialog; import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Bundle; import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
@ -12,8 +11,6 @@ import android.widget.ImageButton;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import androidx.appcompat.app.AlertDialog;
import net.osmand.data.PointDescription; import net.osmand.data.PointDescription;
import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R; import net.osmand.plus.R;
@ -22,19 +19,23 @@ import net.osmand.plus.dashboard.DashBaseFragment;
import net.osmand.plus.dashboard.DashboardOnMap; import net.osmand.plus.dashboard.DashboardOnMap;
import net.osmand.plus.dashboard.tools.DashFragmentData; import net.osmand.plus.dashboard.tools.DashFragmentData;
import net.osmand.plus.dialogs.ProgressDialogFragment; import net.osmand.plus.dialogs.ProgressDialogFragment;
import net.osmand.plus.osmedit.dialogs.SendPoiDialogFragment; import net.osmand.plus.measurementtool.LoginBottomSheetFragment;
import net.osmand.plus.osmedit.dialogs.SendPoiDialogFragment.PoiUploaderType; import net.osmand.plus.osmedit.dialogs.ProgressDialogPoiUploader;
import net.osmand.plus.osmedit.dialogs.SendOsmNoteBottomSheetFragment;
import net.osmand.plus.osmedit.dialogs.SendPoiBottomSheetFragment;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import static net.osmand.plus.osmedit.oauth.OsmOAuthHelper.*;
/** /**
* Created by Denis * Created by Denis
* on 20.01.2015. * on 20.01.2015.
*/ */
public class DashOsmEditsFragment extends DashBaseFragment public class DashOsmEditsFragment extends DashBaseFragment
implements SendPoiDialogFragment.ProgressDialogPoiUploader { implements ProgressDialogPoiUploader, OsmAuthorizationListener {
public static final String TAG = "DASH_OSM_EDITS_FRAGMENT"; public static final String TAG = "DASH_OSM_EDITS_FRAGMENT";
public static final int TITLE_ID = R.string.osm_settings; public static final int TITLE_ID = R.string.osm_settings;
@ -51,6 +52,7 @@ public class DashOsmEditsFragment extends DashBaseFragment
new DashFragmentData(TAG, DashOsmEditsFragment.class, SHOULD_SHOW_FUNCTION, 130, ROW_NUMBER_TAG); new DashFragmentData(TAG, DashOsmEditsFragment.class, SHOULD_SHOW_FUNCTION, 130, ROW_NUMBER_TAG);
OsmEditingPlugin plugin; OsmEditingPlugin plugin;
private OsmPoint selectedPoint;
@Override @Override
public View initView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View initView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
@ -72,7 +74,6 @@ public class DashOsmEditsFragment extends DashBaseFragment
return view; return view;
} }
@Override @Override
public void onOpenDash() { public void onOpenDash() {
if (plugin == null) { if (plugin == null) {
@ -114,10 +115,15 @@ public class DashOsmEditsFragment extends DashBaseFragment
@Override @Override
public void onClick(View v) { public void onClick(View v) {
if (point.getGroup() == OsmPoint.Group.POI) { if (point.getGroup() == OsmPoint.Group.POI) {
SendPoiDialogFragment.createInstance(new OsmPoint[] {point}, PoiUploaderType.FRAGMENT) selectedPoint = point;
.show(getChildFragmentManager(), "SendPoiDialogFragment"); if (getMyApplication().getOsmOAuthHelper().isLogged()) {
SendPoiBottomSheetFragment.showInstance(getChildFragmentManager(), new OsmPoint[]{point});
} else {
LoginBottomSheetFragment.showInstance(getActivity().getSupportFragmentManager(),
DashOsmEditsFragment.this);
}
} else { } else {
uploadItem(point); SendOsmNoteBottomSheetFragment.showInstance(getChildFragmentManager(), new OsmPoint[]{point});
} }
} }
}); });
@ -141,18 +147,9 @@ public class DashOsmEditsFragment extends DashBaseFragment
} }
} }
// TODO: 9/7/15 Redesign osm notes. @Override
private void uploadItem(final OsmPoint point) { public void authorizationCompleted() {
AlertDialog.Builder b = new AlertDialog.Builder(getActivity()); SendPoiBottomSheetFragment.showInstance(getChildFragmentManager(), new OsmPoint[]{selectedPoint});
b.setMessage(getString(R.string.local_osm_changes_upload_all_confirm, 1));
b.setPositiveButton(R.string.shared_string_yes, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
showProgressDialog(new OsmPoint[] {point}, false, false);
}
});
b.setNegativeButton(R.string.shared_string_cancel, null);
b.show();
} }
@Override @Override
@ -215,5 +212,4 @@ public class DashOsmEditsFragment extends DashBaseFragment
} }
} }
} }
} }

View file

@ -35,11 +35,11 @@ public class HandleOsmNoteAsyncTask extends AsyncTask<Void, Void, OsmBugResult>
@Override @Override
protected OsmBugResult doInBackground(Void... params) { protected OsmBugResult doInBackground(Void... params) {
if (bug != null) { if (bug != null) {
OsmNotesPoint pnt = new OsmNotesPoint(); OsmNotesPoint point = new OsmNotesPoint();
pnt.setId(bug.getId()); point.setId(bug.getId());
pnt.setLatitude(bug.getLatitude()); point.setLatitude(bug.getLatitude());
pnt.setLongitude(bug.getLongitude()); point.setLongitude(bug.getLongitude());
return osmbugsUtil.commit(pnt, text, action); return osmbugsUtil.commit(point, text, action);
} else if (point != null) { } else if (point != null) {
osmbugsUtil = local; osmbugsUtil = local;
return osmbugsUtil.modify(point, text); return osmbugsUtil.modify(point, text);

View file

@ -1,19 +1,14 @@
package net.osmand.plus.osmedit; package net.osmand.plus.osmedit;
import android.annotation.SuppressLint;
import android.content.DialogInterface;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.PointF; import android.graphics.PointF;
import android.util.Xml; import android.util.Xml;
import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.widget.EditText; import android.widget.EditText;
import android.widget.Toast; import android.widget.Toast;
import androidx.appcompat.app.AlertDialog;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
import net.osmand.AndroidUtils;
import net.osmand.PlatformUtil; import net.osmand.PlatformUtil;
import net.osmand.data.FavouritePoint.BackgroundType; import net.osmand.data.FavouritePoint.BackgroundType;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
@ -25,6 +20,7 @@ import net.osmand.osm.io.NetworkUtils;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.base.PointImageDrawable; import net.osmand.plus.base.PointImageDrawable;
import net.osmand.plus.osmedit.dialogs.BugBottomSheetDialog; import net.osmand.plus.osmedit.dialogs.BugBottomSheetDialog;
import net.osmand.plus.osmedit.dialogs.SendOsmNoteBottomSheetFragment;
import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
@ -32,7 +28,6 @@ import net.osmand.plus.osmedit.OsmPoint.Action;
import net.osmand.plus.views.layers.ContextMenuLayer.IContextMenuProvider; import net.osmand.plus.views.layers.ContextMenuLayer.IContextMenuProvider;
import net.osmand.plus.views.OsmandMapLayer; import net.osmand.plus.views.OsmandMapLayer;
import net.osmand.plus.views.OsmandMapTileView; import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.util.Algorithms;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParser;
@ -362,43 +357,18 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider
} }
private void createBugDialog(final boolean offline, String text, int titleTextId, int posButtonTextId, private void createBugDialog(final boolean offline, String text, int titleTextId, int posButtonTextId,
final Action action, final OpenStreetNote bug, final OsmNotesPoint point) { final Action action, final OpenStreetNote bug, OsmNotesPoint point) {
@SuppressLint("InflateParams") final View view = LayoutInflater.from(activity).inflate(R.layout.open_bug, null);
if (offline) { if (offline) {
activity.getContextMenu().close(); activity.getContextMenu().close();
BugBottomSheetDialog.showInstance(activity.getSupportFragmentManager(), getOsmbugsUtil(bug), local, text, BugBottomSheetDialog.showInstance(activity.getSupportFragmentManager(), getOsmbugsUtil(bug), local, text,
titleTextId, posButtonTextId, action, bug, point, getHandleBugListener()); titleTextId, posButtonTextId, action, bug, point, getHandleBugListener());
return;
} else { } else {
((EditText) view.findViewById(R.id.user_name_field)).setText(getUserName()); OsmNotesPoint notesPoint = new OsmNotesPoint();
((EditText) view.findViewById(R.id.password_field)).setText( notesPoint.setAction(action);
activity.getMyApplication().getSettings().USER_PASSWORD.get()); notesPoint.setId(bug.getId());
} notesPoint.setLatitude(bug.getLatitude());
if (!Algorithms.isEmpty(text)) { notesPoint.setLongitude(bug.getLongitude());
((EditText) view.findViewById(R.id.message_field)).setText(text); SendOsmNoteBottomSheetFragment.showInstance(activity.getSupportFragmentManager(), new OsmPoint[]{notesPoint});
}
view.findViewById(R.id.message_field).requestFocus();
AndroidUtils.softKeyboardDelayed(activity, view.findViewById(R.id.message_field));
final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setTitle(R.string.shared_string_commit);
builder.setView(view);
builder.setPositiveButton(posButtonTextId, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
String text = offline ? getMessageText(view) : getTextAndUpdateUserPwd(view);
activity.getContextMenu().close();
handleBug(text, bug, action, point);
}
});
builder.setNegativeButton(R.string.shared_string_cancel, null);
builder.create().show();
}
private void handleBug(String text, OpenStreetNote bug, Action action, OsmNotesPoint point) {
if (bug != null || point != null) {
executeTaskInBackground(new HandleOsmNoteAsyncTask(getOsmbugsUtil(bug), local, bug, point, text, action,
getHandleBugListener()));
} }
} }
@ -453,19 +423,6 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider
}; };
} }
private String getUserName() {
return ((OsmandApplication) activity.getApplication()).getSettings().USER_NAME.get();
}
private String getTextAndUpdateUserPwd(final View view) {
String text = getMessageText(view);
String author = ((EditText) view.findViewById(R.id.user_name_field)).getText().toString();
String pwd = ((EditText) view.findViewById(R.id.password_field)).getText().toString();
((OsmandApplication) OsmBugsLayer.this.activity.getApplication()).getSettings().USER_NAME.set(author);
((OsmandApplication) OsmBugsLayer.this.activity.getApplication()).getSettings().USER_PASSWORD.set(pwd);
return text;
}
private String getMessageText(final View view) { private String getMessageText(final View view) {
return ((EditText) view.findViewById(R.id.message_field)).getText().toString(); return ((EditText) view.findViewById(R.id.message_field)).getText().toString();
} }

View file

@ -58,10 +58,9 @@ import net.osmand.plus.osmedit.FileTypeBottomSheetDialogFragment.FileTypeFragmen
import net.osmand.plus.osmedit.OpenstreetmapLocalUtil.OnNodeCommittedListener; import net.osmand.plus.osmedit.OpenstreetmapLocalUtil.OnNodeCommittedListener;
import net.osmand.plus.osmedit.OsmEditOptionsBottomSheetDialogFragment.OsmEditOptionsFragmentListener; import net.osmand.plus.osmedit.OsmEditOptionsBottomSheetDialogFragment.OsmEditOptionsFragmentListener;
import net.osmand.plus.osmedit.OsmPoint.Group; import net.osmand.plus.osmedit.OsmPoint.Group;
import net.osmand.plus.osmedit.dialogs.ProgressDialogPoiUploader;
import net.osmand.plus.osmedit.dialogs.SendOsmNoteBottomSheetFragment; import net.osmand.plus.osmedit.dialogs.SendOsmNoteBottomSheetFragment;
import net.osmand.plus.osmedit.dialogs.SendPoiBottomSheetFragment; import net.osmand.plus.osmedit.dialogs.SendPoiBottomSheetFragment;
import net.osmand.plus.osmedit.dialogs.SendPoiDialogFragment.ProgressDialogPoiUploader;
import net.osmand.plus.osmedit.oauth.OsmOAuthAuthorizationAdapter;
import net.osmand.plus.osmedit.oauth.OsmOAuthHelper.OsmAuthorizationListener; import net.osmand.plus.osmedit.oauth.OsmOAuthHelper.OsmAuthorizationListener;
import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
@ -633,14 +632,8 @@ public class OsmEditsFragment extends OsmAndListFragment implements ProgressDial
private void uploadItems(final OsmPoint[] points) { private void uploadItems(final OsmPoint[] points) {
FragmentActivity activity = getActivity(); FragmentActivity activity = getActivity();
if (activity != null) { if (activity != null) {
OsmandApplication app = getMyApplication();
OsmandSettings settings = app.getSettings();
OsmOAuthAuthorizationAdapter authorizationAdapter = app.getOsmOAuthHelper().getAuthorizationAdapter();
boolean isLogged = authorizationAdapter.isValidToken()
|| !Algorithms.isEmpty(settings.USER_NAME.get())
&& !Algorithms.isEmpty(settings.USER_PASSWORD.get());
if (hasPoiGroup(points)) { if (hasPoiGroup(points)) {
if (isLogged) { if (getMyApplication().getOsmOAuthHelper().isLogged()) {
SendPoiBottomSheetFragment.showInstance(getChildFragmentManager(), points); SendPoiBottomSheetFragment.showInstance(getChildFragmentManager(), points);
} else { } else {
LoginBottomSheetFragment.showInstance(activity.getSupportFragmentManager(), this); LoginBottomSheetFragment.showInstance(activity.getSupportFragmentManager(), this);

View file

@ -28,10 +28,8 @@ import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.UiUtilities; import net.osmand.plus.UiUtilities;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.dialogs.ProgressDialogFragment; import net.osmand.plus.dialogs.ProgressDialogFragment;
import net.osmand.plus.osmedit.dialogs.SendPoiDialogFragment; import net.osmand.plus.measurementtool.LoginBottomSheetFragment;
import net.osmand.plus.osmedit.dialogs.SendPoiDialogFragment.PoiUploaderType;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.util.ArrayList; import java.util.ArrayList;
@ -74,13 +72,7 @@ public class OsmEditsUploadListenerHelper implements OsmEditsUploadListener {
OsmPoint point = loadErrorsMap.keySet().iterator().next(); OsmPoint point = loadErrorsMap.keySet().iterator().next();
String message = loadErrorsMap.get(point); String message = loadErrorsMap.get(point);
if (message.equals(activity.getString(R.string.auth_failed))) { if (message.equals(activity.getString(R.string.auth_failed))) {
SendPoiDialogFragment dialogFragment; LoginBottomSheetFragment.showInstance(activity.getSupportFragmentManager(), null);
if (activity instanceof MapActivity) {
dialogFragment = SendPoiDialogFragment.createInstance(new OsmPoint[]{point}, PoiUploaderType.SIMPLE);
} else {
dialogFragment = SendPoiDialogFragment.createInstance(new OsmPoint[]{point}, PoiUploaderType.FRAGMENT);
}
dialogFragment.show(activity.getSupportFragmentManager(), "error_loading");
} else { } else {
DialogFragment dialogFragment = DialogFragment dialogFragment =
UploadingErrorDialogFragment.getInstance(message, point); UploadingErrorDialogFragment.getInstance(message, point);

View file

@ -57,8 +57,6 @@ public class BugBottomSheetDialog extends MenuBottomSheetDialogFragment {
View osmNoteView = View.inflate(UiUtilities.getThemedContext(app, nightMode), View osmNoteView = View.inflate(UiUtilities.getThemedContext(app, nightMode),
R.layout.open_osm_note_text, null); R.layout.open_osm_note_text, null);
TextInputLayout textBox = osmNoteView.findViewById(R.id.name_text_box); TextInputLayout textBox = osmNoteView.findViewById(R.id.name_text_box);
int highlightColorId = nightMode ? R.color.list_background_color_dark : R.color.activity_background_color_light;
textBox.setBoxBackgroundColorResource(highlightColorId);
textBox.setHint(AndroidUtils.addColon(app, R.string.osn_bug_name)); textBox.setHint(AndroidUtils.addColon(app, R.string.osn_bug_name));
ColorStateList colorStateList = ColorStateList.valueOf(ContextCompat ColorStateList colorStateList = ColorStateList.valueOf(ContextCompat
.getColor(app, nightMode ? R.color.text_color_secondary_dark : R.color.text_color_secondary_light)); .getColor(app, nightMode ? R.color.text_color_secondary_dark : R.color.text_color_secondary_light));
@ -86,11 +84,6 @@ public class BugBottomSheetDialog extends MenuBottomSheetDialogFragment {
dismiss(); dismiss();
} }
@Override
protected int getBgColorId() {
return nightMode ? R.color.activity_background_color_dark : R.color.list_background_color_light;
}
public static void showInstance(@NonNull FragmentManager fm, OsmBugsUtil osmBugsUtil, OsmBugsUtil local, public static void showInstance(@NonNull FragmentManager fm, OsmBugsUtil osmBugsUtil, OsmBugsUtil local,
String text, int titleTextId, int posButtonTextId, final OsmPoint.Action action, String text, int titleTextId, int posButtonTextId, final OsmPoint.Action action,
final OsmBugsLayer.OpenStreetNote bug, final OsmNotesPoint point, final OsmBugsLayer.OpenStreetNote bug, final OsmNotesPoint point,

View file

@ -0,0 +1,7 @@
package net.osmand.plus.osmedit.dialogs;
import net.osmand.plus.osmedit.OsmPoint;
public interface ProgressDialogPoiUploader {
void showProgressDialog(OsmPoint[] points, boolean closeChangeSet, boolean anonymously);
}

View file

@ -28,6 +28,7 @@ import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.MenuBottomSheetDialogFragment; import net.osmand.plus.base.MenuBottomSheetDialogFragment;
import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem; import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem;
import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem; import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem;
import net.osmand.plus.osmedit.DashOsmEditsFragment;
import net.osmand.plus.osmedit.OsmNotesPoint; import net.osmand.plus.osmedit.OsmNotesPoint;
import net.osmand.plus.osmedit.OsmPoint; import net.osmand.plus.osmedit.OsmPoint;
import net.osmand.plus.osmedit.oauth.OsmOAuthAuthorizationAdapter; import net.osmand.plus.osmedit.oauth.OsmOAuthAuthorizationAdapter;
@ -42,9 +43,7 @@ import static net.osmand.plus.UiUtilities.setupDialogButton;
import static net.osmand.plus.osmedit.OsmEditingFragment.OSM_LOGIN_DATA; import static net.osmand.plus.osmedit.OsmEditingFragment.OSM_LOGIN_DATA;
import static net.osmand.plus.osmedit.ValidateOsmLoginDetailsTask.ValidateOsmLoginListener; import static net.osmand.plus.osmedit.ValidateOsmLoginDetailsTask.ValidateOsmLoginListener;
import static net.osmand.plus.osmedit.dialogs.SendGpxBottomSheetFragment.showOpenStreetMapScreen; import static net.osmand.plus.osmedit.dialogs.SendGpxBottomSheetFragment.showOpenStreetMapScreen;
import static net.osmand.plus.osmedit.dialogs.SendPoiDialogFragment.OPENSTREETMAP_POINT; import static net.osmand.plus.osmedit.dialogs.SendPoiBottomSheetFragment.OPENSTREETMAP_POINT;
import static net.osmand.plus.osmedit.dialogs.SendPoiDialogFragment.ProgressDialogPoiUploader;
import static net.osmand.plus.osmedit.dialogs.SendPoiDialogFragment.SimpleProgressDialogPoiUploader;
public class SendOsmNoteBottomSheetFragment extends MenuBottomSheetDialogFragment implements ValidateOsmLoginListener, public class SendOsmNoteBottomSheetFragment extends MenuBottomSheetDialogFragment implements ValidateOsmLoginListener,
OsmAuthorizationListener { OsmAuthorizationListener {
@ -59,6 +58,7 @@ public class SendOsmNoteBottomSheetFragment extends MenuBottomSheetDialogFragmen
private LinearLayout signInView; private LinearLayout signInView;
private SwitchCompat uploadAnonymously; private SwitchCompat uploadAnonymously;
private OsmandApplication app; private OsmandApplication app;
private EditText noteText;
private boolean isLoginOAuth() { private boolean isLoginOAuth() {
return !Algorithms.isEmpty(settings.USER_DISPLAY_NAME.get()); return !Algorithms.isEmpty(settings.USER_DISPLAY_NAME.get());
@ -78,7 +78,7 @@ public class SendOsmNoteBottomSheetFragment extends MenuBottomSheetDialogFragmen
final View sendOsmNoteView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), final View sendOsmNoteView = View.inflate(new ContextThemeWrapper(getContext(), themeRes),
R.layout.send_osm_note_fragment, null); R.layout.send_osm_note_fragment, null);
EditText noteText = sendOsmNoteView.findViewById(R.id.note_text); noteText = sendOsmNoteView.findViewById(R.id.note_text);
noteText.setText(((OsmNotesPoint) poi[0]).getText()); noteText.setText(((OsmNotesPoint) poi[0]).getText());
noteText.setSelection(noteText.getText().length()); noteText.setSelection(noteText.getText().length());
TextInputLayout noteHint = sendOsmNoteView.findViewById(R.id.note_hint); TextInputLayout noteHint = sendOsmNoteView.findViewById(R.id.note_hint);
@ -98,7 +98,7 @@ public class SendOsmNoteBottomSheetFragment extends MenuBottomSheetDialogFragmen
if (fragment instanceof OsmAuthorizationListener) { if (fragment instanceof OsmAuthorizationListener) {
app.getOsmOAuthHelper().addListener((OsmAuthorizationListener) fragment); app.getOsmOAuthHelper().addListener((OsmAuthorizationListener) fragment);
} }
app.getOsmOAuthHelper().startOAuth((ViewGroup) v); app.getOsmOAuthHelper().startOAuth((ViewGroup) getView(), nightMode);
} }
}); });
View loginButton = sendOsmNoteView.findViewById(R.id.login_button); View loginButton = sendOsmNoteView.findViewById(R.id.login_button);
@ -196,11 +196,16 @@ public class SendOsmNoteBottomSheetFragment extends MenuBottomSheetDialogFragmen
ProgressDialogPoiUploader progressDialogPoiUploader = null; ProgressDialogPoiUploader progressDialogPoiUploader = null;
Activity activity = getActivity(); Activity activity = getActivity();
if (activity instanceof MapActivity) { if (activity instanceof MapActivity) {
progressDialogPoiUploader = new SimpleProgressDialogPoiUploader((MapActivity) activity); if (getParentFragment() instanceof DashOsmEditsFragment) {
progressDialogPoiUploader = (ProgressDialogPoiUploader) getParentFragment();
} else {
progressDialogPoiUploader = new SimpleProgressDialogPoiUploader((MapActivity) activity);
}
} else if (getParentFragment() instanceof ProgressDialogPoiUploader) { } else if (getParentFragment() instanceof ProgressDialogPoiUploader) {
progressDialogPoiUploader = (ProgressDialogPoiUploader) getParentFragment(); progressDialogPoiUploader = (ProgressDialogPoiUploader) getParentFragment();
} }
if (progressDialogPoiUploader != null) { if (progressDialogPoiUploader != null) {
((OsmNotesPoint) poi[0]).setText(noteText.getText().toString());
progressDialogPoiUploader.showProgressDialog(poi, false, uploadAnonymously.isChecked()); progressDialogPoiUploader.showProgressDialog(poi, false, uploadAnonymously.isChecked());
} }
dismiss(); dismiss();

View file

@ -34,14 +34,12 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import static net.osmand.plus.osmedit.dialogs.SendGpxBottomSheetFragment.showOpenStreetMapScreen; import static net.osmand.plus.osmedit.dialogs.SendGpxBottomSheetFragment.showOpenStreetMapScreen;
import static net.osmand.plus.osmedit.dialogs.SendPoiDialogFragment.OPENSTREETMAP_POINT;
import static net.osmand.plus.osmedit.dialogs.SendPoiDialogFragment.ProgressDialogPoiUploader;
import static net.osmand.plus.osmedit.dialogs.SendPoiDialogFragment.SimpleProgressDialogPoiUploader;
public class SendPoiBottomSheetFragment extends MenuBottomSheetDialogFragment { public class SendPoiBottomSheetFragment extends MenuBottomSheetDialogFragment {
public static final String TAG = SendPoiBottomSheetFragment.class.getSimpleName(); public static final String TAG = SendPoiBottomSheetFragment.class.getSimpleName();
private static final Log LOG = PlatformUtil.getLog(SendPoiBottomSheetFragment.class); private static final Log LOG = PlatformUtil.getLog(SendPoiBottomSheetFragment.class);
public static final String OPENSTREETMAP_POINT = "openstreetmap_point";
private OsmPoint[] poi; private OsmPoint[] poi;
private SwitchCompat closeChangeSet; private SwitchCompat closeChangeSet;

View file

@ -1,280 +0,0 @@
package net.osmand.plus.osmedit.dialogs;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.View;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.widget.SwitchCompat;
import androidx.fragment.app.DialogFragment;
import net.osmand.osm.PoiType;
import net.osmand.osm.edit.Entity;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.dialogs.ProgressDialogFragment;
import net.osmand.plus.osmedit.OpenstreetmapPoint;
import net.osmand.plus.osmedit.OsmBugsLayer;
import net.osmand.plus.osmedit.OsmEditingPlugin;
import net.osmand.plus.osmedit.OsmEditsUploadListener;
import net.osmand.plus.osmedit.OsmEditsUploadListenerHelper;
import net.osmand.plus.osmedit.OsmPoint;
import net.osmand.plus.osmedit.UploadOpenstreetmapPointAsyncTask;
import net.osmand.util.Algorithms;
import java.util.HashMap;
import java.util.Map;
public class SendPoiDialogFragment extends DialogFragment {
public static final String TAG = "SendPoiDialogFragment";
public static final String OPENSTREETMAP_POINT = "openstreetmap_point";
public static final String POI_UPLOADER_TYPE = "poi_uploader_type";
private OsmPoint[] poi;
public enum PoiUploaderType {
SIMPLE,
FRAGMENT
}
private OsmandApplication getMyApplication() {
return (OsmandApplication) getActivity().getApplication();
}
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
poi = (OsmPoint[]) getArguments().getSerializable(OPENSTREETMAP_POINT);
final PoiUploaderType poiUploaderType = PoiUploaderType.valueOf(getArguments().getString(POI_UPLOADER_TYPE, PoiUploaderType.SIMPLE.name()));
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
View view = getActivity().getLayoutInflater().inflate(R.layout.send_poi_dialog, null);
final SwitchCompat uploadAnonymously = (SwitchCompat) view.findViewById(R.id.upload_anonymously_switch);
final EditText messageEditText = (EditText) view.findViewById(R.id.message_field);
final EditText userNameEditText = (EditText) view.findViewById(R.id.user_name_field);
final EditText passwordEditText = (EditText) view.findViewById(R.id.password_field);
final View messageLabel = view.findViewById(R.id.message_label);
final View userNameLabel = view.findViewById(R.id.osm_user_name_label);
final View passwordLabel = view.findViewById(R.id.osm_user_password_label);
final CheckBox closeChangeSetCheckBox =
(CheckBox) view.findViewById(R.id.close_change_set_checkbox);
final OsmandSettings settings = ((OsmandApplication) getActivity().getApplication())
.getSettings();
userNameEditText.setText(settings.USER_NAME.get());
passwordEditText.setText(settings.USER_PASSWORD.get());
boolean hasPoiGroup = false;
assert poi != null;
for (OsmPoint p : poi) {
if (p.getGroup() == OsmPoint.Group.POI) {
hasPoiGroup = true;
break;
}
}
String defaultChangeSet = createDefaultChangeSet();
messageEditText.setText(defaultChangeSet);
final boolean hasPOI = hasPoiGroup;
messageLabel.setVisibility(hasPOI ? View.VISIBLE : View.GONE);
messageEditText.setVisibility(hasPOI ? View.VISIBLE : View.GONE);
closeChangeSetCheckBox.setVisibility(hasPOI ? View.VISIBLE : View.GONE);
closeChangeSetCheckBox.setChecked(hasPOI && !defaultChangeSet.isEmpty());
view.findViewById(R.id.osm_note_header).setVisibility(hasPOI ? View.GONE : View.VISIBLE);
uploadAnonymously.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
userNameLabel.setVisibility(isChecked ? View.GONE : View.VISIBLE);
userNameEditText.setVisibility(isChecked ? View.GONE : View.VISIBLE);
passwordLabel.setVisibility(isChecked ? View.GONE : View.VISIBLE);
passwordEditText.setVisibility(isChecked ? View.GONE : View.VISIBLE);
}
});
final ProgressDialogPoiUploader progressDialogPoiUploader;
if (poiUploaderType == PoiUploaderType.SIMPLE && getActivity() instanceof MapActivity) {
progressDialogPoiUploader =
new SendPoiDialogFragment.SimpleProgressDialogPoiUploader((MapActivity) getActivity());
} else {
progressDialogPoiUploader = (ProgressDialogPoiUploader) getParentFragment();
}
builder.setTitle(hasPOI ? R.string.upload_poi : R.string.upload_osm_note)
.setView(view)
.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (progressDialogPoiUploader != null) {
settings.USER_NAME.set(userNameEditText.getText().toString());
settings.USER_PASSWORD.set(passwordEditText.getText().toString());
String comment = messageEditText.getText().toString();
if (comment.length() > 0) {
for (OsmPoint osmPoint : poi) {
if (osmPoint.getGroup() == OsmPoint.Group.POI) {
((OpenstreetmapPoint) osmPoint).setComment(comment);
break;
}
}
}
progressDialogPoiUploader.showProgressDialog(poi,
closeChangeSetCheckBox.isChecked(),
!hasPOI && uploadAnonymously.isChecked());
}
}
})
.setNegativeButton(R.string.shared_string_cancel, null);
return builder.create();
}
public static SendPoiDialogFragment createInstance(@NonNull OsmPoint[] points, @NonNull PoiUploaderType uploaderType) {
SendPoiDialogFragment fragment = new SendPoiDialogFragment();
Bundle bundle = new Bundle();
bundle.putSerializable(OPENSTREETMAP_POINT, points);
bundle.putString(POI_UPLOADER_TYPE, uploaderType.name());
fragment.setArguments(bundle);
return fragment;
}
private String createDefaultChangeSet() {
Map<String, PoiType> allTranslatedSubTypes = getMyApplication().getPoiTypes().getAllTranslatedNames(true);
if (allTranslatedSubTypes == null) {
return "";
}
Map<String, Integer> addGroup = new HashMap<>();
Map<String, Integer> editGroup = new HashMap<>();
Map<String, Integer> deleteGroup = new HashMap<>();
Map<String, Integer> reopenGroup = new HashMap<>();
String comment = "";
for (OsmPoint p : poi) {
if (p.getGroup() == OsmPoint.Group.POI) {
OsmPoint.Action action = p.getAction();
String type = ((OpenstreetmapPoint) p).getEntity().getTag(Entity.POI_TYPE_TAG);
if (type == null) {
continue;
}
PoiType localizedPoiType = allTranslatedSubTypes.get(type.toLowerCase().trim());
if (localizedPoiType != null) {
type = Algorithms.capitalizeFirstLetter(localizedPoiType.getKeyName().replace('_', ' '));
}
if (action == OsmPoint.Action.CREATE) {
if (!addGroup.containsKey(type)) {
addGroup.put(type, 1);
} else {
addGroup.put(type, addGroup.get(type) + 1);
}
} else if (action == OsmPoint.Action.MODIFY) {
if (!editGroup.containsKey(type)) {
editGroup.put(type, 1);
} else {
editGroup.put(type, editGroup.get(type) + 1);
}
} else if (action == OsmPoint.Action.DELETE) {
if (!deleteGroup.containsKey(type)) {
deleteGroup.put(type, 1);
} else {
deleteGroup.put(type, deleteGroup.get(type) + 1);
}
} else if (action == OsmPoint.Action.REOPEN) {
if (!reopenGroup.containsKey(type)) {
reopenGroup.put(type, 1);
} else {
reopenGroup.put(type, reopenGroup.get(type) + 1);
}
}
}
}
int modifiedItemsOutOfLimit = 0;
for (int i = 0; i < 4; i++) {
String action;
Map<String, Integer> group;
switch (i) {
case 0:
action = getString(R.string.default_changeset_add);
group = addGroup;
break;
case 1:
action = getString(R.string.default_changeset_edit);
group = editGroup;
break;
case 2:
action = getString(R.string.default_changeset_delete);
group = deleteGroup;
break;
case 3:
action = getString(R.string.default_changeset_reopen);
group = reopenGroup;
break;
default:
action = "";
group = new HashMap<>();
}
if (!group.isEmpty()) {
int pos = 0;
for (Map.Entry<String, Integer> entry : group.entrySet()) {
String type = entry.getKey();
int quantity = entry.getValue();
if (comment.length() > 200) {
modifiedItemsOutOfLimit += quantity;
} else {
if (pos == 0) {
comment = comment.concat(comment.length() == 0 ? "" : "; ").concat(action).concat(" ").concat(quantity == 1 ? "" : quantity + " ").concat(type);
} else {
comment = comment.concat(", ").concat(quantity == 1 ? "" : quantity + " ").concat(type);
}
}
pos++;
}
}
}
if (modifiedItemsOutOfLimit != 0) {
comment = comment.concat("; ").concat(modifiedItemsOutOfLimit + " ").concat(getString(R.string.items_modified)).concat(".");
} else if (!comment.isEmpty()){
comment = comment.concat(".");
}
return comment;
}
public interface ProgressDialogPoiUploader {
void showProgressDialog(OsmPoint[] points, boolean closeChangeSet, boolean anonymously);
}
public static class SimpleProgressDialogPoiUploader implements ProgressDialogPoiUploader {
private MapActivity mapActivity;
public SimpleProgressDialogPoiUploader(MapActivity mapActivity) {
this.mapActivity = mapActivity;
}
@Override
public void showProgressDialog(OsmPoint[] points, boolean closeChangeSet, boolean anonymously) {
ProgressDialogFragment dialog = ProgressDialogFragment.createInstance(
R.string.uploading,
R.string.local_openstreetmap_uploading,
ProgressDialog.STYLE_HORIZONTAL);
OsmEditingPlugin plugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class);
OsmEditsUploadListener listener = new OsmEditsUploadListenerHelper(mapActivity,
mapActivity.getString(R.string.local_openstreetmap_were_uploaded)) {
@Override
public void uploadEnded(Map<OsmPoint, String> loadErrorsMap) {
super.uploadEnded(loadErrorsMap);
mapActivity.getContextMenu().close();
OsmBugsLayer l = mapActivity.getMapView().getLayerByClass(OsmBugsLayer.class);
if(l != null) {
l.clearCache();
mapActivity.refreshMap();
}
}
};
dialog.show(mapActivity.getSupportFragmentManager(), ProgressDialogFragment.TAG);
UploadOpenstreetmapPointAsyncTask uploadTask = new UploadOpenstreetmapPointAsyncTask(
dialog, listener, plugin, points.length, closeChangeSet, anonymously);
uploadTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, points);
}
}
}

View file

@ -0,0 +1,52 @@
package net.osmand.plus.osmedit.dialogs;
import android.app.ProgressDialog;
import android.os.AsyncTask;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.dialogs.ProgressDialogFragment;
import net.osmand.plus.osmedit.OsmBugsLayer;
import net.osmand.plus.osmedit.OsmEditingPlugin;
import net.osmand.plus.osmedit.OsmEditsUploadListener;
import net.osmand.plus.osmedit.OsmEditsUploadListenerHelper;
import net.osmand.plus.osmedit.OsmPoint;
import net.osmand.plus.osmedit.UploadOpenstreetmapPointAsyncTask;
import java.util.Map;
public class SimpleProgressDialogPoiUploader implements ProgressDialogPoiUploader {
private MapActivity mapActivity;
public SimpleProgressDialogPoiUploader(MapActivity mapActivity) {
this.mapActivity = mapActivity;
}
@Override
public void showProgressDialog(OsmPoint[] points, boolean closeChangeSet, boolean anonymously) {
ProgressDialogFragment dialog = ProgressDialogFragment.createInstance(
R.string.uploading,
R.string.local_openstreetmap_uploading,
ProgressDialog.STYLE_HORIZONTAL);
OsmEditingPlugin plugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class);
OsmEditsUploadListener listener = new OsmEditsUploadListenerHelper(mapActivity,
mapActivity.getString(R.string.local_openstreetmap_were_uploaded)) {
@Override
public void uploadEnded(Map<OsmPoint, String> loadErrorsMap) {
super.uploadEnded(loadErrorsMap);
mapActivity.getContextMenu().close();
OsmBugsLayer l = mapActivity.getMapView().getLayerByClass(OsmBugsLayer.class);
if (l != null) {
l.clearCache();
mapActivity.refreshMap();
}
}
};
dialog.show(mapActivity.getSupportFragmentManager(), ProgressDialogFragment.TAG);
UploadOpenstreetmapPointAsyncTask uploadTask = new UploadOpenstreetmapPointAsyncTask(
dialog, listener, plugin, points.length, closeChangeSet, anonymously);
uploadTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, points);
}
}

View file

@ -1,12 +1,19 @@
package net.osmand.plus.osmedit.oauth; package net.osmand.plus.osmedit.oauth;
import android.content.Context;
import android.content.Intent;
import android.net.TrafficStats; import android.net.TrafficStats;
import android.net.Uri;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Build;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.webkit.WebView; import android.webkit.WebView;
import android.webkit.WebViewClient;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.browser.customtabs.CustomTabsIntent;
import androidx.core.content.ContextCompat;
import com.github.scribejava.core.builder.api.DefaultApi10a; import com.github.scribejava.core.builder.api.DefaultApi10a;
import com.github.scribejava.core.model.OAuth1AccessToken; import com.github.scribejava.core.model.OAuth1AccessToken;
@ -20,6 +27,7 @@ import net.osmand.osm.oauth.OsmOAuthAuthorizationClient;
import net.osmand.plus.OsmAndConstants; import net.osmand.plus.OsmAndConstants;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.wikipedia.WikipediaDialogFragment;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParser;
@ -79,8 +87,8 @@ public class OsmOAuthAuthorizationAdapter {
} }
} }
public void startOAuth(final ViewGroup rootLayout) { public void startOAuth(final ViewGroup rootLayout, boolean nightMode) {
new StartOAuthAsyncTask(rootLayout).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Void) null); new StartOAuthAsyncTask(rootLayout, nightMode).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Void) null);
} }
private void saveToken() { private void saveToken() {
@ -89,11 +97,10 @@ public class OsmOAuthAuthorizationAdapter {
app.getSettings().USER_ACCESS_TOKEN_SECRET.set(accessToken.getTokenSecret()); app.getSettings().USER_ACCESS_TOKEN_SECRET.set(accessToken.getTokenSecret());
} }
private void loadWebView(ViewGroup root, String url) { private void loadWebView(ViewGroup root, boolean nightMode, String url) {
WebView webView = new WebView(root.getContext()); Uri uri = Uri.parse(url);
webView.requestFocus(View.FOCUS_DOWN); Context context = root.getContext();
webView.loadUrl(url); WikipediaDialogFragment.showFullArticle(context, uri, nightMode);
root.addView(webView);
} }
public void performGetRequest(String url, OAuthAsyncRequestCallback<Response> callback) { public void performGetRequest(String url, OAuthAsyncRequestCallback<Response> callback) {
@ -117,9 +124,11 @@ public class OsmOAuthAuthorizationAdapter {
private class StartOAuthAsyncTask extends AsyncTask<Void, Void, OAuth1RequestToken> { private class StartOAuthAsyncTask extends AsyncTask<Void, Void, OAuth1RequestToken> {
private final ViewGroup rootLayout; private final ViewGroup rootLayout;
boolean nightMode;
public StartOAuthAsyncTask(ViewGroup rootLayout) { public StartOAuthAsyncTask(ViewGroup rootLayout, boolean nightMode) {
this.rootLayout = rootLayout; this.rootLayout = rootLayout;
this.nightMode = nightMode;
} }
@Override @Override
@ -129,7 +138,7 @@ public class OsmOAuthAuthorizationAdapter {
@Override @Override
protected void onPostExecute(@NonNull OAuth1RequestToken requestToken) { protected void onPostExecute(@NonNull OAuth1RequestToken requestToken) {
loadWebView(rootLayout, client.getService().getAuthorizationUrl(requestToken)); loadWebView(rootLayout, nightMode, client.getService().getAuthorizationUrl(requestToken));
} }
} }

View file

@ -28,9 +28,8 @@ public class OsmOAuthHelper {
listeners.add(listener); listeners.add(listener);
} }
public OsmOAuthAuthorizationAdapter updateAdapter(){ public void updateAdapter() {
authorizationAdapter = new OsmOAuthAuthorizationAdapter(app); authorizationAdapter = new OsmOAuthAuthorizationAdapter(app);
return authorizationAdapter;
} }
public void removeListener(OsmAuthorizationListener listener) { public void removeListener(OsmAuthorizationListener listener) {
@ -41,8 +40,8 @@ public class OsmOAuthHelper {
return authorizationAdapter; return authorizationAdapter;
} }
public void startOAuth(@NonNull ViewGroup view) { public void startOAuth(@NonNull ViewGroup view, boolean nightMode) {
authorizationAdapter.startOAuth(view); authorizationAdapter.startOAuth(view, nightMode);
} }
public void authorize(@NonNull String oauthVerifier) { public void authorize(@NonNull String oauthVerifier) {
@ -76,6 +75,10 @@ public class OsmOAuthHelper {
return authorizationAdapter.isValidToken(); return authorizationAdapter.isValidToken();
} }
public boolean isLogged() {
return isValidToken() || isLoginExists();
}
public interface OsmAuthorizationListener { public interface OsmAuthorizationListener {
void authorizationCompleted(); void authorizationCompleted();
} }

View file

@ -703,9 +703,16 @@ public class ContextMenuLayer extends OsmandMapLayer {
RenderingContext rc = maps.getVisibleRenderingContext(); RenderingContext rc = maps.getVisibleRenderingContext();
RenderedObject[] renderedObjects = null; RenderedObject[] renderedObjects = null;
if (rc != null && rc.zoom == tileBox.getZoom()) { if (rc != null && rc.zoom == tileBox.getZoom()) {
double sinRotate = Math.sin(Math.toRadians(rc.rotate - tileBox.getRotate()));
double cosRotate = Math.cos(Math.toRadians(rc.rotate - tileBox.getRotate()));
float x = tileBox.getPixXFrom31((int) (rc.leftX * rc.tileDivisor), (int) (rc.topY * rc.tileDivisor)); float x = tileBox.getPixXFrom31((int) (rc.leftX * rc.tileDivisor), (int) (rc.topY * rc.tileDivisor));
float y = tileBox.getPixYFrom31((int) (rc.leftX * rc.tileDivisor), (int) (rc.topY * rc.tileDivisor)); float y = tileBox.getPixYFrom31((int) (rc.leftX * rc.tileDivisor), (int) (rc.topY * rc.tileDivisor));
renderedObjects = nativeLib.searchRenderedObjectsFromContext(rc, (int) (point.x - x), (int) (point.y - y)); float dx = point.x - x;
float dy = point.y - y;
int coordX = (int) (dx * cosRotate - dy * sinRotate);
int coordY = (int) (dy * cosRotate + dx * sinRotate);
renderedObjects = nativeLib.searchRenderedObjectsFromContext(rc, coordX, coordY);
} }
if (renderedObjects != null) { if (renderedObjects != null) {
int TILE_SIZE = 256; int TILE_SIZE = 256;