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"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout android:background="@color/color_white"
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
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"
|
||||||
android:orientation="vertical"
|
|
||||||
android:clickable="true"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="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
|
<LinearLayout
|
||||||
|
android:id="@+id/toolbar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="@dimen/toolbar_height"
|
android:layout_height="@dimen/toolbar_height"
|
||||||
android:layout_marginTop="@dimen/dialog_content_margin">
|
android:layout_marginTop="@dimen/dialog_content_margin">
|
||||||
|
@ -20,55 +21,71 @@
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_gravity="start"
|
android:layout_gravity="start"
|
||||||
android:contentDescription="@string/shared_string_back"
|
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>
|
</LinearLayout>
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatImageView
|
<androidx.core.widget.NestedScrollView
|
||||||
android:id="@+id/opr_img"
|
android:layout_width="match_parent"
|
||||||
android:layout_width="wrap_content"
|
android:layout_height="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_below="@id/toolbar"
|
||||||
android:layout_gravity="center"
|
android:layout_above="@id/buttons">
|
||||||
android:contentDescription="@string/shared_string_back"
|
|
||||||
app:srcCompat="@drawable/ic_img_logo_openplacereview" />
|
|
||||||
|
|
||||||
<net.osmand.plus.widgets.TextViewEx
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textColor="?android:textColorPrimary"
|
android:orientation="vertical">
|
||||||
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_marginBottom="@dimen/dashPadding"
|
|
||||||
android:text="@string/register_on_openplacereviews"
|
|
||||||
android:gravity="center_horizontal" />
|
|
||||||
|
|
||||||
|
<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
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
android:id="@+id/start_opr_description"
|
android:layout_width="match_parent"
|
||||||
android:layout_width="match_parent"
|
android:layout_height="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_marginLeft="@dimen/content_padding"
|
||||||
android:layout_marginTop="@dimen/dashPadding"
|
android:layout_marginTop="@dimen/content_padding"
|
||||||
android:layout_marginLeft="@dimen/content_padding"
|
android:layout_marginRight="@dimen/content_padding"
|
||||||
android:lineSpacingExtra="5sp"
|
android:layout_marginBottom="@dimen/dashPadding"
|
||||||
android:textColor="?android:textColorPrimary"
|
android:gravity="center_horizontal"
|
||||||
android:textColorLink="@color/icon_color_active_light"
|
android:lineSpacingMultiplier="@dimen/bottom_sheet_text_spacing_multiplier"
|
||||||
android:layout_marginRight="@dimen/content_padding"
|
android:text="@string/register_on_openplacereviews"
|
||||||
android:text="@string/register_on_openplacereviews_desc" />
|
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
|
<LinearLayout
|
||||||
android:gravity="bottom"
|
android:id="@+id/buttons"
|
||||||
android:orientation="vertical"
|
|
||||||
android:layout_marginBottom="@dimen/content_padding_small"
|
|
||||||
android:layout_marginLeft="@dimen/content_padding"
|
|
||||||
android:layout_marginRight="@dimen/content_padding"
|
|
||||||
android:layout_width="match_parent"
|
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
|
<include
|
||||||
android:id="@+id/register_opr_create_account"
|
android:id="@+id/register_opr_create_account"
|
||||||
|
@ -85,4 +102,4 @@
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</RelativeLayout>
|
|
@ -7,12 +7,11 @@
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatImageView
|
<androidx.appcompat.widget.AppCompatImageView
|
||||||
android:id="@+id/add_photos_icon"
|
android:id="@+id/add_photos_icon"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="@dimen/favorites_icon_outline_size"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="@dimen/favorites_icon_outline_size"
|
||||||
android:layout_marginTop="@dimen/bottom_sheet_icon_margin"
|
android:layout_marginTop="@dimen/bottom_sheet_icon_margin"
|
||||||
android:layout_marginBottom="@dimen/content_padding_small"
|
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
osmand:srcCompat="@drawable/ic_img_logo_openplacereview" />
|
osmand:srcCompat="@drawable/ic_action_photo_upload_colored" />
|
||||||
|
|
||||||
<net.osmand.plus.widgets.TextViewEx
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
android:id="@+id/add_photos_title"
|
android:id="@+id/add_photos_title"
|
||||||
|
@ -32,8 +31,10 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="@dimen/content_padding"
|
android:layout_marginLeft="@dimen/content_padding"
|
||||||
android:layout_marginRight="@dimen/content_padding"
|
android:layout_marginRight="@dimen/content_padding"
|
||||||
|
android:layout_marginBottom="@dimen/text_margin_small"
|
||||||
android:textColor="?android:textColorPrimary"
|
android:textColor="?android:textColorPrimary"
|
||||||
android:textSize="@dimen/default_list_text_size"
|
android:textSize="@dimen/default_list_text_size"
|
||||||
|
android:lineSpacingMultiplier="@dimen/bottom_sheet_text_spacing_multiplier"
|
||||||
osmand:typeface="@string/font_roboto_regular"
|
osmand:typeface="@string/font_roboto_regular"
|
||||||
android:text="@string/add_photos_descr" />
|
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_info_spacing_multiplier" format="float">1.5</dimen>
|
||||||
<dimen name="bottom_sheet_big_item_height">128dp</dimen>
|
<dimen name="bottom_sheet_big_item_height">128dp</dimen>
|
||||||
<dimen name="bottom_sheet_top_shadow_height">8dp</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_width_land">236dp</dimen>
|
||||||
<dimen name="action_bar_image_top_margin_land">68dp</dimen>
|
<dimen name="action_bar_image_top_margin_land">68dp</dimen>
|
||||||
|
|
|
@ -1,74 +1,128 @@
|
||||||
package net.osmand.plus.openplacereviews;
|
package net.osmand.plus.openplacereviews;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.text.SpannableString;
|
||||||
|
import android.text.Spanned;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.fragment.app.FragmentActivity;
|
import androidx.fragment.app.FragmentActivity;
|
||||||
import androidx.fragment.app.FragmentManager;
|
import androidx.fragment.app.FragmentManager;
|
||||||
|
|
||||||
|
import net.osmand.PlatformUtil;
|
||||||
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.UiUtilities;
|
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.MenuBottomSheetDialogFragment;
|
||||||
import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemButton;
|
|
||||||
import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem;
|
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.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 class AddPhotosBottomSheetDialogFragment extends MenuBottomSheetDialogFragment {
|
||||||
|
|
||||||
public static final String TAG = AddPhotosBottomSheetDialogFragment.class.getSimpleName();
|
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
|
@Override
|
||||||
public void createMenuItems(Bundle savedInstanceState) {
|
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);
|
R.layout.opr_add_photo, null);
|
||||||
|
setDescriptionSpan(view);
|
||||||
items.add(new SimpleBottomSheetItem.Builder()
|
items.add(new SimpleBottomSheetItem.Builder()
|
||||||
.setCustomView(mainView)
|
.setCustomView(view)
|
||||||
.create());
|
.create());
|
||||||
|
items.add(new DividerSpaceItem(app, app.getResources().getDimensionPixelSize(R.dimen.text_margin_small)));
|
||||||
|
}
|
||||||
|
|
||||||
DividerItem divider = new DividerItem(getContext());
|
private void setDescriptionSpan(View view) {
|
||||||
int contextPadding = getResources().getDimensionPixelSize(R.dimen.content_padding);
|
String desc = requireContext().getString(R.string.add_photos_descr);
|
||||||
int contextPaddingSmall = getResources().getDimensionPixelSize(R.dimen.content_padding_small);
|
BoldSpannableString ss = new BoldSpannableString(desc, view.getContext());
|
||||||
divider.setMargins(contextPadding, contextPadding, contextPadding, contextPaddingSmall);
|
ss.setBold(OPEN_PLACE_REVIEWS);
|
||||||
items.add(divider);
|
ss.setBold(MAPILLARY);
|
||||||
|
ss.setBold(WEB_WIKIMEDIA);
|
||||||
|
ss.setBold(OPEN_STREET_MAP);
|
||||||
|
view.<TextView>findViewById(R.id.add_photos_descr).setText(ss);
|
||||||
|
}
|
||||||
|
|
||||||
items.add(new BottomSheetItemButton.Builder()
|
static class BoldSpannableString extends SpannableString {
|
||||||
.setTitle(getString(R.string.add_to_opr))
|
Context ctx;
|
||||||
.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));
|
public BoldSpannableString(CharSequence source, Context ctx) {
|
||||||
|
super(source);
|
||||||
|
this.ctx = ctx;
|
||||||
|
}
|
||||||
|
|
||||||
items.add(new BottomSheetItemButton.Builder()
|
public void setBold(String boldText) {
|
||||||
.setButtonType(UiUtilities.DialogButtonType.SECONDARY)
|
String source = toString();
|
||||||
.setTitle(getString(R.string.add_to_mapillary))
|
setSpan(new CustomTypefaceSpan(FontCache.getRobotoMedium(ctx)),
|
||||||
.setLayoutId(R.layout.bottom_sheet_button)
|
source.indexOf(boldText), source.indexOf(boldText) + boldText.length(),
|
||||||
.setOnClickListener(new View.OnClickListener() {
|
Spanned.SPAN_INCLUSIVE_INCLUSIVE);
|
||||||
@Override
|
}
|
||||||
public void onClick(View v) {
|
}
|
||||||
Activity activity = getActivity();
|
|
||||||
if (activity instanceof MapActivity) {
|
|
||||||
}
|
|
||||||
dismiss();
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.create());
|
|
||||||
|
|
||||||
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
|
@Override
|
||||||
|
@ -76,10 +130,14 @@ public class AddPhotosBottomSheetDialogFragment extends MenuBottomSheetDialogFra
|
||||||
return R.string.shared_string_cancel;
|
return R.string.shared_string_cancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void showInstance(@NonNull FragmentManager fragmentManager) {
|
public static void showInstance(@NonNull FragmentManager fm) {
|
||||||
if (!fragmentManager.isStateSaved()) {
|
try {
|
||||||
AddPhotosBottomSheetDialogFragment fragment = new AddPhotosBottomSheetDialogFragment();
|
if (!fm.isStateSaved()) {
|
||||||
fragment.show(fragmentManager, TAG);
|
AddPhotosBottomSheetDialogFragment fragment = new AddPhotosBottomSheetDialogFragment();
|
||||||
|
fragment.show(fm, TAG);
|
||||||
|
}
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
LOG.error("showInstance", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue