mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 12:23:58 +01:00
Merge pull request #200 from misaochan/google-photos-fix-2
Fix multiple shares from Google Photos
This commit is contained in:
commit
0339ec143f
4 changed files with 39 additions and 8 deletions
|
|
@ -1,5 +1,8 @@
|
|||
# Wikimedia Commons for Android
|
||||
|
||||
##v1.21
|
||||
- Fixed Google Photos multiple share crash
|
||||
|
||||
##v1.20
|
||||
- Hotfix for data=null crash
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="fr.free.nrw.commons"
|
||||
android:versionCode="38"
|
||||
android:versionName="1.20" >
|
||||
android:versionCode="39"
|
||||
android:versionName="1.21" >
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
||||
|
|
@ -44,9 +44,7 @@
|
|||
>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.SEND" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
|
||||
<data android:mimeType="image/*" />
|
||||
<data android:mimeType="audio/ogg" />
|
||||
</intent-filter>
|
||||
|
|
@ -58,9 +56,7 @@
|
|||
>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.SEND_MULTIPLE" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
|
||||
<data android:mimeType="image/*" />
|
||||
<data android:mimeType="audio/ogg" />
|
||||
</intent-filter>
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ public class ContributionsListFragment extends Fragment {
|
|||
Uri imageData = data.getData();
|
||||
controller.handleImagePicked(requestCode, imageData);
|
||||
} else {
|
||||
Log.d("Contributions", "OnActivityResult() parameters: Result code: " + resultCode + " Data: null");
|
||||
Log.e("Contributions", "OnActivityResult() parameters: Result code: " + resultCode + " Data: null");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,13 +2,18 @@ package fr.free.nrw.commons.upload;
|
|||
|
||||
import java.util.*;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.*;
|
||||
import android.content.*;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.database.DataSetObserver;
|
||||
import android.net.*;
|
||||
import android.os.*;
|
||||
import android.support.v4.app.ActivityCompat;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.util.Log;
|
||||
import android.view.*;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.*;
|
||||
|
|
@ -77,6 +82,32 @@ public class MultipleShareActivity
|
|||
}
|
||||
|
||||
public void OnMultipleUploadInitiated() {
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
//Check for Storage permission that is required for upload. Do not allow user to proceed without permission, otherwise will crash
|
||||
if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
||||
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, 1);
|
||||
} else {
|
||||
multipleUploadBegins();
|
||||
}
|
||||
} else {
|
||||
multipleUploadBegins();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
|
||||
if (requestCode == 1) {
|
||||
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
multipleUploadBegins();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void multipleUploadBegins() {
|
||||
|
||||
Log.d("MultipleShareActivity", "Multiple upload begins");
|
||||
|
||||
final ProgressDialog dialog = new ProgressDialog(MultipleShareActivity.this);
|
||||
dialog.setIndeterminate(false);
|
||||
dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
|
||||
|
|
@ -114,7 +145,8 @@ public class MultipleShareActivity
|
|||
}
|
||||
getSupportFragmentManager().beginTransaction()
|
||||
.add(R.id.uploadsFragmentContainer, categorizationFragment, "categorization")
|
||||
.commit();
|
||||
.commitAllowingStateLoss();
|
||||
//See http://stackoverflow.com/questions/7469082/getting-exception-illegalstateexception-can-not-perform-this-action-after-onsa
|
||||
}
|
||||
|
||||
public void onCategoriesSave(ArrayList<String> categories) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue