Commit 1c2010a4 authored by DrKLO's avatar DrKLO

Bug fixes

parent d24578fe
......@@ -83,7 +83,7 @@ android {
defaultConfig {
minSdkVersion 8
targetSdkVersion 19
versionCode 281
versionName "1.6.0"
versionCode 286
versionName "1.6.1"
}
}
......@@ -174,15 +174,23 @@ public class AndroidUtilities {
public static File getCacheDir() {
if (externalCacheNotAvailableState == 1 || externalCacheNotAvailableState == 0 && Environment.getExternalStorageState().startsWith(Environment.MEDIA_MOUNTED)) {
externalCacheNotAvailableState = 1;
File file = ApplicationLoader.applicationContext.getExternalCacheDir();
if (file != null) {
return file;
try {
File file = ApplicationLoader.applicationContext.getExternalCacheDir();
if (file != null) {
return file;
}
} catch (Exception e) {
FileLog.e("tmessages", e);
}
}
externalCacheNotAvailableState = 2;
File file = ApplicationLoader.applicationContext.getCacheDir();
if (file != null) {
return file;
try {
File file = ApplicationLoader.applicationContext.getCacheDir();
if (file != null) {
return file;
}
} catch (Exception e) {
FileLog.e("tmessages", e);
}
return new File("");
}
......
......@@ -354,30 +354,45 @@ public class NotificationsController {
.setContentIntent(contentIntent);
String lastMessage = null;
NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
inboxStyle.setBigContentTitle(name);
int count = Math.min(10, pushMessages.size());
for (int i = 0; i < count; i++) {
String message = getStringForMessage(pushMessages.get(i));
if (pushMessages.size() == 1) {
String message = lastMessage = getStringForMessage(pushMessages.get(0));
if (message == null) {
continue;
return;
}
if (i == 0) {
lastMessage = message;
if (replace) {
if (chat != null) {
message = message.replace(" @ " + name, "");
} else {
message = message.replace(name + ": ", "").replace(name + " ", "");
}
}
if (pushDialogs.size() == 1) {
if (replace) {
if (chat != null) {
message = message.replace(" @ " + name, "");
} else {
message = message.replace(name + ": ", "").replace(name + " ", "");
mBuilder.setStyle(new NotificationCompat.BigTextStyle().bigText(message));
} else {
NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
inboxStyle.setBigContentTitle(name);
int count = Math.min(10, pushMessages.size());
for (int i = 0; i < count; i++) {
String message = getStringForMessage(pushMessages.get(i));
if (message == null) {
continue;
}
if (i == 0) {
lastMessage = message;
}
if (pushDialogs.size() == 1) {
if (replace) {
if (chat != null) {
message = message.replace(" @ " + name, "");
} else {
message = message.replace(name + ": ", "").replace(name + " ", "");
}
}
}
inboxStyle.addLine(message);
}
inboxStyle.addLine(message);
inboxStyle.setSummaryText(detailText);
mBuilder.setStyle(inboxStyle);
}
inboxStyle.setSummaryText(detailText);
mBuilder.setStyle(inboxStyle);
if (photoPath != null) {
Bitmap img = FileLoader.getInstance().getImageFromMemory(photoPath, null, null, "50_50", false);
......@@ -547,38 +562,47 @@ public class NotificationsController {
public void processDialogsUpdateRead(final HashMap<Long, Integer> dialogsToUpdate, boolean replace) {
int old_unread_count = total_unread_count;
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Context.MODE_PRIVATE);
for (HashMap.Entry<Long, Integer> entry : dialogsToUpdate.entrySet()) {
Long dialog_id = entry.getKey();
long dialog_id = entry.getKey();
int notify_override = preferences.getInt("notify2_" + dialog_id, 0);
boolean isChat = (int)dialog_id < 0;
Integer currentCount = pushDialogs.get(dialog_id);
Integer newCount = entry.getValue();
if (replace) {
if (currentCount != null) {
total_unread_count -= currentCount;
}
if (newCount == 0) {
pushDialogs.remove(dialog_id);
if (!(notify_override == 2 || (!preferences.getBoolean("EnableAll", true) || isChat && !preferences.getBoolean("EnableGroup", true)) && notify_override == 0)) {
Integer newCount = entry.getValue();
if (replace) {
if (currentCount != null) {
total_unread_count -= currentCount;
}
if (newCount == 0) {
pushDialogs.remove(dialog_id);
} else {
total_unread_count += newCount;
pushDialogs.put(dialog_id, newCount);
}
} else {
if (currentCount == null) {
currentCount = 0;
}
currentCount += newCount;
total_unread_count += newCount;
pushDialogs.put(dialog_id, newCount);
pushDialogs.put(dialog_id, currentCount);
}
} else {
if (currentCount == null) {
currentCount = 0;
}
currentCount += newCount;
total_unread_count += newCount;
pushDialogs.put(dialog_id, currentCount);
}
}
if (old_unread_count != total_unread_count) {
showOrUpdateNotification(notifyCheck);
notifyCheck = false;
}
setBadge(ApplicationLoader.applicationContext, total_unread_count);
if (preferences.getBoolean("badgeNumber", true)) {
setBadge(ApplicationLoader.applicationContext, total_unread_count);
}
}
public void processLoadedUnreadMessages(HashMap<Long, Integer> dialogs) {
pushDialogs.clear();
total_unread_count = 0;
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Context.MODE_PRIVATE);
String dialogsToLoad = "";
for (HashMap.Entry<Long, Integer> entry : dialogs.entrySet()) {
......@@ -594,7 +618,20 @@ public class NotificationsController {
dialogsToLoad += "" + dialog_id;
}
}
setBadge(ApplicationLoader.applicationContext, total_unread_count);
if (total_unread_count == 0) {
pushMessages.clear();
pushMessagesDict.clear();
popupMessages.clear();
showOrUpdateNotification(false);
NotificationCenter.getInstance().postNotificationName(pushMessagesUpdated);
}
if (preferences.getBoolean("badgeNumber", true)) {
setBadge(ApplicationLoader.applicationContext, total_unread_count);
}
}
public void setBadgeEnabled(boolean enabled) {
setBadge(ApplicationLoader.applicationContext, enabled ? total_unread_count : 0);
}
private void setBadge(Context context, int count) {
......
......@@ -101,15 +101,18 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
public void run() {
Utilities.stageQueue.handler.removeCallbacks(stageRunnable);
if (datacenters != null) {
Datacenter datacenter = datacenterWithId(currentDatacenterId);
if (sendingPushPing && lastPushPingTime < System.currentTimeMillis() - 30000 || Math.abs(lastPushPingTime - System.currentTimeMillis()) > 60000 * 3 + 10000) {
lastPushPingTime = 0;
sendingPushPing = false;
if (datacenter != null && datacenter.pushConnection != null) {
datacenter.pushConnection.suspendConnection(true);
}
FileLog.e("tmessages", "push ping timeout");
}
if (lastPushPingTime < System.currentTimeMillis() - 60000 * 3) {
FileLog.e("tmessages", "time for push ping");
lastPushPingTime = System.currentTimeMillis();
Datacenter datacenter = datacenterWithId(currentDatacenterId);
if (datacenter != null) {
generatePing(datacenter, true);
}
......@@ -448,7 +451,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
datacenter = new Datacenter();
datacenter.datacenterId = 4;
datacenter.addAddressAndPort("31.210.235.12", 443);
datacenter.addAddressAndPort("149.154.167.90", 443);
datacenters.put(datacenter.datacenterId, datacenter);
datacenter = new Datacenter();
......@@ -2374,7 +2377,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
FileLog.e("tmessages", "no network available");
}
} catch (Exception e) {
FileLog.e("tmessages", "NETWORK STATE GET ERROR");
FileLog.e("tmessages", "NETWORK STATE GET ERROR", e);
}
}
final int stateCopy = connectionState;
......
......@@ -674,7 +674,7 @@ public class FileLoadOperation {
}
}
if (downloadedBytes % downloadChunkSize == 0 || totalBytesCount > 0 && totalBytesCount > downloadedBytes) {
if (totalBytesCount != downloadedBytes && downloadedBytes % downloadChunkSize == 0 || totalBytesCount > 0 && totalBytesCount > downloadedBytes) {
startDownloadRequest();
} else {
onFinishLoadingFile();
......
......@@ -174,17 +174,13 @@ public class HandshakeAction extends Action implements TcpConnection.TcpConnecti
}
ByteBufferDesc sendMessageData(TLObject message, long messageId) {
ByteBufferDesc innerOs = BuffersStorage.getInstance().getFreeBuffer(message.getObjectSize());
message.serializeToStream(innerOs);
message.freeResources();
ByteBufferDesc messageOs = BuffersStorage.getInstance().getFreeBuffer(8 + 8 + 4 + innerOs.length());
int messageLength = message.getObjectSize();
ByteBufferDesc messageOs = BuffersStorage.getInstance().getFreeBuffer(8 + 8 + 4 + messageLength);
messageOs.writeInt64(0);
messageOs.writeInt64(messageId);
messageOs.writeInt32(innerOs.length());
innerOs.position(0);
messageOs.writeRaw(innerOs);
BuffersStorage.getInstance().reuseFreeBuffer(innerOs);
messageOs.writeInt32(messageLength);
message.serializeToStream(messageOs);
message.freeResources();
datacenter.connection.sendData(messageOs, false, false);
return messageOs;
......
......@@ -30,6 +30,7 @@ import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.gcm.GoogleCloudMessaging;
import org.telegram.android.AndroidUtilities;
import org.telegram.android.ContactsController;
import org.telegram.android.NotificationsService;
import org.telegram.messenger.BuildVars;
import org.telegram.messenger.ConnectionsManager;
......@@ -128,6 +129,8 @@ public class ApplicationLoader extends Application {
ApplicationLoader app = (ApplicationLoader)ApplicationLoader.applicationContext;
app.initPlayServices();
FileLog.e("tmessages", "app initied");
ContactsController.getInstance().checkAppAccount();
}
@Override
......
......@@ -307,7 +307,7 @@ public class ChatOrUserCell extends BaseCell {
nameString = nameString2.replace("\n", " ");
}
if (nameString.length() == 0) {
if (user.phone != null && user.phone.length() != 0) {
if (user != null && user.phone != null && user.phone.length() != 0) {
nameString = PhoneFormat.getInstance().format("+" + user.phone);
} else {
nameString = LocaleController.getString("HiddenName", R.string.HiddenName);
......
......@@ -89,7 +89,8 @@ import java.util.HashMap;
import java.util.concurrent.Semaphore;
public class ChatActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate, MessagesActivity.MessagesActivityDelegate,
DocumentSelectActivity.DocumentSelectActivityDelegate, PhotoViewer.PhotoViewerProvider, PhotoPickerActivity.PhotoPickerActivityDelegate {
DocumentSelectActivity.DocumentSelectActivityDelegate, PhotoViewer.PhotoViewerProvider, PhotoPickerActivity.PhotoPickerActivityDelegate,
VideoEditorActivity.VideoEditorActivityDelegate {
private ChatActivityEnterView chatActivityEnterView;
private View timeItem;
......@@ -1318,7 +1319,15 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
currentPicturePath = null;
}
processSendingVideo(videoPath);
/*if(android.os.Build.VERSION.SDK_INT >= 10) {
Bundle args = new Bundle();
args.putString("videoPath", videoPath);
VideoEditorActivity fragment = new VideoEditorActivity(args);
fragment.setDelegate(this);
presentFragment(fragment);
} else {*/
processSendingVideo(videoPath);
//}
} else if (requestCode == 21) {
if (data == null || data.getData() == null) {
showAttachmentError();
......@@ -1339,6 +1348,11 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
}
@Override
public void didFinishedVideoConverting(String videoPath) {
processSendingVideo(videoPath);
}
private void showAttachmentError() {
if (getParentActivity() == null) {
return;
......
......@@ -133,6 +133,9 @@ public class LocationActivity extends BaseFragment implements NotificationCenter
}
avatarImageView = (BackupImageView)fragmentView.findViewById(R.id.location_avatar_view);
if (avatarImageView != null) {
avatarImageView.processDetach = false;
}
nameTextView = (TextView)fragmentView.findViewById(R.id.location_name_label);
distanceTextView = (TextView)fragmentView.findViewById(R.id.location_distance_label);
View bottomView = fragmentView.findViewById(R.id.location_bottom_view);
......
......@@ -506,12 +506,12 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
builder.setMessage(LocaleController.formatStringSimple(selectAlertString, Utilities.formatName(user.first_name, user.last_name)));
}
CheckBox checkBox = null;
if (delegate instanceof ChatActivity) {
/*if (delegate instanceof ChatActivity) {
checkBox = new CheckBox(getParentActivity());
checkBox.setText(LocaleController.getString("ForwardFromMyName", R.string.ForwardFromMyName));
checkBox.setChecked(false);
builder.setView(checkBox);
}
}*/
final CheckBox checkBoxFinal = checkBox;
builder.setPositiveButton(R.string.OK, new DialogInterface.OnClickListener() {
@Override
......
......@@ -150,6 +150,7 @@ public class PopupNotificationActivity extends Activity implements NotificationC
NotificationCenter.getInstance().addObserver(this, MessagesController.updateInterfaces);
NotificationCenter.getInstance().addObserver(this, MediaController.audioProgressDidChanged);
NotificationCenter.getInstance().addObserver(this, MediaController.audioDidReset);
NotificationCenter.getInstance().addObserver(this, MessagesController.contactsDidLoaded);
NotificationCenter.getInstance().addObserver(this, 999);
chatActivityEnterView = new ChatActivityEnterView();
......@@ -940,6 +941,8 @@ public class PopupNotificationActivity extends Activity implements NotificationC
view.invalidate();
}
}
} else if (id == MessagesController.contactsDidLoaded) {
updateSubtitle();
}
}
......@@ -962,6 +965,7 @@ public class PopupNotificationActivity extends Activity implements NotificationC
NotificationCenter.getInstance().removeObserver(this, MessagesController.updateInterfaces);
NotificationCenter.getInstance().removeObserver(this, MediaController.audioProgressDidChanged);
NotificationCenter.getInstance().removeObserver(this, MediaController.audioDidReset);
NotificationCenter.getInstance().removeObserver(this, MessagesController.contactsDidLoaded);
NotificationCenter.getInstance().removeObserver(this, 999);
if (chatActivityEnterView != null) {
chatActivityEnterView.onDestroy();
......
......@@ -293,7 +293,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
} else if (i == notificationRow) {
presentFragment(new SettingsNotificationsActivity());
} else if (i == blockedRow) {
presentFragment(new SettingsBlockedUsers());
presentFragment(new SettingsBlockedUsersActivity());
} else if (i == backgroundRow) {
presentFragment(new SettingsWallpapersActivity());
} else if (i == askQuestionRow) {
......
......@@ -38,7 +38,7 @@ import org.telegram.ui.Views.ActionBar.BaseFragment;
import java.util.ArrayList;
import java.util.HashMap;
public class SettingsBlockedUsers extends BaseFragment implements NotificationCenter.NotificationCenterDelegate, ContactsActivity.ContactsActivityDelegate {
public class SettingsBlockedUsersActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate, ContactsActivity.ContactsActivityDelegate {
private ListView listView;
private ListAdapter listViewAdapter;
private boolean loading;
......@@ -82,7 +82,7 @@ public class SettingsBlockedUsers extends BaseFragment implements NotificationCe
args.putBoolean("usersAsSections", true);
args.putBoolean("returnAsResult", true);
ContactsActivity fragment = new ContactsActivity(args);
fragment.setDelegate(SettingsBlockedUsers.this);
fragment.setDelegate(SettingsBlockedUsersActivity.this);
presentFragment(fragment);
}
}
......
......@@ -28,6 +28,7 @@ import android.widget.TextView;
import android.widget.Toast;
import org.telegram.android.LocaleController;
import org.telegram.android.NotificationsController;
import org.telegram.messenger.NotificationCenter;
import org.telegram.messenger.TLObject;
import org.telegram.messenger.TLRPC;
......@@ -67,7 +68,8 @@ public class SettingsNotificationsActivity extends BaseFragment implements Notif
private int inappPreviewRow;
private int eventsSectionRow;
private int contactJoinedRow;
private int pebbleSectionRow;
private int otherSectionRow;
private int badgeNumberRow;
private int pebbleAlertRow;
private int resetSectionRow;
private int resetNotificationsRow;
......@@ -96,7 +98,8 @@ public class SettingsNotificationsActivity extends BaseFragment implements Notif
inappPreviewRow = rowCount++;
eventsSectionRow = rowCount++;
contactJoinedRow = rowCount++;
pebbleSectionRow = rowCount++;
otherSectionRow = rowCount++;
badgeNumberRow = rowCount++;
pebbleAlertRow = rowCount++;
resetSectionRow = rowCount++;
resetNotificationsRow = rowCount++;
......@@ -279,6 +282,14 @@ public class SettingsNotificationsActivity extends BaseFragment implements Notif
editor.putBoolean("EnablePebbleNotifications", !enabled);
editor.commit();
listView.invalidateViews();
} else if (i == badgeNumberRow) {
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
boolean enabled = preferences.getBoolean("badgeNumber", true);
editor.putBoolean("badgeNumber", !enabled);
editor.commit();
listView.invalidateViews();
NotificationsController.getInstance().setBadgeEnabled(!enabled);
} else if (i == notificationsServiceRow) {
final SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
boolean enabled = preferences.getBoolean("pushService", true);
......@@ -480,7 +491,7 @@ public class SettingsNotificationsActivity extends BaseFragment implements Notif
@Override
public boolean isEnabled(int i) {
return !(i == messageSectionRow || i == groupSectionRow || i == inappSectionRow || i == eventsSectionRow || i == pebbleSectionRow || i == resetSectionRow);
return !(i == messageSectionRow || i == groupSectionRow || i == inappSectionRow || i == eventsSectionRow || i == otherSectionRow || i == resetSectionRow);
}
@Override
......@@ -520,8 +531,8 @@ public class SettingsNotificationsActivity extends BaseFragment implements Notif
textView.setText(LocaleController.getString("InAppNotifications", R.string.InAppNotifications));
} else if (i == eventsSectionRow) {
textView.setText(LocaleController.getString("Events", R.string.Events));
} else if (i == pebbleSectionRow) {
textView.setText(LocaleController.getString("Pebble", R.string.Pebble));
} else if (i == otherSectionRow) {
textView.setText(LocaleController.getString("PhoneOther", R.string.PhoneOther));
} else if (i == resetSectionRow) {
textView.setText(LocaleController.getString("Reset", R.string.Reset));
}
......@@ -581,12 +592,16 @@ public class SettingsNotificationsActivity extends BaseFragment implements Notif
divider.setVisibility(View.INVISIBLE);
} else if (i == pebbleAlertRow) {
enabled = preferences.getBoolean("EnablePebbleNotifications", false);
textView.setText(LocaleController.getString("Alert", R.string.Alert));
textView.setText(LocaleController.getString("Pebble", R.string.Pebble));
divider.setVisibility(View.INVISIBLE);
} else if (i == notificationsServiceRow) {
enabled = preferences.getBoolean("pushService", true);
textView.setText(LocaleController.getString("NotificationsService", R.string.NotificationsService));
divider.setVisibility(View.INVISIBLE);
} else if (i == badgeNumberRow) {
enabled = preferences.getBoolean("badgeNumber", true);
textView.setText(LocaleController.getString("BadgeNumber", R.string.BadgeNumber));
divider.setVisibility(View.VISIBLE);
}
if (enabled) {
checkButton.setImageResource(R.drawable.btn_check_on);
......@@ -664,13 +679,13 @@ public class SettingsNotificationsActivity extends BaseFragment implements Notif
@Override
public int getItemViewType(int i) {
if (i == messageSectionRow || i == groupSectionRow || i == inappSectionRow || i == eventsSectionRow || i == pebbleSectionRow || i == resetSectionRow) {
if (i == messageSectionRow || i == groupSectionRow || i == inappSectionRow || i == eventsSectionRow || i == otherSectionRow || i == resetSectionRow) {
return 0;
} else if (i == messageAlertRow || i == messagePreviewRow || i == messageVibrateRow ||
i == groupAlertRow || i == groupPreviewRow || i == groupVibrateRow ||
i == inappSoundRow || i == inappVibrateRow || i == inappPreviewRow ||
i == contactJoinedRow ||
i == pebbleAlertRow || i == notificationsServiceRow) {
i == pebbleAlertRow || i == notificationsServiceRow || i == badgeNumberRow) {
return 1;
} else if (i == messageLedRow || i == groupLedRow) {
return 3;
......
......@@ -15,6 +15,8 @@ import android.graphics.Paint;
import android.graphics.Rect;
import android.view.View;
import org.telegram.messenger.FileLog;
public class ClippingImageView extends View {
private int clipBottom;
private int clipLeft;
......@@ -64,7 +66,11 @@ public class ClippingImageView extends View {
canvas.save();
canvas.clipRect(clipLeft / getScaleY(), clipTop / getScaleY(), getWidth() - clipRight / getScaleY(), getHeight() - clipBottom / getScaleY());
drawRect.set(0, 0, getWidth(), getHeight());
canvas.drawBitmap(this.bmp, null, drawRect, this.paint);
try {
canvas.drawBitmap(this.bmp, null, drawRect, this.paint);
} catch (Exception e) {
FileLog.e("tmessages", e);
}
canvas.restore();
}
}
......
/*
* This is the source code of Telegram for Android v. 1.7.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.Views;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import org.telegram.android.AndroidUtilities;
import org.telegram.messenger.R;
public class VideoSeekBarView extends View {
private static Drawable thumbDrawable1;
private static Drawable thumbDrawablePressed1;
private static Paint innerPaint1 = new Paint();
private static int thumbWidth;
private static int thumbHeight;
private int thumbDX = 0;
private float progress = 0;
private boolean pressed = false;
public SeekBarDelegate delegate;
public abstract interface SeekBarDelegate {
public void onSeekBarDrag(float progress);
}
private void init(Context context) {
if (thumbDrawable1 == null) {
thumbDrawable1 = context.getResources().getDrawable(R.drawable.playback);
thumbDrawablePressed1 = context.getResources().getDrawable(R.drawable.playback_active);
innerPaint1.setColor(0x99999999);
thumbWidth = thumbDrawable1.getIntrinsicWidth();
thumbHeight = thumbDrawable1.getIntrinsicHeight();
}
}
public VideoSeekBarView(Context context) {
super(context);
init(context);
}
public VideoSeekBarView(Context context, AttributeSet attrs) {
super(context, attrs);
init(context);
}
public VideoSeekBarView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init(context);
}
@Override
public boolean onTouchEvent(MotionEvent event) {
if (event == null) {
return false;
}
float x = event.getX();
float y = event.getY();
float thumbX = (int)((getMeasuredWidth() - thumbWidth) * progress);
if (event.getAction() == MotionEvent.ACTION_DOWN) {
int additionWidth = (getMeasuredHeight() - thumbWidth) / 2;
if (thumbX - additionWidth <= x && x <= thumbX + thumbWidth + additionWidth && y >= 0 && y <= getMeasuredHeight()) {
pressed = true;
thumbDX = (int)(x - thumbX);
getParent().requestDisallowInterceptTouchEvent(true);
invalidate();
return true;
}
} else if (event.getAction() == MotionEvent.ACTION_UP || event.getAction() == MotionEvent.ACTION_CANCEL) {
if (pressed) {
if (event.getAction() == MotionEvent.ACTION_UP && delegate != null) {
delegate.onSeekBarDrag(thumbX / (float)(getMeasuredWidth() - thumbWidth));
}
pressed = false;
invalidate();
return true;
}
} else if (event.getAction() == MotionEvent.ACTION_MOVE) {
if (pressed) {
thumbX = (int)(x - thumbDX);
if (thumbX < 0) {
thumbX = 0;
} else if (thumbX > getMeasuredWidth() - thumbWidth) {
thumbX = getMeasuredWidth() - thumbWidth;
}
progress = thumbX / (getMeasuredWidth() - thumbWidth);
invalidate();
return true;
}
}
return false;
}
public void setProgress(float progress) {
if (progress < 0) {
progress = 0;
} else if (progress > 1) {
progress = 1;
}
this.progress = progress;
invalidate();
}
public float getProgress() {
return progress;
}
@Override
protected void onDraw(Canvas canvas) {
Drawable thumb = null;
if (!pressed) {
thumb = thumbDrawable1;
} else {
thumb = thumbDrawablePressed1;
}
int y = (getMeasuredHeight() - thumbHeight) / 2;
int thumbX = (int)((getMeasuredWidth() - thumbWidth) * progress);
canvas.drawRect(thumbWidth / 2, getMeasuredHeight() / 2 - AndroidUtilities.dp(1), getMeasuredWidth() - thumbWidth / 2, getMeasuredHeight() / 2 + AndroidUtilities.dp(1), innerPaint1);
thumb.setBounds(thumbX, y, thumbX + thumbWidth, y + thumbHeight);
thumb.draw(canvas);
}
}
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="40dp">
android:layout_height="40dp"
android:layout_gravity="top">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="27dp"
android:background="@drawable/newmsg_divider"
android:layout_marginTop="7dp">
android:layout_marginTop="7dp"
android:layout_gravity="top">
<ImageView
android:layout_width="wrap_content"
......
......@@ -18,7 +18,6 @@
android:drawablePadding="8dp"
android:paddingRight="16dp"
android:paddingLeft="16dp"
android:background="@drawable/bar_selector"
android:minHeight="60dp"
android:textAllCaps="true"/>
......
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ff000000">
<FrameLayout
android:layout_height="match_parent"
android:layout_width="match_parent"
android:layout_marginTop="16dp"
android:layout_marginBottom="160dp"
android:id="@+id/video_container"
android:layout_gravity="top">
<SurfaceView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_gravity="center"
android:id="@+id/video_view"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="center"
android:src="@drawable/video_play"
android:layout_gravity="center"
android:id="@+id/play_button"/>
<org.telegram.ui.Views.VideoSeekBarView
android:layout_height="36dp"
android:layout_width="match_parent"
android:id="@+id/video_seekbar"
android:background="#77000000"
android:layout_gravity="bottom"/>
</FrameLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="143dp"
android:layout_gravity="bottom"
android:id="@+id/info_container">
<org.telegram.ui.Views.VideoTimelineView
android:layout_width="match_parent"
android:layout_height="45dp"
android:id="@+id/video_timeline_view"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#999999"
android:textSize="16dp"
android:layout_gravity="bottom|center_horizontal"
android:layout_marginBottom="66dp"
android:id="@+id/original_size"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#999999"
android:textSize="16dp"
android:layout_gravity="bottom|center_horizontal"
android:layout_marginBottom="38dp"
android:id="@+id/edited_size"/>
</FrameLayout>
</FrameLayout>
......@@ -275,6 +275,7 @@
<string name="OnlyWhenScreenOn">فقط عندما تكون الشاشة تعمل</string>
<string name="OnlyWhenScreenOff">فقط عندما تكون الشاشة مطفأة</string>
<string name="AlwaysShowPopup">دائمًا أظهر الإشعارات المنبثقة</string>
<string name="BadgeNumber">Badge Number</string>
<!--media view-->
<string name="NoMedia">لا توجد وسائط بعد</string>
......@@ -298,6 +299,11 @@
<string name="AllPhotos">جميع الصور</string>
<string name="NoPhotos">لا توجد صور حتى الآن</string>
<!--edit video view-->
<string name="EditVideo">Edit Video</string>
<string name="OriginalVideo">Original Video</string>
<string name="EditedVideo">Edited Video</string>
<!--button titles-->
<string name="Next">التالي</string>
<string name="Back">رجوع</string>
......
......@@ -275,6 +275,7 @@
<string name="OnlyWhenScreenOn">Nur wenn Bildschirm „an“</string>
<string name="OnlyWhenScreenOff">Nur wenn Bildschirm „aus“</string>
<string name="AlwaysShowPopup">Popups immer anzeigen</string>
<string name="BadgeNumber">Badge Number</string>
<!--media view-->
<string name="NoMedia">Noch keine geteilten Medien vorhanden</string>
......@@ -298,6 +299,11 @@
<string name="AllPhotos">Alle Fotos</string>
<string name="NoPhotos">Noch keine Fotos</string>
<!--edit video view-->
<string name="EditVideo">Edit Video</string>
<string name="OriginalVideo">Original Video</string>
<string name="EditedVideo">Edited Video</string>
<!--button titles-->
<string name="Next">Weiter</string>
<string name="Back">Zurück</string>
......
......@@ -275,6 +275,7 @@
<string name="OnlyWhenScreenOn">Sólo con pantalla encendida</string>
<string name="OnlyWhenScreenOff">Sólo con pantalla apagada</string>
<string name="AlwaysShowPopup">Siempre mostrar notificación emergente</string>
<string name="BadgeNumber">Globo de notificación</string>
<!--media view-->
<string name="NoMedia">No hay fotos ni vídeos compartidos aún</string>
......@@ -298,6 +299,11 @@
<string name="AllPhotos">Todas</string>
<string name="NoPhotos">No hay fotos aún</string>
<!--edit video view-->
<string name="EditVideo">Edit Video</string>
<string name="OriginalVideo">Original Video</string>
<string name="EditedVideo">Edited Video</string>
<!--button titles-->
<string name="Next">Siguiente</string>
<string name="Back">Atrás</string>
......
......@@ -275,6 +275,7 @@
<string name="OnlyWhenScreenOn">Solo con schermo acceso</string>
<string name="OnlyWhenScreenOff">Solo con schermo spento</string>
<string name="AlwaysShowPopup">Mostra sempre i popup</string>
<string name="BadgeNumber">Badge Number</string>
<!--media view-->
<string name="NoMedia">Nessun media condiviso</string>
......@@ -298,6 +299,11 @@
<string name="AllPhotos">Tutte le foto</string>
<string name="NoPhotos">Ancora nessuna foto</string>
<!--edit video view-->
<string name="EditVideo">Edit Video</string>
<string name="OriginalVideo">Original Video</string>
<string name="EditedVideo">Edited Video</string>
<!--button titles-->
<string name="Next">Avanti</string>
<string name="Back">Indietro</string>
......
......@@ -275,6 +275,7 @@
<string name="OnlyWhenScreenOn">Alleen wanneer scherm \"aan\" staat</string>
<string name="OnlyWhenScreenOff">Alleen wanneer scherm \"uit\" staat</string>
<string name="AlwaysShowPopup">Altijd popup tonen</string>
<string name="BadgeNumber">Badge Number</string>
<!--media view-->
<string name="NoMedia">Nog geen media gedeeld</string>
......@@ -298,6 +299,11 @@
<string name="AllPhotos">Alle foto\'s</string>
<string name="NoPhotos">Nog geen foto\'s</string>
<!--edit video view-->
<string name="EditVideo">Edit Video</string>
<string name="OriginalVideo">Original Video</string>
<string name="EditedVideo">Edited Video</string>
<!--button titles-->
<string name="Next">Volgende</string>
<string name="Back">Vorige</string>
......
......@@ -275,6 +275,7 @@
<string name="OnlyWhenScreenOn">Somente com a tela ligada</string>
<string name="OnlyWhenScreenOff">Somente com a tela desligada</string>
<string name="AlwaysShowPopup">Sempre mostrar popup</string>
<string name="BadgeNumber">Badge Number</string>
<!--media view-->
<string name="NoMedia">Ainda não há mídia compartilhada</string>
......@@ -298,6 +299,11 @@
<string name="AllPhotos">Todas as Fotos</string>
<string name="NoPhotos">Ainda não há fotos</string>
<!--edit video view-->
<string name="EditVideo">Edit Video</string>
<string name="OriginalVideo">Original Video</string>
<string name="EditedVideo">Edited Video</string>
<!--button titles-->
<string name="Next">Próximo</string>
<string name="Back">Voltar</string>
......
......@@ -275,6 +275,7 @@
<string name="OnlyWhenScreenOn">Only when screen "on"</string>
<string name="OnlyWhenScreenOff">Only when screen "off"</string>
<string name="AlwaysShowPopup">Always show popup</string>
<string name="BadgeNumber">Badge Number</string>
<!--media view-->
<string name="NoMedia">Ainda não há multimédia partilhado</string>
......@@ -298,6 +299,11 @@
<string name="AllPhotos">Todas as fotos</string>
<string name="NoPhotos">Ainda não há fotos</string>
<!--edit video view-->
<string name="EditVideo">Edit Video</string>
<string name="OriginalVideo">Original Video</string>
<string name="EditedVideo">Edited Video</string>
<!--button titles-->
<string name="Next">Seguinte</string>
<string name="Back">Anterior</string>
......
......@@ -275,6 +275,7 @@
<string name="OnlyWhenScreenOn">Only when screen "on"</string>
<string name="OnlyWhenScreenOff">Only when screen "off"</string>
<string name="AlwaysShowPopup">Always show popup</string>
<string name="BadgeNumber">Badge Number</string>
<!--media view-->
<string name="NoMedia">No shared media yet</string>
......@@ -298,6 +299,11 @@
<string name="AllPhotos">All Photos</string>
<string name="NoPhotos">No photos yet</string>
<!--edit video view-->
<string name="EditVideo">Edit Video</string>
<string name="OriginalVideo">Original Video</string>
<string name="EditedVideo">Edited Video</string>
<!--button titles-->
<string name="Next">Next</string>
<string name="Back">Back</string>
......
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