mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 21:03:54 +01:00
* added copy to subsequent media button * minor change Co-authored-by: Pratham2305 <Pratham2305@users.noreply.github.com>
This commit is contained in:
parent
ff96f5047e
commit
a479dd5bb1
7 changed files with 54 additions and 44 deletions
|
|
@ -205,16 +205,16 @@ public class UploadRepository {
|
|||
}
|
||||
|
||||
/**
|
||||
* fetches and returns the previous upload item
|
||||
* fetches and returns the upload item
|
||||
*
|
||||
* @param index
|
||||
* @return
|
||||
*/
|
||||
public UploadItem getPreviousUploadItem(int index) {
|
||||
if (index - 1 >= 0) {
|
||||
return uploadModel.getItems().get(index - 1);
|
||||
public UploadItem getUploadItem(int index) {
|
||||
if (index >= 0) {
|
||||
return uploadModel.getItems().get(index);
|
||||
}
|
||||
return null; //There is no previous item to copy details
|
||||
return null; //There is no item to copy details
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import android.widget.CheckBox;
|
|||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.widget.AppCompatButton;
|
||||
|
|
@ -69,8 +70,8 @@ public class UploadMediaDetailFragment extends UploadBaseFragment implements
|
|||
@BindView(R.id.tooltip)
|
||||
ImageView tooltip;
|
||||
private UploadMediaDetailAdapter uploadMediaDetailAdapter;
|
||||
@BindView(R.id.btn_copy_prev_title_desc)
|
||||
AppCompatButton btnCopyPreviousTitleDesc;
|
||||
@BindView(R.id.btn_copy_subsequent_media)
|
||||
AppCompatButton btnCopyToSubsequentMedia;
|
||||
|
||||
@Inject
|
||||
UploadMediaDetailsContract.UserActionListener presenter;
|
||||
|
|
@ -123,9 +124,9 @@ public class UploadMediaDetailFragment extends UploadBaseFragment implements
|
|||
showInfoAlert(R.string.media_detail_step_title, R.string.media_details_tooltip);
|
||||
}
|
||||
});
|
||||
initRecyclerView();
|
||||
initPresenter();
|
||||
presenter.receiveImage(uploadableFile, place);
|
||||
initRecyclerView();
|
||||
|
||||
if (callback.getIndexInViewFlipper(this) == 0) {
|
||||
btnPrevious.setEnabled(false);
|
||||
|
|
@ -135,11 +136,11 @@ public class UploadMediaDetailFragment extends UploadBaseFragment implements
|
|||
btnPrevious.setAlpha(1.0f);
|
||||
}
|
||||
|
||||
//If this is the first media, we have nothing to copy, lets not show the button
|
||||
if (callback.getIndexInViewFlipper(this) == 0) {
|
||||
btnCopyPreviousTitleDesc.setVisibility(View.GONE);
|
||||
//If this is the last media, we have nothing to copy, lets not show the button
|
||||
if (callback.getIndexInViewFlipper(this) == callback.getTotalNumberOfSteps()-4) {
|
||||
btnCopyToSubsequentMedia.setVisibility(View.GONE);
|
||||
} else {
|
||||
btnCopyPreviousTitleDesc.setVisibility(View.VISIBLE);
|
||||
btnCopyToSubsequentMedia.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
attachImageViewScaleChangeListener();
|
||||
|
|
@ -261,6 +262,12 @@ public class UploadMediaDetailFragment extends UploadBaseFragment implements
|
|||
callback.onNextButtonClicked(callback.getIndexInViewFlipper(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onBecameVisible() {
|
||||
super.onBecameVisible();
|
||||
presenter.fetchTitleAndDescription(callback.getIndexInViewFlipper(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showMessage(int stringResourceId, int colorResourceId) {
|
||||
ViewUtil.showLongToast(getContext(), stringResourceId);
|
||||
|
|
@ -369,6 +376,9 @@ public class UploadMediaDetailFragment extends UploadBaseFragment implements
|
|||
|
||||
@Override
|
||||
public void onPrimaryCaptionTextChange(boolean isNotEmpty) {
|
||||
btnCopyToSubsequentMedia.setEnabled(isNotEmpty);
|
||||
btnCopyToSubsequentMedia.setClickable(isNotEmpty);
|
||||
btnCopyToSubsequentMedia.setAlpha(isNotEmpty ? 1.0f: 0.5f);
|
||||
btnNext.setEnabled(isNotEmpty);
|
||||
btnNext.setClickable(isNotEmpty);
|
||||
btnNext.setAlpha(isNotEmpty ? 1.0f: 0.5f);
|
||||
|
|
@ -380,9 +390,10 @@ public class UploadMediaDetailFragment extends UploadBaseFragment implements
|
|||
}
|
||||
|
||||
|
||||
@OnClick(R.id.btn_copy_prev_title_desc)
|
||||
public void onButtonCopyPreviousTitleDesc(){
|
||||
presenter.fetchPreviousTitleAndDescription(callback.getIndexInViewFlipper(this));
|
||||
@OnClick(R.id.btn_copy_subsequent_media)
|
||||
public void onButtonCopyTitleDescToSubsequentMedia(){
|
||||
presenter.copyTitleAndDescriptionToSubsequentMedia(callback.getIndexInViewFlipper(this));
|
||||
Toast.makeText(getContext(), getResources().getString(R.string.copied_successfully), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,7 +45,9 @@ public interface UploadMediaDetailsContract {
|
|||
|
||||
void verifyImageQuality(int uploadItemIndex);
|
||||
|
||||
void fetchPreviousTitleAndDescription(int indexInViewFlipper);
|
||||
void copyTitleAndDescriptionToSubsequentMedia(int indexInViewFlipper);
|
||||
|
||||
void fetchTitleAndDescription(int indexInViewFlipper);
|
||||
|
||||
void useSimilarPictureCoordinates(ImageCoordinates imageCoordinates, int uploadItemIndex);
|
||||
|
||||
|
|
|
|||
|
|
@ -147,22 +147,29 @@ public class UploadMediaPresenter implements UserActionListener, SimilarImageInt
|
|||
|
||||
|
||||
/**
|
||||
* Fetches and sets the caption and desctiption of the previous item
|
||||
* Copies the caption and description of the current item to the subsequent media
|
||||
*
|
||||
* @param indexInViewFlipper
|
||||
*/
|
||||
@Override
|
||||
public void fetchPreviousTitleAndDescription(int indexInViewFlipper) {
|
||||
UploadItem previousUploadItem = repository.getPreviousUploadItem(indexInViewFlipper);
|
||||
if (null != previousUploadItem) {
|
||||
final UploadItem currentUploadItem = repository.getUploads().get(indexInViewFlipper);
|
||||
currentUploadItem.setMediaDetails(deepCopy(previousUploadItem.getUploadMediaDetails()));
|
||||
view.updateMediaDetails(currentUploadItem.getUploadMediaDetails());
|
||||
} else {
|
||||
view.showMessage(R.string.previous_image_title_description_not_found, R.color.color_error);
|
||||
}
|
||||
public void copyTitleAndDescriptionToSubsequentMedia(int indexInViewFlipper) {
|
||||
for(int i = indexInViewFlipper+1; i < repository.getCount(); i++){
|
||||
final UploadItem subsequentUploadItem = repository.getUploads().get(i);
|
||||
subsequentUploadItem.setMediaDetails(deepCopy(repository.getUploads().get(indexInViewFlipper).getUploadMediaDetails()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches and set the caption and description of the item
|
||||
*
|
||||
* @param indexInViewFlipper
|
||||
*/
|
||||
@Override
|
||||
public void fetchTitleAndDescription(int indexInViewFlipper) {
|
||||
final UploadItem currentUploadItem = repository.getUploads().get(indexInViewFlipper);
|
||||
view.updateMediaDetails(currentUploadItem.getUploadMediaDetails());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private List<UploadMediaDetail> deepCopy(List<UploadMediaDetail> uploadMediaDetails) {
|
||||
final ArrayList<UploadMediaDetail> newList = new ArrayList<>();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue