From 53a3b24c6ccb6e73160dfc04046614aaa08e0497 Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Mon, 23 Nov 2020 12:04:10 +0200 Subject: [PATCH 01/10] 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 From 671db0c84abb12439cbf9e210458d950220519ad Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Mon, 23 Nov 2020 16:50:59 +0200 Subject: [PATCH 02/10] Refactoring --- .../net/osmand/plus/mapcontextmenu/MenuBuilder.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java index 6e8a8f0c67..958af6a0be 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java @@ -325,12 +325,9 @@ public class MenuBuilder { 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 params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); - params.setMargins(dp16, 0, dp12, dp16); + params.setMargins(dp16, 0, dp16, dp12); buttonLayout.setLayoutParams(params); LinearLayout.LayoutParams buttonParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, ctx.getResources().getDimensionPixelSize(R.dimen.dialog_button_height)); @@ -338,7 +335,9 @@ public class MenuBuilder { 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); + TextView textView = view.findViewById(R.id.button_text); + textView.setPadding(dp8, 0, dp16, 0); + textView.setCompoundDrawablePadding(dp6); //TODO This feature is under development buttonLayout.setVisibility(View.VISIBLE); return buttonLayout; From ef9b018011810681e1e533d3fa6281cdfbe4152c Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Mon, 23 Nov 2020 22:57:55 +0200 Subject: [PATCH 03/10] Refactoring --- OsmAnd/res/layout/dialog_button_with_icon.xml | 43 +++++++++++++++++++ OsmAnd/res/values/sizes.xml | 1 + .../plus/mapcontextmenu/MenuBuilder.java | 33 +++++--------- .../openplacereviews/OPRWebviewActivity.java | 2 +- 4 files changed, 56 insertions(+), 23 deletions(-) create mode 100644 OsmAnd/res/layout/dialog_button_with_icon.xml diff --git a/OsmAnd/res/layout/dialog_button_with_icon.xml b/OsmAnd/res/layout/dialog_button_with_icon.xml new file mode 100644 index 0000000000..264f884495 --- /dev/null +++ b/OsmAnd/res/layout/dialog_button_with_icon.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/values/sizes.xml b/OsmAnd/res/values/sizes.xml index 64ab1cc330..c1addc1349 100644 --- a/OsmAnd/res/values/sizes.xml +++ b/OsmAnd/res/values/sizes.xml @@ -249,6 +249,7 @@ 16dp 12dp 8dp + 6dp 8dp 13dp 5dp diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java index 958af6a0be..b6959beca0 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java @@ -22,6 +22,7 @@ import android.view.Gravity; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; +import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; @@ -313,34 +314,22 @@ public class MenuBuilder { 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() { + View view = UiUtilities.getInflater(ctx, nightMode).inflate(R.layout.dialog_button_with_icon, null); + int dp6 = ctx.getResources().getDimensionPixelSize(R.dimen.bottom_sheet_title_padding_bottom); + View button = view.findViewById(R.id.button); + UiUtilities.setupDialogButton(nightMode, button, UiUtilities.DialogButtonType.STROKED, + ctx.getString(R.string.shared_string_add_photo), R.drawable.ic_sample); + TextView textView = view.findViewById(R.id.button_text); + textView.setCompoundDrawablePadding(dp6); + button.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { AddPhotosBottomSheetDialogFragment.showInstance(mapActivity.getSupportFragmentManager()); } }); - 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); - LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, - LinearLayout.LayoutParams.WRAP_CONTENT); - params.setMargins(dp16, 0, dp16, dp12); - 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 textView = view.findViewById(R.id.button_text); - textView.setPadding(dp8, 0, dp16, 0); - textView.setCompoundDrawablePadding(dp6); //TODO This feature is under development - buttonLayout.setVisibility(View.VISIBLE); - return buttonLayout; + view.setVisibility(View.VISIBLE); + return view; } 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 6f97080ffc..293c3b566c 100644 --- a/OsmAnd/src/net/osmand/plus/openplacereviews/OPRWebviewActivity.java +++ b/OsmAnd/src/net/osmand/plus/openplacereviews/OPRWebviewActivity.java @@ -58,7 +58,7 @@ public class OPRWebviewActivity extends OsmandActionBarActivity { String title = bundle.getString(KEY_TITLE, ""); titleView.setText(title); } - ColorDrawable colorDrawable = new ColorDrawable(AndroidUtils.getColorFromAttr(app, R.attr.bg_color)); + ColorDrawable colorDrawable = new ColorDrawable(AndroidUtils.getColorFromAttr(this, 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); From 4a56b6cb2962e9f4309906d2cd9e953879601161 Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Mon, 23 Nov 2020 23:56:01 +0200 Subject: [PATCH 04/10] Fix status bar color --- .../plus/openplacereviews/OPRWebviewActivity.java | 2 ++ .../plus/openplacereviews/OprStartFragment.java | 12 +++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/openplacereviews/OPRWebviewActivity.java b/OsmAnd/src/net/osmand/plus/openplacereviews/OPRWebviewActivity.java index 4205e1e1f5..53c76e5309 100644 --- a/OsmAnd/src/net/osmand/plus/openplacereviews/OPRWebviewActivity.java +++ b/OsmAnd/src/net/osmand/plus/openplacereviews/OPRWebviewActivity.java @@ -53,6 +53,8 @@ public class OPRWebviewActivity extends OsmandActionBarActivity { boolean nightMode = !settings.isLightContent(); int themeId = nightMode ? R.style.OsmandDarkTheme_NoActionbar : R.style.OsmandLightTheme_NoActionbar_LightStatusBar; setTheme(themeId); + getWindow().setStatusBarColor(ContextCompat.getColor(this, nightMode + ? R.color.list_background_color_dark : R.color.list_background_color_light)); super.onCreate(savedInstanceState); setContentView(R.layout.activity_opr_webview); Bundle bundle = getIntent().getExtras(); diff --git a/OsmAnd/src/net/osmand/plus/openplacereviews/OprStartFragment.java b/OsmAnd/src/net/osmand/plus/openplacereviews/OprStartFragment.java index ae04f52622..00aba01997 100644 --- a/OsmAnd/src/net/osmand/plus/openplacereviews/OprStartFragment.java +++ b/OsmAnd/src/net/osmand/plus/openplacereviews/OprStartFragment.java @@ -2,6 +2,7 @@ package net.osmand.plus.openplacereviews; import android.content.Intent; import android.graphics.Typeface; +import android.os.Build; import android.os.Bundle; import android.text.SpannableString; import android.text.Spanned; @@ -26,10 +27,11 @@ public class OprStartFragment extends BaseOsmAndFragment { private static final String TAG = OprStartFragment.class.getSimpleName(); private static final Log LOG = PlatformUtil.getLog(OprStartFragment.class); private static final String openPlaceReviewsUrl = "OpenPlaceReviews.org"; + private boolean nightMode; @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { - boolean nightMode = getMyApplication().getDaynightHelper().isNightModeForMapControls(); + nightMode = getMyApplication().getDaynightHelper().isNightModeForMapControls(); View v = UiUtilities.getInflater(requireMyActivity(), nightMode).inflate(R.layout.fragment_opr_login, container, false); View createAccount = v.findViewById(R.id.register_opr_create_account); @@ -78,6 +80,14 @@ public class OprStartFragment extends BaseOsmAndFragment { v.findViewById(R.id.start_opr_description).setMovementMethod(LinkMovementMethod.getInstance()); } + @Override + public int getStatusBarColorId() { + View view = getView(); + if (view != null && Build.VERSION.SDK_INT >= 23 && !nightMode) { + view.setSystemUiVisibility(view.getSystemUiVisibility() | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); + } + return nightMode ? R.color.list_background_color_dark : R.color.list_background_color_light; + } private class URLSpanNoUnderline extends URLSpan { public URLSpanNoUnderline(String url) { From ed5566d4ea3372218c11e8d0d651bbcde5464314 Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Tue, 24 Nov 2020 14:58:44 +0200 Subject: [PATCH 05/10] Fix "Use dev.openstreetmap.org" should be visible only if "OsmAnd Development" is enabled. --- .../development/OsmandDevelopmentPlugin.java | 9 ++++ .../LoginBottomSheetFragment.java | 3 +- .../plus/osmedit/OsmEditingFragment.java | 41 +++++++++---------- .../plus/osmedit/oauth/OsmOAuthHelper.java | 24 +++++++++++ 4 files changed, 54 insertions(+), 23 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/development/OsmandDevelopmentPlugin.java b/OsmAnd/src/net/osmand/plus/development/OsmandDevelopmentPlugin.java index d7798a646b..e5d7b3e11d 100644 --- a/OsmAnd/src/net/osmand/plus/development/OsmandDevelopmentPlugin.java +++ b/OsmAnd/src/net/osmand/plus/development/OsmandDevelopmentPlugin.java @@ -140,4 +140,13 @@ public class OsmandDevelopmentPlugin extends OsmandPlugin { public DashFragmentData getCardFragment() { return DashSimulateFragment.FRAGMENT_DATA; } + + @Override + public void disable(OsmandApplication app) { + if (app.getSettings().USE_DEV_URL.get()) { + app.getSettings().USE_DEV_URL.set(false); + app.getOsmOAuthHelper().resetAuthorization(); + } + super.disable(app); + } } \ 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 2b50ea6b2f..94ef66beab 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/LoginBottomSheetFragment.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/LoginBottomSheetFragment.java @@ -16,6 +16,7 @@ import net.osmand.PlatformUtil; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.UiUtilities.DialogButtonType; +import net.osmand.plus.activities.MapActivity; import net.osmand.plus.base.MenuBottomSheetDialogFragment; import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem; import net.osmand.plus.osmedit.oauth.OsmOAuthHelper; @@ -90,7 +91,7 @@ public class LoginBottomSheetFragment extends MenuBottomSheetDialogFragment impl View view = getView(); if (view != null) { Fragment fragment = getTargetFragment(); - if (fragment instanceof OsmAuthorizationListener) { + if (!(getActivity() instanceof MapActivity) && fragment instanceof OsmAuthorizationListener) { osmOAuthHelper.addListener((OsmAuthorizationListener) fragment); } osmOAuthHelper.startOAuth((ViewGroup) view); diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingFragment.java index 991073c435..81cebe393d 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingFragment.java @@ -15,13 +15,14 @@ import androidx.fragment.app.FragmentManager; import androidx.preference.Preference; import androidx.preference.PreferenceViewHolder; +import net.osmand.plus.OsmandPlugin; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.helpers.FontCache; import net.osmand.plus.measurementtool.LoginBottomSheetFragment; import net.osmand.plus.osmedit.ValidateOsmLoginDetailsTask.ValidateOsmLoginListener; -import net.osmand.plus.osmedit.oauth.OsmOAuthAuthorizationAdapter; +import net.osmand.plus.osmedit.oauth.OsmOAuthHelper; import net.osmand.plus.osmedit.oauth.OsmOAuthHelper.OsmAuthorizationListener; import net.osmand.plus.settings.backend.OsmAndAppCustomization; import net.osmand.plus.settings.fragments.BaseSettingsFragment; @@ -41,12 +42,12 @@ public class OsmEditingFragment extends BaseSettingsFragment implements OnPrefer public static final String OSM_LOGIN_DATA = "osm_login_data"; private static final String OSM_EDITING_INFO = "osm_editing_info"; - private OsmOAuthAuthorizationAdapter authorizationAdapter; + private OsmOAuthHelper authHelper; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - authorizationAdapter = app.getOsmOAuthHelper().getAuthorizationAdapter(); + authHelper = app.getOsmOAuthHelper(); FragmentActivity activity = requireMyActivity(); activity.getOnBackPressedDispatcher().addCallback(this, new OnBackPressedCallback(true) { @@ -121,7 +122,7 @@ public class OsmEditingFragment extends BaseSettingsFragment implements OnPrefer } private boolean isValidToken() { - return authorizationAdapter.isValidToken(); + return authHelper.isValidToken(); } private boolean isLoginExists() { @@ -139,10 +140,14 @@ public class OsmEditingFragment extends BaseSettingsFragment implements OnPrefer } private void setupUseDevUrlPref() { - Drawable icon = getPersistentPrefIcon(R.drawable.ic_action_laptop); SwitchPreferenceEx useDevUrlPref = findPreference(settings.USE_DEV_URL.getId()); - useDevUrlPref.setDescription(getString(R.string.use_dev_url_descr)); - useDevUrlPref.setIcon(icon); + if (OsmandPlugin.isDevelopment()) { + Drawable icon = getPersistentPrefIcon(R.drawable.ic_action_laptop); + useDevUrlPref.setDescription(getString(R.string.use_dev_url_descr)); + useDevUrlPref.setIcon(icon); + } else { + useDevUrlPref.setVisible(false); + } } private void setupOsmEditsDescrPref() { @@ -174,7 +179,6 @@ public class OsmEditingFragment extends BaseSettingsFragment implements OnPrefer if (settings.USE_DEV_URL.getId().equals(prefId) && newValue instanceof Boolean) { settings.USE_DEV_URL.set((Boolean) newValue); osmLogout(); - authorizationAdapter = app.getOsmOAuthHelper().updateAdapter(); return true; } return super.onPreferenceChange(preference, newValue); @@ -206,33 +210,26 @@ public class OsmEditingFragment extends BaseSettingsFragment implements OnPrefer return super.onPreferenceClick(preference); } - private void osmLogout() { - boolean validToken = isValidToken(); - if (validToken || isLoginExists()) { - if (validToken) { - settings.USER_ACCESS_TOKEN.resetToDefault(); - settings.USER_ACCESS_TOKEN_SECRET.resetToDefault(); - authorizationAdapter.resetToken(); - } else { - settings.USER_NAME.resetToDefault(); - settings.USER_PASSWORD.resetToDefault(); - } + public void osmLogout() { + if (authHelper.isValidToken() || isLoginExists()) { app.showShortToastMessage(R.string.osm_edit_logout_success); - updateAllSettings(); } + authHelper.resetAuthorization(); + updateAllSettings(); } @Override public void onPreferenceChanged(String prefId) { if (settings.USE_DEV_URL.getId().equals(prefId)) { osmLogout(); - authorizationAdapter = app.getOsmOAuthHelper().updateAdapter(); } updateAllSettings(); } @Override public void authorizationCompleted() { - updateAllSettings(); + if (getContext() != null) { + updateAllSettings(); + } } } \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/osmedit/oauth/OsmOAuthHelper.java b/OsmAnd/src/net/osmand/plus/osmedit/oauth/OsmOAuthHelper.java index d7ef523d8c..acda0e0361 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/oauth/OsmOAuthHelper.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/oauth/OsmOAuthHelper.java @@ -5,6 +5,8 @@ import android.view.ViewGroup; import androidx.annotation.NonNull; import net.osmand.plus.OsmandApplication; +import net.osmand.plus.settings.backend.OsmandSettings; +import net.osmand.util.Algorithms; import java.util.HashSet; import java.util.Set; @@ -14,9 +16,11 @@ public class OsmOAuthHelper { private final OsmandApplication app; private OsmOAuthAuthorizationAdapter authorizationAdapter; private final Set listeners = new HashSet<>(); + private final OsmandSettings settings; public OsmOAuthHelper(@NonNull OsmandApplication app) { this.app = app; + settings = app.getSettings(); authorizationAdapter = new OsmOAuthAuthorizationAdapter(app); } @@ -45,6 +49,22 @@ public class OsmOAuthHelper { authorizationAdapter.authorize(oauthVerifier, this); } + public void resetAuthorization() { + if (isValidToken()) { + settings.USER_ACCESS_TOKEN.resetToDefault(); + settings.USER_ACCESS_TOKEN_SECRET.resetToDefault(); + authorizationAdapter.resetToken(); + } else if (isLoginExists()) { + settings.USER_NAME.resetToDefault(); + settings.USER_PASSWORD.resetToDefault(); + } + updateAdapter(); + } + + private boolean isLoginExists() { + return !Algorithms.isEmpty(settings.USER_NAME.get()) && !Algorithms.isEmpty(settings.USER_PASSWORD.get()); + } + public void notifyAndRemoveListeners() { for (OsmAuthorizationListener listener : listeners) { listener.authorizationCompleted(); @@ -52,6 +72,10 @@ public class OsmOAuthHelper { listeners.clear(); } + public boolean isValidToken() { + return authorizationAdapter.isValidToken(); + } + public interface OsmAuthorizationListener { void authorizationCompleted(); } From 0c81c1a1e060f2c39f594a5ce01a28b386a2f444 Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Tue, 24 Nov 2020 15:59:16 +0200 Subject: [PATCH 06/10] Fix review --- OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java | 7 ++----- .../osmand/plus/openplacereviews/OPRWebviewActivity.java | 3 +-- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java index e7075bb44d..26dfdaefa7 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java @@ -10,7 +10,6 @@ import android.graphics.Bitmap; import android.graphics.BitmapFactory; 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; @@ -24,7 +23,6 @@ import android.view.Gravity; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; -import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; @@ -370,11 +368,10 @@ public class MenuBuilder { } private View createAddPhotoButton(Context ctx) { - boolean nightMode = getApplication().getDaynightHelper().isNightModeForMapControls(); - View view = UiUtilities.getInflater(ctx, nightMode).inflate(R.layout.dialog_button_with_icon, null); + View view = UiUtilities.getInflater(ctx, !light).inflate(R.layout.dialog_button_with_icon, null); int dp6 = ctx.getResources().getDimensionPixelSize(R.dimen.bottom_sheet_title_padding_bottom); View button = view.findViewById(R.id.button); - UiUtilities.setupDialogButton(nightMode, button, UiUtilities.DialogButtonType.STROKED, + UiUtilities.setupDialogButton(!light, button, UiUtilities.DialogButtonType.STROKED, ctx.getString(R.string.shared_string_add_photo), R.drawable.ic_sample); TextView textView = view.findViewById(R.id.button_text); textView.setCompoundDrawablePadding(dp6); diff --git a/OsmAnd/src/net/osmand/plus/openplacereviews/OPRWebviewActivity.java b/OsmAnd/src/net/osmand/plus/openplacereviews/OPRWebviewActivity.java index 53c76e5309..14fd181f54 100644 --- a/OsmAnd/src/net/osmand/plus/openplacereviews/OPRWebviewActivity.java +++ b/OsmAnd/src/net/osmand/plus/openplacereviews/OPRWebviewActivity.java @@ -64,8 +64,7 @@ public class OPRWebviewActivity extends OsmandActionBarActivity { String title = bundle.getString(KEY_TITLE, ""); titleView.setText(title); } - ColorDrawable colorDrawable = new ColorDrawable(AndroidUtils.getColorFromAttr(this, R.attr.bg_color)); - toolbar.setBackgroundDrawable(colorDrawable); + toolbar.setBackgroundDrawable(new ColorDrawable(AndroidUtils.getColorFromAttr(this, R.attr.bg_color))); final Drawable upArrow = app.getUIUtilities().getIcon(AndroidUtils.getNavigationIconResId(this)); upArrow.setColorFilter(ContextCompat.getColor(this, R.color.color_favorite_gray), PorterDuff.Mode.SRC_ATOP); toolbar.setNavigationIcon(upArrow); From e9b3a881b578d68192b3f9041961fb1bde6abbd8 Mon Sep 17 00:00:00 2001 From: max-klaus Date: Tue, 24 Nov 2020 17:07:44 +0300 Subject: [PATCH 07/10] OsmAnd library config --- OsmAnd/AndroidManifest-library.xml | 49 ++++++++ OsmAnd/build.gradle.lib | 182 ++++++----------------------- 2 files changed, 86 insertions(+), 145 deletions(-) create mode 100644 OsmAnd/AndroidManifest-library.xml diff --git a/OsmAnd/AndroidManifest-library.xml b/OsmAnd/AndroidManifest-library.xml new file mode 100644 index 0000000000..379f1ce963 --- /dev/null +++ b/OsmAnd/AndroidManifest-library.xml @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OsmAnd/build.gradle.lib b/OsmAnd/build.gradle.lib index b70a881218..0f2fefae73 100644 --- a/OsmAnd/build.gradle.lib +++ b/OsmAnd/build.gradle.lib @@ -1,23 +1,5 @@ -//apply plugin: 'com.android.application' apply plugin: 'com.android.library' -// Global Parameters accepted -// TARGET_APP_NAME - app name -// APK_NUMBER_VERSION - version number of apk -// APK_VERSION_SUFFIX - build number like #99999Z, appended (for dev builds) to Manifest's versionName as X.X.X#99999Z -// Z means flavor: M=-master, D=-main-default, B=-Blackberry, Des=-design, MQA=-main-qt-arm, MQDA=-main-qt-default-arm, S=-sherpafy -// APP_EDITION - date stamp of builds -// APP_FEATURES - features +play_market +gps_status -parking_plugin -blackberry -free_version -amazon - -// 1. To be done Filter fonts -// -// -// -// -// -// -// Less important - task printc { configurations.each { if(it.isCanBeResolved()) println it.name } } @@ -27,67 +9,21 @@ android { buildToolsVersion "29.0.3" // compileNdkVersion "android-ndk-r17b" - signingConfigs { - development { - storeFile file("../keystores/debug.keystore") - storePassword "android" - keyAlias "androiddebugkey" - keyPassword "android" - } - - publishing { - storeFile file("/var/lib/jenkins/osmand_key") - storePassword System.getenv("OSMAND_APK_PASSWORD") - keyAlias "osmand" - keyPassword System.getenv("OSMAND_APK_PASSWORD") - } - } - defaultConfig { - minSdkVersion System.getenv("MIN_SDK_VERSION") ? System.getenv("MIN_SDK_VERSION").toInteger() : 15 + minSdkVersion 15 targetSdkVersion 29 - versionCode 390 - versionCode System.getenv("APK_NUMBER_VERSION") ? System.getenv("APK_NUMBER_VERSION").toInteger() : versionCode multiDexEnabled true - versionName "3.9.0" - versionName System.getenv("APK_VERSION")? System.getenv("APK_VERSION").toString(): versionName - versionName System.getenv("APK_VERSION_SUFFIX")? versionName + System.getenv("APK_VERSION_SUFFIX").toString(): versionName - // Stops the Gradle plugin’s automatic rasterization of vectors - // vectorDrawables.generatedDensities = ['hdpi'] vectorDrawables.useSupportLibrary = true } lintOptions { - lintConfig file("lint.xml") abortOnError false - warningsAsErrors false } - /* - bundle { - language { - // Specifies that the app bundle should not support - // configuration APKs for language resources. These - // resources are instead packaged with each base and - // dynamic feature APK. - enableSplit = false - } - } - */ - // related to kuromoji - //packagingOptions { - // exclude '/META-INF/CONTRIBUTORS.md' - // exclude '/META-INF/LICENSE.md' - // exclude '/META-INF/NOTICE.md' - //} - - // This is from OsmAndCore_android.aar - for some reason it's not inherited aaptOptions { // Don't compress any embedded resources noCompress "qz" cruncherEnabled = false - // Flag notifies aapt to keep the attribute IDs around - // additionalParameters "--no-version-vectors" } dexOptions { @@ -96,7 +32,7 @@ android { sourceSets { main { - manifest.srcFile "AndroidManifest.xml" + manifest.srcFile "AndroidManifest-library.xml" jni.srcDirs = [] jniLibs.srcDirs = ["libs"] aidl.srcDirs = ["src"] @@ -107,25 +43,8 @@ android { assets.srcDirs = ["assets"] } debug { - manifest.srcFile "AndroidManifest-debug.xml" } - /* - full { - java.srcDirs = ["src-google"] - } - free { - java.srcDirs = ["src-google"] - manifest.srcFile "AndroidManifest-free.xml" - } - freedev { - java.srcDirs = ["src-google"] - manifest.srcFile "AndroidManifest-freedev.xml" - } - freehuawei { - java.srcDirs = ["src-huawei"] - manifest.srcFile "AndroidManifest-freehuawei.xml" - } - */ + legacy { jniLibs.srcDirs = ["libc++"] } @@ -165,70 +84,27 @@ android { } } - /* - // Version - freedev { - dimension "version" - applicationId "net.osmand.dev" - // resConfig "en" - } - free { - dimension "version" - applicationId "net.osmand" - } - full { - dimension "version" - applicationId "net.osmand.plus" - } - freehuawei { - dimension "version" - applicationId "net.osmand.huawei" - } - */ // CoreVersion // Build that doesn't include 3D OpenGL legacy { dimension "coreversion" } - // Build that includes 3D OpenGL release - qtcore { - dimension "coreversion" - } - // Build that includes 3D OpenGL debug - qtcoredebug { - dimension "coreversion" - } } buildTypes { debug { - buildConfigField "String", "OPR_BASE_URL", "\"https://test.openplacereviews.org/\"" - buildConfigField "String", "OSM_OAUTH_CONSUMER_KEY", "\"Ti2qq3fo4i4Wmuox3SiWRIGq3obZisBHnxmcM05y\"" - buildConfigField "String", "OSM_OAUTH_CONSUMER_SECRET", "\"lxulb3HYoMmd2cC4xxNe1dyfRMAY8dS0eNihJ0DM\"" - signingConfig signingConfigs.development + debuggable true } + release { - buildConfigField "String", "OPR_BASE_URL", "\"https://test.openplacereviews.org/\"" - buildConfigField "String", "OSM_OAUTH_CONSUMER_KEY", "\"Ti2qq3fo4i4Wmuox3SiWRIGq3obZisBHnxmcM05y\"" - buildConfigField "String", "OSM_OAUTH_CONSUMER_SECRET", "\"lxulb3HYoMmd2cC4xxNe1dyfRMAY8dS0eNihJ0DM\"" - signingConfig signingConfigs.publishing + debuggable false } } - } def replaceNoTranslate(line) { - if (line.contains("\"app_name\"") && System.getenv("TARGET_APP_NAME")) { - return line.replaceAll(">[^<]*<", ">" + System.getenv("TARGET_APP_NAME") + "<") - } - if (line.contains("\"app_name_free\"") && System.getenv("TARGET_APP_NAME")) { - return line.replaceAll(">[^<]*<", ">" + System.getenv("TARGET_APP_NAME") + "<") - } - if (line.contains("\"app_edition\"") && System.getenv("APP_EDITION")) { - return line.replaceAll(">[^<]*<", ">" + System.getenv("APP_EDITION") + "<") - } - if (line.contains("\"versionFeatures\"") && System.getenv("APP_FEATURES")) { - return line.replaceAll(">[^<]*<", ">" + System.getenv("APP_FEATURES") + "<") + if (line.contains("\"versionFeatures\"")) { + return line.replaceAll(">[^<]*<", ">" + "" + "<") } return line; } @@ -402,6 +278,8 @@ task collectExternalResources { // Legacy core build import org.apache.tools.ant.taskdefs.condition.Os +import java.util.regex.Pattern + task buildOsmAndCore(type: Exec) { Gradle gradle = getGradle() String tskReqStr = gradle.getStartParameter().getTaskRequests().toString().toLowerCase() @@ -452,11 +330,6 @@ afterEvaluate { android.libraryVariants.all { variant -> variant.javaCompiler.dependsOn(collectExternalResources, buildOsmAndCore, cleanupDuplicatesInCore) } - Gradle gradle = getGradle() - String tskReqStr = gradle.getStartParameter().getTaskRequests().toString().toLowerCase() - if (tskReqStr.contains("huawei")) { - apply plugin: 'com.huawei.agconnect' - } } task appStart(type: Exec) { @@ -466,6 +339,27 @@ task appStart(type: Exec) { // commandLine 'cmd', '/c', 'adb', 'shell', 'am', 'start', '-n', 'net.osmand.plus/net.osmand.plus.activities.MapActivity' } +// Uploading artifacts to local path +group = "net.osmand" +uploadArchives { + repositories.ivy { + // credentials { + // username "" + // password "" + // } + url = "/Users/alexey/tmp/ivy";//System.getenv("OSMAND_BINARIES_IVY_ROOT") ?: "./" + layout "pattern" , { + artifact "[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" + } + +// def gitInfo = "git describe --long".execute().text.trim() +// def parsedGitInfo = Pattern.compile("v(\\d+\\.\\d+)-([\\d.]+)-(\\w+)").matcher(gitInfo) +// assert parsedGitInfo.matches() +// version = parsedGitInfo.group(1) + "-SNAPSHOT" + version = "1.0" + } +} + dependencies { implementation project(path: ':OsmAnd-java', configuration: 'android') implementation project(':OsmAnd-api') @@ -497,14 +391,14 @@ dependencies { // implementation 'com.ibm.icu:icu4j:50.1' // implementation 'net.sf.trove4j:trove4j:3.0.3' - qtcoreImplementation fileTree(include: ['QtAndroid.jar', 'QtAndroidBearer.jar'], dir: 'libs') - qtcoredebugImplementation fileTree(include: ['QtAndroid.jar', 'QtAndroidBearer.jar'], dir: 'libs') +// qtcoreImplementation fileTree(include: ['QtAndroid.jar', 'QtAndroidBearer.jar'], dir: 'libs') +// qtcoredebugImplementation fileTree(include: ['QtAndroid.jar', 'QtAndroidBearer.jar'], dir: 'libs') legacyImplementation "net.osmand:OsmAndCore_android:0.1-SNAPSHOT@jar" - qtcoredebugImplementation "net.osmand:OsmAndCore_androidNativeDebug:0.1-SNAPSHOT@aar" - qtcoredebugImplementation "net.osmand:OsmAndCore_android:0.1-SNAPSHOT@aar" - qtcoreImplementation "net.osmand:OsmAndCore_androidNativeRelease:0.1-SNAPSHOT@aar" - qtcoreImplementation "net.osmand:OsmAndCore_android:0.1-SNAPSHOT@aar" +// qtcoredebugImplementation "net.osmand:OsmAndCore_androidNativeDebug:0.1-SNAPSHOT@aar" +// qtcoredebugImplementation "net.osmand:OsmAndCore_android:0.1-SNAPSHOT@aar" +// qtcoreImplementation "net.osmand:OsmAndCore_androidNativeRelease:0.1-SNAPSHOT@aar" +// qtcoreImplementation "net.osmand:OsmAndCore_android:0.1-SNAPSHOT@aar" implementation ("com.getkeepsafe.taptargetview:taptargetview:1.12.0"){ exclude group: 'com.android.support' } @@ -516,6 +410,4 @@ dependencies { exclude group: "com.fasterxml.jackson.core" } implementation 'com.jaredrummler:colorpicker:1.1.0' - - //freehuaweiImplementation 'com.huawei.hms:iap:5.0.2.300' } From 360338d9def7b120fd55669465a0cab568cddb8a Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Tue, 24 Nov 2020 16:38:46 +0200 Subject: [PATCH 08/10] Fix core-sample compilation --- .../samples/android/sample1/SampleFormatter.java | 15 ++++++--------- .../builders/AmenityMenuBuilder.java | 12 ++++-------- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/OsmAndCore-sample/src/net/osmand/core/samples/android/sample1/SampleFormatter.java b/OsmAndCore-sample/src/net/osmand/core/samples/android/sample1/SampleFormatter.java index 6a340aa528..0c5780bd6a 100644 --- a/OsmAndCore-sample/src/net/osmand/core/samples/android/sample1/SampleFormatter.java +++ b/OsmAndCore-sample/src/net/osmand/core/samples/android/sample1/SampleFormatter.java @@ -12,7 +12,6 @@ import net.osmand.util.Algorithms; import java.text.DecimalFormat; import java.text.MessageFormat; -import java.util.Map.Entry; public class SampleFormatter { public final static float METERS_IN_KILOMETER = 1000f; @@ -275,10 +274,9 @@ public class SampleFormatter { return ""; } MapPoiTypes poiTypes = ctx.getPoiTypes(); - for(Entry e : amenity.getAdditionalInfo().entrySet()) { - String key = e.getKey(); - String vl = e.getValue(); - if(key.startsWith("name:")) { + for (String key : amenity.getAdditionalInfoKeys()) { + String vl = amenity.getAdditionalInfo(key); + if (key.startsWith("name:")) { continue; } else if(vl.length() >= 150) { if(shortDescription) { @@ -291,16 +289,15 @@ public class SampleFormatter { } else if(Amenity.WEBSITE.equals(key)) { d.append(ctx.getString("website") + ": "); } else { - AbstractPoiType pt = poiTypes.getAnyPoiAdditionalTypeByKey(e.getKey()); + AbstractPoiType pt = poiTypes.getAnyPoiAdditionalTypeByKey(key); if (pt != null) { if(pt instanceof PoiType && !((PoiType) pt).isText()) { vl = pt.getTranslation(); } else { - vl = pt.getTranslation() + ": " + amenity.unzipContent(e.getValue()); + vl = pt.getTranslation() + ": " + vl; } } else { - vl = Algorithms.capitalizeFirstLetterAndLowercase(e.getKey()) + - ": " + amenity.unzipContent(e.getValue()); + vl = Algorithms.capitalizeFirstLetterAndLowercase(key) + ": " + vl; } } d.append(vl).append('\n'); diff --git a/OsmAndCore-sample/src/net/osmand/core/samples/android/sample1/mapcontextmenu/builders/AmenityMenuBuilder.java b/OsmAndCore-sample/src/net/osmand/core/samples/android/sample1/mapcontextmenu/builders/AmenityMenuBuilder.java index 2215c4ad90..5719c097e8 100644 --- a/OsmAndCore-sample/src/net/osmand/core/samples/android/sample1/mapcontextmenu/builders/AmenityMenuBuilder.java +++ b/OsmAndCore-sample/src/net/osmand/core/samples/android/sample1/mapcontextmenu/builders/AmenityMenuBuilder.java @@ -39,7 +39,6 @@ import java.util.Collections; import java.util.Comparator; import java.util.LinkedList; import java.util.List; -import java.util.Map; public class AmenityMenuBuilder extends MenuBuilder { @@ -275,12 +274,11 @@ public class AmenityMenuBuilder extends MenuBuilder { List infoRows = new LinkedList<>(); List descriptions = new LinkedList<>(); - for (Map.Entry e : amenity.getAdditionalInfo().entrySet()) { + for (String key : amenity.getAdditionalInfoKeys()) { + String vl = amenity.getAdditionalInfo(key); int iconId; Drawable icon = null; int textColor = 0; - String key = e.getKey(); - String vl = e.getValue(); String textPrefix = ""; View collapsableView = null; @@ -357,7 +355,7 @@ public class AmenityMenuBuilder extends MenuBuilder { } else if (Amenity.CUISINE.equals(key)) { iconId = OsmandResources.getDrawableId("ic_action_cuisine"); StringBuilder sb = new StringBuilder(); - for (String c : e.getValue().split(";")) { + for (String c : vl.split(";")) { if (sb.length() > 0) { sb.append(", "); } else { @@ -388,7 +386,6 @@ public class AmenityMenuBuilder extends MenuBuilder { isText = true; isDescription = iconId == OsmandResources.getDrawableId("ic_action_note_dark"); textPrefix = pType.getTranslation(); - vl = amenity.unzipContent(e.getValue()); } if (!isDescription && icon == null) { icon = getRowIcon(view.getContext(), pType.getIconKeyName()); @@ -400,8 +397,7 @@ public class AmenityMenuBuilder extends MenuBuilder { iconId = OsmandResources.getDrawableId("ic_action_note_dark"); } } else { - textPrefix = Algorithms.capitalizeFirstLetterAndLowercase(e.getKey()); - vl = amenity.unzipContent(e.getValue()); + textPrefix = Algorithms.capitalizeFirstLetterAndLowercase(vl); } } From 368c339d309770fbedacffd10d85122ce9dcd4d2 Mon Sep 17 00:00:00 2001 From: max-klaus Date: Tue, 24 Nov 2020 18:10:18 +0300 Subject: [PATCH 09/10] Fix gradle script --- OsmAnd/build.gradle.lib | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OsmAnd/build.gradle.lib b/OsmAnd/build.gradle.lib index 0f2fefae73..a9a8ca41b0 100644 --- a/OsmAnd/build.gradle.lib +++ b/OsmAnd/build.gradle.lib @@ -410,4 +410,6 @@ dependencies { exclude group: "com.fasterxml.jackson.core" } implementation 'com.jaredrummler:colorpicker:1.1.0' + + implementation 'org.bouncycastle:bcpkix-jdk15on:1.56' } From 2aa202c41d1083434b3fb9c0aedfac743871d5d7 Mon Sep 17 00:00:00 2001 From: max-klaus Date: Tue, 24 Nov 2020 18:16:29 +0300 Subject: [PATCH 10/10] Fix gradle script --- OsmAnd/build.gradle.lib | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OsmAnd/build.gradle.lib b/OsmAnd/build.gradle.lib index a9a8ca41b0..2824130409 100644 --- a/OsmAnd/build.gradle.lib +++ b/OsmAnd/build.gradle.lib @@ -347,7 +347,7 @@ uploadArchives { // username "" // password "" // } - url = "/Users/alexey/tmp/ivy";//System.getenv("OSMAND_BINARIES_IVY_ROOT") ?: "./" + url = System.getenv("OSMAND_BINARIES_IVY_ROOT") ?: "./" layout "pattern" , { artifact "[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" } @@ -410,6 +410,6 @@ dependencies { exclude group: "com.fasterxml.jackson.core" } implementation 'com.jaredrummler:colorpicker:1.1.0' - + implementation 'org.bouncycastle:bcpkix-jdk15on:1.56' }