Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
942cef5
#3222 Merge master into Structured Data branch, fix conflicts (#3447)
macgills Mar 10, 2020
66e195d
#3482 Use Room in Structured Data branch - remove unused code (#3483)
macgills Mar 18, 2020
fb751c6
#3490 Depiction Search in upload shows No Results before it gets resu…
macgills Mar 19, 2020
719f32c
Merge remote-tracking branch 'origin/master' into structured-data
macgills Mar 20, 2020
e992ed4
fix unit test compilation
macgills Mar 20, 2020
02a0042
Merge remote-tracking branch 'origin/master' into structured-data
macgills Mar 20, 2020
bc8b29b
#3222 remove lingering reference to depiction content provider
macgills Mar 20, 2020
f1f0f4a
Fix Crash
macgills Mar 20, 2020
1404bb0
Merge remote-tracking branch 'origin/master' into structured-data
macgills Mar 20, 2020
895b343
#3222 Merge master into Structured Data branch, fix conflicts - revie…
macgills Mar 23, 2020
2e43995
Merge remote-tracking branch 'origin/master' into structured-data
macgills Mar 24, 2020
d5b62be
Merge remote-tracking branch 'origin/master' into structured-data
macgills Mar 24, 2020
2854f6a
Fix method invocations
macgills Mar 24, 2020
587d977
Merge branch 'master' into structured-data
macgills Mar 25, 2020
23b8c2e
#3529 Captions/depictions are not saved to Commons (#3574)
macgills Mar 25, 2020
dec68ed
#3503 Remove Title/Caption From MediaUploadDetail and only use Captio…
macgills Mar 26, 2020
00e9357
fix thumbnail issue 3526 (#3617)
vvijayalakshmi21 Apr 2, 2020
5d2c786
Merge remote-tracking branch 'origin/master' into structured-data
macgills Apr 7, 2020
a9797a7
#3222 Merge master into Structured Data branch, fix conflicts - fix b…
macgills Apr 7, 2020
3f6d26c
Merge branch 'master' into structured-data
macgills Apr 9, 2020
628a605
#3529 Captions/depictions are not saved to Commons (#3588)
macgills Apr 9, 2020
62f1764
Fix issue 3526 Unlike "Items" tab, "child classes" tab does not displ…
vvijayalakshmi21 Apr 10, 2020
46847f0
Fix issue 3137 (#3637)
vvijayalakshmi21 Apr 10, 2020
94da061
#3222 Merge master into Structured Data branch, fix conflicts - rever…
macgills Apr 10, 2020
752d634
Merge branch 'master' into structured-data
maskaravivek Apr 14, 2020
dee9638
Fix build
maskaravivek Apr 15, 2020
d8f9809
#3661 No Depictions Selected Dialog has reversed buttons - fix button…
macgills Apr 16, 2020
e9cd3b4
Revert "#3661 No Depictions Selected Dialog has reversed buttons - fi…
macgills Apr 16, 2020
c9e6788
Merge branch 'master' into structured-data
macgills Apr 16, 2020
92d6848
#3222 Merge master into Structured Data branch, fix conflicts - remov…
macgills Apr 16, 2020
d2e7652
#3661 No Depictions Selected Dialog has reversed buttons - fix button…
macgills Apr 16, 2020
b7384b3
#3653 Many Mnull requests - stop requesting captions for null ids (#3…
macgills Apr 16, 2020
590a7ed
#3633 [structured-data branch] In depictions selection screen, sugges…
macgills Apr 16, 2020
194d31e
#3666 Crash when uploading on structured-data branch - revert cleanup…
macgills Apr 17, 2020
41f3076
Merge branch 'master' into structured-data
macgills Apr 20, 2020
25bcff2
#3222 Merge Structured Data branch into master - fix caption renderin…
macgills Apr 20, 2020
fe9d6ca
Merge remote-tracking branch 'origin/master' into structured-data
macgills Apr 20, 2020
b20dec0
#3222 Merge Structured Data branch into master - upgrade retrofit + o…
macgills Apr 20, 2020
f7b1b14
#3664 Stop using JsonObject on StructuredData (#3672)
macgills Apr 20, 2020
fe22424
#228 Overwrite happens - fix extension of filename (#3689)
macgills Apr 22, 2020
e0f1bff
#3675 Rename buttons of the dialog box shown when no depiction is sel…
macgills Apr 22, 2020
d066412
#3680 Tip appears even when not tapping the (i) icon - use TextInputL…
macgills Apr 22, 2020
7941ede
Merge remote-tracking branch 'origin/master' into structured-data
macgills Apr 22, 2020
8af39c5
structured data - fix compilation
macgills Apr 22, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
package fr.free.nrw.commons.upload;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
Expand All @@ -17,6 +13,7 @@
import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;
import butterknife.ButterKnife;
import com.google.android.material.textfield.TextInputLayout;
import fr.free.nrw.commons.R;
import fr.free.nrw.commons.utils.AbstractTextWatcher;
import java.util.ArrayList;
Expand Down Expand Up @@ -93,9 +90,15 @@ public class ViewHolder extends RecyclerView.ViewHolder {
@BindView(R.id.description_item_edit_text)
AppCompatEditText descItemEditText;

@BindView(R.id.description_item_edit_text_input_layout)
TextInputLayout descInputLayout;

@BindView(R.id.caption_item_edit_text)
AppCompatEditText captionItemEditText;

@BindView(R.id.caption_item_edit_text_input_layout)
TextInputLayout captionInputLayout;

public ViewHolder(View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
Expand All @@ -116,38 +119,19 @@ public void bind(int position) {
}));

if (position == 0) {
captionItemEditText.setCompoundDrawablesWithIntrinsicBounds(null, null, getInfoIcon(),
null);
captionItemEditText.setOnTouchListener((v, event) -> {
//2 is for drawable right
if (event.getAction() == MotionEvent.ACTION_UP && (event.getRawX() >= (captionItemEditText.getRight() - captionItemEditText.getCompoundDrawables()[2].getBounds().width()))) {
if (getAdapterPosition() == 0) {
callback.showAlert(R.string.media_detail_caption,
R.string.caption_info);
}
return true;
}
return false;
});

descItemEditText.setCompoundDrawablesWithIntrinsicBounds(null, null, getInfoIcon(),
null);
descItemEditText.setOnTouchListener((v, event) -> {
//2 is for drawable right
float twelveDpInPixels = convertDpToPixel(12, descItemEditText.getContext());
if (event.getAction() == MotionEvent.ACTION_UP && descItemEditText.getCompoundDrawables()[2].getBounds().contains((int)(descItemEditText.getWidth()-(event.getX()+twelveDpInPixels)),(int)(event.getY()-twelveDpInPixels))){
if (getAdapterPosition() == 0) {
callback.showAlert(R.string.media_detail_description,
R.string.description_info);
}
return true;
}
return false;
});
captionInputLayout.setEndIconMode(TextInputLayout.END_ICON_CUSTOM);
captionInputLayout.setEndIconDrawable(R.drawable.mapbox_info_icon_default);
captionInputLayout.setEndIconOnClickListener(v ->
callback.showAlert(R.string.media_detail_caption, R.string.caption_info));

descInputLayout.setEndIconMode(TextInputLayout.END_ICON_CUSTOM);
descInputLayout.setEndIconDrawable(R.drawable.mapbox_info_icon_default);
descInputLayout.setEndIconOnClickListener(v ->
callback.showAlert(R.string.media_detail_description, R.string.description_info));

} else {
captionItemEditText.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
descItemEditText.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
captionInputLayout.setEndIconDrawable(null);
descInputLayout.setEndIconDrawable(null);
}

captionItemEditText.addTextChangedListener(new AbstractTextWatcher(
Expand Down Expand Up @@ -218,15 +202,6 @@ public void onNothingSelected(AdapterView<?> adapterView) {
selectedLanguages.put(spinnerDescriptionLanguages, description.getLanguageCode());
}
}

/**
* Extracted out the method to get the icon drawable
*/
private Drawable getInfoIcon() {
return descItemEditText.getContext()
.getResources()
.getDrawable(R.drawable.mapbox_info_icon_default);
}
}

public interface Callback {
Expand All @@ -238,13 +213,4 @@ public interface EventListener {
void onPrimaryCaptionTextChange(boolean isNotEmpty);
}

/**
* converts dp to pixel
* @param dp
* @param context
* @return
*/
private float convertDpToPixel(float dp, Context context) {
return dp * ((float) context.getResources().getDisplayMetrics().densityDpi / DisplayMetrics.DENSITY_DEFAULT);
}
}
22 changes: 8 additions & 14 deletions app/src/main/java/fr/free/nrw/commons/upload/UploadModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
import android.content.Context;
import android.net.Uri;
import androidx.annotation.Nullable;
import fr.free.nrw.commons.Utils;
import fr.free.nrw.commons.auth.SessionManager;
import fr.free.nrw.commons.contributions.Contribution;
import fr.free.nrw.commons.filepicker.MimeTypeMapWrapper;
import fr.free.nrw.commons.filepicker.UploadableFile;
import fr.free.nrw.commons.kvstore.JsonKvStore;
import fr.free.nrw.commons.nearby.Place;
Expand Down Expand Up @@ -106,8 +108,8 @@ private UploadItem createAndAddUploadItem(final UploadableFile uploadableFile,
Timber.d("File created date is %d", fileCreatedDate);
final ImageCoordinates imageCoordinates = fileProcessor
.processFileCoordinates(similarImageInterface, uploadableFile.getFilePath());
final UploadItem uploadItem = new UploadItem(uploadableFile.getContentUri(),
Uri.parse(uploadableFile.getFilePath()),
final UploadItem uploadItem = new UploadItem(
Uri.parse(uploadableFile.getFilePath()),
uploadableFile.getMimeType(context), imageCoordinates, place, fileCreatedDate,
createdTimestampSource);
if (place != null) {
Expand Down Expand Up @@ -204,7 +206,6 @@ public List<DepictedItem> getSelectedDepictions() {
@SuppressWarnings("WeakerAccess")
public static class UploadItem {

private final Uri originalContentUri;
private final Uri mediaUri;
private final String mimeType;
private ImageCoordinates gpsCoords;
Expand All @@ -214,13 +215,12 @@ public static class UploadItem {
private final String createdTimestampSource;
private final BehaviorSubject<Integer> imageQuality;
@SuppressLint("CheckResult")
UploadItem(final Uri originalContentUri,
final Uri mediaUri, final String mimeType,
UploadItem(final Uri mediaUri,
final String mimeType,
final ImageCoordinates gpsCoords,
final Place place,
final long createdTimestamp,
final String createdTimestampSource) {
this.originalContentUri = originalContentUri;
this.createdTimestampSource = createdTimestampSource;
uploadMediaDetails = new ArrayList<>(Arrays.asList(new UploadMediaDetail()));
this.place = place;
Expand Down Expand Up @@ -267,10 +267,6 @@ public void setMediaDetails(final List<UploadMediaDetail> uploadMediaDetails) {
this.uploadMediaDetails = uploadMediaDetails;
}

public Uri getContentUri() {
return originalContentUri;
}

@Override
public boolean equals(@Nullable final Object obj) {
if (!(obj instanceof UploadItem)) {
Expand All @@ -290,15 +286,13 @@ public int hashCode() {
* Currently, the caption is used as a filename. If several languages have been entered, the first language is used.
*/
public String getFileName() {
return uploadMediaDetails.get(0).getCaptionText();
return Utils.fixExtension(uploadMediaDetails.get(0).getCaptionText(),
MimeTypeMapWrapper.getExtensionFromMimeType(mimeType));
}

public void setGpsCoords(final ImageCoordinates gpsCoords) {
this.gpsCoords = gpsCoords;
}

public String getMimeType() {
return mimeType;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ public void showNoCategorySelected() {
DialogUtil.showAlertDialog(getActivity(),
getString(R.string.no_categories_selected),
getString(R.string.no_categories_selected_warning_desc),
getString(R.string.yes_submit),
getString(R.string.no_go_back),
getString(R.string.continue_message),
getString(R.string.cancel),
() -> goToNextScreen(),
null);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ public void noDepictionSelected() {
DialogUtil.showAlertDialog(getActivity(),
getString(R.string.no_depictions_selected),
getString(R.string.no_depictions_selected_warning_desc),
getString(R.string.yes_submit),
getString(R.string.no_go_back),
getString(R.string.continue_message),
getString(R.string.cancel),
this::goToNextScreen,
null
);
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/res/layout/row_item_description.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
android:orientation="vertical"
android:layout_weight="8">
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/caption_item_edit_text_input_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
Expand All @@ -33,6 +34,7 @@
</com.google.android.material.textfield.TextInputLayout>

<com.google.android.material.textfield.TextInputLayout
android:id="@+id/description_item_edit_text_input_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
Expand All @@ -47,4 +49,4 @@
</com.google.android.material.textfield.TextInputLayout>

</LinearLayout>
</LinearLayout>
</LinearLayout>
7 changes: 2 additions & 5 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -460,13 +460,10 @@ Upload your first media by tapping on the add button.</string>
<string name="desc_language_Pacific">Pacific</string>

<string name="no_categories_selected">No Categories Selected</string>
<string name="no_categories_selected_warning_desc">Images without categories are rarely usable. Are you sure you want to submit without selecting categories?</string>
<string name="no_categories_selected_warning_desc">Images without categories are rarely usable. Are you sure you want to continue without selecting categories?</string>

<string name="no_depictions_selected">No Depictions Selected</string>
<string name="no_depictions_selected_warning_desc">Depictions help when searching for images. Are you sure you want to submit without selecting depictions?</string>

<string name="yes_submit">Yes, Submit</string>
<string name="no_go_back">No, Go Back</string>
<string name="no_depictions_selected_warning_desc">Images with depictions are more easily found and more likely to be used. Are you sure you want to continue without selecting depictions?</string>

<string name="upload_flow_all_images_in_set">(For all images in set)</string>
<string name="search_this_area">Search this area</string>
Expand Down