From 53a3b24c6ccb6e73160dfc04046614aaa08e0497 Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Mon, 23 Nov 2020 12:04:10 +0200 Subject: [PATCH] Fix add point button --- OsmAnd/res/layout/activity_opr_webview.xml | 12 +++--- .../plus/mapcontextmenu/MenuBuilder.java | 42 ++++++++++--------- .../openplacereviews/OPRWebviewActivity.java | 40 +++++++++++++----- .../openplacereviews/OprStartFragment.java | 3 +- 4 files changed, 58 insertions(+), 39 deletions(-) diff --git a/OsmAnd/res/layout/activity_opr_webview.xml b/OsmAnd/res/layout/activity_opr_webview.xml index 9d3f28c67a..9e32d56df4 100644 --- a/OsmAnd/res/layout/activity_opr_webview.xml +++ b/OsmAnd/res/layout/activity_opr_webview.xml @@ -1,25 +1,23 @@ + android:layout_height="@dimen/toolbar_height"> diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java index 67f53b96ea..6e8a8f0c67 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java @@ -311,35 +311,37 @@ public class MenuBuilder { } } - private View createAddPhotoButton(Context context) { - TextView b = new TextView(context); - b.setOnClickListener(new OnClickListener() { + private View createAddPhotoButton(Context ctx) { + boolean nightMode = getApplication().getDaynightHelper().isNightModeForMapControls(); + View view = UiUtilities.getInflater(app, nightMode).inflate(R.layout.bottom_sheet_dialog_button, null); + LinearLayout buttonLayout = new LinearLayout(ctx); + view.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { AddPhotosBottomSheetDialogFragment.showInstance(mapActivity.getSupportFragmentManager()); } }); - b.setTypeface(FontCache.getRobotoRegular(context)); - Drawable d = ContextCompat.getDrawable(context, R.drawable.ic_sample); - b.setCompoundDrawablesWithIntrinsicBounds(d, null, null, null); + int dp6 = ctx.getResources().getDimensionPixelSize(R.dimen.bottom_sheet_title_padding_bottom); + int dp8 = ctx.getResources().getDimensionPixelSize(R.dimen.content_padding_half); + int dp12 = ctx.getResources().getDimensionPixelSize(R.dimen.content_padding_small); + int dp16 = ctx.getResources().getDimensionPixelSize(R.dimen.content_padding); + view.findViewById(R.id.button_text).setPadding(dp8, 0, dp16, 0); + ((TextView) view.findViewById(R.id.button_text)).setCompoundDrawablePadding(0); 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); + params.setMargins(dp16, 0, dp12, dp16); + buttonLayout.setLayoutParams(params); + LinearLayout.LayoutParams buttonParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, + ctx.getResources().getDimensionPixelSize(R.dimen.dialog_button_height)); + view.setLayoutParams(buttonParams); + buttonLayout.addView(view); + UiUtilities.setupDialogButton(nightMode, buttonLayout, UiUtilities.DialogButtonType.STROKED, + ctx.getString(R.string.shared_string_add_photo), R.drawable.ic_sample); + ((TextView) view.findViewById(R.id.button_text)).setCompoundDrawablePadding(dp6); //TODO This feature is under development - b.setVisibility(View.VISIBLE); - b.setTextColor(ContextCompat.getColor(context, R.color.preference_category_title)); - return b; + buttonLayout.setVisibility(View.VISIBLE); + return buttonLayout; } private void buildCoordinatesRow(View view) { diff --git a/OsmAnd/src/net/osmand/plus/openplacereviews/OPRWebviewActivity.java b/OsmAnd/src/net/osmand/plus/openplacereviews/OPRWebviewActivity.java index ebcf32e4ec..236c9ab5ae 100644 --- a/OsmAnd/src/net/osmand/plus/openplacereviews/OPRWebviewActivity.java +++ b/OsmAnd/src/net/osmand/plus/openplacereviews/OPRWebviewActivity.java @@ -2,8 +2,10 @@ package net.osmand.plus.openplacereviews; 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.WebView; import android.webkit.WebViewClient; @@ -12,8 +14,10 @@ import androidx.appcompat.widget.Toolbar; import androidx.core.content.ContextCompat; import net.osmand.AndroidUtils; import net.osmand.plus.BuildConfig; +import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.activities.OsmandActionBarActivity; +import net.osmand.plus.settings.backend.OsmandSettings; public class OPRWebviewActivity extends OsmandActionBarActivity { public static final String KEY_LOGIN = "LOGIN_KEY"; @@ -27,24 +31,38 @@ public class OPRWebviewActivity extends OsmandActionBarActivity { private boolean isLogin = false; public void onCreate(Bundle savedInstanceState) { + OsmandApplication app = getMyApplication(); + OsmandSettings settings = app.getSettings(); + boolean nightMode = !settings.isLightContent(); + int themeId = nightMode ? R.style.OsmandDarkTheme_NoActionbar : R.style.OsmandLightTheme_NoActionbar_LightStatusBar; + setTheme(themeId); super.onCreate(savedInstanceState); setContentView(R.layout.activity_opr_webview); - Bundle b = getIntent().getExtras(); - setSupportActionBar(this.findViewById(R.id.toolbar)); - if (b != null) { - String title = b.getString(KEY_TITLE, ""); - this.findViewById(R.id.toolbar_text).setText(title); + Bundle bundle = getIntent().getExtras(); + Toolbar toolbar = findViewById(R.id.toolbar); + if (bundle != null) { + TextView titleView = findViewById(R.id.toolbar_text); + String title = bundle.getString(KEY_TITLE, ""); + titleView.setText(title); } - getSupportActionBar().setDisplayHomeAsUpEnabled(true); - final Drawable upArrow = getMyApplication().getUIUtilities().getIcon(AndroidUtils.getNavigationIconResId(this)); + ColorDrawable colorDrawable = new ColorDrawable(AndroidUtils.getColorFromAttr(app, R.attr.bg_color)); + toolbar.setBackgroundDrawable(colorDrawable); + final Drawable upArrow = app.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); + toolbar.setNavigationIcon(upArrow); + toolbar.setNavigationContentDescription(R.string.access_shared_string_navigate_up); + toolbar.setNavigationOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + onBackPressed(); + } + }); + webView = findViewById(R.id.printDialogWebview); webView.setWebViewClient(new CloseOnSuccessWebViewClient()); webView.getSettings().setJavaScriptEnabled(true); WebView.setWebContentsDebuggingEnabled(true); - if (b != null) { - isLogin = b.getBoolean(KEY_LOGIN); + if (bundle != null) { + isLogin = bundle.getBoolean(KEY_LOGIN); if (isLogin) { webView.loadUrl(loginUrl); } else { diff --git a/OsmAnd/src/net/osmand/plus/openplacereviews/OprStartFragment.java b/OsmAnd/src/net/osmand/plus/openplacereviews/OprStartFragment.java index 19a4ba57be..f03d76e39d 100644 --- a/OsmAnd/src/net/osmand/plus/openplacereviews/OprStartFragment.java +++ b/OsmAnd/src/net/osmand/plus/openplacereviews/OprStartFragment.java @@ -33,7 +33,8 @@ public class OprStartFragment extends BaseOsmAndFragment { @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { boolean nightMode = getMyApplication().getDaynightHelper().isNightModeForMapControls(); - View v = inflater.inflate(R.layout.fragment_opr_login, container, false); + View v = UiUtilities.getInflater(requireMyActivity(), nightMode).inflate(R.layout.fragment_opr_login, container, + false); View createAccount = v.findViewById(R.id.register_opr_create_account); v.findViewById(R.id.back_button).setOnClickListener(new View.OnClickListener() { @Override