Commit d3afc836 authored by DrKLO's avatar DrKLO

Notification improvements

parent c549e8bc
...@@ -82,7 +82,7 @@ android { ...@@ -82,7 +82,7 @@ android {
defaultConfig { defaultConfig {
minSdkVersion 8 minSdkVersion 8
targetSdkVersion 19 targetSdkVersion 19
versionCode 269 versionCode 270
versionName "1.5.8" versionName "1.6.0"
} }
} }
...@@ -18,7 +18,6 @@ import android.media.AudioRecord; ...@@ -18,7 +18,6 @@ import android.media.AudioRecord;
import android.media.AudioTrack; import android.media.AudioTrack;
import android.media.MediaPlayer; import android.media.MediaPlayer;
import android.media.MediaRecorder; import android.media.MediaRecorder;
import android.media.audiofx.AutomaticGainControl;
import android.net.Uri; import android.net.Uri;
import android.os.Environment; import android.os.Environment;
import android.os.ParcelFileDescriptor; import android.os.ParcelFileDescriptor;
...@@ -165,7 +164,6 @@ public class MediaController implements NotificationCenter.NotificationCenterDel ...@@ -165,7 +164,6 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
private final Integer progressTimerSync = 1; private final Integer progressTimerSync = 1;
private AudioRecord audioRecorder = null; private AudioRecord audioRecorder = null;
private Object audioGainObj = null;
private TLRPC.TL_audio recordingAudio = null; private TLRPC.TL_audio recordingAudio = null;
private File recordingAudioFile = null; private File recordingAudioFile = null;
private long recordStartTime; private long recordStartTime;
...@@ -879,7 +877,9 @@ public class MediaController implements NotificationCenter.NotificationCenterDel ...@@ -879,7 +877,9 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
if (currentTotalPcmDuration * progress == currentTotalPcmDuration) { if (currentTotalPcmDuration * progress == currentTotalPcmDuration) {
return; return;
} }
if (!isPaused) {
audioTrackPlayer.pause(); audioTrackPlayer.pause();
}
audioTrackPlayer.flush(); audioTrackPlayer.flush();
fileDecodingQueue.postRunnable(new Runnable() { fileDecodingQueue.postRunnable(new Runnable() {
@Override @Override
...@@ -892,15 +892,16 @@ public class MediaController implements NotificationCenter.NotificationCenterDel ...@@ -892,15 +892,16 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
Utilities.RunOnUIThread(new Runnable() { Utilities.RunOnUIThread(new Runnable() {
@Override @Override
public void run() { public void run() {
if (!isPaused) {
ignoreFirstProgress = 3; ignoreFirstProgress = 3;
//audioTrackPlayer.setNotificationMarkerPosition((int)(currentTotalPcmDuration * (1 - playingMessageObject.audioProgress))); lastPlayPcm = (long) (currentTotalPcmDuration * progress);
lastPlayPcm = (long)(currentTotalPcmDuration * progress);
if (audioTrackPlayer != null) { if (audioTrackPlayer != null) {
audioTrackPlayer.play(); audioTrackPlayer.play();
} }
lastProgress = (int)(currentTotalPcmDuration / 48.0f * progress); lastProgress = (int) (currentTotalPcmDuration / 48.0f * progress);
checkPlayerQueue(); checkPlayerQueue();
} }
}
}); });
} }
}); });
...@@ -1176,31 +1177,6 @@ public class MediaController implements NotificationCenter.NotificationCenterDel ...@@ -1176,31 +1177,6 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
recordDialogId = dialog_id; recordDialogId = dialog_id;
fileBuffer.rewind(); fileBuffer.rewind();
if (android.os.Build.VERSION.SDK_INT >= 16) {
File f = new File("/vendor/lib/libaudioeffect_jni.so");
File f2 = new File("/system/lib/libaudioeffect_jni.so");
if (f.exists() || f2.exists()) {
AutomaticGainControl agc = null;
try {
if (AutomaticGainControl.isAvailable()) {
agc = AutomaticGainControl.create(audioRecorder.getAudioSessionId());
agc.setEnabled(true);
audioGainObj = agc;
}
} catch (Exception e) {
try {
if (agc != null) {
agc.release();
agc = null;
}
} catch (Exception e2) {
FileLog.e("tmessages", e2);
}
FileLog.e("tmessages", e);
}
}
}
audioRecorder.startRecording(); audioRecorder.startRecording();
} catch (Exception e) { } catch (Exception e) {
FileLog.e("tmessages", e); FileLog.e("tmessages", e);
...@@ -1215,18 +1191,6 @@ public class MediaController implements NotificationCenter.NotificationCenterDel ...@@ -1215,18 +1191,6 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
FileLog.e("tmessages", e2); FileLog.e("tmessages", e2);
} }
if (android.os.Build.VERSION.SDK_INT >= 16 && audioGainObj != null) {
AutomaticGainControl agc = (AutomaticGainControl)audioGainObj;
try {
if (agc != null) {
agc.release();
agc = null;
}
} catch (Exception e2) {
FileLog.e("tmessages", e2);
}
}
Utilities.RunOnUIThread(new Runnable() { Utilities.RunOnUIThread(new Runnable() {
@Override @Override
public void run() { public void run() {
...@@ -1279,17 +1243,6 @@ public class MediaController implements NotificationCenter.NotificationCenterDel ...@@ -1279,17 +1243,6 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
audioRecorder.release(); audioRecorder.release();
audioRecorder = null; audioRecorder = null;
} }
if (android.os.Build.VERSION.SDK_INT >= 16 && audioGainObj != null) {
AutomaticGainControl agc = (AutomaticGainControl)audioGainObj;
try {
if (agc != null) {
agc.release();
agc = null;
}
} catch (Exception e2) {
FileLog.e("tmessages", e2);
}
}
} catch (Exception e) { } catch (Exception e) {
FileLog.e("tmessages", e); FileLog.e("tmessages", e);
} }
......
...@@ -541,6 +541,10 @@ public class MessageObject { ...@@ -541,6 +541,10 @@ public class MessageObject {
return messageOwner.from_id == UserConfig.getClientUserId(); return messageOwner.from_id == UserConfig.getClientUserId();
} }
public boolean isUnread () {
return messageOwner.unread;
}
public long getDialogId() { public long getDialogId() {
if (messageOwner.dialog_id != 0) { if (messageOwner.dialog_id != 0) {
return messageOwner.dialog_id; return messageOwner.dialog_id;
......
...@@ -31,6 +31,7 @@ import android.text.TextUtils; ...@@ -31,6 +31,7 @@ import android.text.TextUtils;
import android.util.TypedValue; import android.util.TypedValue;
import android.view.Gravity; import android.view.Gravity;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.ViewParent; import android.view.ViewParent;
...@@ -51,6 +52,7 @@ import org.telegram.PhoneFormat.PhoneFormat; ...@@ -51,6 +52,7 @@ import org.telegram.PhoneFormat.PhoneFormat;
import org.telegram.android.LocaleController; import org.telegram.android.LocaleController;
import org.telegram.android.MediaController; import org.telegram.android.MediaController;
import org.telegram.android.MessagesStorage; import org.telegram.android.MessagesStorage;
import org.telegram.android.NotificationsController;
import org.telegram.messenger.TLRPC; import org.telegram.messenger.TLRPC;
import org.telegram.android.ContactsController; import org.telegram.android.ContactsController;
import org.telegram.messenger.FileLog; import org.telegram.messenger.FileLog;
...@@ -334,12 +336,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not ...@@ -334,12 +336,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (currentChat != null) { if (currentChat != null) {
downloadPhotos = preferences.getInt("photo_download_chat2", 0); downloadPhotos = preferences.getInt("photo_download_chat2", 0);
} else {
downloadPhotos = preferences.getInt("photo_download_user2", 0);
}
if (currentChat != null) {
downloadAudios = preferences.getInt("audio_download_chat2", 0); downloadAudios = preferences.getInt("audio_download_chat2", 0);
} else { } else {
downloadPhotos = preferences.getInt("photo_download_user2", 0);
downloadAudios = preferences.getInt("audio_download_user2", 0); downloadAudios = preferences.getInt("audio_download_user2", 0);
} }
...@@ -567,6 +566,12 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not ...@@ -567,6 +566,12 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
selectedMessagesCountTextView.setEllipsize(TextUtils.TruncateAt.END); selectedMessagesCountTextView.setEllipsize(TextUtils.TruncateAt.END);
selectedMessagesCountTextView.setPadding(AndroidUtilities.dp(6), 0, 0, 0); selectedMessagesCountTextView.setPadding(AndroidUtilities.dp(6), 0, 0, 0);
selectedMessagesCountTextView.setGravity(Gravity.CENTER_VERTICAL); selectedMessagesCountTextView.setGravity(Gravity.CENTER_VERTICAL);
selectedMessagesCountTextView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return true;
}
});
actionMode.addView(selectedMessagesCountTextView); actionMode.addView(selectedMessagesCountTextView);
layoutParams = (LinearLayout.LayoutParams)selectedMessagesCountTextView.getLayoutParams(); layoutParams = (LinearLayout.LayoutParams)selectedMessagesCountTextView.getLayoutParams();
layoutParams.weight = 1; layoutParams.weight = 1;
...@@ -2335,7 +2340,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not ...@@ -2335,7 +2340,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (chatAdapter != null) { if (chatAdapter != null) {
chatAdapter.notifyDataSetChanged(); chatAdapter.notifyDataSetChanged();
} }
MessagesController.getInstance().openned_dialog_id = dialog_id; NotificationsController.getInstance().setOpennedDialogId(dialog_id);
if (scrollToTopOnResume) { if (scrollToTopOnResume) {
if (scrollToTopUnReadOnResume && unreadMessageObject != null) { if (scrollToTopUnReadOnResume && unreadMessageObject != null) {
if (chatListView != null) { if (chatListView != null) {
...@@ -2421,7 +2426,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not ...@@ -2421,7 +2426,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
actionBarLayer.hideActionMode(); actionBarLayer.hideActionMode();
chatActivityEnterView.hideEmojiPopup(); chatActivityEnterView.hideEmojiPopup();
paused = true; paused = true;
MessagesController.getInstance().openned_dialog_id = 0; NotificationsController.getInstance().setOpennedDialogId(0);
String text = chatActivityEnterView.getFieldText(); String text = chatActivityEnterView.getFieldText();
if (text != null) { if (text != null) {
...@@ -3468,6 +3473,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not ...@@ -3468,6 +3473,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
addContactView.setVisibility(View.GONE); addContactView.setVisibility(View.GONE);
} }
} else if (type == 7) { } else if (type == 7) {
messageTextView.setTextSize(16);
messageTextView.setText(LocaleController.formatPluralString("NewMessages", unread_to_load)); messageTextView.setText(LocaleController.formatPluralString("NewMessages", unread_to_load));
} else if (type == 8 || type == 9) { } else if (type == 8 || type == 9) {
TLRPC.Document document = message.messageOwner.media.document; TLRPC.Document document = message.messageOwner.media.document;
......
...@@ -512,7 +512,6 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen ...@@ -512,7 +512,6 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
ApplicationLoader.mainInterfacePaused = false; ApplicationLoader.mainInterfacePaused = false;
ConnectionsManager.getInstance().setAppPaused(false, false); ConnectionsManager.getInstance().setAppPaused(false, false);
actionBar.setBackOverlayVisible(currentConnectionState != 0); actionBar.setBackOverlayVisible(currentConnectionState != 0);
MessagesController.getInstance().dismissNotification();
} }
@Override @Override
...@@ -647,4 +646,9 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen ...@@ -647,4 +646,9 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
} }
return super.onPreIme(); return super.onPreIme();
} }
@Override
public void onLowMemory() {
super.onLowMemory();
}
} }
...@@ -118,8 +118,8 @@ public class AvatarUpdater implements NotificationCenter.NotificationCenterDeleg ...@@ -118,8 +118,8 @@ public class AvatarUpdater implements NotificationCenter.NotificationCenterDeleg
if (bitmap == null) { if (bitmap == null) {
return; return;
} }
smallPhoto = FileLoader.scaleAndSaveImage(bitmap, 100, 100, 87, false); smallPhoto = FileLoader.scaleAndSaveImage(bitmap, 100, 100, 80, false);
bigPhoto = FileLoader.scaleAndSaveImage(bitmap, 800, 800, 87, false); bigPhoto = FileLoader.scaleAndSaveImage(bitmap, 800, 800, 80, false);
if (bigPhoto != null && smallPhoto != null) { if (bigPhoto != null && smallPhoto != null) {
if (returnOnly) { if (returnOnly) {
if (delegate != null) { if (delegate != null) {
......
...@@ -96,6 +96,7 @@ public class ChatActivityEnterView implements NotificationCenter.NotificationCen ...@@ -96,6 +96,7 @@ public class ChatActivityEnterView implements NotificationCenter.NotificationCen
NotificationCenter.getInstance().removeObserver(this, MediaController.recordStopped); NotificationCenter.getInstance().removeObserver(this, MediaController.recordStopped);
NotificationCenter.getInstance().removeObserver(this, MediaController.recordProgressChanged); NotificationCenter.getInstance().removeObserver(this, MediaController.recordProgressChanged);
NotificationCenter.getInstance().removeObserver(this, MessagesController.closeChats); NotificationCenter.getInstance().removeObserver(this, MessagesController.closeChats);
NotificationCenter.getInstance().removeObserver(this, MediaController.audioDidSent);
NotificationCenter.getInstance().removeObserver(this, 999); NotificationCenter.getInstance().removeObserver(this, 999);
if (mWakeLock != null) { if (mWakeLock != null) {
try { try {
...@@ -197,6 +198,7 @@ public class ChatActivityEnterView implements NotificationCenter.NotificationCen ...@@ -197,6 +198,7 @@ public class ChatActivityEnterView implements NotificationCenter.NotificationCen
startedDraggingX = -1; startedDraggingX = -1;
MediaController.getInstance().startRecording(dialog_id); MediaController.getInstance().startRecording(dialog_id);
updateAudioRecordIntefrace(); updateAudioRecordIntefrace();
audioSendButton.getParent().requestDisallowInterceptTouchEvent(true);
} else if (motionEvent.getAction() == MotionEvent.ACTION_UP || motionEvent.getAction() == MotionEvent.ACTION_CANCEL) { } else if (motionEvent.getAction() == MotionEvent.ACTION_UP || motionEvent.getAction() == MotionEvent.ACTION_CANCEL) {
startedDraggingX = -1; startedDraggingX = -1;
MediaController.getInstance().stopRecording(true); MediaController.getInstance().stopRecording(true);
...@@ -590,9 +592,11 @@ public class ChatActivityEnterView implements NotificationCenter.NotificationCen ...@@ -590,9 +592,11 @@ public class ChatActivityEnterView implements NotificationCenter.NotificationCen
sizeNotifierRelativeLayout.post(new Runnable() { sizeNotifierRelativeLayout.post(new Runnable() {
@Override @Override
public void run() { public void run() {
if (sizeNotifierRelativeLayout != null) {
sizeNotifierRelativeLayout.setPadding(0, 0, 0, layoutParams.height); sizeNotifierRelativeLayout.setPadding(0, 0, 0, layoutParams.height);
sizeNotifierRelativeLayout.requestLayout(); sizeNotifierRelativeLayout.requestLayout();
} }
}
}); });
} }
} }
......
...@@ -35,6 +35,7 @@ public class ImageReceiver { ...@@ -35,6 +35,7 @@ public class ImageReceiver {
public Rect drawRegion = new Rect(); public Rect drawRegion = new Rect();
private boolean isVisible = true; private boolean isVisible = true;
private boolean selfSetting = false; private boolean selfSetting = false;
public boolean isAspectFit = false;
public void setImage(TLRPC.FileLocation path, String filter, Drawable placeholder) { public void setImage(TLRPC.FileLocation path, String filter, Drawable placeholder) {
setImage(path, null, filter, placeholder, 0); setImage(path, null, filter, placeholder, 0);
...@@ -188,6 +189,16 @@ public class ImageReceiver { ...@@ -188,6 +189,16 @@ public class ImageReceiver {
float scaleW = bitmapW / (float)w; float scaleW = bitmapW / (float)w;
float scaleH = bitmapH / (float)h; float scaleH = bitmapH / (float)h;
if (isAspectFit) {
float scale = Math.max(scaleW, scaleH);
canvas.save();
bitmapW /= scale;
bitmapH /= scale;
drawRegion.set(x + (w - bitmapW) / 2, y + (h - bitmapH) / 2, x + (w + bitmapW) / 2, y + (h + bitmapH) / 2);
bitmapDrawable.setBounds(drawRegion);
bitmapDrawable.draw(canvas);
canvas.restore();
} else {
if (Math.abs(scaleW - scaleH) > 0.00001f) { if (Math.abs(scaleW - scaleH) > 0.00001f) {
canvas.save(); canvas.save();
canvas.clipRect(x, y, x + w, y + h); canvas.clipRect(x, y, x + w, y + h);
...@@ -212,6 +223,7 @@ public class ImageReceiver { ...@@ -212,6 +223,7 @@ public class ImageReceiver {
bitmapDrawable.draw(canvas); bitmapDrawable.draw(canvas);
} }
} }
}
} else if (last_placeholder != null) { } else if (last_placeholder != null) {
drawRegion.set(x, y, x + w, y + h); drawRegion.set(x, y, x + w, y + h);
last_placeholder.setBounds(drawRegion); last_placeholder.setBounds(drawRegion);
......
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/text_container"
android:background="@drawable/list_selector"
android:layout_gravity="top">
<FrameLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_gravity="center"
android:id="@+id/audio_container"/>
</FrameLayout>
\ No newline at end of file
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="top"
android:id="@+id/text_container"
android:padding="10dp"
android:background="@drawable/list_selector">
<org.telegram.ui.Views.BackupImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/message_image"
android:layout_gravity="center"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="16dp"
android:textColor="#ff000000"
android:id="@+id/message_text"
android:gravity="center"
android:layout_gravity="center"/>
</FrameLayout>
\ No newline at end of file
...@@ -19,35 +19,6 @@ ...@@ -19,35 +19,6 @@
android:layout_marginRight="12dp" android:layout_marginRight="12dp"
android:id="@+id/popup_container"> android:id="@+id/popup_container">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="48dp"
android:layout_marginTop="48dp"
android:fillViewport="true"
android:id="@+id/text_scroll">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:padding="10dp"
android:id="@+id/text_container"
android:background="@drawable/list_selector">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="16dp"
android:textColor="#ff000000"
android:id="@+id/message_text"
android:gravity="center"
android:layout_gravity="center"/>
</LinearLayout>
</ScrollView>
<RelativeLayout <RelativeLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
...@@ -93,7 +64,6 @@ ...@@ -93,7 +64,6 @@
android:textSize="18dp" android:textSize="18dp"
android:textColorHint="#909090" android:textColorHint="#909090"
android:ems="10" android:ems="10"
android:imeOptions="flagNoExtractUi"
android:inputType="textCapSentences|textMultiLine" android:inputType="textCapSentences|textMultiLine"
android:layout_alignParentTop="true" android:layout_alignParentTop="true"
android:paddingBottom="12dp" android:paddingBottom="12dp"
......
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:id="@+id/text_scroll">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:padding="10dp"
android:id="@+id/text_container"
android:background="@drawable/list_selector"
android:orientation="horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="16dp"
android:textColor="#ff000000"
android:id="@+id/message_text"
android:gravity="center"
android:layout_gravity="center"/>
</LinearLayout>
</ScrollView>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment