Attempt to detect screenshots(not perfect now, disabled)

This commit is contained in:
DrKLO 2014-04-04 21:58:33 +04:00
parent cea585cd39
commit 0b01da670a
26 changed files with 509 additions and 61 deletions

View File

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.telegram.messenger">
package="org.telegram.messenger"
android:installLocation="auto">
<supports-screens android:anyDensity="true"
android:smallScreens="true"
@ -45,8 +46,7 @@
android:theme="@style/Theme.TMessages.Start"
android:name="org.telegram.ui.ApplicationLoader"
android:hardwareAccelerated="true"
android:largeHeap="true"
android:installLocation="auto">
android:largeHeap="true">
<activity
android:name="org.telegram.ui.LaunchActivity"

View File

@ -70,7 +70,7 @@
673;BN;Brunei Darussalam
672;NF;Norfolk Island
670;TL;Timor-Leste
599;BQ;Bonaire, Sint Eustatius & Saba
599;BQ;Bonaire, Sint Eustatius & Saba
599;CW;Curaçao
598;UY;Uruguay
597;SR;Suriname
@ -150,7 +150,7 @@
246;IO;Diego Garcia
245;GW;Guinea-Bissau
244;AO;Angola
243;CD;Congo (Dem. Rep.)
243;CD;Congo (Dem. Rep.)
242;CG;Congo (Rep.)
241;GA;Gabon
240;GQ;Equatorial Guinea
@ -212,6 +212,7 @@
45;DK;Denmark
44;GB;United Kingdom
43;AT;Austria
42;YL;Y-land
41;CH;Switzerland
40;RO;Romania
39;IT;Italy
@ -223,9 +224,9 @@
30;GR;Greece
27;ZA;South Africa
20;EG;Egypt
7;KZ;Kazakhstan
7;RU;Russian Federation
1;PR;Puerto Rico
1;DO;Dominican Rep.
1;CA;Canada
7;KZ;Kazakhstan
7;RU;Russian Federation
1;PR;Puerto Rico
1;DO;Dominican Rep.
1;CA;Canada
1;US;USA

View File

