Small fixes for description icon
This commit is contained in:
parent
c963740d18
commit
d30532aac8
3 changed files with 61 additions and 62 deletions
|
@ -135,6 +135,7 @@
|
||||||
android:id="@+id/address_edit"
|
android:id="@+id/address_edit"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="start"
|
||||||
android:maxLines="4"
|
android:maxLines="4"
|
||||||
android:minHeight="@dimen/favorites_list_item_height"
|
android:minHeight="@dimen/favorites_list_item_height"
|
||||||
android:paddingStart="@dimen/content_padding_small"
|
android:paddingStart="@dimen/content_padding_small"
|
||||||
|
@ -142,7 +143,6 @@
|
||||||
android:paddingEnd="@dimen/content_padding_small"
|
android:paddingEnd="@dimen/content_padding_small"
|
||||||
android:paddingRight="@dimen/content_padding_small"
|
android:paddingRight="@dimen/content_padding_small"
|
||||||
android:textSize="@dimen/default_list_text_size"
|
android:textSize="@dimen/default_list_text_size"
|
||||||
android:gravity="left"
|
|
||||||
tools:text="@string/lorem_ipsum" />
|
tools:text="@string/lorem_ipsum" />
|
||||||
|
|
||||||
</com.google.android.material.textfield.TextInputLayout>
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
@ -158,36 +158,37 @@
|
||||||
android:id="@+id/address_button"
|
android:id="@+id/address_button"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
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_marginStart="@dimen/content_padding_half"
|
||||||
android:layout_marginLeft="@dimen/content_padding_half"
|
android:layout_marginLeft="@dimen/content_padding_half"
|
||||||
android:layout_marginEnd="@dimen/content_padding"
|
android:layout_marginEnd="@dimen/content_padding"
|
||||||
android:layout_marginRight="@dimen/content_padding"
|
android:layout_marginRight="@dimen/content_padding"
|
||||||
android:paddingTop="@dimen/content_padding_half"
|
android:layout_weight="1"
|
||||||
android:paddingBottom="@dimen/content_padding_half"
|
|
||||||
android:drawablePadding="8dp"
|
android:drawablePadding="8dp"
|
||||||
android:duplicateParentState="true"
|
android:duplicateParentState="true"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
|
android:minHeight="@dimen/setting_list_item_small_height"
|
||||||
android:paddingStart="@dimen/content_padding_half"
|
android:paddingStart="@dimen/content_padding_half"
|
||||||
android:paddingLeft="@dimen/content_padding_half"
|
android:paddingLeft="@dimen/content_padding_half"
|
||||||
|
android:paddingTop="@dimen/content_padding_half"
|
||||||
android:paddingEnd="@dimen/content_padding_half"
|
android:paddingEnd="@dimen/content_padding_half"
|
||||||
android:paddingRight="@dimen/content_padding_half"
|
android:paddingRight="@dimen/content_padding_half"
|
||||||
|
android:paddingBottom="@dimen/content_padding_half"
|
||||||
android:text="@string/add_address"
|
android:text="@string/add_address"
|
||||||
android:textSize="@dimen/default_desc_text_size"
|
android:textSize="@dimen/default_desc_text_size"
|
||||||
osmand:typeface="@string/font_roboto_medium"
|
osmand:typeface="@string/font_roboto_medium"
|
||||||
tools:text="@string/add_address" />
|
tools:text="@string/add_address" />
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatImageView
|
<ImageButton
|
||||||
android:id="@+id/delete_address_icon"
|
android:id="@+id/delete_address_icon"
|
||||||
android:layout_width="@dimen/content_padding"
|
style="@style/Widget.AppCompat.Toolbar.Button.Navigation"
|
||||||
android:layout_height="@dimen/content_padding"
|
android:layout_width="@dimen/setting_list_item_small_height"
|
||||||
|
android:layout_height="@dimen/setting_list_item_small_height"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:layout_marginStart="@dimen/content_padding_small"
|
android:layout_marginStart="@dimen/list_item_button_padding"
|
||||||
android:layout_marginLeft="@dimen/content_padding_small"
|
android:layout_marginLeft="@dimen/list_item_button_padding"
|
||||||
android:layout_marginEnd="@dimen/content_padding"
|
android:layout_marginEnd="@dimen/list_item_button_padding"
|
||||||
android:layout_marginRight="@dimen/content_padding"
|
android:layout_marginRight="@dimen/list_item_button_padding"
|
||||||
android:contentDescription="@string/shared_string_list"
|
android:contentDescription="@string/delete_address"
|
||||||
app:srcCompat="@drawable/ic_action_trash_basket_16" />
|
app:srcCompat="@drawable/ic_action_trash_basket_16" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
|
@ -243,8 +243,8 @@ public class FavoritePointEditorFragmentNew extends PointEditorFragmentNew {
|
||||||
if (favorite != null) {
|
if (favorite != null) {
|
||||||
final FavouritePoint point = new FavouritePoint(favorite.getLatitude(), favorite.getLongitude(),
|
final FavouritePoint point = new FavouritePoint(favorite.getLatitude(), favorite.getLongitude(),
|
||||||
getNameTextValue(), getCategoryTextValue());
|
getNameTextValue(), getCategoryTextValue());
|
||||||
point.setDescription(isDescriptionAvailable()?getDescriptionTextValue():null);
|
point.setDescription(isDescriptionAvailable() ? getDescriptionTextValue() : null);
|
||||||
point.setAddress(isAddressAvailable()?getAddressTextValue():null);
|
point.setAddress(isAddressAvailable() ? getAddressTextValue() : null);
|
||||||
point.setColor(color);
|
point.setColor(color);
|
||||||
point.setBackgroundType(backgroundType);
|
point.setBackgroundType(backgroundType);
|
||||||
point.setIconId(iconId);
|
point.setIconId(iconId);
|
||||||
|
@ -259,8 +259,8 @@ public class FavoritePointEditorFragmentNew extends PointEditorFragmentNew {
|
||||||
if (favorite != null) {
|
if (favorite != null) {
|
||||||
final FavouritePoint point = new FavouritePoint(favorite.getLatitude(), favorite.getLongitude(),
|
final FavouritePoint point = new FavouritePoint(favorite.getLatitude(), favorite.getLongitude(),
|
||||||
getNameTextValue(), getCategoryTextValue());
|
getNameTextValue(), getCategoryTextValue());
|
||||||
point.setDescription(isDescriptionAvailable()?getDescriptionTextValue():null);
|
point.setDescription(isDescriptionAvailable() ? getDescriptionTextValue() : null);
|
||||||
point.setAddress(isAddressAvailable()?getAddressTextValue():null);
|
point.setAddress(isAddressAvailable() ? getAddressTextValue() : null);
|
||||||
point.setColor(color);
|
point.setColor(color);
|
||||||
point.setBackgroundType(backgroundType);
|
point.setBackgroundType(backgroundType);
|
||||||
point.setIconId(iconId);
|
point.setIconId(iconId);
|
||||||
|
|
|
@ -27,6 +27,7 @@ import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.activity.OnBackPressedCallback;
|
import androidx.activity.OnBackPressedCallback;
|
||||||
import androidx.annotation.ColorInt;
|
import androidx.annotation.ColorInt;
|
||||||
|
import androidx.annotation.ColorRes;
|
||||||
import androidx.annotation.DrawableRes;
|
import androidx.annotation.DrawableRes;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
@ -39,7 +40,6 @@ import androidx.fragment.app.FragmentActivity;
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import com.google.android.material.textfield.TextInputEditText;
|
|
||||||
import com.google.android.material.textfield.TextInputLayout;
|
import com.google.android.material.textfield.TextInputLayout;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
import net.osmand.AndroidUtils;
|
||||||
|
@ -81,6 +81,7 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
|
||||||
private TextView addDelDescription;
|
private TextView addDelDescription;
|
||||||
private TextView addAddressBtn;
|
private TextView addAddressBtn;
|
||||||
private TextView addToHiddenGroupInfo;
|
private TextView addToHiddenGroupInfo;
|
||||||
|
private ImageView deleteAddressIcon;
|
||||||
private boolean cancelled;
|
private boolean cancelled;
|
||||||
private boolean nightMode;
|
private boolean nightMode;
|
||||||
@DrawableRes
|
@DrawableRes
|
||||||
|
@ -167,7 +168,7 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
final int activeColorResId = nightMode ? R.color.active_color_primary_dark : R.color.active_color_primary_light;
|
final int activeColorResId = getActiveColorRes();
|
||||||
ImageView toolbarAction = (ImageView) view.findViewById(R.id.toolbar_action);
|
ImageView toolbarAction = (ImageView) view.findViewById(R.id.toolbar_action);
|
||||||
view.findViewById(R.id.background_layout).setBackgroundResource(nightMode
|
view.findViewById(R.id.background_layout).setBackgroundResource(nightMode
|
||||||
? R.color.app_bar_color_dark : R.color.list_background_color_light);
|
? R.color.app_bar_color_dark : R.color.list_background_color_light);
|
||||||
|
@ -247,78 +248,69 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
|
||||||
if (getDescriptionInitValue() != null) {
|
if (getDescriptionInitValue() != null) {
|
||||||
descriptionEdit.setText(getDescriptionInitValue());
|
descriptionEdit.setText(getDescriptionInitValue());
|
||||||
}
|
}
|
||||||
if (getAddressInitValue() != null){
|
|
||||||
addressEdit.setText(getAddressInitValue());
|
|
||||||
addressEdit.setSelection(addressEdit.getText().length());
|
|
||||||
}
|
|
||||||
|
|
||||||
descriptionCaption = view.findViewById(R.id.description);
|
descriptionCaption = view.findViewById(R.id.description);
|
||||||
addressCaption = view.findViewById(R.id.address);
|
addressCaption = view.findViewById(R.id.address);
|
||||||
addDelDescription = (TextView) view.findViewById(R.id.description_button);
|
addDelDescription = (TextView) view.findViewById(R.id.description_button);
|
||||||
addAddressBtn = view.findViewById(R.id.address_button);
|
addAddressBtn = view.findViewById(R.id.address_button);
|
||||||
|
deleteAddressIcon = view.findViewById(R.id.delete_address_icon);
|
||||||
|
deleteAddressIcon.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_trash_basket_16, activeColorResId));
|
||||||
|
|
||||||
addDelDescription.setTextColor(getResources().getColor(activeColorResId));
|
addDelDescription.setTextColor(getResources().getColor(activeColorResId));
|
||||||
addAddressBtn.setTextColor(getResources().getColor(activeColorResId));
|
addAddressBtn.setTextColor(getResources().getColor(activeColorResId));
|
||||||
addAddressBtn.setCompoundDrawablesWithIntrinsicBounds(
|
Drawable addressIcon = app.getUIUtilities().getIcon(R.drawable.ic_action_location_16, activeColorResId);
|
||||||
app.getUIUtilities().getIcon(R.drawable.ic_action_location_16,
|
addAddressBtn.setCompoundDrawablesWithIntrinsicBounds(addressIcon, null, null, null);
|
||||||
activeColorResId),null,null,null);
|
|
||||||
selectIconDescription(activeColorResId);
|
|
||||||
addDelDescription.setOnClickListener(new View.OnClickListener() {
|
addDelDescription.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
if (descriptionCaption.getVisibility() != View.VISIBLE) {
|
if (descriptionCaption.getVisibility() != View.VISIBLE) {
|
||||||
descriptionCaption.setVisibility(View.VISIBLE);
|
descriptionCaption.setVisibility(View.VISIBLE);
|
||||||
addDelDescription.setText(view.getResources().getString(R.string.delete_description));
|
addDelDescription.setText(view.getResources().getString(R.string.delete_description));
|
||||||
addDelDescription.setCompoundDrawablesWithIntrinsicBounds(
|
|
||||||
app.getUIUtilities().getIcon(R.drawable.ic_action_trash_basket_16,
|
|
||||||
activeColorResId),null,null,null);
|
|
||||||
View descriptionEdit = view.findViewById(R.id.description_edit);
|
View descriptionEdit = view.findViewById(R.id.description_edit);
|
||||||
descriptionEdit.requestFocus();
|
descriptionEdit.requestFocus();
|
||||||
AndroidUtils.softKeyboardDelayed(getActivity(), descriptionEdit);
|
AndroidUtils.softKeyboardDelayed(getActivity(), descriptionEdit);
|
||||||
} else {
|
} else {
|
||||||
descriptionCaption.setVisibility(View.GONE);
|
descriptionCaption.setVisibility(View.GONE);
|
||||||
addDelDescription.setText(view.getResources().getString(R.string.add_description));
|
addDelDescription.setText(view.getResources().getString(R.string.add_description));
|
||||||
addDelDescription.setCompoundDrawablesWithIntrinsicBounds(
|
|
||||||
app.getUIUtilities().getIcon(R.drawable.ic_action_description_16,
|
|
||||||
activeColorResId),null,null,null);
|
|
||||||
AndroidUtils.hideSoftKeyboard(requireActivity(), descriptionEdit);
|
AndroidUtils.hideSoftKeyboard(requireActivity(), descriptionEdit);
|
||||||
descriptionEdit.clearFocus();
|
descriptionEdit.clearFocus();
|
||||||
}
|
}
|
||||||
|
updateDescriptionIcon();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
AndroidUiHelper.updateVisibility(addressCaption, false);
|
AndroidUiHelper.updateVisibility(addressCaption, false);
|
||||||
if(!Algorithms.isEmpty(getAddressInitValue())){
|
|
||||||
addAddressBtn.setText(getAddressInitValue());
|
String addressInitValue = getAddressInitValue();
|
||||||
|
if (!Algorithms.isEmpty(addressInitValue)) {
|
||||||
|
addressEdit.setText(addressInitValue);
|
||||||
|
addAddressBtn.setText(addressInitValue);
|
||||||
|
addressEdit.setSelection(addressInitValue.length());
|
||||||
|
AndroidUiHelper.updateVisibility(deleteAddressIcon, true);
|
||||||
} else {
|
} else {
|
||||||
addAddressBtn.setText(getString(R.string.add_address));
|
addAddressBtn.setText(getString(R.string.add_address));
|
||||||
};
|
AndroidUiHelper.updateVisibility(deleteAddressIcon, false);
|
||||||
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() {
|
deleteAddressIcon.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
addressCaption.setVisibility(View.GONE);
|
|
||||||
addAddressBtn.setText(view.getResources().getString(R.string.add_address));
|
|
||||||
addressEdit.setText("");
|
addressEdit.setText("");
|
||||||
deleteAddressIcon.setVisibility(View.GONE);
|
addAddressBtn.setText(view.getResources().getString(R.string.add_address));
|
||||||
|
AndroidUiHelper.updateVisibility(addressCaption, false);
|
||||||
|
AndroidUiHelper.updateVisibility(deleteAddressIcon, false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
final View addressRow = view.findViewById(R.id.address_row);
|
||||||
addAddressBtn.setOnClickListener(new View.OnClickListener() {
|
addAddressBtn.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
if (addressCaption.getVisibility() != View.VISIBLE) {
|
if (addressCaption.getVisibility() != View.VISIBLE) {
|
||||||
addressCaption.setVisibility(View.VISIBLE);
|
addressCaption.setVisibility(View.VISIBLE);
|
||||||
TextInputEditText addressEdit = view.findViewById(R.id.address_edit);
|
|
||||||
View row = view.findViewById(R.id.address_row);
|
|
||||||
row.setVisibility(View.GONE);
|
|
||||||
addAddressBtn.setText(getString(R.string.add_address));
|
|
||||||
addressEdit.requestFocus();
|
addressEdit.requestFocus();
|
||||||
addressEdit.setSelection(addressEdit.getText().length());
|
addressEdit.setSelection(addressEdit.getText().length());
|
||||||
AndroidUtils.softKeyboardDelayed(requireActivity(),addressEdit);
|
AndroidUtils.softKeyboardDelayed(requireActivity(), addressEdit);
|
||||||
|
AndroidUiHelper.updateVisibility(addressRow, false);
|
||||||
} else {
|
} else {
|
||||||
addressCaption.setVisibility(View.GONE);
|
addressCaption.setVisibility(View.GONE);
|
||||||
addAddressBtn.setText(getAddressTextValue());
|
addAddressBtn.setText(getAddressTextValue());
|
||||||
|
@ -393,19 +385,17 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateDescriptionIcon() {
|
||||||
private void selectIconDescription(int activeColorResId) {
|
int iconId;
|
||||||
if (descriptionCaption.getVisibility() != View.VISIBLE) {
|
if (descriptionCaption.getVisibility() == View.VISIBLE) {
|
||||||
addDelDescription.setCompoundDrawablesWithIntrinsicBounds(
|
iconId = R.drawable.ic_action_trash_basket_16;
|
||||||
app.getUIUtilities().getIcon(R.drawable.ic_action_description_16, activeColorResId),null,null,null);
|
|
||||||
} else {
|
} else {
|
||||||
addDelDescription.setCompoundDrawablesWithIntrinsicBounds(
|
iconId = R.drawable.ic_action_description_16;
|
||||||
app.getUIUtilities().getIcon(R.drawable.ic_action_trash_basket_16,
|
|
||||||
activeColorResId),null,null,null);
|
|
||||||
}
|
}
|
||||||
|
Drawable icon = app.getUIUtilities().getIcon(iconId, getActiveColorRes());
|
||||||
|
addDelDescription.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void checkEmptyName(Editable name, TextInputLayout nameCaption, View saveButton) {
|
private void checkEmptyName(Editable name, TextInputLayout nameCaption, View saveButton) {
|
||||||
if (name.toString().trim().isEmpty()) {
|
if (name.toString().trim().isEmpty()) {
|
||||||
nameCaption.setError(app.getString(R.string.please_provide_point_name_error));
|
nameCaption.setError(app.getString(R.string.please_provide_point_name_error));
|
||||||
|
@ -443,14 +433,22 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
|
||||||
descriptionCaption.setVisibility(View.GONE);
|
descriptionCaption.setVisibility(View.GONE);
|
||||||
addDelDescription.setText(app.getString(R.string.add_description));
|
addDelDescription.setText(app.getString(R.string.add_description));
|
||||||
}
|
}
|
||||||
|
updateDescriptionIcon();
|
||||||
}
|
}
|
||||||
boolean isAddressAvailable(){
|
|
||||||
|
boolean isAddressAvailable() {
|
||||||
return addressCaption.getVisibility() == View.VISIBLE;
|
return addressCaption.getVisibility() == View.VISIBLE;
|
||||||
}
|
}
|
||||||
boolean isDescriptionAvailable(){
|
|
||||||
|
boolean isDescriptionAvailable() {
|
||||||
return descriptionCaption.getVisibility() == View.VISIBLE;
|
return descriptionCaption.getVisibility() == View.VISIBLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ColorRes
|
||||||
|
private int getActiveColorRes() {
|
||||||
|
return nightMode ? R.color.active_color_primary_dark : R.color.active_color_primary_light;
|
||||||
|
}
|
||||||
|
|
||||||
private void createGroupSelector() {
|
private void createGroupSelector() {
|
||||||
groupListAdapter = new GroupAdapter();
|
groupListAdapter = new GroupAdapter();
|
||||||
groupRecyclerView = view.findViewById(R.id.group_recycler_view);
|
groupRecyclerView = view.findViewById(R.id.group_recycler_view);
|
||||||
|
|
Loading…
Reference in a new issue