Skip to content

Commit

Permalink
Make multiple uploads work for Google Photos
Browse files Browse the repository at this point in the history
  • Loading branch information
maskara committed Nov 10, 2018
1 parent ce8c9cf commit be7e094
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.database.Cursor;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.provider.MediaStore;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.FloatingActionButton;
Expand All @@ -25,7 +23,6 @@
import android.widget.GridView;
import android.widget.ListAdapter;
import android.widget.ProgressBar;
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
import android.widget.TextView;

import java.util.ArrayList;
Expand All @@ -45,6 +42,7 @@
import static android.Manifest.permission.READ_EXTERNAL_STORAGE;
import static android.Manifest.permission.WRITE_EXTERNAL_STORAGE;
import static android.app.Activity.RESULT_OK;
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
import static android.view.View.GONE;
import static fr.free.nrw.commons.contributions.ContributionController.SELECT_FROM_GALLERY;

Expand Down Expand Up @@ -307,23 +305,21 @@ private void handleMultipleImages(int requestCode, Intent data) {
if (getContext() == null) {
return;
}
if (data.getData() != null) {
controller.handleImagePicked(SELECT_FROM_GALLERY, data.getData(), false, null);
} else {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
if (data.getClipData() != null) {
ClipData mClipData = data.getClipData();
ArrayList<Uri> mArrayUri = new ArrayList<Uri>();
for (int i = 0; i < mClipData.getItemCount(); i++) {

ClipData.Item item = mClipData.getItemAt(i);
Uri uri = item.getUri();
mArrayUri.add(uri);
}
Log.v("LOG_TAG", "Selected Images" + mArrayUri.size());
controller.handleImagesPicked(requestCode, mArrayUri);
}

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN
&& data.getClipData() != null) {
ClipData mClipData = data.getClipData();
ArrayList<Uri> mArrayUri = new ArrayList<Uri>();
for (int i = 0; i < mClipData.getItemCount(); i++) {

ClipData.Item item = mClipData.getItemAt(i);
Uri uri = item.getUri();
mArrayUri.add(uri);
}
Log.v("LOG_TAG", "Selected Images" + mArrayUri.size());
controller.handleImagesPicked(requestCode, mArrayUri);
} else if(data.getData() != null) {
controller.handleImagePicked(SELECT_FROM_GALLERY, data.getData(), false, null);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,8 @@ public void init(int position) {
} else {
descItemEditText.setText("");
}
Drawable drawableRight = context.getResources()
.getDrawable(R.drawable.mapbox_info_icon_default);
descItemEditText.setCompoundDrawablesWithIntrinsicBounds(null, null, drawableRight, null);

descItemEditText.setCompoundDrawablesWithIntrinsicBounds(null, null, getInfoIcon(), null);

descItemEditText.addTextChangedListener(new AbstractTextWatcher(titleText ->{
title.setTitleText(titleText);
Expand All @@ -165,14 +164,14 @@ public void init(int position) {
descItemEditText.setText("");
}
if (position == 1) {
Drawable drawableRight = context.getResources()
.getDrawable(R.drawable.mapbox_info_icon_default);
descItemEditText.setCompoundDrawablesWithIntrinsicBounds(null, null, drawableRight, null);
descItemEditText.setCompoundDrawablesWithIntrinsicBounds(null, null, getInfoIcon(), null);
} else {
descItemEditText.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
}

descItemEditText.addTextChangedListener(new AbstractTextWatcher(description::setDescriptionText));
descItemEditText.addTextChangedListener(new AbstractTextWatcher(descriptionText -> {
description.setDescriptionText(descriptionText);
}));
descItemEditText.setOnFocusChangeListener((v, hasFocus) -> {
if (!hasFocus) {
ViewUtil.hideKeyboard(v);
Expand Down Expand Up @@ -243,7 +242,7 @@ boolean descriptionInfo(View view, MotionEvent motionEvent) {
}
}
//Description info is visible only for the first description
}else if (getAdapterPosition() == 1) {
} else if (getAdapterPosition() == 1) {
final int value;
if (ViewCompat.getLayoutDirection(view) == ViewCompat.LAYOUT_DIRECTION_LTR) {
value = view.getRight() - descItemEditText.getCompoundDrawables()[2].getBounds().width();
Expand All @@ -267,6 +266,11 @@ boolean descriptionInfo(View view, MotionEvent motionEvent) {
}
}

private Drawable getInfoIcon() {
return context.getResources()
.getDrawable(R.drawable.mapbox_info_icon_default);
}

public interface Callback {
void showAlert(int mediaDetailDescription, int descriptionInfo);
}
Expand Down

0 comments on commit be7e094

Please sign in to comment.