diff --git a/OsmAnd/res/layout/fragment_opr_login.xml b/OsmAnd/res/layout/fragment_opr_login.xml index 59c31069b9..5c5d4c23b5 100644 --- a/OsmAnd/res/layout/fragment_opr_login.xml +++ b/OsmAnd/res/layout/fragment_opr_login.xml @@ -1,14 +1,15 @@ - + android:background="?attr/bg_color" + android:clickable="true" + android:focusable="true" + android:orientation="vertical"> @@ -20,55 +21,71 @@ android:layout_height="match_parent" android:layout_gravity="start" android:contentDescription="@string/shared_string_back" - app:tint="@color/icon_color_default_light" - app:srcCompat="@drawable/ic_arrow_back"/> + app:srcCompat="@drawable/ic_arrow_back" + app:tint="@color/icon_color_default_light" /> - + - + + - + + + + + + android:layout_height="wrap_content" + android:layout_marginLeft="@dimen/content_padding" + android:layout_marginTop="@dimen/content_padding_small" + android:layout_marginRight="@dimen/content_padding" + android:layout_marginBottom="@dimen/content_padding_small" + android:layout_alignParentBottom="true" + android:orientation="vertical"> - \ No newline at end of file + \ No newline at end of file diff --git a/OsmAnd/res/layout/opr_add_photo.xml b/OsmAnd/res/layout/opr_add_photo.xml index 827fda4a16..80d43411fe 100644 --- a/OsmAnd/res/layout/opr_add_photo.xml +++ b/OsmAnd/res/layout/opr_add_photo.xml @@ -7,12 +7,11 @@ + osmand:srcCompat="@drawable/ic_action_photo_upload_colored" /> diff --git a/OsmAnd/res/values/sizes.xml b/OsmAnd/res/values/sizes.xml index 0cb79d23d1..64ab1cc330 100644 --- a/OsmAnd/res/values/sizes.xml +++ b/OsmAnd/res/values/sizes.xml @@ -289,6 +289,7 @@ 1.5 128dp 8dp + 28dp 236dp 68dp diff --git a/OsmAnd/src/net/osmand/plus/openplacereviews/AddPhotosBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/openplacereviews/AddPhotosBottomSheetDialogFragment.java index 4a55e9b425..dae4fcad4b 100644 --- a/OsmAnd/src/net/osmand/plus/openplacereviews/AddPhotosBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/openplacereviews/AddPhotosBottomSheetDialogFragment.java @@ -1,74 +1,128 @@ package net.osmand.plus.openplacereviews; -import android.app.Activity; +import android.content.Context; import android.os.Bundle; +import android.text.SpannableString; +import android.text.Spanned; import android.view.View; +import android.widget.TextView; import androidx.annotation.NonNull; import androidx.fragment.app.FragmentActivity; import androidx.fragment.app.FragmentManager; +import net.osmand.PlatformUtil; +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.UiUtilities.DialogButtonType; import net.osmand.plus.base.MenuBottomSheetDialogFragment; -import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemButton; import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem; -import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerItem; import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerSpaceItem; +import net.osmand.plus.helpers.FontCache; +import net.osmand.plus.mapillary.MapillaryPlugin; +import net.osmand.plus.widgets.style.CustomTypefaceSpan; + +import org.apache.commons.logging.Log; public class AddPhotosBottomSheetDialogFragment extends MenuBottomSheetDialogFragment { public static final String TAG = AddPhotosBottomSheetDialogFragment.class.getSimpleName(); + private static final Log LOG = PlatformUtil.getLog(AddPhotosBottomSheetDialogFragment.class); + + public static final String OPEN_PLACE_REVIEWS = "OpenPlaceReviews"; + public static final String MAPILLARY = "Mapillary"; + public static final String WEB_WIKIMEDIA = "Web / Wikimedia"; + public static final String OPEN_STREET_MAP = "OpenStreetMap"; @Override public void createMenuItems(Bundle savedInstanceState) { - View mainView = View.inflate(UiUtilities.getThemedContext(getMyApplication(), nightMode), + OsmandApplication app = getMyApplication(); + if (app == null) { + return; + } + View view = View.inflate(UiUtilities.getThemedContext(app, nightMode), R.layout.opr_add_photo, null); + setDescriptionSpan(view); items.add(new SimpleBottomSheetItem.Builder() - .setCustomView(mainView) + .setCustomView(view) .create()); + items.add(new DividerSpaceItem(app, app.getResources().getDimensionPixelSize(R.dimen.text_margin_small))); + } - DividerItem divider = new DividerItem(getContext()); - int contextPadding = getResources().getDimensionPixelSize(R.dimen.content_padding); - int contextPaddingSmall = getResources().getDimensionPixelSize(R.dimen.content_padding_small); - divider.setMargins(contextPadding, contextPadding, contextPadding, contextPaddingSmall); - items.add(divider); + private void setDescriptionSpan(View view) { + String desc = requireContext().getString(R.string.add_photos_descr); + BoldSpannableString ss = new BoldSpannableString(desc, view.getContext()); + ss.setBold(OPEN_PLACE_REVIEWS); + ss.setBold(MAPILLARY); + ss.setBold(WEB_WIKIMEDIA); + ss.setBold(OPEN_STREET_MAP); + view.findViewById(R.id.add_photos_descr).setText(ss); + } - items.add(new BottomSheetItemButton.Builder() - .setTitle(getString(R.string.add_to_opr)) - .setLayoutId(R.layout.bottom_sheet_button) - .setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - FragmentActivity activity = getActivity(); - if (activity != null) { - OprStartFragment.showInstance(activity.getSupportFragmentManager()); - } - dismiss(); - } - }) - .create()); + static class BoldSpannableString extends SpannableString { + Context ctx; - items.add(new DividerSpaceItem(getContext(), contextPaddingSmall)); + public BoldSpannableString(CharSequence source, Context ctx) { + super(source); + this.ctx = ctx; + } - items.add(new BottomSheetItemButton.Builder() - .setButtonType(UiUtilities.DialogButtonType.SECONDARY) - .setTitle(getString(R.string.add_to_mapillary)) - .setLayoutId(R.layout.bottom_sheet_button) - .setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - Activity activity = getActivity(); - if (activity instanceof MapActivity) { - } - dismiss(); - } - }) - .create()); + public void setBold(String boldText) { + String source = toString(); + setSpan(new CustomTypefaceSpan(FontCache.getRobotoMedium(ctx)), + source.indexOf(boldText), source.indexOf(boldText) + boldText.length(), + Spanned.SPAN_INCLUSIVE_INCLUSIVE); + } + } - items.add(new DividerSpaceItem(getContext(), contextPaddingSmall)); + @Override + protected int getThirdBottomButtonTextId() { + return R.string.add_to_opr; + } + + @Override + protected DialogButtonType getThirdBottomButtonType() { + return DialogButtonType.SECONDARY; + } + + @Override + protected int getFirstDividerHeight() { + return getResources().getDimensionPixelSize(R.dimen.bottom_sheet_button_divider_height); + } + + @Override + protected void onThirdBottomButtonClick() { + FragmentActivity activity = getActivity(); + if (activity != null) { + OprStartFragment.showInstance(activity.getSupportFragmentManager()); + } + dismiss(); + } + + @Override + protected int getRightBottomButtonTextId() { + return R.string.add_to_mapillary; + } + + @Override + protected DialogButtonType getRightBottomButtonType() { + return DialogButtonType.SECONDARY; + } + + @Override + protected void onRightBottomButtonClick() { + FragmentActivity activity = getActivity(); + if (activity != null) { + MapillaryPlugin.openMapillary(activity, null); + } + dismiss(); + } + + @Override + protected int getSecondDividerHeight() { + return getResources().getDimensionPixelSize(R.dimen.content_padding_small); } @Override @@ -76,10 +130,14 @@ public class AddPhotosBottomSheetDialogFragment extends MenuBottomSheetDialogFra return R.string.shared_string_cancel; } - public static void showInstance(@NonNull FragmentManager fragmentManager) { - if (!fragmentManager.isStateSaved()) { - AddPhotosBottomSheetDialogFragment fragment = new AddPhotosBottomSheetDialogFragment(); - fragment.show(fragmentManager, TAG); + public static void showInstance(@NonNull FragmentManager fm) { + try { + if (!fm.isStateSaved()) { + AddPhotosBottomSheetDialogFragment fragment = new AddPhotosBottomSheetDialogFragment(); + fragment.show(fm, TAG); + } + } catch (RuntimeException e) { + LOG.error("showInstance", e); } } } \ No newline at end of file