Messaging: Get rid of storage permissions
Since these have no effect on sdk 33 and up and everything works without them we can get rid of those Change-Id: I0482d8b8772dc2c64bb1930fbc6ba4852f4b4c61
This commit is contained in:
@@ -17,7 +17,6 @@
|
||||
|
||||
package com.android.messaging.ui.conversation;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.Activity;
|
||||
import android.app.DownloadManager;
|
||||
import android.content.BroadcastReceiver;
|
||||
@@ -306,20 +305,15 @@ public class ConversationFragment extends Fragment implements ConversationDataLi
|
||||
final String messageId = data.getMessageId();
|
||||
int itemId = menuItem.getItemId();
|
||||
if (itemId == R.id.save_attachment) {
|
||||
if (OsUtil.hasStoragePermission()) {
|
||||
final SaveAttachmentTask saveAttachmentTask = new SaveAttachmentTask(
|
||||
getActivity());
|
||||
for (final MessagePartData part : data.getAttachments()) {
|
||||
saveAttachmentTask.addAttachmentToSave(part.getContentUri(),
|
||||
part.getContentType());
|
||||
}
|
||||
if (saveAttachmentTask.getAttachmentCount() > 0) {
|
||||
saveAttachmentTask.executeOnThreadPool();
|
||||
mHost.dismissActionMode();
|
||||
}
|
||||
} else {
|
||||
getActivity().requestPermissions(
|
||||
new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 0);
|
||||
final SaveAttachmentTask saveAttachmentTask = new SaveAttachmentTask(
|
||||
getActivity());
|
||||
for (final MessagePartData part : data.getAttachments()) {
|
||||
saveAttachmentTask.addAttachmentToSave(part.getContentUri(),
|
||||
part.getContentType());
|
||||
}
|
||||
if (saveAttachmentTask.getAttachmentCount() > 0) {
|
||||
saveAttachmentTask.executeOnThreadPool();
|
||||
mHost.dismissActionMode();
|
||||
}
|
||||
return true;
|
||||
} else if (itemId == R.id.action_delete_message) {
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package com.android.messaging.ui.photoviewer;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@@ -40,7 +39,6 @@ import com.android.messaging.datamodel.MediaScratchFileProvider;
|
||||
import com.android.messaging.ui.conversation.ConversationFragment;
|
||||
import com.android.messaging.util.Dates;
|
||||
import com.android.messaging.util.LogUtil;
|
||||
import com.android.messaging.util.OsUtil;
|
||||
|
||||
/**
|
||||
* Customizations for the photoviewer to display conversation images in full screen.
|
||||
@@ -148,23 +146,18 @@ public class BuglePhotoViewController extends PhotoViewController {
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(final MenuItem item) {
|
||||
if (item.getItemId() == R.id.action_save) {
|
||||
if (OsUtil.hasStoragePermission()) {
|
||||
final PhotoPagerAdapter adapter = getAdapter();
|
||||
final Cursor cursor = getCursorAtProperPosition();
|
||||
if (cursor == null) {
|
||||
final Context context = getActivity().getContext();
|
||||
final String error = context.getResources().getQuantityString(
|
||||
R.plurals.attachment_save_error, 1, 1);
|
||||
Toast.makeText(context, error, Toast.LENGTH_SHORT).show();
|
||||
return true;
|
||||
}
|
||||
final String photoUri = adapter.getPhotoUri(cursor);
|
||||
new ConversationFragment.SaveAttachmentTask(((Activity) getActivity()),
|
||||
Uri.parse(photoUri), adapter.getContentType(cursor)).executeOnThreadPool();
|
||||
} else {
|
||||
((Activity)getActivity()).requestPermissions(
|
||||
new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE }, 0);
|
||||
final PhotoPagerAdapter adapter = getAdapter();
|
||||
final Cursor cursor = getCursorAtProperPosition();
|
||||
if (cursor == null) {
|
||||
final Context context = getActivity().getContext();
|
||||
final String error = context.getResources().getQuantityString(
|
||||
R.plurals.attachment_save_error, 1, 1);
|
||||
Toast.makeText(context, error, Toast.LENGTH_SHORT).show();
|
||||
return true;
|
||||
}
|
||||
final String photoUri = adapter.getPhotoUri(cursor);
|
||||
new ConversationFragment.SaveAttachmentTask(((Activity) getActivity()),
|
||||
Uri.parse(photoUri), adapter.getContentType(cursor)).executeOnThreadPool();
|
||||
return true;
|
||||
} else {
|
||||
return super.onOptionsItemSelected(item);
|
||||
|
||||
Reference in New Issue
Block a user