Fix "add photos" bottom sheet
This commit is contained in:
parent
8848da6466
commit
76315ec099
4 changed files with 172 additions and 95 deletions
|
@ -1,14 +1,15 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout android:background="@color/color_white"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="vertical"
|
||||
android:clickable="true"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:focusable="true">
|
||||
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="@dimen/toolbar_height"
|
||||
android:layout_marginTop="@dimen/dialog_content_margin">
|
||||
|
@ -20,11 +21,22 @@
|
|||
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.core.widget.NestedScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_below="@id/toolbar"
|
||||
android:layout_above="@id/buttons">
|
||||
|
||||
<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"
|
||||
|
@ -36,39 +48,44 @@
|
|||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
app:typeface="@string/font_roboto_medium"
|
||||
android:textSize="20sp"
|
||||
android:lineSpacingExtra="5sp"
|
||||
android:textAlignment="center"
|
||||
android:layout_marginRight="@dimen/content_padding"
|
||||
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:gravity="center_horizontal" />
|
||||
|
||||
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_marginTop="@dimen/dashPadding"
|
||||
android:layout_marginLeft="@dimen/content_padding"
|
||||
android:lineSpacingExtra="5sp"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textColorLink="@color/icon_color_active_light"
|
||||
android:layout_marginTop="@dimen/dashPadding"
|
||||
android:layout_marginRight="@dimen/content_padding"
|
||||
android:text="@string/register_on_openplacereviews_desc" />
|
||||
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:layout_marginLeft="@dimen/content_padding"
|
||||
android:layout_marginRight="@dimen/content_padding"
|
||||
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">
|
||||
|
||||
<include
|
||||
android:id="@+id/register_opr_create_account"
|
||||
|
@ -85,4 +102,4 @@
|
|||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
|
@ -7,12 +7,11 @@
|
|||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/add_photos_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
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_marginBottom="@dimen/content_padding_small"
|
||||
android:layout_gravity="center"
|
||||
osmand:srcCompat="@drawable/ic_img_logo_openplacereview" />
|
||||
osmand:srcCompat="@drawable/ic_action_photo_upload_colored" />
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/add_photos_title"
|
||||
|
@ -32,8 +31,10 @@
|
|||
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" />
|
||||
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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.<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);
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
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();
|
||||
}
|
||||
})
|
||||
.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) {
|
||||
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();
|
||||
}
|
||||
})
|
||||
.create());
|
||||
|
||||
items.add(new DividerSpaceItem(getContext(), contextPaddingSmall));
|
||||
@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()) {
|
||||
public static void showInstance(@NonNull FragmentManager fm) {
|
||||
try {
|
||||
if (!fm.isStateSaved()) {
|
||||
AddPhotosBottomSheetDialogFragment fragment = new AddPhotosBottomSheetDialogFragment();
|
||||
fragment.show(fragmentManager, TAG);
|
||||
fragment.show(fm, TAG);
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
LOG.error("showInstance", e);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue