From 0aafc4ce84653a98f7c4c55a844239ae842f31ff Mon Sep 17 00:00:00 2001 From: simon Date: Wed, 11 Nov 2020 17:27:45 +0200 Subject: [PATCH 1/9] opr login added --- .../drawable/ic_img_logo_openplacereview.xml | 36 +++++++ OsmAnd/res/drawable/ic_sample.xml | 13 +++ OsmAnd/res/layout/fragment_opr_login.xml | 92 ++++++++++++++++++ OsmAnd/res/values/strings.xml | 5 + .../plus/mapcontextmenu/MenuBuilder.java | 97 ++++++++++++------- .../openplacereviews/OprStartFragment.java | 19 ++++ 6 files changed, 225 insertions(+), 37 deletions(-) create mode 100644 OsmAnd/res/drawable/ic_img_logo_openplacereview.xml create mode 100644 OsmAnd/res/drawable/ic_sample.xml create mode 100644 OsmAnd/res/layout/fragment_opr_login.xml create mode 100644 OsmAnd/src/net/osmand/plus/openplacereviews/OprStartFragment.java diff --git a/OsmAnd/res/drawable/ic_img_logo_openplacereview.xml b/OsmAnd/res/drawable/ic_img_logo_openplacereview.xml new file mode 100644 index 0000000000..3ef860a90c --- /dev/null +++ b/OsmAnd/res/drawable/ic_img_logo_openplacereview.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + diff --git a/OsmAnd/res/drawable/ic_sample.xml b/OsmAnd/res/drawable/ic_sample.xml new file mode 100644 index 0000000000..9612304bcf --- /dev/null +++ b/OsmAnd/res/drawable/ic_sample.xml @@ -0,0 +1,13 @@ + + + + diff --git a/OsmAnd/res/layout/fragment_opr_login.xml b/OsmAnd/res/layout/fragment_opr_login.xml new file mode 100644 index 0000000000..656da83538 --- /dev/null +++ b/OsmAnd/res/layout/fragment_opr_login.xml @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index dc262a8b1b..67e7b46abf 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -11,6 +11,11 @@ Thx - Hardy --> + I already have an account + Create new account + Photos are provided by open data project OpenPlaceReviews.org. In order to upload your photos you need to sign up on website. + Register on\nOpenPlaceReviews.org + Add photo OsmAnd Live subscription is on hold OsmAnd Live subscription has been paused OsmAnd Live subscription has been expired diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java index e18beeeb01..0a3543394d 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java @@ -8,6 +8,7 @@ import android.content.Intent; import android.content.res.ColorStateList; import android.graphics.Color; import android.graphics.PorterDuff; +import android.graphics.Typeface; import android.graphics.drawable.Drawable; import android.graphics.drawable.GradientDrawable; import android.net.Uri; @@ -21,30 +22,19 @@ import android.view.Gravity; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; -import android.widget.ImageView; -import android.widget.LinearLayout; -import android.widget.TextView; -import android.widget.Toast; - +import android.widget.*; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.AlertDialog; import androidx.appcompat.view.ContextThemeWrapper; import androidx.core.content.ContextCompat; import androidx.core.graphics.drawable.DrawableCompat; - import net.osmand.AndroidUtils; -import net.osmand.binary.BinaryMapIndexReader; import net.osmand.data.Amenity; import net.osmand.data.LatLon; import net.osmand.data.PointDescription; import net.osmand.data.QuadRect; -import net.osmand.osm.PoiCategory; -import net.osmand.plus.OsmAndFormatter; -import net.osmand.plus.OsmandApplication; -import net.osmand.plus.OsmandPlugin; -import net.osmand.plus.R; -import net.osmand.plus.UiUtilities; +import net.osmand.plus.*; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.helpers.FontCache; import net.osmand.plus.mapcontextmenu.builders.cards.AbstractCard; @@ -53,6 +43,7 @@ import net.osmand.plus.mapcontextmenu.builders.cards.ImageCard; import net.osmand.plus.mapcontextmenu.builders.cards.ImageCard.GetImageCardsTask; import net.osmand.plus.mapcontextmenu.builders.cards.NoImagesCard; import net.osmand.plus.mapcontextmenu.controllers.TransportStopController; +import net.osmand.plus.openplacereviews.OprStartFragment; import net.osmand.plus.poi.PoiUIFilter; import net.osmand.plus.render.RenderingIcons; import net.osmand.plus.transport.TransportStopRoute; @@ -63,13 +54,7 @@ import net.osmand.plus.widgets.tools.ClickableSpanTouchListener; import net.osmand.util.Algorithms; import net.osmand.util.MapUtils; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; import static net.osmand.plus.mapcontextmenu.builders.cards.ImageCard.GetImageCardsTask.GetImageCardsListener; @@ -77,7 +62,7 @@ public class MenuBuilder { public static final float SHADOW_HEIGHT_TOP_DP = 17f; public static final int TITLE_LIMIT = 60; - protected static final String[] arrowChars = new String[]{"=>"," - "}; + protected static final String[] arrowChars = new String[] {"=>", " - "}; protected MapActivity mapActivity; protected MapContextMenu mapContextMenu; @@ -254,7 +239,7 @@ public class MenuBuilder { protected boolean needBuildPlainMenuItems() { return true; } - + protected boolean needBuildCoordinatesRow() { return true; } @@ -282,7 +267,7 @@ public class MenuBuilder { protected void buildNearestWikiRow(View view) { if (processNearestWiki() && nearestWiki.size() > 0) { - buildRow(view, R.drawable.ic_action_wikipedia, null, app.getString(R.string.wiki_around) + " (" + nearestWiki.size()+")", 0, + buildRow(view, R.drawable.ic_action_wikipedia, null, app.getString(R.string.wiki_around) + " (" + nearestWiki.size() + ")", 0, true, getCollapsableWikiView(view.getContext(), true), false, 0, false, null, false); } @@ -296,7 +281,14 @@ public class MenuBuilder { boolean needUpdateOnly = onlinePhotoCardsRow != null && onlinePhotoCardsRow.getMenuBuilder() == this; onlinePhotoCardsRow = new CardsRowBuilder(this, view, false); onlinePhotoCardsRow.build(); - CollapsableView collapsableView = new CollapsableView(onlinePhotoCardsRow.getContentView(), this, + LinearLayout parent = new LinearLayout(view.getContext()); + parent.setLayoutParams( + new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, + LinearLayout.LayoutParams.WRAP_CONTENT)); + parent.setOrientation(LinearLayout.VERTICAL); + parent.addView(onlinePhotoCardsRow.getContentView()); + parent.addView(createAddPhotoButton(view.getContext())); + CollapsableView collapsableView = new CollapsableView(parent, this, app.getSettings().ONLINE_PHOTOS_ROW_COLLAPSED); collapsableView.setCollapseExpandListener(new CollapseExpandListener() { @Override @@ -316,15 +308,46 @@ public class MenuBuilder { } } + private View createAddPhotoButton(Context context) { + TextView b = new TextView(context); + b.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View view) { + mapActivity.getSupportFragmentManager().beginTransaction() + .add(R.id.fragmentContainer, new OprStartFragment(), "OPR_REGISTER_FRAGMENT") + .addToBackStack(null).commit(); + } + }); + b.setTypeface(FontCache.getRobotoRegular(context)); + Drawable d = ContextCompat.getDrawable(context, R.drawable.ic_sample); + b.setCompoundDrawablesWithIntrinsicBounds(d, null, null, null); + LinearLayout.LayoutParams params = new + LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, + LinearLayout.LayoutParams.WRAP_CONTENT); + int dp16 = AndroidUtils.dpToPx(context, 16f); + int dp8 = AndroidUtils.dpToPx(context, 8f); + params.setMargins(dp16, 0, dp16, dp16); + b.setPadding(dp8, dp8, dp16, dp8); + b.setTextAlignment(View.TEXT_ALIGNMENT_CENTER); + b.setLayoutParams(params); + b.setCompoundDrawablePadding(dp8); + b.setGravity(Gravity.CENTER_VERTICAL); + b.setTypeface(null, Typeface.BOLD); + b.setText(context.getResources().getString(R.string.shared_string_add_photo)); + b.setBackgroundResource(R.drawable.btn_border_light); + b.setTextColor(ContextCompat.getColor(context,R.color.preference_category_title)); + return b; + } + private void buildCoordinatesRow(View view) { Map locationData = PointDescription.getLocationData(mapActivity, latLon.getLatitude(), latLon.getLongitude(), true); String title = locationData.get(PointDescription.LOCATION_LIST_HEADER); locationData.remove(PointDescription.LOCATION_LIST_HEADER); CollapsableView cv = getLocationCollapsableView(locationData); buildRow(view, R.drawable.ic_action_get_my_location, null, title, 0, true, cv, false, 1, - false, null, false); + false, null, false); } - + private void startLoadingImages() { if (onlinePhotoCardsRow == null) { return; @@ -379,7 +402,7 @@ public class MenuBuilder { } } - protected void buildDescription(View view){ + protected void buildDescription(View view) { } protected void buildAfter(View view) { @@ -395,8 +418,8 @@ public class MenuBuilder { } public View buildRow(View view, int iconId, String buttonText, String text, int textColor, - boolean collapsable, final CollapsableView collapsableView, - boolean needLinks, int textLinesLimit, boolean isUrl, OnClickListener onClickListener, boolean matchWidthDivider) { + boolean collapsable, final CollapsableView collapsableView, + boolean needLinks, int textLinesLimit, boolean isUrl, OnClickListener onClickListener, boolean matchWidthDivider) { return buildRow(view, iconId == 0 ? null : getRowIcon(iconId), buttonText, text, textColor, null, collapsable, collapsableView, needLinks, textLinesLimit, isUrl, onClickListener, matchWidthDivider); } @@ -480,7 +503,7 @@ public class MenuBuilder { textPrefixView.setLayoutParams(llTextParams); textPrefixView.setTypeface(FontCache.getRobotoRegular(view.getContext())); textPrefixView.setTextSize(12); - textPrefixView.setTextColor(app.getResources().getColor(light ? R.color.text_color_secondary_light: R.color.text_color_secondary_dark)); + textPrefixView.setTextColor(app.getResources().getColor(light ? R.color.text_color_secondary_light : R.color.text_color_secondary_dark)); textPrefixView.setMinLines(1); textPrefixView.setMaxLines(1); textPrefixView.setText(textPrefix); @@ -526,7 +549,7 @@ public class MenuBuilder { textViewSecondary.setLayoutParams(llTextSecondaryParams); textViewSecondary.setTypeface(FontCache.getRobotoRegular(view.getContext())); textViewSecondary.setTextSize(14); - textViewSecondary.setTextColor(app.getResources().getColor(light ? R.color.text_color_secondary_light: R.color.text_color_secondary_dark)); + textViewSecondary.setTextColor(app.getResources().getColor(light ? R.color.text_color_secondary_light : R.color.text_color_secondary_dark)); textViewSecondary.setText(secondaryText); llText.addView(textViewSecondary); } @@ -581,7 +604,7 @@ public class MenuBuilder { } if (collapsableView.getContentView().getParent() != null) { ((ViewGroup) collapsableView.getContentView().getParent()) - .removeView(collapsableView.getContentView()); + .removeView(collapsableView.getContentView()); } baseView.addView(collapsableView.getContentView()); } @@ -682,7 +705,7 @@ public class MenuBuilder { ssb.append("UTM: "); } else if (line.getKey() == OsmAndFormatter.MGRS_FORMAT) { ssb.append("MGRS: "); - } else if (line.getKey() == OsmAndFormatter.OLC_FORMAT){ + } else if (line.getKey() == OsmAndFormatter.OLC_FORMAT) { ssb.append("OLC: "); } ssb.setSpan(new ForegroundColorSpan(app.getResources().getColor(R.color.text_color_secondary_light)), 0, 4, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); @@ -747,8 +770,8 @@ public class MenuBuilder { } public void addPlainMenuItem(int iconId, String text, boolean needLinks, boolean isUrl, - boolean collapsable, CollapsableView collapsableView, - OnClickListener onClickListener) { + boolean collapsable, CollapsableView collapsableView, + OnClickListener onClickListener) { plainMenuItems.add(new PlainMenuItem(iconId, null, text, needLinks, isUrl, collapsable, collapsableView, onClickListener)); } @@ -970,7 +993,7 @@ public class MenuBuilder { button.setTypeface(FontCache.getRobotoRegular(context)); int bg; if (selected) { - bg = light ? R.drawable.context_menu_controller_bg_light_selected: R.drawable.context_menu_controller_bg_dark_selected; + bg = light ? R.drawable.context_menu_controller_bg_light_selected : R.drawable.context_menu_controller_bg_dark_selected; } else if (showAll) { bg = light ? R.drawable.context_menu_controller_bg_light_show_all : R.drawable.context_menu_controller_bg_dark_show_all; } else { @@ -1027,7 +1050,7 @@ public class MenuBuilder { private List getAmenities(QuadRect rect, PoiUIFilter wikiPoiFilter) { return wikiPoiFilter.searchAmenities(rect.top, rect.left, - rect.bottom, rect.right, -1, null); + rect.bottom, rect.right, -1, null); } @SuppressWarnings("unchecked") diff --git a/OsmAnd/src/net/osmand/plus/openplacereviews/OprStartFragment.java b/OsmAnd/src/net/osmand/plus/openplacereviews/OprStartFragment.java new file mode 100644 index 0000000000..98d4a83815 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/openplacereviews/OprStartFragment.java @@ -0,0 +1,19 @@ +package net.osmand.plus.openplacereviews; + +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import net.osmand.plus.R; +import net.osmand.plus.base.BaseOsmAndFragment; + +public class OprStartFragment extends BaseOsmAndFragment { + + @Override + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + View v = inflater.inflate(R.layout.fragment_opr_login, container, false); + return v; + } +} From 221d28567f84b3f496727bd65c5b90bc50c82787 Mon Sep 17 00:00:00 2001 From: simon Date: Wed, 11 Nov 2020 17:35:32 +0200 Subject: [PATCH 2/9] opr login changed --- OsmAnd/res/layout/fragment_opr_login.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/OsmAnd/res/layout/fragment_opr_login.xml b/OsmAnd/res/layout/fragment_opr_login.xml index 656da83538..8352d5444f 100644 --- a/OsmAnd/res/layout/fragment_opr_login.xml +++ b/OsmAnd/res/layout/fragment_opr_login.xml @@ -17,6 +17,7 @@ android:layout_height="match_parent" android:layout_gravity="start" android:contentDescription="@string/shared_string_back" + app:tint="@color/color_black" app:srcCompat="@drawable/ic_arrow_back"/> @@ -55,6 +56,7 @@ android:textColorLink="@color/icon_color_active_light" android:layout_marginRight="16dp" android:autoLink="all" + android:text="@string/register_on_openplacereviews_desc"/> Date: Thu, 12 Nov 2020 15:42:46 +0200 Subject: [PATCH 3/9] opr start page --- OsmAnd/AndroidManifest.xml | 1 + OsmAnd/build.gradle | 2 + OsmAnd/res/layout/activity_opr_webview.xml | 34 +++++++ OsmAnd/res/layout/fragment_opr_login.xml | 5 +- .../openplacereviews/OPRWebviewActivity.java | 94 +++++++++++++++++++ .../openplacereviews/OprStartFragment.java | 25 +++++ 6 files changed, 159 insertions(+), 2 deletions(-) create mode 100644 OsmAnd/res/layout/activity_opr_webview.xml create mode 100644 OsmAnd/src/net/osmand/plus/openplacereviews/OPRWebviewActivity.java diff --git a/OsmAnd/AndroidManifest.xml b/OsmAnd/AndroidManifest.xml index 54442ccbf2..85235f8647 100644 --- a/OsmAnd/AndroidManifest.xml +++ b/OsmAnd/AndroidManifest.xml @@ -66,6 +66,7 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/layout/fragment_opr_login.xml b/OsmAnd/res/layout/fragment_opr_login.xml index 8352d5444f..5decb55147 100644 --- a/OsmAnd/res/layout/fragment_opr_login.xml +++ b/OsmAnd/res/layout/fragment_opr_login.xml @@ -8,7 +8,8 @@ + android:layout_height="56dp" + android:layout_marginTop="24dp"> findViewById(R.id.toolbar)); + if (b != null) { + String title = b.getString(KEY_TITLE, ""); + this.findViewById(R.id.toolbar_text).setText(title); + } + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + final Drawable upArrow = ContextCompat.getDrawable(this, R.drawable.ic_arrow_back); + upArrow.setColorFilter(ContextCompat.getColor(this, R.color.color_favorite_gray), PorterDuff.Mode.SRC_ATOP); + getSupportActionBar().setHomeAsUpIndicator(upArrow); + webView = (WebView) findViewById(R.id.printDialogWebview); + webView.getSettings().setJavaScriptEnabled(true); + WebView.setWebContentsDebuggingEnabled(true); + if (b != null){ + if (b.getBoolean(KEY_LOGIN)){ + webView.loadUrl(loginUrl); + } + else { + webView.loadUrl(registerUrl); + } + } + } + + @Override + public boolean onSupportNavigateUp() { + onBackPressed(); + return true; + } + + public static String getPrivateKeyFromCookie() { + return returnCookieByKey("opr-token"); + } + + public static String getUsernameFromCookie() { + return returnCookieByKey("opr-nickname"); + } + + private static String returnCookieByKey(String key) { + String CookieValue = null; + CookieManager cookieManager = CookieManager.getInstance(); + String cookies = cookieManager.getCookie(cookieUrl); + if (cookies == null || cookies.isEmpty()) { + return ""; + } + String[] temp = cookies.split(";"); + for (String ar1 : temp) { + if (ar1.contains(key)) { + String[] temp1 = ar1.split("="); + CookieValue = temp1[1]; + break; + } + } + return CookieValue; + } + + @Override + protected void onDestroy() { + super.onDestroy(); + } +} \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/openplacereviews/OprStartFragment.java b/OsmAnd/src/net/osmand/plus/openplacereviews/OprStartFragment.java index 98d4a83815..b4f66b1c65 100644 --- a/OsmAnd/src/net/osmand/plus/openplacereviews/OprStartFragment.java +++ b/OsmAnd/src/net/osmand/plus/openplacereviews/OprStartFragment.java @@ -1,5 +1,6 @@ package net.osmand.plus.openplacereviews; +import android.content.Intent; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; @@ -14,6 +15,30 @@ public class OprStartFragment extends BaseOsmAndFragment { @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View v = inflater.inflate(R.layout.fragment_opr_login, container, false); + v.findViewById(R.id.register_opr_create_account).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Intent i = new Intent(requireContext(),OPRWebviewActivity.class); + i.putExtra(OPRWebviewActivity.KEY_TITLE,getString(R.string.register_opr_create_new_account)); + i.putExtra(OPRWebviewActivity.KEY_LOGIN,false); + startActivity(i); + } + }); + v.findViewById(R.id.back_button).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + getActivity().getSupportFragmentManager().popBackStack(); + } + }); + v.findViewById(R.id.register_opr_have_account).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Intent i = new Intent(requireContext(),OPRWebviewActivity.class); + i.putExtra(OPRWebviewActivity.KEY_TITLE,getString(R.string.user_login)); + i.putExtra(OPRWebviewActivity.KEY_LOGIN,true); + startActivity(i); + } + }); return v; } } From 3b44211bf4900f5546b9f1b983894bf51d1c688b Mon Sep 17 00:00:00 2001 From: simon Date: Thu, 12 Nov 2020 18:35:41 +0200 Subject: [PATCH 4/9] webview closing --- .../openplacereviews/OPRWebviewActivity.java | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/openplacereviews/OPRWebviewActivity.java b/OsmAnd/src/net/osmand/plus/openplacereviews/OPRWebviewActivity.java index 180abda83d..48fc356a25 100644 --- a/OsmAnd/src/net/osmand/plus/openplacereviews/OPRWebviewActivity.java +++ b/OsmAnd/src/net/osmand/plus/openplacereviews/OPRWebviewActivity.java @@ -1,15 +1,13 @@ package net.osmand.plus.openplacereviews; -import android.content.Context; import android.graphics.PorterDuff; -import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; import android.os.Bundle; -import android.view.View; import android.webkit.CookieManager; +import android.webkit.WebResourceRequest; import android.webkit.WebView; -import android.widget.ImageView; +import android.webkit.WebViewClient; import android.widget.TextView; import androidx.appcompat.widget.Toolbar; import androidx.core.content.ContextCompat; @@ -26,8 +24,10 @@ public class OPRWebviewActivity extends OsmandActionBarActivity { private static final String cookieUrl = BuildConfig.OPR_BASE_URL + "profile"; private static final String loginUrl = BuildConfig.OPR_BASE_URL + "login"; private static final String registerUrl = BuildConfig.OPR_BASE_URL + "signup"; + private static final String finishUrl = cookieUrl; public static String KEY_TITLE = "TITLE_KEY"; private final Log log = PlatformUtil.getLog(OPRWebviewActivity.class); + private boolean isRegister = false; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -43,13 +43,14 @@ public class OPRWebviewActivity extends OsmandActionBarActivity { upArrow.setColorFilter(ContextCompat.getColor(this, R.color.color_favorite_gray), PorterDuff.Mode.SRC_ATOP); getSupportActionBar().setHomeAsUpIndicator(upArrow); webView = (WebView) findViewById(R.id.printDialogWebview); + webView.setWebViewClient(new CloseOnSuccessWebViewClient()); webView.getSettings().setJavaScriptEnabled(true); WebView.setWebContentsDebuggingEnabled(true); - if (b != null){ - if (b.getBoolean(KEY_LOGIN)){ + if (b != null) { + isRegister = b.getBoolean(KEY_LOGIN); + if (isRegister) { webView.loadUrl(loginUrl); - } - else { + } else { webView.loadUrl(registerUrl); } } @@ -87,8 +88,13 @@ public class OPRWebviewActivity extends OsmandActionBarActivity { return CookieValue; } - @Override - protected void onDestroy() { - super.onDestroy(); + public class CloseOnSuccessWebViewClient extends WebViewClient { + @Override + public void onPageFinished(WebView view, String url) { + if (url.contains(finishUrl) && !isRegister) { + finish(); + } + super.onPageFinished(view, url); + } } } \ No newline at end of file From 275cc58e8a518bd4d52d5641493ed9d04e437c13 Mon Sep 17 00:00:00 2001 From: simon Date: Fri, 13 Nov 2020 13:06:26 +0200 Subject: [PATCH 5/9] small changes --- OsmAnd/res/layout/fragment_opr_login.xml | 2 +- .../openplacereviews/OPRWebviewActivity.java | 9 ++-- .../openplacereviews/OprStartFragment.java | 43 ++++++++++++++++--- 3 files changed, 42 insertions(+), 12 deletions(-) diff --git a/OsmAnd/res/layout/fragment_opr_login.xml b/OsmAnd/res/layout/fragment_opr_login.xml index 5decb55147..9cfb97a1e3 100644 --- a/OsmAnd/res/layout/fragment_opr_login.xml +++ b/OsmAnd/res/layout/fragment_opr_login.xml @@ -3,6 +3,7 @@ android:background="@color/color_white" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:orientation="vertical" + android:clickable="true" android:layout_width="match_parent" android:layout_height="match_parent"> @@ -57,7 +58,6 @@ android:textColor="@color/color_black" android:textColorLink="@color/icon_color_active_light" android:layout_marginRight="16dp" - android:autoLink="all" android:text="@string/register_on_openplacereviews_desc"/> findViewById(R.id.start_opr_description).setText(ss); + v.findViewById(R.id.start_opr_description).setMovementMethod(LinkMovementMethod.getInstance()); + } + + + private class URLSpanNoUnderline extends URLSpan { + public URLSpanNoUnderline(String url) { + super(url); + } + + @Override + public void updateDrawState(TextPaint ds) { + super.updateDrawState(ds); + ds.setUnderlineText(false); + } + } + } From ce648cb1db3be649107d335ebf86f663bd9c864d Mon Sep 17 00:00:00 2001 From: simon Date: Fri, 13 Nov 2020 13:13:38 +0200 Subject: [PATCH 6/9] style issues fix --- OsmAnd/res/layout/activity_opr_webview.xml | 1 - OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java | 7 +++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/OsmAnd/res/layout/activity_opr_webview.xml b/OsmAnd/res/layout/activity_opr_webview.xml index e337e83c41..9d3f28c67a 100644 --- a/OsmAnd/res/layout/activity_opr_webview.xml +++ b/OsmAnd/res/layout/activity_opr_webview.xml @@ -1,6 +1,5 @@ Date: Fri, 13 Nov 2020 16:54:10 +0200 Subject: [PATCH 7/9] issue fix --- OsmAnd/res/layout/fragment_opr_login.xml | 34 +++++++++---------- OsmAnd/res/values/strings.xml | 1 - .../plus/mapcontextmenu/MenuBuilder.java | 4 +-- .../openplacereviews/OPRWebviewActivity.java | 8 ++--- .../openplacereviews/OprStartFragment.java | 20 ++++++++++- 5 files changed, 40 insertions(+), 27 deletions(-) diff --git a/OsmAnd/res/layout/fragment_opr_login.xml b/OsmAnd/res/layout/fragment_opr_login.xml index 9cfb97a1e3..dae5934805 100644 --- a/OsmAnd/res/layout/fragment_opr_login.xml +++ b/OsmAnd/res/layout/fragment_opr_login.xml @@ -10,11 +10,11 @@ + android:layout_marginTop="@dimen/dialog_content_margin"> @@ -52,38 +52,38 @@ android:id="@+id/start_opr_description" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginTop="6dp" - android:layout_marginLeft="16dp" + android:layout_marginTop="@dimen/dashPadding" + android:layout_marginLeft="@dimen/content_padding" android:lineSpacingExtra="5sp" android:textColor="@color/color_black" android:textColorLink="@color/icon_color_active_light" - android:layout_marginRight="16dp" + android:layout_marginRight="@dimen/content_padding" android:text="@string/register_on_openplacereviews_desc"/> Enter tags separated by comma. Send GPX file to OpenStreetMap Markers history ->>>>>>> fd85ed7c4201db81b3fbbea71aebfb0155066129 OsmAnd Live subscription is on hold OsmAnd Live subscription has been paused OsmAnd Live subscription has been expired diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java index b4e30f7771..45c4864a2a 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java @@ -316,9 +316,7 @@ public class MenuBuilder { b.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { - mapActivity.getSupportFragmentManager().beginTransaction() - .add(R.id.fragmentContainer, new OprStartFragment(), "OPR_REGISTER_FRAGMENT") - .addToBackStack(null).commit(); + OprStartFragment.showInstance(mapActivity.getSupportFragmentManager()); } }); b.setTypeface(FontCache.getRobotoRegular(context)); diff --git a/OsmAnd/src/net/osmand/plus/openplacereviews/OPRWebviewActivity.java b/OsmAnd/src/net/osmand/plus/openplacereviews/OPRWebviewActivity.java index ddbc32ad9a..ebcf32e4ec 100644 --- a/OsmAnd/src/net/osmand/plus/openplacereviews/OPRWebviewActivity.java +++ b/OsmAnd/src/net/osmand/plus/openplacereviews/OPRWebviewActivity.java @@ -10,22 +10,20 @@ import android.webkit.WebViewClient; import android.widget.TextView; import androidx.appcompat.widget.Toolbar; import androidx.core.content.ContextCompat; -import net.osmand.PlatformUtil; +import net.osmand.AndroidUtils; import net.osmand.plus.BuildConfig; import net.osmand.plus.R; import net.osmand.plus.activities.OsmandActionBarActivity; -import org.apache.commons.logging.Log; public class OPRWebviewActivity extends OsmandActionBarActivity { public static final String KEY_LOGIN = "LOGIN_KEY"; - private WebView webView; private static final String url = BuildConfig.OPR_BASE_URL; private static final String cookieUrl = BuildConfig.OPR_BASE_URL + "profile"; private static final String loginUrl = BuildConfig.OPR_BASE_URL + "login"; private static final String registerUrl = BuildConfig.OPR_BASE_URL + "signup"; private static final String finishUrl = cookieUrl; public static String KEY_TITLE = "TITLE_KEY"; - private final Log log = PlatformUtil.getLog(OPRWebviewActivity.class); + private WebView webView; private boolean isLogin = false; public void onCreate(Bundle savedInstanceState) { @@ -38,7 +36,7 @@ public class OPRWebviewActivity extends OsmandActionBarActivity { this.findViewById(R.id.toolbar_text).setText(title); } getSupportActionBar().setDisplayHomeAsUpEnabled(true); - final Drawable upArrow = ContextCompat.getDrawable(this, R.drawable.ic_arrow_back); + final Drawable upArrow = getMyApplication().getUIUtilities().getIcon(AndroidUtils.getNavigationIconResId(this)); upArrow.setColorFilter(ContextCompat.getColor(this, R.color.color_favorite_gray), PorterDuff.Mode.SRC_ATOP); getSupportActionBar().setHomeAsUpIndicator(upArrow); webView = (WebView) findViewById(R.id.printDialogWebview); diff --git a/OsmAnd/src/net/osmand/plus/openplacereviews/OprStartFragment.java b/OsmAnd/src/net/osmand/plus/openplacereviews/OprStartFragment.java index 2f32233886..eecd0c3f32 100644 --- a/OsmAnd/src/net/osmand/plus/openplacereviews/OprStartFragment.java +++ b/OsmAnd/src/net/osmand/plus/openplacereviews/OprStartFragment.java @@ -13,11 +13,16 @@ import android.view.ViewGroup; import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.fragment.app.FragmentManager; +import net.osmand.PlatformUtil; import net.osmand.plus.R; import net.osmand.plus.base.BaseOsmAndFragment; +import org.apache.commons.logging.Log; public class OprStartFragment extends BaseOsmAndFragment { - private static String openPlaceReviewsUrl = "OpenPlaceReviews.org"; + private static final String TAG = "fragment_oprstart"; + private static final Log LOG = PlatformUtil.getLog(OprStartFragment.class); + private static final String openPlaceReviewsUrl = "OpenPlaceReviews.org"; @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { @@ -72,4 +77,17 @@ public class OprStartFragment extends BaseOsmAndFragment { } } + + public static void showInstance(@NonNull FragmentManager fm) { + try { + if (fm.findFragmentByTag(OprStartFragment.TAG) == null) { + OprStartFragment fragment = new OprStartFragment(); + fm.beginTransaction() + .add(R.id.fragmentContainer, fragment, OprStartFragment.TAG) + .addToBackStack(null).commit(); + } + } catch (RuntimeException e) { + LOG.error("showInstance", e); + } + } } From b93e7011dd3b32df962aed01be91cc849ca1d8ac Mon Sep 17 00:00:00 2001 From: simon Date: Fri, 13 Nov 2020 16:58:42 +0200 Subject: [PATCH 8/9] fixes --- OsmAnd/res/layout/fragment_opr_login.xml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/OsmAnd/res/layout/fragment_opr_login.xml b/OsmAnd/res/layout/fragment_opr_login.xml index dae5934805..c9f3c33980 100644 --- a/OsmAnd/res/layout/fragment_opr_login.xml +++ b/OsmAnd/res/layout/fragment_opr_login.xml @@ -12,9 +12,9 @@ android:layout_height="56dp" android:layout_marginTop="@dimen/dialog_content_margin"> - - Date: Fri, 13 Nov 2020 17:02:23 +0200 Subject: [PATCH 9/9] fixes --- OsmAnd/res/layout/fragment_opr_login.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/res/layout/fragment_opr_login.xml b/OsmAnd/res/layout/fragment_opr_login.xml index c9f3c33980..3313679aec 100644 --- a/OsmAnd/res/layout/fragment_opr_login.xml +++ b/OsmAnd/res/layout/fragment_opr_login.xml @@ -19,7 +19,7 @@ android:layout_height="match_parent" android:layout_gravity="start" android:contentDescription="@string/shared_string_back" - app:tint="@color/color_black" + app:tint="@color/icon_color_default_light" app:srcCompat="@drawable/ic_arrow_back"/>