Merge pull request #10234 from osmandapp/opr_add_photos

OPR add photos
This commit is contained in:
Vitaliy 2020-11-19 18:31:33 +00:00 committed by GitHub
commit 7d4dad3745
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 291 additions and 76 deletions

View file

@ -1,15 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:background="@color/color_white"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" android:orientation="vertical"
android:clickable="true"
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:background="?attr/bg_color"
android:clickable="true"
android:focusable="true"
android:orientation="vertical">
<LinearLayout
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="56dp"
android:layout_height="@dimen/toolbar_height"
android:layout_marginTop="@dimen/dialog_content_margin">
<androidx.appcompat.widget.AppCompatImageView
@ -19,77 +21,85 @@
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" />
</LinearLayout>
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/opr_img"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:contentDescription="@string/shared_string_back"
app:srcCompat="@drawable/ic_img_logo_openplacereview"/>
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/toolbar"
android:layout_above="@id/buttons">
<androidx.appcompat.widget.AppCompatTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/content_padding"
android:textColor="@color/color_black"
android:textSize="20sp"
android:lineSpacingExtra="5sp"
android:textAlignment="center"
android:layout_marginRight="@dimen/content_padding"
android:layout_marginTop="@dimen/content_padding"
android:layout_marginBottom="@dimen/dashPadding"
android:text="@string/register_on_openplacereviews"
android:gravity="center_horizontal"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/opr_img"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:contentDescription="@string/shared_string_back"
app:srcCompat="@drawable/ic_img_logo_openplacereview" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/start_opr_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dashPadding"
android:layout_marginLeft="@dimen/content_padding"
android:lineSpacingExtra="5sp"
android:textColor="@color/color_black"
android:textColorLink="@color/icon_color_active_light"
android:layout_marginRight="@dimen/content_padding"
android:text="@string/register_on_openplacereviews_desc"/>
<net.osmand.plus.widgets.TextViewEx
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/content_padding"
android:layout_marginTop="@dimen/content_padding"
android:layout_marginRight="@dimen/content_padding"
android:layout_marginBottom="@dimen/dashPadding"
android:gravity="center_horizontal"
android:lineSpacingMultiplier="@dimen/bottom_sheet_text_spacing_multiplier"
android:text="@string/register_on_openplacereviews"
android:textAlignment="center"
android:textColor="?android:textColorPrimary"
android:textSize="20sp"
app:typeface="@string/font_roboto_medium" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/start_opr_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/content_padding"
android:layout_marginTop="@dimen/dashPadding"
android:layout_marginRight="@dimen/content_padding"
android:lineSpacingMultiplier="@dimen/bottom_sheet_text_spacing_multiplier"
app:typeface="@string/font_roboto_regular"
android:text="@string/register_on_openplacereviews_desc"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size"
android:textColorLink="@color/icon_color_active_light" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>
<LinearLayout
android:gravity="bottom"
android:orientation="vertical"
android:layout_marginBottom="@dimen/content_padding_small"
android:id="@+id/buttons"
android:layout_width="match_parent"
android:layout_height="match_parent">
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">
<androidx.appcompat.widget.AppCompatButton
<include
android:id="@+id/register_opr_create_account"
android:layout_marginLeft="@dimen/content_padding"
android:layout_marginRight="@dimen/content_padding"
android:layout_marginBottom="@dimen/dashPadding"
android:text="@string/register_opr_create_new_account"
android:textColor="@color/color_white"
android:layout_marginTop="@dimen/content_padding_small"
android:background="@color/icon_color_active_light"
layout="@layout/bottom_sheet_dialog_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
android:layout_height="@dimen/dialog_button_height"
android:layout_marginBottom="@dimen/content_padding_small" />
<androidx.appcompat.widget.AppCompatButton
<include
android:id="@+id/register_opr_have_account"
android:layout_marginLeft="@dimen/content_padding"
android:layout_marginRight="@dimen/content_padding"
android:layout_marginTop="@dimen/dashPadding"
android:layout_gravity="bottom"
android:text="@string/register_opr_have_account"
android:textColor="@color/icon_color_active_light"
android:background="@color/activity_background_color_light"
layout="@layout/bottom_sheet_dialog_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
android:layout_height="@dimen/dialog_button_height" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>

View file

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:osmand="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/add_photos_icon"
android:layout_width="@dimen/favorites_icon_outline_size"
android:layout_height="@dimen/favorites_icon_outline_size"
android:layout_marginTop="@dimen/bottom_sheet_icon_margin"
android:layout_gravity="center"
osmand:srcCompat="@drawable/ic_action_photo_upload_colored" />
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/add_photos_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="@dimen/content_padding_small"
android:layout_marginBottom="@dimen/content_padding_small"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/dialog_header_text_size"
osmand:typeface="@string/font_roboto_medium"
android:text="@string/shared_string_add_photos" />
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/add_photos_descr"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/content_padding"
android:layout_marginRight="@dimen/content_padding"
android:layout_marginBottom="@dimen/text_margin_small"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size"
android:lineSpacingMultiplier="@dimen/bottom_sheet_text_spacing_multiplier"
osmand:typeface="@string/font_roboto_regular"
android:text="@string/add_photos_descr" />
</LinearLayout>

View file

@ -289,6 +289,7 @@
<dimen name="bottom_sheet_info_spacing_multiplier" format="float">1.5</dimen>
<dimen name="bottom_sheet_big_item_height">128dp</dimen>
<dimen name="bottom_sheet_top_shadow_height">8dp</dimen>
<dimen name="bottom_sheet_button_divider_height">28dp</dimen>
<dimen name="action_bar_image_width_land">236dp</dimen>
<dimen name="action_bar_image_top_margin_land">68dp</dimen>

View file

@ -17,6 +17,9 @@
<string name="select_data_to_export">Select the data to be exported to the file.</string>
<string name="approximate_file_size">Approximate file size</string>
<string name="shared_string_resources">Resources</string>
<string name="add_photos_descr">OsmAnd shows photos from several sources:\nOpenPlaceReviews - POI photos;\nMapillary - street-level imagery;\nWeb / Wikimedia - POI photos specified in OpenStreetMap data.</string>
<string name="add_to_opr">Add to OpenPlaceReviews</string>
<string name="add_to_mapillary">Add to Mapillary</string>
<string name="app_mode_motorboat">Motorboat</string>
<string name="app_mode_kayak">Kayak</string>
<string name="shared_string_search_history">Search history</string>

View file

@ -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;
}

View file

@ -0,0 +1,143 @@
package net.osmand.plus.openplacereviews;
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.UiUtilities.DialogButtonType;
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem;
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) {
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(view)
.create());
items.add(new DividerSpaceItem(app, app.getResources().getDimensionPixelSize(R.dimen.text_margin_small)));
}
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.<TextView>findViewById(R.id.add_photos_descr).setText(ss);
}
static class BoldSpannableString extends SpannableString {
Context ctx;
public BoldSpannableString(CharSequence source, Context ctx) {
super(source);
this.ctx = ctx;
}
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);
}
}
@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
protected int getDismissButtonTextId() {
return R.string.shared_string_cancel;
}
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);
}
}
}

View file

@ -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);
}
}