Bug fixes

This commit is contained in:
DrKLO 2014-11-21 22:36:21 +03:00
parent d69b5b3b36
commit fdaf4555c5
14 changed files with 168 additions and 45 deletions

View file

@ -65,16 +65,16 @@ android {
jni.srcDirs = [] //disable automatic ndk-build call jni.srcDirs = [] //disable automatic ndk-build call
} }
sourceSets { sourceSets.debug {
debug { manifest.srcFile 'config/debug/AndroidManifest.xml'
manifest.srcFile 'config/debug/AndroidManifest.xml' }
}
release { sourceSets.release {
manifest.srcFile 'config/release/AndroidManifest.xml' manifest.srcFile 'config/release/AndroidManifest.xml'
} }
foss {
manifest.srcFile 'config/foss/AndroidManifest.xml' sourceSets.foss {
} manifest.srcFile 'config/foss/AndroidManifest.xml'
} }
defaultConfig { defaultConfig {

View file

@ -346,7 +346,7 @@ public class AndroidUtilities {
} else if (encryptedChat.ttl == 60 * 60 * 24 * 7) { } else if (encryptedChat.ttl == 60 * 60 * 24 * 7) {
numberPicker.setValue(20); numberPicker.setValue(20);
} else if (encryptedChat.ttl == 0) { } else if (encryptedChat.ttl == 0) {
numberPicker.setValue(5); numberPicker.setValue(0);
} }
numberPicker.setFormatter(new NumberPicker.Formatter() { numberPicker.setFormatter(new NumberPicker.Formatter() {
@Override @Override

View file

@ -345,7 +345,9 @@ public class MessageObject {
int dateMonth = rightNow.get(Calendar.MONTH); int dateMonth = rightNow.get(Calendar.MONTH);
dateKey = String.format("%d_%02d_%02d", dateYear, dateMonth, dateDay); dateKey = String.format("%d_%02d_%02d", dateYear, dateMonth, dateDay);
generateLayout(); if (preview != 0) {
generateLayout();
}
generateThumbs(false, preview); generateThumbs(false, preview);
} }

View file

@ -424,6 +424,12 @@ public class NotificationsController {
mBuilder.setPriority(NotificationCompat.PRIORITY_MAX); mBuilder.setPriority(NotificationCompat.PRIORITY_MAX);
} }
mBuilder.setCategory(NotificationCompat.CATEGORY_MESSAGE);
mBuilder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC);
/*Bundle bundle = new Bundle();
bundle.putString(NotificationCompat.EXTRA_PEOPLE, );
mBuilder.setExtras()*/
String lastMessage = null; String lastMessage = null;
String lastMessageFull = null; String lastMessageFull = null;
if (pushMessages.size() == 1) { if (pushMessages.size() == 1) {
@ -627,7 +633,8 @@ public class NotificationsController {
.setContentText(text) .setContentText(text)
.setGroupSummary(false) .setGroupSummary(false)
.setContentIntent(contentIntent) .setContentIntent(contentIntent)
.extend(new NotificationCompat.WearableExtender().addAction(action)); .extend(new NotificationCompat.WearableExtender().addAction(action))
.setCategory(NotificationCompat.CATEGORY_MESSAGE);
notificationManager.notify(notificationId, builder.build()); notificationManager.notify(notificationId, builder.build());
wearNoticationsIds.put(dialog_id, notificationId); wearNoticationsIds.put(dialog_id, notificationId);

View file

@ -220,7 +220,7 @@ public class ContactsAdapter extends BaseSectionsAdapter {
TLRPC.User user = MessagesController.getInstance().getUser(arr.get(position).user_id); TLRPC.User user = MessagesController.getInstance().getUser(arr.get(position).user_id);
((UserCell)convertView).setData(user, null, null, 0); ((UserCell)convertView).setData(user, null, null, 0);
if (checkedMap != null) { if (checkedMap != null) {
((UserCell) convertView).setChecked(checkedMap.containsKey(user.id)); ((UserCell) convertView).setChecked(checkedMap.containsKey(user.id), false);
} }
if (ignoreUsers != null) { if (ignoreUsers != null) {
if (ignoreUsers.containsKey(user.id)) { if (ignoreUsers.containsKey(user.id)) {

View file

@ -215,6 +215,9 @@ public class ContactsSearchAdapter extends BaseContactsSearchAdapter {
if (view == null) { if (view == null) {
if (useUserCell) { if (useUserCell) {
view = new UserCell(mContext, 1); view = new UserCell(mContext, 1);
if (checkedMap != null) {
((UserCell) view).setChecked(false, false);
}
} else { } else {
view = new ProfileSearchCell(mContext); view = new ProfileSearchCell(mContext);
} }
@ -244,7 +247,7 @@ public class ContactsSearchAdapter extends BaseContactsSearchAdapter {
if (useUserCell) { if (useUserCell) {
((UserCell) view).setData(user, name, username, 0); ((UserCell) view).setData(user, name, username, 0);
if (checkedMap != null) { if (checkedMap != null) {
((UserCell) view).setChecked(checkedMap.containsKey(user.id)); ((UserCell) view).setChecked(checkedMap.containsKey(user.id), false);
} }
} else { } else {
((ProfileSearchCell) view).setData(user, null, null, name, username); ((ProfileSearchCell) view).setData(user, null, null, name, username);

View file

@ -228,7 +228,7 @@ public class ChatActionCell extends BaseCell {
setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec), textHeight + AndroidUtilities.dp(14)); setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec), textHeight + AndroidUtilities.dp(14));
return; return;
} }
int width = MeasureSpec.getSize(widthMeasureSpec); int width = Math.max(AndroidUtilities.dp(30), MeasureSpec.getSize(widthMeasureSpec));
if (width != previousWidth) { if (width != previousWidth) {
previousWidth = width; previousWidth = width;

View file

@ -328,7 +328,12 @@ public class DialogCell extends BaseCell {
messageString = Emoji.replaceEmoji(Html.fromHtml(String.format("<font color=#4d83b3>%s:</font> <font color=#4d83b3>%s</font>", name, message.messageText)), messagePaint.getFontMetricsInt(), AndroidUtilities.dp(20)); messageString = Emoji.replaceEmoji(Html.fromHtml(String.format("<font color=#4d83b3>%s:</font> <font color=#4d83b3>%s</font>", name, message.messageText)), messagePaint.getFontMetricsInt(), AndroidUtilities.dp(20));
} else { } else {
if (message.messageOwner.message != null) { if (message.messageOwner.message != null) {
messageString = Emoji.replaceEmoji(Html.fromHtml(String.format("<font color=#4d83b3>%s:</font> <font color=#808080>%s</font>", name, message.messageOwner.message.replace("\n", " ").replace("<", "&lt;").replace(">", "&gt;"))), messagePaint.getFontMetricsInt(), AndroidUtilities.dp(20)); String mess = message.messageOwner.message;
if (mess.length() > 150) {
mess = mess.substring(0, 150);
}
mess = mess.replace("\n", " ");
messageString = Emoji.replaceEmoji(Html.fromHtml(String.format("<font color=#4d83b3>%s:</font> <font color=#808080>%s</font>", name, mess.replace("<", "&lt;").replace(">", "&gt;"))), messagePaint.getFontMetricsInt(), AndroidUtilities.dp(20));
} }
} }
} else { } else {
@ -505,10 +510,11 @@ public class DialogCell extends BaseCell {
if (messageString == null) { if (messageString == null) {
messageString = ""; messageString = "";
} }
String mess = messageString.toString().replace("\n", " "); String mess = messageString.toString();
if (mess.length() > 150) { if (mess.length() > 150) {
mess = mess.substring(0, 150); mess = mess.substring(0, 150);
} }
mess = mess.replace("\n", " ");
messageString = Emoji.replaceEmoji(mess, messagePaint.getFontMetricsInt(), AndroidUtilities.dp(17)); messageString = Emoji.replaceEmoji(mess, messagePaint.getFontMetricsInt(), AndroidUtilities.dp(17));
} }
messageWidth = Math.max(AndroidUtilities.dp(12), messageWidth); messageWidth = Math.max(AndroidUtilities.dp(12), messageWidth);

View file

@ -142,11 +142,11 @@ public class UserCell extends FrameLayout {
update(0); update(0);
} }
public void setChecked(boolean checked) { public void setChecked(boolean checked, boolean animated) {
if (checkBox.getVisibility() != VISIBLE) { if (checkBox.getVisibility() != VISIBLE) {
checkBox.setVisibility(VISIBLE); checkBox.setVisibility(VISIBLE);
} }
checkBox.setChecked(checked); checkBox.setChecked(checked, animated);
} }
@Override @Override

View file

@ -120,7 +120,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
isBroadcast = args.getBoolean("broadcast", false); isBroadcast = args.getBoolean("broadcast", false);
isAlwaysShare = args.getBoolean("isAlwaysShare", false); isAlwaysShare = args.getBoolean("isAlwaysShare", false);
isNeverShare = args.getBoolean("isNeverShare", false); isNeverShare = args.getBoolean("isNeverShare", false);
maxCount = !isBroadcast ? MessagesController.getInstance().maxGroupCount : MessagesController.getInstance().maxBroadcastCount; maxCount = !isBroadcast ? MessagesController.getInstance().maxGroupCount - 1 : MessagesController.getInstance().maxBroadcastCount;
} }
@Override @Override
@ -391,7 +391,9 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
return; return;
} }
boolean check = true;
if (selectedContacts.containsKey(user.id)) { if (selectedContacts.containsKey(user.id)) {
check = false;
try { try {
XImageSpan span = selectedContacts.get(user.id); XImageSpan span = selectedContacts.get(user.id);
selectedContacts.remove(user.id); selectedContacts.remove(user.id);
@ -441,7 +443,9 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
listView.setVerticalScrollBarEnabled(false); listView.setVerticalScrollBarEnabled(false);
emptyTextView.setText(LocaleController.getString("NoContacts", R.string.NoContacts)); emptyTextView.setText(LocaleController.getString("NoContacts", R.string.NoContacts));
} else { } else {
listView.invalidateViews(); if (view instanceof UserCell) {
((UserCell) view).setChecked(check, true);
}
} }
} }
}); });

View file

@ -193,8 +193,14 @@ public class LastSeenActivity extends BaseFragment implements NotificationCenter
public void didSelectUsers(ArrayList<Integer> ids) { public void didSelectUsers(ArrayList<Integer> ids) {
if (i == neverShareRow) { if (i == neverShareRow) {
currentMinus = ids; currentMinus = ids;
for (Integer id : currentMinus) {
currentPlus.remove(id);
}
} else { } else {
currentPlus = ids; currentPlus = ids;
for (Integer id : currentPlus) {
currentMinus.remove(id);
}
} }
doneButton.setVisibility(View.VISIBLE); doneButton.setVisibility(View.VISIBLE);
listAdapter.notifyDataSetChanged(); listAdapter.notifyDataSetChanged();

View file

@ -9,50 +9,146 @@
package org.telegram.ui.Views; package org.telegram.ui.Views;
import android.content.Context; import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Paint; import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.widget.CompoundButton; import android.view.View;
import org.telegram.android.AndroidUtilities;
import org.telegram.messenger.R; import org.telegram.messenger.R;
import org.telegram.ui.AnimationCompat.ObjectAnimatorProxy;
public class CheckBox extends CompoundButton { public class CheckBox extends View {
private Paint paint; private static Drawable checkDrawable;
private Drawable checkDrawable; private static Paint paint;
private static Paint eraser;
private static Paint eraser2;
private static Paint checkPaint;
private Bitmap drawBitmap;
private Bitmap checkBitmap;
private Canvas bitmapCanvas;
private Canvas checkCanvas;
private float progress;
private ObjectAnimatorProxy checkAnimator;
private boolean isCheckAnimation = true;
private boolean attachedToWindow;
private boolean isChecked = false;
private final static float progressBounceDiff = 0.2f;
public CheckBox(Context context) { public CheckBox(Context context) {
super(context); super(context);
if (checkDrawable == null) {
checkDrawable = context.getResources().getDrawable(R.drawable.round_check2);
paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setColor(0xff5ec245);
eraser = new Paint(Paint.ANTI_ALIAS_FLAG);
eraser.setColor(0);
eraser.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
eraser2 = new Paint(Paint.ANTI_ALIAS_FLAG);
eraser2.setColor(0);
eraser2.setStyle(Paint.Style.STROKE);
eraser2.setStrokeWidth(AndroidUtilities.dp(28));
eraser2.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
}
drawBitmap = Bitmap.createBitmap(AndroidUtilities.dp(22), AndroidUtilities.dp(22), Bitmap.Config.ARGB_4444);
bitmapCanvas = new Canvas(drawBitmap);
checkBitmap = Bitmap.createBitmap(AndroidUtilities.dp(22), AndroidUtilities.dp(22), Bitmap.Config.ARGB_4444);
checkCanvas = new Canvas(checkBitmap);
}
paint = new Paint(Paint.ANTI_ALIAS_FLAG); public void setProgress(float value) {
paint.setColor(0xff5ec245); progress = value;
invalidate();
}
checkDrawable = context.getResources().getDrawable(R.drawable.round_check2); public float getProgress() {
return progress;
}
private void cancelCheckAnimator() {
if (checkAnimator != null) {
checkAnimator.cancel();
}
}
private void animateToCheckedState(boolean newCheckedState) {
isCheckAnimation = newCheckedState;
checkAnimator = ObjectAnimatorProxy.ofFloatProxy(this, "progress", newCheckedState ? 1 : 0);
checkAnimator.setDuration(300);
checkAnimator.start();
} }
@Override @Override
public void setChecked(boolean checked) { protected void onAttachedToWindow() {
super.setChecked(checked); super.onAttachedToWindow();
attachedToWindow = true;
}
checked = isChecked(); @Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
attachedToWindow = false;
}
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
}
public void setChecked(boolean checked, boolean animated) {
isChecked = checked;
invalidate(); invalidate();
/*if (attachedToWindow && wasLayout) { if (attachedToWindow && animated) {
animateThumbToCheckedState(checked); animateToCheckedState(checked);
} else { } else {
cancelPositionAnimator(); cancelCheckAnimator();
setThumbPosition(checked ? 1 : 0); setProgress(checked ? 1.0f : 0.0f);
}*/ }
}
public boolean isChecked() {
return isChecked;
} }
@Override @Override
protected void onDraw(Canvas canvas) { protected void onDraw(Canvas canvas) {
if (isChecked()) { if (progress != 0) {
canvas.drawCircle(getMeasuredWidth() / 2, getMeasuredHeight() / 2, getMeasuredWidth() / 2, paint); drawBitmap.eraseColor(0);
int x = (getMeasuredWidth() - checkDrawable.getIntrinsicWidth()) / 2; float rad = getMeasuredWidth() / 2;
int y = (getMeasuredHeight() - checkDrawable.getIntrinsicHeight()) / 2;
checkDrawable.setBounds(x, y, x + checkDrawable.getIntrinsicWidth(), y + checkDrawable.getIntrinsicHeight()); float roundProgress = progress >= 0.5f ? 1.0f : progress / 0.5f;
checkDrawable.draw(canvas); float checkProgress = progress < 0.5f ? 0.0f : (progress - 0.5f) / 0.5f;
float roundProgressCheckState = isCheckAnimation ? progress : (1.0f - progress);
if (roundProgressCheckState < progressBounceDiff) {
rad -= AndroidUtilities.dp(2) * roundProgressCheckState / progressBounceDiff;
} else if (roundProgressCheckState < progressBounceDiff * 2) {
rad -= AndroidUtilities.dp(2) - AndroidUtilities.dp(2) * (roundProgressCheckState - progressBounceDiff) / progressBounceDiff;
}
bitmapCanvas.drawCircle(getMeasuredWidth() / 2, getMeasuredHeight() / 2, rad, paint);
bitmapCanvas.drawCircle(getMeasuredWidth() / 2, getMeasuredHeight() / 2, rad * (1 - roundProgress), eraser);
canvas.drawBitmap(drawBitmap, 0, 0, null);
checkBitmap.eraseColor(0);
int w = checkDrawable.getIntrinsicWidth();
int h = checkDrawable.getIntrinsicHeight();
int x = (getMeasuredWidth() - w) / 2;
int y = (getMeasuredHeight() - h) / 2;
checkDrawable.setBounds(x, y, x + w, y + h);
checkDrawable.draw(checkCanvas);
checkCanvas.drawCircle(getMeasuredWidth() / 2 - AndroidUtilities.dp(2.5f), getMeasuredHeight() / 2 + AndroidUtilities.dp(4), ((getMeasuredWidth() + AndroidUtilities.dp(6)) / 2) * (1 - checkProgress), eraser2);
canvas.drawBitmap(checkBitmap, 0, 0, null);
} }
} }
} }

View file

@ -90,7 +90,6 @@ public class Switch extends CompoundButton {
private ObjectAnimatorProxy mPositionAnimator; private ObjectAnimatorProxy mPositionAnimator;
@SuppressWarnings("hiding")
private final Rect mTempRect = new Rect(); private final Rect mTempRect = new Rect();
public Switch(Context context) { public Switch(Context context) {

View file

@ -137,7 +137,7 @@
<string name="NotificationGroupKickYou">%1$s removed you from the group %2$s</string> <string name="NotificationGroupKickYou">%1$s removed you from the group %2$s</string>
<string name="NotificationGroupLeftMember">%1$s has left the group %2$s</string> <string name="NotificationGroupLeftMember">%1$s has left the group %2$s</string>
<string name="NotificationContactJoined">%1$s joined Telegram!</string> <string name="NotificationContactJoined">%1$s joined Telegram!</string>
<string name="NotificationUnrecognizedDevice">%1$s,\nWe detected a login into your account from a new device on %2$s\n\nDevice: %3$s\nLocation: %4$s\n\nIf this wasn\'t you, you can go to Settings - Terminate all sessions.\n\nSincerely,\nThe Telegram Team</string> <string name="NotificationUnrecognizedDevice">%1$s,\nWe detected a login into your account from a new device on %2$s\n\nDevice: %3$s\nLocation: %4$s\n\nIf this wasn\'t you, you can go to Settings - Privacy and Security - Terminate all other sessions.\n\nSincerely,\nThe Telegram Team</string>
<string name="NotificationContactNewPhoto">%1$s updated profile photo</string> <string name="NotificationContactNewPhoto">%1$s updated profile photo</string>
<string name="Reply">Reply</string> <string name="Reply">Reply</string>
<string name="ReplyToGroup">Reply to %1$s</string> <string name="ReplyToGroup">Reply to %1$s</string>