<provider
android:name=".providers.FileContentProvider"
- android:authorities="org.owncloud.beta.provider"
+ android:authorities="@string/authority"
android:enabled="true"
android:exported="true"
android:label="@string/sync_string_files"
<provider
android:name=".ui.adapter.DiskLruImageCacheFileProvider"
- android:authorities="org.owncloud.beta.imageCache.provider">
+ android:authorities="@string/authorityCache"
+ android:exported="true">
</provider>
<activity
+# 2015-11-02
+- PR [#1240](https://github.com/owncloud/android/pull/1240) "Set as wallpaper" merged
+- updated other PRs
+
# 2015-11-01
- PR [#1236](https://github.com/owncloud/android/pull/1236) "Streaming video/audio" merged
- PR [#1035](https://github.com/owncloud/android/pull/1035) "Enable video thumbnail" merged
android:icon="@android:drawable/ic_menu_set_as"
android:orderInCategory="1" />
<item
+ android:id="@+id/action_set_as_wallpaper"
+ android:title="@string/set_picture_as"
+ android:icon="@android:drawable/ic_menu_set_as"
+ android:orderInCategory="1" />
+ <item
android:id="@+id/action_see_details"
android:title="@string/actionbar_see_details"
android:icon="@android:drawable/ic_menu_info_details"
<string name="app_name">Owncloud Beta</string>
<string name="account_type">owncloud.beta</string> <!-- better if was a domain name; but changing it now would require migrate accounts when the app is updated -->
<string name="authority">org.owncloud.beta.provider</string> <!-- better if was the app package with ".provider" appended ; it identifies the provider -->
+ <string name="authorityCache">org.owncloud.beta.imageCache.provider</string>
<string name ="db_file">owncloud.db</string>
<string name ="db_name">ownCloud</string>
<string name ="data_folder">owncloud-beta</string>
<string name="error_log_title">Error Log</string>
<string name="action_stream_file">Stream file with external player</string>
<string name="stream_expose_password">Do you want to stream this file with an external app?\n\nCAUTION: This may expose your password!</string>
+ <string name="set_picture_as">Set picture as</string>
</resources>
import org.apache.http.protocol.HTTP;
+import java.io.File;
import java.util.List;
import java.io.ByteArrayOutputStream;
}
}
+ public void setPictureAs(OCFile file) {
+ if (file != null){
+ if (file.isDown()) {
+ File externalFile = new File(file.getStoragePath());
+ Uri sendUri = Uri.fromFile(externalFile);
+ Intent intent = new Intent(Intent.ACTION_ATTACH_DATA);
+ intent.setDataAndType(sendUri, file.getMimetype());
+ intent.putExtra("mimeType", file.getMimetype());
+ mFileActivity.startActivityForResult(Intent.createChooser(intent, "Set As"), 200);
+ } else {
+ // TODO re-enable after resized images is available
+ Uri sendUri = Uri.parse("content://" + DiskLruImageCacheFileProvider.AUTHORITY + file.getRemotePath());
+ Intent intent = new Intent(Intent.ACTION_ATTACH_DATA);
+ intent.setDataAndType(sendUri, file.getMimetype());
+ intent.putExtra("mimeType", file.getMimetype());
+ mFileActivity.startActivityForResult(Intent.createChooser(intent, "Set As"), 200);
+
+// Intent sendIntent = new Intent(android.content.Intent.ACTION_SEND);
+// // set MimeType
+// sendIntent.setType(file.getMimetype());
+//// sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("content://" + DiskLruImageCacheFileProvider.AUTHORITY + "/#" + file.getRemoteId() + "#" + file.getFileName()));
+// sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("content://" + DiskLruImageCacheFileProvider.AUTHORITY + file.getRemotePath()));
+// sendIntent.putExtra(Intent.ACTION_SEND, true); // Send Action
+//
+// // Show dialog, without the own app
+// String[] packagesToExclude = new String[] { mFileActivity.getPackageName() };
+// DialogFragment chooserDialog = ShareLinkToDialog.newInstance(sendIntent, packagesToExclude, file);
+// chooserDialog.show(mFileActivity.getSupportFragmentManager(), FTAG_CHOOSER_DIALOG);
+ }
+ } else {
+ Log_OC.wtf(TAG, "Trying to send a NULL OCFile");
+ }
+ }
+
public void sendCachedImage(OCFile file) {
if (file != null) {
Intent sendIntent = new Intent(android.content.Intent.ACTION_SEND);
import android.content.ContentValues;
import android.content.UriMatcher;
import android.database.Cursor;
+import android.database.MatrixCursor;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.ParcelFileDescriptor;
+import android.provider.OpenableColumns;
import com.owncloud.android.MainApp;
import com.owncloud.android.authentication.AccountUtils;
public class DiskLruImageCacheFileProvider extends ContentProvider {
private static String TAG = FileDataStorageManager.class.getSimpleName();
+ private FileDataStorageManager mFileDataStorageManager;
- public static final String AUTHORITY = "com.owncloud.imageCache.provider";
+ public static final String AUTHORITY = "org.owncloud.beta.imageCache.provider";
@Override
- public ParcelFileDescriptor openFile(Uri uri, String mode) throws FileNotFoundException {
+ public boolean onCreate() {
+ return true;
+ }
+
+ private OCFile getFile(Uri uri){
Account account = AccountUtils.getCurrentOwnCloudAccount(MainApp.getAppContext());
- FileDataStorageManager fileDataStorageManager = new FileDataStorageManager(account,
+ mFileDataStorageManager = new FileDataStorageManager(account,
MainApp.getAppContext().getContentResolver());
- OCFile ocFile = fileDataStorageManager.getFileByPath(uri.getPath());
+ OCFile ocFile = mFileDataStorageManager.getFileByPath(uri.getPath());
+ return ocFile;
+ }
+
+ @Override
+ public ParcelFileDescriptor openFile(Uri uri, String mode) throws FileNotFoundException {
+ OCFile ocFile = getFile(uri);
Bitmap thumbnail = ThumbnailsCacheManager.getBitmapFromDiskCache(
String.valueOf("r" + ocFile.getRemoteId()));
return ParcelFileDescriptor.open(f, ParcelFileDescriptor.MODE_READ_ONLY);
}
-
@Override
- public boolean onCreate() {
- return true;
+ public String getType(Uri uri) {
+ OCFile ocFile = getFile(uri);
+ return ocFile.getMimetype();
}
@Override
- public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
- return null;
- }
+ public Cursor query(Uri uri, String[] arg1, String arg2, String[] arg3, String arg4) {
+ MatrixCursor cursor = null;
+
+ OCFile ocFile = getFile(uri);
+ File file = new File(MainApp.getAppContext().getCacheDir(), ocFile.getFileName());
+ if (file.exists()) {
+ cursor = new MatrixCursor(new String[] {
+ OpenableColumns.DISPLAY_NAME, OpenableColumns.SIZE });
+ cursor.addRow(new Object[] { uri.getLastPathSegment(),
+ file.length() });
+ }
- @Override
- public String getType(Uri uri) {
- return null;
+ return cursor;
}
@Override
((FileDisplayActivity) mContainerActivity).startMediaPreview(file, 0, true);
} else if (file.isDown()) {
mContainerActivity.getFileOperationsHelper().openFile(file);
- } else {
+ } else {
// automatic download, preview on finish
((FileDisplayActivity) mContainerActivity).startDownloadForPreview(file);
}
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.file_actions_menu, menu);
+
+// MenuItem item = menu.findItem(R.id.action_set_as_wallpaper);
+// item.setVisible(getFile().isDown());
}
/**
mContainerActivity.getFileOperationsHelper().toggleFavorite(getFile(), false);
return true;
}
+ case R.id.action_set_as_wallpaper:{
+ mContainerActivity.getFileOperationsHelper().setPictureAs(getFile());
+ return true;
+ }
default:
return false;
}