Small fixes

This commit is contained in:
Vitaliy 2021-04-19 17:51:21 +03:00
parent adabe9d54e
commit 324397cc25
8 changed files with 23 additions and 132 deletions

View file

@ -1,8 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:osmand="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/bg_color" android:background="?attr/bg_color"
@ -13,78 +11,13 @@
android:layout_height="@dimen/list_content_padding" android:layout_height="@dimen/list_content_padding"
android:background="?attr/activity_background_color" /> android:background="?attr/activity_background_color" />
<include <include layout="@layout/divider" />
layout="@layout/divider" />
<FrameLayout <FrameLayout
android:id="@+id/subscriptions_list_container" android:id="@+id/subscriptions_list_container"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" /> android:layout_height="wrap_content" />
<!-- <LinearLayout-->
<!-- android:id="@+id/support_region_container"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:orientation="horizontal"-->
<!-- android:background="?android:attr/selectableItemBackground"-->
<!-- android:paddingStart="@dimen/content_padding"-->
<!-- android:paddingLeft="@dimen/content_padding"-->
<!-- android:paddingRight="@dimen/content_padding"-->
<!-- android:paddingEnd="@dimen/content_padding">-->
<!-- <androidx.appcompat.widget.AppCompatImageView-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:minHeight="@dimen/setting_list_item_group_height"-->
<!-- android:layout_gravity="center_vertical"-->
<!-- android:layout_marginEnd="@dimen/map_widget_height"-->
<!-- android:layout_marginRight="@dimen/map_widget_height"-->
<!-- app:srcCompat="@drawable/ic_world_globe_dark"-->
<!-- app:tint="?attr/default_icon_color" />-->
<!-- <LinearLayout-->
<!-- android:layout_width="0dp"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_weight="1"-->
<!-- android:layout_marginTop="@dimen/content_padding_small"-->
<!-- android:layout_marginBottom="@dimen/content_padding_small"-->
<!-- android:layout_gravity="center_vertical"-->
<!-- android:orientation="vertical">-->
<!-- <net.osmand.plus.widgets.TextViewEx-->
<!-- android:id="@+id/support_region_header"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:textColor="?android:attr/textColorPrimary"-->
<!-- android:textSize="@dimen/default_list_text_size"-->
<!-- osmand:typeface="@string/font_roboto_regular"-->
<!-- tools:text="@string/osm_live_support_region"/>-->
<!-- <net.osmand.plus.widgets.TextViewEx-->
<!-- android:id="@+id/support_region"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_marginEnd="@dimen/content_padding"-->
<!-- android:layout_marginRight="@dimen/content_padding"-->
<!-- android:text="@string/osm_live_support_region"-->
<!-- android:textColor="?android:attr/textColorSecondary"-->
<!-- android:textSize="@dimen/default_desc_text_size"-->
<!-- osmand:typeface="@string/font_roboto_regular"-->
<!-- tools:text="@string/clear_updates_proposition_message"/>-->
<!-- </LinearLayout>-->
<!-- <androidx.appcompat.widget.AppCompatImageView-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_gravity="center_vertical"-->
<!-- app:srcCompat="@drawable/ic_action_settings"-->
<!-- app:tint="?attr/default_icon_color" />-->
<!-- </LinearLayout>-->
<!-- <include layout="@layout/simple_divider_item" />-->
<LinearLayout <LinearLayout
android:id="@+id/report_container" android:id="@+id/report_container"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -206,8 +139,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/activity_background_color"> android:background="?attr/activity_background_color">
<include <include layout="@layout/card_bottom_divider" />
layout="@layout/card_bottom_divider" />
</FrameLayout> </FrameLayout>

View file

@ -442,11 +442,11 @@ public class UiUtilities {
} catch (Throwable e) { } } catch (Throwable e) { }
} }
public static void rotateImageByLayoutDirection(ImageView image, Context context) { public static void rotateImageByLayoutDirection(ImageView image) {
if (image == null || context == null) { if (image == null) {
return; 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); image.setRotationY(rotation);
} }

View file

@ -109,7 +109,7 @@ public class PluginInfoFragment extends BaseOsmAndFragment implements PluginStat
} }
} }
}); });
UiUtilities.rotateImageByLayoutDirection(closeButton, app); UiUtilities.rotateImageByLayoutDirection(closeButton);
Drawable pluginImage = plugin.getAssetResourceImage(); Drawable pluginImage = plugin.getAssetResourceImage();
if (pluginImage != null) { if (pluginImage != null) {

View file

@ -101,7 +101,7 @@ public class PluginsFragment extends BaseOsmAndFragment implements PluginStateLi
} }
} }
}); });
UiUtilities.rotateImageByLayoutDirection(closeButton, app); UiUtilities.rotateImageByLayoutDirection(closeButton);
adapter = new PluginsListAdapter(requireContext()); adapter = new PluginsListAdapter(requireContext());

