Edit_favorite_screen
This commit is contained in:
parent
d8bd5f936e
commit
ce4fcc0ebe
4 changed files with 108 additions and 32 deletions
|
@ -142,29 +142,62 @@
|
|||
android:paddingEnd="@dimen/content_padding_small"
|
||||
android:paddingRight="@dimen/content_padding_small"
|
||||
android:textSize="@dimen/default_list_text_size"
|
||||
android:gravity="left"
|
||||
tools:text="@string/lorem_ipsum" />
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/address_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="@dimen/context_menu_buttons_bottom_height"
|
||||
android:layout_marginStart="@dimen/content_padding_half"
|
||||
android:layout_marginLeft="@dimen/content_padding_half"
|
||||
android:layout_marginTop="@dimen/content_padding_small"
|
||||
android:drawablePadding="8dp"
|
||||
android:duplicateParentState="true"
|
||||
android:gravity="center"
|
||||
android:paddingStart="@dimen/content_padding_half"
|
||||
android:paddingLeft="@dimen/content_padding_half"
|
||||
android:paddingEnd="@dimen/content_padding_half"
|
||||
android:paddingRight="@dimen/content_padding_half"
|
||||
android:text="@string/add_address"
|
||||
android:textSize="@dimen/default_desc_text_size"
|
||||
osmand:typeface="@string/font_roboto_medium"
|
||||
tools:text="@string/add_address" />
|
||||
<LinearLayout
|
||||
android:id="@+id/address_row"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/address_button"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="@dimen/setting_list_item_small_height"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginStart="@dimen/content_padding_half"
|
||||
android:layout_marginLeft="@dimen/content_padding_half"
|
||||
android:layout_marginEnd="@dimen/content_padding"
|
||||
android:layout_marginRight="@dimen/content_padding"
|
||||
android:paddingTop="@dimen/content_padding_half"
|
||||
android:paddingBottom="@dimen/content_padding_half"
|
||||
android:drawablePadding="8dp"
|
||||
android:duplicateParentState="true"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingStart="@dimen/content_padding_half"
|
||||
android:paddingLeft="@dimen/content_padding_half"
|
||||
android:paddingEnd="@dimen/content_padding_half"
|
||||
android:paddingRight="@dimen/content_padding_half"
|
||||
android:text="@string/add_address"
|
||||
android:textSize="@dimen/default_desc_text_size"
|
||||
osmand:typeface="@string/font_roboto_medium"
|
||||
tools:text="@string/add_address" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/delete_address_icon"
|
||||
android:layout_width="@dimen/content_padding"
|
||||
android:layout_height="@dimen/content_padding"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginStart="@dimen/content_padding_small"
|
||||
android:layout_marginLeft="@dimen/content_padding_small"
|
||||
android:layout_marginEnd="@dimen/content_padding"
|
||||
android:layout_marginRight="@dimen/content_padding"
|
||||
android:contentDescription="@string/shared_string_list"
|
||||
app:srcCompat="@drawable/ic_action_trash_basket_16" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginLeft="@dimen/content_padding"
|
||||
android:layout_marginRight="@dimen/content_padding"
|
||||
android:background="?attr/dashboard_divider" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/description"
|
||||
|
|
|
@ -160,11 +160,13 @@ public class FavouritePointMenuController extends MenuController {
|
|||
@NonNull
|
||||
@Override
|
||||
public CharSequence getSubtypeStr() {
|
||||
Typeface typeface = FontCache.getRobotoRegular(getMapActivity());
|
||||
SpannableString addressSpannable = new SpannableString(fav.getAddress());
|
||||
addressSpannable.setSpan(new CustomTypefaceSpan(typeface), 0, addressSpannable.length(), 0);
|
||||
|
||||
return addressSpannable;
|
||||
if (fav.getAddress() != null) {Typeface typeface = FontCache.getRobotoRegular(getMapActivity());
|
||||
SpannableString addressSpannable = new SpannableString(fav.getAddress());
|
||||
addressSpannable.setSpan(new CustomTypefaceSpan(typeface), 0, addressSpannable.length(), 0);
|
||||
return addressSpannable;
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -243,8 +243,8 @@ public class FavoritePointEditorFragmentNew extends PointEditorFragmentNew {
|
|||
if (favorite != null) {
|
||||
final FavouritePoint point = new FavouritePoint(favorite.getLatitude(), favorite.getLongitude(),
|
||||
getNameTextValue(), getCategoryTextValue());
|
||||
point.setDescription(getDescriptionTextValue());
|
||||
point.setAddress(getAddressTextValue());
|
||||
point.setDescription(isDescriptionAvailable()?getDescriptionTextValue():null);
|
||||
point.setAddress(isAddressAvailable()?getAddressTextValue():null);
|
||||
point.setColor(color);
|
||||
point.setBackgroundType(backgroundType);
|
||||
point.setIconId(iconId);
|
||||
|
@ -259,8 +259,8 @@ public class FavoritePointEditorFragmentNew extends PointEditorFragmentNew {
|
|||
if (favorite != null) {
|
||||
final FavouritePoint point = new FavouritePoint(favorite.getLatitude(), favorite.getLongitude(),
|
||||
getNameTextValue(), getCategoryTextValue());
|
||||
point.setDescription(getDescriptionTextValue());
|
||||
point.setAddress(getAddressTextValue());
|
||||
point.setDescription(isDescriptionAvailable()?getDescriptionTextValue():null);
|
||||
point.setAddress(isAddressAvailable()?getAddressTextValue():null);
|
||||
point.setColor(color);
|
||||
point.setBackgroundType(backgroundType);
|
||||
point.setIconId(iconId);
|
||||
|
|
|
@ -243,9 +243,9 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
|
|||
addDelDescription.setTextColor(getResources().getColor(activeColorResId));
|
||||
addAddressBtn.setTextColor(getResources().getColor(activeColorResId));
|
||||
addAddressBtn.setCompoundDrawablesWithIntrinsicBounds(
|
||||
app.getUIUtilities().getIcon(R.drawable.ic_action_location_16, activeColorResId),null,null,null);
|
||||
addDelDescription.setCompoundDrawablesWithIntrinsicBounds(
|
||||
app.getUIUtilities().getIcon(R.drawable.ic_action_description_16, activeColorResId),null,null,null);
|
||||
app.getUIUtilities().getIcon(R.drawable.ic_action_location_16,
|
||||
activeColorResId),null,null,null);
|
||||
selectIconDescription(activeColorResId);
|
||||
addDelDescription.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
@ -270,13 +270,36 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
|
|||
}
|
||||
});
|
||||
AndroidUiHelper.updateVisibility(addressCaption, false);
|
||||
addAddressBtn.setText(getAddressInitValue());
|
||||
if(!Algorithms.isEmpty(getAddressInitValue())){
|
||||
addAddressBtn.setText(getAddressInitValue());
|
||||
} else {
|
||||
addAddressBtn.setText(getString(R.string.add_address));
|
||||
};
|
||||
final ImageView deleteAddressIcon = (ImageView) view.findViewById(R.id.delete_address_icon);
|
||||
deleteAddressIcon.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_trash_basket_16, activeColorResId));
|
||||
if(!Algorithms.isEmpty(getAddressInitValue())){
|
||||
deleteAddressIcon.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
deleteAddressIcon.setVisibility(View.GONE);
|
||||
}
|
||||
deleteAddressIcon.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
addressCaption.setVisibility(View.GONE);
|
||||
addAddressBtn.setText(view.getResources().getString(R.string.add_address));
|
||||
addressEdit.setText("");
|
||||
deleteAddressIcon.setVisibility(View.GONE);
|
||||
}
|
||||
});
|
||||
addAddressBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (addressCaption.getVisibility() != View.VISIBLE) {
|
||||
addressCaption.setVisibility(View.VISIBLE);
|
||||
addAddressBtn.setText(view.getResources().getString(R.string.delete_address));
|
||||
View row = view.findViewById(R.id.address_row);
|
||||
row.setVisibility(View.GONE);
|
||||
addAddressBtn.setText(getString(R.string.add_address));
|
||||
View addressEdit = view.findViewById(R.id.address_edit);
|
||||
addressEdit.requestFocus();
|
||||
AndroidUtils.softKeyboardDelayed(requireActivity(),addressEdit);
|
||||
|
@ -354,6 +377,19 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
|
|||
return view;
|
||||
}
|
||||
|
||||
|
||||
private void selectIconDescription(int activeColorResId) {
|
||||
if (descriptionCaption.getVisibility() != View.VISIBLE) {
|
||||
addDelDescription.setCompoundDrawablesWithIntrinsicBounds(
|
||||
app.getUIUtilities().getIcon(R.drawable.ic_action_description_16, activeColorResId),null,null,null);
|
||||
} else {
|
||||
addDelDescription.setCompoundDrawablesWithIntrinsicBounds(
|
||||
app.getUIUtilities().getIcon(R.drawable.ic_action_trash_basket_16,
|
||||
activeColorResId),null,null,null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void checkEmptyName(Editable name, TextInputLayout nameCaption, View saveButton) {
|
||||
if (name.toString().trim().isEmpty()) {
|
||||
nameCaption.setError(app.getString(R.string.please_provide_point_name_error));
|
||||
|
@ -393,7 +429,12 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
boolean isAddressAvailable(){
|
||||
return addressCaption.getVisibility() == View.VISIBLE;
|
||||
}
|
||||
boolean isDescriptionAvailable(){
|
||||
return descriptionCaption.getVisibility() == View.VISIBLE;
|
||||
}
|
||||
private void createGroupSelector() {
|
||||
groupListAdapter = new GroupAdapter();
|
||||
groupRecyclerView = view.findViewById(R.id.group_recycler_view);
|
||||
|
|
Loading…
Reference in a new issue