@ -149,7 +149,7 @@ public class ContactsController {
public void checkAppAccount() {
AccountManager am = AccountManager.get(ApplicationLoader.applicationContext);
Account[] accounts = am.getAccountsByType("org.telegram.messenger.account");
Account[] accounts = am.getAccountsByType("org.telegram.account");
boolean recreateAccount = false;
if (UserConfig.currentUser != null) {
if (accounts.length == 1) {
@ -173,8 +173,12 @@ public class ContactsController {
am.removeAccount(c, null, null);
}
if (UserConfig.currentUser != null) {
currentAccount = new Account(UserConfig.currentUser.phone, "org.telegram.messenger.account");
am.addAccountExplicitly(currentAccount, "", null);
try {
currentAccount = new Account(UserConfig.currentUser.phone, "org.telegram.account");
am.addAccountExplicitly(currentAccount, "", null);
} catch (Exception e) {
FileLog.e("tmessages", e);
}
}
}
}
@ -376,12 +380,12 @@ public class ContactsController {
if (schedule) {
try {
AccountManager am = AccountManager.get(ApplicationLoader.applicationContext);
Account[] accounts = am.getAccountsByType("org.telegram.messenger.account");
Account[] accounts = am.getAccountsByType("org.telegram.account");
boolean recreateAccount = false;
if (UserConfig.currentUser != null) {
if (accounts.length != 1) {
FileLog.e("tmessages", "detected account deletion!");
currentAccount = new Account(UserConfig.currentUser.phone, "org.telegram.messenger.account");
currentAccount = new Account(UserConfig.currentUser.phone, "org.telegram.account");
am.addAccountExplicitly(currentAccount, "", null);
performWriteContactsToPhoneBookInternal();
}

View File

@ -113,8 +113,7 @@ public class FileLoader {
try {
Class cl = Class.forName("dalvik.system.VMRuntime");
Method getRt = cl.getMethod("getRuntime", new Class[0]);
Object obj = new Object[0];
runtime = getRt.invoke(null, obj);
runtime = getRt.invoke(null, new Object[0]);
trackAllocation = cl.getMethod("trackExternalAllocation", new Class[] {long.class});
trackFree = cl.getMethod("trackExternalFree", new Class[] {long.class});
success = true;

View File

@ -10,6 +10,8 @@ package org.telegram.messenger;
import android.app.ProgressDialog;
import android.content.Context;
import android.database.ContentObserver;
import android.database.Cursor;
import android.media.AudioFormat;
import android.media.AudioManager;
import android.media.AudioRecord;
@ -20,6 +22,7 @@ import android.media.audiofx.AutomaticGainControl;
import android.net.Uri;
import android.os.Environment;
import android.os.Vibrator;
import android.provider.MediaStore;
import android.view.View;
import org.telegram.objects.MessageObject;
@ -80,6 +83,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
public final static int recordStarted = 50004;
public final static int recordStartError = 50005;
public final static int recordStopped = 50006;
public final static int screenshotTook = 50007;
private HashMap<String, ArrayList<WeakReference<FileDownloadProgressListener>>> loadingFileObservers = new HashMap<String, ArrayList<WeakReference<FileDownloadProgressListener>>>();
private HashMap<Integer, String> observersByTag = new HashMap<Integer, String>();
@ -188,6 +192,72 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
}
};
private class InternalObserver extends ContentObserver {
public InternalObserver() {
super(null);
}
@Override
public void onChange(boolean selfChange) {
super.onChange(selfChange);
processMediaObserver(MediaStore.Images.Media.INTERNAL_CONTENT_URI);
}
}
private class ExternalObserver extends ContentObserver {
public ExternalObserver() {
super(null);
}
@Override
public void onChange(boolean selfChange) {
super.onChange(selfChange);
processMediaObserver(MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
}
}
private ExternalObserver externalObserver = null;
private InternalObserver internalObserver = null;
private long lastSecretChatEnterTime = 0;
private long lastSecretChatLeaveTime = 0;
private long lastMediaCheckTime = 0;
private TLRPC.EncryptedChat lastSecretChat = null;
private ArrayList<Long> lastSecretChatVisibleMessages = null;
private int startObserverToken = 0;
private StopMediaObserverRunnable stopMediaObserverRunnable = null;
private final class StopMediaObserverRunnable implements Runnable {
public int currentObserverToken = 0;
@Override
public void run() {
if (currentObserverToken == startObserverToken) {
try {
if (internalObserver != null) {
ApplicationLoader.applicationContext.getContentResolver().unregisterContentObserver(internalObserver);
internalObserver = null;
}
} catch (Exception e) {
FileLog.e("tmessages", e);
}
try {
if (externalObserver != null) {
ApplicationLoader.applicationContext.getContentResolver().unregisterContentObserver(externalObserver);
externalObserver = null;
}
} catch (Exception e) {
FileLog.e("tmessages", e);
}
}
}
}
private String[] mediaProjections = new String[] {
MediaStore.Images.ImageColumns.DATA,
MediaStore.Images.ImageColumns.DISPLAY_NAME,
MediaStore.Images.ImageColumns.BUCKET_DISPLAY_NAME,
MediaStore.Images.ImageColumns.DATE_TAKEN,
MediaStore.Images.ImageColumns.TITLE
};
private static volatile MediaController Instance = null;
public static MediaController getInstance() {
MediaController localInstance = Instance;
@ -290,6 +360,165 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
currentGifMessageObject = null;
}
public void startMediaObserver() {
if (android.os.Build.VERSION.SDK_INT > 0) { //disable while it's not perferct
return;
}
ApplicationLoader.applicationHandler.removeCallbacks(stopMediaObserverRunnable);
startObserverToken++;
try {
if (internalObserver == null) {
ApplicationLoader.applicationContext.getContentResolver().registerContentObserver(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, false, externalObserver = new ExternalObserver());
}
} catch (Exception e) {
FileLog.e("tmessages", e);
}
try {
if (externalObserver == null) {
ApplicationLoader.applicationContext.getContentResolver().registerContentObserver(MediaStore.Images.Media.INTERNAL_CONTENT_URI, false, internalObserver = new InternalObserver());
}
} catch (Exception e) {
FileLog.e("tmessages", e);
}
}
public void stopMediaObserver() {
if (android.os.Build.VERSION.SDK_INT < 10) { //disable while it's not perferct
return;
}
if (stopMediaObserverRunnable == null) {
stopMediaObserverRunnable = new StopMediaObserverRunnable();
}
stopMediaObserverRunnable.currentObserverToken = startObserverToken;
ApplicationLoader.applicationHandler.postDelayed(stopMediaObserverRunnable, 5000);
}
public void processMediaObserver(Uri uri) {
try {
Cursor cursor = ApplicationLoader.applicationContext.getContentResolver().query(uri, mediaProjections, null, null, "date_added DESC LIMIT 1");
final ArrayList<Long> screenshotDates = new ArrayList<Long>();
if (cursor != null) {
while (cursor.moveToNext()) {
String val = "";
String data = cursor.getString(0);
String display_name = cursor.getString(1);
String album_name = cursor.getString(2);
String title = cursor.getString(4);
long date = cursor.getLong(3);
if (data != null && data.toLowerCase().contains("screenshot") ||
display_name != null && display_name.toLowerCase().contains("screenshot") ||
album_name != null && album_name.toLowerCase().contains("screenshot") ||
title != null && title.toLowerCase().contains("screenshot")) {
/*BitmapRegionDecoder bitmapRegionDecoder = null;
boolean added = false;
try {
int waitCount = 0;
while (waitCount < 5 && bitmapRegionDecoder == null) {
try {
bitmapRegionDecoder = BitmapRegionDecoder.newInstance(data, true);
if (bitmapRegionDecoder != null) {
break;
}
} catch (Exception e) {
FileLog.e("tmessages", e);
}
Thread.sleep(1000);
}
if (bitmapRegionDecoder != null) {
Bitmap bitmap = bitmapRegionDecoder.decodeRegion(new Rect(0, 0, Utilities.dp(44), Utilities.dp(44)), null);
int w = bitmap.getWidth();
int h = bitmap.getHeight();
for (int y = 0; y < h; y++) {
int rowCount = 0;
for (int x = 0; x < w; x++) {
int px = bitmap.getPixel(x, y);
if (px == 0xffffffff) {
rowCount++;
} else {
rowCount = 0;
}
if (rowCount > 8) {
break;
}
}
if (rowCount > 8) {
screenshotDates.add(date);
added = true;
break;
}
}
bitmapRegionDecoder.recycle();
try {
if (bitmap != null) {
bitmap.recycle();
}
} catch (Exception e) {
FileLog.e("tmessages", e);
}
}
} catch (Exception e) {
FileLog.e("tmessages", e);
try {
if (bitmapRegionDecoder != null) {
bitmapRegionDecoder.recycle();
}
} catch (Exception e2) {
FileLog.e("tmessages", e2);
}
if (!added) {
screenshotDates.add(date);
}
}*/
screenshotDates.add(date);
}
FileLog.e("tmessages", "screenshot!");
}
cursor.close();
}
if (!screenshotDates.isEmpty()) {
Utilities.RunOnUIThread(new Runnable() {
@Override
public void run() {
NotificationCenter.getInstance().postNotificationName(screenshotTook);
checkScreenshots(screenshotDates);
}
});
}
} catch (Exception e) {
FileLog.e("tmessages", e);
}
}
private void checkScreenshots(ArrayList<Long> dates) {
if (dates == null || dates.isEmpty() || lastSecretChatEnterTime == 0 || lastSecretChat == null || !(lastSecretChat instanceof TLRPC.TL_encryptedChat)) {
return;
}
long dt = 2000;
boolean send = false;
for (Long date : dates) {
if (lastMediaCheckTime != 0 && date <= lastMediaCheckTime) {
continue;
}
if (date >= lastSecretChatEnterTime) {
if (lastSecretChatLeaveTime == 0 || date <= lastSecretChatLeaveTime + dt) {
lastMediaCheckTime = Math.max(lastMediaCheckTime, date);
send = true;
}
}
}
if (send) {
MessagesController.getInstance().sendScreenshotMessage(lastSecretChat, lastSecretChatVisibleMessages);
}
}
public void setLastEncryptedChatParams(long enterTime, long leaveTime, TLRPC.EncryptedChat encryptedChat, ArrayList<Long> visibleMessages) {
lastSecretChatEnterTime = enterTime;
lastSecretChatLeaveTime = leaveTime;
lastSecretChat = encryptedChat;
lastSecretChatVisibleMessages = visibleMessages;
}
public int generateObserverTag() {
return lastTag++;
}
@ -1159,7 +1388,8 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
if (f.length() > 0) {
cacheFile = f;
}
} else {
}
if (cacheFile == null) {
cacheFile = new File(Utilities.getCacheDir(), messageObject.getFileName());
}
try {

View File

@ -401,7 +401,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
public void deleteAllAppAccounts() {
try {
AccountManager am = AccountManager.get(ApplicationLoader.applicationContext);
Account[] accounts = am.getAccountsByType("org.telegram.messenger.account");
Account[] accounts = am.getAccountsByType("org.telegram.account");
for (Account c : accounts) {
am.removeAccount(c, null, null);
}
@ -1613,6 +1613,9 @@ public class MessagesController implements NotificationCenter.NotificationCenter
}
private void sendMessagesDeleteMessage(ArrayList<Long> random_ids, TLRPC.EncryptedChat encryptedChat) {
if (!(encryptedChat instanceof TLRPC.TL_encryptedChat)) {
return;
}
TLRPC.TL_decryptedMessageService reqSend = new TLRPC.TL_decryptedMessageService();
reqSend.random_id = getNextRandomId();
reqSend.random_bytes = new byte[Math.max(1, (int)Math.ceil(random.nextDouble() * 16))];
@ -1620,9 +1623,13 @@ public class MessagesController implements NotificationCenter.NotificationCenter
reqSend.action = new TLRPC.TL_decryptedMessageActionDeleteMessages();
reqSend.action.random_ids = random_ids;
performSendEncryptedRequest(reqSend, null, encryptedChat, null);
}
private void sendClearHistoryMessage(TLRPC.EncryptedChat encryptedChat) {
if (!(encryptedChat instanceof TLRPC.TL_encryptedChat)) {
return;
}
TLRPC.TL_decryptedMessageService reqSend = new TLRPC.TL_decryptedMessageService();
reqSend.random_id = getNextRandomId();
reqSend.random_bytes = new byte[Math.max(1, (int)Math.ceil(random.nextDouble() * 16))];
@ -1632,6 +1639,9 @@ public class MessagesController implements NotificationCenter.NotificationCenter
}
public void sendTTLMessage(TLRPC.EncryptedChat encryptedChat) {
if (!(encryptedChat instanceof TLRPC.TL_encryptedChat)) {
return;
}
TLRPC.TL_messageService newMsg = new TLRPC.TL_messageService();
newMsg.action = new TLRPC.TL_messageActionTTLChange();
@ -1672,6 +1682,54 @@ public class MessagesController implements NotificationCenter.NotificationCenter
performSendEncryptedRequest(reqSend, newMsgObj, encryptedChat, null);
}
public void sendScreenshotMessage(TLRPC.EncryptedChat encryptedChat, ArrayList<Long> random_ids) {
if (!(encryptedChat instanceof TLRPC.TL_encryptedChat)) {
return;
}
TLRPC.TL_decryptedMessageActionScreenshotMessages action = new TLRPC.TL_decryptedMessageActionScreenshotMessages();
action.random_ids = random_ids;
TLRPC.TL_messageService newMsg = new TLRPC.TL_messageService();
newMsg.action = new TLRPC.TL_messageEcryptedAction();
newMsg.action.encryptedAction = action;
newMsg.local_id = newMsg.id = UserConfig.getNewMessageId();
newMsg.from_id = UserConfig.clientUserId;
newMsg.unread = true;
newMsg.dialog_id = ((long)encryptedChat.id) << 32;
newMsg.to_id = new TLRPC.TL_peerUser();
if (encryptedChat.participant_id == UserConfig.clientUserId) {
newMsg.to_id.user_id = encryptedChat.admin_id;
} else {
newMsg.to_id.user_id = encryptedChat.participant_id;
}
newMsg.out = true;
newMsg.date = ConnectionsManager.getInstance().getCurrentTime();
newMsg.random_id = getNextRandomId();
UserConfig.saveConfig(false);
final MessageObject newMsgObj = new MessageObject(newMsg, users);
newMsgObj.messageOwner.send_state = MESSAGE_SEND_STATE_SENDING;
final ArrayList<MessageObject> objArr = new ArrayList<MessageObject>();
objArr.add(newMsgObj);
ArrayList<TLRPC.Message> arr = new ArrayList<TLRPC.Message>();
arr.add(newMsg);
MessagesStorage.getInstance().putMessages(arr, false, true);
updateInterfaceWithMessages(newMsg.dialog_id, objArr);
NotificationCenter.getInstance().postNotificationName(dialogsNeedReload);
sendingMessages.put(newMsg.id, newMsgObj);
TLRPC.TL_decryptedMessageService reqSend = new TLRPC.TL_decryptedMessageService();
reqSend.random_id = newMsg.random_id;
reqSend.random_bytes = new byte[Math.max(1, (int)Math.ceil(random.nextDouble() * 16))];
random.nextBytes(reqSend.random_bytes);
reqSend.action = action;
performSendEncryptedRequest(reqSend, newMsgObj, encryptedChat, 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, long peer) {
TLRPC.Message newMsg = null;
int type = -1;
@ -4542,6 +4600,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
notification.ledOnMS = 1000;
notification.ledOffMS = 1000;
notification.flags |= Notification.FLAG_SHOW_LIGHTS;
notification.defaults = 0;
try {
mNotificationManager.notify(1, notification);
if (preferences.getBoolean("EnablePebbleNotifications", false)) {
@ -4827,10 +4886,17 @@ public class MessagesController implements NotificationCenter.NotificationCenter
return newMessage;
} else if (object instanceof TLRPC.TL_decryptedMessageService) {
TLRPC.TL_decryptedMessageService serviceMessage = (TLRPC.TL_decryptedMessageService)object;
if (serviceMessage.action instanceof TLRPC.TL_decryptedMessageActionSetMessageTTL) {
if (serviceMessage.action instanceof TLRPC.TL_decryptedMessageActionSetMessageTTL || serviceMessage.action instanceof TLRPC.TL_decryptedMessageActionScreenshotMessages) {
TLRPC.TL_messageService newMessage = new TLRPC.TL_messageService();
newMessage.action = new TLRPC.TL_messageActionTTLChange();
newMessage.action.ttl = chat.ttl = serviceMessage.action.ttl_seconds;
if (serviceMessage.action instanceof TLRPC.TL_decryptedMessageActionSetMessageTTL) {
newMessage.action = new TLRPC.TL_messageActionTTLChange();
newMessage.action.ttl = chat.ttl = serviceMessage.action.ttl_seconds;
} else if (serviceMessage.action instanceof TLRPC.TL_decryptedMessageActionScreenshotMessages) {
newMessage.action = new TLRPC.TL_messageEcryptedAction();
newMessage.action.encryptedAction = serviceMessage.action;
} else {
return null;
}
newMessage.local_id = newMessage.id = UserConfig.getNewMessageId();
UserConfig.saveConfig(false);
newMessage.unread = true;

View File

@ -410,6 +410,8 @@ public class TLClassStore {
classStore.put(TLRPC.TL_help_getSupport.constructor, TLRPC.TL_help_getSupport.class);
classStore.put(TLRPC.TL_decryptedMessageActionDeleteMessages.constructor, TLRPC.TL_decryptedMessageActionDeleteMessages.class);
classStore.put(TLRPC.TL_decryptedMessageActionFlushHistory.constructor, TLRPC.TL_decryptedMessageActionFlushHistory.class);
classStore.put(TLRPC.TL_decryptedMessageActionScreenshotMessages.constructor, TLRPC.TL_decryptedMessageActionScreenshotMessages.class);
classStore.put(TLRPC.TL_messageEcryptedAction.constructor, TLRPC.TL_messageEcryptedAction.class);
classStore.put(TLRPC.TL_msg_container.constructor, TLRPC.TL_msg_container.class);
classStore.put(TLRPC.TL_fileEncryptedLocation.constructor, TLRPC.TL_fileEncryptedLocation.class);

View File

@ -8818,6 +8818,7 @@ public class TLRPC {
public ArrayList<Integer> users = new ArrayList<Integer>();
public String address;
public int ttl;
public DecryptedMessageAction encryptedAction;
}
public static class TL_messageActionTTLChange extends MessageAction {
@ -9110,6 +9111,52 @@ public class TLRPC {
}
}
public static class TL_decryptedMessageActionScreenshotMessages extends DecryptedMessageAction {
public static int constructor = 0x954bd30;
public void readParams(AbsSerializedData stream) {
boolean[] error = new boolean[1];
stream.readInt32(error);
if (error[0]) {
return;
}
int count = stream.readInt32(error);
if (error[0]) {
return;
}
for (long a = 0; a < count; a++) {
random_ids.add(stream.readInt64(error));
if (error[0]) {
return;
}
}
}
public void serializeToStream(AbsSerializedData stream) {
stream.writeInt32(constructor);
stream.writeInt32(0x1cb5c415);
int count = random_ids.size();
stream.writeInt32(count);
for (Long value : random_ids) {
stream.writeInt64(value);
}
}
}
public static class TL_messageEcryptedAction extends MessageAction {
public static int constructor = 0x555555F7;
public void readParams(AbsSerializedData stream) {
encryptedAction = (DecryptedMessageAction)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32());
}
public void serializeToStream(AbsSerializedData stream) {
stream.writeInt32(constructor);
encryptedAction.serializeToStream(stream);
}
}
public static class TL_upload_saveBigFilePart extends TLObject {
public static int constructor = 0xde7b673d;

View File

@ -217,6 +217,18 @@ public class MessageObject {
} else {
messageText = LocaleController.formatString("NotificationContactNewPhoto", R.string.NotificationContactNewPhoto, "");
}
} else if (message.action instanceof TLRPC.TL_messageEcryptedAction) {
if (message.action.encryptedAction instanceof TLRPC.TL_decryptedMessageActionScreenshotMessages) {
if (isFromMe()) {
messageText = LocaleController.formatString("ActionTakeScreenshootYou", R.string.ActionTakeScreenshootYou);
} else {
if (fromUser != null) {
messageText = LocaleController.formatString("ActionTakeScreenshoot", R.string.ActionTakeScreenshoot).replace("un1", fromUser.first_name);
} else {
messageText = LocaleController.formatString("ActionTakeScreenshoot", R.string.ActionTakeScreenshoot).replace("un1", "");
}
}
}
}
}
} else if (message.media != null && !(message.media instanceof TLRPC.TL_messageMediaEmpty)) {

View File

@ -411,7 +411,8 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
fileName = currentMessageObject.messageOwner.attachPath;
cacheFile = f;
}
} else {
}
if (fileName == null) {
fileName = currentMessageObject.getFileName();
cacheFile = new File(Utilities.getCacheDir(), fileName);
}

View File

@ -196,6 +196,9 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
private CharSequence lastPrintString;
private long chatEnterTime = 0;
private long chatLeaveTime = 0;
private final static int copy = 1;
private final static int forward = 2;
private final static int delete = 3;
@ -268,7 +271,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
random_ids = new ArrayList<Long>();
for (HashMap.Entry<Integer, MessageObject> entry : selectedMessagesIds.entrySet()) {
MessageObject msg = entry.getValue();
if (msg.messageOwner.random_id != 0) {
if (msg.messageOwner.random_id != 0 && msg.type != 10) {
random_ids.add(msg.messageOwner.random_id);
}
}
@ -401,6 +404,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
dialog_id = ((long)encId) << 32;
maxMessageId = Integer.MIN_VALUE;
minMessageId = Integer.MAX_VALUE;
MediaController.getInstance().startMediaObserver();
} else {
return false;
}
@ -429,6 +433,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
NotificationCenter.getInstance().addObserver(this, MediaController.recordStarted);
NotificationCenter.getInstance().addObserver(this, MediaController.recordStartError);
NotificationCenter.getInstance().addObserver(this, MediaController.recordStopped);
NotificationCenter.getInstance().addObserver(this, MediaController.screenshotTook);
NotificationCenter.getInstance().addObserver(this, 997);
loading = true;
@ -478,7 +483,11 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
NotificationCenter.getInstance().removeObserver(this, MediaController.recordStarted);
NotificationCenter.getInstance().removeObserver(this, MediaController.recordStartError);
NotificationCenter.getInstance().removeObserver(this, MediaController.recordStopped);
NotificationCenter.getInstance().removeObserver(this, MediaController.screenshotTook);
NotificationCenter.getInstance().removeObserver(this, 997);
if (currentEncryptedChat != null) {
MediaController.getInstance().stopMediaObserver();
}
if (sizeNotifierRelativeLayout != null) {
sizeNotifierRelativeLayout.delegate = null;
sizeNotifierRelativeLayout = null;
@ -1263,7 +1272,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
if (canSave) {
if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaDocument) {
String mime = messageObject.messageOwner.media.document.mime_type;
if (mime != null && mime.equals("text/xml")) {
if (mime != null && mime.endsWith("/xml")) {
return 5;
}
}
@ -1307,7 +1316,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
if (canSave) {
if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaDocument) {
String mime = messageObject.messageOwner.media.document.mime_type;
if (mime != null && mime.equals("text/xml")) {
if (mime != null && mime.endsWith("text/xml")) {
return 5;
}
}
@ -2404,6 +2413,8 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
recordingAudio = true;
updateAudioRecordIntefrace();
}
} else if (id == MediaController.screenshotTook) {
updateInformationForScreenshotDetector();
}
}
@ -2635,10 +2646,10 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
}
}, 400);
}
// if (currentEncryptedChat != null && parentActivity != null) {
// parentActivity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
// }
if (currentEncryptedChat != null) {
chatEnterTime = System.currentTimeMillis();
chatLeaveTime = 0;
}
}
private void setTypingAnimation(boolean start) {
@ -2686,9 +2697,35 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
editor.commit();
}
// if (currentEncryptedChat != null && parentActivity != null) {
// parentActivity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_SECURE);
// }
if (currentEncryptedChat != null) {
chatLeaveTime = System.currentTimeMillis();
updateInformationForScreenshotDetector();
}
}
private void updateInformationForScreenshotDetector() {
ArrayList<Long> visibleMessages = new ArrayList<Long>();
if (chatListView != null) {
int count = chatListView.getChildCount();
for (int a = 0; a < count; a++) {
View view = chatListView.getChildAt(a);
MessageObject object = null;
if (view instanceof ChatBaseCell) {
ChatBaseCell cell = (ChatBaseCell) view;
object = cell.getMessageObject();
} else {
Object tag = view.getTag();
if (tag instanceof ChatListRowHolderEx) {
ChatListRowHolderEx holder = (ChatListRowHolderEx) tag;
object = holder.message;
}
}
if (object != null && object.messageOwner.id < 0 && object.messageOwner.random_id != 0) {
visibleMessages.add(object.messageOwner.random_id);
}
}
}
MediaController.getInstance().setLastEncryptedChatParams(chatEnterTime, chatLeaveTime, currentEncryptedChat, visibleMessages);
}
private void fixLayout() {
@ -3155,7 +3192,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
ArrayList<Integer> arr = new ArrayList<Integer>();
arr.add(selectedObject.messageOwner.id);
ArrayList<Long> random_ids = null;
if (currentEncryptedChat != null && selectedObject.messageOwner.random_id != 0) {
if (currentEncryptedChat != null && selectedObject.messageOwner.random_id != 0 && selectedObject.type != 10) {
random_ids = new ArrayList<Long>();
random_ids.add(selectedObject.messageOwner.random_id);
}
@ -3168,7 +3205,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
ids.add(selectedObject.messageOwner.id);
removeUnreadPlane(true);
ArrayList<Long> random_ids = null;
if (currentEncryptedChat != null && selectedObject.messageOwner.random_id != 0) {
if (currentEncryptedChat != null && selectedObject.messageOwner.random_id != 0 && selectedObject.type != 10) {
random_ids = new ArrayList<Long>();
random_ids.add(selectedObject.messageOwner.random_id);
}

View File

@ -380,6 +380,14 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
((LaunchActivity)parentActivity).updateActionBar();
}
@Override
public void onPause() {
super.onPause();
if (searchItem != null && searchItem.isActionViewExpanded()) {
searchItem.collapseActionView();
}
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int itemId = item.getItemId();

View File

@ -172,6 +172,14 @@ public class CountrySelectActivity extends ActionBarActivity {
applySelfActionBar();
}
@Override
public void onPause() {
super.onPause();
if (searchItem != null && searchItem.isActionViewExpanded()) {
searchItem.collapseActionView();
}
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int itemId = item.getItemId();

View File

@ -233,6 +233,14 @@ public class LanguageSelectActivity extends BaseFragment {
((LaunchActivity)parentActivity).updateActionBar();
}
@Override
public void onPause() {
super.onPause();
if (searchItem != null && searchItem.isActionViewExpanded()) {
searchItem.collapseActionView();
}
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int itemId = item.getItemId();

View File

@ -322,7 +322,7 @@ public class LoginActivityPhoneView extends SlideView implements AdapterView.OnI
delegate.needShowAlert(LocaleController.getString("WrongCountry", R.string.WrongCountry));
return;
}
if (codeField.length() == 0 || phoneField.length() == 0) {
if (codeField.length() == 0) {
delegate.needShowAlert(LocaleController.getString("InvalidPhoneNumber", R.string.InvalidPhoneNumber));
return;
}

View File

@ -37,7 +37,6 @@ import org.telegram.messenger.R;
import org.telegram.ui.Views.BackupImageView;
import org.telegram.ui.Views.BaseFragment;
import org.telegram.ui.Views.OnSwipeTouchListener;
import org.w3c.dom.Text;
import java.util.ArrayList;
import java.util.HashMap;

View File

@ -361,10 +361,19 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
if (messagesListViewAdapter != null) {
messagesListViewAdapter.notifyDataSetChanged();
}
((LaunchActivity)parentActivity).showActionBar();
((LaunchActivity)parentActivity).updateActionBar();
}
@Override
public void onPause() {
super.onPause();
if (searchItem != null && searchItem.isActionViewExpanded()) {
searchItem.collapseActionView();
}
}
@Override
@SuppressWarnings("unchecked")
public void didReceivedNotification(int id, Object... args) {
@ -541,6 +550,9 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
if (parentActivity == null) {
return;
}
searchItem = (SupportMenuItem)menu.add(Menu.NONE, 0, Menu.NONE, LocaleController.getString("Search", R.string.Search)).setIcon(R.drawable.ic_ab_search);
searchItem.setShowAsAction(SupportMenuItem.SHOW_AS_ACTION_ALWAYS|SupportMenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
searchItem.setActionView(searchView = new SearchView(parentActivity));

View File

@ -533,7 +533,9 @@ public class SettingsWallpapersActivity extends BaseFragment implements Notifica
View selection = view.findViewById(R.id.selection);
TLRPC.WallPaper wallPaper = wallPapers.get(i - 1);
TLRPC.PhotoSize size = PhotoObject.getClosestPhotoSizeWithSize(wallPaper.sizes, Utilities.dp(100), Utilities.dp(100));
image.setImage(size.location, "100_100", 0);
if (size != null && size.location != null) {
image.setImage(size.location, "100_100", 0);
}
if (wallPaper.id == selectedBackground) {
selection.setVisibility(View.VISIBLE);
} else {

View File

@ -329,6 +329,8 @@
<string name="AttachDocument">مستند</string>
<string name="AttachAudio">مقطع صوتي</string>
<string name="FromYou">أنت</string>
<string name="ActionTakeScreenshootYou">You took a screenshot!</string>
<string name="ActionTakeScreenshoot">un1 took a screenshot!</string>
<!--Alert messages-->
<string name="InvalidPhoneNumber">رقم الهاتف غير صحيح</string>

View File

@ -224,7 +224,7 @@
<string name="NoBlocked">Keine blockierten Benutzer</string>
<string name="YourPhoneNumber">DEINE TELEFONNUMMER</string>
<string name="MessageNotifications">NACHRICHTEN</string>
<string name="Alert">Nachrichtenton</string>
<string name="Alert">Benachrichtigung</string>
<string name="MessagePreview">Nachrichtenvorschau</string>
<string name="GroupNotifications">GRUPPEN</string>
<string name="Sound">Nachrichtenton auswählen</string>
@ -256,12 +256,12 @@
<string name="ContactJoined">Kontakt ist Telegram beigetreten</string>
<string name="Pebble">PEBBLE</string>
<string name="Language">Sprache</string>
<string name="AskAQuestionInfo">Please note that Telegram Support is done by volunteers. We try to respond as quickly as possible, but it may take a while.<![CDATA[<br><br>]]>Please take a look at the <![CDATA[<a href="http://telegram.org/faq#general">Telegram FAQ</a>]]>: it has important <![CDATA[<a href="http://telegram.org/faq#troubleshooting">troubleshooting tips</a>]]> and answers to most questions.</string>
<string name="AskButton">Ask a volunteer</string>
<string name="AskAQuestionInfo">Bedenke bitte, dass der Telegram Support von Freiwilligen geleistet wird. Wir versuchen so schnell wie möglich zu antworten. Dies kann jedoch manchmal etwas länger dauern.<![CDATA[<br><br>]]>Bitte schau in den <![CDATA[<a href="http://telegram.org/faq#general">Telegram FAQ</a>]]>: nach. Dort findest du Antworten auf die meisten Fragen und wichtige Tipps zur <![CDATA[<a href="http://telegram.org/faq#troubleshooting">Problemlösung</a>]]>.</string>
<string name="AskButton">Frage einen Freiwilligen</string>
<string name="TelegramFaq">Telegram-FAQ</string>
<string name="TelegramFaqUrl">https://telegram.org/faq</string>
<string name="DeleteLocalization">Lokalisierung löschen?</string>
<string name="IncorrectLocalization">Incorrect localization file</string>
<string name="IncorrectLocalization">Falsche Sprachdatei</string>
<!--media view-->
<string name="NoMedia">Noch keine geteilten Medien vorhanden</string>
@ -321,7 +321,7 @@
<string name="ActionYouCreateGroup">Du hast die Gruppe erstellt</string>
<string name="ActionKickUserYou">un1 hat dich aus der Gruppe entfernt</string>
<string name="ActionAddUserYou">un1 hat dich hinzugefügt</string>
<string name="UnsuppotedMedia">Diese Nachricht wird von deiner Telegram-Version nicht unterstützt.</string>
<string name="UnsuppotedMedia">Diese Nachricht wird auf deiner Version von Telegram nicht unterstützt. Bitte aktualisiere die App um sie zu sehen: http://telegram.org/update</string>
<string name="AttachPhoto">Foto</string>
<string name="AttachVideo">Video</string>
<string name="AttachLocation">Standort</string>
@ -329,6 +329,8 @@
<string name="AttachDocument">Dokument</string>
<string name="AttachAudio">Audio</string>
<string name="FromYou">Du</string>
<string name="ActionTakeScreenshootYou">You took a screenshot!</string>
<string name="ActionTakeScreenshoot">un1 took a screenshot!</string>
<!--Alert messages-->
<string name="InvalidPhoneNumber">Ungültige Telefonnummer</string>
@ -356,12 +358,12 @@
<string name="Page6Title">Cloud-Basiert</string>
<string name="Page7Title">Vertraulich</string>
<string name="Page1Message">Willkommen im Zeitalter der sicheren und schnellen Kommunikation.</string>
<string name="Page2Message"><![CDATA[<b>Telegram</b>]]> stellt Nachrichten schneller<![CDATA[<br/>]]>zu als andere Anwendungen</string>
<string name="Page3Message"><![CDATA[<b>Telegram</b>]]> ist für immer kostenlos.<![CDATA[<br/>]]>Keine Werbung. Keine wiederkehrenden Kosten.</string>
<string name="Page4Message"><![CDATA[<b>Telegram</b>]]> schützt deine Nachrichten<![CDATA[<br/>]]>vor Hacker-Angriffen</string>
<string name="Page5Message"><![CDATA[<b>Telegram</b>]]> hat keine Grenzen in Sachen<![CDATA[<br/>]]>Größe deiner Chats und Medien</string>
<string name="Page6Message"><![CDATA[<b>Telegram</b>]]> lässt sich von verschiedenen<![CDATA[<br/>]]>Geräten gleichzeitig nutzen</string>
<string name="Page7Message"><![CDATA[<b>Telegram</b>]]>-Nachrichten sind stark<![CDATA[<br/>]]>verschlüsselt und können sich selbst zerstören</string>
<string name="Page2Message"><![CDATA[<b>Telegram</b>]]> stellt Nachrichten schneller zu als andere Anwendungen</string>
<string name="Page3Message"><![CDATA[<b>Telegram</b>]]> ist für immer kostenlos. Keine Werbung. Keine wiederkehrenden Kosten.</string>
<string name="Page4Message"><![CDATA[<b>Telegram</b>]]> schützt deine Nachrichten vor Hacker-Angriffen</string>
<string name="Page5Message"><![CDATA[<b>Telegram</b>]]> hat keine Grenzen in Sachen Größe deiner Chats und Medien</string>
<string name="Page6Message"><![CDATA[<b>Telegram</b>]]> lässt sich von verschiedenen Geräten gleichzeitig nutzen</string>
<string name="Page7Message"><![CDATA[<b>Telegram</b>]]>-Nachrichten sind stark verschlüsselt und können sich selbst zerstören</string>
<string name="StartMessaging">Jetzt beginnen</string>
<!--Don't change this! Not for localization!-->

View File

@ -329,6 +329,8 @@
<string name="AttachDocument">Archivo</string>
<string name="AttachAudio">Audio</string>
<string name="FromYou"></string>
<string name="ActionTakeScreenshootYou">You took a screenshot!</string>
<string name="ActionTakeScreenshoot">un1 took a screenshot!</string>
<!--Alert messages-->
<string name="InvalidPhoneNumber">Número de teléfono inválido</string>

View File

@ -321,7 +321,7 @@
<string name="ActionYouCreateGroup">Hai creato il gruppo</string>
<string name="ActionKickUserYou">un1 ti ha rimosso</string>
<string name="ActionAddUserYou">un1 ti ha aggiunto</string>
<string name="UnsuppotedMedia">Questo messaggio non è supportato dalla tua versione di Telegram.</string>
<string name="UnsuppotedMedia">Questo messaggio non è supportato sulla tua versione di Telegram. Aggiorna l\'applicazione per\nvisualizzarlo: http://telegram.org/update</string>
<string name="AttachPhoto">Foto</string>
<string name="AttachVideo">Video</string>
<string name="AttachLocation">Posizione</string>
@ -329,6 +329,8 @@
<string name="AttachDocument">Documento</string>
<string name="AttachAudio">Audio</string>
<string name="FromYou">Tu</string>
<string name="ActionTakeScreenshootYou">You took a screenshot!</string>
<string name="ActionTakeScreenshoot">un1 took a screenshot!</string>
<!--Alert messages-->
<string name="InvalidPhoneNumber">Numero di telefono non valido</string>
@ -358,7 +360,7 @@
<string name="Page1Message">Benvenuto nell\'era della messaggistica veloce e sicura</string>
<string name="Page2Message"><![CDATA[<b>Telegram</b>]]> consegna i messaggi più velocemente di qualsiasi altra applicazione</string>
<string name="Page3Message"><![CDATA[<b>Telegram</b>]]> è gratuita per sempre. Nessuna pubblicità. Nessun costo di abbonamento</string>
<string name="Page4Message"><![CDATA[<b>Telegram</b>]]> tiene al sicuro i tuoi messaggi dagli attacchi dei hacker</string>
<string name="Page4Message"><![CDATA[<b>Telegram</b>]]> tiene al sicuro i tuoi messaggi dagli attacchi degli hacker</string>
<string name="Page5Message"><![CDATA[<b>Telegram</b>]]> non ha limiti sulle dimensioni dei tuoi file multimediali e delle chat</string>
<string name="Page6Message"><![CDATA[<b>Telegram</b>]]> ti consente di accedere ai messaggi da più dispositivi</string>
<string name="Page7Message"><![CDATA[<b>Telegram</b>]]> cifra in maniera sicura i messaggi e può far sì che si autodistruggano</string>

View File

@ -110,7 +110,7 @@
<string name="YouLeft">U hebt deze groep verlaten</string>
<string name="DeleteThisGroup">Deze groep verwijderen</string>
<string name="SlideToCancel">SLEEP OM TE ANNULEREN</string>
<string name="SaveToDownloads">Opslaan in downloads</string>
<string name="SaveToDownloads">Opslaan in Downloads</string>
<string name="ApplyLocalizationFile">Vertaling toepassen</string>
<!--notification-->
@ -256,12 +256,12 @@
<string name="ContactJoined">Contact lid geworden van Telegram</string>
<string name="Pebble">PEBBLE</string>
<string name="Language">Taal</string>
<string name="AskAQuestionInfo">Please note that Telegram Support is done by volunteers. We try to respond as quickly as possible, but it may take a while.<![CDATA[<br><br>]]>Please take a look at the <![CDATA[<a href="http://telegram.org/faq#general">Telegram FAQ</a>]]>: it has important <![CDATA[<a href="http://telegram.org/faq#troubleshooting">troubleshooting tips</a>]]> and answers to most questions.</string>
<string name="AskButton">Ask a volunteer</string>
<string name="TelegramFaq">Telegram FAQ</string>
<string name="AskAQuestionInfo">Houd er rekening mee dat de ondersteuning van Telegram door vrijwilligers wordt gedaan. We doen ons best om zo snel als mogelijk te antwoorden, maar het kan even even duren.<![CDATA[<br><br>]]>Bekijk ook de <![CDATA[<a href="http://telegram.org/faq#general">veelgestelde vragen (FAQ)</a>]]>: hier staan de antwoorden op de meeste vragen en belangrijke tips voor <![CDATA[<a href="http://telegram.org/faq#troubleshooting">het oplossen van problemen</a>]]>.</string>
<string name="AskButton">Vraag een vrijwilliger</string>
<string name="TelegramFaq">Telegram veelgestelde vragen (FAQ)</string>
<string name="TelegramFaqUrl">https://telegram.org/faq</string>
<string name="DeleteLocalization">Delete localization?</string>
<string name="IncorrectLocalization">Incorrect localization file</string>
<string name="DeleteLocalization">Verwijder vertaling?</string>
<string name="IncorrectLocalization">Ongeldig vertalingsbestand</string>
<!--media view-->
<string name="NoMedia">Nog geen media gedeeld</string>
@ -280,7 +280,7 @@
<!--photo gallery view-->
<string name="ShowAllMedia">Alle media weergeven</string>
<string name="SaveToGallery">Opslaan in galerij</string>
<string name="Of">%1$d van %1$d</string>
<string name="Of">%1$d van %2$d</string>
<string name="Gallery">Galerij</string>
<!--button titles-->
@ -321,7 +321,7 @@
<string name="ActionYouCreateGroup">U hebt de groep gemaakt</string>
<string name="ActionKickUserYou">un1 heeft u verwijderd</string>
<string name="ActionAddUserYou">un1 heeft u toegevoegd</string>
<string name="UnsuppotedMedia">Dit bericht wordt niet ondersteund in uw versie van Telegram.</string>
<string name="UnsuppotedMedia">Dit bericht wordt niet ondersteund door uw versie van Telegram. Werk Telegram bij om dit bericht te bekijken: http://telegram.org/update</string>
<string name="AttachPhoto">Foto</string>
<string name="AttachVideo">Video</string>
<string name="AttachLocation">Locatie</string>
@ -329,6 +329,8 @@
<string name="AttachDocument">Document</string>
<string name="AttachAudio">Geluidsbestand</string>
<string name="FromYou">U</string>
<string name="ActionTakeScreenshootYou">You took a screenshot!</string>
<string name="ActionTakeScreenshoot">un1 took a screenshot!</string>
<!--Alert messages-->
<string name="InvalidPhoneNumber">Ongeldig telefoonnummer</string>

View File

@ -329,6 +329,8 @@
<string name="AttachDocument">Document</string>
<string name="AttachAudio">Audio</string>
<string name="FromYou">You</string>
<string name="ActionTakeScreenshootYou">You took a screenshot!</string>
<string name="ActionTakeScreenshoot">un1 took a screenshot!</string>
<!--Alert messages-->
<string name="InvalidPhoneNumber">Invalid phone number</string>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<account-authenticator xmlns:android="http://schemas.android.com/apk/res/android"
android:accountType="org.telegram.messenger.account"
android:accountType="org.telegram.account"
android:icon="@drawable/ic_launcher"
android:smallIcon="@drawable/ic_launcher"
android:label="@string/AppName"

View File

@ -1,3 +1,3 @@
<sync-adapter xmlns:android="http://schemas.android.com/apk/res/android"
android:contentAuthority="com.android.contacts"
android:accountType="org.telegram.messenger.account"/>
android:accountType="org.telegram.account"/>