mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
Implement save to downloads/music/gallery.
This commit is contained in:
@@ -22,15 +22,15 @@
|
||||
|
||||
package com.b44t.messenger;
|
||||
|
||||
import android.Manifest;
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorSet;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.DownloadManager;
|
||||
import android.content.ContentUris;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
@@ -41,8 +41,6 @@ import android.graphics.Color;
|
||||
import android.graphics.Point;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.Typeface;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
@@ -64,7 +62,6 @@ import android.widget.AbsListView;
|
||||
import android.widget.EdgeEffect;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ListView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
@@ -80,6 +77,7 @@ import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
@@ -625,11 +623,11 @@ public class AndroidUtilities {
|
||||
showHint(context, ApplicationLoader.applicationContext.getString(R.string.ErrorHint));
|
||||
}
|
||||
|
||||
public static void showHint(Context context, String text)
|
||||
public static Toast showHint(Context context, String text)
|
||||
{
|
||||
if( text != null ) {
|
||||
Toast.makeText(context, text, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
Toast t = Toast.makeText(context, text, Toast.LENGTH_LONG);
|
||||
t.show();
|
||||
return t;
|
||||
}
|
||||
|
||||
public static void addToClipboard(CharSequence str) {
|
||||
@@ -787,49 +785,6 @@ public class AndroidUtilities {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static CharSequence generateSearchName(String name, String name2, String q) {
|
||||
if (name == null && name2 == null) {
|
||||
return "";
|
||||
}
|
||||
SpannableStringBuilder builder = new SpannableStringBuilder();
|
||||
String wholeString = name;
|
||||
if (wholeString == null || wholeString.length() == 0) {
|
||||
wholeString = name2;
|
||||
} else if (name2 != null && name2.length() != 0) {
|
||||
wholeString += " " + name2;
|
||||
}
|
||||
wholeString = wholeString.trim();
|
||||
String lower = " " + wholeString.toLowerCase();
|
||||
|
||||
int index;
|
||||
int lastIndex = 0;
|
||||
while ((index = lower.indexOf(" " + q, lastIndex)) != -1) {
|
||||
int idx = index - (index == 0 ? 0 : 1);
|
||||
int end = q.length() + (index == 0 ? 0 : 1) + idx;
|
||||
|
||||
if (lastIndex != 0 && lastIndex != idx + 1) {
|
||||
builder.append(wholeString.substring(lastIndex, idx));
|
||||
} else if (lastIndex == 0 && idx != 0) {
|
||||
builder.append(wholeString.substring(0, idx));
|
||||
}
|
||||
|
||||
String query = wholeString.substring(idx, end);
|
||||
if (query.startsWith(" ")) {
|
||||
builder.append(" ");
|
||||
}
|
||||
query = query.trim();
|
||||
builder.append(AndroidUtilities.replaceTags("<c#ff4d83b3>" + query + "</c>"));
|
||||
|
||||
lastIndex = end;
|
||||
}
|
||||
|
||||
if (lastIndex != -1 && lastIndex != wholeString.length()) {
|
||||
builder.append(wholeString.substring(lastIndex, wholeString.length()));
|
||||
}
|
||||
|
||||
return builder;
|
||||
}
|
||||
|
||||
public static File generateVideoPath() {
|
||||
try {
|
||||
File storageDir = getAlbumDir();
|
||||
@@ -918,44 +873,17 @@ public class AndroidUtilities {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static byte[] calcAuthKeyHash(byte[] auth_key) {
|
||||
byte[] sha1 = Utilities.computeSHA1(auth_key);
|
||||
byte[] key_hash = new byte[16];
|
||||
System.arraycopy(sha1, 0, key_hash, 0, 16);
|
||||
return key_hash;
|
||||
}
|
||||
/* open, view, download files
|
||||
**********************************************************************************************/
|
||||
|
||||
/*
|
||||
public static void saveToDownloads()
|
||||
public static String getMimetype(MessageObject message)
|
||||
{
|
||||
if (Build.VERSION.SDK_INT >= 23 && getParentActivity().checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
||||
getParentActivity().requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 4);
|
||||
selectedObject = null;
|
||||
return;
|
||||
}
|
||||
String fileName = FileLoader.getDocumentFileName(selectedObject.getDocument());
|
||||
if (fileName == null || fileName.length() == 0) {
|
||||
fileName = selectedObject.getFileName();
|
||||
}
|
||||
String path = selectedObject.messageOwner.attachPath;
|
||||
if (path != null && path.length() > 0) {
|
||||
File temp = new File(path);
|
||||
if (!temp.exists()) {
|
||||
path = null;
|
||||
}
|
||||
}
|
||||
if (path == null || path.length() == 0) {
|
||||
path = FileLoader.getPathToMessage(selectedObject.messageOwner).toString();
|
||||
}
|
||||
MediaController.saveFile(path, getParentActivity(), selectedObject.isMusic() ? 3 : 2, fileName, selectedObject.getDocument() != null ? selectedObject.getDocument().mime_type : "");
|
||||
|
||||
return getMimetype(message.messageOwner.media.document.file_name, message.messageOwner.media.document.mime_type);
|
||||
}
|
||||
*/
|
||||
|
||||
public static String getMimetypeForView(MessageObject message)
|
||||
public static String getMimetype(String fileName, String def)
|
||||
{
|
||||
String mimeType = "application/octet-stream";
|
||||
String fileName = message.messageOwner.media.document.file_name;
|
||||
try {
|
||||
MimeTypeMap mimeMap = MimeTypeMap.getSingleton();
|
||||
int idx = fileName.lastIndexOf('.');
|
||||
@@ -964,7 +892,7 @@ public class AndroidUtilities {
|
||||
mimeType = mimeMap.getMimeTypeFromExtension(ext.toLowerCase());
|
||||
}
|
||||
if (mimeType == null) {
|
||||
mimeType = message.messageOwner.media.document.mime_type;
|
||||
mimeType = def==null? "application/octet-stream" : def;
|
||||
}
|
||||
}
|
||||
catch(Exception e) {
|
||||
@@ -984,11 +912,133 @@ public class AndroidUtilities {
|
||||
uri = Uri.fromFile(file);
|
||||
}
|
||||
|
||||
String mimeType = getMimetypeForView(message);
|
||||
String mimeType = getMimetype(message);
|
||||
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||
intent.setDataAndType(uri, mimeType);
|
||||
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||
activity.startActivity(intent);
|
||||
}
|
||||
|
||||
private static File getFineFilename(File path, String desiredName)
|
||||
{
|
||||
// get a fine file name by adding a number to the basename and avoid overwrites
|
||||
for( int i = 0; i < 1000; i++ ) {
|
||||
String testName = desiredName;
|
||||
if( i > 0 ) {
|
||||
String baseName=desiredName, ext = "";
|
||||
int idx = desiredName.lastIndexOf('.');
|
||||
if( idx != -1 ) {
|
||||
baseName = desiredName.substring(0, idx);
|
||||
ext = desiredName.substring(idx);
|
||||
}
|
||||
testName = String.format("%s-%d%s", baseName, i, ext);
|
||||
}
|
||||
File pathNFile = new File(path, testName);
|
||||
if (!pathNFile.exists()) {
|
||||
return pathNFile;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void saveMessageFileToExt(final Activity context, int msg_id)
|
||||
{
|
||||
if (Build.VERSION.SDK_INT >= 23 && context.checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
||||
context.requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 4);
|
||||
return;
|
||||
}
|
||||
|
||||
MrMsg msg = MrMailbox.getMsg(msg_id);
|
||||
final int msg_type = msg.getType();
|
||||
String msg_file_path = msg.getParam('f', "");
|
||||
final String msg_mime = msg.getParam('m', "application/octet-stream");
|
||||
final String msg_file_name = msg.getFilename();
|
||||
final File sourceFile = new File(msg_file_path);
|
||||
if( !sourceFile.exists() ) {
|
||||
showErrorHint(context);
|
||||
return;
|
||||
}
|
||||
|
||||
final Toast waitingHint = showHint(context, ApplicationLoader.applicationContext.getString(R.string.OneMomentPlease));
|
||||
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
boolean allOkay = false;
|
||||
|
||||
try {
|
||||
// get destination path
|
||||
File destPath = null;
|
||||
boolean add_to_download_manager = false;
|
||||
if (msg_type == MrMsg.MR_MSG_IMAGE || msg_type == MrMsg.MR_MSG_VIDEO) {
|
||||
destPath = AndroidUtilities.getAlbumDir();
|
||||
} else if (msg_type == MrMsg.MR_MSG_FILE) {
|
||||
destPath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
|
||||
add_to_download_manager = true;
|
||||
} else if (msg_type == MrMsg.MR_MSG_AUDIO || msg_type == MrMsg.MR_MSG_VOICE ) {
|
||||
destPath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MUSIC);
|
||||
}
|
||||
|
||||
// create destination path (must be done, see documentation for getExternalStoragePublicDirectory())
|
||||
destPath.mkdirs();
|
||||
|
||||
File destPathNFile = getFineFilename(destPath, msg_file_name);
|
||||
if( destPathNFile != null )
|
||||
{
|
||||
destPathNFile.createNewFile();
|
||||
boolean copied = true;
|
||||
FileChannel source = null;
|
||||
FileChannel destination = null;
|
||||
try {
|
||||
source = new FileInputStream(sourceFile).getChannel();
|
||||
destination = new FileOutputStream(destPathNFile).getChannel();
|
||||
long size = source.size();
|
||||
for (long a = 0; a < size; a += 4096) {
|
||||
destination.transferFrom(source, a, Math.min(4096, size - a));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
copied = false;
|
||||
} finally {
|
||||
if (source != null) {
|
||||
source.close();
|
||||
}
|
||||
if (destination != null) {
|
||||
destination.close();
|
||||
}
|
||||
}
|
||||
|
||||
if (copied) {
|
||||
if ( add_to_download_manager ) {
|
||||
DownloadManager downloadManager = (DownloadManager) ApplicationLoader.applicationContext.getSystemService(Context.DOWNLOAD_SERVICE);
|
||||
downloadManager.addCompletedDownload(destPathNFile.getName(), destPathNFile.getName(), false, getMimetype(msg_file_name, msg_mime), destPathNFile.getAbsolutePath(), destPathNFile.length(), true);
|
||||
} else {
|
||||
addMediaToGallery(Uri.fromFile(destPathNFile));
|
||||
}
|
||||
allOkay = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
;
|
||||
}
|
||||
|
||||
final boolean allOkayFinal = allOkay;
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
waitingHint.cancel();
|
||||
if( allOkayFinal ) {
|
||||
showDoneHint(context);
|
||||
}
|
||||
else {
|
||||
showHint(context, ApplicationLoader.applicationContext.getString(R.string.AccessError));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -92,12 +92,6 @@ public class FileLoader {
|
||||
mediaDirs = dirs;
|
||||
}
|
||||
|
||||
/*
|
||||
public File checkDirectory(int type) {
|
||||
return mediaDirs.get(type);
|
||||
}
|
||||
*/
|
||||
|
||||
public File getDirectory(int type) { // always returns the cache directory as this is the only one set in mediaDirs[] - we do not use the other directories at the moment
|
||||
File dir = mediaDirs.get(type);
|
||||
if (dir == null && type != MEDIA_DIR_CACHE) {
|
||||
|
||||
@@ -37,7 +37,6 @@ import android.media.ThumbnailUtils;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
import android.os.Environment;
|
||||
import android.provider.MediaStore;
|
||||
|
||||
import com.b44t.ui.Components.AnimatedFileDrawable;
|
||||
@@ -96,8 +95,6 @@ public class ImageLoader {
|
||||
private int lastImageNum = 0;
|
||||
private long lastProgressUpdateTime = 0;
|
||||
|
||||
private File messengerPath = null;
|
||||
|
||||
private class ThumbGenerateInfo {
|
||||
private int count;
|
||||
private TLRPC.FileLocation fileLocation;
|
||||
@@ -530,16 +527,6 @@ public class ImageLoader {
|
||||
kf += "@" + filter;
|
||||
}
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageThumbGenerated, bitmapDrawable, kf);
|
||||
/*BitmapDrawable old = memCache.get(kf);
|
||||
if (old != null) {
|
||||
Bitmap image = old.getBitmap();
|
||||
if (runtimeHack != null) {
|
||||
runtimeHack.trackAlloc(image.getRowBytes() * image.getHeight());
|
||||
}
|
||||
if (!image.isRecycled()) {
|
||||
image.recycle();
|
||||
}
|
||||
}*/
|
||||
memCache.put(kf, bitmapDrawable);
|
||||
}
|
||||
});
|
||||
@@ -1256,149 +1243,6 @@ public class ImageLoader {
|
||||
|
||||
mediaDirs.put(FileLoader.MEDIA_DIR_CACHE, cachePath);
|
||||
FileLoader.getInstance().setMediaDirs(mediaDirs);
|
||||
|
||||
/*
|
||||
cacheOutQueue.postRunnable(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final HashMap<Integer, File> paths = createMediaPaths();
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
FileLoader.getInstance().setMediaDirs(paths);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
*/
|
||||
}
|
||||
|
||||
/*
|
||||
public HashMap<Integer, File> createMediaPaths() { // not sure, but it seems as if these paths are not needed
|
||||
HashMap<Integer, File> mediaDirs = new HashMap<>();
|
||||
File cachePath = AndroidUtilities.getCacheDir();
|
||||
if (!cachePath.isDirectory()) {
|
||||
try {
|
||||
cachePath.mkdirs();
|
||||
} catch (Exception e) {
|
||||
FileLog.e("messenger", e);
|
||||
}
|
||||
}
|
||||
try {
|
||||
new File(cachePath, ".nomedia").createNewFile();
|
||||
} catch (Exception e) {
|
||||
FileLog.e("messenger", e);
|
||||
}
|
||||
|
||||
mediaDirs.put(FileLoader.MEDIA_DIR_CACHE, cachePath);
|
||||
FileLog.e("messenger", "cache path = " + cachePath);
|
||||
|
||||
try {
|
||||
if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
|
||||
messengerPath = new File(Environment.getExternalStorageDirectory(), "Delta Chat");
|
||||
messengerPath.mkdirs();
|
||||
|
||||
if (messengerPath.isDirectory()) {
|
||||
try {
|
||||
File imagePath = new File(messengerPath, "Delta Chat Images");
|
||||
imagePath.mkdir();
|
||||
if (imagePath.isDirectory() && canMoveFiles(cachePath, imagePath, FileLoader.MEDIA_DIR_IMAGE)) {
|
||||
mediaDirs.put(FileLoader.MEDIA_DIR_IMAGE, imagePath);
|
||||
FileLog.e("messenger", "image path = " + imagePath);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e("messenger", e);
|
||||
}
|
||||
|
||||
try {
|
||||
File videoPath = new File(messengerPath, "Delta Chat Video");
|
||||
videoPath.mkdir();
|
||||
if (videoPath.isDirectory() && canMoveFiles(cachePath, videoPath, FileLoader.MEDIA_DIR_VIDEO)) {
|
||||
mediaDirs.put(FileLoader.MEDIA_DIR_VIDEO, videoPath);
|
||||
FileLog.e("messenger", "video path = " + videoPath);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e("messenger", e);
|
||||
}
|
||||
|
||||
try {
|
||||
File audioPath = new File(messengerPath, "Delta Chat Audio");
|
||||
audioPath.mkdir();
|
||||
if (audioPath.isDirectory() && canMoveFiles(cachePath, audioPath, FileLoader.MEDIA_DIR_AUDIO)) {
|
||||
new File(audioPath, ".nomedia").createNewFile();
|
||||
mediaDirs.put(FileLoader.MEDIA_DIR_AUDIO, audioPath);
|
||||
FileLog.e("messenger", "audio path = " + audioPath);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e("messenger", e);
|
||||
}
|
||||
|
||||
try {
|
||||
File documentPath = new File(messengerPath, "Delta Chat Documents");
|
||||
documentPath.mkdir();
|
||||
if (documentPath.isDirectory() && canMoveFiles(cachePath, documentPath, FileLoader.MEDIA_DIR_DOCUMENT)) {
|
||||
new File(documentPath, ".nomedia").createNewFile();
|
||||
mediaDirs.put(FileLoader.MEDIA_DIR_DOCUMENT, documentPath);
|
||||
FileLog.e("messenger", "documents path = " + documentPath);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e("messenger", e);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
FileLog.e("messenger", "this Android can't rename files");
|
||||
}
|
||||
MediaController.getInstance().checkSaveToGalleryFiles();
|
||||
} catch (Exception e) {
|
||||
FileLog.e("messenger", e);
|
||||
}
|
||||
|
||||
return mediaDirs;
|
||||
}
|
||||
*/
|
||||
|
||||
private boolean canMoveFiles(File from, File to, int type) {
|
||||
RandomAccessFile file = null;
|
||||
try {
|
||||
File srcFile = null;
|
||||
File dstFile = null;
|
||||
if (type == FileLoader.MEDIA_DIR_IMAGE) {
|
||||
srcFile = new File(from, "000000000_999999_temp.jpg");
|
||||
dstFile = new File(to, "000000000_999999.jpg");
|
||||
} else if (type == FileLoader.MEDIA_DIR_DOCUMENT) {
|
||||
srcFile = new File(from, "000000000_999999_temp.doc");
|
||||
dstFile = new File(to, "000000000_999999.doc");
|
||||
} else if (type == FileLoader.MEDIA_DIR_AUDIO) {
|
||||
srcFile = new File(from, "000000000_999999_temp.ogg");
|
||||
dstFile = new File(to, "000000000_999999.ogg");
|
||||
} else if (type == FileLoader.MEDIA_DIR_VIDEO) {
|
||||
srcFile = new File(from, "000000000_999999_temp.mp4");
|
||||
dstFile = new File(to, "000000000_999999.mp4");
|
||||
}
|
||||
byte[] buffer = new byte[1024];
|
||||
srcFile.createNewFile();
|
||||
file = new RandomAccessFile(srcFile, "rws");
|
||||
file.write(buffer);
|
||||
file.close();
|
||||
file = null;
|
||||
boolean canRename = srcFile.renameTo(dstFile);
|
||||
srcFile.delete();
|
||||
dstFile.delete();
|
||||
if (canRename) {
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e("messenger", e);
|
||||
} finally {
|
||||
try {
|
||||
if (file != null) {
|
||||
file.close();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e("messenger", e);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public Float getFileProgress(String location) {
|
||||
@@ -1408,21 +1252,6 @@ public class ImageLoader {
|
||||
return fileProgresses.get(location);
|
||||
}
|
||||
|
||||
private void performReplace(String oldKey, String newKey) {
|
||||
BitmapDrawable b = memCache.get(oldKey);
|
||||
if (b != null) {
|
||||
ignoreRemoval = oldKey;
|
||||
memCache.remove(oldKey);
|
||||
memCache.put(newKey, b);
|
||||
ignoreRemoval = null;
|
||||
}
|
||||
Integer val = bitmapUseCounts.get(oldKey);
|
||||
if (val != null) {
|
||||
bitmapUseCounts.put(newKey, val);
|
||||
bitmapUseCounts.remove(oldKey);
|
||||
}
|
||||
}
|
||||
|
||||
public void incrementUseCount(String key) {
|
||||
Integer count = bitmapUseCounts.get(key);
|
||||
if (count == null) {
|
||||
@@ -1503,65 +1332,6 @@ public class ImageLoader {
|
||||
});
|
||||
}
|
||||
|
||||
public BitmapDrawable getImageFromMemory(String key) {
|
||||
return memCache.get(key);
|
||||
}
|
||||
|
||||
public BitmapDrawable getImageFromMemory(TLObject fileLocation, String httpUrl, String filter) {
|
||||
if (fileLocation == null && httpUrl == null) {
|
||||
return null;
|
||||
}
|
||||
String key = null;
|
||||
if (httpUrl != null) {
|
||||
key = Utilities.MD5(httpUrl);
|
||||
} else {
|
||||
if (fileLocation instanceof TLRPC.FileLocation) {
|
||||
TLRPC.FileLocation location = (TLRPC.FileLocation) fileLocation;
|
||||
key = location.volume_id + "_" + location.local_id;
|
||||
} else if (fileLocation instanceof TLRPC.Document) {
|
||||
TLRPC.Document location = (TLRPC.Document) fileLocation;
|
||||
key = location.dc_id + "_" + location.id;
|
||||
}
|
||||
}
|
||||
if (filter != null) {
|
||||
key += "@" + filter;
|
||||
}
|
||||
return memCache.get(key);
|
||||
}
|
||||
|
||||
private void replaceImageInCacheInternal(final String oldKey, final String newKey, final TLRPC.FileLocation newLocation) {
|
||||
ArrayList<String> arr = memCache.getFilterKeys(oldKey);
|
||||
if (arr != null) {
|
||||
for (int a = 0; a < arr.size(); a++) {
|
||||
String filter = arr.get(a);
|
||||
String oldK = oldKey + "@" + filter;
|
||||
String newK = newKey + "@" + filter;
|
||||
performReplace(oldK, newK);
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.didReplacedPhotoInMemCache, oldK, newK, newLocation);
|
||||
}
|
||||
} else {
|
||||
performReplace(oldKey, newKey);
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.didReplacedPhotoInMemCache, oldKey, newKey, newLocation);
|
||||
}
|
||||
}
|
||||
|
||||
public void replaceImageInCache(final String oldKey, final String newKey, final TLRPC.FileLocation newLocation, boolean post) {
|
||||
if (post) {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
replaceImageInCacheInternal(oldKey, newKey, newLocation);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
replaceImageInCacheInternal(oldKey, newKey, newLocation);
|
||||
}
|
||||
}
|
||||
|
||||
public void putImageToCache(BitmapDrawable bitmap, String key) {
|
||||
memCache.put(key, bitmap);
|
||||
}
|
||||
|
||||
private void generateThumb(int mediaType, File originalPath, TLRPC.FileLocation thumbLocation, String filter) {
|
||||
if (mediaType != FileLoader.MEDIA_DIR_IMAGE && mediaType != FileLoader.MEDIA_DIR_VIDEO && mediaType != FileLoader.MEDIA_DIR_DOCUMENT || originalPath == null || thumbLocation == null) {
|
||||
return;
|
||||
@@ -1619,7 +1389,6 @@ public class ImageLoader {
|
||||
|
||||
if (!added) {
|
||||
boolean onlyCache = false;
|
||||
boolean isQuality = false;
|
||||
File cacheFile = null;
|
||||
|
||||
if (httpLocation != null) {
|
||||
@@ -1932,34 +1701,6 @@ public class ImageLoader {
|
||||
}
|
||||
}
|
||||
|
||||
public void loadHttpFile(String url, String defaultExt) {
|
||||
if (url == null || url.length() == 0 || httpFileLoadTasksByKeys.containsKey(url)) {
|
||||
return;
|
||||
}
|
||||
String ext = getHttpUrlExtension(url, defaultExt);
|
||||
File file = new File(FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_CACHE), Utilities.MD5(url) + "_temp." + ext);
|
||||
file.delete();
|
||||
|
||||
HttpFileTask task = new HttpFileTask(url, file, ext);
|
||||
httpFileLoadTasks.add(task);
|
||||
httpFileLoadTasksByKeys.put(url, task);
|
||||
runHttpFileLoadTasks(null, 0);
|
||||
}
|
||||
|
||||
public void cancelLoadHttpFile(String url) {
|
||||
HttpFileTask task = httpFileLoadTasksByKeys.get(url);
|
||||
if (task != null) {
|
||||
task.cancel(true);
|
||||
httpFileLoadTasksByKeys.remove(url);
|
||||
httpFileLoadTasks.remove(task);
|
||||
}
|
||||
Runnable runnable = retryHttpsTasks.get(url);
|
||||
if (runnable != null) {
|
||||
AndroidUtilities.cancelRunOnUIThread(runnable);
|
||||
}
|
||||
runHttpFileLoadTasks(null, 0);
|
||||
}
|
||||
|
||||
private void runHttpFileLoadTasks(final HttpFileTask oldTask, final int reason) {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
@@ -2005,7 +1746,6 @@ public class ImageLoader {
|
||||
InputStream inputStream = null;
|
||||
|
||||
if (path == null && uri != null && uri.getScheme() != null) {
|
||||
String imageFilePath = null;
|
||||
if (uri.getScheme().contains("file")) {
|
||||
path = uri.getPath();
|
||||
} else {
|
||||
@@ -2020,7 +1760,6 @@ public class ImageLoader {
|
||||
if (path != null) {
|
||||
BitmapFactory.decodeFile(path, bmOptions);
|
||||
} else if (uri != null) {
|
||||
boolean error = false;
|
||||
try {
|
||||
inputStream = ApplicationLoader.applicationContext.getContentResolver().openInputStream(uri);
|
||||
BitmapFactory.decodeStream(inputStream, null, bmOptions);
|
||||
|
||||
@@ -27,8 +27,6 @@ import android.Manifest;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Activity;
|
||||
import android.app.DownloadManager;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@@ -288,7 +286,6 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
|
||||
private ArrayList<DownloadObject> videoDownloadQueue = new ArrayList<>();
|
||||
private HashMap<String, DownloadObject> downloadQueueKeys = new HashMap<>();
|
||||
|
||||
private final boolean saveToGallery = false;
|
||||
private final boolean autoplayGifs = true;
|
||||
private boolean raiseToSpeak = true;
|
||||
private boolean directShare = true;
|
||||
@@ -613,7 +610,6 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
|
||||
mobileDataDownloadMask = preferences.getInt("mobileDataDownloadMask", AUTODOWNLOAD_MASK_PHOTO | AUTODOWNLOAD_MASK_AUDIO | AUTODOWNLOAD_MASK_MUSIC | AUTODOWNLOAD_MASK_GIF);
|
||||
wifiDownloadMask = preferences.getInt("wifiDownloadMask", AUTODOWNLOAD_MASK_PHOTO | AUTODOWNLOAD_MASK_AUDIO | AUTODOWNLOAD_MASK_MUSIC | AUTODOWNLOAD_MASK_GIF);
|
||||
roamingDownloadMask = preferences.getInt("roamingDownloadMask", 0);
|
||||
//saveToGallery = preferences.getBoolean("save_gallery", false);
|
||||
//autoplayGifs = preferences.getBoolean("autoplay_gif", true);
|
||||
raiseToSpeak = preferences.getBoolean("raise_to_speak", true);
|
||||
directShare = preferences.getBoolean("direct_share", true);
|
||||
@@ -2730,130 +2726,6 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
|
||||
});
|
||||
}
|
||||
|
||||
public static void saveFile(String fullPath, Context context, final int type, final String name, final String mime) {
|
||||
if (fullPath == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
File file = null;
|
||||
if (fullPath != null && fullPath.length() != 0) {
|
||||
file = new File(fullPath);
|
||||
if (!file.exists()) {
|
||||
file = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (file == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final File sourceFile = file;
|
||||
if (sourceFile.exists()) {
|
||||
ProgressDialog progressDialog = null;
|
||||
if (context != null) {
|
||||
try {
|
||||
progressDialog = new ProgressDialog(context);
|
||||
progressDialog.setMessage(LocaleController.getString("Loading", R.string.Loading));
|
||||
progressDialog.setCanceledOnTouchOutside(false);
|
||||
progressDialog.setCancelable(false);
|
||||
progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
|
||||
progressDialog.setMax(100);
|
||||
progressDialog.show();
|
||||
} catch (Exception e) {
|
||||
FileLog.e("messenger", e);
|
||||
}
|
||||
}
|
||||
|
||||
final ProgressDialog finalProgress = progressDialog;
|
||||
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
File destFile = null;
|
||||
if (type == 0) {
|
||||
destFile = AndroidUtilities.generatePicturePath();
|
||||
} else if (type == 1) {
|
||||
destFile = AndroidUtilities.generateVideoPath();
|
||||
} else if (type == 2) {
|
||||
File f = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
|
||||
f.mkdir();
|
||||
destFile = new File(f, name);
|
||||
} else if (type == 3) {
|
||||
File f = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MUSIC);
|
||||
f.mkdirs();
|
||||
destFile = new File(f, name);
|
||||
}
|
||||
|
||||
if (!destFile.exists()) {
|
||||
destFile.createNewFile();
|
||||
}
|
||||
FileChannel source = null;
|
||||
FileChannel destination = null;
|
||||
boolean result = true;
|
||||
long lastProgress = System.currentTimeMillis() - 500;
|
||||
try {
|
||||
source = new FileInputStream(sourceFile).getChannel();
|
||||
destination = new FileOutputStream(destFile).getChannel();
|
||||
long size = source.size();
|
||||
for (long a = 0; a < size; a += 4096) {
|
||||
destination.transferFrom(source, a, Math.min(4096, size - a));
|
||||
if (finalProgress != null) {
|
||||
if (lastProgress <= System.currentTimeMillis() - 500) {
|
||||
lastProgress = System.currentTimeMillis();
|
||||
final int progress = (int) ((float) a / (float) size * 100);
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
finalProgress.setProgress(progress);
|
||||
} catch (Exception e) {
|
||||
FileLog.e("messenger", e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e("messenger", e);
|
||||
result = false;
|
||||
} finally {
|
||||
if (source != null) {
|
||||
source.close();
|
||||
}
|
||||
if (destination != null) {
|
||||
destination.close();
|
||||
}
|
||||
}
|
||||
|
||||
if (result) {
|
||||
if (type == 2) {
|
||||
DownloadManager downloadManager = (DownloadManager) ApplicationLoader.applicationContext.getSystemService(Context.DOWNLOAD_SERVICE);
|
||||
downloadManager.addCompletedDownload(destFile.getName(), destFile.getName(), false, mime, destFile.getAbsolutePath(), destFile.length(), true);
|
||||
} else {
|
||||
AndroidUtilities.addMediaToGallery(Uri.fromFile(destFile));
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e("messenger", e);
|
||||
}
|
||||
if (finalProgress != null) {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
finalProgress.dismiss();
|
||||
} catch (Exception e) {
|
||||
FileLog.e("messenger", e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isWebp(Uri uri) {
|
||||
InputStream inputStream = null;
|
||||
@@ -2977,15 +2849,6 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
|
||||
}
|
||||
|
||||
/*
|
||||
public void toggleSaveToGallery() {
|
||||
saveToGallery = !saveToGallery;
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putBoolean("save_gallery", saveToGallery);
|
||||
editor.apply();
|
||||
checkSaveToGalleryFiles();
|
||||
}
|
||||
|
||||
public void toggleAutoplayGifs() {
|
||||
autoplayGifs = !autoplayGifs;
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
|
||||
@@ -3011,40 +2874,6 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public void checkSaveToGalleryFiles() { // not sure, but it seems as if these paths are not needed
|
||||
try {
|
||||
File messengerPath = new File(Environment.getExternalStorageDirectory(), "Delta Chat");
|
||||
File imagePath = new File(messengerPath, "Delta Chat Images");
|
||||
imagePath.mkdir();
|
||||
File videoPath = new File(messengerPath, "Delta Chat Video");
|
||||
videoPath.mkdir();
|
||||
|
||||
if (saveToGallery) {
|
||||
if (imagePath.isDirectory()) {
|
||||
new File(imagePath, ".nomedia").delete();
|
||||
}
|
||||
if (videoPath.isDirectory()) {
|
||||
new File(videoPath, ".nomedia").delete();
|
||||
}
|
||||
} else {
|
||||
if (imagePath.isDirectory()) {
|
||||
new File(imagePath, ".nomedia").createNewFile();
|
||||
}
|
||||
if (videoPath.isDirectory()) {
|
||||
new File(videoPath, ".nomedia").createNewFile();
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e("messenger", e);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
public boolean canSaveToGallery() {
|
||||
return saveToGallery;
|
||||
}
|
||||
*/
|
||||
|
||||
public boolean canAutoplayGifs() {
|
||||
return autoplayGifs;
|
||||
}
|
||||
|
||||
@@ -215,110 +215,6 @@ public class CacheControlActivity extends BaseFragment {
|
||||
return size;
|
||||
}
|
||||
|
||||
/*
|
||||
private void cleanupFolders() {
|
||||
final ProgressDialog progressDialog = new ProgressDialog(getParentActivity());
|
||||
progressDialog.setMessage(LocaleController.getString("Loading", R.string.Loading));
|
||||
progressDialog.setCanceledOnTouchOutside(false);
|
||||
progressDialog.setCancelable(false);
|
||||
progressDialog.show();
|
||||
Utilities.globalQueue.postRunnable(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
boolean imagesCleared = false;
|
||||
for (int a = 0; a < 6; a++) {
|
||||
if (!clear[a]) {
|
||||
continue;
|
||||
}
|
||||
int type = -1;
|
||||
int documentsMusicType = 0;
|
||||
if (a == 0) {
|
||||
type = FileLoader.MEDIA_DIR_IMAGE;
|
||||
} else if (a == 1) {
|
||||
type = FileLoader.MEDIA_DIR_VIDEO;
|
||||
} else if (a == 2) {
|
||||
type = FileLoader.MEDIA_DIR_DOCUMENT;
|
||||
documentsMusicType = 1;
|
||||
} else if (a == 3) {
|
||||
type = FileLoader.MEDIA_DIR_DOCUMENT;
|
||||
documentsMusicType = 2;
|
||||
} else if (a == 4) {
|
||||
type = FileLoader.MEDIA_DIR_AUDIO;
|
||||
} else if (a == 5) {
|
||||
type = FileLoader.MEDIA_DIR_CACHE;
|
||||
}
|
||||
if (type == -1) {
|
||||
continue;
|
||||
}
|
||||
File file = FileLoader.getInstance().checkDirectory(type);
|
||||
if (file != null) {
|
||||
try {
|
||||
File[] array = file.listFiles();
|
||||
if (array != null) {
|
||||
for (int b = 0; b < array.length; b++) {
|
||||
String name = array[b].getName().toLowerCase();
|
||||
if (documentsMusicType == 1 || documentsMusicType == 2) {
|
||||
if (name.endsWith(".mp3") || name.endsWith(".m4a")) {
|
||||
if (documentsMusicType == 1) {
|
||||
continue;
|
||||
}
|
||||
} else if (documentsMusicType == 2) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (name.equals(".nomedia")) {
|
||||
continue;
|
||||
}
|
||||
if (array[b].isFile()) {
|
||||
array[b].delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
FileLog.e("messenger", e);
|
||||
}
|
||||
}
|
||||
if (type == FileLoader.MEDIA_DIR_CACHE) {
|
||||
cacheSize = getDirectorySize(FileLoader.getInstance().checkDirectory(FileLoader.MEDIA_DIR_CACHE), documentsMusicType);
|
||||
imagesCleared = true;
|
||||
} else if (type == FileLoader.MEDIA_DIR_AUDIO) {
|
||||
audioSize = getDirectorySize(FileLoader.getInstance().checkDirectory(FileLoader.MEDIA_DIR_AUDIO), documentsMusicType);
|
||||
} else if (type == FileLoader.MEDIA_DIR_DOCUMENT) {
|
||||
if (documentsMusicType == 1) {
|
||||
documentsSize = getDirectorySize(FileLoader.getInstance().checkDirectory(FileLoader.MEDIA_DIR_DOCUMENT), documentsMusicType);
|
||||
} else {
|
||||
musicSize = getDirectorySize(FileLoader.getInstance().checkDirectory(FileLoader.MEDIA_DIR_DOCUMENT), documentsMusicType);
|
||||
}
|
||||
} else if (type == FileLoader.MEDIA_DIR_IMAGE) {
|
||||
imagesCleared = true;
|
||||
photoSize = getDirectorySize(FileLoader.getInstance().checkDirectory(FileLoader.MEDIA_DIR_IMAGE), documentsMusicType);
|
||||
} else if (type == FileLoader.MEDIA_DIR_VIDEO) {
|
||||
videoSize = getDirectorySize(FileLoader.getInstance().checkDirectory(FileLoader.MEDIA_DIR_VIDEO), documentsMusicType);
|
||||
}
|
||||
}
|
||||
final boolean imagesClearedFinal = imagesCleared;
|
||||
totalSize = cacheSize + videoSize + audioSize + photoSize + documentsSize + musicSize;
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (imagesClearedFinal) {
|
||||
ImageLoader.getInstance().clearMemory();
|
||||
}
|
||||
if (listAdapter != null) {
|
||||
listAdapter.notifyDataSetChanged();
|
||||
}
|
||||
try {
|
||||
progressDialog.dismiss();
|
||||
} catch (Exception e) {
|
||||
FileLog.e("messenger", e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
*/
|
||||
|
||||
@Override
|
||||
public View createView(final Context context) {
|
||||
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
|
||||
|
||||
@@ -498,7 +498,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||
}
|
||||
else if( id== ID_SAVE_TO_XX )
|
||||
{
|
||||
Toast.makeText(getParentActivity(), ApplicationLoader.applicationContext.getString(R.string.NotYetImplemented), Toast.LENGTH_SHORT).show();
|
||||
AndroidUtilities.saveMessageFileToExt(getParentActivity(), getFirstSelectedId());
|
||||
actionBar.hideActionMode();
|
||||
updateVisibleRows();
|
||||
}
|
||||
else if( id== ID_SHARE )
|
||||
{
|
||||
@@ -2817,7 +2819,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||
if ( getParentActivity()!=null ) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||
builder.setPositiveButton(ApplicationLoader.applicationContext.getString(R.string.OK), null);
|
||||
builder.setMessage(LocaleController.formatString("NoHandleAppInstalled", R.string.NoHandleAppInstalled, AndroidUtilities.getMimetypeForView(message)));
|
||||
builder.setMessage(LocaleController.formatString("NoHandleAppInstalled", R.string.NoHandleAppInstalled, AndroidUtilities.getMimetype(message)));
|
||||
showDialog(builder.create());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -966,11 +966,6 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(f));
|
||||
|
||||
parentActivity.startActivityForResult(Intent.createChooser(intent, LocaleController.getString("ShareFile", R.string.ShareFile)), 500);
|
||||
} else {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
|
||||
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
|
||||
builder.setMessage(LocaleController.getString("PleaseDownload", R.string.PleaseDownload));
|
||||
showAlertDialog(builder);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e("messenger", e);
|
||||
@@ -1064,25 +1059,8 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
}*/
|
||||
closePhoto(true, false);
|
||||
} else if (id == gallery_menu_save) {
|
||||
if (Build.VERSION.SDK_INT >= 23 && parentActivity.checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
||||
parentActivity.requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 4);
|
||||
return;
|
||||
}
|
||||
|
||||
File f = null;
|
||||
if (currentMessageObject != null) {
|
||||
f = FileLoader.getPathToMessage(currentMessageObject.messageOwner);
|
||||
} else if (currentFileLocation != null) {
|
||||
f = FileLoader.getPathToAttach(currentFileLocation, avatarsDialogId != 0);
|
||||
}
|
||||
|
||||
if (f != null && f.exists()) {
|
||||
MediaController.saveFile(f.toString(), parentActivity, currentMessageObject != null && currentMessageObject.isVideo() ? 1 : 0, null, null);
|
||||
} else {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
|
||||
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
|
||||
builder.setMessage(LocaleController.getString("PleaseDownload", R.string.PleaseDownload));
|
||||
showAlertDialog(builder);
|
||||
AndroidUtilities.saveMessageFileToExt(parentActivity, currentMessageObject.getId());
|
||||
}
|
||||
}
|
||||
/*else if (id == gallery_menu_showall) {
|
||||
@@ -1286,8 +1264,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
str = str.substring(0,1).toUpperCase() + str.substring(1).toLowerCase();
|
||||
}
|
||||
menuItem.addSubItem(gallery_menu_openin, str, 0);
|
||||
menuItem.addSubItem(gallery_menu_save, LocaleController.getString("SaveToGallery", R.string.SaveToGallery), 0);
|
||||
//menuItem.addSubItem(gallery_menu_showall, LocaleController.getString("ShowAllMedia", R.string.ShowAllMedia), 0);
|
||||
menuItem.addSubItem(gallery_menu_save, ApplicationLoader.applicationContext.getString(R.string.SaveToGallery), 0);
|
||||
|
||||
// the following 3 options are disabled for the moment, we'll add them if we have the time (bp)
|
||||
// (as a replacement, you can use "save to gallery" for sharing or the options from the chat for forwarding/delete)
|
||||
|
||||
@@ -120,7 +120,6 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
||||
notificationRow = rowCount++;
|
||||
backgroundRow = rowCount++;
|
||||
languageRow = rowCount++;
|
||||
// saveToGalleryRow: for now, we do not use this option, this results in confusing folders ("AppName" and "AppName Images" etc.); instead, for now, the user can use the option to manually save a media. Moreover, we also avoid the problem to double-save each image _or_ to handle the case a user deletes an image in the gallery.
|
||||
messagesSectionRow = rowCount++;
|
||||
messagesSectionRow2 = rowCount++;
|
||||
textSizeRow = rowCount++; // incoming messages
|
||||
|
||||
@@ -91,6 +91,9 @@ public class WallpapersActivity extends BaseFragment implements NotificationCent
|
||||
|
||||
private final static int done_button = 1;
|
||||
|
||||
private final static int RC10_TAKE_WALLPAPER_PICTURE = 10;
|
||||
private final static int RC11_SELECT_WALLPAPER_FROM_GALLERY = 11;
|
||||
|
||||
@Override
|
||||
public boolean onFragmentCreate() {
|
||||
super.onFragmentCreate();
|
||||
@@ -230,11 +233,11 @@ public class WallpapersActivity extends BaseFragment implements NotificationCent
|
||||
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(image));
|
||||
currentPicturePath = image.getAbsolutePath();
|
||||
}
|
||||
startActivityForResult(takePictureIntent, 10);
|
||||
startActivityForResult(takePictureIntent, RC10_TAKE_WALLPAPER_PICTURE);
|
||||
} else if (i == 1) {
|
||||
Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
|
||||
photoPickerIntent.setType("image/*");
|
||||
startActivityForResult(photoPickerIntent, 11);
|
||||
startActivityForResult(photoPickerIntent, RC11_SELECT_WALLPAPER_FROM_GALLERY);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e("messenger", e);
|
||||
@@ -262,7 +265,7 @@ public class WallpapersActivity extends BaseFragment implements NotificationCent
|
||||
@Override
|
||||
public void onActivityResultFragment(int requestCode, int resultCode, Intent data) {
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
if (requestCode == 10) {
|
||||
if (requestCode == RC10_TAKE_WALLPAPER_PICTURE) {
|
||||
AndroidUtilities.addMediaToGallery(currentPicturePath);
|
||||
FileOutputStream stream = null;
|
||||
try {
|
||||
@@ -287,7 +290,7 @@ public class WallpapersActivity extends BaseFragment implements NotificationCent
|
||||
}
|
||||
}
|
||||
currentPicturePath = null;
|
||||
} else if (requestCode == 11) {
|
||||
} else if (requestCode == RC11_SELECT_WALLPAPER_FROM_GALLERY) {
|
||||
if (data == null || data.getData() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -184,7 +184,6 @@
|
||||
<string name="FingerprintInfo">Fingerabdruck bestätigen.</string>
|
||||
<string name="FingerprintNotRecognized">Abdruck nicht erkannt; erneut versuchen </string>
|
||||
<!--photo gallery view-->
|
||||
<string name="ShowAllMedia">Zeige alle Medien</string>
|
||||
<string name="SaveToGallery">In der Galerie speichern</string>
|
||||
<string name="Of">%1$d von %2$d</string>
|
||||
<string name="Gallery">Galerie</string>
|
||||
@@ -192,7 +191,6 @@
|
||||
<string name="AllVideo">Alle Videos</string>
|
||||
<string name="NoPhotos">Noch keine Bilder</string>
|
||||
<string name="NoVideo">Noch keine Videos</string>
|
||||
<string name="PleaseDownload">Medien bitte zuerst herunterladen</string>
|
||||
<string name="NoRecentPhotos">Suchverlauf</string>
|
||||
<string name="NoRecentGIFs">Suchverlauf</string>
|
||||
<string name="SearchImages">BILDERSUCHE</string>
|
||||
@@ -274,7 +272,6 @@
|
||||
<string name="AttachVoiceMessage">Sprachnachricht</string>
|
||||
<string name="FromSelf">Ich</string>
|
||||
<!--Alert messages-->
|
||||
<string name="Loading">Lädt …</string>
|
||||
<string name="NoHandleAppInstalled">Um den Dateityp \"%1$s\" öffnen zu können, muss eine entsprechende App installiert werden.</string>
|
||||
<string name="ContactAlreadyInGroup">Kontakt befindet sich schon in der Gruppe.</string>
|
||||
<string name="ForwardMessagesTo">Ausgewählte Nachrichten an <![CDATA[<b>]]>%1$s<![CDATA[</b>]]> weiterleiten?</string>
|
||||
|
||||
@@ -181,7 +181,6 @@
|
||||
<string name="FingerprintInfo">Confirma la huella digital para continuar</string>
|
||||
<string name="FingerprintNotRecognized">Huella digital no reconocida. Reinténtalo</string>
|
||||
<!--photo gallery view-->
|
||||
<string name="ShowAllMedia">Ir a Multimedia</string>
|
||||
<string name="SaveToGallery">Guardar en galería</string>
|
||||
<string name="Of">%1$d de %2$d</string>
|
||||
<string name="Gallery">Galería</string>
|
||||
@@ -189,7 +188,6 @@
|
||||
<string name="AllVideo">Todos los vídeos</string>
|
||||
<string name="NoPhotos">Aún sin fotos</string>
|
||||
<string name="NoVideo">Sin vídeos aún</string>
|
||||
<string name="PleaseDownload">Por favor, primero descarga la multimedia</string>
|
||||
<string name="NoRecentPhotos">No hay fotos recientes</string>
|
||||
<string name="NoRecentGIFs">No hay GIF recientes</string>
|
||||
<string name="SearchImages">BUSCA FOTOS</string>
|
||||
@@ -271,7 +269,6 @@
|
||||
<string name="AttachVoiceMessage">Mensaje de voz</string>
|
||||
<string name="FromSelf">Tú</string>
|
||||
<!--Alert messages-->
|
||||
<string name="Loading">Cargando…</string>
|
||||
<string name="NoHandleAppInstalled">No tienes aplicaciones que puedan manejar el tipo de archivo “%1$s”. Por favor, instala una para continuar.</string>
|
||||
<string name="AskAddMemberToGroup">¿Añadir a <![CDATA[<b>]]>%1$s<![CDATA[</b>]]> al grupo?</string>
|
||||
<string name="ContactAlreadyInGroup">Este usuario ya está en el grupo</string>
|
||||
|
||||
@@ -179,7 +179,6 @@
|
||||
<string name="FingerprintInfo">Confirmer votre empreinte digitale pour continuer</string>
|
||||
<string name="FingerprintNotRecognized">Empreinte non reconnue. Essayer encore</string>
|
||||
<!--photo gallery view-->
|
||||
<string name="ShowAllMedia">Montrer tous les médias</string>
|
||||
<string name="SaveToGallery">Enregistrer dans la galerie</string>
|
||||
<string name="Of">%1$d de %2$d</string>
|
||||
<string name="Gallery">Gallerie</string>
|
||||
@@ -187,7 +186,6 @@
|
||||
<string name="AllVideo">Toutes les vidéos</string>
|
||||
<string name="NoPhotos">Aucune photo pour le moment</string>
|
||||
<string name="NoVideo">Aucune vidéo pour le moement</string>
|
||||
<string name="PleaseDownload">Veuiller télécharger le média</string>
|
||||
<string name="NoRecentPhotos">Aucune photo récente</string>
|
||||
<string name="NoRecentGIFs">Aucun GIF récent</string>
|
||||
<string name="SearchImages">TROUVER LES IMAGES</string>
|
||||
@@ -269,7 +267,6 @@
|
||||
<string name="AttachVoiceMessage">Message vocal</string>
|
||||
<string name="FromSelf">Moi</string>
|
||||
<!--Alert messages-->
|
||||
<string name="Loading">Chargement…</string>
|
||||
<string name="NoHandleAppInstalled">Vous n\'avez pas d\'application qui peut gérer le type \'%1$s\', veuillez en installer un pour continuer</string>
|
||||
<string name="ContactAlreadyInGroup">Ce contact est déjà dans ce groupe</string>
|
||||
<string name="ForwardMessagesTo">Renvoyer les messages sélectionnés à <![CDATA[<b>]]>%1$s<![CDATA[</b>]]> ?</string>
|
||||
|
||||
@@ -181,7 +181,6 @@
|
||||
<string name="FingerprintInfo">Conferma impronta digitale per continuare</string>
|
||||
<string name="FingerprintNotRecognized">Impronta digitale non riconosciuta. Riprova</string>
|
||||
<!--photo gallery view-->
|
||||
<string name="ShowAllMedia">Mostra tutti i file media</string>
|
||||
<string name="SaveToGallery">Salva nella galleria</string>
|
||||
<string name="Of">%1$d di %2$d</string>
|
||||
<string name="Gallery">Galleria</string>
|
||||
@@ -189,7 +188,6 @@
|
||||
<string name="AllVideo">Tutti i video</string>
|
||||
<string name="NoPhotos">Ancora nessuna foto</string>
|
||||
<string name="NoVideo">Ancora nessun video</string>
|
||||
<string name="PleaseDownload">Scarica prima il file</string>
|
||||
<string name="NoRecentPhotos">Nessuna foto recente</string>
|
||||
<string name="NoRecentGIFs">Nessuna GIF recente</string>
|
||||
<string name="SearchImages">CERCA IMMAGINI</string>
|
||||
@@ -271,7 +269,6 @@
|
||||
<string name="AttachVoiceMessage">Messaggio vocale</string>
|
||||
<string name="FromSelf">Tu</string>
|
||||
<!--Alert messages-->
|
||||
<string name="Loading">Caricamento…</string>
|
||||
<string name="NoHandleAppInstalled">Non hai applicazioni che possono gestire il tipo di file \'%1$s\': installane una per proseguire</string>
|
||||
<string name="AskAddMemberToGroup">Aggiungere <![CDATA[<b>]]>%1$s<![CDATA[</b>]]> al gruppo?</string>
|
||||
<string name="ContactAlreadyInGroup">Questo utente è già membro del gruppo</string>
|
||||
|
||||
@@ -181,7 +181,6 @@
|
||||
<string name="FingerprintInfo">Vingerafdruk bevestigen</string>
|
||||
<string name="FingerprintNotRecognized">Vingerafdruk niet herkend, probeer opnieuw</string>
|
||||
<!--photo gallery view-->
|
||||
<string name="ShowAllMedia">Alle media weergeven</string>
|
||||
<string name="SaveToGallery">Opslaan in galerij</string>
|
||||
<string name="Of">%1$d van %2$d</string>
|
||||
<string name="Gallery">Galerij</string>
|
||||
@@ -189,7 +188,6 @@
|
||||
<string name="AllVideo">Alle video\'s</string>
|
||||
<string name="NoPhotos">Nog geen foto\'s</string>
|
||||
<string name="NoVideo">Nog geen video\'s</string>
|
||||
<string name="PleaseDownload">Download media eerst</string>
|
||||
<string name="NoRecentPhotos">Niets recents</string>
|
||||
<string name="NoRecentGIFs">Niets recents</string>
|
||||
<string name="SearchImages">ONLINE ZOEKEN</string>
|
||||
@@ -271,7 +269,6 @@
|
||||
<string name="AttachVoiceMessage">Spraakbericht</string>
|
||||
<string name="FromSelf">Jij</string>
|
||||
<!--Alert messages-->
|
||||
<string name="Loading">Bezig met laden</string>
|
||||
<string name="NoHandleAppInstalled">Je hebt geen apps die bestandstype \'%1$s\' kunnen verwerken, gelieve een compatibele app te installeren</string>
|
||||
<string name="AskAddMemberToGroup"><![CDATA[<b>]]>%1$s<![CDATA[</b>]]> toevoegen aan de groep?</string>
|
||||
<string name="ContactAlreadyInGroup">Gebruiker is al een groepslid</string>
|
||||
|
||||
@@ -184,7 +184,6 @@
|
||||
<string name="FingerprintInfo">Potwierdź odcisk palca, aby kontynuować</string>
|
||||
<string name="FingerprintNotRecognized">Odcisk palca nie rozpoznany. Spróbuj ponownie</string>
|
||||
<!--photo gallery view-->
|
||||
<string name="ShowAllMedia">Pokaż wszystkie multimedia</string>
|
||||
<string name="SaveToGallery">Zapisz w galerii</string>
|
||||
<string name="Of">%1$d z %2$d</string>
|
||||
<string name="Gallery">Galeria</string>
|
||||
@@ -192,7 +191,6 @@
|
||||
<string name="AllVideo">Wszystkie wideo</string>
|
||||
<string name="NoPhotos">Nie ma zdjęć</string>
|
||||
<string name="NoVideo">Nie ma jeszcze wideo</string>
|
||||
<string name="PleaseDownload">Pobierz najpierw multimedia</string>
|
||||
<string name="NoRecentPhotos">Nie ma wcześniejszych zdjęć</string>
|
||||
<string name="NoRecentGIFs">Nie ma wcześniejszych GIFów</string>
|
||||
<string name="SearchImages">SZUKAJ OBRAZY</string>
|
||||
@@ -274,7 +272,6 @@
|
||||
<string name="AttachVoiceMessage">Wiadomość głosowa</string>
|
||||
<string name="FromSelf">Ja</string>
|
||||
<!--Alert messages-->
|
||||
<string name="Loading">Wczytywanie…</string>
|
||||
<string name="NoHandleAppInstalled">Nie masz aplikacji obsługujących pliki typu „%1$s”. Zainstaluj jakąś, aby kontynuować.</string>
|
||||
<string name="ContactAlreadyInGroup">Ten kontakt jest już w tej grupie</string>
|
||||
<string name="ForwardMessagesTo">Przekazać wybrane wiadomości do <![CDATA[<b>]]>%1$s<![CDATA[</b>]]>?</string>
|
||||
|
||||
@@ -181,7 +181,6 @@
|
||||
<string name="FingerprintInfo">Confirme a impressão digital para continuar</string>
|
||||
<string name="FingerprintNotRecognized">Impressão digital não reconhecida.</string>
|
||||
<!--photo gallery view-->
|
||||
<string name="ShowAllMedia">Mostrar todas as mídias</string>
|
||||
<string name="SaveToGallery">Salvar na galeria</string>
|
||||
<string name="Of">%1$d de %2$d</string>
|
||||
<string name="Gallery">Galeria</string>
|
||||
@@ -189,7 +188,6 @@
|
||||
<string name="AllVideo">Todos os Vídeos</string>
|
||||
<string name="NoPhotos">Ainda não há fotos</string>
|
||||
<string name="NoVideo">Nenhum vídeo ainda</string>
|
||||
<string name="PleaseDownload">Baixar o vídeo primeiro</string>
|
||||
<string name="NoRecentPhotos">Nenhuma foto recente</string>
|
||||
<string name="NoRecentGIFs">Nenhum GIF recente</string>
|
||||
<string name="SearchImages">BUSCAR IMAGENS</string>
|
||||
@@ -271,7 +269,6 @@
|
||||
<string name="AttachVoiceMessage">Mensagem de voz</string>
|
||||
<string name="FromSelf">Você</string>
|
||||
<!--Alert messages-->
|
||||
<string name="Loading">Carregando…</string>
|
||||
<string name="NoHandleAppInstalled">Você não possui um aplicativo que suporte o tipo de arquivo \'%1$s\', por favor instale um para continuar</string>
|
||||
<string name="AskAddMemberToGroup">Adicionar <![CDATA[<b>]]>%1$s<![CDATA[</b>]]> no grupo?</string>
|
||||
<string name="ContactAlreadyInGroup">Este usuário já está neste grupo</string>
|
||||
|
||||
@@ -184,7 +184,6 @@
|
||||
<string name="FingerprintInfo">Confirm fingerprint to continue</string>
|
||||
<string name="FingerprintNotRecognized">Fingerprint not recognized. Try again</string>
|
||||
<!--photo gallery view-->
|
||||
<string name="ShowAllMedia">Show all media</string>
|
||||
<string name="SaveToGallery">Save to gallery</string>
|
||||
<string name="Of">%1$d of %2$d</string>
|
||||
<string name="Gallery">Gallery</string>
|
||||
@@ -192,7 +191,6 @@
|
||||
<string name="AllVideo">All Videos</string>
|
||||
<string name="NoPhotos">No photos yet</string>
|
||||
<string name="NoVideo">No videos yet</string>
|
||||
<string name="PleaseDownload">Please download media first</string>
|
||||
<string name="NoRecentPhotos">No recent photos</string>
|
||||
<string name="NoRecentGIFs">No recent GIFs</string>
|
||||
<string name="SearchImages">FIND IMAGES</string>
|
||||
@@ -274,7 +272,6 @@
|
||||
<string name="AttachVoiceMessage">Voice message</string>
|
||||
<string name="FromSelf">Me</string>
|
||||
<!--Alert messages-->
|
||||
<string name="Loading">Loading …</string>
|
||||
<string name="NoHandleAppInstalled">You don\'t have applications that can handle the file type \'%1$s\', please install one to continue</string>
|
||||
<string name="ContactAlreadyInGroup">This contact is already in this group.</string>
|
||||
<string name="ForwardMessagesTo">Forward selected messages to <![CDATA[<b>]]>%1$s<![CDATA[</b>]]>?</string>
|
||||
|
||||
Reference in New Issue
Block a user