Merge branch 'GSoC2017-evaluation-final'

This commit is contained in:
Gioacchino Mazzurco 2017-08-18 01:37:39 +02:00
commit 32f43b999e
1431 changed files with 6666 additions and 445 deletions

View file

@ -11,6 +11,7 @@
android:label="RetroShare"
android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation"
android:screenOrientation="unspecified"
android:windowSoftInputMode="adjustResize"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
@ -206,4 +207,8 @@
<!-- Added by G10h4ck: Needed permission for autostart at boot -->
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<!-- Added by Angesoc: used to pick images from gallery or take it from camera -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
</manifest>

View file

@ -19,17 +19,25 @@
package org.retroshare.android.qml_app;
import android.app.ActivityManager;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.provider.MediaStore;
import android.util.Log;
import android.net.Uri;
import org.qtproject.qt5.android.bindings.QtActivity;
import org.retroshare.android.qml_app.jni.NativeCalls;
public class RetroShareQmlActivity extends QtActivity
{
static final int PICK_PHOTO = 1;
@Override
public void onCreate(Bundle savedInstanceState)
{
@ -57,12 +65,16 @@ public class RetroShareQmlActivity extends QtActivity
@Override
public void onNewIntent(Intent intent)
{
Log.i("RetroShareQmlActivity", "onNewIntent(Intent intent)");
Log.i("RetroShareQmlActivity", "on NewIntent(Intent intent)");
super.onNewIntent(intent);
String uri = intent.getDataString();
if (uri != null) NativeCalls.notifyIntentUri(uri);
if (uri != null)
{
NativeCalls.notifyIntentUri(uri);
Log.i("RetroShareQmlActivity", "onNewIntent(Intent intent) Uri: " + uri);
}
}
@UsedByNativeCode @SuppressWarnings("unused")
@ -84,4 +96,88 @@ public class RetroShareQmlActivity extends QtActivity
return true;
return false;
}
private Uri capturedImageURI;
public void openImagePicker()
{
Log.i("RetroShareQmlActivity", "openImagePicker()");
Intent pickIntent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
pickIntent.setType("image/*");
ContentValues values = new ContentValues();
values.put(MediaStore.Images.Media.TITLE, "Retroshare Avatar");
capturedImageURI = getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
Intent takePicture = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
takePicture.putExtra(MediaStore.EXTRA_OUTPUT, capturedImageURI);
Intent chooserIntent = Intent.createChooser(pickIntent, "Select Image");
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[] {takePicture});
startActivityForResult( chooserIntent, PICK_PHOTO);
};
public void onActivityResult(int requestCode, int resultCode, Intent data)
{
Log.i("RetroShareQmlActivity", "onActivityResult()" + String.valueOf(requestCode));
if (resultCode == RESULT_OK)
{
if (requestCode == PICK_PHOTO)
{
final boolean isCamera;
if (data == null)
{
isCamera = true;
}
else
{
final String action = data.getAction();
if (action == null)
{
isCamera = false;
}
else
{
isCamera = action.equals(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
}
}
Uri selectedImageUri;
if (isCamera)
{
selectedImageUri = capturedImageURI;
}
else
{
selectedImageUri = data == null ? null : data.getData();
}
String uri = getRealPathFromURI(selectedImageUri);
if (uri != null)
{
Log.i("RetroShareQmlActivity", "Image path from uri found!" + uri);
NativeCalls.notifyIntentUri("//file"+uri); // Add the authority for get it on qml code
}
}
}
}
public String getRealPathFromURI(Uri uri) {
String[] projection = { MediaStore.Images.Media.DATA };
@SuppressWarnings("deprecation")
Cursor cursor = managedQuery(uri, projection, null, null, null);
int column_index = cursor
.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
String result = cursor.getString(column_index);
return result;
}
}