mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 04:43:54 +01:00
Merge pull request #194 from misaochan/google-photos-fix
Google Photos fix attempt
This commit is contained in:
commit
fa5b6c0869
6 changed files with 15 additions and 6 deletions
|
|
@ -16,6 +16,7 @@ public abstract class HandlerService<T> extends Service {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleMessage(Message msg) {
|
public void handleMessage(Message msg) {
|
||||||
|
//FIXME: Google Photos bug
|
||||||
handle(msg.what, (T)msg.obj);
|
handle(msg.what, (T)msg.obj);
|
||||||
stopSelf(msg.arg1);
|
stopSelf(msg.arg1);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -61,18 +61,20 @@ public class ContributionController {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startGalleryPick() {
|
public void startGalleryPick() {
|
||||||
|
//FIXME: Starts gallery (opens Google Photos)
|
||||||
Intent pickImageIntent = new Intent(Intent.ACTION_GET_CONTENT);
|
Intent pickImageIntent = new Intent(Intent.ACTION_GET_CONTENT);
|
||||||
pickImageIntent.setType("image/*");
|
pickImageIntent.setType("image/*");
|
||||||
fragment.startActivityForResult(pickImageIntent, SELECT_FROM_GALLERY);
|
fragment.startActivityForResult(pickImageIntent, SELECT_FROM_GALLERY);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleImagePicked(int requestCode, Intent data) {
|
public void handleImagePicked(int requestCode, Uri imageData) {
|
||||||
Intent shareIntent = new Intent(activity, ShareActivity.class);
|
Intent shareIntent = new Intent(activity, ShareActivity.class);
|
||||||
shareIntent.setAction(Intent.ACTION_SEND);
|
shareIntent.setAction(Intent.ACTION_SEND);
|
||||||
switch(requestCode) {
|
switch(requestCode) {
|
||||||
case SELECT_FROM_GALLERY:
|
case SELECT_FROM_GALLERY:
|
||||||
shareIntent.setType(activity.getContentResolver().getType(data.getData()));
|
//FIXME: Handles image picked from gallery (from Google Photos)
|
||||||
shareIntent.putExtra(Intent.EXTRA_STREAM, data.getData());
|
shareIntent.setType(activity.getContentResolver().getType(imageData));
|
||||||
|
shareIntent.putExtra(Intent.EXTRA_STREAM, imageData);
|
||||||
shareIntent.putExtra(UploadService.EXTRA_SOURCE, fr.free.nrw.commons.contributions.Contribution.SOURCE_GALLERY);
|
shareIntent.putExtra(UploadService.EXTRA_SOURCE, fr.free.nrw.commons.contributions.Contribution.SOURCE_GALLERY);
|
||||||
break;
|
break;
|
||||||
case SELECT_FROM_CAMERA:
|
case SELECT_FROM_CAMERA:
|
||||||
|
|
|
||||||
|
|
@ -227,6 +227,7 @@ public class ContributionsActivity
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//FIXME: Potential cause of wrong image display bug
|
||||||
public Media getMediaAtPosition(int i) {
|
public Media getMediaAtPosition(int i) {
|
||||||
if (contributionsList.getAdapter() == null) {
|
if (contributionsList.getAdapter() == null) {
|
||||||
// not yet ready to return data
|
// not yet ready to return data
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ class ContributionsListAdapter extends CursorAdapter {
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//FIXME: Potential cause of wrong image display bug
|
||||||
@Override
|
@Override
|
||||||
public void bindView(View view, Context context, Cursor cursor) {
|
public void bindView(View view, Context context, Cursor cursor) {
|
||||||
final ContributionViewHolder views = (ContributionViewHolder)view.getTag();
|
final ContributionViewHolder views = (ContributionViewHolder)view.getTag();
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.ActivityCompat;
|
import android.support.v4.app.ActivityCompat;
|
||||||
|
|
@ -29,6 +30,7 @@ import fr.free.nrw.commons.AboutActivity;
|
||||||
import fr.free.nrw.commons.CommonsApplication;
|
import fr.free.nrw.commons.CommonsApplication;
|
||||||
import fr.free.nrw.commons.R;
|
import fr.free.nrw.commons.R;
|
||||||
import fr.free.nrw.commons.SettingsActivity;
|
import fr.free.nrw.commons.SettingsActivity;
|
||||||
|
import fr.free.nrw.commons.upload.UploadService;
|
||||||
|
|
||||||
public class ContributionsListFragment extends Fragment {
|
public class ContributionsListFragment extends Fragment {
|
||||||
|
|
||||||
|
|
@ -88,10 +90,10 @@ public class ContributionsListFragment extends Fragment {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
|
//FIXME: must get the file data for Google Photos when receive the intent answer, in the onActivityResult method
|
||||||
super.onActivityResult(requestCode, resultCode, data);
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
if(resultCode == Activity.RESULT_OK) {
|
Uri imageData = data.getData();
|
||||||
controller.handleImagePicked(requestCode, data);
|
controller.handleImagePicked(requestCode, imageData);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -111,6 +111,7 @@ public class UploadService extends HandlerService<Contribution> {
|
||||||
protected void handle(int what, Contribution contribution) {
|
protected void handle(int what, Contribution contribution) {
|
||||||
switch(what) {
|
switch(what) {
|
||||||
case ACTION_UPLOAD_FILE:
|
case ACTION_UPLOAD_FILE:
|
||||||
|
//FIXME: Google Photos bug
|
||||||
uploadContribution(contribution);
|
uploadContribution(contribution);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
@ -173,6 +174,7 @@ public class UploadService extends HandlerService<Contribution> {
|
||||||
String notificationTag = contribution.getLocalUri().toString();
|
String notificationTag = contribution.getLocalUri().toString();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
//FIXME: Google Photos bug
|
||||||
file = this.getContentResolver().openInputStream(contribution.getLocalUri());
|
file = this.getContentResolver().openInputStream(contribution.getLocalUri());
|
||||||
} catch(FileNotFoundException e) {
|
} catch(FileNotFoundException e) {
|
||||||
Log.d("Exception", "File not found");
|
Log.d("Exception", "File not found");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue