Fixed incoming files display + store them in a Linphone directory instead of /
This commit is contained in:
parent
3d94dc0629
commit
417ed4e121
4 changed files with 12 additions and 8 deletions
|
@ -757,5 +757,9 @@ public final class LinphoneUtils {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getStorageDirectory(Context mContext) {
|
||||||
|
return Environment.getExternalStorageDirectory() + "/" + mContext.getString(mContext.getResources().getIdentifier("app_name", "string", mContext.getPackageName()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -325,10 +325,10 @@ public class ChatEventsAdapter extends SelectableAdapter<ChatBubbleViewHolder> {
|
||||||
if (mContext.getPackageManager().checkPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE, mContext.getPackageName()) == PackageManager.PERMISSION_GRANTED) {
|
if (mContext.getPackageManager().checkPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE, mContext.getPackageName()) == PackageManager.PERMISSION_GRANTED) {
|
||||||
v.setEnabled(false);
|
v.setEnabled(false);
|
||||||
String filename = message.getFileTransferInformation().getName();
|
String filename = message.getFileTransferInformation().getName();
|
||||||
File file = new File(Environment.getExternalStorageDirectory(), filename);
|
File file = new File(LinphoneUtils.getStorageDirectory(mContext), filename);
|
||||||
int prefix = 1;
|
int prefix = 1;
|
||||||
while (file.exists()) {
|
while (file.exists()) {
|
||||||
file = new File(Environment.getExternalStorageDirectory(), prefix + "_" + filename);
|
file = new File(LinphoneUtils.getStorageDirectory(mContext), prefix + "_" + filename);
|
||||||
Log.w("File with that name already exists, renamed to " + prefix + "_" + filename);
|
Log.w("File with that name already exists, renamed to " + prefix + "_" + filename);
|
||||||
prefix += 1;
|
prefix += 1;
|
||||||
}
|
}
|
||||||
|
@ -468,8 +468,8 @@ public class ChatEventsAdapter extends SelectableAdapter<ChatBubbleViewHolder> {
|
||||||
|
|
||||||
private void openFile(String path) {
|
private void openFile(String path) {
|
||||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||||
File file = null;
|
File file;
|
||||||
Uri contentUri = null;
|
Uri contentUri;
|
||||||
if (path.startsWith("file://")) {
|
if (path.startsWith("file://")) {
|
||||||
path = path.substring("file://".length());
|
path = path.substring("file://".length());
|
||||||
file = new File(path);
|
file = new File(path);
|
||||||
|
|
|
@ -589,7 +589,7 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
|
||||||
private void pickFile() {
|
private void pickFile() {
|
||||||
List<Intent> cameraIntents = new ArrayList<>();
|
List<Intent> cameraIntents = new ArrayList<>();
|
||||||
Intent captureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
Intent captureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
||||||
File file = new File(Environment.getExternalStorageDirectory(), getString(R.string.temp_photo_name_with_date).replace("%s", String.valueOf(System.currentTimeMillis()) + ".jpeg"));
|
File file = new File(LinphoneUtils.getStorageDirectory(mContext), getString(R.string.temp_photo_name_with_date).replace("%s", String.valueOf(System.currentTimeMillis()) + ".jpeg"));
|
||||||
mImageToUploadUri = Uri.fromFile(file);
|
mImageToUploadUri = Uri.fromFile(file);
|
||||||
captureIntent.putExtra(MediaStore.EXTRA_OUTPUT, mImageToUploadUri);
|
captureIntent.putExtra(MediaStore.EXTRA_OUTPUT, mImageToUploadUri);
|
||||||
cameraIntents.add(captureIntent);
|
cameraIntents.add(captureIntent);
|
||||||
|
|
|
@ -339,9 +339,9 @@ public class ContactEditorFragment extends Fragment {
|
||||||
|
|
||||||
private void pickImage() {
|
private void pickImage() {
|
||||||
pickedPhotoForContactUri = null;
|
pickedPhotoForContactUri = null;
|
||||||
final List<Intent> cameraIntents = new ArrayList<Intent>();
|
final List<Intent> cameraIntents = new ArrayList<>();
|
||||||
final Intent captureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
final Intent captureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
||||||
File file = new File(Environment.getExternalStorageDirectory(), getString(R.string.temp_photo_name));
|
File file = new File(LinphoneUtils.getStorageDirectory(LinphoneActivity.instance()), getString(R.string.temp_photo_name));
|
||||||
pickedPhotoForContactUri = Uri.fromFile(file);
|
pickedPhotoForContactUri = Uri.fromFile(file);
|
||||||
captureIntent.putExtra("outputX", PHOTO_SIZE);
|
captureIntent.putExtra("outputX", PHOTO_SIZE);
|
||||||
captureIntent.putExtra("outputY", PHOTO_SIZE);
|
captureIntent.putExtra("outputY", PHOTO_SIZE);
|
||||||
|
@ -381,7 +381,7 @@ public class ContactEditorFragment extends Fragment {
|
||||||
String filePath = pickedPhotoForContactUri.getPath();
|
String filePath = pickedPhotoForContactUri.getPath();
|
||||||
editContactPicture(filePath, null);
|
editContactPicture(filePath, null);
|
||||||
} else {
|
} else {
|
||||||
File file = new File(Environment.getExternalStorageDirectory(), getString(R.string.temp_photo_name));
|
File file = new File(LinphoneUtils.getStorageDirectory(LinphoneActivity.instance()), getString(R.string.temp_photo_name));
|
||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
pickedPhotoForContactUri = Uri.fromFile(file);
|
pickedPhotoForContactUri = Uri.fromFile(file);
|
||||||
String filePath = pickedPhotoForContactUri.getPath();
|
String filePath = pickedPhotoForContactUri.getPath();
|
||||||
|
|
Loading…
Reference in a new issue