mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Use previous Title/Description option added (#2713)
* Use previous Title/Description option added * Update UploadActivity.java * add previous title/description option modified * declaration of Descripton object moved within the loop * spinner position gets adjusted according to the description's language * prev Title/Desc option for multiple upload added * Tooltip for previous title/description button added * UI and other resolved issues
This commit is contained in:
parent
84637c5fed
commit
8ef99caa81
4 changed files with 110 additions and 5 deletions
|
|
@ -4,6 +4,7 @@ import android.Manifest;
|
|||
import android.annotation.SuppressLint;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import com.google.android.material.textfield.TextInputLayout;
|
||||
|
|
@ -12,6 +13,10 @@ import androidx.cardview.widget.CardView;
|
|||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import android.text.TextUtils;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.text.style.ClickableSpan;
|
||||
import android.text.style.URLSpan;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.AdapterView;
|
||||
|
|
@ -33,6 +38,7 @@ import com.jakewharton.rxbinding2.widget.RxTextView;
|
|||
import com.pedrogomez.renderers.RVRendererAdapter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
|
@ -100,6 +106,7 @@ public class UploadActivity extends BaseActivity implements UploadView, SimilarI
|
|||
@BindView(R.id.bottom_card_next) Button next;
|
||||
@BindView(R.id.bottom_card_previous) Button previous;
|
||||
@BindView(R.id.bottom_card_add_desc) Button bottomCardAddDescription;
|
||||
@BindView(R.id.prev_title_desc) Button prevTitleDecs;
|
||||
@BindView(R.id.categories_subtitle) TextView categoriesSubtitle;
|
||||
@BindView(R.id.license_subtitle) TextView licenseSubtitle;
|
||||
@BindView(R.id.please_wait_text_view) TextView pleaseWaitTextView;
|
||||
|
|
@ -129,6 +136,7 @@ public class UploadActivity extends BaseActivity implements UploadView, SimilarI
|
|||
private DescriptionsAdapter descriptionsAdapter;
|
||||
private RVRendererAdapter<CategoryItem> categoriesAdapter;
|
||||
private ProgressDialog progressDialog;
|
||||
private boolean multipleUpload = false, flagForSubmit = false;
|
||||
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
|
|
@ -214,9 +222,10 @@ public class UploadActivity extends BaseActivity implements UploadView, SimilarI
|
|||
|
||||
@Override
|
||||
public void updateRightCardContent(boolean gpsPresent) {
|
||||
if(gpsPresent){
|
||||
if (gpsPresent) {
|
||||
rightCardMapButton.setVisibility(View.VISIBLE);
|
||||
}else{
|
||||
}
|
||||
else {
|
||||
rightCardMapButton.setVisibility(View.GONE);
|
||||
}
|
||||
//The card should be disabled if it has no buttons.
|
||||
|
|
@ -228,6 +237,9 @@ public class UploadActivity extends BaseActivity implements UploadView, SimilarI
|
|||
int stepCount,
|
||||
UploadModel.UploadItem uploadItem,
|
||||
boolean isShowingItem) {
|
||||
boolean saveForPrevImage = false;
|
||||
int singleUploadStepCount = 3;
|
||||
|
||||
String cardTitle = getResources().getString(R.string.step_count, currentStep, stepCount);
|
||||
String cardSubTitle = getResources().getString(R.string.image_in_set_label, currentStep);
|
||||
bottomCardTitle.setText(cardTitle);
|
||||
|
|
@ -237,6 +249,13 @@ public class UploadActivity extends BaseActivity implements UploadView, SimilarI
|
|||
if (currentStep == stepCount) {
|
||||
dismissKeyboard();
|
||||
}
|
||||
if (stepCount > singleUploadStepCount) {
|
||||
multipleUpload = true;
|
||||
}
|
||||
if (multipleUpload && currentStep != 1) {
|
||||
saveForPrevImage = true;
|
||||
}
|
||||
configurePrevButton(saveForPrevImage);
|
||||
if(isShowingItem) {
|
||||
descriptionsAdapter.setItems(uploadItem.getTitle(), uploadItem.getDescriptions());
|
||||
rvDescriptions.setAdapter(descriptionsAdapter);
|
||||
|
|
@ -341,7 +360,7 @@ public class UploadActivity extends BaseActivity implements UploadView, SimilarI
|
|||
|
||||
@Override
|
||||
public void setBottomCardState(boolean state) {
|
||||
updateCardState(state, bottomCardExpandButton, rvDescriptions, previous, next, bottomCardAddDescription);
|
||||
updateCardState(state, bottomCardExpandButton, rvDescriptions, previous, next, prevTitleDecs, bottomCardAddDescription);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -458,6 +477,13 @@ public class UploadActivity extends BaseActivity implements UploadView, SimilarI
|
|||
}
|
||||
|
||||
private void configureBottomCard() {
|
||||
boolean flagVal = directKvStore.getBoolean("flagForSubmit");
|
||||
if(flagVal){
|
||||
prevTitleDecs.setVisibility(View.VISIBLE);
|
||||
}
|
||||
else {
|
||||
prevTitleDecs.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
bottomCardExpandButton.setOnClickListener(v -> presenter.toggleBottomCardState());
|
||||
bottomCard.setOnClickListener(v -> presenter.toggleBottomCardState());
|
||||
bottomCardAddDescription.setOnClickListener(v -> addNewDescription());
|
||||
|
|
@ -472,6 +498,49 @@ public class UploadActivity extends BaseActivity implements UploadView, SimilarI
|
|||
rightCardMapButton.setOnClickListener(v -> presenter.openCoordinateMap());
|
||||
}
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
public void configurePrevButton(Boolean saveForPrevImage){
|
||||
prevTitleDecs.setCompoundDrawablesWithIntrinsicBounds(null, null, getResources().getDrawable(R.drawable.mapbox_info_icon_default), null);
|
||||
|
||||
String name = "prev_";
|
||||
if (saveForPrevImage) {
|
||||
name = name + "image_";
|
||||
} else {
|
||||
name = name + "upload_";
|
||||
}
|
||||
String title = directKvStore.getString(name + "title");
|
||||
Title t = new Title();
|
||||
t.setTitleText(title);
|
||||
|
||||
List<Description> finalDesc = new LinkedList<>();
|
||||
int descCount = directKvStore.getInt(name + "descCount");
|
||||
for (int i = 0; i < descCount; i++) {
|
||||
Description description= new Description();
|
||||
String desc = directKvStore.getString(name + "description_<"+Integer.toString(i)+">");
|
||||
description.setDescriptionText(desc);
|
||||
finalDesc.add(description);
|
||||
int position = directKvStore.getInt(name + "spinnerPosition_<"+Integer.toString(i)+">");
|
||||
description.setSelectedLanguageIndex(position);
|
||||
}
|
||||
prevTitleDecs.setOnTouchListener((v, event) -> {
|
||||
// Check this is a touch up event
|
||||
if(event.getAction() != MotionEvent.ACTION_UP) return false;
|
||||
// Check we are tapping within 15px of the info icon
|
||||
int extraTapArea = 15;
|
||||
Drawable info = prevTitleDecs.getCompoundDrawables()[2];
|
||||
int infoHintbox = prevTitleDecs.getWidth() - info.getBounds().width();
|
||||
if (event.getX() + extraTapArea < infoHintbox) return false;
|
||||
|
||||
DialogUtil.showAlertDialog(this, null, getString(R.string.previous_button_tooltip_message), "okay", null, null, null);
|
||||
|
||||
return true;
|
||||
});
|
||||
prevTitleDecs.setOnClickListener((View v) -> {
|
||||
descriptionsAdapter.setItems(t, finalDesc);
|
||||
rvDescriptions.setAdapter(descriptionsAdapter);
|
||||
});
|
||||
}
|
||||
|
||||
private void configureNavigationButtons() {
|
||||
// Navigation next / previous for each image as we're collecting title + description
|
||||
next.setOnClickListener(v -> {
|
||||
|
|
@ -480,6 +549,9 @@ public class UploadActivity extends BaseActivity implements UploadView, SimilarI
|
|||
return;
|
||||
}
|
||||
setTitleAndDescriptions();
|
||||
if (multipleUpload) {
|
||||
savePrevTitleDesc("prev_image_");
|
||||
}
|
||||
presenter.handleNext(descriptionsAdapter.getTitle(),
|
||||
descriptionsAdapter.getDescriptions());
|
||||
});
|
||||
|
|
@ -492,6 +564,9 @@ public class UploadActivity extends BaseActivity implements UploadView, SimilarI
|
|||
// Finally, the previous / submit buttons on the final currentPage of the wizard
|
||||
licensePrevious.setOnClickListener(v -> presenter.handlePrevious());
|
||||
submit.setOnClickListener(v -> {
|
||||
flagForSubmit = true;
|
||||
directKvStore.putBoolean("flagForSubmit", flagForSubmit);
|
||||
savePrevTitleDesc("prev_upload_");
|
||||
Toast.makeText(this, R.string.uploading_started, Toast.LENGTH_LONG).show();
|
||||
presenter.handleSubmit(categoriesModel);
|
||||
finish();
|
||||
|
|
@ -662,4 +737,15 @@ public class UploadActivity extends BaseActivity implements UploadView, SimilarI
|
|||
newFragment.setArguments(args);
|
||||
newFragment.show(getSupportFragmentManager(), "dialog");
|
||||
}
|
||||
|
||||
public void savePrevTitleDesc(String name){
|
||||
|
||||
directKvStore.putString(name + "title", descriptionsAdapter.getTitle().toString());
|
||||
int n = descriptionsAdapter.getItemCount() - 1;
|
||||
directKvStore.putInt(name + "descCount", n);
|
||||
for (int i = 0; i < n; i++) {
|
||||
directKvStore.putString(name + "description_<"+Integer.toString(i)+">", descriptionsAdapter.getDescriptions().get(i).getDescriptionText());
|
||||
directKvStore.putInt(name + "spinnerPosition_<" + Integer.toString(i) + ">", descriptionsAdapter.getDescriptions().get(i).getSelectedLanguageIndex());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -118,6 +118,7 @@ public class UploadPresenter {
|
|||
List<Description> descriptions) {
|
||||
Timber.e("Inside handleNext");
|
||||
view.showProgressDialog();
|
||||
setTitleAndDescription(title, descriptions);
|
||||
compositeDisposable.add(uploadModel.getImageQuality(uploadModel.getCurrentItem(), true)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
|
|
|
|||
|
|
@ -137,13 +137,29 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
app:layout_constraintBottom_toTopOf="@+id/bottom_card_previous"
|
||||
android:layout_marginBottom="20dp"
|
||||
app:layout_constraintBottom_toTopOf="@+id/prev_title_desc"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/bottom_card_subtitle"
|
||||
tools:visibility="gone" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/prev_title_desc"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="25dp"
|
||||
android:background="@color/white"
|
||||
android:text="@string/previous_image_title_description"
|
||||
android:textColor="@color/button_blue"
|
||||
android:layout_marginBottom="15dp"
|
||||
android:layout_marginEnd="3.5dp"
|
||||
android:gravity="center"
|
||||
style="@style/Widget.AppCompat.Button.Borderless"
|
||||
app:layout_constraintBottom_toTopOf="@id/bottom_card_previous"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/rv_descriptions" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/bottom_card_next"
|
||||
style="@style/Widget.AppCompat.Button.Borderless"
|
||||
|
|
|
|||
|
|
@ -533,6 +533,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_title_description">Copy previous title & description</string>
|
||||
<string name="previous_button_tooltip_message">Click to reuse the title and description you entered in your previous picture and modify it to fit your current one</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>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue