diff --git a/OsmAnd/res/values/colors.xml b/OsmAnd/res/values/colors.xml index 3e9a872edb..788849dad0 100644 --- a/OsmAnd/res/values/colors.xml +++ b/OsmAnd/res/values/colors.xml @@ -477,7 +477,8 @@ #80D28521 #80000000 #4DCCCCCC - #14000000 - #0DFFFFFF + #4DCCCCCC + #1AFFFFFF + #67727272 \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/LoginBottomSheetFragment.java b/OsmAnd/src/net/osmand/plus/measurementtool/LoginBottomSheetFragment.java index 94ef66beab..cb0ee688d0 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/LoginBottomSheetFragment.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/LoginBottomSheetFragment.java @@ -94,7 +94,7 @@ public class LoginBottomSheetFragment extends MenuBottomSheetDialogFragment impl if (!(getActivity() instanceof MapActivity) && fragment instanceof OsmAuthorizationListener) { osmOAuthHelper.addListener((OsmAuthorizationListener) fragment); } - osmOAuthHelper.startOAuth((ViewGroup) view); + osmOAuthHelper.startOAuth((ViewGroup) view, nightMode); } } diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLayer.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLayer.java index 71f7f112ec..1c0540637c 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLayer.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLayer.java @@ -1,7 +1,6 @@ package net.osmand.plus.osmedit; import android.annotation.SuppressLint; -import android.content.DialogInterface; import android.graphics.Canvas; import android.graphics.PointF; import android.util.Xml; @@ -10,10 +9,8 @@ import android.view.View; import android.widget.EditText; import android.widget.Toast; -import androidx.appcompat.app.AlertDialog; import androidx.core.content.ContextCompat; -import net.osmand.AndroidUtils; import net.osmand.PlatformUtil; import net.osmand.data.FavouritePoint.BackgroundType; import net.osmand.data.LatLon; @@ -25,6 +22,7 @@ import net.osmand.osm.io.NetworkUtils; import net.osmand.plus.OsmandApplication; import net.osmand.plus.base.PointImageDrawable; 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.R; import net.osmand.plus.activities.MapActivity; @@ -32,7 +30,6 @@ import net.osmand.plus.osmedit.OsmPoint.Action; import net.osmand.plus.views.layers.ContextMenuLayer.IContextMenuProvider; import net.osmand.plus.views.OsmandMapLayer; import net.osmand.plus.views.OsmandMapTileView; -import net.osmand.util.Algorithms; import org.apache.commons.logging.Log; import org.xmlpull.v1.XmlPullParser; @@ -370,29 +367,13 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider titleTextId, posButtonTextId, action, bug, point, getHandleBugListener()); return; } else { - ((EditText) view.findViewById(R.id.user_name_field)).setText(getUserName()); - ((EditText) view.findViewById(R.id.password_field)).setText( - activity.getMyApplication().getSettings().USER_PASSWORD.get()); + OsmNotesPoint pnt = new OsmNotesPoint(); + pnt.setAction(action); + pnt.setId(bug.getId()); + pnt.setLatitude(bug.getLatitude()); + pnt.setLongitude(bug.getLongitude()); + SendOsmNoteBottomSheetFragment.showInstance(activity.getSupportFragmentManager(), new OsmPoint[]{pnt}); } - if (!Algorithms.isEmpty(text)) { - ((EditText) view.findViewById(R.id.message_field)).setText(text); - } - 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) { diff --git a/OsmAnd/src/net/osmand/plus/osmedit/dialogs/BugBottomSheetDialog.java b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/BugBottomSheetDialog.java index 3793196ce0..38bb8da5fe 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/dialogs/BugBottomSheetDialog.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/BugBottomSheetDialog.java @@ -57,8 +57,6 @@ public class BugBottomSheetDialog extends MenuBottomSheetDialogFragment { View osmNoteView = View.inflate(UiUtilities.getThemedContext(app, nightMode), R.layout.open_osm_note_text, null); 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)); ColorStateList colorStateList = ColorStateList.valueOf(ContextCompat .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(); } - @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, String text, int titleTextId, int posButtonTextId, final OsmPoint.Action action, final OsmBugsLayer.OpenStreetNote bug, final OsmNotesPoint point, diff --git a/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendOsmNoteBottomSheetFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendOsmNoteBottomSheetFragment.java index d26c1ac212..25ff6968a8 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendOsmNoteBottomSheetFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendOsmNoteBottomSheetFragment.java @@ -59,6 +59,7 @@ public class SendOsmNoteBottomSheetFragment extends MenuBottomSheetDialogFragmen private LinearLayout signInView; private SwitchCompat uploadAnonymously; private OsmandApplication app; + private EditText noteText; private boolean isLoginOAuth() { return !Algorithms.isEmpty(settings.USER_DISPLAY_NAME.get()); @@ -78,7 +79,7 @@ public class SendOsmNoteBottomSheetFragment extends MenuBottomSheetDialogFragmen final View sendOsmNoteView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), 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.setSelection(noteText.getText().length()); TextInputLayout noteHint = sendOsmNoteView.findViewById(R.id.note_hint); @@ -98,7 +99,7 @@ public class SendOsmNoteBottomSheetFragment extends MenuBottomSheetDialogFragmen if (fragment instanceof OsmAuthorizationListener) { app.getOsmOAuthHelper().addListener((OsmAuthorizationListener) fragment); } - app.getOsmOAuthHelper().startOAuth((ViewGroup) v); + app.getOsmOAuthHelper().startOAuth((ViewGroup) getView(), nightMode); } }); View loginButton = sendOsmNoteView.findViewById(R.id.login_button); @@ -201,6 +202,7 @@ public class SendOsmNoteBottomSheetFragment extends MenuBottomSheetDialogFragmen progressDialogPoiUploader = (ProgressDialogPoiUploader) getParentFragment(); } if (progressDialogPoiUploader != null) { + ((OsmNotesPoint) poi[0]).setText(noteText.getText().toString()); progressDialogPoiUploader.showProgressDialog(poi, false, uploadAnonymously.isChecked()); } dismiss(); diff --git a/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendPoiDialogFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendPoiDialogFragment.java index adfb8a2b60..88e52b70e7 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendPoiDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendPoiDialogFragment.java @@ -36,6 +36,8 @@ 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"; diff --git a/OsmAnd/src/net/osmand/plus/osmedit/oauth/OsmOAuthAuthorizationAdapter.java b/OsmAnd/src/net/osmand/plus/osmedit/oauth/OsmOAuthAuthorizationAdapter.java index 5df7bfb765..d1c9f36e9a 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/oauth/OsmOAuthAuthorizationAdapter.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/oauth/OsmOAuthAuthorizationAdapter.java @@ -1,12 +1,19 @@ package net.osmand.plus.osmedit.oauth; +import android.content.Context; +import android.content.Intent; import android.net.TrafficStats; +import android.net.Uri; import android.os.AsyncTask; +import android.os.Build; import android.view.View; import android.view.ViewGroup; import android.webkit.WebView; +import android.webkit.WebViewClient; 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.model.OAuth1AccessToken; @@ -20,6 +27,7 @@ import net.osmand.osm.oauth.OsmOAuthAuthorizationClient; import net.osmand.plus.OsmAndConstants; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; +import net.osmand.plus.wikipedia.WikipediaDialogFragment; import org.apache.commons.logging.Log; import org.xmlpull.v1.XmlPullParser; @@ -79,8 +87,8 @@ public class OsmOAuthAuthorizationAdapter { } } - public void startOAuth(final ViewGroup rootLayout) { - new StartOAuthAsyncTask(rootLayout).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Void) null); + public void startOAuth(final ViewGroup rootLayout, boolean nightMode) { + new StartOAuthAsyncTask(rootLayout, nightMode).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Void) null); } private void saveToken() { @@ -89,11 +97,10 @@ public class OsmOAuthAuthorizationAdapter { app.getSettings().USER_ACCESS_TOKEN_SECRET.set(accessToken.getTokenSecret()); } - private void loadWebView(ViewGroup root, String url) { - WebView webView = new WebView(root.getContext()); - webView.requestFocus(View.FOCUS_DOWN); - webView.loadUrl(url); - root.addView(webView); + private void loadWebView(ViewGroup root, boolean nightMode, String url) { + Uri uri = Uri.parse(url); + Context context = root.getContext(); + WikipediaDialogFragment.showFullArticle(context, uri, nightMode); } public void performGetRequest(String url, OAuthAsyncRequestCallback callback) { @@ -117,9 +124,11 @@ public class OsmOAuthAuthorizationAdapter { private class StartOAuthAsyncTask extends AsyncTask { private final ViewGroup rootLayout; + boolean nightMode; - public StartOAuthAsyncTask(ViewGroup rootLayout) { + public StartOAuthAsyncTask(ViewGroup rootLayout, boolean nightMode) { this.rootLayout = rootLayout; + this.nightMode = nightMode; } @Override @@ -129,7 +138,7 @@ public class OsmOAuthAuthorizationAdapter { @Override protected void onPostExecute(@NonNull OAuth1RequestToken requestToken) { - loadWebView(rootLayout, client.getService().getAuthorizationUrl(requestToken)); + loadWebView(rootLayout, nightMode, client.getService().getAuthorizationUrl(requestToken)); } } diff --git a/OsmAnd/src/net/osmand/plus/osmedit/oauth/OsmOAuthHelper.java b/OsmAnd/src/net/osmand/plus/osmedit/oauth/OsmOAuthHelper.java index acda0e0361..44e25e21fd 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/oauth/OsmOAuthHelper.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/oauth/OsmOAuthHelper.java @@ -41,8 +41,8 @@ public class OsmOAuthHelper { return authorizationAdapter; } - public void startOAuth(@NonNull ViewGroup view) { - authorizationAdapter.startOAuth(view); + public void startOAuth(@NonNull ViewGroup view, boolean nightMode) { + authorizationAdapter.startOAuth(view, nightMode); } public void authorize(@NonNull String oauthVerifier) {