From 324397cc25290f167bd07ae57faf6a36bf7ce102 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Mon, 19 Apr 2021 17:51:21 +0300 Subject: [PATCH] Small fixes --- OsmAnd/res/layout/subscriptions_card.xml | 72 +------------------ OsmAnd/src/net/osmand/plus/UiUtilities.java | 6 +- .../plus/activities/PluginInfoFragment.java | 2 +- .../plus/activities/PluginsFragment.java | 2 +- .../fragments/BaseSettingsFragment.java | 3 +- .../settings/fragments/PurchasesFragment.java | 16 ++--- .../settings/fragments/SubscriptionsCard.java | 44 +----------- .../TroubleshootingOrPurchasingCard.java | 10 +-- 8 files changed, 23 insertions(+), 132 deletions(-) diff --git a/OsmAnd/res/layout/subscriptions_card.xml b/OsmAnd/res/layout/subscriptions_card.xml index d8ec722375..7d2058a487 100644 --- a/OsmAnd/res/layout/subscriptions_card.xml +++ b/OsmAnd/res/layout/subscriptions_card.xml @@ -1,8 +1,6 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + diff --git a/OsmAnd/src/net/osmand/plus/UiUtilities.java b/OsmAnd/src/net/osmand/plus/UiUtilities.java index 886b1c7f8c..cba86b7f8b 100644 --- a/OsmAnd/src/net/osmand/plus/UiUtilities.java +++ b/OsmAnd/src/net/osmand/plus/UiUtilities.java @@ -442,11 +442,11 @@ public class UiUtilities { } catch (Throwable e) { } } - public static void rotateImageByLayoutDirection(ImageView image, Context context) { - if (image == null || context == null) { + public static void rotateImageByLayoutDirection(ImageView image) { + if (image == null) { return; } - int rotation = AndroidUtils.getLayoutDirection(context) == ViewCompat.LAYOUT_DIRECTION_RTL ? 180 : 0; + int rotation = AndroidUtils.getLayoutDirection(image.getContext()) == ViewCompat.LAYOUT_DIRECTION_RTL ? 180 : 0; image.setRotationY(rotation); } diff --git a/OsmAnd/src/net/osmand/plus/activities/PluginInfoFragment.java b/OsmAnd/src/net/osmand/plus/activities/PluginInfoFragment.java index 90fccc5c3e..5d32ee228d 100644 --- a/OsmAnd/src/net/osmand/plus/activities/PluginInfoFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/PluginInfoFragment.java @@ -109,7 +109,7 @@ public class PluginInfoFragment extends BaseOsmAndFragment implements PluginStat } } }); - UiUtilities.rotateImageByLayoutDirection(closeButton, app); + UiUtilities.rotateImageByLayoutDirection(closeButton); Drawable pluginImage = plugin.getAssetResourceImage(); if (pluginImage != null) { diff --git a/OsmAnd/src/net/osmand/plus/activities/PluginsFragment.java b/OsmAnd/src/net/osmand/plus/activities/PluginsFragment.java index 5b6c302d84..54439daefa 100644 --- a/OsmAnd/src/net/osmand/plus/activities/PluginsFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/PluginsFragment.java @@ -101,7 +101,7 @@ public class PluginsFragment extends BaseOsmAndFragment implements PluginStateLi } } }); - UiUtilities.rotateImageByLayoutDirection(closeButton, app); + UiUtilities.rotateImageByLayoutDirection(closeButton); adapter = new PluginsListAdapter(requireContext()); diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/BaseSettingsFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/BaseSettingsFragment.java index f89afd91a2..73c62eacfe 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/BaseSettingsFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/BaseSettingsFragment.java @@ -492,8 +492,7 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl } }); if (closeButton instanceof ImageView) { - UiUtilities.rotateImageByLayoutDirection( - (ImageView) closeButton, app); + UiUtilities.rotateImageByLayoutDirection((ImageView) closeButton); } } diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/PurchasesFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/PurchasesFragment.java index 8cd4d61179..9c60348d65 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/PurchasesFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/PurchasesFragment.java @@ -10,6 +10,11 @@ import android.widget.ImageButton; import android.widget.ImageView; 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; @@ -30,11 +35,6 @@ import net.osmand.util.Algorithms; import org.apache.commons.logging.Log; -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 { private static final Log log = PlatformUtil.getLog(PurchasesFragment.class); @@ -152,7 +152,7 @@ public class PurchasesFragment extends BaseOsmAndFragment implements InAppPurcha } }); ImageButton backButton = toolbar.findViewById(R.id.close_button); - UiUtilities.rotateImageByLayoutDirection(backButton, getContext()); + UiUtilities.rotateImageByLayoutDirection(backButton); backButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -198,9 +198,7 @@ public class PurchasesFragment extends BaseOsmAndFragment implements InAppPurcha @Override public void onSearchResult(CountrySelectionFragment.CountryItem name) { - if (subscriptionsCard != null) { - subscriptionsCard.onSupportRegionSelected(name); - } + } @Override diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/SubscriptionsCard.java b/OsmAnd/src/net/osmand/plus/settings/fragments/SubscriptionsCard.java index 12c34ede1e..0957969ccd 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/SubscriptionsCard.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/SubscriptionsCard.java @@ -5,30 +5,26 @@ import android.net.Uri; import android.view.View; import android.view.ViewGroup; import android.widget.LinearLayout; -import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.fragment.app.Fragment; import net.osmand.AndroidUtils; 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.liveupdates.CountrySelectionFragment; import net.osmand.plus.liveupdates.LiveUpdatesFragment; 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 androidx.annotation.NonNull; -import androidx.fragment.app.Fragment; - public class SubscriptionsCard extends BaseCard { 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 Fragment target; -// private CountrySelectionFragment countrySelectionFragment = new CountrySelectionFragment(); private SubscriptionsListCard subscriptionsListCard; private InAppPurchaseHelper purchaseHelper; @@ -54,7 +50,6 @@ public class SubscriptionsCard extends BaseCard { } updateSubscriptionsListCard(); - setupSupportRegion(); LinearLayout reportContainer = view.findViewById(R.id.report_container); reportContainer.setOnClickListener(new View.OnClickListener() { @@ -99,26 +94,6 @@ public class SubscriptionsCard extends BaseCard { } } - 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) { @@ -129,17 +104,4 @@ public class SubscriptionsCard extends BaseCard { return PLAY_STORE_SUBSCRIPTION_URL; } } - - 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/TroubleshootingOrPurchasingCard.java b/OsmAnd/src/net/osmand/plus/settings/fragments/TroubleshootingOrPurchasingCard.java index db33837202..6758292334 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/TroubleshootingOrPurchasingCard.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/TroubleshootingOrPurchasingCard.java @@ -10,6 +10,10 @@ import android.view.View; import android.widget.ImageView; import android.widget.TextView; +import androidx.annotation.NonNull; +import androidx.cardview.widget.CardView; +import androidx.core.content.ContextCompat; + import net.osmand.AndroidUtils; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; @@ -19,10 +23,6 @@ import net.osmand.plus.inapp.InAppPurchaseHelper; import net.osmand.plus.routepreparationmenu.cards.BaseCard; import net.osmand.plus.wikipedia.WikipediaDialogFragment; -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"; @@ -78,7 +78,7 @@ public class TroubleshootingOrPurchasingCard extends BaseCard { } ImageView getItArrow = view.findViewById(R.id.additional_button_icon); - UiUtilities.rotateImageByLayoutDirection(getItArrow, app); + UiUtilities.rotateImageByLayoutDirection(getItArrow); } }