View file

@ -492,8 +492,7 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
} }
}); });
if (closeButton instanceof ImageView) { if (closeButton instanceof ImageView) {
UiUtilities.rotateImageByLayoutDirection( UiUtilities.rotateImageByLayoutDirection((ImageView) closeButton);
(ImageView) closeButton, app);
} }
} }

View file

@ -10,6 +10,11 @@ import android.widget.ImageButton;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; 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 com.google.android.material.appbar.AppBarLayout;
import net.osmand.AndroidUtils; import net.osmand.AndroidUtils;
@ -30,11 +35,6 @@ import net.osmand.util.Algorithms;
import org.apache.commons.logging.Log; 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 { public class PurchasesFragment extends BaseOsmAndFragment implements InAppPurchaseListener, OnFragmentInteractionListener {
private static final Log log = PlatformUtil.getLog(PurchasesFragment.class); 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); ImageButton backButton = toolbar.findViewById(R.id.close_button);
UiUtilities.rotateImageByLayoutDirection(backButton, getContext()); UiUtilities.rotateImageByLayoutDirection(backButton);
backButton.setOnClickListener(new View.OnClickListener() { backButton.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@ -198,9 +198,7 @@ public class PurchasesFragment extends BaseOsmAndFragment implements InAppPurcha
@Override @Override
public void onSearchResult(CountrySelectionFragment.CountryItem name) { public void onSearchResult(CountrySelectionFragment.CountryItem name) {
if (subscriptionsCard != null) {
subscriptionsCard.onSupportRegionSelected(name);
}
} }
@Override @Override

View file

@ -5,30 +5,26 @@ import android.net.Uri;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import net.osmand.AndroidUtils; import net.osmand.AndroidUtils;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.inapp.InAppPurchaseHelper; import net.osmand.plus.inapp.InAppPurchaseHelper;
import net.osmand.plus.liveupdates.CountrySelectionFragment;
import net.osmand.plus.liveupdates.LiveUpdatesFragment; import net.osmand.plus.liveupdates.LiveUpdatesFragment;
import net.osmand.plus.liveupdates.OsmLiveActivity; import net.osmand.plus.liveupdates.OsmLiveActivity;
import net.osmand.plus.routepreparationmenu.cards.BaseCard; import net.osmand.plus.routepreparationmenu.cards.BaseCard;
import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
public class SubscriptionsCard extends BaseCard { 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_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 PLAY_STORE_SUBSCRIPTION_DEEPLINK_URL = "https://play.google.com/store/account/subscriptions?sku=%s&package=%s";
private Fragment target; private Fragment target;
// private CountrySelectionFragment countrySelectionFragment = new CountrySelectionFragment();
private SubscriptionsListCard subscriptionsListCard; private SubscriptionsListCard subscriptionsListCard;
private InAppPurchaseHelper purchaseHelper; private InAppPurchaseHelper purchaseHelper;
@ -54,7 +50,6 @@ public class SubscriptionsCard extends BaseCard {
} }
updateSubscriptionsListCard(); updateSubscriptionsListCard();
setupSupportRegion();
LinearLayout reportContainer = view.findViewById(R.id.report_container); LinearLayout reportContainer = view.findViewById(R.id.report_container);
reportContainer.setOnClickListener(new View.OnClickListener() { 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() { private String getSubscriptionUrl() {
InAppPurchaseHelper purchaseHelper = app.getInAppPurchaseHelper(); InAppPurchaseHelper purchaseHelper = app.getInAppPurchaseHelper();
if (purchaseHelper != null && purchaseHelper.getFullVersion() != null) { if (purchaseHelper != null && purchaseHelper.getFullVersion() != null) {
@ -129,17 +104,4 @@ public class SubscriptionsCard extends BaseCard {
return PLAY_STORE_SUBSCRIPTION_URL; 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);
}
} }

View file

@ -10,6 +10,10 @@ import android.view.View;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; 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.AndroidUtils;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.UiUtilities; 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.routepreparationmenu.cards.BaseCard;
import net.osmand.plus.wikipedia.WikipediaDialogFragment; 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 { 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_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); ImageView getItArrow = view.findViewById(R.id.additional_button_icon);
UiUtilities.rotateImageByLayoutDirection(getItArrow, app); UiUtilities.rotateImageByLayoutDirection(getItArrow);
} }
} }