Avoid sending file twice (photos, documents, videos), move notifications settings from profiles to other view
This commit is contained in:
parent
f6eac5cbce
commit
70882c5d28
@ -81,7 +81,7 @@ android {
|
||||
defaultConfig {
|
||||
minSdkVersion 8
|
||||
targetSdkVersion 19
|
||||
versionCode 261
|
||||
versionName "1.5.6"
|
||||
versionCode 262
|
||||
versionName "1.5.7"
|
||||
}
|
||||
}
|
||||
|
@ -211,10 +211,10 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
if (paused) {
|
||||
lastPauseTime = System.currentTimeMillis();
|
||||
nextSleepTimeout = 30000;
|
||||
FileLog.e("tmessages", "wakeup network in background by received push");
|
||||
FileLog.e("tmessages", "wakeup network in background");
|
||||
} else if (lastPauseTime != 0) {
|
||||
lastPauseTime = System.currentTimeMillis();
|
||||
FileLog.e("tmessages", "reset sleep timeout by received push");
|
||||
FileLog.e("tmessages", "reset sleep timeout");
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -641,9 +641,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
if (exist.downloadConnection != null) {
|
||||
exist.downloadConnection.suspendConnection(true);
|
||||
}
|
||||
if (dc == 1) {
|
||||
updateDcSettings(1);
|
||||
}
|
||||
updateDcSettings(dc);
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -1062,13 +1060,17 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
for (int i = 0; i < runningRequests.size(); i++) {
|
||||
RPCRequest request = runningRequests.get(i);
|
||||
|
||||
if (updatingDcSettings && datacenters.size() > 1 && request.rawRequest instanceof TLRPC.TL_help_getConfig) {
|
||||
if (updatingDcStartTime < currentTime - 60) {
|
||||
FileLog.e("tmessages", "move TL_help_getConfig to requestQueue");
|
||||
requestQueue.add(request);
|
||||
runningRequests.remove(i);
|
||||
i--;
|
||||
continue;
|
||||
if (datacenters.size() > 1) {
|
||||
if (updatingDcSettings && request.rawRequest instanceof TLRPC.TL_help_getConfig) {
|
||||
if (updatingDcStartTime < currentTime - 60) {
|
||||
FileLog.e("tmessages", "move TL_help_getConfig to requestQueue");
|
||||
requestQueue.add(request);
|
||||
runningRequests.remove(i);
|
||||
i--;
|
||||
continue;
|
||||
}
|
||||
} else if (request.rawRequest instanceof TLRPC.TL_auth_sendCode || request.rawRequest instanceof TLRPC.TL_auth_signIn || request.rawRequest instanceof TLRPC.TL_auth_signUp) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,6 @@ import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.os.Build;
|
||||
import android.provider.MediaStore;
|
||||
import android.util.Log;
|
||||
|
||||
import org.telegram.ui.ApplicationLoader;
|
||||
|
||||
@ -79,12 +78,7 @@ public class FileLoadOperation {
|
||||
}
|
||||
|
||||
public FileLoadOperation(TLRPC.Video videoLocation) {
|
||||
if (videoLocation instanceof TLRPC.TL_video) {
|
||||
location = new TLRPC.TL_inputVideoFileLocation();
|
||||
datacenter_id = videoLocation.dc_id;
|
||||
location.id = videoLocation.id;
|
||||
location.access_hash = videoLocation.access_hash;
|
||||
} else if (videoLocation instanceof TLRPC.TL_videoEncrypted) {
|
||||
if (videoLocation instanceof TLRPC.TL_videoEncrypted) {
|
||||
location = new TLRPC.TL_inputEncryptedFileLocation();
|
||||
location.id = videoLocation.id;
|
||||
location.access_hash = videoLocation.access_hash;
|
||||
@ -92,6 +86,11 @@ public class FileLoadOperation {
|
||||
iv = new byte[32];
|
||||
System.arraycopy(videoLocation.iv, 0, iv, 0, iv.length);
|
||||
key = videoLocation.key;
|
||||
} else if (videoLocation instanceof TLRPC.TL_video) {
|
||||
location = new TLRPC.TL_inputVideoFileLocation();
|
||||
datacenter_id = videoLocation.dc_id;
|
||||
location.id = videoLocation.id;
|
||||
location.access_hash = videoLocation.access_hash;
|
||||
}
|
||||
ext = ".mp4";
|
||||
}
|
||||
@ -115,12 +114,7 @@ public class FileLoadOperation {
|
||||
}
|
||||
|
||||
public FileLoadOperation(TLRPC.Document documentLocation) {
|
||||
if (documentLocation instanceof TLRPC.TL_document) {
|
||||
location = new TLRPC.TL_inputDocumentFileLocation();
|
||||
datacenter_id = documentLocation.dc_id;
|
||||
location.id = documentLocation.id;
|
||||
location.access_hash = documentLocation.access_hash;
|
||||
} else if (documentLocation instanceof TLRPC.TL_documentEncrypted) {
|
||||
if (documentLocation instanceof TLRPC.TL_documentEncrypted) {
|
||||
location = new TLRPC.TL_inputEncryptedFileLocation();
|
||||
location.id = documentLocation.id;
|
||||
location.access_hash = documentLocation.access_hash;
|
||||
@ -128,6 +122,11 @@ public class FileLoadOperation {
|
||||
iv = new byte[32];
|
||||
System.arraycopy(documentLocation.iv, 0, iv, 0, iv.length);
|
||||
key = documentLocation.key;
|
||||
} else if (documentLocation instanceof TLRPC.TL_document) {
|
||||
location = new TLRPC.TL_inputDocumentFileLocation();
|
||||
datacenter_id = documentLocation.dc_id;
|
||||
location.id = documentLocation.id;
|
||||
location.access_hash = documentLocation.access_hash;
|
||||
}
|
||||
ext = documentLocation.file_name;
|
||||
int idx = -1;
|
||||
@ -675,6 +674,9 @@ public class FileLoadOperation {
|
||||
delegate.didFailedLoadingFile(FileLoadOperation.this);
|
||||
}
|
||||
} else {
|
||||
if (location != null) {
|
||||
FileLog.e("tmessages", "" + location + " id = " + location.id + " access_hash = " + location.access_hash + " volume_id = " + location.local_id + " secret = " + location.secret);
|
||||
}
|
||||
cleanup();
|
||||
delegate.didFailedLoadingFile(FileLoadOperation.this);
|
||||
}
|
||||
|
@ -127,6 +127,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
public TLRPC.TL_messages_sendMedia sendRequest;
|
||||
public TLRPC.TL_decryptedMessage sendEncryptedRequest;
|
||||
public int type;
|
||||
public String originalPath;
|
||||
public TLRPC.FileLocation location;
|
||||
public TLRPC.TL_video videoLocation;
|
||||
public TLRPC.TL_audio audioLocation;
|
||||
@ -1600,7 +1601,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
Utilities.random.nextBytes(reqSend.random_bytes);
|
||||
reqSend.action = new TLRPC.TL_decryptedMessageActionDeleteMessages();
|
||||
reqSend.action.random_ids = random_ids;
|
||||
performSendEncryptedRequest(reqSend, null, encryptedChat, null);
|
||||
performSendEncryptedRequest(reqSend, null, encryptedChat, null, null);
|
||||
|
||||
}
|
||||
|
||||
@ -1613,7 +1614,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
reqSend.random_bytes = new byte[Math.max(1, (int)Math.ceil(Utilities.random.nextDouble() * 16))];
|
||||
Utilities.random.nextBytes(reqSend.random_bytes);
|
||||
reqSend.action = new TLRPC.TL_decryptedMessageActionFlushHistory();
|
||||
performSendEncryptedRequest(reqSend, null, encryptedChat, null);
|
||||
performSendEncryptedRequest(reqSend, null, encryptedChat, null, null);
|
||||
}
|
||||
|
||||
public void sendTTLMessage(TLRPC.EncryptedChat encryptedChat) {
|
||||
@ -1657,7 +1658,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
Utilities.random.nextBytes(reqSend.random_bytes);
|
||||
reqSend.action = new TLRPC.TL_decryptedMessageActionSetMessageTTL();
|
||||
reqSend.action.ttl_seconds = encryptedChat.ttl;
|
||||
performSendEncryptedRequest(reqSend, newMsgObj, encryptedChat, null);
|
||||
performSendEncryptedRequest(reqSend, newMsgObj, encryptedChat, null, null);
|
||||
}
|
||||
|
||||
public void sendScreenshotMessage(TLRPC.EncryptedChat encryptedChat, ArrayList<Long> random_ids) {
|
||||
@ -1705,7 +1706,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
reqSend.random_bytes = new byte[Math.max(1, (int)Math.ceil(Utilities.random.nextDouble() * 16))];
|
||||
Utilities.random.nextBytes(reqSend.random_bytes);
|
||||
reqSend.action = action;
|
||||
performSendEncryptedRequest(reqSend, newMsgObj, encryptedChat, null);
|
||||
performSendEncryptedRequest(reqSend, newMsgObj, encryptedChat, null, null);
|
||||
}
|
||||
|
||||
private void sendMessage(String message, double lat, double lon, TLRPC.TL_photo photo, TLRPC.TL_video video, MessageObject msgObj, TLRPC.FileLocation location, TLRPC.User user, TLRPC.TL_document document, TLRPC.TL_audio audio, String originalPath, long peer) {
|
||||
@ -1749,14 +1750,6 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
newMsg.fwd_msg_id = msgObj.messageOwner.id;
|
||||
newMsg.attachPath = msgObj.messageOwner.attachPath;
|
||||
type = 4;
|
||||
} else if (msgObj.type == 11) {
|
||||
newMsg.fwd_from_id = msgObj.messageOwner.from_id;
|
||||
newMsg.fwd_date = msgObj.messageOwner.date;
|
||||
newMsg.media = new TLRPC.TL_messageMediaPhoto();
|
||||
newMsg.media.photo = msgObj.messageOwner.action.photo;
|
||||
newMsg.message = "";
|
||||
newMsg.fwd_msg_id = msgObj.messageOwner.id;
|
||||
type = 5;
|
||||
} else {
|
||||
newMsg.fwd_from_id = msgObj.messageOwner.from_id;
|
||||
newMsg.fwd_date = msgObj.messageOwner.date;
|
||||
@ -1858,7 +1851,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
reqSend.message = message;
|
||||
reqSend.peer = sendToPeer;
|
||||
reqSend.random_id = newMsg.random_id;
|
||||
performSendMessageRequest(reqSend, newMsgObj);
|
||||
performSendMessageRequest(reqSend, newMsgObj, null);
|
||||
} else {
|
||||
TLRPC.TL_decryptedMessage reqSend = new TLRPC.TL_decryptedMessage();
|
||||
reqSend.random_id = newMsg.random_id;
|
||||
@ -1866,7 +1859,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
Utilities.random.nextBytes(reqSend.random_bytes);
|
||||
reqSend.message = message;
|
||||
reqSend.media = new TLRPC.TL_decryptedMessageMediaEmpty();
|
||||
performSendEncryptedRequest(reqSend, newMsgObj, encryptedChat, null);
|
||||
performSendEncryptedRequest(reqSend, newMsgObj, encryptedChat, null, null);
|
||||
}
|
||||
} else if (type >= 1 && type <= 3 || type >= 5 && type <= 8) {
|
||||
if (encryptedChat == null) {
|
||||
@ -1878,55 +1871,78 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
reqSend.media.geo_point = new TLRPC.TL_inputGeoPoint();
|
||||
reqSend.media.geo_point.lat = lat;
|
||||
reqSend.media.geo_point._long = lon;
|
||||
performSendMessageRequest(reqSend, newMsgObj);
|
||||
performSendMessageRequest(reqSend, newMsgObj, null);
|
||||
} else if (type == 2) {
|
||||
reqSend.media = new TLRPC.TL_inputMediaUploadedPhoto();
|
||||
DelayedMessage delayedMessage = new DelayedMessage();
|
||||
delayedMessage.sendRequest = reqSend;
|
||||
delayedMessage.type = 0;
|
||||
delayedMessage.obj = newMsgObj;
|
||||
delayedMessage.location = photo.sizes.get(photo.sizes.size() - 1).location;
|
||||
performSendDelayedMessage(delayedMessage);
|
||||
if (photo.access_hash == 0) {
|
||||
reqSend.media = new TLRPC.TL_inputMediaUploadedPhoto();
|
||||
DelayedMessage delayedMessage = new DelayedMessage();
|
||||
delayedMessage.originalPath = originalPath;
|
||||
delayedMessage.sendRequest = reqSend;
|
||||
delayedMessage.type = 0;
|
||||
delayedMessage.obj = newMsgObj;
|
||||
delayedMessage.location = photo.sizes.get(photo.sizes.size() - 1).location;
|
||||
performSendDelayedMessage(delayedMessage);
|
||||
} else {
|
||||
TLRPC.TL_inputMediaPhoto media = new TLRPC.TL_inputMediaPhoto();
|
||||
media.id = new TLRPC.TL_inputPhoto();
|
||||
media.id.id = photo.id;
|
||||
media.id.access_hash = photo.access_hash;
|
||||
reqSend.media = media;
|
||||
performSendMessageRequest(reqSend, newMsgObj, null);
|
||||
}
|
||||
} else if (type == 3) {
|
||||
reqSend.media = new TLRPC.TL_inputMediaUploadedThumbVideo();
|
||||
reqSend.media.duration = video.duration;
|
||||
reqSend.media.w = video.w;
|
||||
reqSend.media.h = video.h;
|
||||
DelayedMessage delayedMessage = new DelayedMessage();
|
||||
delayedMessage.sendRequest = reqSend;
|
||||
delayedMessage.type = 1;
|
||||
delayedMessage.obj = newMsgObj;
|
||||
delayedMessage.location = video.thumb.location;
|
||||
delayedMessage.videoLocation = video;
|
||||
performSendDelayedMessage(delayedMessage);
|
||||
} else if (type == 5) {
|
||||
reqSend.media = new TLRPC.TL_inputMediaPhoto();
|
||||
TLRPC.TL_inputPhoto ph = new TLRPC.TL_inputPhoto();
|
||||
ph.id = msgObj.messageOwner.action.photo.id;
|
||||
ph.access_hash = msgObj.messageOwner.action.photo.access_hash;
|
||||
((TLRPC.TL_inputMediaPhoto)reqSend.media).id = ph;
|
||||
performSendMessageRequest(reqSend, newMsgObj);
|
||||
if (video.access_hash == 0) {
|
||||
reqSend.media = new TLRPC.TL_inputMediaUploadedThumbVideo();
|
||||
reqSend.media.duration = video.duration;
|
||||
reqSend.media.w = video.w;
|
||||
reqSend.media.h = video.h;
|
||||
DelayedMessage delayedMessage = new DelayedMessage();
|
||||
delayedMessage.originalPath = originalPath;
|
||||
delayedMessage.sendRequest = reqSend;
|
||||
delayedMessage.type = 1;
|
||||
delayedMessage.obj = newMsgObj;
|
||||
delayedMessage.location = video.thumb.location;
|
||||
delayedMessage.videoLocation = video;
|
||||
performSendDelayedMessage(delayedMessage);
|
||||
} else {
|
||||
TLRPC.TL_inputMediaVideo media = new TLRPC.TL_inputMediaVideo();
|
||||
media.id = new TLRPC.TL_inputVideo();
|
||||
media.id.id = video.id;
|
||||
media.id.access_hash = video.access_hash;
|
||||
reqSend.media = media;
|
||||
performSendMessageRequest(reqSend, newMsgObj, null);
|
||||
}
|
||||
} else if (type == 6) {
|
||||
reqSend.media = new TLRPC.TL_inputMediaContact();
|
||||
reqSend.media.phone_number = user.phone;
|
||||
reqSend.media.first_name = user.first_name;
|
||||
reqSend.media.last_name = user.last_name;
|
||||
performSendMessageRequest(reqSend, newMsgObj);
|
||||
performSendMessageRequest(reqSend, newMsgObj, null);
|
||||
} else if (type == 7) {
|
||||
if (document.thumb.location != null && document.thumb.location instanceof TLRPC.TL_fileLocation) {
|
||||
reqSend.media = new TLRPC.TL_inputMediaUploadedThumbDocument();
|
||||
if (document.access_hash == 0) {
|
||||
if (document.thumb.location != null && document.thumb.location instanceof TLRPC.TL_fileLocation) {
|
||||
reqSend.media = new TLRPC.TL_inputMediaUploadedThumbDocument();
|
||||
} else {
|
||||
reqSend.media = new TLRPC.TL_inputMediaUploadedDocument();
|
||||
}
|
||||
reqSend.media.mime_type = document.mime_type;
|
||||
reqSend.media.file_name = document.file_name;
|
||||
DelayedMessage delayedMessage = new DelayedMessage();
|
||||
delayedMessage.originalPath = originalPath;
|
||||
delayedMessage.sendRequest = reqSend;
|
||||
delayedMessage.type = 2;
|
||||
delayedMessage.obj = newMsgObj;
|
||||
delayedMessage.documentLocation = document;
|
||||
delayedMessage.location = document.thumb.location;
|
||||
performSendDelayedMessage(delayedMessage);
|
||||
} else {
|
||||
reqSend.media = new TLRPC.TL_inputMediaUploadedDocument();
|
||||
TLRPC.TL_inputMediaDocument media = new TLRPC.TL_inputMediaDocument();
|
||||
media.id = new TLRPC.TL_inputDocument();
|
||||
media.id.id = document.id;
|
||||
media.id.access_hash = document.access_hash;
|
||||
reqSend.media = media;
|
||||
performSendMessageRequest(reqSend, newMsgObj, null);
|
||||
}
|
||||
reqSend.media.mime_type = document.mime_type;
|
||||
reqSend.media.file_name = document.file_name;
|
||||
DelayedMessage delayedMessage = new DelayedMessage();
|
||||
delayedMessage.sendRequest = reqSend;
|
||||
delayedMessage.type = 2;
|
||||
delayedMessage.obj = newMsgObj;
|
||||
delayedMessage.documentLocation = document;
|
||||
delayedMessage.location = document.thumb.location;
|
||||
performSendDelayedMessage(delayedMessage);
|
||||
} else if (type == 8) {
|
||||
reqSend.media = new TLRPC.TL_inputMediaUploadedAudio();
|
||||
reqSend.media.duration = audio.duration;
|
||||
@ -1947,25 +1963,34 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
reqSend.media = new TLRPC.TL_decryptedMessageMediaGeoPoint();
|
||||
reqSend.media.lat = lat;
|
||||
reqSend.media._long = lon;
|
||||
performSendEncryptedRequest(reqSend, newMsgObj, encryptedChat, null);
|
||||
performSendEncryptedRequest(reqSend, newMsgObj, encryptedChat, null, null);
|
||||
} else if (type == 2) {
|
||||
reqSend.media = new TLRPC.TL_decryptedMessageMediaPhoto();
|
||||
TLRPC.PhotoSize small = photo.sizes.get(0);
|
||||
TLRPC.PhotoSize big = photo.sizes.get(photo.sizes.size() - 1);
|
||||
reqSend.media = new TLRPC.TL_decryptedMessageMediaPhoto();
|
||||
reqSend.media.thumb = small.bytes;
|
||||
reqSend.media.thumb_h = small.h;
|
||||
reqSend.media.thumb_w = small.w;
|
||||
reqSend.media.w = big.w;
|
||||
reqSend.media.h = big.h;
|
||||
reqSend.media.size = big.size;
|
||||
|
||||
DelayedMessage delayedMessage = new DelayedMessage();
|
||||
delayedMessage.sendEncryptedRequest = reqSend;
|
||||
delayedMessage.type = 0;
|
||||
delayedMessage.obj = newMsgObj;
|
||||
delayedMessage.encryptedChat = encryptedChat;
|
||||
delayedMessage.location = photo.sizes.get(photo.sizes.size() - 1).location;
|
||||
performSendDelayedMessage(delayedMessage);
|
||||
if (big.location.key == null) {
|
||||
DelayedMessage delayedMessage = new DelayedMessage();
|
||||
delayedMessage.originalPath = originalPath;
|
||||
delayedMessage.sendEncryptedRequest = reqSend;
|
||||
delayedMessage.type = 0;
|
||||
delayedMessage.obj = newMsgObj;
|
||||
delayedMessage.encryptedChat = encryptedChat;
|
||||
delayedMessage.location = photo.sizes.get(photo.sizes.size() - 1).location;
|
||||
performSendDelayedMessage(delayedMessage);
|
||||
} else {
|
||||
TLRPC.TL_inputEncryptedFile encryptedFile = new TLRPC.TL_inputEncryptedFile();
|
||||
encryptedFile.id = big.location.volume_id;
|
||||
encryptedFile.access_hash = big.location.secret;
|
||||
reqSend.media.key = big.location.key;
|
||||
reqSend.media.iv = big.location.iv;
|
||||
performSendEncryptedRequest(reqSend, newMsgObj, encryptedChat, encryptedFile, null);
|
||||
}
|
||||
} else if (type == 3) {
|
||||
reqSend.media = new TLRPC.TL_decryptedMessageMediaVideo();
|
||||
reqSend.media.duration = video.duration;
|
||||
@ -1975,23 +2000,30 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
reqSend.media.thumb = video.thumb.bytes;
|
||||
reqSend.media.thumb_h = video.thumb.h;
|
||||
reqSend.media.thumb_w = video.thumb.w;
|
||||
|
||||
DelayedMessage delayedMessage = new DelayedMessage();
|
||||
delayedMessage.sendEncryptedRequest = reqSend;
|
||||
delayedMessage.type = 1;
|
||||
delayedMessage.obj = newMsgObj;
|
||||
delayedMessage.encryptedChat = encryptedChat;
|
||||
delayedMessage.videoLocation = video;
|
||||
performSendDelayedMessage(delayedMessage);
|
||||
} else if (type == 5) {
|
||||
|
||||
if (video.access_hash == 0) {
|
||||
DelayedMessage delayedMessage = new DelayedMessage();
|
||||
delayedMessage.originalPath = originalPath;
|
||||
delayedMessage.sendEncryptedRequest = reqSend;
|
||||
delayedMessage.type = 1;
|
||||
delayedMessage.obj = newMsgObj;
|
||||
delayedMessage.encryptedChat = encryptedChat;
|
||||
delayedMessage.videoLocation = video;
|
||||
performSendDelayedMessage(delayedMessage);
|
||||
} else {
|
||||
TLRPC.TL_inputEncryptedFile encryptedFile = new TLRPC.TL_inputEncryptedFile();
|
||||
encryptedFile.id = video.id;
|
||||
encryptedFile.access_hash = video.access_hash;
|
||||
reqSend.media.key = video.key;
|
||||
reqSend.media.iv = video.iv;
|
||||
performSendEncryptedRequest(reqSend, newMsgObj, encryptedChat, encryptedFile, null);
|
||||
}
|
||||
} else if (type == 6) {
|
||||
reqSend.media = new TLRPC.TL_decryptedMessageMediaContact();
|
||||
reqSend.media.phone_number = user.phone;
|
||||
reqSend.media.first_name = user.first_name;
|
||||
reqSend.media.last_name = user.last_name;
|
||||
reqSend.media.user_id = user.id;
|
||||
performSendEncryptedRequest(reqSend, newMsgObj, encryptedChat, null);
|
||||
performSendEncryptedRequest(reqSend, newMsgObj, encryptedChat, null, null);
|
||||
} else if (type == 7) {
|
||||
reqSend.media = new TLRPC.TL_decryptedMessageMediaDocument();
|
||||
reqSend.media.size = document.size;
|
||||
@ -2006,14 +2038,23 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
}
|
||||
reqSend.media.file_name = document.file_name;
|
||||
reqSend.media.mime_type = document.mime_type;
|
||||
|
||||
DelayedMessage delayedMessage = new DelayedMessage();
|
||||
delayedMessage.sendEncryptedRequest = reqSend;
|
||||
delayedMessage.type = 2;
|
||||
delayedMessage.obj = newMsgObj;
|
||||
delayedMessage.encryptedChat = encryptedChat;
|
||||
delayedMessage.documentLocation = document;
|
||||
performSendDelayedMessage(delayedMessage);
|
||||
if (document.access_hash == 0) {
|
||||
DelayedMessage delayedMessage = new DelayedMessage();
|
||||
delayedMessage.originalPath = originalPath;
|
||||
delayedMessage.sendEncryptedRequest = reqSend;
|
||||
delayedMessage.type = 2;
|
||||
delayedMessage.obj = newMsgObj;
|
||||
delayedMessage.encryptedChat = encryptedChat;
|
||||
delayedMessage.documentLocation = document;
|
||||
performSendDelayedMessage(delayedMessage);
|
||||
} else {
|
||||
TLRPC.TL_inputEncryptedFile encryptedFile = new TLRPC.TL_inputEncryptedFile();
|
||||
encryptedFile.id = document.id;
|
||||
encryptedFile.access_hash = document.access_hash;
|
||||
reqSend.media.key = document.key;
|
||||
reqSend.media.iv = document.iv;
|
||||
performSendEncryptedRequest(reqSend, newMsgObj, encryptedChat, encryptedFile, null);
|
||||
}
|
||||
} else if (type == 8) {
|
||||
reqSend.media = new TLRPC.TL_decryptedMessageMediaAudio();
|
||||
reqSend.media.duration = audio.duration;
|
||||
@ -2037,13 +2078,15 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
} else {
|
||||
reqSend.id = msgObj.messageOwner.fwd_msg_id;
|
||||
}
|
||||
performSendMessageRequest(reqSend, newMsgObj);
|
||||
performSendMessageRequest(reqSend, newMsgObj, null);
|
||||
}
|
||||
}
|
||||
|
||||
private void processSentMessage(TLRPC.Message newMsg, TLRPC.Message sentMessage, TLRPC.EncryptedFile file, TLRPC.DecryptedMessage decryptedMessage) {
|
||||
private void processSentMessage(TLRPC.Message newMsg, TLRPC.Message sentMessage, TLRPC.EncryptedFile file, TLRPC.DecryptedMessage decryptedMessage, String originalPath) {
|
||||
if (sentMessage != null) {
|
||||
if (sentMessage.media instanceof TLRPC.TL_messageMediaPhoto && sentMessage.media.photo != null && newMsg.media instanceof TLRPC.TL_messageMediaPhoto && newMsg.media.photo != null) {
|
||||
MessagesStorage.getInstance().putSentFile(originalPath, sentMessage.media.photo, 0);
|
||||
|
||||
for (TLRPC.PhotoSize size : sentMessage.media.photo.sizes) {
|
||||
if (size instanceof TLRPC.TL_photoSizeEmpty) {
|
||||
continue;
|
||||
@ -2067,6 +2110,8 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
sentMessage.message = newMsg.message;
|
||||
sentMessage.attachPath = newMsg.attachPath;
|
||||
} else if (sentMessage.media instanceof TLRPC.TL_messageMediaVideo && sentMessage.media.video != null && newMsg.media instanceof TLRPC.TL_messageMediaVideo && newMsg.media.video != null) {
|
||||
MessagesStorage.getInstance().putSentFile(originalPath, sentMessage.media.video, 2);
|
||||
|
||||
TLRPC.PhotoSize size2 = newMsg.media.video.thumb;
|
||||
TLRPC.PhotoSize size = sentMessage.media.video.thumb;
|
||||
if (size2.location != null && size.location != null && !(size instanceof TLRPC.TL_photoSizeEmpty) && !(size2 instanceof TLRPC.TL_photoSizeEmpty)) {
|
||||
@ -2083,6 +2128,8 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
sentMessage.message = newMsg.message;
|
||||
sentMessage.attachPath = newMsg.attachPath;
|
||||
} else if (sentMessage.media instanceof TLRPC.TL_messageMediaDocument && sentMessage.media.document != null && newMsg.media instanceof TLRPC.TL_messageMediaDocument && newMsg.media.document != null) {
|
||||
MessagesStorage.getInstance().putSentFile(originalPath, sentMessage.media.document, 1);
|
||||
|
||||
TLRPC.PhotoSize size2 = newMsg.media.document.thumb;
|
||||
TLRPC.PhotoSize size = sentMessage.media.document.thumb;
|
||||
if (size2.location != null && size.location != null && !(size instanceof TLRPC.TL_photoSizeEmpty) && !(size2 instanceof TLRPC.TL_photoSizeEmpty)) {
|
||||
@ -2145,12 +2192,13 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
ArrayList<TLRPC.Message> arr = new ArrayList<TLRPC.Message>();
|
||||
arr.add(newMsg);
|
||||
MessagesStorage.getInstance().putMessages(arr, false, true);
|
||||
|
||||
MessagesStorage.getInstance().putSentFile(originalPath, newMsg.media.photo, 3);
|
||||
} else if (newMsg.media instanceof TLRPC.TL_messageMediaVideo && newMsg.media.video != null) {
|
||||
TLRPC.Video video = newMsg.media.video;
|
||||
newMsg.media.video = new TLRPC.TL_videoEncrypted();
|
||||
newMsg.media.video.duration = video.duration;
|
||||
newMsg.media.video.thumb = video.thumb;
|
||||
newMsg.media.video.id = video.id;
|
||||
newMsg.media.video.dc_id = file.dc_id;
|
||||
newMsg.media.video.w = video.w;
|
||||
newMsg.media.video.h = video.h;
|
||||
@ -2166,6 +2214,8 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
ArrayList<TLRPC.Message> arr = new ArrayList<TLRPC.Message>();
|
||||
arr.add(newMsg);
|
||||
MessagesStorage.getInstance().putMessages(arr, false, true);
|
||||
|
||||
MessagesStorage.getInstance().putSentFile(originalPath, newMsg.media.video, 5);
|
||||
} else if (newMsg.media instanceof TLRPC.TL_messageMediaDocument && newMsg.media.document != null) {
|
||||
TLRPC.Document document = newMsg.media.document;
|
||||
newMsg.media.document = new TLRPC.TL_documentEncrypted();
|
||||
@ -2191,6 +2241,8 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
ArrayList<TLRPC.Message> arr = new ArrayList<TLRPC.Message>();
|
||||
arr.add(newMsg);
|
||||
MessagesStorage.getInstance().putMessages(arr, false, true);
|
||||
|
||||
MessagesStorage.getInstance().putSentFile(originalPath, newMsg.media.document, 4);
|
||||
} else if (newMsg.media instanceof TLRPC.TL_messageMediaAudio && newMsg.media.audio != null) {
|
||||
TLRPC.Audio audio = newMsg.media.audio;
|
||||
newMsg.media.audio = new TLRPC.TL_audioEncrypted();
|
||||
@ -2220,7 +2272,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
}
|
||||
}
|
||||
|
||||
private void performSendEncryptedRequest(final TLRPC.DecryptedMessage req, final MessageObject newMsgObj, final TLRPC.EncryptedChat chat, final TLRPC.InputEncryptedFile encryptedFile) {
|
||||
private void performSendEncryptedRequest(final TLRPC.DecryptedMessage req, final MessageObject newMsgObj, final TLRPC.EncryptedChat chat, final TLRPC.InputEncryptedFile encryptedFile, final String originalPath) {
|
||||
if (req == null || chat.auth_key == null || chat instanceof TLRPC.TL_encryptedChatRequested || chat instanceof TLRPC.TL_encryptedChatWaiting) {
|
||||
return;
|
||||
}
|
||||
@ -2285,7 +2337,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
TLRPC.messages_SentEncryptedMessage res = (TLRPC.messages_SentEncryptedMessage) response;
|
||||
newMsgObj.messageOwner.date = res.date;
|
||||
if (res.file instanceof TLRPC.TL_encryptedFile) {
|
||||
processSentMessage(newMsgObj.messageOwner, null, res.file, req);
|
||||
processSentMessage(newMsgObj.messageOwner, null, res.file, req, originalPath);
|
||||
}
|
||||
MessagesStorage.getInstance().updateMessageStateAndId(newMsgObj.messageOwner.random_id, newMsgObj.messageOwner.id, newMsgObj.messageOwner.id, res.date, true);
|
||||
MessagesStorage.getInstance().storageQueue.postRunnable(new Runnable() {
|
||||
@ -2316,7 +2368,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
}, null, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassCanCompress);
|
||||
}
|
||||
|
||||
private void performSendMessageRequest(TLObject req, final MessageObject newMsgObj) {
|
||||
private void performSendMessageRequest(TLObject req, final MessageObject newMsgObj, final String originalPath) {
|
||||
ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
|
||||
@Override
|
||||
public void run(TLObject response, TLRPC.TL_error error) {
|
||||
@ -2350,7 +2402,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
TLRPC.messages_StatedMessage res = (TLRPC.messages_StatedMessage) response;
|
||||
sentMessages.add(res.message);
|
||||
newMsgObj.messageOwner.id = res.message.id;
|
||||
processSentMessage(newMsgObj.messageOwner, res.message, null, null);
|
||||
processSentMessage(newMsgObj.messageOwner, res.message, null, null, originalPath);
|
||||
if (MessagesStorage.lastSeqValue + 1 == res.seq) {
|
||||
MessagesStorage.lastSeqValue = res.seq;
|
||||
MessagesStorage.lastPtsValue = res.pts;
|
||||
@ -2376,7 +2428,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
TLRPC.Message message = res.messages.get(0);
|
||||
newMsgObj.messageOwner.id = message.id;
|
||||
sentMessages.add(message);
|
||||
processSentMessage(newMsgObj.messageOwner, message, null, null);
|
||||
processSentMessage(newMsgObj.messageOwner, message, null, null, originalPath);
|
||||
}
|
||||
if (MessagesStorage.lastSeqValue + 1 == res.seq) {
|
||||
MessagesStorage.lastSeqValue = res.seq;
|
||||
@ -2593,14 +2645,14 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
if (file != null && message.sendRequest != null) {
|
||||
if (message.type == 0) {
|
||||
message.sendRequest.media.file = file;
|
||||
performSendMessageRequest(message.sendRequest, message.obj);
|
||||
performSendMessageRequest(message.sendRequest, message.obj, message.originalPath);
|
||||
} else if (message.type == 1) {
|
||||
if (message.sendRequest.media.thumb == null) {
|
||||
message.sendRequest.media.thumb = file;
|
||||
performSendDelayedMessage(message);
|
||||
} else {
|
||||
message.sendRequest.media.file = file;
|
||||
performSendMessageRequest(message.sendRequest, message.obj);
|
||||
performSendMessageRequest(message.sendRequest, message.obj, message.originalPath);
|
||||
}
|
||||
} else if (message.type == 2) {
|
||||
if (message.sendRequest.media.thumb == null && message.location != null) {
|
||||
@ -2608,18 +2660,18 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
performSendDelayedMessage(message);
|
||||
} else {
|
||||
message.sendRequest.media.file = file;
|
||||
performSendMessageRequest(message.sendRequest, message.obj);
|
||||
performSendMessageRequest(message.sendRequest, message.obj, message.originalPath);
|
||||
}
|
||||
} else if (message.type == 3) {
|
||||
message.sendRequest.media.file = file;
|
||||
performSendMessageRequest(message.sendRequest, message.obj);
|
||||
performSendMessageRequest(message.sendRequest, message.obj, message.originalPath);
|
||||
}
|
||||
arr.remove(a);
|
||||
a--;
|
||||
} else if (encryptedFile != null && message.sendEncryptedRequest != null) {
|
||||
message.sendEncryptedRequest.media.key = encryptedFile.key;
|
||||
message.sendEncryptedRequest.media.iv = encryptedFile.iv;
|
||||
performSendEncryptedRequest(message.sendEncryptedRequest, message.obj, message.encryptedChat, encryptedFile);
|
||||
performSendEncryptedRequest(message.sendEncryptedRequest, message.obj, message.encryptedChat, encryptedFile, message.originalPath);
|
||||
arr.remove(a);
|
||||
a--;
|
||||
}
|
||||
@ -4454,8 +4506,9 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
String choosenSoundPath = null;
|
||||
int ledColor = 0xff00ff00;
|
||||
|
||||
choosenSoundPath = preferences.getString("sound_path_" + dialog_id, null);
|
||||
|
||||
if (chat_id != 0) {
|
||||
choosenSoundPath = preferences.getString("sound_chat_path_" + chat_id, null);
|
||||
if (choosenSoundPath != null && choosenSoundPath.equals(defaultPath)) {
|
||||
choosenSoundPath = null;
|
||||
} else if (choosenSoundPath == null) {
|
||||
@ -4464,7 +4517,6 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
needVibrate = preferences.getBoolean("EnableVibrateGroup", true);
|
||||
ledColor = preferences.getInt("GroupLed", 0xff00ff00);
|
||||
} else if (user_id != 0) {
|
||||
choosenSoundPath = preferences.getString("sound_path_" + user_id, null);
|
||||
if (choosenSoundPath != null && choosenSoundPath.equals(defaultPath)) {
|
||||
choosenSoundPath = null;
|
||||
} else if (choosenSoundPath == null) {
|
||||
@ -4808,7 +4860,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
newMessage.media.audio = new TLRPC.TL_audioEncrypted();
|
||||
newMessage.media.audio.id = message.file.id;
|
||||
newMessage.media.audio.access_hash = message.file.access_hash;
|
||||
newMessage.media.audio.user_id = decryptedMessage.media.user_id;
|
||||
newMessage.media.audio.user_id = from_id;
|
||||
newMessage.media.audio.date = message.date;
|
||||
newMessage.media.audio.size = message.file.size;
|
||||
newMessage.media.audio.key = decryptedMessage.media.key;
|
||||
|
@ -97,6 +97,8 @@ public class MessagesStorage {
|
||||
database.executeFast("CREATE TABLE user_contacts_v6(uid INTEGER PRIMARY KEY, fname TEXT, sname TEXT)").stepThis().dispose();
|
||||
database.executeFast("CREATE TABLE user_phones_v6(uid INTEGER, phone TEXT, sphone TEXT, deleted INTEGER, PRIMARY KEY (uid, phone))").stepThis().dispose();
|
||||
|
||||
database.executeFast("CREATE TABLE sent_files_v2(uid TEXT, type INTEGER, data BLOB, PRIMARY KEY (uid, type))").stepThis().dispose();
|
||||
|
||||
database.executeFast("CREATE INDEX IF NOT EXISTS mid_idx_randoms ON randoms(mid);").stepThis().dispose();
|
||||
|
||||
database.executeFast("CREATE INDEX IF NOT EXISTS sphone_deleted_idx_user_phones ON user_phones_v6(sphone, deleted);").stepThis().dispose();
|
||||
@ -166,6 +168,8 @@ public class MessagesStorage {
|
||||
database.executeFast("CREATE INDEX IF NOT EXISTS sphone_deleted_idx_user_phones ON user_phones_v6(sphone, deleted);").stepThis().dispose();
|
||||
|
||||
database.executeFast("CREATE INDEX IF NOT EXISTS mid_idx_randoms ON randoms(mid);").stepThis().dispose();
|
||||
|
||||
database.executeFast("CREATE TABLE IF NOT EXISTS sent_files_v2(uid TEXT, type INTEGER, data BLOB, PRIMARY KEY (uid, type))").stepThis().dispose();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
@ -1435,6 +1439,73 @@ public class MessagesStorage {
|
||||
}
|
||||
}
|
||||
|
||||
public TLObject getSentFile(final String path, final int type) {
|
||||
if (path == null) {
|
||||
return null;
|
||||
}
|
||||
final Semaphore semaphore = new Semaphore(0);
|
||||
final ArrayList<TLObject> result = new ArrayList<TLObject>();
|
||||
storageQueue.postRunnable(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
String id = Utilities.MD5(path);
|
||||
if (id != null) {
|
||||
SQLiteCursor cursor = database.queryFinalized(String.format(Locale.US, "SELECT data FROM sent_files_v2 WHERE uid = '%s' AND type = %d", id, type));
|
||||
if (cursor.next()) {
|
||||
byte[] fileData = cursor.byteArrayValue(0);
|
||||
if (fileData != null) {
|
||||
SerializedData data = new SerializedData(fileData);
|
||||
TLObject file = TLClassStore.Instance().TLdeserialize(data, data.readInt32());
|
||||
if (file != null) {
|
||||
result.add(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
cursor.dispose();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
} finally {
|
||||
semaphore.release();
|
||||
}
|
||||
}
|
||||
});
|
||||
try {
|
||||
semaphore.acquire();
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
return !result.isEmpty() ? result.get(0) : null;
|
||||
}
|
||||
|
||||
public void putSentFile(final String path, final TLObject file, final int type) {
|
||||
if (path == null || file == null) {
|
||||
return;
|
||||
}
|
||||
storageQueue.postRunnable(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
String id = Utilities.MD5(path);
|
||||
if (id != null) {
|
||||
SQLitePreparedStatement state = database.executeFast("REPLACE INTO sent_files_v2 VALUES(?, ?, ?)");
|
||||
state.requery();
|
||||
SerializedData data = new SerializedData();
|
||||
file.serializeToStream(data);
|
||||
state.bindString(1, id);
|
||||
state.bindInteger(2, type);
|
||||
state.bindByteArray(3, data.toByteArray());
|
||||
state.step();
|
||||
state.dispose();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void updateEncryptedChatTTL(final TLRPC.EncryptedChat chat) {
|
||||
if (chat == null) {
|
||||
return;
|
||||
|
@ -8826,7 +8826,7 @@ public class TLRPC {
|
||||
}
|
||||
}
|
||||
|
||||
public static class TL_documentEncrypted extends Document {
|
||||
public static class TL_documentEncrypted extends TL_document {
|
||||
public static int constructor = 0x55555556;
|
||||
|
||||
|
||||
@ -8860,7 +8860,7 @@ public class TLRPC {
|
||||
}
|
||||
}
|
||||
|
||||
public static class TL_videoEncrypted extends Video {
|
||||
public static class TL_videoEncrypted extends TL_video {
|
||||
public static int constructor = 0x55555553;
|
||||
|
||||
|
||||
|
@ -1003,4 +1003,8 @@ public class Utilities {
|
||||
UpdateManager.register(context, BuildVars.HOCKEY_APP_HASH);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isTablet(Context context) {
|
||||
return (context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE;
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
package org.telegram.ui.Adapters;
|
||||
|
||||
import android.database.DataSetObserver;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
@ -38,4 +39,11 @@ public class BaseFragmentAdapter extends BaseAdapter {
|
||||
public View getView(int i, View view, ViewGroup viewGroup) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregisterDataSetObserver(DataSetObserver observer) {
|
||||
if (observer != null) {
|
||||
super.unregisterDataSetObserver(observer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -50,7 +50,6 @@ import android.view.inputmethod.InputMethodManager;
|
||||
import android.webkit.MimeTypeMap;
|
||||
import android.widget.AbsListView;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.EditText;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageButton;
|
||||
@ -79,6 +78,7 @@ import org.telegram.messenger.NotificationCenter;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.UserConfig;
|
||||
import org.telegram.messenger.Utilities;
|
||||
import org.telegram.ui.Adapters.BaseFragmentAdapter;
|
||||
import org.telegram.ui.Cells.ChatAudioCell;
|
||||
import org.telegram.ui.Cells.ChatBaseCell;
|
||||
import org.telegram.ui.Cells.ChatMediaCell;
|
||||
@ -1643,25 +1643,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
|
||||
showAttachmentError();
|
||||
return;
|
||||
}
|
||||
String tempPath = Utilities.getPath(data.getData());
|
||||
|
||||
boolean isGif = false;
|
||||
String originalPath = null;
|
||||
if (tempPath != null && tempPath.endsWith(".gif")) {
|
||||
isGif = true;
|
||||
} else if (tempPath == null) {
|
||||
isGif = MediaController.isGif(data.getData());
|
||||
if (isGif) {
|
||||
originalPath = data.toString();
|
||||
tempPath = MediaController.copyDocumentToCache(data.getData(), "gif");
|
||||
}
|
||||
}
|
||||
|
||||
if (tempPath != null && isGif) {
|
||||
processSendingDocument(tempPath, originalPath);
|
||||
} else {
|
||||
processSendingPhoto(null, data.getData());
|
||||
}
|
||||
processSendingPhoto(null, data.getData());
|
||||
} else if (requestCode == 2) {
|
||||
String videoPath = null;
|
||||
if (data != null) {
|
||||
@ -1701,8 +1683,8 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
|
||||
showAttachmentError();
|
||||
return;
|
||||
}
|
||||
String originalPath = null;
|
||||
String tempPath = Utilities.getPath(data.getData());
|
||||
String originalPath = tempPath;
|
||||
if (tempPath == null) {
|
||||
originalPath = data.toString();
|
||||
tempPath = MediaController.copyDocumentToCache(data.getData(), "file");
|
||||
@ -1750,21 +1732,17 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
|
||||
}
|
||||
|
||||
public void processSendingPhoto(String imageFilePath, Uri imageUri) {
|
||||
if ((imageFilePath == null || imageFilePath.length() == 0) && imageUri == null) {
|
||||
return;
|
||||
ArrayList<String> paths = null;
|
||||
ArrayList<Uri> uris = null;
|
||||
if (imageFilePath != null && imageFilePath.length() != 0) {
|
||||
paths = new ArrayList<String>();
|
||||
paths.add(imageFilePath);
|
||||
}
|
||||
TLRPC.TL_photo photo = MessagesController.getInstance().generatePhotoSizes(imageFilePath, imageUri);
|
||||
if (photo != null) {
|
||||
String originalPath = imageFilePath;
|
||||
if (originalPath == null && imageUri != null) {
|
||||
originalPath = imageUri.toString();
|
||||
}
|
||||
MessagesController.getInstance().sendMessage(photo, originalPath, dialog_id);
|
||||
if (chatListView != null) {
|
||||
chatListView.setSelection(messages.size() + 1);
|
||||
}
|
||||
scrollToTopOnResume = true;
|
||||
if (imageUri != null) {
|
||||
uris = new ArrayList<Uri>();
|
||||
uris.add(imageUri);
|
||||
}
|
||||
processSendingPhotos(paths, uris);
|
||||
}
|
||||
|
||||
public void processSendingPhotos(ArrayList<String> paths, ArrayList<Uri> uris) {
|
||||
@ -1782,6 +1760,8 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ArrayList<String> sendAsDocuments = null;
|
||||
ArrayList<String> sendAsDocumentsOriginal = null;
|
||||
int count = !pathsCopy.isEmpty() ? pathsCopy.size() : urisCopy.size();
|
||||
String path = null;
|
||||
Uri uri = null;
|
||||
@ -1792,131 +1772,222 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
|
||||
uri = urisCopy.get(a);
|
||||
}
|
||||
|
||||
String originalPath = path;
|
||||
String tempPath = path;
|
||||
if (tempPath == null && uri != null) {
|
||||
tempPath = Utilities.getPath(uri);
|
||||
originalPath = uri.toString();
|
||||
}
|
||||
|
||||
boolean isGif = false;
|
||||
if (path != null && path.endsWith(".gif")) {
|
||||
final String finalPath = path;
|
||||
Utilities.RunOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
processSendingDocument(finalPath, null);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
final TLRPC.TL_photo photo = MessagesController.getInstance().generatePhotoSizes(path, uri);
|
||||
String originalPath = path;
|
||||
if (originalPath == null && uri != null) {
|
||||
if (tempPath != null && tempPath.endsWith(".gif")) {
|
||||
isGif = true;
|
||||
} else if (tempPath == null && uri != null) {
|
||||
isGif = MediaController.isGif(uri);
|
||||
if (isGif) {
|
||||
originalPath = uri.toString();
|
||||
tempPath = MediaController.copyDocumentToCache(uri, "gif");
|
||||
}
|
||||
final String originalPathFinal = originalPath;
|
||||
Utilities.RunOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (photo != null) {
|
||||
MessagesController.getInstance().sendMessage(photo, originalPathFinal, dialog_id);
|
||||
}
|
||||
|
||||
if (isGif) {
|
||||
if (sendAsDocuments == null) {
|
||||
sendAsDocuments = new ArrayList<String>();
|
||||
sendAsDocumentsOriginal = new ArrayList<String>();
|
||||
}
|
||||
sendAsDocuments.add(tempPath);
|
||||
sendAsDocumentsOriginal.add(originalPath);
|
||||
} else {
|
||||
TLRPC.TL_photo photo = (TLRPC.TL_photo)MessagesStorage.getInstance().getSentFile(originalPath, currentEncryptedChat == null ? 0 : 3);
|
||||
if (photo == null && uri != null) {
|
||||
photo = (TLRPC.TL_photo)MessagesStorage.getInstance().getSentFile(Utilities.getPath(uri), currentEncryptedChat == null ? 0 : 3);
|
||||
}
|
||||
if (photo == null) {
|
||||
photo = MessagesController.getInstance().generatePhotoSizes(path, uri);
|
||||
}
|
||||
if (photo != null) {
|
||||
final String originalPathFinal = originalPath;
|
||||
final TLRPC.TL_photo photoFinal = photo;
|
||||
Utilities.RunOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MessagesController.getInstance().sendMessage(photoFinal, originalPathFinal, dialog_id);
|
||||
if (chatListView != null) {
|
||||
chatListView.setSelection(messages.size() + 1);
|
||||
}
|
||||
scrollToTopOnResume = true;
|
||||
if (paused) {
|
||||
scrollToTopOnResume = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sendAsDocuments != null && !sendAsDocuments.isEmpty()) {
|
||||
for (int a = 0; a < sendAsDocuments.size(); a++) {
|
||||
processSendingDocumentInternal(sendAsDocuments.get(a), sendAsDocumentsOriginal.get(a));
|
||||
}
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
public void processSendingDocument(String documentFilePath, String originalPathOverride) {
|
||||
if (documentFilePath == null || documentFilePath.length() == 0) {
|
||||
private void processSendingDocumentInternal(String path, String originalPath) {
|
||||
if (path == null || path.length() == 0) {
|
||||
return;
|
||||
}
|
||||
File f = new File(documentFilePath);
|
||||
final File f = new File(path);
|
||||
if (!f.exists() || f.length() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
String name = f.getName();
|
||||
if (name == null) {
|
||||
name = "noname";
|
||||
}
|
||||
String ext = "";
|
||||
int idx = documentFilePath.lastIndexOf(".");
|
||||
int idx = path.lastIndexOf(".");
|
||||
if (idx != -1) {
|
||||
ext = documentFilePath.substring(idx + 1);
|
||||
ext = path.substring(idx + 1);
|
||||
}
|
||||
TLRPC.TL_document document = new TLRPC.TL_document();
|
||||
document.id = 0;
|
||||
document.user_id = UserConfig.getClientUserId();
|
||||
document.date = ConnectionsManager.getInstance().getCurrentTime();
|
||||
document.file_name = name;
|
||||
document.size = (int)f.length();
|
||||
document.dc_id = 0;
|
||||
document.path = documentFilePath;
|
||||
if (ext.length() != 0) {
|
||||
MimeTypeMap myMime = MimeTypeMap.getSingleton();
|
||||
String mimeType = myMime.getMimeTypeFromExtension(ext.toLowerCase());
|
||||
if (mimeType != null) {
|
||||
document.mime_type = mimeType;
|
||||
if (originalPath != null) {
|
||||
originalPath += "" + f.length();
|
||||
}
|
||||
|
||||
TLRPC.TL_document document = (TLRPC.TL_document)MessagesStorage.getInstance().getSentFile(originalPath, currentEncryptedChat == null ? 1 : 4);
|
||||
if (document == null && !path.equals(originalPath)) {
|
||||
document = (TLRPC.TL_document)MessagesStorage.getInstance().getSentFile(path + f.length(), currentEncryptedChat == null ? 1 : 4);
|
||||
}
|
||||
if (document == null) {
|
||||
document = new TLRPC.TL_document();
|
||||
document.id = 0;
|
||||
document.user_id = UserConfig.getClientUserId();
|
||||
document.date = ConnectionsManager.getInstance().getCurrentTime();
|
||||
document.file_name = name;
|
||||
document.size = (int)f.length();
|
||||
document.dc_id = 0;
|
||||
if (ext.length() != 0) {
|
||||
MimeTypeMap myMime = MimeTypeMap.getSingleton();
|
||||
String mimeType = myMime.getMimeTypeFromExtension(ext.toLowerCase());
|
||||
if (mimeType != null) {
|
||||
document.mime_type = mimeType;
|
||||
} else {
|
||||
document.mime_type = "application/octet-stream";
|
||||
}
|
||||
} else {
|
||||
document.mime_type = "application/octet-stream";
|
||||
}
|
||||
} else {
|
||||
document.mime_type = "application/octet-stream";
|
||||
}
|
||||
if (document.mime_type.equals("image/gif")) {
|
||||
try {
|
||||
Bitmap bitmap = FileLoader.loadBitmap(f.getAbsolutePath(), null, 90, 90);
|
||||
if (bitmap != null) {
|
||||
document.thumb = FileLoader.scaleAndSaveImage(bitmap, 90, 90, 55, currentEncryptedChat != null);
|
||||
document.thumb.type = "s";
|
||||
if (document.mime_type.equals("image/gif")) {
|
||||
try {
|
||||
Bitmap bitmap = FileLoader.loadBitmap(f.getAbsolutePath(), null, 90, 90);
|
||||
if (bitmap != null) {
|
||||
document.thumb = FileLoader.scaleAndSaveImage(bitmap, 90, 90, 55, currentEncryptedChat != null);
|
||||
document.thumb.type = "s";
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
if (document.thumb == null) {
|
||||
document.thumb = new TLRPC.TL_photoSizeEmpty();
|
||||
document.thumb.type = "s";
|
||||
}
|
||||
}
|
||||
if (document.thumb == null) {
|
||||
document.thumb = new TLRPC.TL_photoSizeEmpty();
|
||||
document.thumb.type = "s";
|
||||
document.path = path;
|
||||
|
||||
final TLRPC.TL_document documentFinal = document;
|
||||
final String originalPathFinal = originalPath;
|
||||
Utilities.RunOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MessagesController.getInstance().sendMessage(documentFinal, originalPathFinal, dialog_id);
|
||||
if (chatListView != null) {
|
||||
chatListView.setSelection(messages.size() + 1);
|
||||
}
|
||||
if (paused) {
|
||||
scrollToTopOnResume = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void processSendingDocument(String path, String originalPath) {
|
||||
if (path == null || originalPath == null) {
|
||||
return;
|
||||
}
|
||||
MessagesController.getInstance().sendMessage(document, originalPathOverride == null ? (documentFilePath + document.size) : originalPathOverride, dialog_id);
|
||||
ArrayList<String> paths = new ArrayList<String>();
|
||||
ArrayList<String> originalPaths = new ArrayList<String>();
|
||||
paths.add(path);
|
||||
originalPaths.add(originalPath);
|
||||
processSendingDocuments(paths, originalPaths);
|
||||
}
|
||||
|
||||
public void processSendingDocuments(final ArrayList<String> paths, final ArrayList<String> originalPaths) {
|
||||
if (paths == null && originalPaths == null || paths != null && originalPaths != null && paths.size() != originalPaths.size()) {
|
||||
return;
|
||||
}
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (int a = 0; a < paths.size(); a++) {
|
||||
processSendingDocumentInternal(paths.get(a), originalPaths.get(a));
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
public void processSendingVideo(final String videoPath) {
|
||||
if (videoPath == null || videoPath.length() == 0) {
|
||||
return;
|
||||
}
|
||||
Bitmap thumb = ThumbnailUtils.createVideoThumbnail(videoPath, MediaStore.Video.Thumbnails.MINI_KIND);
|
||||
TLRPC.PhotoSize size = FileLoader.scaleAndSaveImage(thumb, 90, 90, 55, currentEncryptedChat != null);
|
||||
if (size == null) {
|
||||
return;
|
||||
}
|
||||
size.type = "s";
|
||||
TLRPC.TL_video video = new TLRPC.TL_video();
|
||||
video.thumb = size;
|
||||
video.caption = "";
|
||||
video.id = 0;
|
||||
video.path = videoPath;
|
||||
File temp = new File(videoPath);
|
||||
if (temp != null && temp.exists()) {
|
||||
video.size = (int)temp.length();
|
||||
}
|
||||
UserConfig.lastLocalId--;
|
||||
UserConfig.saveConfig(false);
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
TLRPC.TL_video video = (TLRPC.TL_video)MessagesStorage.getInstance().getSentFile(videoPath, currentEncryptedChat == null ? 2 : 5);
|
||||
if (video == null) {
|
||||
Bitmap thumb = ThumbnailUtils.createVideoThumbnail(videoPath, MediaStore.Video.Thumbnails.MINI_KIND);
|
||||
TLRPC.PhotoSize size = FileLoader.scaleAndSaveImage(thumb, 90, 90, 55, currentEncryptedChat != null);
|
||||
if (size == null) {
|
||||
return;
|
||||
}
|
||||
size.type = "s";
|
||||
video = new TLRPC.TL_video();
|
||||
video.thumb = size;
|
||||
video.caption = "";
|
||||
video.id = 0;
|
||||
File temp = new File(videoPath);
|
||||
if (temp != null && temp.exists()) {
|
||||
video.size = (int) temp.length();
|
||||
}
|
||||
UserConfig.lastLocalId--;
|
||||
UserConfig.saveConfig(false);
|
||||
|
||||
MediaPlayer mp = MediaPlayer.create(ApplicationLoader.applicationContext, Uri.fromFile(new File(videoPath)));
|
||||
if (mp == null) {
|
||||
return;
|
||||
}
|
||||
video.duration = (int)Math.ceil(mp.getDuration() / 1000.0f);
|
||||
video.w = mp.getVideoWidth();
|
||||
video.h = mp.getVideoHeight();
|
||||
mp.release();
|
||||
MediaPlayer mp = MediaPlayer.create(ApplicationLoader.applicationContext, Uri.fromFile(new File(videoPath)));
|
||||
if (mp == null) {
|
||||
return;
|
||||
}
|
||||
video.duration = (int) Math.ceil(mp.getDuration() / 1000.0f);
|
||||
video.w = mp.getVideoWidth();
|
||||
video.h = mp.getVideoHeight();
|
||||
mp.release();
|
||||
}
|
||||
video.path = videoPath;
|
||||
|
||||
MediaStore.Video.Media media = new MediaStore.Video.Media();
|
||||
MessagesController.getInstance().sendMessage(video, videoPath, dialog_id);
|
||||
if (chatListView != null) {
|
||||
chatListView.setSelection(messages.size() + 1);
|
||||
}
|
||||
scrollToTopOnResume = true;
|
||||
final TLRPC.TL_video videoFinal = video;
|
||||
Utilities.RunOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MessagesController.getInstance().sendMessage(videoFinal, videoPath, dialog_id);
|
||||
if (chatListView != null) {
|
||||
chatListView.setSelection(messages.size() + 1);
|
||||
}
|
||||
if (paused) {
|
||||
scrollToTopOnResume = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
private void removeUnreadPlane(boolean reload) {
|
||||
@ -2752,7 +2823,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
|
||||
MessagesController.getInstance().markDialogAsRead(dialog_id, messages.get(0).messageOwner.id, readWithMid, 0, readWithDate, true);
|
||||
}
|
||||
|
||||
fixLayout();
|
||||
fixLayout(true);
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
|
||||
String lastMessageText = preferences.getString("dialog_" + dialog_id, null);
|
||||
if (lastMessageText != null) {
|
||||
@ -2870,7 +2941,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
|
||||
MediaController.getInstance().setLastEncryptedChatParams(chatEnterTime, chatLeaveTime, currentEncryptedChat, visibleMessages);
|
||||
}
|
||||
|
||||
private void fixLayout() {
|
||||
private void fixLayout(final boolean resume) {
|
||||
final int lastPos = chatListView.getLastVisiblePosition();
|
||||
ViewTreeObserver obs = chatListView.getViewTreeObserver();
|
||||
obs.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
|
||||
@ -2883,7 +2954,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
|
||||
return true;
|
||||
}
|
||||
int height = Utilities.dp(48);
|
||||
if (getParentActivity().getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
if (!Utilities.isTablet(getParentActivity()) && getParentActivity().getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
height = Utilities.dp(40);
|
||||
selectedMessagesCountTextView.setTextSize(16);
|
||||
} else {
|
||||
@ -2895,7 +2966,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
|
||||
params.height = height;
|
||||
avatarImageView.setLayoutParams(params);
|
||||
}
|
||||
if (lastPos >= messages.size() - 1) {
|
||||
if (!resume && lastPos >= messages.size() - 1) {
|
||||
chatListView.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -2910,7 +2981,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
|
||||
|
||||
@Override
|
||||
public void onConfigurationChanged(android.content.res.Configuration newConfig) {
|
||||
fixLayout();
|
||||
fixLayout(false);
|
||||
}
|
||||
|
||||
private View getRowParentView(View v) {
|
||||
@ -3216,7 +3287,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
|
||||
@Override
|
||||
public void didSelectFile(DocumentSelectActivity activity, String path) {
|
||||
activity.finishFragment();
|
||||
processSendingDocument(path, null);
|
||||
processSendingDocument(path, path);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -3515,7 +3586,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
|
||||
@Override
|
||||
public int getSelectedCount() { return 0; }
|
||||
|
||||
private class ChatAdapter extends BaseAdapter {
|
||||
private class ChatAdapter extends BaseFragmentAdapter {
|
||||
|
||||
private Context mContext;
|
||||
|
||||
@ -3938,14 +4009,17 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
|
||||
if (actionView != null) {
|
||||
actionView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
Float progress = FileLoader.getInstance().fileProgresses.get(message.messageOwner.attachPath);
|
||||
Float progress = null;
|
||||
if (message.messageOwner.attachPath != null && message.messageOwner.attachPath.length() != 0) {
|
||||
progress = FileLoader.getInstance().fileProgresses.get(message.messageOwner.attachPath);
|
||||
progressByTag.put((Integer)actionProgress.getTag(), message.messageOwner.attachPath);
|
||||
progressBarMap.put(message.messageOwner.attachPath, actionProgress);
|
||||
}
|
||||
if (progress != null) {
|
||||
actionProgress.setProgress((int)(progress * 100));
|
||||
} else {
|
||||
actionProgress.setProgress(0);
|
||||
}
|
||||
progressByTag.put((Integer)actionProgress.getTag(), message.messageOwner.attachPath);
|
||||
progressBarMap.put(message.messageOwner.attachPath, actionProgress);
|
||||
}
|
||||
if (actionAttachButton != null) {
|
||||
actionAttachButton.setVisibility(View.GONE);
|
||||
|
@ -8,24 +8,16 @@
|
||||
|
||||
package org.telegram.ui;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Typeface;
|
||||
import android.media.Ringtone;
|
||||
import android.media.RingtoneManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
import android.text.Html;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
@ -41,13 +33,13 @@ import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.UserConfig;
|
||||
import org.telegram.messenger.Utilities;
|
||||
import org.telegram.objects.MessageObject;
|
||||
import org.telegram.ui.Adapters.BaseFragmentAdapter;
|
||||
import org.telegram.ui.Cells.ChatOrUserCell;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarLayer;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
||||
import org.telegram.ui.Views.AvatarUpdater;
|
||||
import org.telegram.ui.Views.BackupImageView;
|
||||
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
||||
import org.telegram.ui.Views.ColorPickerView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@ -71,9 +63,6 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
|
||||
private int avatarRow;
|
||||
private int settingsSectionRow;
|
||||
private int settingsNotificationsRow;
|
||||
private int settingsVibrateRow;
|
||||
private int settingsLedRow;
|
||||
private int settingsSoundRow;
|
||||
private int sharedMediaSectionRow;
|
||||
private int sharedMediaRow;
|
||||
private int membersSectionRow;
|
||||
@ -142,9 +131,6 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
|
||||
avatarRow = rowCount++;
|
||||
settingsSectionRow = rowCount++;
|
||||
settingsNotificationsRow = rowCount++;
|
||||
settingsVibrateRow = rowCount++;
|
||||
settingsLedRow = rowCount++;
|
||||
settingsSoundRow = rowCount++;
|
||||
sharedMediaSectionRow = rowCount++;
|
||||
sharedMediaRow = rowCount++;
|
||||
if (info != null && !(info instanceof TLRPC.TL_chatParticipantsForbidden)) {
|
||||
@ -239,36 +225,7 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
|
||||
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> adapterView, View view, final int i, long l) {
|
||||
if (i == settingsSoundRow) {
|
||||
try {
|
||||
Intent tmpIntent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
|
||||
tmpIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_NOTIFICATION);
|
||||
tmpIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true);
|
||||
tmpIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_DEFAULT_URI, RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION));
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
||||
Uri currentSound = null;
|
||||
|
||||
String defaultPath = null;
|
||||
Uri defaultUri = Settings.System.DEFAULT_NOTIFICATION_URI;
|
||||
if (defaultUri != null) {
|
||||
defaultPath = defaultUri.getPath();
|
||||
}
|
||||
|
||||
String path = preferences.getString("sound_chat_path_" + chat_id, defaultPath);
|
||||
if (path != null && !path.equals("NoSound")) {
|
||||
if (path.equals(defaultPath)) {
|
||||
currentSound = defaultUri;
|
||||
} else {
|
||||
currentSound = Uri.parse(path);
|
||||
}
|
||||
}
|
||||
|
||||
tmpIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, currentSound);
|
||||
getParentActivity().startActivityForResult(tmpIntent, 3);
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
} else if (i == sharedMediaRow) {
|
||||
if (i == sharedMediaRow) {
|
||||
Bundle args = new Bundle();
|
||||
args.putLong("dialog_id", -chat_id);
|
||||
presentFragment(new MediaActivity(args));
|
||||
@ -282,84 +239,10 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
|
||||
Bundle args = new Bundle();
|
||||
args.putInt("user_id", user_id);
|
||||
presentFragment(new UserProfileActivity(args));
|
||||
} else if (i == settingsVibrateRow || i == settingsNotificationsRow) {
|
||||
if (getParentActivity() == null) {
|
||||
return;
|
||||
}
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
||||
builder.setItems(new CharSequence[] {
|
||||
LocaleController.getString("Default", R.string.Default),
|
||||
LocaleController.getString("Enabled", R.string.Enabled),
|
||||
LocaleController.getString("Disabled", R.string.Disabled)
|
||||
}, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
if (i == settingsVibrateRow) {
|
||||
editor.putInt("vibrate_" + (-chat_id), which);
|
||||
} else if (i == settingsNotificationsRow) {
|
||||
editor.putInt("notify2_" + (-chat_id), which);
|
||||
}
|
||||
editor.commit();
|
||||
if (listView != null) {
|
||||
listView.invalidateViews();
|
||||
}
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
||||
showAlertDialog(builder);
|
||||
} else if (i == settingsLedRow) {
|
||||
if (getParentActivity() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
LayoutInflater li = (LayoutInflater)getParentActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
view = li.inflate(R.layout.settings_color_dialog_layout, null, false);
|
||||
final ColorPickerView colorPickerView = (ColorPickerView)view.findViewById(R.id.color_picker);
|
||||
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
||||
if (preferences.contains("color_" + (-chat_id))) {
|
||||
colorPickerView.setOldCenterColor(preferences.getInt("color_" + (-chat_id), 0xff00ff00));
|
||||
} else {
|
||||
colorPickerView.setOldCenterColor(preferences.getInt("GroupLed", 0xff00ff00));
|
||||
}
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||
builder.setTitle(LocaleController.getString("LedColor", R.string.LedColor));
|
||||
builder.setView(view);
|
||||
builder.setPositiveButton(LocaleController.getString("Set", R.string.Set), new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int which) {
|
||||
final SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putInt("color_" + (-chat_id), colorPickerView.getColor());
|
||||
editor.commit();
|
||||
listView.invalidateViews();
|
||||
}
|
||||
});
|
||||
builder.setNeutralButton(LocaleController.getString("Disabled", R.string.Disabled), new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
final SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putInt("color_" + (-chat_id), 0);
|
||||
editor.commit();
|
||||
listView.invalidateViews();
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(LocaleController.getString("Default", R.string.Default), new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
final SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.remove("color_" + (-chat_id));
|
||||
editor.commit();
|
||||
listView.invalidateViews();
|
||||
}
|
||||
});
|
||||
showAlertDialog(builder);
|
||||
} else if (i == settingsNotificationsRow) {
|
||||
Bundle args = new Bundle();
|
||||
args.putLong("dialog_id", -chat_id);
|
||||
presentFragment(new ProfileNotificationsActivity(args));
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -377,41 +260,6 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
|
||||
MessagesController.getInstance().addUserToChat(chat_id, user, info);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResultFragment(int requestCode, int resultCode, Intent data) {
|
||||
avatarUpdater.onActivityResult(requestCode, resultCode, data);
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
if (requestCode == 3) {
|
||||
Uri ringtone = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
|
||||
String name = null;
|
||||
if (ringtone != null) {
|
||||
Ringtone rng = RingtoneManager.getRingtone(getParentActivity(), ringtone);
|
||||
if (rng != null) {
|
||||
if(ringtone.equals(Settings.System.DEFAULT_NOTIFICATION_URI)) {
|
||||
name = LocaleController.getString("Default", R.string.Default);
|
||||
} else {
|
||||
name = rng.getTitle(getParentActivity());
|
||||
}
|
||||
rng.stop();
|
||||
}
|
||||
}
|
||||
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
|
||||
if (name != null && ringtone != null) {
|
||||
editor.putString("sound_chat_" + chat_id, name);
|
||||
editor.putString("sound_chat_path_" + chat_id, ringtone.toString());
|
||||
} else {
|
||||
editor.putString("sound_chat_" + chat_id, "NoSound");
|
||||
editor.putString("sound_chat_path_" + chat_id, "NoSound");
|
||||
}
|
||||
editor.commit();
|
||||
listView.invalidateViews();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveSelfArgs(Bundle args) {
|
||||
if (avatarUpdater != null && avatarUpdater.currentPicturePath != null) {
|
||||
@ -630,7 +478,7 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
|
||||
}
|
||||
}
|
||||
|
||||
private class ListAdapter extends BaseAdapter {
|
||||
private class ListAdapter extends BaseFragmentAdapter {
|
||||
private Context mContext;
|
||||
|
||||
public ListAdapter(Context context) {
|
||||
@ -644,7 +492,7 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(int i) {
|
||||
return i == settingsNotificationsRow || i == settingsSoundRow || i == sharedMediaRow || i == addMemberRow || i > membersSectionRow && i < membersEndRow || i == settingsVibrateRow || i == settingsLedRow;
|
||||
return i == settingsNotificationsRow || i == sharedMediaRow || i == addMemberRow || i > membersSectionRow && i < membersEndRow;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -792,30 +640,6 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
|
||||
detailTextView.setText(String.format("%d", totalMediaCount));
|
||||
}
|
||||
divider.setVisibility(View.INVISIBLE);
|
||||
} else if (i == settingsVibrateRow) {
|
||||
textView.setText(LocaleController.getString("Vibrate", R.string.Vibrate));
|
||||
divider.setVisibility(View.VISIBLE);
|
||||
SharedPreferences preferences = mContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
||||
int value = preferences.getInt("vibrate_" + (-chat_id), 0);
|
||||
if (value == 0) {
|
||||
detailTextView.setText(LocaleController.getString("Default", R.string.Default));
|
||||
} else if (value == 1) {
|
||||
detailTextView.setText(LocaleController.getString("Enabled", R.string.Enabled));
|
||||
} else if (value == 2) {
|
||||
detailTextView.setText(LocaleController.getString("Disabled", R.string.Disabled));
|
||||
}
|
||||
} else if (i == settingsNotificationsRow) {
|
||||
textView.setText(LocaleController.getString("Notifications", R.string.Notifications));
|
||||
divider.setVisibility(View.VISIBLE);
|
||||
SharedPreferences preferences = mContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
||||
int value = preferences.getInt("notify2_" + (-chat_id), 0);
|
||||
if (value == 0) {
|
||||
detailTextView.setText(LocaleController.getString("Default", R.string.Default));
|
||||
} else if (value == 1) {
|
||||
detailTextView.setText(LocaleController.getString("Enabled", R.string.Enabled));
|
||||
} else if (value == 2) {
|
||||
detailTextView.setText(LocaleController.getString("Disabled", R.string.Disabled));
|
||||
}
|
||||
}
|
||||
} else if (type == 3) {
|
||||
TLRPC.TL_chatParticipant part = info.participants.get(sortedUsers.get(i - membersSectionRow - 1));
|
||||
@ -828,12 +652,6 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
|
||||
}
|
||||
|
||||
((ChatOrUserCell)view).setData(user, null, null, null, null);
|
||||
|
||||
// if (info.admin_id != UserConfig.clientUserId && part.inviter_id != UserConfig.clientUserId && part.user_id != UserConfig.clientUserId) {
|
||||
//
|
||||
// } else {
|
||||
//
|
||||
// }
|
||||
} else if (type == 4) {
|
||||
if (view == null) {
|
||||
LayoutInflater li = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
@ -870,39 +688,14 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
|
||||
} else if (type == 6) {
|
||||
if (view == null) {
|
||||
LayoutInflater li = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
view = li.inflate(R.layout.settings_row_detail_layout, viewGroup, false);
|
||||
view = li.inflate(R.layout.settings_row_button_layout, viewGroup, false);
|
||||
}
|
||||
TextView textView = (TextView)view.findViewById(R.id.settings_row_text);
|
||||
TextView detailTextView = (TextView)view.findViewById(R.id.settings_row_text_detail);
|
||||
View divider = view.findViewById(R.id.settings_row_divider);
|
||||
if (i == settingsSoundRow) {
|
||||
SharedPreferences preferences = mContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
||||
String name = preferences.getString("sound_chat_" + chat_id, LocaleController.getString("Default", R.string.Default));
|
||||
if (name.equals("NoSound")) {
|
||||
detailTextView.setText(LocaleController.getString("NoSound", R.string.NoSound));
|
||||
} else {
|
||||
detailTextView.setText(name);
|
||||
}
|
||||
textView.setText(LocaleController.getString("Sound", R.string.Sound));
|
||||
if (i == settingsNotificationsRow) {
|
||||
textView.setText(LocaleController.getString("NotificationsAndSounds", R.string.NotificationsAndSounds));
|
||||
divider.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
} else if (type == 7) {
|
||||
if (view == null) {
|
||||
LayoutInflater li = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
view = li.inflate(R.layout.settings_row_color_layout, viewGroup, false);
|
||||
}
|
||||
TextView textView = (TextView)view.findViewById(R.id.settings_row_text);
|
||||
View colorView = view.findViewById(R.id.settings_color);
|
||||
View divider = view.findViewById(R.id.settings_row_divider);
|
||||
textView.setText(LocaleController.getString("LedColor", R.string.LedColor));
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
||||
|
||||
if (preferences.contains("color_" + (-chat_id))) {
|
||||
colorView.setBackgroundColor(preferences.getInt("color_" + (-chat_id), 0xff00ff00));
|
||||
} else {
|
||||
colorView.setBackgroundColor(preferences.getInt("GroupLed", 0xff00ff00));
|
||||
}
|
||||
divider.setVisibility(View.VISIBLE);
|
||||
}
|
||||
return view;
|
||||
}
|
||||
@ -913,25 +706,23 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
|
||||
return 0;
|
||||
} else if (i == settingsSectionRow || i == sharedMediaSectionRow || i == membersSectionRow) {
|
||||
return 1;
|
||||
} else if (i == sharedMediaRow || i == settingsVibrateRow || i == settingsNotificationsRow) {
|
||||
} else if (i == sharedMediaRow) {
|
||||
return 2;
|
||||
} else if (i == settingsSoundRow) {
|
||||
return 6;
|
||||
} else if (i == addMemberRow) {
|
||||
return 4;
|
||||
} else if (i == leaveGroupRow) {
|
||||
return 5;
|
||||
} else if (i > membersSectionRow && i < membersEndRow) {
|
||||
return 3;
|
||||
} else if (i == settingsLedRow) {
|
||||
return 7;
|
||||
} else if (i == settingsNotificationsRow) {
|
||||
return 6;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getViewTypeCount() {
|
||||
return 8;
|
||||
return 7;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -22,6 +22,7 @@ import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.Utilities;
|
||||
import org.telegram.ui.Adapters.BaseFragmentAdapter;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarLayer;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarMenuItem;
|
||||
@ -321,7 +322,7 @@ public class CountrySelectActivity extends BaseFragment {
|
||||
});
|
||||
}
|
||||
|
||||
private class SearchAdapter extends BaseAdapter {
|
||||
private class SearchAdapter extends BaseFragmentAdapter {
|
||||
private Context mContext;
|
||||
|
||||
public SearchAdapter(Context context) {
|
||||
|
@ -20,7 +20,6 @@ import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
@ -28,6 +27,7 @@ import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.Utilities;
|
||||
import org.telegram.ui.Adapters.BaseFragmentAdapter;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarLayer;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarMenuItem;
|
||||
@ -387,7 +387,7 @@ public class DocumentSelectActivity extends BaseFragment {
|
||||
return LocaleController.formatString("FreeOfTotal", R.string.FreeOfTotal, Utilities.formatFileSize(free), Utilities.formatFileSize(total));
|
||||
}
|
||||
|
||||
private class ListAdapter extends BaseAdapter {
|
||||
private class ListAdapter extends BaseFragmentAdapter {
|
||||
private Context mContext;
|
||||
|
||||
public ListAdapter(Context context) {
|
||||
|
@ -10,6 +10,7 @@ package org.telegram.ui;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.database.DataSetObserver;
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcelable;
|
||||
import android.support.v4.view.PagerAdapter;
|
||||
@ -283,5 +284,12 @@ public class IntroActivity extends Activity {
|
||||
@Override
|
||||
public void startUpdate(View arg0) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregisterDataSetObserver(DataSetObserver observer) {
|
||||
if (observer != null) {
|
||||
super.unregisterDataSetObserver(observer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,6 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AbsListView;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
@ -25,6 +24,7 @@ import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.Utilities;
|
||||
import org.telegram.ui.Adapters.BaseFragmentAdapter;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarLayer;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarMenuItem;
|
||||
@ -35,11 +35,11 @@ import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
public class LanguageSelectActivity extends BaseFragment {
|
||||
private BaseAdapter listAdapter;
|
||||
private BaseFragmentAdapter listAdapter;
|
||||
private ListView listView;
|
||||
private boolean searchWas;
|
||||
private boolean searching;
|
||||
private BaseAdapter searchListViewAdapter;
|
||||
private BaseFragmentAdapter searchListViewAdapter;
|
||||
private TextView emptyTextView;
|
||||
|
||||
private Timer searchTimer;
|
||||
@ -265,7 +265,7 @@ public class LanguageSelectActivity extends BaseFragment {
|
||||
});
|
||||
}
|
||||
|
||||
private class SearchAdapter extends BaseAdapter {
|
||||
private class SearchAdapter extends BaseFragmentAdapter {
|
||||
private Context mContext;
|
||||
|
||||
public SearchAdapter(Context context) {
|
||||
@ -341,7 +341,7 @@ public class LanguageSelectActivity extends BaseFragment {
|
||||
}
|
||||
}
|
||||
|
||||
private class ListAdapter extends BaseAdapter {
|
||||
private class ListAdapter extends BaseFragmentAdapter {
|
||||
private Context mContext;
|
||||
|
||||
public ListAdapter(Context context) {
|
||||
|
@ -30,7 +30,6 @@ import org.telegram.PhoneFormat.PhoneFormat;
|
||||
import org.telegram.messenger.ConnectionsManager;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.messenger.MediaController;
|
||||
import org.telegram.messenger.MessagesController;
|
||||
import org.telegram.messenger.NotificationCenter;
|
||||
import org.telegram.messenger.R;
|
||||
@ -51,12 +50,11 @@ import java.util.Map;
|
||||
public class LaunchActivity extends ActionBarActivity implements NotificationCenter.NotificationCenterDelegate, MessagesActivity.MessagesActivityDelegate {
|
||||
private boolean finished = false;
|
||||
private NotificationView notificationView;
|
||||
private Uri photoPath = null;
|
||||
private String videoPath = null;
|
||||
private String sendingText = null;
|
||||
private String documentPath = null;
|
||||
private ArrayList<Uri> imagesPathArray = null;
|
||||
private ArrayList<String> documentsPathArray = null;
|
||||
private ArrayList<Uri> photoPathsArray = null;
|
||||
private ArrayList<String> documentsPathsArray = null;
|
||||
private ArrayList<String> documentsOriginalPathsArray = null;
|
||||
private ArrayList<TLRPC.User> contactsToSend = null;
|
||||
private int currentConnectionState;
|
||||
|
||||
@ -162,15 +160,14 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
|
||||
Integer push_enc_id = 0;
|
||||
Integer open_settings = 0;
|
||||
|
||||
photoPath = null;
|
||||
photoPathsArray = null;
|
||||
videoPath = null;
|
||||
sendingText = null;
|
||||
documentPath = null;
|
||||
imagesPathArray = null;
|
||||
documentsPathArray = null;
|
||||
documentsPathsArray = null;
|
||||
documentsOriginalPathsArray = null;
|
||||
contactsToSend = null;
|
||||
|
||||
if ((intent.getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) == 0) {
|
||||
|
||||
if (intent != null && intent.getAction() != null && !restore) {
|
||||
if (Intent.ACTION_SEND.equals(intent.getAction())) {
|
||||
boolean error = false;
|
||||
@ -273,19 +270,10 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
|
||||
Uri uri = (Uri) parcelable;
|
||||
if (uri != null && type != null && type.startsWith("image/")) {
|
||||
String tempPath = Utilities.getPath(uri);
|
||||
boolean isGif = false;
|
||||
if (tempPath != null && tempPath.endsWith(".gif")) {
|
||||
isGif = true;
|
||||
documentPath = tempPath;
|
||||
} else if (tempPath == null) {
|
||||
isGif = MediaController.isGif(uri);
|
||||
if (isGif) {
|
||||
documentPath = MediaController.copyDocumentToCache(uri, "gif");
|
||||
}
|
||||
}
|
||||
if (!isGif || documentPath == null) {
|
||||
photoPath = uri;
|
||||
if (photoPathsArray == null) {
|
||||
photoPathsArray = new ArrayList<Uri>();
|
||||
}
|
||||
photoPathsArray.add(uri);
|
||||
} else {
|
||||
path = Utilities.getPath(uri);
|
||||
if (path != null) {
|
||||
@ -295,7 +283,12 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
|
||||
if (type != null && type.startsWith("video/")) {
|
||||
videoPath = path;
|
||||
} else {
|
||||
documentPath = path;
|
||||
if (documentsPathsArray == null) {
|
||||
documentsPathsArray = new ArrayList<String>();
|
||||
documentsOriginalPathsArray = new ArrayList<String>();
|
||||
}
|
||||
documentsPathsArray.add(path);
|
||||
documentsOriginalPathsArray.add(uri.toString());
|
||||
}
|
||||
} else {
|
||||
error = true;
|
||||
@ -317,32 +310,10 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
|
||||
parcelable = Uri.parse(parcelable.toString());
|
||||
}
|
||||
Uri uri = (Uri) parcelable;
|
||||
String tempPath = Utilities.getPath(uri);
|
||||
|
||||
boolean isGif = false;
|
||||
if (tempPath != null && tempPath.endsWith(".gif")) {
|
||||
isGif = true;
|
||||
} else if (tempPath == null) {
|
||||
isGif = MediaController.isGif(uri);
|
||||
if (isGif) {
|
||||
tempPath = MediaController.copyDocumentToCache(uri, "gif");
|
||||
}
|
||||
}
|
||||
if (isGif && tempPath != null) {
|
||||
if (documentsPathArray == null) {
|
||||
documentsPathArray = new ArrayList<String>();
|
||||
}
|
||||
try {
|
||||
documentsPathArray.add(tempPath);
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
} else {
|
||||
if (imagesPathArray == null) {
|
||||
imagesPathArray = new ArrayList<Uri>();
|
||||
}
|
||||
imagesPathArray.add(uri);
|
||||
if (photoPathsArray == null) {
|
||||
photoPathsArray = new ArrayList<Uri>();
|
||||
}
|
||||
photoPathsArray.add(uri);
|
||||
}
|
||||
} else {
|
||||
for (Parcelable parcelable : uris) {
|
||||
@ -350,14 +321,20 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
|
||||
parcelable = Uri.parse(parcelable.toString());
|
||||
}
|
||||
String path = Utilities.getPath((Uri) parcelable);
|
||||
String originalPath = parcelable.toString();
|
||||
if (originalPath == null) {
|
||||
originalPath = path;
|
||||
}
|
||||
if (path != null) {
|
||||
if (path.startsWith("file:")) {
|
||||
path = path.replace("file://", "");
|
||||
}
|
||||
if (documentsPathArray == null) {
|
||||
documentsPathArray = new ArrayList<String>();
|
||||
if (documentsPathsArray == null) {
|
||||
documentsPathsArray = new ArrayList<String>();
|
||||
documentsOriginalPathsArray = new ArrayList<String>();
|
||||
}
|
||||
documentsPathArray.add(path);
|
||||
documentsPathsArray.add(path);
|
||||
documentsOriginalPathsArray.add(originalPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -442,7 +419,7 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
|
||||
pushOpened = true;
|
||||
}
|
||||
}
|
||||
if (videoPath != null || photoPath != null || sendingText != null || documentPath != null || documentsPathArray != null || imagesPathArray != null || contactsToSend != null) {
|
||||
if (videoPath != null || photoPathsArray != null || sendingText != null || documentsPathsArray != null || contactsToSend != null) {
|
||||
NotificationCenter.getInstance().postNotificationName(MessagesController.closeChats);
|
||||
Bundle args = new Bundle();
|
||||
args.putBoolean("onlySelect", true);
|
||||
@ -488,37 +465,29 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
|
||||
}
|
||||
ChatActivity fragment = new ChatActivity(args);
|
||||
presentFragment(fragment, true);
|
||||
if (photoPath != null) {
|
||||
fragment.processSendingPhoto(null, photoPath);
|
||||
}
|
||||
if (videoPath != null) {
|
||||
fragment.processSendingVideo(videoPath);
|
||||
}
|
||||
if (sendingText != null) {
|
||||
fragment.processSendingText(sendingText);
|
||||
}
|
||||
if (documentPath != null) {
|
||||
fragment.processSendingDocument(documentPath, null);
|
||||
if (photoPathsArray != null) {
|
||||
fragment.processSendingPhotos(null, photoPathsArray);
|
||||
}
|
||||
if (imagesPathArray != null) {
|
||||
fragment.processSendingPhotos(null, imagesPathArray);
|
||||
}
|
||||
if (documentsPathArray != null) {
|
||||
for (String path : documentsPathArray) {
|
||||
fragment.processSendingDocument(path, null);
|
||||
}
|
||||
if (documentsPathsArray != null) {
|
||||
fragment.processSendingDocuments(documentsPathsArray, documentsOriginalPathsArray);
|
||||
}
|
||||
if (contactsToSend != null && !contactsToSend.isEmpty()) {
|
||||
for (TLRPC.User user : contactsToSend) {
|
||||
MessagesController.getInstance().sendMessage(user, dialog_id);
|
||||
}
|
||||
}
|
||||
photoPath = null;
|
||||
|
||||
photoPathsArray = null;
|
||||
videoPath = null;
|
||||
sendingText = null;
|
||||
documentPath = null;
|
||||
imagesPathArray = null;
|
||||
documentsPathArray = null;
|
||||
documentsPathsArray = null;
|
||||
documentsOriginalPathsArray = null;
|
||||
contactsToSend = null;
|
||||
}
|
||||
}
|
||||
@ -602,7 +571,7 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
|
||||
int rotation = manager.getDefaultDisplay().getRotation();
|
||||
|
||||
int height = Utilities.dp(48);
|
||||
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
if (!Utilities.isTablet(this) && getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
height = Utilities.dp(40);
|
||||
}
|
||||
notificationView.applyOrientationPaddings(rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90, height);
|
||||
|
@ -20,7 +20,6 @@ import android.view.ViewTreeObserver;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.AbsListView;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.GridView;
|
||||
import android.widget.TextView;
|
||||
|
||||
@ -32,6 +31,7 @@ import org.telegram.messenger.MessagesController;
|
||||
import org.telegram.messenger.NotificationCenter;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.objects.PhotoObject;
|
||||
import org.telegram.ui.Adapters.BaseFragmentAdapter;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarLayer;
|
||||
import org.telegram.ui.Views.BackupImageView;
|
||||
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
||||
@ -347,7 +347,7 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
|
||||
}
|
||||
}
|
||||
|
||||
private class ListAdapter extends BaseAdapter {
|
||||
private class ListAdapter extends BaseFragmentAdapter {
|
||||
private Context mContext;
|
||||
|
||||
public ListAdapter(Context context) {
|
||||
|
@ -17,7 +17,6 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AbsListView;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
@ -33,6 +32,7 @@ import org.telegram.messenger.NotificationCenter;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.UserConfig;
|
||||
import org.telegram.messenger.Utilities;
|
||||
import org.telegram.ui.Adapters.BaseFragmentAdapter;
|
||||
import org.telegram.ui.Cells.ChatOrUserCell;
|
||||
import org.telegram.ui.Cells.DialogCell;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarLayer;
|
||||
@ -558,7 +558,7 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
||||
}
|
||||
}
|
||||
|
||||
private class MessagesAdapter extends BaseAdapter {
|
||||
private class MessagesAdapter extends BaseFragmentAdapter {
|
||||
private Context mContext;
|
||||
|
||||
public MessagesAdapter(Context context) {
|
||||
|
@ -18,7 +18,6 @@ import android.view.ViewGroup;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.GridView;
|
||||
import android.widget.ImageView;
|
||||
@ -32,6 +31,7 @@ import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.messenger.Utilities;
|
||||
import org.telegram.objects.MessageObject;
|
||||
import org.telegram.ui.Adapters.BaseFragmentAdapter;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarLayer;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
||||
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
||||
@ -441,7 +441,7 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen
|
||||
}
|
||||
}
|
||||
|
||||
private class ListAdapter extends BaseAdapter {
|
||||
private class ListAdapter extends BaseFragmentAdapter {
|
||||
private Context mContext;
|
||||
|
||||
public ListAdapter(Context context) {
|
||||
|
@ -1723,7 +1723,9 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
if (velocityTracker != null) {
|
||||
velocityTracker.addMovement(ev);
|
||||
}
|
||||
if (canDragDown && !draggingDown && scale == 1 && Math.abs(ev.getY() - dragY) >= Utilities.dp(30)) {
|
||||
float dx = Math.abs(ev.getX() - moveStartX);
|
||||
float dy = Math.abs(ev.getY() - dragY);
|
||||
if (canDragDown && !draggingDown && scale == 1 && dy >= Utilities.dp(30) && dy / 2 > dx) {
|
||||
draggingDown = true;
|
||||
moving = false;
|
||||
dragY = ev.getY();
|
||||
|
@ -0,0 +1,392 @@
|
||||
/*
|
||||
* This is the source code of Telegram for Android v. 1.4.x.
|
||||
* It is licensed under GNU GPL v. 2 or later.
|
||||
* You should have received a copy of the license in this archive (see LICENSE).
|
||||
*
|
||||
* Copyright Nikolai Kudashov, 2013-2014.
|
||||
*/
|
||||
|
||||
package org.telegram.ui;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.media.Ringtone;
|
||||
import android.media.RingtoneManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.ui.Adapters.BaseFragmentAdapter;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarLayer;
|
||||
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
||||
import org.telegram.ui.Views.ColorPickerView;
|
||||
|
||||
public class ProfileNotificationsActivity extends BaseFragment {
|
||||
|
||||
private ListView listView;
|
||||
private long dialog_id;
|
||||
|
||||
private int settingsNotificationsRow;
|
||||
private int settingsVibrateRow;
|
||||
private int settingsSoundRow;
|
||||
private int settingsLedRow;
|
||||
private int rowCount = 0;
|
||||
|
||||
public ProfileNotificationsActivity(Bundle args) {
|
||||
super(args);
|
||||
dialog_id = args.getLong("dialog_id");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFragmentDestroy() {
|
||||
super.onFragmentDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onFragmentCreate() {
|
||||
settingsNotificationsRow = rowCount++;
|
||||
settingsVibrateRow = rowCount++;
|
||||
settingsLedRow = rowCount++;
|
||||
settingsSoundRow = rowCount++;
|
||||
return super.onFragmentCreate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public View createView(LayoutInflater inflater, ViewGroup container) {
|
||||
if (fragmentView == null) {
|
||||
actionBarLayer.setDisplayHomeAsUpEnabled(true, R.drawable.ic_ab_back);
|
||||
actionBarLayer.setBackOverlay(R.layout.updating_state_layout);
|
||||
|
||||
actionBarLayer.setTitle(LocaleController.getString("NotificationsAndSounds", R.string.NotificationsAndSounds));
|
||||
|
||||
actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() {
|
||||
@Override
|
||||
public void onItemClick(int id) {
|
||||
if (id == -1) {
|
||||
finishFragment();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
fragmentView = inflater.inflate(R.layout.settings_layout, container, false);
|
||||
|
||||
listView = (ListView)fragmentView.findViewById(R.id.listView);
|
||||
listView.setAdapter(new ListAdapter(getParentActivity()));
|
||||
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> adapterView, View view, final int i, long l) {
|
||||
if (i == settingsVibrateRow || i == settingsNotificationsRow) {
|
||||
if (getParentActivity() == null) {
|
||||
return;
|
||||
}
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
||||
builder.setItems(new CharSequence[] {
|
||||
LocaleController.getString("Default", R.string.Default),
|
||||
LocaleController.getString("Enabled", R.string.Enabled),
|
||||
LocaleController.getString("Disabled", R.string.Disabled)
|
||||
}, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
if (i == settingsVibrateRow) {
|
||||
editor.putInt("vibrate_" + dialog_id, which);
|
||||
} else if (i == settingsNotificationsRow) {
|
||||
editor.putInt("notify2_" + dialog_id, which);
|
||||
}
|
||||
editor.commit();
|
||||
if (listView != null) {
|
||||
listView.invalidateViews();
|
||||
}
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
||||
showAlertDialog(builder);
|
||||
} else if (i == settingsSoundRow) {
|
||||
try {
|
||||
Intent tmpIntent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
|
||||
tmpIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_NOTIFICATION);
|
||||
tmpIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true);
|
||||
tmpIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_DEFAULT_URI, RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION));
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
||||
Uri currentSound = null;
|
||||
|
||||
String defaultPath = null;
|
||||
Uri defaultUri = Settings.System.DEFAULT_NOTIFICATION_URI;
|
||||
if (defaultUri != null) {
|
||||
defaultPath = defaultUri.getPath();
|
||||
}
|
||||
|
||||
String path = preferences.getString("sound_path_" + dialog_id, defaultPath);
|
||||
if (path != null && !path.equals("NoSound")) {
|
||||
if (path.equals(defaultPath)) {
|
||||
currentSound = defaultUri;
|
||||
} else {
|
||||
currentSound = Uri.parse(path);
|
||||
}
|
||||
}
|
||||
|
||||
tmpIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, currentSound);
|
||||
getParentActivity().startActivityForResult(tmpIntent, 12);
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
} else if (i == settingsLedRow) {
|
||||
if (getParentActivity() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
LayoutInflater li = (LayoutInflater)getParentActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
view = li.inflate(R.layout.settings_color_dialog_layout, null, false);
|
||||
final ColorPickerView colorPickerView = (ColorPickerView)view.findViewById(R.id.color_picker);
|
||||
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
||||
if (preferences.contains("color_" + dialog_id)) {
|
||||
colorPickerView.setOldCenterColor(preferences.getInt("color_" + dialog_id, 0xff00ff00));
|
||||
} else {
|
||||
if ((int)dialog_id < 0) {
|
||||
colorPickerView.setOldCenterColor(preferences.getInt("GroupLed", 0xff00ff00));
|
||||
} else {
|
||||
colorPickerView.setOldCenterColor(preferences.getInt("MessagesLed", 0xff00ff00));
|
||||
}
|
||||
}
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||
builder.setTitle(LocaleController.getString("LedColor", R.string.LedColor));
|
||||
builder.setView(view);
|
||||
builder.setPositiveButton(LocaleController.getString("Set", R.string.Set), new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int which) {
|
||||
final SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putInt("color_" + dialog_id, colorPickerView.getColor());
|
||||
editor.commit();
|
||||
listView.invalidateViews();
|
||||
}
|
||||
});
|
||||
builder.setNeutralButton(LocaleController.getString("Disabled", R.string.Disabled), new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
final SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putInt("color_" + dialog_id, 0);
|
||||
editor.commit();
|
||||
listView.invalidateViews();
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(LocaleController.getString("Default", R.string.Default), new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
final SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.remove("color_" + dialog_id);
|
||||
editor.commit();
|
||||
listView.invalidateViews();
|
||||
}
|
||||
});
|
||||
showAlertDialog(builder);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
ViewGroup parent = (ViewGroup)fragmentView.getParent();
|
||||
if (parent != null) {
|
||||
parent.removeView(fragmentView);
|
||||
}
|
||||
}
|
||||
return fragmentView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResultFragment(int requestCode, int resultCode, Intent data) {
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
if (data == null) {
|
||||
return;
|
||||
}
|
||||
Uri ringtone = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
|
||||
String name = null;
|
||||
if (ringtone != null) {
|
||||
Ringtone rng = RingtoneManager.getRingtone(ApplicationLoader.applicationContext, ringtone);
|
||||
if (rng != null) {
|
||||
if(ringtone.equals(Settings.System.DEFAULT_NOTIFICATION_URI)) {
|
||||
name = LocaleController.getString("Default", R.string.Default);
|
||||
} else {
|
||||
name = rng.getTitle(getParentActivity());
|
||||
}
|
||||
rng.stop();
|
||||
}
|
||||
}
|
||||
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
|
||||
if (requestCode == 12) {
|
||||
if (name != null && ringtone != null) {
|
||||
editor.putString("sound_" + dialog_id, name);
|
||||
editor.putString("sound_path_" + dialog_id, ringtone.toString());
|
||||
} else {
|
||||
editor.putString("sound_" + dialog_id, "NoSound");
|
||||
editor.putString("sound_path_" + dialog_id, "NoSound");
|
||||
}
|
||||
}
|
||||
editor.commit();
|
||||
listView.invalidateViews();
|
||||
}
|
||||
}
|
||||
|
||||
private class ListAdapter extends BaseFragmentAdapter {
|
||||
private Context mContext;
|
||||
|
||||
public ListAdapter(Context context) {
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean areAllItemsEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(int i) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return rowCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int i) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int i) {
|
||||
return i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasStableIds() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int i, View view, ViewGroup viewGroup) {
|
||||
int type = getItemViewType(i);
|
||||
if (type == 0) {
|
||||
if (view == null) {
|
||||
LayoutInflater li = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
view = li.inflate(R.layout.user_profile_leftright_row_layout, viewGroup, false);
|
||||
}
|
||||
TextView textView = (TextView)view.findViewById(R.id.settings_row_text);
|
||||
TextView detailTextView = (TextView)view.findViewById(R.id.settings_row_text_detail);
|
||||
|
||||
View divider = view.findViewById(R.id.settings_row_divider);
|
||||
if (i == settingsVibrateRow) {
|
||||
textView.setText(LocaleController.getString("Vibrate", R.string.Vibrate));
|
||||
divider.setVisibility(View.VISIBLE);
|
||||
SharedPreferences preferences = mContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
||||
int value = preferences.getInt("vibrate_" + dialog_id, 0);
|
||||
if (value == 0) {
|
||||
detailTextView.setText(LocaleController.getString("Default", R.string.Default));
|
||||
} else if (value == 1) {
|
||||
detailTextView.setText(LocaleController.getString("Enabled", R.string.Enabled));
|
||||
} else if (value == 2) {
|
||||
detailTextView.setText(LocaleController.getString("Disabled", R.string.Disabled));
|
||||
}
|
||||
} else if (i == settingsNotificationsRow) {
|
||||
textView.setText(LocaleController.getString("Notifications", R.string.Notifications));
|
||||
divider.setVisibility(View.VISIBLE);
|
||||
SharedPreferences preferences = mContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
||||
int value = preferences.getInt("notify2_" + dialog_id, 0);
|
||||
if (value == 0) {
|
||||
detailTextView.setText(LocaleController.getString("Default", R.string.Default));
|
||||
} else if (value == 1) {
|
||||
detailTextView.setText(LocaleController.getString("Enabled", R.string.Enabled));
|
||||
} else if (value == 2) {
|
||||
detailTextView.setText(LocaleController.getString("Disabled", R.string.Disabled));
|
||||
}
|
||||
}
|
||||
} if (type == 1) {
|
||||
if (view == null) {
|
||||
LayoutInflater li = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
view = li.inflate(R.layout.settings_row_detail_layout, viewGroup, false);
|
||||
}
|
||||
TextView textView = (TextView)view.findViewById(R.id.settings_row_text);
|
||||
TextView detailTextView = (TextView)view.findViewById(R.id.settings_row_text_detail);
|
||||
|
||||
View divider = view.findViewById(R.id.settings_row_divider);
|
||||
if (i == settingsSoundRow) {
|
||||
SharedPreferences preferences = mContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
||||
String name = preferences.getString("sound_" + dialog_id, LocaleController.getString("Default", R.string.Default));
|
||||
if (name.equals("NoSound")) {
|
||||
detailTextView.setText(LocaleController.getString("NoSound", R.string.NoSound));
|
||||
} else {
|
||||
detailTextView.setText(name);
|
||||
}
|
||||
textView.setText(LocaleController.getString("Sound", R.string.Sound));
|
||||
divider.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
} else if (type == 2) {
|
||||
if (view == null) {
|
||||
LayoutInflater li = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
view = li.inflate(R.layout.settings_row_color_layout, viewGroup, false);
|
||||
}
|
||||
TextView textView = (TextView)view.findViewById(R.id.settings_row_text);
|
||||
View colorView = view.findViewById(R.id.settings_color);
|
||||
View divider = view.findViewById(R.id.settings_row_divider);
|
||||
textView.setText(LocaleController.getString("LedColor", R.string.LedColor));
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
||||
|
||||
if (preferences.contains("color_" + dialog_id)) {
|
||||
colorView.setBackgroundColor(preferences.getInt("color_" + dialog_id, 0xff00ff00));
|
||||
} else {
|
||||
if ((int)dialog_id < 0) {
|
||||
colorView.setBackgroundColor(preferences.getInt("GroupLed", 0xff00ff00));
|
||||
} else {
|
||||
colorView.setBackgroundColor(preferences.getInt("MessagesLed", 0xff00ff00));
|
||||
}
|
||||
}
|
||||
divider.setVisibility(View.VISIBLE);
|
||||
}
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int i) {
|
||||
if (i == settingsNotificationsRow || i == settingsVibrateRow) {
|
||||
return 0;
|
||||
} else if (i == settingsSoundRow) {
|
||||
return 1;
|
||||
} else if (i == settingsLedRow) {
|
||||
return 2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getViewTypeCount() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@ -28,7 +28,6 @@ import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
@ -53,6 +52,7 @@ import org.telegram.messenger.UserConfig;
|
||||
import org.telegram.messenger.Utilities;
|
||||
import org.telegram.objects.MessageObject;
|
||||
import org.telegram.objects.PhotoObject;
|
||||
import org.telegram.ui.Adapters.BaseFragmentAdapter;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarLayer;
|
||||
import org.telegram.ui.Views.AvatarUpdater;
|
||||
import org.telegram.ui.Views.BackupImageView;
|
||||
@ -636,7 +636,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
||||
}
|
||||
}
|
||||
|
||||
private class ListAdapter extends BaseAdapter {
|
||||
private class ListAdapter extends BaseFragmentAdapter {
|
||||
private Context mContext;
|
||||
|
||||
public ListAdapter(Context context) {
|
||||
|
@ -16,7 +16,6 @@ import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
@ -30,6 +29,7 @@ import org.telegram.messenger.NotificationCenter;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.RPCRequest;
|
||||
import org.telegram.messenger.Utilities;
|
||||
import org.telegram.ui.Adapters.BaseFragmentAdapter;
|
||||
import org.telegram.ui.Cells.ChatOrUserCell;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarLayer;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
||||
@ -276,7 +276,7 @@ public class SettingsBlockedUsers extends BaseFragment implements NotificationCe
|
||||
}, null, true, RPCRequest.RPCRequestClassGeneric);
|
||||
}
|
||||
|
||||
private class ListAdapter extends BaseAdapter {
|
||||
private class ListAdapter extends BaseFragmentAdapter {
|
||||
private Context mContext;
|
||||
|
||||
public ListAdapter(Context context) {
|
||||
|
@ -22,7 +22,6 @@ import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
@ -37,6 +36,7 @@ import org.telegram.messenger.MessagesController;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.RPCRequest;
|
||||
import org.telegram.messenger.Utilities;
|
||||
import org.telegram.ui.Adapters.BaseFragmentAdapter;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarLayer;
|
||||
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
||||
import org.telegram.ui.Views.ColorPickerView;
|
||||
@ -396,7 +396,7 @@ public class SettingsNotificationsActivity extends BaseFragment {
|
||||
}
|
||||
}
|
||||
|
||||
private class ListAdapter extends BaseAdapter {
|
||||
private class ListAdapter extends BaseFragmentAdapter {
|
||||
private Context mContext;
|
||||
|
||||
public ListAdapter(Context context) {
|
||||
|
@ -24,7 +24,6 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ProgressBar;
|
||||
@ -42,6 +41,7 @@ import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.RPCRequest;
|
||||
import org.telegram.messenger.Utilities;
|
||||
import org.telegram.objects.PhotoObject;
|
||||
import org.telegram.ui.Adapters.BaseFragmentAdapter;
|
||||
import org.telegram.ui.Views.BackupImageView;
|
||||
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
||||
import org.telegram.ui.Views.HorizontalListView;
|
||||
@ -111,7 +111,14 @@ public class SettingsWallpapersActivity extends BaseFragment implements Notifica
|
||||
boolean done;
|
||||
TLRPC.WallPaper wallPaper = wallpappersByIds.get(selectedBackground);
|
||||
if (wallPaper != null && wallPaper.id != 1000001 && wallPaper instanceof TLRPC.TL_wallPaper) {
|
||||
TLRPC.PhotoSize size = PhotoObject.getClosestPhotoSizeWithSize(wallPaper.sizes, Utilities.dp(320), Utilities.dp(480));
|
||||
int width = Utilities.displaySize.x;
|
||||
int height = Utilities.displaySize.y;
|
||||
if (width > height) {
|
||||
int temp = width;
|
||||
width = height;
|
||||
height = temp;
|
||||
}
|
||||
TLRPC.PhotoSize size = PhotoObject.getClosestPhotoSizeWithSize(wallPaper.sizes, width, height);
|
||||
String fileName = size.location.volume_id + "_" + size.location.local_id + ".jpg";
|
||||
File f = new File(Utilities.getCacheDir(), fileName);
|
||||
File toFile = new File(ApplicationLoader.applicationContext.getFilesDir(), "wallpaper.jpg");
|
||||
@ -254,7 +261,14 @@ public class SettingsWallpapersActivity extends BaseFragment implements Notifica
|
||||
private void processSelectedBackground() {
|
||||
TLRPC.WallPaper wallPaper = wallpappersByIds.get(selectedBackground);
|
||||
if (selectedBackground != -1 && selectedBackground != 1000001 && wallPaper != null && wallPaper instanceof TLRPC.TL_wallPaper) {
|
||||
TLRPC.PhotoSize size = PhotoObject.getClosestPhotoSizeWithSize(wallPaper.sizes, Utilities.dp(320), Utilities.dp(480));
|
||||
int width = Utilities.displaySize.x;
|
||||
int height = Utilities.displaySize.y;
|
||||
if (width > height) {
|
||||
int temp = width;
|
||||
width = height;
|
||||
height = temp;
|
||||
}
|
||||
TLRPC.PhotoSize size = PhotoObject.getClosestPhotoSizeWithSize(wallPaper.sizes, width, height);
|
||||
String fileName = size.location.volume_id + "_" + size.location.local_id + ".jpg";
|
||||
File f = new File(Utilities.getCacheDir(), fileName);
|
||||
if (!f.exists()) {
|
||||
@ -435,7 +449,7 @@ public class SettingsWallpapersActivity extends BaseFragment implements Notifica
|
||||
fixLayout();
|
||||
}
|
||||
|
||||
private class ListAdapter extends BaseAdapter {
|
||||
private class ListAdapter extends BaseFragmentAdapter {
|
||||
private Context mContext;
|
||||
|
||||
public ListAdapter(Context context) {
|
||||
|
@ -8,23 +8,17 @@
|
||||
|
||||
package org.telegram.ui;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Typeface;
|
||||
import android.media.Ringtone;
|
||||
import android.media.RingtoneManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
@ -43,12 +37,12 @@ import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.RPCRequest;
|
||||
import org.telegram.messenger.Utilities;
|
||||
import org.telegram.objects.MessageObject;
|
||||
import org.telegram.ui.Adapters.BaseFragmentAdapter;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarLayer;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarMenuItem;
|
||||
import org.telegram.ui.Views.BackupImageView;
|
||||
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
||||
import org.telegram.ui.Views.ColorPickerView;
|
||||
import org.telegram.ui.Views.IdenticonView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -76,11 +70,8 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
|
||||
private int settingsTimerRow;
|
||||
private int settingsKeyRow;
|
||||
private int settingsNotificationsRow;
|
||||
private int settingsVibrateRow;
|
||||
private int settingsSoundRow;
|
||||
private int sharedMediaSectionRow;
|
||||
private int sharedMediaRow;
|
||||
private int settingsLedRow;
|
||||
private int rowCount = 0;
|
||||
|
||||
public UserProfileActivity(Bundle args) {
|
||||
@ -127,9 +118,6 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
|
||||
settingsKeyRow = -1;
|
||||
}
|
||||
settingsNotificationsRow = rowCount++;
|
||||
settingsVibrateRow = rowCount++;
|
||||
settingsLedRow = rowCount++;
|
||||
settingsSoundRow = rowCount++;
|
||||
sharedMediaSectionRow = rowCount++;
|
||||
sharedMediaRow = rowCount++;
|
||||
}
|
||||
@ -254,72 +242,7 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
|
||||
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> adapterView, View view, final int i, long l) {
|
||||
if (i == settingsVibrateRow || i == settingsNotificationsRow) {
|
||||
if (getParentActivity() == null) {
|
||||
return;
|
||||
}
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
||||
builder.setItems(new CharSequence[] {
|
||||
LocaleController.getString("Default", R.string.Default),
|
||||
LocaleController.getString("Enabled", R.string.Enabled),
|
||||
LocaleController.getString("Disabled", R.string.Disabled)
|
||||
}, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
if (i == settingsVibrateRow) {
|
||||
if (dialog_id == 0) {
|
||||
editor.putInt("vibrate_" + user_id, which);
|
||||
} else {
|
||||
editor.putInt("vibrate_" + dialog_id, which);
|
||||
}
|
||||
} else if (i == settingsNotificationsRow) {
|
||||
if (dialog_id == 0) {
|
||||
editor.putInt("notify2_" + user_id, which);
|
||||
} else {
|
||||
editor.putInt("notify2_" + dialog_id, which);
|
||||
}
|
||||
}
|
||||
editor.commit();
|
||||
if (listView != null) {
|
||||
listView.invalidateViews();
|
||||
}
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
||||
showAlertDialog(builder);
|
||||
} else if (i == settingsSoundRow) {
|
||||
try {
|
||||
Intent tmpIntent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
|
||||
tmpIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_NOTIFICATION);
|
||||
tmpIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true);
|
||||
tmpIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_DEFAULT_URI, RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION));
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
||||
Uri currentSound = null;
|
||||
|
||||
String defaultPath = null;
|
||||
Uri defaultUri = Settings.System.DEFAULT_NOTIFICATION_URI;
|
||||
if (defaultUri != null) {
|
||||
defaultPath = defaultUri.getPath();
|
||||
}
|
||||
|
||||
String path = preferences.getString("sound_path_" + user_id, defaultPath);
|
||||
if (path != null && !path.equals("NoSound")) {
|
||||
if (path.equals(defaultPath)) {
|
||||
currentSound = defaultUri;
|
||||
} else {
|
||||
currentSound = Uri.parse(path);
|
||||
}
|
||||
}
|
||||
|
||||
tmpIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, currentSound);
|
||||
getParentActivity().startActivityForResult(tmpIntent, 12);
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
} else if (i == sharedMediaRow) {
|
||||
if (i == sharedMediaRow) {
|
||||
Bundle args = new Bundle();
|
||||
if (dialog_id != 0) {
|
||||
args.putLong("dialog_id", dialog_id);
|
||||
@ -376,57 +299,10 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
|
||||
});
|
||||
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
||||
showAlertDialog(builder);
|
||||
} else if (i == settingsLedRow) {
|
||||
if (getParentActivity() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
LayoutInflater li = (LayoutInflater)getParentActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
view = li.inflate(R.layout.settings_color_dialog_layout, null, false);
|
||||
final ColorPickerView colorPickerView = (ColorPickerView)view.findViewById(R.id.color_picker);
|
||||
|
||||
final String key = dialog_id == 0 ? "color_" + user_id : "color_" + dialog_id;
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
||||
if (preferences.contains(key)) {
|
||||
colorPickerView.setOldCenterColor(preferences.getInt(key, 0xff00ff00));
|
||||
} else {
|
||||
colorPickerView.setOldCenterColor(preferences.getInt("MessagesLed", 0xff00ff00));
|
||||
}
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||
builder.setTitle(LocaleController.getString("LedColor", R.string.LedColor));
|
||||
builder.setView(view);
|
||||
builder.setPositiveButton(LocaleController.getString("Set", R.string.Set), new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int which) {
|
||||
final SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putInt(key, colorPickerView.getColor());
|
||||
editor.commit();
|
||||
listView.invalidateViews();
|
||||
}
|
||||
});
|
||||
builder.setNeutralButton(LocaleController.getString("Disabled", R.string.Disabled), new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
final SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putInt(key, 0);
|
||||
editor.commit();
|
||||
listView.invalidateViews();
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(LocaleController.getString("Default", R.string.Default), new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
final SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.remove(key);
|
||||
editor.commit();
|
||||
listView.invalidateViews();
|
||||
}
|
||||
});
|
||||
showAlertDialog(builder);
|
||||
} else if (i == settingsNotificationsRow) {
|
||||
Bundle args = new Bundle();
|
||||
args.putLong("dialog_id", dialog_id == 0 ? user_id : dialog_id);
|
||||
presentFragment(new ProfileNotificationsActivity(args));
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -444,43 +320,6 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
|
||||
return fragmentView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResultFragment(int requestCode, int resultCode, Intent data) {
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
if (data == null) {
|
||||
return;
|
||||
}
|
||||
Uri ringtone = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
|
||||
String name = null;
|
||||
if (ringtone != null) {
|
||||
Ringtone rng = RingtoneManager.getRingtone(ApplicationLoader.applicationContext, ringtone);
|
||||
if (rng != null) {
|
||||
if(ringtone.equals(Settings.System.DEFAULT_NOTIFICATION_URI)) {
|
||||
name = LocaleController.getString("Default", R.string.Default);
|
||||
} else {
|
||||
name = rng.getTitle(getParentActivity());
|
||||
}
|
||||
rng.stop();
|
||||
}
|
||||
}
|
||||
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
|
||||
if (requestCode == 12) {
|
||||
if (name != null && ringtone != null) {
|
||||
editor.putString("sound_" + user_id, name);
|
||||
editor.putString("sound_path_" + user_id, ringtone.toString());
|
||||
} else {
|
||||
editor.putString("sound_" + user_id, "NoSound");
|
||||
editor.putString("sound_path_" + user_id, "NoSound");
|
||||
}
|
||||
}
|
||||
editor.commit();
|
||||
listView.invalidateViews();
|
||||
}
|
||||
}
|
||||
|
||||
public void didReceivedNotification(int id, Object... args) {
|
||||
if (id == MessagesController.updateInterfaces) {
|
||||
int mask = (Integer)args[0];
|
||||
@ -629,7 +468,7 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
|
||||
}
|
||||
}
|
||||
|
||||
private class ListAdapter extends BaseAdapter {
|
||||
private class ListAdapter extends BaseFragmentAdapter {
|
||||
private Context mContext;
|
||||
|
||||
public ListAdapter(Context context) {
|
||||
@ -643,7 +482,7 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(int i) {
|
||||
return i == phoneRow || i == settingsTimerRow || i == settingsKeyRow || i == settingsNotificationsRow || i == sharedMediaRow || i == settingsSoundRow || i == settingsVibrateRow || i == settingsLedRow;
|
||||
return i == phoneRow || i == settingsTimerRow || i == settingsKeyRow || i == settingsNotificationsRow || i == sharedMediaRow;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -829,44 +668,6 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
|
||||
} else {
|
||||
detailTextView.setText(String.format("%d", encryptedChat.ttl));
|
||||
}
|
||||
} else if (i == settingsVibrateRow) {
|
||||
textView.setText(LocaleController.getString("Vibrate", R.string.Vibrate));
|
||||
divider.setVisibility(View.VISIBLE);
|
||||
SharedPreferences preferences = mContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
||||
|
||||
String key;
|
||||
if (dialog_id == 0) {
|
||||
key = "vibrate_" + user_id;
|
||||
} else {
|
||||
key = "vibrate_" + dialog_id;
|
||||
}
|
||||
|
||||
int value = preferences.getInt(key, 0);
|
||||
if (value == 0) {
|
||||
detailTextView.setText(LocaleController.getString("Default", R.string.Default));
|
||||
} else if (value == 1) {
|
||||
detailTextView.setText(LocaleController.getString("Enabled", R.string.Enabled));
|
||||
} else if (value == 2) {
|
||||
detailTextView.setText(LocaleController.getString("Disabled", R.string.Disabled));
|
||||
}
|
||||
} else if (i == settingsNotificationsRow) {
|
||||
textView.setText(LocaleController.getString("Notifications", R.string.Notifications));
|
||||
divider.setVisibility(View.VISIBLE);
|
||||
SharedPreferences preferences = mContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
||||
String key;
|
||||
if (dialog_id == 0) {
|
||||
key = "notify2_" + user_id;
|
||||
} else {
|
||||
key = "notify2_" + dialog_id;
|
||||
}
|
||||
int value = preferences.getInt(key, 0);
|
||||
if (value == 0) {
|
||||
detailTextView.setText(LocaleController.getString("Default", R.string.Default));
|
||||
} else if (value == 1) {
|
||||
detailTextView.setText(LocaleController.getString("Enabled", R.string.Enabled));
|
||||
} else if (value == 2) {
|
||||
detailTextView.setText(LocaleController.getString("Disabled", R.string.Disabled));
|
||||
}
|
||||
}
|
||||
} else if (type == 4) {
|
||||
if (view == null) {
|
||||
@ -883,41 +684,14 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
|
||||
} else if (type == 5) {
|
||||
if (view == null) {
|
||||
LayoutInflater li = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
view = li.inflate(R.layout.settings_row_detail_layout, viewGroup, false);
|
||||
view = li.inflate(R.layout.settings_row_button_layout, viewGroup, false);
|
||||
}
|
||||
TextView textView = (TextView)view.findViewById(R.id.settings_row_text);
|
||||
TextView detailTextView = (TextView)view.findViewById(R.id.settings_row_text_detail);
|
||||
|
||||
View divider = view.findViewById(R.id.settings_row_divider);
|
||||
if (i == settingsSoundRow) {
|
||||
SharedPreferences preferences = mContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
||||
String name = preferences.getString("sound_" + user_id, LocaleController.getString("Default", R.string.Default));
|
||||
if (name.equals("NoSound")) {
|
||||
detailTextView.setText(LocaleController.getString("NoSound", R.string.NoSound));
|
||||
} else {
|
||||
detailTextView.setText(name);
|
||||
}
|
||||
textView.setText(LocaleController.getString("Sound", R.string.Sound));
|
||||
if (i == settingsNotificationsRow) {
|
||||
textView.setText(LocaleController.getString("NotificationsAndSounds", R.string.NotificationsAndSounds));
|
||||
divider.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
} else if (type == 6) {
|
||||
if (view == null) {
|
||||
LayoutInflater li = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
view = li.inflate(R.layout.settings_row_color_layout, viewGroup, false);
|
||||
}
|
||||
TextView textView = (TextView)view.findViewById(R.id.settings_row_text);
|
||||
View colorView = view.findViewById(R.id.settings_color);
|
||||
View divider = view.findViewById(R.id.settings_row_divider);
|
||||
textView.setText(LocaleController.getString("LedColor", R.string.LedColor));
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
||||
|
||||
String key = dialog_id == 0 ? "color_" + user_id : "color_" + dialog_id;
|
||||
if (preferences.contains(key)) {
|
||||
colorView.setBackgroundColor(preferences.getInt(key, 0xff00ff00));
|
||||
} else {
|
||||
colorView.setBackgroundColor(preferences.getInt("MessagesLed", 0xff00ff00));
|
||||
}
|
||||
divider.setVisibility(View.VISIBLE);
|
||||
}
|
||||
return view;
|
||||
}
|
||||
@ -930,21 +704,19 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
|
||||
return 1;
|
||||
} else if (i == phoneRow) {
|
||||
return 2;
|
||||
} else if (i == sharedMediaRow || i == settingsTimerRow || i == settingsNotificationsRow || i == settingsVibrateRow) {
|
||||
} else if (i == sharedMediaRow || i == settingsTimerRow) {
|
||||
return 3;
|
||||
} else if (i == settingsKeyRow) {
|
||||
return 4;
|
||||
} else if (i == settingsSoundRow) {
|
||||
} else if (i == settingsNotificationsRow) {
|
||||
return 5;
|
||||
} else if (i == settingsLedRow) {
|
||||
return 6;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getViewTypeCount() {
|
||||
return 7;
|
||||
return 6;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -170,7 +170,7 @@ public class ActionBar extends FrameLayout {
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
if (!Utilities.isTablet(getContext()) && getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(Utilities.dp(40), MeasureSpec.EXACTLY));
|
||||
} else {
|
||||
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(Utilities.dp(48), MeasureSpec.EXACTLY));
|
||||
|
@ -64,6 +64,7 @@ public class ActionBarActivity extends Activity {
|
||||
private boolean maybeStartTracking = false;
|
||||
protected boolean startedTracking = false;
|
||||
private int startedTrackingX;
|
||||
private int startedTrackingY;
|
||||
protected boolean animationInProgress = false;
|
||||
private VelocityTracker velocityTracker = null;
|
||||
private boolean beginTrackingSent = false;
|
||||
@ -272,6 +273,7 @@ public class ActionBarActivity extends Activity {
|
||||
startedTrackingPointerId = ev.getPointerId(0);
|
||||
maybeStartTracking = true;
|
||||
startedTrackingX = (int) ev.getX();
|
||||
startedTrackingY = (int) ev.getY();
|
||||
if (velocityTracker != null) {
|
||||
velocityTracker.clear();
|
||||
}
|
||||
@ -280,8 +282,9 @@ public class ActionBarActivity extends Activity {
|
||||
velocityTracker = VelocityTracker.obtain();
|
||||
}
|
||||
int dx = Math.max(0, (int) (ev.getX() - startedTrackingX));
|
||||
int dy = Math.abs((int)ev.getY() - startedTrackingY);
|
||||
velocityTracker.addMovement(ev);
|
||||
if (maybeStartTracking && !startedTracking && dx >= Utilities.dp(10)) {
|
||||
if (maybeStartTracking && !startedTracking && dx >= Utilities.dp(10) && Math.abs(dx) / 3 > dy) {
|
||||
prepareForMoving(ev);
|
||||
} else if (startedTracking) {
|
||||
if (!beginTrackingSent) {
|
||||
@ -435,7 +438,7 @@ public class ActionBarActivity extends Activity {
|
||||
|
||||
int height = 0;
|
||||
if (actionBar.getVisibility() == View.VISIBLE) {
|
||||
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
if (!Utilities.isTablet(this) && getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
height = Utilities.dp(40);
|
||||
} else {
|
||||
height = Utilities.dp(48);
|
||||
@ -660,7 +663,6 @@ public class ActionBarActivity extends Activity {
|
||||
public boolean onKeyUp(int keyCode, KeyEvent event) {
|
||||
if (keyCode == KeyEvent.KEYCODE_MENU && !checkTransitionAnimation() && !startedTracking) {
|
||||
actionBar.onMenuButtonPressed();
|
||||
return true;
|
||||
}
|
||||
return super.onKeyUp(keyCode, event);
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ public class ActionBarLayer extends FrameLayout {
|
||||
private void positionLogoImage(int height) {
|
||||
if (logoImageView != null) {
|
||||
LayoutParams layoutParams = (LayoutParams) logoImageView.getLayoutParams();
|
||||
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
if (!Utilities.isTablet(getContext()) && getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
layoutParams.width = (int)(logoImageView.getDrawable().getIntrinsicWidth() / 1.3f);
|
||||
layoutParams.height = (int)(logoImageView.getDrawable().getIntrinsicHeight() / 1.3f);
|
||||
layoutParams.setMargins(Utilities.dp(12), (height - layoutParams.height) / 2, 0, 0);
|
||||
@ -123,7 +123,7 @@ public class ActionBarLayer extends FrameLayout {
|
||||
|
||||
private void positionTitle(int width, int height) {
|
||||
int offset = Utilities.dp(2);
|
||||
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
if (!Utilities.isTablet(getContext()) && getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
offset = Utilities.dp(1);
|
||||
}
|
||||
int maxTextWidth = 0;
|
||||
@ -131,7 +131,7 @@ public class ActionBarLayer extends FrameLayout {
|
||||
LayoutParams layoutParams = null;
|
||||
|
||||
if (titleTextView != null && titleTextView.getVisibility() == VISIBLE) {
|
||||
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
if (!Utilities.isTablet(getContext()) && getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
titleTextView.setTextSize(16);
|
||||
} else {
|
||||
titleTextView.setTextSize(18);
|
||||
@ -146,7 +146,7 @@ public class ActionBarLayer extends FrameLayout {
|
||||
maxTextWidth = titleTextView.getMeasuredWidth();
|
||||
}
|
||||
if (subTitleTextView != null && subTitleTextView.getVisibility() == VISIBLE) {
|
||||
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
if (!Utilities.isTablet(getContext()) && getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
subTitleTextView.setTextSize(12);
|
||||
} else {
|
||||
subTitleTextView.setTextSize(14);
|
||||
@ -165,7 +165,7 @@ public class ActionBarLayer extends FrameLayout {
|
||||
if (logoImageView == null || logoImageView.getVisibility() == GONE) {
|
||||
x = Utilities.dp(16);
|
||||
} else {
|
||||
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
if (!Utilities.isTablet(getContext()) && getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
x = Utilities.dp(22) + (int)(logoImageView.getDrawable().getIntrinsicWidth() / 1.3f);
|
||||
} else {
|
||||
x = Utilities.dp(22) + logoImageView.getDrawable().getIntrinsicWidth();
|
||||
@ -243,6 +243,7 @@ public class ActionBarLayer extends FrameLayout {
|
||||
if (value != null && subTitleTextView == null) {
|
||||
subTitleTextView = new TextView(getContext());
|
||||
backButtonFrameLayout.addView(subTitleTextView);
|
||||
subTitleTextView.setGravity(Gravity.LEFT);
|
||||
subTitleTextView.setTextColor(0xffd7e8f7);
|
||||
subTitleTextView.setSingleLine(true);
|
||||
subTitleTextView.setLines(1);
|
||||
@ -260,6 +261,7 @@ public class ActionBarLayer extends FrameLayout {
|
||||
if (resourceId != 0 && subTitleTextView == null) {
|
||||
subTitleTextView = new TextView(getContext());
|
||||
backButtonFrameLayout.addView(subTitleTextView);
|
||||
subTitleTextView.setGravity(Gravity.LEFT);
|
||||
subTitleTextView.setTextColor(0xffd7e8f7);
|
||||
subTitleTextView.setSingleLine(true);
|
||||
subTitleTextView.setLines(1);
|
||||
@ -276,7 +278,10 @@ public class ActionBarLayer extends FrameLayout {
|
||||
public void setTitle(CharSequence value) {
|
||||
if (value != null && titleTextView == null) {
|
||||
titleTextView = new TextView(getContext());
|
||||
titleTextView.setGravity(Gravity.LEFT);
|
||||
titleTextView.setSingleLine(true);
|
||||
titleTextView.setLines(1);
|
||||
titleTextView.setMaxLines(1);
|
||||
titleTextView.setEllipsize(TextUtils.TruncateAt.END);
|
||||
backButtonFrameLayout.addView(titleTextView);
|
||||
titleTextView.setTextColor(0xffffffff);
|
||||
@ -291,6 +296,7 @@ public class ActionBarLayer extends FrameLayout {
|
||||
public void setTitleIcon(int resourceId, int padding) {
|
||||
if (resourceId != 0 && titleTextView == null) {
|
||||
titleTextView = new TextView(getContext());
|
||||
titleTextView.setGravity(Gravity.LEFT);
|
||||
backButtonFrameLayout.addView(titleTextView);
|
||||
titleTextView.setTextColor(0xffffffff);
|
||||
titleTextView.setSingleLine(true);
|
||||
|
@ -9,6 +9,7 @@
|
||||
package org.telegram.ui.Views;
|
||||
|
||||
import android.content.Context;
|
||||
import android.database.DataSetObserver;
|
||||
import android.graphics.drawable.GradientDrawable;
|
||||
import android.support.v4.view.PagerAdapter;
|
||||
import android.support.v4.view.ViewPager;
|
||||
@ -247,6 +248,13 @@ public class EmojiView extends LinearLayout {
|
||||
localObject.setTag(this.data[paramInt]);
|
||||
return localObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregisterDataSetObserver(DataSetObserver observer) {
|
||||
if (observer != null) {
|
||||
super.unregisterDataSetObserver(observer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class EmojiPagesAdapter extends PagerAdapter implements PagerSlidingTabStrip.IconTabProvider {
|
||||
@ -286,6 +294,13 @@ public class EmojiView extends LinearLayout {
|
||||
public boolean isViewFromObject(View paramView, Object paramObject) {
|
||||
return paramView == paramObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregisterDataSetObserver(DataSetObserver observer) {
|
||||
if (observer != null) {
|
||||
super.unregisterDataSetObserver(observer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static abstract interface Listener {
|
||||
|
@ -113,7 +113,7 @@ public class HorizontalListView extends AdapterView<ListAdapter> {
|
||||
|
||||
@Override
|
||||
public void setAdapter(ListAdapter adapter) {
|
||||
if(mAdapter != null) {
|
||||
if(mAdapter != null && mDataObserver != null) {
|
||||
mAdapter.unregisterDataSetObserver(mDataObserver);
|
||||
}
|
||||
mAdapter = adapter;
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
package org.telegram.ui.Views;
|
||||
|
||||
import android.database.DataSetObserver;
|
||||
import android.util.SparseArray;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@ -222,4 +223,11 @@ public abstract class SectionedBaseAdapter extends BaseFragmentAdapter implement
|
||||
mSectionCount = getSectionCount();
|
||||
return mSectionCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregisterDataSetObserver(DataSetObserver observer) {
|
||||
if (observer != null) {
|
||||
super.unregisterDataSetObserver(observer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user