small changes
This commit is contained in:
parent
3b44211bf4
commit
275cc58e8a
3 changed files with 42 additions and 12 deletions
|
@ -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"/>
|
||||
|
||||
<LinearLayout
|
||||
|
|
|
@ -5,7 +5,6 @@ import android.graphics.PorterDuff;
|
|||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.webkit.CookieManager;
|
||||
import android.webkit.WebResourceRequest;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.TextView;
|
||||
|
@ -27,7 +26,7 @@ public class OPRWebviewActivity extends OsmandActionBarActivity {
|
|||
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;
|
||||
private boolean isLogin = false;
|
||||
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
@ -47,8 +46,8 @@ public class OPRWebviewActivity extends OsmandActionBarActivity {
|
|||
webView.getSettings().setJavaScriptEnabled(true);
|
||||
WebView.setWebContentsDebuggingEnabled(true);
|
||||
if (b != null) {
|
||||
isRegister = b.getBoolean(KEY_LOGIN);
|
||||
if (isRegister) {
|
||||
isLogin = b.getBoolean(KEY_LOGIN);
|
||||
if (isLogin) {
|
||||
webView.loadUrl(loginUrl);
|
||||
} else {
|
||||
webView.loadUrl(registerUrl);
|
||||
|
@ -91,7 +90,7 @@ public class OPRWebviewActivity extends OsmandActionBarActivity {
|
|||
public class CloseOnSuccessWebViewClient extends WebViewClient {
|
||||
@Override
|
||||
public void onPageFinished(WebView view, String url) {
|
||||
if (url.contains(finishUrl) && !isRegister) {
|
||||
if (url.contains(finishUrl) && isLogin) {
|
||||
finish();
|
||||
}
|
||||
super.onPageFinished(view, url);
|
||||
|
|
|
@ -2,15 +2,22 @@ package net.osmand.plus.openplacereviews;
|
|||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.SpannableString;
|
||||
import android.text.Spanned;
|
||||
import android.text.TextPaint;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.text.style.URLSpan;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.base.BaseOsmAndFragment;
|
||||
|
||||
public class OprStartFragment extends BaseOsmAndFragment {
|
||||
private static String openPlaceReviewsUrl = "OpenPlaceReviews.org";
|
||||
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
|
@ -18,9 +25,9 @@ public class OprStartFragment extends BaseOsmAndFragment {
|
|||
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);
|
||||
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);
|
||||
}
|
||||
});
|
||||
|
@ -33,12 +40,36 @@ public class OprStartFragment extends BaseOsmAndFragment {
|
|||
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);
|
||||
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);
|
||||
}
|
||||
});
|
||||
setURLSpan(v);
|
||||
return v;
|
||||
}
|
||||
|
||||
private void setURLSpan(View v) {
|
||||
String desc = requireContext().getString(R.string.register_on_openplacereviews_desc);
|
||||
SpannableString ss = new SpannableString(desc);
|
||||
ss.setSpan(new URLSpanNoUnderline("https://" + openPlaceReviewsUrl), desc.indexOf(openPlaceReviewsUrl),
|
||||
desc.indexOf(openPlaceReviewsUrl) + openPlaceReviewsUrl.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
|
||||
v.<TextView>findViewById(R.id.start_opr_description).setText(ss);
|
||||
v.<TextView>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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue