mirror of
https://github.com/nextcloud/android.git
synced 2024-12-18 23:11:58 +03:00
handle Nougat and wallpaper app
This commit is contained in:
parent
58c9a7ddc7
commit
01761718d9
2 changed files with 85 additions and 67 deletions
|
@ -5,19 +5,18 @@
|
|||
* @author David A. Velasco
|
||||
* @author Juan Carlos González Cabrero
|
||||
* Copyright (C) 2015 ownCloud Inc.
|
||||
*
|
||||
* <p>
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* <p>
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* <p>
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.owncloud.android.ui.helpers;
|
||||
|
@ -29,12 +28,14 @@ import android.content.Intent;
|
|||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.net.Uri;
|
||||
import android.os.Parcelable;
|
||||
import android.os.Build;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v4.content.FileProvider;
|
||||
import android.webkit.MimeTypeMap;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.authentication.AccountUtils;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
|
@ -374,8 +375,8 @@ public class FileOperationsHelper {
|
|||
*/
|
||||
public void showShareFile(OCFile file) {
|
||||
Intent intent = new Intent(mFileActivity, ShareActivity.class);
|
||||
intent.putExtra(mFileActivity.EXTRA_FILE, (Parcelable) file);
|
||||
intent.putExtra(mFileActivity.EXTRA_ACCOUNT, mFileActivity.getAccount());
|
||||
intent.putExtra(FileActivity.EXTRA_FILE, file);
|
||||
intent.putExtra(FileActivity.EXTRA_ACCOUNT, mFileActivity.getAccount());
|
||||
mFileActivity.startActivity(intent);
|
||||
|
||||
}
|
||||
|
@ -527,13 +528,29 @@ public class FileOperationsHelper {
|
|||
public void setPictureAs(OCFile file) {
|
||||
if (file != null) {
|
||||
if (file.isDown()) {
|
||||
Context context = MainApp.getAppContext();
|
||||
|
||||
try {
|
||||
File externalFile = new File(file.getStoragePath());
|
||||
Uri sendUri = Uri.fromFile(externalFile);
|
||||
Intent intent = new Intent(Intent.ACTION_ATTACH_DATA);
|
||||
Uri sendUri;
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||
sendUri = FileProvider.getUriForFile(context,
|
||||
context.getResources().getString(R.string.file_provider_authority), externalFile);
|
||||
} else {
|
||||
sendUri = Uri.fromFile(externalFile);
|
||||
}
|
||||
|
||||
intent.setDataAndType(sendUri, file.getMimetype());
|
||||
intent.putExtra("mimeType", file.getMimetype());
|
||||
mFileActivity.startActivityForResult(Intent.createChooser(intent,
|
||||
mFileActivity.getString(R.string.set_as)), 200);
|
||||
|
||||
} catch (ActivityNotFoundException exception) {
|
||||
Toast.makeText(context, R.string.picture_set_as_no_app, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Log_OC.wtf(TAG, "Trying to send a NULL OCFile");
|
||||
|
|
|
@ -662,6 +662,7 @@
|
|||
<!-- Notifications -->
|
||||
<string name="new_notification_received">New notification received</string>
|
||||
<string name="drawer_logout">Logout</string>
|
||||
<string name="picture_set_as_no_app">No app found to set a picture with!</string>
|
||||
|
||||
|
||||
</resources>
|
||||
|
|
Loading…
Reference in a new issue