From 984aaa36a7cd50bb7230eacd0e6b000aac3b724a Mon Sep 17 00:00:00 2001 From: androiddevkotlin <64539346+androiddevkotlin@users.noreply.github.com> Date: Sun, 21 Mar 2021 19:20:50 +0200 Subject: [PATCH 01/74] init --- OsmAnd/res/layout/empty_purchases_layout.xml | 220 ++++++++++++ .../profile_preference_toolbar_with_icon.xml | 1 + OsmAnd/res/layout/purchases_layout.xml | 338 ++++++++++++++++++ OsmAnd/res/values/strings.xml | 7 + OsmAnd/res/xml/settings_main_screen.xml | 8 + .../fragments/MainSettingsFragment.java | 6 +- .../settings/fragments/PurchasesFragment.java | 101 ++++++ .../fragments/PurchasesFragmentEmpty.java | 148 ++++++++ 8 files changed, 827 insertions(+), 2 deletions(-) create mode 100644 OsmAnd/res/layout/empty_purchases_layout.xml create mode 100644 OsmAnd/res/layout/purchases_layout.xml create mode 100644 OsmAnd/src/net/osmand/plus/settings/fragments/PurchasesFragment.java create mode 100644 OsmAnd/src/net/osmand/plus/settings/fragments/PurchasesFragmentEmpty.java diff --git a/OsmAnd/res/layout/empty_purchases_layout.xml b/OsmAnd/res/layout/empty_purchases_layout.xml new file mode 100644 index 0000000000..7a19918581 --- /dev/null +++ b/OsmAnd/res/layout/empty_purchases_layout.xml @@ -0,0 +1,220 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/layout/profile_preference_toolbar_with_icon.xml b/OsmAnd/res/layout/profile_preference_toolbar_with_icon.xml index 98f2b0966d..3890b58e8f 100644 --- a/OsmAnd/res/layout/profile_preference_toolbar_with_icon.xml +++ b/OsmAnd/res/layout/profile_preference_toolbar_with_icon.xml @@ -69,6 +69,7 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 2bc271e8dd..74cea426f4 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -11,6 +11,13 @@ Thx - Hardy --> + + support@osmand.net + Contact support + If your purchases don\'t show up here, tap on “Restore purchases”, or contact our support team. + If you have any questions, please contact us at %1$s. + New device / new account + You don\'t have any purchases Please select another type of colorization. The track does not contain speed data. The track does not contain altitude data. diff --git a/OsmAnd/res/xml/settings_main_screen.xml b/OsmAnd/res/xml/settings_main_screen.xml index ba31622bf4..610b675747 100644 --- a/OsmAnd/res/xml/settings_main_screen.xml +++ b/OsmAnd/res/xml/settings_main_screen.xml @@ -13,6 +13,14 @@ app:fragment="net.osmand.plus.settings.fragments.GlobalSettingsFragment" tools:icon="@drawable/ic_action_settings" /> + + diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/MainSettingsFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/MainSettingsFragment.java index 225ed389e7..1dd498a4c2 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/MainSettingsFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/MainSettingsFragment.java @@ -70,10 +70,12 @@ public class MainSettingsFragment extends BaseSettingsFragment implements OnSele availableAppModes = new LinkedHashSet<>(ApplicationMode.values(getMyApplication())); Preference globalSettings = findPreference("global_settings"); globalSettings.setIcon(getContentIcon(R.drawable.ic_action_settings)); - PreferenceCategory selectedProfile = (PreferenceCategory) findPreference(SELECTED_PROFILE); + Preference purchasesSettings = findPreference("purchases_settings"); + purchasesSettings.setIcon(getContentIcon(R.drawable.ic_action_purchases)); + PreferenceCategory selectedProfile = findPreference(SELECTED_PROFILE); selectedProfile.setIconSpaceReserved(false); setupConfigureProfilePref(); - PreferenceCategory appProfiles = (PreferenceCategory) findPreference(APP_PROFILES); + PreferenceCategory appProfiles = findPreference(APP_PROFILES); appProfiles.setIconSpaceReserved(false); setupAppProfiles(appProfiles); profileManagementPref(); diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/PurchasesFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/PurchasesFragment.java new file mode 100644 index 0000000000..8f96c68fa6 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/PurchasesFragment.java @@ -0,0 +1,101 @@ +package net.osmand.plus.settings.fragments; + +import android.app.Activity; +import android.content.Context; +import android.content.Intent; +import android.net.Uri; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageButton; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.fragment.app.FragmentActivity; + +import com.google.android.material.appbar.AppBarLayout; + +import net.osmand.plus.R; +import net.osmand.plus.UiUtilities; +import net.osmand.plus.activities.OsmandInAppPurchaseActivity; +import net.osmand.plus.base.BaseOsmAndFragment; +import net.osmand.plus.chooseplan.ChoosePlanDialogFragment; +import net.osmand.plus.inapp.InAppPurchaseHelper; + +public class PurchasesFragment extends BaseOsmAndFragment { + public static final String TAG = PurchasesFragmentEmpty.class.getName(); + private InAppPurchaseHelper purchaseHelper; + private View mainView; + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + @Override + public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + Context context = requireContext(); + purchaseHelper = getInAppPurchaseHelper(); + boolean nightMode = !getMyApplication().getSettings().isLightContent(); + LayoutInflater themedInflater = UiUtilities.getInflater(context, nightMode); + mainView = themedInflater.inflate(R.layout.purchases_layout, container, false); + AppBarLayout appbar = mainView.findViewById(R.id.appbar); + View toolbar = themedInflater.inflate(R.layout.profile_preference_toolbar_with_icon, container, false); + appbar.addView(toolbar); + + TextView toolbarTitle = appbar.findViewById(R.id.toolbar_title); + View iconToolbarContainer = appbar.findViewById(R.id.icon_toolbar); + toolbarTitle.setText(getString(R.string.purchases)); + ImageView icon = iconToolbarContainer.findViewById(R.id.profile_icon); + icon.setImageResource(R.drawable.ic_action_help_online); + icon.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Uri uri = Uri.parse("https://docs.osmand.net/en/main@latest/osmand/purchases"); + Intent intent = new Intent(Intent.ACTION_VIEW, uri); + startActivity(intent); + } + }); + ImageButton backButton = mainView.findViewById(R.id.close_button); + backButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + FragmentActivity fragmentActivity = getActivity(); + if (fragmentActivity != null) { + fragmentActivity.onBackPressed(); + } + } + }); + LinearLayout purchasesRestore = mainView.findViewById(R.id.restore_purchases); + purchasesRestore.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (purchaseHelper != null && !purchaseHelper.hasInventory()) { + purchaseHelper.requestInventory(); + } + } + }); + LinearLayout osmandLive = mainView.findViewById(R.id.osmand_live); + osmandLive.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { +// ChoosePlanDialogFragment.showOsmLiveInstance(getMyActivity().getSupportFragmentManager()); + } + }); + return mainView; + } + + @Nullable + public InAppPurchaseHelper getInAppPurchaseHelper() { + Activity activity = getActivity(); + if (activity instanceof OsmandInAppPurchaseActivity) { + return ((OsmandInAppPurchaseActivity) activity).getPurchaseHelper(); + } else { + return null; + } + } +} diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/PurchasesFragmentEmpty.java b/OsmAnd/src/net/osmand/plus/settings/fragments/PurchasesFragmentEmpty.java new file mode 100644 index 0000000000..f3fc5621fb --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/PurchasesFragmentEmpty.java @@ -0,0 +1,148 @@ +package net.osmand.plus.settings.fragments; + +import android.app.Activity; +import android.content.Context; +import android.content.Intent; +import android.graphics.Typeface; +import android.net.Uri; +import android.os.Bundle; +import android.text.Spannable; +import android.text.SpannableString; +import android.text.Spanned; +import android.text.method.LinkMovementMethod; +import android.text.style.StyleSpan; +import android.text.style.URLSpan; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageButton; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.fragment.app.FragmentActivity; + +import com.google.android.material.appbar.AppBarLayout; + +import net.osmand.AndroidUtils; +import net.osmand.plus.R; +import net.osmand.plus.UiUtilities; +import net.osmand.plus.activities.OsmandInAppPurchaseActivity; +import net.osmand.plus.base.BaseOsmAndFragment; +import net.osmand.plus.chooseplan.ChoosePlanDialogFragment; +import net.osmand.plus.inapp.InAppPurchaseHelper; + +public class PurchasesFragmentEmpty extends BaseOsmAndFragment { + public static final String TAG = PurchasesFragmentEmpty.class.getName(); + private InAppPurchaseHelper purchaseHelper; + private View mainView; + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + @Override + public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + Context context = requireContext(); + purchaseHelper = getInAppPurchaseHelper(); + boolean nightMode = !getMyApplication().getSettings().isLightContent(); + LayoutInflater themedInflater = UiUtilities.getInflater(context, nightMode); + mainView = themedInflater.inflate(R.layout.empty_purchases_layout, container, false); + createToolbar(mainView, nightMode); + LinearLayout purchasesRestore = mainView.findViewById(R.id.restore_purchases); + purchasesRestore.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (purchaseHelper != null && !purchaseHelper.hasInventory()) { + purchaseHelper.requestInventory(); + } + } + }); + LinearLayout osmandLive = mainView.findViewById(R.id.osmand_live); + osmandLive.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + ChoosePlanDialogFragment.showDialogInstance(getMyApplication(), getMyActivity().getSupportFragmentManager(), ChoosePlanDialogFragment.ChoosePlanDialogType.OSM_LIVE); + } + }); + setFormatLink(); + return mainView; + } + + @Nullable + public InAppPurchaseHelper getInAppPurchaseHelper() { + Activity activity = getActivity(); + if (activity instanceof OsmandInAppPurchaseActivity) { + return ((OsmandInAppPurchaseActivity) activity).getPurchaseHelper(); + } else { + return null; + } + } + + private void createToolbar(View mainView, boolean nightMode) { + AppBarLayout appbar = mainView.findViewById(R.id.appbar); + View toolbar = UiUtilities.getInflater(getContext(), nightMode).inflate(R.layout.profile_preference_toolbar_with_icon, appbar, false); + + View iconToolbarContainer = toolbar.findViewById(R.id.icon_toolbar); + ImageView icon = iconToolbarContainer.findViewById(R.id.profile_icon); + icon.setImageResource(R.drawable.ic_action_help_online); + icon.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Uri uri = Uri.parse("https://docs.osmand.net/en/main@latest/osmand/purchases"); + Intent intent = new Intent(Intent.ACTION_VIEW, uri); + startActivity(intent); + } + }); + ImageButton backButton = toolbar.findViewById(R.id.close_button); + backButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + FragmentActivity fragmentActivity = getActivity(); + if (fragmentActivity != null) { + fragmentActivity.onBackPressed(); + } + } + }); + TextView toolbarTitle = toolbar.findViewById(R.id.toolbar_title); + toolbarTitle.setText(getString(R.string.purchases)); + appbar.addView(toolbar); + } + + public void setFormatLink() { + TextView newDeviceAccountLink = mainView.findViewById(R.id.new_device_account_title); + TextView contactSupportLink = mainView.findViewById(R.id.contact_support_title); + TextView supportDescription = mainView.findViewById(R.id.support_link_title); + + SpannableString spannableStringSupport = new SpannableString(getString(R.string.contact_support)); + String urlSupport = "mailto:support@osmand.net"; + spannableStringSupport.setSpan(new URLSpan(urlSupport), 0, spannableStringSupport.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); + + SpannableString spannableStringNewDeviceAccount = new SpannableString(getString(R.string.new_device_account)); + String urlNewDeviceAccount = "https://docs.osmand.net/en/main@latest/osmand/purchases#new-device--new-account"; + spannableStringNewDeviceAccount.setSpan(new URLSpan(urlNewDeviceAccount), 0, spannableStringNewDeviceAccount.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); + + String emailString = getString(R.string.contact_support_mail); + String supportDescriptionString = getString(R.string.contact_support_description, emailString); + SpannableString spannableStringMail = new SpannableString(supportDescriptionString); + int startIndex = supportDescriptionString.indexOf(emailString); + int endIndex = startIndex + emailString.length(); + StyleSpan boldSpan = new StyleSpan(Typeface.BOLD); + spannableStringMail.setSpan(boldSpan, startIndex, endIndex, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); + + contactSupportLink.setText(spannableStringSupport); + newDeviceAccountLink.setText(spannableStringNewDeviceAccount); + supportDescription.setText(spannableStringMail); + + AndroidUtils.removeLinkUnderline(contactSupportLink); + AndroidUtils.removeLinkUnderline(newDeviceAccountLink); + + contactSupportLink.setMovementMethod(LinkMovementMethod.getInstance()); + newDeviceAccountLink.setMovementMethod(LinkMovementMethod.getInstance()); + + } + +} From ac370efcd95adbcdf8c741cc93073bdeb6577316 Mon Sep 17 00:00:00 2001 From: androiddevkotlin <64539346+androiddevkotlin@users.noreply.github.com> Date: Mon, 22 Mar 2021 01:48:00 +0200 Subject: [PATCH 02/74] First iteration --- OsmAnd/res/layout/purchases_layout.xml | 47 ++--- OsmAnd/res/values/attrs.xml | 1 + OsmAnd/res/values/strings.xml | 2 + OsmAnd/res/values/styles.xml | 2 + OsmAnd/res/xml/settings_main_screen.xml | 2 +- .../fragments/MainSettingsFragment.java | 3 +- .../settings/fragments/PurchasesFragment.java | 160 ++++++++++++++---- .../fragments/PurchasesFragmentEmpty.java | 4 +- 8 files changed, 163 insertions(+), 58 deletions(-) diff --git a/OsmAnd/res/layout/purchases_layout.xml b/OsmAnd/res/layout/purchases_layout.xml index dfab75ff90..b0c12c905d 100644 --- a/OsmAnd/res/layout/purchases_layout.xml +++ b/OsmAnd/res/layout/purchases_layout.xml @@ -11,21 +11,16 @@ android:layout_width="match_parent" android:layout_height="wrap_content"> + + + - - - - + app:tint="?attr/active_color_basic_green" /> @@ -189,18 +185,14 @@ android:layout_height="wrap_content" android:layout_marginEnd="@dimen/card_button_progress_size_small" android:layout_marginRight="@dimen/card_button_progress_size_small" - android:letterSpacing="@dimen/text_button_letter_spacing" - android:text="@string/live_updates" - android:textColor="?attr/active_color_basic" - android:textSize="@dimen/default_list_text_size" - app:typeface="@string/font_roboto_medium" /> + android:letterSpacing="@dimen/description_letter_spacing" + android:text="@string/troubleshooting_description" + android:textColor="?android:textColorSecondary" + android:textSize="@dimen/default_desc_text_size" + app:typeface="@string/font_roboto_regular" /> - - + + + + + diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 74cea426f4..b18a660072 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -12,6 +12,8 @@ --> + Please follow this link if you any issues with purchases. + Troubleshooting support@osmand.net Contact support If your purchases don\'t show up here, tap on “Restore purchases”, or contact our support team. diff --git a/OsmAnd/res/values/styles.xml b/OsmAnd/res/values/styles.xml index 7f16bc4586..81c73d5697 100644 --- a/OsmAnd/res/values/styles.xml +++ b/OsmAnd/res/values/styles.xml @@ -218,6 +218,7 @@ @color/divider_color_light @color/text_color_primary_light @color/active_color_primary_light + @color/profile_icon_color_green_light @color/card_and_list_background_light @color/activity_background_light @drawable/pages_bg_light @@ -519,6 +520,7 @@ @color/divider_color_dark @color/text_color_primary_dark @color/active_color_primary_dark + @color/profile_icon_color_green_dark @color/card_and_list_background_dark @color/activity_background_dark @drawable/pages_bg_dark diff --git a/OsmAnd/res/xml/settings_main_screen.xml b/OsmAnd/res/xml/settings_main_screen.xml index 610b675747..b71907f71c 100644 --- a/OsmAnd/res/xml/settings_main_screen.xml +++ b/OsmAnd/res/xml/settings_main_screen.xml @@ -18,7 +18,7 @@ android:layout="@layout/preference_with_descr" android:persistent="false" android:title="@string/purchases" - app:fragment="net.osmand.plus.settings.fragments.PurchasesFragmentEmpty" + app:fragment="net.osmand.plus.settings.fragments.PurchasesFragment" tools:icon="@drawable/ic_action_purchases" /> (ApplicationMode.values(getMyApplication())); Preference globalSettings = findPreference("global_settings"); globalSettings.setIcon(getContentIcon(R.drawable.ic_action_settings)); - Preference purchasesSettings = findPreference("purchases_settings"); + Preference purchasesSettings = findPreference(PURCHASES_SETTINGS); purchasesSettings.setIcon(getContentIcon(R.drawable.ic_action_purchases)); PreferenceCategory selectedProfile = findPreference(SELECTED_PROFILE); selectedProfile.setIconSpaceReserved(false); diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/PurchasesFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/PurchasesFragment.java index 8f96c68fa6..9fe813fa1f 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/PurchasesFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/PurchasesFragment.java @@ -3,8 +3,15 @@ package net.osmand.plus.settings.fragments; import android.app.Activity; import android.content.Context; import android.content.Intent; +import android.graphics.Typeface; import android.net.Uri; import android.os.Bundle; +import android.text.Spannable; +import android.text.SpannableString; +import android.text.Spanned; +import android.text.method.LinkMovementMethod; +import android.text.style.StyleSpan; +import android.text.style.URLSpan; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -19,17 +26,27 @@ import androidx.fragment.app.FragmentActivity; import com.google.android.material.appbar.AppBarLayout; +import net.osmand.AndroidUtils; +import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; +import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.OsmandInAppPurchaseActivity; import net.osmand.plus.base.BaseOsmAndFragment; -import net.osmand.plus.chooseplan.ChoosePlanDialogFragment; import net.osmand.plus.inapp.InAppPurchaseHelper; +import net.osmand.plus.liveupdates.OsmLiveActivity; public class PurchasesFragment extends BaseOsmAndFragment { - public static final String TAG = PurchasesFragmentEmpty.class.getName(); + + public static final String TAG = PurchasesFragment.class.getName(); private InAppPurchaseHelper purchaseHelper; private View mainView; + private Context context; + private OsmandApplication app; + private String url; + private static final String PLAY_STORE_SUBSCRIPTION_URL = "https://play.google.com/store/account/subscriptions"; + private static final String PLAY_STORE_SUBSCRIPTION_DEEPLINK_URL = "https://play.google.com/store/account/subscriptions?sku=%s&package=%s"; + @Override public void onCreate(Bundle savedInstanceState) { @@ -38,38 +55,15 @@ public class PurchasesFragment extends BaseOsmAndFragment { @Override public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - Context context = requireContext(); + app = getMyApplication(); + context = requireContext(); purchaseHelper = getInAppPurchaseHelper(); + final MapActivity mapActivity = (MapActivity) getActivity(); boolean nightMode = !getMyApplication().getSettings().isLightContent(); LayoutInflater themedInflater = UiUtilities.getInflater(context, nightMode); mainView = themedInflater.inflate(R.layout.purchases_layout, container, false); - AppBarLayout appbar = mainView.findViewById(R.id.appbar); - View toolbar = themedInflater.inflate(R.layout.profile_preference_toolbar_with_icon, container, false); - appbar.addView(toolbar); - TextView toolbarTitle = appbar.findViewById(R.id.toolbar_title); - View iconToolbarContainer = appbar.findViewById(R.id.icon_toolbar); - toolbarTitle.setText(getString(R.string.purchases)); - ImageView icon = iconToolbarContainer.findViewById(R.id.profile_icon); - icon.setImageResource(R.drawable.ic_action_help_online); - icon.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - Uri uri = Uri.parse("https://docs.osmand.net/en/main@latest/osmand/purchases"); - Intent intent = new Intent(Intent.ACTION_VIEW, uri); - startActivity(intent); - } - }); - ImageButton backButton = mainView.findViewById(R.id.close_button); - backButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - FragmentActivity fragmentActivity = getActivity(); - if (fragmentActivity != null) { - fragmentActivity.onBackPressed(); - } - } - }); + createToolbar(mainView, nightMode); LinearLayout purchasesRestore = mainView.findViewById(R.id.restore_purchases); purchasesRestore.setOnClickListener(new View.OnClickListener() { @Override @@ -79,13 +73,28 @@ public class PurchasesFragment extends BaseOsmAndFragment { } } }); - LinearLayout osmandLive = mainView.findViewById(R.id.osmand_live); - osmandLive.setOnClickListener(new View.OnClickListener() { + LinearLayout reportContainer = mainView.findViewById(R.id.report_container); + reportContainer.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { -// ChoosePlanDialogFragment.showOsmLiveInstance(getMyActivity().getSupportFragmentManager()); + Intent intent = new Intent(mapActivity, OsmLiveActivity.class); + intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); + if (mapActivity != null) { + mapActivity.startActivity(intent); + } } }); + LinearLayout liveUpdatesContainer = mainView.findViewById(R.id.live_updates_container); + liveUpdatesContainer.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { +// Fragment parent = getParentFragment(); +// if (parent != null) { +// ((LiveUpdatesFragment) parent).updateSubscriptionHeader(); +// } + } + }); + setFormatLink(); return mainView; } @@ -98,4 +107,91 @@ public class PurchasesFragment extends BaseOsmAndFragment { return null; } } + + private void createToolbar(View mainView, boolean nightMode) { + AppBarLayout appbar = mainView.findViewById(R.id.appbar); + View toolbar = UiUtilities.getInflater(getContext(), nightMode).inflate(R.layout.profile_preference_toolbar_with_icon, appbar, false); + + View iconToolbarContainer = toolbar.findViewById(R.id.icon_toolbar); + ImageView icon = iconToolbarContainer.findViewById(R.id.profile_icon); + icon.setImageResource(R.drawable.ic_action_help_online); + icon.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Uri uri = Uri.parse("https://docs.osmand.net/en/main@latest/osmand/purchases"); + Intent intent = new Intent(Intent.ACTION_VIEW, uri); + if (AndroidUtils.isIntentSafe(context, intent)) { + startActivity(intent); + } + } + }); + ImageButton backButton = toolbar.findViewById(R.id.close_button); + backButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + FragmentActivity fragmentActivity = getActivity(); + if (fragmentActivity != null) { + fragmentActivity.onBackPressed(); + } + } + }); + getSkuAppId(); + LinearLayout manageSubscriptionContainer = mainView.findViewById(R.id.manage_subscription_container); + manageSubscriptionContainer.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent intent = new Intent(Intent.ACTION_VIEW); + intent.setData(Uri.parse(url)); + if (AndroidUtils.isIntentSafe(context, intent)) { + startActivity(intent); + } + } + }); + TextView toolbarTitle = toolbar.findViewById(R.id.toolbar_title); + toolbarTitle.setText(getString(R.string.purchases)); + appbar.addView(toolbar); + } + + public void setFormatLink() { + TextView newDeviceAccountLink = mainView.findViewById(R.id.new_device_account_title); + TextView contactSupportLink = mainView.findViewById(R.id.contact_support_title); + TextView supportDescription = mainView.findViewById(R.id.support_link_title); + + SpannableString spannableStringSupport = new SpannableString(getString(R.string.contact_support)); + String urlSupport = "mailto:support@osmand.net"; + spannableStringSupport.setSpan(new URLSpan(urlSupport), 0, spannableStringSupport.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); + + SpannableString spannableStringNewDeviceAccount = new SpannableString(getString(R.string.new_device_account)); + String urlNewDeviceAccount = "https://docs.osmand.net/en/main@latest/osmand/purchases#new-device--new-account"; + spannableStringNewDeviceAccount.setSpan(new URLSpan(urlNewDeviceAccount), 0, spannableStringNewDeviceAccount.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); + + String emailString = getString(R.string.contact_support_mail); + String supportDescriptionString = getString(R.string.contact_support_description, emailString); + SpannableString spannableStringMail = new SpannableString(supportDescriptionString); + int startIndex = supportDescriptionString.indexOf(emailString); + int endIndex = startIndex + emailString.length(); + StyleSpan boldSpan = new StyleSpan(Typeface.BOLD); + spannableStringMail.setSpan(boldSpan, startIndex, endIndex, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); + + contactSupportLink.setText(spannableStringSupport); + newDeviceAccountLink.setText(spannableStringNewDeviceAccount); + supportDescription.setText(spannableStringMail); + + AndroidUtils.removeLinkUnderline(contactSupportLink); + AndroidUtils.removeLinkUnderline(newDeviceAccountLink); + + contactSupportLink.setMovementMethod(LinkMovementMethod.getInstance()); + newDeviceAccountLink.setMovementMethod(LinkMovementMethod.getInstance()); + } + + private void getSkuAppId() { + InAppPurchaseHelper purchaseHelper = app.getInAppPurchaseHelper(); + if (purchaseHelper != null) { + String sku = purchaseHelper.getFullVersion().getSku(); + url = String.format(PLAY_STORE_SUBSCRIPTION_DEEPLINK_URL, + sku, context.getPackageName()); + } else { + url = PLAY_STORE_SUBSCRIPTION_URL; + } + } } diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/PurchasesFragmentEmpty.java b/OsmAnd/src/net/osmand/plus/settings/fragments/PurchasesFragmentEmpty.java index f3fc5621fb..8fe8676cdc 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/PurchasesFragmentEmpty.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/PurchasesFragmentEmpty.java @@ -65,7 +65,9 @@ public class PurchasesFragmentEmpty extends BaseOsmAndFragment { osmandLive.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - ChoosePlanDialogFragment.showDialogInstance(getMyApplication(), getMyActivity().getSupportFragmentManager(), ChoosePlanDialogFragment.ChoosePlanDialogType.OSM_LIVE); + if (getMyApplication() != null && getMyActivity() != null) { + ChoosePlanDialogFragment.showDialogInstance(getMyApplication(), getMyActivity().getSupportFragmentManager(), ChoosePlanDialogFragment.ChoosePlanDialogType.OSM_LIVE); + } } }); setFormatLink(); From 8de07a2c59a42f9eecd5c5170bca4de132b0bbab Mon Sep 17 00:00:00 2001 From: androiddevkotlin <64539346+androiddevkotlin@users.noreply.github.com> Date: Mon, 22 Mar 2021 14:36:32 +0200 Subject: [PATCH 03/74] Second Iteration --- OsmAnd/res/layout/purchases_layout.xml | 7 +- OsmAnd/res/xml/settings_main_screen.xml | 1 - .../fragments/MainSettingsFragment.java | 8 ++- .../settings/fragments/PurchasesFragment.java | 64 ++++++++++++------- 4 files changed, 52 insertions(+), 28 deletions(-) diff --git a/OsmAnd/res/layout/purchases_layout.xml b/OsmAnd/res/layout/purchases_layout.xml index b0c12c905d..c5f9bb471b 100644 --- a/OsmAnd/res/layout/purchases_layout.xml +++ b/OsmAnd/res/layout/purchases_layout.xml @@ -11,11 +11,8 @@ android:layout_width="match_parent" android:layout_height="wrap_content"> - - - + android:paddingBottom="@dimen/card_padding" + android:clickable="true" + android:focusable="true"> Date: Tue, 23 Mar 2021 01:02:19 +0200 Subject: [PATCH 04/74] Review --- OsmAnd/res/layout/empty_purchases_layout.xml | 12 +- OsmAnd/res/layout/purchases_layout.xml | 25 +-- OsmAnd/res/values/attrs.xml | 2 +- OsmAnd/res/values/strings.xml | 1 - OsmAnd/res/values/styles.xml | 4 +- .../plus/activities/MapActivityActions.java | 16 -- .../settings/fragments/PurchasesFragment.java | 81 +++++++--- .../fragments/PurchasesFragmentEmpty.java | 150 ------------------ 8 files changed, 81 insertions(+), 210 deletions(-) delete mode 100644 OsmAnd/src/net/osmand/plus/settings/fragments/PurchasesFragmentEmpty.java diff --git a/OsmAnd/res/layout/empty_purchases_layout.xml b/OsmAnd/res/layout/empty_purchases_layout.xml index 7a19918581..ca7fdef2dd 100644 --- a/OsmAnd/res/layout/empty_purchases_layout.xml +++ b/OsmAnd/res/layout/empty_purchases_layout.xml @@ -12,13 +12,11 @@ android:layout_width="match_parent" android:layout_height="wrap_content"> - - + + + + app:tint="?attr/profile_icon_color_green" /> + + - + diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index b18a660072..30b850dba0 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -14,7 +14,6 @@ Please follow this link if you any issues with purchases. Troubleshooting - support@osmand.net Contact support If your purchases don\'t show up here, tap on “Restore purchases”, or contact our support team. If you have any questions, please contact us at %1$s. diff --git a/OsmAnd/res/values/styles.xml b/OsmAnd/res/values/styles.xml index 81c73d5697..113454ae88 100644 --- a/OsmAnd/res/values/styles.xml +++ b/OsmAnd/res/values/styles.xml @@ -218,7 +218,7 @@ @color/divider_color_light @color/text_color_primary_light @color/active_color_primary_light - @color/profile_icon_color_green_light + @color/profile_icon_color_green_light @color/card_and_list_background_light @color/activity_background_light @drawable/pages_bg_light @@ -520,7 +520,7 @@ @color/divider_color_dark @color/text_color_primary_dark @color/active_color_primary_dark - @color/profile_icon_color_green_dark + @color/profile_icon_color_green_dark @color/card_and_list_background_dark @color/activity_background_dark @drawable/pages_bg_dark diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java index c0fec48168..01ae04a0d8 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java @@ -1030,22 +1030,6 @@ public class MapActivityActions implements DialogProvider { }).createItem()); */ - if (Version.isGooglePlayEnabled() || Version.isHuawei() || Version.isDeveloperVersion(app)) { - optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.purchases, mapActivity) - .setId(DRAWER_OSMAND_LIVE_ID) - .setIcon(R.drawable.ic_action_purchases) - .setListener(new ItemClickListener() { - @Override - public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) { - app.logEvent("drawer_osm_live_open"); - Intent intent = new Intent(mapActivity, OsmLiveActivity.class); - intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); - mapActivity.startActivity(intent); - return true; - } - }).createItem()); - } - optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.shared_string_help, mapActivity) .setId(DRAWER_HELP_ID) .setIcon(R.drawable.ic_action_help) diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/PurchasesFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/PurchasesFragment.java index c70b7a8cc4..fccfd40d48 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/PurchasesFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/PurchasesFragment.java @@ -32,9 +32,11 @@ import net.osmand.AndroidUtils; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; +import net.osmand.plus.Version; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.OsmandInAppPurchaseActivity; import net.osmand.plus.base.BaseOsmAndFragment; +import net.osmand.plus.chooseplan.ChoosePlanDialogFragment; import net.osmand.plus.inapp.InAppPurchaseHelper; import net.osmand.plus.liveupdates.LiveUpdatesFragmentNew; import net.osmand.plus.liveupdates.OsmLiveActivity; @@ -43,6 +45,7 @@ import net.osmand.plus.wikipedia.WikipediaDialogFragment; public class PurchasesFragment extends BaseOsmAndFragment { public static final String TAG = PurchasesFragment.class.getName(); + public static final String KEY_IS_SUBSCRIBER = "action_is_new"; private static final String PLAY_STORE_SUBSCRIPTION_URL = "https://play.google.com/store/account/subscriptions"; private static final String PLAY_STORE_SUBSCRIPTION_DEEPLINK_URL = "https://play.google.com/store/account/subscriptions?sku=%s&package=%s"; private InAppPurchaseHelper purchaseHelper; @@ -50,6 +53,7 @@ public class PurchasesFragment extends BaseOsmAndFragment { private Context context; private OsmandApplication app; private String url; + private Boolean isSubscriber; public static boolean showInstance(FragmentManager fragmentManager) { try { @@ -74,12 +78,26 @@ public class PurchasesFragment extends BaseOsmAndFragment { app = getMyApplication(); context = requireContext(); purchaseHelper = getInAppPurchaseHelper(); - - + isSubscriber = Version.isPaidVersion(app); final MapActivity mapActivity = (MapActivity) getActivity(); final boolean nightMode = !getMyApplication().getSettings().isLightContent(); LayoutInflater themedInflater = UiUtilities.getInflater(context, nightMode); - mainView = themedInflater.inflate(R.layout.purchases_layout, container, false); + + if (!isSubscriber) { + mainView = themedInflater.inflate(R.layout.purchases_layout, container, false); + setSubscriptionClick(mapActivity); + } else { + mainView = themedInflater.inflate(R.layout.empty_purchases_layout, container, false); + LinearLayout osmandLive = mainView.findViewById(R.id.osmand_live); + osmandLive.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (getMyApplication() != null && getMyActivity() != null) { + ChoosePlanDialogFragment.showDialogInstance(getMyApplication(), getMyActivity().getSupportFragmentManager(), ChoosePlanDialogFragment.ChoosePlanDialogType.OSM_LIVE); + } + } + }); + } AndroidUtils.addStatusBarPadding21v(getActivity(), mainView); createToolbar(mainView, nightMode); mainView.setOnTouchListener(new View.OnTouchListener() { @@ -87,7 +105,6 @@ public class PurchasesFragment extends BaseOsmAndFragment { return true; } }); - LinearLayout purchasesRestore = mainView.findViewById(R.id.restore_purchases); purchasesRestore.setOnClickListener(new View.OnClickListener() { @Override @@ -97,6 +114,33 @@ public class PurchasesFragment extends BaseOsmAndFragment { } } }); + LinearLayout newDeviceAccountContainer = mainView.findViewById(R.id.new_device_account_container); + newDeviceAccountContainer.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + WikipediaDialogFragment.showFullArticle(context, Uri.parse("https://docs.osmand.net/en/main@latest/osmand/purchases#new-device--new-account"), nightMode); + } + }); + + setFormatLink(); + return mainView; + } + + @Override + public void onSaveInstanceState(@NonNull Bundle outState) { + super.onSaveInstanceState(outState); + outState.putBoolean(KEY_IS_SUBSCRIBER, isSubscriber); + } + + @Override + public void onViewStateRestored(@Nullable Bundle savedInstanceState) { + super.onViewStateRestored(savedInstanceState); + if (savedInstanceState != null) { + savedInstanceState.getBoolean(KEY_IS_SUBSCRIBER); + } + } + + private void setSubscriptionClick(final MapActivity mapActivity) { LinearLayout reportContainer = mainView.findViewById(R.id.report_container); reportContainer.setOnClickListener(new View.OnClickListener() { @Override @@ -118,16 +162,18 @@ public class PurchasesFragment extends BaseOsmAndFragment { } } }); - LinearLayout newDeviceAccountContainer = mainView.findViewById(R.id.new_device_account_container); - newDeviceAccountContainer.setOnClickListener(new View.OnClickListener() { + getSkuAppId(); + LinearLayout manageSubscriptionContainer = mainView.findViewById(R.id.manage_subscription_container); + manageSubscriptionContainer.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - WikipediaDialogFragment.showFullArticle(context, Uri.parse("https://docs.osmand.net/en/main@latest/osmand/purchases#new-device--new-account"), nightMode); + Intent intent = new Intent(Intent.ACTION_VIEW); + intent.setData(Uri.parse(url)); + if (AndroidUtils.isIntentSafe(context, intent)) { + startActivity(intent); + } } }); - - setFormatLink(); - return mainView; } @Nullable @@ -163,18 +209,7 @@ public class PurchasesFragment extends BaseOsmAndFragment { } } }); - getSkuAppId(); - LinearLayout manageSubscriptionContainer = mainView.findViewById(R.id.manage_subscription_container); - manageSubscriptionContainer.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - Intent intent = new Intent(Intent.ACTION_VIEW); - intent.setData(Uri.parse(url)); - if (AndroidUtils.isIntentSafe(context, intent)) { - startActivity(intent); - } - } - }); + TextView toolbarTitle = toolbar.findViewById(R.id.toolbar_title); toolbarTitle.setText(getString(R.string.purchases)); appbar.addView(toolbar); @@ -188,7 +223,7 @@ public class PurchasesFragment extends BaseOsmAndFragment { String urlSupport = "mailto:support@osmand.net"; spannableStringSupport.setSpan(new URLSpan(urlSupport), 0, spannableStringSupport.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); - String emailString = getString(R.string.contact_support_mail); + String emailString = "support@osmand.net"; String supportDescriptionString = getString(R.string.contact_support_description, emailString); SpannableString spannableStringMail = new SpannableString(supportDescriptionString); int startIndex = supportDescriptionString.indexOf(emailString); diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/PurchasesFragmentEmpty.java b/OsmAnd/src/net/osmand/plus/settings/fragments/PurchasesFragmentEmpty.java deleted file mode 100644 index 8fe8676cdc..0000000000 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/PurchasesFragmentEmpty.java +++ /dev/null @@ -1,150 +0,0 @@ -package net.osmand.plus.settings.fragments; - -import android.app.Activity; -import android.content.Context; -import android.content.Intent; -import android.graphics.Typeface; -import android.net.Uri; -import android.os.Bundle; -import android.text.Spannable; -import android.text.SpannableString; -import android.text.Spanned; -import android.text.method.LinkMovementMethod; -import android.text.style.StyleSpan; -import android.text.style.URLSpan; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ImageButton; -import android.widget.ImageView; -import android.widget.LinearLayout; -import android.widget.TextView; - -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.fragment.app.FragmentActivity; - -import com.google.android.material.appbar.AppBarLayout; - -import net.osmand.AndroidUtils; -import net.osmand.plus.R; -import net.osmand.plus.UiUtilities; -import net.osmand.plus.activities.OsmandInAppPurchaseActivity; -import net.osmand.plus.base.BaseOsmAndFragment; -import net.osmand.plus.chooseplan.ChoosePlanDialogFragment; -import net.osmand.plus.inapp.InAppPurchaseHelper; - -public class PurchasesFragmentEmpty extends BaseOsmAndFragment { - public static final String TAG = PurchasesFragmentEmpty.class.getName(); - private InAppPurchaseHelper purchaseHelper; - private View mainView; - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - } - - @Override - public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - Context context = requireContext(); - purchaseHelper = getInAppPurchaseHelper(); - boolean nightMode = !getMyApplication().getSettings().isLightContent(); - LayoutInflater themedInflater = UiUtilities.getInflater(context, nightMode); - mainView = themedInflater.inflate(R.layout.empty_purchases_layout, container, false); - createToolbar(mainView, nightMode); - LinearLayout purchasesRestore = mainView.findViewById(R.id.restore_purchases); - purchasesRestore.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - if (purchaseHelper != null && !purchaseHelper.hasInventory()) { - purchaseHelper.requestInventory(); - } - } - }); - LinearLayout osmandLive = mainView.findViewById(R.id.osmand_live); - osmandLive.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - if (getMyApplication() != null && getMyActivity() != null) { - ChoosePlanDialogFragment.showDialogInstance(getMyApplication(), getMyActivity().getSupportFragmentManager(), ChoosePlanDialogFragment.ChoosePlanDialogType.OSM_LIVE); - } - } - }); - setFormatLink(); - return mainView; - } - - @Nullable - public InAppPurchaseHelper getInAppPurchaseHelper() { - Activity activity = getActivity(); - if (activity instanceof OsmandInAppPurchaseActivity) { - return ((OsmandInAppPurchaseActivity) activity).getPurchaseHelper(); - } else { - return null; - } - } - - private void createToolbar(View mainView, boolean nightMode) { - AppBarLayout appbar = mainView.findViewById(R.id.appbar); - View toolbar = UiUtilities.getInflater(getContext(), nightMode).inflate(R.layout.profile_preference_toolbar_with_icon, appbar, false); - - View iconToolbarContainer = toolbar.findViewById(R.id.icon_toolbar); - ImageView icon = iconToolbarContainer.findViewById(R.id.profile_icon); - icon.setImageResource(R.drawable.ic_action_help_online); - icon.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - Uri uri = Uri.parse("https://docs.osmand.net/en/main@latest/osmand/purchases"); - Intent intent = new Intent(Intent.ACTION_VIEW, uri); - startActivity(intent); - } - }); - ImageButton backButton = toolbar.findViewById(R.id.close_button); - backButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - FragmentActivity fragmentActivity = getActivity(); - if (fragmentActivity != null) { - fragmentActivity.onBackPressed(); - } - } - }); - TextView toolbarTitle = toolbar.findViewById(R.id.toolbar_title); - toolbarTitle.setText(getString(R.string.purchases)); - appbar.addView(toolbar); - } - - public void setFormatLink() { - TextView newDeviceAccountLink = mainView.findViewById(R.id.new_device_account_title); - TextView contactSupportLink = mainView.findViewById(R.id.contact_support_title); - TextView supportDescription = mainView.findViewById(R.id.support_link_title); - - SpannableString spannableStringSupport = new SpannableString(getString(R.string.contact_support)); - String urlSupport = "mailto:support@osmand.net"; - spannableStringSupport.setSpan(new URLSpan(urlSupport), 0, spannableStringSupport.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); - - SpannableString spannableStringNewDeviceAccount = new SpannableString(getString(R.string.new_device_account)); - String urlNewDeviceAccount = "https://docs.osmand.net/en/main@latest/osmand/purchases#new-device--new-account"; - spannableStringNewDeviceAccount.setSpan(new URLSpan(urlNewDeviceAccount), 0, spannableStringNewDeviceAccount.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); - - String emailString = getString(R.string.contact_support_mail); - String supportDescriptionString = getString(R.string.contact_support_description, emailString); - SpannableString spannableStringMail = new SpannableString(supportDescriptionString); - int startIndex = supportDescriptionString.indexOf(emailString); - int endIndex = startIndex + emailString.length(); - StyleSpan boldSpan = new StyleSpan(Typeface.BOLD); - spannableStringMail.setSpan(boldSpan, startIndex, endIndex, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); - - contactSupportLink.setText(spannableStringSupport); - newDeviceAccountLink.setText(spannableStringNewDeviceAccount); - supportDescription.setText(spannableStringMail); - - AndroidUtils.removeLinkUnderline(contactSupportLink); - AndroidUtils.removeLinkUnderline(newDeviceAccountLink); - - contactSupportLink.setMovementMethod(LinkMovementMethod.getInstance()); - newDeviceAccountLink.setMovementMethod(LinkMovementMethod.getInstance()); - - } - -} From 294bc53ecde2393e25337226aad07a87c5921fd4 Mon Sep 17 00:00:00 2001 From: androiddevkotlin <64539346+androiddevkotlin@users.noreply.github.com> Date: Tue, 23 Mar 2021 14:01:11 +0200 Subject: [PATCH 05/74] Minor addition strings format --- OsmAnd/res/values/strings.xml | 2 +- .../plus/settings/fragments/PurchasesFragment.java | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 30b850dba0..1117181317 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -15,7 +15,7 @@ Please follow this link if you any issues with purchases. Troubleshooting Contact support - If your purchases don\'t show up here, tap on “Restore purchases”, or contact our support team. + If your purchases don\'t show up here, tap on “%1$s”, or contact our support team. If you have any questions, please contact us at %1$s. New device / new account You don\'t have any purchases diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/PurchasesFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/PurchasesFragment.java index fccfd40d48..32b0bf2f38 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/PurchasesFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/PurchasesFragment.java @@ -122,7 +122,7 @@ public class PurchasesFragment extends BaseOsmAndFragment { } }); - setFormatLink(); + setFormatStrings(); return mainView; } @@ -215,9 +215,14 @@ public class PurchasesFragment extends BaseOsmAndFragment { appbar.addView(toolbar); } - public void setFormatLink() { + public void setFormatStrings() { TextView contactSupportLink = mainView.findViewById(R.id.contact_support_title); TextView supportDescription = mainView.findViewById(R.id.support_link_title); + TextView infoDescription = mainView.findViewById(R.id.info_description); + + String restorePurchases = getString(R.string.restore_purchases); + String infoPurchases = String.format(getString(R.string.empty_purchases_description), restorePurchases); + infoDescription.setText(infoPurchases); SpannableString spannableStringSupport = new SpannableString(getString(R.string.contact_support)); String urlSupport = "mailto:support@osmand.net"; From edc741e84fcec133bd3b5a553ccdb1f23f7b5ec1 Mon Sep 17 00:00:00 2001 From: androiddevkotlin <64539346+androiddevkotlin@users.noreply.github.com> Date: Tue, 23 Mar 2021 14:26:15 +0200 Subject: [PATCH 06/74] NPE fix --- OsmAnd/res/layout/empty_purchases_layout.xml | 8 ++++---- .../plus/settings/fragments/PurchasesFragment.java | 11 ++++++----- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/OsmAnd/res/layout/empty_purchases_layout.xml b/OsmAnd/res/layout/empty_purchases_layout.xml index ca7fdef2dd..56bfb82b6f 100644 --- a/OsmAnd/res/layout/empty_purchases_layout.xml +++ b/OsmAnd/res/layout/empty_purchases_layout.xml @@ -69,7 +69,7 @@ android:id="@+id/restore_purchases" android:layout_width="match_parent" android:layout_height="wrap_content" - android:background="@android:drawable/list_selector_background" + android:background="?android:attr/selectableItemBackground" android:minHeight="@dimen/list_item_height" android:paddingStart="@dimen/list_content_padding" android:paddingLeft="@dimen/list_content_padding" @@ -115,7 +115,7 @@ android:id="@+id/new_device_account_container" android:layout_width="match_parent" android:layout_height="wrap_content" - android:background="@android:drawable/list_selector_background" + android:background="?android:attr/selectableItemBackground" android:minHeight="@dimen/list_item_height" android:paddingStart="@dimen/list_content_padding" android:paddingLeft="@dimen/list_content_padding" @@ -153,7 +153,7 @@ android:id="@+id/support_link_container" android:layout_width="match_parent" android:layout_height="wrap_content" - android:background="@android:drawable/list_selector_background" + android:background="?android:attr/selectableItemBackground" android:minHeight="@dimen/list_item_height" android:paddingStart="@dimen/list_content_padding" android:paddingLeft="@dimen/list_content_padding" @@ -189,7 +189,7 @@ android:id="@+id/contact_support_container" android:layout_width="match_parent" android:layout_height="wrap_content" - android:background="@android:drawable/list_selector_background" + android:background="?android:attr/selectableItemBackground" android:paddingStart="@dimen/action_bar_image_side_margin" android:paddingLeft="@dimen/action_bar_image_side_margin" android:paddingTop="@dimen/card_padding" diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/PurchasesFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/PurchasesFragment.java index 32b0bf2f38..9fb4047ca5 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/PurchasesFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/PurchasesFragment.java @@ -97,6 +97,11 @@ public class PurchasesFragment extends BaseOsmAndFragment { } } }); + TextView infoDescription = mainView.findViewById(R.id.info_description); + + String restorePurchases = getString(R.string.restore_purchases); + String infoPurchases = String.format(getString(R.string.empty_purchases_description), restorePurchases); + infoDescription.setText(infoPurchases); } AndroidUtils.addStatusBarPadding21v(getActivity(), mainView); createToolbar(mainView, nightMode); @@ -174,6 +179,7 @@ public class PurchasesFragment extends BaseOsmAndFragment { } } }); + } @Nullable @@ -218,11 +224,6 @@ public class PurchasesFragment extends BaseOsmAndFragment { public void setFormatStrings() { TextView contactSupportLink = mainView.findViewById(R.id.contact_support_title); TextView supportDescription = mainView.findViewById(R.id.support_link_title); - TextView infoDescription = mainView.findViewById(R.id.info_description); - - String restorePurchases = getString(R.string.restore_purchases); - String infoPurchases = String.format(getString(R.string.empty_purchases_description), restorePurchases); - infoDescription.setText(infoPurchases); SpannableString spannableStringSupport = new SpannableString(getString(R.string.contact_support)); String urlSupport = "mailto:support@osmand.net"; From 3e4153a5cb885d7957be18ac261ffea4a5c35e9f Mon Sep 17 00:00:00 2001 From: cepprice Date: Tue, 23 Mar 2021 23:36:38 +0500 Subject: [PATCH 07/74] Add subscription card --- OsmAnd/res/drawable/bg_osmand_live_active.xml | 5 + .../res/drawable/bg_osmand_live_cancelled.xml | 5 + OsmAnd/res/drawable/btn_solid_border_dark.xml | 7 + .../res/drawable/btn_solid_border_light.xml | 7 + .../layout/dialog_edit_gpx_description.xml | 4 +- OsmAnd/res/layout/purchases_layout.xml | 586 +++++++++--------- OsmAnd/res/layout/subscription_layout.xml | 108 ++++ OsmAnd/res/layout/subscriptions_card.xml | 5 + OsmAnd/res/values/colors.xml | 2 + OsmAnd/res/values/strings.xml | 10 + .../net/osmand/plus/inapp/InAppPurchases.java | 34 +- .../settings/fragments/PurchasesFragment.java | 39 +- .../settings/fragments/SubscriptionsCard.java | 179 ++++++ .../GpxEditDescriptionDialogFragment.java | 15 +- 14 files changed, 703 insertions(+), 303 deletions(-) create mode 100644 OsmAnd/res/drawable/bg_osmand_live_active.xml create mode 100644 OsmAnd/res/drawable/bg_osmand_live_cancelled.xml create mode 100644 OsmAnd/res/drawable/btn_solid_border_dark.xml create mode 100644 OsmAnd/res/drawable/btn_solid_border_light.xml create mode 100644 OsmAnd/res/layout/subscription_layout.xml create mode 100644 OsmAnd/res/layout/subscriptions_card.xml create mode 100644 OsmAnd/src/net/osmand/plus/settings/fragments/SubscriptionsCard.java diff --git a/OsmAnd/res/drawable/bg_osmand_live_active.xml b/OsmAnd/res/drawable/bg_osmand_live_active.xml new file mode 100644 index 0000000000..8544f60004 --- /dev/null +++ b/OsmAnd/res/drawable/bg_osmand_live_active.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/OsmAnd/res/drawable/bg_osmand_live_cancelled.xml b/OsmAnd/res/drawable/bg_osmand_live_cancelled.xml new file mode 100644 index 0000000000..2774bc263a --- /dev/null +++ b/OsmAnd/res/drawable/bg_osmand_live_cancelled.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/OsmAnd/res/drawable/btn_solid_border_dark.xml b/OsmAnd/res/drawable/btn_solid_border_dark.xml new file mode 100644 index 0000000000..5f0ecb368b --- /dev/null +++ b/OsmAnd/res/drawable/btn_solid_border_dark.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/drawable/btn_solid_border_light.xml b/OsmAnd/res/drawable/btn_solid_border_light.xml new file mode 100644 index 0000000000..528f174597 --- /dev/null +++ b/OsmAnd/res/drawable/btn_solid_border_light.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/layout/dialog_edit_gpx_description.xml b/OsmAnd/res/layout/dialog_edit_gpx_description.xml index 66c0d57f0a..a2997960b9 100644 --- a/OsmAnd/res/layout/dialog_edit_gpx_description.xml +++ b/OsmAnd/res/layout/dialog_edit_gpx_description.xml @@ -45,7 +45,7 @@ osmand:typeface="@string/font_roboto_medium" /> - + android:layout_height="match_parent"> - - - + android:orientation="vertical"> - + - + - + - + - + - + - + - + - + - + - + - - + - + - + - + - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/layout/subscription_layout.xml b/OsmAnd/res/layout/subscription_layout.xml new file mode 100644 index 0000000000..de35b80f4a --- /dev/null +++ b/OsmAnd/res/layout/subscription_layout.xml @@ -0,0 +1,108 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OsmAnd/res/layout/subscriptions_card.xml b/OsmAnd/res/layout/subscriptions_card.xml new file mode 100644 index 0000000000..278f381933 --- /dev/null +++ b/OsmAnd/res/layout/subscriptions_card.xml @@ -0,0 +1,5 @@ + + \ No newline at end of file diff --git a/OsmAnd/res/values/colors.xml b/OsmAnd/res/values/colors.xml index 410723dc79..8d9f9dc24a 100644 --- a/OsmAnd/res/values/colors.xml +++ b/OsmAnd/res/values/colors.xml @@ -75,6 +75,8 @@ #d28521 #237bff #d28521 + #14CC70 + #EE5622 #505050 diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 1117181317..3e81d699c3 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -12,6 +12,16 @@ --> + Expired + On hold + In grace period + Renew subscription + Cancelled + Next billing date: %1$s + Three months subscription + Monthly subscription + Annual subscription + OsmAnd Live Please follow this link if you any issues with purchases. Troubleshooting Contact support diff --git a/OsmAnd/src/net/osmand/plus/inapp/InAppPurchases.java b/OsmAnd/src/net/osmand/plus/inapp/InAppPurchases.java index e6ec431187..8a6d5a0128 100644 --- a/OsmAnd/src/net/osmand/plus/inapp/InAppPurchases.java +++ b/OsmAnd/src/net/osmand/plus/inapp/InAppPurchases.java @@ -8,8 +8,10 @@ import android.text.SpannableStringBuilder; import android.text.style.ForegroundColorSpan; import androidx.annotation.ColorInt; +import androidx.annotation.DrawableRes; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.annotation.StringRes; import net.osmand.AndroidUtils; import net.osmand.Period; @@ -580,24 +582,40 @@ public abstract class InAppPurchases { private InAppSubscriptionIntroductoryInfo introductoryInfo; public enum SubscriptionState { - UNDEFINED("undefined"), - ACTIVE("active"), - CANCELLED("cancelled"), - IN_GRACE_PERIOD("in_grace_period"), - ON_HOLD("on_hold"), - PAUSED("paused"), - EXPIRED("expired"); + UNDEFINED("undefined", 0, 0), + ACTIVE("active", R.string.osm_live_active, R.drawable.bg_osmand_live_active), + CANCELLED("cancelled", R.string.osmand_live_cancelled, R.drawable.bg_osmand_live_cancelled), + IN_GRACE_PERIOD("in_grace_period", R.string.in_grace_period, R.drawable.bg_osmand_live_active), + ON_HOLD("on_hold", R.string.on_hold, R.drawable.bg_osmand_live_cancelled), + PAUSED("paused", R.string.shared_string_paused, R.drawable.bg_osmand_live_cancelled), + EXPIRED("expired", R.string.expired, R.drawable.bg_osmand_live_cancelled); private final String stateStr; + @StringRes + private final int stringRes; + @DrawableRes + private final int backgroundRes; - SubscriptionState(@NonNull String stateStr) { + SubscriptionState(@NonNull String stateStr, @StringRes int stringRes, @DrawableRes int backgroundRes) { this.stateStr = stateStr; + this.stringRes = stringRes; + this.backgroundRes = backgroundRes; } public String getStateStr() { return stateStr; } + @StringRes + public int getStringRes() { + return stringRes; + } + + @DrawableRes + public int getBackgroundRes() { + return backgroundRes; + } + @NonNull public static SubscriptionState getByStateStr(@NonNull String stateStr) { for (SubscriptionState state : SubscriptionState.values()) { diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/PurchasesFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/PurchasesFragment.java index 9fb4047ca5..6b5a9c5d5f 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/PurchasesFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/PurchasesFragment.java @@ -38,11 +38,12 @@ import net.osmand.plus.activities.OsmandInAppPurchaseActivity; import net.osmand.plus.base.BaseOsmAndFragment; import net.osmand.plus.chooseplan.ChoosePlanDialogFragment; import net.osmand.plus.inapp.InAppPurchaseHelper; +import net.osmand.plus.inapp.InAppPurchaseHelper.InAppPurchaseListener; import net.osmand.plus.liveupdates.LiveUpdatesFragmentNew; import net.osmand.plus.liveupdates.OsmLiveActivity; import net.osmand.plus.wikipedia.WikipediaDialogFragment; -public class PurchasesFragment extends BaseOsmAndFragment { +public class PurchasesFragment extends BaseOsmAndFragment implements InAppPurchaseListener { public static final String TAG = PurchasesFragment.class.getName(); public static final String KEY_IS_SUBSCRIBER = "action_is_new"; @@ -50,6 +51,7 @@ public class PurchasesFragment extends BaseOsmAndFragment { private static final String PLAY_STORE_SUBSCRIPTION_DEEPLINK_URL = "https://play.google.com/store/account/subscriptions?sku=%s&package=%s"; private InAppPurchaseHelper purchaseHelper; private View mainView; + private SubscriptionsCard subscriptionsCard; private Context context; private OsmandApplication app; private String url; @@ -83,9 +85,14 @@ public class PurchasesFragment extends BaseOsmAndFragment { final boolean nightMode = !getMyApplication().getSettings().isLightContent(); LayoutInflater themedInflater = UiUtilities.getInflater(context, nightMode); - if (!isSubscriber) { + if (isSubscriber) { mainView = themedInflater.inflate(R.layout.purchases_layout, container, false); setSubscriptionClick(mapActivity); + if (mapActivity != null && purchaseHelper != null) { + ViewGroup subscriptionsCardContainer = mainView.findViewById(R.id.subscriptions_card_container); + subscriptionsCard = new SubscriptionsCard(mapActivity, purchaseHelper); + subscriptionsCardContainer.addView(subscriptionsCard.build(mapActivity)); + } } else { mainView = themedInflater.inflate(R.layout.empty_purchases_layout, container, false); LinearLayout osmandLive = mainView.findViewById(R.id.osmand_live); @@ -114,7 +121,7 @@ public class PurchasesFragment extends BaseOsmAndFragment { purchasesRestore.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - if (purchaseHelper != null && !purchaseHelper.hasInventory()) { + if (purchaseHelper != null) { purchaseHelper.requestInventory(); } } @@ -255,4 +262,30 @@ public class PurchasesFragment extends BaseOsmAndFragment { url = PLAY_STORE_SUBSCRIPTION_URL; } } + + @Override + public void onError(InAppPurchaseHelper.InAppPurchaseTaskType taskType, String error) { + } + + @Override + public void onGetItems() { + if (subscriptionsCard != null) { + subscriptionsCard.update(); + } + } + + @Override + public void onItemPurchased(String sku, boolean active) { + if (purchaseHelper != null) { + purchaseHelper.requestInventory(); + } + } + + @Override + public void showProgress(InAppPurchaseHelper.InAppPurchaseTaskType taskType) { + } + + @Override + public void dismissProgress(InAppPurchaseHelper.InAppPurchaseTaskType taskType) { + } } diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/SubscriptionsCard.java b/OsmAnd/src/net/osmand/plus/settings/fragments/SubscriptionsCard.java new file mode 100644 index 0000000000..40ef081602 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/SubscriptionsCard.java @@ -0,0 +1,179 @@ +package net.osmand.plus.settings.fragments; + +import android.os.Build; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; +import android.widget.Toast; + +import net.osmand.AndroidUtils; +import net.osmand.Period; +import net.osmand.plus.R; +import net.osmand.plus.activities.MapActivity; +import net.osmand.plus.helpers.AndroidUiHelper; +import net.osmand.plus.inapp.InAppPurchaseHelper; +import net.osmand.plus.inapp.InAppPurchases.InAppSubscription; +import net.osmand.plus.inapp.InAppPurchases.InAppSubscription.SubscriptionState; +import net.osmand.plus.routepreparationmenu.cards.BaseCard; +import net.osmand.plus.settings.backend.OsmandSettings; +import net.osmand.util.Algorithms; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +import androidx.annotation.NonNull; +import androidx.appcompat.view.ContextThemeWrapper; +import androidx.core.content.ContextCompat; + +public class SubscriptionsCard extends BaseCard { + + private final InAppPurchaseHelper purchaseHelper; + + @Override + public int getCardLayoutId() { + return R.layout.subscriptions_card; + } + + public SubscriptionsCard(@NonNull MapActivity mapActivity, @NonNull InAppPurchaseHelper purchaseHelper) { + super(mapActivity); + this.purchaseHelper = purchaseHelper; + } + + @Override + protected void updateContent() { + if (mapActivity == null) { + return; + } + + List subscriptions = getActiveAndCancelledSubscriptions(); + if (Algorithms.isEmpty(subscriptions)) { + return; + } + + ContextThemeWrapper ctx = new ContextThemeWrapper(mapActivity, !nightMode ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme); + LayoutInflater inflater = LayoutInflater.from(ctx); + ((ViewGroup) view).removeAllViews(); + + for (int i = 0; i < subscriptions.size(); i++) { + InAppSubscription subscription = subscriptions.get(i); + SubscriptionState state = subscription.getState(); + boolean autoRenewed = SubscriptionState.ACTIVE.equals(state) || SubscriptionState.IN_GRACE_PERIOD.equals(state); + + View card = inflater.inflate(R.layout.subscription_layout, null, false); + ((ViewGroup) view).addView(card); + + TextView subscriptionPeriod = card.findViewById(R.id.subscription_type); + String period = getSubscriptionPeriod(subscription.getSubscriptionPeriod()); + if (!Algorithms.isEmpty(period)) { + subscriptionPeriod.setText(period); + AndroidUiHelper.updateVisibility(subscriptionPeriod, true); + } + + if (autoRenewed) { + TextView nextBillingDate = card.findViewById(R.id.next_billing_date); + String date = getHumanDate(subscription.getPurchaseTime(), subscription.getSubscriptionPeriod()); + if (!Algorithms.isEmpty(date)) { + nextBillingDate.setText(app.getString(R.string.next_billing_date, date)); + AndroidUiHelper.updateVisibility(nextBillingDate, true); + } + } + + TextView status = card.findViewById(R.id.status); + status.setText(app.getString(state.getStringRes())); + status.setBackgroundDrawable(ContextCompat.getDrawable(mapActivity, state.getBackgroundRes())); + + if (!autoRenewed) { + View renewContainer = card.findViewById(R.id.renewContainer); + AndroidUiHelper.updateVisibility(renewContainer, true); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + AndroidUtils.setBackground(ctx, renewContainer, nightMode, R.drawable.ripple_light, R.drawable.ripple_dark); + } else { + AndroidUtils.setBackground(ctx, renewContainer, nightMode, R.drawable.btn_unstroked_light, R.drawable.btn_unstroked_dark); + } + final String sku = subscription.getSku(); + renewContainer.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + subscribe(sku); + } + }); + + View renew = card.findViewById(R.id.renew); + AndroidUtils.setBackground(ctx, renew, nightMode, + R.drawable.btn_solid_border_light, R.drawable.btn_solid_border_dark); + } + + int dividerLayout = i + 1 == subscriptions.size() ? R.layout.simple_divider_item : R.layout.divider_half_item; + View divider = inflater.inflate(dividerLayout, (ViewGroup) view, false); + ((ViewGroup) view).addView(divider); + } + } + + private String getHumanDate(long time, Period period) { + Date date = new Date(time); + int monthsCount; + if (period == null || period.getUnit() == null) { + return ""; + } else if (period.getUnit().equals(Period.PeriodUnit.YEAR)) { + monthsCount = 12; + } else { + monthsCount = period.getNumberOfUnits(); + } + Calendar calendar = Calendar.getInstance(); + calendar.setTime(date); + calendar.add(Calendar.MONTH, monthsCount); + date = calendar.getTime(); + SimpleDateFormat format = new SimpleDateFormat("MMM d, yyyy", app.getLocaleHelper().getPreferredLocale()); + return format.format(date); + } + + private void subscribe(String sku) { + if (app == null) { + return; + } + if (!app.getSettings().isInternetConnectionAvailable(true)) { + Toast.makeText(app, R.string.internet_not_available, Toast.LENGTH_LONG).show(); + } else if (mapActivity != null && purchaseHelper != null) { + OsmandSettings settings = app.getSettings(); + purchaseHelper.purchaseLiveUpdates(mapActivity, sku, + settings.BILLING_USER_EMAIL.get(), + settings.BILLING_USER_NAME.get(), + settings.BILLING_USER_COUNTRY_DOWNLOAD_NAME.get(), + settings.BILLING_HIDE_USER_NAME.get()); + } + } + + private String getSubscriptionPeriod(Period period) { + if (period == null || period.getUnit() == null) { + return ""; + } else if (period.getUnit().equals(Period.PeriodUnit.YEAR)) { + return app.getString(R.string.annual_subscription); + } else if (period.getUnit().equals(Period.PeriodUnit.MONTH)) { + int unitsNumber = period.getNumberOfUnits(); + if (unitsNumber == 1) { + return app.getString(R.string.monthly_subscription); + } else if (unitsNumber == 3) { + return app.getString(R.string.three_months_subscription); + } + } + return ""; + } + + private List getActiveAndCancelledSubscriptions() { + List subscriptions = new ArrayList<>(); + for (InAppSubscription subscription : purchaseHelper.getLiveUpdates().getVisibleSubscriptions()) { + if (shouldShowSubscription(subscription)) { + subscriptions.add(subscription); + } + } + return subscriptions; + } + + private boolean shouldShowSubscription(InAppSubscription s) { + return s.getState() != null && !SubscriptionState.UNDEFINED.equals(s.getState()); + } +} \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/track/GpxEditDescriptionDialogFragment.java b/OsmAnd/src/net/osmand/plus/track/GpxEditDescriptionDialogFragment.java index b8ef1c24d2..52536316b8 100644 --- a/OsmAnd/src/net/osmand/plus/track/GpxEditDescriptionDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/track/GpxEditDescriptionDialogFragment.java @@ -110,9 +110,8 @@ public class GpxEditDescriptionDialogFragment extends BaseOsmAndDialogFragment { } private void setupSaveButton(View view) { - View btnSave = view.findViewById(R.id.btn_save); - - btnSave.setOnClickListener(new View.OnClickListener() { + View btnSaveContainer = view.findViewById(R.id.btn_save_container); + btnSaveContainer.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Editable editable = editableHtml.getText(); @@ -122,12 +121,16 @@ public class GpxEditDescriptionDialogFragment extends BaseOsmAndDialogFragment { } }); - Context ctx = btnSave.getContext(); + Context ctx = btnSaveContainer.getContext(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - AndroidUtils.setBackground(ctx, btnSave, isNightMode(true), R.drawable.ripple_light, R.drawable.ripple_dark); + AndroidUtils.setBackground(ctx, btnSaveContainer, isNightMode(true), R.drawable.ripple_light, R.drawable.ripple_dark); } else { - AndroidUtils.setBackground(ctx, btnSave, isNightMode(true), R.drawable.btn_unstroked_light, R.drawable.btn_unstroked_dark); + AndroidUtils.setBackground(ctx, btnSaveContainer, isNightMode(true), R.drawable.btn_unstroked_light, R.drawable.btn_unstroked_dark); } + + View btnSave = view.findViewById(R.id.btn_save); + int drawableRes = isNightMode(true) ? R.drawable.btn_solid_border_dark : R.drawable.btn_solid_border_light; + btnSave.setBackgroundDrawable(ContextCompat.getDrawable(ctx, drawableRes)); } private void showDismissDialog() { From 03f0f19caef2f496a4630f58b6b436c12c668583 Mon Sep 17 00:00:00 2001 From: cepprice Date: Wed, 24 Mar 2021 02:41:47 +0500 Subject: [PATCH 08/74] Add UI of support region setting --- OsmAnd/res/layout/purchases_layout.xml | 66 ++++++++++ .../plus/inapp/InAppPurchaseHelper.java | 12 ++ .../liveupdates/CountrySelectionFragment.java | 2 + .../plus/liveupdates/LiveUpdatesFragment.java | 26 +--- .../liveupdates/SubscriptionFragment.java | 2 +- .../settings/fragments/PurchasesFragment.java | 121 +++++++++++++++--- .../settings/fragments/SubscriptionsCard.java | 18 +-- 7 files changed, 192 insertions(+), 55 deletions(-) diff --git a/OsmAnd/res/layout/purchases_layout.xml b/OsmAnd/res/layout/purchases_layout.xml index 306f37f690..2140d2cc5c 100644 --- a/OsmAnd/res/layout/purchases_layout.xml +++ b/OsmAnd/res/layout/purchases_layout.xml @@ -1,6 +1,8 @@ + + + + + + + + + + + + + + + + + + getEverMadeSubscriptions() { + List subscriptions = new ArrayList<>(); + for (InAppSubscription subscription : getLiveUpdates().getVisibleSubscriptions()) { + SubscriptionState state = subscription.getState(); + if (state != null && !SubscriptionState.UNDEFINED.equals(state)) { + subscriptions.add(subscription); + } + } + return subscriptions; + } + public abstract void isInAppPurchaseSupported(@NonNull final Activity activity, @Nullable final InAppPurchaseInitCallback callback); public boolean hasInventory() { diff --git a/OsmAnd/src/net/osmand/plus/liveupdates/CountrySelectionFragment.java b/OsmAnd/src/net/osmand/plus/liveupdates/CountrySelectionFragment.java index f070559121..9c29e9762b 100644 --- a/OsmAnd/src/net/osmand/plus/liveupdates/CountrySelectionFragment.java +++ b/OsmAnd/src/net/osmand/plus/liveupdates/CountrySelectionFragment.java @@ -35,6 +35,8 @@ import java.util.List; public class CountrySelectionFragment extends BaseOsmAndDialogFragment { + public static final String TAG = CountrySelectionFragment.class.getSimpleName(); + private List countryItems = new ArrayList<>(); private OnFragmentInteractionListener mListener; diff --git a/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesFragment.java b/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesFragment.java index 02bdad0a43..631b1a7f07 100644 --- a/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesFragment.java +++ b/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesFragment.java @@ -49,6 +49,7 @@ import net.osmand.plus.inapp.InAppPurchaseHelper.InAppPurchaseListener; import net.osmand.plus.inapp.InAppPurchaseHelper.InAppPurchaseTaskType; import net.osmand.plus.inapp.InAppPurchases.InAppSubscription; import net.osmand.plus.resources.IncrementalChangesManager; +import net.osmand.plus.settings.fragments.PurchasesFragment; import net.osmand.util.Algorithms; import java.io.File; @@ -181,28 +182,9 @@ public class LiveUpdatesFragment extends BaseOsmAndFragment implements InAppPurc statusTextView.setText(getString(R.string.osm_live_active)); statusIcon.setImageDrawable(app.getUIUtilities().getThemedIcon(R.drawable.ic_action_done)); - regionNameHeaderTextView.setText(R.string.osm_live_support_region); - String countryName = app.getSettings().BILLING_USER_COUNTRY.get(); - InAppPurchaseHelper purchaseHelper = getInAppPurchaseHelper(); - if (purchaseHelper != null) { - InAppSubscription monthlyPurchased = purchaseHelper.getPurchasedMonthlyLiveUpdates(); - if (monthlyPurchased != null && monthlyPurchased.isDonationSupported()) { - if (Algorithms.isEmpty(countryName)) { - if (app.getSettings().BILLING_USER_COUNTRY_DOWNLOAD_NAME.get().equals(OsmandSettings.BILLING_USER_DONATION_NONE_PARAMETER)) { - regionNameHeaderTextView.setText(R.string.default_buttons_support); - countryName = getString(R.string.osmand_team); - } else { - countryName = getString(R.string.shared_string_world); - } - } - } else { - regionNameHeaderTextView.setText(R.string.default_buttons_support); - countryName = getString(R.string.osmand_team); - } - } else { - regionNameHeaderTextView.setText(R.string.default_buttons_support); - countryName = getString(R.string.osmand_team); - } + String countryName = PurchasesFragment.getSupportRegionName(app, getInAppPurchaseHelper()); + String header = PurchasesFragment.getSupportRegionHeader(app, countryName); + regionNameHeaderTextView.setText(header); regionNameTextView.setText(countryName); View subscriptionsButton = subscriptionHeader.findViewById(R.id.button_subscriptions); diff --git a/OsmAnd/src/net/osmand/plus/liveupdates/SubscriptionFragment.java b/OsmAnd/src/net/osmand/plus/liveupdates/SubscriptionFragment.java index a2afb3d933..b73bf20c6e 100644 --- a/OsmAnd/src/net/osmand/plus/liveupdates/SubscriptionFragment.java +++ b/OsmAnd/src/net/osmand/plus/liveupdates/SubscriptionFragment.java @@ -177,7 +177,7 @@ public class SubscriptionFragment extends BaseOsmAndDialogFragment implements In CountrySelectionFragment countryCountrySelectionFragment = countrySelectionFragment; countryCountrySelectionFragment - .show(getChildFragmentManager(), "CountriesSearchSelectionFragment"); + .show(getChildFragmentManager(), CountrySelectionFragment.TAG); } return false; } diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/PurchasesFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/PurchasesFragment.java index 6b5a9c5d5f..af834f73b8 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/PurchasesFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/PurchasesFragment.java @@ -21,11 +21,6 @@ import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.fragment.app.FragmentActivity; -import androidx.fragment.app.FragmentManager; - import com.google.android.material.appbar.AppBarLayout; import net.osmand.AndroidUtils; @@ -39,21 +34,37 @@ import net.osmand.plus.base.BaseOsmAndFragment; import net.osmand.plus.chooseplan.ChoosePlanDialogFragment; import net.osmand.plus.inapp.InAppPurchaseHelper; import net.osmand.plus.inapp.InAppPurchaseHelper.InAppPurchaseListener; +import net.osmand.plus.inapp.InAppPurchases.InAppSubscription; +import net.osmand.plus.liveupdates.CountrySelectionFragment; +import net.osmand.plus.liveupdates.CountrySelectionFragment.CountryItem; +import net.osmand.plus.liveupdates.CountrySelectionFragment.OnFragmentInteractionListener; import net.osmand.plus.liveupdates.LiveUpdatesFragmentNew; import net.osmand.plus.liveupdates.OsmLiveActivity; +import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.wikipedia.WikipediaDialogFragment; +import net.osmand.util.Algorithms; -public class PurchasesFragment extends BaseOsmAndFragment implements InAppPurchaseListener { +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.fragment.app.FragmentActivity; +import androidx.fragment.app.FragmentManager; + +public class PurchasesFragment extends BaseOsmAndFragment implements InAppPurchaseListener, OnFragmentInteractionListener { public static final String TAG = PurchasesFragment.class.getName(); public static final String KEY_IS_SUBSCRIBER = "action_is_new"; private static final String PLAY_STORE_SUBSCRIPTION_URL = "https://play.google.com/store/account/subscriptions"; private static final String PLAY_STORE_SUBSCRIPTION_DEEPLINK_URL = "https://play.google.com/store/account/subscriptions?sku=%s&package=%s"; + + private OsmandApplication app; + private Context context; private InAppPurchaseHelper purchaseHelper; + private View mainView; private SubscriptionsCard subscriptionsCard; - private Context context; - private OsmandApplication app; + + private CountrySelectionFragment countrySelectionFragment = new CountrySelectionFragment(); + private String url; private Boolean isSubscriber; @@ -79,20 +90,14 @@ public class PurchasesFragment extends BaseOsmAndFragment implements InAppPurcha public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { app = getMyApplication(); context = requireContext(); - purchaseHelper = getInAppPurchaseHelper(); isSubscriber = Version.isPaidVersion(app); - final MapActivity mapActivity = (MapActivity) getActivity(); - final boolean nightMode = !getMyApplication().getSettings().isLightContent(); + final MapActivity mapActivity = getMapActivity(); + final boolean nightMode = !app.getSettings().isLightContent(); LayoutInflater themedInflater = UiUtilities.getInflater(context, nightMode); if (isSubscriber) { mainView = themedInflater.inflate(R.layout.purchases_layout, container, false); setSubscriptionClick(mapActivity); - if (mapActivity != null && purchaseHelper != null) { - ViewGroup subscriptionsCardContainer = mainView.findViewById(R.id.subscriptions_card_container); - subscriptionsCard = new SubscriptionsCard(mapActivity, purchaseHelper); - subscriptionsCardContainer.addView(subscriptionsCard.build(mapActivity)); - } } else { mainView = themedInflater.inflate(R.layout.empty_purchases_layout, container, false); LinearLayout osmandLive = mainView.findViewById(R.id.osmand_live); @@ -138,6 +143,21 @@ public class PurchasesFragment extends BaseOsmAndFragment implements InAppPurcha return mainView; } + @Override + public void onResume() { + super.onResume(); + purchaseHelper = getInAppPurchaseHelper(); + if (isSubscriber) { + MapActivity mapActivity = getMapActivity(); + if (getMapActivity() != null && purchaseHelper != null) { + ViewGroup subscriptionsCardContainer = mainView.findViewById(R.id.subscriptions_card_container); + subscriptionsCard = new SubscriptionsCard(mapActivity, purchaseHelper); + subscriptionsCardContainer.addView(subscriptionsCard.build(mapActivity)); + } + setupSupportRegion(); + } + } + @Override public void onSaveInstanceState(@NonNull Bundle outState) { super.onSaveInstanceState(outState); @@ -189,6 +209,54 @@ public class PurchasesFragment extends BaseOsmAndFragment implements InAppPurcha } + private void setupSupportRegion() { + String region = getSupportRegionName(app, purchaseHelper); + String header = getSupportRegionHeader(app, region); + TextView supportRegionHeader = mainView.findViewById(R.id.support_region_header); + TextView supportRegion = mainView.findViewById(R.id.support_region); + supportRegionHeader.setText(header); + supportRegion.setText(region); + + View supportRegionContainer = mainView.findViewById(R.id.support_region_container); + supportRegionContainer.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + CountrySelectionFragment countryCountrySelectionFragment = countrySelectionFragment; + countryCountrySelectionFragment.show(getChildFragmentManager(), CountrySelectionFragment.TAG); + } + }); + + countrySelectionFragment.initCountries(app); + } + + public static String getSupportRegionName(OsmandApplication app, InAppPurchaseHelper purchaseHelper) { + OsmandSettings settings = app.getSettings(); + String countryName = settings.BILLING_USER_COUNTRY.get(); + if (purchaseHelper != null) { + InAppSubscription monthlyPurchased = purchaseHelper.getPurchasedMonthlyLiveUpdates(); + if (monthlyPurchased != null && monthlyPurchased.isDonationSupported()) { + if (Algorithms.isEmpty(countryName)) { + if (OsmandSettings.BILLING_USER_DONATION_NONE_PARAMETER.equals(settings.BILLING_USER_COUNTRY_DOWNLOAD_NAME.get())) { + countryName = app.getString(R.string.osmand_team); + } else { + countryName = app.getString(R.string.shared_string_world); + } + } + } else { + countryName = app.getString(R.string.osmand_team); + } + } else { + countryName = app.getString(R.string.osmand_team); + } + return countryName; + } + + public static String getSupportRegionHeader(OsmandApplication app, String supportRegion) { + return supportRegion.equals(app.getString(R.string.osmand_team)) ? + app.getString(R.string.default_buttons_support) : + app.getString(R.string.osm_live_support_region); + } + @Nullable public InAppPurchaseHelper getInAppPurchaseHelper() { Activity activity = getActivity(); @@ -263,6 +331,23 @@ public class PurchasesFragment extends BaseOsmAndFragment implements InAppPurcha } } + @Override + public void onSearchResult(CountryItem selectedCountryItem) { + String countryName = selectedCountryItem != null ? selectedCountryItem.getLocalName() : ""; + String countryDownloadName = selectedCountryItem != null ? + selectedCountryItem.getDownloadName() : OsmandSettings.BILLING_USER_DONATION_WORLD_PARAMETER; + + OsmandApplication app = getMyApplication(); + if (app != null) { + TextView supportRegionHeader = mainView.findViewById(R.id.support_region_header); + TextView supportRegion = mainView.findViewById(R.id.support_region); + supportRegionHeader.setText(getSupportRegionHeader(app, countryName)); + supportRegion.setText(countryName); + app.getSettings().BILLING_USER_COUNTRY.set(countryName); + app.getSettings().BILLING_USER_COUNTRY_DOWNLOAD_NAME.set(countryDownloadName); + } + } + @Override public void onError(InAppPurchaseHelper.InAppPurchaseTaskType taskType, String error) { } @@ -288,4 +373,8 @@ public class PurchasesFragment extends BaseOsmAndFragment implements InAppPurcha @Override public void dismissProgress(InAppPurchaseHelper.InAppPurchaseTaskType taskType) { } + + private MapActivity getMapActivity() { + return (MapActivity) getActivity(); + } } diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/SubscriptionsCard.java b/OsmAnd/src/net/osmand/plus/settings/fragments/SubscriptionsCard.java index 40ef081602..c8c0d5202b 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/SubscriptionsCard.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/SubscriptionsCard.java @@ -45,11 +45,11 @@ public class SubscriptionsCard extends BaseCard { @Override protected void updateContent() { - if (mapActivity == null) { + if (mapActivity == null || purchaseHelper == null) { return; } - List subscriptions = getActiveAndCancelledSubscriptions(); + List subscriptions = purchaseHelper.getEverMadeSubscriptions(); if (Algorithms.isEmpty(subscriptions)) { return; } @@ -162,18 +162,4 @@ public class SubscriptionsCard extends BaseCard { } return ""; } - - private List getActiveAndCancelledSubscriptions() { - List subscriptions = new ArrayList<>(); - for (InAppSubscription subscription : purchaseHelper.getLiveUpdates().getVisibleSubscriptions()) { - if (shouldShowSubscription(subscription)) { - subscriptions.add(subscription); - } - } - return subscriptions; - } - - private boolean shouldShowSubscription(InAppSubscription s) { - return s.getState() != null && !SubscriptionState.UNDEFINED.equals(s.getState()); - } } \ No newline at end of file From a8bca97b0b402d1941060e76cf1ed435f79e9c08 Mon Sep 17 00:00:00 2001 From: androiddevkotlin <64539346+androiddevkotlin@users.noreply.github.com> Date: Wed, 24 Mar 2021 01:40:52 +0200 Subject: [PATCH 09/74] Rtl fix xml and Announcement time --- .../layout-land/fragment_measurement_tool.xml | 4 +- OsmAnd/res/layout/account_details.xml | 8 +++- .../res/layout/add_new_favorite_category.xml | 8 +++- OsmAnd/res/layout/adjust_speed_slider.xml | 4 +- ...om_sheet_item_description_with_padding.xml | 4 +- ...ttom_sheet_item_edit_with_recyclerview.xml | 4 +- .../res/layout/bottom_sheet_item_progress.xml | 4 +- ...bottom_sheet_item_slider_with_two_text.xml | 8 +++- ...eet_item_with_descr_radio_and_icon_btn.xml | 4 +- ...escr_switch_and_additional_button_56dp.xml | 4 +- OsmAnd/res/layout/custom_color_picker.xml | 4 +- OsmAnd/res/layout/dashboard_toolbar.xml | 24 ++++++++--- OsmAnd/res/layout/dialog_button_with_icon.xml | 3 +- .../layout/download_description_button.xml | 4 +- .../res/layout/enough_space_warning_card.xml | 8 +++- OsmAnd/res/layout/follow_track_card.xml | 4 +- OsmAnd/res/layout/fragment_import.xml | 8 +++- .../res/layout/fragment_measurement_tool.xml | 4 +- OsmAnd/res/layout/fragment_opr_login.xml | 12 ++++-- OsmAnd/res/layout/fragment_terrain.xml | 8 +++- ...global_preferences_toolbar_with_switch.xml | 4 +- OsmAnd/res/layout/gpx_item_list_header.xml | 4 +- .../res/layout/gpx_list_item_tab_content.xml | 4 +- OsmAnd/res/layout/gpx_overview_fragment.xml | 4 +- OsmAnd/res/layout/group_description_item.xml | 8 +++- OsmAnd/res/layout/import_track_card.xml | 4 +- .../layout/item_header_export_expand_list.xml | 4 +- OsmAnd/res/layout/item_info_fragment.xml | 4 +- OsmAnd/res/layout/map_hud_bottom.xml | 4 +- OsmAnd/res/layout/map_marker_item_header.xml | 4 +- .../layout/navigate_track_options_card.xml | 4 +- .../res/layout/navigation_profiles_card.xml | 4 +- .../online_routing_preference_segment.xml | 12 ++++-- OsmAnd/res/layout/opr_add_photo.xml | 4 +- .../layout/plan_route_threshold_slider.xml | 8 +++- .../res/layout/point_editor_fragment_new.xml | 40 ++++++++++++++----- .../layout/profile_data_list_item_group.xml | 8 +++- .../layout/quick_action_add_dialog_header.xml | 4 +- .../layout/quick_action_add_dialog_item.xml | 4 +- OsmAnd/res/layout/quick_action_list_item.xml | 8 +++- .../res/layout/radio_buttons_with_descr.xml | 4 +- .../layout/read_wikipedia_ofline_banner.xml | 8 +++- .../res/layout/recalculation_angle_dialog.xml | 4 +- OsmAnd/res/layout/select_folder_row.xml | 4 +- OsmAnd/res/layout/send_gpx_fragment.xml | 12 ++++-- OsmAnd/res/layout/send_osm_note_fragment.xml | 4 +- OsmAnd/res/layout/send_poi_fragment.xml | 4 +- OsmAnd/res/layout/settings_group_title.xml | 4 +- OsmAnd/res/layout/track_appearance.xml | 4 +- OsmAnd/res/layout/track_menu.xml | 4 +- OsmAnd/res/layout/track_split_interval.xml | 4 +- OsmAnd/res/layout/track_width_card.xml | 4 +- .../res/layout/wikivoyage_travel_gpx_card.xml | 8 +++- OsmAnd/res/layout/zoom_levels_with_descr.xml | 4 +- .../routing/data/AnnounceTimeDistances.java | 25 ++++++------ 55 files changed, 269 insertions(+), 99 deletions(-) diff --git a/OsmAnd/res/layout-land/fragment_measurement_tool.xml b/OsmAnd/res/layout-land/fragment_measurement_tool.xml index 4ed0e425e3..505e680262 100644 --- a/OsmAnd/res/layout-land/fragment_measurement_tool.xml +++ b/OsmAnd/res/layout-land/fragment_measurement_tool.xml @@ -160,7 +160,9 @@ android:paddingRight="@dimen/measurement_tool_text_button_padding_small" android:text="@string/shared_string_options" android:textColor="?attr/color_dialog_buttons" - osmand:typeface="@string/font_roboto_medium" /> + osmand:typeface="@string/font_roboto_medium" + android:paddingEnd="@dimen/measurement_tool_text_button_padding_small" + android:paddingStart="@dimen/measurement_tool_text_button_padding_small" /> + osmand:srcCompat="@drawable/ic_action_user_account" + android:layout_marginStart="@dimen/content_padding" + android:layout_marginEnd="@dimen/content_padding" /> + android:orientation="vertical" + android:layout_marginStart="@dimen/content_padding" + android:layout_marginEnd="@dimen/content_padding"> + osmand:typeface="@string/font_roboto_medium" + android:paddingEnd="@dimen/content_padding" + android:paddingStart="@dimen/content_padding" /> + osmand:typeface="@string/font_roboto_medium" + android:paddingStart="@dimen/content_padding" + android:paddingEnd="@dimen/content_padding" /> + android:paddingBottom="@dimen/content_padding" + android:layout_marginStart="@dimen/content_padding_small" + android:layout_marginEnd="@dimen/content_padding_small" /> \ No newline at end of file diff --git a/OsmAnd/res/layout/bottom_sheet_item_description_with_padding.xml b/OsmAnd/res/layout/bottom_sheet_item_description_with_padding.xml index b6516e85ff..9a5aec71e8 100644 --- a/OsmAnd/res/layout/bottom_sheet_item_description_with_padding.xml +++ b/OsmAnd/res/layout/bottom_sheet_item_description_with_padding.xml @@ -8,7 +8,9 @@ android:paddingBottom="@dimen/content_padding_small" android:minHeight="@dimen/card_row_min_height" android:layout_width="match_parent" - android:layout_height="wrap_content"> + android:layout_height="wrap_content" + android:paddingEnd="@dimen/content_padding" + android:paddingStart="@dimen/content_padding"> + android:layout_marginRight="@dimen/content_padding" + android:layout_marginStart="@dimen/content_padding" + android:layout_marginEnd="@dimen/content_padding"> + android:paddingBottom="@dimen/content_padding_small" + android:paddingEnd="@dimen/content_padding" + android:paddingStart="@dimen/content_padding" /> diff --git a/OsmAnd/res/layout/bottom_sheet_item_slider_with_two_text.xml b/OsmAnd/res/layout/bottom_sheet_item_slider_with_two_text.xml index f386e8c59f..fc8cb6a41e 100644 --- a/OsmAnd/res/layout/bottom_sheet_item_slider_with_two_text.xml +++ b/OsmAnd/res/layout/bottom_sheet_item_slider_with_two_text.xml @@ -11,7 +11,9 @@ android:layout_height="wrap_content" android:gravity="center_vertical" android:paddingLeft="@dimen/content_padding" - android:paddingRight="@dimen/content_padding"> + android:paddingRight="@dimen/content_padding" + android:paddingStart="@dimen/content_padding" + android:paddingEnd="@dimen/content_padding"> + android:layout_height="wrap_content" + android:layout_marginStart="@dimen/content_padding" + android:layout_marginEnd="@dimen/content_padding" /> \ No newline at end of file diff --git a/OsmAnd/res/layout/bottom_sheet_item_with_descr_radio_and_icon_btn.xml b/OsmAnd/res/layout/bottom_sheet_item_with_descr_radio_and_icon_btn.xml index c4dc6d4265..c0cacc0b79 100644 --- a/OsmAnd/res/layout/bottom_sheet_item_with_descr_radio_and_icon_btn.xml +++ b/OsmAnd/res/layout/bottom_sheet_item_with_descr_radio_and_icon_btn.xml @@ -90,7 +90,9 @@ android:paddingLeft="@dimen/content_padding" android:paddingRight="@dimen/content_padding" android:layout_width="wrap_content" - android:layout_height="match_parent"> + android:layout_height="match_parent" + android:paddingEnd="@dimen/content_padding" + android:paddingStart="@dimen/content_padding"> + tools:src="@drawable/ic_action_info_dark" + android:layout_marginEnd="@dimen/content_padding" + android:layout_marginStart="@dimen/content_padding" /> diff --git a/OsmAnd/res/layout/custom_color_picker.xml b/OsmAnd/res/layout/custom_color_picker.xml index f2133e410b..c48205c25e 100644 --- a/OsmAnd/res/layout/custom_color_picker.xml +++ b/OsmAnd/res/layout/custom_color_picker.xml @@ -6,7 +6,9 @@ android:layout_height="wrap_content" android:orientation="vertical" android:paddingLeft="@dimen/content_padding" - android:paddingRight="@dimen/content_padding"> + android:paddingRight="@dimen/content_padding" + android:paddingStart="@dimen/content_padding" + android:paddingEnd="@dimen/content_padding"> + tools:visibility="gone" + android:layout_marginEnd="@dimen/multi_selection_menu_padding_top" + android:layout_marginStart="@dimen/multi_selection_menu_padding_top" /> + app:srcCompat="@drawable/ic_configure_screen_dark" + android:layout_marginEnd="@dimen/multi_selection_menu_padding_top" + android:layout_marginStart="@dimen/multi_selection_menu_padding_top" /> + app:srcCompat="@drawable/ic_action_done" + android:layout_marginEnd="@dimen/multi_selection_menu_padding_top" + android:layout_marginStart="@dimen/multi_selection_menu_padding_top" /> + app:srcCompat="@drawable/ic_sort_waypoint_dark" + android:layout_marginStart="@dimen/multi_selection_menu_padding_top" + android:layout_marginEnd="@dimen/multi_selection_menu_padding_top" /> + android:visibility="gone" + android:layout_marginEnd="@dimen/multi_selection_menu_padding_top" + android:layout_marginStart="@dimen/multi_selection_menu_padding_top" /> + android:visibility="gone" + android:layout_marginEnd="@dimen/multi_selection_menu_padding_top" + android:layout_marginStart="@dimen/multi_selection_menu_padding_top" /> diff --git a/OsmAnd/res/layout/dialog_button_with_icon.xml b/OsmAnd/res/layout/dialog_button_with_icon.xml index 264f884495..6a80553e49 100644 --- a/OsmAnd/res/layout/dialog_button_with_icon.xml +++ b/OsmAnd/res/layout/dialog_button_with_icon.xml @@ -13,7 +13,8 @@ android:layout_marginRight="@dimen/content_padding" android:layout_marginStart="@dimen/content_padding" android:layout_marginBottom="@dimen/content_padding_small" - tools:ignore="UselessParent"> + tools:ignore="UselessParent" + android:layout_marginEnd="@dimen/content_padding"> \ No newline at end of file + tools:text="@string/read_more" + android:paddingStart="@dimen/content_padding_half" + android:paddingEnd="@dimen/content_padding_half" /> \ No newline at end of file diff --git a/OsmAnd/res/layout/enough_space_warning_card.xml b/OsmAnd/res/layout/enough_space_warning_card.xml index 3fcbb69bac..6b85dcb27c 100644 --- a/OsmAnd/res/layout/enough_space_warning_card.xml +++ b/OsmAnd/res/layout/enough_space_warning_card.xml @@ -20,7 +20,9 @@ android:layout_marginLeft="@dimen/content_padding" android:layout_marginTop="@dimen/content_padding" android:layout_marginRight="@dimen/content_padding" - app:srcCompat="@drawable/ic_action_sdcard_warning_colored" /> + app:srcCompat="@drawable/ic_action_sdcard_warning_colored" + android:layout_marginStart="@dimen/content_padding" + android:layout_marginEnd="@dimen/content_padding" /> + android:orientation="vertical" + android:layout_marginStart="@dimen/content_padding" + android:layout_marginEnd="@dimen/content_padding"> + tools:listitem="@layout/point_editor_icon_category_item" + android:paddingStart="@dimen/content_padding" + android:paddingEnd="@dimen/content_padding" /> + tools:visibility="visible" + android:paddingEnd="@dimen/content_padding" + android:paddingStart="@dimen/content_padding"> + android:layout_marginBottom="@dimen/content_padding_half" + android:layout_marginEnd="@dimen/content_padding_half" + android:layout_marginStart="@dimen/content_padding_half"> + android:paddingRight="@dimen/measurement_tool_button_margin" + android:paddingStart="@dimen/measurement_tool_button_margin" + android:paddingEnd="@dimen/measurement_tool_button_margin"> + app:typeface="@string/font_roboto_medium" + android:layout_marginStart="@dimen/content_padding" + android:layout_marginEnd="@dimen/content_padding" /> + app:typeface="@string/font_roboto_regular" + android:layout_marginEnd="@dimen/content_padding" + android:layout_marginStart="@dimen/content_padding" /> @@ -73,7 +77,9 @@ android:layout_marginTop="@dimen/content_padding_small" android:layout_marginRight="@dimen/content_padding" android:layout_marginBottom="@dimen/content_padding_small" - android:orientation="vertical"> + android:orientation="vertical" + android:layout_marginStart="@dimen/content_padding" + android:layout_marginEnd="@dimen/content_padding"> + android:stepSize="1" + android:layout_marginStart="@dimen/content_padding" + android:layout_marginEnd="@dimen/content_padding" /> + android:stepSize="1" + android:layout_marginStart="@dimen/content_padding" + android:layout_marginEnd="@dimen/content_padding" /> + tools:text="@string/routing_settings_2" + android:layout_marginStart="@dimen/content_padding" + android:layout_marginEnd="@dimen/content_padding" /> + android:paddingBottom="@dimen/content_padding_half" + android:paddingEnd="@dimen/content_padding" + android:paddingStart="@dimen/content_padding"> + android:paddingTop="@dimen/content_padding" + android:layout_marginStart="@dimen/content_padding" + android:layout_marginEnd="@dimen/content_padding" /> + tools:text="Amsterdam is the Netherlands' capital and financial, cultural and creative centre with more" + android:layout_marginEnd="@dimen/content_padding" + android:layout_marginStart="@dimen/content_padding" /> + tools:text="@string/plugin_disabled_descr" + android:paddingEnd="@dimen/content_padding" + android:paddingStart="@dimen/content_padding" /> + android:orientation="vertical" + android:layout_marginStart="@dimen/content_padding_half" + android:layout_marginEnd="@dimen/content_padding_half" /> diff --git a/OsmAnd/res/layout/import_track_card.xml b/OsmAnd/res/layout/import_track_card.xml index 24ead3b9a6..108676e545 100644 --- a/OsmAnd/res/layout/import_track_card.xml +++ b/OsmAnd/res/layout/import_track_card.xml @@ -19,7 +19,9 @@ android:text="@string/import_track_descr" android:textAppearance="@style/TextAppearance.ContextMenuSubtitle" android:textColor="?android:textColorSecondary" - osmand:typeface="@string/font_roboto_regular" /> + osmand:typeface="@string/font_roboto_regular" + android:paddingEnd="@dimen/content_padding" + android:paddingStart="@dimen/content_padding" /> diff --git a/OsmAnd/res/layout/item_header_export_expand_list.xml b/OsmAnd/res/layout/item_header_export_expand_list.xml index a77881d33a..09fc11ad23 100644 --- a/OsmAnd/res/layout/item_header_export_expand_list.xml +++ b/OsmAnd/res/layout/item_header_export_expand_list.xml @@ -22,7 +22,9 @@ android:text="@string/export_profile_dialog_description" android:textColor="?android:textColorPrimary" android:textSize="@dimen/default_list_text_size" - app:typeface="@string/font_roboto_regular" /> + app:typeface="@string/font_roboto_regular" + android:paddingStart="@dimen/content_padding" + android:paddingEnd="@dimen/content_padding" /> + tools:text="@string/plugin_disabled_descr" + android:paddingStart="@dimen/content_padding" + android:paddingEnd="@dimen/content_padding" /> diff --git a/OsmAnd/res/layout/map_hud_bottom.xml b/OsmAnd/res/layout/map_hud_bottom.xml index 629f9350a1..30acd574e9 100644 --- a/OsmAnd/res/layout/map_hud_bottom.xml +++ b/OsmAnd/res/layout/map_hud_bottom.xml @@ -76,7 +76,9 @@ android:layout_height="wrap_content" android:layout_gravity="center" android:layout_marginLeft="@dimen/dashPadding" - android:layout_marginRight="@dimen/dashPadding"/> + android:layout_marginRight="@dimen/dashPadding" + android:layout_marginStart="@dimen/dashPadding" + android:layout_marginEnd="@dimen/dashPadding" /> diff --git a/OsmAnd/res/layout/map_marker_item_header.xml b/OsmAnd/res/layout/map_marker_item_header.xml index ab0a14e08b..14e5f8e9f4 100644 --- a/OsmAnd/res/layout/map_marker_item_header.xml +++ b/OsmAnd/res/layout/map_marker_item_header.xml @@ -50,7 +50,9 @@ android:gravity="center" android:visibility="gone" android:background="?android:selectableItemBackground" - android:textColor="?attr/active_color_basic" /> + android:textColor="?attr/active_color_basic" + android:paddingEnd="@dimen/bottom_sheet_content_margin" + android:paddingStart="@dimen/bottom_sheet_content_margin" /> + osmand:typeface="@string/font_roboto_medium" + android:paddingEnd="@dimen/content_padding" + android:paddingStart="@dimen/content_padding" /> + android:text="@string/navigation_profile" + android:layout_marginEnd="@dimen/content_padding" + android:layout_marginStart="@dimen/content_padding" /> + android:visibility="gone" + android:paddingStart="@dimen/content_padding" + android:paddingEnd="@dimen/content_padding"> + android:visibility="gone" + android:paddingEnd="@dimen/content_padding" + android:paddingStart="@dimen/content_padding" /> + android:visibility="gone" + android:paddingEnd="@dimen/content_padding" + android:paddingStart="@dimen/content_padding"> + android:text="@string/add_photos_descr" + android:layout_marginEnd="@dimen/content_padding" + android:layout_marginStart="@dimen/content_padding" /> \ No newline at end of file diff --git a/OsmAnd/res/layout/plan_route_threshold_slider.xml b/OsmAnd/res/layout/plan_route_threshold_slider.xml index 54fd7609d8..6d742b3c47 100644 --- a/OsmAnd/res/layout/plan_route_threshold_slider.xml +++ b/OsmAnd/res/layout/plan_route_threshold_slider.xml @@ -12,7 +12,9 @@ android:layout_height="wrap_content" android:paddingTop="@dimen/content_padding_small" android:paddingLeft="@dimen/content_padding" - android:paddingRight="@dimen/content_padding"> + android:paddingRight="@dimen/content_padding" + android:paddingEnd="@dimen/content_padding" + android:paddingStart="@dimen/content_padding"> + android:layout_height="wrap_content" + android:layout_marginEnd="@dimen/content_padding" + android:layout_marginStart="@dimen/content_padding" /> diff --git a/OsmAnd/res/layout/point_editor_fragment_new.xml b/OsmAnd/res/layout/point_editor_fragment_new.xml index 6beccf0dd7..b146b2ea1e 100644 --- a/OsmAnd/res/layout/point_editor_fragment_new.xml +++ b/OsmAnd/res/layout/point_editor_fragment_new.xml @@ -58,7 +58,9 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="@dimen/content_padding" - android:layout_marginRight="@dimen/content_padding"> + android:layout_marginRight="@dimen/content_padding" + android:layout_marginEnd="@dimen/content_padding" + android:layout_marginStart="@dimen/content_padding"> + app:hintAnimationEnabled="false" + android:layout_marginEnd="@dimen/content_padding" + android:layout_marginStart="@dimen/content_padding"> + android:background="?attr/dashboard_divider" + android:layout_marginStart="@dimen/content_padding" + android:layout_marginEnd="@dimen/content_padding" /> + app:hintAnimationEnabled="false" + android:layout_marginStart="@dimen/content_padding" + android:layout_marginEnd="@dimen/content_padding"> + osmand:typeface="@string/font_roboto_medium" + android:paddingEnd="@dimen/content_padding" + android:paddingStart="@dimen/content_padding" /> + osmand:typeface="@string/font_roboto_medium" + android:paddingEnd="@dimen/content_padding" + android:paddingStart="@dimen/content_padding" /> + osmand:typeface="@string/font_roboto_medium" + android:paddingStart="@dimen/content_padding" + android:paddingEnd="@dimen/content_padding" /> + osmand:typeface="@string/font_roboto_medium" + android:paddingStart="@dimen/content_padding" + android:paddingEnd="@dimen/content_padding" /> + osmand:typeface="@string/font_roboto_medium" + android:paddingEnd="@dimen/content_padding" + android:paddingStart="@dimen/content_padding" /> + osmand:typeface="@string/font_roboto_medium" + android:paddingStart="@dimen/content_padding" + android:paddingEnd="@dimen/content_padding" /> + osmand:srcCompat="@drawable/ic_action_arrow_down" + android:layout_marginEnd="@dimen/content_padding" + android:layout_marginStart="@dimen/content_padding" /> + android:orientation="vertical" + android:layout_marginEnd="@dimen/content_padding" + android:layout_marginStart="@dimen/content_padding"> + osmand:typeface="@string/font_roboto_medium" + android:layout_marginStart="@dimen/content_padding" + android:layout_marginEnd="@dimen/content_padding" /> + android:orientation="horizontal" + android:paddingStart="@dimen/content_padding" + android:paddingEnd="@dimen/content_padding"> + android:padding="@dimen/content_padding_small" + android:layout_marginEnd="@dimen/dashCardMargin" + android:layout_marginStart="@dimen/dashCardMargin"> + android:padding="@dimen/content_padding_small" + android:layout_marginEnd="@dimen/dashCardMargin" + android:layout_marginStart="@dimen/dashCardMargin"> + tools:text="@string/pass_whole_track_descr" + android:paddingStart="@dimen/content_padding" + android:paddingEnd="@dimen/content_padding" /> diff --git a/OsmAnd/res/layout/read_wikipedia_ofline_banner.xml b/OsmAnd/res/layout/read_wikipedia_ofline_banner.xml index 1093ad41f1..4e27debe49 100644 --- a/OsmAnd/res/layout/read_wikipedia_ofline_banner.xml +++ b/OsmAnd/res/layout/read_wikipedia_ofline_banner.xml @@ -16,7 +16,9 @@ android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_marginLeft="@dimen/content_padding" - android:layout_marginRight="@dimen/content_padding"> + android:layout_marginRight="@dimen/content_padding" + android:layout_marginStart="@dimen/content_padding" + android:layout_marginEnd="@dimen/content_padding"> + android:visibility="invisible" + android:layout_marginEnd="@dimen/content_padding" + android:layout_marginStart="@dimen/content_padding"> + android:paddingBottom="@dimen/content_padding" + android:layout_marginEnd="@dimen/content_padding_small" + android:layout_marginStart="@dimen/content_padding_small" /> diff --git a/OsmAnd/res/layout/select_folder_row.xml b/OsmAnd/res/layout/select_folder_row.xml index 1d855ff70f..dccba6c9b8 100644 --- a/OsmAnd/res/layout/select_folder_row.xml +++ b/OsmAnd/res/layout/select_folder_row.xml @@ -20,7 +20,9 @@ android:text="@string/select_folder" android:textColor="?android:textColorSecondary" android:textSize="@dimen/default_desc_text_size" - osmand:typeface="@string/font_roboto_regular" /> + osmand:typeface="@string/font_roboto_regular" + android:paddingStart="@dimen/content_padding" + android:paddingEnd="@dimen/content_padding" /> + osmand:typeface="@string/font_roboto_regular" + android:paddingStart="@dimen/content_padding" + android:paddingEnd="@dimen/content_padding" /> + tools:text="@string/gpx_visibility_txt" + android:paddingStart="@dimen/content_padding" + android:paddingEnd="@dimen/content_padding" /> @@ -138,7 +142,9 @@ android:paddingBottom="@dimen/context_menu_first_line_top_margin" android:textColor="?android:textColorPrimary" android:textSize="@dimen/default_desc_text_size" - osmand:typeface="@string/font_roboto_regular" /> + osmand:typeface="@string/font_roboto_regular" + android:paddingEnd="@dimen/content_padding" + android:paddingStart="@dimen/content_padding" /> + osmand:typeface="@string/font_roboto_regular" + android:paddingStart="@dimen/content_padding_small" + android:paddingEnd="@dimen/content_padding_small" /> diff --git a/OsmAnd/res/layout/send_poi_fragment.xml b/OsmAnd/res/layout/send_poi_fragment.xml index 751c0b1fe8..538cc55e0b 100644 --- a/OsmAnd/res/layout/send_poi_fragment.xml +++ b/OsmAnd/res/layout/send_poi_fragment.xml @@ -57,7 +57,9 @@ android:text="@string/close_changeset" android:textColor="?android:textColorPrimary" android:textSize="@dimen/default_list_text_size" - osmand:typeface="@string/font_roboto_regular" /> + osmand:typeface="@string/font_roboto_regular" + android:paddingStart="@dimen/content_padding_small" + android:paddingEnd="@dimen/content_padding_small" /> diff --git a/OsmAnd/res/layout/settings_group_title.xml b/OsmAnd/res/layout/settings_group_title.xml index 456a3aace1..7d4fb811cd 100644 --- a/OsmAnd/res/layout/settings_group_title.xml +++ b/OsmAnd/res/layout/settings_group_title.xml @@ -70,7 +70,9 @@ android:paddingLeft="@dimen/content_padding" android:paddingTop="@dimen/content_padding_small" android:paddingRight="@dimen/content_padding" - android:paddingBottom="@dimen/content_padding_small"> + android:paddingBottom="@dimen/content_padding_small" + android:paddingStart="@dimen/content_padding" + android:paddingEnd="@dimen/content_padding"> + android:paddingRight="@dimen/content_padding" + android:paddingEnd="@dimen/content_padding" + android:paddingStart="@dimen/content_padding"> + tools:visibility="visible" + android:layout_marginStart="@dimen/content_padding_half" + android:layout_marginEnd="@dimen/content_padding_half"> + android:stepSize="1" + android:layout_marginEnd="@dimen/content_padding" + android:layout_marginStart="@dimen/content_padding" /> + android:stepSize="1" + android:layout_marginStart="@dimen/content_padding" + android:layout_marginEnd="@dimen/content_padding" /> + tools:text="@string/mapillary_menu_title_username" + android:paddingStart="@dimen/content_padding_small_half" + android:paddingEnd="@dimen/content_padding_small_half" /> + tools:text="@string/shared_string_profiles" + android:paddingStart="@dimen/content_padding_small_half" + android:paddingEnd="@dimen/content_padding_small_half" /> diff --git a/OsmAnd/res/layout/zoom_levels_with_descr.xml b/OsmAnd/res/layout/zoom_levels_with_descr.xml index 5cfbcde5e9..3d5b16a7df 100644 --- a/OsmAnd/res/layout/zoom_levels_with_descr.xml +++ b/OsmAnd/res/layout/zoom_levels_with_descr.xml @@ -78,7 +78,9 @@ android:layout_marginLeft="@dimen/content_padding" android:layout_marginRight="@dimen/content_padding" android:layout_weight="1" - android:stepSize="1" /> + android:stepSize="1" + android:layout_marginEnd="@dimen/content_padding" + android:layout_marginStart="@dimen/content_padding" /> 12 m (capped by POSITIONING_TOLERANCE) - ARRIVAL_DISTANCE = (int) (Math.max(POSITIONING_TOLERANCE, DEFAULT_SPEED * 5.) * arrivalDistanceFactor); + ARRIVAL_DISTANCE = (int) (Math.max(POSITIONING_TOLERANCE, DEFAULT_SPEED * 5.) * arrivalDistanceFactor); // 20 s: car 250 m, bicycle 56 m, pedestrian 22 m OFF_ROUTE_DISTANCE = DEFAULT_SPEED * 20 * arrivalDistanceFactor; // 20 seconds @@ -175,17 +176,14 @@ public class AnnounceTimeDistances { } private boolean isDistanceLess(float currentSpeed, double dist, double etalon, float defSpeed) { - // Check triggers: + // Check triggers: // (1) distance < etalon? if (dist - voicePromptDelayTimeSec * currentSpeed <= etalon) { return true; } // (2) time_with_current_speed < etalon_time_with_default_speed? // check only if speed > 0 - if (currentSpeed > 0 && (dist / currentSpeed - voicePromptDelayTimeSec) <= etalon / defSpeed) { - return true; - } - return false; + return currentSpeed > 0 && (dist / currentSpeed - voicePromptDelayTimeSec) <= etalon / defSpeed; } public float getSpeed(Location loc) { @@ -219,7 +217,8 @@ public class AnnounceTimeDistances { // round to 5 time = (time / 5) * 5; } - builder.append(String.format("\n%s: %d - %d %s, %d %s.", name, minDist, minDist + 5, meter, time, second)); + BidiFormatter myBidiFormatter = BidiFormatter.getInstance(); + builder.append(String.format("\n%s: %d - %d %s, %d %s.", name, minDist, minDist + 5, myBidiFormatter.unicodeWrap(meter), time, myBidiFormatter.unicodeWrap(second))); } public Spannable getIntervalsDescription(OsmandApplication app) { From 3c239cae0cc206226c2cb95fa307dc6081f7dadf Mon Sep 17 00:00:00 2001 From: androiddevkotlin <64539346+androiddevkotlin@users.noreply.github.com> Date: Wed, 24 Mar 2021 11:21:41 +0200 Subject: [PATCH 10/74] Api low --- .../osmand/plus/routing/data/AnnounceTimeDistances.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/routing/data/AnnounceTimeDistances.java b/OsmAnd/src/net/osmand/plus/routing/data/AnnounceTimeDistances.java index 9285cae0a0..d03d4f2c43 100644 --- a/OsmAnd/src/net/osmand/plus/routing/data/AnnounceTimeDistances.java +++ b/OsmAnd/src/net/osmand/plus/routing/data/AnnounceTimeDistances.java @@ -217,8 +217,13 @@ public class AnnounceTimeDistances { // round to 5 time = (time / 5) * 5; } - BidiFormatter myBidiFormatter = BidiFormatter.getInstance(); - builder.append(String.format("\n%s: %d - %d %s, %d %s.", name, minDist, minDist + 5, myBidiFormatter.unicodeWrap(meter), time, myBidiFormatter.unicodeWrap(second))); + BidiFormatter myBidiFormatter; + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR2) { + myBidiFormatter = BidiFormatter.getInstance(); + builder.append(String.format("\n%s: %d - %d %s, %d %s.", name, minDist, minDist + 5, myBidiFormatter.unicodeWrap(meter), time, myBidiFormatter.unicodeWrap(second))); + }else{ + builder.append(String.format("\n%s: %d - %d %s, %d %s.", name, minDist, minDist + 5, "\u200F"+meter, time, "\u200F"+second)); + } } public Spannable getIntervalsDescription(OsmandApplication app) { From faa8503847864a41b32adfc7fc4336887996211f Mon Sep 17 00:00:00 2001 From: cepprice Date: Wed, 24 Mar 2021 22:02:32 +0500 Subject: [PATCH 11/74] Add border to gradient track line --- .../src/net/osmand/plus/views/Renderable.java | 81 +++++++++++++++---- .../osmand/plus/views/layers/GPXLayer.java | 10 +++ 2 files changed, 74 insertions(+), 17 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/views/Renderable.java b/OsmAnd/src/net/osmand/plus/views/Renderable.java index 5053f46a69..27d741d964 100644 --- a/OsmAnd/src/net/osmand/plus/views/Renderable.java +++ b/OsmAnd/src/net/osmand/plus/views/Renderable.java @@ -4,6 +4,7 @@ import android.graphics.Canvas; import android.graphics.LinearGradient; import android.graphics.Paint; import android.graphics.Path; +import android.graphics.PointF; import android.graphics.Shader; import net.osmand.GPXUtilities; @@ -67,6 +68,7 @@ public class Renderable { protected double zoom = -1; protected AsynchronousResampler culler = null; // The currently active resampler protected Paint paint = null; // MUST be set by 'updateLocalPaint' before use + protected Paint borderPaint; protected GradientScaleType scaleType = null; protected GpxGeometryWay geometryWay; @@ -88,6 +90,10 @@ public class Renderable { paint.setStrokeWidth(p.getStrokeWidth()); } + public void setBorderPaint(@NonNull Paint paint) { + borderPaint = paint; + } + public void setGradientScaleType(GradientScaleType type) { this.scaleType = type; } @@ -177,33 +183,74 @@ public class Renderable { protected void drawGradient(List pts, Paint p, Canvas canvas, RotatedTileBox tileBox) { QuadRect tileBounds = tileBox.getLatLonBounds(); - Path path = new Path(); + Path currentPath = new Path(); + Path nextPath = new Path(); Paint paint = new Paint(this.paint); - WptPt prevPt = pts.get(0); + + WptPt prevWpt = pts.get(0); + WptPt currWpt = pts.get(1); + + PointF prevXY = new PointF(); + PointF currXY = new PointF(); + PointF nextXY = new PointF(); + + boolean currLineVisible = arePointsInsideTile(prevWpt, currWpt, tileBounds); + boolean nextLineVisible; + + if (currLineVisible) { + pixXYFromWptPt(tileBox, prevXY, prevWpt); + pixXYFromWptPt(tileBox, currXY, currWpt); + canvas.drawPath(pathFromStartEnd(currentPath, prevXY, currXY), borderPaint); + } + for (int i = 1; i < pts.size(); i++) { - WptPt currentPt = pts.get(i); - if (arePointsInsideTile(currentPt, prevPt, tileBounds)) { - float startX = tileBox.getPixXFromLatLon(prevPt.lat, prevPt.lon); - float startY = tileBox.getPixYFromLatLon(prevPt.lat, prevPt.lon); - float endX = tileBox.getPixXFromLatLon(currentPt.lat, currentPt.lon); - float endY = tileBox.getPixYFromLatLon(currentPt.lat, currentPt.lon); - int prevColor = prevPt.getColor(scaleType.toColorizationType()); - int currentColor = currentPt.getColor(scaleType.toColorizationType()); - LinearGradient gradient = new LinearGradient(startX, startY, endX, endY, prevColor, currentColor, Shader.TileMode.CLAMP); - paint.setShader(gradient); - path.reset(); - path.moveTo(startX, startY); - path.lineTo(endX, endY); - canvas.drawPath(path, paint); + currWpt = pts.get(i); + WptPt nextWpt = i + 1 == pts.size() ? null : pts.get(i + 1); + + nextLineVisible = arePointsInsideTile(currWpt, nextWpt, tileBounds); + if (nextWpt != null && nextLineVisible) { + pixXYFromWptPt(tileBox, currXY, currWpt); + pixXYFromWptPt(tileBox, nextXY, nextWpt); + canvas.drawPath(pathFromStartEnd(nextPath, currXY, nextXY), borderPaint); } - prevPt = currentPt; + + if (currLineVisible) { + int prevColor = prevWpt.getColor(scaleType.toColorizationType()); + int currentColor = currWpt.getColor(scaleType.toColorizationType()); + LinearGradient gradient = new LinearGradient(prevXY.x, prevXY.y, currXY.x, currXY.y, + prevColor, currentColor, Shader.TileMode.CLAMP); + paint.setShader(gradient); + canvas.drawPath(currentPath, paint); + } + + prevWpt = currWpt; + currentPath.set(nextPath); + prevXY.set(currXY); + currXY.set(nextXY); + currLineVisible = nextLineVisible; } } protected boolean arePointsInsideTile(WptPt first, WptPt second, QuadRect tileBounds) { + if (first == null || second == null) { + return false; + } return Math.min(first.lon, second.lon) < tileBounds.right && Math.max(first.lon, second.lon) > tileBounds.left && Math.min(first.lat, second.lat) < tileBounds.top && Math.max(first.lat, second.lat) > tileBounds.bottom; } + + protected PointF pixXYFromWptPt(RotatedTileBox tileBox, PointF pointF, WptPt wptPt) { + pointF.x = tileBox.getPixXFromLatLon(wptPt.lat, wptPt.lon); + pointF.y = tileBox.getPixYFromLatLon(wptPt.lat, wptPt.lon); + return pointF; + } + + protected Path pathFromStartEnd(Path path, PointF start, PointF end) { + path.reset(); + path.moveTo(start.x, start.y); + path.lineTo(end.x, end.y); + return path; + } } public static class StandardTrack extends RenderableSegment { diff --git a/OsmAnd/src/net/osmand/plus/views/layers/GPXLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/GPXLayer.java index c55fb675fd..c16d687614 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/GPXLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/GPXLayer.java @@ -95,6 +95,7 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM private OsmandMapTileView view; private Paint paint; + private Paint borderPaint; private Paint shadowPaint; private Paint paintIcon; @@ -190,6 +191,13 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM paint = new Paint(); paint.setStyle(Style.STROKE); paint.setAntiAlias(true); + + borderPaint = new Paint(Paint.ANTI_ALIAS_FLAG); + borderPaint.setStyle(Style.STROKE); + borderPaint.setStrokeJoin(Paint.Join.ROUND); + borderPaint.setStrokeCap(Paint.Cap.ROUND); + borderPaint.setColor(0x80000000); + shadowPaint = new Paint(); shadowPaint.setStyle(Style.STROKE); shadowPaint.setAntiAlias(true); @@ -341,6 +349,7 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM } paint.setColor(color == 0 ? cachedColor : color); paint.setStrokeWidth(getTrackWidth(width, defaultTrackWidth)); + borderPaint.setStrokeWidth(paint.getStrokeWidth() + AndroidUtils.dpToPx(view.getContext(), 2)); } private void acquireTrackWidth(String widthKey, RenderingRulesStorage rrs, RenderingRuleSearchRequest req, RenderingContext rc) { @@ -700,6 +709,7 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM updatePaints(color, width, selectedGpxFile.isRoutePoints(), currentTrack, settings, tileBox); if (ts.renderer instanceof Renderable.RenderableSegment) { Renderable.RenderableSegment renderableSegment = (Renderable.RenderableSegment) ts.renderer; + renderableSegment.setBorderPaint(borderPaint); renderableSegment.setGradientScaleType(scaleType); renderableSegment.drawSegment(view.getZoom(), paint, canvas, tileBox); } From 3dd74265fe54466e83a91928def2d3ac7a801dfd Mon Sep 17 00:00:00 2001 From: Skalii Date: Thu, 25 Mar 2021 00:56:34 +0200 Subject: [PATCH 12/74] fix "Start" button appearance --- .../monitoring/TripRecordingBottomSheet.java | 38 +++++++++++++++++++ .../TripRecordingStartingBottomSheet.java | 3 +- 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java index 8db1508454..c7f4316848 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java @@ -453,6 +453,21 @@ public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment impl setItemBackground(context, nightMode, view, enabled); } + public static void createItemActive(Context context, boolean nightMode, View view, ItemType type) { + view.setTag(type); + AppCompatImageView icon = view.findViewById(R.id.icon); + if (icon != null) { + setTintedIconActive(context, icon, nightMode, type); + } + TextView title = view.findViewById(R.id.button_text); + Integer titleId = type.getTitleId(); + if (title != null && titleId != null) { + title.setText(titleId); + setTextColorActive(context, title, nightMode, type); + } + setItemBackgroundActive(context, nightMode, view); + } + public static void setItemBackground(Context context, boolean nightMode, View view, boolean enabled) { if (view instanceof CardView) { int colorId = enabled ? getActiveTransparentColorId(nightMode) : getInactiveButtonColorId(nightMode); @@ -472,6 +487,12 @@ public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment impl view.setBackgroundDrawable(background); } + public static void setItemBackgroundActive(Context context, boolean nightMode, View view) { + if (view instanceof CardView) { + ((CardView) view).setCardBackgroundColor(ContextCompat.getColor(context, getActiveTextColorId(nightMode))); + } + } + public enum ItemType { SHOW_TRACK(R.string.shared_string_show_on_map, null), APPEARANCE(null, null), @@ -528,6 +549,12 @@ public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment impl } } + protected static void setTextColorActive(Context context, TextView tv, boolean nightMode, ItemType type) { + if (tv != null) { + tv.setTextColor(ContextCompat.getColor(context, getPressedColorId(nightMode))); + } + } + protected static void setTintedIcon(Context context, AppCompatImageView iv, boolean enabled, boolean nightMode, ItemType type) { Integer iconId = type.getIconId(); if (iv != null && iconId != null) { @@ -550,6 +577,17 @@ public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment impl } } + protected static void setTintedIconActive(Context context, AppCompatImageView iv, boolean nightMode, ItemType type) { + Integer iconId = type.getIconId(); + if (iv != null && iconId != null) { + Drawable icon = AppCompatResources.getDrawable(context, iconId); + if (icon != null) { + DrawableCompat.setTint(icon, ContextCompat.getColor(context, getPressedColorId(nightMode))); + } + iv.setImageDrawable(icon); + } + } + @Override public void onPointSelected(TrkSegment segment, double lat, double lon) { if (trackChartPoints == null) { diff --git a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingStartingBottomSheet.java b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingStartingBottomSheet.java index e45f792514..17d472a489 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingStartingBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingStartingBottomSheet.java @@ -35,6 +35,7 @@ import net.osmand.plus.settings.fragments.BaseSettingsFragment.SettingsScreenTyp import static net.osmand.plus.monitoring.OsmandMonitoringPlugin.MINUTES; import static net.osmand.plus.monitoring.OsmandMonitoringPlugin.SECONDS; +import static net.osmand.plus.monitoring.TripRecordingBottomSheet.createItemActive; import static net.osmand.plus.monitoring.TripRecordingBottomSheet.createItem; import static net.osmand.plus.monitoring.TripRecordingBottomSheet.createShowTrackItem; import static net.osmand.plus.monitoring.TripRecordingBottomSheet.updateTrackIcon; @@ -123,7 +124,7 @@ public class TripRecordingStartingBottomSheet extends MenuBottomSheetDialogFragm }); CardView cardCenter = itemView.findViewById(R.id.button_center); - createItem(app, nightMode, cardCenter, ItemType.START_RECORDING, true, null); + createItemActive(app, nightMode, cardCenter, ItemType.START_RECORDING); cardCenter.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { From 5a68b91b0c823ff45b483a22441d339b36d7145a Mon Sep 17 00:00:00 2001 From: Skalii Date: Thu, 25 Mar 2021 03:51:02 +0200 Subject: [PATCH 13/74] fix close button in main dialog; fix divider between toggle buttons; --- .../plus/monitoring/TripRecordingBottomSheet.java | 5 +++-- .../net/osmand/plus/myplaces/SegmentGPXAdapter.java | 10 ++++++++-- OsmAnd/src/net/osmand/plus/track/SegmentsCard.java | 2 +- .../plus/views/controls/PagerSlidingTabStrip.java | 2 +- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java index c7f4316848..97a56b6c68 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java @@ -163,7 +163,7 @@ public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment impl ContextCompat.getColor(app, getActiveTextColorId(nightMode))); CardView cardLeft = itemView.findViewById(R.id.button_left); - createItem(cardLeft, ItemType.CANCEL); + createItem(cardLeft, ItemType.CLOSE); cardLeft.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -296,7 +296,7 @@ public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment impl viewGroup.removeAllViews(); setupDisplayHelper(); - View segmentView = SegmentGPXAdapter.createGpxTabsView(displayHelper, viewGroup, this, nightMode); + View segmentView = SegmentGPXAdapter.createGpxTabsView(displayHelper, viewGroup, this, nightMode, true); AndroidUiHelper.setVisibility(View.GONE, segmentView.findViewById(R.id.list_item_divider)); WrapContentHeightViewPager pager = segmentView.findViewById(R.id.pager); PagerSlidingTabStrip tabLayout = segmentView.findViewById(R.id.sliding_tabs); @@ -509,6 +509,7 @@ public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment impl STOP_AND_SAVE(R.string.track_recording_save_and_stop, R.drawable.ic_action_save_to_file), STOP_ONLINE(R.string.live_monitoring_stop, R.drawable.ic_world_globe_dark), CANCEL(R.string.shared_string_cancel, R.drawable.ic_action_close), + CLOSE(R.string.shared_string_close, R.drawable.ic_action_close), START_RECORDING(R.string.shared_string_control_start, R.drawable.ic_action_direction_movement), SETTINGS(R.string.shared_string_settings, R.drawable.ic_action_settings), FINISH(R.string.shared_string_finish, R.drawable.ic_action_point_destination), diff --git a/OsmAnd/src/net/osmand/plus/myplaces/SegmentGPXAdapter.java b/OsmAnd/src/net/osmand/plus/myplaces/SegmentGPXAdapter.java index ac45fc1294..9891c6ef5f 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/SegmentGPXAdapter.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/SegmentGPXAdapter.java @@ -6,6 +6,7 @@ import android.view.ViewGroup; import android.widget.ArrayAdapter; import androidx.annotation.NonNull; +import androidx.core.content.ContextCompat; import net.osmand.AndroidUtils; import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem; @@ -48,7 +49,7 @@ public class SegmentGPXAdapter extends ArrayAdapter { boolean create = false; if (row == null) { create = true; - row = createGpxTabsView(displayHelper, parent, listener, nightMode); + row = createGpxTabsView(displayHelper, parent, listener, nightMode, false); } GpxDisplayItem item = getItem(position); if (item != null) { @@ -66,7 +67,7 @@ public class SegmentGPXAdapter extends ArrayAdapter { } public static View createGpxTabsView(TrackDisplayHelper displayHelper, ViewGroup root, - SegmentActionsListener listener, boolean nightMode) { + SegmentActionsListener listener, boolean nightMode, boolean withDivider) { Context context = root.getContext(); View row = UiUtilities.getInflater(context, nightMode).inflate(R.layout.gpx_list_item_tab_content, root, false); @@ -74,6 +75,11 @@ public class SegmentGPXAdapter extends ArrayAdapter { tabLayout.setTabBackground(AndroidUtils.resolveAttribute(context, R.attr.btn_bg_border_inactive)); tabLayout.setIndicatorHeight(0); tabLayout.setShouldExpand(true); + if (withDivider) { + tabLayout.setDividerWidth(AndroidUtils.dpToPx(context, 1.0f)); + tabLayout.setDividerColor(ContextCompat.getColor(context, nightMode ? + R.color.stroked_buttons_and_links_outline_dark : R.color.stroked_buttons_and_links_outline_light)); + } WrapContentHeightViewPager pager = row.findViewById(R.id.pager); pager.setSwipeable(false); pager.setOffscreenPageLimit(2); diff --git a/OsmAnd/src/net/osmand/plus/track/SegmentsCard.java b/OsmAnd/src/net/osmand/plus/track/SegmentsCard.java index a3ed324543..8a49438bc6 100644 --- a/OsmAnd/src/net/osmand/plus/track/SegmentsCard.java +++ b/OsmAnd/src/net/osmand/plus/track/SegmentsCard.java @@ -42,7 +42,7 @@ public class SegmentsCard extends BaseCard { container.removeAllViews(); List items = TrackDisplayHelper.flatten(displayHelper.getOriginalGroups(filterTypes)); for (GpxDisplayItem displayItem : items) { - View segmentView = SegmentGPXAdapter.createGpxTabsView(displayHelper, container, listener, nightMode); + View segmentView = SegmentGPXAdapter.createGpxTabsView(displayHelper, container, listener, nightMode, false); WrapContentHeightViewPager pager = segmentView.findViewById(R.id.pager); PagerSlidingTabStrip tabLayout = segmentView.findViewById(R.id.sliding_tabs); diff --git a/OsmAnd/src/net/osmand/plus/views/controls/PagerSlidingTabStrip.java b/OsmAnd/src/net/osmand/plus/views/controls/PagerSlidingTabStrip.java index f79ac0c6b5..7eade8f2ba 100644 --- a/OsmAnd/src/net/osmand/plus/views/controls/PagerSlidingTabStrip.java +++ b/OsmAnd/src/net/osmand/plus/views/controls/PagerSlidingTabStrip.java @@ -485,7 +485,7 @@ public class PagerSlidingTabStrip extends HorizontalScrollView { dividerPaint.setColor(dividerColor); for (int i = 0; i < tabCount - 1; i++) { View tab = tabsContainer.getChildAt(i); - canvas.drawLine(tab.getRight(), dividerPadding, tab.getRight(), height - dividerPadding, dividerPaint); + canvas.drawLine(tab.getRight(), tabsContainer.getTop(), tab.getRight(), tabsContainer.getBottom(), dividerPaint); } } } From eff2d35a7f9f1ddeb4be2aa1f18e34aba8332eda Mon Sep 17 00:00:00 2001 From: Skalii Date: Thu, 25 Mar 2021 04:14:47 +0200 Subject: [PATCH 14/74] fix header height in main dialog; fix header title and stop button title in discard dialog; --- OsmAnd/res/layout/trip_recording_fragment.xml | 1 + .../net/osmand/plus/monitoring/TripRecordingBottomSheet.java | 2 +- .../plus/monitoring/TripRecordingDiscardBottomSheet.java | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/OsmAnd/res/layout/trip_recording_fragment.xml b/OsmAnd/res/layout/trip_recording_fragment.xml index 449ae3dd5d..d3f1cd81ca 100644 --- a/OsmAnd/res/layout/trip_recording_fragment.xml +++ b/OsmAnd/res/layout/trip_recording_fragment.xml @@ -18,6 +18,7 @@ android:paddingEnd="@dimen/content_padding" android:paddingRight="@dimen/content_padding" android:paddingBottom="@dimen/content_padding" + android:minHeight="@dimen/bottom_sheet_selected_item_title_height" android:weightSum="2"> negative = Arrays.asList(CLEAR_DATA, STOP_AND_DISCARD); + private static final List negative = Arrays.asList(CLEAR_DATA, STOP, STOP_AND_DISCARD); ItemType(@Nullable @StringRes Integer titleId, @Nullable @DrawableRes Integer iconId) { this.titleId = titleId; diff --git a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingDiscardBottomSheet.java b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingDiscardBottomSheet.java index 70414eab5e..cff99d9daa 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingDiscardBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingDiscardBottomSheet.java @@ -42,13 +42,13 @@ public class TripRecordingDiscardBottomSheet extends MenuBottomSheetDialogFragme LayoutInflater inflater = UiUtilities.getInflater(app, nightMode); int verticalBig = getResources().getDimensionPixelSize(R.dimen.dialog_content_margin); int verticalNormal = getResources().getDimensionPixelSize(R.dimen.content_padding); - final View buttonDiscard = createItem(inflater, ItemType.STOP_AND_DISCARD); + final View buttonDiscard = createItem(inflater, ItemType.STOP); final View buttonCancel = createItem(inflater, ItemType.CANCEL); items.add(new BottomSheetItemWithDescription.Builder() .setDescription(getString(R.string.track_recording_description)) .setDescriptionColorId(getPrimaryTextColorId(nightMode)) - .setTitle(app.getString(R.string.track_recording_title)) + .setTitle(app.getString(R.string.track_recording_stop_without_saving)) .setLayoutId(R.layout.bottom_sheet_item_title_with_description) .create()); From 27bf5e7809655e5da4ba38e61fb1515ee7a31bb1 Mon Sep 17 00:00:00 2001 From: Skalii Date: Thu, 25 Mar 2021 12:56:50 +0200 Subject: [PATCH 15/74] fix display of the button "Start online monitoring" --- .../monitoring/TripRecordingBottomSheet.java | 3 +- .../TripRecordingOptionsBottomSheet.java | 42 ++++++++----------- 2 files changed, 20 insertions(+), 25 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java index 1389e473c5..c11c452149 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java @@ -507,7 +507,8 @@ public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment impl STOP(R.string.shared_string_control_stop, R.drawable.ic_action_rec_stop), STOP_AND_DISCARD(R.string.track_recording_stop_without_saving, R.drawable.ic_action_rec_stop), STOP_AND_SAVE(R.string.track_recording_save_and_stop, R.drawable.ic_action_save_to_file), - STOP_ONLINE(R.string.live_monitoring_stop, R.drawable.ic_world_globe_dark), + START_ONLINE(R.string.live_monitoring_start, R.drawable.ic_world_globe_dark), + STOP_ONLINE(R.string.live_monitoring_stop, R.drawable.ic_action_offline), CANCEL(R.string.shared_string_cancel, R.drawable.ic_action_close), CLOSE(R.string.shared_string_close, R.drawable.ic_action_close), START_RECORDING(R.string.shared_string_control_start, R.drawable.ic_action_direction_movement), diff --git a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingOptionsBottomSheet.java b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingOptionsBottomSheet.java index ac42775bd2..52f218190f 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingOptionsBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingOptionsBottomSheet.java @@ -51,8 +51,6 @@ public class TripRecordingOptionsBottomSheet extends MenuBottomSheetDialogFragme private SelectedGpxFile selectedGpxFile; private final Handler handler = new Handler(); private Runnable updatingTimeTrackSaved; - private int indexButtonOnline = -1; - private int indexButtonOnlineDivider = -1; private GPXFile getGPXFile() { return selectedGpxFile.getGpxFile(); @@ -91,7 +89,8 @@ public class TripRecordingOptionsBottomSheet extends MenuBottomSheetDialogFragme buttonClear = createItem(inflater, ItemType.CLEAR_DATA, hasDataToSave()); final View buttonDiscard = createItem(inflater, ItemType.STOP_AND_DISCARD); - final View buttonOnline = createItem(inflater, ItemType.STOP_ONLINE, hasDataToSave()); + final View buttonOnline = createItem(inflater, settings.LIVE_MONITORING.get() + ? ItemType.STOP_ONLINE : ItemType.START_ONLINE); buttonSave = createItem(inflater, ItemType.SAVE, hasDataToSave()); final View buttonSegment = createItem(inflater, ItemType.START_NEW_SEGMENT, wasTrackMonitored()); @@ -131,27 +130,19 @@ public class TripRecordingOptionsBottomSheet extends MenuBottomSheetDialogFragme items.add(new DividerSpaceItem(app, dp36)); - if (app.getLiveMonitoringHelper().isLiveMonitoringEnabled()) { - items.add(new BaseBottomSheetItem.Builder() - .setCustomView(buttonOnline) - .setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - settings.LIVE_MONITORING.set(false); - if (indexButtonOnline != -1) { - AndroidUiHelper.updateVisibility(items.get(indexButtonOnline).getView(), false); - } - if (indexButtonOnlineDivider != -1) { - AndroidUiHelper.updateVisibility(items.get(indexButtonOnlineDivider).getView(), false); - } - } - }) - .create()); - indexButtonOnline = items.size() - 1; + items.add(new BaseBottomSheetItem.Builder() + .setCustomView(buttonOnline) + .setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + boolean wasOnlineMonitored = !settings.LIVE_MONITORING.get(); + settings.LIVE_MONITORING.set(wasOnlineMonitored); + createItem(buttonOnline, wasOnlineMonitored ? ItemType.STOP_ONLINE : ItemType.START_ONLINE); + } + }) + .create()); - items.add(new DividerSpaceItem(app, dp36)); - indexButtonOnlineDivider = items.size() - 1; - } + items.add(new DividerSpaceItem(app, dp36)); items.add(new BaseBottomSheetItem.Builder() .setCustomView(buttonSave) @@ -181,7 +172,6 @@ public class TripRecordingOptionsBottomSheet extends MenuBottomSheetDialogFragme .create()); items.add(new DividerSpaceItem(app, getResources().getDimensionPixelSize(R.dimen.content_padding_small))); - } @Override @@ -243,6 +233,10 @@ public class TripRecordingOptionsBottomSheet extends MenuBottomSheetDialogFragme } } + private void createItem(View view, ItemType type) { + TripRecordingBottomSheet.createItem(app, nightMode, view, type, true, null); + } + private View createItem(LayoutInflater inflater, ItemType type, boolean enabled) { return TripRecordingBottomSheet.createItem(app, nightMode, inflater, type, enabled, null); } From ffe15a976fc83b3d070d4295abe0d77aac5f1a76 Mon Sep 17 00:00:00 2001 From: Skalii Date: Thu, 25 Mar 2021 13:23:16 +0200 Subject: [PATCH 16/74] add horizontal margins for graphs --- .../plus/monitoring/TripRecordingBottomSheet.java | 1 + .../net/osmand/plus/myplaces/GPXItemPagerAdapter.java | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java index c11c452149..2b2e13d2c4 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java @@ -314,6 +314,7 @@ public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment impl graphsAdapter = new GPXItemPagerAdapter(app, GpxUiHelper.makeGpxDisplayItem(app, displayHelper.getGpx()), displayHelper, nightMode, this, true); + graphsAdapter.setChartHMargin(getResources().getDimensionPixelSize(R.dimen.content_padding)); pager.setAdapter(graphsAdapter); tabLayout.setViewPager(pager); diff --git a/OsmAnd/src/net/osmand/plus/myplaces/GPXItemPagerAdapter.java b/OsmAnd/src/net/osmand/plus/myplaces/GPXItemPagerAdapter.java index b8899dd9c7..34232a8c6d 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/GPXItemPagerAdapter.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/GPXItemPagerAdapter.java @@ -24,6 +24,7 @@ import com.github.mikephil.charting.listener.ChartTouchListener.ChartGesture; import com.github.mikephil.charting.listener.OnChartGestureListener; import com.github.mikephil.charting.listener.OnChartValueSelectedListener; +import net.osmand.AndroidUtils; import net.osmand.GPXUtilities; import net.osmand.GPXUtilities.GPXFile; import net.osmand.GPXUtilities.GPXTrackAnalysis; @@ -82,6 +83,11 @@ public class GPXItemPagerAdapter extends PagerAdapter implements CustomTabProvid private boolean chartClicked; private boolean nightMode; private boolean onlyGraphs; + private int chartHMargin = 0; + + public void setChartHMargin(int chartHMargin) { + this.chartHMargin = chartHMargin; + } public GPXItemPagerAdapter(@NonNull OsmandApplication app, @NonNull GpxDisplayItem gpxItem, @@ -201,6 +207,8 @@ public class GPXItemPagerAdapter extends PagerAdapter implements CustomTabProvid if (gpxFile != null && gpxItem != null) { GPXTrackAnalysis analysis = gpxItem.analysis; LineChart chart = view.findViewById(R.id.chart); + ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) chart.getLayoutParams(); + AndroidUtils.setMargins(lp, chartHMargin, lp.topMargin, chartHMargin, lp.bottomMargin); setupChart(view, chart); switch (tabType) { @@ -436,8 +444,8 @@ public class GPXItemPagerAdapter extends PagerAdapter implements CustomTabProvid view.findViewById(R.id.list_divider).setVisibility(View.GONE); view.findViewById(R.id.bottom_line_blocks).setVisibility(View.GONE); } - updateJoinGapsInfo(view, position); if (!onlyGraphs) { + updateJoinGapsInfo(view, position); view.findViewById(R.id.analyze_on_map).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { From d9a69dd154b7588f7cf55baf80676f451e6f4867 Mon Sep 17 00:00:00 2001 From: nazar-kutz Date: Thu, 25 Mar 2021 16:17:14 +0200 Subject: [PATCH 17/74] Use different colors for route line appearance --- .../plus/routing/RouteLineDrawInfo.java | 66 ++++++++++++++----- .../routing/cards/RouteLineColorCard.java | 58 +++++++++++----- .../routing/cards/RouteLineWidthCard.java | 15 ++--- .../plus/settings/backend/OsmandSettings.java | 2 + .../fragments/ProfileAppearanceFragment.java | 30 ++++++--- .../RouteLineAppearanceFragment.java | 5 ++ .../src/net/osmand/plus/track/ColorsCard.java | 1 + .../osmand/plus/views/layers/RouteLayer.java | 13 ++-- 8 files changed, 137 insertions(+), 53 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/routing/RouteLineDrawInfo.java b/OsmAnd/src/net/osmand/plus/routing/RouteLineDrawInfo.java index 92cb926fa1..838e553b5b 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RouteLineDrawInfo.java +++ b/OsmAnd/src/net/osmand/plus/routing/RouteLineDrawInfo.java @@ -10,17 +10,20 @@ import net.osmand.util.Algorithms; public class RouteLineDrawInfo { - private static final String LINE_COLOR = "line_color"; + private static final String LINE_COLOR_DAY = "line_color_day"; + private static final String LINE_COLOR_NIGHT = "line_color_night"; private static final String LINE_WIDTH = "line_width"; private static final String NAVIGATION_ICON_ID = "navigation_icon_id"; private static final String NAVIGATION_ICON_COLOR = "navigation_icon_color"; private static final String CENTER_X = "center_x"; private static final String CENTER_Y = "center_y"; private static final String SCREEN_HEIGHT = "screen_height"; + private static final String USE_DEFAULT_COLOR = "use_default_color"; // parameters to save @ColorInt - private Integer color; + private Integer colorDay; + private Integer colorNight; private String width; // temporally parameters to show in preview @@ -30,10 +33,13 @@ public class RouteLineDrawInfo { private int centerX; private int centerY; private int screenHeight; + private boolean useDefaultColor; - public RouteLineDrawInfo(@Nullable @ColorInt Integer color, + public RouteLineDrawInfo(@Nullable @ColorInt Integer colorDay, + @Nullable @ColorInt Integer colorNight, @Nullable String width) { - this.color = color; + this.colorDay = colorDay; + this.colorNight = colorNight; this.width = width; } @@ -42,17 +48,27 @@ public class RouteLineDrawInfo { } public RouteLineDrawInfo(@NonNull RouteLineDrawInfo existed) { - this.color = existed.color; + this.colorDay = existed.colorDay; + this.colorNight = existed.colorNight; this.width = existed.width; this.iconId = existed.iconId; this.iconColor = existed.iconColor; this.centerX = existed.centerX; this.centerY = existed.centerY; this.screenHeight = existed.screenHeight; + this.useDefaultColor = existed.useDefaultColor; } - public void setColor(@Nullable Integer color) { - this.color = color; + public void setColor(@ColorInt int color, boolean nightMode) { + if (nightMode) { + colorNight = color; + } else { + colorDay = color; + } + } + + public void setUseDefaultColor(boolean useDefaultColor) { + this.useDefaultColor = useDefaultColor; } public void setWidth(@Nullable String width) { @@ -80,8 +96,16 @@ public class RouteLineDrawInfo { } @Nullable - public Integer getColor() { - return color; + public Integer getColor(boolean nightMode) { + if (!useDefaultColor) { + return getColorIgnoreDefault(nightMode); + } + return null; + } + + @Nullable + public Integer getColorIgnoreDefault(boolean nightMode) { + return nightMode ? colorNight : colorDay; } @Nullable @@ -111,8 +135,11 @@ public class RouteLineDrawInfo { } private void readBundle(@NonNull Bundle bundle) { - if (bundle.containsKey(LINE_COLOR)) { - color = bundle.getInt(LINE_COLOR); + if (bundle.containsKey(LINE_COLOR_DAY)) { + colorDay = bundle.getInt(LINE_COLOR_DAY); + } + if (bundle.containsKey(LINE_COLOR_NIGHT)) { + colorNight = bundle.getInt(LINE_COLOR_NIGHT); } width = bundle.getString(LINE_WIDTH); iconId = bundle.getInt(NAVIGATION_ICON_ID); @@ -120,11 +147,15 @@ public class RouteLineDrawInfo { centerX = bundle.getInt(CENTER_X); centerY = bundle.getInt(CENTER_Y); screenHeight = bundle.getInt(SCREEN_HEIGHT); + useDefaultColor = bundle.getBoolean(USE_DEFAULT_COLOR); } public void saveToBundle(@NonNull Bundle bundle) { - if (color != null) { - bundle.putInt(LINE_COLOR, color); + if (colorDay != null) { + bundle.putInt(LINE_COLOR_DAY, colorDay); + } + if (colorNight != null) { + bundle.putInt(LINE_COLOR_NIGHT, colorNight); } if (width != null) { bundle.putString(LINE_WIDTH, width); @@ -134,6 +165,7 @@ public class RouteLineDrawInfo { bundle.putInt(CENTER_X, centerX); bundle.putInt(CENTER_Y, centerY); bundle.putInt(SCREEN_HEIGHT, screenHeight); + bundle.putBoolean(USE_DEFAULT_COLOR, useDefaultColor); } @Override @@ -143,13 +175,15 @@ public class RouteLineDrawInfo { RouteLineDrawInfo that = (RouteLineDrawInfo) o; - if (!Algorithms.objectEquals(getColor(), that.getColor())) return false; - return Algorithms.objectEquals(getWidth(), that.getWidth()); + if (!Algorithms.objectEquals(colorDay, that.colorDay)) return false; + if (!Algorithms.objectEquals(colorNight, that.colorNight)) return false; + return Algorithms.objectEquals(width, that.width); } @Override public int hashCode() { - int result = color != null ? color.hashCode() : 0; + int result = colorDay != null ? colorDay.hashCode() : 0; + result = 31 * result + (colorNight != null ? colorNight.hashCode() : 0); result = 31 * result + (width != null ? width.hashCode() : 0); return result; } diff --git a/OsmAnd/src/net/osmand/plus/routing/cards/RouteLineColorCard.java b/OsmAnd/src/net/osmand/plus/routing/cards/RouteLineColorCard.java index 3eabe283e3..d8abad16e4 100644 --- a/OsmAnd/src/net/osmand/plus/routing/cards/RouteLineColorCard.java +++ b/OsmAnd/src/net/osmand/plus/routing/cards/RouteLineColorCard.java @@ -10,6 +10,7 @@ import android.widget.LinearLayout; import android.widget.TextView; import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import androidx.appcompat.content.res.AppCompatResources; import androidx.core.content.ContextCompat; import androidx.fragment.app.Fragment; @@ -22,7 +23,6 @@ import net.osmand.plus.UiUtilities; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.helpers.ColorDialogs; import net.osmand.plus.helpers.enums.DayNightMode; -import net.osmand.plus.render.RendererRegistry; import net.osmand.plus.routepreparationmenu.cards.BaseCard; import net.osmand.plus.routepreparationmenu.cards.BaseCard.CardListener; import net.osmand.plus.routing.RouteLineDrawInfo; @@ -110,7 +110,7 @@ public class RouteLineColorCard extends BaseCard implements CardListener, ColorP } private void initSelectedMode() { - selectedMode = routeLineDrawInfo.getColor() == null ? ColorMode.DEFAULT : ColorMode.CUSTOM; + selectedMode = getRouteLineColor() == null ? ColorMode.DEFAULT : ColorMode.CUSTOM; modeChanged(); } @@ -118,13 +118,15 @@ public class RouteLineColorCard extends BaseCard implements CardListener, ColorP if (selectedMode == ColorMode.DEFAULT) { themeToggleContainer.setVisibility(View.GONE); cardsContainer.setVisibility(View.GONE); + routeLineDrawInfo.setUseDefaultColor(true); changeMapTheme(initMapTheme); } else { themeToggleContainer.setVisibility(View.VISIBLE); cardsContainer.setVisibility(View.VISIBLE); + routeLineDrawInfo.setUseDefaultColor(false); changeMapTheme(isNightMap() ? DayNightMode.NIGHT : DayNightMode.DAY); } - updateSelectedColor(); + updateColorItems(); updateDescription(); } @@ -156,6 +158,12 @@ public class RouteLineColorCard extends BaseCard implements CardListener, ColorP if (targetFragment instanceof OnMapThemeUpdateListener) { ((OnMapThemeUpdateListener) targetFragment).onMapThemeUpdated(mapTheme); } + if (selectedMode == ColorMode.CUSTOM) { + Integer color = getRouteLineColor(); + if (color != null) { + colorsCard.setSelectedColor(color); + } + } } private void createColorSelector(ViewGroup container) { @@ -165,14 +173,9 @@ public class RouteLineColorCard extends BaseCard implements CardListener, ColorP for (int color : ColorDialogs.pallette) { colors.add(color); } - Integer selectedColor = routeLineDrawInfo.getColor(); - if (selectedColor != null) { - if (!ColorDialogs.isPaletteColor(selectedColor)) { - colors.add(selectedColor); - } - } else { - selectedColor = colors.get(0); - } + int selectedColorDay = getSelectedColorForTheme(colors, false); + int selectedColorNight = getSelectedColorForTheme(colors, true); + int selectedColor = isNightMap() ? selectedColorNight : selectedColorDay; ListStringPreference preference = app.getSettings().CUSTOM_ROUTE_LINE_COLORS; colorsCard = new ColorsCard(mapActivity, selectedColor, targetFragment, colors, preference, null); colorsCard.setListener(this); @@ -180,26 +183,49 @@ public class RouteLineColorCard extends BaseCard implements CardListener, ColorP } } + private int getSelectedColorForTheme(List colors, boolean nightMode) { + Integer color = routeLineDrawInfo.getColorIgnoreDefault(nightMode); + if (color != null) { + if (!ColorDialogs.isPaletteColor(color)) { + colors.add(color); + } + } else { + color = colors.get(0); + routeLineDrawInfo.setUseDefaultColor(true); + routeLineDrawInfo.setColor(color, nightMode); + } + return color; + } + @Override public void onColorSelected(Integer prevColor, int newColor) { colorsCard.onColorSelected(prevColor, newColor); updateSelectedColor(); } + @Nullable + private Integer getRouteLineColor() { + return routeLineDrawInfo.getColor(isNightMap()); + } + private void updateSelectedColor() { - Integer color = selectedMode == ColorMode.CUSTOM ? colorsCard.getSelectedColor() : null; - routeLineDrawInfo.setColor(color); - updateColorName(); + int selectedColor = colorsCard.getSelectedColor(); + routeLineDrawInfo.setColor(selectedColor, isNightMap()); + updateColorItems(); + } + + private void updateColorItems() { if (targetFragment instanceof OnSelectedColorChangeListener) { ((OnSelectedColorChangeListener) targetFragment).onSelectedColorChanged(); } + updateColorName(); } private void updateColorName() { if (selectedMode == ColorMode.DEFAULT) { tvColorName.setText(app.getString(R.string.map_widget_renderer)); - } else if (routeLineDrawInfo.getColor() != null) { - int colorNameId = ColorDialogs.getColorName(routeLineDrawInfo.getColor()); + } else if (getRouteLineColor() != null) { + int colorNameId = ColorDialogs.getColorName(getRouteLineColor()); tvColorName.setText(app.getString(colorNameId)); } } diff --git a/OsmAnd/src/net/osmand/plus/routing/cards/RouteLineWidthCard.java b/OsmAnd/src/net/osmand/plus/routing/cards/RouteLineWidthCard.java index 95c20783a4..72055da936 100644 --- a/OsmAnd/src/net/osmand/plus/routing/cards/RouteLineWidthCard.java +++ b/OsmAnd/src/net/osmand/plus/routing/cards/RouteLineWidthCard.java @@ -24,7 +24,6 @@ import net.osmand.plus.R; import net.osmand.plus.UiUtilities; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.helpers.AndroidUiHelper; -import net.osmand.plus.render.RendererRegistry; import net.osmand.plus.routepreparationmenu.cards.BaseCard; import net.osmand.plus.routing.RouteLineDrawInfo; import net.osmand.plus.track.AppearanceViewHolder; @@ -201,6 +200,10 @@ public class RouteLineWidthCard extends BaseCard { return WidthMode.DEFAULT; } + private boolean isNightMode() { + return app.getDaynightHelper().isNightModeForMapControls(); + } + private class WidthAdapter extends RecyclerView.Adapter { private final List items = Arrays.asList(WidthMode.values()); @@ -268,13 +271,9 @@ public class RouteLineWidthCard extends BaseCard { } private int getIconColor(@NonNull WidthMode mode, @ColorInt int defaultColor) { - return mode.widthKey != null ? getRouteLineColor() : defaultColor; - } - - private int getRouteLineColor() { - Integer color = routeLineDrawInfo.getColor(); - return color != null ? color : - mapActivity.getMapLayers().getRouteLayer().getRouteLineColor(nightMode); + return mode.widthKey != null ? + mapActivity.getMapLayers().getRouteLayer().getRouteLineColor(isNightMode()) : + defaultColor; } private void updateButtonBg(AppearanceViewHolder holder, WidthMode item) { diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java index 5fbc34e674..b5ea05fb09 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java @@ -2691,8 +2691,10 @@ public class OsmandSettings { public final CommonPreference ROUTE_RECALCULATION_DISTANCE = new FloatPreference(this, "routing_recalc_distance", 0.f).makeProfile(); public final CommonPreference ROUTE_STRAIGHT_ANGLE = new FloatPreference(this, "routing_straight_angle", 30.f).makeProfile(); + public final ListStringPreference CUSTOM_ROUTE_LINE_COLORS = (ListStringPreference) new ListStringPreference(this, "custom_route_line_colors", null, ",").makeShared().makeGlobal(); public final CommonPreference ROUTE_LINE_COLOR = new IntPreference(this, "route_line_color", 0).makeProfile(); + public final CommonPreference ROUTE_LINE_COLOR_NIGHT = new IntPreference(this, "route_line_color_night", 0).makeProfile(); public final CommonPreference ROUTE_LINE_WIDTH = new StringPreference(this, "route_line_width", null).makeProfile(); public final OsmandPreference USE_OSM_LIVE_FOR_ROUTING = new BooleanPreference(this, "enable_osmc_routing", true).makeProfile(); diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/ProfileAppearanceFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/ProfileAppearanceFragment.java index f4b38a32b8..01d9229eb0 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/ProfileAppearanceFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/ProfileAppearanceFragment.java @@ -1019,23 +1019,35 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O } private RouteLineDrawInfo createRouteLineDrawInfo(@NonNull ApplicationMode appMode) { - int storedValue = settings.ROUTE_LINE_COLOR.getModeValue(appMode); - Integer color = storedValue != 0 ? storedValue : null; + Integer colorDay = getRouteLineColor(appMode, settings.ROUTE_LINE_COLOR); + Integer colorNight = getRouteLineColor(appMode, settings.ROUTE_LINE_COLOR_NIGHT); String widthKey = settings.ROUTE_LINE_WIDTH.getModeValue(appMode); - return new RouteLineDrawInfo(color, widthKey); + return new RouteLineDrawInfo(colorDay, colorNight, widthKey); + } + + private Integer getRouteLineColor(@NonNull ApplicationMode appMode, + @NonNull CommonPreference preference) { + int storedValue = preference.getModeValue(appMode); + return storedValue != 0 ? storedValue : null; } private void saveRouteLineAppearance(@NonNull ApplicationMode appMode, @NonNull RouteLineDrawInfo drawInfo) { - Integer color = drawInfo.getColor(); - if (color != null) { - settings.ROUTE_LINE_COLOR.setModeValue(appMode, color); - } else { - settings.ROUTE_LINE_COLOR.resetModeToDefault(appMode); - } + saveRouteLineColor(appMode, settings.ROUTE_LINE_COLOR, drawInfo.getColor(false)); + saveRouteLineColor(appMode, settings.ROUTE_LINE_COLOR_NIGHT, drawInfo.getColor(true)); settings.ROUTE_LINE_WIDTH.setModeValue(appMode, drawInfo.getWidth()); } + private void saveRouteLineColor(@NonNull ApplicationMode appMode, + @NonNull CommonPreference preference, + @Nullable @ColorInt Integer color) { + if (color != null) { + preference.setModeValue(appMode, color); + } else { + preference.resetModeToDefault(appMode); + } + } + public static boolean showInstance(FragmentActivity activity, SettingsScreenType screenType, @Nullable String appMode, boolean imported) { try { Fragment fragment = Fragment.instantiate(activity, screenType.fragmentName); diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/RouteLineAppearanceFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/RouteLineAppearanceFragment.java index b0587eacde..2975815bb4 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/RouteLineAppearanceFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/RouteLineAppearanceFragment.java @@ -385,6 +385,10 @@ public class RouteLineAppearanceFragment extends ContextMenuScrollFragment imple @Override public void onSelectedColorChanged() { + updateColorItems(); + } + + private void updateColorItems() { if (widthCard != null) { widthCard.updateItems(); } @@ -415,6 +419,7 @@ public class RouteLineAppearanceFragment extends ContextMenuScrollFragment imple @Override public void onMapThemeUpdated(@NonNull DayNightMode mapTheme) { changeMapTheme(mapTheme); + updateColorItems(); } private void changeMapTheme(@NonNull DayNightMode mapTheme) { diff --git a/OsmAnd/src/net/osmand/plus/track/ColorsCard.java b/OsmAnd/src/net/osmand/plus/track/ColorsCard.java index 7651775f6c..dd832da27f 100644 --- a/OsmAnd/src/net/osmand/plus/track/ColorsCard.java +++ b/OsmAnd/src/net/osmand/plus/track/ColorsCard.java @@ -72,6 +72,7 @@ public class ColorsCard extends BaseCard implements ColorPickerListener { public void setSelectedColor(int selectedColor) { this.selectedColor = selectedColor; + updateContent(); } @Override diff --git a/OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java index 2a432c8041..816327eda6 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java @@ -42,6 +42,7 @@ import net.osmand.plus.routing.RouteLineDrawInfo; import net.osmand.plus.routing.RouteService; import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.routing.TransportRoutingHelper; +import net.osmand.plus.settings.backend.CommonPreference; import net.osmand.plus.views.OsmandMapLayer; import net.osmand.plus.views.OsmandMapTileView; import net.osmand.plus.views.layers.geometry.PublicTransportGeometryWay; @@ -315,14 +316,16 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont QuadPoint c = tileBox.getCenterPixelPoint(); canvas.rotate(-angle, c.x, c.y); - drawRouteLinePreview(canvas, tileBox, routeLineDrawInfo); + drawRouteLinePreview(canvas, tileBox, settings, routeLineDrawInfo); canvas.rotate(angle, c.x, c.y); } } private void drawRouteLinePreview(Canvas canvas, RotatedTileBox tileBox, + DrawSettings settings, RouteLineDrawInfo drawInfo) { + updateAttrs(settings, tileBox); paintRouteLinePreview.setColor(getRouteLineColor(nightMode)); paintRouteLinePreview.setStrokeWidth(getRouteLineWidth(tileBox)); @@ -417,12 +420,14 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont public int getRouteLineColor(boolean night) { Integer color; if (routeLineDrawInfo != null) { - color = routeLineDrawInfo.getColor(); + color = routeLineDrawInfo.getColor(night); } else { - int storedValue = view.getSettings().ROUTE_LINE_COLOR.getModeValue(helper.getAppMode()); + CommonPreference colorPreference = night ? + view.getSettings().ROUTE_LINE_COLOR_NIGHT : + view.getSettings().ROUTE_LINE_COLOR; + int storedValue = colorPreference.getModeValue(helper.getAppMode()); color = storedValue != 0 ? storedValue : null; } - if (color == null) { updateAttrs(new DrawSettings(night), view.getCurrentRotatedTileBox()); color = attrs.paint.getColor(); From 9d17f50f4b66358ca9aa0d1daf3eb5ddd65c0fcb Mon Sep 17 00:00:00 2001 From: Skalii Date: Thu, 25 Mar 2021 17:24:09 +0200 Subject: [PATCH 18/74] fix full height of main dialog in landscape --- .../monitoring/TripRecordingBottomSheet.java | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java index 2b2e13d2c4..425378b4b6 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java @@ -5,11 +5,13 @@ import android.app.Dialog; import android.content.Context; import android.content.res.ColorStateList; import android.graphics.drawable.Drawable; +import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.view.ViewTreeObserver; import android.widget.CompoundButton; import android.widget.FrameLayout; import android.widget.LinearLayout; @@ -690,6 +692,36 @@ public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment impl return nightMode ? R.drawable.btn_background_inactive_dark : R.drawable.btn_background_inactive_light; } + @Override + protected void setupHeightAndBackground(final View mainView) { + final Activity activity = getActivity(); + if (activity == null) { + return; + } + if (AndroidUiHelper.isOrientationPortrait(activity)) { + super.setupHeightAndBackground(mainView); + return; + } + + mainView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { + @Override + public void onGlobalLayout() { + ViewTreeObserver obs = mainView.getViewTreeObserver(); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { + obs.removeOnGlobalLayoutListener(this); + } else { + obs.removeGlobalOnLayoutListener(this); + } + final View contentView = mainView.findViewById(R.id.scroll_view); + contentView.getLayoutParams().height = ViewGroup.LayoutParams.MATCH_PARENT; + contentView.requestLayout(); + boolean showTopShadow = AndroidUtils.getScreenHeight(activity) - AndroidUtils.getStatusBarHeight(activity) + - mainView.getHeight() >= AndroidUtils.dpToPx(activity, 8); + drawTopShadow(showTopShadow); + } + }); + } + @Override protected boolean hideButtonsContainer() { return true; From ad409bc96796b1e52b718a79449e999d3fc50949 Mon Sep 17 00:00:00 2001 From: Skalii Date: Thu, 25 Mar 2021 17:49:46 +0200 Subject: [PATCH 19/74] fix keep the main "Trip Record" dialog visible after clicking on "Options" --- .../osmand/plus/monitoring/TripRecordingBottomSheet.java | 6 +----- .../plus/monitoring/TripRecordingOptionsBottomSheet.java | 4 ---- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java index 425378b4b6..3decf5bbad 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java @@ -239,15 +239,11 @@ public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment impl } } - public void show() { + public void show(String... keys) { Dialog dialog = getDialog(); if (dialog != null) { dialog.show(); } - } - - public void show(String... keys) { - show(); for (String key : keys) { if (key.equals(UPDATE_TRACK_ICON)) { updateTrackIcon(app, trackAppearanceIcon); diff --git a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingOptionsBottomSheet.java b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingOptionsBottomSheet.java index 52f218190f..994b3034d9 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingOptionsBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingOptionsBottomSheet.java @@ -178,10 +178,6 @@ public class TripRecordingOptionsBottomSheet extends MenuBottomSheetDialogFragme public void onResume() { super.onResume(); runUpdatingTimeTrackSaved(); - Fragment target = getTargetFragment(); - if (target instanceof TripRecordingBottomSheet) { - ((TripRecordingBottomSheet) target).hide(); - } } @Override From 11d03489cc8c7c7dcf679d24f85d778c8084fe4b Mon Sep 17 00:00:00 2001 From: Skalii Date: Thu, 25 Mar 2021 20:27:16 +0200 Subject: [PATCH 20/74] add new items "Altitude range" and "Time on motion" in gpx block statistics --- .../plus/track/GpxBlockStatisticsBuilder.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/track/GpxBlockStatisticsBuilder.java b/OsmAnd/src/net/osmand/plus/track/GpxBlockStatisticsBuilder.java index 96478490bb..8851507084 100644 --- a/OsmAnd/src/net/osmand/plus/track/GpxBlockStatisticsBuilder.java +++ b/OsmAnd/src/net/osmand/plus/track/GpxBlockStatisticsBuilder.java @@ -193,15 +193,20 @@ public class GpxBlockStatisticsBuilder { float totalDistance = withoutGaps ? analysis.totalDistanceWithoutGaps : analysis.totalDistance; String asc = OsmAndFormatter.getFormattedAlt(analysis.diffElevationUp, app); String desc = OsmAndFormatter.getFormattedAlt(analysis.diffElevationDown, app); + String minElevation = OsmAndFormatter.getFormattedAlt(analysis.minElevation, app); + String maxElevation = OsmAndFormatter.getFormattedAlt(analysis.maxElevation, app); String avg = OsmAndFormatter.getFormattedSpeed(analysis.avgSpeed, app); - String max = OsmAndFormatter.getFormattedSpeed(analysis.maxSpeed, app); + String maxSpeed = OsmAndFormatter.getFormattedSpeed(analysis.maxSpeed, app); float timeSpan = withoutGaps ? analysis.timeSpanWithoutGaps : analysis.timeSpan; + long timeMoving = withoutGaps ? analysis.timeMovingWithoutGaps : analysis.timeMoving; prepareDataDistance(totalDistance); prepareDataAscent(asc); prepareDataDescent(desc); + prepareDataAltitudeRange(minElevation, maxElevation); prepareDataAverageSpeed(avg); - prepareDataMaximumSpeed(max); + prepareDataMaximumSpeed(maxSpeed); prepareDataTimeSpan(timeSpan); + prepareDataTimeMoving(timeMoving); break; } } @@ -219,8 +224,7 @@ public class GpxBlockStatisticsBuilder { } public void prepareDataAltitudeRange(String min, String max) { - String pattern = app.getString(R.string.ltr_or_rtl_combine_via_dash); - prepareData(app.getString(R.string.altitude_range), String.format(pattern, min, max), + prepareData(app.getString(R.string.altitude_range), min + " - " + max, R.drawable.ic_action_altitude_range_16, GPXDataSetType.ALTITUDE, null, ItemType.ITEM_ALTITUDE); } @@ -247,9 +251,10 @@ public class GpxBlockStatisticsBuilder { } public void prepareDataTimeMoving(long timeMoving) { - prepareData(app.getString(R.string.shared_string_time_moving), + prepareData(app.getString(initBlocksKey.equals(INIT_BLOCKS_SPEED) ? R.string.shared_string_time_moving : R.string.moving_time), Algorithms.formatDuration((int) (timeMoving / 1000), app.accessibilityEnabled()), - R.drawable.ic_action_time_span_16, GPXDataSetType.SPEED, null, ItemType.ITEM_TIME_MOVING); + initBlocksKey.equals(INIT_BLOCKS_SPEED) ? R.drawable.ic_action_time_span_16 : R.drawable.ic_action_time_moving_16, + GPXDataSetType.SPEED, null, ItemType.ITEM_TIME_MOVING); } public void prepareDataDistanceCorrected(float totalDistanceMoving) { From 483f33bccd4b9a88c974c848c2dee1b486f81424 Mon Sep 17 00:00:00 2001 From: nazar-kutz Date: Thu, 25 Mar 2021 20:49:28 +0200 Subject: [PATCH 21/74] small fixes --- .../src/net/osmand/plus/settings/backend/OsmandSettings.java | 4 ++-- .../plus/settings/fragments/ProfileAppearanceFragment.java | 4 ++-- OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java index b5ea05fb09..d1cd8fd622 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java @@ -2693,8 +2693,8 @@ public class OsmandSettings { public final CommonPreference ROUTE_STRAIGHT_ANGLE = new FloatPreference(this, "routing_straight_angle", 30.f).makeProfile(); public final ListStringPreference CUSTOM_ROUTE_LINE_COLORS = (ListStringPreference) new ListStringPreference(this, "custom_route_line_colors", null, ",").makeShared().makeGlobal(); - public final CommonPreference ROUTE_LINE_COLOR = new IntPreference(this, "route_line_color", 0).makeProfile(); - public final CommonPreference ROUTE_LINE_COLOR_NIGHT = new IntPreference(this, "route_line_color_night", 0).makeProfile(); + public final CommonPreference ROUTE_LINE_COLOR_DAY = new IntPreference(this, "route_line_color", 0).cache().makeProfile(); + public final CommonPreference ROUTE_LINE_COLOR_NIGHT = new IntPreference(this, "route_line_color_night", 0).cache().makeProfile(); public final CommonPreference ROUTE_LINE_WIDTH = new StringPreference(this, "route_line_width", null).makeProfile(); public final OsmandPreference USE_OSM_LIVE_FOR_ROUTING = new BooleanPreference(this, "enable_osmc_routing", true).makeProfile(); diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/ProfileAppearanceFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/ProfileAppearanceFragment.java index 01d9229eb0..c8d600315c 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/ProfileAppearanceFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/ProfileAppearanceFragment.java @@ -1019,7 +1019,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O } private RouteLineDrawInfo createRouteLineDrawInfo(@NonNull ApplicationMode appMode) { - Integer colorDay = getRouteLineColor(appMode, settings.ROUTE_LINE_COLOR); + Integer colorDay = getRouteLineColor(appMode, settings.ROUTE_LINE_COLOR_DAY); Integer colorNight = getRouteLineColor(appMode, settings.ROUTE_LINE_COLOR_NIGHT); String widthKey = settings.ROUTE_LINE_WIDTH.getModeValue(appMode); return new RouteLineDrawInfo(colorDay, colorNight, widthKey); @@ -1033,7 +1033,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O private void saveRouteLineAppearance(@NonNull ApplicationMode appMode, @NonNull RouteLineDrawInfo drawInfo) { - saveRouteLineColor(appMode, settings.ROUTE_LINE_COLOR, drawInfo.getColor(false)); + saveRouteLineColor(appMode, settings.ROUTE_LINE_COLOR_DAY, drawInfo.getColor(false)); saveRouteLineColor(appMode, settings.ROUTE_LINE_COLOR_NIGHT, drawInfo.getColor(true)); settings.ROUTE_LINE_WIDTH.setModeValue(appMode, drawInfo.getWidth()); } diff --git a/OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java index 816327eda6..d7393b2cc9 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java @@ -424,7 +424,7 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont } else { CommonPreference colorPreference = night ? view.getSettings().ROUTE_LINE_COLOR_NIGHT : - view.getSettings().ROUTE_LINE_COLOR; + view.getSettings().ROUTE_LINE_COLOR_DAY; int storedValue = colorPreference.getModeValue(helper.getAppMode()); color = storedValue != 0 ? storedValue : null; } From 1a149c0d63b72ad2a53f62e88e1447408e0a259d Mon Sep 17 00:00:00 2001 From: Skalii Date: Thu, 25 Mar 2021 21:05:10 +0200 Subject: [PATCH 22/74] small fixes --- .../plus/monitoring/TripRecordingBottomSheet.java | 5 ++++- .../net/osmand/plus/myplaces/SegmentGPXAdapter.java | 9 ++------- OsmAnd/src/net/osmand/plus/track/SegmentsCard.java | 2 +- .../plus/views/controls/PagerSlidingTabStrip.java | 12 ------------ 4 files changed, 7 insertions(+), 21 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java index 3decf5bbad..480e5affa8 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java @@ -294,10 +294,13 @@ public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment impl viewGroup.removeAllViews(); setupDisplayHelper(); - View segmentView = SegmentGPXAdapter.createGpxTabsView(displayHelper, viewGroup, this, nightMode, true); + View segmentView = SegmentGPXAdapter.createGpxTabsView(displayHelper, viewGroup, this, nightMode); AndroidUiHelper.setVisibility(View.GONE, segmentView.findViewById(R.id.list_item_divider)); WrapContentHeightViewPager pager = segmentView.findViewById(R.id.pager); PagerSlidingTabStrip tabLayout = segmentView.findViewById(R.id.sliding_tabs); + tabLayout.setDividerWidth(AndroidUtils.dpToPx(app, 1)); + tabLayout.setDividerColor(ContextCompat.getColor(app, nightMode ? + R.color.stroked_buttons_and_links_outline_dark : R.color.stroked_buttons_and_links_outline_light)); tabLayout.setOnTabReselectedListener(new PagerSlidingTabStrip.OnTabReselectedListener() { @Override public void onTabSelected(int position) { diff --git a/OsmAnd/src/net/osmand/plus/myplaces/SegmentGPXAdapter.java b/OsmAnd/src/net/osmand/plus/myplaces/SegmentGPXAdapter.java index 9891c6ef5f..91f67afd22 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/SegmentGPXAdapter.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/SegmentGPXAdapter.java @@ -49,7 +49,7 @@ public class SegmentGPXAdapter extends ArrayAdapter { boolean create = false; if (row == null) { create = true; - row = createGpxTabsView(displayHelper, parent, listener, nightMode, false); + row = createGpxTabsView(displayHelper, parent, listener, nightMode); } GpxDisplayItem item = getItem(position); if (item != null) { @@ -67,7 +67,7 @@ public class SegmentGPXAdapter extends ArrayAdapter { } public static View createGpxTabsView(TrackDisplayHelper displayHelper, ViewGroup root, - SegmentActionsListener listener, boolean nightMode, boolean withDivider) { + SegmentActionsListener listener, boolean nightMode) { Context context = root.getContext(); View row = UiUtilities.getInflater(context, nightMode).inflate(R.layout.gpx_list_item_tab_content, root, false); @@ -75,11 +75,6 @@ public class SegmentGPXAdapter extends ArrayAdapter { tabLayout.setTabBackground(AndroidUtils.resolveAttribute(context, R.attr.btn_bg_border_inactive)); tabLayout.setIndicatorHeight(0); tabLayout.setShouldExpand(true); - if (withDivider) { - tabLayout.setDividerWidth(AndroidUtils.dpToPx(context, 1.0f)); - tabLayout.setDividerColor(ContextCompat.getColor(context, nightMode ? - R.color.stroked_buttons_and_links_outline_dark : R.color.stroked_buttons_and_links_outline_light)); - } WrapContentHeightViewPager pager = row.findViewById(R.id.pager); pager.setSwipeable(false); pager.setOffscreenPageLimit(2); diff --git a/OsmAnd/src/net/osmand/plus/track/SegmentsCard.java b/OsmAnd/src/net/osmand/plus/track/SegmentsCard.java index 8a49438bc6..a3ed324543 100644 --- a/OsmAnd/src/net/osmand/plus/track/SegmentsCard.java +++ b/OsmAnd/src/net/osmand/plus/track/SegmentsCard.java @@ -42,7 +42,7 @@ public class SegmentsCard extends BaseCard { container.removeAllViews(); List items = TrackDisplayHelper.flatten(displayHelper.getOriginalGroups(filterTypes)); for (GpxDisplayItem displayItem : items) { - View segmentView = SegmentGPXAdapter.createGpxTabsView(displayHelper, container, listener, nightMode, false); + View segmentView = SegmentGPXAdapter.createGpxTabsView(displayHelper, container, listener, nightMode); WrapContentHeightViewPager pager = segmentView.findViewById(R.id.pager); PagerSlidingTabStrip tabLayout = segmentView.findViewById(R.id.sliding_tabs); diff --git a/OsmAnd/src/net/osmand/plus/views/controls/PagerSlidingTabStrip.java b/OsmAnd/src/net/osmand/plus/views/controls/PagerSlidingTabStrip.java index 7eade8f2ba..bdb936f8ba 100644 --- a/OsmAnd/src/net/osmand/plus/views/controls/PagerSlidingTabStrip.java +++ b/OsmAnd/src/net/osmand/plus/views/controls/PagerSlidingTabStrip.java @@ -129,7 +129,6 @@ public class PagerSlidingTabStrip extends HorizontalScrollView { private int dividerWidth = 0; - private int dividerPadding = 0; @ColorInt private int dividerColor; @@ -183,7 +182,6 @@ public class PagerSlidingTabStrip extends HorizontalScrollView { scrollOffset = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, scrollOffset, dm); indicatorHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, indicatorHeight, dm); underlineHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, underlineHeight, dm); - dividerPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerPadding, dm); tabPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabPadding, dm); dividerWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerWidth, dm); tabTextSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, tabTextSize, dm); @@ -214,7 +212,6 @@ public class PagerSlidingTabStrip extends HorizontalScrollView { dividerWidth = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsDividerWidth, dividerWidth); indicatorHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsIndicatorHeight, indicatorHeight); underlineHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsUnderlineHeight, underlineHeight); - dividerPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsDividerPadding, dividerPadding); tabPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsTabPaddingLeftRight, tabPadding); tabBackgroundResId = a.getResourceId(R.styleable.PagerSlidingTabStrip_pstsTabBackground, tabBackgroundResId); indicatorBgColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsTabBackground, Color.TRANSPARENT); @@ -720,10 +717,6 @@ public class PagerSlidingTabStrip extends HorizontalScrollView { return underlineHeight; } - public int getDividerPadding() { - return dividerPadding; - } - public int getScrollOffset() { return scrollOffset; } @@ -826,11 +819,6 @@ public class PagerSlidingTabStrip extends HorizontalScrollView { invalidate(); } - public void setDividerPadding(int dividerPaddingPx) { - this.dividerPadding = dividerPaddingPx; - invalidate(); - } - public void setScrollOffset(int scrollOffsetPx) { this.scrollOffset = scrollOffsetPx; invalidate(); From 27cf399bd9edc200e101187136dd86a133c9c7e7 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Thu, 25 Mar 2021 22:49:31 +0200 Subject: [PATCH 23/74] Fix NoClassDefFoundError for old android version --- .../main/java/net/osmand/router/RoutePlannerFrontEnd.java | 7 +++---- .../main/java/net/osmand/router/RoutingConfiguration.java | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/router/RoutePlannerFrontEnd.java b/OsmAnd-java/src/main/java/net/osmand/router/RoutePlannerFrontEnd.java index 74dceb13a1..4fb6c9a193 100644 --- a/OsmAnd-java/src/main/java/net/osmand/router/RoutePlannerFrontEnd.java +++ b/OsmAnd-java/src/main/java/net/osmand/router/RoutePlannerFrontEnd.java @@ -6,7 +6,6 @@ import net.osmand.NativeLibrary; import net.osmand.PlatformUtil; import net.osmand.ResultMatcher; import net.osmand.binary.BinaryMapIndexReader; -import net.osmand.binary.BinaryMapRouteReaderAdapter; import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteRegion; import net.osmand.binary.RouteDataObject; import net.osmand.data.LatLon; @@ -689,15 +688,15 @@ public class RoutePlannerFrontEnd { } } if (ctx.calculationMode == RouteCalculationMode.COMPLEX && routeDirection == null - && maxDistance > ctx.config.DEVIATION_RADIUS * 6) { + && maxDistance > RoutingConfiguration.DEVIATION_RADIUS * 6) { ctx.calculationProgress.totalIterations++; RoutingContext nctx = buildRoutingContext(ctx.config, ctx.nativeLib, ctx.getMaps(), RouteCalculationMode.BASE); nctx.calculationProgress = ctx.calculationProgress; List ls = searchRoute(nctx, start, end, intermediates); - if(ls == null) { + if (ls == null) { return null; } - routeDirection = PrecalculatedRouteDirection.build(ls, ctx.config.DEVIATION_RADIUS, ctx.getRouter().getMaxSpeed()); + routeDirection = PrecalculatedRouteDirection.build(ls, RoutingConfiguration.DEVIATION_RADIUS, ctx.getRouter().getMaxSpeed()); } List res ; if (intermediatesEmpty && ctx.nativeLib != null) { diff --git a/OsmAnd-java/src/main/java/net/osmand/router/RoutingConfiguration.java b/OsmAnd-java/src/main/java/net/osmand/router/RoutingConfiguration.java index 232b971f9f..829e061494 100644 --- a/OsmAnd-java/src/main/java/net/osmand/router/RoutingConfiguration.java +++ b/OsmAnd-java/src/main/java/net/osmand/router/RoutingConfiguration.java @@ -20,7 +20,7 @@ import java.util.Stack; public class RoutingConfiguration { public static final int DEFAULT_MEMORY_LIMIT = 30; - public final float DEVIATION_RADIUS = 3000; + public static final float DEVIATION_RADIUS = 3000; public Map attributes = new LinkedHashMap(); // 1. parameters of routing and different tweaks From 9cfd0f5e360b8faa5bc44b728ee3b6da17861cf5 Mon Sep 17 00:00:00 2001 From: androiddevkotlin <64539346+androiddevkotlin@users.noreply.github.com> Date: Thu, 25 Mar 2021 23:45:29 +0200 Subject: [PATCH 24/74] Directions: Displayed tracks, select segment doesn't show https://github.com/osmandapp/OsmAnd-Issues/issues/518 --- .../routepreparationmenu/cards/TracksCard.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/TracksCard.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/TracksCard.java index 5becff9bad..7170847059 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/TracksCard.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/TracksCard.java @@ -10,6 +10,7 @@ import android.widget.TextView; import androidx.annotation.NonNull; import androidx.appcompat.view.ContextThemeWrapper; import androidx.core.content.ContextCompat; +import androidx.fragment.app.Fragment; import net.osmand.AndroidUtils; import net.osmand.GPXUtilities; @@ -20,7 +21,11 @@ import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.helpers.GpxUiHelper; import net.osmand.plus.helpers.GpxUiHelper.GPXInfo; +import net.osmand.plus.routepreparationmenu.FollowTrackFragment; +import net.osmand.plus.routepreparationmenu.MapRouteInfoMenuFragment; import net.osmand.plus.settings.backend.ApplicationMode; +import net.osmand.plus.track.TrackMenuFragment; +import net.osmand.plus.track.TrackSelectSegmentBottomSheet; import java.io.File; import java.util.ArrayList; @@ -30,7 +35,7 @@ import java.util.List; public class TracksCard extends BaseCard { - private List gpxFiles; + private final List gpxFiles; private boolean showLimited = true; private static class GpxItem { @@ -127,8 +132,13 @@ public class TracksCard extends BaseCard { app.initVoiceCommandPlayer(mapActivity, mode, true, null, false, false, true); } } - mapActivity.getMapActions().setGPXRouteParams(item.file); - app.getTargetPointsHelper().updateRouteAndRefresh(true); + if (item.file.getNonEmptySegmentsCount() > 1) { + Fragment f = mapActivity.getSupportFragmentManager().findFragmentByTag(TrackMenuFragment.TAG); + TrackSelectSegmentBottomSheet.showInstance(mapActivity.getSupportFragmentManager(), item.file, f); + } else { + mapActivity.getMapActions().setGPXRouteParams(item.file); + app.getTargetPointsHelper().updateRouteAndRefresh(true); + } } }); tracks.addView(v); From 8ee7cd0736ffbe0a916293db06915ea1820ab45d Mon Sep 17 00:00:00 2001 From: androiddevkotlin <64539346+androiddevkotlin@users.noreply.github.com> Date: Thu, 25 Mar 2021 23:47:04 +0200 Subject: [PATCH 25/74] Remove unused import and unnecessary casting --- .../plus/routepreparationmenu/cards/TracksCard.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/TracksCard.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/TracksCard.java index 7170847059..1abccb3382 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/TracksCard.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/TracksCard.java @@ -21,8 +21,6 @@ import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.helpers.GpxUiHelper; import net.osmand.plus.helpers.GpxUiHelper.GPXInfo; -import net.osmand.plus.routepreparationmenu.FollowTrackFragment; -import net.osmand.plus.routepreparationmenu.MapRouteInfoMenuFragment; import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.track.TrackMenuFragment; import net.osmand.plus.track.TrackSelectSegmentBottomSheet; @@ -81,7 +79,7 @@ public class TracksCard extends BaseCard { } }); - LinearLayout tracks = (LinearLayout) view.findViewById(R.id.items); + LinearLayout tracks = view.findViewById(R.id.items); tracks.removeAllViews(); int minCardHeight = app.getResources().getDimensionPixelSize(R.dimen.route_info_card_item_height); @@ -115,10 +113,10 @@ public class TracksCard extends BaseCard { ((TextView) v.findViewById(R.id.points_count)).setTextColor(descriptionColor); ((TextView) v.findViewById(R.id.time)).setTextColor(descriptionColor); - ImageView img = (ImageView) v.findViewById(R.id.icon); + ImageView img = v.findViewById(R.id.icon); img.setImageDrawable(getActiveIcon(R.drawable.ic_action_polygom_dark)); img.setVisibility(View.VISIBLE); - LinearLayout container = (LinearLayout) v.findViewById(R.id.container); + LinearLayout container = v.findViewById(R.id.container); container.setMinimumHeight(minCardHeight); AndroidUtils.setPadding(container, listContentPadding, 0, 0, 0); v.setOnClickListener(new View.OnClickListener() { @@ -134,7 +132,7 @@ public class TracksCard extends BaseCard { } if (item.file.getNonEmptySegmentsCount() > 1) { Fragment f = mapActivity.getSupportFragmentManager().findFragmentByTag(TrackMenuFragment.TAG); - TrackSelectSegmentBottomSheet.showInstance(mapActivity.getSupportFragmentManager(), item.file, f); + TrackSelectSegmentBottomSheet.showInstance(mapActivity.getSupportFragmentManager(), item.file, f); } else { mapActivity.getMapActions().setGPXRouteParams(item.file); app.getTargetPointsHelper().updateRouteAndRefresh(true); From eeaf45ea98a68518e4ce0d38bf70ae62daaaf79b Mon Sep 17 00:00:00 2001 From: androiddevkotlin <64539346+androiddevkotlin@users.noreply.github.com> Date: Thu, 25 Mar 2021 23:56:08 +0200 Subject: [PATCH 26/74] RTL issue - Applying correct text direction (ltr or rtl) https://github.com/osmandapp/OsmAnd/issues/11212 --- .../src/net/osmand/plus/OsmAndFormatter.java | 91 +++++++++++-------- 1 file changed, 51 insertions(+), 40 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/OsmAndFormatter.java b/OsmAnd/src/net/osmand/plus/OsmAndFormatter.java index 883cc908c5..10838339d0 100644 --- a/OsmAnd/src/net/osmand/plus/OsmAndFormatter.java +++ b/OsmAnd/src/net/osmand/plus/OsmAndFormatter.java @@ -3,6 +3,8 @@ package net.osmand.plus; import android.content.Context; import android.text.format.DateUtils; +import androidx.core.text.TextUtilsCompat; +import androidx.core.view.ViewCompat; import com.jwetherell.openmap.common.LatLonPoint; import com.jwetherell.openmap.common.MGRSPoint; import com.jwetherell.openmap.common.UTMPoint; @@ -37,7 +39,7 @@ public class OsmAndFormatter { public final static float METERS_IN_KILOMETER = 1000f; public final static float METERS_IN_ONE_MILE = 1609.344f; // 1609.344 public final static float METERS_IN_ONE_NAUTICALMILE = 1852f; // 1852 - + public final static float YARDS_IN_ONE_METER = 1.0936f; public final static float FEET_IN_ONE_METER = YARDS_IN_ONE_METER * 3f; private static final DecimalFormat fixed2 = new DecimalFormat("0.00"); @@ -175,7 +177,7 @@ public class OsmAndFormatter { } else { generator *= 2; } - + if (point == mainUnitInMeter && metersInSecondUnit * mainUnitInMeter * 0.9f <= generator) { point = 1 / metersInSecondUnit; generator = 1; @@ -198,14 +200,14 @@ public class OsmAndFormatter { } return roundDist; } - + public static String getFormattedRoundDistanceKm(float meters, int digits, OsmandApplication ctx) { int mainUnitStr = R.string.km; float mainUnitInMeters = METERS_IN_KILOMETER; if (digits == 0) { return (int) (meters / mainUnitInMeters + 0.5) + " " + ctx.getString(mainUnitStr); //$NON-NLS-1$ } else if (digits == 1) { - return fixed1.format(((float) meters) / mainUnitInMeters) + " " + ctx.getString(mainUnitStr); + return fixed1.format(((float) meters) / mainUnitInMeters) + " " + ctx.getString(mainUnitStr); } else { return fixed2.format(((float) meters) / mainUnitInMeters) + " " + ctx.getString(mainUnitStr); } @@ -225,10 +227,10 @@ public class OsmAndFormatter { } public static String getFormattedAzimuth(float bearing, AngularConstants angularConstant) { - while(bearing < -180.0) { + while (bearing < -180.0) { bearing += 360; } - while(bearing > 360.0) { + while (bearing > 360.0) { bearing -= 360; } switch (angularConstant) { @@ -315,7 +317,7 @@ public class OsmAndFormatter { return ((int) (alt * FEET_IN_ONE_METER + 0.5)) + " " + ctx.getString(R.string.foot); } } - + public static String getFormattedSpeed(float metersperseconds, OsmandApplication ctx) { OsmandSettings settings = ctx.getSettings(); SpeedConstants mc = settings.SPEED_SYSTEM.get(); @@ -376,22 +378,22 @@ public class OsmAndFormatter { return (kmh10 / 10f) + " " + SpeedConstants.METERS_PER_SECOND.toShortString(ctx); } } - - + + public static String toPublicString(CityType t, Context ctx) { switch (t) { - case CITY: - return ctx.getString(R.string.city_type_city); - case HAMLET: - return ctx.getString(R.string.city_type_hamlet); - case TOWN: - return ctx.getString(R.string.city_type_town); - case VILLAGE: - return ctx.getString(R.string.city_type_village); - case SUBURB: - return ctx.getString(R.string.city_type_suburb); - default: - break; + case CITY: + return ctx.getString(R.string.city_type_city); + case HAMLET: + return ctx.getString(R.string.city_type_hamlet); + case TOWN: + return ctx.getString(R.string.city_type_town); + case VILLAGE: + return ctx.getString(R.string.city_type_village); + case SUBURB: + return ctx.getString(R.string.city_type_suburb); + default: + break; } return ""; } @@ -402,7 +404,7 @@ public class OsmAndFormatter { String typeName = amenity.getSubType(); if (pt != null) { typeName = pt.getTranslation(); - } else if(typeName != null){ + } else if (typeName != null) { typeName = Algorithms.capitalizeFirstLetterAndLowercase(typeName.replace('_', ' ')); } String localName = amenity.getName(locale, transliterate); @@ -506,18 +508,27 @@ public class OsmAndFormatter { if (outputFormat == FORMAT_DEGREES_SHORT) { result.append(formatCoordinate(lat, outputFormat)).append(" ").append(formatCoordinate(lon, outputFormat)); } else if (outputFormat == FORMAT_DEGREES || outputFormat == FORMAT_MINUTES || outputFormat == FORMAT_SECONDS) { - result - .append(formatCoordinate(lat, outputFormat)).append(" ") - .append(lat > 0 ? NORTH : SOUTH).append(", ") - .append(formatCoordinate(lon, outputFormat)).append(" ") - .append(lon > 0 ? EAST : WEST); - } else if (outputFormat == UTM_FORMAT) { + boolean isLeftToRight = TextUtilsCompat.getLayoutDirectionFromLocale(Locale.getDefault()) == ViewCompat.LAYOUT_DIRECTION_LTR; + if (isLeftToRight) { + result + .append(formatCoordinate(lat, outputFormat)).append(" ") + .append(lat > 0 ? NORTH : SOUTH).append(", ") + .append(formatCoordinate(lon, outputFormat)).append(" ") + .append(lon > 0 ? EAST : WEST); + } else { + result + .append(formatCoordinate(lat, outputFormat)).append(" ") + .append(lon > 0 ? EAST : WEST).append(" ") + .append(formatCoordinate(lon, outputFormat)).append(", ") + .append(lat > 0 ? NORTH : SOUTH); + } + } else if (outputFormat == UTM_FORMAT) { UTMPoint pnt = new UTMPoint(new LatLonPoint(lat, lon)); result - .append(pnt.zone_number) - .append(pnt.zone_letter).append(" ") - .append((long) pnt.easting).append(" ") - .append((long) pnt.northing); + .append(pnt.zone_number) + .append(pnt.zone_letter).append(" ") + .append((long) pnt.easting).append(" ") + .append((long) pnt.northing); } else if (outputFormat == OLC_FORMAT) { String r; try { @@ -536,21 +547,21 @@ public class OsmAndFormatter { } return result.toString(); } - + private static String formatCoordinate(double coordinate, int outputType) { - + if (coordinate < -180.0 || coordinate > 180.0 || Double.isNaN(coordinate)) { return "Error. Wrong coordinates data!"; } if ((outputType != FORMAT_DEGREES) && (outputType != FORMAT_MINUTES) && (outputType - != FORMAT_SECONDS) && (outputType != FORMAT_DEGREES_SHORT)) { - return "Unknown Output Format!"; + != FORMAT_SECONDS) && (outputType != FORMAT_DEGREES_SHORT)) { + return "Unknown Output Format!"; } DecimalFormat degDf = new DecimalFormat("##0.00000", new DecimalFormatSymbols(Locale.US)); DecimalFormat minDf = new DecimalFormat("00.000", new DecimalFormatSymbols(Locale.US)); DecimalFormat secDf = new DecimalFormat("00.0", new DecimalFormatSymbols(Locale.US)); - + StringBuilder sb = new StringBuilder(); if (coordinate < 0) { @@ -566,11 +577,11 @@ public class OsmAndFormatter { sb.append(degDf.format(coordinate)).append(DELIMITER_DEGREES); } else if (outputType == FORMAT_MINUTES) { sb.append(minDf.format(formatCoordinate(coordinate, sb, DELIMITER_DEGREES))) - .append(DELIMITER_MINUTES); + .append(DELIMITER_MINUTES); } else { sb.append(secDf.format(formatCoordinate( - formatCoordinate(coordinate, sb, DELIMITER_DEGREES), sb, DELIMITER_MINUTES))) - .append(DELIMITER_SECONDS); + formatCoordinate(coordinate, sb, DELIMITER_DEGREES), sb, DELIMITER_MINUTES))) + .append(DELIMITER_SECONDS); } return sb.toString(); } From f1aedd7ef0210881fe86736dca328f4ee6a8ce4e Mon Sep 17 00:00:00 2001 From: nazar-kutz Date: Fri, 26 Mar 2021 00:34:12 +0200 Subject: [PATCH 27/74] Fix #11045 --- .../src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java b/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java index b43171e632..be88b777a7 100644 --- a/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java +++ b/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java @@ -369,8 +369,10 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin { settings.MAP_OVERLAY_PREVIOUS.set(null); } if (underlayLayer.getMap() == null) { + settings.MAP_UNDERLAY.removeListener(underlayListener); settings.MAP_UNDERLAY.set(null); settings.MAP_UNDERLAY_PREVIOUS.set(null); + settings.MAP_UNDERLAY.addListener(underlayListener); } String overlayMapDescr = settings.MAP_OVERLAY.get(); if (overlayMapDescr!=null && overlayMapDescr.contains(".sqlitedb")) { From 27002fd152146b33210c51203a5f73e03d3d3313 Mon Sep 17 00:00:00 2001 From: androiddevkotlin <64539346+androiddevkotlin@users.noreply.github.com> Date: Fri, 26 Mar 2021 01:03:37 +0200 Subject: [PATCH 28/74] Here please use ltr_or_rtl_combine_via_comma for text parts after colon (There's nothing to do with colon itself). --- .../routing/data/AnnounceTimeDistances.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/routing/data/AnnounceTimeDistances.java b/OsmAnd/src/net/osmand/plus/routing/data/AnnounceTimeDistances.java index d03d4f2c43..ea50cdf1e5 100644 --- a/OsmAnd/src/net/osmand/plus/routing/data/AnnounceTimeDistances.java +++ b/OsmAnd/src/net/osmand/plus/routing/data/AnnounceTimeDistances.java @@ -1,11 +1,13 @@ package net.osmand.plus.routing.data; import android.graphics.Typeface; -import android.text.BidiFormatter; import android.text.Spannable; import android.text.SpannableStringBuilder; import android.text.style.StyleSpan; +import androidx.core.text.TextUtilsCompat; +import androidx.core.view.ViewCompat; + import net.osmand.Location; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; @@ -13,6 +15,8 @@ import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.voice.AbstractPrologCommandPlayer; +import java.util.Locale; + public class AnnounceTimeDistances { // Avoids false negatives: Pre-pone close announcements by this distance to allow for the possible over-estimation of the 'true' lead distance due to positioning error. // A smaller value will increase the timing precision, but at the risk of missing prompts which do not meet the precision limit. @@ -217,12 +221,12 @@ public class AnnounceTimeDistances { // round to 5 time = (time / 5) * 5; } - BidiFormatter myBidiFormatter; - if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR2) { - myBidiFormatter = BidiFormatter.getInstance(); - builder.append(String.format("\n%s: %d - %d %s, %d %s.", name, minDist, minDist + 5, myBidiFormatter.unicodeWrap(meter), time, myBidiFormatter.unicodeWrap(second))); - }else{ - builder.append(String.format("\n%s: %d - %d %s, %d %s.", name, minDist, minDist + 5, "\u200F"+meter, time, "\u200F"+second)); + boolean isLeftToRight = TextUtilsCompat.getLayoutDirectionFromLocale(Locale.getDefault()) == ViewCompat.LAYOUT_DIRECTION_LTR; + if (isLeftToRight) { + builder.append(String.format("\n%s: %d - %d %s, %d %s.", name, minDist, minDist + 5, meter, time, second)); + } else { + builder.append(String.format("\n%s: %s %d, %s %d - %d.", name, second, time, meter, minDist, minDist + 5)); + } } From 33968534fa8d63e8c181c196e2acd61059f56ba9 Mon Sep 17 00:00:00 2001 From: androiddevkotlin <64539346+androiddevkotlin@users.noreply.github.com> Date: Fri, 26 Mar 2021 01:55:38 +0200 Subject: [PATCH 29/74] MGRS number translate fix --- .../java/com/jwetherell/openmap/common/MGRSPoint.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/OsmAnd-java/src/main/java/com/jwetherell/openmap/common/MGRSPoint.java b/OsmAnd-java/src/main/java/com/jwetherell/openmap/common/MGRSPoint.java index 6e99eec8b5..be6793bef8 100644 --- a/OsmAnd-java/src/main/java/com/jwetherell/openmap/common/MGRSPoint.java +++ b/OsmAnd-java/src/main/java/com/jwetherell/openmap/common/MGRSPoint.java @@ -17,6 +17,7 @@ package com.jwetherell.openmap.common; import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.Locale; public class MGRSPoint extends ZonedUTMPoint { @@ -697,10 +698,9 @@ public class MGRSPoint extends ZonedUTMPoint { all.set(1, shiftChar(all.get(1), eastShift, northShift)); String zero = ""; } - - - all.add(String.format("%0" + accuracy + "d", roundedEasting)); - all.add(String.format("%0" + accuracy + "d", roundedNorthing)); + + all.add(String.format(java.util.Locale.US,"%0" + accuracy + "d", roundedEasting)); + all.add(String.format(java.util.Locale.US,"%0" + accuracy + "d", roundedNorthing)); break; } } From 67449365b482eba07447e26d1946f7a8357ed3b0 Mon Sep 17 00:00:00 2001 From: cepprice Date: Fri, 26 Mar 2021 11:01:37 +0500 Subject: [PATCH 30/74] Small fixes and corrections --- .../src/main/java/net/osmand/Period.java | 17 ++-- OsmAnd/res/layout/purchases_layout.xml | 2 +- OsmAnd/res/layout/subscription_layout.xml | 1 - .../osmand/plus/inapp/InAppPurchasesImpl.java | 11 ++- .../chooseplan/ChoosePlanDialogFragment.java | 38 ++++---- .../plus/inapp/InAppPurchaseHelper.java | 8 +- .../net/osmand/plus/inapp/InAppPurchases.java | 30 +++++-- .../settings/fragments/PurchasesFragment.java | 45 +++++----- .../settings/fragments/SubscriptionsCard.java | 90 +++++-------------- .../GpxEditDescriptionDialogFragment.java | 2 +- 10 files changed, 119 insertions(+), 125 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/Period.java b/OsmAnd-java/src/main/java/net/osmand/Period.java index d6bd911257..b529fdb6db 100644 --- a/OsmAnd-java/src/main/java/net/osmand/Period.java +++ b/OsmAnd-java/src/main/java/net/osmand/Period.java @@ -1,20 +1,23 @@ package net.osmand; import java.text.ParseException; +import java.util.Calendar; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Period { public enum PeriodUnit { - YEAR("Y"), - MONTH("M"), - WEEK("W"), - DAY("D"); + YEAR("Y", Calendar.YEAR), + MONTH("M", Calendar.MONTH), + WEEK("W", Calendar.WEEK_OF_YEAR), + DAY("D", Calendar.DATE); private String unitStr; + private int calendarIdx; - PeriodUnit(String unitStr) { + PeriodUnit(String unitStr, int calendarIdx) { + this.calendarIdx = calendarIdx; this.unitStr = unitStr; } @@ -22,6 +25,10 @@ public class Period { return unitStr; } + public int getCalendarIdx() { + return calendarIdx; + } + public double getMonthsValue() { switch (this) { case YEAR: diff --git a/OsmAnd/res/layout/purchases_layout.xml b/OsmAnd/res/layout/purchases_layout.xml index 2140d2cc5c..d4bb5a3465 100644 --- a/OsmAnd/res/layout/purchases_layout.xml +++ b/OsmAnd/res/layout/purchases_layout.xml @@ -4,7 +4,7 @@ xmlns:osmand="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" - android:layout_height="wrap_content" + android:layout_height="match_parent" android:background="?attr/bg_color" android:orientation="vertical"> diff --git a/OsmAnd/res/layout/subscription_layout.xml b/OsmAnd/res/layout/subscription_layout.xml index de35b80f4a..411e49db31 100644 --- a/OsmAnd/res/layout/subscription_layout.xml +++ b/OsmAnd/res/layout/subscription_layout.xml @@ -7,7 +7,6 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" - android:background="@android:drawable/list_selector_background" android:paddingStart="@dimen/content_padding" android:paddingLeft="@dimen/content_padding" android:paddingRight="@dimen/content_padding" diff --git a/OsmAnd/src-google/net/osmand/plus/inapp/InAppPurchasesImpl.java b/OsmAnd/src-google/net/osmand/plus/inapp/InAppPurchasesImpl.java index a2a0f8d680..9c7ee92758 100644 --- a/OsmAnd/src-google/net/osmand/plus/inapp/InAppPurchasesImpl.java +++ b/OsmAnd/src-google/net/osmand/plus/inapp/InAppPurchasesImpl.java @@ -2,15 +2,15 @@ package net.osmand.plus.inapp; import android.content.Context; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; - import com.android.billingclient.api.SkuDetails; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.Version; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + public class InAppPurchasesImpl extends InAppPurchases { private static final InAppPurchase FULL_VERSION = new InAppPurchaseFullVersion(); @@ -285,6 +285,11 @@ public class InAppPurchasesImpl extends InAppPurchases { this.details = details; } + @Override + public int getPeriodTypeString() { + return R.string.monthly_subscription; + } + @Override public String getDefaultPrice(Context ctx) { return ""; diff --git a/OsmAnd/src/net/osmand/plus/chooseplan/ChoosePlanDialogFragment.java b/OsmAnd/src/net/osmand/plus/chooseplan/ChoosePlanDialogFragment.java index 8488daf0f5..814fe15871 100644 --- a/OsmAnd/src/net/osmand/plus/chooseplan/ChoosePlanDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/chooseplan/ChoosePlanDialogFragment.java @@ -22,17 +22,6 @@ import android.widget.ProgressBar; import android.widget.TextView; import android.widget.Toast; -import androidx.annotation.ColorRes; -import androidx.annotation.DrawableRes; -import androidx.annotation.LayoutRes; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.appcompat.widget.AppCompatImageView; -import androidx.core.content.ContextCompat; -import androidx.fragment.app.Fragment; -import androidx.fragment.app.FragmentActivity; -import androidx.fragment.app.FragmentManager; - import net.osmand.AndroidUtils; import net.osmand.PlatformUtil; import net.osmand.plus.OsmandApplication; @@ -59,6 +48,17 @@ import org.apache.commons.logging.Log; import java.util.List; +import androidx.annotation.ColorRes; +import androidx.annotation.DrawableRes; +import androidx.annotation.LayoutRes; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.widget.AppCompatImageView; +import androidx.core.content.ContextCompat; +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentActivity; +import androidx.fragment.app.FragmentManager; + public abstract class ChoosePlanDialogFragment extends BaseOsmAndDialogFragment implements InAppPurchaseListener { public static final String TAG = ChoosePlanDialogFragment.class.getSimpleName(); private static final Log LOG = PlatformUtil.getLog(ChoosePlanDialogFragment.class); @@ -489,14 +489,18 @@ public abstract class ChoosePlanDialogFragment extends BaseOsmAndDialogFragment buttonView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { - subscribe(s.getSku()); + if (getActivity() != null) { + subscribe(app, getActivity(), purchaseHelper, s.getSku()); + } } }); } else { buttonExView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { - subscribe(s.getSku()); + if (getActivity() != null) { + subscribe(app, getActivity(), purchaseHelper, s.getSku()); + } } }); } @@ -526,14 +530,14 @@ public abstract class ChoosePlanDialogFragment extends BaseOsmAndDialogFragment } } - private void subscribe(String sku) { + public static void subscribe(@NonNull OsmandApplication app, Activity activity, + InAppPurchaseHelper purchaseHelper, String sku) { if (!app.getSettings().isInternetConnectionAvailable(true)) { Toast.makeText(app, R.string.internet_not_available, Toast.LENGTH_LONG).show(); } else { - FragmentActivity ctx = getActivity(); - if (ctx != null && purchaseHelper != null) { + if (activity != null && purchaseHelper != null) { OsmandSettings settings = app.getSettings(); - purchaseHelper.purchaseLiveUpdates(ctx, sku, + purchaseHelper.purchaseLiveUpdates(activity, sku, settings.BILLING_USER_EMAIL.get(), settings.BILLING_USER_NAME.get(), settings.BILLING_USER_COUNTRY_DOWNLOAD_NAME.get(), diff --git a/OsmAnd/src/net/osmand/plus/inapp/InAppPurchaseHelper.java b/OsmAnd/src/net/osmand/plus/inapp/InAppPurchaseHelper.java index dfa3f55c84..5136cd1f73 100644 --- a/OsmAnd/src/net/osmand/plus/inapp/InAppPurchaseHelper.java +++ b/OsmAnd/src/net/osmand/plus/inapp/InAppPurchaseHelper.java @@ -8,9 +8,6 @@ import android.os.AsyncTask; import android.text.TextUtils; import android.util.Log; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; - import net.osmand.AndroidNetworkUtils; import net.osmand.AndroidNetworkUtils.OnRequestResultListener; import net.osmand.AndroidNetworkUtils.OnRequestsResultListener; @@ -43,6 +40,9 @@ import java.util.List; import java.util.Map; import java.util.Set; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + public abstract class InAppPurchaseHelper { // Debug tag, for logging protected static final org.apache.commons.logging.Log LOG = PlatformUtil.getLog(InAppPurchaseHelper.class); @@ -203,7 +203,7 @@ public abstract class InAppPurchaseHelper { List subscriptions = new ArrayList<>(); for (InAppSubscription subscription : getLiveUpdates().getVisibleSubscriptions()) { SubscriptionState state = subscription.getState(); - if (state != null && !SubscriptionState.UNDEFINED.equals(state)) { + if (state != SubscriptionState.UNDEFINED) { subscriptions.add(subscription); } } diff --git a/OsmAnd/src/net/osmand/plus/inapp/InAppPurchases.java b/OsmAnd/src/net/osmand/plus/inapp/InAppPurchases.java index 8a6d5a0128..27d359630e 100644 --- a/OsmAnd/src/net/osmand/plus/inapp/InAppPurchases.java +++ b/OsmAnd/src/net/osmand/plus/inapp/InAppPurchases.java @@ -7,12 +7,6 @@ import android.text.Spannable; import android.text.SpannableStringBuilder; import android.text.style.ForegroundColorSpan; -import androidx.annotation.ColorInt; -import androidx.annotation.DrawableRes; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.annotation.StringRes; - import net.osmand.AndroidUtils; import net.osmand.Period; import net.osmand.Period.PeriodUnit; @@ -34,6 +28,12 @@ import java.util.Locale; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; +import androidx.annotation.ColorInt; +import androidx.annotation.DrawableRes; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.annotation.StringRes; + public abstract class InAppPurchases { protected InAppPurchase fullVersion; @@ -645,6 +645,9 @@ public abstract class InAppPurchases { this.skuNoVersion = sku; } + @StringRes + public abstract int getPeriodTypeString(); + @NonNull private List getUpgrades() { return new ArrayList<>(upgrades.values()); @@ -835,6 +838,11 @@ public abstract class InAppPurchases { this(sku, false); } + @Override + public int getPeriodTypeString() { + return R.string.monthly_subscription; + } + @Override public void setPriceValue(double priceValue) { super.setPriceValue(priceValue); @@ -883,6 +891,11 @@ public abstract class InAppPurchases { super(sku, false); } + @Override + public int getPeriodTypeString() { + return R.string.three_months_subscription; + } + @Override public void setPriceValue(double priceValue) { super.setPriceValue(priceValue); @@ -926,6 +939,11 @@ public abstract class InAppPurchases { super(sku, false); } + @Override + public int getPeriodTypeString() { + return R.string.annual_subscription; + } + @Override public void setPriceValue(double priceValue) { super.setPriceValue(priceValue); diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/PurchasesFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/PurchasesFragment.java index af834f73b8..00a15b3071 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/PurchasesFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/PurchasesFragment.java @@ -24,6 +24,7 @@ import android.widget.TextView; import com.google.android.material.appbar.AppBarLayout; import net.osmand.AndroidUtils; +import net.osmand.PlatformUtil; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; @@ -44,6 +45,8 @@ import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.wikipedia.WikipediaDialogFragment; import net.osmand.util.Algorithms; +import org.apache.commons.logging.Log; + import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.fragment.app.FragmentActivity; @@ -51,10 +54,17 @@ import androidx.fragment.app.FragmentManager; public class PurchasesFragment extends BaseOsmAndFragment implements InAppPurchaseListener, OnFragmentInteractionListener { + private static final Log log = PlatformUtil.getLog(PurchasesFragment.class); public static final String TAG = PurchasesFragment.class.getName(); + public static final String KEY_IS_SUBSCRIBER = "action_is_new"; + private static final String PLAY_STORE_SUBSCRIPTION_URL = "https://play.google.com/store/account/subscriptions"; private static final String PLAY_STORE_SUBSCRIPTION_DEEPLINK_URL = "https://play.google.com/store/account/subscriptions?sku=%s&package=%s"; + private static final String EMAIL_DEEPLINK_URI = "mailto:support@osmand.net"; + private static final String OSMAND_EMAIL = "support@osmand.net"; + private static final String OSMAND_NEW_DEVICE_URL = "https://docs.osmand.net/en/main@latest/osmand/purchases#new-device--new-account"; + private static final String OSMAND_PURCHASES_URL = "https://docs.osmand.net/en/main@latest/osmand/purchases"; private OsmandApplication app; private Context context; @@ -66,17 +76,18 @@ public class PurchasesFragment extends BaseOsmAndFragment implements InAppPurcha private CountrySelectionFragment countrySelectionFragment = new CountrySelectionFragment(); private String url; - private Boolean isSubscriber; + private Boolean isPaidVersion; public static boolean showInstance(FragmentManager fragmentManager) { try { PurchasesFragment fragment = new PurchasesFragment(); fragmentManager.beginTransaction() - .add(R.id.fragmentContainer, fragment, TAG) + .replace(R.id.fragmentContainer, fragment, TAG) .addToBackStack(TAG) .commitAllowingStateLoss(); return true; } catch (Exception e) { + log.error(e); return false; } } @@ -90,12 +101,12 @@ public class PurchasesFragment extends BaseOsmAndFragment implements InAppPurcha public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { app = getMyApplication(); context = requireContext(); - isSubscriber = Version.isPaidVersion(app); + isPaidVersion = Version.isPaidVersion(app); final MapActivity mapActivity = getMapActivity(); final boolean nightMode = !app.getSettings().isLightContent(); LayoutInflater themedInflater = UiUtilities.getInflater(context, nightMode); - if (isSubscriber) { + if (isPaidVersion) { mainView = themedInflater.inflate(R.layout.purchases_layout, container, false); setSubscriptionClick(mapActivity); } else { @@ -117,11 +128,6 @@ public class PurchasesFragment extends BaseOsmAndFragment implements InAppPurcha } AndroidUtils.addStatusBarPadding21v(getActivity(), mainView); createToolbar(mainView, nightMode); - mainView.setOnTouchListener(new View.OnTouchListener() { - public boolean onTouch(View v, MotionEvent event) { - return true; - } - }); LinearLayout purchasesRestore = mainView.findViewById(R.id.restore_purchases); purchasesRestore.setOnClickListener(new View.OnClickListener() { @Override @@ -135,7 +141,7 @@ public class PurchasesFragment extends BaseOsmAndFragment implements InAppPurcha newDeviceAccountContainer.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - WikipediaDialogFragment.showFullArticle(context, Uri.parse("https://docs.osmand.net/en/main@latest/osmand/purchases#new-device--new-account"), nightMode); + WikipediaDialogFragment.showFullArticle(context, Uri.parse(OSMAND_NEW_DEVICE_URL), nightMode); } }); @@ -147,10 +153,11 @@ public class PurchasesFragment extends BaseOsmAndFragment implements InAppPurcha public void onResume() { super.onResume(); purchaseHelper = getInAppPurchaseHelper(); - if (isSubscriber) { + if (isPaidVersion) { MapActivity mapActivity = getMapActivity(); if (getMapActivity() != null && purchaseHelper != null) { ViewGroup subscriptionsCardContainer = mainView.findViewById(R.id.subscriptions_card_container); + subscriptionsCardContainer.removeAllViews(); subscriptionsCard = new SubscriptionsCard(mapActivity, purchaseHelper); subscriptionsCardContainer.addView(subscriptionsCard.build(mapActivity)); } @@ -161,7 +168,7 @@ public class PurchasesFragment extends BaseOsmAndFragment implements InAppPurcha @Override public void onSaveInstanceState(@NonNull Bundle outState) { super.onSaveInstanceState(outState); - outState.putBoolean(KEY_IS_SUBSCRIBER, isSubscriber); + outState.putBoolean(KEY_IS_SUBSCRIBER, isPaidVersion); } @Override @@ -277,7 +284,7 @@ public class PurchasesFragment extends BaseOsmAndFragment implements InAppPurcha icon.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - WikipediaDialogFragment.showFullArticle(context, Uri.parse("https://docs.osmand.net/en/main@latest/osmand/purchases"), nightMode); + WikipediaDialogFragment.showFullArticle(context, Uri.parse(OSMAND_PURCHASES_URL), nightMode); } }); ImageButton backButton = toolbar.findViewById(R.id.close_button); @@ -301,14 +308,12 @@ public class PurchasesFragment extends BaseOsmAndFragment implements InAppPurcha TextView supportDescription = mainView.findViewById(R.id.support_link_title); SpannableString spannableStringSupport = new SpannableString(getString(R.string.contact_support)); - String urlSupport = "mailto:support@osmand.net"; - spannableStringSupport.setSpan(new URLSpan(urlSupport), 0, spannableStringSupport.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); + spannableStringSupport.setSpan(new URLSpan(EMAIL_DEEPLINK_URI), 0, spannableStringSupport.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); - String emailString = "support@osmand.net"; - String supportDescriptionString = getString(R.string.contact_support_description, emailString); + String supportDescriptionString = getString(R.string.contact_support_description, OSMAND_EMAIL); SpannableString spannableStringMail = new SpannableString(supportDescriptionString); - int startIndex = supportDescriptionString.indexOf(emailString); - int endIndex = startIndex + emailString.length(); + int startIndex = supportDescriptionString.indexOf(OSMAND_EMAIL); + int endIndex = startIndex + OSMAND_EMAIL.length(); StyleSpan boldSpan = new StyleSpan(Typeface.BOLD); spannableStringMail.setSpan(boldSpan, startIndex, endIndex, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); @@ -322,7 +327,7 @@ public class PurchasesFragment extends BaseOsmAndFragment implements InAppPurcha private void getSkuAppId() { InAppPurchaseHelper purchaseHelper = app.getInAppPurchaseHelper(); - if (purchaseHelper != null) { + if (purchaseHelper != null && purchaseHelper.getFullVersion() != null) { String sku = purchaseHelper.getFullVersion().getSku(); url = String.format(PLAY_STORE_SUBSCRIPTION_DEEPLINK_URL, sku, context.getPackageName()); diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/SubscriptionsCard.java b/OsmAnd/src/net/osmand/plus/settings/fragments/SubscriptionsCard.java index c8c0d5202b..1cc422b3ff 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/SubscriptionsCard.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/SubscriptionsCard.java @@ -5,34 +5,34 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; -import android.widget.Toast; import net.osmand.AndroidUtils; import net.osmand.Period; import net.osmand.plus.R; +import net.osmand.plus.UiUtilities; import net.osmand.plus.activities.MapActivity; +import net.osmand.plus.chooseplan.ChoosePlanDialogFragment; import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.inapp.InAppPurchaseHelper; import net.osmand.plus.inapp.InAppPurchases.InAppSubscription; import net.osmand.plus.inapp.InAppPurchases.InAppSubscription.SubscriptionState; import net.osmand.plus.routepreparationmenu.cards.BaseCard; -import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.util.Algorithms; import java.text.SimpleDateFormat; -import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.List; +import java.util.Locale; import androidx.annotation.NonNull; -import androidx.appcompat.view.ContextThemeWrapper; -import androidx.core.content.ContextCompat; public class SubscriptionsCard extends BaseCard { private final InAppPurchaseHelper purchaseHelper; + private final SimpleDateFormat dateFormat; + @Override public int getCardLayoutId() { return R.layout.subscriptions_card; @@ -41,33 +41,29 @@ public class SubscriptionsCard extends BaseCard { public SubscriptionsCard(@NonNull MapActivity mapActivity, @NonNull InAppPurchaseHelper purchaseHelper) { super(mapActivity); this.purchaseHelper = purchaseHelper; + this.dateFormat = new SimpleDateFormat("MMM d, yyyy", Locale.getDefault()); } @Override protected void updateContent() { - if (mapActivity == null || purchaseHelper == null) { + if (purchaseHelper == null || Algorithms.isEmpty(purchaseHelper.getEverMadeSubscriptions())) { return; } - List subscriptions = purchaseHelper.getEverMadeSubscriptions(); - if (Algorithms.isEmpty(subscriptions)) { - return; - } - - ContextThemeWrapper ctx = new ContextThemeWrapper(mapActivity, !nightMode ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme); - LayoutInflater inflater = LayoutInflater.from(ctx); + LayoutInflater inflater = UiUtilities.getInflater(mapActivity, nightMode); ((ViewGroup) view).removeAllViews(); + List subscriptions = purchaseHelper.getEverMadeSubscriptions(); for (int i = 0; i < subscriptions.size(); i++) { InAppSubscription subscription = subscriptions.get(i); SubscriptionState state = subscription.getState(); - boolean autoRenewed = SubscriptionState.ACTIVE.equals(state) || SubscriptionState.IN_GRACE_PERIOD.equals(state); + boolean autoRenewed = state == SubscriptionState.ACTIVE || state == SubscriptionState.IN_GRACE_PERIOD; View card = inflater.inflate(R.layout.subscription_layout, null, false); ((ViewGroup) view).addView(card); TextView subscriptionPeriod = card.findViewById(R.id.subscription_type); - String period = getSubscriptionPeriod(subscription.getSubscriptionPeriod()); + String period = app.getString(subscription.getPeriodTypeString()); if (!Algorithms.isEmpty(period)) { subscriptionPeriod.setText(period); AndroidUiHelper.updateVisibility(subscriptionPeriod, true); @@ -80,33 +76,31 @@ public class SubscriptionsCard extends BaseCard { nextBillingDate.setText(app.getString(R.string.next_billing_date, date)); AndroidUiHelper.updateVisibility(nextBillingDate, true); } - } - - TextView status = card.findViewById(R.id.status); - status.setText(app.getString(state.getStringRes())); - status.setBackgroundDrawable(ContextCompat.getDrawable(mapActivity, state.getBackgroundRes())); - - if (!autoRenewed) { + } else { View renewContainer = card.findViewById(R.id.renewContainer); AndroidUiHelper.updateVisibility(renewContainer, true); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - AndroidUtils.setBackground(ctx, renewContainer, nightMode, R.drawable.ripple_light, R.drawable.ripple_dark); + AndroidUtils.setBackground(mapActivity, renewContainer, nightMode, R.drawable.ripple_light, R.drawable.ripple_dark); } else { - AndroidUtils.setBackground(ctx, renewContainer, nightMode, R.drawable.btn_unstroked_light, R.drawable.btn_unstroked_dark); + AndroidUtils.setBackground(mapActivity, renewContainer, nightMode, R.drawable.btn_unstroked_light, R.drawable.btn_unstroked_dark); } final String sku = subscription.getSku(); renewContainer.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - subscribe(sku); + ChoosePlanDialogFragment.subscribe(app, mapActivity, purchaseHelper, sku); } }); View renew = card.findViewById(R.id.renew); - AndroidUtils.setBackground(ctx, renew, nightMode, + AndroidUtils.setBackground(mapActivity, renew, nightMode, R.drawable.btn_solid_border_light, R.drawable.btn_solid_border_dark); } + TextView status = card.findViewById(R.id.status); + status.setText(app.getString(state.getStringRes())); + AndroidUtils.setBackground(status, app.getUIUtilities().getIcon(state.getBackgroundRes())); + int dividerLayout = i + 1 == subscriptions.size() ? R.layout.simple_divider_item : R.layout.divider_half_item; View divider = inflater.inflate(dividerLayout, (ViewGroup) view, false); ((ViewGroup) view).addView(divider); @@ -114,52 +108,14 @@ public class SubscriptionsCard extends BaseCard { } private String getHumanDate(long time, Period period) { - Date date = new Date(time); - int monthsCount; if (period == null || period.getUnit() == null) { return ""; - } else if (period.getUnit().equals(Period.PeriodUnit.YEAR)) { - monthsCount = 12; - } else { - monthsCount = period.getNumberOfUnits(); } + Date date = new Date(time); Calendar calendar = Calendar.getInstance(); calendar.setTime(date); - calendar.add(Calendar.MONTH, monthsCount); + calendar.add(period.getUnit().getCalendarIdx(), period.getNumberOfUnits()); date = calendar.getTime(); - SimpleDateFormat format = new SimpleDateFormat("MMM d, yyyy", app.getLocaleHelper().getPreferredLocale()); - return format.format(date); - } - - private void subscribe(String sku) { - if (app == null) { - return; - } - if (!app.getSettings().isInternetConnectionAvailable(true)) { - Toast.makeText(app, R.string.internet_not_available, Toast.LENGTH_LONG).show(); - } else if (mapActivity != null && purchaseHelper != null) { - OsmandSettings settings = app.getSettings(); - purchaseHelper.purchaseLiveUpdates(mapActivity, sku, - settings.BILLING_USER_EMAIL.get(), - settings.BILLING_USER_NAME.get(), - settings.BILLING_USER_COUNTRY_DOWNLOAD_NAME.get(), - settings.BILLING_HIDE_USER_NAME.get()); - } - } - - private String getSubscriptionPeriod(Period period) { - if (period == null || period.getUnit() == null) { - return ""; - } else if (period.getUnit().equals(Period.PeriodUnit.YEAR)) { - return app.getString(R.string.annual_subscription); - } else if (period.getUnit().equals(Period.PeriodUnit.MONTH)) { - int unitsNumber = period.getNumberOfUnits(); - if (unitsNumber == 1) { - return app.getString(R.string.monthly_subscription); - } else if (unitsNumber == 3) { - return app.getString(R.string.three_months_subscription); - } - } - return ""; + return dateFormat.format(date); } } \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/track/GpxEditDescriptionDialogFragment.java b/OsmAnd/src/net/osmand/plus/track/GpxEditDescriptionDialogFragment.java index 52536316b8..0d8e91e26c 100644 --- a/OsmAnd/src/net/osmand/plus/track/GpxEditDescriptionDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/track/GpxEditDescriptionDialogFragment.java @@ -130,7 +130,7 @@ public class GpxEditDescriptionDialogFragment extends BaseOsmAndDialogFragment { View btnSave = view.findViewById(R.id.btn_save); int drawableRes = isNightMode(true) ? R.drawable.btn_solid_border_dark : R.drawable.btn_solid_border_light; - btnSave.setBackgroundDrawable(ContextCompat.getDrawable(ctx, drawableRes)); + AndroidUtils.setBackground(btnSave, getMyApplication().getUIUtilities().getIcon(drawableRes)); } private void showDismissDialog() { From 4da71a3734e9b02ce6fad721a3cc876a2d64ea5f Mon Sep 17 00:00:00 2001 From: Hinagiku Zeppeki Date: Fri, 26 Mar 2021 05:55:53 +0000 Subject: [PATCH 31/74] Translated using Weblate (Japanese) Currently translated at 97.6% (3609 of 3695 strings) --- OsmAnd/res/values-ja/strings.xml | 42 +++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/OsmAnd/res/values-ja/strings.xml b/OsmAnd/res/values-ja/strings.xml index 9820354ce7..c619818f9b 100644 --- a/OsmAnd/res/values-ja/strings.xml +++ b/OsmAnd/res/values-ja/strings.xml @@ -3082,7 +3082,7 @@ POIの更新は利用できません 『クイックアクション』のリストに最低ひとつは項目を設定する必要があります アルペン/ダウンヒルスキー アルペンスキーまたはダウンヒルスキーに用の斜面(ゲレンデ)やスキーリフトへの道 - クロスカントリー/ノルディックスキー + クロスカントリースキーとノルディックスキー ノルディックスキーやクロスカントリースキー用コースやそれらに用いられる小道などです。 スキーツーリング スキーツーリング用ルートです。 @@ -3354,9 +3354,9 @@ POIの更新は利用できません ルート再計算 案内 ユーザー名とパスワード - これらの設定はアプリ全般に関するもので、すべてのプロファイルに適用されます + これらのプラグイン設定はアプリ全般に関するもので、すべてのプロファイルに適用されます OSM編集 - まだアップロードしていない編集やOSMバグを%1$sで表示できます。アップロードされた後にはOsmAndに表示されません。 + まだアップロードしていない編集やOSMバグを%1$sで表示できます。アップロードされた変更部分は表示されなくなります。 OSM ナビゲーションまたは移動中に表示されるアイコンです。 静止時に表示されるアイコンです。 @@ -3799,8 +3799,8 @@ POIの更新は利用できません 最終更新日 名称: 降順(Z-A) 名称: 昇順(A-Z) - Java(セーフモード)での公共交通機関ルーティング計算に切り替えます - OsmEdit機能を利用するには、OAuthでのログインが必要です。 + Java(セーフモード)での公共交通機関ルート計算に切り替えます + OsmEdit機能を利用するには、OAuth方式でのログインが必要です。 OAuthでログイン OpenStreetMapOAuthトークンを消去する ログアウトしました @@ -3832,20 +3832,20 @@ POIの更新は利用できません ユーザー名とパスワードを使用する ログイン サブスクリプションの管理 - サブスクリプションに際し問題が発生しています。ボタンをタップしてGooglePlayサブスクリプション設定に移動し、お支払い方法を確認してください。 + ボタンをタップしてGoogle Playで支払い方法を設定し、サブスクリプションを修正します。 OsmAndLiveサブスクリプションの有効期限が切れました OsmAndLiveサブスクリプションが一時停止されました OsmAndLiveサブスクリプションは保留中です マーカーの履歴 GPXファイルをOpenStreetMapに送信 タグはカンマで区切って入力してください。 - パブリック状態は、経路がGPS経路およびGPS経路リストに公開を目的として表示されることを示唆しています。 APIを介して提供されるデータは、経路ページを参照していません。経路ポイントのタイムスタンプは、パブリックGPS APIからは入手できず、各地点は時系列で並べられることはありません。ただし他のユーザーは、公開経路リストとその中のタイムスタンプから生の経路データをダウンロードすることができます。 - 識別可能状態は、経路がGPS経路およびパブリックGPS経路リストに表示されることを示唆しています。他のユーザーは現在の経路をダウンロードして、ユーザー名とリンクできます。 trackpoints APIを介して配信されるデータは、元の経路追跡ページを参照します。経路ポイントのタイムスタンプは、パブリックGPSAPIを介して入手できます。 - プライベート状態は、経路がパブリックリストに表示されないことを示唆しています。経路ポイントは、タイムスタンプなしでパブリックGPS APIを介して引き続き利用できますが、時系列で並べられることはありません。 - 追跡可能状態にある場合は経路が公開リストに表示されないことを示唆していますが、経路ポイントは自体はタイムスタンプ付きの公開GPSAPIを介して引き続き利用できます。他のユーザーからはあなたに直接関連付けることはできず、自身の処理済み経路ポイントのみをダウンロードできます。 + \"公開 \"状態は、追跡機能にてユーザーのGPS追跡、公開GPS追跡リスト、および生データのタイムスタンプ付き公開追跡リストに公開されることを意味します。APIを介して提供されるデータはユーザーの追跡ページを参照しません。追跡ポイントのタイムスタンプはパブリックGPS APIでは利用できず、また追跡ポイントは時系列に並んでいません。 + \"識別可能\"状態は、経路がGPS経路およびパブリックGPS経路リストに表示されることを示唆しています。他のユーザーは現在の経路をダウンロードして、ユーザー名とリンクできます。経路ポイント APIを介して配信されるデータは、元の経路追跡ページを参照します。経路ポイントのタイムスタンプは、公開されているGPS APIを通じて入手できます。 + \"プライベート\"状態は、経路が公開リストに表示されないことを示唆しています。経路ポイントはタイムスタンプなしでパブリックGPS APIを介して引き続き利用できますが、時系列で並べられることはありません。 + \"追跡可能\"状態は、経路が公開リストに表示されることはありませんが、公開されているGPS APIからのダウンロードを通じて、タイムスタンプ付きの経路ポイント(個人と直接関連付けることはできません)を処理出来ることを意味します。 アカウント - ルートが再計算されるのを待ちます。 -\nグラフは再計算後に利用できるようになります。 + しばらくお待ち下さい。 +\nグラフはルートが再計算された後に利用できるようになります。 OSM通知/ POI / GPXのアップロードをテストする場合、openstreetmap.orgではなくdev.openstreetmap.orgを使用するよう切り替えます。 dev.openstreetmap.orgを使用 次々回案内(中距離) @@ -4034,4 +4034,22 @@ POIの更新は利用できません フォルダーの変更 開始ダイアログを表示 無効にした場合、ウィジェットまたはメニュー項目をタップするとすぐに記録が始まり、確認のダイアログは表示されません。 + ネイティブ公共交通機関モードの展開 + グラフ + %1$sデータは道路でのみ利用可能です。グラフを表示するには、\"地点間ルート\"を使用してルートを計算する必要があります。 + ギャップ + 音声アナウンスの間隔 + ルートラインのカスタマイズ + ルートライン + ルートライン指定は%1$s、選択したマップスタイルは:%2$s + マップモードの色指定: %1$s + • OsmAndLiveのアップデートは\"ダウンロード\">\"更新\"に移動 +\n +\n• 経路は、高度、速度、または傾斜によって色付けされる可能性あり +\n +\n• ナビゲーションルートラインの外観を変更するオプションが追加 +\n +\n• \"旅程記録\"ダイアログを更新 +\n +\n \ No newline at end of file From 3f62b5cc1a763230e4fed9dd4967c14926cc137c Mon Sep 17 00:00:00 2001 From: Ldm Public Date: Thu, 25 Mar 2021 20:31:59 +0000 Subject: [PATCH 32/74] Translated using Weblate (French) Currently translated at 100.0% (3695 of 3695 strings) --- OsmAnd/res/values-fr/strings.xml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/OsmAnd/res/values-fr/strings.xml b/OsmAnd/res/values-fr/strings.xml index 5dc5f5fc88..72e77075b4 100644 --- a/OsmAnd/res/values-fr/strings.xml +++ b/OsmAnd/res/values-fr/strings.xml @@ -4040,4 +4040,17 @@ Toutes les données non enregistrées seront perdues. Afficher la boîte de dialogue de démarrage Si désactivé, l\'enregistrement débutera dès appui sur le gadget ou dans le menu (sans demande de confirmation). + - Les mises à jour d\'OsmAnd Live ont été déplacées vers \"Téléchargements > Mises à jour\" +\n +\n - Les traces peuvent maintenant être colorées par altitude, vitesse ou pente. +\n +\n - Ajout d\'une option pour modifier l\'apparence de la ligne d\'itinéraire en navigation +\n +\n - Mise à jour de la fenêtre \"Enregistrement du trajet\". +\n +\n + La ligne d\'itinéraire utilisera le %1$s pour le style de carte : %2$s. + Personnaliser la ligne d\'itinéraire + Ligne d\'itinéraire + Définissez une couleur pour le mode de carte : %1$s. \ No newline at end of file From 6c439350c49ab7e8c3bb0bf4562c514e708fce61 Mon Sep 17 00:00:00 2001 From: Oliver Date: Thu, 25 Mar 2021 17:31:40 +0000 Subject: [PATCH 33/74] Translated using Weblate (German) Currently translated at 99.9% (3693 of 3695 strings) --- OsmAnd/res/values-de/strings.xml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/OsmAnd/res/values-de/strings.xml b/OsmAnd/res/values-de/strings.xml index 4be82a75ce..1f6d915238 100644 --- a/OsmAnd/res/values-de/strings.xml +++ b/OsmAnd/res/values-de/strings.xml @@ -4054,4 +4054,16 @@ Alle nicht gespeicherten Daten gehen verloren. Startdialog anzeigen Wenn deaktiviert, beginnt die Aufnahme direkt nach dem Tippen auf das Widget oder den Menüpunkt und überspringt den Bestätigungsdialog. + Routenlinie anpassen + Routenlinie + Legen Sie die Farbe für den Kartenmodus fest: %1$s. + • OsmAnd Live-Updates nach \"Downloads > Updates\" verschoben +\n +\n• Tracks können nun nach Höhe, Geschwindigkeit oder Steigung eingefärbt werden. +\n +\n• Option zugefügt, um das Aussehen der Navigationsrouten-Linie zu ändern +\n +\n• Dialog \"Streckenaufzeichnung\" aktualisiert +\n +\n \ No newline at end of file From 3f011367086cf65853f86cb840de5ee29f6efa64 Mon Sep 17 00:00:00 2001 From: solokot Date: Thu, 25 Mar 2021 07:37:36 +0000 Subject: [PATCH 34/74] Translated using Weblate (Russian) Currently translated at 100.0% (3690 of 3690 strings) --- OsmAnd/res/values-ru/strings.xml | 45 +++++++++++++++++--------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/OsmAnd/res/values-ru/strings.xml b/OsmAnd/res/values-ru/strings.xml index 8ed1ef86a1..ada07660d2 100644 --- a/OsmAnd/res/values-ru/strings.xml +++ b/OsmAnd/res/values-ru/strings.xml @@ -597,7 +597,7 @@ Чтение кешированных растровых карт… Недостаточно памяти для локальной карты «{0}» Версия локальной карты «{0}» не поддерживается - Офлайн-навигация OsmAnd — это экспериментальная функция, и она не работает на дистанциях больше 20 км. + Локальная навигация OsmAnd — это экспериментальная функция, и она не работает на дистанциях больше 20 км. \n \nНавигация временно переключена на онлайн-сервис CloudMade. Невозможно найти указанную папку. @@ -1528,7 +1528,7 @@ Линии метро Продолжить навигацию Приостановить навигацию - Отрисовка дорог cогласно шкале SAC. + Отрисовка дорог согласно шкале SAC. Отрисовка дорог согласно трассам OSMC. Раннее По умолчанию @@ -1580,7 +1580,10 @@ Размер текста Нажмите на любой элемент списка для просмотра более подробной информации, долго удерживайте, чтобы поместить в архив или удалить. Текущие данные на устройстве (%1$s свободно): Анонимный пользователь - Анонимному пользователю недоступно:\n- создание групп;\n- синхронизация групп и устройств с сервером;\n- управление группами и устройствами в личном кабинете. + Анонимному пользователю недоступно: +\n— создание групп; +\n— синхронизация групп и устройств с сервером; +\n— управление группами и устройствами в личном кабинете. Вы вошли как %1$s Маршруты Детали @@ -1894,7 +1897,7 @@ Пропустить OsmAnd Плагины - Офлайн-карты + Локальные карты \nи навигация Номер дома Тип лыжной трассы @@ -2385,7 +2388,7 @@ Дорога Показывать направляющие линии Тёмно-жёлтый - OsmAnd — это активно развивающийся проект с открытым исходным кодом. Благодаря открытости, каждый может внести свой вклад в приложение, сообщая об ошибках, совершенствуя перевод или разрабатывая новые возможности. Кроме того, проект финансируется за счет денежных взносов с целью разработки и тестирования новых функций. + OsmAnd — это активно развивающийся проект с открытым исходным кодом. Благодаря открытости, каждый может внести свой вклад в приложение, сообщая об ошибках, совершенствуя перевод или разрабатывая новые возможности. Кроме того, проект финансируется за счёт денежных взносов с целью разработки и тестирования новых функций. \nПримерное покрытие и качество карт: \n • Западная Европа: **** \n • Восточная Европа: *** @@ -2398,7 +2401,7 @@ \n • Африка: ** \n • Антарктида: \nДля скачивания доступно большинство стран мира! -\n Получите надежный навигатор в своей стране — будь то Франция, Германия, Мексика, Великобритания, Испания, Нидерланды, США, Россия, Бразилия или любая другая. +\n Получите надёжный навигатор в своей стране — будь то Франция, Германия, Мексика, Великобритания, Испания, Нидерланды, США, Россия, Бразилия или любая другая. Примерная карта покрытия и качество: \n • Западная Европа: **** \n • Восточная Европа: *** @@ -2519,11 +2522,11 @@ \n• Просмотр вашей скорости и высоты над уровнем моря \n• Функция записи GPX позволяет вам записывать ваше путешествие и делиться им \n• Через приложение вы можете включить отображение контурных линий и затемнение рельефа - Прогулки, пеший туризм, экскурсии -\n• Карта показывает пешеходные и треккинговые тропы -\n• Википедия на предпочитаемом вами языке может многое рассказать вам во время экскурсии по городу -\n• Остановки общественного транспорта (автобус, трамвай, поезд), включая названия маршрутов, помогут ориентироваться в новом городе -\n• GPS навигация в пешеходном режиме высчитывает маршрут, используя пешеходные тропы + Прогулки, пеший туризм, экскурсии +\n• Карта показывает пешеходные и трекинговые тропы +\n• Википедия на предпочитаемом вами языке может многое рассказать вам во время экскурсии по городу +\n• Остановки общественного транспорта (автобус, трамвай, поезд), включая названия маршрутов, помогут ориентироваться в новом городе +\n• GPS навигация в пешеходном режиме высчитывает маршрут, используя пешеходные тропы \n• Отправьте и следуйте по маршруту GPX или запишите и поделитесь своим собственным \n Внесение вклада в OSM @@ -2944,7 +2947,7 @@ Без паромов Исключить паромы Отправить журнал - К сожалению OsmAnd не смог найти подходящий для вас маршрут. + К сожалению, OsmAnd не смог найти подходящий для вас маршрут. Попробуйте пройти навигацию пешком. Попробуйте изменить настройки. Рассчитать маршрут ходьбы @@ -3772,7 +3775,7 @@ Все предыдущие сегменты будут пересчитаны с использованием выбранного профиля. Открыть сохранённый трек Остановка записи GPX при принудительном закрытии (через последние приложения). (Из панели уведомлений Android исчезнет значок фонового режима.) - сохранен + сохранён Добавьте хотя бы две точки. Повторить • Обновлённая функция планирования маршрута позволяет применять к сегментам разные режимы навигации и настраивать привязку к дорогам @@ -3794,7 +3797,7 @@ Имя: Я - А Имя: А - Я Значки старта и финиша - Спасибо за покупку \'Контурных линий\' + Спасибо за покупку «Контурных линий» Избегать пешеходных дорожек Избегать пешеходных дорожек Подписка оплачивается за выбранный период. Отмените её в AppGallery в любое время. @@ -3863,7 +3866,7 @@ Добавить в OpenPlaceReviews Добавить в Mapillary OsmAnd показывает фотографии из нескольких источников: -\nOpenPlaceReviews — фотогорафии POI; +\nOpenPlaceReviews — фотографии POI; \nMapillary — изображения улиц; \nWeb / Wikimedia — фотографии POI по данным OpenStreetMap. Ресурсы @@ -3885,7 +3888,7 @@ Каяк %1$s * %2$s Немецкий (повседневный) - Легкий самолет + Лёгкий самолёт Добавить новый сегмент Объединить сегменты Разделить до @@ -4008,7 +4011,7 @@ Обновления карт будут проверяться каждый день. Следующий раз %1$s в %2$s. Обновления карт будут проверяться каждый час. Следующий раз %1$s в %2$s. Удалить обновления - Вы уверены, что хотите удалить все live обновления для %s\? + Вы уверены, что хотите удалить все live-обновления для %s\? Покупки Показать/скрыть Природные границы @@ -4029,9 +4032,9 @@ Сохранить и остановить запись Запись трека остановлена Вы уверены, что хотите остановить запись\? -\nВсе несохраненные данные будут потеряны. +\nВсе несохранённые данные будут потеряны. На паузе - Позволяет избегать больших подъемов при навигации. + Позволяет избегать больших подъёмов при навигации. Переключатель для отображения или скрытия виджета координат. Выберите категорию или добавьте новую Копировать имя POI @@ -4044,8 +4047,8 @@ Выберите цель, чтобы проложить к ней короткий, быстрый или безопасный маршрут Удалить %1$d файлов\? Сохранить и продолжить - Все несохраненные данные будут потеряны. + Все несохранённые данные будут потеряны. Показывать начальный диалог - Если выключено, запись начнется сразу после нажатия на виджет или пункт меню, пропуская диалоговое окно подтверждения. + Если выключено, запись начнётся сразу после нажатия на виджет или пункт меню, пропуская диалоговое окно подтверждения. Интервал записи трека указывает период времени, через который OsmAnd будет запрашивать данные о текущем местоположении. \ No newline at end of file From 15bd1b01fef7368d788807cd086100119cc08b72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Babos=20G=C3=A1bor?= Date: Thu, 25 Mar 2021 10:55:55 +0000 Subject: [PATCH 35/74] Translated using Weblate (Hungarian) Currently translated at 99.9% (3694 of 3695 strings) --- OsmAnd/res/values-hu/strings.xml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/OsmAnd/res/values-hu/strings.xml b/OsmAnd/res/values-hu/strings.xml index e95128dd82..9796e64f4c 100644 --- a/OsmAnd/res/values-hu/strings.xml +++ b/OsmAnd/res/values-hu/strings.xml @@ -4044,4 +4044,16 @@ Minden nem mentett adat törlődni fog. Kezdő párbeszéd megjelenítése Ha le van tiltva, akkor a felvétel közvetlenül a widget vagy a menüelem megérintése után elindul, kihagyva a megerősítő párbeszédpanelt. + • Az OsmAnd Live frissítések átköltöztek a „Letöltések> Frissítések” helyre +\n +\n• A nyomvonalak színezhetők magasság, sebesség vagy lejtés szerint. +\n +\n• Módoítható a navigációs útvonal megjelenése +\n +\n• Frissült az „Utazás felvétele” párbeszédpanel +\n +\n + Útvonal + Útvonal testreszabása + Szín meghatározása a következő térképmódhoz: %1$s. \ No newline at end of file From 94a78b636ab4092581c88de7f9edfdcfd6f5c913 Mon Sep 17 00:00:00 2001 From: Ihor Hordiichuk Date: Thu, 25 Mar 2021 22:52:17 +0000 Subject: [PATCH 36/74] Translated using Weblate (Ukrainian) Currently translated at 100.0% (3695 of 3695 strings) --- OsmAnd/res/values-uk/strings.xml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/OsmAnd/res/values-uk/strings.xml b/OsmAnd/res/values-uk/strings.xml index 6e7fab1d5f..a2fcf4cd0e 100644 --- a/OsmAnd/res/values-uk/strings.xml +++ b/OsmAnd/res/values-uk/strings.xml @@ -4049,4 +4049,17 @@ Усі незбережені дані буде втрачено. Показати діалогове вікно запуску Якщо вимкнено, запис почнеться відразу після торкання до віджета або пункту меню, пропускаючи діалогове вікно підтвердження. + Налаштувати лінію маршруту + Лінія маршруту + Лінія маршруту застосовуватиме %1$s, вказаний у вибраному стилі мапи: %2$s. + Вкажіть колір для режиму мапи: %1$s. + • Оновлення OsmAnd Live переміщено до «Завантаження >Оновлення» +\n +\n• Тепер треки можуть бути забарвлені за висотою, швидкістю або нахилом. +\n +\n• Додано можливість зміни зовнішнього вигляду лінії навігації маршрутом +\n +\n• Оновлено діалогове вікно «Запис поїздки» +\n +\n \ No newline at end of file From b4b32853260e950dfb1602a01b4084efc477a5ba Mon Sep 17 00:00:00 2001 From: ace shadow Date: Thu, 25 Mar 2021 22:32:35 +0000 Subject: [PATCH 37/74] Translated using Weblate (Slovak) Currently translated at 100.0% (3695 of 3695 strings) --- OsmAnd/res/values-sk/strings.xml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/OsmAnd/res/values-sk/strings.xml b/OsmAnd/res/values-sk/strings.xml index 6c12a3f3b0..4d855b855a 100644 --- a/OsmAnd/res/values-sk/strings.xml +++ b/OsmAnd/res/values-sk/strings.xml @@ -4045,4 +4045,17 @@ Všetky neuložené údaje budú stratené. Zobraziť úvodné okno Ak je vypnuté, záznam začne hneď po stlačení nástroja alebo položky v menu a preskočí okno nastavenia. + • Aktualizácie OsmAnd Live presunuté do \"Sťahovania > Aktualizácie\" +\n +\n • Stopy je teraz možné vyfarbiť podľa nadmorskej výšky, rýchlosti alebo sklonu svahu. +\n +\n • Pridaná možnosť zmeny vzhľadu navigačnej trasy +\n +\n • Vylepšené okno \"Záznam výletu\" +\n +\n + Upraviť navigačnú trasu + Navigačná trasa + Navigačná trasa použije %1$s, zadané na zvolenom štýle mapy: %2$s. + Zadajte farbu pre režim mapy: %1$s. \ No newline at end of file From 17964af6e73faa811cae37c5bba57ae2447f888a Mon Sep 17 00:00:00 2001 From: Yaron Shahrabani Date: Thu, 25 Mar 2021 07:53:48 +0000 Subject: [PATCH 38/74] Translated using Weblate (Hebrew) Currently translated at 99.9% (3693 of 3695 strings) --- OsmAnd/res/values-iw/strings.xml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/OsmAnd/res/values-iw/strings.xml b/OsmAnd/res/values-iw/strings.xml index c320b44aa6..456c757f3c 100644 --- a/OsmAnd/res/values-iw/strings.xml +++ b/OsmAnd/res/values-iw/strings.xml @@ -4053,4 +4053,16 @@ כל הנתונים שלא נשמרו יאבדו. להציג חלונית פתיחה אם האפשרות מושבתת, ההקלטה תתחיל מיד לאחר הנגיעה בווידג׳ט או בפריט שבתפריט תוך דילוג על חלונית האישור. + להתאים קו מסלול אישית + קו מסלול + לציין צבע למצב מפה: %1$s. + • העדכונים החיים של OsmAnd הועברו אל „הורדות > עדכונים” +\n +\n • אפשר לצבוע מסלולים לפי גובה, מהירות או שיפוע. +\n +\n • נוספה אפשרות לשנות את מראה קו מסלול הניווט +\n +\n • החלונית „הקלטת מסלול” עודכנה +\n +\n \ No newline at end of file From cf217b425b44521581acc213f9be7795fe0b8c6d Mon Sep 17 00:00:00 2001 From: Softmap Date: Thu, 25 Mar 2021 22:20:59 +0000 Subject: [PATCH 39/74] Translated using Weblate (Arabic) Currently translated at 99.9% (3693 of 3695 strings) --- OsmAnd/res/values-ar/strings.xml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/OsmAnd/res/values-ar/strings.xml b/OsmAnd/res/values-ar/strings.xml index 475178ebc4..d697e4909f 100644 --- a/OsmAnd/res/values-ar/strings.xml +++ b/OsmAnd/res/values-ar/strings.xml @@ -4119,4 +4119,17 @@ سيتم فقدان كافة البيانات غير المحفوظة. إظهار مربع حوار البدء حفظ ومتابعة + تخصيص خط المسار + خط المسار + سيستخدم خط الطريق %1$s المحدد في نمط الخريطة المحدد: %2$s. + حدد لونًا لوضع الخريطة: %1$s. + • تم نقل تحديثات OsmAnd Live إلى \"التنزيلات> التحديثات\" +\n +\n • يمكن تلوين المسارات الآن حسب الارتفاع، السرعة أو المنحدر. +\n +\n • خيار مضاف لتغيير مظهر خط مسار الملاحة +\n +\n • تحديث مربع حوار \"تسجيل الرحلة\" +\n +\n \ No newline at end of file From a919a99a892b764a705312d8afb130764d05e191 Mon Sep 17 00:00:00 2001 From: iman Date: Thu, 25 Mar 2021 10:01:39 +0000 Subject: [PATCH 40/74] Translated using Weblate (Persian) Currently translated at 99.9% (3692 of 3695 strings) --- OsmAnd/res/values-fa/strings.xml | 44 +++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/OsmAnd/res/values-fa/strings.xml b/OsmAnd/res/values-fa/strings.xml index 5196513604..92ceed2233 100644 --- a/OsmAnd/res/values-fa/strings.xml +++ b/OsmAnd/res/values-fa/strings.xml @@ -594,8 +594,8 @@ ویرایش OpenStreetMap رد جاری را همین حالا در قالب فایل GPX ذخیره کن. ذخیرهٔ رد جاری - بازهٔ زمانی ثبت هنگام ناوبری - مشخص کنید برای ضبط رد در هنگام ناوبری، فاصلهٔ زمانی ردنگاری چقدر باشد + تناوب ردنگاری هنگام ناوبری + مشخص کنید برای ضبط رد در هنگام ناوبری، تناوب ردنگاری چقدر باشد هنگام ناوبری، یک رد GPX به‌صورت خودکار ضبط و در پوشهٔ ردها (tracks) ذخیره می‌شود. تنظیمات لازم برای ارتباط با (OpenStreetMap.org (OSM را مشخص کنید. زبان را مشخص و داده را دانلود/دوباره بار کنید. @@ -615,7 +615,7 @@ قفل قفل قفل‌گشایی - تنظیم فواصل بیدارباش: + تنظیم تناوب بیدارباش: سرعت شبیه‌سازی مسیر: کل حافظهٔ native اختصاص‌یافته به برنامه %1$s مگابایت (دالویک %2$s مگابایت، بقیه %3$s مگابایت). \nحافظهٔ proportional ‏%4$s مگابایت (حد اندروید %5$s مگابایت، دالویک %6$s مگابایت). @@ -835,8 +835,8 @@ کارت حافظه در حالت فقط‌خواندنی است. \nفقط می‌توانید نقشه‌هایی را ببینید که قبلاً دریافت شده‌اند و نمی‌توانید مناطق جدیدی را دانلود کنید. خدمات ناوبری OsmAnd - بازهٔ بیدارباش سرویس پس‌زمینه: - بازهٔ زمانی بیدارباش GPS + تناوب بیدارباش برای سرویس پس‌زمینه: + تناوب بیدارباش GPS شیوهٔ موقعیت‌یابی سرویس پس‌زمینه: ارائه‌دهندهٔ موقعیت زمانی که صفحه خاموش است موقعیت شما را ردگیری می‌کند. @@ -913,8 +913,8 @@ لایه‌های شب‌نما یادداشت‌ها یا POIهای OSMای ذخیره‌شده روی دستگاه مشاهده و مدیریت POIها یا یادداشت‌های OSMای که روی دستگاه شما قرار دارند. - بازهٔ زمانی ردیابی آنلاین را مشخص کنید. - بازهٔ زمانی ردیابی آنلاین + تناوب ردیابی آنلاین را مشخص کنید. + تناوب ردیابی آنلاین برنامهٔ OsmAnd (مخفف OSM Automated Navigation Directions به‌معنی راهنمای خودکار ناوبری بر پایهٔ OSM) یک نرم‌افزار ناوبری متن‌باز است که به گسترهٔ وسیعی از دادهٔ جهانی OSM دسترسی دارد. \n \nتمام دادهٔ نقشه (بُرداری یا کاشی) را می‌توانید برای استفادهٔ آفلاین روی کارت حافظه ذخیره کنید. @@ -1198,7 +1198,7 @@ هم‌رسانی مسیر در قالب فایل GPX مسیر از طریق OsmAnd هم‌رسانی شد دستی (روی فِلِش بزنید) - فرمان‌های ناوبری در بازه‌های منظم بازگو می‌شود. + فرمان‌های ناوبری در فاصله‌های زمانی منظم بازگو می‌شود. تکرار فرمان‌های ناوبری قالب نامعتبر: %s اعلام رسیدن @@ -1258,7 +1258,7 @@ نگه‌داشتن توقف فعال‌کردن حالت پس‌زمینهٔ GPS - بازهٔ بیدارباش GPS + تناوب بیدارباش GPS حالت پس‌زمینهٔ GPS متوقف شود؟ زبان ارجح برای نقشه سواحیلی @@ -1306,9 +1306,9 @@ کیفیت راه سطح راه مسیرهای دوچرخه - بازهٔ زمانی ثبت (سراسری) + تناوب ردنگاری عمومی می‌توانید با استفاده از ابزارک ضبط GPX روی نقشه، ردنگاری در فایل GPX را خاموش یا روشن کنید. - بازهٔ زمانی ثبت + تناوب ردنگاری این افزونه یک ابزارک ضبط GPX روی نقشه اضافه می‌کند و با انتخاب آن می‌توانید رد خود را ضبط و در قالب فایل GPX ذخیره کنید. همچنین این امکان را فراهم می‌کند که هنگام مسیریابی، به‌طور خودکار این کار برای شما انجام شود. \n \nردهای ضبط‌شده را با دوستان یا برای استفاده در مشارکت‌های OSM هم‌رسانی کنید. @@ -1689,7 +1689,7 @@ اعلام هوشمند خودکار فقط اگر جهتم از سمت نقطهٔ مقصد منحرف شد، اعلام شود. بازهٔ زمانی اعلام خودکار - بازهٔ زمانی کمینی بین اعلام پیام‌ها. + تناوب زمانی کمینی بین اعلام پیام‌ها. رنگ پیش‌فرض انتخاب دسته نام @@ -3374,7 +3374,7 @@ اثرات جانبی: بازه‌های توقف یا اصلاً ضبط نخواهند شد یا فقط یک نقطه به‌ازای هر کدام ضبط می‌شود. جابه‌جایی‌های واقعیِ کوچک احتمالاً حذف می‌شود. فایل نهایی اطلاعات کمتری برای پس‌پردازش خواهد داشت و همچنین با حذف نقاط زائد در هنگام ضبط و حفظ بالقوهٔ نقاط غیرواقعی (ناشی از گیرایی ضعیف یا اثرات چیپست GPS) اطلاعات آماریِ فایل بدتر می‌شود. توصیه: اگر به جزئیات بیشتر از ۵ متر نیاز ندارید و در زمان توقف نمی‌خواهید داده ضبط کنید، تنظیم حدود ۵ متر احتمالاً خوب جواب بدهد. مدت حافظهٔ تأخیری - بازهٔ زمانی ردیابی + تناوب ردیابی نشانی وب نشانی اینترنتی را با این پارامترها تعریف کنید: \nlat={0}, lon={1}, timestamp={2}, hdop={3}, altitude={4}, speed={5}, bearing={6} @@ -3813,7 +3813,7 @@ %s فایل رد انتخاب شده است ضبط هنگامی که برنامه را از طریق برنامه‌های اخیر ببندید ضبط رد به‌طور موقت می‌ایستد. (نشانگر اجرای پس‌زمینه از نوار اعلان حذف می‌شود.) - بازهٔ زمانی برای ضبط رد را انتخاب کنید (که از طریق ابزارک ضبط سفر روی نقشه روشن می‌شود). + تناوب ردنگاری عمومی را انتخاب کنید (که از طریق ابزارک ضبط سفر روی نقشه روشن می‌شود). نگه‌داشتن ضبط سفر ازسرگیری ضبط سفر اسکیت این‌لاین @@ -4061,7 +4061,7 @@ آمادگی خروج از مسیر رسیدن به مقصد - بازه‌های زمانی و مسافتی + تناوب زمانی و مسافتی زمان اعلام پیام‌های گفتاری به نوع پیام، سرعت ناوبری جاری و سرعت ناوبری پیش‌فرض بستگی دارد. زمان اعلام پیام شروع دوباره @@ -4073,4 +4073,18 @@ نمایش کادر آغاز اگر غیرفعال باشد، بلافاصله پس از لمس ابزارک یا آیتم منو، ضبط آغاز می‌شود و کادر تأیید ظاهر نمی‌شود. تمام دادهٔ ذخیره‌نشده از دست خواهد رفت. + برای خط مسیر از %1$s استفاده می‌شود که در سبک انتخاب‌شده برای نقشه (%2$s) مشخص شده است. + رنگ حالت نقشهٔ %1$s را مشخص کنید. + تناوب ردنگاری مشخص می‌کند OsmAnd هر چند وقت یک بار دادهٔ مربوط به موقعیت جاری را درخواست کند. + سفارشی‌سازی خط مسیر + خط مسیر + • روزآمدسازه‌های OsmAnd Live منتقل شد به Downloads ‏> Updates +\n +\n• اکنون می‌توانید رنگ‌بندی ردها را بر اساس ارتفاع، سرعت یا شیب انجام دهید. +\n +\n• گزینه‌ای برای تغییر ظاهر خط مسیر هنگام ناوبری اضافه شد. +\n +\n• کادر «ضبط سفر» روزآمد شد. +\n +\n \ No newline at end of file From befb22b2187544ae1155438857e05ce02a3b77f2 Mon Sep 17 00:00:00 2001 From: ovl-1 Date: Thu, 25 Mar 2021 09:17:13 +0000 Subject: [PATCH 41/74] =?UTF-8?q?Translated=20using=20Weblate=20(Norwegian?= =?UTF-8?q?=20Bokm=C3=A5l)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently translated at 60.8% (2249 of 3695 strings) --- OsmAnd/res/values-nb/strings.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/OsmAnd/res/values-nb/strings.xml b/OsmAnd/res/values-nb/strings.xml index c902064e98..c0254ccc92 100644 --- a/OsmAnd/res/values-nb/strings.xml +++ b/OsmAnd/res/values-nb/strings.xml @@ -3941,4 +3941,8 @@ Ruting kan unngå kraftige oppoverbakker. Lagre og fortsett All ulagret data vil gå tapt. + Vis startdialog + Tilpass rutelinje + Rutelinje + Angi farge for kartmodus: %1$s. \ No newline at end of file From 199c7772bab8f4119bec5651704bc2a7e8c7c4ba Mon Sep 17 00:00:00 2001 From: Franco Date: Thu, 25 Mar 2021 14:16:45 +0000 Subject: [PATCH 42/74] Translated using Weblate (Spanish (Argentina)) Currently translated at 99.9% (3694 of 3695 strings) --- OsmAnd/res/values-es-rAR/strings.xml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/OsmAnd/res/values-es-rAR/strings.xml b/OsmAnd/res/values-es-rAR/strings.xml index 720dccf045..91493663a7 100644 --- a/OsmAnd/res/values-es-rAR/strings.xml +++ b/OsmAnd/res/values-es-rAR/strings.xml @@ -4052,4 +4052,17 @@ Se perderán todos los datos no guardados. Mostrar el diálogo inicial Si se desactiva, la grabación será iniciada al pulsar el widget o el elemento del menú, saltándose el diálogo de confirmación. + Personalizar línea de ruta + Línea de ruta + La línea de la ruta sería el uso %1$s especificado en el estilo de mapa seleccionado: %2$s. + Define el color para el modo de mapa: %1$s. + • Las actualizaciones de OsmAnd Live se movieron a «Descargas > Actualizaciones» +\n +\n • Las trazas ahora se pueden colorear por altitud, velocidad o pendiente. +\n +\n • Se añade opción para cambiar la apariencia de la línea de ruta de navegación +\n +\n • Se actualiza el cuadro de diálogo «Grabación de viaje» +\n +\n \ No newline at end of file From e8c0064cb7004abb4aa927250674c9a27710e32c Mon Sep 17 00:00:00 2001 From: Eduardo Addad de Oliveira Date: Thu, 25 Mar 2021 17:06:19 +0000 Subject: [PATCH 43/74] Translated using Weblate (Portuguese (Brazil)) Currently translated at 100.0% (3695 of 3695 strings) --- OsmAnd/res/values-pt-rBR/strings.xml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/OsmAnd/res/values-pt-rBR/strings.xml b/OsmAnd/res/values-pt-rBR/strings.xml index 0c4060b65a..30546270a5 100644 --- a/OsmAnd/res/values-pt-rBR/strings.xml +++ b/OsmAnd/res/values-pt-rBR/strings.xml @@ -4045,4 +4045,17 @@ O intervalo de registro define o período de tempo no qual OsmAnd solicitará os dados de posição de localização atual. Mostrar caixa de diálogo inicial Se desativado, a gravação começará logo após tocar no widget ou item de menu, pulando a caixa de diálogo de confirmação. + Personalizar linha de rota + Linha de rota + A linha de rota seria usada %1$s especificado no estilo de mapa selecionado: %2$s. + Especifique a cor para o modo de mapa: %1$s. + "• As atualizações do OsmAnd Live foram movidas para \"Downloads > Atualizações\" +\n +\n • As trilhas agora podem ser coloridas por altitude, velocidade ou inclinação. +\n +\n • Adicionada opção para alterar a aparência da linha da rota de navegação +\n +\n • Caixa de diálogo \"Gravação de viagem\" atualizada +\n +\n" \ No newline at end of file From 393e4b06d31528a2b933f641605af14e283550c2 Mon Sep 17 00:00:00 2001 From: Verdulo Date: Thu, 25 Mar 2021 14:41:00 +0000 Subject: [PATCH 44/74] Translated using Weblate (Esperanto) Currently translated at 100.0% (3695 of 3695 strings) --- OsmAnd/res/values-eo/strings.xml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/OsmAnd/res/values-eo/strings.xml b/OsmAnd/res/values-eo/strings.xml index 0eb1180e72..1063075114 100644 --- a/OsmAnd/res/values-eo/strings.xml +++ b/OsmAnd/res/values-eo/strings.xml @@ -4050,4 +4050,17 @@ Konservi kaj daŭrigi Se malŝaltita, registrado komenciĝos tuj post frapeto sur la fenestraĵo aŭ menuero, preterlasante la konfirman dialogon. Montri komencan dialogon + Elektu koloron por map‑reĝimo: %1$s. + Alĝustigi linion de kurso + Linio de kurso + Por la linio de kurso estos uzata %1$s difinita por la map‑stilo: %2$s. + • ĝisdatigoj OsmAnd Live movitaj al “elŝutoj” → “ĝisdatigoj” +\n +\n• eblo kolorigi spurojn laŭ altitudo, rapido aŭ dekliveco +\n +\n• eblo ŝanĝi aspekton de linio de la navigata kurso +\n +\n• plibonigita ekrano “registri spuron” +\n +\n \ No newline at end of file From aaff5c3f7c29e92a4c8b835e96df80160336a2c7 Mon Sep 17 00:00:00 2001 From: Jeff Huang Date: Fri, 26 Mar 2021 01:43:11 +0000 Subject: [PATCH 45/74] Translated using Weblate (Chinese (Traditional)) Currently translated at 100.0% (3695 of 3695 strings) --- OsmAnd/res/values-zh-rTW/strings.xml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/OsmAnd/res/values-zh-rTW/strings.xml b/OsmAnd/res/values-zh-rTW/strings.xml index a40440e789..a12ea721bc 100644 --- a/OsmAnd/res/values-zh-rTW/strings.xml +++ b/OsmAnd/res/values-zh-rTW/strings.xml @@ -4043,4 +4043,17 @@ 所有未儲存的資料都將會遺失。 顯示開始對話框 若停用,則在點擊小工具或選單項目後將跳過確認對話框,立刻開始。 + 自訂路線 + 路線 + 路線將會使用 %1$s 在選定的地圖樣式上指定的:%2$s。 + 指定地圖模式的顏色:%1$s。 + • OsmAnd Live 更新移動至「下載 > 更新」 +\n +\n • 軌跡現在可以使用海拔、速度或坡度來填色 +\n +\n • 新增了變更導航路線外觀的選項 +\n +\n • 更新「旅程錄製」對話框 +\n +\n \ No newline at end of file From ee7e8bf3eb0cb1dc286569f47e75b7a43454dfa5 Mon Sep 17 00:00:00 2001 From: Artem Date: Thu, 25 Mar 2021 08:03:50 +0000 Subject: [PATCH 46/74] Translated using Weblate (Russian) Currently translated at 99.8% (3888 of 3894 strings) --- OsmAnd/res/values-ru/phrases.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OsmAnd/res/values-ru/phrases.xml b/OsmAnd/res/values-ru/phrases.xml index 7b2f28b784..660f3dae0d 100644 --- a/OsmAnd/res/values-ru/phrases.xml +++ b/OsmAnd/res/values-ru/phrases.xml @@ -3886,4 +3886,6 @@ Название трассы Лыжный трамплин По лесу: да + Туннель летучих мышей + Мост летучих мышей \ No newline at end of file From 83902e281a2379a3854125b154aa86494f727f1f Mon Sep 17 00:00:00 2001 From: solokot Date: Thu, 25 Mar 2021 07:40:20 +0000 Subject: [PATCH 47/74] Translated using Weblate (Russian) Currently translated at 99.8% (3888 of 3894 strings) --- OsmAnd/res/values-ru/phrases.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/OsmAnd/res/values-ru/phrases.xml b/OsmAnd/res/values-ru/phrases.xml index 660f3dae0d..5735fbfac4 100644 --- a/OsmAnd/res/values-ru/phrases.xml +++ b/OsmAnd/res/values-ru/phrases.xml @@ -3888,4 +3888,5 @@ По лесу: да Туннель летучих мышей Мост летучих мышей + Конференц-центр \ No newline at end of file From d22edfd9ae044bb65e585c5c1749ee37c4f86745 Mon Sep 17 00:00:00 2001 From: cepprice Date: Fri, 26 Mar 2021 20:28:30 +0500 Subject: [PATCH 48/74] Split layout to cards --- OsmAnd/res/layout/contact_support.xml | 73 ++++ OsmAnd/res/layout/empty_purchases_layout.xml | 220 ---------- .../layout/new_device_or_account_button.xml | 34 ++ OsmAnd/res/layout/no_purchases_card.xml | 92 ++++ OsmAnd/res/layout/purchases_layout.xml | 407 +----------------- .../res/layout/restore_purchases_button.xml | 34 ++ OsmAnd/res/layout/subscriptions_card.xml | 204 ++++++++- OsmAnd/res/layout/subscriptions_list_card.xml | 6 + OsmAnd/res/layout/troubleshooting_card.xml | 96 +++++ .../plus/liveupdates/LiveUpdatesFragment.java | 64 ++- .../settings/fragments/PurchasesFragment.java | 245 ++--------- .../settings/fragments/SubscriptionsCard.java | 173 ++++---- .../fragments/SubscriptionsListCard.java | 124 ++++++ .../TroubleshootingOrPurchasingCard.java | 126 ++++++ 14 files changed, 975 insertions(+), 923 deletions(-) create mode 100644 OsmAnd/res/layout/contact_support.xml delete mode 100644 OsmAnd/res/layout/empty_purchases_layout.xml create mode 100644 OsmAnd/res/layout/new_device_or_account_button.xml create mode 100644 OsmAnd/res/layout/no_purchases_card.xml create mode 100644 OsmAnd/res/layout/restore_purchases_button.xml create mode 100644 OsmAnd/res/layout/subscriptions_list_card.xml create mode 100644 OsmAnd/res/layout/troubleshooting_card.xml create mode 100644 OsmAnd/src/net/osmand/plus/settings/fragments/SubscriptionsListCard.java create mode 100644 OsmAnd/src/net/osmand/plus/settings/fragments/TroubleshootingOrPurchasingCard.java diff --git a/OsmAnd/res/layout/contact_support.xml b/OsmAnd/res/layout/contact_support.xml new file mode 100644 index 0000000000..30e45c4ea4 --- /dev/null +++ b/OsmAnd/res/layout/contact_support.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/layout/empty_purchases_layout.xml b/OsmAnd/res/layout/empty_purchases_layout.xml deleted file mode 100644 index 56bfb82b6f..0000000000 --- a/OsmAnd/res/layout/empty_purchases_layout.xml +++ /dev/null @@ -1,220 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/OsmAnd/res/layout/new_device_or_account_button.xml b/OsmAnd/res/layout/new_device_or_account_button.xml new file mode 100644 index 0000000000..d6afc440ef --- /dev/null +++ b/OsmAnd/res/layout/new_device_or_account_button.xml @@ -0,0 +1,34 @@ + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/layout/no_purchases_card.xml b/OsmAnd/res/layout/no_purchases_card.xml new file mode 100644 index 0000000000..7bb787d4ab --- /dev/null +++ b/OsmAnd/res/layout/no_purchases_card.xml @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/layout/purchases_layout.xml b/OsmAnd/res/layout/purchases_layout.xml index d4bb5a3465..c4f361eca5 100644 --- a/OsmAnd/res/layout/purchases_layout.xml +++ b/OsmAnd/res/layout/purchases_layout.xml @@ -1,12 +1,10 @@ + android:background="?attr/activity_background_color" + android:orientation="vertical" + android:focusableInTouchMode="false"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + android:orientation="vertical"/> diff --git a/OsmAnd/res/layout/restore_purchases_button.xml b/OsmAnd/res/layout/restore_purchases_button.xml new file mode 100644 index 0000000000..a4a34bcd6c --- /dev/null +++ b/OsmAnd/res/layout/restore_purchases_button.xml @@ -0,0 +1,34 @@ + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/layout/subscriptions_card.xml b/OsmAnd/res/layout/subscriptions_card.xml index 278f381933..b4deb45ffc 100644 --- a/OsmAnd/res/layout/subscriptions_card.xml +++ b/OsmAnd/res/layout/subscriptions_card.xml @@ -1,5 +1,207 @@ \ No newline at end of file + android:background="?attr/bg_color" + android:orientation="vertical"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/layout/subscriptions_list_card.xml b/OsmAnd/res/layout/subscriptions_list_card.xml new file mode 100644 index 0000000000..54c8480c4e --- /dev/null +++ b/OsmAnd/res/layout/subscriptions_list_card.xml @@ -0,0 +1,6 @@ + + \ No newline at end of file diff --git a/OsmAnd/res/layout/troubleshooting_card.xml b/OsmAnd/res/layout/troubleshooting_card.xml new file mode 100644 index 0000000000..96e6b3627d --- /dev/null +++ b/OsmAnd/res/layout/troubleshooting_card.xml @@ -0,0 +1,96 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesFragment.java b/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesFragment.java index 631b1a7f07..f6c3bd4b66 100644 --- a/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesFragment.java +++ b/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesFragment.java @@ -22,19 +22,7 @@ import android.widget.ImageView; import android.widget.ProgressBar; import android.widget.TextView; -import androidx.annotation.DrawableRes; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.appcompat.widget.SwitchCompat; -import androidx.core.content.ContextCompat; -import androidx.fragment.app.FragmentActivity; -import androidx.fragment.app.FragmentManager; -import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; - import net.osmand.plus.OsmandApplication; -import net.osmand.plus.chooseplan.ChoosePlanDialogFragment.ChoosePlanDialogType; -import net.osmand.plus.settings.backend.CommonPreference; -import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.R; import net.osmand.plus.Version; import net.osmand.plus.activities.LocalIndexHelper; @@ -43,13 +31,15 @@ import net.osmand.plus.activities.OsmandBaseExpandableListAdapter; import net.osmand.plus.activities.OsmandInAppPurchaseActivity; import net.osmand.plus.base.BaseOsmAndFragment; import net.osmand.plus.chooseplan.ChoosePlanDialogFragment; +import net.osmand.plus.chooseplan.ChoosePlanDialogFragment.ChoosePlanDialogType; import net.osmand.plus.download.ui.AbstractLoadLocalIndexTask; import net.osmand.plus.inapp.InAppPurchaseHelper; import net.osmand.plus.inapp.InAppPurchaseHelper.InAppPurchaseListener; import net.osmand.plus.inapp.InAppPurchaseHelper.InAppPurchaseTaskType; import net.osmand.plus.inapp.InAppPurchases.InAppSubscription; import net.osmand.plus.resources.IncrementalChangesManager; -import net.osmand.plus.settings.fragments.PurchasesFragment; +import net.osmand.plus.settings.backend.CommonPreference; +import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.util.Algorithms; import java.io.File; @@ -60,6 +50,15 @@ import java.util.HashSet; import java.util.List; import java.util.Set; +import androidx.annotation.DrawableRes; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.widget.SwitchCompat; +import androidx.core.content.ContextCompat; +import androidx.fragment.app.FragmentActivity; +import androidx.fragment.app.FragmentManager; +import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; + import static net.osmand.plus.liveupdates.LiveUpdatesFragmentNew.showUpdateDialog; import static net.osmand.plus.liveupdates.LiveUpdatesHelper.DEFAULT_LAST_CHECK; import static net.osmand.plus.liveupdates.LiveUpdatesHelper.TimeOfDay; @@ -182,8 +181,8 @@ public class LiveUpdatesFragment extends BaseOsmAndFragment implements InAppPurc statusTextView.setText(getString(R.string.osm_live_active)); statusIcon.setImageDrawable(app.getUIUtilities().getThemedIcon(R.drawable.ic_action_done)); - String countryName = PurchasesFragment.getSupportRegionName(app, getInAppPurchaseHelper()); - String header = PurchasesFragment.getSupportRegionHeader(app, countryName); + String countryName = getSupportRegionName(app, getInAppPurchaseHelper()); + String header = getSupportRegionHeader(app, countryName); regionNameHeaderTextView.setText(header); regionNameTextView.setText(countryName); @@ -279,6 +278,41 @@ public class LiveUpdatesFragment extends BaseOsmAndFragment implements InAppPurc subscriptionFragment.show(getChildFragmentManager(), SubscriptionFragment.TAG); } + public static String getSupportRegionName(OsmandApplication app, InAppPurchaseHelper purchaseHelper) { + OsmandSettings settings = app.getSettings(); + String countryName = settings.BILLING_USER_COUNTRY.get(); + if (purchaseHelper != null) { + List subscriptions = purchaseHelper.getLiveUpdates().getVisibleSubscriptions(); + boolean donationSupported = false; + for (InAppSubscription s : subscriptions) { + if (s.isDonationSupported()) { + donationSupported = true; + break; + } + } + if (donationSupported) { + if (Algorithms.isEmpty(countryName)) { + if (OsmandSettings.BILLING_USER_DONATION_NONE_PARAMETER.equals(settings.BILLING_USER_COUNTRY_DOWNLOAD_NAME.get())) { + countryName = app.getString(R.string.osmand_team); + } else { + countryName = app.getString(R.string.shared_string_world); + } + } + } else { + countryName = app.getString(R.string.osmand_team); + } + } else { + countryName = app.getString(R.string.osmand_team); + } + return countryName; + } + + public static String getSupportRegionHeader(OsmandApplication app, String supportRegion) { + return supportRegion.equals(app.getString(R.string.osmand_team)) ? + app.getString(R.string.default_buttons_support) : + app.getString(R.string.osm_live_support_region); + } + protected class LocalIndexesAdapter extends OsmandBaseExpandableListAdapter { public static final int SHOULD_UPDATE_GROUP_POSITION = 0; public static final int SHOULD_NOT_UPDATE_GROUP_POSITION = 1; diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/PurchasesFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/PurchasesFragment.java index 00a15b3071..d08cf6f892 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/PurchasesFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/PurchasesFragment.java @@ -2,23 +2,13 @@ package net.osmand.plus.settings.fragments; import android.app.Activity; import android.content.Context; -import android.content.Intent; -import android.graphics.Typeface; import android.net.Uri; import android.os.Bundle; -import android.text.Spannable; -import android.text.SpannableString; -import android.text.Spanned; -import android.text.method.LinkMovementMethod; -import android.text.style.StyleSpan; -import android.text.style.URLSpan; import android.view.LayoutInflater; -import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.widget.ImageButton; import android.widget.ImageView; -import android.widget.LinearLayout; import android.widget.TextView; import com.google.android.material.appbar.AppBarLayout; @@ -32,16 +22,10 @@ import net.osmand.plus.Version; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.OsmandInAppPurchaseActivity; import net.osmand.plus.base.BaseOsmAndFragment; -import net.osmand.plus.chooseplan.ChoosePlanDialogFragment; import net.osmand.plus.inapp.InAppPurchaseHelper; import net.osmand.plus.inapp.InAppPurchaseHelper.InAppPurchaseListener; -import net.osmand.plus.inapp.InAppPurchases.InAppSubscription; import net.osmand.plus.liveupdates.CountrySelectionFragment; -import net.osmand.plus.liveupdates.CountrySelectionFragment.CountryItem; import net.osmand.plus.liveupdates.CountrySelectionFragment.OnFragmentInteractionListener; -import net.osmand.plus.liveupdates.LiveUpdatesFragmentNew; -import net.osmand.plus.liveupdates.OsmLiveActivity; -import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.wikipedia.WikipediaDialogFragment; import net.osmand.util.Algorithms; @@ -59,11 +43,6 @@ public class PurchasesFragment extends BaseOsmAndFragment implements InAppPurcha public static final String KEY_IS_SUBSCRIBER = "action_is_new"; - private static final String PLAY_STORE_SUBSCRIPTION_URL = "https://play.google.com/store/account/subscriptions"; - private static final String PLAY_STORE_SUBSCRIPTION_DEEPLINK_URL = "https://play.google.com/store/account/subscriptions?sku=%s&package=%s"; - private static final String EMAIL_DEEPLINK_URI = "mailto:support@osmand.net"; - private static final String OSMAND_EMAIL = "support@osmand.net"; - private static final String OSMAND_NEW_DEVICE_URL = "https://docs.osmand.net/en/main@latest/osmand/purchases#new-device--new-account"; private static final String OSMAND_PURCHASES_URL = "https://docs.osmand.net/en/main@latest/osmand/purchases"; private OsmandApplication app; @@ -71,18 +50,16 @@ public class PurchasesFragment extends BaseOsmAndFragment implements InAppPurcha private InAppPurchaseHelper purchaseHelper; private View mainView; + ViewGroup cardsContainer; private SubscriptionsCard subscriptionsCard; - private CountrySelectionFragment countrySelectionFragment = new CountrySelectionFragment(); - - private String url; private Boolean isPaidVersion; public static boolean showInstance(FragmentManager fragmentManager) { try { PurchasesFragment fragment = new PurchasesFragment(); fragmentManager.beginTransaction() - .replace(R.id.fragmentContainer, fragment, TAG) + .add(R.id.fragmentContainer, fragment, TAG) .addToBackStack(TAG) .commitAllowingStateLoss(); return true; @@ -102,67 +79,39 @@ public class PurchasesFragment extends BaseOsmAndFragment implements InAppPurcha app = getMyApplication(); context = requireContext(); isPaidVersion = Version.isPaidVersion(app); - final MapActivity mapActivity = getMapActivity(); final boolean nightMode = !app.getSettings().isLightContent(); LayoutInflater themedInflater = UiUtilities.getInflater(context, nightMode); - if (isPaidVersion) { - mainView = themedInflater.inflate(R.layout.purchases_layout, container, false); - setSubscriptionClick(mapActivity); - } else { - mainView = themedInflater.inflate(R.layout.empty_purchases_layout, container, false); - LinearLayout osmandLive = mainView.findViewById(R.id.osmand_live); - osmandLive.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - if (getMyApplication() != null && getMyActivity() != null) { - ChoosePlanDialogFragment.showDialogInstance(getMyApplication(), getMyActivity().getSupportFragmentManager(), ChoosePlanDialogFragment.ChoosePlanDialogType.OSM_LIVE); - } - } - }); - TextView infoDescription = mainView.findViewById(R.id.info_description); - - String restorePurchases = getString(R.string.restore_purchases); - String infoPurchases = String.format(getString(R.string.empty_purchases_description), restorePurchases); - infoDescription.setText(infoPurchases); - } + mainView = themedInflater.inflate(R.layout.purchases_layout, container, false); AndroidUtils.addStatusBarPadding21v(getActivity(), mainView); createToolbar(mainView, nightMode); - LinearLayout purchasesRestore = mainView.findViewById(R.id.restore_purchases); - purchasesRestore.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - if (purchaseHelper != null) { - purchaseHelper.requestInventory(); - } - } - }); - LinearLayout newDeviceAccountContainer = mainView.findViewById(R.id.new_device_account_container); - newDeviceAccountContainer.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - WikipediaDialogFragment.showFullArticle(context, Uri.parse(OSMAND_NEW_DEVICE_URL), nightMode); - } - }); + cardsContainer = mainView.findViewById(R.id.cards_container); - setFormatStrings(); return mainView; } @Override public void onResume() { super.onResume(); + updateCards(); + } + + private void updateCards() { + MapActivity mapActivity = getMapActivity(); purchaseHelper = getInAppPurchaseHelper(); - if (isPaidVersion) { - MapActivity mapActivity = getMapActivity(); - if (getMapActivity() != null && purchaseHelper != null) { - ViewGroup subscriptionsCardContainer = mainView.findViewById(R.id.subscriptions_card_container); - subscriptionsCardContainer.removeAllViews(); - subscriptionsCard = new SubscriptionsCard(mapActivity, purchaseHelper); - subscriptionsCardContainer.addView(subscriptionsCard.build(mapActivity)); - } - setupSupportRegion(); + cardsContainer.removeAllViews(); + if (mapActivity == null || purchaseHelper == null) { + return; } + + boolean hasSubscriptions = !Algorithms.isEmpty(purchaseHelper.getEverMadeSubscriptions()); + if (hasSubscriptions) { + subscriptionsCard = new SubscriptionsCard(mapActivity, this, purchaseHelper); + cardsContainer.addView(subscriptionsCard.build(mapActivity)); + } + + cardsContainer.addView(new TroubleshootingOrPurchasingCard(mapActivity, purchaseHelper, isPaidVersion) + .build(mapActivity)); } @Override @@ -175,95 +124,10 @@ public class PurchasesFragment extends BaseOsmAndFragment implements InAppPurcha public void onViewStateRestored(@Nullable Bundle savedInstanceState) { super.onViewStateRestored(savedInstanceState); if (savedInstanceState != null) { - savedInstanceState.getBoolean(KEY_IS_SUBSCRIBER); + isPaidVersion = savedInstanceState.getBoolean(KEY_IS_SUBSCRIBER); } } - private void setSubscriptionClick(final MapActivity mapActivity) { - LinearLayout reportContainer = mainView.findViewById(R.id.report_container); - reportContainer.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - Intent intent = new Intent(mapActivity, OsmLiveActivity.class); - intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); - if (mapActivity != null) { - mapActivity.startActivity(intent); - } - } - }); - LinearLayout liveUpdatesContainer = mainView.findViewById(R.id.live_updates_container); - liveUpdatesContainer.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - FragmentActivity activity = getActivity(); - if (activity != null) { - LiveUpdatesFragmentNew.showInstance(activity.getSupportFragmentManager(), PurchasesFragment.this); - } - } - }); - getSkuAppId(); - LinearLayout manageSubscriptionContainer = mainView.findViewById(R.id.manage_subscription_container); - manageSubscriptionContainer.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - Intent intent = new Intent(Intent.ACTION_VIEW); - intent.setData(Uri.parse(url)); - if (AndroidUtils.isIntentSafe(context, intent)) { - startActivity(intent); - } - } - }); - - } - - private void setupSupportRegion() { - String region = getSupportRegionName(app, purchaseHelper); - String header = getSupportRegionHeader(app, region); - TextView supportRegionHeader = mainView.findViewById(R.id.support_region_header); - TextView supportRegion = mainView.findViewById(R.id.support_region); - supportRegionHeader.setText(header); - supportRegion.setText(region); - - View supportRegionContainer = mainView.findViewById(R.id.support_region_container); - supportRegionContainer.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - CountrySelectionFragment countryCountrySelectionFragment = countrySelectionFragment; - countryCountrySelectionFragment.show(getChildFragmentManager(), CountrySelectionFragment.TAG); - } - }); - - countrySelectionFragment.initCountries(app); - } - - public static String getSupportRegionName(OsmandApplication app, InAppPurchaseHelper purchaseHelper) { - OsmandSettings settings = app.getSettings(); - String countryName = settings.BILLING_USER_COUNTRY.get(); - if (purchaseHelper != null) { - InAppSubscription monthlyPurchased = purchaseHelper.getPurchasedMonthlyLiveUpdates(); - if (monthlyPurchased != null && monthlyPurchased.isDonationSupported()) { - if (Algorithms.isEmpty(countryName)) { - if (OsmandSettings.BILLING_USER_DONATION_NONE_PARAMETER.equals(settings.BILLING_USER_COUNTRY_DOWNLOAD_NAME.get())) { - countryName = app.getString(R.string.osmand_team); - } else { - countryName = app.getString(R.string.shared_string_world); - } - } - } else { - countryName = app.getString(R.string.osmand_team); - } - } else { - countryName = app.getString(R.string.osmand_team); - } - return countryName; - } - - public static String getSupportRegionHeader(OsmandApplication app, String supportRegion) { - return supportRegion.equals(app.getString(R.string.osmand_team)) ? - app.getString(R.string.default_buttons_support) : - app.getString(R.string.osm_live_support_region); - } - @Nullable public InAppPurchaseHelper getInAppPurchaseHelper() { Activity activity = getActivity(); @@ -303,69 +167,21 @@ public class PurchasesFragment extends BaseOsmAndFragment implements InAppPurcha appbar.addView(toolbar); } - public void setFormatStrings() { - TextView contactSupportLink = mainView.findViewById(R.id.contact_support_title); - TextView supportDescription = mainView.findViewById(R.id.support_link_title); - - SpannableString spannableStringSupport = new SpannableString(getString(R.string.contact_support)); - spannableStringSupport.setSpan(new URLSpan(EMAIL_DEEPLINK_URI), 0, spannableStringSupport.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); - - String supportDescriptionString = getString(R.string.contact_support_description, OSMAND_EMAIL); - SpannableString spannableStringMail = new SpannableString(supportDescriptionString); - int startIndex = supportDescriptionString.indexOf(OSMAND_EMAIL); - int endIndex = startIndex + OSMAND_EMAIL.length(); - StyleSpan boldSpan = new StyleSpan(Typeface.BOLD); - spannableStringMail.setSpan(boldSpan, startIndex, endIndex, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); - - contactSupportLink.setText(spannableStringSupport); - supportDescription.setText(spannableStringMail); - - AndroidUtils.removeLinkUnderline(contactSupportLink); - - contactSupportLink.setMovementMethod(LinkMovementMethod.getInstance()); - } - - private void getSkuAppId() { - InAppPurchaseHelper purchaseHelper = app.getInAppPurchaseHelper(); - if (purchaseHelper != null && purchaseHelper.getFullVersion() != null) { - String sku = purchaseHelper.getFullVersion().getSku(); - url = String.format(PLAY_STORE_SUBSCRIPTION_DEEPLINK_URL, - sku, context.getPackageName()); - } else { - url = PLAY_STORE_SUBSCRIPTION_URL; - } - } - - @Override - public void onSearchResult(CountryItem selectedCountryItem) { - String countryName = selectedCountryItem != null ? selectedCountryItem.getLocalName() : ""; - String countryDownloadName = selectedCountryItem != null ? - selectedCountryItem.getDownloadName() : OsmandSettings.BILLING_USER_DONATION_WORLD_PARAMETER; - - OsmandApplication app = getMyApplication(); - if (app != null) { - TextView supportRegionHeader = mainView.findViewById(R.id.support_region_header); - TextView supportRegion = mainView.findViewById(R.id.support_region); - supportRegionHeader.setText(getSupportRegionHeader(app, countryName)); - supportRegion.setText(countryName); - app.getSettings().BILLING_USER_COUNTRY.set(countryName); - app.getSettings().BILLING_USER_COUNTRY_DOWNLOAD_NAME.set(countryDownloadName); - } - } - @Override public void onError(InAppPurchaseHelper.InAppPurchaseTaskType taskType, String error) { } @Override public void onGetItems() { - if (subscriptionsCard != null) { - subscriptionsCard.update(); + if (app != null) { + isPaidVersion = Version.isPaidVersion(app); } + updateCards(); } @Override public void onItemPurchased(String sku, boolean active) { + isPaidVersion = true; if (purchaseHelper != null) { purchaseHelper.requestInventory(); } @@ -379,7 +195,14 @@ public class PurchasesFragment extends BaseOsmAndFragment implements InAppPurcha public void dismissProgress(InAppPurchaseHelper.InAppPurchaseTaskType taskType) { } + @Override + public void onSearchResult(CountrySelectionFragment.CountryItem name) { + if (subscriptionsCard != null) { + subscriptionsCard.onSupportRegionSelected(name); + } + } + private MapActivity getMapActivity() { return (MapActivity) getActivity(); } -} +} \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/SubscriptionsCard.java b/OsmAnd/src/net/osmand/plus/settings/fragments/SubscriptionsCard.java index 1cc422b3ff..100bab00df 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/SubscriptionsCard.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/SubscriptionsCard.java @@ -1,121 +1,146 @@ package net.osmand.plus.settings.fragments; -import android.os.Build; -import android.view.LayoutInflater; +import android.content.Intent; +import android.net.Uri; import android.view.View; import android.view.ViewGroup; +import android.widget.LinearLayout; import android.widget.TextView; import net.osmand.AndroidUtils; -import net.osmand.Period; import net.osmand.plus.R; -import net.osmand.plus.UiUtilities; import net.osmand.plus.activities.MapActivity; -import net.osmand.plus.chooseplan.ChoosePlanDialogFragment; import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.inapp.InAppPurchaseHelper; -import net.osmand.plus.inapp.InAppPurchases.InAppSubscription; -import net.osmand.plus.inapp.InAppPurchases.InAppSubscription.SubscriptionState; +import net.osmand.plus.liveupdates.CountrySelectionFragment; +import net.osmand.plus.liveupdates.LiveUpdatesFragment; +import net.osmand.plus.liveupdates.LiveUpdatesFragmentNew; +import net.osmand.plus.liveupdates.OsmLiveActivity; import net.osmand.plus.routepreparationmenu.cards.BaseCard; +import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.util.Algorithms; -import java.text.SimpleDateFormat; -import java.util.Calendar; -import java.util.Date; -import java.util.List; -import java.util.Locale; - import androidx.annotation.NonNull; +import androidx.fragment.app.Fragment; public class SubscriptionsCard extends BaseCard { - private final InAppPurchaseHelper purchaseHelper; + private static final String PLAY_STORE_SUBSCRIPTION_URL = "https://play.google.com/store/account/subscriptions"; + private static final String PLAY_STORE_SUBSCRIPTION_DEEPLINK_URL = "https://play.google.com/store/account/subscriptions?sku=%s&package=%s"; - private final SimpleDateFormat dateFormat; + private Fragment target; + private CountrySelectionFragment countrySelectionFragment = new CountrySelectionFragment(); + private SubscriptionsListCard subscriptionsListCard; + + private InAppPurchaseHelper purchaseHelper; @Override public int getCardLayoutId() { return R.layout.subscriptions_card; } - public SubscriptionsCard(@NonNull MapActivity mapActivity, @NonNull InAppPurchaseHelper purchaseHelper) { + public SubscriptionsCard(@NonNull MapActivity mapActivity, @NonNull Fragment target, @NonNull InAppPurchaseHelper purchaseHelper) { super(mapActivity); + this.target = target; this.purchaseHelper = purchaseHelper; - this.dateFormat = new SimpleDateFormat("MMM d, yyyy", Locale.getDefault()); } @Override protected void updateContent() { if (purchaseHelper == null || Algorithms.isEmpty(purchaseHelper.getEverMadeSubscriptions())) { + AndroidUiHelper.updateVisibility(view, false); return; + } else { + AndroidUiHelper.updateVisibility(view, true); } - LayoutInflater inflater = UiUtilities.getInflater(mapActivity, nightMode); - ((ViewGroup) view).removeAllViews(); + updateSubscriptionsListCard(); + setupSupportRegion(); - List subscriptions = purchaseHelper.getEverMadeSubscriptions(); - for (int i = 0; i < subscriptions.size(); i++) { - InAppSubscription subscription = subscriptions.get(i); - SubscriptionState state = subscription.getState(); - boolean autoRenewed = state == SubscriptionState.ACTIVE || state == SubscriptionState.IN_GRACE_PERIOD; - - View card = inflater.inflate(R.layout.subscription_layout, null, false); - ((ViewGroup) view).addView(card); - - TextView subscriptionPeriod = card.findViewById(R.id.subscription_type); - String period = app.getString(subscription.getPeriodTypeString()); - if (!Algorithms.isEmpty(period)) { - subscriptionPeriod.setText(period); - AndroidUiHelper.updateVisibility(subscriptionPeriod, true); + LinearLayout reportContainer = view.findViewById(R.id.report_container); + reportContainer.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent intent = new Intent(mapActivity, OsmLiveActivity.class); + intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); + mapActivity.startActivity(intent); } + }); - if (autoRenewed) { - TextView nextBillingDate = card.findViewById(R.id.next_billing_date); - String date = getHumanDate(subscription.getPurchaseTime(), subscription.getSubscriptionPeriod()); - if (!Algorithms.isEmpty(date)) { - nextBillingDate.setText(app.getString(R.string.next_billing_date, date)); - AndroidUiHelper.updateVisibility(nextBillingDate, true); - } - } else { - View renewContainer = card.findViewById(R.id.renewContainer); - AndroidUiHelper.updateVisibility(renewContainer, true); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - AndroidUtils.setBackground(mapActivity, renewContainer, nightMode, R.drawable.ripple_light, R.drawable.ripple_dark); - } else { - AndroidUtils.setBackground(mapActivity, renewContainer, nightMode, R.drawable.btn_unstroked_light, R.drawable.btn_unstroked_dark); - } - final String sku = subscription.getSku(); - renewContainer.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - ChoosePlanDialogFragment.subscribe(app, mapActivity, purchaseHelper, sku); - } - }); - - View renew = card.findViewById(R.id.renew); - AndroidUtils.setBackground(mapActivity, renew, nightMode, - R.drawable.btn_solid_border_light, R.drawable.btn_solid_border_dark); + LinearLayout liveUpdatesContainer = view.findViewById(R.id.live_updates_container); + liveUpdatesContainer.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + LiveUpdatesFragmentNew.showInstance(mapActivity.getSupportFragmentManager(), target); } + }); - TextView status = card.findViewById(R.id.status); - status.setText(app.getString(state.getStringRes())); - AndroidUtils.setBackground(status, app.getUIUtilities().getIcon(state.getBackgroundRes())); + final String subscriptionUrl = getSubscriptionUrl(); + LinearLayout manageSubscriptionContainer = view.findViewById(R.id.manage_subscription_container); + manageSubscriptionContainer.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent intent = new Intent(Intent.ACTION_VIEW); + intent.setData(Uri.parse(subscriptionUrl)); + if (AndroidUtils.isIntentSafe(mapActivity, intent)) { + target.startActivity(intent); + } + } + }); + } - int dividerLayout = i + 1 == subscriptions.size() ? R.layout.simple_divider_item : R.layout.divider_half_item; - View divider = inflater.inflate(dividerLayout, (ViewGroup) view, false); - ((ViewGroup) view).addView(divider); + public void updateSubscriptionsListCard() { + if (subscriptionsListCard == null) { + ViewGroup subscriptionsListContainer = view.findViewById(R.id.subscriptions_list_container); + subscriptionsListContainer.removeAllViews(); + subscriptionsListCard = new SubscriptionsListCard(mapActivity, purchaseHelper); + subscriptionsListContainer.addView(subscriptionsListCard.build(mapActivity)); + } else { + subscriptionsListCard.update(); } } - private String getHumanDate(long time, Period period) { - if (period == null || period.getUnit() == null) { - return ""; + private void setupSupportRegion() { + String region = LiveUpdatesFragment.getSupportRegionName(app, purchaseHelper); + String header = LiveUpdatesFragment.getSupportRegionHeader(app, region); + TextView supportRegionHeader = view.findViewById(R.id.support_region_header); + TextView supportRegion = view.findViewById(R.id.support_region); + supportRegionHeader.setText(header); + supportRegion.setText(region); + + View supportRegionContainer = view.findViewById(R.id.support_region_container); + supportRegionContainer.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + CountrySelectionFragment countryCountrySelectionFragment = countrySelectionFragment; + countryCountrySelectionFragment.show(target.getChildFragmentManager(), CountrySelectionFragment.TAG); + } + }); + + countrySelectionFragment.initCountries(app); + } + + private String getSubscriptionUrl() { + InAppPurchaseHelper purchaseHelper = app.getInAppPurchaseHelper(); + if (purchaseHelper != null && purchaseHelper.getFullVersion() != null) { + String sku = purchaseHelper.getFullVersion().getSku(); + return String.format(PLAY_STORE_SUBSCRIPTION_DEEPLINK_URL, + sku, mapActivity.getPackageName()); + } else { + return PLAY_STORE_SUBSCRIPTION_URL; } - Date date = new Date(time); - Calendar calendar = Calendar.getInstance(); - calendar.setTime(date); - calendar.add(period.getUnit().getCalendarIdx(), period.getNumberOfUnits()); - date = calendar.getTime(); - return dateFormat.format(date); + } + + public void onSupportRegionSelected(CountrySelectionFragment.CountryItem selectedCountryItem) { + String countryName = selectedCountryItem != null ? selectedCountryItem.getLocalName() : ""; + String countryDownloadName = selectedCountryItem != null ? + selectedCountryItem.getDownloadName() : OsmandSettings.BILLING_USER_DONATION_WORLD_PARAMETER; + + TextView supportRegionHeader = view.findViewById(R.id.support_region_header); + TextView supportRegion = view.findViewById(R.id.support_region); + supportRegionHeader.setText(LiveUpdatesFragment.getSupportRegionHeader(app, countryName)); + supportRegion.setText(countryName); + app.getSettings().BILLING_USER_COUNTRY.set(countryName); + app.getSettings().BILLING_USER_COUNTRY_DOWNLOAD_NAME.set(countryDownloadName); } } \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/SubscriptionsListCard.java b/OsmAnd/src/net/osmand/plus/settings/fragments/SubscriptionsListCard.java new file mode 100644 index 0000000000..9d8d4f9568 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/SubscriptionsListCard.java @@ -0,0 +1,124 @@ +package net.osmand.plus.settings.fragments; + +import android.os.Build; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import net.osmand.AndroidUtils; +import net.osmand.Period; +import net.osmand.plus.R; +import net.osmand.plus.UiUtilities; +import net.osmand.plus.activities.MapActivity; +import net.osmand.plus.chooseplan.ChoosePlanDialogFragment; +import net.osmand.plus.helpers.AndroidUiHelper; +import net.osmand.plus.inapp.InAppPurchaseHelper; +import net.osmand.plus.inapp.InAppPurchases.InAppSubscription; +import net.osmand.plus.inapp.InAppPurchases.InAppSubscription.SubscriptionState; +import net.osmand.plus.routepreparationmenu.cards.BaseCard; +import net.osmand.util.Algorithms; + +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.List; +import java.util.Locale; + +import androidx.annotation.NonNull; + +public class SubscriptionsListCard extends BaseCard { + + private final InAppPurchaseHelper purchaseHelper; + + private final SimpleDateFormat dateFormat; + + @Override + public int getCardLayoutId() { + return R.layout.subscriptions_list_card; + } + + public SubscriptionsListCard(@NonNull MapActivity mapActivity, @NonNull InAppPurchaseHelper purchaseHelper) { + super(mapActivity); + this.purchaseHelper = purchaseHelper; + this.dateFormat = new SimpleDateFormat("MMM d, yyyy", Locale.getDefault()); + } + + @Override + protected void updateContent() { + if (purchaseHelper == null || Algorithms.isEmpty(purchaseHelper.getEverMadeSubscriptions())) { + AndroidUiHelper.updateVisibility(view, false); + return; + } else { + AndroidUiHelper.updateVisibility(view, true); + } + + LayoutInflater inflater = UiUtilities.getInflater(mapActivity, nightMode); + ((ViewGroup) view).removeAllViews(); + + List subscriptions = purchaseHelper.getEverMadeSubscriptions(); + for (int i = 0; i < subscriptions.size(); i++) { + InAppSubscription subscription = subscriptions.get(i); + SubscriptionState state = subscription.getState(); + boolean autoRenewed = state == SubscriptionState.ACTIVE || state == SubscriptionState.IN_GRACE_PERIOD; + + View card = inflater.inflate(R.layout.subscription_layout, null, false); + ((ViewGroup) view).addView(card); + + TextView subscriptionPeriod = card.findViewById(R.id.subscription_type); + String period = app.getString(subscription.getPeriodTypeString()); + if (!Algorithms.isEmpty(period)) { + subscriptionPeriod.setText(period); + AndroidUiHelper.updateVisibility(subscriptionPeriod, true); + } + + if (autoRenewed) { + TextView nextBillingDate = card.findViewById(R.id.next_billing_date); + String date = getHumanDate(subscription.getPurchaseTime(), subscription.getSubscriptionPeriod()); + if (!Algorithms.isEmpty(date)) { + nextBillingDate.setText(app.getString(R.string.next_billing_date, date)); + AndroidUiHelper.updateVisibility(nextBillingDate, true); + } + } else { + View renewContainer = card.findViewById(R.id.renewContainer); + AndroidUiHelper.updateVisibility(renewContainer, true); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + AndroidUtils.setBackground(mapActivity, renewContainer, nightMode, R.drawable.ripple_light, R.drawable.ripple_dark); + } else { + AndroidUtils.setBackground(mapActivity, renewContainer, nightMode, R.drawable.btn_unstroked_light, R.drawable.btn_unstroked_dark); + } + final String sku = subscription.getSku(); + renewContainer.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + ChoosePlanDialogFragment.subscribe(app, mapActivity, purchaseHelper, sku); + } + }); + + View renew = card.findViewById(R.id.renew); + AndroidUtils.setBackground(mapActivity, renew, nightMode, + R.drawable.btn_solid_border_light, R.drawable.btn_solid_border_dark); + } + + TextView status = card.findViewById(R.id.status); + status.setText(app.getString(state.getStringRes())); + AndroidUtils.setBackground(status, app.getUIUtilities().getIcon(state.getBackgroundRes())); + + int dividerLayout = i + 1 == subscriptions.size() ? R.layout.simple_divider_item : R.layout.divider_half_item; + View divider = inflater.inflate(dividerLayout, (ViewGroup) view, false); + ((ViewGroup) view).addView(divider); + } + } + + private String getHumanDate(long time, Period period) { + if (period == null || period.getUnit() == null) { + return ""; + } + Date date = new Date(time); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(date); + calendar.add(period.getUnit().getCalendarIdx(), period.getNumberOfUnits()); + date = calendar.getTime(); + return dateFormat.format(date); + } +} \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/TroubleshootingOrPurchasingCard.java b/OsmAnd/src/net/osmand/plus/settings/fragments/TroubleshootingOrPurchasingCard.java new file mode 100644 index 0000000000..c53950ee2b --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/TroubleshootingOrPurchasingCard.java @@ -0,0 +1,126 @@ +package net.osmand.plus.settings.fragments; + +import android.graphics.Typeface; +import android.net.Uri; +import android.os.Build; +import android.text.Spannable; +import android.text.SpannableString; +import android.text.Spanned; +import android.text.method.LinkMovementMethod; +import android.text.style.StyleSpan; +import android.text.style.URLSpan; +import android.view.View; +import android.widget.TextView; + +import net.osmand.AndroidUtils; +import net.osmand.plus.R; +import net.osmand.plus.activities.MapActivity; +import net.osmand.plus.chooseplan.ChoosePlanDialogFragment; +import net.osmand.plus.inapp.InAppPurchaseHelper; +import net.osmand.plus.routepreparationmenu.cards.BaseCard; +import net.osmand.plus.wikipedia.WikipediaDialogFragment; + +import androidx.annotation.IdRes; +import androidx.annotation.NonNull; +import androidx.cardview.widget.CardView; +import androidx.core.content.ContextCompat; + +public class TroubleshootingOrPurchasingCard extends BaseCard { + + private static final String OSMAND_NEW_DEVICE_URL = "https://docs.osmand.net/en/main@latest/osmand/purchases#new-device--new-account"; + private static final String OSMAND_EMAIL = "support@osmand.net"; + private static final String EMAIL_DEEPLINK_URI = "mailto:support@osmand.net"; + + protected InAppPurchaseHelper purchaseHelper; + + private final boolean isPaidVersion; + + @Override + public int getCardLayoutId() { + return isPaidVersion ? R.layout.troubleshooting_card : R.layout.no_purchases_card; + } + + public TroubleshootingOrPurchasingCard(@NonNull MapActivity mapActivity, @NonNull InAppPurchaseHelper purchaseHelper, boolean isPaidVersion) { + super(mapActivity); + this.purchaseHelper = purchaseHelper; + this.isPaidVersion = isPaidVersion; + } + + @Override + protected void updateContent() { + setupRestorePurchasesBtn(R.id.restore_purchases); + setupNewDeviceOrAccountBtn(R.id.new_device_account_container); + setupSupportDescription(); + setupContactUsLink(); + + if (!isPaidVersion) { + TextView infoDescription = view.findViewById(R.id.info_description); + String restorePurchases = app.getString(R.string.restore_purchases); + String infoPurchases = String.format(app.getString(R.string.empty_purchases_description), restorePurchases); + infoDescription.setText(infoPurchases); + + View osmandLive = view.findViewById(R.id.osmand_live); + osmandLive.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + ChoosePlanDialogFragment.showDialogInstance(getMyApplication(), + mapActivity.getSupportFragmentManager(), + ChoosePlanDialogFragment.ChoosePlanDialogType.OSM_LIVE); + } + }); + + CardView getItButtonContainer = view.findViewById(R.id.card_view); + int colorRes = nightMode ? R.color.switch_button_active_dark : R.color.switch_button_active_light; + getItButtonContainer.setCardBackgroundColor(ContextCompat.getColor(mapActivity, colorRes)); + + View getItButton = view.findViewById(R.id.card_container); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + AndroidUtils.setBackground(mapActivity, getItButton, nightMode, R.drawable.ripple_light, R.drawable.ripple_dark); + } else { + AndroidUtils.setBackground(mapActivity, getItButton, nightMode, R.drawable.btn_unstroked_light, R.drawable.btn_unstroked_dark); + } + } + } + + protected void setupRestorePurchasesBtn(@IdRes int btnId) { + View purchasesRestore = view.findViewById(btnId); + purchasesRestore.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (purchaseHelper != null) { + purchaseHelper.requestInventory(); + } + } + }); + } + + protected void setupNewDeviceOrAccountBtn(@IdRes int btnId) { + View newDeviceAccountContainer = view.findViewById(btnId); + newDeviceAccountContainer.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + WikipediaDialogFragment.showFullArticle(mapActivity, Uri.parse(OSMAND_NEW_DEVICE_URL), nightMode); + } + }); + } + + protected void setupSupportDescription() { + TextView supportDescription = view.findViewById(R.id.support_link_title); + String supportDescriptionString = app.getString(R.string.contact_support_description, OSMAND_EMAIL); + SpannableString spannableStringMail = new SpannableString(supportDescriptionString); + int startIndex = supportDescriptionString.indexOf(OSMAND_EMAIL); + int endIndex = startIndex + OSMAND_EMAIL.length(); + StyleSpan boldSpan = new StyleSpan(Typeface.BOLD); + spannableStringMail.setSpan(boldSpan, startIndex, endIndex, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); + supportDescription.setText(spannableStringMail); + } + + protected void setupContactUsLink() { + TextView contactSupportLink = view.findViewById(R.id.contact_support_title); + SpannableString spannableStringSupport = new SpannableString(app.getString(R.string.contact_support)); + spannableStringSupport.setSpan(new URLSpan(EMAIL_DEEPLINK_URI), 0, spannableStringSupport.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); + contactSupportLink.setText(spannableStringSupport); + AndroidUtils.removeLinkUnderline(contactSupportLink); + contactSupportLink.setMovementMethod(LinkMovementMethod.getInstance()); + } +} \ No newline at end of file From 3e8dac9cafa131f63c1c0094f28510ef791b3466 Mon Sep 17 00:00:00 2001 From: androiddevkotlin <64539346+androiddevkotlin@users.noreply.github.com> Date: Fri, 26 Mar 2021 23:09:00 +0200 Subject: [PATCH 49/74] Setting format --- .../src/net/osmand/plus/OsmAndFormatter.java | 22 ++++++++----------- .../fragments/CoordinatesFormatFragment.java | 2 +- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/OsmAndFormatter.java b/OsmAnd/src/net/osmand/plus/OsmAndFormatter.java index 10838339d0..383128095b 100644 --- a/OsmAnd/src/net/osmand/plus/OsmAndFormatter.java +++ b/OsmAnd/src/net/osmand/plus/OsmAndFormatter.java @@ -5,6 +5,7 @@ import android.text.format.DateUtils; import androidx.core.text.TextUtilsCompat; import androidx.core.view.ViewCompat; + import com.jwetherell.openmap.common.LatLonPoint; import com.jwetherell.openmap.common.MGRSPoint; import com.jwetherell.openmap.common.UTMPoint; @@ -509,19 +510,14 @@ public class OsmAndFormatter { result.append(formatCoordinate(lat, outputFormat)).append(" ").append(formatCoordinate(lon, outputFormat)); } else if (outputFormat == FORMAT_DEGREES || outputFormat == FORMAT_MINUTES || outputFormat == FORMAT_SECONDS) { boolean isLeftToRight = TextUtilsCompat.getLayoutDirectionFromLocale(Locale.getDefault()) == ViewCompat.LAYOUT_DIRECTION_LTR; - if (isLeftToRight) { - result - .append(formatCoordinate(lat, outputFormat)).append(" ") - .append(lat > 0 ? NORTH : SOUTH).append(", ") - .append(formatCoordinate(lon, outputFormat)).append(" ") - .append(lon > 0 ? EAST : WEST); - } else { - result - .append(formatCoordinate(lat, outputFormat)).append(" ") - .append(lon > 0 ? EAST : WEST).append(" ") - .append(formatCoordinate(lon, outputFormat)).append(", ") - .append(lat > 0 ? NORTH : SOUTH); - } + String rtlCoordinates = isLeftToRight ? "" : "\u200f"; + String rtlCoordinatesPunctuation = isLeftToRight ? ", " : " ,"; + result + .append(rtlCoordinates) + .append(formatCoordinate(lat, outputFormat)).append(rtlCoordinates).append(" ").append(rtlCoordinates) + .append(lat > 0 ? NORTH : SOUTH).append(rtlCoordinates).append(rtlCoordinatesPunctuation).append(rtlCoordinates) + .append(formatCoordinate(lon, outputFormat)).append(rtlCoordinates).append(" ").append(rtlCoordinates) + .append(lon > 0 ? EAST : WEST); } else if (outputFormat == UTM_FORMAT) { UTMPoint pnt = new UTMPoint(new LatLonPoint(lat, lon)); result diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/CoordinatesFormatFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/CoordinatesFormatFragment.java index fd62f6df3c..2af8ac55b8 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/CoordinatesFormatFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/CoordinatesFormatFragment.java @@ -146,7 +146,7 @@ public class CoordinatesFormatFragment extends BaseSettingsFragment { return spannableBuilder; } - return getString(R.string.ltr_or_rtl_combine_via_colon, getString(R.string.shared_string_example), formattedCoordinates); + return formattedCoordinates; } @Override From ae858ede93857a6619c69c647a2e6bc9240adafc Mon Sep 17 00:00:00 2001 From: androiddevkotlin <64539346+androiddevkotlin@users.noreply.github.com> Date: Sun, 28 Mar 2021 00:24:57 +0200 Subject: [PATCH 50/74] storage path fix --- .../net/osmand/plus/settings/datastorage/DataStorageHelper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/settings/datastorage/DataStorageHelper.java b/OsmAnd/src/net/osmand/plus/settings/datastorage/DataStorageHelper.java index 67fd73897e..b292a02e0d 100644 --- a/OsmAnd/src/net/osmand/plus/settings/datastorage/DataStorageHelper.java +++ b/OsmAnd/src/net/osmand/plus/settings/datastorage/DataStorageHelper.java @@ -106,7 +106,7 @@ public class DataStorageHelper { //shared storage dir = settings.getDefaultInternalStorage(); - path = dir.getAbsolutePath(); + path = "\u200e" + dir.getAbsolutePath(); iconId = R.drawable.ic_action_phone; StorageItem sharedStorageItem = StorageItem.builder() From 239d42852af4447f2bc681cf92de0e10af07e6db Mon Sep 17 00:00:00 2001 From: Hinagiku Zeppeki Date: Fri, 26 Mar 2021 10:24:45 +0000 Subject: [PATCH 51/74] Translated using Weblate (Japanese) Currently translated at 97.8% (3616 of 3695 strings) --- OsmAnd/res/values-ja/strings.xml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/OsmAnd/res/values-ja/strings.xml b/OsmAnd/res/values-ja/strings.xml index c619818f9b..212dfab6fe 100644 --- a/OsmAnd/res/values-ja/strings.xml +++ b/OsmAnd/res/values-ja/strings.xml @@ -3080,7 +3080,7 @@ POIの更新は利用できません 経路%sを保存しました 一時的な制限の検討 『クイックアクション』のリストに最低ひとつは項目を設定する必要があります - アルペン/ダウンヒルスキー + アルペンスキーとダウンヒルスキー アルペンスキーまたはダウンヒルスキーに用の斜面(ゲレンデ)やスキーリフトへの道 クロスカントリースキーとノルディックスキー ノルディックスキーやクロスカントリースキー用コースやそれらに用いられる小道などです。 @@ -3776,7 +3776,7 @@ POIの更新は利用できません 繰り返し • ルート計画機能を更新 : セグメントごとに異なるナビゲーションタイプを使用し、経路として反映することが可能に \n -\n• 経路の新しい外観オプション : 色、太さ、表示方向矢印、開始/終了アイコン選択 +\n• 経路の新しい外観オプション : 色、太さ、表示方向矢印、開始と終了アイコンの選択 \n \n• 自転車ノードの視認性を向上 \n @@ -4052,4 +4052,12 @@ POIの更新は利用できません \n• \"旅程記録\"ダイアログを更新 \n \n + 開始・終了アイコン + \'等高線(Contour lines)\'をご購入いただきありがとうございます + サブスクリプションは選択した期間に応じて課金されます。 AppGalleryからいつでもキャンセルできます。 + 購入確認後に利用者のAppGalleryアカウントへ請求されます。 +\n +\nサブスクリプションは更新日前にキャンセルされない限り自動的に延長されます。アカウントには更新日に更新期間分(月/ 3ヶ月/年)の金額が請求されます。 +\n +\nAppGallery設定でサブスクリプションの管理およびキャンセルができます。 \ No newline at end of file From fa0dcb03aaf88017aac4e0995ef584c38c450298 Mon Sep 17 00:00:00 2001 From: Ldm Public Date: Sat, 27 Mar 2021 18:14:41 +0000 Subject: [PATCH 52/74] Translated using Weblate (French) Currently translated at 100.0% (3695 of 3695 strings) --- OsmAnd/res/values-fr/strings.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/OsmAnd/res/values-fr/strings.xml b/OsmAnd/res/values-fr/strings.xml index 72e77075b4..89e6c2730b 100644 --- a/OsmAnd/res/values-fr/strings.xml +++ b/OsmAnd/res/values-fr/strings.xml @@ -715,7 +715,7 @@ Enregistrez l\'emplacement de stationnement de votre véhicule et, si besoin, mesurez la durée de stationnement restante. \nCes informations sont visibles sur le Tableau de bord comme sur la carte. Un rappel peut même être ajouté à votre calendrier. Stationnement - Marquer comme stationnement + Stationnement Supprimer l\'emplacement de stationnement Point de départ trop éloigné de la route la plus proche. Lieu partagé @@ -1217,7 +1217,7 @@ \nPoints de passage %2$s %1$s \nPoints %1$s \nTrace %2$s - Itinéraire + Point de passage Heure actuelle Chargement de %1$s… Enregistrer comme groupe de favoris @@ -3722,7 +3722,7 @@ Saisissez l\'adresse Ajouter à un fichier de trace Ajouter des fichiers de trace - Ajouter un point de passage + Ajouter une étape Ajouter un point de passage à la trace Début de la trace Déplacer sur les routes From 2b01201311dcaed456be8a6959f085926d6a2502 Mon Sep 17 00:00:00 2001 From: Ihor Hordiichuk Date: Fri, 26 Mar 2021 19:13:36 +0000 Subject: [PATCH 53/74] Translated using Weblate (Ukrainian) Currently translated at 100.0% (3695 of 3695 strings) --- OsmAnd/res/values-uk/strings.xml | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/OsmAnd/res/values-uk/strings.xml b/OsmAnd/res/values-uk/strings.xml index a2fcf4cd0e..c679111b1e 100644 --- a/OsmAnd/res/values-uk/strings.xml +++ b/OsmAnd/res/values-uk/strings.xml @@ -545,7 +545,7 @@ Завантажується список доступних регіонів… Не вдалося отримати список регіонів з https://osmand.net. Збережена точка закладки була змінена - Точки Закладок відсутні + Немає закладених точок Замінити Показати маршрут Почати супровід @@ -878,7 +878,7 @@ Показувати попередження… Аварійні служби Швидка побудова маршруту (можливо неоптимальна) - Налаштування попередження про дорожній рух (обмеження швидкості, вимушені зупинки, штучні нерівності, тунелі), попередження про камери контролю швидкості, відомості про смуги руху. + Налаштування попереджень про дорожній рух (обмеження швидкості, вимушені зупинки, штучні нерівності, тунелі), попередження про камери контролю швидкості, відомості про смуги руху. Уник. автомагістралей Прив’язуватися до доріг Перегляд та навігація в автономному та мережевому режимах мапами OSM @@ -977,7 +977,7 @@ Використовувати магнітометр Налаштуйте, як записувати свої поїздки. Завантаження… - Вилучити точку + Видалити точку час точність швидкість @@ -1348,7 +1348,7 @@ Ви увійшли як %1$s Допустиме значення перевищення швидкості Оберіть допустиме значення перевищення швидкості, при перевищенні якого Ви отримаєте голосове попередження. - Назву Закладки було змінено на %1$s, щоб мати можливість зберігати рядки зі смайликами у файл. + Закладку перейменовано на «%1$s», щоб зберегти у файл рядок, що містить смайлики. Друк маршруту Дублювання назви закладки Вказана назва Закладки вже існує, тому її було змінено на %1$s, щоб уникнути появи дублікатів. @@ -1900,7 +1900,7 @@ Сповіщати лише, коли змінюється напрямок до цільової точки. Період сповіщеннь Найменший час між оголошеннями. - Усталений колір + Типовий колір Оберіть категорію Додайте назву Додайте категорію @@ -2031,7 +2031,7 @@ Втулок для необмеженого доступу до мап, їх оновлень та отримання відомостей з Wikipedia. Милі/метри Пропустити завантаження мап - У Вас немає завантажених мап. Ви можете вибрати мапу зі списку або завантажити її пізніше за допомогою меню — %1$s. + У вас немає завантажених мап. Ви можете вибрати мапу зі списку або завантажити її пізніше за допомогою меню — %1$s. Виберіть інший регіон Пошук мапи… OsmAnd визначить ваше розташування і запропонує завантажити мапи для цього регіону. @@ -2395,7 +2395,7 @@ Поділитися своїми вуличними видами цієї місцевості через Mapillary. Віджет Mapillary Дозволяє швидко зробити внесок в Mapillary. - Світлини вулиць в мережі для всіх. Відкрийте для себе місця, діліться та знимкуйте весь світ. + Світлини вулиць в мережі для всіх. Відкрийте для себе місця, діліться та захоплюйте весь світ. Вуличні світлини для усіх. Відкривайте для себе місця, співпрацюйте, знімкуйте світ. Мережеві світлини Тут нема світлин. @@ -2979,7 +2979,7 @@ Виберіть профіль для початку Служба завантаження OsmAnd Пурпуровий - Значок + Піктограма Дані зібрано Натисніть ще раз для зміни орієнтації мапи Мінімальна швидкість @@ -3077,7 +3077,7 @@ Зовнішні пристрої введення Оберіть пристрій на зразок звичайної клавіатури чи WunderLINQ для зовнішнього керування. Немає - Звичайна клавіатура + Клавіатура WundеrLINQ Parrot Увімкніть принаймні один профіль застосунку, щоб скористатися цим параметром. @@ -3253,7 +3253,7 @@ Надавати перевагу ґрунтовим дорогам Надати перевагу незаасфальтованим над асфальтованими дорогами для прокладки. Правки OSM - Увімк/вимк показ горизонталей. + Увімк/вимк показ горизонталей на мапі. Кнопка, що показує чи приховує горизонталі на мапі. Не вдається запустити рушій мовлення. Відтворити свою позицію за допомогою записаного треку GPX. @@ -3370,7 +3370,7 @@ Додати власну категорію Показувати лише вночі Усі налаштування втулка відновлено до усталеного стану. - Усі налаштування профілю відновлено до усталеного стану. + Усі налаштування профілю відновлено до типових. %1$s/%2$s Захід сонця о %1$s Схід сонця о %1$s @@ -3436,7 +3436,7 @@ Нічого не вибрано Швидкі дії Профілі - Перелічені %1$s вже існують у OsmAnd. + Перелічені %1$s вже існують в OsmAnd. Поточні елементи будуть замінені на елементи з файлу Замінити все Зберегти обидва @@ -3464,7 +3464,7 @@ Маршрут буде перераховано, якщо відстань від маршруту до поточного місця розташування перевищує вибране значення. Виберіть відстань, після якого маршрут буде перераховано. Перерахунок маршруту у випадку відхилення - Хв + Мін Рельєф Мапа пагорбів використовує темні відтінки для показу схилів, вершин і низин. У режимі Схил, рельєф місцевості візуалізується за допомогою кольорів. @@ -3485,7 +3485,7 @@ Вибрати групу Вибрати фігуру Коло - Площа + Квадрат Восьмикутник Замінити іншу точку цією. Гірськолижний туризм From c7c9cd76828c7593a34e7e188bead700bffc498d Mon Sep 17 00:00:00 2001 From: Manuel Tassi Date: Fri, 26 Mar 2021 10:23:45 +0000 Subject: [PATCH 54/74] Translated using Weblate (Italian) Currently translated at 88.1% (3257 of 3695 strings) --- OsmAnd/res/values-it/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/res/values-it/strings.xml b/OsmAnd/res/values-it/strings.xml index 240b7e3156..56bc8eff8e 100644 --- a/OsmAnd/res/values-it/strings.xml +++ b/OsmAnd/res/values-it/strings.xml @@ -2070,7 +2070,7 @@ Spessore linee isoipse Spessore linee isoipse Acqua - Non visualizzare l\'acqua + Nascondi l\'acqua Densità linee isoipse Azione rapida Azione %d From 387a92af01fef7e8961dd934fa1c8d7779247cf5 Mon Sep 17 00:00:00 2001 From: iman Date: Sat, 27 Mar 2021 19:03:31 +0000 Subject: [PATCH 55/74] Translated using Weblate (Persian) Currently translated at 99.9% (3692 of 3695 strings) --- OsmAnd/res/values-fa/strings.xml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/OsmAnd/res/values-fa/strings.xml b/OsmAnd/res/values-fa/strings.xml index 92ceed2233..c7a92d5c8a 100644 --- a/OsmAnd/res/values-fa/strings.xml +++ b/OsmAnd/res/values-fa/strings.xml @@ -680,7 +680,7 @@ \n {1} مگابایت (از {2} مگابایت) استفاده خواهد شد. پوستهٔ شفاف کتابخانهٔ native بر روی این دستگاه پشتیبانی نمی‌شود. - مقداردهی اولیهٔ کتابخانهٔ native… + در حال مقداردهی اولیهٔ کتابخانهٔ native… نمای نقشه خودکار-مرکز مدت‌زمانی که طول می‌کشد تا نقشه با موقعیت کنونی همگام شود. ناوبری فقط با حالت خودکار-مرکز @@ -706,7 +706,7 @@ آیا از حذف %1$d علاقه‌مندی و %2$d گروه علاقه‌مندی مطمئن هستید؟ نقشه پایهٔ جهان را دانلود کنید تا نمایی از سراسر جهان در زوم‌های کم داشته باشید. نسخهٔ محلی - گشودن دادهٔ جدید… + در حال گشودن دادهٔ جدید… ناوبری آنلاین به‌طور آفلاین کار نمی‌کند. داده وجود ندارد برعکس‌کردن جهت رد @@ -744,7 +744,7 @@ هم‌رسانی مکان در حال نمایه‌کردن نشانی… در حال نمایه‌کردن نقشه… - نمایه‌کردن POI‏… + در حال نمایه‌کردن نقاط توجه… در حال نمایه‌کردن حمل‌ونقل… خطای ورودی/خروجی km @@ -787,8 +787,8 @@ در حال تبدیل اسامی محلی/انگلیسی… ناموفق اجازهٔ دسترسی احراز نشد - بستن بستهٔ تغییر… - بازکردن بستهٔ تغییر… + در حال بستن بستهٔ تغییر… + در حال بازکردن بستهٔ تغییر… دریافت لیست مناطق از https://osmand.net ناموفق بود. در حال دانلود لیست مناطق موجود… دادهٔ آفلاینِ {0} از قبل وجود دارد ({1}). آن را روزآمد می‌کنید ({2})؟ @@ -1633,7 +1633,7 @@ صرف‌نظر از دانلود نقشه‌ها نقشهٔ آفلاینی نصب نکرده‌اید. نقشه‌ای را از لیست انتخاب نمایید یا بعداً از طریق «منو ← %1$s»، آن را دانلود کنید. منطقهٔ دیگری را انتخاب کنید - جست‌وجوی نقشه‌ها… + در حال جست‌وجوی نقشه‌ها… اجازه دهید برنامه موقعیت شما را پیدا کند تا نقشهٔ آنجا را برای دانلود پیشنهاد بدهد. موقعیت پیدا نشد اتصال اینترنت برقرار نیست @@ -2375,7 +2375,7 @@ درون‌برد فایل GPX ورود فوری مختصات نمایش خطوط جهت‌دار - به نمایشش روی نقشه ادامه بده + روی نقشه نمایان بماند ذخیره به‌عنوان نقاط مسیر نقطهٔ مسیر میزان اُفت‌وخیز ارتفاع را انتخاب کنید @@ -2824,7 +2824,7 @@ پیاده طول مسیر نقاط توجه (POI) - محاسبهٔ مسیر… + در حال محاسبهٔ مسیر… حمل‌ونقل عمومی جاده‌ای که می‌خواهید هنگام ناوبری از آن بپرهیزید، روی نقشه یا از لیست زیر انتخاب کنید: در امتداد مسیر نشان بده @@ -2947,7 +2947,7 @@ محاسبهٔ مسیر پیاده نوع حمل‌ونقل ارسال گزارش - جست‌وجوی GPS‏ + در حال جست‌وجوی GPS‏ ابزارک مختصات لطفاً در گوگل‌پلی دربارهٔ کار ما نظر و امتیاز بدهید. سیاست حریم خصوصی From 787ec5b159bf0fc954a95d90b9bf4b64c7d2272f Mon Sep 17 00:00:00 2001 From: Ihor Hordiichuk Date: Fri, 26 Mar 2021 19:18:25 +0000 Subject: [PATCH 56/74] Translated using Weblate (Ukrainian) Currently translated at 100.0% (3894 of 3894 strings) --- OsmAnd/res/values-uk/phrases.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/res/values-uk/phrases.xml b/OsmAnd/res/values-uk/phrases.xml index 015cddb2a8..454bd79608 100644 --- a/OsmAnd/res/values-uk/phrases.xml +++ b/OsmAnd/res/values-uk/phrases.xml @@ -1209,7 +1209,7 @@ Скайп Ютюб Інстаграм - Вконтактє + VKontakte Гугле+ Мобільний телефон Час обслуговування From 6322fad7b578a55acdf3a5ac0543f06504974b9f Mon Sep 17 00:00:00 2001 From: Franco Date: Fri, 26 Mar 2021 11:44:04 +0000 Subject: [PATCH 57/74] Translated using Weblate (Spanish (Argentina)) Currently translated at 99.9% (3694 of 3695 strings) --- OsmAnd/res/values-es-rAR/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/res/values-es-rAR/strings.xml b/OsmAnd/res/values-es-rAR/strings.xml index 91493663a7..177cc6c449 100644 --- a/OsmAnd/res/values-es-rAR/strings.xml +++ b/OsmAnd/res/values-es-rAR/strings.xml @@ -1394,7 +1394,7 @@ Descargando lista de regiones disponibles… No se pudo obtener la lista de regiones desde https://osmand.net. Punto favorito editado - Sin puntos de Favoritos + No existen puntos favoritos Reemplazar Mostrar ruta Iniciar la guía From 122aef6ae662da3f033d48f8f307d804264646f9 Mon Sep 17 00:00:00 2001 From: Softmap Date: Fri, 26 Mar 2021 22:07:42 +0000 Subject: [PATCH 58/74] Translated using Weblate (Arabic) Currently translated at 93.4% (3639 of 3894 strings) --- OsmAnd/res/values-ar/phrases.xml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/OsmAnd/res/values-ar/phrases.xml b/OsmAnd/res/values-ar/phrases.xml index 372df7b654..ddb10cbcc1 100644 --- a/OsmAnd/res/values-ar/phrases.xml +++ b/OsmAnd/res/values-ar/phrases.xml @@ -3703,4 +3703,12 @@ الجيوديسيا (شكل الأرض ومساحتها) المرجع المحلي الزحلقه + التدريب: تصفيف الشعر + التدريب: الطيران + التدريب: اليوغا + التدريب: الحاسوب + التدريب: فن + التدريب: رياضة + نصب تذكاري بوذي + ممر زحلقة الشمالي \ No newline at end of file From 97f0f8d9e82904ebb0672533201e005aedc69fa0 Mon Sep 17 00:00:00 2001 From: Famlam Date: Fri, 26 Mar 2021 21:43:42 +0000 Subject: [PATCH 59/74] Translated using Weblate (Dutch) Currently translated at 98.2% (3629 of 3695 strings) --- OsmAnd/res/values-nl/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/res/values-nl/strings.xml b/OsmAnd/res/values-nl/strings.xml index 07c4aef6f7..bad32e0a9e 100644 --- a/OsmAnd/res/values-nl/strings.xml +++ b/OsmAnd/res/values-nl/strings.xml @@ -2884,7 +2884,7 @@ Wissel tussen dag-/nachtmodus Oppervlakte Kwaliteit wegdek - Steilte + Helling U gebruikt {0} kaart geleverd door OsmAnd. Wilt u de \"OsmAnd full\" versie openen\? Open OsmAnd\? Eenheid hoeken From be85c4dcd6dc455ce49b1f17ff840e1971f2e831 Mon Sep 17 00:00:00 2001 From: androiddevkotlin <64539346+androiddevkotlin@users.noreply.github.com> Date: Sun, 28 Mar 2021 22:37:03 +0300 Subject: [PATCH 60/74] User suggestion --- .../routing/data/AnnounceTimeDistances.java | 35 +++++++++---------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/routing/data/AnnounceTimeDistances.java b/OsmAnd/src/net/osmand/plus/routing/data/AnnounceTimeDistances.java index ea50cdf1e5..a0f1ca0cd8 100644 --- a/OsmAnd/src/net/osmand/plus/routing/data/AnnounceTimeDistances.java +++ b/OsmAnd/src/net/osmand/plus/routing/data/AnnounceTimeDistances.java @@ -210,24 +210,21 @@ public class AnnounceTimeDistances { return (int) (dist - voicePromptDelayTimeSec * speed); } - private void appendTurnDesc(SpannableStringBuilder builder, String name, int dist, String meter, String second) { - appendTurnDesc(builder, name, dist, DEFAULT_SPEED, meter, second); + private void appendTurnDesc(OsmandApplication app, SpannableStringBuilder builder, String name, int dist, String meter, String second) { + appendTurnDesc(app, builder, name, dist, DEFAULT_SPEED, meter, second); } - private void appendTurnDesc(SpannableStringBuilder builder, String name, int dist, float speed, String meter, String second) { + private void appendTurnDesc(OsmandApplication app, SpannableStringBuilder builder, String name, int dist, float speed, String meter, String second) { int minDist = (dist / 5) * 5; int time = (int) (dist / speed); if (time > 15) { // round to 5 time = (time / 5) * 5; } - boolean isLeftToRight = TextUtilsCompat.getLayoutDirectionFromLocale(Locale.getDefault()) == ViewCompat.LAYOUT_DIRECTION_LTR; - if (isLeftToRight) { - builder.append(String.format("\n%s: %d - %d %s, %d %s.", name, minDist, minDist + 5, meter, time, second)); - } else { - builder.append(String.format("\n%s: %s %d, %s %d - %d.", name, second, time, meter, minDist, minDist + 5)); + String distStr = String.format("\n%s: %d - %d %s", name, minDist, minDist + 5, meter); + String timeStr = String.format("%d %s.", time, second); + builder.append(app.getString(R.string.ltr_or_rtl_combine_via_comma, distStr, timeStr)); - } } public Spannable getIntervalsDescription(OsmandApplication app) { @@ -253,35 +250,35 @@ public class AnnounceTimeDistances { builder.append(turn); makeBold(builder, turn); if (PREPARE_DISTANCE_END <= PREPARE_DISTANCE) { - appendTurnDesc(builder, prepare, PREPARE_DISTANCE, meter, second); + appendTurnDesc(app, builder, prepare, PREPARE_DISTANCE, meter, second); } if (PREPARE_LONG_DISTANCE_END <= PREPARE_LONG_DISTANCE) { - appendTurnDesc(builder, longPrepare, PREPARE_LONG_DISTANCE, meter, second); + appendTurnDesc(app, builder, longPrepare, PREPARE_LONG_DISTANCE, meter, second); } - appendTurnDesc(builder, approach, TURN_IN_DISTANCE, meter, second); - appendTurnDesc(builder, passing, TURN_NOW_DISTANCE, TURN_NOW_SPEED, meter, second); + appendTurnDesc(app, builder, approach, TURN_IN_DISTANCE, meter, second); + appendTurnDesc(app, builder, passing, TURN_NOW_DISTANCE, TURN_NOW_SPEED, meter, second); // Arrive at destination - appendTurnDesc(builder, arrive, (int) (getArrivalDistance()), meter, second); + appendTurnDesc(app, builder, arrive, (int) (getArrivalDistance()), meter, second); makeBoldFormatted(builder, arrive); // Off-route if (getOffRouteDistance() > 0) { - appendTurnDesc(builder, offRoute, (int) getOffRouteDistance(), meter, second); + appendTurnDesc(app, builder, offRoute, (int) getOffRouteDistance(), meter, second); makeBoldFormatted(builder, offRoute); } // Traffic warnings builder.append(traffic); makeBold(builder, traffic); - appendTurnDesc(builder, approach, LONG_ALARM_ANNOUNCE_RADIUS, meter, second); - appendTurnDesc(builder, passing, SHORT_ALARM_ANNOUNCE_RADIUS, meter, second); + appendTurnDesc(app, builder, approach, LONG_ALARM_ANNOUNCE_RADIUS, meter, second); + appendTurnDesc(app, builder, passing, SHORT_ALARM_ANNOUNCE_RADIUS, meter, second); // Waypoint / Favorite / POI builder.append(point); makeBold(builder, point); - appendTurnDesc(builder, approach, LONG_PNT_ANNOUNCE_RADIUS, meter, second); - appendTurnDesc(builder, passing, SHORT_PNT_ANNOUNCE_RADIUS, meter, second); + appendTurnDesc(app, builder, approach, LONG_PNT_ANNOUNCE_RADIUS, meter, second); + appendTurnDesc(app, builder, passing, SHORT_PNT_ANNOUNCE_RADIUS, meter, second); return builder; } From 6fb2273ee49472ede4ef140a67a4380a6c3ca771 Mon Sep 17 00:00:00 2001 From: xmd5a Date: Sun, 28 Mar 2021 23:30:32 +0300 Subject: [PATCH 61/74] Add phrase --- OsmAnd/res/values/phrases.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OsmAnd/res/values/phrases.xml b/OsmAnd/res/values/phrases.xml index 675077e65c..1f4afe5537 100644 --- a/OsmAnd/res/values/phrases.xml +++ b/OsmAnd/res/values/phrases.xml @@ -4347,4 +4347,6 @@ Local ref + Camp pitch + From 99c432d9ff37216b2e2dc367069fdd09d9a6e007 Mon Sep 17 00:00:00 2001 From: androiddevkotlin <64539346+androiddevkotlin@users.noreply.github.com> Date: Sun, 28 Mar 2021 23:41:49 +0300 Subject: [PATCH 62/74] Change targetFragment to MapRouteInfoMenu, static startNavigation --- .../MapRouteInfoMenuFragment.java | 47 ++++++++++++++----- .../cards/TracksCard.java | 6 +-- .../osmand/plus/track/TrackMenuFragment.java | 23 +++++---- 3 files changed, 48 insertions(+), 28 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenuFragment.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenuFragment.java index bd1d382677..8710c934dd 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenuFragment.java @@ -16,6 +16,7 @@ import androidx.annotation.Nullable; import androidx.core.content.ContextCompat; import net.osmand.AndroidUtils; +import net.osmand.GPXUtilities; import net.osmand.data.QuadRect; import net.osmand.data.RotatedTileBox; import net.osmand.plus.OsmandApplication; @@ -23,11 +24,14 @@ import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.base.ContextMenuFragment; import net.osmand.plus.helpers.AndroidUiHelper; +import net.osmand.plus.routing.GPXRouteParams; import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.settings.backend.ApplicationMode; +import net.osmand.plus.track.TrackMenuFragment; +import net.osmand.plus.track.TrackSelectSegmentBottomSheet; import net.osmand.plus.widgets.TextViewExProgress; -public class MapRouteInfoMenuFragment extends ContextMenuFragment { +public class MapRouteInfoMenuFragment extends ContextMenuFragment implements TrackSelectSegmentBottomSheet.OnSegmentSelectedListener { public static final String TAG = MapRouteInfoMenuFragment.class.getName(); @Nullable @@ -95,13 +99,13 @@ public class MapRouteInfoMenuFragment extends ContextMenuFragment { @Override public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { + Bundle savedInstanceState) { MapActivity mapActivity = requireMapActivity(); menu = mapActivity.getMapRouteInfoMenu(); View view = super.onCreateView(inflater, container, savedInstanceState); if (view != null) { - bottomContainer = (FrameLayout) view.findViewById(R.id.bottom_container); + bottomContainer = view.findViewById(R.id.bottom_container); modesLayoutToolbar = view.findViewById(R.id.modes_layout_toolbar); modesLayoutToolbarContainer = view.findViewById(R.id.modes_layout_toolbar_container); modesLayoutListContainer = view.findViewById(R.id.modes_layout_list_container); @@ -121,7 +125,7 @@ public class MapRouteInfoMenuFragment extends ContextMenuFragment { int widthNoShadow = getLandscapeNoShadowWidth(); modesLayoutToolbar.setLayoutParams(new FrameLayout.LayoutParams(widthNoShadow, ViewGroup.LayoutParams.WRAP_CONTENT)); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(widthNoShadow, ViewGroup.LayoutParams.WRAP_CONTENT); - params.gravity = Gravity.BOTTOM|Gravity.START; + params.gravity = Gravity.BOTTOM | Gravity.START; view.findViewById(R.id.control_buttons).setLayoutParams(params); View appModesView = view.findViewById(R.id.app_modes); AndroidUtils.setPadding(appModesView, 0, 0, appModesView.getPaddingRight(), 0); @@ -182,15 +186,15 @@ public class MapRouteInfoMenuFragment extends ContextMenuFragment { @Override protected void updateMenuState(int currentMenuState, int newMenuState) { - if(getMyApplication().getRoutingHelper().isRouteCalculated() ) { + if (getMyApplication().getRoutingHelper().isRouteCalculated()) { ApplicationMode mV = getMyApplication().getRoutingHelper().getAppMode(); if (newMenuState == MenuState.HEADER_ONLY && currentMenuState == MenuState.HALF_SCREEN) { - getSettings().OPEN_ONLY_HEADER_STATE_ROUTE_CALCULATED.setModeValue(mV,true); + getSettings().OPEN_ONLY_HEADER_STATE_ROUTE_CALCULATED.setModeValue(mV, true); } else if (currentMenuState == MenuState.HEADER_ONLY && newMenuState == MenuState.HALF_SCREEN) { getSettings().OPEN_ONLY_HEADER_STATE_ROUTE_CALCULATED.resetModeToDefault(mV); } } - } + } @Override protected void setViewY(int y, boolean animated, boolean adjustMapPos) { @@ -347,7 +351,7 @@ public class MapRouteInfoMenuFragment extends ContextMenuFragment { OsmandApplication app = getMyApplication(); return app != null && app.getRoutingHelper().isOsmandRouting(); } - + public void updateRouteCalculationProgress(int progress) { MapActivity mapActivity = getMapActivity(); View mainView = getMainView(); @@ -356,7 +360,7 @@ public class MapRouteInfoMenuFragment extends ContextMenuFragment { return; } boolean indeterminate = isPublicTransportMode() || !isOsmandRouting(); - ProgressBar progressBar = (ProgressBar) mainView.findViewById(R.id.progress_bar); + ProgressBar progressBar = mainView.findViewById(R.id.progress_bar); if (progressBar != null) { if (progress == 0) { progressBar.setIndeterminate(indeterminate); @@ -366,14 +370,14 @@ public class MapRouteInfoMenuFragment extends ContextMenuFragment { } progressBar.setProgress(progress); } - ProgressBar progressBarButton = (ProgressBar) view.findViewById(R.id.progress_bar_button); + ProgressBar progressBarButton = view.findViewById(R.id.progress_bar_button); if (progressBarButton != null) { if (progressBarButton.getVisibility() != View.VISIBLE) { progressBarButton.setVisibility(View.VISIBLE); } progressBarButton.setProgress(indeterminate ? 0 : progress); } - TextViewExProgress textViewExProgress = (TextViewExProgress) view.findViewById(R.id.start_button_descr); + TextViewExProgress textViewExProgress = view.findViewById(R.id.start_button_descr); textViewExProgress.percent = indeterminate ? 0 : progress / 100f; textViewExProgress.invalidate(); } @@ -390,11 +394,11 @@ public class MapRouteInfoMenuFragment extends ContextMenuFragment { if (progressBar != null) { progressBar.setVisibility(View.GONE); } - ProgressBar progressBarButton = (ProgressBar) view.findViewById(R.id.progress_bar_button); + ProgressBar progressBarButton = view.findViewById(R.id.progress_bar_button); if (progressBarButton != null) { progressBarButton.setProgress(0); } - TextViewExProgress textViewExProgress = (TextViewExProgress) view.findViewById(R.id.start_button_descr); + TextViewExProgress textViewExProgress = view.findViewById(R.id.start_button_descr); textViewExProgress.percent = 0; } @@ -501,4 +505,21 @@ public class MapRouteInfoMenuFragment extends ContextMenuFragment { return false; } } + + @Override + public void onSegmentSelect(GPXUtilities.GPXFile gpxFile, int selectedSegment) { + if (getMyApplication() != null) { + getMyApplication().getSettings().GPX_ROUTE_SEGMENT.set(selectedSegment); + MapActivity mapActivity = getMapActivity(); + if (mapActivity != null) { + TrackMenuFragment.startNavigationForGPX(gpxFile, mapActivity.getMapActions(), mapActivity); + GPXRouteParams.GPXRouteParamsBuilder paramsBuilder = getMyApplication().getRoutingHelper().getCurrentGPXRoute(); + if (paramsBuilder != null) { + paramsBuilder.setSelectedSegment(selectedSegment); + getMyApplication().getRoutingHelper().onSettingsChanged(true); + } + dismiss(); + } + } + } } \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/TracksCard.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/TracksCard.java index 1abccb3382..fe09174683 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/TracksCard.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/TracksCard.java @@ -21,8 +21,8 @@ import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.helpers.GpxUiHelper; import net.osmand.plus.helpers.GpxUiHelper.GPXInfo; +import net.osmand.plus.routepreparationmenu.MapRouteInfoMenuFragment; import net.osmand.plus.settings.backend.ApplicationMode; -import net.osmand.plus.track.TrackMenuFragment; import net.osmand.plus.track.TrackSelectSegmentBottomSheet; import java.io.File; @@ -131,8 +131,8 @@ public class TracksCard extends BaseCard { } } if (item.file.getNonEmptySegmentsCount() > 1) { - Fragment f = mapActivity.getSupportFragmentManager().findFragmentByTag(TrackMenuFragment.TAG); - TrackSelectSegmentBottomSheet.showInstance(mapActivity.getSupportFragmentManager(), item.file, f); + Fragment targetFragment = mapActivity.getSupportFragmentManager().findFragmentByTag(MapRouteInfoMenuFragment.TAG); + TrackSelectSegmentBottomSheet.showInstance(mapActivity.getSupportFragmentManager(), item.file, targetFragment); } else { mapActivity.getMapActions().setGPXRouteParams(item.file); app.getTargetPointsHelper().updateRouteAndRefresh(true); diff --git a/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java b/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java index bb738a8e00..f5c52a11ce 100644 --- a/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java @@ -82,8 +82,8 @@ import net.osmand.plus.myplaces.TrackActivityFragmentAdapter; import net.osmand.plus.osmedit.OsmEditingPlugin; import net.osmand.plus.routepreparationmenu.cards.BaseCard; import net.osmand.plus.routepreparationmenu.cards.BaseCard.CardListener; -import net.osmand.plus.search.QuickSearchDialogFragment; import net.osmand.plus.routing.GPXRouteParams.GPXRouteParamsBuilder; +import net.osmand.plus.search.QuickSearchDialogFragment; import net.osmand.plus.track.SaveGpxAsyncTask.SaveGpxListener; import net.osmand.plus.track.TrackSelectSegmentBottomSheet.OnSegmentSelectedListener; import net.osmand.plus.views.AddGpxPointBottomSheetHelper.NewGpxPoint; @@ -804,7 +804,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card if (gpxFile.getNonEmptySegmentsCount() > 1) { TrackSelectSegmentBottomSheet.showInstance(mapActivity.getSupportFragmentManager(), gpxFile, this); } else { - startNavigationForGPX(gpxFile, mapActions); + startNavigationForGPX(gpxFile, mapActions, mapActivity); dismiss(); } } @@ -827,7 +827,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card segment = segments.get(0); } } - GpxDisplayItemType[] filterTypes = new GpxDisplayItemType[] {GpxDisplayItemType.TRACK_SEGMENT}; + GpxDisplayItemType[] filterTypes = new GpxDisplayItemType[]{GpxDisplayItemType.TRACK_SEGMENT}; List items = TrackDisplayHelper.flatten(displayHelper.getOriginalGroups(filterTypes)); if (segment != null && !Algorithms.isEmpty(items)) { SplitSegmentDialogFragment.showInstance(fragmentManager, displayHelper, items.get(0), segment); @@ -904,12 +904,11 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card } } - private void startNavigationForGPX(final GPXFile gpxFile, MapActivityActions mapActions) { - if (app.getRoutingHelper().isFollowingMode()) { + public static void startNavigationForGPX(final GPXFile gpxFile, MapActivityActions mapActions, final MapActivity mapActivity) { + if (mapActivity.getMyApplication().getRoutingHelper().isFollowingMode()) { mapActions.stopNavigationActionConfirm(null, new Runnable() { @Override public void run() { - MapActivity mapActivity = getMapActivity(); if (mapActivity != null) { mapActivity.getMapActions().enterRoutePlanningModeGivenGpx(gpxFile, null, null, null, true, true, MenuState.HEADER_ONLY); @@ -1130,7 +1129,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card public boolean onMenuItemClick(MenuItem item) { int i = item.getItemId(); if (i == R.id.action_edit) { - editSegment(segment); + editSegment(); return true; } else if (i == R.id.action_delete) { FragmentActivity activity = getActivity(); @@ -1164,7 +1163,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card app.getSettings().GPX_ROUTE_SEGMENT.set(selectedSegment); MapActivity mapActivity = getMapActivity(); if (mapActivity != null) { - startNavigationForGPX(gpxFile, mapActivity.getMapActions()); + startNavigationForGPX(gpxFile, mapActivity.getMapActions(), mapActivity); GPXRouteParamsBuilder paramsBuilder = app.getRoutingHelper().getCurrentGPXRoute(); if (paramsBuilder != null) { paramsBuilder.setSelectedSegment(selectedSegment); @@ -1174,7 +1173,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card } } - private void editSegment(TrkSegment segment) { + private void editSegment() { GPXFile gpxFile = getGpx(); openPlanRoute(new GpxData(gpxFile)); hide(); @@ -1219,7 +1218,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card @Override public void gpxSavingFinished(Exception errorMessage) { if (selectedGpxFile != null) { - List groups = displayHelper.getDisplayGroups(new GpxDisplayItemType[] {GpxDisplayItemType.TRACK_SEGMENT}); + List groups = displayHelper.getDisplayGroups(new GpxDisplayItemType[]{GpxDisplayItemType.TRACK_SEGMENT}); selectedGpxFile.setDisplayGroups(groups, app); selectedGpxFile.processPoints(app); } @@ -1313,7 +1312,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card } public static void showInstance(@NonNull MapActivity mapActivity, - @Nullable String path, + @Nullable String path, boolean showCurrentTrack, @Nullable final LatLon latLon, @Nullable final String returnScreenName, @@ -1332,7 +1331,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card } public static boolean showInstance(@NonNull MapActivity mapActivity, - @NonNull SelectedGpxFile selectedGpxFile, + @NonNull SelectedGpxFile selectedGpxFile, @Nullable LatLon latLon, @Nullable String returnScreenName, @Nullable String callingFragmentTag) { From 1cdf506212c4b18dc3e6281c4bb1c7a2511046e5 Mon Sep 17 00:00:00 2001 From: Hierax Swiftwing Date: Sun, 28 Mar 2021 13:40:21 +0000 Subject: [PATCH 63/74] Translated using Weblate (Serbian) Currently translated at 97.7% (3612 of 3695 strings) --- OsmAnd/res/values-sr/strings.xml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/OsmAnd/res/values-sr/strings.xml b/OsmAnd/res/values-sr/strings.xml index e23eae86cc..f3e3dd9e2b 100644 --- a/OsmAnd/res/values-sr/strings.xml +++ b/OsmAnd/res/values-sr/strings.xml @@ -1604,7 +1604,7 @@ Просек %1$d од %2$d Успон/Спуст - Време кретања + Време у покрету Макс/Мин Мин/Макс Туре @@ -3861,7 +3861,7 @@ Спорт Хитна помоћ Путовање - Треба да додате најмање две тачке + Додајте најмање две тачке Пријавите се на OpenStreetMap.org Пријавите се на OpenStreetMap.org Пријавите се помоћу ОпенСтритМап @@ -3979,4 +3979,13 @@ Сегмент %1$d Отпремљено %1$d од %2$d Одаберите измене за отпремање + Подврста + Возило + Бицикл + Аутомобил + Празно + Уреди путању + Преименуј путању + Сачувај и настави + Сви несачувани подаци ће бити изгубљени. \ No newline at end of file From 53106fd8e2eee9d5d40a021c5285a34a0ac7392c Mon Sep 17 00:00:00 2001 From: Ajeje Brazorf Date: Sun, 28 Mar 2021 16:37:49 +0000 Subject: [PATCH 64/74] Translated using Weblate (Sardinian) Currently translated at 99.2% (3669 of 3695 strings) --- OsmAnd/res/values-sc/strings.xml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/OsmAnd/res/values-sc/strings.xml b/OsmAnd/res/values-sc/strings.xml index f2fdc6c6d8..c11864da5a 100644 --- a/OsmAnd/res/values-sc/strings.xml +++ b/OsmAnd/res/values-sc/strings.xml @@ -844,7 +844,7 @@ Domo Amigos Logos - Àteru + Àteros Nùmene Categoria No, gràtzias @@ -4042,4 +4042,8 @@ Ischerta un\'àtera casta de coloratzione. Còmporas Distàntzia pro tocu + Sarva e sighi + Totu sos datos non sarvados s\'ant a pèrdere. + Ammustra su diàlogu de incumintzu + Dislinda unu colore pro sa modalidade pro sa mapa: %1$s. \ No newline at end of file From a557c6f2fc2a1896e5933e9fe85836fe3a3839c1 Mon Sep 17 00:00:00 2001 From: Hierax Swiftwing Date: Sun, 28 Mar 2021 13:55:23 +0000 Subject: [PATCH 65/74] Translated using Weblate (Serbian) Currently translated at 97.4% (3795 of 3894 strings) --- OsmAnd/res/values-sr/phrases.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/OsmAnd/res/values-sr/phrases.xml b/OsmAnd/res/values-sr/phrases.xml index f261e4e3f9..fae32d16dc 100644 --- a/OsmAnd/res/values-sr/phrases.xml +++ b/OsmAnd/res/values-sr/phrases.xml @@ -3863,4 +3863,8 @@ Сирена Медицинска сестра Мобилни агент за новац + Језеро + Река + Цепљење: Ковид 19 + Цепљење \ No newline at end of file From aa7e75bc4a3473df054cfc155ee7c523f7406a94 Mon Sep 17 00:00:00 2001 From: Hinagiku Zeppeki Date: Mon, 29 Mar 2021 01:37:06 +0000 Subject: [PATCH 66/74] Translated using Weblate (Japanese) Currently translated at 98.5% (3643 of 3695 strings) --- OsmAnd/res/values-ja/strings.xml | 92 +++++++++++++++++++------------- 1 file changed, 55 insertions(+), 37 deletions(-) diff --git a/OsmAnd/res/values-ja/strings.xml b/OsmAnd/res/values-ja/strings.xml index 212dfab6fe..8e969c342f 100644 --- a/OsmAnd/res/values-ja/strings.xml +++ b/OsmAnd/res/values-ja/strings.xml @@ -556,7 +556,7 @@ POIの更新は利用できません %1$d ファイルが残っています あと%1$d個のファイルがダウンロード可能です フルバージョン - ルートをキャンセル + ルートを破棄しますか? ナビゲーションの停止 選択した目的地、経由地点を削除します、よろしいですか? Wi-Fiに接続されていません。現在の接続を利用してインターネットからダウンロードを行いますか? @@ -1941,7 +1941,7 @@ POIの更新は利用できません 進行方向を振動で示して案内します。 OsmAnd Live更新でのナビゲーションを有効化します。 OsmAnd Liveナビゲーション - 目的地が設定されていません + アクセシビリティプラグイン: ターゲットが設定されていません 指定の道を外れた後にルート再計算を行わない 反対方向へ向かった場合ルートを変更しない ルートと反対方向に移動しても、自動的にルートの再計算をしないようにします。 @@ -2294,13 +2294,20 @@ POIの更新は利用できません  • GPX経路情報をアプリから直接OSMにアップロードできます  • POIを追加してOSMに直接アップロードできます(オフラインの場合は後で行うことができます) " - OsmAndはオープンソースで積極的に開発されています。バグを報告したり、翻訳を改善したり、新しい機能をコーディングすることで、誰もがアプリケーションの開発に貢献できます。このような開発者とユーザーとのやりとりによって、プロジェクトは継続的に改善されています。プロジェクトの進捗状況は、資金調達と新しい機能のテストに大きく左右されます。 -\n -\n地図のおおよそのエリアとその品質(※注 *の数が多いほど充実しています): -\n • 西ヨーロッパ: ****  • 東ヨーロッパ: ***  • ロシア: ***  • 北アメリカ: ***  • 南アメリカ: **  • アジア: **  • 日本、韓国: ***  • 中東: **  • アフリカ: **  • 南極: * -\n -\n 世界中のほとんどの国の地図がダウンロード可能です! -\n フランス、ドイツ、メキシコ、イギリス、スペイン、オランダ、アメリカ、ロシア、ブラジルなどの国の便利なナビゲーターを入手しましょう。 + OsmAndはオープンソースで現在も積極的に開発されています。バグを報告したり、翻訳を改善したり、新機能をコーディングしたりすることで、誰もがアプリの開発に貢献できます。またこのプロジェクトは、新機能のコーディングとテストに要する金銭面での貢献によっても支えられています。 +\n地図のおおよその範囲と品質(※注 *の数が多いほど内容が充実しています): +\n• 西ヨーロッパ:**** +\n• 東ヨーロッパ:*** +\n• ロシア:*** +\n• 北アメリカ:*** +\n• 南アメリカ:** +\n• アジア:** +\n• 日本、韓国:*** +\n• 中東:** +\n• アフリカ:** +\n• 南極大陸:* +\n世界中のほとんどの国がダウンロード可能です! +\nフランス、ドイツ、メキシコ、イギリス、スペイン、オランダ、アメリカ、ロシア、ブラジルなど、各国において頼りとなるナビゲーターを手に入れましょう。 OsmAnd(OSM Automated Navigation Directions~自動ナビ案内)は、『無償利用可、ワールドワイド対応、高品質のOSM』データを使用した、地図&ナビゲーションアプリです。 \n音声と視覚による案内、POI(Point Of Interest~興味的地点)表示、GPX経路の作成と管理、等高線を使った地形情報(要プラグイン)、ドライブ、サイクリング、徒歩移動各移動手段別のモード、OSMの編集等々に対応。 \n OsmAnd+は有料のアプリケーションです。購入することで同プロジェクトの資金、新機能開発への援助となり、最新アップデートも利用可能になります。 @@ -2347,7 +2354,7 @@ POIの更新は利用できません マップ画面でのOSMメモの表示/非表示を切り替えるボタンです。 距離順で並べ替え お気に入りで検索 - 標高の高低をグラデーション表示するには、陰影起伏図(Hillshade Overlay)マップのダウンロードが必要です。 + 標高の高低をグラデーション表示するには、\'Hillshade(陰影起伏図)\'マップのダウンロードが必要です。 等高線プラグイン『Contour lines plugin — OsmAnd』をインストールすることで、陰影起伏図(高低差を陰影で表したもの)をマップ上に表示できます。 ズームレベルを非表示 この地域用の等高線マップをダウンロードします。 @@ -2369,20 +2376,20 @@ POIの更新は利用できません 検索範囲を拡大 再検索 配色 - " 地図のおおよそのエリアとその品質(※注 *の数が多いほど充実しています): -\n • 西ヨーロッパ: **** -\n • 東ヨーロッパ: *** -\n • ロシア: *** -\n • 北米: *** -\n • 南アメリカ: ** -\n • アジア: ** -\n • 日本、韓国: *** -\n • 中東: ** -\n • アフリカ: ** -\n • 南極: * -\n -\n 世界中のほとんどの国の地図がダウンロード可能です! -\n アフガニスタンからジンバブエ、オーストラリアからアメリカ、 アルゼンチン、ブラジル、カナダ、フランス、ドイツ、メキシコ、イギリス、スペイン、... " + 地図のおおよその範囲と品質:(※注 *の数が多いほど内容が充実しています): +\n• 西ヨーロッパ:**** +\n• 東ヨーロッパ:*** +\n• ロシア:*** +\n• 北アメリカ:*** +\n• 南アメリカ: ** +\n• アジア:** +\n• 日本、韓国:*** +\n• 中東:** +\n•アフリカ:** +\n•南極大陸:* +\n世界中のほとんどの国がダウンロード可能です! +\nアフガニスタンからジンバブエへ、オーストラリアからアメリカへも…またアルゼンチン、ブラジル、カナダ、フランス、ドイツ、メキシコ、イギリス、スペイン等々… +\n " 直接OSMに寄与 • データ、バグの報告ができます @@ -2812,7 +2819,7 @@ POIの更新は利用できません By OsmAnd プランと料金 月間 - 3ヶ月間 + 3ヶ月毎 年間 %1$s / 月 %1$.2f %2$s / 月 @@ -3489,9 +3496,9 @@ POIの更新は利用できません 四角形 最小 マップ内公共交通機関の表示/非表示を切り替えるボタンです。 - POIの作成/編集 + POIの作成・編集 駐車位置 - お気に入りの追加/編集 + お気に入りの追加・編集 アイテム順序を初期状態に戻します 編集に戻る 選択したプロファイルを切り替えるボタンです。 @@ -3518,7 +3525,7 @@ POIの更新は利用できません %1$s / %2$s お支払いは、購入の確認後にGoogle Playアカウントに請求されます。 \n -\nサブスクリプションは更新日より前にキャンセルしない限り、自動的に更新されます。アカウントの更新期間(月/ 3ヶ月/年)に準じた更新日に請求されます。 +\nサブスクリプションは更新日前にキャンセルしない限り、自動的に延長されます。アカウントには更新日に更新期間(月/ 3ヶ月/年)に応じた金額が請求されます。 \n \nサブスクリプションの管理およびキャンセルはGoogle Playの設定からおこなえます。 POIのタイプで検索 @@ -3661,7 +3668,7 @@ POIの更新は利用できません 車高を入力してください。一部のルートにおいては、車高の高い車両では通行できない場合があります。 車両の重量を入力してください。一部のルートにおいては、大型車両では通行できない場合があります。 車の長さを入力してください。一部のルートにおいては、長い車両では通行できない場合があります。 - 常に + 常時 画面の制御 現在無効。 \'画面を表示する時間\'の下にある\'画面を常に表示\'への設定が必要です。 画面オフを維持 @@ -3725,9 +3732,9 @@ POIの更新は利用できません インラインスケート 最も近い目的地を削除 地点の名前を入力してください - ルート上の現在の目的地点が削除されます。目的地に着いた場合はナビは停止します。 + ルート上の次の目的地を削除します。それが最終目的地の場合は、ナビゲーションが停止します。 Wikipediaマップのダウンロード - Wikipediaから興味のあるポイントに関する情報を取得します。それがあなたのモバイルオフラインガイドになります - Wikipediaプラグインを有効にして、周囲の名所に関する記事を楽しんでください。 + 場所や目的地に関する記事が掲載されたWikipediaのオフラインポケットガイドを活用し、ランドマークや観光名所の詳しい情報を入手しましょう。 追加した地点はマップ上に表示されません。選択したグループは非表示になっているため、\"%s\"から見つけることができます。 新しい経路ファイルとして保存 経路ファイルを追加 @@ -3762,8 +3769,8 @@ POIの更新は利用できません 次年度以降 %1$s 初%2$s度 %1$s 初%2$s度 %1$s - ルート記録を一時停止 - ルート記録を続行 + 旅程の記録を一時停止 + 旅程の記録を続行 システムのデフォルト 以後のすべてのセグメントは、選択したプロファイルを使用して再計算されます。 以後のすべてのセグメント @@ -3794,7 +3801,7 @@ POIの更新は利用できません %s個の経路ファイルが選択されました ファイル名 (最近使用したアプリを介して) OsmAndを終了すると、GPXの記録が一時停止されます(バックグラウンドサービスインジケーターがAndroid通知バーから消えます。) - 一般的な経路記録の記録間隔を定義します(マップ画面の\'GPX\'ボタンを使用) + 一般的な経路記録の記録間隔を指定します(マップウィジェットの\'旅程の記録\'ボタンでONにします) 保存されました 最終更新日 名称: 降順(Z-A) @@ -4055,9 +4062,20 @@ POIの更新は利用できません 開始・終了アイコン \'等高線(Contour lines)\'をご購入いただきありがとうございます サブスクリプションは選択した期間に応じて課金されます。 AppGalleryからいつでもキャンセルできます。 - 購入確認後に利用者のAppGalleryアカウントへ請求されます。 + お支払いは、購入の確認後にAppGalleryアカウントへ請求されます。 \n -\nサブスクリプションは更新日前にキャンセルされない限り自動的に延長されます。アカウントには更新日に更新期間分(月/ 3ヶ月/年)の金額が請求されます。 +\nサブスクリプションは更新日前にキャンセルされない限り自動的に延長されます。アカウントには更新日に更新期間(月/ 3ヶ月/年)に応じた金額が請求されます。 \n -\nAppGallery設定でサブスクリプションの管理およびキャンセルができます。 +\nサブスクリプションの管理およびキャンセルはAppGalleryの設定からおこなえます。 + ドイツ語(話し言葉) + MGRS(Military Grid Reference System) + 新着情報 + スノーモービルレジャー用の専用道路や通路です。 + MGRS(Military Grid Reference System) + OsmAndは、UTM NATO形式類似のMGRSを使用します。 + 凡例 + %2$sの%1$s + 基本前進のみの車椅子 + 通常色 + 逆方向の場合 \ No newline at end of file From 8ceef9af42a25db1c092fe2ad03f5bfcb5f9e19b Mon Sep 17 00:00:00 2001 From: Ahmad Alfrhood Date: Mon, 29 Mar 2021 08:04:00 +0000 Subject: [PATCH 67/74] Translated using Weblate (Arabic) Currently translated at 100.0% (3695 of 3695 strings) --- OsmAnd/res/values-ar/strings.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OsmAnd/res/values-ar/strings.xml b/OsmAnd/res/values-ar/strings.xml index d697e4909f..4cb4b38f94 100644 --- a/OsmAnd/res/values-ar/strings.xml +++ b/OsmAnd/res/values-ar/strings.xml @@ -1010,7 +1010,7 @@ المفضلة تم حفظها بنجاح إلى {0} لم يتم العثور على نقاط أماكن مفضلة للقيام بالاحتفاظ بها تم تعديل النقطة المفضلة - لا وجود لأية نقطة مفضلة + لا يوجد نقاط مفضلة تعديل المفضلة حذف المفضلة إزالة النقطة المفضلة \'%s\' ؟ @@ -3536,7 +3536,7 @@ مربع دائرة تحديد الشكل - تحديد المجموعة + تحديد مجموعة إضافة وصف حذف الوصف زر لإظهار طبقة التضاريس أو إخفائها على الخريطة. From 03a450f9e2bfd72303831f4ee9129ada47defc3e Mon Sep 17 00:00:00 2001 From: androiddevkotlin <64539346+androiddevkotlin@users.noreply.github.com> Date: Mon, 29 Mar 2021 12:49:11 +0300 Subject: [PATCH 68/74] WeakReference - mapActivity, import header --- .../MapRouteInfoMenuFragment.java | 22 +++++++++---------- .../osmand/plus/track/TrackMenuFragment.java | 6 +++-- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenuFragment.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenuFragment.java index 8710c934dd..b60074f0b4 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenuFragment.java @@ -31,6 +31,8 @@ import net.osmand.plus.track.TrackMenuFragment; import net.osmand.plus.track.TrackSelectSegmentBottomSheet; import net.osmand.plus.widgets.TextViewExProgress; +import static net.osmand.plus.track.TrackMenuFragment.startNavigationForGPX; + public class MapRouteInfoMenuFragment extends ContextMenuFragment implements TrackSelectSegmentBottomSheet.OnSegmentSelectedListener { public static final String TAG = MapRouteInfoMenuFragment.class.getName(); @@ -508,18 +510,16 @@ public class MapRouteInfoMenuFragment extends ContextMenuFragment implements Tra @Override public void onSegmentSelect(GPXUtilities.GPXFile gpxFile, int selectedSegment) { - if (getMyApplication() != null) { - getMyApplication().getSettings().GPX_ROUTE_SEGMENT.set(selectedSegment); - MapActivity mapActivity = getMapActivity(); - if (mapActivity != null) { - TrackMenuFragment.startNavigationForGPX(gpxFile, mapActivity.getMapActions(), mapActivity); - GPXRouteParams.GPXRouteParamsBuilder paramsBuilder = getMyApplication().getRoutingHelper().getCurrentGPXRoute(); - if (paramsBuilder != null) { - paramsBuilder.setSelectedSegment(selectedSegment); - getMyApplication().getRoutingHelper().onSettingsChanged(true); - } - dismiss(); + MapActivity mapActivity = getMapActivity(); + if (mapActivity != null) { + mapActivity.getMyApplication().getSettings().GPX_ROUTE_SEGMENT.set(selectedSegment); + startNavigationForGPX(gpxFile, mapActivity.getMapActions(), mapActivity); + GPXRouteParams.GPXRouteParamsBuilder paramsBuilder = getMyApplication().getRoutingHelper().getCurrentGPXRoute(); + if (paramsBuilder != null) { + paramsBuilder.setSelectedSegment(selectedSegment); + getMyApplication().getRoutingHelper().onSettingsChanged(true); } + dismiss(); } } } \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java b/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java index f5c52a11ce..b2d3aaa7dd 100644 --- a/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java @@ -906,11 +906,13 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card public static void startNavigationForGPX(final GPXFile gpxFile, MapActivityActions mapActions, final MapActivity mapActivity) { if (mapActivity.getMyApplication().getRoutingHelper().isFollowingMode()) { + final WeakReference activityRef = new WeakReference<>(mapActivity); mapActions.stopNavigationActionConfirm(null, new Runnable() { @Override public void run() { - if (mapActivity != null) { - mapActivity.getMapActions().enterRoutePlanningModeGivenGpx(gpxFile, null, + MapActivity activity = activityRef.get(); + if (activity != null) { + activity.getMapActions().enterRoutePlanningModeGivenGpx(gpxFile, null, null, null, true, true, MenuState.HEADER_ONLY); } } From 78175e8a1cd269cb6609828d9e8bef237ee04294 Mon Sep 17 00:00:00 2001 From: androiddevkotlin <64539346+androiddevkotlin@users.noreply.github.com> Date: Mon, 29 Mar 2021 13:39:36 +0300 Subject: [PATCH 69/74] Import header, storage path replace in UI display --- .../main/java/com/jwetherell/openmap/common/MGRSPoint.java | 4 ++-- .../plus/settings/datastorage/DataStorageFragment.java | 5 ++++- .../osmand/plus/settings/datastorage/DataStorageHelper.java | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/OsmAnd-java/src/main/java/com/jwetherell/openmap/common/MGRSPoint.java b/OsmAnd-java/src/main/java/com/jwetherell/openmap/common/MGRSPoint.java index be6793bef8..519fc9d171 100644 --- a/OsmAnd-java/src/main/java/com/jwetherell/openmap/common/MGRSPoint.java +++ b/OsmAnd-java/src/main/java/com/jwetherell/openmap/common/MGRSPoint.java @@ -699,8 +699,8 @@ public class MGRSPoint extends ZonedUTMPoint { String zero = ""; } - all.add(String.format(java.util.Locale.US,"%0" + accuracy + "d", roundedEasting)); - all.add(String.format(java.util.Locale.US,"%0" + accuracy + "d", roundedNorthing)); + all.add(String.format(Locale.US,"%0" + accuracy + "d", roundedEasting)); + all.add(String.format(Locale.US,"%0" + accuracy + "d", roundedNorthing)); break; } } diff --git a/OsmAnd/src/net/osmand/plus/settings/datastorage/DataStorageFragment.java b/OsmAnd/src/net/osmand/plus/settings/datastorage/DataStorageFragment.java index 7fd96b8185..e25a4a6cc0 100644 --- a/OsmAnd/src/net/osmand/plus/settings/datastorage/DataStorageFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/datastorage/DataStorageFragment.java @@ -46,6 +46,7 @@ import java.util.ArrayList; import static net.osmand.plus.settings.datastorage.DataStorageHelper.INTERNAL_STORAGE; import static net.osmand.plus.settings.datastorage.DataStorageHelper.MANUALLY_SPECIFIED; import static net.osmand.plus.settings.datastorage.DataStorageHelper.OTHER_MEMORY; +import static net.osmand.plus.settings.datastorage.DataStorageHelper.SHARED_STORAGE; import static net.osmand.plus.settings.datastorage.DataStorageHelper.TILES_MEMORY; import static net.osmand.plus.settings.bottomsheets.ChangeDataStorageBottomSheet.CHOSEN_DIRECTORY; import static net.osmand.plus.settings.bottomsheets.ChangeDataStorageBottomSheet.MOVE_DATA; @@ -226,7 +227,7 @@ public class DataStorageFragment extends BaseSettingsFragment implements DataSto int defaultIconColor = isNightMode() ? R.color.icon_color_default_dark : R.color.icon_color_default_light; int chosenIconColor = isNightMode() ? R.color.icon_color_osmand_dark : R.color.icon_color_osmand_light; - Drawable icon = app.getUIUtilities().getIcon(item.getIconResId(), + Drawable icon = app.getUIUtilities().getIcon(item.getIconResId(), isCurrent ? chosenIconColor : defaultIconColor); ivIcon.setImageDrawable(icon); @@ -249,6 +250,8 @@ public class DataStorageFragment extends BaseSettingsFragment implements DataSto } if (currentKey.equals(INTERNAL_STORAGE)) { tvAdditionalDescription.setText(item.getDescription()); + } else if(currentKey.equals(SHARED_STORAGE)){ + tvAdditionalDescription.setText(String.format("\u200E%s", item.getDirectory())); } else { tvAdditionalDescription.setText(item.getDirectory()); } diff --git a/OsmAnd/src/net/osmand/plus/settings/datastorage/DataStorageHelper.java b/OsmAnd/src/net/osmand/plus/settings/datastorage/DataStorageHelper.java index b292a02e0d..67fd73897e 100644 --- a/OsmAnd/src/net/osmand/plus/settings/datastorage/DataStorageHelper.java +++ b/OsmAnd/src/net/osmand/plus/settings/datastorage/DataStorageHelper.java @@ -106,7 +106,7 @@ public class DataStorageHelper { //shared storage dir = settings.getDefaultInternalStorage(); - path = "\u200e" + dir.getAbsolutePath(); + path = dir.getAbsolutePath(); iconId = R.drawable.ic_action_phone; StorageItem sharedStorageItem = StorageItem.builder() From a77362c5e013536a112862cb18327265bc17b523 Mon Sep 17 00:00:00 2001 From: androiddevkotlin <64539346+androiddevkotlin@users.noreply.github.com> Date: Mon, 29 Mar 2021 14:43:14 +0300 Subject: [PATCH 70/74] BidiFormatter --- .../datastorage/DataStorageFragment.java | 39 +++++++++++-------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/settings/datastorage/DataStorageFragment.java b/OsmAnd/src/net/osmand/plus/settings/datastorage/DataStorageFragment.java index e25a4a6cc0..41c58ebd7f 100644 --- a/OsmAnd/src/net/osmand/plus/settings/datastorage/DataStorageFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/datastorage/DataStorageFragment.java @@ -6,7 +6,9 @@ import android.content.Context; import android.content.DialogInterface; import android.graphics.drawable.Drawable; import android.os.AsyncTask; +import android.os.Build; import android.os.Bundle; +import android.text.BidiFormatter; import android.view.View; import android.widget.ImageView; import android.widget.TextView; @@ -24,12 +26,12 @@ import androidx.preference.PreferenceViewHolder; import net.osmand.AndroidUtils; import net.osmand.FileUtils; import net.osmand.plus.OsmandApplication; -import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.OsmandActionBarActivity; import net.osmand.plus.download.DownloadActivity; +import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.settings.bottomsheets.ChangeDataStorageBottomSheet; import net.osmand.plus.settings.bottomsheets.SelectFolderBottomSheet; import net.osmand.plus.settings.datastorage.item.MemoryItem; @@ -43,20 +45,20 @@ import java.io.File; import java.text.DecimalFormat; import java.util.ArrayList; +import static net.osmand.plus.settings.bottomsheets.ChangeDataStorageBottomSheet.CHOSEN_DIRECTORY; +import static net.osmand.plus.settings.bottomsheets.ChangeDataStorageBottomSheet.MOVE_DATA; +import static net.osmand.plus.settings.bottomsheets.SelectFolderBottomSheet.NEW_PATH; +import static net.osmand.plus.settings.bottomsheets.SelectFolderBottomSheet.PATH_CHANGED; import static net.osmand.plus.settings.datastorage.DataStorageHelper.INTERNAL_STORAGE; import static net.osmand.plus.settings.datastorage.DataStorageHelper.MANUALLY_SPECIFIED; import static net.osmand.plus.settings.datastorage.DataStorageHelper.OTHER_MEMORY; import static net.osmand.plus.settings.datastorage.DataStorageHelper.SHARED_STORAGE; import static net.osmand.plus.settings.datastorage.DataStorageHelper.TILES_MEMORY; -import static net.osmand.plus.settings.bottomsheets.ChangeDataStorageBottomSheet.CHOSEN_DIRECTORY; -import static net.osmand.plus.settings.bottomsheets.ChangeDataStorageBottomSheet.MOVE_DATA; -import static net.osmand.plus.settings.bottomsheets.SelectFolderBottomSheet.NEW_PATH; -import static net.osmand.plus.settings.bottomsheets.SelectFolderBottomSheet.PATH_CHANGED; public class DataStorageFragment extends BaseSettingsFragment implements DataStorageHelper.UpdateMemoryInfoUIAdapter { public final static int PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE = 500; public final static int UI_REFRESH_TIME_MS = 500; - + private final static String CHANGE_DIRECTORY_BUTTON = "change_directory"; private final static String OSMAND_USAGE = "osmand_usage"; @@ -68,7 +70,7 @@ public class DataStorageFragment extends BaseSettingsFragment implements DataSto private String tmpManuallySpecifiedPath; private DataStorageHelper dataStorageHelper; private boolean calculateTilesBtnPressed; - + private RefreshUsedMemoryTask calculateMemoryTask; private RefreshUsedMemoryTask calculateTilesMemoryTask; @@ -85,10 +87,10 @@ public class DataStorageFragment extends BaseSettingsFragment implements DataSto } super.onCreate(savedInstanceState); } - + @Override protected void setupPreferences() { - + PreferenceScreen screen = getPreferenceScreen(); if (screen == null || dataStorageHelper == null) { @@ -203,13 +205,13 @@ public class DataStorageFragment extends BaseSettingsFragment implements DataSto int primaryTextColorResId = isNightMode() ? R.color.text_color_primary_dark : R.color.text_color_primary_light; int primaryTextColor = ContextCompat.getColor(app, primaryTextColorResId); - String[] memoryUnitsFormats = new String[] { + String[] memoryUnitsFormats = new String[]{ getString(R.string.shared_string_memory_kb_desc), getString(R.string.shared_string_memory_mb_desc), getString(R.string.shared_string_memory_gb_desc), getString(R.string.shared_string_memory_tb_desc) }; - + final View itemView = holder.itemView; if (preference instanceof CheckBoxPreference) { StorageItem item = dataStorageHelper.getStorage(key); @@ -250,8 +252,13 @@ public class DataStorageFragment extends BaseSettingsFragment implements DataSto } if (currentKey.equals(INTERNAL_STORAGE)) { tvAdditionalDescription.setText(item.getDescription()); - } else if(currentKey.equals(SHARED_STORAGE)){ - tvAdditionalDescription.setText(String.format("\u200E%s", item.getDirectory())); + } else if (currentKey.equals(SHARED_STORAGE)) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { + BidiFormatter rtlFormatter = BidiFormatter.getInstance(); + tvAdditionalDescription.setText(rtlFormatter.unicodeWrap(item.getDirectory())); + } else { + tvAdditionalDescription.setText(String.format("\u200E%s", item.getDirectory())); + } } else { tvAdditionalDescription.setText(item.getDirectory()); } @@ -264,7 +271,7 @@ public class DataStorageFragment extends BaseSettingsFragment implements DataSto AndroidUtils.setBackground(itemView, drawable); icon.setVisibility(View.INVISIBLE); title.setText(R.string.shared_string_change); - } else if(key.equals(OSMAND_USAGE)) { + } else if (key.equals(OSMAND_USAGE)) { long totalUsageBytes = dataStorageHelper.getTotalUsedBytes(); TextView tvSummary = itemView.findViewById(R.id.summary); tvSummary.setText(DataStorageHelper.getFormattedMemoryInfo(totalUsageBytes, memoryUnitsFormats)); @@ -427,7 +434,7 @@ public class DataStorageFragment extends BaseSettingsFragment implements DataSto refreshDataInfo(); updateAllSettings(); } - + private void refreshDataInfo() { calculateTilesBtnPressed = false; dataStorageHelper = new DataStorageHelper(app); @@ -463,7 +470,7 @@ public class DataStorageFragment extends BaseSettingsFragment implements DataSto public void onMemoryInfoUpdate() { updateAllSettings(); } - + @Override public void onFinishUpdating(String tag) { updateAllSettings(); From d190da742acd61d226dfe25b24b2b29cd1786136 Mon Sep 17 00:00:00 2001 From: cepprice Date: Mon, 29 Mar 2021 18:13:56 +0500 Subject: [PATCH 71/74] Huawei fix and small corrections --- .../osmand/plus/inapp/InAppPurchasesImpl.java | 5 +++++ .../settings/fragments/PurchasesFragment.java | 16 ++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/OsmAnd/src-huawei/net/osmand/plus/inapp/InAppPurchasesImpl.java b/OsmAnd/src-huawei/net/osmand/plus/inapp/InAppPurchasesImpl.java index 4ed0021b6f..59d97daed0 100644 --- a/OsmAnd/src-huawei/net/osmand/plus/inapp/InAppPurchasesImpl.java +++ b/OsmAnd/src-huawei/net/osmand/plus/inapp/InAppPurchasesImpl.java @@ -165,6 +165,11 @@ public class InAppPurchasesImpl extends InAppPurchases { this.info = info; } + @Override + public int getPeriodTypeString() { + return R.string.monthly_subscription; + } + @Override public String getDefaultPrice(Context ctx) { return ""; diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/PurchasesFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/PurchasesFragment.java index d08cf6f892..e3bbb85f04 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/PurchasesFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/PurchasesFragment.java @@ -46,13 +46,12 @@ public class PurchasesFragment extends BaseOsmAndFragment implements InAppPurcha private static final String OSMAND_PURCHASES_URL = "https://docs.osmand.net/en/main@latest/osmand/purchases"; private OsmandApplication app; - private Context context; private InAppPurchaseHelper purchaseHelper; - private View mainView; - ViewGroup cardsContainer; + private ViewGroup cardsContainer; private SubscriptionsCard subscriptionsCard; + private boolean nightMode; private Boolean isPaidVersion; public static boolean showInstance(FragmentManager fragmentManager) { @@ -77,12 +76,11 @@ public class PurchasesFragment extends BaseOsmAndFragment implements InAppPurcha @Override public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { app = getMyApplication(); - context = requireContext(); isPaidVersion = Version.isPaidVersion(app); - final boolean nightMode = !app.getSettings().isLightContent(); - LayoutInflater themedInflater = UiUtilities.getInflater(context, nightMode); + nightMode = !app.getSettings().isLightContent(); + LayoutInflater themedInflater = UiUtilities.getInflater(getContext(), nightMode); - mainView = themedInflater.inflate(R.layout.purchases_layout, container, false); + View mainView = themedInflater.inflate(R.layout.purchases_layout, container, false); AndroidUtils.addStatusBarPadding21v(getActivity(), mainView); createToolbar(mainView, nightMode); cardsContainer = mainView.findViewById(R.id.cards_container); @@ -148,7 +146,9 @@ public class PurchasesFragment extends BaseOsmAndFragment implements InAppPurcha icon.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - WikipediaDialogFragment.showFullArticle(context, Uri.parse(OSMAND_PURCHASES_URL), nightMode); + if (getContext() != null) { + WikipediaDialogFragment.showFullArticle(getContext(), Uri.parse(OSMAND_PURCHASES_URL), nightMode); + } } }); ImageButton backButton = toolbar.findViewById(R.id.close_button); From 0b361afaec5fe7f70a9ca5cb16688b9cdabc9b43 Mon Sep 17 00:00:00 2001 From: androiddevkotlin <64539346+androiddevkotlin@users.noreply.github.com> Date: Mon, 29 Mar 2021 16:44:38 +0300 Subject: [PATCH 72/74] Quick action list fix for show/hide for editable items --- .../osmand/plus/quickaction/QuickActionListFragment.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/quickaction/QuickActionListFragment.java b/OsmAnd/src/net/osmand/plus/quickaction/QuickActionListFragment.java index ec282deb4c..b750aac1a1 100644 --- a/OsmAnd/src/net/osmand/plus/quickaction/QuickActionListFragment.java +++ b/OsmAnd/src/net/osmand/plus/quickaction/QuickActionListFragment.java @@ -593,7 +593,13 @@ public class QuickActionListFragment extends BaseOsmAndFragment List actions = getQuickActions(); int actionGlobalPosition = actions.indexOf(action); int actionPosition = actionGlobalPosition % ITEMS_IN_GROUP + 1; - h.title.setText(action.getName(app)); + int test = action.getType(); + if (test == 5) { + String prefAction = getString(R.string.quick_action_show_hide_title); + h.title.setText(getString(R.string.ltr_or_rtl_combine_via_dash, prefAction, action.getName(app))); + } else { + h.title.setText(action.getName(app)); + } h.subTitle.setText(getResources().getString(R.string.quick_action_item_action, actionPosition)); h.icon.setImageDrawable(getContentIcon(action.getIconRes(app))); From 896ae118789a6b49b48a185ea13e66a52da9ecab Mon Sep 17 00:00:00 2001 From: androiddevkotlin <64539346+androiddevkotlin@users.noreply.github.com> Date: Mon, 29 Mar 2021 19:34:44 +0300 Subject: [PATCH 73/74] Add constant, rename variable --- .../osmand/plus/quickaction/QuickActionListFragment.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/quickaction/QuickActionListFragment.java b/OsmAnd/src/net/osmand/plus/quickaction/QuickActionListFragment.java index b750aac1a1..6a9cd6c310 100644 --- a/OsmAnd/src/net/osmand/plus/quickaction/QuickActionListFragment.java +++ b/OsmAnd/src/net/osmand/plus/quickaction/QuickActionListFragment.java @@ -72,6 +72,8 @@ public class QuickActionListFragment extends BaseOsmAndFragment private static final int ITEMS_IN_GROUP = 6; + public static final int GROUP_POI_ID = 5; + private RecyclerView rv; private FloatingActionButton fab; private View bottomPanel; @@ -593,8 +595,8 @@ public class QuickActionListFragment extends BaseOsmAndFragment List actions = getQuickActions(); int actionGlobalPosition = actions.indexOf(action); int actionPosition = actionGlobalPosition % ITEMS_IN_GROUP + 1; - int test = action.getType(); - if (test == 5) { + int actionType = action.getType(); + if (actionType == GROUP_POI_ID) { String prefAction = getString(R.string.quick_action_show_hide_title); h.title.setText(getString(R.string.ltr_or_rtl_combine_via_dash, prefAction, action.getName(app))); } else { From 5e1a5e8d3eaebea78e2baec9bea6fc4863152cf5 Mon Sep 17 00:00:00 2001 From: androiddevkotlin <64539346+androiddevkotlin@users.noreply.github.com> Date: Mon, 29 Mar 2021 20:43:41 +0300 Subject: [PATCH 74/74] Review --- .../plus/quickaction/QuickActionListFragment.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/quickaction/QuickActionListFragment.java b/OsmAnd/src/net/osmand/plus/quickaction/QuickActionListFragment.java index 6a9cd6c310..28981e5db6 100644 --- a/OsmAnd/src/net/osmand/plus/quickaction/QuickActionListFragment.java +++ b/OsmAnd/src/net/osmand/plus/quickaction/QuickActionListFragment.java @@ -72,8 +72,6 @@ public class QuickActionListFragment extends BaseOsmAndFragment private static final int ITEMS_IN_GROUP = 6; - public static final int GROUP_POI_ID = 5; - private RecyclerView rv; private FloatingActionButton fab; private View bottomPanel; @@ -595,12 +593,12 @@ public class QuickActionListFragment extends BaseOsmAndFragment List actions = getQuickActions(); int actionGlobalPosition = actions.indexOf(action); int actionPosition = actionGlobalPosition % ITEMS_IN_GROUP + 1; - int actionType = action.getType(); - if (actionType == GROUP_POI_ID) { - String prefAction = getString(R.string.quick_action_show_hide_title); + String name = action.getName(app); + if (action.getActionNameRes() != 0 && !name.contains(getString(action.getActionNameRes()))) { + String prefAction = getString(action.getActionNameRes()); h.title.setText(getString(R.string.ltr_or_rtl_combine_via_dash, prefAction, action.getName(app))); } else { - h.title.setText(action.getName(app)); + h.title.setText(name); } h.subTitle.setText(getResources().getString(R.string.quick_action_item_action, actionPosition)); h.icon.setImageDrawable(getContentIcon(action.getIconRes(app)));