diff --git a/TMessagesProj/build.gradle b/TMessagesProj/build.gradle index 2a1bb4c7..1f144ec1 100644 --- a/TMessagesProj/build.gradle +++ b/TMessagesProj/build.gradle @@ -80,7 +80,7 @@ android { defaultConfig { minSdkVersion 8 targetSdkVersion 21 - versionCode 395 - versionName "2.0.4" + versionCode 397 + versionName "2.0.5" } } diff --git a/TMessagesProj/src/main/java/org/telegram/android/NotificationsController.java b/TMessagesProj/src/main/java/org/telegram/android/NotificationsController.java index 4b23d7ef..4d4840a6 100644 --- a/TMessagesProj/src/main/java/org/telegram/android/NotificationsController.java +++ b/TMessagesProj/src/main/java/org/telegram/android/NotificationsController.java @@ -425,7 +425,9 @@ public class NotificationsController { } mBuilder.setCategory(NotificationCompat.CATEGORY_MESSAGE); - mBuilder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC); + if (chat == null && user != null && user.phone != null && user.phone.length() > 0) { + mBuilder.addPerson("tel:+" + user.phone); + } /*Bundle bundle = new Bundle(); bundle.putString(NotificationCompat.EXTRA_PEOPLE, ); mBuilder.setExtras()*/ @@ -636,6 +638,10 @@ public class NotificationsController { .extend(new NotificationCompat.WearableExtender().addAction(action)) .setCategory(NotificationCompat.CATEGORY_MESSAGE); + if (chat == null && user != null && user.phone != null && user.phone.length() > 0) { + builder.addPerson("tel:+" + user.phone); + } + notificationManager.notify(notificationId, builder.build()); wearNoticationsIds.put(dialog_id, notificationId); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBar.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBar.java index 4ae92f59..629942b4 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBar.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBar.java @@ -40,6 +40,7 @@ public class ActionBar extends FrameLayout { private ImageView backButtonImageView; private TextView titleTextView; private TextView subTitleTextView; + private View actionModeTop; private ActionBarMenu menu; private ActionBarMenu actionMode; private boolean occupyStatusBar = Build.VERSION.SDK_INT >= 21; @@ -343,6 +344,19 @@ public class ActionBar extends FrameLayout { layoutParams.gravity = Gravity.RIGHT; actionMode.setLayoutParams(layoutParams); actionMode.setVisibility(GONE); + + if (occupyStatusBar) { + actionModeTop = new View(getContext()); + actionModeTop.setBackgroundColor(0x99000000); + addView(actionModeTop); + layoutParams = (FrameLayout.LayoutParams)actionModeTop.getLayoutParams(); + layoutParams.height = AndroidUtilities.statusBarHeight; + layoutParams.width = LayoutParams.FILL_PARENT; + layoutParams.gravity = Gravity.TOP | Gravity.LEFT; + actionModeTop.setLayoutParams(layoutParams); + actionModeTop.setVisibility(GONE); + } + return actionMode; } @@ -351,6 +365,9 @@ public class ActionBar extends FrameLayout { return; } actionMode.setVisibility(VISIBLE); + if (actionModeTop != null) { + actionModeTop.setVisibility(VISIBLE); + } if (titleFrameLayout != null) { titleFrameLayout.setVisibility(INVISIBLE); } @@ -364,6 +381,9 @@ public class ActionBar extends FrameLayout { return; } actionMode.setVisibility(GONE); + if (actionModeTop != null) { + actionModeTop.setVisibility(GONE); + } if (titleFrameLayout != null) { titleFrameLayout.setVisibility(VISIBLE); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/BaseFragment.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/BaseFragment.java index 8646005b..9270ca1c 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/BaseFragment.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/BaseFragment.java @@ -119,7 +119,6 @@ public class BaseFragment { public void onPause() { if (actionBar != null) { actionBar.onPause(); - actionBar.closeSearchField(); } try { if (visibleDialog != null && visibleDialog.isShowing()) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/ContactsAdapter.java b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/ContactsAdapter.java index 99915e3e..cd50fac4 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/ContactsAdapter.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/ContactsAdapter.java @@ -9,6 +9,7 @@ package org.telegram.ui.Adapters; import android.content.Context; +import android.os.Build; import android.view.View; import android.view.ViewGroup; @@ -35,6 +36,7 @@ public class ContactsAdapter extends BaseSectionsAdapter { private boolean needPhonebook; private HashMap ignoreUsers; private HashMap checkedMap; + private boolean scrolling; public ContactsAdapter(Context context, boolean arg1, boolean arg2, HashMap arg3) { mContext = context; @@ -47,6 +49,10 @@ public class ContactsAdapter extends BaseSectionsAdapter { checkedMap = map; } + public void setIsScrolling(boolean value) { + scrolling = value; + } + @Override public Object getItem(int section, int position) { if (onlyUsers) { @@ -175,7 +181,7 @@ public class ContactsAdapter extends BaseSectionsAdapter { if (type == 4) { if (convertView == null) { convertView = new DividerCell(mContext); - convertView.setPadding(AndroidUtilities.dp(LocaleController.isRTL ? 24 : 72), 0, AndroidUtilities.dp(LocaleController.isRTL ? 72 : 24), 0); + convertView.setPadding(AndroidUtilities.dp(LocaleController.isRTL ? 28 : 72), 0, AndroidUtilities.dp(LocaleController.isRTL ? 72 : 28), 0); } } else if (type == 3) { if (convertView == null) { @@ -220,7 +226,7 @@ public class ContactsAdapter extends BaseSectionsAdapter { TLRPC.User user = MessagesController.getInstance().getUser(arr.get(position).user_id); ((UserCell)convertView).setData(user, null, null, 0); if (checkedMap != null) { - ((UserCell) convertView).setChecked(checkedMap.containsKey(user.id), false); + ((UserCell) convertView).setChecked(checkedMap.containsKey(user.id), !scrolling && Build.VERSION.SDK_INT > 10); } if (ignoreUsers != null) { if (ignoreUsers.containsKey(user.id)) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextDetailDocumentsCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextDetailDocumentsCell.java index 46bcf793..43700151 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextDetailDocumentsCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextDetailDocumentsCell.java @@ -19,6 +19,7 @@ import android.widget.TextView; import org.telegram.android.AndroidUtilities; import org.telegram.android.LocaleController; import org.telegram.ui.Views.BackupImageView; +import org.telegram.ui.Views.CheckBox; public class TextDetailDocumentsCell extends FrameLayout { @@ -26,6 +27,7 @@ public class TextDetailDocumentsCell extends FrameLayout { private TextView valueTextView; private TextView typeTextView; private BackupImageView imageView; + private CheckBox checkBox; public TextDetailDocumentsCell(Context context) { super(context); @@ -90,6 +92,18 @@ public class TextDetailDocumentsCell extends FrameLayout { layoutParams.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? 16 : 0); layoutParams.gravity = (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL; imageView.setLayoutParams(layoutParams); + + checkBox = new CheckBox(context); + checkBox.setVisibility(GONE); + addView(checkBox); + layoutParams = (LayoutParams) checkBox.getLayoutParams(); + layoutParams.width = AndroidUtilities.dp(22); + layoutParams.height = AndroidUtilities.dp(22); + layoutParams.topMargin = AndroidUtilities.dp(34); + layoutParams.leftMargin = LocaleController.isRTL ? 0 : AndroidUtilities.dp(38); + layoutParams.rightMargin = LocaleController.isRTL ? AndroidUtilities.dp(38) : 0; + layoutParams.gravity = (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT); + checkBox.setLayoutParams(layoutParams); } @Override @@ -117,4 +131,11 @@ public class TextDetailDocumentsCell extends FrameLayout { imageView.setVisibility(GONE); } } + + public void setChecked(boolean checked, boolean animated) { + if (checkBox.getVisibility() != VISIBLE) { + checkBox.setVisibility(VISIBLE); + } + checkBox.setChecked(checked, animated); + } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java index 3777d6ba..a8880bab 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java @@ -572,9 +572,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not DocumentSelectActivity fragment = new DocumentSelectActivity(); fragment.setDelegate(new DocumentSelectActivity.DocumentSelectActivityDelegate() { @Override - public void didSelectFile(DocumentSelectActivity activity, String path) { + public void didSelectFiles(DocumentSelectActivity activity, ArrayList files) { activity.finishFragment(); - SendMessagesHelper.prepareSendingDocument(path, path, null, null, dialog_id); + SendMessagesHelper.prepareSendingDocuments(files, files, null, null, dialog_id); } @Override diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ContactsActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ContactsActivity.java index deba9e8f..a2b44f87 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ContactsActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ContactsActivity.java @@ -440,6 +440,14 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter } } + @Override + public void onPause() { + super.onPause(); + if (actionBar != null) { + actionBar.closeSearchField(); + } + } + @Override public void didReceivedNotification(int id, Object... args) { if (id == NotificationCenter.contactsDidLoaded) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/DocumentSelectActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/DocumentSelectActivity.java index d56a7be6..66b99d28 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/DocumentSelectActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/DocumentSelectActivity.java @@ -16,11 +16,15 @@ import android.content.IntentFilter; import android.os.Build; import android.os.Environment; import android.os.StatFs; +import android.text.TextUtils; +import android.view.Gravity; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; +import android.widget.AbsListView; import android.widget.AdapterView; +import android.widget.LinearLayout; import android.widget.ListView; import android.widget.TextView; @@ -33,6 +37,8 @@ import org.telegram.ui.Adapters.BaseFragmentAdapter; import org.telegram.ui.ActionBar.ActionBar; import org.telegram.ui.ActionBar.ActionBarMenu; import org.telegram.ui.ActionBar.ActionBarMenuItem; +import org.telegram.ui.AnimationCompat.AnimatorSetProxy; +import org.telegram.ui.AnimationCompat.ObjectAnimatorProxy; import org.telegram.ui.Cells.TextDetailDocumentsCell; import org.telegram.ui.ActionBar.BaseFragment; @@ -47,19 +53,26 @@ import java.util.HashMap; public class DocumentSelectActivity extends BaseFragment { public static abstract interface DocumentSelectActivityDelegate { - public void didSelectFile(DocumentSelectActivity activity, String path); + public void didSelectFiles(DocumentSelectActivity activity, ArrayList files); public void startDocumentSelectActivity(); } private ListView listView; private ListAdapter listAdapter; - private File currentDir; + private TextView selectedMessagesCountTextView; private TextView emptyView; + + private File currentDir; private ArrayList items = new ArrayList(); private boolean receiverRegistered = false; private ArrayList history = new ArrayList(); private long sizeLimit = 1024 * 1024 * 1024; private DocumentSelectActivityDelegate delegate; + private HashMap selectedFiles = new HashMap(); + private ArrayList actionModeViews = new ArrayList(); + private boolean scrolling; + + private final static int done = 3; private class ListItem { int icon; @@ -144,11 +157,51 @@ public class DocumentSelectActivity extends BaseFragment { delegate.startDocumentSelectActivity(); } finishFragment(false); + } else if (id == -2) { + selectedFiles.clear(); + actionBar.hideActionMode(); + listView.invalidateViews(); + } else if (id == done) { + if (delegate != null) { + ArrayList files = new ArrayList(); + files.addAll(selectedFiles.keySet()); + delegate.didSelectFiles(DocumentSelectActivity.this, files); + } } } }); ActionBarMenu menu = actionBar.createMenu(); - ActionBarMenuItem item = menu.addItem(1, R.drawable.ic_ab_other); + final ActionBarMenuItem item = menu.addItem(1, R.drawable.ic_ab_other); + + selectedFiles.clear(); + actionModeViews.clear(); + + final ActionBarMenu actionMode = actionBar.createActionMode(); + actionModeViews.add(actionMode.addItem(-2, R.drawable.ic_ab_back_grey, R.drawable.bar_selector_mode, null, AndroidUtilities.dp(54))); + + selectedMessagesCountTextView = new TextView(actionMode.getContext()); + selectedMessagesCountTextView.setTextSize(18); + selectedMessagesCountTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); + selectedMessagesCountTextView.setTextColor(0xff737373); + selectedMessagesCountTextView.setSingleLine(true); + selectedMessagesCountTextView.setLines(1); + selectedMessagesCountTextView.setEllipsize(TextUtils.TruncateAt.END); + selectedMessagesCountTextView.setPadding(AndroidUtilities.dp(11), 0, 0, AndroidUtilities.dp(2)); + selectedMessagesCountTextView.setGravity(Gravity.CENTER_VERTICAL); + selectedMessagesCountTextView.setOnTouchListener(new View.OnTouchListener() { + @Override + public boolean onTouch(View v, MotionEvent event) { + return true; + } + }); + actionMode.addView(selectedMessagesCountTextView); + LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams)selectedMessagesCountTextView.getLayoutParams(); + layoutParams.weight = 1; + layoutParams.width = 0; + layoutParams.height = LinearLayout.LayoutParams.MATCH_PARENT; + selectedMessagesCountTextView.setLayoutParams(layoutParams); + + actionModeViews.add(actionMode.addItem(done, R.drawable.ic_ab_done_gray, R.drawable.bar_selector_mode, null, AndroidUtilities.dp(54))); fragmentView = inflater.inflate(R.layout.document_select_layout, container, false); listAdapter = new ListAdapter(getParentActivity()); @@ -162,9 +215,75 @@ public class DocumentSelectActivity extends BaseFragment { listView = (ListView)fragmentView.findViewById(R.id.listView); listView.setEmptyView(emptyView); listView.setAdapter(listAdapter); + + listView.setOnScrollListener(new AbsListView.OnScrollListener() { + @Override + public void onScrollStateChanged(AbsListView view, int scrollState) { + scrolling = scrollState != SCROLL_STATE_IDLE; + } + + @Override + public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { + + } + }); + + listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { + @Override + public boolean onItemLongClick(AdapterView parent, View view, int i, long id) { + if (actionBar.isActionModeShowed() || i < 0 || i >= items.size()) { + return false; + } + ListItem item = items.get(i); + File file = item.file; + if (file != null && !file.isDirectory()) { + if (!file.canRead()) { + showErrorBox(LocaleController.getString("AccessError", R.string.AccessError)); + return false; + } + if (sizeLimit != 0) { + if (file.length() > sizeLimit) { + showErrorBox(LocaleController.formatString("FileUploadLimit", R.string.FileUploadLimit, Utilities.formatFileSize(sizeLimit))); + return false; + } + } + if (file.length() == 0) { + return false; + } + selectedFiles.put(file.toString(), item); + selectedMessagesCountTextView.setText(String.format("%d", selectedFiles.size())); + if (Build.VERSION.SDK_INT >= 11) { + AnimatorSetProxy animatorSet = new AnimatorSetProxy(); + ArrayList animators = new ArrayList(); + for (int a = 0; a < actionModeViews.size(); a++) { + View view2 = actionModeViews.get(a); + AndroidUtilities.clearDrawableAnimation(view2); + if (a < 1) { + animators.add(ObjectAnimatorProxy.ofFloat(view2, "translationX", -AndroidUtilities.dp(56), 0)); + } else { + animators.add(ObjectAnimatorProxy.ofFloat(view2, "scaleY", 0.1f, 1.0f)); + } + } + animatorSet.playTogether(animators); + animatorSet.setDuration(250); + animatorSet.start(); + } + scrolling = false; + if (view instanceof TextDetailDocumentsCell) { + ((TextDetailDocumentsCell) view).setChecked(true, true); + } + actionBar.showActionMode(); + } + return true; + } + }); + listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView adapterView, View view, int i, long l) { + if (i < 0 || i >= items.size()) { + return; + } ListItem item = items.get(i); File file = item.file; if (file == null) { @@ -202,8 +321,27 @@ public class DocumentSelectActivity extends BaseFragment { if (file.length() == 0) { return; } - if (delegate != null) { - delegate.didSelectFile(DocumentSelectActivity.this, file.getAbsolutePath()); + if (actionBar.isActionModeShowed()) { + if (selectedFiles.containsKey(file.toString())) { + selectedFiles.remove(file.toString()); + } else { + selectedFiles.put(file.toString(), item); + } + if (selectedFiles.isEmpty()) { + actionBar.hideActionMode(); + } else { + selectedMessagesCountTextView.setText(String.format("%d", selectedFiles.size())); + } + scrolling = false; + if (view instanceof TextDetailDocumentsCell) { + ((TextDetailDocumentsCell) view).setChecked(selectedFiles.containsKey(item.file.toString()), true); + } + } else { + if (delegate != null) { + ArrayList files = new ArrayList(); + files.add(file.getAbsolutePath()); + delegate.didSelectFiles(DocumentSelectActivity.this, files); + } } } } @@ -263,6 +401,7 @@ public class DocumentSelectActivity extends BaseFragment { emptyView.setText(LocaleController.getString("NotMounted", R.string.NotMounted)); } AndroidUtilities.clearDrawableAnimation(listView); + scrolling = true; listAdapter.notifyDataSetChanged(); return true; } @@ -331,6 +470,7 @@ public class DocumentSelectActivity extends BaseFragment { item.file = null; items.add(0, item); AndroidUtilities.clearDrawableAnimation(listView); + scrolling = true; listAdapter.notifyDataSetChanged(); return true; } @@ -421,6 +561,7 @@ public class DocumentSelectActivity extends BaseFragment { } AndroidUtilities.clearDrawableAnimation(listView); + scrolling = true; listAdapter.notifyDataSetChanged(); } @@ -477,6 +618,11 @@ public class DocumentSelectActivity extends BaseFragment { String type = item.ext.toUpperCase().substring(0, Math.min(item.ext.length(), 4)); ((TextDetailDocumentsCell) convertView).setTextAndValueAndTypeAndThumb(item.title, item.subtitle, type, item.thumb, 0); } + if (item.file != null && actionBar.isActionModeShowed()) { + textDetailCell.setChecked(selectedFiles.containsKey(item.file.toString()), !scrolling); + } else { + textDetailCell.setChecked(false, !scrolling); + } return convertView; } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/GroupCreateActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/GroupCreateActivity.java index 7a319383..18ec6a7e 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/GroupCreateActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/GroupCreateActivity.java @@ -455,6 +455,9 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen if (i == SCROLL_STATE_TOUCH_SCROLL) { AndroidUtilities.hideKeyboard(userSelectEditText); } + if (listViewAdapter != null) { + listViewAdapter.setIsScrolling(i != SCROLL_STATE_IDLE); + } } @Override diff --git a/TMessagesProj/src/main/java/org/telegram/ui/MessagesActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/MessagesActivity.java index fd10cf9d..b244c4e0 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/MessagesActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/MessagesActivity.java @@ -362,6 +362,10 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter } if (message_id != 0) { args.putInt("message_id", message_id); + } else { + if (actionBar != null) { + actionBar.closeSearchField(); + } } if (AndroidUtilities.isTablet()) { if (openedDialogId == dialog_id) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java index 634d6052..14ad761c 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java @@ -485,10 +485,10 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. } else if (i == 1) { if(Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB) { android.text.ClipboardManager clipboard = (android.text.ClipboardManager)ApplicationLoader.applicationContext.getSystemService(Context.CLIPBOARD_SERVICE); - clipboard.setText(user.phone); + clipboard.setText("+" + user.phone); } else { android.content.ClipboardManager clipboard = (android.content.ClipboardManager)ApplicationLoader.applicationContext.getSystemService(Context.CLIPBOARD_SERVICE); - android.content.ClipData clip = android.content.ClipData.newPlainText("label", user.phone); + android.content.ClipData clip = android.content.ClipData.newPlainText("label", "+" + user.phone); clipboard.setPrimaryClip(clip); } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Views/ChatActivityEnterView.java b/TMessagesProj/src/main/java/org/telegram/ui/Views/ChatActivityEnterView.java index ab697708..10643559 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Views/ChatActivityEnterView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Views/ChatActivityEnterView.java @@ -148,6 +148,7 @@ public class ChatActivityEnterView implements NotificationCenter.NotificationCen ViewProxy.setScaleX(sendButton, 0.1f); ViewProxy.setScaleY(sendButton, 0.1f); ViewProxy.setAlpha(sendButton, 0.0f); + sendButton.clearAnimation(); emojiButton = (ImageView) containerView.findViewById(R.id.chat_smile_button); audioSendButton = (ImageButton) containerView.findViewById(R.id.chat_audio_send_button); recordPanel = containerView.findViewById(R.id.record_panel); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Views/CheckBox.java b/TMessagesProj/src/main/java/org/telegram/ui/Views/CheckBox.java index 9a27adba..6f5275b2 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Views/CheckBox.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Views/CheckBox.java @@ -58,13 +58,23 @@ public class CheckBox extends View { 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); + } + + @Override + public void setVisibility(int visibility) { + super.setVisibility(visibility); + if (visibility == VISIBLE && drawBitmap == null) { + 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); + } } public void setProgress(float value) { + if (progress == value) { + return; + } progress = value; invalidate(); } @@ -104,8 +114,10 @@ public class CheckBox extends View { } public void setChecked(boolean checked, boolean animated) { + if (checked == isChecked) { + return; + } isChecked = checked; - invalidate(); if (attachedToWindow && animated) { animateToCheckedState(checked); @@ -121,6 +133,9 @@ public class CheckBox extends View { @Override protected void onDraw(Canvas canvas) { + if (getVisibility() != VISIBLE) { + return; + } if (progress != 0) { drawBitmap.eraseColor(0); float rad = getMeasuredWidth() / 2; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Views/Switch.java b/TMessagesProj/src/main/java/org/telegram/ui/Views/Switch.java index 1a10e433..02e2a537 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Views/Switch.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Views/Switch.java @@ -23,6 +23,7 @@ import android.graphics.PorterDuffColorFilter; import android.graphics.Rect; import android.graphics.Region; import android.graphics.drawable.Drawable; +import android.os.Build; import android.view.Gravity; import android.view.MotionEvent; import android.view.VelocityTracker; @@ -532,7 +533,7 @@ public class Switch extends CompoundButton { mThumbDrawable.setBounds(thumbLeft, switchTop + offset, thumbRight, switchBottom + offset); final Drawable background = getBackground(); - if (background != null) { + if (background != null && Build.VERSION.SDK_INT >= 21) { background.setHotspotBounds(thumbLeft, switchTop, thumbRight, switchBottom); } } diff --git a/TMessagesProj/src/main/res/drawable-hdpi/ic_ab_done_gray.png b/TMessagesProj/src/main/res/drawable-hdpi/ic_ab_done_gray.png new file mode 100755 index 00000000..99240881 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/ic_ab_done_gray.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/ic_ab_done_gray.png b/TMessagesProj/src/main/res/drawable-mdpi/ic_ab_done_gray.png new file mode 100755 index 00000000..47beed22 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/ic_ab_done_gray.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/ic_ab_done_gray.png b/TMessagesProj/src/main/res/drawable-xhdpi/ic_ab_done_gray.png new file mode 100755 index 00000000..41671b4f Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/ic_ab_done_gray.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_ab_done_gray.png b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_ab_done_gray.png new file mode 100755 index 00000000..4ff3b63b Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_ab_done_gray.png differ