From 8848da646675039b4bc47a59b9e9a62ade564adf Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Thu, 19 Nov 2020 16:00:12 +0200 Subject: [PATCH] Fix "register on" fragment, add "add photos" bottom sheet --- OsmAnd/res/layout/fragment_opr_login.xml | 53 +++++------- OsmAnd/res/layout/opr_add_photo.xml | 40 +++++++++ OsmAnd/res/values/strings.xml | 3 + .../plus/mapcontextmenu/MenuBuilder.java | 6 +- .../AddPhotosBottomSheetDialogFragment.java | 85 +++++++++++++++++++ .../openplacereviews/OprStartFragment.java | 37 +++++--- 6 files changed, 181 insertions(+), 43 deletions(-) create mode 100644 OsmAnd/res/layout/opr_add_photo.xml create mode 100644 OsmAnd/src/net/osmand/plus/openplacereviews/AddPhotosBottomSheetDialogFragment.java diff --git a/OsmAnd/res/layout/fragment_opr_login.xml b/OsmAnd/res/layout/fragment_opr_login.xml index 3313679aec..59c31069b9 100644 --- a/OsmAnd/res/layout/fragment_opr_login.xml +++ b/OsmAnd/res/layout/fragment_opr_login.xml @@ -1,15 +1,16 @@ - + android:layout_height="match_parent" + android:focusable="true"> + app:srcCompat="@drawable/ic_img_logo_openplacereview" /> - + android:gravity="center_horizontal" /> + android:text="@string/register_on_openplacereviews_desc" /> - + android:layout_height="@dimen/dialog_button_height" + android:layout_marginBottom="@dimen/content_padding_small" /> - + android:layout_height="@dimen/dialog_button_height" /> diff --git a/OsmAnd/res/layout/opr_add_photo.xml b/OsmAnd/res/layout/opr_add_photo.xml new file mode 100644 index 0000000000..827fda4a16 --- /dev/null +++ b/OsmAnd/res/layout/opr_add_photo.xml @@ -0,0 +1,40 @@ + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index bde6a98173..8fa1c6ab03 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -17,6 +17,9 @@ Select the data to be exported to the file. Approximate file size Resources + OsmAnd shows photos from several sources:\nOpenPlaceReviews - POI photos;\nMapillary - street-level imagery;\nWeb / Wikimedia - POI photos specified in OpenStreetMap data. + Add to OpenPlaceReviews + Add to Mapillary Motorboat Kayak Search history diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java index 1aa35b8589..35db3c821e 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java @@ -46,7 +46,7 @@ import net.osmand.plus.mapcontextmenu.builders.cards.ImageCard; import net.osmand.plus.mapcontextmenu.builders.cards.ImageCard.GetImageCardsTask; import net.osmand.plus.mapcontextmenu.builders.cards.NoImagesCard; import net.osmand.plus.mapcontextmenu.controllers.TransportStopController; -import net.osmand.plus.openplacereviews.OprStartFragment; +import net.osmand.plus.openplacereviews.AddPhotosBottomSheetDialogFragment; import net.osmand.plus.poi.PoiUIFilter; import net.osmand.plus.render.RenderingIcons; import net.osmand.plus.transport.TransportStopRoute; @@ -316,7 +316,7 @@ public class MenuBuilder { b.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { - OprStartFragment.showInstance(mapActivity.getSupportFragmentManager()); + AddPhotosBottomSheetDialogFragment.showInstance(mapActivity.getSupportFragmentManager()); } }); b.setTypeface(FontCache.getRobotoRegular(context)); @@ -337,7 +337,7 @@ public class MenuBuilder { b.setText(context.getResources().getString(R.string.shared_string_add_photo)); b.setBackgroundResource(R.drawable.btn_border_light); //TODO This feature is under development - b.setVisibility(View.GONE); + b.setVisibility(View.VISIBLE); b.setTextColor(ContextCompat.getColor(context, R.color.preference_category_title)); return b; } diff --git a/OsmAnd/src/net/osmand/plus/openplacereviews/AddPhotosBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/openplacereviews/AddPhotosBottomSheetDialogFragment.java new file mode 100644 index 0000000000..4a55e9b425 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/openplacereviews/AddPhotosBottomSheetDialogFragment.java @@ -0,0 +1,85 @@ +package net.osmand.plus.openplacereviews; + +import android.app.Activity; +import android.os.Bundle; +import android.view.View; + +import androidx.annotation.NonNull; +import androidx.fragment.app.FragmentActivity; +import androidx.fragment.app.FragmentManager; + +import net.osmand.plus.R; +import net.osmand.plus.UiUtilities; +import net.osmand.plus.activities.MapActivity; +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; + +public class AddPhotosBottomSheetDialogFragment extends MenuBottomSheetDialogFragment { + + public static final String TAG = AddPhotosBottomSheetDialogFragment.class.getSimpleName(); + + @Override + public void createMenuItems(Bundle savedInstanceState) { + + View mainView = View.inflate(UiUtilities.getThemedContext(getMyApplication(), nightMode), + R.layout.opr_add_photo, null); + items.add(new SimpleBottomSheetItem.Builder() + .setCustomView(mainView) + .create()); + + 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); + + 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()); + + items.add(new DividerSpaceItem(getContext(), contextPaddingSmall)); + + 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()); + + items.add(new DividerSpaceItem(getContext(), contextPaddingSmall)); + } + + @Override + protected int getDismissButtonTextId() { + return R.string.shared_string_cancel; + } + + public static void showInstance(@NonNull FragmentManager fragmentManager) { + if (!fragmentManager.isStateSaved()) { + AddPhotosBottomSheetDialogFragment fragment = new AddPhotosBottomSheetDialogFragment(); + fragment.show(fragmentManager, TAG); + } + } +} \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/openplacereviews/OprStartFragment.java b/OsmAnd/src/net/osmand/plus/openplacereviews/OprStartFragment.java index eecd0c3f32..19a4ba57be 100644 --- a/OsmAnd/src/net/osmand/plus/openplacereviews/OprStartFragment.java +++ b/OsmAnd/src/net/osmand/plus/openplacereviews/OprStartFragment.java @@ -1,6 +1,7 @@ package net.osmand.plus.openplacereviews; import android.content.Intent; +import android.graphics.Typeface; import android.os.Bundle; import android.text.SpannableString; import android.text.Spanned; @@ -11,23 +12,41 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; + import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.fragment.app.FragmentActivity; import androidx.fragment.app.FragmentManager; + import net.osmand.PlatformUtil; import net.osmand.plus.R; +import net.osmand.plus.UiUtilities; import net.osmand.plus.base.BaseOsmAndFragment; + import org.apache.commons.logging.Log; public class OprStartFragment extends BaseOsmAndFragment { - private static final String TAG = "fragment_oprstart"; + private static final String TAG = OprStartFragment.class.getSimpleName(); private static final Log LOG = PlatformUtil.getLog(OprStartFragment.class); private static final String openPlaceReviewsUrl = "OpenPlaceReviews.org"; @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + boolean nightMode = getMyApplication().getDaynightHelper().isNightModeForMapControls(); View v = inflater.inflate(R.layout.fragment_opr_login, container, false); - v.findViewById(R.id.register_opr_create_account).setOnClickListener(new View.OnClickListener() { + View createAccount = v.findViewById(R.id.register_opr_create_account); + v.findViewById(R.id.back_button).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + FragmentActivity activity = getActivity(); + if (activity != null) { + activity.getSupportFragmentManager().popBackStack(); + } + } + }); + UiUtilities.setupDialogButton(nightMode, createAccount, UiUtilities.DialogButtonType.PRIMARY, + R.string.register_opr_create_new_account); + createAccount.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent i = new Intent(requireContext(), OPRWebviewActivity.class); @@ -36,13 +55,10 @@ public class OprStartFragment extends BaseOsmAndFragment { startActivity(i); } }); - v.findViewById(R.id.back_button).setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - getActivity().getSupportFragmentManager().popBackStack(); - } - }); - v.findViewById(R.id.register_opr_have_account).setOnClickListener(new View.OnClickListener() { + View haveAccount = v.findViewById(R.id.register_opr_have_account); + UiUtilities.setupDialogButton(nightMode, haveAccount, UiUtilities.DialogButtonType.SECONDARY, + R.string.register_opr_have_account); + haveAccount.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent i = new Intent(requireContext(), OPRWebviewActivity.class); @@ -71,9 +87,10 @@ public class OprStartFragment extends BaseOsmAndFragment { } @Override - public void updateDrawState(TextPaint ds) { + public void updateDrawState(@NonNull TextPaint ds) { super.updateDrawState(ds); ds.setUnderlineText(false); + ds.setTypeface(Typeface.DEFAULT_BOLD); } }