1
0
mirror of https://github.com/MGislv/NekoX.git synced 2024-06-30 22:22:57 +00:00

Merge branch 'dev' into sessions

This commit is contained in:
DrKLO 2015-03-27 13:41:43 +03:00
commit 525676eb1b
18 changed files with 125 additions and 20 deletions

View File

@ -82,7 +82,7 @@ android {
defaultConfig {
minSdkVersion 8
targetSdkVersion 22
versionCode 475
versionCode 479
versionName "2.6.1"
}
}

View File

@ -1772,7 +1772,7 @@ public class ContactsController {
}
public static String formatName(String firstName, String lastName) {
String result = null;
String result = "";
if (LocaleController.nameDisplayOrder == 1) {
result = firstName;
if (result == null || result.length() == 0) {

View File

@ -17,10 +17,10 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.res.AssetFileDescriptor;
import android.graphics.drawable.BitmapDrawable;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.media.SoundPool;
import android.net.Uri;
import android.os.Build;
import android.os.SystemClock;
@ -68,11 +68,10 @@ public class NotificationsController {
private int lastOnlineFromOtherDevice = 0;
private boolean inChatSoundEnabled = true;
private SoundPool soundPool;
private int inChatOutgoingSound;
private long lastSoundPlay;
private MediaPlayer mediaPlayer;
private String lastMediaPlayerUri;
private MediaPlayer mediaPlayerIn;
private MediaPlayer mediaPlayerOut;
private AudioManager audioManager;
private static volatile NotificationsController Instance = null;
public static NotificationsController getInstance() {
@ -94,9 +93,8 @@ public class NotificationsController {
inChatSoundEnabled = preferences.getBoolean("EnableInChatSound", true);
try {
soundPool = new SoundPool(1, AudioManager.STREAM_NOTIFICATION, 0);
inChatOutgoingSound = soundPool.load(ApplicationLoader.applicationContext, R.raw.sound_out, 1);
mediaPlayer = new MediaPlayer();
audioManager = (AudioManager) ApplicationLoader.applicationContext.getSystemService(Context.AUDIO_SERVICE);
//mediaPlayer = new MediaPlayer();
} catch (Exception e) {
FileLog.e("tmessages", e);
}
@ -389,6 +387,7 @@ public class NotificationsController {
inAppPriority = preferences.getBoolean("EnableInAppPriority", false);
vibrate_override = preferences.getInt("vibrate_" + dialog_id, 0);
priority_override = preferences.getInt("priority_" + dialog_id, 3);
boolean vibrateOnlyIfSilent = false;
choosenSoundPath = preferences.getString("sound_path_" + dialog_id, null);
if (chat_id != 0) {
@ -418,6 +417,10 @@ public class NotificationsController {
priority = priority_override;
}
if (needVibrate == 4) {
vibrateOnlyIfSilent = true;
needVibrate = 0;
}
if (needVibrate == 2 && (vibrate_override == 1 || vibrate_override == 3 || vibrate_override == 5) || needVibrate != 2 && vibrate_override == 2 || vibrate_override != 0) {
needVibrate = vibrate_override;
}
@ -434,6 +437,16 @@ public class NotificationsController {
priority = 1;
}
}
if (vibrateOnlyIfSilent && needVibrate != 2) {
try {
int mode = audioManager.getRingerMode();
if (mode != AudioManager.RINGER_MODE_SILENT && mode != AudioManager.RINGER_MODE_VIBRATE) {
needVibrate = 2;
}
} catch (Exception e) {
FileLog.e("tmessages", e);
}
}
}
Intent intent = new Intent(ApplicationLoader.applicationContext, LaunchActivity.class);
@ -824,13 +837,53 @@ public class NotificationsController {
if (!inChatSoundEnabled) {
return;
}
if (lastSoundPlay > System.currentTimeMillis() - 1800) {
return;
}
try {
String choosenSoundPath = null;
String defaultPath = Settings.System.DEFAULT_NOTIFICATION_URI.getPath();
if (audioManager.getRingerMode() == AudioManager.RINGER_MODE_SILENT) {
return;
}
} catch (Exception e) {
FileLog.e("tmessages", e);
}
try {
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Context.MODE_PRIVATE);
int notify_override = preferences.getInt("notify2_" + openned_dialog_id, 0);
if (notify_override == 3) {
int mute_until = preferences.getInt("notifyuntil_" + openned_dialog_id, 0);
if (mute_until >= ConnectionsManager.getInstance().getCurrentTime()) {
notify_override = 2;
}
}
if (notify_override == 2) {
return;
}
notificationsQueue.postRunnable(new Runnable() {
@Override
public void run() {
if (lastSoundPlay > System.currentTimeMillis() - 500) {
return;
}
try {
if (mediaPlayerIn == null) {
AssetFileDescriptor assetFileDescriptor = ApplicationLoader.applicationContext.getResources().openRawResourceFd(R.raw.sound_in);
if (assetFileDescriptor != null) {
mediaPlayerIn = new MediaPlayer();
mediaPlayerIn.setAudioStreamType(AudioManager.STREAM_NOTIFICATION);
mediaPlayerIn.setDataSource(assetFileDescriptor.getFileDescriptor(), assetFileDescriptor.getStartOffset(), assetFileDescriptor.getLength());
mediaPlayerIn.setLooping(false);
assetFileDescriptor.close();
mediaPlayerIn.prepare();
}
}
mediaPlayerIn.start();
} catch (Exception e) {
FileLog.e("tmessages", e);
}
}
});
/*String choosenSoundPath = null;
String defaultPath = Settings.System.DEFAULT_NOTIFICATION_URI.getPath();
choosenSoundPath = preferences.getString("sound_path_" + openned_dialog_id, null);
boolean isChat = (int)(openned_dialog_id) < 0;
if (isChat) {
@ -860,7 +913,7 @@ public class NotificationsController {
mediaPlayer.prepare();
}
mediaPlayer.start();
}
}*/
} catch (Exception e) {
FileLog.e("tmessages", e);
}
@ -871,10 +924,33 @@ public class NotificationsController {
return;
}
try {
soundPool.play(inChatOutgoingSound, 1, 1, 1, 0, 1);
if (audioManager.getRingerMode() == AudioManager.RINGER_MODE_SILENT) {
return;
}
} catch (Exception e) {
FileLog.e("tmessages", e);
}
notificationsQueue.postRunnable(new Runnable() {
@Override
public void run() {
try {
if (mediaPlayerOut == null) {
AssetFileDescriptor assetFileDescriptor = ApplicationLoader.applicationContext.getResources().openRawResourceFd(R.raw.sound_out);
if (assetFileDescriptor != null) {
mediaPlayerOut = new MediaPlayer();
mediaPlayerOut.setAudioStreamType(AudioManager.STREAM_NOTIFICATION);
mediaPlayerOut.setDataSource(assetFileDescriptor.getFileDescriptor(), assetFileDescriptor.getStartOffset(), assetFileDescriptor.getLength());
mediaPlayerOut.setLooping(false);
assetFileDescriptor.close();
mediaPlayerOut.prepare();
}
}
mediaPlayerOut.start();
} catch (Exception e) {
FileLog.e("tmessages", e);
}
}
});
}
public void processNewMessages(ArrayList<MessageObject> messageObjects, boolean isLast) {

View File

@ -1810,8 +1810,13 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
FileLog.e("tmessages", e);
}
if (bmOptions.outWidth != 0 && bmOptions.outHeight != 0 && bmOptions.outWidth <= 800 && bmOptions.outHeight <= 800) {
TLRPC.TL_documentAttributeSticker attributeSticker = new TLRPC.TL_documentAttributeSticker();
attributeSticker.alt = "";
TLRPC.TL_documentAttributeSticker attributeSticker = null;
if (isEncrypted) {
attributeSticker = new TLRPC.TL_documentAttributeSticker_old();
} else {
attributeSticker = new TLRPC.TL_documentAttributeSticker();
attributeSticker.alt = "";
}
document.attributes.add(attributeSticker);
TLRPC.TL_documentAttributeImageSize attributeImageSize = new TLRPC.TL_documentAttributeImageSize();
attributeImageSize.w = bmOptions.outWidth;

View File

@ -1799,6 +1799,14 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
}
}
for (int a = 0; a < document.attributes.size(); a++) {
TLRPC.DocumentAttribute attribute = document.attributes.get(a);
if (attribute instanceof TLRPC.TL_documentAttributeSticker) {
document.attributes.remove(a);
document.attributes.add(new TLRPC.TL_documentAttributeSticker_old());
break;
}
}
SendMessagesHelper.getInstance().sendMessage((TLRPC.TL_document) document, null, null, dialog_id, replyingMessageObject);
showReplyForMessageObjectOrForward(false, null, null, true);
}

View File

@ -376,6 +376,7 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat
audioSendButton.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
audioSendButton.setImageResource(R.drawable.mic_button_states);
audioSendButton.setBackgroundColor(0xffffffff);
audioSendButton.setSoundEffectsEnabled(false);
audioSendButton.setPadding(0, 0, AndroidUtilities.dp(4), 0);
frameLayout1.addView(audioSendButton);
layoutParams1 = (FrameLayout.LayoutParams) audioSendButton.getLayoutParams();
@ -461,6 +462,7 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat
sendButton.setVisibility(View.INVISIBLE);
sendButton.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
sendButton.setImageResource(R.drawable.ic_send);
sendButton.setSoundEffectsEnabled(false);
ViewProxy.setScaleX(sendButton, 0.1f);
ViewProxy.setScaleY(sendButton, 0.1f);
ViewProxy.setAlpha(sendButton, 0.0f);

View File

@ -439,7 +439,8 @@ public class NotificationsSettingsActivity extends BaseFragment implements Notif
LocaleController.getString("VibrationDisabled", R.string.VibrationDisabled),
LocaleController.getString("Default", R.string.Default),
LocaleController.getString("Short", R.string.Short),
LocaleController.getString("Long", R.string.Long)
LocaleController.getString("Long", R.string.Long),
LocaleController.getString("OnlyIfSilent", R.string.OnlyIfSilent)
}, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
@ -457,6 +458,8 @@ public class NotificationsSettingsActivity extends BaseFragment implements Notif
editor.putInt(param, 1);
} else if (which == 3) {
editor.putInt(param, 3);
} else if (which == 4) {
editor.putInt(param, 4);
}
editor.commit();
if (listView != null) {
@ -767,6 +770,8 @@ public class NotificationsSettingsActivity extends BaseFragment implements Notif
textCell.setTextAndValue(LocaleController.getString("Vibrate", R.string.Vibrate), LocaleController.getString("VibrationDisabled", R.string.VibrationDisabled), true);
} else if (value == 3) {
textCell.setTextAndValue(LocaleController.getString("Vibrate", R.string.Vibrate), LocaleController.getString("Long", R.string.Long), true);
} else if (value == 4) {
textCell.setTextAndValue(LocaleController.getString("Vibrate", R.string.Vibrate), LocaleController.getString("OnlyIfSilent", R.string.OnlyIfSilent), true);
}
} else if (i == repeatRow) {
textCell.setMultilineDetail(false);

Binary file not shown.

View File

@ -245,6 +245,7 @@
<string name="NoSound">لا يوجد صوت</string>
<string name="Default">افتراضي</string>
<string name="Support">الدعم</string>
<string name="OnlyIfSilent">إذا كان على الصامت</string>
<string name="ChatBackground">خلفية الدردشة</string>
<string name="MessagesSettings">الرسائل</string>
<string name="SendByEnter">أرسل بزر الإدخال</string>

View File

@ -245,6 +245,7 @@
<string name="NoSound">Kein Ton</string>
<string name="Default">Standard</string>
<string name="Support">Support</string>
<string name="OnlyIfSilent">Nur wenn stumm</string>
<string name="ChatBackground">Chat-Hintergrundbild</string>
<string name="MessagesSettings">Nachrichten</string>
<string name="SendByEnter">Mit Enter senden</string>

View File

@ -245,6 +245,7 @@
<string name="NoSound">Sin sonido</string>
<string name="Default">Por defecto</string>
<string name="Support">Soporte</string>
<string name="OnlyIfSilent">Only if silent</string>
<string name="ChatBackground">Fondo de chat</string>
<string name="MessagesSettings">Mensajes</string>
<string name="SendByEnter">Enviar con \'Intro\'</string>

View File

@ -245,6 +245,7 @@
<string name="NoSound">Nessun suono</string>
<string name="Default">Default</string>
<string name="Support">Supporto</string>
<string name="OnlyIfSilent">Solo se silenzioso</string>
<string name="ChatBackground">Sfondo chat</string>
<string name="MessagesSettings">Messaggi</string>
<string name="SendByEnter">Spedisci con Invio</string>

View File

@ -245,6 +245,7 @@
<string name="NoSound">알림음 없음</string>
<string name="Default">기본값</string>
<string name="Support">지원</string>
<string name="OnlyIfSilent">Only if silent</string>
<string name="ChatBackground">채팅방 배경화면</string>
<string name="MessagesSettings">메시지</string>
<string name="SendByEnter">엔터키로 메시지 전송</string>

View File

@ -245,6 +245,7 @@
<string name="NoSound">Geen geluid</string>
<string name="Default">Standaard</string>
<string name="Support">Ondersteuning</string>
<string name="OnlyIfSilent">Alleen indien stil</string>
<string name="ChatBackground">Achtergrond kiezen</string>
<string name="MessagesSettings">Berichten</string>
<string name="SendByEnter">Versturen met Enter</string>

View File

@ -245,6 +245,7 @@
<string name="NoSound">Sem som</string>
<string name="Default">Padrão</string>
<string name="Support">Suporte</string>
<string name="OnlyIfSilent">Only if silent</string>
<string name="ChatBackground">Papel de Parede</string>
<string name="MessagesSettings">Mensagens</string>
<string name="SendByEnter">Enviar usando \'Enter\'</string>

View File

@ -245,6 +245,7 @@
<string name="NoSound">Sem som</string>
<string name="Default">Padrão</string>
<string name="Support">Suporte</string>
<string name="OnlyIfSilent">Only if silent</string>
<string name="ChatBackground">Papel de Parede</string>
<string name="MessagesSettings">Mensagens</string>
<string name="SendByEnter">Enviar usando \'Enter\'</string>

View File

@ -245,6 +245,7 @@
<string name="NoSound">No sound</string>
<string name="Default">Default</string>
<string name="Support">Support</string>
<string name="OnlyIfSilent">Only if silent</string>
<string name="ChatBackground">Chat Background</string>
<string name="MessagesSettings">Messages</string>
<string name="SendByEnter">Send by Enter</string>