mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 21:03:54 +01:00
* Fixed Grey empty screen at Upload wizard caption step after denying files permission * Empty commit * Fixed loop issue * Created docs for earlier commits * Fixed javadoc * Fixed spaces * Added added basic features to OSM Maps * Added search location feature * Added filter to Open Street Maps * Fixed chipGroup in Open Street Maps * Removed mapBox code * Removed mapBox's code * Reformat code * Reformatted code * Removed rotation feature to map * Removed rotation files and Fixed Marker click problem * Ignored failing tests * Added voice input feature * Fixed test cases * Changed caption and description text * Replaced mapbox to osmdroid in upload activity * Fixed Unit Tests * Made selected marker to be fixed on map * Changed color of map marker * Fixes #5439 by capitalizing first letter of voice input * Made UI changes in UploadMediaDetailAdapter * Added javadoc --------- Co-authored-by: Nicolas Raoul <nicolas.raoul@gmail.com>
This commit is contained in:
parent
ab3540312a
commit
3d0e65c92c
14 changed files with 263 additions and 112 deletions
|
|
@ -73,7 +73,6 @@ class DescriptionEditActivity : BaseActivity(), UploadMediaDetailAdapter.EventLi
|
|||
savedLanguageValue = bundle.getString(Prefs.DESCRIPTION_LANGUAGE)!!
|
||||
initRecyclerView(descriptionAndCaptions)
|
||||
|
||||
binding.btnAddDescription.setOnClickListener(::onButtonAddDescriptionClicked)
|
||||
binding.btnEditSubmit.setOnClickListener(::onSubmitButtonClicked)
|
||||
binding.toolbarBackButton.setOnClickListener(::onBackButtonClicked)
|
||||
}
|
||||
|
|
@ -112,17 +111,20 @@ class DescriptionEditActivity : BaseActivity(), UploadMediaDetailAdapter.EventLi
|
|||
|
||||
override fun onPrimaryCaptionTextChange(isNotEmpty: Boolean) {}
|
||||
|
||||
private fun onBackButtonClicked(view: View) {
|
||||
onBackPressed()
|
||||
}
|
||||
|
||||
private fun onButtonAddDescriptionClicked(view: View) {
|
||||
/**
|
||||
* Adds new language item to RecyclerView
|
||||
*/
|
||||
override fun addLanguage() {
|
||||
val uploadMediaDetail = UploadMediaDetail()
|
||||
uploadMediaDetail.isManuallyAdded = true //This was manually added by the user
|
||||
uploadMediaDetailAdapter.addDescription(uploadMediaDetail)
|
||||
rvDescriptions!!.smoothScrollToPosition(uploadMediaDetailAdapter.itemCount - 1)
|
||||
}
|
||||
|
||||
private fun onBackButtonClicked(view: View) {
|
||||
onBackPressed()
|
||||
}
|
||||
|
||||
private fun onSubmitButtonClicked(view: View) {
|
||||
showLoggingProgressBar()
|
||||
val uploadMediaDetails = uploadMediaDetailAdapter.items
|
||||
|
|
|
|||
|
|
@ -15,12 +15,14 @@ import android.view.ViewGroup;
|
|||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.EditText;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import butterknife.BindView;
|
||||
|
|
@ -190,6 +192,7 @@ public class UploadMediaDetailAdapter extends
|
|||
}
|
||||
notifyItemRemoved(position);
|
||||
notifyItemRangeChanged(position, uploadMediaDetails.size() - position);
|
||||
updateAddButtonVisibility();
|
||||
}
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder {
|
||||
|
|
@ -213,6 +216,12 @@ public class UploadMediaDetailAdapter extends
|
|||
@BindView(R.id.btn_remove)
|
||||
ImageView removeButton;
|
||||
|
||||
@BindView(R.id.btn_add)
|
||||
ImageView addButton;
|
||||
|
||||
@BindView(R.id.cl_parent)
|
||||
ConstraintLayout clParent;
|
||||
|
||||
@BindView(R.id.ll_write_better_caption)
|
||||
LinearLayout betterCaptionLinearLayout;
|
||||
|
||||
|
|
@ -292,6 +301,17 @@ public class UploadMediaDetailAdapter extends
|
|||
descItemEditText.addTextChangedListener(descriptionListener);
|
||||
initLanguage(position, uploadMediaDetail);
|
||||
|
||||
if (fragment != null) {
|
||||
FrameLayout.LayoutParams newLayoutParams = (FrameLayout.LayoutParams) clParent.getLayoutParams();
|
||||
newLayoutParams.topMargin = 0;
|
||||
newLayoutParams.leftMargin = 0;
|
||||
newLayoutParams.rightMargin = 0;
|
||||
newLayoutParams.bottomMargin = 0;
|
||||
clParent.setLayoutParams(newLayoutParams);
|
||||
}
|
||||
updateAddButtonVisibility();
|
||||
addButton.setOnClickListener(v -> eventListener.addLanguage());
|
||||
|
||||
//If the description was manually added by the user, it deserves focus, if not, let the user decide
|
||||
if (uploadMediaDetail.isManuallyAdded()) {
|
||||
captionItemEditText.requestFocus();
|
||||
|
|
@ -557,6 +577,55 @@ public class UploadMediaDetailAdapter extends
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Hides the visibility of the "Add" button for all items in the RecyclerView except
|
||||
* the last item in RecyclerView
|
||||
*/
|
||||
private void updateAddButtonVisibility() {
|
||||
int lastItemPosition = getItemCount() - 1;
|
||||
// Hide Add Button for all items
|
||||
for (int i = 0; i < getItemCount(); i++) {
|
||||
if (fragment != null) {
|
||||
if (fragment.getView() != null) {
|
||||
ViewHolder holder = (ViewHolder) ((RecyclerView) fragment.getView()
|
||||
.findViewById(R.id.rv_descriptions)).findViewHolderForAdapterPosition(i);
|
||||
if (holder != null) {
|
||||
holder.addButton.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (this.activity != null) {
|
||||
ViewHolder holder = (ViewHolder) ((RecyclerView) activity.findViewById(
|
||||
R.id.rv_descriptions_captions)).findViewHolderForAdapterPosition(i);
|
||||
if (holder != null) {
|
||||
holder.addButton.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Show Add Button for the last item
|
||||
if (fragment != null) {
|
||||
if (fragment.getView() != null) {
|
||||
ViewHolder lastItemHolder = (ViewHolder) ((RecyclerView) fragment.getView()
|
||||
.findViewById(R.id.rv_descriptions)).findViewHolderForAdapterPosition(
|
||||
lastItemPosition);
|
||||
if (lastItemHolder != null) {
|
||||
lastItemHolder.addButton.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (this.activity != null) {
|
||||
ViewHolder lastItemHolder = (ViewHolder) ((RecyclerView) activity
|
||||
.findViewById(R.id.rv_descriptions_captions)).findViewHolderForAdapterPosition(
|
||||
lastItemPosition);
|
||||
if (lastItemHolder != null) {
|
||||
lastItemHolder.addButton.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public interface Callback {
|
||||
|
||||
void showAlert(int mediaDetailDescription, int descriptionInfo);
|
||||
|
|
@ -565,6 +634,8 @@ public class UploadMediaDetailAdapter extends
|
|||
public interface EventListener {
|
||||
|
||||
void onPrimaryCaptionTextChange(boolean isNotEmpty);
|
||||
|
||||
void addLanguage();
|
||||
}
|
||||
|
||||
enum SelectedVoiceIcon {
|
||||
|
|
|
|||
|
|
@ -76,8 +76,12 @@ public class UploadMediaDetailFragment extends UploadBaseFragment implements
|
|||
public static final String LAST_ZOOM = "last_zoom_level_while_uploading";
|
||||
@BindView(R.id.tv_title)
|
||||
TextView tvTitle;
|
||||
@BindView(R.id.ib_map)
|
||||
AppCompatImageButton ibMap;
|
||||
@BindView(R.id.location_image_view)
|
||||
ImageView locationImageView;
|
||||
@BindView(R.id.location_text_view)
|
||||
TextView locationTextView;
|
||||
@BindView(R.id.ll_location_status)
|
||||
LinearLayout llLocationStatus;
|
||||
@BindView(R.id.ib_expand_collapse)
|
||||
AppCompatImageButton ibExpandCollapse;
|
||||
@BindView(R.id.ll_container_media_detail)
|
||||
|
|
@ -90,8 +94,8 @@ public class UploadMediaDetailFragment extends UploadBaseFragment implements
|
|||
AppCompatButton btnNext;
|
||||
@BindView(R.id.btn_previous)
|
||||
AppCompatButton btnPrevious;
|
||||
@BindView(R.id.edit_image)
|
||||
AppCompatButton editImage;
|
||||
@BindView(R.id.ll_edit_image)
|
||||
LinearLayout llEditImage;
|
||||
@BindView(R.id.tooltip)
|
||||
ImageView tooltip;
|
||||
|
||||
|
|
@ -195,13 +199,15 @@ public class UploadMediaDetailFragment extends UploadBaseFragment implements
|
|||
// If the image EXIF data contains the location, show the map icon with a green tick
|
||||
if (inAppPictureLocation != null ||
|
||||
(uploadableFile != null && uploadableFile.hasLocation())) {
|
||||
Drawable mapTick = getResources().getDrawable(R.drawable.ic_map_tick_white_24dp);
|
||||
ibMap.setImageDrawable(mapTick);
|
||||
Drawable mapTick = getResources().getDrawable(R.drawable.ic_map_available_20dp);
|
||||
locationImageView.setImageDrawable(mapTick);
|
||||
locationTextView.setText(R.string.edit_location);
|
||||
} else {
|
||||
// Otherwise, show the map icon with a red question mark
|
||||
Drawable mapQuestionMark =
|
||||
getResources().getDrawable(R.drawable.ic_map_question_white_24dp);
|
||||
ibMap.setImageDrawable(mapQuestionMark);
|
||||
getResources().getDrawable(R.drawable.ic_map_not_available_20dp);
|
||||
locationImageView.setImageDrawable(mapQuestionMark);
|
||||
locationTextView.setText(R.string.add_location);
|
||||
}
|
||||
|
||||
//If this is the last media, we have nothing to copy, lets not show the button
|
||||
|
|
@ -269,15 +275,7 @@ public class UploadMediaDetailFragment extends UploadBaseFragment implements
|
|||
callback.onPreviousButtonClicked(callback.getIndexInViewFlipper(this));
|
||||
}
|
||||
|
||||
@OnClick(R.id.btn_add_description)
|
||||
public void onButtonAddDescriptionClicked() {
|
||||
UploadMediaDetail uploadMediaDetail = new UploadMediaDetail();
|
||||
uploadMediaDetail.setManuallyAdded(true);//This was manually added by the user
|
||||
uploadMediaDetailAdapter.addDescription(uploadMediaDetail);
|
||||
rvDescriptions.smoothScrollToPosition(uploadMediaDetailAdapter.getItemCount()-1);
|
||||
}
|
||||
|
||||
@OnClick(R.id.edit_image)
|
||||
@OnClick(R.id.ll_edit_image)
|
||||
public void onEditButtonClicked() {
|
||||
presenter.onEditButtonClicked(callback.getIndexInViewFlipper(this));
|
||||
}
|
||||
|
|
@ -619,8 +617,9 @@ public class UploadMediaDetailFragment extends UploadBaseFragment implements
|
|||
editableUploadItem.getGpsCoords().setZoomLevel(zoom);
|
||||
|
||||
// Replace the map icon using the one with a green tick
|
||||
Drawable mapTick = getResources().getDrawable(R.drawable.ic_map_tick_white_24dp);
|
||||
ibMap.setImageDrawable(mapTick);
|
||||
Drawable mapTick = getResources().getDrawable(R.drawable.ic_map_available_20dp);
|
||||
locationImageView.setImageDrawable(mapTick);
|
||||
locationTextView.setText(R.string.edit_location);
|
||||
|
||||
Toast.makeText(getContext(), "Location Updated", Toast.LENGTH_LONG).show();
|
||||
|
||||
|
|
@ -682,8 +681,8 @@ public class UploadMediaDetailFragment extends UploadBaseFragment implements
|
|||
presenter.onDetachView();
|
||||
}
|
||||
|
||||
@OnClick(R.id.rl_container_title)
|
||||
public void onRlContainerTitleClicked() {
|
||||
@OnClick(R.id.ll_container_title)
|
||||
public void onLlContainerTitleClicked() {
|
||||
expandCollapseLlMediaDetail(!isExpanded);
|
||||
}
|
||||
|
||||
|
|
@ -697,7 +696,7 @@ public class UploadMediaDetailFragment extends UploadBaseFragment implements
|
|||
ibExpandCollapse.setRotation(ibExpandCollapse.getRotation() + 180);
|
||||
}
|
||||
|
||||
@OnClick(R.id.ib_map) public void onIbMapClicked() {
|
||||
@OnClick(R.id.ll_location_status) public void onIbMapClicked() {
|
||||
presenter.onMapIconClicked(callback.getIndexInViewFlipper(this));
|
||||
}
|
||||
|
||||
|
|
@ -711,6 +710,17 @@ public class UploadMediaDetailFragment extends UploadBaseFragment implements
|
|||
btnNext.setAlpha(isNotEmpty ? 1.0f : 0.5f);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds new language item to RecyclerView
|
||||
*/
|
||||
@Override
|
||||
public void addLanguage() {
|
||||
UploadMediaDetail uploadMediaDetail = new UploadMediaDetail();
|
||||
uploadMediaDetail.setManuallyAdded(true);//This was manually added by the user
|
||||
uploadMediaDetailAdapter.addDescription(uploadMediaDetail);
|
||||
rvDescriptions.smoothScrollToPosition(uploadMediaDetailAdapter.getItemCount()-1);
|
||||
}
|
||||
|
||||
public interface UploadMediaDetailFragmentCallback extends Callback {
|
||||
|
||||
void deletePictureAtIndex(int index);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue