mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 12:23:58 +01:00
Add support for uploading pictures taken from camera
This commit is contained in:
parent
999b8a0c0e
commit
006558ccd3
4 changed files with 33 additions and 2 deletions
14
commons/res/menu/activity_contributions.xml
Normal file
14
commons/res/menu/activity_contributions.xml
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:id="@+id/menu_from_gallery"
|
||||
android:title="@string/menu_from_gallery"
|
||||
android:orderInCategory="100"
|
||||
android:showAsAction="always"
|
||||
android:icon="@android:drawable/ic_menu_gallery"
|
||||
/>
|
||||
<item android:id="@+id/menu_from_camera"
|
||||
android:title="@string/menu_from_camera"
|
||||
android:orderInCategory="200"
|
||||
android:showAsAction="always"
|
||||
android:icon="@android:drawable/ic_menu_camera"
|
||||
/>
|
||||
</menu>
|
||||
|
|
@ -40,4 +40,5 @@
|
|||
<string name="contribution_state_queued">Queued</string>
|
||||
<string name="contribution_state_in_progress">Uploading</string>
|
||||
<string name="menu_from_gallery">From Gallery</string>
|
||||
<string name="menu_from_camera">Take Photo</string>
|
||||
</resources>
|
||||
|
|
@ -159,7 +159,7 @@ public class UploadService extends IntentService {
|
|||
if(cursor != null && cursor.getCount() != 0) {
|
||||
cursor.moveToFirst();
|
||||
dateCreated = new Date(cursor.getLong(0));
|
||||
}
|
||||
} // FIXME: Alternate way of setting dateCreated if this data is not found
|
||||
} /* else if (mimeType.startsWith("audio/")) {
|
||||
Removed Audio implementationf or now
|
||||
} */
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package org.wikimedia.commons.contributions;
|
|||
|
||||
import android.graphics.Bitmap;
|
||||
import android.net.Uri;
|
||||
import android.provider.MediaStore;
|
||||
import android.support.v4.app.LoaderManager;
|
||||
import android.support.v4.content.CursorLoader;
|
||||
import android.support.v4.content.Loader;
|
||||
|
|
@ -42,6 +43,7 @@ import java.util.Date;
|
|||
public class ContributionsActivity extends AuthenticatedActivity implements LoaderManager.LoaderCallbacks<Cursor> {
|
||||
|
||||
private final static int SELECT_FROM_GALLERY = 1;
|
||||
private final static int SELECT_FROM_CAMERA = 2;
|
||||
|
||||
public ContributionsActivity() {
|
||||
super(WikiAccountAuthenticator.COMMONS_ACCOUNT_TYPE);
|
||||
|
|
@ -171,8 +173,18 @@ public class ContributionsActivity extends AuthenticatedActivity implements Load
|
|||
shareIntent.setType("image/*"); //FIXME: Find out appropriate mime type
|
||||
shareIntent.putExtra(Intent.EXTRA_STREAM, data.getData());
|
||||
startActivity(shareIntent);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case SELECT_FROM_CAMERA:
|
||||
if(resultCode == RESULT_OK) {
|
||||
Intent shareIntent = new Intent(this, ShareActivity.class);
|
||||
shareIntent.setAction(Intent.ACTION_SEND);
|
||||
Log.d("Commons", "Type is " + data.getType() + " Uri is " + data.getData());
|
||||
shareIntent.setType("image/*"); //FIXME: Find out appropriate mime type
|
||||
shareIntent.putExtra(Intent.EXTRA_STREAM, data.getData());
|
||||
startActivity(shareIntent);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -184,6 +196,10 @@ public class ContributionsActivity extends AuthenticatedActivity implements Load
|
|||
pickImageIntent.setType("image/*");
|
||||
startActivityForResult(pickImageIntent, SELECT_FROM_GALLERY);
|
||||
return true;
|
||||
case R.id.menu_from_camera:
|
||||
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
||||
startActivityForResult(takePictureIntent, SELECT_FROM_CAMERA);
|
||||
return true;
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue