mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +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<>();
|
||||
|
|
|
|||
|
|
@ -99,11 +99,11 @@
|
|||
|
||||
|
||||
<androidx.appcompat.widget.AppCompatButton
|
||||
android:id="@+id/btn_copy_prev_title_desc"
|
||||
android:id="@+id/btn_copy_subsequent_media"
|
||||
style="@style/Widget.AppCompat.Button.Borderless"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/previous_image_caption_description"
|
||||
android:text="@string/copy_image_caption_description"
|
||||
android:padding="@dimen/miniscule_margin"
|
||||
android:textAlignment="textEnd"
|
||||
android:textColor="@color/button_blue"
|
||||
|
|
|
|||
|
|
@ -460,7 +460,8 @@ Upload your first media by tapping on the add button.</string>
|
|||
<string name="images_featured_explanation">Featured pictures are images from highly skilled photographers and illustrators that the Wikimedia Commons community has chosen as some of the highest quality on the site.</string>
|
||||
<string name="images_via_nearby_explanation">Images Uploaded via Nearby places are the images which are uploaded by discovering places on the map.</string>
|
||||
<string name="thanks_received_explanation">This feature allows editors to send a Thank you notification to users who make useful edits – by using a small thank link on the history page or diff page.</string>
|
||||
<string name="previous_image_caption_description">Copy previous captions & description</string>
|
||||
<string name="copy_image_caption_description">Copy to subsequent Media</string>
|
||||
<string name="copied_successfully">Copied Successfully</string>
|
||||
<string name="welcome_do_upload_content_description">Examples of good images to upload to Commons</string>
|
||||
<string name="welcome_dont_upload_content_description">Examples of images not to upload</string>
|
||||
<string name="skip_image">Skip this image</string>
|
||||
|
|
|
|||
|
|
@ -164,30 +164,19 @@ class UploadMediaPresenterTest {
|
|||
}
|
||||
|
||||
/**
|
||||
* Test fetch previous image title when there was one
|
||||
* Test fetch image title when there was one
|
||||
*/
|
||||
@Test
|
||||
fun fetchPreviousImageAndTitleTestPositive() {
|
||||
fun fetchImageAndTitleTest() {
|
||||
whenever(repository.uploads).thenReturn(listOf(uploadItem))
|
||||
whenever(repository.getPreviousUploadItem(ArgumentMatchers.anyInt()))
|
||||
whenever(repository.getUploadItem(ArgumentMatchers.anyInt()))
|
||||
.thenReturn(uploadItem)
|
||||
whenever(uploadItem.uploadMediaDetails).thenReturn(listOf())
|
||||
|
||||
uploadMediaPresenter.fetchPreviousTitleAndDescription(0)
|
||||
uploadMediaPresenter.fetchTitleAndDescription(0)
|
||||
verify(view).updateMediaDetails(ArgumentMatchers.any())
|
||||
}
|
||||
|
||||
/**
|
||||
* Test fetch previous image title when there was none
|
||||
*/
|
||||
@Test
|
||||
fun fetchPreviousImageAndTitleTestNegative() {
|
||||
whenever(repository.getPreviousUploadItem(ArgumentMatchers.anyInt()))
|
||||
.thenReturn(null)
|
||||
uploadMediaPresenter.fetchPreviousTitleAndDescription(0)
|
||||
verify(view).showMessage(ArgumentMatchers.anyInt(), ArgumentMatchers.anyInt())
|
||||
}
|
||||
|
||||
/**
|
||||
* Test bad image invalid location
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue