diff --git a/TMessagesProj/src/main/java/org/telegram/android/AndroidUtilities.java b/TMessagesProj/src/main/java/org/telegram/android/AndroidUtilities.java index c77842c5..ccaf8f10 100644 --- a/TMessagesProj/src/main/java/org/telegram/android/AndroidUtilities.java +++ b/TMessagesProj/src/main/java/org/telegram/android/AndroidUtilities.java @@ -24,7 +24,10 @@ import android.view.Surface; import android.view.View; import android.view.WindowManager; import android.view.inputmethod.InputMethodManager; +import android.widget.AbsListView; +import android.widget.EdgeEffect; import android.widget.EditText; +import android.widget.ListView; import android.widget.TextView; import org.telegram.messenger.FileLog; @@ -466,4 +469,26 @@ public class AndroidUtilities { } return size; } + + public static void setListViewEdgeEffectColor(ListView listView, int color) { + if (Build.VERSION.SDK_INT >= 21) { + try { + Field field = AbsListView.class.getDeclaredField("mEdgeGlowTop"); + field.setAccessible(true); + EdgeEffect mEdgeGlowTop = (EdgeEffect) field.get(listView); + if (mEdgeGlowTop != null) { + mEdgeGlowTop.setColor(color); + } + + field = AbsListView.class.getDeclaredField("mEdgeGlowBottom"); + field.setAccessible(true); + EdgeEffect mEdgeGlowBottom = (EdgeEffect) field.get(listView); + if (mEdgeGlowBottom != null) { + mEdgeGlowBottom.setColor(color); + } + } catch (Exception e) { + FileLog.e("tmessages", e); + } + } + } } diff --git a/TMessagesProj/src/main/java/org/telegram/android/MessagesController.java b/TMessagesProj/src/main/java/org/telegram/android/MessagesController.java index 76fb997e..f6332c27 100644 --- a/TMessagesProj/src/main/java/org/telegram/android/MessagesController.java +++ b/TMessagesProj/src/main/java/org/telegram/android/MessagesController.java @@ -110,6 +110,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter public static final int UPDATE_MASK_USER_PRINT = 64; public static final int UPDATE_MASK_USER_PHONE = 128; public static final int UPDATE_MASK_READ_DIALOG_MESSAGE = 256; + public static final int UPDATE_MASK_SELECT_DIALOG = 512; public static final int UPDATE_MASK_ALL = UPDATE_MASK_AVATAR | UPDATE_MASK_STATUS | UPDATE_MASK_NAME | UPDATE_MASK_CHAT_AVATAR | UPDATE_MASK_CHAT_NAME | UPDATE_MASK_CHAT_MEMBERS | UPDATE_MASK_USER_PRINT | UPDATE_MASK_USER_PHONE | UPDATE_MASK_READ_DIALOG_MESSAGE; public static class PrintingUser { @@ -1006,6 +1007,9 @@ public class MessagesController implements NotificationCenter.NotificationCenter } public void deleteDialog(final long did, int offset, final boolean onlyHistory) { + if (offset == 0) { + MessagesStorage.getInstance().deleteDialog(did, onlyHistory); + } TLRPC.TL_dialog dialog = dialogs_dict.get(did); if (dialog != null) { int lower_part = (int)did; @@ -1035,7 +1039,6 @@ public class MessagesController implements NotificationCenter.NotificationCenter }); } }); - MessagesStorage.getInstance().deleteDialog(did, onlyHistory); NotificationCenter.getInstance().postNotificationName(NotificationCenter.removeAllMessagesFromDialog, did); NotificationCenter.getInstance().postNotificationName(NotificationCenter.dialogsNeedReload); } @@ -1760,7 +1763,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter TLRPC.TL_dialog dialog = dialogs_dict.get(dialog_id); if (dialog != null) { dialog.unread_count = 0; - NotificationCenter.getInstance().postNotificationName(NotificationCenter.dialogsNeedReload); + NotificationCenter.getInstance().postNotificationName(NotificationCenter.updateInterfaces, UPDATE_MASK_READ_DIALOG_MESSAGE); } if (!popup) { NotificationsController.getInstance().processReadMessages(null, dialog_id, 0, max_positive_id, false); @@ -1824,7 +1827,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter TLRPC.TL_dialog dialog = dialogs_dict.get(dialog_id); if (dialog != null) { dialog.unread_count = 0; - NotificationCenter.getInstance().postNotificationName(NotificationCenter.dialogsNeedReload); + NotificationCenter.getInstance().postNotificationName(NotificationCenter.updateInterfaces, UPDATE_MASK_READ_DIALOG_MESSAGE); } HashMap dialogsToUpdate = new HashMap(); dialogsToUpdate.put(dialog_id, 0); @@ -2049,6 +2052,9 @@ public class MessagesController implements NotificationCenter.NotificationCenter return; } final TLRPC.messages_StatedMessage res = (TLRPC.messages_StatedMessage) response; + if (user.id == UserConfig.getClientUserId()) { + res.chats = null; + } MessagesStorage.getInstance().putUsersAndChats(res.users, res.chats, true, true); AndroidUtilities.runOnUIThread(new Runnable() { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Animation/FloatProperty.java b/TMessagesProj/src/main/java/org/telegram/ui/Animation/FloatProperty10.java similarity index 88% rename from TMessagesProj/src/main/java/org/telegram/ui/Animation/FloatProperty.java rename to TMessagesProj/src/main/java/org/telegram/ui/Animation/FloatProperty10.java index 870f895c..1a05b3bc 100755 --- a/TMessagesProj/src/main/java/org/telegram/ui/Animation/FloatProperty.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Animation/FloatProperty10.java @@ -15,9 +15,9 @@ */ package org.telegram.ui.Animation; -public abstract class FloatProperty extends Property { +public abstract class FloatProperty10 extends Property { - public FloatProperty(String name) { + public FloatProperty10(String name) { super(Float.class, name); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Animation/ObjectAnimator10.java b/TMessagesProj/src/main/java/org/telegram/ui/Animation/ObjectAnimator10.java index 6b97065b..6aa87d56 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Animation/ObjectAnimator10.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Animation/ObjectAnimator10.java @@ -18,6 +18,8 @@ package org.telegram.ui.Animation; import android.view.View; +import org.telegram.ui.Views.ActionBar.ActionBarLayout; + import java.util.HashMap; public final class ObjectAnimator10 extends ValueAnimator { @@ -25,7 +27,7 @@ public final class ObjectAnimator10 extends ValueAnimator { private static final HashMap PROXY_PROPERTIES = new HashMap(); static { - Property ALPHA = new FloatProperty("alpha") { + Property ALPHA = new FloatProperty10("alpha") { @Override public void setValue(View object, float value) { View10.wrap(object).setAlpha(value); @@ -37,7 +39,7 @@ public final class ObjectAnimator10 extends ValueAnimator { } }; - Property PIVOT_X = new FloatProperty("pivotX") { + Property PIVOT_X = new FloatProperty10("pivotX") { @Override public void setValue(View object, float value) { View10.wrap(object).setPivotX(value); @@ -49,7 +51,7 @@ public final class ObjectAnimator10 extends ValueAnimator { } }; - Property PIVOT_Y = new FloatProperty("pivotY") { + Property PIVOT_Y = new FloatProperty10("pivotY") { @Override public void setValue(View object, float value) { View10.wrap(object).setPivotY(value); @@ -61,7 +63,7 @@ public final class ObjectAnimator10 extends ValueAnimator { } }; - Property TRANSLATION_X = new FloatProperty("translationX") { + Property TRANSLATION_X = new FloatProperty10("translationX") { @Override public void setValue(View object, float value) { View10.wrap(object).setTranslationX(value); @@ -73,7 +75,7 @@ public final class ObjectAnimator10 extends ValueAnimator { } }; - Property TRANSLATION_Y = new FloatProperty("translationY") { + Property TRANSLATION_Y = new FloatProperty10("translationY") { @Override public void setValue(View object, float value) { View10.wrap(object).setTranslationY(value); @@ -85,7 +87,7 @@ public final class ObjectAnimator10 extends ValueAnimator { } }; - Property ROTATION = new FloatProperty("rotation") { + Property ROTATION = new FloatProperty10("rotation") { @Override public void setValue(View object, float value) { View10.wrap(object).setRotation(value); @@ -97,7 +99,7 @@ public final class ObjectAnimator10 extends ValueAnimator { } }; - Property ROTATION_X = new FloatProperty("rotationX") { + Property ROTATION_X = new FloatProperty10("rotationX") { @Override public void setValue(View object, float value) { View10.wrap(object).setRotationX(value); @@ -109,7 +111,7 @@ public final class ObjectAnimator10 extends ValueAnimator { } }; - Property ROTATION_Y = new FloatProperty("rotationY") { + Property ROTATION_Y = new FloatProperty10("rotationY") { @Override public void setValue(View object, float value) { View10.wrap(object).setRotationY(value); @@ -121,7 +123,7 @@ public final class ObjectAnimator10 extends ValueAnimator { } }; - Property SCALE_X = new FloatProperty("scaleX") { + Property SCALE_X = new FloatProperty10("scaleX") { @Override public void setValue(View object, float value) { View10.wrap(object).setScaleX(value); @@ -133,7 +135,7 @@ public final class ObjectAnimator10 extends ValueAnimator { } }; - Property SCALE_Y = new FloatProperty("scaleY") { + Property SCALE_Y = new FloatProperty10("scaleY") { @Override public void setValue(View object, float value) { View10.wrap(object).setScaleY(value); @@ -169,7 +171,7 @@ public final class ObjectAnimator10 extends ValueAnimator { } }; - Property X = new FloatProperty("x") { + Property X = new FloatProperty10("x") { @Override public void setValue(View object, float value) { View10.wrap(object).setX(value); @@ -181,7 +183,7 @@ public final class ObjectAnimator10 extends ValueAnimator { } }; - Property Y = new FloatProperty("y") { + Property Y = new FloatProperty10("y") { @Override public void setValue(View object, float value) { View10.wrap(object).setY(value); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Animation/PropertyValuesHolder.java b/TMessagesProj/src/main/java/org/telegram/ui/Animation/PropertyValuesHolder.java index 5f5c6c70..d01e4d9c 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Animation/PropertyValuesHolder.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Animation/PropertyValuesHolder.java @@ -148,10 +148,10 @@ public class PropertyValuesHolder implements Cloneable { Class args[] = null; if (valueType == null) { try { - returnVal = targetClass.getMethod(methodName, args); + returnVal = targetClass.getMethod(methodName); } catch (NoSuchMethodException e) { try { - returnVal = targetClass.getDeclaredMethod(methodName, args); + returnVal = targetClass.getDeclaredMethod(methodName); returnVal.setAccessible(true); } catch (NoSuchMethodException e2) { e2.printStackTrace(); @@ -464,7 +464,7 @@ public class PropertyValuesHolder implements Cloneable { static class FloatPropertyValuesHolder extends PropertyValuesHolder { private static final HashMap> sJNISetterPropertyMap = new HashMap>(); - private FloatProperty mFloatProperty; + private FloatProperty10 mFloatProperty; FloatKeyframeSet mFloatKeyframeSet; float mFloatAnimatedValue; @@ -481,8 +481,8 @@ public class PropertyValuesHolder implements Cloneable { mValueType = float.class; mKeyframeSet = keyframeSet; mFloatKeyframeSet = (FloatKeyframeSet) mKeyframeSet; - if (property instanceof FloatProperty) { - mFloatProperty = (FloatProperty) mProperty; + if (property instanceof FloatProperty10) { + mFloatProperty = (FloatProperty10) mProperty; } } @@ -494,8 +494,8 @@ public class PropertyValuesHolder implements Cloneable { public FloatPropertyValuesHolder(Property property, float... values) { super(property); setFloatValues(values); - if (property instanceof FloatProperty) { - mFloatProperty = (FloatProperty) mProperty; + if (property instanceof FloatProperty10) { + mFloatProperty = (FloatProperty10) mProperty; } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/AnimationCompat/AnimatorSetProxy.java b/TMessagesProj/src/main/java/org/telegram/ui/AnimationCompat/AnimatorSetProxy.java index e039dfb5..be53d82d 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/AnimationCompat/AnimatorSetProxy.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/AnimationCompat/AnimatorSetProxy.java @@ -18,6 +18,7 @@ import org.telegram.ui.Animation.AnimatorListenerAdapter10; import org.telegram.ui.Animation.AnimatorSet10; import org.telegram.ui.Animation.View10; +import java.util.ArrayList; import java.util.Arrays; public class AnimatorSetProxy { @@ -41,6 +42,22 @@ public class AnimatorSetProxy { } } + public void playTogether(ArrayList items) { + if (View10.NEED_PROXY) { + ArrayList animators = new ArrayList(); + for (Object obj : items) { + animators.add((Animator10)obj); + } + ((AnimatorSet10) animatorSet).playTogether(animators); + } else { + ArrayList animators = new ArrayList(); + for (Object obj : items) { + animators.add((Animator)obj); + } + ((AnimatorSet) animatorSet).playTogether(animators); + } + } + public AnimatorSetProxy setDuration(long duration) { if (View10.NEED_PROXY) { ((AnimatorSet10) animatorSet).setDuration(duration); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/AnimationCompat/ObjectAnimatorProxy.java b/TMessagesProj/src/main/java/org/telegram/ui/AnimationCompat/ObjectAnimatorProxy.java index 5263dcef..cd4df17e 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/AnimationCompat/ObjectAnimatorProxy.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/AnimationCompat/ObjectAnimatorProxy.java @@ -78,4 +78,36 @@ public class ObjectAnimatorProxy { ((ObjectAnimator) objectAnimator).start(); } } + + public void setAutoCancel(boolean cancel) { + if (View10.NEED_PROXY) { + ((ObjectAnimator10) objectAnimator).setAutoCancel(cancel); + } else { + ((ObjectAnimator) objectAnimator).setAutoCancel(cancel); + } + } + + public boolean isRunning() { + if (View10.NEED_PROXY) { + return ((ObjectAnimator10) objectAnimator).isRunning(); + } else { + return ((ObjectAnimator) objectAnimator).isRunning(); + } + } + + public void end() { + if (View10.NEED_PROXY) { + ((ObjectAnimator10) objectAnimator).end(); + } else { + ((ObjectAnimator) objectAnimator).end(); + } + } + + public void cancel() { + if (View10.NEED_PROXY) { + ((ObjectAnimator10) objectAnimator).cancel(); + } else { + ((ObjectAnimator) objectAnimator).cancel(); + } + } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatContactCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatContactCell.java index f84ceb24..4e47935c 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatContactCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatContactCell.java @@ -72,6 +72,7 @@ public class ChatContactCell extends ChatBaseCell { addContactDrawableOut = getResources().getDrawable(R.drawable.addcontact_green); } avatarImage = new ImageReceiver(this); + avatarDrawable = new AvatarDrawable(); } public void setContactDelegate(ChatContactCellDelegate delegate) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/DetailTextCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/DetailTextCell.java new file mode 100644 index 00000000..4386dfd9 --- /dev/null +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/DetailTextCell.java @@ -0,0 +1,49 @@ +/* + * 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.Cells; + +import android.content.Context; +import android.util.TypedValue; +import android.view.Gravity; +import android.widget.FrameLayout; +import android.widget.TextView; + +import org.telegram.android.AndroidUtilities; + +public class DetailTextCell extends FrameLayout { + + private TextView textView; + + public DetailTextCell(Context context) { + super(context); + + textView = new TextView(context); + textView.setTextColor(0xffa3a3a3); + textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13); + textView.setGravity(Gravity.CENTER); + textView.setPadding(0, AndroidUtilities.dp(19), 0, AndroidUtilities.dp(19)); + addView(textView); + LayoutParams layoutParams = (LayoutParams) textView.getLayoutParams(); + layoutParams.width = LayoutParams.WRAP_CONTENT; + layoutParams.height = LayoutParams.WRAP_CONTENT; + layoutParams.leftMargin = AndroidUtilities.dp(17); + layoutParams.rightMargin = AndroidUtilities.dp(17); + layoutParams.gravity = Gravity.CENTER; + textView.setLayoutParams(layoutParams); + } + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)); + } + + public void setText(String text) { + textView.setText(text); + } +} diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/DialogCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/DialogCell.java index dac69c9f..9b44bf64 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/DialogCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/DialogCell.java @@ -56,6 +56,7 @@ public class DialogCell extends BaseCell { private boolean allowPrintStrings; private int lastMessageDate; private int unreadCount; + private boolean lastUnreadState; private MessageObject message; private ImageReceiver avatarImage; @@ -148,7 +149,7 @@ public class DialogCell extends BaseCell { errorDrawable = getResources().getDrawable(R.drawable.dialogs_warning); countDrawable = getResources().getDrawable(R.drawable.dialogs_badge); groupDrawable = getResources().getDrawable(R.drawable.list_group); - broadcastDrawable = getResources().getDrawable(R.drawable.broadcast); + broadcastDrawable = getResources().getDrawable(R.drawable.list_broadcast); } } @@ -166,6 +167,7 @@ public class DialogCell extends BaseCell { allowPrintStrings = usePrintStrings; lastMessageDate = date; unreadCount = unread; + lastUnreadState = messageObject != null && messageObject.isUnread(); update(0); } @@ -584,7 +586,9 @@ public class DialogCell extends BaseCell { } } if ((mask & MessagesController.UPDATE_MASK_READ_DIALOG_MESSAGE) != 0) { - continueUpdate = true; + if (message != null && lastUnreadState != message.isUnread()) { + continueUpdate = true; + } } if (!continueUpdate) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/DividerCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/DividerCell.java index 55ce4d3f..cfc8fa11 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/DividerCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/DividerCell.java @@ -16,12 +16,15 @@ import org.telegram.android.AndroidUtilities; public class DividerCell extends BaseCell { - Paint paint = new Paint(); + private static Paint paint; public DividerCell(Context context) { super(context); - paint.setColor(0xffd9d9d9); - paint.setStrokeWidth(1); + if (paint == null) { + paint = new Paint(); + paint.setColor(0xffd9d9d9); + paint.setStrokeWidth(1); + } } @Override diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/HeaderCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/HeaderCell.java new file mode 100644 index 00000000..fcfd8b2e --- /dev/null +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/HeaderCell.java @@ -0,0 +1,70 @@ +/* + * 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.Cells; + +import android.content.Context; +import android.util.AttributeSet; +import android.util.TypedValue; +import android.view.Gravity; +import android.widget.FrameLayout; +import android.widget.TextView; + +import org.telegram.android.AndroidUtilities; +import org.telegram.android.LocaleController; + +public class HeaderCell extends FrameLayout { + + private TextView textView; + + private void init() { + textView = new TextView(getContext()); + textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15); + textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); + textView.setTextColor(0xff3e90cf); + textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL); + addView(textView); + FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams)textView.getLayoutParams(); + layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; + layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT; + layoutParams.leftMargin = AndroidUtilities.dp(17); + layoutParams.rightMargin = AndroidUtilities.dp(17); + layoutParams.topMargin = AndroidUtilities.dp(15); + layoutParams.gravity = LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT; + textView.setLayoutParams(layoutParams); + } + + public HeaderCell(Context context) { + super(context); + init(); + } + + public HeaderCell(Context context, AttributeSet attrs) { + super(context, attrs); + init(); + } + + public HeaderCell(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + init(); + } + + public HeaderCell(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { + super(context, attrs, defStyleAttr, defStyleRes); + init(); + } + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(38), MeasureSpec.EXACTLY)); + } + + public void setText(String text) { + textView.setText(text); + } +} diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ProfileSearchCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ProfileSearchCell.java index 7249674b..b8d5ac16 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ProfileSearchCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ProfileSearchCell.java @@ -95,13 +95,11 @@ public class ProfileSearchCell extends BaseCell { offlinePaint.setTextSize(AndroidUtilities.dp(16)); offlinePaint.setColor(0xff999999); - lockDrawable = getResources().getDrawable(R.drawable.list_secret); - linePaint = new Paint(); linePaint.setColor(0xffdcdcdc); - broadcastDrawable = getResources().getDrawable(R.drawable.broadcast); - + broadcastDrawable = getResources().getDrawable(R.drawable.list_broadcast); + lockDrawable = getResources().getDrawable(R.drawable.list_secret); groupDrawable = getResources().getDrawable(R.drawable.list_group); } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ShadowSectionCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ShadowSectionCell.java new file mode 100644 index 00000000..b8c7ce11 --- /dev/null +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ShadowSectionCell.java @@ -0,0 +1,48 @@ +/* + * 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.Cells; + +import android.content.Context; +import android.util.AttributeSet; +import android.view.View; + +import org.telegram.android.AndroidUtilities; +import org.telegram.messenger.R; + +public class ShadowSectionCell extends View { + + private void init() { + setBackgroundResource(R.drawable.greydivider); + } + + public ShadowSectionCell(Context context) { + super(context); + init(); + } + + public ShadowSectionCell(Context context, AttributeSet attrs) { + super(context, attrs); + init(); + } + + public ShadowSectionCell(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + init(); + } + + public ShadowSectionCell(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { + super(context, attrs, defStyleAttr, defStyleRes); + init(); + } + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(12), MeasureSpec.EXACTLY)); + } +} diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextCheckCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextCheckCell.java new file mode 100644 index 00000000..e8cc2e6e --- /dev/null +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextCheckCell.java @@ -0,0 +1,88 @@ +/* + * 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.Cells; + +import android.content.Context; +import android.graphics.Canvas; +import android.graphics.Paint; +import android.util.TypedValue; +import android.view.Gravity; +import android.widget.FrameLayout; +import android.widget.TextView; + +import org.telegram.android.AndroidUtilities; +import org.telegram.android.LocaleController; +import org.telegram.ui.Views.Switch; + +public class TextCheckCell extends FrameLayout { + + private TextView textView; + private Switch checkBox; + private static Paint paint; + private boolean needDivider; + + public TextCheckCell(Context context) { + super(context); + + if (paint == null) { + paint = new Paint(); + paint.setColor(0xffd9d9d9); + paint.setStrokeWidth(1); + } + + textView = new TextView(context); + textView.setTextColor(0xff000000); + textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); + textView.setLines(1); + textView.setMaxLines(1); + textView.setSingleLine(true); + textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL); + addView(textView); + LayoutParams layoutParams = (LayoutParams) textView.getLayoutParams(); + layoutParams.width = LayoutParams.MATCH_PARENT; + layoutParams.height = LayoutParams.MATCH_PARENT; + layoutParams.leftMargin = AndroidUtilities.dp(17); + layoutParams.rightMargin = AndroidUtilities.dp(17); + layoutParams.gravity = LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT; + textView.setLayoutParams(layoutParams); + + checkBox = new Switch(context); + checkBox.setDuplicateParentStateEnabled(false); + checkBox.setFocusable(false); + checkBox.setFocusableInTouchMode(false); + checkBox.setClickable(false); + addView(checkBox); + layoutParams = (LayoutParams) checkBox.getLayoutParams(); + layoutParams.width = LayoutParams.WRAP_CONTENT; + layoutParams.height = LayoutParams.WRAP_CONTENT; + layoutParams.leftMargin = AndroidUtilities.dp(14); + layoutParams.rightMargin = AndroidUtilities.dp(14); + layoutParams.gravity = (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL; + checkBox.setLayoutParams(layoutParams); + } + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(48) + (needDivider ? 1 : 0), MeasureSpec.EXACTLY)); + } + + public void setTextAndCheck(String text, boolean checked, boolean divider) { + textView.setText(text); + checkBox.setChecked(checked); + needDivider = divider; + setWillNotDraw(!divider); + } + + @Override + protected void onDraw(Canvas canvas) { + if (needDivider) { + canvas.drawLine(getPaddingLeft(), getHeight() - 1, getWidth() - getPaddingRight(), getHeight() - 1, paint); + } + } +} diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextDetailCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextDetailCell.java index 1854a990..f85c4b94 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextDetailCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextDetailCell.java @@ -39,7 +39,7 @@ public class TextDetailCell extends FrameLayout { FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) textView.getLayoutParams(); layoutParams.width = LayoutParams.WRAP_CONTENT; layoutParams.height = LayoutParams.WRAP_CONTENT; - layoutParams.topMargin = AndroidUtilities.dp(11); + layoutParams.topMargin = AndroidUtilities.dp(10); layoutParams.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? 16 : 71); layoutParams.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? 71 : 16); layoutParams.gravity = LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT; @@ -56,7 +56,7 @@ public class TextDetailCell extends FrameLayout { layoutParams = (FrameLayout.LayoutParams) valueTextView.getLayoutParams(); layoutParams.width = LayoutParams.WRAP_CONTENT; layoutParams.height = LayoutParams.WRAP_CONTENT; - layoutParams.topMargin = AndroidUtilities.dp(36); + layoutParams.topMargin = AndroidUtilities.dp(35); layoutParams.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? 16 : 71); layoutParams.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? 71 : 16); layoutParams.gravity = LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextDetailSettingsCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextDetailSettingsCell.java new file mode 100644 index 00000000..5d23153b --- /dev/null +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextDetailSettingsCell.java @@ -0,0 +1,91 @@ +/* + * 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.Cells; + +import android.content.Context; +import android.graphics.Canvas; +import android.graphics.Paint; +import android.util.TypedValue; +import android.view.Gravity; +import android.widget.FrameLayout; +import android.widget.TextView; + +import org.telegram.android.AndroidUtilities; +import org.telegram.android.LocaleController; + +public class TextDetailSettingsCell extends FrameLayout { + + private TextView textView; + private TextView valueTextView; + private static Paint paint; + private boolean needDivider; + + public TextDetailSettingsCell(Context context) { + super(context); + + if (paint == null) { + paint = new Paint(); + paint.setColor(0xffd9d9d9); + paint.setStrokeWidth(1); + } + + textView = new TextView(context); + textView.setTextColor(0xff000000); + textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); + textView.setLines(1); + textView.setMaxLines(1); + textView.setSingleLine(true); + textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL); + addView(textView); + LayoutParams layoutParams = (LayoutParams) textView.getLayoutParams(); + layoutParams.width = LayoutParams.WRAP_CONTENT; + layoutParams.height = LayoutParams.WRAP_CONTENT; + layoutParams.topMargin = AndroidUtilities.dp(10); + layoutParams.leftMargin = AndroidUtilities.dp(17); + layoutParams.rightMargin = AndroidUtilities.dp(17); + layoutParams.gravity = LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT; + textView.setLayoutParams(layoutParams); + + valueTextView = new TextView(context); + valueTextView.setTextColor(0xff8a8a8a); + valueTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13); + valueTextView.setLines(1); + valueTextView.setMaxLines(1); + valueTextView.setSingleLine(true); + valueTextView.setGravity((LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL); + addView(valueTextView); + layoutParams = (LayoutParams) valueTextView.getLayoutParams(); + layoutParams.width = LayoutParams.WRAP_CONTENT; + layoutParams.height = LayoutParams.WRAP_CONTENT; + layoutParams.topMargin = AndroidUtilities.dp(35); + layoutParams.leftMargin = AndroidUtilities.dp(17); + layoutParams.rightMargin = AndroidUtilities.dp(17); + layoutParams.gravity = LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT; + valueTextView.setLayoutParams(layoutParams); + } + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(64) + (needDivider ? 1 : 0), MeasureSpec.EXACTLY)); + } + + public void setTextAndValue(String text, String value, boolean divider) { + textView.setText(text); + valueTextView.setText(value); + needDivider = divider; + setWillNotDraw(!divider); + } + + @Override + protected void onDraw(Canvas canvas) { + if (needDivider) { + canvas.drawLine(getPaddingLeft(), getHeight() - 1, getWidth() - getPaddingRight(), getHeight() - 1, paint); + } + } +} diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextSettingsCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextSettingsCell.java new file mode 100644 index 00000000..4d56c03e --- /dev/null +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextSettingsCell.java @@ -0,0 +1,101 @@ +/* + * 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.Cells; + +import android.content.Context; +import android.graphics.Canvas; +import android.graphics.Paint; +import android.util.TypedValue; +import android.view.Gravity; +import android.widget.FrameLayout; +import android.widget.TextView; + +import org.telegram.android.AndroidUtilities; +import org.telegram.android.LocaleController; + +public class TextSettingsCell extends FrameLayout { + + private TextView textView; + private TextView valueTextView; + private static Paint paint; + private boolean needDivider; + + public TextSettingsCell(Context context) { + super(context); + + if (paint == null) { + paint = new Paint(); + paint.setColor(0xffd9d9d9); + paint.setStrokeWidth(1); + } + + textView = new TextView(context); + textView.setTextColor(0xff000000); + textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); + textView.setLines(1); + textView.setMaxLines(1); + textView.setSingleLine(true); + textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL); + addView(textView); + LayoutParams layoutParams = (LayoutParams) textView.getLayoutParams(); + layoutParams.width = LayoutParams.MATCH_PARENT; + layoutParams.height = LayoutParams.MATCH_PARENT; + layoutParams.leftMargin = AndroidUtilities.dp(17); + layoutParams.rightMargin = AndroidUtilities.dp(17); + layoutParams.gravity = LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT; + textView.setLayoutParams(layoutParams); + + valueTextView = new TextView(context); + valueTextView.setTextColor(0xff2f8cc9); + valueTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); + valueTextView.setLines(1); + valueTextView.setMaxLines(1); + valueTextView.setSingleLine(true); + valueTextView.setGravity((LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL); + addView(valueTextView); + layoutParams = (LayoutParams) valueTextView.getLayoutParams(); + layoutParams.width = LayoutParams.WRAP_CONTENT; + layoutParams.height = LayoutParams.MATCH_PARENT; + layoutParams.leftMargin = AndroidUtilities.dp(17); + layoutParams.rightMargin = AndroidUtilities.dp(17); + layoutParams.gravity = LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT; + valueTextView.setLayoutParams(layoutParams); + } + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(48) + (needDivider ? 1 : 0), MeasureSpec.EXACTLY)); + } + + public void setTextColor(int color) { + textView.setTextColor(color); + } + + public void setText(String text, boolean divider) { + textView.setText(text); + valueTextView.setVisibility(GONE); + needDivider = divider; + setWillNotDraw(!divider); + } + + public void setTextAndValue(String text, String value, boolean divider) { + textView.setText(text); + valueTextView.setText(value); + valueTextView.setVisibility(VISIBLE); + needDivider = divider; + setWillNotDraw(!divider); + } + + @Override + protected void onDraw(Canvas canvas) { + if (needDivider) { + canvas.drawLine(getPaddingLeft(), getHeight() - 1, getWidth() - getPaddingRight(), getHeight() - 1, paint); + } + } +} diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java index d5e8630d..61cd94c0 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java @@ -71,7 +71,7 @@ import org.telegram.ui.Cells.ChatBaseCell; import org.telegram.ui.Cells.ChatContactCell; import org.telegram.ui.Cells.ChatMediaCell; import org.telegram.ui.Cells.ChatMessageCell; -import org.telegram.ui.Views.ActionBar.ActionBarLayer; +import org.telegram.ui.Views.ActionBar.ActionBar; import org.telegram.ui.Views.ActionBar.ActionBarMenu; import org.telegram.ui.Views.ActionBar.ActionBarMenuItem; import org.telegram.ui.Views.AvatarDrawable; @@ -165,6 +165,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not private int onlineCount = -1; private CharSequence lastPrintString; + private TLRPC.UserStatus lastStatus; private long chatEnterTime = 0; private long chatLeaveTime = 0; @@ -190,7 +191,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not AdapterView.OnItemLongClickListener onItemLongClickListener = new AdapterView.OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView adapter, View view, int position, long id) { - if (!actionBarLayer.isActionModeShowed()) { + if (!actionBar.isActionModeShowed()) { createMenu(view, false); } return true; @@ -200,7 +201,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not AdapterView.OnItemClickListener onItemClickListener = new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView adapterView, View view, int i, long l) { - if (actionBarLayer.isActionModeShowed()) { + if (actionBar.isActionModeShowed()) { processRowSelect(view); return; } @@ -443,9 +444,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not public View createView(LayoutInflater inflater, ViewGroup container) { if (fragmentView == null) { - actionBarLayer.setBackButtonImage(R.drawable.ic_ab_back); - actionBarLayer.setBackOverlay(R.layout.updating_state_layout); - actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() { + actionBar.setBackButtonImage(R.drawable.ic_ab_back); + actionBar.setBackOverlay(R.layout.updating_state_layout); + actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @Override public void onItemClick(int id) { if (id == -1) { @@ -453,7 +454,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } else if (id == -2) { selectedMessagesIds.clear(); selectedMessagesCanCopyIds.clear(); - actionBarLayer.hideActionMode(); + actionBar.hideActionMode(); updateVisibleRows(); } else if (id == attach_photo) { try { @@ -604,7 +605,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } selectedMessagesIds.clear(); selectedMessagesCanCopyIds.clear(); - actionBarLayer.hideActionMode(); + actionBar.hideActionMode(); updateVisibleRows(); } else if (id == delete) { ArrayList ids = new ArrayList(selectedMessagesIds.keySet()); @@ -619,7 +620,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } } MessagesController.getInstance().deleteMessages(ids, random_ids, currentEncryptedChat); - actionBarLayer.hideActionMode(); + actionBar.hideActionMode(); } else if (id == forward) { Bundle args = new Bundle(); args.putBoolean("onlySelect", true); @@ -633,15 +634,16 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } }); + updateTitle(); updateSubtitle(); if (currentEncryptedChat != null) { - actionBarLayer.setTitleIcon(R.drawable.ic_lock_white, AndroidUtilities.dp(4)); + actionBar.setTitleIcon(R.drawable.ic_lock_white, AndroidUtilities.dp(4)); } else if (currentChat != null && currentChat.id < 0) { - actionBarLayer.setTitleIcon(R.drawable.broadcast2, AndroidUtilities.dp(4)); + actionBar.setTitleIcon(R.drawable.broadcast2, AndroidUtilities.dp(4)); } - ActionBarMenu menu = actionBarLayer.createMenu(); + ActionBarMenu menu = actionBar.createMenu(); if (currentEncryptedChat != null) { timeItem = menu.addItemResource(chat_enc_timer, R.layout.chat_header_enc_layout); @@ -657,7 +659,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not actionModeViews.clear(); - final ActionBarMenu actionMode = actionBarLayer.createActionMode(); + final ActionBarMenu actionMode = actionBar.createActionMode(); actionModeViews.add(actionMode.addItem(-2, R.drawable.ic_ab_done_gray, R.drawable.bar_selector_mode)); FrameLayout layout = new FrameLayout(actionMode.getContext()); @@ -713,7 +715,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not View contentView = fragmentView.findViewById(R.id.chat_layout); TextView emptyView = (TextView) fragmentView.findViewById(R.id.searchEmptyView); emptyViewContainer = fragmentView.findViewById(R.id.empty_view); - emptyViewContainer.setVisibility(View.GONE); + emptyViewContainer.setVisibility(View.INVISIBLE); emptyViewContainer.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { @@ -776,7 +778,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } if (currentEncryptedChat != null) { - emptyView.setVisibility(View.GONE); + emptyView.setVisibility(View.INVISIBLE); View secretChatPlaceholder = contentView.findViewById(R.id.secret_placeholder); secretChatPlaceholder.setVisibility(View.VISIBLE); if (isCustomTheme) { @@ -828,7 +830,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not chatListView.setOnInterceptTouchEventListener(new LayoutListView.OnInterceptTouchEventListener() { @Override public boolean onInterceptTouchEvent(MotionEvent event) { - if (actionBarLayer.isActionModeShowed()) { + if (actionBar.isActionModeShowed()) { return false; } if (event.getAction() == MotionEvent.ACTION_DOWN) { @@ -991,7 +993,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not progressView.setVisibility(View.VISIBLE); chatListView.setEmptyView(null); } else { - progressView.setVisibility(View.GONE); + progressView.setVisibility(View.INVISIBLE); chatListView.setEmptyView(emptyViewContainer); } @@ -1206,8 +1208,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not onlineCount++; } } - - updateSubtitle(); } private int getMessageType(MessageObject messageObject) { @@ -1333,11 +1333,11 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not selectedMessagesCanCopyIds.put(messageObject.messageOwner.id, messageObject); } } - if (actionBarLayer.isActionModeShowed()) { + if (actionBar.isActionModeShowed()) { if (selectedMessagesIds.isEmpty()) { - actionBarLayer.hideActionMode(); + actionBar.hideActionMode(); } - actionBarLayer.createActionMode().getItem(copy).setVisibility(selectedMessagesCanCopyIds.size() != 0 ? View.VISIBLE : View.GONE); + actionBar.createActionMode().getItem(copy).setVisibility(selectedMessagesCanCopyIds.size() != 0 ? View.VISIBLE : View.GONE); } } @@ -1360,7 +1360,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } private void updateActionModeTitle() { - if (!actionBarLayer.isActionModeShowed()) { + if (!actionBar.isActionModeShowed()) { return; } if (!selectedMessagesIds.isEmpty()) { @@ -1368,21 +1368,23 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } } - private void updateSubtitle() { + private void updateTitle() { if (currentChat != null) { - actionBarLayer.setTitle(currentChat.title); + actionBar.setTitle(currentChat.title); } else if (currentUser != null) { if (currentUser.id / 1000 != 777 && currentUser.id / 1000 != 333 && ContactsController.getInstance().contactsDict.get(currentUser.id) == null && (ContactsController.getInstance().contactsDict.size() != 0 || !ContactsController.getInstance().isLoadingContacts())) { if (currentUser.phone != null && currentUser.phone.length() != 0) { - actionBarLayer.setTitle(PhoneFormat.getInstance().format("+" + currentUser.phone)); + actionBar.setTitle(PhoneFormat.getInstance().format("+" + currentUser.phone)); } else { - actionBarLayer.setTitle(ContactsController.formatName(currentUser.first_name, currentUser.last_name)); + actionBar.setTitle(ContactsController.formatName(currentUser.first_name, currentUser.last_name)); } } else { - actionBarLayer.setTitle(ContactsController.formatName(currentUser.first_name, currentUser.last_name)); + actionBar.setTitle(ContactsController.formatName(currentUser.first_name, currentUser.last_name)); } } + } + private void updateSubtitle() { CharSequence printString = MessagesController.getInstance().printingStrings.get(dialog_id); if (printString != null) { printString = TextUtils.replace(printString, new String[]{"..."}, new String[]{""}); @@ -1392,18 +1394,18 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not setTypingAnimation(false); if (currentChat != null) { if (currentChat instanceof TLRPC.TL_chatForbidden) { - actionBarLayer.setSubtitle(LocaleController.getString("YouWereKicked", R.string.YouWereKicked)); + actionBar.setSubtitle(LocaleController.getString("YouWereKicked", R.string.YouWereKicked)); } else if (currentChat.left) { - actionBarLayer.setSubtitle(LocaleController.getString("YouLeft", R.string.YouLeft)); + actionBar.setSubtitle(LocaleController.getString("YouLeft", R.string.YouLeft)); } else { int count = currentChat.participants_count; if (info != null) { count = info.participants.size(); } if (onlineCount > 1 && count != 0) { - actionBarLayer.setSubtitle(String.format("%s, %s", LocaleController.formatPluralString("Members", count), LocaleController.formatPluralString("Online", onlineCount))); + actionBar.setSubtitle(String.format("%s, %s", LocaleController.formatPluralString("Members", count), LocaleController.formatPluralString("Online", onlineCount))); } else { - actionBarLayer.setSubtitle(LocaleController.formatPluralString("Members", count)); + actionBar.setSubtitle(LocaleController.formatPluralString("Members", count)); } } } else if (currentUser != null) { @@ -1411,28 +1413,31 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not if (user != null) { currentUser = user; } - actionBarLayer.setSubtitle(LocaleController.formatUserStatus(currentUser)); + if (lastStatus != user.status || lastStatus != null && user.status != null && lastStatus.expires != user.status.expires) { + lastStatus = user.status; + actionBar.setSubtitle(LocaleController.formatUserStatus(currentUser)); + } } } else { lastPrintString = printString; - actionBarLayer.setSubtitle(printString); + actionBar.setSubtitle(printString); setTypingAnimation(true); } } private void setTypingAnimation(boolean start) { - if (actionBarLayer == null) { + if (actionBar == null) { return; } if (start) { try { - actionBarLayer.setSubTitleIcon(0, typingDotsDrawable, AndroidUtilities.dp(4)); + actionBar.setSubTitleIcon(0, typingDotsDrawable, AndroidUtilities.dp(4)); typingDotsDrawable.start(); } catch (Exception e) { FileLog.e("tmessages", e); } } else { - actionBarLayer.setSubTitleIcon(0, null, 0); + actionBar.setSubTitleIcon(0, null, 0); if (typingDotsDrawable != null) { typingDotsDrawable.stop(); } @@ -1614,6 +1619,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not @Override public void didReceivedNotification(int id, final Object... args) { if (id == NotificationCenter.messagesDidLoaded) { + long did = (Long)args[0]; if (did == dialog_id) { loadsCount++; @@ -1788,7 +1794,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } } chatListView.getViewTreeObserver().removeOnPreDrawListener(this); - return false; + return true; } }); chatListView.invalidate(); @@ -1830,16 +1836,23 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } if (first && messages.size() > 0) { - if (last_message_id != 0) { - MessagesController.getInstance().markDialogAsRead(dialog_id, messages.get(0).messageOwner.id, last_message_id, 0, last_unread_date, wasUnread, false); - } else { - MessagesController.getInstance().markDialogAsRead(dialog_id, messages.get(0).messageOwner.id, minMessageId, 0, maxDate, wasUnread, false); - } + final boolean wasUnreadFinal = wasUnread; + final int last_unread_date_final = last_unread_date; + AndroidUtilities.runOnUIThread(new Runnable() { + @Override + public void run() { + if (last_message_id != 0) { + MessagesController.getInstance().markDialogAsRead(dialog_id, messages.get(0).messageOwner.id, last_message_id, 0, last_unread_date_final, wasUnreadFinal, false); + } else { + MessagesController.getInstance().markDialogAsRead(dialog_id, messages.get(0).messageOwner.id, minMessageId, 0, maxDate, wasUnreadFinal, false); + } + } + }, 700); first = false; } if (progressView != null) { - progressView.setVisibility(View.GONE); + progressView.setVisibility(View.INVISIBLE); } } } else if (id == NotificationCenter.emojiDidLoaded) { @@ -1848,10 +1861,20 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } } else if (id == NotificationCenter.updateInterfaces) { int updateMask = (Integer)args[0]; - if ((updateMask & MessagesController.UPDATE_MASK_NAME) != 0 || (updateMask & MessagesController.UPDATE_MASK_STATUS) != 0 || (updateMask & MessagesController.UPDATE_MASK_CHAT_NAME) != 0 || (updateMask & MessagesController.UPDATE_MASK_CHAT_MEMBERS) != 0) { - updateSubtitle(); + if ((updateMask & MessagesController.UPDATE_MASK_NAME) != 0 || (updateMask & MessagesController.UPDATE_MASK_CHAT_NAME) != 0) { + updateTitle(); + } + boolean updateSubtitle = false; + if ((updateMask & MessagesController.UPDATE_MASK_CHAT_MEMBERS) != 0) { + updateSubtitle = true; updateOnlineCount(); } + if ((updateMask & MessagesController.UPDATE_MASK_STATUS) != 0) { + updateSubtitle = true; + } + if (updateSubtitle) { + updateSubtitle(); + } if ((updateMask & MessagesController.UPDATE_MASK_AVATAR) != 0 || (updateMask & MessagesController.UPDATE_MASK_CHAT_AVATAR) != 0 || (updateMask & MessagesController.UPDATE_MASK_NAME) != 0) { checkAndUpdateAvatar(); updateVisibleRows(); @@ -2000,7 +2023,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } } if (progressView != null) { - progressView.setVisibility(View.GONE); + progressView.setVisibility(View.INVISIBLE); } if (chatAdapter != null) { chatAdapter.notifyDataSetChanged(); @@ -2044,7 +2067,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } } if (updateChat) { - updateSubtitle(); + updateTitle(); checkAndUpdateAvatar(); } } @@ -2092,7 +2115,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } if (messages.isEmpty()) { if (!endReached && !loading) { - progressView.setVisibility(View.GONE); + progressView.setVisibility(View.INVISIBLE); chatListView.setEmptyView(null); if (currentEncryptedChat == null) { maxMessageId = Integer.MAX_VALUE; @@ -2146,6 +2169,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not if (currentChat != null && chatId == currentChat.id) { info = (TLRPC.ChatParticipants)args[1]; updateOnlineCount(); + updateSubtitle(); if (isBroadcast) { SendMessagesHelper.getInstance().setCurrentChatInfo(info); } @@ -2213,7 +2237,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not messages.clear(); messagesByDays.clear(); messagesDict.clear(); - progressView.setVisibility(View.GONE); + progressView.setVisibility(View.INVISIBLE); chatListView.setEmptyView(emptyViewContainer); if (currentEncryptedChat == null) { maxMessageId = Integer.MAX_VALUE; @@ -2226,7 +2250,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not minDate = 0; selectedMessagesIds.clear(); selectedMessagesCanCopyIds.clear(); - actionBarLayer.hideActionMode(); + actionBar.hideActionMode(); chatAdapter.notifyDataSetChanged(); } } else if (id == NotificationCenter.screenshotTook) { @@ -2383,15 +2407,10 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not public void onResume() { super.onResume(); - if (parentLayout != null) { - parentLayout.getDrawerLayoutContainer().setStatusBarColor(0xff54759e); - } getParentActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); checkActionBarMenu(); - if (chatAdapter != null) { - chatAdapter.notifyDataSetChanged(); - } + NotificationsController.getInstance().setOpennedDialogId(dialog_id); if (scrollToTopOnResume) { if (scrollToTopUnReadOnResume && scrollToMessage != null) { @@ -2462,7 +2481,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not @Override public void onPause() { super.onPause(); - actionBarLayer.hideActionMode(); + actionBar.hideActionMode(); chatActivityEnterView.hideEmojiPopup(); paused = true; NotificationsController.getInstance().setOpennedDialogId(0); @@ -2507,40 +2526,53 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } private void fixLayout(final boolean resume) { - final int lastPos = chatListView.getLastVisiblePosition(); - ViewTreeObserver obs = chatListView.getViewTreeObserver(); - obs.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { - @Override - public boolean onPreDraw() { - if (chatListView != null) { + if (avatarImageView != null) { + avatarImageView.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { + @Override + public boolean onPreDraw() { + if (avatarImageView != null) { + avatarImageView.getViewTreeObserver().removeOnPreDrawListener(this); + } + if (getParentActivity() == null) { + return false; + } + int height = AndroidUtilities.getCurrentActionBarHeight(); + if (!AndroidUtilities.isTablet() && getParentActivity().getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { + selectedMessagesCountTextView.setTextSize(16); + } else { + selectedMessagesCountTextView.setTextSize(18); + } + if (avatarImageView != null) { + RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) avatarImageView.getLayoutParams(); + params.width = height; + params.height = height; + avatarImageView.setLayoutParams(params); + } + return false; + } + }); + } + if (!resume && chatListView != null) { + final int lastPos = chatListView.getLastVisiblePosition(); + chatListView.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { + @Override + public boolean onPreDraw() { + if (chatListView == null) { + return false; + } chatListView.getViewTreeObserver().removeOnPreDrawListener(this); + if (lastPos >= messages.size() - 1) { + chatListView.post(new Runnable() { + @Override + public void run() { + chatListView.setSelectionFromTop(messages.size() - 1, -100000 - chatListView.getPaddingTop()); + } + }); + } + return false; } - if (getParentActivity() == null) { - return true; - } - int height = AndroidUtilities.getCurrentActionBarHeight(); - if (!AndroidUtilities.isTablet() && getParentActivity().getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { - selectedMessagesCountTextView.setTextSize(16); - } else { - selectedMessagesCountTextView.setTextSize(18); - } - if (avatarImageView != null) { - RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) avatarImageView.getLayoutParams(); - params.width = height; - params.height = height; - avatarImageView.setLayoutParams(params); - } - if (!resume && lastPos >= messages.size() - 1) { - chatListView.post(new Runnable() { - @Override - public void run() { - chatListView.setSelectionFromTop(messages.size() - 1, -100000 - chatListView.getPaddingTop()); - } - }); - } - return false; - } - }); + }); + } } @Override @@ -2549,7 +2581,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } public void createMenu(View v, boolean single) { - if (actionBarLayer.isActionModeShowed()) { + if (actionBar.isActionModeShowed()) { return; } @@ -2702,7 +2734,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } return; } - actionBarLayer.showActionMode(); + actionBar.showActionMode(); if (Build.VERSION.SDK_INT >= 11) { AnimatorSet animatorSet = new AnimatorSet(); ArrayList animators = new ArrayList(); @@ -2868,7 +2900,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not chatListView.setSelectionFromTop(messages.size() - 1, -100000 - chatListView.getPaddingTop()); scrollToTopOnResume = true; if (AndroidUtilities.isTablet()) { - actionBarLayer.hideActionMode(); + actionBar.hideActionMode(); } } } @@ -2876,10 +2908,10 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not @Override public boolean onBackPressed() { - if (actionBarLayer.isActionModeShowed()) { + if (actionBar.isActionModeShowed()) { selectedMessagesIds.clear(); selectedMessagesCanCopyIds.clear(); - actionBarLayer.hideActionMode(); + actionBar.hideActionMode(); updateVisibleRows(); return false; } else if (chatActivityEnterView.isEmojiPopupShowing()) { @@ -2930,7 +2962,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not boolean disableSelection = false; boolean selected = false; - if (actionBarLayer.isActionModeShowed()) { + if (actionBar.isActionModeShowed()) { if (selectedMessagesIds.containsKey(cell.getMessageObject().messageOwner.id)) { view.setBackgroundColor(0x6633b5e5); selected = true; @@ -3122,7 +3154,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not ((ChatBaseCell)view).setDelegate(new ChatBaseCell.ChatBaseCellDelegate() { @Override public void didPressedUserAvatar(ChatBaseCell cell, TLRPC.User user) { - if (actionBarLayer.isActionModeShowed()) { + if (actionBar.isActionModeShowed()) { processRowSelect(cell); return; } @@ -3148,7 +3180,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not @Override public boolean canPerformActions() { - return actionBarLayer != null && !actionBarLayer.isActionModeShowed(); + return actionBar != null && !actionBar.isActionModeShowed(); } }); if (view instanceof ChatMediaCell) { @@ -3248,7 +3280,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not ((ChatContactCell)view).setContactDelegate(new ChatContactCell.ChatContactCellDelegate() { @Override public void didClickAddButton(ChatContactCell cell, TLRPC.User user) { - if (actionBarLayer.isActionModeShowed()) { + if (actionBar.isActionModeShowed()) { processRowSelect(cell); return; } @@ -3261,7 +3293,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not @Override public void didClickPhone(ChatContactCell cell) { - if (actionBarLayer.isActionModeShowed()) { + if (actionBar.isActionModeShowed()) { processRowSelect(cell); return; } @@ -3326,7 +3358,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not boolean selected = false; boolean disableSelection = false; - if (actionBarLayer.isActionModeShowed()) { + if (actionBar.isActionModeShowed()) { if (selectedMessagesIds.containsKey(message.messageOwner.id)) { view.setBackgroundColor(0x6633b5e5); selected = true; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChatProfileActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChatProfileActivity.java index f58ead16..bb9ad4bd 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChatProfileActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChatProfileActivity.java @@ -37,7 +37,7 @@ import org.telegram.messenger.Utilities; import org.telegram.android.MessageObject; import org.telegram.ui.Adapters.BaseFragmentAdapter; import org.telegram.ui.Cells.UserCell; -import org.telegram.ui.Views.ActionBar.ActionBarLayer; +import org.telegram.ui.Views.ActionBar.ActionBar; import org.telegram.ui.Views.ActionBar.ActionBarMenu; import org.telegram.ui.Views.AvatarDrawable; import org.telegram.ui.Views.AvatarUpdater; @@ -173,14 +173,14 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen public View createView(LayoutInflater inflater, ViewGroup container) { if (fragmentView == null) { - actionBarLayer.setBackButtonImage(R.drawable.ic_ab_back); - actionBarLayer.setBackOverlay(R.layout.updating_state_layout); + actionBar.setBackButtonImage(R.drawable.ic_ab_back); + actionBar.setBackOverlay(R.layout.updating_state_layout); if (chat_id > 0) { - actionBarLayer.setTitle(LocaleController.getString("GroupInfo", R.string.GroupInfo)); + actionBar.setTitle(LocaleController.getString("GroupInfo", R.string.GroupInfo)); } else { - actionBarLayer.setTitle(LocaleController.getString("BroadcastList", R.string.BroadcastList)); + actionBar.setTitle(LocaleController.getString("BroadcastList", R.string.BroadcastList)); } - actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() { + actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @Override public void onItemClick(int id) { if (id == -1) { @@ -190,7 +190,7 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen } } }); - ActionBarMenu menu = actionBarLayer.createMenu(); + ActionBarMenu menu = actionBar.createMenu(); View item = menu.addItemResource(done_button, R.layout.group_profile_add_member_layout); TextView textView = (TextView)item.findViewById(R.id.done_button); if (textView != null) { @@ -653,7 +653,7 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen if (i == settingsSectionRow) { ((SettingsSectionLayout) view).setText(LocaleController.getString("SETTINGS", R.string.SETTINGS)); } else if (i == sharedMediaSectionRow) { - ((SettingsSectionLayout) view).setText(LocaleController.getString("SHAREDMEDIA", R.string.SHAREDMEDIA)); + } else if (i == membersSectionRow) { TLRPC.Chat chat = MessagesController.getInstance().getChat(chat_id); int count = chat.participants_count; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChatProfileChangeNameActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChatProfileChangeNameActivity.java index a77ea02e..461672d5 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChatProfileChangeNameActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChatProfileChangeNameActivity.java @@ -52,16 +52,16 @@ public class ChatProfileChangeNameActivity extends BaseFragment { @Override public View createView(LayoutInflater inflater, ViewGroup container) { if (fragmentView == null) { - actionBarLayer.setCustomView(R.layout.settings_do_action_layout); + actionBar.setCustomView(R.layout.settings_do_action_layout); - Button cancelButton = (Button)actionBarLayer.findViewById(R.id.cancel_button); + Button cancelButton = (Button) actionBar.findViewById(R.id.cancel_button); cancelButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { finishFragment(); } }); - doneButton = actionBarLayer.findViewById(R.id.done_button); + doneButton = actionBar.findViewById(R.id.done_button); doneButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ContactAddActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ContactAddActivity.java index 28a9a3c3..d4c2f7ef 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ContactAddActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ContactAddActivity.java @@ -65,15 +65,15 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent @Override public View createView(LayoutInflater inflater, ViewGroup container) { if (fragmentView == null) { - actionBarLayer.setCustomView(R.layout.settings_do_action_layout); - Button cancelButton = (Button)actionBarLayer.findViewById(R.id.cancel_button); + actionBar.setCustomView(R.layout.settings_do_action_layout); + Button cancelButton = (Button) actionBar.findViewById(R.id.cancel_button); cancelButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { finishFragment(); } }); - doneButton = actionBarLayer.findViewById(R.id.done_button); + doneButton = actionBar.findViewById(R.id.done_button); doneButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ContactsActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ContactsActivity.java index 583319f9..1b128d87 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ContactsActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ContactsActivity.java @@ -42,7 +42,7 @@ import org.telegram.ui.Adapters.BaseSectionsAdapter; import org.telegram.ui.Adapters.ContactsActivityAdapter; import org.telegram.ui.Adapters.ContactsActivitySearchAdapter; import org.telegram.ui.Cells.UserCell; -import org.telegram.ui.Views.ActionBar.ActionBarLayer; +import org.telegram.ui.Views.ActionBar.ActionBar; import org.telegram.ui.Views.ActionBar.ActionBarMenu; import org.telegram.ui.Views.ActionBar.ActionBarMenuItem; import org.telegram.ui.Views.ActionBar.BaseFragment; @@ -117,15 +117,15 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter searching = false; searchWas = false; - actionBarLayer.setBackButtonImage(R.drawable.ic_ab_back); - actionBarLayer.setBackOverlay(R.layout.updating_state_layout); + actionBar.setBackButtonImage(R.drawable.ic_ab_back); + actionBar.setBackOverlay(R.layout.updating_state_layout); if (destroyAfterSelect) { - actionBarLayer.setTitle(LocaleController.getString("SelectContact", R.string.SelectContact)); + actionBar.setTitle(LocaleController.getString("SelectContact", R.string.SelectContact)); } else { - actionBarLayer.setTitle(LocaleController.getString("Contacts", R.string.Contacts)); + actionBar.setTitle(LocaleController.getString("Contacts", R.string.Contacts)); } - actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() { + actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @Override public void onItemClick(int id) { if (id == -1) { @@ -134,7 +134,7 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter } }); - ActionBarMenu menu = actionBarLayer.createMenu(); + ActionBarMenu menu = actionBar.createMenu(); menu.addItem(0, R.drawable.ic_ab_search).setIsSearchField(true).setActionBarMenuItemSearchListener(new ActionBarMenuItem.ActionBarMenuItemSearchListener() { @Override public void onSearchExpand() { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/CountrySelectActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/CountrySelectActivity.java index 4419303b..c687be75 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/CountrySelectActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/CountrySelectActivity.java @@ -25,7 +25,7 @@ import org.telegram.android.LocaleController; import org.telegram.messenger.R; import org.telegram.messenger.Utilities; import org.telegram.ui.Adapters.BaseFragmentAdapter; -import org.telegram.ui.Views.ActionBar.ActionBarLayer; +import org.telegram.ui.Views.ActionBar.ActionBar; import org.telegram.ui.Views.ActionBar.ActionBarMenu; import org.telegram.ui.Views.ActionBar.ActionBarMenuItem; import org.telegram.ui.Views.ActionBar.BaseFragment; @@ -122,11 +122,11 @@ public class CountrySelectActivity extends BaseFragment { @Override public View createView(LayoutInflater inflater, ViewGroup container) { if (fragmentView == null) { - actionBarLayer.setBackButtonImage(R.drawable.ic_ab_back); - actionBarLayer.setBackOverlay(R.layout.updating_state_layout); - actionBarLayer.setTitle(LocaleController.getString("ChooseCountry", R.string.ChooseCountry)); + actionBar.setBackButtonImage(R.drawable.ic_ab_back); + actionBar.setBackOverlay(R.layout.updating_state_layout); + actionBar.setTitle(LocaleController.getString("ChooseCountry", R.string.ChooseCountry)); - actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() { + actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @Override public void onItemClick(int id) { if (id == -1) { @@ -135,7 +135,7 @@ public class CountrySelectActivity extends BaseFragment { } }); - ActionBarMenu menu = actionBarLayer.createMenu(); + ActionBarMenu menu = actionBar.createMenu(); menu.addItem(0, R.drawable.ic_ab_search).setIsSearchField(true).setActionBarMenuItemSearchListener(new ActionBarMenuItem.ActionBarMenuItemSearchListener() { @Override public void onSearchExpand() { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/DocumentSelectActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/DocumentSelectActivity.java index d8d6cd31..d3788938 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/DocumentSelectActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/DocumentSelectActivity.java @@ -29,7 +29,7 @@ import org.telegram.android.LocaleController; import org.telegram.messenger.R; import org.telegram.messenger.Utilities; import org.telegram.ui.Adapters.BaseFragmentAdapter; -import org.telegram.ui.Views.ActionBar.ActionBarLayer; +import org.telegram.ui.Views.ActionBar.ActionBar; import org.telegram.ui.Views.ActionBar.ActionBarMenu; import org.telegram.ui.Views.ActionBar.ActionBarMenuItem; import org.telegram.ui.Views.BackupImageView; @@ -130,10 +130,10 @@ public class DocumentSelectActivity extends BaseFragment { } if (fragmentView == null) { - actionBarLayer.setBackButtonImage(R.drawable.ic_ab_back); - actionBarLayer.setBackOverlay(R.layout.updating_state_layout); - actionBarLayer.setTitle(LocaleController.getString("SelectFile", R.string.SelectFile)); - actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() { + actionBar.setBackButtonImage(R.drawable.ic_ab_back); + actionBar.setBackOverlay(R.layout.updating_state_layout); + actionBar.setTitle(LocaleController.getString("SelectFile", R.string.SelectFile)); + actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @Override public void onItemClick(int id) { if (id == -1) { @@ -146,7 +146,7 @@ public class DocumentSelectActivity extends BaseFragment { } } }); - ActionBarMenu menu = actionBarLayer.createMenu(); + ActionBarMenu menu = actionBar.createMenu(); ActionBarMenuItem item = menu.addItem(1, R.drawable.ic_ab_other); fragmentView = inflater.inflate(R.layout.document_select_layout, container, false); @@ -168,7 +168,7 @@ public class DocumentSelectActivity extends BaseFragment { File file = item.file; if (file == null) { HistoryEntry he = history.remove(history.size() - 1); - actionBarLayer.setTitle(he.title); + actionBar.setTitle(he.title); if (he.dir != null) { listFiles(he.dir); } else { @@ -180,12 +180,12 @@ public class DocumentSelectActivity extends BaseFragment { he.scrollItem = listView.getFirstVisiblePosition(); he.scrollOffset = listView.getChildAt(0).getTop(); he.dir = currentDir; - he.title = actionBarLayer.getTitle().toString(); + he.title = actionBar.getTitle().toString(); if (!listFiles(file)) { return; } history.add(he); - actionBarLayer.setTitle(item.title); + actionBar.setTitle(item.title); listView.setSelection(0); } else { if (!file.canRead()) { @@ -230,7 +230,7 @@ public class DocumentSelectActivity extends BaseFragment { public boolean onBackPressed() { if (history.size() > 0) { HistoryEntry he = history.remove(history.size() - 1); - actionBarLayer.setTitle(he.title); + actionBar.setTitle(he.title); if (he.dir != null) { listFiles(he.dir); } else { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/GroupCreateActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/GroupCreateActivity.java index d2681cbd..8a1dc8c2 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/GroupCreateActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/GroupCreateActivity.java @@ -45,7 +45,7 @@ import org.telegram.android.NotificationCenter; import org.telegram.messenger.R; import org.telegram.messenger.UserConfig; import org.telegram.messenger.Utilities; -import org.telegram.ui.Views.ActionBar.ActionBarLayer; +import org.telegram.ui.Views.ActionBar.ActionBar; import org.telegram.ui.Views.ActionBar.ActionBarMenu; import org.telegram.ui.Views.AvatarDrawable; import org.telegram.ui.Views.BackupImageView; @@ -139,16 +139,16 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen @Override public View createView(LayoutInflater inflater, ViewGroup container) { if (fragmentView == null) { - actionBarLayer.setBackButtonImage(R.drawable.ic_ab_back); - actionBarLayer.setBackOverlay(R.layout.updating_state_layout); + actionBar.setBackButtonImage(R.drawable.ic_ab_back); + actionBar.setBackOverlay(R.layout.updating_state_layout); if (isBroadcast) { - actionBarLayer.setTitle(LocaleController.getString("NewBroadcastList", R.string.NewBroadcastList)); + actionBar.setTitle(LocaleController.getString("NewBroadcastList", R.string.NewBroadcastList)); } else { - actionBarLayer.setTitle(LocaleController.getString("NewGroup", R.string.NewGroup)); + actionBar.setTitle(LocaleController.getString("NewGroup", R.string.NewGroup)); } - actionBarLayer.setSubtitle(LocaleController.formatString("MembersCount", R.string.MembersCount, selectedContacts.size(), maxCount)); + actionBar.setSubtitle(LocaleController.formatString("MembersCount", R.string.MembersCount, selectedContacts.size(), maxCount)); - actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() { + actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @Override public void onItemClick(int id) { if (id == -1) { @@ -166,7 +166,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen } }); - ActionBarMenu menu = actionBarLayer.createMenu(); + ActionBarMenu menu = actionBar.createMenu(); View doneItem = menu.addItemResource(done_button, R.layout.group_create_done_layout); TextView doneTextView = (TextView)doneItem.findViewById(R.id.done_button); doneTextView.setText(LocaleController.getString("Next", R.string.Next)); @@ -227,7 +227,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen selectedContacts.remove(sp.uid); } } - actionBarLayer.setSubtitle(LocaleController.formatString("MembersCount", R.string.MembersCount, selectedContacts.size(), maxCount)); + actionBar.setSubtitle(LocaleController.formatString("MembersCount", R.string.MembersCount, selectedContacts.size(), maxCount)); listView.invalidateViews(); } else { search = true; @@ -293,7 +293,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen span.uid = user.id; ignoreChange = false; } - actionBarLayer.setSubtitle(LocaleController.formatString("MembersCount", R.string.MembersCount, selectedContacts.size(), maxCount)); + actionBar.setSubtitle(LocaleController.formatString("MembersCount", R.string.MembersCount, selectedContacts.size(), maxCount)); if (searching || searchWas) { searching = false; searchWas = false; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/GroupCreateFinalActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/GroupCreateFinalActivity.java index fb76a7bc..7e482fc6 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/GroupCreateFinalActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/GroupCreateFinalActivity.java @@ -31,7 +31,7 @@ import org.telegram.android.MessagesController; import org.telegram.android.NotificationCenter; import org.telegram.messenger.R; import org.telegram.ui.Cells.UserCell; -import org.telegram.ui.Views.ActionBar.ActionBarLayer; +import org.telegram.ui.Views.ActionBar.ActionBar; import org.telegram.ui.Views.ActionBar.ActionBarMenu; import org.telegram.ui.Views.AvatarDrawable; import org.telegram.ui.Views.AvatarUpdater; @@ -123,15 +123,15 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati @Override public View createView(LayoutInflater inflater, ViewGroup container) { if (fragmentView == null) { - actionBarLayer.setBackButtonImage(R.drawable.ic_ab_back); - actionBarLayer.setBackOverlay(R.layout.updating_state_layout); + actionBar.setBackButtonImage(R.drawable.ic_ab_back); + actionBar.setBackOverlay(R.layout.updating_state_layout); if (isBroadcast) { - actionBarLayer.setTitle(LocaleController.getString("NewBroadcastList", R.string.NewBroadcastList)); + actionBar.setTitle(LocaleController.getString("NewBroadcastList", R.string.NewBroadcastList)); } else { - actionBarLayer.setTitle(LocaleController.getString("NewGroup", R.string.NewGroup)); + actionBar.setTitle(LocaleController.getString("NewGroup", R.string.NewGroup)); } - actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() { + actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @Override public void onItemClick(int id) { if (id == -1) { @@ -177,7 +177,7 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati } }); - ActionBarMenu menu = actionBarLayer.createMenu(); + ActionBarMenu menu = actionBar.createMenu(); View doneItem = menu.addItemResource(done_button, R.layout.group_create_done_layout); TextView doneTextView = (TextView)doneItem.findViewById(R.id.done_button); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/IdenticonActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/IdenticonActivity.java index fa8d5624..ab436098 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/IdenticonActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/IdenticonActivity.java @@ -26,7 +26,7 @@ import org.telegram.android.LocaleController; import org.telegram.messenger.TLRPC; import org.telegram.android.MessagesController; import org.telegram.messenger.R; -import org.telegram.ui.Views.ActionBar.ActionBarLayer; +import org.telegram.ui.Views.ActionBar.ActionBar; import org.telegram.ui.Views.ActionBar.BaseFragment; import org.telegram.ui.Views.IdenticonDrawable; @@ -46,12 +46,12 @@ public class IdenticonActivity extends BaseFragment { @Override public View createView(LayoutInflater inflater, ViewGroup container) { if (fragmentView == null) { - actionBarLayer.setBackButtonImage(R.drawable.ic_ab_back); - actionBarLayer.setBackOverlay(R.layout.updating_state_layout); - actionBarLayer.setTitle(LocaleController.getString("EncryptionKey", R.string.EncryptionKey)); - actionBarLayer.setTitleIcon(R.drawable.ic_lock_white, AndroidUtilities.dp(4)); + actionBar.setBackButtonImage(R.drawable.ic_ab_back); + actionBar.setBackOverlay(R.layout.updating_state_layout); + actionBar.setTitle(LocaleController.getString("EncryptionKey", R.string.EncryptionKey)); + actionBar.setTitleIcon(R.drawable.ic_lock_white, AndroidUtilities.dp(4)); - actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() { + actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @Override public void onItemClick(int id) { if (id == -1) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LanguageSelectActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/LanguageSelectActivity.java index 848bb665..f5365d32 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/LanguageSelectActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/LanguageSelectActivity.java @@ -27,7 +27,7 @@ import org.telegram.android.LocaleController; import org.telegram.messenger.R; import org.telegram.messenger.Utilities; import org.telegram.ui.Adapters.BaseFragmentAdapter; -import org.telegram.ui.Views.ActionBar.ActionBarLayer; +import org.telegram.ui.Views.ActionBar.ActionBar; import org.telegram.ui.Views.ActionBar.ActionBarMenu; import org.telegram.ui.Views.ActionBar.ActionBarMenuItem; import org.telegram.ui.Views.ActionBar.BaseFragment; @@ -50,11 +50,11 @@ public class LanguageSelectActivity extends BaseFragment { @Override public View createView(LayoutInflater inflater, ViewGroup container) { if (fragmentView == null) { - actionBarLayer.setBackButtonImage(R.drawable.ic_ab_back); - actionBarLayer.setBackOverlay(R.layout.updating_state_layout); - actionBarLayer.setTitle(LocaleController.getString("Language", R.string.Language)); + actionBar.setBackButtonImage(R.drawable.ic_ab_back); + actionBar.setBackOverlay(R.layout.updating_state_layout); + actionBar.setTitle(LocaleController.getString("Language", R.string.Language)); - actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() { + actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @Override public void onItemClick(int id) { if (id == -1) { @@ -63,7 +63,7 @@ public class LanguageSelectActivity extends BaseFragment { } }); - ActionBarMenu menu = actionBarLayer.createMenu(); + ActionBarMenu menu = actionBar.createMenu(); menu.addItem(0, R.drawable.ic_ab_search).setIsSearchField(true).setActionBarMenuItemSearchListener(new ActionBarMenuItem.ActionBarMenuItemSearchListener() { @Override public void onSearchExpand() { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java index 6869ee2b..48a45a74 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java @@ -240,7 +240,6 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa }); } else { drawerLayoutContainer = new DrawerLayoutContainer(this); - drawerLayoutContainer.setStatusBarColor(0xff54759e); drawerLayoutContainer.addView(actionBarLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); ListView listView = new ListView(this); @@ -933,7 +932,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa Utilities.checkForUpdates(this); ApplicationLoader.mainInterfacePaused = false; ConnectionsManager.getInstance().setAppPaused(false, false); - actionBarLayout.getActionBar().setBackOverlayVisible(currentConnectionState != 0); + //actionBarLayout.getActionBar().setBackOverlayVisible(currentConnectionState != 0); } @Override @@ -974,7 +973,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa if (currentConnectionState != state) { FileLog.e("tmessages", "switch to state " + state); currentConnectionState = state; - actionBarLayout.getActionBar().setBackOverlayVisible(currentConnectionState != 0); + //actionBarLayout.getActionBar().setBackOverlayVisible(currentConnectionState != 0); } } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LocationActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/LocationActivity.java index 0685347b..653b1471 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/LocationActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/LocationActivity.java @@ -35,7 +35,7 @@ import org.telegram.android.MessageObject; import org.telegram.android.MessagesController; import org.telegram.android.NotificationCenter; import org.telegram.messenger.R; -import org.telegram.ui.Views.ActionBar.ActionBarLayer; +import org.telegram.ui.Views.ActionBar.ActionBar; import org.telegram.ui.Views.ActionBar.ActionBarMenu; import org.telegram.ui.Views.ActionBar.ActionBarMenuItem; import org.telegram.ui.Views.AvatarDrawable; @@ -91,15 +91,15 @@ public class LocationActivity extends BaseFragment implements NotificationCenter @Override public View createView(LayoutInflater inflater, ViewGroup container) { if (fragmentView == null) { - actionBarLayer.setBackButtonImage(R.drawable.ic_ab_back); - actionBarLayer.setBackOverlay(R.layout.updating_state_layout); + actionBar.setBackButtonImage(R.drawable.ic_ab_back); + actionBar.setBackOverlay(R.layout.updating_state_layout); if (messageObject != null) { - actionBarLayer.setTitle(LocaleController.getString("ChatLocation", R.string.ChatLocation)); + actionBar.setTitle(LocaleController.getString("ChatLocation", R.string.ChatLocation)); } else { - actionBarLayer.setTitle(LocaleController.getString("ShareLocation", R.string.ShareLocation)); + actionBar.setTitle(LocaleController.getString("ShareLocation", R.string.ShareLocation)); } - actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() { + actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @Override public void onItemClick(int id) { if (id == -1) { @@ -128,7 +128,7 @@ public class LocationActivity extends BaseFragment implements NotificationCenter } }); - ActionBarMenu menu = actionBarLayer.createMenu(); + ActionBarMenu menu = actionBar.createMenu(); menu.addItem(map_to_my_location, R.drawable.ic_ab_location); ActionBarMenuItem item = menu.addItem(0, R.drawable.ic_ab_other); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LoginActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/LoginActivity.java index e553530b..6db5174c 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/LoginActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/LoginActivity.java @@ -27,7 +27,7 @@ import org.telegram.android.AndroidUtilities; import org.telegram.messenger.FileLog; import org.telegram.android.LocaleController; import org.telegram.messenger.R; -import org.telegram.ui.Views.ActionBar.ActionBarLayer; +import org.telegram.ui.Views.ActionBar.ActionBar; import org.telegram.ui.Views.ActionBar.ActionBarMenu; import org.telegram.ui.Views.ActionBar.BaseFragment; import org.telegram.ui.Views.SlideView; @@ -68,9 +68,9 @@ public class LoginActivity extends BaseFragment implements SlideView.SlideViewDe @Override public View createView(LayoutInflater inflater, ViewGroup container) { if (fragmentView == null) { - actionBarLayer.setTitle(LocaleController.getString("AppName", R.string.AppName)); + actionBar.setTitle(LocaleController.getString("AppName", R.string.AppName)); - actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() { + actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @Override public void onItemClick(int id) { if (id == done_button) { @@ -79,7 +79,7 @@ public class LoginActivity extends BaseFragment implements SlideView.SlideViewDe } }); - ActionBarMenu menu = actionBarLayer.createMenu(); + ActionBarMenu menu = actionBar.createMenu(); View doneItem = menu.addItemResource(done_button, R.layout.group_create_done_layout); TextView doneTextView = (TextView)doneItem.findViewById(R.id.done_button); doneTextView.setText(LocaleController.getString("Done", R.string.Done).toUpperCase()); @@ -103,7 +103,7 @@ public class LoginActivity extends BaseFragment implements SlideView.SlideViewDe FileLog.e("tmessages", e); } - actionBarLayer.setTitle(views[0].getHeaderName()); + actionBar.setTitle(views[0].getHeaderName()); Bundle savedInstanceState = loadCurrentState(); if (savedInstanceState != null) { @@ -283,7 +283,7 @@ public class LoginActivity extends BaseFragment implements SlideView.SlideViewDe currentViewNum = page; newView.setParams(params); - actionBarLayer.setTitle(newView.getHeaderName()); + actionBar.setTitle(newView.getHeaderName()); newView.onShow(); newView.setX(back ? -AndroidUtilities.displaySize.x : AndroidUtilities.displaySize.x); outView.animate().setInterpolator(new AccelerateDecelerateInterpolator()).setListener(new Animator.AnimatorListener() { @@ -328,7 +328,7 @@ public class LoginActivity extends BaseFragment implements SlideView.SlideViewDe currentViewNum = page; views[page].setParams(params); views[page].setVisibility(View.VISIBLE); - actionBarLayer.setTitle(views[page].getHeaderName()); + actionBar.setTitle(views[page].getHeaderName()); views[page].onShow(); } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/MediaActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/MediaActivity.java index 9eb7d940..69df42d5 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/MediaActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/MediaActivity.java @@ -33,7 +33,7 @@ import org.telegram.android.MessagesController; import org.telegram.android.NotificationCenter; import org.telegram.messenger.R; import org.telegram.ui.Adapters.BaseFragmentAdapter; -import org.telegram.ui.Views.ActionBar.ActionBarLayer; +import org.telegram.ui.Views.ActionBar.ActionBar; import org.telegram.ui.Views.BackupImageView; import org.telegram.ui.Views.ActionBar.BaseFragment; @@ -87,10 +87,10 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No @Override public View createView(LayoutInflater inflater, ViewGroup container) { if (fragmentView == null) { - actionBarLayer.setBackButtonImage(R.drawable.ic_ab_back); - actionBarLayer.setBackOverlay(R.layout.updating_state_layout); - actionBarLayer.setTitle(LocaleController.getString("SharedMedia", R.string.SharedMedia)); - actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() { + actionBar.setBackButtonImage(R.drawable.ic_ab_back); + actionBar.setBackOverlay(R.layout.updating_state_layout); + actionBar.setTitle(LocaleController.getString("SharedMedia", R.string.SharedMedia)); + actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @Override public void onItemClick(int id) { if (id == -1) { @@ -259,9 +259,6 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No @Override public void onResume() { super.onResume(); - if (parentLayout != null) { - parentLayout.getDrawerLayoutContainer().setStatusBarColor(0xff54759e); - } if (listAdapter != null) { listAdapter.notifyDataSetChanged(); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/MessagesActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/MessagesActivity.java index 7dc66a99..d0d0933c 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/MessagesActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/MessagesActivity.java @@ -46,7 +46,7 @@ import org.telegram.ui.AnimationCompat.ObjectAnimatorProxy; import org.telegram.ui.AnimationCompat.ViewProxy; import org.telegram.ui.Cells.UserCell; import org.telegram.ui.Cells.DialogCell; -import org.telegram.ui.Views.ActionBar.ActionBarLayer; +import org.telegram.ui.Views.ActionBar.ActionBar; import org.telegram.ui.Views.ActionBar.ActionBarMenu; import org.telegram.ui.Views.ActionBar.ActionBarMenuItem; import org.telegram.ui.Views.ActionBar.BaseFragment; @@ -129,7 +129,7 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter @Override public View createView(LayoutInflater inflater, ViewGroup container) { if (fragmentView == null) { - ActionBarMenu menu = actionBarLayer.createMenu(); + ActionBarMenu menu = actionBar.createMenu(); menu.addItem(0, R.drawable.ic_ab_search).setIsSearchField(true).setActionBarMenuItemSearchListener(new ActionBarMenuItem.ActionBarMenuItemSearchListener() { @Override public void onSearchExpand() { @@ -189,15 +189,15 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter } }); if (onlySelect) { - actionBarLayer.setBackButtonImage(R.drawable.ic_ab_back); - actionBarLayer.setTitle(LocaleController.getString("SelectChat", R.string.SelectChat)); + actionBar.setBackButtonImage(R.drawable.ic_ab_back); + actionBar.setTitle(LocaleController.getString("SelectChat", R.string.SelectChat)); } else { - actionBarLayer.setBackButtonDrawable(new MenuDrawable()); - actionBarLayer.setTitle(LocaleController.getString("AppName", R.string.AppName)); + actionBar.setBackButtonDrawable(new MenuDrawable()); + actionBar.setTitle(LocaleController.getString("AppName", R.string.AppName)); } - actionBarLayer.setBackOverlay(R.layout.updating_state_layout); + actionBar.setBackOverlay(R.layout.updating_state_layout); - actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() { + actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @Override public void onItemClick(int id) { if (id == -1) { @@ -357,9 +357,9 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter return; } messagesActivityAdapter.setOpenedDialogId(openedDialogId = dialog_id); + updateVisibleRows(MessagesController.UPDATE_MASK_SELECT_DIALOG); } presentFragment(new ChatActivity(args)); - updateVisibleRows(0); } } }); @@ -501,7 +501,6 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter @Override public void onResume() { super.onResume(); - showActionBar(); if (messagesActivityAdapter != null) { messagesActivityAdapter.notifyDataSetChanged(); } @@ -579,7 +578,7 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter openedDialogId = dialog_id; } messagesActivityAdapter.setOpenedDialogId(openedDialogId); - updateVisibleRows(0); + updateVisibleRows(MessagesController.UPDATE_MASK_SELECT_DIALOG); } } } @@ -603,14 +602,17 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter View child = messagesListView.getChildAt(a); if (child instanceof DialogCell) { DialogCell cell = (DialogCell) child; - if (!serverOnly && AndroidUtilities.isTablet()) { - if (cell.getDialogId() == openedDialogId) { - child.setBackgroundColor(0x0f000000); - } else { - child.setBackgroundColor(0); + if ((mask & MessagesController.UPDATE_MASK_SELECT_DIALOG) != 0) { + if (!serverOnly && AndroidUtilities.isTablet()) { + if (cell.getDialogId() == openedDialogId) { + child.setBackgroundColor(0x0f000000); + } else { + child.setBackgroundColor(0); + } } + } else { + cell.update(mask); } - cell.update(mask); } else if (child instanceof UserCell) { ((UserCell) child).update(mask); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/PhotoCropActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/PhotoCropActivity.java index d65194d4..df151897 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/PhotoCropActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/PhotoCropActivity.java @@ -328,15 +328,15 @@ public class PhotoCropActivity extends BaseFragment { @Override public View createView(LayoutInflater inflater, ViewGroup container) { if (fragmentView == null) { - actionBarLayer.setCustomView(R.layout.settings_do_action_layout); - Button cancelButton = (Button)actionBarLayer.findViewById(R.id.cancel_button); + actionBar.setCustomView(R.layout.settings_do_action_layout); + Button cancelButton = (Button) actionBar.findViewById(R.id.cancel_button); cancelButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { finishFragment(); } }); - View doneButton = actionBarLayer.findViewById(R.id.done_button); + View doneButton = actionBar.findViewById(R.id.done_button); doneButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/PhotoPickerActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/PhotoPickerActivity.java index 40b82e88..56da3ea1 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/PhotoPickerActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/PhotoPickerActivity.java @@ -32,7 +32,7 @@ import org.telegram.messenger.R; import org.telegram.messenger.TLRPC; import org.telegram.android.MessageObject; import org.telegram.ui.Adapters.BaseFragmentAdapter; -import org.telegram.ui.Views.ActionBar.ActionBarLayer; +import org.telegram.ui.Views.ActionBar.ActionBar; import org.telegram.ui.Views.ActionBar.ActionBarMenu; import org.telegram.ui.Views.ActionBar.BaseFragment; import org.telegram.ui.Views.BackupImageView; @@ -84,17 +84,17 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen @Override public View createView(LayoutInflater inflater, ViewGroup container) { if (fragmentView == null) { - actionBarLayer.setBackgroundColor(0xff333333); - actionBarLayer.setItemsBackground(R.drawable.bar_selector_picker); - actionBarLayer.setBackButtonImage(R.drawable.ic_ab_back); - actionBarLayer.setTitle(LocaleController.getString("Gallery", R.string.Gallery)); - actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() { + actionBar.setBackgroundColor(0xff333333); + actionBar.setItemsBackground(R.drawable.bar_selector_picker); + actionBar.setBackButtonImage(R.drawable.ic_ab_back); + actionBar.setTitle(LocaleController.getString("Gallery", R.string.Gallery)); + actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @Override public void onItemClick(int id) { if (id == -1) { if (selectedAlbum != null) { selectedAlbum = null; - actionBarLayer.setTitle(LocaleController.getString("Gallery", R.string.Gallery)); + actionBar.setTitle(LocaleController.getString("Gallery", R.string.Gallery)); fixLayoutInternal(); } else { if (Build.VERSION.SDK_INT < 11) { @@ -113,7 +113,7 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen } }); - ActionBarMenu menu = actionBarLayer.createMenu(); + ActionBarMenu menu = actionBar.createMenu(); menu.addItem(1, R.drawable.ic_ab_other); fragmentView = inflater.inflate(R.layout.photo_picker_layout, container, false); @@ -158,7 +158,7 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen return; } selectedAlbum = albumsSorted.get(i); - actionBarLayer.setTitle(selectedAlbum.bucketName); + actionBar.setTitle(selectedAlbum.bucketName); fixLayoutInternal(); } else { if (i < 0 || i >= selectedAlbum.photos.size()) { @@ -231,7 +231,7 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen public boolean onBackPressed() { if (selectedAlbum != null) { selectedAlbum = null; - actionBarLayer.setTitle(LocaleController.getString("Gallery", R.string.Gallery)); + actionBar.setTitle(LocaleController.getString("Gallery", R.string.Gallery)); fixLayoutInternal(); return false; } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java b/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java index 92bd205b..1e22d13b 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java @@ -64,7 +64,6 @@ import org.telegram.ui.AnimationCompat.AnimatorSetProxy; import org.telegram.ui.AnimationCompat.ObjectAnimatorProxy; import org.telegram.ui.AnimationCompat.ViewProxy; import org.telegram.ui.Views.ActionBar.ActionBar; -import org.telegram.ui.Views.ActionBar.ActionBarLayer; import org.telegram.ui.Views.ActionBar.ActionBarMenu; import org.telegram.ui.Views.ActionBar.ActionBarMenuItem; import org.telegram.ui.Views.ClippingImageView; @@ -84,7 +83,6 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat private Activity parentActivity; private ActionBar actionBar; - private ActionBarLayer actionBarLayer; private boolean isActionBarVisible = true; private static Drawable[] progressDrawables = null; @@ -484,7 +482,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat loadingMoreImages = true; MessagesController.getInstance().loadMedia(currentDialogId, 0, 100, 0, true, classGuid); } else if (!imagesArr.isEmpty()) { - actionBarLayer.setTitle(LocaleController.formatString("Of", R.string.Of, (totalImagesCount - imagesArr.size()) + currentIndex + 1, totalImagesCount)); + actionBar.setTitle(LocaleController.formatString("Of", R.string.Of, (totalImagesCount - imagesArr.size()) + currentIndex + 1, totalImagesCount)); } } } else if (id == NotificationCenter.mediaDidLoaded) { @@ -603,18 +601,16 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat windowLayoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; actionBar = new ActionBar(activity); - containerView.addView(actionBar); actionBar.setBackgroundColor(0x7F000000); - layoutParams = (FrameLayout.LayoutParams)actionBar.getLayoutParams(); + actionBar.setItemsBackground(R.drawable.bar_selector_white); + actionBar.setBackButtonImage(R.drawable.ic_ab_back); + actionBar.setTitle(LocaleController.formatString("Of", R.string.Of, 1, 1)); + containerView.addView(actionBar); + layoutParams = (FrameLayout.LayoutParams) actionBar.getLayoutParams(); layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; actionBar.setLayoutParams(layoutParams); - actionBarLayer = actionBar.createLayer(); - actionBarLayer.setItemsBackground(R.drawable.bar_selector_white); - actionBarLayer.setBackButtonImage(R.drawable.ic_ab_back); - actionBarLayer.setTitle(LocaleController.formatString("Of", R.string.Of, 1, 1)); - actionBar.setCurrentActionBarLayer(actionBarLayer); - actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() { + actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @Override public void onItemClick(int id) { if (id == -1) { @@ -692,7 +688,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat } }); - ActionBarMenu menu = actionBarLayer.createMenu(); + ActionBarMenu menu = actionBar.createMenu(); menuItem = menu.addItem(0, R.drawable.ic_ab_other); menuItem.addSubItem(gallery_menu_save, LocaleController.getString("SaveToGallery", R.string.SaveToGallery), 0); menuItem.addSubItem(gallery_menu_showall, LocaleController.getString("ShowAllMedia", R.string.ShowAllMedia), 0); @@ -953,7 +949,6 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat } isActionBarVisible = show; actionBar.setEnabled(show); - actionBarLayer.setEnabled(show); bottomLayout.setEnabled(show); if (animated) { @@ -1295,7 +1290,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat MessagesController.getInstance().loadMedia(currentDialogId, 0, 100, lastMessage.messageOwner.id, !cacheEndReached, classGuid); loadingMoreImages = true; } - actionBarLayer.setTitle(LocaleController.formatString("Of", R.string.Of, (totalImagesCount - imagesArr.size()) + currentIndex + 1, totalImagesCount)); + actionBar.setTitle(LocaleController.formatString("Of", R.string.Of, (totalImagesCount - imagesArr.size()) + currentIndex + 1, totalImagesCount)); } if (currentMessageObject.messageOwner.ttl != 0) { menuItem.hideSubItem(gallery_menu_save); @@ -1317,12 +1312,12 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat if (old != null && currentFileLocation != null && old.local_id == currentFileLocation.local_id && old.volume_id == currentFileLocation.volume_id) { sameImage = true; } - actionBarLayer.setTitle(LocaleController.formatString("Of", R.string.Of, currentIndex + 1, imagesArrLocations.size())); + actionBar.setTitle(LocaleController.formatString("Of", R.string.Of, currentIndex + 1, imagesArrLocations.size())); menuItem.showSubItem(gallery_menu_save); shareButton.setVisibility(View.VISIBLE); } else if (!imagesArrLocals.isEmpty()) { currentPathObject = imagesArrLocals.get(index).path; - actionBarLayer.setTitle(LocaleController.formatString("Of", R.string.Of, currentIndex + 1, imagesArrLocals.size())); + actionBar.setTitle(LocaleController.formatString("Of", R.string.Of, currentIndex + 1, imagesArrLocals.size())); if (placeProvider.isPhotoChecked(currentIndex)) { checkImageView.setBackgroundColor(0xff42d1f6); @@ -1559,7 +1554,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat return; } - actionBarLayer.setTitle(LocaleController.formatString("Of", R.string.Of, 1, 1)); + actionBar.setTitle(LocaleController.formatString("Of", R.string.Of, 1, 1)); NotificationCenter.getInstance().addObserver(this, NotificationCenter.FileDidFailedLoad); NotificationCenter.getInstance().addObserver(this, NotificationCenter.FileDidLoaded); NotificationCenter.getInstance().addObserver(this, NotificationCenter.FileLoadProgressChanged); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/PopupNotificationActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/PopupNotificationActivity.java index afbd4805..90201f2d 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/PopupNotificationActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/PopupNotificationActivity.java @@ -45,7 +45,6 @@ import org.telegram.messenger.TLRPC; import org.telegram.android.MessageObject; import org.telegram.android.PhotoObject; import org.telegram.ui.Views.ActionBar.ActionBar; -import org.telegram.ui.Views.ActionBar.ActionBarLayer; import org.telegram.ui.Views.ActionBar.ActionBarMenu; import org.telegram.ui.Views.AvatarDrawable; import org.telegram.ui.Views.BackupImageView; @@ -59,7 +58,7 @@ import java.util.ArrayList; public class PopupNotificationActivity extends Activity implements NotificationCenter.NotificationCenterDelegate { - private ActionBarLayer actionBarLayer; + private ActionBar actionBar; private ChatActivityEnterView chatActivityEnterView; private BackupImageView avatarImageView; private TextView countText; @@ -182,19 +181,16 @@ public class PopupNotificationActivity extends Activity implements NotificationC messageContainer = new FrameLayoutTouch(this); popupContainer.addView(messageContainer, 0); - ActionBar actionBar = new ActionBar(this); + actionBar = new ActionBar(this); + actionBar.setBackButtonImage(R.drawable.ic_ab_back); + actionBar.setBackgroundResource(R.color.header); + actionBar.setItemsBackground(R.drawable.bar_selector); popupContainer.addView(actionBar); ViewGroup.LayoutParams layoutParams = actionBar.getLayoutParams(); layoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT; actionBar.setLayoutParams(layoutParams); - actionBarLayer = actionBar.createLayer(); - actionBarLayer.setBackButtonImage(R.drawable.ic_ab_back); - actionBarLayer.setBackgroundResource(R.color.header); - actionBarLayer.setItemsBackground(R.drawable.bar_selector); - actionBar.setCurrentActionBarLayer(actionBarLayer); - - ActionBarMenu menu = actionBarLayer.createMenu(); + ActionBarMenu menu = actionBar.createMenu(); View view = menu.addItemResource(2, R.layout.popup_count_layout); countText = (TextView) view.findViewById(R.id.count_text); @@ -202,7 +198,7 @@ public class PopupNotificationActivity extends Activity implements NotificationC avatarImageView = (BackupImageView)view.findViewById(R.id.chat_avatar_image); avatarImageView.processDetach = false; - actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() { + actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @Override public void onItemClick(int id) { if (id == -1) { @@ -715,7 +711,7 @@ public class PopupNotificationActivity extends Activity implements NotificationC } private void updateInterfaceForCurrentMessage(int move) { - if (actionBarLayer == null) { + if (actionBar == null) { return; } currentChat = null; @@ -736,15 +732,15 @@ public class PopupNotificationActivity extends Activity implements NotificationC } if (currentChat != null && currentUser != null) { - actionBarLayer.setTitle(currentChat.title); - actionBarLayer.setSubtitle(ContactsController.formatName(currentUser.first_name, currentUser.last_name)); - actionBarLayer.setTitleIcon(0, 0); + actionBar.setTitle(currentChat.title); + actionBar.setSubtitle(ContactsController.formatName(currentUser.first_name, currentUser.last_name)); + actionBar.setTitleIcon(0, 0); } else if (currentUser != null) { - actionBarLayer.setTitle(ContactsController.formatName(currentUser.first_name, currentUser.last_name)); + actionBar.setTitle(ContactsController.formatName(currentUser.first_name, currentUser.last_name)); if ((int)dialog_id == 0) { - actionBarLayer.setTitleIcon(R.drawable.ic_lock_white, AndroidUtilities.dp(4)); + actionBar.setTitleIcon(R.drawable.ic_lock_white, AndroidUtilities.dp(4)); } else { - actionBarLayer.setTitleIcon(0, 0); + actionBar.setTitleIcon(0, 0); } } @@ -755,7 +751,7 @@ public class PopupNotificationActivity extends Activity implements NotificationC } private void updateSubtitle() { - if (actionBarLayer == null) { + if (actionBar == null) { return; } if (currentChat != null || currentUser == null) { @@ -763,12 +759,12 @@ public class PopupNotificationActivity extends Activity implements NotificationC } if (currentUser.id / 1000 != 777 && currentUser.id / 1000 != 333 && ContactsController.getInstance().contactsDict.get(currentUser.id) == null && (ContactsController.getInstance().contactsDict.size() != 0 || !ContactsController.getInstance().isLoadingContacts())) { if (currentUser.phone != null && currentUser.phone.length() != 0) { - actionBarLayer.setTitle(PhoneFormat.getInstance().format("+" + currentUser.phone)); + actionBar.setTitle(PhoneFormat.getInstance().format("+" + currentUser.phone)); } else { - actionBarLayer.setTitle(ContactsController.formatName(currentUser.first_name, currentUser.last_name)); + actionBar.setTitle(ContactsController.formatName(currentUser.first_name, currentUser.last_name)); } } else { - actionBarLayer.setTitle(ContactsController.formatName(currentUser.first_name, currentUser.last_name)); + actionBar.setTitle(ContactsController.formatName(currentUser.first_name, currentUser.last_name)); } CharSequence printString = MessagesController.getInstance().printingStrings.get(currentMessageObject.getDialogId()); if (printString == null || printString.length() == 0) { @@ -778,10 +774,10 @@ public class PopupNotificationActivity extends Activity implements NotificationC if (user != null) { currentUser = user; } - actionBarLayer.setSubtitle(LocaleController.formatUserStatus(currentUser)); + actionBar.setSubtitle(LocaleController.formatUserStatus(currentUser)); } else { lastPrintString = printString; - actionBarLayer.setSubtitle(printString); + actionBar.setSubtitle(printString); setTypingAnimation(true); } } @@ -816,18 +812,18 @@ public class PopupNotificationActivity extends Activity implements NotificationC } private void setTypingAnimation(boolean start) { - if (actionBarLayer == null) { + if (actionBar == null) { return; } if (start) { try { - actionBarLayer.setSubTitleIcon(0, typingDotsDrawable, AndroidUtilities.dp(4)); + actionBar.setSubTitleIcon(0, typingDotsDrawable, AndroidUtilities.dp(4)); typingDotsDrawable.start(); } catch (Exception e) { FileLog.e("tmessages", e); } } else { - actionBarLayer.setSubTitleIcon(0, null, 0); + actionBar.setSubTitleIcon(0, null, 0); typingDotsDrawable.stop(); } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java index f4996bf9..faa04f45 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java @@ -12,6 +12,7 @@ import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; +import android.content.res.Configuration; import android.net.Uri; import android.os.Build; import android.os.Bundle; @@ -20,6 +21,7 @@ import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.view.ViewTreeObserver; import android.widget.AdapterView; import android.widget.FrameLayout; import android.widget.ImageView; @@ -42,7 +44,7 @@ import org.telegram.ui.Cells.DividerCell; import org.telegram.ui.Cells.EmptyCell; import org.telegram.ui.Cells.TextCell; import org.telegram.ui.Cells.TextDetailCell; -import org.telegram.ui.Views.ActionBar.ActionBarLayer; +import org.telegram.ui.Views.ActionBar.ActionBar; import org.telegram.ui.Views.ActionBar.ActionBarMenu; import org.telegram.ui.Views.ActionBar.ActionBarMenuItem; import org.telegram.ui.Views.AvatarDrawable; @@ -58,7 +60,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. private BackupImageView avatarImage; private TextView nameTextView; private TextView onlineTextView; - FrameLayout nameContainer; + private ImageView writeButton; private int user_id; private int totalMediaCount = -1; @@ -128,10 +130,12 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. @Override public View createView(LayoutInflater inflater, ViewGroup container) { if (fragmentView == null) { - actionBarLayer.setBackgroundColor(AvatarDrawable.getProfileBackColorForId(user_id)); - actionBarLayer.setBackButtonImage(R.drawable.ic_ab_back); - actionBarLayer.setBackOverlay(R.layout.updating_state_layout); - actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() { + actionBar.setBackgroundColor(AvatarDrawable.getProfileBackColorForId(user_id)); + actionBar.setItemsBackground(AvatarDrawable.getButtonColorForId(user_id)); + actionBar.setBackButtonImage(R.drawable.ic_ab_back); + actionBar.setBackOverlay(R.layout.updating_state_layout); + actionBar.setExtraHeight(AndroidUtilities.dp(88)); + actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @Override public void onItemClick(final int id) { if (id == -1) { @@ -200,27 +204,20 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. fragmentView = new FrameLayout(getParentActivity()); FrameLayout frameLayout = (FrameLayout) fragmentView; - - nameContainer = new FrameLayout(getParentActivity()); - nameContainer.setBackgroundColor(AvatarDrawable.getProfileBackColorForId(user_id)); - frameLayout.addView(nameContainer); - FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) nameContainer.getLayoutParams(); - layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; - layoutParams.height = AndroidUtilities.dp(88); - nameContainer.setLayoutParams(layoutParams); + frameLayout.addView(actionBar); avatarImage = new BackupImageView(getParentActivity()); avatarImage.imageReceiver.setRoundRadius(AndroidUtilities.dp(30)); avatarImage.processDetach = false; - nameContainer.addView(avatarImage); - FrameLayout.LayoutParams layoutParams1 = (FrameLayout.LayoutParams) avatarImage.getLayoutParams(); - layoutParams1.gravity = (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.BOTTOM; - layoutParams1.width = AndroidUtilities.dp(60); - layoutParams1.height = AndroidUtilities.dp(60); - layoutParams1.leftMargin = LocaleController.isRTL ? 0 : AndroidUtilities.dp(17); - layoutParams1.rightMargin = LocaleController.isRTL ? AndroidUtilities.dp(17) : 0; - layoutParams1.bottomMargin = AndroidUtilities.dp(22); - avatarImage.setLayoutParams(layoutParams1); + actionBar.addView(avatarImage); + FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) avatarImage.getLayoutParams(); + layoutParams.gravity = (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.BOTTOM; + layoutParams.width = AndroidUtilities.dp(60); + layoutParams.height = AndroidUtilities.dp(60); + layoutParams.leftMargin = LocaleController.isRTL ? 0 : AndroidUtilities.dp(17); + layoutParams.rightMargin = LocaleController.isRTL ? AndroidUtilities.dp(17) : 0; + layoutParams.bottomMargin = AndroidUtilities.dp(22); + avatarImage.setLayoutParams(layoutParams); avatarImage.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -240,42 +237,43 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. nameTextView.setSingleLine(true); nameTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT)); nameTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); - nameContainer.addView(nameTextView); - layoutParams1 = (FrameLayout.LayoutParams) nameTextView.getLayoutParams(); - layoutParams1.width = FrameLayout.LayoutParams.WRAP_CONTENT; - layoutParams1.height = FrameLayout.LayoutParams.WRAP_CONTENT; - layoutParams1.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? 16 : 97); - layoutParams1.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? 97 : 16); - layoutParams1.bottomMargin = AndroidUtilities.dp(51); - layoutParams1.gravity = (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.BOTTOM; - nameTextView.setLayoutParams(layoutParams1); + actionBar.addView(nameTextView); + layoutParams = (FrameLayout.LayoutParams) nameTextView.getLayoutParams(); + layoutParams.width = FrameLayout.LayoutParams.WRAP_CONTENT; + layoutParams.height = FrameLayout.LayoutParams.WRAP_CONTENT; + layoutParams.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? 16 : 97); + layoutParams.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? 97 : 16); + layoutParams.bottomMargin = AndroidUtilities.dp(51); + layoutParams.gravity = (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.BOTTOM; + nameTextView.setLayoutParams(layoutParams); onlineTextView = new TextView(getParentActivity()); - onlineTextView.setTextColor(0xffd0e4ea); + onlineTextView.setTextColor(AvatarDrawable.getProfileTextColorForId(user_id)); onlineTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); onlineTextView.setLines(1); onlineTextView.setMaxLines(1); onlineTextView.setSingleLine(true); onlineTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT)); - nameContainer.addView(onlineTextView); - layoutParams1 = (FrameLayout.LayoutParams) onlineTextView.getLayoutParams(); - layoutParams1.width = FrameLayout.LayoutParams.WRAP_CONTENT; - layoutParams1.height = FrameLayout.LayoutParams.WRAP_CONTENT; - layoutParams1.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? 16 : 97); - layoutParams1.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? 97 : 16); - layoutParams1.bottomMargin = AndroidUtilities.dp(30); - layoutParams1.gravity = (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.BOTTOM; - onlineTextView.setLayoutParams(layoutParams1); + actionBar.addView(onlineTextView); + layoutParams = (FrameLayout.LayoutParams) onlineTextView.getLayoutParams(); + layoutParams.width = FrameLayout.LayoutParams.WRAP_CONTENT; + layoutParams.height = FrameLayout.LayoutParams.WRAP_CONTENT; + layoutParams.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? 16 : 97); + layoutParams.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? 97 : 16); + layoutParams.bottomMargin = AndroidUtilities.dp(30); + layoutParams.gravity = (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.BOTTOM; + onlineTextView.setLayoutParams(layoutParams); listView = new ListView(getParentActivity()); listView.setDivider(null); listView.setDividerHeight(0); listView.setVerticalScrollBarEnabled(false); + AndroidUtilities.setListViewEdgeEffectColor(listView, AvatarDrawable.getProfileBackColorForId(user_id)); frameLayout.addView(listView); layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams(); - layoutParams.topMargin = AndroidUtilities.dp(88); layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT; + layoutParams.gravity = Gravity.TOP; listView.setLayoutParams(layoutParams); listView.setAdapter(listAdapter); @@ -359,17 +357,16 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. MessagesController.getInstance().getMediaCount(user_id, classGuid, true); } - ImageView writeButton = new ImageView(getParentActivity()); - writeButton.setImageResource(R.drawable.floating_states); + writeButton = new ImageView(getParentActivity()); + writeButton.setImageResource(R.drawable.floating_user_states); frameLayout.addView(writeButton); - layoutParams1 = (FrameLayout.LayoutParams) writeButton.getLayoutParams(); - layoutParams1.width = FrameLayout.LayoutParams.WRAP_CONTENT; - layoutParams1.height = FrameLayout.LayoutParams.WRAP_CONTENT; - layoutParams1.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? 16 : 0); - layoutParams1.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? 0 : 16); - layoutParams1.topMargin = AndroidUtilities.dp(58); - layoutParams1.gravity = (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT); - writeButton.setLayoutParams(layoutParams1); + layoutParams = (FrameLayout.LayoutParams) writeButton.getLayoutParams(); + layoutParams.width = FrameLayout.LayoutParams.WRAP_CONTENT; + layoutParams.height = FrameLayout.LayoutParams.WRAP_CONTENT; + layoutParams.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? 16 : 0); + layoutParams.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? 0 : 16); + layoutParams.gravity = (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT); + writeButton.setLayoutParams(layoutParams); writeButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -394,6 +391,38 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. return fragmentView; } + private void fixLayout() { + if (fragmentView == null) { + return; + } + fragmentView.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { + @Override + public boolean onPreDraw() { + if (fragmentView != null) { + ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) listView.getLayoutParams(); + layoutParams.topMargin = actionBar.getHeight(); + listView.setLayoutParams(layoutParams); + layoutParams = (ViewGroup.MarginLayoutParams) writeButton.getLayoutParams(); + layoutParams.topMargin = actionBar.getHeight() - AndroidUtilities.dp(29.5f); + writeButton.setLayoutParams(layoutParams); + fragmentView.getViewTreeObserver().removeOnPreDrawListener(this); + } + return false; + } + }); + } + + @Override + public void onConfigurationChanged(Configuration newConfig) { + super.onConfigurationChanged(newConfig); + fixLayout(); + } + + @Override + public boolean needAddActionBar() { + return false; + } + public void didReceivedNotification(int id, final Object... args) { if (id == NotificationCenter.updateInterfaces) { int mask = (Integer)args[0]; @@ -444,12 +473,10 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. @Override public void onResume() { super.onResume(); - if (parentLayout != null) { - parentLayout.getDrawerLayoutContainer().setStatusBarColor(AvatarDrawable.getProfileBackColorForId(user_id)); - } if (listAdapter != null) { listAdapter.notifyDataSetChanged(); } + fixLayout(); } @Override @@ -466,7 +493,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. PhotoViewer.PlaceProviderObject object = new PhotoViewer.PlaceProviderObject(); object.viewX = coords[0]; object.viewY = coords[1] - AndroidUtilities.statusBarHeight; - object.parentView = nameContainer; + object.parentView = avatarImage; object.imageReceiver = avatarImage.imageReceiver; object.user_id = user_id; object.thumb = object.imageReceiver.getBitmap(); @@ -509,6 +536,8 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. usernameRow = -1; } sectionRow = rowCount++; + settingsNotificationsRow = rowCount++; + sharedMediaRow = rowCount++; if (currentEncryptedChat instanceof TLRPC.TL_encryptedChat) { settingsTimerRow = rowCount++; settingsKeyRow = rowCount++; @@ -516,8 +545,6 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. settingsTimerRow = -1; settingsKeyRow = -1; } - settingsNotificationsRow = rowCount++; - sharedMediaRow = rowCount++; if (currentEncryptedChat == null) { startSecretChatRow = rowCount++; } else { @@ -543,7 +570,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. } private void createActionBarMenu() { - ActionBarMenu menu = actionBarLayer.createMenu(); + ActionBarMenu menu = actionBar.createMenu(); menu.clearItems(); if (ContactsController.getInstance().contactsDict.get(user_id) == null) { @@ -661,7 +688,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. } else { text = LocaleController.getString("NumberUnknown", R.string.NumberUnknown); } - textDetailCell.setTextAndValue(text, LocaleController.getString("PhoneMobile", R.string.PhoneMobile)); + textDetailCell.setTextAndValueAndIcon(text, LocaleController.getString("PhoneMobile", R.string.PhoneMobile), R.drawable.phone_grey); } else if (i == usernameRow) { String text; if (user != null && user.username != null && user.username.length() != 0) { @@ -696,7 +723,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. } textCell.setTextAndValue(LocaleController.getString("MessageLifetime", R.string.MessageLifetime), value); } else if (i == settingsNotificationsRow) { - textCell.setText(LocaleController.getString("NotificationsAndSounds", R.string.NotificationsAndSounds)); + textCell.setTextAndIcon(LocaleController.getString("NotificationsAndSounds", R.string.NotificationsAndSounds), R.drawable.profile_list); } else if (i == startSecretChatRow) { textCell.setText(LocaleController.getString("StartEncryptedChat", R.string.StartEncryptedChat)); textCell.setTextColor(0xff37a919); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ProfileNotificationsActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ProfileNotificationsActivity.java index 3aadeff6..8ab9fd8c 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ProfileNotificationsActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ProfileNotificationsActivity.java @@ -23,9 +23,11 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; +import android.widget.FrameLayout; import android.widget.ListView; import android.widget.TextView; +import org.telegram.android.AndroidUtilities; import org.telegram.android.MessagesController; import org.telegram.android.MessagesStorage; import org.telegram.messenger.ConnectionsManager; @@ -37,8 +39,9 @@ import org.telegram.messenger.RPCRequest; import org.telegram.messenger.TLObject; import org.telegram.messenger.TLRPC; import org.telegram.ui.Adapters.BaseFragmentAdapter; -import org.telegram.ui.Views.ActionBar.ActionBarLayer; +import org.telegram.ui.Views.ActionBar.ActionBar; import org.telegram.ui.Views.ActionBar.BaseFragment; +import org.telegram.ui.Views.AvatarDrawable; import org.telegram.ui.Views.ColorPickerView; public class ProfileNotificationsActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate { @@ -76,12 +79,10 @@ public class ProfileNotificationsActivity extends BaseFragment implements Notifi @Override public View createView(LayoutInflater inflater, ViewGroup container) { if (fragmentView == null) { - actionBarLayer.setBackButtonImage(R.drawable.ic_ab_back); - actionBarLayer.setBackOverlay(R.layout.updating_state_layout); - - actionBarLayer.setTitle(LocaleController.getString("NotificationsAndSounds", R.string.NotificationsAndSounds)); - - actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() { + actionBar.setBackButtonImage(R.drawable.ic_ab_back); + actionBar.setBackOverlay(R.layout.updating_state_layout); + actionBar.setTitle(LocaleController.getString("NotificationsAndSounds", R.string.NotificationsAndSounds)); + actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @Override public void onItemClick(int id) { if (id == -1) { @@ -90,9 +91,19 @@ public class ProfileNotificationsActivity extends BaseFragment implements Notifi } }); - fragmentView = inflater.inflate(R.layout.settings_layout, container, false); + fragmentView = new FrameLayout(getParentActivity()); + FrameLayout frameLayout = (FrameLayout) fragmentView; - listView = (ListView)fragmentView.findViewById(R.id.listView); + listView = new ListView(getParentActivity()); + listView.setDivider(null); + listView.setDividerHeight(0); + listView.setVerticalScrollBarEnabled(false); + AndroidUtilities.setListViewEdgeEffectColor(listView, AvatarDrawable.getProfileBackColorForId(5)); + frameLayout.addView(listView); + FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams(); + layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; + layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT; + listView.setLayoutParams(layoutParams); listView.setAdapter(new ListAdapter(getParentActivity())); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override @@ -253,14 +264,6 @@ public class ProfileNotificationsActivity extends BaseFragment implements Notifi return fragmentView; } - @Override - public void onResume() { - super.onResume(); - if (parentLayout != null) { - parentLayout.getDrawerLayoutContainer().setStatusBarColor(0xff54759e); - } - } - public void updateServerNotificationsSettings() { if ((int)dialog_id == 0) { return; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/SettingsActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/SettingsActivity.java index 2fb8fe67..de6a54d6 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/SettingsActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/SettingsActivity.java @@ -16,19 +16,22 @@ import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.content.pm.PackageInfo; -import android.graphics.Typeface; +import android.content.res.Configuration; import android.net.Uri; import android.os.Bundle; import android.text.Html; import android.text.Spannable; import android.text.method.LinkMovementMethod; import android.util.Base64; +import android.util.TypedValue; +import android.view.Gravity; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; +import android.view.ViewTreeObserver; import android.widget.AdapterView; -import android.widget.ImageButton; +import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.ListView; import android.widget.TextView; @@ -55,55 +58,74 @@ import org.telegram.messenger.RPCRequest; import org.telegram.messenger.UserConfig; import org.telegram.android.MessageObject; import org.telegram.ui.Adapters.BaseFragmentAdapter; -import org.telegram.ui.Views.ActionBar.ActionBarLayer; +import org.telegram.ui.Cells.DetailTextCell; +import org.telegram.ui.Cells.EmptyCell; +import org.telegram.ui.Cells.HeaderCell; +import org.telegram.ui.Cells.ShadowSectionCell; +import org.telegram.ui.Cells.TextCheckCell; +import org.telegram.ui.Cells.TextDetailSettingsCell; +import org.telegram.ui.Cells.TextSettingsCell; +import org.telegram.ui.Views.ActionBar.ActionBar; +import org.telegram.ui.Views.ActionBar.ActionBarMenu; +import org.telegram.ui.Views.ActionBar.ActionBarMenuItem; import org.telegram.ui.Views.AvatarDrawable; import org.telegram.ui.Views.AvatarUpdater; import org.telegram.ui.Views.BackupImageView; import org.telegram.ui.Views.ActionBar.BaseFragment; import org.telegram.ui.Views.NumberPicker; -import org.telegram.ui.Views.SettingsSectionLayout; import java.io.File; import java.util.ArrayList; import java.util.Locale; public class SettingsActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate, PhotoViewer.PhotoViewerProvider { + private ListView listView; private ListAdapter listAdapter; + private BackupImageView avatarImage; + private TextView nameTextView; + private TextView onlineTextView; + private ImageView writeButton; private AvatarUpdater avatarUpdater = new AvatarUpdater(); - private int profileRow; + private int emptyRow; private int numberSectionRow; private int numberRow; private int usernameRow; private int settingsSectionRow; - private int textSizeRow; + private int settingsSectionRow2; private int enableAnimationsRow; private int notificationRow; private int blockedRow; private int backgroundRow; - private int supportSectionRow; - private int askQuestionRow; - private int logoutRow; - private int sendLogsRow; - private int clearLogsRow; - private int switchBackendButtonRow; - private int messagesSectionRow; - private int sendByEnterRow; + private int languageRow; private int terminateSessionsRow; private int mediaDownloadSection; + private int mediaDownloadSection2; private int mobileDownloadRow; private int wifiDownloadRow; private int roamingDownloadRow; private int saveToGalleryRow; + private int messagesSectionRow; + private int messagesSectionRow2; + private int textSizeRow; + private int sendByEnterRow; + private int supportSectionRow; + private int supportSectionRow2; + private int askQuestionRow; private int telegramFaqRow; - private int languageRow; + private int sendLogsRow; + private int clearLogsRow; + private int switchBackendButtonRow; private int versionRow; private int contactsSectionRow; private int contactsReimportRow; private int contactsSortRow; private int rowCount; + private final static int edit_name = 1; + private final static int logout = 2; + private static class LinkMovementMethodMy extends LinkMovementMethod { @Override public boolean onTouchEvent(TextView widget, Spannable buffer, MotionEvent event) { @@ -177,40 +199,42 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter }; NotificationCenter.getInstance().addObserver(this, NotificationCenter.updateInterfaces); - rowCount = 0; - profileRow = rowCount++; + emptyRow = rowCount++; numberSectionRow = rowCount++; numberRow = rowCount++; usernameRow = rowCount++; settingsSectionRow = rowCount++; + settingsSectionRow2 = rowCount++; enableAnimationsRow = rowCount++; - languageRow = rowCount++; notificationRow = rowCount++; blockedRow = rowCount++; backgroundRow = rowCount++; + languageRow = rowCount++; terminateSessionsRow = rowCount++; mediaDownloadSection = rowCount++; + mediaDownloadSection2 = rowCount++; mobileDownloadRow = rowCount++; wifiDownloadRow = rowCount++; roamingDownloadRow = rowCount++; saveToGalleryRow = rowCount++; messagesSectionRow = rowCount++; + messagesSectionRow2 = rowCount++; textSizeRow = rowCount++; sendByEnterRow = rowCount++; - //contactsSectionRow = rowCount++; - //contactsSortRow = rowCount++; - //contactsReimportRow = rowCount++; supportSectionRow = rowCount++; + supportSectionRow2 = rowCount++; + askQuestionRow = rowCount++; + telegramFaqRow = rowCount++; if (BuildVars.DEBUG_VERSION) { sendLogsRow = rowCount++; clearLogsRow = rowCount++; switchBackendButtonRow = rowCount++; } - telegramFaqRow = rowCount++; - askQuestionRow = rowCount++; - logoutRow = rowCount++; versionRow = rowCount++; + //contactsSectionRow = rowCount++; + //contactsReimportRow = rowCount++; + //contactsSortRow = rowCount++; MessagesController.getInstance().loadFullUser(UserConfig.getCurrentUser(), classGuid); @@ -225,24 +249,134 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter avatarUpdater.clear(); } + @Override + public boolean needAddActionBar() { + return false; + } + @Override public View createView(LayoutInflater inflater, ViewGroup container) { if (fragmentView == null) { - actionBarLayer.setBackButtonImage(R.drawable.ic_ab_back); - actionBarLayer.setBackOverlay(R.layout.updating_state_layout); - actionBarLayer.setTitle(LocaleController.getString("Settings", R.string.Settings)); - actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() { + actionBar.setBackgroundColor(AvatarDrawable.getProfileBackColorForId(5)); + actionBar.setItemsBackground(AvatarDrawable.getButtonColorForId(5)); + actionBar.setBackButtonImage(R.drawable.ic_ab_back); + actionBar.setBackOverlay(R.layout.updating_state_layout); + actionBar.setExtraHeight(AndroidUtilities.dp(88)); + actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @Override public void onItemClick(int id) { if (id == -1) { finishFragment(); + } else if (id == edit_name) { + presentFragment(new SettingsChangeNameActivity()); + } else if (id == logout) { + if (getParentActivity() == null) { + return; + } + AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); + builder.setMessage(LocaleController.getString("AreYouSureLogout", R.string.AreYouSureLogout)); + builder.setTitle(LocaleController.getString("AppName", R.string.AppName)); + builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); + SharedPreferences.Editor editor = preferences.edit(); + editor.clear().commit(); + NotificationCenter.getInstance().postNotificationName(NotificationCenter.appDidLogout); + MessagesController.getInstance().unregistedPush(); + MessagesController.getInstance().logOut(); + UserConfig.clearConfig(); + MessagesStorage.getInstance().cleanUp(false); + MessagesController.getInstance().cleanUp(); + ContactsController.getInstance().deleteAllAppAccounts(); + } + }); + builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); + showAlertDialog(builder); + } + } + }); + ActionBarMenu menu = actionBar.createMenu(); + menu.clearItems(); + ActionBarMenuItem item = menu.addItem(0, R.drawable.ic_ab_other); + item.addSubItem(edit_name, LocaleController.getString("EditName", R.string.EditName), 0); + item.addSubItem(logout, LocaleController.getString("LogOut", R.string.LogOut), 0); + + listAdapter = new ListAdapter(getParentActivity()); + + fragmentView = new FrameLayout(getParentActivity()); + FrameLayout frameLayout = (FrameLayout) fragmentView; + frameLayout.addView(actionBar); + + avatarImage = new BackupImageView(getParentActivity()); + avatarImage.imageReceiver.setRoundRadius(AndroidUtilities.dp(30)); + avatarImage.processDetach = false; + actionBar.addView(avatarImage); + FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) avatarImage.getLayoutParams(); + layoutParams.gravity = (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.BOTTOM; + layoutParams.width = AndroidUtilities.dp(60); + layoutParams.height = AndroidUtilities.dp(60); + layoutParams.leftMargin = LocaleController.isRTL ? 0 : AndroidUtilities.dp(17); + layoutParams.rightMargin = LocaleController.isRTL ? AndroidUtilities.dp(17) : 0; + layoutParams.bottomMargin = AndroidUtilities.dp(22); + avatarImage.setLayoutParams(layoutParams); + avatarImage.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + TLRPC.User user = MessagesController.getInstance().getUser(UserConfig.getClientUserId()); + if (user.photo != null && user.photo.photo_big != null) { + PhotoViewer.getInstance().setParentActivity(getParentActivity()); + PhotoViewer.getInstance().openPhoto(user.photo.photo_big, SettingsActivity.this); } } }); - fragmentView = inflater.inflate(R.layout.settings_layout, container, false); - listAdapter = new ListAdapter(getParentActivity()); - listView = (ListView)fragmentView.findViewById(R.id.listView); + nameTextView = new TextView(getParentActivity()); + nameTextView.setTextColor(0xffffffff); + nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20); + nameTextView.setLines(1); + nameTextView.setMaxLines(1); + nameTextView.setSingleLine(true); + nameTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT)); + nameTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); + actionBar.addView(nameTextView); + layoutParams = (FrameLayout.LayoutParams) nameTextView.getLayoutParams(); + layoutParams.width = FrameLayout.LayoutParams.WRAP_CONTENT; + layoutParams.height = FrameLayout.LayoutParams.WRAP_CONTENT; + layoutParams.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? 16 : 97); + layoutParams.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? 97 : 16); + layoutParams.bottomMargin = AndroidUtilities.dp(51); + layoutParams.gravity = (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.BOTTOM; + nameTextView.setLayoutParams(layoutParams); + + onlineTextView = new TextView(getParentActivity()); + onlineTextView.setTextColor(AvatarDrawable.getProfileTextColorForId(5)); + onlineTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); + onlineTextView.setLines(1); + onlineTextView.setMaxLines(1); + onlineTextView.setSingleLine(true); + onlineTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT)); + actionBar.addView(onlineTextView); + layoutParams = (FrameLayout.LayoutParams) onlineTextView.getLayoutParams(); + layoutParams.width = FrameLayout.LayoutParams.WRAP_CONTENT; + layoutParams.height = FrameLayout.LayoutParams.WRAP_CONTENT; + layoutParams.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? 16 : 97); + layoutParams.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? 97 : 16); + layoutParams.bottomMargin = AndroidUtilities.dp(30); + layoutParams.gravity = (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.BOTTOM; + onlineTextView.setLayoutParams(layoutParams); + + listView = new ListView(getParentActivity()); + listView.setDivider(null); + listView.setDividerHeight(0); + listView.setVerticalScrollBarEnabled(false); + AndroidUtilities.setListViewEdgeEffectColor(listView, AvatarDrawable.getProfileBackColorForId(5)); + frameLayout.addView(listView); + layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams(); + layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; + layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT; + layoutParams.gravity = Gravity.TOP; + listView.setLayoutParams(layoutParams); listView.setAdapter(listAdapter); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override @@ -433,7 +567,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter mask = MediaController.getInstance().roamingDownloadMask; } builder.setMultiChoiceItems( - new CharSequence[]{LocaleController.getString("AttachPhoto", R.string.AttachPhoto), LocaleController.getString("AttachAudio", R.string.AttachAudio), LocaleController.getString("AttachAudio", R.string.AttachVideo), LocaleController.getString("AttachAudio", R.string.AttachDocument)}, + new CharSequence[]{LocaleController.getString("AttachPhoto", R.string.AttachPhoto), LocaleController.getString("AttachAudio", R.string.AttachAudio), LocaleController.getString("AttachVideo", R.string.AttachVideo), LocaleController.getString("AttachDocument", R.string.AttachDocument)}, new boolean[]{(mask & MediaController.AUTODOWNLOAD_MASK_PHOTO) != 0, (mask & MediaController.AUTODOWNLOAD_MASK_AUDIO) != 0, (mask & MediaController.AUTODOWNLOAD_MASK_VIDEO) != 0, (mask & MediaController.AUTODOWNLOAD_MASK_DOCUMENT) != 0}, new DialogInterface.OnMultiChoiceClickListener() { @Override @@ -489,6 +623,60 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter } } }); + + writeButton = new ImageView(getParentActivity()); + writeButton.setImageResource(R.drawable.floating_group_states); + frameLayout.addView(writeButton); + layoutParams = (FrameLayout.LayoutParams) writeButton.getLayoutParams(); + layoutParams.width = FrameLayout.LayoutParams.WRAP_CONTENT; + layoutParams.height = FrameLayout.LayoutParams.WRAP_CONTENT; + layoutParams.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? 16 : 0); + layoutParams.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? 0 : 16); + layoutParams.gravity = (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT); + writeButton.setLayoutParams(layoutParams); + writeButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (getParentActivity() == null) { + return; + } + AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); + + CharSequence[] items; + + TLRPC.User user = MessagesController.getInstance().getUser(UserConfig.getClientUserId()); + if (user == null) { + user = UserConfig.getCurrentUser(); + } + if (user == null) { + return; + } + boolean fullMenu = false; + if (user.photo != null && user.photo.photo_big != null && !(user.photo instanceof TLRPC.TL_userProfilePhotoEmpty)) { + items = new CharSequence[] {LocaleController.getString("FromCamera", R.string.FromCamera), LocaleController.getString("FromGalley", R.string.FromGalley), LocaleController.getString("DeletePhoto", R.string.DeletePhoto)}; + fullMenu = true; + } else { + items = new CharSequence[] {LocaleController.getString("FromCamera", R.string.FromCamera), LocaleController.getString("FromGalley", R.string.FromGalley)}; + } + + final boolean full = fullMenu; + builder.setItems(items, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + if (i == 0) { + avatarUpdater.openCamera(); + } else if (i == 1) { + avatarUpdater.openGallery(); + } else if (i == 3) { + MessagesController.getInstance().deleteUserPhoto(null); + } + } + }); + showAlertDialog(builder); + } + }); + + updateUserData(); } else { ViewGroup parent = (ViewGroup)fragmentView.getParent(); if (parent != null) { @@ -512,24 +700,17 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter if (user != null && user.photo != null && user.photo.photo_big != null) { TLRPC.FileLocation photoBig = user.photo.photo_big; if (photoBig.local_id == fileLocation.local_id && photoBig.volume_id == fileLocation.volume_id && photoBig.dc_id == fileLocation.dc_id) { - int count = listView.getChildCount(); - for (int a = 0; a < count; a++) { - View view = listView.getChildAt(a); - BackupImageView avatarImage = (BackupImageView)view.findViewById(R.id.settings_avatar_image); - if (avatarImage != null) { - int coords[] = new int[2]; - avatarImage.getLocationInWindow(coords); - PhotoViewer.PlaceProviderObject object = new PhotoViewer.PlaceProviderObject(); - object.viewX = coords[0]; - object.viewY = coords[1] - AndroidUtilities.statusBarHeight; - object.parentView = listView; - object.imageReceiver = avatarImage.imageReceiver; - object.user_id = UserConfig.getClientUserId(); - object.thumb = object.imageReceiver.getBitmap(); - object.size = -1; - return object; - } - } + int coords[] = new int[2]; + avatarImage.getLocationInWindow(coords); + PhotoViewer.PlaceProviderObject object = new PhotoViewer.PlaceProviderObject(); + object.viewX = coords[0]; + object.viewY = coords[1] - AndroidUtilities.statusBarHeight; + object.parentView = avatarImage; + object.imageReceiver = avatarImage.imageReceiver; + object.user_id = UserConfig.getClientUserId(); + object.thumb = object.imageReceiver.getBitmap(); + object.size = -1; + return object; } } return null; @@ -663,13 +844,64 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter if (id == NotificationCenter.updateInterfaces) { int mask = (Integer)args[0]; if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0 || (mask & MessagesController.UPDATE_MASK_NAME) != 0) { - if (listView != null) { - listView.invalidateViews(); - } + updateUserData(); } } } + @Override + public void onResume() { + super.onResume(); + if (listAdapter != null) { + listAdapter.notifyDataSetChanged(); + } + fixLayout(); + } + + @Override + public void onConfigurationChanged(Configuration newConfig) { + super.onConfigurationChanged(newConfig); + fixLayout(); + } + + private void fixLayout() { + if (fragmentView == null) { + return; + } + fragmentView.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { + @Override + public boolean onPreDraw() { + if (fragmentView != null) { + ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) listView.getLayoutParams(); + layoutParams.topMargin = actionBar.getHeight(); + listView.setLayoutParams(layoutParams); + layoutParams = (ViewGroup.MarginLayoutParams) writeButton.getLayoutParams(); + layoutParams.topMargin = actionBar.getHeight() - AndroidUtilities.dp(29.5f); + writeButton.setLayoutParams(layoutParams); + fragmentView.getViewTreeObserver().removeOnPreDrawListener(this); + } + return false; + } + }); + } + + private void updateUserData() { + TLRPC.User user = MessagesController.getInstance().getUser(UserConfig.getClientUserId()); + TLRPC.FileLocation photo = null; + TLRPC.FileLocation photoBig = null; + if (user.photo != null) { + photo = user.photo.photo_small; + photoBig = user.photo.photo_big; + } + avatarImage.setImage(photo, "50_50", new AvatarDrawable(user, true)); + avatarImage.imageReceiver.setVisible(!PhotoViewer.getInstance().isShowingImage(photoBig), false); + + nameTextView.setText(ContactsController.formatName(user.first_name, user.last_name)); + onlineTextView.setText(LocaleController.formatUserStatus(user)); + + avatarImage.imageReceiver.setVisible(!PhotoViewer.getInstance().isShowingImage(photoBig), false); + } + private void sendLogs() { try { ArrayList uris = new ArrayList(); @@ -694,14 +926,6 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter } } - @Override - public void onResume() { - super.onResume(); - if (listAdapter != null) { - listAdapter.notifyDataSetChanged(); - } - } - private class ListAdapter extends BaseFragmentAdapter { private Context mContext; @@ -747,349 +971,180 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter int type = getItemViewType(i); if (type == 0) { if (view == null) { - LayoutInflater li = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); - view = li.inflate(R.layout.settings_name_layout, viewGroup, false); - - ImageButton button = (ImageButton)view.findViewById(R.id.settings_edit_name); - button.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - presentFragment(new SettingsChangeNameActivity()); - } - }); - - final ImageButton button2 = (ImageButton)view.findViewById(R.id.settings_change_avatar_button); - button2.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - if (getParentActivity() == null) { - return; - } - AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); - - CharSequence[] items; - - TLRPC.User user = MessagesController.getInstance().getUser(UserConfig.getClientUserId()); - if (user == null) { - user = UserConfig.getCurrentUser(); - } - if (user == null) { - return; - } - boolean fullMenu = false; - if (user.photo != null && user.photo.photo_big != null && !(user.photo instanceof TLRPC.TL_userProfilePhotoEmpty)) { - items = new CharSequence[] {LocaleController.getString("OpenPhoto", R.string.OpenPhoto), LocaleController.getString("FromCamera", R.string.FromCamera), LocaleController.getString("FromGalley", R.string.FromGalley), LocaleController.getString("DeletePhoto", R.string.DeletePhoto)}; - fullMenu = true; - } else { - items = new CharSequence[] {LocaleController.getString("FromCamera", R.string.FromCamera), LocaleController.getString("FromGalley", R.string.FromGalley)}; - } - - final boolean full = fullMenu; - builder.setItems(items, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialogInterface, int i) { - if (i == 0 && full) { - TLRPC.User user = MessagesController.getInstance().getUser(UserConfig.getClientUserId()); - if (user != null && user.photo != null && user.photo.photo_big != null) { - PhotoViewer.getInstance().setParentActivity(getParentActivity()); - PhotoViewer.getInstance().openPhoto(user.photo.photo_big, SettingsActivity.this); - } - } else if (i == 0 && !full || i == 1 && full) { - avatarUpdater.openCamera(); - } else if (i == 1 && !full || i == 2 && full) { - avatarUpdater.openGallery(); - } else if (i == 3) { - MessagesController.getInstance().deleteUserPhoto(null); - } - } - }); - showAlertDialog(builder); - } - }); + view = new EmptyCell(mContext, 16); } - TextView textView = (TextView)view.findViewById(R.id.settings_online); - textView.setText(LocaleController.getString("Online", R.string.Online)); - - textView = (TextView)view.findViewById(R.id.settings_name); - Typeface typeface = AndroidUtilities.getTypeface("fonts/rmedium.ttf"); - textView.setTypeface(typeface); - TLRPC.User user = MessagesController.getInstance().getUser(UserConfig.getClientUserId()); - if (user == null) { - user = UserConfig.getCurrentUser(); - } - if (user != null) { - textView.setText(ContactsController.formatName(user.first_name, user.last_name)); - BackupImageView avatarImage = (BackupImageView)view.findViewById(R.id.settings_avatar_image); - avatarImage.processDetach = false; - TLRPC.FileLocation photo = null; - TLRPC.FileLocation photoBig = null; - if (user.photo != null) { - photo = user.photo.photo_small; - photoBig = user.photo.photo_big; - } - avatarImage.setImage(photo, "50_50", new AvatarDrawable(user)); - avatarImage.imageReceiver.setVisible(!PhotoViewer.getInstance().isShowingImage(photoBig), false); - } - return view; } else if (type == 1) { if (view == null) { - view = new SettingsSectionLayout(mContext); - } - if (i == numberSectionRow) { - ((SettingsSectionLayout) view).setText(LocaleController.getString("Info", R.string.Info)); - } else if (i == settingsSectionRow) { - ((SettingsSectionLayout) view).setText(LocaleController.getString("SETTINGS", R.string.SETTINGS)); - } else if (i == supportSectionRow) { - ((SettingsSectionLayout) view).setText(LocaleController.getString("Support", R.string.Support)); - } else if (i == messagesSectionRow) { - ((SettingsSectionLayout) view).setText(LocaleController.getString("MessagesSettings", R.string.MessagesSettings)); - } else if (i == mediaDownloadSection) { - ((SettingsSectionLayout) view).setText(LocaleController.getString("AutomaticMediaDownload", R.string.AutomaticMediaDownload)); - } else if (i == contactsSectionRow) { - ((SettingsSectionLayout) view).setText(LocaleController.getString("Contacts", R.string.Contacts).toUpperCase()); + view = new ShadowSectionCell(mContext); } } else if (type == 2) { if (view == null) { - LayoutInflater li = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); - view = li.inflate(R.layout.settings_row_button_layout, viewGroup, false); + view = new TextSettingsCell(mContext); } - TextView textView = (TextView)view.findViewById(R.id.settings_row_text); - View divider = view.findViewById(R.id.settings_row_divider); - if (i == notificationRow) { - textView.setText(LocaleController.getString("NotificationsAndSounds", R.string.NotificationsAndSounds)); - divider.setVisibility(View.VISIBLE); - } else if (i == blockedRow) { - textView.setText(LocaleController.getString("BlockedUsers", R.string.BlockedUsers)); - divider.setVisibility(backgroundRow != 0 ? View.VISIBLE : View.INVISIBLE); - } else if (i == backgroundRow) { - textView.setText(LocaleController.getString("ChatBackground", R.string.ChatBackground)); - divider.setVisibility(View.VISIBLE); - } else if (i == sendLogsRow) { - textView.setText("Send Logs"); - divider.setVisibility(View.VISIBLE); - } else if (i == clearLogsRow) { - textView.setText("Clear Logs"); - divider.setVisibility(View.VISIBLE); - } else if (i == askQuestionRow) { - textView.setText(LocaleController.getString("AskAQuestion", R.string.AskAQuestion)); - divider.setVisibility(View.INVISIBLE); - } else if (i == terminateSessionsRow) { - textView.setText(LocaleController.getString("TerminateAllSessions", R.string.TerminateAllSessions)); - divider.setVisibility(View.INVISIBLE); - } else if (i == switchBackendButtonRow) { - textView.setText("Switch Backend"); - divider.setVisibility(View.VISIBLE); - } else if (i == telegramFaqRow) { - textView.setText(LocaleController.getString("TelegramFAQ", R.string.TelegramFaq)); - divider.setVisibility(View.VISIBLE); - } else if (i == contactsReimportRow) { - textView.setText(LocaleController.getString("ImportContacts", R.string.ImportContacts)); - divider.setVisibility(View.INVISIBLE); - } - } else if (type == 3) { - if (view == null) { - LayoutInflater li = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); - view = li.inflate(R.layout.settings_row_check_layout, viewGroup, false); - } - TextView textView = (TextView)view.findViewById(R.id.settings_row_text); - View divider = view.findViewById(R.id.settings_row_divider); - ImageView checkButton = (ImageView)view.findViewById(R.id.settings_row_check_button); - SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE); - if (i == enableAnimationsRow) { - textView.setText(LocaleController.getString("EnableAnimations", R.string.EnableAnimations)); - divider.setVisibility(View.VISIBLE); - boolean enabled = preferences.getBoolean("view_animations", true); - if (enabled) { - checkButton.setImageResource(R.drawable.btn_check_on); - } else { - checkButton.setImageResource(R.drawable.btn_check_off); - } - } else if (i == sendByEnterRow) { - textView.setText(LocaleController.getString("SendByEnter", R.string.SendByEnter)); - divider.setVisibility(View.INVISIBLE); - boolean enabled = preferences.getBoolean("send_by_enter", false); - if (enabled) { - checkButton.setImageResource(R.drawable.btn_check_on); - } else { - checkButton.setImageResource(R.drawable.btn_check_off); - } - } else if (i == saveToGalleryRow) { - textView.setText(LocaleController.getString("SaveToGallerySettings", R.string.SaveToGallerySettings)); - divider.setVisibility(View.INVISIBLE); - if (MediaController.getInstance().canSaveToGallery()) { - checkButton.setImageResource(R.drawable.btn_check_on); - } else { - checkButton.setImageResource(R.drawable.btn_check_off); - } - } - } else if (type == 4) { - if (view == null) { - LayoutInflater li = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); - view = li.inflate(R.layout.settings_logout_button, viewGroup, false); - TextView textView = (TextView)view.findViewById(R.id.settings_row_text); - textView.setText(LocaleController.getString("LogOut", R.string.LogOut)); - textView.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - if (getParentActivity() == null) { - return; - } - AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); - builder.setMessage(LocaleController.getString("AreYouSureLogout", R.string.AreYouSureLogout)); - builder.setTitle(LocaleController.getString("AppName", R.string.AppName)); - builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialogInterface, int i) { - SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); - SharedPreferences.Editor editor = preferences.edit(); - editor.clear().commit(); - NotificationCenter.getInstance().postNotificationName(NotificationCenter.appDidLogout); - MessagesController.getInstance().unregistedPush(); - MessagesController.getInstance().logOut(); - UserConfig.clearConfig(); - MessagesStorage.getInstance().cleanUp(false); - MessagesController.getInstance().cleanUp(); - ContactsController.getInstance().deleteAllAppAccounts(); - } - }); - builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); - showAlertDialog(builder); - } - }); - } - } else if (type == 5) { - if (view == null) { - LayoutInflater li = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); - view = li.inflate(R.layout.user_profile_leftright_row_layout, viewGroup, false); - } - TextView textView = (TextView)view.findViewById(R.id.settings_row_text); - TextView detailTextView = (TextView)view.findViewById(R.id.settings_row_text_detail); - View divider = view.findViewById(R.id.settings_row_divider); - if (i == numberRow) { - TLRPC.User user = UserConfig.getCurrentUser(); - textView.setText(LocaleController.getString("Phone", R.string.Phone)); - if (user != null && user.phone != null && user.phone.length() != 0) { - detailTextView.setText(PhoneFormat.getInstance().format("+" + user.phone)); - } else { - detailTextView.setText(LocaleController.getString("NumberUnknown", R.string.NumberUnknown)); - } - divider.setVisibility(View.VISIBLE); - } else if (i == textSizeRow) { + TextSettingsCell textCell = (TextSettingsCell) view; + if (i == textSizeRow) { SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE); int size = preferences.getInt("fons_size", AndroidUtilities.isTablet() ? 18 : 16); - detailTextView.setText(String.format("%d", size)); - textView.setText(LocaleController.getString("TextSize", R.string.TextSize)); - divider.setVisibility(View.VISIBLE); + textCell.setTextAndValue(LocaleController.getString("TextSize", R.string.TextSize), String.format("%d", size), true); } else if (i == languageRow) { - detailTextView.setText(LocaleController.getCurrentLanguageName()); - textView.setText(LocaleController.getString("Language", R.string.Language)); - divider.setVisibility(View.VISIBLE); + textCell.setTextAndValue(LocaleController.getString("Language", R.string.Language), LocaleController.getCurrentLanguageName(), true); } else if (i == contactsSortRow) { - textView.setText(LocaleController.getString("SortBy", R.string.SortBy)); - divider.setVisibility(View.VISIBLE); + String value; SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE); int sort = preferences.getInt("sortContactsBy", 0); if (sort == 0) { - detailTextView.setText(LocaleController.getString("Default", R.string.Default)); + value = LocaleController.getString("Default", R.string.Default); } else if (sort == 1) { - detailTextView.setText(LocaleController.getString("FirstName", R.string.SortFirstName)); - } else if (sort == 2) { - detailTextView.setText(LocaleController.getString("LastName", R.string.SortLastName)); - } - } else if (i == usernameRow) { - TLRPC.User user = UserConfig.getCurrentUser(); - textView.setText(LocaleController.getString("Username", R.string.Username)); - if (user != null && user.username != null && user.username.length() != 0) { - detailTextView.setText("@" + user.username); + value = LocaleController.getString("FirstName", R.string.SortFirstName); } else { - detailTextView.setText(LocaleController.getString("UsernameEmpty", R.string.UsernameEmpty)); + value = LocaleController.getString("LastName", R.string.SortLastName); } - divider.setVisibility(View.INVISIBLE); + textCell.setTextAndValue(LocaleController.getString("SortBy", R.string.SortBy), value, true); + } else if (i == notificationRow) { + textCell.setText(LocaleController.getString("NotificationsAndSounds", R.string.NotificationsAndSounds), true); + } else if (i == blockedRow) { + textCell.setText(LocaleController.getString("BlockedUsers", R.string.BlockedUsers), true); + } else if (i == backgroundRow) { + textCell.setText(LocaleController.getString("ChatBackground", R.string.ChatBackground), true); + } else if (i == sendLogsRow) { + textCell.setText("Send Logs", true); + } else if (i == clearLogsRow) { + textCell.setText("Clear Logs", true); + } else if (i == askQuestionRow) { + textCell.setText(LocaleController.getString("AskAQuestion", R.string.AskAQuestion), true); + } else if (i == terminateSessionsRow) { + textCell.setText(LocaleController.getString("TerminateAllSessions", R.string.TerminateAllSessions), false); + } else if (i == switchBackendButtonRow) { + textCell.setText("Switch Backend", true); + } else if (i == telegramFaqRow) { + textCell.setText(LocaleController.getString("TelegramFAQ", R.string.TelegramFaq), true); + } else if (i == contactsReimportRow) { + textCell.setText(LocaleController.getString("ImportContacts", R.string.ImportContacts), true); } - } else if (type == 6) { + } else if (type == 3) { if (view == null) { - LayoutInflater li = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); - view = li.inflate(R.layout.settings_row_version, viewGroup, false); - TextView textView = (TextView)view.findViewById(R.id.settings_row_text); + view = new TextCheckCell(mContext); + } + TextCheckCell textCell = (TextCheckCell) view; + + SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE); + if (i == enableAnimationsRow) { + textCell.setTextAndCheck(LocaleController.getString("EnableAnimations", R.string.EnableAnimations), preferences.getBoolean("view_animations", true), true); + } else if (i == sendByEnterRow) { + textCell.setTextAndCheck(LocaleController.getString("SendByEnter", R.string.SendByEnter), preferences.getBoolean("send_by_enter", false), false); + } else if (i == saveToGalleryRow) { + textCell.setTextAndCheck(LocaleController.getString("SaveToGallerySettings", R.string.SaveToGallerySettings), MediaController.getInstance().canSaveToGallery(), false); + } + } else if (type == 4) { + if (view == null) { + view = new HeaderCell(mContext); + } + if (i == settingsSectionRow2) { + ((HeaderCell) view).setText(LocaleController.getString("SETTINGS", R.string.SETTINGS)); + } else if (i == supportSectionRow2) { + ((HeaderCell) view).setText(LocaleController.getString("Support", R.string.Support)); + } else if (i == messagesSectionRow2) { + ((HeaderCell) view).setText(LocaleController.getString("MessagesSettings", R.string.MessagesSettings)); + } else if (i == mediaDownloadSection2) { + ((HeaderCell) view).setText(LocaleController.getString("AutomaticMediaDownload", R.string.AutomaticMediaDownload)); + } else if (i == numberSectionRow) { + ((HeaderCell) view).setText(LocaleController.getString("Info", R.string.Info)); + } + } else if (type == 5) { + if (view == null) { + view = new DetailTextCell(mContext); try { PackageInfo pInfo = ApplicationLoader.applicationContext.getPackageManager().getPackageInfo(ApplicationLoader.applicationContext.getPackageName(), 0); - textView.setText(String.format(Locale.US, "Telegram for Android v%s (%d)", pInfo.versionName, pInfo.versionCode)); + ((DetailTextCell) view).setText(String.format(Locale.US, "Telegram for Android v%s (%d)", pInfo.versionName, pInfo.versionCode)); } catch (Exception e) { FileLog.e("tmessages", e); } } - } else if (type == 7) { + } else if (type == 6) { if (view == null) { - LayoutInflater li = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); - view = li.inflate(R.layout.settings_row_detail_layout, viewGroup, false); + view = new TextDetailSettingsCell(mContext); } - TextView textView = (TextView)view.findViewById(R.id.settings_row_text); - TextView textViewDetail = (TextView)view.findViewById(R.id.settings_row_text_detail); - View divider = view.findViewById(R.id.settings_row_divider); + TextDetailSettingsCell textCell = (TextDetailSettingsCell) view; - SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE); - int mask = 0; - if (i == mobileDownloadRow) { - textView.setText(LocaleController.getString("WhenUsingMobileData", R.string.WhenUsingMobileData)); - divider.setVisibility(View.VISIBLE); - mask = MediaController.getInstance().mobileDataDownloadMask; - } else if (i == wifiDownloadRow) { - textView.setText(LocaleController.getString("WhenConnectedOnWiFi", R.string.WhenConnectedOnWiFi)); - divider.setVisibility(View.VISIBLE); - mask = MediaController.getInstance().wifiDownloadMask; - } else if (i == roamingDownloadRow) { - textView.setText(LocaleController.getString("WhenRoaming", R.string.WhenRoaming)); - divider.setVisibility(View.VISIBLE); - mask = MediaController.getInstance().roamingDownloadMask; - } - String text = ""; - if ((mask & MediaController.AUTODOWNLOAD_MASK_PHOTO) != 0) { - text += LocaleController.getString("AttachPhoto", R.string.AttachPhoto); - } - if ((mask & MediaController.AUTODOWNLOAD_MASK_AUDIO) != 0) { - if (text.length() != 0) { - text += ", "; + if (i == mobileDownloadRow || i == wifiDownloadRow || i == roamingDownloadRow) { + int mask = 0; + String value; + SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE); + if (i == mobileDownloadRow) { + value = LocaleController.getString("WhenUsingMobileData", R.string.WhenUsingMobileData); + mask = MediaController.getInstance().mobileDataDownloadMask; + } else if (i == wifiDownloadRow) { + value = LocaleController.getString("WhenConnectedOnWiFi", R.string.WhenConnectedOnWiFi); + mask = MediaController.getInstance().wifiDownloadMask; + } else { + value = LocaleController.getString("WhenRoaming", R.string.WhenRoaming); + mask = MediaController.getInstance().roamingDownloadMask; } - text += LocaleController.getString("AttachAudio", R.string.AttachAudio); - } - if ((mask & MediaController.AUTODOWNLOAD_MASK_VIDEO) != 0) { - if (text.length() != 0) { - text += ", "; + String text = ""; + if ((mask & MediaController.AUTODOWNLOAD_MASK_PHOTO) != 0) { + text += LocaleController.getString("AttachPhoto", R.string.AttachPhoto); } - text += LocaleController.getString("AttachVideo", R.string.AttachVideo); - } - if ((mask & MediaController.AUTODOWNLOAD_MASK_DOCUMENT) != 0) { - if (text.length() != 0) { - text += ", "; + if ((mask & MediaController.AUTODOWNLOAD_MASK_AUDIO) != 0) { + if (text.length() != 0) { + text += ", "; + } + text += LocaleController.getString("AttachAudio", R.string.AttachAudio); } - text += LocaleController.getString("AttachDocument", R.string.AttachDocument); + if ((mask & MediaController.AUTODOWNLOAD_MASK_VIDEO) != 0) { + if (text.length() != 0) { + text += ", "; + } + text += LocaleController.getString("AttachVideo", R.string.AttachVideo); + } + if ((mask & MediaController.AUTODOWNLOAD_MASK_DOCUMENT) != 0) { + if (text.length() != 0) { + text += ", "; + } + text += LocaleController.getString("AttachDocument", R.string.AttachDocument); + } + if (text.length() == 0) { + text = LocaleController.getString("NoMediaAutoDownload", R.string.NoMediaAutoDownload); + } + textCell.setTextAndValue(value, text, true); + } else if (i == numberRow) { + TLRPC.User user = UserConfig.getCurrentUser(); + String value; + if (user != null && user.phone != null && user.phone.length() != 0) { + value = PhoneFormat.getInstance().format("+" + user.phone); + } else { + value = LocaleController.getString("NumberUnknown", R.string.NumberUnknown); + } + textCell.setTextAndValue(value, LocaleController.getString("Phone", R.string.Phone), true); + } else if (i == usernameRow) { + TLRPC.User user = UserConfig.getCurrentUser(); + String value; + if (user != null && user.username != null && user.username.length() != 0) { + value = "@" + user.username; + } else { + value = LocaleController.getString("UsernameEmpty", R.string.UsernameEmpty); + } + textCell.setTextAndValue(value, LocaleController.getString("Username", R.string.Username), false); } - if (text.length() == 0) { - text = LocaleController.getString("NoMediaAutoDownload", R.string.NoMediaAutoDownload); - } - textViewDetail.setText(text); } return view; } @Override public int getItemViewType(int i) { - if (i == profileRow) { + if (i == emptyRow) { return 0; - } else if (i == numberSectionRow || i == settingsSectionRow || i == supportSectionRow || i == messagesSectionRow || i == mediaDownloadSection || i == contactsSectionRow) { + } if (i == settingsSectionRow || i == supportSectionRow || i == messagesSectionRow || i == mediaDownloadSection || i == contactsSectionRow) { return 1; - } else if (i == textSizeRow || i == languageRow || i == contactsSortRow || i == numberRow || i == usernameRow) { - return 5; } else if (i == enableAnimationsRow || i == sendByEnterRow || i == saveToGalleryRow) { return 3; - } else if (i == notificationRow || i == blockedRow || i == backgroundRow || i == askQuestionRow || i == sendLogsRow || i == terminateSessionsRow || i == clearLogsRow || i == switchBackendButtonRow || i == telegramFaqRow || i == contactsReimportRow) { + } else if (i == notificationRow || i == blockedRow || i == backgroundRow || i == askQuestionRow || i == sendLogsRow || i == terminateSessionsRow || i == clearLogsRow || i == switchBackendButtonRow || i == telegramFaqRow || i == contactsReimportRow || i == textSizeRow || i == languageRow || i == contactsSortRow) { return 2; - } else if (i == logoutRow) { - return 4; } else if (i == versionRow) { + return 5; + } else if (i == wifiDownloadRow || i == mobileDownloadRow || i == roamingDownloadRow || i == numberRow || i == usernameRow) { return 6; - } else if (i == wifiDownloadRow || i == mobileDownloadRow || i == roamingDownloadRow) { - return 7; + } else if (i == settingsSectionRow2 || i == messagesSectionRow2 || i == supportSectionRow2 || i == numberSectionRow || i == mediaDownloadSection2) { + return 4; } else { return 2; } @@ -1097,7 +1152,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter @Override public int getViewTypeCount() { - return 8; + return 7; } @Override diff --git a/TMessagesProj/src/main/java/org/telegram/ui/SettingsBlockedUsersActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/SettingsBlockedUsersActivity.java index 490cb519..66c458e1 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/SettingsBlockedUsersActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/SettingsBlockedUsersActivity.java @@ -28,7 +28,7 @@ import org.telegram.android.NotificationCenter; import org.telegram.messenger.R; import org.telegram.ui.Adapters.BaseFragmentAdapter; import org.telegram.ui.Cells.UserCell; -import org.telegram.ui.Views.ActionBar.ActionBarLayer; +import org.telegram.ui.Views.ActionBar.ActionBar; import org.telegram.ui.Views.ActionBar.ActionBarMenu; import org.telegram.ui.Views.ActionBar.BaseFragment; @@ -60,10 +60,10 @@ public class SettingsBlockedUsersActivity extends BaseFragment implements Notifi @Override public View createView(LayoutInflater inflater, ViewGroup container) { if (fragmentView == null) { - actionBarLayer.setBackButtonImage(R.drawable.ic_ab_back); - actionBarLayer.setBackOverlay(R.layout.updating_state_layout); - actionBarLayer.setTitle(LocaleController.getString("BlockedUsers", R.string.BlockedUsers)); - actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() { + actionBar.setBackButtonImage(R.drawable.ic_ab_back); + actionBar.setBackOverlay(R.layout.updating_state_layout); + actionBar.setTitle(LocaleController.getString("BlockedUsers", R.string.BlockedUsers)); + actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @Override public void onItemClick(int id) { if (id == -1) { @@ -80,7 +80,7 @@ public class SettingsBlockedUsersActivity extends BaseFragment implements Notifi } }); - ActionBarMenu menu = actionBarLayer.createMenu(); + ActionBarMenu menu = actionBar.createMenu(); menu.addItem(block_user, R.drawable.plus); fragmentView = inflater.inflate(R.layout.settings_blocked_users_layout, container, false); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/SettingsChangeNameActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/SettingsChangeNameActivity.java index 2d616aff..bc3c78b4 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/SettingsChangeNameActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/SettingsChangeNameActivity.java @@ -45,15 +45,15 @@ public class SettingsChangeNameActivity extends BaseFragment { @Override public View createView(LayoutInflater inflater, ViewGroup container) { if (fragmentView == null) { - actionBarLayer.setCustomView(R.layout.settings_do_action_layout); - Button cancelButton = (Button)actionBarLayer.findViewById(R.id.cancel_button); + actionBar.setCustomView(R.layout.settings_do_action_layout); + Button cancelButton = (Button) actionBar.findViewById(R.id.cancel_button); cancelButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { finishFragment(); } }); - doneButton = actionBarLayer.findViewById(R.id.done_button); + doneButton = actionBar.findViewById(R.id.done_button); doneButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/SettingsChangeUsernameActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/SettingsChangeUsernameActivity.java index 1a632b9f..3941c422 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/SettingsChangeUsernameActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/SettingsChangeUsernameActivity.java @@ -59,15 +59,15 @@ public class SettingsChangeUsernameActivity extends BaseFragment { @Override public View createView(LayoutInflater inflater, ViewGroup container) { if (fragmentView == null) { - actionBarLayer.setCustomView(R.layout.settings_do_action_layout); - Button cancelButton = (Button)actionBarLayer.findViewById(R.id.cancel_button); + actionBar.setCustomView(R.layout.settings_do_action_layout); + Button cancelButton = (Button) actionBar.findViewById(R.id.cancel_button); cancelButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { finishFragment(); } }); - doneButton = actionBarLayer.findViewById(R.id.done_button); + doneButton = actionBar.findViewById(R.id.done_button); doneButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/SettingsNotificationsActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/SettingsNotificationsActivity.java index 37e434f5..835035f9 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/SettingsNotificationsActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/SettingsNotificationsActivity.java @@ -22,6 +22,7 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; +import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.ListView; import android.widget.TextView; @@ -39,8 +40,10 @@ import org.telegram.android.MessagesController; import org.telegram.messenger.R; import org.telegram.messenger.RPCRequest; import org.telegram.ui.Adapters.BaseFragmentAdapter; -import org.telegram.ui.Views.ActionBar.ActionBarLayer; +import org.telegram.ui.Cells.TextCheckCell; +import org.telegram.ui.Views.ActionBar.ActionBar; import org.telegram.ui.Views.ActionBar.BaseFragment; +import org.telegram.ui.Views.AvatarDrawable; import org.telegram.ui.Views.ColorPickerView; import org.telegram.ui.Views.SettingsSectionLayout; @@ -119,10 +122,10 @@ public class SettingsNotificationsActivity extends BaseFragment implements Notif @Override public View createView(LayoutInflater inflater, ViewGroup container) { if (fragmentView == null) { - actionBarLayer.setBackButtonImage(R.drawable.ic_ab_back); - actionBarLayer.setBackOverlay(R.layout.updating_state_layout); - actionBarLayer.setTitle(LocaleController.getString("NotificationsAndSounds", R.string.NotificationsAndSounds)); - actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() { + actionBar.setBackButtonImage(R.drawable.ic_ab_back); + actionBar.setBackOverlay(R.layout.updating_state_layout); + actionBar.setTitle(LocaleController.getString("NotificationsAndSounds", R.string.NotificationsAndSounds)); + actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @Override public void onItemClick(int id) { if (id == -1) { @@ -131,10 +134,20 @@ public class SettingsNotificationsActivity extends BaseFragment implements Notif } }); - fragmentView = inflater.inflate(R.layout.settings_layout, container, false); - final ListAdapter listAdapter = new ListAdapter(getParentActivity()); - listView = (ListView)fragmentView.findViewById(R.id.listView); - listView.setAdapter(listAdapter); + fragmentView = new FrameLayout(getParentActivity()); + FrameLayout frameLayout = (FrameLayout) fragmentView; + + listView = new ListView(getParentActivity()); + listView.setDivider(null); + listView.setDividerHeight(0); + listView.setVerticalScrollBarEnabled(false); + AndroidUtilities.setListViewEdgeEffectColor(listView, AvatarDrawable.getProfileBackColorForId(5)); + frameLayout.addView(listView); + FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams(); + layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; + layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT; + listView.setLayoutParams(layoutParams); + listView.setAdapter(new ListAdapter(getParentActivity())); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView adapterView, View view, final int i, long l) { @@ -559,13 +572,10 @@ public class SettingsNotificationsActivity extends BaseFragment implements Notif } } if (type == 1) { if (view == null) { - LayoutInflater li = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); - view = li.inflate(R.layout.settings_row_check_notify_layout, viewGroup, false); + view = new TextCheckCell(mContext); } - TextView textView = (TextView)view.findViewById(R.id.settings_row_text); - View divider = view.findViewById(R.id.settings_row_divider); + TextCheckCell checkCell = (TextCheckCell) view; - ImageView checkButton = (ImageView)view.findViewById(R.id.settings_row_check_button); SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); boolean enabled = false; boolean enabledAll = preferences.getBoolean("EnableAll", true); @@ -577,49 +587,28 @@ public class SettingsNotificationsActivity extends BaseFragment implements Notif } else if (i == groupAlertRow) { enabled = enabledGroup; } - textView.setText(LocaleController.getString("Alert", R.string.Alert)); - divider.setVisibility(View.VISIBLE); + checkCell.setTextAndCheck(LocaleController.getString("Alert", R.string.Alert), enabled, true); } else if (i == messagePreviewRow || i == groupPreviewRow) { if (i == messagePreviewRow) { enabled = preferences.getBoolean("EnablePreviewAll", true); } else if (i == groupPreviewRow) { enabled = preferences.getBoolean("EnablePreviewGroup", true); } - textView.setText(LocaleController.getString("MessagePreview", R.string.MessagePreview)); - divider.setVisibility(View.VISIBLE); + checkCell.setTextAndCheck(LocaleController.getString("MessagePreview", R.string.MessagePreview), enabled, true); } else if (i == inappSoundRow) { - enabled = preferences.getBoolean("EnableInAppSounds", true); - textView.setText(LocaleController.getString("InAppSounds", R.string.InAppSounds)); - divider.setVisibility(View.VISIBLE); + checkCell.setTextAndCheck(LocaleController.getString("InAppSounds", R.string.InAppSounds), preferences.getBoolean("EnableInAppSounds", true), true); } else if (i == inappVibrateRow) { - enabled = preferences.getBoolean("EnableInAppVibrate", true); - textView.setText(LocaleController.getString("InAppVibrate", R.string.InAppVibrate)); - divider.setVisibility(View.VISIBLE); + checkCell.setTextAndCheck(LocaleController.getString("InAppVibrate", R.string.InAppVibrate), preferences.getBoolean("EnableInAppVibrate", true), true); } else if (i == inappPreviewRow) { - enabled = preferences.getBoolean("EnableInAppPreview", true); - textView.setText(LocaleController.getString("InAppPreview", R.string.InAppPreview)); - divider.setVisibility(View.INVISIBLE); + checkCell.setTextAndCheck(LocaleController.getString("InAppPreview", R.string.InAppPreview), preferences.getBoolean("EnableInAppPreview", true), false); } else if (i == contactJoinedRow) { - enabled = preferences.getBoolean("EnableContactJoined", true); - textView.setText(LocaleController.getString("ContactJoined", R.string.ContactJoined)); - divider.setVisibility(View.INVISIBLE); + checkCell.setTextAndCheck(LocaleController.getString("ContactJoined", R.string.ContactJoined), preferences.getBoolean("EnableContactJoined", true), false); } else if (i == pebbleAlertRow) { - enabled = preferences.getBoolean("EnablePebbleNotifications", false); - textView.setText(LocaleController.getString("Pebble", R.string.Pebble)); - divider.setVisibility(View.INVISIBLE); + checkCell.setTextAndCheck(LocaleController.getString("Pebble", R.string.Pebble), preferences.getBoolean("EnablePebbleNotifications", false), false); } else if (i == notificationsServiceRow) { - enabled = preferences.getBoolean("pushService", true); - textView.setText(LocaleController.getString("NotificationsService", R.string.NotificationsService)); - divider.setVisibility(View.INVISIBLE); + checkCell.setTextAndCheck(LocaleController.getString("NotificationsService", R.string.NotificationsService), preferences.getBoolean("pushService", true), false); } 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); - } else { - checkButton.setImageResource(R.drawable.btn_check_off); + checkCell.setTextAndCheck(LocaleController.getString("BadgeNumber", R.string.BadgeNumber), preferences.getBoolean("badgeNumber", true), true); } } else if (type == 2) { if (view == null) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/SettingsWallpapersActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/SettingsWallpapersActivity.java index 104a2bd6..e3a80113 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/SettingsWallpapersActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/SettingsWallpapersActivity.java @@ -99,15 +99,15 @@ public class SettingsWallpapersActivity extends BaseFragment implements Notifica @Override public View createView(LayoutInflater inflater, ViewGroup container) { if (fragmentView == null) { - actionBarLayer.setCustomView(R.layout.settings_do_action_layout); - Button cancelButton = (Button)actionBarLayer.findViewById(R.id.cancel_button); + actionBar.setCustomView(R.layout.settings_do_action_layout); + Button cancelButton = (Button) actionBar.findViewById(R.id.cancel_button); cancelButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { finishFragment(); } }); - doneButton = actionBarLayer.findViewById(R.id.done_button); + doneButton = actionBar.findViewById(R.id.done_button); doneButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/VideoEditorActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/VideoEditorActivity.java index ebb8fbcb..c1cac76c 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/VideoEditorActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/VideoEditorActivity.java @@ -46,7 +46,7 @@ import org.telegram.android.MediaController; import org.telegram.messenger.FileLog; import org.telegram.messenger.R; import org.telegram.messenger.Utilities; -import org.telegram.ui.Views.ActionBar.ActionBarLayer; +import org.telegram.ui.Views.ActionBar.ActionBar; import org.telegram.ui.Views.ActionBar.ActionBarMenu; import org.telegram.ui.Views.ActionBar.BaseFragment; import org.telegram.ui.Views.VideoSeekBarView; @@ -220,11 +220,11 @@ public class VideoEditorActivity extends BaseFragment implements TextureView.Sur @Override public View createView(LayoutInflater inflater, ViewGroup container) { if (fragmentView == null) { - actionBarLayer.setBackgroundColor(0xff333333); - actionBarLayer.setItemsBackground(R.drawable.bar_selector_white); - actionBarLayer.setBackButtonImage(R.drawable.ic_ab_back); - actionBarLayer.setTitle(LocaleController.getString("EditVideo", R.string.EditVideo)); - actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() { + actionBar.setBackgroundColor(0xff333333); + actionBar.setItemsBackground(R.drawable.bar_selector_white); + actionBar.setBackButtonImage(R.drawable.ic_ab_back); + actionBar.setTitle(LocaleController.getString("EditVideo", R.string.EditVideo)); + actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @Override public void onItemClick(int id) { if (id == -1) { @@ -253,7 +253,7 @@ public class VideoEditorActivity extends BaseFragment implements TextureView.Sur } }); - ActionBarMenu menu = actionBarLayer.createMenu(); + ActionBarMenu menu = actionBar.createMenu(); View doneItem = menu.addItemResource(1, R.layout.group_create_done_layout); TextView doneTextView = (TextView) doneItem.findViewById(R.id.done_button); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Views/ActionBar/ActionBar.java b/TMessagesProj/src/main/java/org/telegram/ui/Views/ActionBar/ActionBar.java index f297e29f..9dd5076e 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Views/ActionBar/ActionBar.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Views/ActionBar/ActionBar.java @@ -9,11 +9,18 @@ package org.telegram.ui.Views.ActionBar; import android.content.Context; -import android.util.AttributeSet; +import android.content.res.Configuration; +import android.graphics.drawable.Drawable; +import android.os.Build; +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.FrameLayout; +import android.widget.ImageView; +import android.widget.TextView; import org.telegram.android.AndroidUtilities; import org.telegram.messenger.R; @@ -21,142 +28,462 @@ import org.telegram.ui.AnimationCompat.ViewProxy; public class ActionBar extends FrameLayout { - protected ActionBarLayer currentLayer = null; - protected ActionBarLayer previousLayer = null; - protected View shadowView = null; + public static class ActionBarMenuOnItemClick { + public void onItemClick(int id) { + + } + + public boolean canOpenMenu() { + return true; + } + } + + private static boolean withStatusBar = Build.VERSION.SDK_INT >= 21; + + private FrameLayout titleFrameLayout; + private ImageView backButtonImageView; + private TextView titleTextView; + private TextView subTitleTextView; + private ActionBarMenu menu; + private ActionBarMenu actionMode; + private View actionOverlay; + protected boolean isSearchFieldVisible; + protected int itemsBackgroundResourceId; private boolean isBackOverlayVisible; + protected BaseFragment parentFragment; + public ActionBarMenuOnItemClick actionBarMenuOnItemClick; + private float alphaEx = 1; + private int extraHeight; public ActionBar(Context context) { super(context); - createComponents(); - } - - public ActionBar(Context context, AttributeSet attrs) { - super(context, attrs); - createComponents(); - } - - public ActionBar(Context context, AttributeSet attrs, int defStyleAttr) { - super(context, attrs, defStyleAttr); - createComponents(); - } - - public void createComponents() { - shadowView = new View(getContext()); - addView(shadowView); - shadowView.setVisibility(INVISIBLE); - ViewGroup.LayoutParams layoutParams = shadowView.getLayoutParams(); - layoutParams.width = AndroidUtilities.dp(2); - layoutParams.height = LayoutParams.MATCH_PARENT; - shadowView.setLayoutParams(layoutParams); - shadowView.setBackgroundResource(R.drawable.shadow); - } - - public ActionBarLayer createLayer() { - return new ActionBarLayer(getContext(), this); - } - - public void detachActionBarLayer(ActionBarLayer layer) { - if (layer == null) { - return; - } - removeView(layer); - if (currentLayer == layer) { - currentLayer = null; - } - } - - public void setCurrentActionBarLayer(ActionBarLayer layer) { - if (layer == null || layer.getParent() != null) { - return; - } - if (currentLayer != null) { - removeView(currentLayer); - } - currentLayer = layer; - addView(layer); - FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams)layer.getLayoutParams(); - layoutParams.width = LayoutParams.MATCH_PARENT; - layoutParams.height = LayoutParams.MATCH_PARENT; + titleFrameLayout = new FrameLayout(context); + addView(titleFrameLayout); + FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams)titleFrameLayout.getLayoutParams(); + layoutParams.width = LayoutParams.WRAP_CONTENT; + layoutParams.height = LayoutParams.FILL_PARENT; layoutParams.gravity = Gravity.TOP | Gravity.LEFT; - layer.setLayoutParams(layoutParams); - currentLayer.setBackOverlayVisible(isBackOverlayVisible); - layer.setAlphaEx(1); - } + if (withStatusBar) { + layoutParams.topMargin = AndroidUtilities.statusBarHeight; + } + titleFrameLayout.setLayoutParams(layoutParams); + titleFrameLayout.setPadding(0, 0, AndroidUtilities.dp(4), 0); + titleFrameLayout.setEnabled(false); - public void setBackOverlayVisible(boolean visible) { - isBackOverlayVisible = visible; - if (currentLayer != null) { - currentLayer.setBackOverlayVisible(visible); - } - if (previousLayer != null) { - previousLayer.setBackOverlayVisible(visible); - } - } - - public void prepareForMoving(ActionBarLayer layer) { - if (currentLayer == null || layer == null) { - return; - } - previousLayer = layer; - ViewGroup parent = (ViewGroup) previousLayer.getParent(); - if (parent != null) { - parent.removeView(previousLayer); - } - this.addView(previousLayer, 0); - ViewGroup.LayoutParams layoutParams = layer.getLayoutParams(); - layoutParams.width = LayoutParams.MATCH_PARENT; - layoutParams.height = LayoutParams.MATCH_PARENT; - layer.setLayoutParams(layoutParams); - ViewProxy.setX(shadowView, -AndroidUtilities.dp(2)); - shadowView.setVisibility(VISIBLE); - previousLayer.setBackOverlayVisible(isBackOverlayVisible); - } - - public void stopMoving(boolean backAnimation) { - if (currentLayer == null) { - return; - } - - if (!backAnimation) { - removeView(currentLayer); - currentLayer = previousLayer; - currentLayer.setAlphaEx(1); - previousLayer = null; - } else { - removeView(previousLayer); - previousLayer = null; - } - shadowView.setVisibility(INVISIBLE); - ViewProxy.setX(currentLayer, 0); - } - - public void moveActionBarByX(int dx) { - if (currentLayer == null) { - return; - } - ViewProxy.setX(currentLayer, dx); - ViewProxy.setX(shadowView, dx - AndroidUtilities.dp(2)); - if (dx != 0) { - if (previousLayer != null) { - previousLayer.setAlphaEx(Math.min(1, (float) dx / (float) currentLayer.getMeasuredWidth())); + backButtonImageView = new ImageView(getContext()); + titleFrameLayout.addView(backButtonImageView); + backButtonImageView.setVisibility(VISIBLE); + backButtonImageView.setScaleType(ImageView.ScaleType.CENTER); + backButtonImageView.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + if (isSearchFieldVisible) { + closeSearchField(); + return; + } + if (actionBarMenuOnItemClick != null) { + actionBarMenuOnItemClick.onItemClick(-1); + } } - } else { - if (previousLayer != null) { - previousLayer.setAlphaEx(0); - } - currentLayer.setAlphaEx(1); + }); + } + + private void positionBackImage(int height) { + if (backButtonImageView != null) { + LayoutParams layoutParams = (LayoutParams)backButtonImageView.getLayoutParams(); + layoutParams.width = AndroidUtilities.dp(54); + layoutParams.height = height; + layoutParams.gravity = Gravity.TOP | Gravity.LEFT; + backButtonImageView.setLayoutParams(layoutParams); } } + private void positionTitle(int width, int height) { + int offset = AndroidUtilities.dp(2); + if (!AndroidUtilities.isTablet() && getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { + offset = AndroidUtilities.dp(1); + } + int maxTextWidth = 0; + + LayoutParams layoutParams = null; + + if (titleTextView != null && titleTextView.getVisibility() == VISIBLE) { + if (!AndroidUtilities.isTablet() && getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { + titleTextView.setTextSize(18); + } else { + titleTextView.setTextSize(20); + } + + layoutParams = (LayoutParams) titleTextView.getLayoutParams(); + layoutParams.width = LayoutParams.WRAP_CONTENT; + layoutParams.height = LayoutParams.WRAP_CONTENT; + layoutParams.gravity = Gravity.TOP | Gravity.LEFT; + titleTextView.setLayoutParams(layoutParams); + titleTextView.measure(width, height); + maxTextWidth = titleTextView.getMeasuredWidth(); + } + if (subTitleTextView != null && subTitleTextView.getVisibility() == VISIBLE) { + if (!AndroidUtilities.isTablet() && getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { + subTitleTextView.setTextSize(14); + } else { + subTitleTextView.setTextSize(16); + } + + layoutParams = (LayoutParams) subTitleTextView.getLayoutParams(); + layoutParams.width = LayoutParams.WRAP_CONTENT; + layoutParams.height = LayoutParams.WRAP_CONTENT; + layoutParams.gravity = Gravity.TOP | Gravity.LEFT; + subTitleTextView.setLayoutParams(layoutParams); + subTitleTextView.measure(width, height); + maxTextWidth = Math.max(maxTextWidth, subTitleTextView.getMeasuredWidth()); + } + + int x = 0; + if (AndroidUtilities.isTablet()) { + x = AndroidUtilities.dp(80); + } else { + x = AndroidUtilities.dp(72); + } + + + if (menu != null) { + maxTextWidth = Math.min(maxTextWidth, width - menu.getMeasuredWidth() - AndroidUtilities.dp(16)); + } + + if (titleTextView != null && titleTextView.getVisibility() == VISIBLE) { + layoutParams = (LayoutParams) titleTextView.getLayoutParams(); + layoutParams.width = LayoutParams.MATCH_PARENT; + layoutParams.height = titleTextView.getMeasuredHeight(); + int y; + if (subTitleTextView != null && subTitleTextView.getVisibility() == VISIBLE) { + y = (height / 2 - titleTextView.getMeasuredHeight()) / 2 + offset; + } else { + y = (height - titleTextView.getMeasuredHeight()) / 2 - AndroidUtilities.dp(1); + } + layoutParams.setMargins(x, y, 0, 0); + titleTextView.setLayoutParams(layoutParams); + } + if (subTitleTextView != null && subTitleTextView.getVisibility() == VISIBLE) { + layoutParams = (LayoutParams) subTitleTextView.getLayoutParams(); + layoutParams.width = LayoutParams.MATCH_PARENT; + layoutParams.height = subTitleTextView.getMeasuredHeight(); + layoutParams.setMargins(x, height / 2 + (height / 2 - subTitleTextView.getMeasuredHeight()) / 2 - offset, 0, 0); + subTitleTextView.setLayoutParams(layoutParams); + } + + ViewGroup.LayoutParams layoutParams1 = titleFrameLayout.getLayoutParams(); + layoutParams1.width = x + maxTextWidth + (isSearchFieldVisible ? 0 : AndroidUtilities.dp(6)); + titleFrameLayout.setLayoutParams(layoutParams1); + } + + public void positionMenu(int width, int height) { + if (menu == null) { + return; + } + FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams)menu.getLayoutParams(); + layoutParams.width = isSearchFieldVisible ? LayoutParams.MATCH_PARENT : LayoutParams.WRAP_CONTENT; + layoutParams.height = height; + layoutParams.leftMargin = isSearchFieldVisible ? AndroidUtilities.dp(54) : 0; + if (withStatusBar) { + layoutParams.topMargin = AndroidUtilities.statusBarHeight; + } + menu.setLayoutParams(layoutParams); + menu.measure(width, height); + } + + public void setBackButtonDrawable(Drawable drawable) { + backButtonImageView.setImageDrawable(drawable); + } + + public void setBackButtonImage(int resource) { + backButtonImageView.setImageResource(resource); + } + + private void createSubtitleTextView() { + if (subTitleTextView != null) { + return; + } + subTitleTextView = new TextView(getContext()); + titleFrameLayout.addView(subTitleTextView); + subTitleTextView.setGravity(Gravity.LEFT); + subTitleTextView.setTextColor(0xffd7e8f7); + subTitleTextView.setSingleLine(true); + subTitleTextView.setLines(1); + subTitleTextView.setMaxLines(1); + subTitleTextView.setEllipsize(TextUtils.TruncateAt.END); + } + + public void setSubtitle(CharSequence value) { + if (value != null && subTitleTextView == null) { + createSubtitleTextView(); + } + if (subTitleTextView != null) { + subTitleTextView.setVisibility(value != null ? VISIBLE : GONE); + subTitleTextView.setText(value); + positionTitle(getMeasuredWidth(), getMeasuredHeight()); + } + } + + public void setSubTitleIcon(int resourceId, Drawable drawable, int padding) { + if ((resourceId != 0 || drawable != null) && subTitleTextView == null) { + createSubtitleTextView(); + positionTitle(getMeasuredWidth(), getMeasuredHeight()); + } + if (subTitleTextView != null) { + if (drawable != null) { + subTitleTextView.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null); + } else { + subTitleTextView.setCompoundDrawablesWithIntrinsicBounds(resourceId, 0, 0, 0); + } + subTitleTextView.setCompoundDrawablePadding(padding); + } + } + + private void createTitleTextView() { + if (titleTextView != null) { + return; + } + titleTextView = new TextView(getContext()); + titleTextView.setGravity(Gravity.LEFT); + titleTextView.setSingleLine(true); + titleTextView.setLines(1); + titleTextView.setMaxLines(1); + titleTextView.setEllipsize(TextUtils.TruncateAt.END); + titleFrameLayout.addView(titleTextView); + titleTextView.setTextColor(0xffffffff); + titleTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); + } + + public void setTitle(CharSequence value) { + if (value != null && titleTextView == null) { + createTitleTextView(); + } + if (titleTextView != null) { + titleTextView.setVisibility(value != null ? VISIBLE : GONE); + titleTextView.setText(value); + positionTitle(getMeasuredWidth(), getMeasuredHeight()); + } + } + + public void setTitleIcon(int resourceId, int padding) { + if (resourceId != 0 && titleTextView == null) { + createTitleTextView(); + positionTitle(getMeasuredWidth(), getMeasuredHeight()); + } + titleTextView.setCompoundDrawablesWithIntrinsicBounds(resourceId, 0, 0, 0); + titleTextView.setCompoundDrawablePadding(padding); + } + + public Drawable getSubTitleIcon() { + return subTitleTextView.getCompoundDrawables()[0]; + } + + public CharSequence getTitle() { + if (titleTextView == null) { + return null; + } + return titleTextView.getText(); + } + + public ActionBarMenu createMenu() { + if (menu != null) { + return menu; + } + menu = new ActionBarMenu(getContext(), this); + addView(menu); + FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams)menu.getLayoutParams(); + layoutParams.height = LayoutParams.FILL_PARENT; + layoutParams.width = LayoutParams.WRAP_CONTENT; + layoutParams.gravity = Gravity.RIGHT; + menu.setLayoutParams(layoutParams); + return menu; + } + + public void setActionBarMenuOnItemClick(ActionBarMenuOnItemClick listener) { + actionBarMenuOnItemClick = listener; + } + + public void setCustomView(int resourceId) { + LayoutInflater li = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); + View view = li.inflate(resourceId, null); + addView(view); + FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams)view.getLayoutParams(); + layoutParams.width = LayoutParams.FILL_PARENT; + layoutParams.height = LayoutParams.FILL_PARENT; + if (withStatusBar) { + layoutParams.topMargin = AndroidUtilities.statusBarHeight; + } + view.setLayoutParams(layoutParams); + } + + public ActionBarMenu createActionMode() { + if (actionMode != null) { + return actionMode; + } + actionMode = new ActionBarMenu(getContext(), this); + actionMode.setBackgroundResource(R.drawable.editheader); + addView(actionMode); + FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams)actionMode.getLayoutParams(); + layoutParams.height = LayoutParams.FILL_PARENT; + layoutParams.width = LayoutParams.FILL_PARENT; + layoutParams.gravity = Gravity.RIGHT; + if (withStatusBar) { + layoutParams.topMargin = AndroidUtilities.statusBarHeight; + } + actionMode.setLayoutParams(layoutParams); + actionMode.setVisibility(GONE); + return actionMode; + } + + public void showActionMode() { + if (actionMode == null) { + return; + } + actionMode.setVisibility(VISIBLE); + if (titleFrameLayout != null) { + titleFrameLayout.setVisibility(INVISIBLE); + } + if (menu != null) { + menu.setVisibility(INVISIBLE); + } + } + + public void hideActionMode() { + if (actionMode == null) { + return; + } + actionMode.setVisibility(GONE); + if (titleFrameLayout != null) { + titleFrameLayout.setVisibility(isSearchFieldVisible || actionOverlay == null || actionOverlay.getVisibility() == GONE ? VISIBLE : INVISIBLE); + } + if (menu != null) { + menu.setVisibility(VISIBLE); + } + } + + public boolean isActionModeShowed() { + return actionMode != null && actionMode.getVisibility() == VISIBLE; + } + + protected void onSearchFieldVisibilityChanged(boolean visible) { + isSearchFieldVisible = visible; + if (titleTextView != null) { + titleTextView.setVisibility(visible ? GONE : VISIBLE); + } + if (subTitleTextView != null) { + subTitleTextView.setVisibility(visible ? GONE : VISIBLE); + } + Drawable drawable = backButtonImageView.getDrawable(); + if (drawable != null && drawable instanceof MenuDrawable) { + ((MenuDrawable)drawable).setRotation(visible ? 1 : 0, true); + } + positionBackOverlay(getMeasuredWidth(), getMeasuredHeight()); + } + + public void closeSearchField() { + if (!isSearchFieldVisible || menu == null) { + return; + } + menu.closeSearchField(); + } + @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(AndroidUtilities.getCurrentActionBarHeight(), MeasureSpec.EXACTLY)); + int actionBarHeight = AndroidUtilities.getCurrentActionBarHeight(); + positionBackImage(actionBarHeight); + positionMenu(MeasureSpec.getSize(widthMeasureSpec), actionBarHeight); + positionTitle(MeasureSpec.getSize(widthMeasureSpec), actionBarHeight); + positionBackOverlay(MeasureSpec.getSize(widthMeasureSpec), actionBarHeight); + if (Build.VERSION.SDK_INT >= 21) { + actionBarHeight += AndroidUtilities.statusBarHeight; + } + super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(actionBarHeight + extraHeight, MeasureSpec.EXACTLY)); + } + + public void setAlphaEx(float alpha) { + alphaEx = alpha; + if (menu != null) { + ViewProxy.setAlpha(menu, alphaEx); + } + if (titleFrameLayout != null) { + ViewProxy.setAlpha(titleFrameLayout, alphaEx); + } + } + + public float getAlphaEx() { + return alphaEx; } public void onMenuButtonPressed() { - if (currentLayer != null) { - currentLayer.onMenuButtonPressed(); + if (menu != null) { + menu.onMenuButtonPressed(); } } -} + + protected void onPause() { + if (menu != null) { + menu.hideAllPopupMenus(); + } + } + + public void setBackOverlay(int resourceId) { + LayoutInflater li = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); + actionOverlay = li.inflate(resourceId, null); + addView(actionOverlay); + actionOverlay.setVisibility(GONE); + actionOverlay.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + if (actionBarMenuOnItemClick != null) { + actionBarMenuOnItemClick.onItemClick(-1); + } + } + }); + } + + public void setBackOverlayVisible(boolean visible) { + if (actionOverlay == null || parentFragment == null || parentFragment.parentLayout == null) { + return; + } + isBackOverlayVisible = visible; + if (visible) { + parentFragment.parentLayout.onOverlayShow(actionOverlay, parentFragment); + } + positionBackOverlay(getMeasuredWidth(), getMeasuredHeight()); + } + + public void setExtraHeight(int value) { + extraHeight = value; + } + + private void positionBackOverlay(int widthMeasureSpec, int heightMeasureSpec) { + if (actionOverlay == null) { + return; + } + titleFrameLayout.setVisibility(isSearchFieldVisible || actionOverlay == null || actionOverlay.getVisibility() == GONE ? VISIBLE : INVISIBLE); + actionOverlay.setVisibility(!isSearchFieldVisible && isBackOverlayVisible ? VISIBLE : GONE); + if (actionOverlay.getVisibility() == VISIBLE) { + MarginLayoutParams layoutParams = (MarginLayoutParams) actionOverlay.getLayoutParams(); + layoutParams.width = LayoutParams.WRAP_CONTENT; + layoutParams.height = LayoutParams.MATCH_PARENT; + actionOverlay.setLayoutParams(layoutParams); + actionOverlay.measure(widthMeasureSpec, heightMeasureSpec); + if (withStatusBar) { + layoutParams.topMargin = AndroidUtilities.statusBarHeight; + } + layoutParams.width = Math.min(actionOverlay.getMeasuredWidth() + AndroidUtilities.dp(4), widthMeasureSpec - (menu != null ? menu.getMeasuredWidth() : 0)); + actionOverlay.setLayoutParams(layoutParams); + } + } + + public void setItemsBackground(int resourceId) { + itemsBackgroundResourceId = resourceId; + backButtonImageView.setBackgroundResource(resourceId); + } + + @Override + public boolean onTouchEvent(MotionEvent event) { + super.onTouchEvent(event); + return true; + } +} \ No newline at end of file diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Views/ActionBar/ActionBarLayer.java b/TMessagesProj/src/main/java/org/telegram/ui/Views/ActionBar/ActionBarLayer.java deleted file mode 100644 index a2a83377..00000000 --- a/TMessagesProj/src/main/java/org/telegram/ui/Views/ActionBar/ActionBarLayer.java +++ /dev/null @@ -1,469 +0,0 @@ -/* - * This is the source code of Telegram for Android v. 1.4.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.ActionBar; - -import android.content.Context; -import android.content.res.Configuration; -import android.graphics.drawable.Drawable; -import android.text.TextUtils; -import android.util.AttributeSet; -import android.view.Gravity; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.FrameLayout; -import android.widget.ImageView; -import android.widget.TextView; - -import org.telegram.android.AndroidUtilities; -import org.telegram.messenger.R; -import org.telegram.ui.AnimationCompat.ViewProxy; - -public class ActionBarLayer extends FrameLayout { - - public static class ActionBarMenuOnItemClick { - public void onItemClick(int id) { - - } - - public boolean canOpenMenu() { - return true; - } - } - - private FrameLayout titleFrameLayout; - private ImageView backButtonImageView; - private TextView titleTextView; - private TextView subTitleTextView; - private ActionBarMenu menu; - private ActionBarMenu actionMode; - protected ActionBar parentActionBar; - private View actionOverlay; - protected boolean isSearchFieldVisible; - protected int itemsBackgroundResourceId; - private boolean isBackOverlayVisible; - protected BaseFragment parentFragment; - public ActionBarMenuOnItemClick actionBarMenuOnItemClick; - private float alphaEx = 1; - - public ActionBarLayer(Context context, ActionBar actionBar) { - super(context); - parentActionBar = actionBar; - titleFrameLayout = new FrameLayout(context); - addView(titleFrameLayout); - FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams)titleFrameLayout.getLayoutParams(); - layoutParams.width = LayoutParams.WRAP_CONTENT; - layoutParams.height = LayoutParams.FILL_PARENT; - layoutParams.gravity = Gravity.TOP | Gravity.LEFT; - titleFrameLayout.setLayoutParams(layoutParams); - titleFrameLayout.setPadding(0, 0, AndroidUtilities.dp(4), 0); - titleFrameLayout.setEnabled(false); - - backButtonImageView = new ImageView(getContext()); - titleFrameLayout.addView(backButtonImageView); - backButtonImageView.setVisibility(VISIBLE); - backButtonImageView.setScaleType(ImageView.ScaleType.CENTER); - backButtonImageView.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - if (isSearchFieldVisible) { - closeSearchField(); - return; - } - if (actionBarMenuOnItemClick != null) { - actionBarMenuOnItemClick.onItemClick(-1); - } - } - }); - } - - public ActionBarLayer(Context context) { - super(context); - } - - public ActionBarLayer(Context context, AttributeSet attrs) { - super(context, attrs); - } - - public ActionBarLayer(Context context, AttributeSet attrs, int defStyleAttr) { - super(context, attrs, defStyleAttr); - } - - private void positionBackImage(int height) { - if (backButtonImageView != null) { - LayoutParams layoutParams = (LayoutParams)backButtonImageView.getLayoutParams(); - layoutParams.width = AndroidUtilities.dp(54); - layoutParams.height = height; - layoutParams.gravity = Gravity.TOP | Gravity.LEFT; - backButtonImageView.setLayoutParams(layoutParams); - } - } - - private void positionTitle(int width, int height) { - int offset = AndroidUtilities.dp(2); - if (!AndroidUtilities.isTablet() && getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { - offset = AndroidUtilities.dp(1); - } - int maxTextWidth = 0; - - LayoutParams layoutParams = null; - - if (titleTextView != null && titleTextView.getVisibility() == VISIBLE) { - if (!AndroidUtilities.isTablet() && getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { - titleTextView.setTextSize(18); - } else { - titleTextView.setTextSize(20); - } - - layoutParams = (LayoutParams) titleTextView.getLayoutParams(); - layoutParams.width = LayoutParams.WRAP_CONTENT; - layoutParams.height = LayoutParams.WRAP_CONTENT; - layoutParams.gravity = Gravity.TOP | Gravity.LEFT; - titleTextView.setLayoutParams(layoutParams); - titleTextView.measure(width, height); - maxTextWidth = titleTextView.getMeasuredWidth(); - } - if (subTitleTextView != null && subTitleTextView.getVisibility() == VISIBLE) { - if (!AndroidUtilities.isTablet() && getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { - subTitleTextView.setTextSize(14); - } else { - subTitleTextView.setTextSize(16); - } - - layoutParams = (LayoutParams) subTitleTextView.getLayoutParams(); - layoutParams.width = LayoutParams.WRAP_CONTENT; - layoutParams.height = LayoutParams.WRAP_CONTENT; - layoutParams.gravity = Gravity.TOP | Gravity.LEFT; - subTitleTextView.setLayoutParams(layoutParams); - subTitleTextView.measure(width, height); - maxTextWidth = Math.max(maxTextWidth, subTitleTextView.getMeasuredWidth()); - } - - int x = 0; - if (AndroidUtilities.isTablet()) { - x = AndroidUtilities.dp(80); - } else { - x = AndroidUtilities.dp(72); - } - - - if (menu != null) { - maxTextWidth = Math.min(maxTextWidth, width - menu.getMeasuredWidth() - AndroidUtilities.dp(16)); - } - - if (titleTextView != null && titleTextView.getVisibility() == VISIBLE) { - layoutParams = (LayoutParams) titleTextView.getLayoutParams(); - layoutParams.width = LayoutParams.MATCH_PARENT; - layoutParams.height = titleTextView.getMeasuredHeight(); - int y; - if (subTitleTextView != null && subTitleTextView.getVisibility() == VISIBLE) { - y = (height / 2 - titleTextView.getMeasuredHeight()) / 2 + offset; - } else { - y = (height - titleTextView.getMeasuredHeight()) / 2 - AndroidUtilities.dp(1); - } - layoutParams.setMargins(x, y, 0, 0); - titleTextView.setLayoutParams(layoutParams); - } - if (subTitleTextView != null && subTitleTextView.getVisibility() == VISIBLE) { - layoutParams = (LayoutParams) subTitleTextView.getLayoutParams(); - layoutParams.width = LayoutParams.MATCH_PARENT; - layoutParams.height = subTitleTextView.getMeasuredHeight(); - layoutParams.setMargins(x, height / 2 + (height / 2 - subTitleTextView.getMeasuredHeight()) / 2 - offset, 0, 0); - subTitleTextView.setLayoutParams(layoutParams); - } - - ViewGroup.LayoutParams layoutParams1 = titleFrameLayout.getLayoutParams(); - layoutParams1.width = x + maxTextWidth + (isSearchFieldVisible ? 0 : AndroidUtilities.dp(6)); - titleFrameLayout.setLayoutParams(layoutParams1); - } - - public void positionMenu(int width, int height) { - if (menu == null) { - return; - } - FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams)menu.getLayoutParams(); - layoutParams.width = isSearchFieldVisible ? LayoutParams.MATCH_PARENT : LayoutParams.WRAP_CONTENT; - layoutParams.leftMargin = isSearchFieldVisible ? AndroidUtilities.dp(54) : 0; - menu.setLayoutParams(layoutParams); - menu.measure(width, height); - } - - public void setBackButtonDrawable(Drawable drawable) { - backButtonImageView.setImageDrawable(drawable); - } - - public void setBackButtonImage(int resource) { - backButtonImageView.setImageResource(resource); - } - - private void createSubtitleTextView() { - if (subTitleTextView != null) { - return; - } - subTitleTextView = new TextView(getContext()); - titleFrameLayout.addView(subTitleTextView); - subTitleTextView.setGravity(Gravity.LEFT); - subTitleTextView.setTextColor(0xffd7e8f7); - subTitleTextView.setSingleLine(true); - subTitleTextView.setLines(1); - subTitleTextView.setMaxLines(1); - subTitleTextView.setEllipsize(TextUtils.TruncateAt.END); - } - - public void setSubtitle(CharSequence value) { - if (value != null && subTitleTextView == null) { - createSubtitleTextView(); - } - if (subTitleTextView != null) { - subTitleTextView.setVisibility(value != null ? VISIBLE : GONE); - subTitleTextView.setText(value); - positionTitle(getMeasuredWidth(), getMeasuredHeight()); - } - } - - public void setSubTitleIcon(int resourceId, Drawable drawable, int padding) { - if ((resourceId != 0 || drawable != null) && subTitleTextView == null) { - createSubtitleTextView(); - positionTitle(getMeasuredWidth(), getMeasuredHeight()); - } - if (subTitleTextView != null) { - if (drawable != null) { - subTitleTextView.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null); - } else { - subTitleTextView.setCompoundDrawablesWithIntrinsicBounds(resourceId, 0, 0, 0); - } - subTitleTextView.setCompoundDrawablePadding(padding); - } - } - - private void createTitleTextView() { - if (titleTextView != null) { - return; - } - titleTextView = new TextView(getContext()); - titleTextView.setGravity(Gravity.LEFT); - titleTextView.setSingleLine(true); - titleTextView.setLines(1); - titleTextView.setMaxLines(1); - titleTextView.setEllipsize(TextUtils.TruncateAt.END); - titleFrameLayout.addView(titleTextView); - titleTextView.setTextColor(0xffffffff); - titleTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); - } - - public void setTitle(CharSequence value) { - if (value != null && titleTextView == null) { - createTitleTextView(); - } - if (titleTextView != null) { - titleTextView.setVisibility(value != null ? VISIBLE : GONE); - titleTextView.setText(value); - positionTitle(getMeasuredWidth(), getMeasuredHeight()); - } - } - - public void setTitleIcon(int resourceId, int padding) { - if (resourceId != 0 && titleTextView == null) { - createTitleTextView(); - positionTitle(getMeasuredWidth(), getMeasuredHeight()); - } - titleTextView.setCompoundDrawablesWithIntrinsicBounds(resourceId, 0, 0, 0); - titleTextView.setCompoundDrawablePadding(padding); - } - - public Drawable getSubTitleIcon() { - return subTitleTextView.getCompoundDrawables()[0]; - } - - public CharSequence getTitle() { - if (titleTextView == null) { - return null; - } - return titleTextView.getText(); - } - - public ActionBarMenu createMenu() { - if (menu != null) { - return menu; - } - menu = new ActionBarMenu(getContext(), parentActionBar, this); - addView(menu); - FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams)menu.getLayoutParams(); - layoutParams.height = LayoutParams.FILL_PARENT; - layoutParams.width = LayoutParams.WRAP_CONTENT; - layoutParams.gravity = Gravity.RIGHT; - menu.setLayoutParams(layoutParams); - return menu; - } - - public void onDestroy() { - parentActionBar.detachActionBarLayer(this); - } - - public void setActionBarMenuOnItemClick(ActionBarMenuOnItemClick listener) { - actionBarMenuOnItemClick = listener; - } - - public void setCustomView(int resourceId) { - LayoutInflater li = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); - View view = li.inflate(resourceId, null); - addView(view); - } - - public ActionBarMenu createActionMode() { - if (actionMode != null) { - return actionMode; - } - actionMode = new ActionBarMenu(getContext(), parentActionBar, this); - actionMode.setBackgroundResource(R.drawable.editheader); - addView(actionMode); - FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams)actionMode.getLayoutParams(); - layoutParams.height = LayoutParams.FILL_PARENT; - layoutParams.width = LayoutParams.FILL_PARENT; - layoutParams.gravity = Gravity.RIGHT; - actionMode.setLayoutParams(layoutParams); - actionMode.setVisibility(GONE); - return actionMode; - } - - public void showActionMode() { - if (actionMode == null) { - return; - } - actionMode.setVisibility(VISIBLE); - if (titleFrameLayout != null) { - titleFrameLayout.setVisibility(INVISIBLE); - } - if (menu != null) { - menu.setVisibility(INVISIBLE); - } - } - - public void hideActionMode() { - if (actionMode == null) { - return; - } - actionMode.setVisibility(GONE); - if (titleFrameLayout != null) { - titleFrameLayout.setVisibility(isSearchFieldVisible || actionOverlay == null || actionOverlay.getVisibility() == GONE ? VISIBLE : INVISIBLE); - } - if (menu != null) { - menu.setVisibility(VISIBLE); - } - } - - public boolean isActionModeShowed() { - return actionMode != null && actionMode.getVisibility() == VISIBLE; - } - - protected void onSearchFieldVisibilityChanged(boolean visible) { - isSearchFieldVisible = visible; - if (titleTextView != null) { - titleTextView.setVisibility(visible ? GONE : VISIBLE); - } - if (subTitleTextView != null) { - subTitleTextView.setVisibility(visible ? GONE : VISIBLE); - } - Drawable drawable = backButtonImageView.getDrawable(); - if (drawable != null && drawable instanceof MenuDrawable) { - ((MenuDrawable)drawable).setRotation(visible ? 1 : 0, true); - } - positionBackOverlay(getMeasuredWidth(), getMeasuredHeight()); - } - - public void closeSearchField() { - if (!isSearchFieldVisible || menu == null) { - return; - } - menu.closeSearchField(); - } - - @Override - protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - positionBackImage(MeasureSpec.getSize(heightMeasureSpec)); - positionMenu(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.getSize(heightMeasureSpec)); - positionTitle(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.getSize(heightMeasureSpec)); - positionBackOverlay(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.getSize(heightMeasureSpec)); - super.onMeasure(widthMeasureSpec, heightMeasureSpec); - } - - public void setAlphaEx(float alpha) { - alphaEx = alpha; - if (menu != null) { - ViewProxy.setAlpha(menu, alphaEx); - } - if (titleFrameLayout != null) { - ViewProxy.setAlpha(titleFrameLayout, alphaEx); - } - } - - public float getAlphaEx() { - return alphaEx; - } - - public void onMenuButtonPressed() { - if (menu != null) { - menu.onMenuButtonPressed(); - } - } - - protected void onPause() { - if (menu != null) { - menu.hideAllPopupMenus(); - } - } - - public void setBackOverlay(int resourceId) { - LayoutInflater li = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); - actionOverlay = li.inflate(resourceId, null); - addView(actionOverlay); - actionOverlay.setVisibility(GONE); - actionOverlay.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - if (actionBarMenuOnItemClick != null) { - actionBarMenuOnItemClick.onItemClick(-1); - } - } - }); - } - - public void setBackOverlayVisible(boolean visible) { - if (actionOverlay == null || parentFragment == null || parentFragment.parentLayout == null) { - return; - } - isBackOverlayVisible = visible; - if (visible) { - parentFragment.parentLayout.onOverlayShow(actionOverlay, parentFragment); - } - positionBackOverlay(getMeasuredWidth(), getMeasuredHeight()); - } - - private void positionBackOverlay(int widthMeasureSpec, int heightMeasureSpec) { - if (actionOverlay == null) { - return; - } - titleFrameLayout.setVisibility(isSearchFieldVisible || actionOverlay == null || actionOverlay.getVisibility() == GONE ? VISIBLE : INVISIBLE); - actionOverlay.setVisibility(!isSearchFieldVisible && isBackOverlayVisible ? VISIBLE : GONE); - if (actionOverlay.getVisibility() == VISIBLE) { - ViewGroup.LayoutParams layoutParams = actionOverlay.getLayoutParams(); - layoutParams.width = LayoutParams.WRAP_CONTENT; - layoutParams.height = LayoutParams.MATCH_PARENT; - actionOverlay.setLayoutParams(layoutParams); - actionOverlay.measure(widthMeasureSpec, heightMeasureSpec); - layoutParams.width = Math.min(actionOverlay.getMeasuredWidth() + AndroidUtilities.dp(4), widthMeasureSpec - (menu != null ? menu.getMeasuredWidth() : 0)); - actionOverlay.setLayoutParams(layoutParams); - } - } - - public void setItemsBackground(int resourceId) { - itemsBackgroundResourceId = resourceId; - backButtonImageView.setBackgroundResource(resourceId); - } -} \ No newline at end of file diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Views/ActionBar/ActionBarLayout.java b/TMessagesProj/src/main/java/org/telegram/ui/Views/ActionBar/ActionBarLayout.java index efbf3ee9..ca2ccad0 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Views/ActionBar/ActionBarLayout.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Views/ActionBar/ActionBarLayout.java @@ -11,6 +11,9 @@ package org.telegram.ui.Views.ActionBar; import android.app.Activity; import android.content.Context; import android.content.Intent; +import android.graphics.Canvas; +import android.graphics.Paint; +import android.graphics.drawable.Drawable; import android.os.Build; import android.os.Handler; import android.view.ActionMode; @@ -20,15 +23,13 @@ import android.view.MotionEvent; import android.view.VelocityTracker; import android.view.View; import android.view.ViewGroup; -import android.view.ViewTreeObserver; -import android.view.WindowManager; -import android.view.animation.Animation; -import android.view.animation.AnimationUtils; +import android.view.animation.AccelerateDecelerateInterpolator; +import android.view.animation.DecelerateInterpolator; import android.widget.FrameLayout; +import android.widget.LinearLayout; import org.telegram.android.AndroidUtilities; import org.telegram.android.NotificationCenter; -import org.telegram.messenger.FileLog; import org.telegram.messenger.R; import org.telegram.ui.AnimationCompat.AnimatorListenerAdapterProxy; import org.telegram.ui.AnimationCompat.AnimatorSetProxy; @@ -39,18 +40,6 @@ import java.util.ArrayList; public class ActionBarLayout extends FrameLayout { - private class FrameLayoutAnimationListener extends FrameLayout { - public FrameLayoutAnimationListener(Context context) { - super(context); - } - - @Override - protected void onAnimationEnd() { - super.onAnimationEnd(); - ActionBarLayout.this.onAnimationEndCheck(); - } - } - public static interface ActionBarLayoutDelegate { public abstract boolean onPreIme(); public abstract void onOverlayShow(View view, BaseFragment fragment); @@ -60,18 +49,35 @@ public class ActionBarLayout extends FrameLayout { public abstract void onRebuildAllFragments(ActionBarLayout layout); } - protected ActionBar actionBar; - private FrameLayoutAnimationListener containerView; - private FrameLayoutAnimationListener containerViewBack; - private View shadowView; - private DrawerLayoutContainer drawerLayoutContainer; + public class LinearLayoutContainer extends LinearLayout { - private Animation openAnimation; - private Animation closeAnimation; - private Animation alphaOpenAnimation; - private Animation alphaOpenAnimation2; - private Animation alphaCloseAnimation; - private Animation alphaCloseAnimation2; + public LinearLayoutContainer(Context context) { + super(context); + setOrientation(VERTICAL); + } + + /*@Override + protected boolean drawChild(Canvas canvas, View child, long drawingTime) { + int saveCount = canvas.save(); + canvas.clipRect(0, 0, getWidth(), getHeight()); + boolean result = super.drawChild(canvas, child, drawingTime); + canvas.restoreToCount(saveCount); + return result; + }*/ + } + + private static Drawable headerShadowDrawable; + private static Drawable layerShadowDrawable; + private static Paint scrimPaint; + + private LinearLayoutContainer containerView; + private LinearLayoutContainer containerViewBack; + private DrawerLayoutContainer drawerLayoutContainer; + private ActionBar currentActionBar; + + private AnimatorSetProxy currentAnimation; + + public float innerTranslationX; private boolean maybeStartTracking = false; protected boolean startedTracking = false; @@ -96,71 +102,72 @@ public class ActionBarLayout extends FrameLayout { public ActionBarLayout(Context context) { super(context); - parentActivity = (Activity)context; - try { - openAnimation = AnimationUtils.loadAnimation(context, R.anim.scale_in); - closeAnimation = AnimationUtils.loadAnimation(context, R.anim.scale_out); - } catch (Exception e) { - FileLog.e("tmessages", e); + parentActivity = (Activity) context; + + if (layerShadowDrawable == null) { + layerShadowDrawable = getResources().getDrawable(R.drawable.layer_shadow); + scrimPaint = new Paint(); } } public void init(ArrayList stack) { fragmentsStack = stack; - containerViewBack = new FrameLayoutAnimationListener(parentActivity); + containerViewBack = new LinearLayoutContainer(parentActivity); + //containerViewBack.setOrientation(LinearLayout.VERTICAL); addView(containerViewBack); + FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) containerViewBack.getLayoutParams(); + layoutParams.width = LayoutParams.MATCH_PARENT; + layoutParams.height = LayoutParams.MATCH_PARENT; + layoutParams.gravity = Gravity.TOP | Gravity.LEFT; + containerViewBack.setLayoutParams(layoutParams); - containerView = new FrameLayoutAnimationListener(parentActivity); + containerView = new LinearLayoutContainer(parentActivity); + //containerView.setOrientation(LinearLayout.VERTICAL); addView(containerView); - - shadowView = new FrameLayout(parentActivity); - addView(shadowView); - shadowView.setBackgroundResource(R.drawable.shadow); - ViewGroup.LayoutParams layoutParams = shadowView.getLayoutParams(); - layoutParams.width = AndroidUtilities.dp(2); - layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT; - shadowView.setLayoutParams(layoutParams); - shadowView.setVisibility(View.INVISIBLE); - - actionBar = new ActionBar(parentActivity); - addView(actionBar); - layoutParams = actionBar.getLayoutParams(); - layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; - actionBar.setLayoutParams(layoutParams); + layoutParams = (FrameLayout.LayoutParams) containerView.getLayoutParams(); + layoutParams.width = LayoutParams.MATCH_PARENT; + layoutParams.height = LayoutParams.MATCH_PARENT; + layoutParams.gravity = Gravity.TOP | Gravity.LEFT; + containerView.setLayoutParams(layoutParams); for (BaseFragment fragment : fragmentsStack) { fragment.setParentLayout(this); } - - needLayout(); } @Override public void onConfigurationChanged(android.content.res.Configuration newConfig) { super.onConfigurationChanged(newConfig); - fixLayout(); if (!fragmentsStack.isEmpty()) { BaseFragment lastFragment = fragmentsStack.get(fragmentsStack.size() - 1); lastFragment.onConfigurationChanged(newConfig); } } + public void setInnerTranslationX(float value) { + innerTranslationX = value; + invalidate(); + } + + public float getInnerTranslationX() { + return innerTranslationX; + } + public void onResume() { - fixLayout(); if (transitionAnimationInProgress) { + if (currentAnimation != null) { + currentAnimation.cancel(); + currentAnimation = null; + } if (onCloseAnimationEndRunnable != null) { - closeAnimation.cancel(); onCloseAnimationEnd(false); } else if (onOpenAnimationEndRunnable != null) { - openAnimation.cancel(); onOpenAnimationEnd(false); } } if (!fragmentsStack.isEmpty()) { BaseFragment lastFragment = fragmentsStack.get(fragmentsStack.size() - 1); lastFragment.onResume(); - - actionBar.setCurrentActionBarLayer(lastFragment.actionBarLayer); } } @@ -191,9 +198,39 @@ public class ActionBarLayout extends FrameLayout { } @Override - protected void onAnimationEnd() { - super.onAnimationEnd(); - onAnimationEndCheck(); + protected boolean drawChild(Canvas canvas, View child, long drawingTime) { + int width = getWidth(); + int translationX = (int) innerTranslationX; + int clipLeft = 0; + int clipRight = width; + + if (child == containerViewBack) { + clipRight = translationX; + } else if (child == containerView) { + clipLeft = translationX; + } + + final int restoreCount = canvas.save(); + if (!transitionAnimationInProgress) { + canvas.clipRect(clipLeft, 0, clipRight, getHeight()); + } + final boolean result = super.drawChild(canvas, child, drawingTime); + canvas.restoreToCount(restoreCount); + + if (translationX != 0) { + if (child == containerView) { + final float alpha = Math.max(0, Math.min((width - translationX) / (float) AndroidUtilities.dp(20), 1.0f)); + layerShadowDrawable.setBounds(translationX - layerShadowDrawable.getIntrinsicWidth(), child.getTop(), translationX, child.getBottom()); + layerShadowDrawable.setAlpha((int) (0xff * alpha)); + layerShadowDrawable.draw(canvas); + } else if (child == containerViewBack) { + final float opacity = Math.min(0.8f, (width - translationX) / (float)width); + scrimPaint.setColor((int) (((0x99000000 & 0xff000000) >>> 24) * opacity) << 24); + canvas.drawRect(clipLeft, 0, clipRight, getHeight(), scrimPaint); + } + } + + return result; } public void setDelegate(ActionBarLayoutDelegate delegate) { @@ -208,15 +245,11 @@ public class ActionBarLayout extends FrameLayout { lastFragment.setParentLayout(null); fragmentsStack.remove(fragmentsStack.size() - 1); - FrameLayoutAnimationListener temp = containerView; + LinearLayoutContainer temp = containerView; containerView = containerViewBack; containerViewBack = temp; - ViewGroup parent = (ViewGroup)containerView.getParent(); - parent.bringChildToFront(containerView); - parent.bringChildToFront(shadowView); - parent.bringChildToFront(actionBar); - //parent.removeViewInLayout(containerView); - //parent.addView(containerView, 1); + bringChildToFront(containerView); + lastFragment = fragmentsStack.get(fragmentsStack.size() - 1); lastFragment.onResume(); } else { @@ -228,6 +261,12 @@ public class ActionBarLayout extends FrameLayout { parent.removeView(lastFragment.fragmentView); } } + if (lastFragment.needAddActionBar() && lastFragment.actionBar != null) { + ViewGroup parent = (ViewGroup) lastFragment.actionBar.getParent(); + if (parent != null) { + parent.removeView(lastFragment.actionBar); + } + } } containerViewBack.setVisibility(View.GONE); AndroidUtilities.unlockOrientation(parentActivity); @@ -236,26 +275,28 @@ public class ActionBarLayout extends FrameLayout { ViewProxy.setTranslationX(containerView, 0); ViewProxy.setTranslationX(containerViewBack, 0); - actionBar.stopMoving(backAnimation); - shadowView.setVisibility(View.INVISIBLE); - ViewProxy.setTranslationX(shadowView, -AndroidUtilities.dp(2)); + setInnerTranslationX(0); } private void prepareForMoving(MotionEvent ev) { maybeStartTracking = false; startedTracking = true; startedTrackingX = (int) ev.getX(); - shadowView.setVisibility(View.VISIBLE); - ViewProxy.setTranslationX(shadowView, -AndroidUtilities.dp(2)); containerViewBack.setVisibility(View.VISIBLE); beginTrackingSent = false; BaseFragment lastFragment = fragmentsStack.get(fragmentsStack.size() - 2); - actionBar.prepareForMoving(lastFragment.actionBarLayer); View fragmentView = lastFragment.createView(parentActivity.getLayoutInflater(), null); - ViewGroup parentView = (ViewGroup)fragmentView.getParent(); - if (parentView != null) { - parentView.removeView(fragmentView); + ViewGroup parent = (ViewGroup) fragmentView.getParent(); + if (parent != null) { + parent.removeView(fragmentView); + } + if (lastFragment.needAddActionBar() && lastFragment.actionBar != null) { + parent = (ViewGroup) lastFragment.actionBar.getParent(); + if (parent != null) { + parent.removeView(lastFragment.actionBar); + } + containerViewBack.addView(lastFragment.actionBar); } containerViewBack.addView(fragmentView); ViewGroup.LayoutParams layoutParams = fragmentView.getLayoutParams(); @@ -271,7 +312,7 @@ public class ActionBarLayout extends FrameLayout { } public boolean onTouchEvent(MotionEvent ev) { - if(!checkTransitionAnimation() && !inActionMode && !animationInProgress) { + if (!checkTransitionAnimation() && !inActionMode && !animationInProgress) { if (fragmentsStack.size() > 1) { if (ev != null && ev.getAction() == MotionEvent.ACTION_DOWN && !startedTracking && !maybeStartTracking) { BaseFragment currentFragment = fragmentsStack.get(fragmentsStack.size() - 1); @@ -303,9 +344,8 @@ public class ActionBarLayout extends FrameLayout { currentFragment.onBeginSlide(); beginTrackingSent = true; } - actionBar.moveActionBarByX(dx); ViewProxy.setTranslationX(containerView, dx); - ViewProxy.setTranslationX(shadowView, dx - AndroidUtilities.dp(2)); + setInnerTranslationX(dx); } } else if (ev != null && ev.getPointerId(0) == startedTrackingPointerId && (ev.getAction() == MotionEvent.ACTION_CANCEL || ev.getAction() == MotionEvent.ACTION_UP || ev.getAction() == MotionEvent.ACTION_POINTER_UP)) { if (velocityTracker == null) { @@ -318,8 +358,8 @@ public class ActionBarLayout extends FrameLayout { if (velX >= 3500 && velX > velY) { prepareForMoving(ev); if (!beginTrackingSent) { - if (((Activity)getContext()).getCurrentFocus() != null) { - AndroidUtilities.hideKeyboard(((Activity)getContext()).getCurrentFocus()); + if (((Activity) getContext()).getCurrentFocus() != null) { + AndroidUtilities.hideKeyboard(((Activity) getContext()).getCurrentFocus()); } beginTrackingSent = true; } @@ -336,19 +376,13 @@ public class ActionBarLayout extends FrameLayout { distToMove = containerView.getMeasuredWidth() - x; animatorSet.playTogether( ObjectAnimatorProxy.ofFloat(containerView, "x", containerView.getMeasuredWidth()), - ObjectAnimatorProxy.ofFloat(shadowView, "x", containerView.getMeasuredWidth() - AndroidUtilities.dp(2)), - ObjectAnimatorProxy.ofFloat(actionBar.currentLayer, "x", actionBar.getMeasuredWidth()), - ObjectAnimatorProxy.ofFloat(actionBar.shadowView, "x", actionBar.getMeasuredWidth() - AndroidUtilities.dp(2)), - ObjectAnimatorProxy.ofFloat(actionBar.previousLayer, "alphaEx", 1.0f) + ObjectAnimatorProxy.ofFloat(this, "innerTranslationX", (float)containerView.getMeasuredWidth()) ); } else { distToMove = x; animatorSet.playTogether( ObjectAnimatorProxy.ofFloat(containerView, "x", 0), - ObjectAnimatorProxy.ofFloat(shadowView, "x", -AndroidUtilities.dp(2)), - ObjectAnimatorProxy.ofFloat(actionBar.currentLayer, "x", 0), - ObjectAnimatorProxy.ofFloat(actionBar.shadowView, "x", -AndroidUtilities.dp(2)), - ObjectAnimatorProxy.ofFloat(actionBar.previousLayer, "alphaEx", 0) + ObjectAnimatorProxy.ofFloat(this, "innerTranslationX", 0.0f) ); } @@ -388,16 +422,12 @@ public class ActionBarLayout extends FrameLayout { return false; } - public ActionBar getActionBar() { - return actionBar; - } - public void onBackPressed() { if (startedTracking || checkTransitionAnimation() || fragmentsStack.isEmpty()) { return; } - if (actionBar.currentLayer != null && actionBar.currentLayer.isSearchFieldVisible) { - actionBar.currentLayer.closeSearchField(); + if (currentActionBar != null && currentActionBar.isSearchFieldVisible) { + currentActionBar.closeSearchField(); return; } BaseFragment lastFragment = fragmentsStack.get(fragmentsStack.size() - 1); @@ -414,65 +444,32 @@ public class ActionBarLayout extends FrameLayout { } } - private void onAnimationEndCheck() { + private void onAnimationEndCheck(boolean byCheck) { onCloseAnimationEnd(false); onOpenAnimationEnd(false); + if (currentAnimation != null) { + if (byCheck) { + currentAnimation.cancel(); + } + currentAnimation = null; + } + ViewProxy.setAlpha(this, 1.0f); + ViewProxy.setAlpha(containerView, 1.0f); + ViewProxy.setScaleX(containerView, 1.0f); + ViewProxy.setScaleY(containerView, 1.0f); + ViewProxy.setAlpha(containerViewBack, 1.0f); + ViewProxy.setScaleX(containerViewBack, 1.0f); + ViewProxy.setScaleY(containerViewBack, 1.0f); } public boolean checkTransitionAnimation() { if (transitionAnimationInProgress && transitionAnimationStartTime < System.currentTimeMillis() - 400) { transitionAnimationInProgress = false; - onAnimationEndCheck(); + onAnimationEndCheck(true); } return transitionAnimationInProgress; } - private void fixLayout() { - getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { - @Override - public void onGlobalLayout() { - needLayout(); - - if (Build.VERSION.SDK_INT < 16) { - getViewTreeObserver().removeGlobalOnLayoutListener(this); - } else { - getViewTreeObserver().removeOnGlobalLayoutListener(this); - } - } - }); - } - - public void needLayout() { - WindowManager manager = (WindowManager)parentActivity.getSystemService(Context.WINDOW_SERVICE); - int rotation = manager.getDefaultDisplay().getRotation(); - - int height = 0; - if (actionBar.getVisibility() == View.VISIBLE) { - height = AndroidUtilities.getCurrentActionBarHeight(); - } - - if (containerView != null) { - FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) containerView.getLayoutParams(); - if (layoutParams.topMargin != height) { - layoutParams.setMargins(0, height, 0, 0); - layoutParams.gravity = Gravity.TOP | Gravity.LEFT; - containerView.setLayoutParams(layoutParams); - } - } - if (containerViewBack != null) { - FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) containerViewBack.getLayoutParams(); - if (layoutParams.topMargin != height) { - layoutParams.setMargins(0, height, 0, 0); - layoutParams.gravity = Gravity.TOP | Gravity.LEFT; - containerViewBack.setLayoutParams(layoutParams); - } - } - } - - public ActionBar getInternalActionBar() { - return actionBar; - } - private void presentFragmentInternalRemoveOld(boolean removeLast, final BaseFragment fragment) { if (fragment == null) { return; @@ -489,6 +486,12 @@ public class ActionBarLayout extends FrameLayout { parent.removeView(fragment.fragmentView); } } + if (fragment.needAddActionBar() && fragment.actionBar != null) { + ViewGroup parent = (ViewGroup) fragment.actionBar.getParent(); + if (parent != null) { + parent.removeView(fragment.actionBar); + } + } } containerViewBack.setVisibility(View.GONE); } @@ -509,8 +512,8 @@ public class ActionBarLayout extends FrameLayout { AndroidUtilities.hideKeyboard(parentActivity.getCurrentFocus()); NotificationCenter.getInstance().postNotificationName(NotificationCenter.hideEmojiKeyboard); } - boolean needAnimation = openAnimation != null && !forceWithoutAnimation && parentActivity.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE).getBoolean("view_animations", true); - if (useAlphaAnimations && fragmentsStack.size() == 0 && alphaOpenAnimation == null) { + boolean needAnimation = Build.VERSION.SDK_INT > 10 && !forceWithoutAnimation && parentActivity.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE).getBoolean("view_animations", true); + if (useAlphaAnimations && fragmentsStack.size() == 0) { needAnimation = false; } @@ -518,6 +521,9 @@ public class ActionBarLayout extends FrameLayout { fragment.setParentLayout(this); View fragmentView = fragment.createView(parentActivity.getLayoutInflater(), null); + if (fragment.needAddActionBar() && fragment.actionBar != null) { + containerViewBack.addView(fragment.actionBar); + } containerViewBack.addView(fragmentView); ViewGroup.LayoutParams layoutParams = fragmentView.getLayoutParams(); layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; @@ -525,21 +531,17 @@ public class ActionBarLayout extends FrameLayout { fragmentView.setLayoutParams(layoutParams); fragmentsStack.add(fragment); fragment.onResume(); - actionBar.setCurrentActionBarLayer(fragment.actionBarLayer); + currentActionBar = fragment.actionBar; if (fragmentView.getBackground() == null) { fragmentView.setBackgroundColor(0xffffffff); } - FrameLayoutAnimationListener temp = containerView; + LinearLayoutContainer temp = containerView; containerView = containerViewBack; containerViewBack = temp; containerView.setVisibility(View.VISIBLE); - ViewGroup parent = (ViewGroup)containerView.getParent(); - //parent.removeView(containerView); - //parent.addView(containerView, 1); - parent.bringChildToFront(containerView); - parent.bringChildToFront(shadowView); - parent.bringChildToFront(actionBar); + + bringChildToFront(containerView); if (!needAnimation) { presentFragmentInternalRemoveOld(removeLast, currentFragment); @@ -551,11 +553,27 @@ public class ActionBarLayout extends FrameLayout { if (needAnimation) { if (useAlphaAnimations && fragmentsStack.size() == 1) { presentFragmentInternalRemoveOld(removeLast, currentFragment); - startAnimation(alphaOpenAnimation); + AnimatorSetProxy animatorSet = new AnimatorSetProxy(); + animatorSet.playTogether(); + + ArrayList animators = new ArrayList(); + animators.add(ObjectAnimatorProxy.ofFloat(this, "alpha", 0.0f, 1.0f)); if (backgroundView != null) { backgroundView.setVisibility(VISIBLE); - backgroundView.startAnimation(alphaOpenAnimation2); + animators.add(ObjectAnimatorProxy.ofFloat(backgroundView, "alpha", 0.0f, 1.0f)); } + + currentAnimation = new AnimatorSetProxy(); + currentAnimation.playTogether(animators); + currentAnimation.setInterpolator(new AccelerateDecelerateInterpolator()); + currentAnimation.setDuration(200); + currentAnimation.addListener(new AnimatorListenerAdapterProxy() { + @Override + public void onAnimationEnd(Object animation) { + onAnimationEndCheck(false); + } + }); + currentAnimation.start(); } else { transitionAnimationStartTime = System.currentTimeMillis(); transitionAnimationInProgress = true; @@ -566,8 +584,20 @@ public class ActionBarLayout extends FrameLayout { fragment.onOpenAnimationEnd(); } }; - openAnimation.reset(); - containerView.startAnimation(openAnimation); + currentAnimation = new AnimatorSetProxy(); + currentAnimation.playTogether( + ObjectAnimatorProxy.ofFloat(containerView, "alpha", 0.0f, 1.0f), + ObjectAnimatorProxy.ofFloat(containerView, "scaleX", 0.8f, 1.0f), + ObjectAnimatorProxy.ofFloat(containerView, "scaleY", 0.8f, 1.0f)); + currentAnimation.setInterpolator(new DecelerateInterpolator(1.5f)); + currentAnimation.setDuration(200); + currentAnimation.addListener(new AnimatorListenerAdapterProxy() { + @Override + public void onAnimationEnd(Object animation) { + onAnimationEndCheck(false); + } + }); + currentAnimation.start(); } } else { fragment.onOpenAnimationEnd(); @@ -598,9 +628,7 @@ public class ActionBarLayout extends FrameLayout { fragment.setParentLayout(null); fragmentsStack.remove(fragment); containerViewBack.setVisibility(View.GONE); - ViewGroup parent = (ViewGroup)containerView.getParent(); - parent.removeView(containerViewBack); - parent.addView(containerViewBack, 0); + bringChildToFront(containerView); } public void closeLastFragment(boolean animated) { @@ -610,8 +638,8 @@ public class ActionBarLayout extends FrameLayout { if (parentActivity.getCurrentFocus() != null) { AndroidUtilities.hideKeyboard(parentActivity.getCurrentFocus()); } - boolean needAnimation = animated && closeAnimation != null && parentActivity.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE).getBoolean("view_animations", true); - if (useAlphaAnimations && fragmentsStack.size() == 1 && alphaCloseAnimation == null) { + boolean needAnimation = Build.VERSION.SDK_INT > 10 && animated && parentActivity.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE).getBoolean("view_animations", true); + if (useAlphaAnimations && fragmentsStack.size() == 1) { needAnimation = false; } final BaseFragment currentFragment = fragmentsStack.get(fragmentsStack.size() - 1); @@ -621,20 +649,23 @@ public class ActionBarLayout extends FrameLayout { } if (previousFragment != null) { - FrameLayoutAnimationListener temp = containerView; + LinearLayoutContainer temp = containerView; containerView = containerViewBack; containerViewBack = temp; containerView.setVisibility(View.VISIBLE); previousFragment.setParentLayout(this); View fragmentView = previousFragment.createView(parentActivity.getLayoutInflater(), null); + if (previousFragment.needAddActionBar() && previousFragment.actionBar != null) { + containerView.addView(previousFragment.actionBar); + } containerView.addView(fragmentView); ViewGroup.LayoutParams layoutParams = fragmentView.getLayoutParams(); layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT; fragmentView.setLayoutParams(layoutParams); previousFragment.onResume(); - actionBar.setCurrentActionBarLayer(previousFragment.actionBarLayer); + currentActionBar = previousFragment.actionBar; if (fragmentView.getBackground() == null) { fragmentView.setBackgroundColor(0xffffffff); } @@ -646,25 +677,33 @@ public class ActionBarLayout extends FrameLayout { if (needAnimation) { transitionAnimationStartTime = System.currentTimeMillis(); transitionAnimationInProgress = true; - closeAnimation.reset(); onCloseAnimationEndRunnable = new Runnable() { @Override public void run() { closeLastFragmentInternalRemoveOld(currentFragment); } }; - containerViewBack.startAnimation(closeAnimation); + + currentAnimation = new AnimatorSetProxy(); + currentAnimation.playTogether( + ObjectAnimatorProxy.ofFloat(containerViewBack, "alpha", 1.0f, 0.0f), + ObjectAnimatorProxy.ofFloat(containerViewBack, "scaleX", 1.0f, 0.8f), + ObjectAnimatorProxy.ofFloat(containerViewBack, "scaleY", 1.0f, 0.8f)); + currentAnimation.setInterpolator(new DecelerateInterpolator(1.5f)); + currentAnimation.setDuration(200); + currentAnimation.addListener(new AnimatorListenerAdapterProxy() { + @Override + public void onAnimationEnd(Object animation) { + onAnimationEndCheck(false); + } + }); + currentAnimation.start(); } } else { if (needAnimation && useAlphaAnimations) { transitionAnimationStartTime = System.currentTimeMillis(); transitionAnimationInProgress = true; - alphaCloseAnimation.reset(); - alphaCloseAnimation2.reset(); - startAnimation(alphaCloseAnimation); - if (backgroundView != null) { - backgroundView.startAnimation(alphaCloseAnimation2); - } + onCloseAnimationEndRunnable = new Runnable() { @Override public void run() { @@ -675,6 +714,24 @@ public class ActionBarLayout extends FrameLayout { } } }; + + ArrayList animators = new ArrayList(); + animators.add(ObjectAnimatorProxy.ofFloat(this, "alpha", 1.0f, 0.0f)); + if (backgroundView != null) { + animators.add(ObjectAnimatorProxy.ofFloat(backgroundView, "alpha", 1.0f, 0.0f)); + } + + currentAnimation = new AnimatorSetProxy(); + currentAnimation.playTogether(animators); + currentAnimation.setInterpolator(new AccelerateDecelerateInterpolator()); + currentAnimation.setDuration(200); + currentAnimation.addListener(new AnimatorListenerAdapterProxy() { + @Override + public void onAnimationEnd(Object animation) { + onAnimationEndCheck(false); + } + }); + currentAnimation.start(); } else { removeFragmentFromStack(currentFragment); setVisibility(GONE); @@ -692,13 +749,16 @@ public class ActionBarLayout extends FrameLayout { BaseFragment previousFragment = fragmentsStack.get(fragmentsStack.size() - 1); previousFragment.setParentLayout(this); View fragmentView = previousFragment.createView(parentActivity.getLayoutInflater(), null); + if (previousFragment.needAddActionBar() && previousFragment.actionBar != null) { + containerView.addView(previousFragment.actionBar); + } containerView.addView(fragmentView); ViewGroup.LayoutParams layoutParams = fragmentView.getLayoutParams(); layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT; fragmentView.setLayoutParams(layoutParams); previousFragment.onResume(); - actionBar.setCurrentActionBarLayer(previousFragment.actionBarLayer); + currentActionBar = previousFragment.actionBar; if (fragmentView.getBackground() == null) { fragmentView.setBackgroundColor(0xffffffff); } @@ -728,19 +788,9 @@ public class ActionBarLayout extends FrameLayout { } } - public void showActionBar() { - actionBar.setVisibility(View.VISIBLE); - needLayout(); - } - - public void hideActionBar() { - actionBar.setVisibility(View.GONE); - needLayout(); - } - public boolean onKeyUp(int keyCode, KeyEvent event) { - if (keyCode == KeyEvent.KEYCODE_MENU && !checkTransitionAnimation() && !startedTracking) { - actionBar.onMenuButtonPressed(); + if (keyCode == KeyEvent.KEYCODE_MENU && !checkTransitionAnimation() && !startedTracking && currentActionBar != null) { + currentActionBar.onMenuButtonPressed(); } return super.onKeyUp(keyCode, event); } @@ -752,12 +802,16 @@ public class ActionBarLayout extends FrameLayout { } public void onActionModeStarted(ActionMode mode) { - hideActionBar(); + if (currentActionBar != null) { + currentActionBar.setVisibility(GONE); + } inActionMode = true; } public void onActionModeFinished(ActionMode mode) { - showActionBar(); + if (currentActionBar != null) { + currentActionBar.setVisibility(VISIBLE); + } inActionMode = false; } @@ -802,11 +856,13 @@ public class ActionBarLayout extends FrameLayout { return; } if (transitionAnimationInProgress) { + if (currentAnimation != null) { + currentAnimation.cancel(); + currentAnimation = null; + } if (onCloseAnimationEndRunnable != null) { - closeAnimation.cancel(); onCloseAnimationEnd(false); } else if (onOpenAnimationEndRunnable != null) { - openAnimation.cancel(); onOpenAnimationEnd(false); } containerView.invalidate(); @@ -822,12 +878,6 @@ public class ActionBarLayout extends FrameLayout { public void setUseAlphaAnimations(boolean value) { useAlphaAnimations = value; - if (useAlphaAnimations) { - alphaOpenAnimation = AnimationUtils.loadAnimation(getContext(), R.anim.icon_anim_fade_in); - alphaOpenAnimation2 = AnimationUtils.loadAnimation(getContext(), R.anim.icon_anim_fade_in); - alphaCloseAnimation = AnimationUtils.loadAnimation(getContext(), R.anim.icon_anim_fade_out); - alphaCloseAnimation2 = AnimationUtils.loadAnimation(getContext(), R.anim.icon_anim_fade_out); - } } public void setBackgroundView(View view) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Views/ActionBar/ActionBarMenu.java b/TMessagesProj/src/main/java/org/telegram/ui/Views/ActionBar/ActionBarMenu.java index cbce74e2..fb2fd1ce 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Views/ActionBar/ActionBarMenu.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Views/ActionBar/ActionBarMenu.java @@ -20,14 +20,12 @@ import org.telegram.android.AndroidUtilities; public class ActionBarMenu extends LinearLayout { - private ActionBar parentActionBar; - private ActionBarLayer parentActionBarLayer; + protected ActionBar parentActionBar; - public ActionBarMenu(Context context, ActionBar actionBar, ActionBarLayer layer) { + public ActionBarMenu(Context context, ActionBar layer) { super(context); setOrientation(LinearLayout.HORIZONTAL); - parentActionBar = actionBar; - parentActionBarLayer = layer; + parentActionBar = layer; } public ActionBarMenu(Context context) { @@ -49,7 +47,7 @@ public class ActionBarMenu extends LinearLayout { addView(view); LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams)view.getLayoutParams(); layoutParams.height = FrameLayout.LayoutParams.FILL_PARENT; - view.setBackgroundResource(parentActionBarLayer.itemsBackgroundResourceId); + view.setBackgroundResource(parentActionBar.itemsBackgroundResourceId); view.setLayoutParams(layoutParams); view.setOnClickListener(new OnClickListener() { @Override @@ -61,11 +59,11 @@ public class ActionBarMenu extends LinearLayout { } public ActionBarMenuItem addItem(int id, int icon) { - return addItem(id, icon, parentActionBarLayer.itemsBackgroundResourceId); + return addItem(id, icon, parentActionBar.itemsBackgroundResourceId); } public ActionBarMenuItem addItem(int id, int icon, int backgroundResource) { - ActionBarMenuItem menuItem = new ActionBarMenuItem(getContext(), this, parentActionBar, backgroundResource); + ActionBarMenuItem menuItem = new ActionBarMenuItem(getContext(), this, backgroundResource); menuItem.setTag(id); menuItem.setScaleType(ImageView.ScaleType.CENTER); menuItem.setImageResource(icon); @@ -79,11 +77,11 @@ public class ActionBarMenu extends LinearLayout { public void onClick(View view) { ActionBarMenuItem item = (ActionBarMenuItem)view; if (item.hasSubMenu()) { - if (parentActionBarLayer.actionBarMenuOnItemClick.canOpenMenu()) { + if (parentActionBar.actionBarMenuOnItemClick.canOpenMenu()) { item.toggleSubMenu(); } } else if (item.isSearchField()) { - parentActionBarLayer.onSearchFieldVisibilityChanged(item.toggleSearch()); + parentActionBar.onSearchFieldVisibilityChanged(item.toggleSearch()); } else { onItemClick((Integer)view.getTag()); } @@ -102,8 +100,8 @@ public class ActionBarMenu extends LinearLayout { } public void onItemClick(int id) { - if (parentActionBarLayer.actionBarMenuOnItemClick != null) { - parentActionBarLayer.actionBarMenuOnItemClick.onItemClick(id); + if (parentActionBar.actionBarMenuOnItemClick != null) { + parentActionBar.actionBarMenuOnItemClick.onItemClick(id); } } @@ -132,7 +130,7 @@ public class ActionBarMenu extends LinearLayout { if (view instanceof ActionBarMenuItem) { ActionBarMenuItem item = (ActionBarMenuItem)view; if (item.isSearchField()) { - parentActionBarLayer.onSearchFieldVisibilityChanged(item.toggleSearch()); + parentActionBar.onSearchFieldVisibilityChanged(item.toggleSearch()); } } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Views/ActionBar/ActionBarMenuItem.java b/TMessagesProj/src/main/java/org/telegram/ui/Views/ActionBar/ActionBarMenuItem.java index 766a9a15..3ca42deb 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Views/ActionBar/ActionBarMenuItem.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Views/ActionBar/ActionBarMenuItem.java @@ -13,7 +13,6 @@ import android.graphics.Rect; import android.os.Build; import android.text.Editable; import android.text.TextWatcher; -import android.util.AttributeSet; import android.view.ActionMode; import android.view.ContextMenu; import android.view.Gravity; @@ -48,7 +47,6 @@ public class ActionBarMenuItem extends ImageView { private ActionBarPopupWindow.ActionBarPopupWindowLayout popupLayout; private ActionBarMenu parentMenu; private ActionBarPopupWindow popupWindow; - private ActionBar parentActionBar; private EditText searchField; private boolean isSearchField = false; private ActionBarMenuItemSearchListener listener; @@ -57,23 +55,10 @@ public class ActionBarMenuItem extends ImageView { private View selectedMenuView; private Runnable showMenuRunnable; - public ActionBarMenuItem(Context context, ActionBarMenu menu, ActionBar actionBar, int background) { + public ActionBarMenuItem(Context context, ActionBarMenu menu, int background) { super(context); setBackgroundResource(background); parentMenu = menu; - parentActionBar = actionBar; - } - - public ActionBarMenuItem(Context context) { - super(context); - } - - public ActionBarMenuItem(Context context, AttributeSet attrs) { - super(context, attrs); - } - - public ActionBarMenuItem(Context context, AttributeSet attrs, int defStyleAttr) { - super(context, attrs, defStyleAttr); } @Override @@ -254,10 +239,10 @@ public class ActionBarMenuItem extends ImageView { } popupWindow.setFocusable(true); if (popupLayout.getMeasuredWidth() == 0) { - popupWindow.showAsDropDown(this, parentActionBar.getMeasuredWidth() - popupLayout.getMeasuredWidth() - getLeft() - parentMenu.getLeft(), -getMeasuredHeight()); - popupWindow.update(this, parentActionBar.getMeasuredWidth() - popupLayout.getMeasuredWidth() - getLeft() - parentMenu.getLeft(), -getMeasuredHeight(), -1, -1); + popupWindow.showAsDropDown(this, parentMenu.parentActionBar.getMeasuredWidth() - popupLayout.getMeasuredWidth() - getLeft() - parentMenu.getLeft(), -getMeasuredHeight()); + popupWindow.update(this, parentMenu.parentActionBar.getMeasuredWidth() - popupLayout.getMeasuredWidth() - getLeft() - parentMenu.getLeft(), -getMeasuredHeight(), -1, -1); } else { - popupWindow.showAsDropDown(this, parentActionBar.getMeasuredWidth() - popupLayout.getMeasuredWidth() - getLeft() - parentMenu.getLeft(), -getMeasuredHeight()); + popupWindow.showAsDropDown(this, parentMenu.parentActionBar.getMeasuredWidth() - popupLayout.getMeasuredWidth() - getLeft() - parentMenu.getLeft(), -getMeasuredHeight()); } } @@ -402,10 +387,10 @@ public class ActionBarMenuItem extends ImageView { protected void onLayout(boolean changed, int left, int top, int right, int bottom) { super.onLayout(changed, left, top, right, bottom); if (popupWindow != null && popupWindow.isShowing()) { - int x = parentActionBar.getMeasuredWidth() - popupLayout.getMeasuredWidth() - getLeft() - parentMenu.getLeft(); + int x = parentMenu.parentActionBar.getMeasuredWidth() - popupLayout.getMeasuredWidth() - getLeft() - parentMenu.getLeft(); int y = -getMeasuredHeight(); FileLog.e("tmessages", "x = " + x + " y = " + y); - popupWindow.update(this, parentActionBar.getMeasuredWidth() - popupLayout.getMeasuredWidth() - getLeft() - parentMenu.getLeft(), -getMeasuredHeight(), -1, -1); + popupWindow.update(this, parentMenu.parentActionBar.getMeasuredWidth() - popupLayout.getMeasuredWidth() - getLeft() - parentMenu.getLeft(), -getMeasuredHeight(), -1, -1); } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Views/ActionBar/BaseFragment.java b/TMessagesProj/src/main/java/org/telegram/ui/Views/ActionBar/BaseFragment.java index 51e4b430..811f6488 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Views/ActionBar/BaseFragment.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Views/ActionBar/BaseFragment.java @@ -23,12 +23,13 @@ import org.telegram.messenger.R; public class BaseFragment { private boolean isFinished = false; + private AlertDialog visibleDialog = null; + protected View fragmentView; protected ActionBarLayout parentLayout; - protected ActionBarLayer actionBarLayer; + protected ActionBar actionBar; protected int classGuid = 0; protected Bundle arguments; - private AlertDialog visibleDialog = null; protected boolean swipeBackEnabled = true; public BaseFragment() { @@ -48,7 +49,7 @@ public class BaseFragment { return arguments; } - public void setParentLayout(ActionBarLayout layout) { + protected void setParentLayout(ActionBarLayout layout) { if (parentLayout != layout) { parentLayout = layout; if (fragmentView != null) { @@ -62,14 +63,21 @@ public class BaseFragment { } fragmentView = null; } - if (parentLayout != null) { - if (actionBarLayer != null) { - actionBarLayer.onDestroy(); + if (actionBar != null) { + ViewGroup parent = (ViewGroup) actionBar.getParent(); + if (parent != null) { + try { + parent.removeView(actionBar); + } catch (Exception e) { + FileLog.e("tmessages", e); + } } - actionBarLayer = parentLayout.getInternalActionBar().createLayer(); - actionBarLayer.parentFragment = this; - actionBarLayer.setBackgroundResource(R.color.header); - actionBarLayer.setItemsBackground(R.drawable.bar_selector); + } + if (parentLayout != null) { + actionBar = new ActionBar(parentLayout.getContext()); + actionBar.parentFragment = this; + actionBar.setBackgroundResource(R.color.header); + actionBar.setItemsBackground(R.drawable.bar_selector); } } } @@ -99,8 +107,8 @@ public class BaseFragment { public void onFragmentDestroy() { ConnectionsManager.getInstance().cancelRpcsForClassGuid(classGuid); isFinished = true; - if (actionBarLayer != null) { - actionBarLayer.setEnabled(false); + if (actionBar != null) { + actionBar.setEnabled(false); } } @@ -109,9 +117,9 @@ public class BaseFragment { } public void onPause() { - if (actionBarLayer != null) { - actionBarLayer.onPause(); - actionBarLayer.closeSearchField(); + if (actionBar != null) { + actionBar.onPause(); + actionBar.closeSearchField(); } try { if (visibleDialog != null && visibleDialog.isShowing()) { @@ -168,18 +176,6 @@ public class BaseFragment { } } - public void showActionBar() { - if (parentLayout != null) { - parentLayout.showActionBar(); - } - } - - public void hideActionBar() { - if (parentLayout != null) { - parentLayout.hideActionBar(); - } - } - public void onBeginSlide() { try { if (visibleDialog != null && visibleDialog.isShowing()) { @@ -189,8 +185,8 @@ public class BaseFragment { } catch (Exception e) { FileLog.e("tmessages", e); } - if (actionBarLayer != null) { - actionBarLayer.onPause(); + if (actionBar != null) { + actionBar.onPause(); } } @@ -202,6 +198,10 @@ public class BaseFragment { } + public boolean needAddActionBar() { + return true; + } + protected void showAlertDialog(AlertDialog.Builder builder) { if (parentLayout == null || parentLayout.checkTransitionAnimation() || parentLayout.animationInProgress || parentLayout.startedTracking) { return; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Views/ActionBar/DrawerLayoutContainer.java b/TMessagesProj/src/main/java/org/telegram/ui/Views/ActionBar/DrawerLayoutContainer.java index c1004411..d55b67c7 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Views/ActionBar/DrawerLayoutContainer.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Views/ActionBar/DrawerLayoutContainer.java @@ -46,7 +46,6 @@ public class DrawerLayoutContainer extends FrameLayout { private boolean beginTrackingSent; private AnimatorSetProxy currentAnimation = null; - private Paint statusBarPaint = new Paint(); private Paint scrimPaint = new Paint(); private Object lastInsets; @@ -100,7 +99,7 @@ public class DrawerLayoutContainer extends FrameLayout { child.dispatchApplyWindowInsets(wi); } - private void applyMarginInsets(MarginLayoutParams lp, Object insets, int drawerGravity) { + private void applyMarginInsets(MarginLayoutParams lp, Object insets, int drawerGravity, boolean topOnly) { WindowInsets wi = (WindowInsets) insets; if (drawerGravity == Gravity.LEFT) { wi = wi.replaceSystemWindowInsets(wi.getSystemWindowInsetLeft(), wi.getSystemWindowInsetTop(), 0, wi.getSystemWindowInsetBottom()); @@ -108,7 +107,7 @@ public class DrawerLayoutContainer extends FrameLayout { wi = wi.replaceSystemWindowInsets(0, wi.getSystemWindowInsetTop(), wi.getSystemWindowInsetRight(), wi.getSystemWindowInsetBottom()); } lp.leftMargin = wi.getSystemWindowInsetLeft(); - lp.topMargin = wi.getSystemWindowInsetTop(); + lp.topMargin = topOnly ? 0 : wi.getSystemWindowInsetTop(); lp.rightMargin = wi.getSystemWindowInsetRight(); lp.bottomMargin = wi.getSystemWindowInsetBottom(); } @@ -126,10 +125,6 @@ public class DrawerLayoutContainer extends FrameLayout { requestLayout(); } - public void setStatusBarColor(int color) { - statusBarPaint.setColor(color); - } - public void setDrawerLayout(View layout) { drawerLayout = layout; addView(drawerLayout); @@ -361,14 +356,6 @@ public class DrawerLayoutContainer extends FrameLayout { super.requestDisallowInterceptTouchEvent(disallowIntercept); } - @Override - protected void onDraw(Canvas canvas) { - super.onDraw(canvas); - if (Build.VERSION.SDK_INT >= 21) { - canvas.drawRect(0, 0, getWidth(), AndroidUtilities.statusBarHeight, statusBarPaint); - } - } - @Override protected void onLayout(boolean changed, int l, int t, int r, int b) { inLayout = true; @@ -410,7 +397,6 @@ public class DrawerLayoutContainer extends FrameLayout { final boolean applyInsets = lastInsets != null && Build.VERSION.SDK_INT >= 21; - int foundDrawers = 0; final int childCount = getChildCount(); for (int i = 0; i < childCount; i++) { final View child = getChildAt(i); @@ -425,7 +411,7 @@ public class DrawerLayoutContainer extends FrameLayout { if (child.getFitsSystemWindows()) { dispatchChildInsets(child, lastInsets, lp.gravity); } else { - applyMarginInsets(lp, lastInsets, lp.gravity); + applyMarginInsets(lp, lastInsets, lp.gravity, Build.VERSION.SDK_INT >= 21); } } @@ -471,7 +457,7 @@ public class DrawerLayoutContainer extends FrameLayout { scrimPaint.setColor((int) (((0x99000000 & 0xff000000) >>> 24) * scrimOpacity) << 24); canvas.drawRect(clipLeft, 0, clipRight, getHeight(), scrimPaint); } else if (shadowLeft != null) { - final float alpha = Math.max(0, Math.min((float) drawerPosition / AndroidUtilities.dp(20), 1.f)); + final float alpha = Math.max(0, Math.min((float) drawerPosition / AndroidUtilities.dp(20), 1.0f)); shadowLeft.setBounds(drawerPosition, child.getTop(), drawerPosition + shadowLeft.getIntrinsicWidth(), child.getBottom()); shadowLeft.setAlpha((int) (0xff * alpha)); shadowLeft.draw(canvas); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Views/AvatarDrawable.java b/TMessagesProj/src/main/java/org/telegram/ui/Views/AvatarDrawable.java index ef9eeed0..d4419e56 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Views/AvatarDrawable.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Views/AvatarDrawable.java @@ -19,6 +19,7 @@ import android.text.TextPaint; import org.telegram.android.AndroidUtilities; import org.telegram.messenger.FileLog; +import org.telegram.messenger.R; import org.telegram.messenger.TLRPC; public class AvatarDrawable extends Drawable { @@ -28,6 +29,9 @@ public class AvatarDrawable extends Drawable { private static int[] arrColors = {0xffe56555, 0xfff28c48, 0xffeec764, 0xff76c84d, 0xff5fbed5, 0xff549cdd, 0xff8e85ee, 0xfff2749a}; private static int[] arrColorsProfiles = {0xffd86f65, 0xffdc9663, 0xffdebc68, 0xff67b35d, 0xff56a2bb, 0xff5c98cd, 0xff8c79d2, 0xffda738e}; private static int[] arrColorsProfilesBack = {0xffca6056, 0xffcf8550, 0xffcfa742, 0xff56a14c, 0xff4492ac, 0xff4c84b6, 0xff7d6ac4, 0xffc9637e}; + private static int[] arrColorsProfilesText = {0xfff9cbc5, 0xfffadbc4, 0xfff7e7bf, 0xffc0edba, 0xffb8e2f0, 0xffb3d7f7, 0xffcdc4ed, 0xfff2cfd8}; + private static int[] arrColorsButtons = {R.drawable.bar_selector_red, R.drawable.bar_selector_orange, R.drawable.bar_selector_yellow, + R.drawable.bar_selector_green, R.drawable.bar_selector_cyan, R.drawable.bar_selector_blue, R.drawable.bar_selector_violet, R.drawable.bar_selector_pink}; private int color; private StaticLayout textLayout; @@ -73,10 +77,18 @@ public class AvatarDrawable extends Drawable { return arrColors[Math.abs(id) % arrColors.length]; } + public static int getButtonColorForId(int id) { + return arrColorsButtons[Math.abs(id) % arrColorsButtons.length]; + } + public static int getProfileColorForId(int id) { return arrColorsProfiles[Math.abs(id) % arrColorsProfiles.length]; } + public static int getProfileTextColorForId(int id) { + return arrColorsProfilesText[Math.abs(id) % arrColorsProfilesText.length]; + } + public static int getProfileBackColorForId(int id) { return arrColorsProfilesBack[Math.abs(id) % arrColorsProfilesBack.length]; } @@ -99,7 +111,7 @@ public class AvatarDrawable extends Drawable { public void setInfo(int id, String firstName, String lastName, boolean isBroadcast) { if (isProfile) { - color = arrColorsProfiles[Math.abs(id) % arrColors.length]; + color = arrColorsProfiles[Math.abs(id) % arrColorsProfiles.length]; } else { color = arrColors[Math.abs(id) % arrColors.length]; } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Views/Switch.java b/TMessagesProj/src/main/java/org/telegram/ui/Views/Switch.java new file mode 100644 index 00000000..0cf3ead5 --- /dev/null +++ b/TMessagesProj/src/main/java/org/telegram/ui/Views/Switch.java @@ -0,0 +1,688 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.telegram.ui.Views; + +import android.content.Context; +import android.graphics.Canvas; +import android.graphics.PorterDuff; +import android.graphics.PorterDuffColorFilter; +import android.graphics.Rect; +import android.graphics.Region; +import android.graphics.drawable.Drawable; +import android.view.Gravity; +import android.view.MotionEvent; +import android.view.VelocityTracker; +import android.view.ViewConfiguration; +import android.widget.CompoundButton; + +import org.telegram.android.AndroidUtilities; +import org.telegram.android.LocaleController; +import org.telegram.messenger.R; +import org.telegram.ui.AnimationCompat.ObjectAnimatorProxy; + +public class Switch extends CompoundButton { + + public static class Insets { + public static final Insets NONE = new Insets(AndroidUtilities.dp(4), 0, AndroidUtilities.dp(4), 0); + + public final int left; + public final int top; + public final int right; + public final int bottom; + + private Insets(int left, int top, int right, int bottom) { + this.left = left; + this.top = top; + this.right = right; + this.bottom = bottom; + } + } + + public static float constrain(float amount, float low, float high) { + return amount < low ? low : (amount > high ? high : amount); + } + + private static final int THUMB_ANIMATION_DURATION = 250; + + private static final int TOUCH_MODE_IDLE = 0; + private static final int TOUCH_MODE_DOWN = 1; + private static final int TOUCH_MODE_DRAGGING = 2; + + private Drawable mThumbDrawable; + private Drawable mTrackDrawable; + private int mThumbTextPadding; + private int mSwitchMinWidth; + private int mSwitchPadding; + private boolean mSplitTrack; + + private boolean attachedToWindow; + private boolean wasLayout; + + private int mTouchMode; + private int mTouchSlop; + private float mTouchX; + private float mTouchY; + private VelocityTracker mVelocityTracker = VelocityTracker.obtain(); + private int mMinFlingVelocity; + + private float thumbPosition; + private int mSwitchWidth; + private int mSwitchHeight; + private int mThumbWidth; + private int mSwitchLeft; + private int mSwitchTop; + private int mSwitchRight; + private int mSwitchBottom; + + private ObjectAnimatorProxy mPositionAnimator; + + @SuppressWarnings("hiding") + private final Rect mTempRect = new Rect(); + + public Switch(Context context) { + super(context); + + mThumbDrawable = context.getResources().getDrawable(R.drawable.switch_thumb); + if (mThumbDrawable != null) { + mThumbDrawable.setCallback(this); + } + mTrackDrawable = context.getResources().getDrawable(R.drawable.switch_track); + if (mTrackDrawable != null) { + mTrackDrawable.setCallback(this); + } + + if (AndroidUtilities.density < 1) { + mSwitchMinWidth = AndroidUtilities.dp(30); + } else { + mSwitchMinWidth = 0; + } + + mSwitchPadding = 0; + mSplitTrack = false; + + final ViewConfiguration config = ViewConfiguration.get(context); + mTouchSlop = config.getScaledTouchSlop(); + mMinFlingVelocity = config.getScaledMinimumFlingVelocity(); + + refreshDrawableState(); + setChecked(isChecked()); + } + + public void setSwitchPadding(int pixels) { + mSwitchPadding = pixels; + requestLayout(); + } + + public int getSwitchPadding() { + return mSwitchPadding; + } + + public void setSwitchMinWidth(int pixels) { + mSwitchMinWidth = pixels; + requestLayout(); + } + + public int getSwitchMinWidth() { + return mSwitchMinWidth; + } + + public void setThumbTextPadding(int pixels) { + mThumbTextPadding = pixels; + requestLayout(); + } + + public int getThumbTextPadding() { + return mThumbTextPadding; + } + + public void setTrackDrawable(Drawable track) { + if (mTrackDrawable != null) { + mTrackDrawable.setCallback(null); + } + mTrackDrawable = track; + if (track != null) { + track.setCallback(this); + } + requestLayout(); + } + + public void setTrackResource(int resId) { + setTrackDrawable(getContext().getDrawable(resId)); + } + + public Drawable getTrackDrawable() { + return mTrackDrawable; + } + + public void setThumbDrawable(Drawable thumb) { + if (mThumbDrawable != null) { + mThumbDrawable.setCallback(null); + } + mThumbDrawable = thumb; + if (thumb != null) { + thumb.setCallback(this); + } + requestLayout(); + } + + public void setThumbResource(int resId) { + setThumbDrawable(getContext().getDrawable(resId)); + } + + public Drawable getThumbDrawable() { + return mThumbDrawable; + } + + public void setSplitTrack(boolean splitTrack) { + mSplitTrack = splitTrack; + invalidate(); + } + + public boolean getSplitTrack() { + return mSplitTrack; + } + + @Override + public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + final Rect padding = mTempRect; + int thumbWidth; + int thumbHeight; + if (mThumbDrawable != null) { + mThumbDrawable.getPadding(padding); + thumbWidth = mThumbDrawable.getIntrinsicWidth() - padding.left - padding.right; + thumbHeight = mThumbDrawable.getIntrinsicHeight(); + } else { + thumbWidth = 0; + thumbHeight = 0; + } + + + mThumbWidth = thumbWidth; + + int trackHeight; + if (mTrackDrawable != null) { + mTrackDrawable.getPadding(padding); + trackHeight = mTrackDrawable.getIntrinsicHeight(); + } else { + padding.setEmpty(); + trackHeight = 0; + } + + int paddingLeft = padding.left; + int paddingRight = padding.right; + if (mThumbDrawable != null) { + final Insets inset = Insets.NONE; + paddingLeft = Math.max(paddingLeft, inset.left); + paddingRight = Math.max(paddingRight, inset.right); + } + + final int switchWidth = Math.max(mSwitchMinWidth, 2 * mThumbWidth + paddingLeft + paddingRight); + final int switchHeight = Math.max(trackHeight, thumbHeight); + mSwitchWidth = switchWidth; + mSwitchHeight = switchHeight; + + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + + final int measuredHeight = getMeasuredHeight(); + if (measuredHeight < switchHeight) { + setMeasuredDimension(switchWidth, switchHeight); + } + } + + private boolean hitThumb(float x, float y) { + final int thumbOffset = getThumbOffset(); + + mThumbDrawable.getPadding(mTempRect); + final int thumbTop = mSwitchTop - mTouchSlop; + final int thumbLeft = mSwitchLeft + thumbOffset - mTouchSlop; + final int thumbRight = thumbLeft + mThumbWidth + mTempRect.left + mTempRect.right + mTouchSlop; + final int thumbBottom = mSwitchBottom + mTouchSlop; + return x > thumbLeft && x < thumbRight && y > thumbTop && y < thumbBottom; + } + + @Override + public boolean onTouchEvent(MotionEvent ev) { + mVelocityTracker.addMovement(ev); + final int action = ev.getActionMasked(); + switch (action) { + case MotionEvent.ACTION_DOWN: { + final float x = ev.getX(); + final float y = ev.getY(); + if (isEnabled() && hitThumb(x, y)) { + mTouchMode = TOUCH_MODE_DOWN; + mTouchX = x; + mTouchY = y; + } + break; + } + + case MotionEvent.ACTION_MOVE: { + switch (mTouchMode) { + case TOUCH_MODE_IDLE: + break; + + case TOUCH_MODE_DOWN: { + final float x = ev.getX(); + final float y = ev.getY(); + if (Math.abs(x - mTouchX) > mTouchSlop || Math.abs(y - mTouchY) > mTouchSlop) { + mTouchMode = TOUCH_MODE_DRAGGING; + getParent().requestDisallowInterceptTouchEvent(true); + mTouchX = x; + mTouchY = y; + return true; + } + break; + } + + case TOUCH_MODE_DRAGGING: { + final float x = ev.getX(); + final int thumbScrollRange = getThumbScrollRange(); + final float thumbScrollOffset = x - mTouchX; + float dPos; + if (thumbScrollRange != 0) { + dPos = thumbScrollOffset / thumbScrollRange; + } else { + dPos = thumbScrollOffset > 0 ? 1 : -1; + } + if (LocaleController.isRTL) { + dPos = -dPos; + } + final float newPos = constrain(thumbPosition + dPos, 0, 1); + if (newPos != thumbPosition) { + mTouchX = x; + setThumbPosition(newPos); + } + return true; + } + } + break; + } + + case MotionEvent.ACTION_UP: + case MotionEvent.ACTION_CANCEL: { + if (mTouchMode == TOUCH_MODE_DRAGGING) { + stopDrag(ev); + super.onTouchEvent(ev); + return true; + } + mTouchMode = TOUCH_MODE_IDLE; + mVelocityTracker.clear(); + break; + } + } + + return super.onTouchEvent(ev); + } + + private void cancelSuperTouch(MotionEvent ev) { + MotionEvent cancel = MotionEvent.obtain(ev); + cancel.setAction(MotionEvent.ACTION_CANCEL); + super.onTouchEvent(cancel); + cancel.recycle(); + } + + private void stopDrag(MotionEvent ev) { + mTouchMode = TOUCH_MODE_IDLE; + + final boolean commitChange = ev.getAction() == MotionEvent.ACTION_UP && isEnabled(); + final boolean newState; + if (commitChange) { + mVelocityTracker.computeCurrentVelocity(1000); + final float xvel = mVelocityTracker.getXVelocity(); + if (Math.abs(xvel) > mMinFlingVelocity) { + newState = LocaleController.isRTL ? (xvel < 0) : (xvel > 0); + } else { + newState = getTargetCheckedState(); + } + } else { + newState = isChecked(); + } + + setChecked(newState); + cancelSuperTouch(ev); + } + + private void animateThumbToCheckedState(boolean newCheckedState) { + final float targetPosition = newCheckedState ? 1 : 0; + mPositionAnimator = ObjectAnimatorProxy.ofFloatProxy(this, "thumbPosition", targetPosition); + mPositionAnimator.setDuration(THUMB_ANIMATION_DURATION); + mPositionAnimator.setAutoCancel(true); + mPositionAnimator.start(); + } + + private void cancelPositionAnimator() { + if (mPositionAnimator != null) { + mPositionAnimator.cancel(); + } + } + + private boolean getTargetCheckedState() { + return thumbPosition > 0.5f; + } + + private void setThumbPosition(float position) { + thumbPosition = position; + invalidate(); + } + + public float getThumbPosition() { + return thumbPosition; + } + + @Override + public void toggle() { + setChecked(!isChecked()); + } + + @Override + protected void onAttachedToWindow() { + super.onAttachedToWindow(); + attachedToWindow = true; + } + + @Override + protected void onDetachedFromWindow() { + super.onDetachedFromWindow(); + attachedToWindow = false; + wasLayout = false; + } + + @Override + public void setChecked(boolean checked) { + super.setChecked(checked); + + checked = isChecked(); + + if (attachedToWindow && wasLayout) { + animateThumbToCheckedState(checked); + } else { + cancelPositionAnimator(); + setThumbPosition(checked ? 1 : 0); + } + + if (mTrackDrawable != null) { + mTrackDrawable.setColorFilter(new PorterDuffColorFilter(checked ? 0xffa0d6fa : 0xffc7c7c7, PorterDuff.Mode.MULTIPLY)); + } + if (mThumbDrawable != null) { + mThumbDrawable.setColorFilter(new PorterDuffColorFilter(checked ? 0xff45abef : 0xffededed, PorterDuff.Mode.MULTIPLY)); + } + } + + @Override + protected void onLayout(boolean changed, int left, int top, int right, int bottom) { + super.onLayout(changed, left, top, right, bottom); + + wasLayout = true; + int opticalInsetLeft = 0; + int opticalInsetRight = 0; + if (mThumbDrawable != null) { + final Rect trackPadding = mTempRect; + if (mTrackDrawable != null) { + mTrackDrawable.getPadding(trackPadding); + } else { + trackPadding.setEmpty(); + } + + final Insets insets = Insets.NONE; + opticalInsetLeft = Math.max(0, insets.left - trackPadding.left); + opticalInsetRight = Math.max(0, insets.right - trackPadding.right); + } + + final int switchRight; + final int switchLeft; + if (LocaleController.isRTL) { + switchLeft = getPaddingLeft() + opticalInsetLeft; + switchRight = switchLeft + mSwitchWidth - opticalInsetLeft - opticalInsetRight; + } else { + switchRight = getWidth() - getPaddingRight() - opticalInsetRight; + switchLeft = switchRight - mSwitchWidth + opticalInsetLeft + opticalInsetRight; + } + + final int switchTop; + final int switchBottom; + switch (getGravity() & Gravity.VERTICAL_GRAVITY_MASK) { + default: + case Gravity.TOP: + switchTop = getPaddingTop(); + switchBottom = switchTop + mSwitchHeight; + break; + + case Gravity.CENTER_VERTICAL: + switchTop = (getPaddingTop() + getHeight() - getPaddingBottom()) / 2 - mSwitchHeight / 2; + switchBottom = switchTop + mSwitchHeight; + break; + + case Gravity.BOTTOM: + switchBottom = getHeight() - getPaddingBottom(); + switchTop = switchBottom - mSwitchHeight; + break; + } + + mSwitchLeft = switchLeft; + mSwitchTop = switchTop; + mSwitchBottom = switchBottom; + mSwitchRight = switchRight; + } + + @Override + public void draw(Canvas c) { + final Rect padding = mTempRect; + final int switchLeft = mSwitchLeft; + final int switchTop = mSwitchTop; + final int switchRight = mSwitchRight; + final int switchBottom = mSwitchBottom; + + int thumbInitialLeft = switchLeft + getThumbOffset(); + + final Insets thumbInsets; + if (mThumbDrawable != null) { + thumbInsets = Insets.NONE; + } else { + thumbInsets = Insets.NONE; + } + + if (mTrackDrawable != null) { + mTrackDrawable.getPadding(padding); + + thumbInitialLeft += padding.left; + + int trackLeft = switchLeft; + int trackTop = switchTop; + int trackRight = switchRight; + int trackBottom = switchBottom; + if (thumbInsets != Insets.NONE) { + if (thumbInsets.left > padding.left) { + trackLeft += thumbInsets.left - padding.left; + } + if (thumbInsets.top > padding.top) { + trackTop += thumbInsets.top - padding.top; + } + if (thumbInsets.right > padding.right) { + trackRight -= thumbInsets.right - padding.right; + } + if (thumbInsets.bottom > padding.bottom) { + trackBottom -= thumbInsets.bottom - padding.bottom; + } + } + mTrackDrawable.setBounds(trackLeft, trackTop, trackRight, trackBottom); + } + + if (mThumbDrawable != null) { + mThumbDrawable.getPadding(padding); + + final int thumbLeft = thumbInitialLeft - padding.left; + final int thumbRight = thumbInitialLeft + mThumbWidth + padding.right; + mThumbDrawable.setBounds(thumbLeft, switchTop, thumbRight, switchBottom); + + final Drawable background = getBackground(); + if (background != null) { + background.setHotspotBounds(thumbLeft, switchTop, thumbRight, switchBottom); + } + } + + super.draw(c); + } + + @Override + protected void onDraw(Canvas canvas) { + super.onDraw(canvas); + + final Rect padding = mTempRect; + final Drawable trackDrawable = mTrackDrawable; + if (trackDrawable != null) { + trackDrawable.getPadding(padding); + } else { + padding.setEmpty(); + } + + final int switchTop = mSwitchTop; + final int switchBottom = mSwitchBottom; + final int switchInnerTop = switchTop + padding.top; + final int switchInnerBottom = switchBottom - padding.bottom; + + final Drawable thumbDrawable = mThumbDrawable; + if (trackDrawable != null) { + if (mSplitTrack && thumbDrawable != null) { + final Insets insets = Insets.NONE; + thumbDrawable.copyBounds(padding); + padding.left += insets.left; + padding.right -= insets.right; + + final int saveCount = canvas.save(); + canvas.clipRect(padding, Region.Op.DIFFERENCE); + trackDrawable.draw(canvas); + canvas.restoreToCount(saveCount); + } else { + trackDrawable.draw(canvas); + } + } + + final int saveCount = canvas.save(); + + if (thumbDrawable != null) { + thumbDrawable.draw(canvas); + } + + canvas.restoreToCount(saveCount); + } + + @Override + public int getCompoundPaddingLeft() { + if (!LocaleController.isRTL) { + return super.getCompoundPaddingLeft(); + } + return super.getCompoundPaddingLeft() + mSwitchWidth; + } + + @Override + public int getCompoundPaddingRight() { + if (LocaleController.isRTL) { + return super.getCompoundPaddingRight(); + } + return super.getCompoundPaddingRight() + mSwitchWidth; + } + + private int getThumbOffset() { + final float position; + if (LocaleController.isRTL) { + position = 1 - thumbPosition; + } else { + position = thumbPosition; + } + return (int) (position * getThumbScrollRange() + 0.5f); + } + + private int getThumbScrollRange() { + if (mTrackDrawable != null) { + final Rect padding = mTempRect; + mTrackDrawable.getPadding(padding); + + final Insets insets; + if (mThumbDrawable != null) { + insets = Insets.NONE; + } else { + insets = Insets.NONE; + } + + return mSwitchWidth - mThumbWidth - padding.left - padding.right - insets.left - insets.right; + } else { + return 0; + } + } + + /*@Override + protected int[] onCreateDrawableState(int extraSpace) { + final int[] drawableState = super.onCreateDrawableState(extraSpace + 1); + if (isChecked()) { + mergeDrawableStates(drawableState, CHECKED_STATE_SET); + } + return drawableState; + }*/ + + @Override + protected void drawableStateChanged() { + super.drawableStateChanged(); + + final int[] myDrawableState = getDrawableState(); + + if (mThumbDrawable != null) { + mThumbDrawable.setState(myDrawableState); + } + + if (mTrackDrawable != null) { + mTrackDrawable.setState(myDrawableState); + } + + invalidate(); + } + + @Override + public void drawableHotspotChanged(float x, float y) { + super.drawableHotspotChanged(x, y); + + if (mThumbDrawable != null) { + mThumbDrawable.setHotspot(x, y); + } + + if (mTrackDrawable != null) { + mTrackDrawable.setHotspot(x, y); + } + } + + @Override + protected boolean verifyDrawable(Drawable who) { + return super.verifyDrawable(who) || who == mThumbDrawable || who == mTrackDrawable; + } + + @Override + public void jumpDrawablesToCurrentState() { + super.jumpDrawablesToCurrentState(); + + if (mThumbDrawable != null) { + mThumbDrawable.jumpToCurrentState(); + } + + if (mTrackDrawable != null) { + mTrackDrawable.jumpToCurrentState(); + } + + if (mPositionAnimator != null && mPositionAnimator.isRunning()) { + mPositionAnimator.end(); + mPositionAnimator = null; + } + } +} diff --git a/TMessagesProj/src/main/res/anim/decelerate_cubic.xml b/TMessagesProj/src/main/res/anim/decelerate_cubic.xml deleted file mode 100644 index 053d6d20..00000000 --- a/TMessagesProj/src/main/res/anim/decelerate_cubic.xml +++ /dev/null @@ -1,3 +0,0 @@ - - diff --git a/TMessagesProj/src/main/res/anim/icon_anim_fade_in.xml b/TMessagesProj/src/main/res/anim/icon_anim_fade_in.xml index 8def03b7..34fa7064 100644 --- a/TMessagesProj/src/main/res/anim/icon_anim_fade_in.xml +++ b/TMessagesProj/src/main/res/anim/icon_anim_fade_in.xml @@ -1,21 +1,7 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/TMessagesProj/src/main/res/anim/icon_anim_fade_out.xml b/TMessagesProj/src/main/res/anim/icon_anim_fade_out.xml index 85c91287..915208c6 100644 --- a/TMessagesProj/src/main/res/anim/icon_anim_fade_out.xml +++ b/TMessagesProj/src/main/res/anim/icon_anim_fade_out.xml @@ -1,21 +1,7 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/TMessagesProj/src/main/res/anim/scale_in.xml b/TMessagesProj/src/main/res/anim/scale_in.xml deleted file mode 100644 index a0aa6293..00000000 --- a/TMessagesProj/src/main/res/anim/scale_in.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/TMessagesProj/src/main/res/anim/scale_out.xml b/TMessagesProj/src/main/res/anim/scale_out.xml deleted file mode 100644 index 11135b97..00000000 --- a/TMessagesProj/src/main/res/anim/scale_out.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/TMessagesProj/src/main/res/drawable-hdpi/broadcast.png b/TMessagesProj/src/main/res/drawable-hdpi/broadcast.png deleted file mode 100644 index bd523d0c..00000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/broadcast.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/doc_actions_g.png b/TMessagesProj/src/main/res/drawable-hdpi/doc_actions_g.png deleted file mode 100755 index 1b0aec5a..00000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/doc_actions_g.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/floating3_profile.png b/TMessagesProj/src/main/res/drawable-hdpi/floating3_profile.png new file mode 100755 index 00000000..02c6d524 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/floating3_profile.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/floating3_profile_pressed.png b/TMessagesProj/src/main/res/drawable-hdpi/floating3_profile_pressed.png new file mode 100755 index 00000000..8a0d44a8 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/floating3_profile_pressed.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/floating4_profile.png b/TMessagesProj/src/main/res/drawable-hdpi/floating4_profile.png new file mode 100755 index 00000000..69e720a6 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/floating4_profile.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/floating4_profile_pressed.png b/TMessagesProj/src/main/res/drawable-hdpi/floating4_profile_pressed.png new file mode 100755 index 00000000..54704186 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/floating4_profile_pressed.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/greydivider.png b/TMessagesProj/src/main/res/drawable-hdpi/greydivider.png new file mode 100755 index 00000000..fd8713b0 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/greydivider.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/ic_ab_attach.png b/TMessagesProj/src/main/res/drawable-hdpi/ic_ab_attach.png old mode 100644 new mode 100755 index 20722afc..c7da348a Binary files a/TMessagesProj/src/main/res/drawable-hdpi/ic_ab_attach.png and b/TMessagesProj/src/main/res/drawable-hdpi/ic_ab_attach.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/ic_ab_doc.png b/TMessagesProj/src/main/res/drawable-hdpi/ic_ab_doc.png old mode 100644 new mode 100755 index 30ff62d1..25e2c036 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/ic_ab_doc.png and b/TMessagesProj/src/main/res/drawable-hdpi/ic_ab_doc.png differ 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 old mode 100644 new mode 100755 index 1cd56af3..99240881 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/ic_ab_done_gray.png and b/TMessagesProj/src/main/res/drawable-hdpi/ic_ab_done_gray.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/ic_ab_fwd_copy.png b/TMessagesProj/src/main/res/drawable-hdpi/ic_ab_fwd_copy.png old mode 100644 new mode 100755 index bd84232a..64ed7cd0 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/ic_ab_fwd_copy.png and b/TMessagesProj/src/main/res/drawable-hdpi/ic_ab_fwd_copy.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/ic_ab_fwd_delete.png b/TMessagesProj/src/main/res/drawable-hdpi/ic_ab_fwd_delete.png old mode 100644 new mode 100755 index 6fbbd124..9af1eb09 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/ic_ab_fwd_delete.png and b/TMessagesProj/src/main/res/drawable-hdpi/ic_ab_fwd_delete.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/ic_ab_fwd_forward.png b/TMessagesProj/src/main/res/drawable-hdpi/ic_ab_fwd_forward.png old mode 100644 new mode 100755 index 0b0048d5..cfa12ce2 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/ic_ab_fwd_forward.png and b/TMessagesProj/src/main/res/drawable-hdpi/ic_ab_fwd_forward.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/ic_attach_gallery.png b/TMessagesProj/src/main/res/drawable-hdpi/ic_attach_gallery.png index e8d24783..1c60351c 100755 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/ic_attach_gallery.png and b/TMessagesProj/src/main/res/drawable-hdpi/ic_attach_gallery.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/ic_attach_location.png b/TMessagesProj/src/main/res/drawable-hdpi/ic_attach_location.png index 474c949f..52bf6051 100755 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/ic_attach_location.png and b/TMessagesProj/src/main/res/drawable-hdpi/ic_attach_location.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/ic_attach_photo.png b/TMessagesProj/src/main/res/drawable-hdpi/ic_attach_photo.png index 35aa4306..b2b0caaa 100755 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/ic_attach_photo.png and b/TMessagesProj/src/main/res/drawable-hdpi/ic_attach_photo.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/ic_attach_video.png b/TMessagesProj/src/main/res/drawable-hdpi/ic_attach_video.png index b1a87b16..19337352 100755 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/ic_attach_video.png and b/TMessagesProj/src/main/res/drawable-hdpi/ic_attach_video.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/layer_shadow.png b/TMessagesProj/src/main/res/drawable-hdpi/layer_shadow.png new file mode 100644 index 00000000..9bb9bf10 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/layer_shadow.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/list_broadcast.png b/TMessagesProj/src/main/res/drawable-hdpi/list_broadcast.png new file mode 100755 index 00000000..54a56f82 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/list_broadcast.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/phone_grey.png b/TMessagesProj/src/main/res/drawable-hdpi/phone_grey.png new file mode 100755 index 00000000..e1d32825 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/phone_grey.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/profile_list.png b/TMessagesProj/src/main/res/drawable-hdpi/profile_list.png new file mode 100755 index 00000000..c201168e Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/profile_list.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/switch_to_on1.9.png b/TMessagesProj/src/main/res/drawable-hdpi/switch_to_on1.9.png new file mode 100644 index 00000000..8e7b62f0 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/switch_to_on1.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/switch_to_on2.9.png b/TMessagesProj/src/main/res/drawable-hdpi/switch_to_on2.9.png new file mode 100644 index 00000000..adcb9e96 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/switch_to_on2.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/switch_track.9.png b/TMessagesProj/src/main/res/drawable-hdpi/switch_track.9.png new file mode 100644 index 00000000..0ebe65e7 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/switch_track.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/broadcast.png b/TMessagesProj/src/main/res/drawable-mdpi/broadcast.png deleted file mode 100644 index db6c9411..00000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/broadcast.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/doc_actions_b.png b/TMessagesProj/src/main/res/drawable-mdpi/doc_actions_b.png deleted file mode 100755 index 37a56ecc..00000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/doc_actions_b.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/doc_actions_g.png b/TMessagesProj/src/main/res/drawable-mdpi/doc_actions_g.png deleted file mode 100755 index 3f922d7d..00000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/doc_actions_g.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/floating3_profile.png b/TMessagesProj/src/main/res/drawable-mdpi/floating3_profile.png new file mode 100755 index 00000000..18e87b3e Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/floating3_profile.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/floating3_profile_pressed.png b/TMessagesProj/src/main/res/drawable-mdpi/floating3_profile_pressed.png new file mode 100755 index 00000000..972cd335 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/floating3_profile_pressed.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/floating4_profile.png b/TMessagesProj/src/main/res/drawable-mdpi/floating4_profile.png new file mode 100755 index 00000000..a04f3739 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/floating4_profile.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/floating4_profile_pressed.png b/TMessagesProj/src/main/res/drawable-mdpi/floating4_profile_pressed.png new file mode 100755 index 00000000..d1082b32 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/floating4_profile_pressed.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/greydivider.png b/TMessagesProj/src/main/res/drawable-mdpi/greydivider.png new file mode 100755 index 00000000..342fb818 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/greydivider.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/ic_ab_attach.png b/TMessagesProj/src/main/res/drawable-mdpi/ic_ab_attach.png old mode 100644 new mode 100755 index 4adde960..85f390b8 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/ic_ab_attach.png and b/TMessagesProj/src/main/res/drawable-mdpi/ic_ab_attach.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/ic_ab_doc.png b/TMessagesProj/src/main/res/drawable-mdpi/ic_ab_doc.png old mode 100644 new mode 100755 index da7ea4e3..ce1100b8 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/ic_ab_doc.png and b/TMessagesProj/src/main/res/drawable-mdpi/ic_ab_doc.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 old mode 100644 new mode 100755 index 0b4b8b85..47beed22 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/ic_ab_done_gray.png and b/TMessagesProj/src/main/res/drawable-mdpi/ic_ab_done_gray.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/ic_ab_fwd_copy.png b/TMessagesProj/src/main/res/drawable-mdpi/ic_ab_fwd_copy.png old mode 100644 new mode 100755 index 2288029b..f8bfd187 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/ic_ab_fwd_copy.png and b/TMessagesProj/src/main/res/drawable-mdpi/ic_ab_fwd_copy.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/ic_ab_fwd_delete.png b/TMessagesProj/src/main/res/drawable-mdpi/ic_ab_fwd_delete.png old mode 100644 new mode 100755 index 8f22d438..e2370b3b Binary files a/TMessagesProj/src/main/res/drawable-mdpi/ic_ab_fwd_delete.png and b/TMessagesProj/src/main/res/drawable-mdpi/ic_ab_fwd_delete.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/ic_ab_fwd_forward.png b/TMessagesProj/src/main/res/drawable-mdpi/ic_ab_fwd_forward.png old mode 100644 new mode 100755 index 736c62fc..fe943423 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/ic_ab_fwd_forward.png and b/TMessagesProj/src/main/res/drawable-mdpi/ic_ab_fwd_forward.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/ic_attach_gallery.png b/TMessagesProj/src/main/res/drawable-mdpi/ic_attach_gallery.png index 1de9660a..a5305696 100755 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/ic_attach_gallery.png and b/TMessagesProj/src/main/res/drawable-mdpi/ic_attach_gallery.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/ic_attach_location.png b/TMessagesProj/src/main/res/drawable-mdpi/ic_attach_location.png index 4b4fab56..19330697 100755 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/ic_attach_location.png and b/TMessagesProj/src/main/res/drawable-mdpi/ic_attach_location.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/ic_attach_photo.png b/TMessagesProj/src/main/res/drawable-mdpi/ic_attach_photo.png index ca2130b5..9a70e6b5 100755 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/ic_attach_photo.png and b/TMessagesProj/src/main/res/drawable-mdpi/ic_attach_photo.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/ic_attach_video.png b/TMessagesProj/src/main/res/drawable-mdpi/ic_attach_video.png index f4573911..b6ebbb60 100755 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/ic_attach_video.png and b/TMessagesProj/src/main/res/drawable-mdpi/ic_attach_video.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/layer_shadow.png b/TMessagesProj/src/main/res/drawable-mdpi/layer_shadow.png new file mode 100644 index 00000000..aeefef42 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/layer_shadow.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/list_broadcast.png b/TMessagesProj/src/main/res/drawable-mdpi/list_broadcast.png new file mode 100755 index 00000000..f772b53e Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/list_broadcast.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/phone_grey.png b/TMessagesProj/src/main/res/drawable-mdpi/phone_grey.png new file mode 100755 index 00000000..4d0d0808 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/phone_grey.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/profile_list.png b/TMessagesProj/src/main/res/drawable-mdpi/profile_list.png new file mode 100755 index 00000000..b27a6762 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/profile_list.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/switch_to_on1.9.png b/TMessagesProj/src/main/res/drawable-mdpi/switch_to_on1.9.png new file mode 100644 index 00000000..b8280152 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/switch_to_on1.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/switch_to_on2.9.png b/TMessagesProj/src/main/res/drawable-mdpi/switch_to_on2.9.png new file mode 100644 index 00000000..9bdd2eaf Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/switch_to_on2.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/switch_track.9.png b/TMessagesProj/src/main/res/drawable-mdpi/switch_track.9.png new file mode 100644 index 00000000..f8677ab8 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/switch_track.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-v21/bar_selector_blue.xml b/TMessagesProj/src/main/res/drawable-v21/bar_selector_blue.xml new file mode 100644 index 00000000..34512df8 --- /dev/null +++ b/TMessagesProj/src/main/res/drawable-v21/bar_selector_blue.xml @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/TMessagesProj/src/main/res/drawable-v21/bar_selector_cyan.xml b/TMessagesProj/src/main/res/drawable-v21/bar_selector_cyan.xml new file mode 100644 index 00000000..64d8697d --- /dev/null +++ b/TMessagesProj/src/main/res/drawable-v21/bar_selector_cyan.xml @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/TMessagesProj/src/main/res/drawable-v21/bar_selector_green.xml b/TMessagesProj/src/main/res/drawable-v21/bar_selector_green.xml new file mode 100644 index 00000000..49c5a35e --- /dev/null +++ b/TMessagesProj/src/main/res/drawable-v21/bar_selector_green.xml @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/TMessagesProj/src/main/res/drawable-v21/bar_selector_orange.xml b/TMessagesProj/src/main/res/drawable-v21/bar_selector_orange.xml new file mode 100644 index 00000000..5a4c89bc --- /dev/null +++ b/TMessagesProj/src/main/res/drawable-v21/bar_selector_orange.xml @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/TMessagesProj/src/main/res/drawable-v21/bar_selector_pink.xml b/TMessagesProj/src/main/res/drawable-v21/bar_selector_pink.xml new file mode 100644 index 00000000..d3fa48d1 --- /dev/null +++ b/TMessagesProj/src/main/res/drawable-v21/bar_selector_pink.xml @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/TMessagesProj/src/main/res/drawable-v21/bar_selector_red.xml b/TMessagesProj/src/main/res/drawable-v21/bar_selector_red.xml new file mode 100644 index 00000000..4badd687 --- /dev/null +++ b/TMessagesProj/src/main/res/drawable-v21/bar_selector_red.xml @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/TMessagesProj/src/main/res/drawable-v21/bar_selector_violet.xml b/TMessagesProj/src/main/res/drawable-v21/bar_selector_violet.xml new file mode 100644 index 00000000..ee31ab7f --- /dev/null +++ b/TMessagesProj/src/main/res/drawable-v21/bar_selector_violet.xml @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/TMessagesProj/src/main/res/drawable-v21/bar_selector_yellow.xml b/TMessagesProj/src/main/res/drawable-v21/bar_selector_yellow.xml new file mode 100644 index 00000000..2559175d --- /dev/null +++ b/TMessagesProj/src/main/res/drawable-v21/bar_selector_yellow.xml @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/broadcast.png b/TMessagesProj/src/main/res/drawable-xhdpi/broadcast.png deleted file mode 100644 index f3243392..00000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/broadcast.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/doc_actions_b.png b/TMessagesProj/src/main/res/drawable-xhdpi/doc_actions_b.png index 787e04f9..d36cc837 100755 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/doc_actions_b.png and b/TMessagesProj/src/main/res/drawable-xhdpi/doc_actions_b.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/doc_actions_g.png b/TMessagesProj/src/main/res/drawable-xhdpi/doc_actions_g.png deleted file mode 100755 index 8f768c66..00000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/doc_actions_g.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/floating3_profile.png b/TMessagesProj/src/main/res/drawable-xhdpi/floating3_profile.png new file mode 100755 index 00000000..25d26372 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/floating3_profile.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/floating3_profile_pressed.png b/TMessagesProj/src/main/res/drawable-xhdpi/floating3_profile_pressed.png new file mode 100755 index 00000000..1d496966 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/floating3_profile_pressed.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/floating4_profile.png b/TMessagesProj/src/main/res/drawable-xhdpi/floating4_profile.png new file mode 100755 index 00000000..87a90ab7 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/floating4_profile.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/floating4_profile_pressed.png b/TMessagesProj/src/main/res/drawable-xhdpi/floating4_profile_pressed.png new file mode 100755 index 00000000..e4af9d2f Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/floating4_profile_pressed.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/greydivider.png b/TMessagesProj/src/main/res/drawable-xhdpi/greydivider.png new file mode 100755 index 00000000..a2d2af9d Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/greydivider.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/ic_ab_attach.png b/TMessagesProj/src/main/res/drawable-xhdpi/ic_ab_attach.png old mode 100644 new mode 100755 index 0a88ae79..ff6844ed Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/ic_ab_attach.png and b/TMessagesProj/src/main/res/drawable-xhdpi/ic_ab_attach.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/ic_ab_doc.png b/TMessagesProj/src/main/res/drawable-xhdpi/ic_ab_doc.png old mode 100644 new mode 100755 index aaa8b417..245a76f0 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/ic_ab_doc.png and b/TMessagesProj/src/main/res/drawable-xhdpi/ic_ab_doc.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 old mode 100644 new mode 100755 index 1389811e..41671b4f Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/ic_ab_done_gray.png and b/TMessagesProj/src/main/res/drawable-xhdpi/ic_ab_done_gray.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/ic_ab_fwd_copy.png b/TMessagesProj/src/main/res/drawable-xhdpi/ic_ab_fwd_copy.png old mode 100644 new mode 100755 index 07c61196..4bc6df88 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/ic_ab_fwd_copy.png and b/TMessagesProj/src/main/res/drawable-xhdpi/ic_ab_fwd_copy.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/ic_ab_fwd_delete.png b/TMessagesProj/src/main/res/drawable-xhdpi/ic_ab_fwd_delete.png old mode 100644 new mode 100755 index 72cfed16..ac3d1e98 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/ic_ab_fwd_delete.png and b/TMessagesProj/src/main/res/drawable-xhdpi/ic_ab_fwd_delete.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/ic_ab_fwd_forward.png b/TMessagesProj/src/main/res/drawable-xhdpi/ic_ab_fwd_forward.png old mode 100644 new mode 100755 index e0594ac8..0957f01c Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/ic_ab_fwd_forward.png and b/TMessagesProj/src/main/res/drawable-xhdpi/ic_ab_fwd_forward.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/ic_attach_gallery.png b/TMessagesProj/src/main/res/drawable-xhdpi/ic_attach_gallery.png index 05550c39..4227122d 100755 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/ic_attach_gallery.png and b/TMessagesProj/src/main/res/drawable-xhdpi/ic_attach_gallery.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/ic_attach_location.png b/TMessagesProj/src/main/res/drawable-xhdpi/ic_attach_location.png index 4ae9969e..3e27c97e 100755 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/ic_attach_location.png and b/TMessagesProj/src/main/res/drawable-xhdpi/ic_attach_location.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/ic_attach_photo.png b/TMessagesProj/src/main/res/drawable-xhdpi/ic_attach_photo.png index ee1e52b7..25f0d3c8 100755 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/ic_attach_photo.png and b/TMessagesProj/src/main/res/drawable-xhdpi/ic_attach_photo.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/ic_attach_video.png b/TMessagesProj/src/main/res/drawable-xhdpi/ic_attach_video.png index 50751fc9..49f6685e 100755 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/ic_attach_video.png and b/TMessagesProj/src/main/res/drawable-xhdpi/ic_attach_video.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/layer_shadow.png b/TMessagesProj/src/main/res/drawable-xhdpi/layer_shadow.png new file mode 100644 index 00000000..8724204d Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/layer_shadow.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/list_broadcast.png b/TMessagesProj/src/main/res/drawable-xhdpi/list_broadcast.png new file mode 100755 index 00000000..d4fae87b Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/list_broadcast.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/phone_grey.png b/TMessagesProj/src/main/res/drawable-xhdpi/phone_grey.png new file mode 100755 index 00000000..981ed79f Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/phone_grey.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/doc_actions_b.png b/TMessagesProj/src/main/res/drawable-xhdpi/profile_list.png similarity index 50% rename from TMessagesProj/src/main/res/drawable-hdpi/doc_actions_b.png rename to TMessagesProj/src/main/res/drawable-xhdpi/profile_list.png index 3853c42d..1383d6bc 100755 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/doc_actions_b.png and b/TMessagesProj/src/main/res/drawable-xhdpi/profile_list.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/switch_to_on1.9.png b/TMessagesProj/src/main/res/drawable-xhdpi/switch_to_on1.9.png new file mode 100644 index 00000000..8a648b8b Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/switch_to_on1.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/switch_to_on2.9.png b/TMessagesProj/src/main/res/drawable-xhdpi/switch_to_on2.9.png new file mode 100644 index 00000000..435ce215 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/switch_to_on2.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/switch_track.9.png b/TMessagesProj/src/main/res/drawable-xhdpi/switch_track.9.png new file mode 100644 index 00000000..fd47f15e Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/switch_track.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/broadcast.png b/TMessagesProj/src/main/res/drawable-xxhdpi/broadcast.png deleted file mode 100644 index 4d978707..00000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/broadcast.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/doc_actions_b.png b/TMessagesProj/src/main/res/drawable-xxhdpi/doc_actions_b.png index d05ae14d..3b169ff0 100755 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/doc_actions_b.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/doc_actions_b.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/doc_actions_g.png b/TMessagesProj/src/main/res/drawable-xxhdpi/doc_actions_g.png index 7b61accc..5445d4e1 100755 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/doc_actions_g.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/doc_actions_g.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/floating3_profile.png b/TMessagesProj/src/main/res/drawable-xxhdpi/floating3_profile.png new file mode 100755 index 00000000..eedc3fa8 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/floating3_profile.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/floating3_profile_pressed.png b/TMessagesProj/src/main/res/drawable-xxhdpi/floating3_profile_pressed.png new file mode 100755 index 00000000..2702b312 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/floating3_profile_pressed.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/floating4_profile.png b/TMessagesProj/src/main/res/drawable-xxhdpi/floating4_profile.png new file mode 100755 index 00000000..97378cc0 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/floating4_profile.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/floating4_profile_pressed.png b/TMessagesProj/src/main/res/drawable-xxhdpi/floating4_profile_pressed.png new file mode 100755 index 00000000..db33c079 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/floating4_profile_pressed.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/greydivider.png b/TMessagesProj/src/main/res/drawable-xxhdpi/greydivider.png new file mode 100755 index 00000000..f6b2b94d Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/greydivider.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_ab_attach.png b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_ab_attach.png old mode 100644 new mode 100755 index e34e5366..0a0cbd36 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_ab_attach.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_ab_attach.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_ab_doc.png b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_ab_doc.png old mode 100644 new mode 100755 index 7a199265..7a86b6f0 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_ab_doc.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_ab_doc.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 old mode 100644 new mode 100755 index d12eabc5..4ff3b63b Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_ab_done_gray.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_ab_done_gray.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_ab_fwd_copy.png b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_ab_fwd_copy.png old mode 100644 new mode 100755 index 3519351e..31054c20 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_ab_fwd_copy.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_ab_fwd_copy.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_ab_fwd_delete.png b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_ab_fwd_delete.png old mode 100644 new mode 100755 index a25ac46a..74398b6c Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_ab_fwd_delete.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_ab_fwd_delete.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_ab_fwd_forward.png b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_ab_fwd_forward.png old mode 100644 new mode 100755 index 4fca27f2..f3c8fd6d Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_ab_fwd_forward.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_ab_fwd_forward.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_attach_gallery.png b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_attach_gallery.png index bc757caf..4f8d4075 100755 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_attach_gallery.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_attach_gallery.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_attach_location.png b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_attach_location.png index dc9b83a5..b6bd6ca9 100755 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_attach_location.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_attach_location.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_attach_photo.png b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_attach_photo.png index 850239b6..ccf61d69 100755 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_attach_photo.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_attach_photo.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_attach_video.png b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_attach_video.png index 1fc4ae63..66843485 100755 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_attach_video.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_attach_video.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/layer_shadow.png b/TMessagesProj/src/main/res/drawable-xxhdpi/layer_shadow.png new file mode 100644 index 00000000..637e319f Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/layer_shadow.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/list_broadcast.png b/TMessagesProj/src/main/res/drawable-xxhdpi/list_broadcast.png new file mode 100755 index 00000000..3118410e Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/list_broadcast.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/phone_grey.png b/TMessagesProj/src/main/res/drawable-xxhdpi/phone_grey.png new file mode 100755 index 00000000..a32cf017 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/phone_grey.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/profile_list.png b/TMessagesProj/src/main/res/drawable-xxhdpi/profile_list.png new file mode 100755 index 00000000..b07f5de4 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/profile_list.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/switch_to_on1.9.png b/TMessagesProj/src/main/res/drawable-xxhdpi/switch_to_on1.9.png new file mode 100644 index 00000000..b149e475 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/switch_to_on1.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/switch_to_on2.9.png b/TMessagesProj/src/main/res/drawable-xxhdpi/switch_to_on2.9.png new file mode 100644 index 00000000..00fb83ec Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/switch_to_on2.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/switch_track.9.png b/TMessagesProj/src/main/res/drawable-xxhdpi/switch_track.9.png new file mode 100644 index 00000000..3e3174d0 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/switch_track.9.png differ diff --git a/TMessagesProj/src/main/res/drawable/bar_selector_blue.xml b/TMessagesProj/src/main/res/drawable/bar_selector_blue.xml new file mode 100644 index 00000000..83e87947 --- /dev/null +++ b/TMessagesProj/src/main/res/drawable/bar_selector_blue.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/TMessagesProj/src/main/res/drawable/bar_selector_cyan.xml b/TMessagesProj/src/main/res/drawable/bar_selector_cyan.xml new file mode 100644 index 00000000..e9fb9cc2 --- /dev/null +++ b/TMessagesProj/src/main/res/drawable/bar_selector_cyan.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/TMessagesProj/src/main/res/drawable/bar_selector_green.xml b/TMessagesProj/src/main/res/drawable/bar_selector_green.xml new file mode 100644 index 00000000..2e88b9f4 --- /dev/null +++ b/TMessagesProj/src/main/res/drawable/bar_selector_green.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/TMessagesProj/src/main/res/drawable/bar_selector_orange.xml b/TMessagesProj/src/main/res/drawable/bar_selector_orange.xml new file mode 100644 index 00000000..b468c53f --- /dev/null +++ b/TMessagesProj/src/main/res/drawable/bar_selector_orange.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/TMessagesProj/src/main/res/drawable/bar_selector_pink.xml b/TMessagesProj/src/main/res/drawable/bar_selector_pink.xml new file mode 100644 index 00000000..4990bc1a --- /dev/null +++ b/TMessagesProj/src/main/res/drawable/bar_selector_pink.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/TMessagesProj/src/main/res/drawable/bar_selector_red.xml b/TMessagesProj/src/main/res/drawable/bar_selector_red.xml new file mode 100644 index 00000000..c00e47a4 --- /dev/null +++ b/TMessagesProj/src/main/res/drawable/bar_selector_red.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/TMessagesProj/src/main/res/drawable/bar_selector_violet.xml b/TMessagesProj/src/main/res/drawable/bar_selector_violet.xml new file mode 100644 index 00000000..405397c1 --- /dev/null +++ b/TMessagesProj/src/main/res/drawable/bar_selector_violet.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/TMessagesProj/src/main/res/drawable/bar_selector_yellow.xml b/TMessagesProj/src/main/res/drawable/bar_selector_yellow.xml new file mode 100644 index 00000000..819c2e95 --- /dev/null +++ b/TMessagesProj/src/main/res/drawable/bar_selector_yellow.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/TMessagesProj/src/main/res/drawable/floating_group_states.xml b/TMessagesProj/src/main/res/drawable/floating_group_states.xml new file mode 100644 index 00000000..785cc037 --- /dev/null +++ b/TMessagesProj/src/main/res/drawable/floating_group_states.xml @@ -0,0 +1,15 @@ + + + + + + + + + \ No newline at end of file diff --git a/TMessagesProj/src/main/res/drawable/floating_user_states.xml b/TMessagesProj/src/main/res/drawable/floating_user_states.xml new file mode 100644 index 00000000..ee18cbee --- /dev/null +++ b/TMessagesProj/src/main/res/drawable/floating_user_states.xml @@ -0,0 +1,15 @@ + + + + + + + + + \ No newline at end of file diff --git a/TMessagesProj/src/main/res/drawable/switch_thumb.xml b/TMessagesProj/src/main/res/drawable/switch_thumb.xml new file mode 100644 index 00000000..3d6207ce --- /dev/null +++ b/TMessagesProj/src/main/res/drawable/switch_thumb.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/TMessagesProj/src/main/res/layout/settings_layout.xml b/TMessagesProj/src/main/res/layout/settings_layout.xml deleted file mode 100644 index 6cfa958e..00000000 --- a/TMessagesProj/src/main/res/layout/settings_layout.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - diff --git a/TMessagesProj/src/main/res/values-ar/strings.xml b/TMessagesProj/src/main/res/values-ar/strings.xml index e9947eec..8902545c 100644 --- a/TMessagesProj/src/main/res/values-ar/strings.xml +++ b/TMessagesProj/src/main/res/values-ar/strings.xml @@ -175,7 +175,6 @@ أدخل سم للمجموعة عدد الوسائط المشتركة معلومات المجموعة - عرض الوسائط المشتركة الإعدادات إضافة مشترك مغادرة المجموعة وحذفها diff --git a/TMessagesProj/src/main/res/values-de/strings.xml b/TMessagesProj/src/main/res/values-de/strings.xml index 9a9b14fa..ccc7c267 100644 --- a/TMessagesProj/src/main/res/values-de/strings.xml +++ b/TMessagesProj/src/main/res/values-de/strings.xml @@ -175,7 +175,6 @@ GRUPPENNAMEN EINGEBEN Geteilte Medien Gruppeninfo - GETEILTE MEDIEN EINSTELLUNGEN Mitglied hinzufügen Gruppe löschen und verlassen diff --git a/TMessagesProj/src/main/res/values-es/strings.xml b/TMessagesProj/src/main/res/values-es/strings.xml index a3aa62b0..6c964224 100644 --- a/TMessagesProj/src/main/res/values-es/strings.xml +++ b/TMessagesProj/src/main/res/values-es/strings.xml @@ -175,7 +175,6 @@ PON EL NOMBRE DEL GRUPO Fotos y vídeos Información - FOTOS Y VÍDEOS AJUSTES Añadir miembro Eliminar y dejar el grupo diff --git a/TMessagesProj/src/main/res/values-it/strings.xml b/TMessagesProj/src/main/res/values-it/strings.xml index 73d14027..6eb70c6e 100644 --- a/TMessagesProj/src/main/res/values-it/strings.xml +++ b/TMessagesProj/src/main/res/values-it/strings.xml @@ -175,7 +175,6 @@ INSERISCI IL NOME DEL GRUPPO Media condivisi Info gruppo - MEDIA CONDIVISI IMPOSTAZIONI Aggiungi membro Elimina e lascia il gruppo diff --git a/TMessagesProj/src/main/res/values-ko/strings.xml b/TMessagesProj/src/main/res/values-ko/strings.xml index 674cf461..46c3abe9 100644 --- a/TMessagesProj/src/main/res/values-ko/strings.xml +++ b/TMessagesProj/src/main/res/values-ko/strings.xml @@ -175,7 +175,6 @@ 그룹 이름을 입력하세요 공유한 미디어 그룹 정보 - 공유한 미디어 설정 대화상대 추가 그룹에서 나가기 diff --git a/TMessagesProj/src/main/res/values-nl/strings.xml b/TMessagesProj/src/main/res/values-nl/strings.xml index b2b3b24a..e1e5cfbd 100644 --- a/TMessagesProj/src/main/res/values-nl/strings.xml +++ b/TMessagesProj/src/main/res/values-nl/strings.xml @@ -175,7 +175,6 @@ GROEPSNAAM INSTELLEN Gedeelde media Groepsinformatie - GEDEELDE MEDIA INSTELLINGEN Deelnemer toevoegen Groep verwijderen en verlaten diff --git a/TMessagesProj/src/main/res/values-pt-rBR/strings.xml b/TMessagesProj/src/main/res/values-pt-rBR/strings.xml index 13f55a2b..e720194f 100644 --- a/TMessagesProj/src/main/res/values-pt-rBR/strings.xml +++ b/TMessagesProj/src/main/res/values-pt-rBR/strings.xml @@ -175,7 +175,6 @@ DIGITE O NOME DO GRUPO Mídia compartilhada Informações do Grupo - MÍDIA COMPARTILHADA CONFIGURAÇÕES Adicionar membro Apagar e sair do grupo diff --git a/TMessagesProj/src/main/res/values-pt-rPT/strings.xml b/TMessagesProj/src/main/res/values-pt-rPT/strings.xml index 0d36cec2..dda2b67c 100644 --- a/TMessagesProj/src/main/res/values-pt-rPT/strings.xml +++ b/TMessagesProj/src/main/res/values-pt-rPT/strings.xml @@ -175,7 +175,6 @@ DIGITE O NOME DO GRUPO Mídia compartilhada Informações do Grupo - MÍDIA COMPARTILHADA CONFIGURAÇÕES Adicionar membro Apagar e sair do grupo diff --git a/TMessagesProj/src/main/res/values-v21/styles.xml b/TMessagesProj/src/main/res/values-v21/styles.xml index ea24d7b2..cf7fb548 100644 --- a/TMessagesProj/src/main/res/values-v21/styles.xml +++ b/TMessagesProj/src/main/res/values-v21/styles.xml @@ -34,6 +34,7 @@ @drawable/bar_selector_style #33000000 #54759e + @style/Theme.TMessages.Dialog.Alert + + + + + +